Skip to contentSkip to conversation

power: twl6035: cleanup register access API

PATCH New Nishanth Menon 3 participants 4 messages Mar 12, 2013 – Mar 13, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: twl6035: cleanup register access API

commit 21144298 (power: twl6035: add palmas PMIC support) introduced twl6035_i2c_[read|write]_u8
Then, commit dd23e59d (omap5: pbias ldo9 turn on) introduced palmas_[read|write]_u8
for precisely the same access function. TWL6035 belongs to the palmas family, so instead of having an palmas API, we could use twl6035 API instead (which is used elsewhere as well).

Account for the parameter change while doing the change and remove palmas register accessors.

---
 drivers/power/twl6035.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/power/twl6035.c +2 -13
index d3de698..b0b2406 100644
@@ -34,17 +34,6 @@ int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
 
-/* To align with i2c mw/mr address, reg, val command syntax */
-static inline int palmas_write_u8(u8 chip_no, u8 reg, u8 val)
-{
-	return i2c_write(chip_no, reg, 1, &val, 1);
-}
-
-static inline int palmas_read_u8(u8 chip_no, u8 reg, u8 *val)
-{
-	return i2c_read(chip_no, reg, 1, val, 1);
-}
-
 void twl6035_init_settings(void)
 {
 	return;
@@ -57,7 +46,7 @@ int twl6035_mmc1_poweron_ldo(void)
 	/* set LDO9 TWL6035 to 3V */
 	val = 0x2b; /* (3 -.9)*28 +1 */
 
-	if (palmas_write_u8(0x48, LDO9_VOLTAGE, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_VOLTAGE)) {
 		printf("twl6035: could not set LDO9 voltage.\n");
 		return 1;
 	}
@@ -65,7 +54,7 @@ int twl6035_mmc1_poweron_ldo(void)
 	/* TURN ON LDO9 */
 	val = LDO_ON | LDO_MODE_SLEEP | LDO_MODE_ACTIVE;
 
-	if (palmas_write_u8(0x48, LDO9_CTRL, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_CTRL)) {
 		printf("twl6035: could not turn on LDO9.\n");
 		return 1;
 	}
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 power: twl6035: cleanup register access API

Quoted 52 lines · Nishanth Menon

commit 21144298 (power: twl6035: add palmas PMIC support) introduced twl6035_i2c_[read|write]_u8
Then, commit dd23e59d (omap5: pbias ldo9 turn on) introduced palmas_[read|write]_u8
for precisely the same access function. TWL6035 belongs to the palmas family, so instead of having an palmas API, we could use twl6035 API instead (which is used elsewhere as well).

Account for the parameter change while doing the change and remove palmas register accessors.

---
 drivers/power/twl6035.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/power/twl6035.c +1 -12
index d3de698..b0b2406 100644
@@ -34,17 +34,6 @@ int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
 
-/* To align with i2c mw/mr address, reg, val command syntax */
-static inline int palmas_write_u8(u8 chip_no, u8 reg, u8 val)
-{
-	return i2c_write(chip_no, reg, 1, &val, 1);
-}
-
-static inline int palmas_read_u8(u8 chip_no, u8 reg, u8 *val)
-{
-	return i2c_read(chip_no, reg, 1, val, 1);
-}
-
 void twl6035_init_settings(void)
 {
 	return;
@@ -57,7 +46,7 @@ int twl6035_mmc1_poweron_ldo(void)
 	/* set LDO9 TWL6035 to 3V */
 	val = 0x2b; /* (3 -.9)*28 +1 */
 
-	if (palmas_write_u8(0x48, LDO9_VOLTAGE, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_VOLTAGE)) {
 		printf("twl6035: could not set LDO9 voltage.\n");
 		return 1;
 	}

drivers/power/twl6035.c int twl6035_mmc1_poweron_ldo(void) · line 60

Quoted 8 lines
drivers/power/twl6035.c +1 -1
@@ -65,7 +54,7 @@ int twl6035_mmc1_poweron_ldo(void)
 	/* TURN ON LDO9 */
 	val = LDO_ON | LDO_MODE_SLEEP | LDO_MODE_ACTIVE;
 
-	if (palmas_write_u8(0x48, LDO9_CTRL, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_CTRL)) {
 		printf("twl6035: could not turn on LDO9.\n");
 		return 1;
 	}

Regards,
Sricharan

#2 lore raw

PATCH 1/1 power: twl6035: cleanup register access API

In reply to Nishanth Menon

Hi,

Quoted 8 lines · Nishanth Menon

commit 21144298 (power: twl6035: add palmas PMIC support) introduced twl6035_i2c_[read|write]_u8
Then, commit dd23e59d (omap5: pbias ldo9 turn on) introduced palmas_[read|write]_u8
for precisely the same access function. TWL6035 belongs to the palmas family, so instead of having an palmas API, we could use twl6035 API instead (which is used elsewhere as well).

can you provide reference where twl6035 API is used ?

Quoted 3 lines

Account for the parameter change while doing the change and remove palmas register accessors.

That is the reason ("parameter change") for introducing palmas_write/read_u8 :-)

I think twl6035_i2c_read/write_u8 should have parameter reg address and value interchanged or should get completely removed. twl6035_i2c_read/write_u8 is based on legacy implementation of twl6030/twl4030.

Quoted 14 lines
---
  drivers/power/twl6035.c |   15 ++-------------
  1 file changed, 2 insertions(+), 13 deletions(-)
drivers/power/twl6035.c +0 -0
index d3de698..b0b2406 100644

drivers/power/twl6035.c int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg) · line 38

Quoted 5 lines
drivers/power/twl6035.c +0 -2
@@ -34,17 +34,6 @@ int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
  	return i2c_read(chip_no, reg, 1, val, 1);
  }
 
-/* To align with i2c mw/mr address, reg, val command syntax */
-static inline int palmas_write_u8(u8 chip_no, u8 reg, u8 val)

Please note the reg address, val order with i2c_write API. It aligns with i2c mw/mr command @ u-boot cmd line, with kernel APIs, i2cget, i2cset utilities.

It don't see a reason why twl6035_i2c_read/write_u8 should have parameters interchanged.

Thanks and Regards
Balaji T K

Quoted 31 lines
drivers/power/twl6035.c +2 -11
-{
-	return i2c_write(chip_no, reg, 1, &val, 1);
-}
-
-static inline int palmas_read_u8(u8 chip_no, u8 reg, u8 *val)
-{
-	return i2c_read(chip_no, reg, 1, val, 1);
-}
-
  void twl6035_init_settings(void)
  {
  	return;
@@ -57,7 +46,7 @@ int twl6035_mmc1_poweron_ldo(void)
  	/* set LDO9 TWL6035 to 3V */
  	val = 0x2b; /* (3 -.9)*28 +1 */
 
-	if (palmas_write_u8(0x48, LDO9_VOLTAGE, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_VOLTAGE)) {
  		printf("twl6035: could not set LDO9 voltage.\n");
  		return 1;
  	}
@@ -65,7 +54,7 @@ int twl6035_mmc1_poweron_ldo(void)
  	/* TURN ON LDO9 */
  	val = LDO_ON | LDO_MODE_SLEEP | LDO_MODE_ACTIVE;
 
-	if (palmas_write_u8(0x48, LDO9_CTRL, val)) {
+	if (twl6035_i2c_write_u8(0x48, val, LDO9_CTRL)) {
  		printf("twl6035: could not turn on LDO9.\n");
  		return 1;
  	}
#3 lore raw

PATCH 1/1 power: twl6035: cleanup register access API

Quoted 12 lines · Balaji T K

Hi,

Quoted 8 lines · Nishanth Menon

commit 21144298 (power: twl6035: add palmas PMIC support) introduced twl6035_i2c_[read|write]_u8
Then, commit dd23e59d (omap5: pbias ldo9 turn on) introduced palmas_[read|write]_u8
for precisely the same access function. TWL6035 belongs to the palmas family, so instead of having an palmas API, we could use twl6035 API instead (which is used elsewhere as well).

Quoted 1 line

can you provide reference where twl6035 API is used ?

This is based on commit 21144298 - the exposed API for the rest is what the intent was supposed to be.

Quoted 38 lines
Quoted 4 lines

Account for the parameter change while doing the change and remove palmas register accessors.

That is the reason ("parameter change") for introducing palmas_write/read_u8 :-)

I think twl6035_i2c_read/write_u8 should have parameter reg address and value interchanged or should get completely removed. twl6035_i2c_read/write_u8 is based on legacy implementation of twl6030/twl4030.

Quoted 14 lines
---
 drivers/power/twl6035.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/power/twl6035.c +0 -0
index d3de698..b0b2406 100644

drivers/power/twl6035.c int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg) · line 38

Quoted 5 lines
drivers/power/twl6035.c +0 -2
@@ -34,17 +34,6 @@ int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
 
-/* To align with i2c mw/mr address, reg, val command syntax */
-static inline int palmas_write_u8(u8 chip_no, u8 reg, u8 val)

Please note the reg address, val order with i2c_write API. It aligns with i2c mw/mr command @ u-boot cmd line, with kernel APIs, i2cget, i2cset utilities.

Quoted 2 lines

It don't see a reason why twl6035_i2c_read/write_u8 should have parameters interchanged.

Then we should rather *fix* function usage *NOT* introduce an new function for the same job!

But wait an min, twl4030_i2c_[read|write]_u8 follows the same proto as twl6035_i2c_read/write_u8!
You are welcome to fix both while at it. But please *DONOT* introduce duplicate functions on style need!

Signature · 2 lines
Regards,
Nishanth Menon