Skip to contentSkip to conversation

misc:pmic: Support for voltage to register value conversion function

PATCH New Lukasz Majewski 3 participants 11 messages Mar 28, 2012 – Mar 29, 2012 1 message not in the archive Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Support for voltage (in uV) to proper register value is added. The function tied to this callback is often PMIC dependent and shall be defined for each device.

---
 drivers/misc/pmic_core.c |   10 ++++++++++
 include/pmic.h           |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)
drivers/misc/pmic_core.c +10 -0
index 5d62a56..4366bf0 100644
@@ -89,6 +89,16 @@ struct pmic *get_pmic(void)
 	return &pmic;
 }
 
+int pmic_vol_to_reg(struct pmic *p, int uV)
+{
+	if (p->voltage_to_reg_conv == NULL) {
+		puts("PMIC: Voltage to register value function not defined\n");
+		return 0;
+	}
+
+	return p->voltage_to_reg_conv(uV);
+}
+
 int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	u32 ret, reg, val;
include/pmic.h +2 -0
index 52a1526..f8594a9 100644
@@ -52,12 +52,14 @@ struct pmic {
 		struct p_i2c i2c;
 		struct p_spi spi;
 	} hw;
+	int (*voltage_to_reg_conv) (int uV);
 };
 
 int pmic_init(void);
 int check_reg(u32 reg);
 struct pmic *get_pmic(void);
 int pmic_probe(struct pmic *p);
+int pmic_vol_to_reg(struct pmic *p, int uV);
 int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
 int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
 int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 2/3 misc:pmic:max8997 MAX8997 support for PMIC driver

This commit adds support for MAX8997 PMIC driver.

---
 drivers/misc/Makefile       |    1 +
 drivers/misc/pmic_max8997.c |   60 ++++++++++++++
 include/max8997_pmic.h      |  190 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 251 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/pmic_max8997.c
 create mode 100644 include/max8997_pmic.h
drivers/misc/Makefile +1 -0
index a709707..30c7f8d 100644
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_PMIC_FSL) += pmic_fsl.o
 COBJS-$(CONFIG_PMIC_I2C) += pmic_i2c.o
 COBJS-$(CONFIG_PMIC_SPI) += pmic_spi.o
 COBJS-$(CONFIG_PMIC_MAX8998) += pmic_max8998.o
+COBJS-$(CONFIG_PMIC_MAX8997) += pmic_max8997.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/misc/pmic_max8997.c new file +60 -0

60 lines not on this page · raw message

include/max8997_pmic.h new file +190 -0

190 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 3/3 misc:pmic:samsung Convert TRATS target to use MAX8997 instead of MAX8998

In reply to Lukasz Majewski

TRATS target uses MAX8997 PMIC device instead of MAX8998.

---
 board/samsung/trats/trats.c |   27 ++++++++++-----------------
 include/configs/trats.h     |    2 +-
 2 files changed, 11 insertions(+), 18 deletions(-)
board/samsung/trats/trats.c +10 -17
index aa4291d..a7b4e4a 100644
@@ -32,7 +32,7 @@
 #include <asm/arch/power.h>
 #include <pmic.h>
 #include <usb/s3c_udc.h>
-#include <max8998_pmic.h>
+#include <max8997_pmic.h>
 
 #include "setup.h"
 
@@ -216,26 +216,19 @@ static int s5pc210_phy_control(int on)
 		return -1;
 
 	if (on) {
-		ret |= pmic_set_output(p,
-				       MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
-				       MAX8998_SAFEOUT1, LDO_ON);
-		ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
-				      MAX8998_LDO3, LDO_ON);
-		ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
-				      MAX8998_LDO8, LDO_ON);
-
+		ret |= pmic_set_output(p, MAX8997_REG_SAFEOUTCTRL,
+				      ENSAFEOUT1, LDO_ON);
+		ret |= pmic_reg_write(p, MAX8997_REG_LDO3CTRL, EN_LDO);
+		ret |= pmic_reg_write(p, MAX8997_REG_LDO8CTRL, EN_LDO);
 	} else {
-		ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
-				      MAX8998_LDO8, LDO_OFF);
-		ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
-				      MAX8998_LDO3, LDO_OFF);
-		ret |= pmic_set_output(p,
-				       MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
-				       MAX8998_SAFEOUT1, LDO_OFF);
+		ret |= pmic_reg_write(p, MAX8997_REG_LDO8CTRL, DIS_LDO);
+		ret |= pmic_reg_write(p, MAX8997_REG_LDO3CTRL, DIS_LDO);
+		ret |= pmic_set_output(p, MAX8997_REG_SAFEOUTCTRL,
+				      ENSAFEOUT1, LDO_OFF);
 	}
 
 	if (ret) {
-		puts("MAX8998 LDO setting error!\n");
+		puts("MAX8997 LDO setting error!\n");
 		return -1;
 	}
 
include/configs/trats.h +1 -1
index 10f11d9..585fd71 100644
@@ -208,7 +208,7 @@
 
 #define CONFIG_PMIC
 #define CONFIG_PMIC_I2C
-#define CONFIG_PMIC_MAX8998
+#define CONFIG_PMIC_MAX8997
 
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
Signature · 1 line
1.7.2.3
#3 lore raw

PATCH 3/3 misc:pmic:samsung Convert TRATS target to use MAX8997 instead of MAX8998

Quoted 11 lines · Lukasz Majewski

TRATS target uses MAX8997 PMIC device instead of MAX8998.

---
?board/samsung/trats/trats.c | ? 27 ++++++++++----------------- ?include/configs/trats.h ? ? | ? ?2 +-
?2 files changed, 11 insertions(+), 18 deletions(-)

Signature · 2 lines
from. prom.
www.promsoft.net
#4 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

In reply to Lukasz Majewski
Quoted 8 lines · Lukasz Majewski

Support for voltage (in uV) to proper register value is added. The function tied to this callback is often PMIC dependent and shall be defined for each device.

---

Hi Lukasz,

Quoted 2 lines

+int pmic_vol_to_reg(struct pmic *p, int uV)

You added a new entry point to pmic, but you do not use it...I have not found in your patchset why it is necessary for you.

I am not sure if we require to add this to the PMIC API or hide in the pmic specific code. Other PMICs has not a a register for different voltages, but only a bit inside the same register (this is the case for the Freescale's PMICs we currently support in u-boot).

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Hi Stefano,

Quoted 10 lines · On Wed, 28 Mar 2012 12:26:46 +0200 Stefano Babic <[email protected]> wrote:
Quoted 8 lines · Lukasz Majewski

Support for voltage (in uV) to proper register value is added. The function tied to this callback is often PMIC dependent and shall be defined for each device.

---

Quoted 8 lines

Hi Lukasz,

Quoted 2 lines

+int pmic_vol_to_reg(struct pmic *p, int uV)

You added a new entry point to pmic, but you do not use it...I have not found in your patchset why it is necessary for you.

Rationale for this change is in commits following this one. For trats Samsung target it is necessary to change the default voltage.

I think, that providing access to such a function as a pointer is the best possible solution.

For example the MAX8997 and MAX8998 PMICs have different way of calculating the value, which represents the LDO output value.

Quoted 4 lines

I am not sure if we require to add this to the PMIC API or hide in the pmic specific code. Other PMICs has not a a register for different voltages, but only a bit inside the same register (this is the case for the Freescale's PMICs we currently support in u-boot).

I think, that it is easier to define function pointer in the pmic structure, than separate functions and handling them in target platform data.

Quoted 3 lines

Best regards,
Stefano Babic

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group
#6 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

On 28/03/2012 13:26, Lukasz Majewski wrote:

Hi Lukasz,

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

+int pmic_vol_to_reg(struct pmic *p, int uV)

You added a new entry point to pmic, but you do not use it...I have not found in your patchset why it is necessary for you.

Rationale for this change is in commits following this one. For trats Samsung target it is necessary to change the default voltage.

Yes, I was expecting that you call pmic_vol_to_reg() in your following patches, but I cannot find it. Am I missing something ?

Quoted 8 lines

I think, that providing access to such a function as a pointer is the best possible solution.

For example the MAX8997 and MAX8998 PMICs have different way of calculating the value, which represents the LDO output value.

Quoted 8 lines
Quoted 4 lines

I am not sure if we require to add this to the PMIC API or hide in the pmic specific code. Other PMICs has not a a register for different voltages, but only a bit inside the same register (this is the case for the Freescale's PMICs we currently support in u-boot).

I think, that it is easier to define function pointer in the pmic structure, than separate functions and handling them in target platform data.

Ok, understood.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Quoted 2 lines · Lukasz Majewski

Hi Stefano,

Hi Lucasz,

Quoted 3 lines

I've already forwarded those patches to you.
They are also available on the mailing list, so I don't know what has happened.

Really nothing, I got all e-mails, I was only not able to explain my doubt. I try again:

- In patch 1/3 you add voltage_to_reg to the pmic struct

	==> Ok
- in patch 2/3 you add voltage_to_reg to MAX8997.
	==> Ok

Everything clear.

The consequence for me is that PATCH 3/3 shows the reason to add voltage_to_reg(), and calls the new function pmic_vol_to_reg(), because you need it, as you have already explained. But I see only pmic_set_output() and pmic_reg_write() in your patch.

What have I not yet understood ? (maybe I need a coffe to wake up my brain...)

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#9 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Quoted 21 lines · On Wed, 28 Mar 2012 14:50:35 +0200 Stefano Babic <[email protected]> wrote:
Quoted 2 lines · Lukasz Majewski

Hi Stefano,

Hi Lucasz,

Quoted 3 lines

I've already forwarded those patches to you.
They are also available on the mailing list, so I don't know what has happened.

Really nothing, I got all e-mails, I was only not able to explain my doubt. I try again:

- In patch 1/3 you add voltage_to_reg to the pmic struct

	==> Ok
- in patch 2/3 you add voltage_to_reg to MAX8997.
	==> Ok

Everything clear.

Quoted 8 lines

The consequence for me is that PATCH 3/3 shows the reason to add voltage_to_reg(), and calls the new function pmic_vol_to_reg(), because you need it, as you have already explained. But I see only pmic_set_output() and pmic_reg_write() in your patch.

Stefano

Hi Stefano,

I've looked on patches which I've posted and for patches from 1 do 3 there isn't usage for this function.

However I'm using this functionality in a code on which I'm working on (Trats), so posting it to the list is only a matter of time.

Quoted 2 lines

What have I not yet understood ? (maybe I need a coffe to wake up my brain...)

You understood everything :-), it was my fault.
I thought, that patches 2/3 and 3/3 were missing (or by some mishap I didn't send them properly).

Now, I think, that everything is clear.

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group
#10 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Quoted 2 lines · Lukasz Majewski

Hi Stefano,

Hi Lucasz,

Quoted 5 lines

I've looked on patches which I've posted and for patches from 1 do 3 there isn't usage for this function.

However I'm using this functionality in a code on which I'm working on (Trats), so posting it to the list is only a matter of time.

ok, understood. Then I will suggest you resubmit patches 1 and 2 with your work on Trats, because the patches belong together and they should be in the same patchset.

And Patch 3 can be already applied as it is, because it has no dependecies with the other ones.

Quoted 1 line

Now, I think, that everything is clear.

Yes, everythg clear ;-)

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#11 lore raw

PATCH 1/3 misc:pmic: Support for voltage to register value conversion function

Hi Stefano,

Quoted 3 lines · On Wed, 28 Mar 2012 16:43:51 +0200 Stefano Babic <[email protected]> wrote:

ok, understood. Then I will suggest you resubmit patches 1 and 2 with your work on Trats, because the patches belong together and they should be in the same patchset.

Hmm, I'm not the only one who is working on this board. Moreover some other targets are using this PMIC as well :-).

Quoted 2 lines

And Patch 3 can be already applied as it is, because it has no dependecies with the other ones.

The patch 3/3 depends on patch 2, which defines data for MAX8997 PMIC. And patch 2 depends on patch 1, since patch 1 provides:

+ int (*voltage_to_reg_conv) (int uV);

which function is defined in patch 2 :-).

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group