Skip to contentSkip to conversation

OMAP3-5: TWL[46]03[05]: cleanup register access and misc minimal cleanups

PATCH Superseded Nishanth Menon 3 participants 14 messages Mar 26, 2013 – Apr 15, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover OMAP3-5: TWL[46]03[05]: cleanup register access and misc minimal cleanups

This series helps standardize register parameters for TWL4030, 6030 and 6035 used in various OMAP3,4,5 based platforms.

For historical reasons, we have been following val, reg as the order of parameters while we have reg, val in every other i2c apis including i2c mw/mr command @ u-boot cmd line, with kernel APIs, i2cget, i2cset utilities.

Instead of maintaining this forked implementation, it is never too late to fix them.

Since TPS659038/TWL6035/TWL6037 all belong to the Palmas family of TI PMICs and are mostly compatible among each other, we rename twl6035 to palmas as part of this cleanup.

Build tested (MAKEALL) platforms-at least these seem to be be impacted ones:
cm_t35
devkit8000
dig297
igep0020
igep0020_nand
igep0030
igep0030_nand
nokia_rx51
omap3_beagle
omap3_evm
omap3_evm_quick_mmc
omap3_evm_quick_nand
omap3_logic
omap3_mvblx
omap3_overo
omap3_pandora
omap3_sdp3430
omap3_zoom1
omap3_zoom2
omap4_panda
omap4_sdp4430
omap5_evm
tricorder
dra7xx_evm

Boot tested platforms (upto kernel+shell with dtb):
omap3_beagle - tested on beagle XM (C1), beagle(C1D) - TWL4030 omap4_panda - tested on PandaBoard(A3) and PandaBoard-ES(EB3) - TWL6030 omap5_evm - OMAP5 uEVM - TWL6035

twl4030 changes are little wider in scope, so I have split them into two patches to help review

Series is based on u-boot master:
master 8b906a9 Merge branch 'spi' of git://git.denx.de/u-boot-x86
(rationale being the changes if done on v2013.04-rc1 have much changes to
allow this series to apply cleanly on the latest)

NOTE: the series tries to cleanup existing indentation style to allow the new code to be in sync with checkpatch suggestions.

V2: http://marc.info/?t=136398816800006&r=1&w=2
V1: http://patchwork.ozlabs.org/patch/227112/

Changes since V2 in this series:
- rename of twl6035 to palmas and associated changes
- minor updates to cleaup checkpatch warnings

Nishanth Menon (10):
twl4030: make twl4030_i2c_write_u8 prototype consistent
twl4030: make twl4030_i2c_read_u8 prototype consistent
twl6030: twl6030_i2c_[read|write]_u8 prototype consistent
twl6030: move twl6030 register access functions to common header file
twl6030: add header guard
twl6035: rename to palmas
palmas: rename init_settings to an generic palmas init
palmas: rename twl6035_mmc1_poweron_ldo with an palmas generic
function
palmas: use palmas_i2c_[read|write]_u8
palmas: add header guard

 board/cm_t35/cm_t35.c                 |   24 +++++------
 board/nokia/rx51/rx51.c               |   52 +++++++++++------------
 board/pandora/pandora.c               |    3 +-
 board/ti/dra7xx/evm.c                 |    2 +-
 board/ti/omap5_evm/evm.c              |    6 +--
 drivers/misc/twl4030_led.c            |    4 +-
 drivers/mmc/omap_hsmmc.c              |    8 ++--
 drivers/power/Makefile                |    2 +-
 drivers/power/{twl6035.c => palmas.c} |   34 +++------------
 drivers/power/twl4030.c               |   16 +++----
 drivers/power/twl6030.c               |   75 ++++++++++++++-------------------
 drivers/usb/phy/twl4030.c             |   48 ++++++++++-----------
 include/configs/omap5_evm.h           |    2 +-
 include/{twl6035.h => palmas.h}       |   28 +++++++++---
 include/twl4030.h                     |    4 +-
 include/twl6030.h                     |   16 +++++++
 16 files changed, 162 insertions(+), 162 deletions(-)
 rename drivers/power/{twl6035.c => palmas.c} (61%)
 rename include/{twl6035.h => palmas.h} (68%)

Regards,
Nishanth Menon

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/10 twl4030: make twl4030_i2c_write_u8 prototype consistent

u-boot standard i2c register write prototype is
i2c_reg_write(u8 addr, u8 reg, u8 val)

twl4030_i2c_write_u8(u8 addr, u8 val, u8 reg)
does not provide consistency, so switch the prototype to be consistent with rest of u-boot i2c operations:
twl4030_i2c_write_u8(u8 addr, u8 reg, u8 val)

---
V2: http://patchwork.ozlabs.org/patch/230267/
Changes since v2:
- checkpatch cleanup

 board/cm_t35/cm_t35.c      |   20 +++++++++----------
 board/nokia/rx51/rx51.c    |   36 +++++++++++++++++-----------------
 board/pandora/pandora.c    |    3 ++-
 drivers/misc/twl4030_led.c |    4 ++--
 drivers/power/twl4030.c    |   12 ++++++------
 drivers/usb/phy/twl4030.c  |   46 ++++++++++++++++++++++----------------------
 include/twl4030.h          |    2 +-
 7 files changed, 62 insertions(+), 61 deletions(-)
board/cm_t35/cm_t35.c +10 -10
index e0e8235..bccfacd 100644
@@ -430,17 +430,17 @@ static void setup_net_chip_gmpc(void)
 static void reset_net_chip(void)
 {
 	/* Set GPIO1 of TPS65930 as output */
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
-				TWL4030_BASEADD_GPIO + 0x03);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x03,
+			     0x02);
 	/* Send a pulse on the GPIO pin */
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
-				TWL4030_BASEADD_GPIO + 0x0C);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
+			     0x02);
 	udelay(1);
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
-				TWL4030_BASEADD_GPIO + 0x09);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x09,
+			     0x02);
 	mdelay(40);
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
-				TWL4030_BASEADD_GPIO + 0x0C);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
+			     0x02);
 	mdelay(1);
 }
 #else
@@ -537,10 +537,10 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 	twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, &val, offset);
 	/* Set GPIO6 and GPIO7 of TPS65930 as output */
 	val |= 0xC0;
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, val, offset);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, val);
 	offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_SETGPIODATAOUT1;
 	/* Take both PHYs out of reset */
-	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0xC0, offset);
+	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0);
 	udelay(1);
 
 	return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
board/nokia/rx51/rx51.c +18 -18
index 48eb65f..860d52d 100644
@@ -332,10 +332,10 @@ void *video_hw_init(void)
 static void twl4030_regulator_set_mode(u8 id, u8 mode)
 {
 	u16 msg = MSG_SINGULAR(DEV_GRP_P1, id, mode);
-	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, msg >> 8,
-			TWL4030_PM_MASTER_PB_WORD_MSB);
-	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, msg & 0xff,
-			TWL4030_PM_MASTER_PB_WORD_LSB);
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_PB_WORD_MSB, msg >> 8);
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_PB_WORD_LSB, msg & 0xff);
 }
 
 static void omap3_emu_romcode_call(u32 service_id, u32 *parameters)
@@ -410,8 +410,8 @@ int misc_init_r(void)
 			TWL4030_PM_MASTER_PB_CFG);
 
 	/* enable I2C access to powerbus (needed for twl4030 regulator) */
-	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, 0x02,
-			TWL4030_PM_MASTER_PB_CFG);
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, TWL4030_PM_MASTER_PB_CFG,
+			     0x02);
 
 	/* set VAUX3, VSIM and VMMC1 state to active - enable eMMC memory */
 	twl4030_regulator_set_mode(RES_VAUX3, RES_STATE_ACTIVE);
@@ -419,8 +419,8 @@ int misc_init_r(void)
 	twl4030_regulator_set_mode(RES_VMMC1, RES_STATE_ACTIVE);
 
 	/* restore I2C access state */
-	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, state,
-			TWL4030_PM_MASTER_PB_CFG);
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, TWL4030_PM_MASTER_PB_CFG,
+			     state);
 
 	/* set env variable attkernaddr for relocated kernel */
 	sprintf(buf, "%#x", KERNEL_ADDRESS);
@@ -481,8 +481,8 @@ void hw_watchdog_reset(void)
 	/* timeout 0 means watchdog is disabled */
 	/* reset watchdog timeout to 31s (maximum) */
 	if (timeout != 0)
-		twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, 31,
-				TWL4030_PM_RECEIVER_WATCHDOG_CFG);
+		twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER,
+				     TWL4030_PM_RECEIVER_WATCHDOG_CFG, 31);
 
 	/* store last watchdog reset time */
 	twl_wd_time = get_timer(0);
@@ -541,18 +541,18 @@ int rx51_kp_init(void)
 	ctrl |= TWL4030_KEYPAD_CTRL_KBD_ON;
 	ctrl |= TWL4030_KEYPAD_CTRL_SOFT_NRST;
 	ctrl |= TWL4030_KEYPAD_CTRL_SOFTMODEN;
-	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, ctrl,
-				TWL4030_KEYPAD_KEYP_CTRL_REG);
+	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KEYP_CTRL_REG, ctrl);
 	/* enable key event status */
-	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, 0xfe,
-				TWL4030_KEYPAD_KEYP_IMR1);
+	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KEYP_IMR1, 0xfe);
 	/* enable interrupt generation on rising and falling */
 	/* this is a workaround for qemu twl4030 emulation */
-	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, 0x57,
-				TWL4030_KEYPAD_KEYP_EDR);
+	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KEYP_EDR, 0x57);
 	/* enable ISR clear on read */
-	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD, 0x05,
-				TWL4030_KEYPAD_KEYP_SIH_CTRL);
+	ret |= twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KEYP_SIH_CTRL, 0x05);
 	return 0;
 }
 
board/pandora/pandora.c +2 -1
index 9ff5dd7..5f0c58d 100644
@@ -114,8 +114,9 @@ int misc_init_r(void)
 
 	/* Enable battery backup capacitor (3.2V, 0.5mA charge current) */
 	twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER,
+		TWL4030_PM_RECEIVER_BB_CFG,
 		TWL4030_BB_CFG_BBCHEN | TWL4030_BB_CFG_BBSEL_3200MV |
-		TWL4030_BB_CFG_BBISEL_500UA, TWL4030_PM_RECEIVER_BB_CFG);
+		TWL4030_BB_CFG_BBISEL_500UA);
 
 	dieid_num_r();
 
drivers/misc/twl4030_led.c +2 -2
index 33cea11..e150d8f 100644
@@ -42,7 +42,7 @@ void twl4030_led_init(unsigned char ledon_mask)
 	if (ledon_mask & TWL4030_LED_LEDEN_LEDBON)
 		ledon_mask |= TWL4030_LED_LEDEN_LEDBPWM;
 
-	twl4030_i2c_write_u8(TWL4030_CHIP_LED, ledon_mask,
-			     TWL4030_LED_LEDEN);
+	twl4030_i2c_write_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN,
+			     ledon_mask);
 
 }
drivers/power/twl4030.c +6 -6
index e7d5f13..2bf94b1 100644
@@ -51,8 +51,8 @@ void twl4030_power_reset_init(void)
 		printf("Could not initialize hardware reset\n");
 	} else {
 		val |= TWL4030_PM_MASTER_SW_EVENTS_STOPON_PWRON;
-		if (twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, val,
-					 TWL4030_PM_MASTER_P1_SW_EVENTS)) {
+		if (twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+					 TWL4030_PM_MASTER_P1_SW_EVENTS, val)) {
 			printf("Error:TWL4030: failed to write the power register\n");
 			printf("Could not initialize hardware reset\n");
 		}
@@ -68,8 +68,8 @@ void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
 	int ret;
 
 	/* Select the Voltage */
-	ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
-				vsel_reg);
+	ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_reg,
+				   vsel_val);
 	if (ret != 0) {
 		printf("Could not write vsel to reg %02x (%d)\n",
 			vsel_reg, ret);
@@ -77,8 +77,8 @@ void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
 	}
 
 	/* Select the Device Group (enable the supply if dev_grp_sel != 0) */
-	ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
-				dev_grp);
+	ret = twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp,
+				   dev_grp_sel);
 	if (ret != 0)
 		printf("Could not write grp_sel to reg %02x (%d)\n",
 			dev_grp, ret);
drivers/usb/phy/twl4030.c +23 -23

70 lines not on this page · raw message

include/twl4030.h +1 -1
index 5aa1841..aca695d 100644
@@ -638,7 +638,7 @@
  *   examples are TWL4030_PM_RECEIVER_VMMC1_DEV_GRP and
  *   TWL4030_LED_LEDEN.
  */
-static inline int twl4030_i2c_write_u8(u8 chip_no, u8 val, u8 reg)
+static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 {
 	return i2c_write(chip_no, reg, 1, &val, 1);
 }
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/10 twl4030: make twl4030_i2c_read_u8 prototype consistent

In reply to Nishanth Menon

u-boot standard i2c read prototype is
i2c_read(addr, reg, 1, &buf, 1)

twl4030_i2c_read_u8(u8 addr, u8 *val, u8 reg)
does not provide consistency, so switch the prototype to be consistent with rest of u-boot i2c operations:
twl4030_i2c_read_u8(u8 addr, u8 reg, u8 *val)

---
V2: http://patchwork.ozlabs.org/patch/230260/
Changes since v2:
- checkpatch cleanup

 board/cm_t35/cm_t35.c     |    4 ++--
 board/nokia/rx51/rx51.c   |   16 ++++++++--------
 drivers/power/twl4030.c   |    4 ++--
 drivers/usb/phy/twl4030.c |    2 +-
 include/twl4030.h         |    2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)
board/cm_t35/cm_t35.c +2 -2
index bccfacd..9f8108d 100644
@@ -385,7 +385,7 @@ int board_mmc_getcd(struct mmc *mmc)
 {
 	u8 val;
 
-	if (twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, &val, TWL4030_BASEADD_GPIO))
+	if (twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO, &val))
 		return -1;
 
 	return !(val & 1);
@@ -534,7 +534,7 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 	udelay(1000);
 
 	offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_GPIODATADIR1;
-	twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, &val, offset);
+	twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, offset, &val);
 	/* Set GPIO6 and GPIO7 of TPS65930 as output */
 	val |= 0xC0;
 	twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, val);
board/nokia/rx51/rx51.c +8 -8
index 860d52d..42bf8b6 100644
@@ -406,8 +406,8 @@ int misc_init_r(void)
 				TWL4030_PM_RECEIVER_DEV_GRP_P1);
 
 	/* store I2C access state */
-	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &state,
-			TWL4030_PM_MASTER_PB_CFG);
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, TWL4030_PM_MASTER_PB_CFG,
+			    &state);
 
 	/* enable I2C access to powerbus (needed for twl4030 regulator) */
 	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER, TWL4030_PM_MASTER_PB_CFG,
@@ -475,8 +475,8 @@ void hw_watchdog_reset(void)
 		return;
 
 	/* read actual watchdog timeout */
-	twl4030_i2c_read_u8(TWL4030_CHIP_PM_RECEIVER, &timeout,
-			TWL4030_PM_RECEIVER_WATCHDOG_CFG);
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_RECEIVER,
+			    TWL4030_PM_RECEIVER_WATCHDOG_CFG, &timeout);
 
 	/* timeout 0 means watchdog is disabled */
 	/* reset watchdog timeout to 31s (maximum) */
@@ -531,8 +531,8 @@ int rx51_kp_init(void)
 {
 	int ret = 0;
 	u8 ctrl;
-	ret = twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD, &ctrl,
-		TWL4030_KEYPAD_KEYP_CTRL_REG);
+	ret = twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD,
+				  TWL4030_KEYPAD_KEYP_CTRL_REG, &ctrl);
 
 	if (ret)
 		return ret;
@@ -615,8 +615,8 @@ int rx51_kp_tstc(void)
 	for (i = 0; i < 2; i++) {
 
 		/* check interrupt register for events */
-		twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD, &intr,
-				TWL4030_KEYPAD_KEYP_ISR1+(2*i));
+		twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KEYP_ISR1 + (2 * i), &intr);
 
 		/* no event */
 		if (!(intr&1))
drivers/power/twl4030.c +2 -2
index 2bf94b1..6610f78 100644
@@ -45,8 +45,8 @@
 void twl4030_power_reset_init(void)
 {
 	u8 val = 0;
-	if (twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &val,
-				TWL4030_PM_MASTER_P1_SW_EVENTS)) {
+	if (twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+				TWL4030_PM_MASTER_P1_SW_EVENTS, &val)) {
 		printf("Error:TWL4030: failed to read the power register\n");
 		printf("Could not initialize hardware reset\n");
 	} else {
drivers/usb/phy/twl4030.c +1 -1
index f41cc07..74f1dcc 100644
@@ -66,7 +66,7 @@ static int twl4030_usb_read(u8 address)
 	u8 data;
 	int ret;
 
-	ret = twl4030_i2c_read_u8(TWL4030_CHIP_USB, &data, address);
+	ret = twl4030_i2c_read_u8(TWL4030_CHIP_USB, address, &data);
 	if (ret == 0)
 		ret = data;
 	else
include/twl4030.h +1 -1
index aca695d..569ad27 100644
@@ -643,7 +643,7 @@ static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 	return i2c_write(chip_no, reg, 1, &val, 1);
 }
 
-static inline int twl4030_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
+static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 {
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/10 twl6030: twl6030_i2c_[read|write]_u8 prototype consistent

In reply to Nishanth Menon

u-boot standard i2c register access prototype is i2c_read(addr, reg, 1, &buf, 1) i2c_reg_write(u8 addr, u8 reg, u8 val)

twl6030_i2c_read_u8(u8 addr, u8 *val, u8 reg) twl6030_i2c_write_u8(u8 addr, u8 val, u8 reg)
does not provide consistency, so switch the prototype to be consistent with rest of u-boot i2c operations:
twl6030_i2c_read_u8(u8 addr, u8 reg, u8 *val) twl6030_i2c_write_u8(u8 addr, u8 reg, u8 val)

---
V2: http://patchwork.ozlabs.org/patch/230266/
Changes since v2:
- checkpatch cleanup

 drivers/power/twl6030.c |   68 +++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)
drivers/power/twl6030.c +34 -34
index c5a0038..58ad4ad 100644
@@ -26,12 +26,12 @@
 #include <twl6030.h>
 
 /* Functions to read and write from TWL6030 */
-static inline int twl6030_i2c_write_u8(u8 chip_no, u8 val, u8 reg)
+static inline int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 {
 	return i2c_write(chip_no, reg, 1, &val, 1);
 }
 
-static inline int twl6030_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
+static inline int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 {
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
@@ -42,13 +42,13 @@ static int twl6030_gpadc_read_channel(u8 channel_no)
 	u8 msb = 0;
 	int ret = 0;
 
-	ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC, &lsb,
-				GPCH0_LSB + channel_no * 2);
+	ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC,
+				  GPCH0_LSB + channel_no * 2, &lsb);
 	if (ret)
 		return ret;
 
-	ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC, &msb,
-				GPCH0_MSB + channel_no * 2);
+	ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC,
+				  GPCH0_MSB + channel_no * 2, &msb);
 	if (ret)
 		return ret;
 
@@ -60,7 +60,7 @@ static int twl6030_gpadc_sw2_trigger(void)
 	u8 val;
 	int ret = 0;
 
-	ret = twl6030_i2c_write_u8(TWL6030_CHIP_ADC, CTRL_P2_SP2, CTRL_P2);
+	ret = twl6030_i2c_write_u8(TWL6030_CHIP_ADC, CTRL_P2, CTRL_P2_SP2);
 	if (ret)
 		return ret;
 
@@ -68,7 +68,7 @@ static int twl6030_gpadc_sw2_trigger(void)
 	val =  CTRL_P2_BUSY;
 
 	while (!((val & CTRL_P2_EOCP2) && (!(val & CTRL_P2_BUSY)))) {
-		ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC, &val, CTRL_P2);
+		ret = twl6030_i2c_read_u8(TWL6030_CHIP_ADC, CTRL_P2, &val);
 		if (ret)
 			return ret;
 		udelay(1000);
@@ -79,29 +79,29 @@ static int twl6030_gpadc_sw2_trigger(void)
 
 void twl6030_stop_usb_charging(void)
 {
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, 0, CONTROLLER_CTRL1);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CONTROLLER_CTRL1, 0);
 
 	return;
 }
 
 void twl6030_start_usb_charging(void)
 {
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_VICHRG_1500,
-							CHARGERUSB_VICHRG);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_CIN_LIMIT_NONE,
-							CHARGERUSB_CINLIMIT);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, MBAT_TEMP,
-							CONTROLLER_INT_MASK);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, MASK_MCHARGERUSB_THMREG,
-							CHARGERUSB_INT_MASK);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_VOREG_4P0,
-							CHARGERUSB_VOREG);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_CTRL2_VITERM_400,
-							CHARGERUSB_CTRL2);
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, TERM, CHARGERUSB_CTRL1);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CHARGERUSB_VICHRG, CHARGERUSB_VICHRG_1500);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CHARGERUSB_CINLIMIT, CHARGERUSB_CIN_LIMIT_NONE);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CONTROLLER_INT_MASK, MBAT_TEMP);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CHARGERUSB_INT_MASK, MASK_MCHARGERUSB_THMREG);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CHARGERUSB_VOREG, CHARGERUSB_VOREG_4P0);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CHARGERUSB_CTRL2, CHARGERUSB_CTRL2_VITERM_400);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CHARGERUSB_CTRL1, TERM);
 	/* Enable USB charging */
-	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, CONTROLLER_CTRL1_EN_CHARGER,
-							CONTROLLER_CTRL1);
+	twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER,
+			     CONTROLLER_CTRL1, CONTROLLER_CTRL1_EN_CHARGER);
 	return;
 }
 
@@ -111,8 +111,8 @@ int twl6030_get_battery_current(void)
 	u8 msb = 0;
 	u8 lsb = 0;
 
-	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, &msb, FG_REG_11);
-	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, &lsb, FG_REG_10);
+	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, FG_REG_11, &msb);
+	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, FG_REG_10, &lsb);
 	battery_current = ((msb << 8) | lsb);
 
 	/* convert 10 bit signed number to 16 bit signed number */
@@ -156,10 +156,10 @@ void twl6030_init_battery_charging(void)
 	int ret = 0;
 
 	/* Enable VBAT measurement */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, VBAT_MEAS, MISC1);
+	twl6030_i2c_write_u8(TWL6030_CHIP_PM, MISC1, VBAT_MEAS);
 
 	/* Enable GPADC module */
-	ret = twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, FGS | GPADCS, TOGGLE1);
+	ret = twl6030_i2c_write_u8(TWL6030_CHIP_CHARGER, TOGGLE1, FGS | GPADCS);
 	if (ret) {
 		printf("Failed to enable GPADC\n");
 		return;
@@ -173,7 +173,7 @@ void twl6030_init_battery_charging(void)
 		printf("Main battery voltage too low!\n");
 
 	/* Check for the presence of USB charger */
-	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, &stat1, CONTROLLER_STAT1);
+	twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, CONTROLLER_STAT1, &stat1);
 
 	/* check for battery presence indirectly via Fuel gauge */
 	if ((stat1 & VBUS_DET) && (battery_volt < 3300))
@@ -185,8 +185,8 @@ void twl6030_init_battery_charging(void)
 void twl6030_power_mmc_init()
 {
 	/* set voltage to 3.0 and turnon for APP */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x15, VMMC_CFG_VOLTATE);
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x21, VMMC_CFG_STATE);
+	twl6030_i2c_write_u8(TWL6030_CHIP_PM, VMMC_CFG_VOLTATE, 0x15);
+	twl6030_i2c_write_u8(TWL6030_CHIP_PM, VMMC_CFG_STATE, 0x21);
 }
 
 void twl6030_usb_device_settings()
@@ -194,12 +194,12 @@ void twl6030_usb_device_settings()
 	u8 data = 0;
 
 	/* Select APP Group and set state to ON */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, 0x21, VUSB_CFG_STATE);
+	twl6030_i2c_write_u8(TWL6030_CHIP_PM, VUSB_CFG_STATE, 0x21);
 
-	twl6030_i2c_read_u8(TWL6030_CHIP_PM, &data, MISC2);
+	twl6030_i2c_read_u8(TWL6030_CHIP_PM, MISC2, &data);
 	data |= 0x10;
 
 	/* Select the input supply for VBUS regulator */
-	twl6030_i2c_write_u8(TWL6030_CHIP_PM, data, MISC2);
+	twl6030_i2c_write_u8(TWL6030_CHIP_PM, MISC2, data);
 }
 #endif
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 4/10 twl6030: move twl6030 register access functions to common header file

In reply to Nishanth Menon

twl6030_i2c_[read|write]_u8 can be used else where to access multi-function device such as twl6030, so move the register access functions to the common twl6030.h header file.

---
V2: http://patchwork.ozlabs.org/patch/230259/
Changes since v2:
- no change

 drivers/power/twl6030.c |   11 -----------
 include/twl6030.h       |   11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/power/twl6030.c +0 -11
index 58ad4ad..d421e60 100644
@@ -25,17 +25,6 @@
 
 #include <twl6030.h>
 
-/* Functions to read and write from TWL6030 */
-static inline int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
-{
-	return i2c_write(chip_no, reg, 1, &val, 1);
-}
-
-static inline int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
-{
-	return i2c_read(chip_no, reg, 1, val, 1);
-}
-
 static int twl6030_gpadc_read_channel(u8 channel_no)
 {
 	u8 lsb = 0;
include/twl6030.h +11 -0
index a9fcadb..f7ba3c7 100644
@@ -126,6 +126,17 @@
 #define GPCH0_LSB	0x57
 #define GPCH0_MSB	0x58
 
+/* Functions to read and write from TWL6030 */
+static inline int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
+{
+	return i2c_write(chip_no, reg, 1, &val, 1);
+}
+
+static inline int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
+{
+	return i2c_read(chip_no, reg, 1, val, 1);
+}
+
 void twl6030_init_battery_charging(void);
 void twl6030_usb_device_settings(void);
 void twl6030_start_usb_charging(void);
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 5/10 twl6030: add header guard

In reply to Nishanth Menon

Add an header guard to common header file to prevent multiple includes messing things up.

---
V2: http://patchwork.ozlabs.org/patch/230265/
Changes since v2:
- no change

 include/twl6030.h |    5 +++++
 1 file changed, 5 insertions(+)
include/twl6030.h +5 -0
index f7ba3c7..029b21f 100644
@@ -21,6 +21,9 @@
  * MA 02111-1307 USA
  */
 
+#ifndef TWL6030_H
+#define TWL6030_H
+
 #include <common.h>
 #include <i2c.h>
 
@@ -144,3 +147,5 @@ void twl6030_stop_usb_charging(void);
 int twl6030_get_battery_voltage(void);
 int twl6030_get_battery_current(void);
 void twl6030_power_mmc_init(void);
+
+#endif /* TWL6030_H */
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 6/10 twl6035: rename to palmas

In reply to Nishanth Menon

TPS659038/TWL6035/TWL6037 all belong to palmas family of TI PMICs Rename twl6035 to palmas to allow reuse across multiple current and future platforms

As part of this change, change the CONFIG_TWL6035_POWER to CONFIG_PALMAS_POWER and update usage of header file accordingly.

---
V3: new patch

 board/ti/dra7xx/evm.c                 |    2 +-
 board/ti/omap5_evm/evm.c              |    4 ++--
 drivers/mmc/omap_hsmmc.c              |    6 +++---
 drivers/power/Makefile                |    2 +-
 drivers/power/{twl6035.c => palmas.c} |    4 ++--
 include/configs/omap5_evm.h           |    2 +-
 include/{twl6035.h => palmas.h}       |    4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)
 rename drivers/power/{twl6035.c => palmas.c} (97%)
 rename include/{twl6035.h => palmas.h} (95%)
board/ti/dra7xx/evm.c +1 -1
index 7bbb549..bf7e091 100644
@@ -27,7 +27,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
-#include <twl6035.h>
+#include <palmas.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
board/ti/omap5_evm/evm.c +2 -2
index 55337c0..701842b 100644
@@ -23,7 +23,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
-#include <twl6035.h>
+#include <palmas.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mmc_host_def.h>
 
@@ -63,7 +63,7 @@ int board_eth_init(bd_t *bis)
  */
 int misc_init_r(void)
 {
-#ifdef CONFIG_TWL6035_POWER
+#ifdef CONFIG_PALMAS_POWER
 	twl6035_init_settings();
 #endif
 	return 0;
drivers/mmc/omap_hsmmc.c +3 -3
index 67cfcc2..b7a9eb0 100644
@@ -29,7 +29,7 @@
 #include <i2c.h>
 #include <twl4030.h>
 #include <twl6030.h>
-#include <twl6035.h>
+#include <palmas.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/mmc_host_def.h>
@@ -107,7 +107,7 @@ static void omap4_vmmc_pbias_config(struct mmc *mmc)
 }
 #endif
 
-#if defined(CONFIG_OMAP54XX) && defined(CONFIG_TWL6035_POWER)
+#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
 static void omap5_pbias_config(struct mmc *mmc)
 {
 	u32 value = 0;
@@ -178,7 +178,7 @@ unsigned char mmc_board_init(struct mmc *mmc)
 	if (mmc->block_dev.dev == 0)
 		omap4_vmmc_pbias_config(mmc);
 #endif
-#if defined(CONFIG_OMAP54XX) && defined(CONFIG_TWL6035_POWER)
+#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
 	if (mmc->block_dev.dev == 0)
 		omap5_pbias_config(mmc);
 #endif
drivers/power/Makefile +1 -1
index 8c71901..a2a5bd2 100644
@@ -29,7 +29,7 @@ COBJS-$(CONFIG_FTPMU010_POWER)	+= ftpmu010.o
 COBJS-$(CONFIG_TPS6586X_POWER)	+= tps6586x.o
 COBJS-$(CONFIG_TWL4030_POWER)	+= twl4030.o
 COBJS-$(CONFIG_TWL6030_POWER)	+= twl6030.o
-COBJS-$(CONFIG_TWL6035_POWER)	+= twl6035.o
+COBJS-$(CONFIG_PALMAS_POWER)	+= palmas.o
 
 COBJS-$(CONFIG_POWER) += power_core.o
 COBJS-$(CONFIG_DIALOG_POWER) += power_dialog.o
drivers/power/palmas.c renamed from drivers/power/twl6035.c +2 -2
similarity index 97%
rename from drivers/power/twl6035.c
rename to drivers/power/palmas.c
index d3de698..8ed7742 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2012
+ * (C) Copyright 2012-2013
  * Texas Instruments, <www.ti.com>
  *
  * See file CREDITS for list of people who contributed to this
@@ -21,7 +21,7 @@
  * MA 02111-1307 USA
  */
 #include <config.h>
-#include <twl6035.h>
+#include <palmas.h>
 
 /* Functions to read and write from TWL6030 */
 int twl6035_i2c_write_u8(u8 chip_no, u8 val, u8 reg)
include/configs/omap5_evm.h +1 -1
index 22a8e13..4ad943a 100644
@@ -32,7 +32,7 @@
 
 /* TWL6035 */
 #ifndef CONFIG_SPL_BUILD
-#define CONFIG_TWL6035_POWER
+#define CONFIG_PALMAS_POWER
 #endif
 
 #define CONFIG_SYS_PROMPT		"OMAP5430 EVM # "
include/palmas.h renamed from include/twl6035.h +2 -2
similarity index 95%
rename from include/twl6035.h
rename to include/palmas.h
index ce74348..cf836d7 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2012
+ * (C) Copyright 2012-2013
  * Texas Instruments, <www.ti.com>
  *
  * See file CREDITS for list of people who contributed to this
@@ -25,7 +25,7 @@
 #include <i2c.h>
 
 /* I2C chip addresses */
-#define TWL6035_CHIP_ADDR	0x48
+#define PALMAS_CHIP_ADDR	0x48
 
 /* 0x1XY translates to page 1, register address 0xXY */
 #define LDO9_CTRL		0x60
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 7/10 palmas: rename init_settings to an generic palmas init

In reply to Nishanth Menon

Since TPS659038/TWL6035/TWL6037 all belong to palmas family of TI PMICs, rename twl6035_init_settings with an more generic palmas_init_settings

---
V3: new patch

 board/ti/omap5_evm/evm.c |    2 +-
 drivers/power/palmas.c   |    2 +-
 include/palmas.h         |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
board/ti/omap5_evm/evm.c +1 -1
index 701842b..46db1bf 100644
@@ -64,7 +64,7 @@ int board_eth_init(bd_t *bis)
 int misc_init_r(void)
 {
 #ifdef CONFIG_PALMAS_POWER
-	twl6035_init_settings();
+	palmas_init_settings();
 #endif
 	return 0;
 }
drivers/power/palmas.c +1 -1
index 8ed7742..bf36a19 100644
@@ -45,7 +45,7 @@ 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)
+void palmas_init_settings(void)
 {
 	return;
 }
include/palmas.h +1 -1
index cf836d7..6618aad 100644
@@ -38,5 +38,5 @@
 
 int twl6035_i2c_write_u8(u8 chip_no, u8 val, u8 reg);
 int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg);
-void twl6035_init_settings(void);
+void palmas_init_settings(void);
 int twl6035_mmc1_poweron_ldo(void);
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v3 8/10 palmas: rename twl6035_mmc1_poweron_ldo with an palmas generic function

In reply to Nishanth Menon

Since TPS659038/TWL6035/TWL6037 all belong to palmas family of TI PMICs, rename twl6035_mmc1_poweron_ldo by a more generic palmas_mmc1_poweron_ldo function.

---
V3: new patch

 drivers/mmc/omap_hsmmc.c |    2 +-
 drivers/power/palmas.c   |    2 +-
 include/palmas.h         |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/omap_hsmmc.c +1 -1
index b7a9eb0..e07d488 100644
@@ -117,7 +117,7 @@ static void omap5_pbias_config(struct mmc *mmc)
 	value |= SDCARD_BIAS_HIZ_MODE;
 	writel(value, (*ctrl)->control_pbias);
 
-	twl6035_mmc1_poweron_ldo();
+	palmas_mmc1_poweron_ldo();
 
 	value = readl((*ctrl)->control_pbias);
 	value &= ~SDCARD_BIAS_HIZ_MODE;
drivers/power/palmas.c +1 -1
index bf36a19..489a7a9 100644
@@ -50,7 +50,7 @@ void palmas_init_settings(void)
 	return;
 }
 
-int twl6035_mmc1_poweron_ldo(void)
+int palmas_mmc1_poweron_ldo(void)
 {
 	u8 val = 0;
 
include/palmas.h +1 -1
index 6618aad..305092e 100644
@@ -39,4 +39,4 @@
 int twl6035_i2c_write_u8(u8 chip_no, u8 val, u8 reg);
 int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg);
 void palmas_init_settings(void);
-int twl6035_mmc1_poweron_ldo(void);
+int palmas_mmc1_poweron_ldo(void);
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v3 9/10 palmas: use palmas_i2c_[read|write]_u8

In reply to 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 twl6035 API, we could use an generic palmas API instead.

To stay consistent with the function naming of twl4030,6030 accessors, we use palmas_i2c_[read|write]_u8

---
V2: http://patchwork.ozlabs.org/patch/230261/
Changes since V2:
- uses palmas_i2c_[read|write]_u8

 drivers/power/palmas.c |   26 ++------------------------
 include/palmas.h       |   16 ++++++++++++++--
 2 files changed, 16 insertions(+), 26 deletions(-)
drivers/power/palmas.c +2 -24
index 489a7a9..09c832d 100644
@@ -23,28 +23,6 @@
 #include <config.h>
 #include <palmas.h>
 
-/* Functions to read and write from TWL6030 */
-int twl6035_i2c_write_u8(u8 chip_no, u8 val, u8 reg)
-{
-	return i2c_write(chip_no, reg, 1, &val, 1);
-}
-
-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 palmas_init_settings(void)
 {
 	return;
@@ -57,7 +35,7 @@ int palmas_mmc1_poweron_ldo(void)
 	/* set LDO9 TWL6035 to 3V */
 	val = 0x2b; /* (3 -.9)*28 +1 */
 
-	if (palmas_write_u8(0x48, LDO9_VOLTAGE, val)) {
+	if (palmas_i2c_write_u8(0x48, LDO9_VOLTAGE, val)) {
 		printf("twl6035: could not set LDO9 voltage.\n");
 		return 1;
 	}
@@ -65,7 +43,7 @@ int palmas_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 (palmas_i2c_write_u8(0x48, LDO9_CTRL, val)) {
 		printf("twl6035: could not turn on LDO9.\n");
 		return 1;
 	}
include/palmas.h +14 -2
index 305092e..e629fbf 100644
@@ -36,7 +36,19 @@
 #define LDO_MODE_SLEEP		(1 << 2)
 #define LDO_MODE_ACTIVE		(1 << 0)
 
-int twl6035_i2c_write_u8(u8 chip_no, u8 val, u8 reg);
-int twl6035_i2c_read_u8(u8 chip_no, u8 *val, u8 reg);
+/*
+ * Functions to read and write from TPS659038/TWL6035/TWL6037
+ * or other Palmas family of TI PMICs
+ */
+static inline int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
+{
+	return i2c_write(chip_no, reg, 1, &val, 1);
+}
+
+static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
+{
+	return i2c_read(chip_no, reg, 1, val, 1);
+}
+
 void palmas_init_settings(void);
 int palmas_mmc1_poweron_ldo(void);
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v3 10/10 palmas: add header guard

In reply to Nishanth Menon

Add an header guard to common header file to prevent multiple includes messing things up.

---
V2: http://patchwork.ozlabs.org/patch/230264/
Changes since V2:
- use PALMAS instead of TWL6035

 include/palmas.h |    4 ++++
 1 file changed, 4 insertions(+)
include/palmas.h +4 -0
index e629fbf..3b18589 100644
@@ -20,6 +20,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  */
+#ifndef PALMAS_H
+#define PALMAS_H
 
 #include <common.h>
 #include <i2c.h>
@@ -52,3 +54,5 @@ static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 
 void palmas_init_settings(void);
 int palmas_mmc1_poweron_ldo(void);
+
+#endif /* PALMAS_H */
Signature · 1 line
1.7.9.5
#11 lore raw

v3 cover OMAP3-5: TWL[46]03[05]: cleanup register access and misc minimal cleanups

In reply to Nishanth Menon

Hi Nishanth,

Quoted 96 lines · Nishanth Menon

This series helps standardize register parameters for TWL4030, 6030 and 6035 used in various OMAP3,4,5 based platforms.

For historical reasons, we have been following val, reg as the order of parameters while we have reg, val in every other i2c apis including i2c mw/mr command @ u-boot cmd line, with kernel APIs, i2cget, i2cset utilities.

Instead of maintaining this forked implementation, it is never too late to fix them.

Since TPS659038/TWL6035/TWL6037 all belong to the Palmas family of TI PMICs and are mostly compatible among each other, we rename twl6035 to palmas as part of this cleanup.

Build tested (MAKEALL) platforms-at least these seem to be be impacted ones:
cm_t35
devkit8000
dig297
igep0020
igep0020_nand
igep0030
igep0030_nand
nokia_rx51
omap3_beagle
omap3_evm
omap3_evm_quick_mmc
omap3_evm_quick_nand
omap3_logic
omap3_mvblx
omap3_overo
omap3_pandora
omap3_sdp3430
omap3_zoom1
omap3_zoom2
omap4_panda
omap4_sdp4430
omap5_evm
tricorder
dra7xx_evm

Boot tested platforms (upto kernel+shell with dtb):
omap3_beagle - tested on beagle XM (C1), beagle(C1D) - TWL4030 omap4_panda - tested on PandaBoard(A3) and PandaBoard-ES(EB3) - TWL6030 omap5_evm - OMAP5 uEVM - TWL6035

twl4030 changes are little wider in scope, so I have split them into two patches to help review

Series is based on u-boot master:
master 8b906a9 Merge branch 'spi' of git://git.denx.de/u-boot-x86
(rationale being the changes if done on v2013.04-rc1 have much changes to
allow this series to apply cleanly on the latest)

NOTE: the series tries to cleanup existing indentation style to allow the new code to be in sync with checkpatch suggestions.

V2: http://marc.info/?t=136398816800006&r=1&w=2
V1: http://patchwork.ozlabs.org/patch/227112/

Changes since V2 in this series:
- rename of twl6035 to palmas and associated changes
- minor updates to cleaup checkpatch warnings

Nishanth Menon (10):
twl4030: make twl4030_i2c_write_u8 prototype consistent
twl4030: make twl4030_i2c_read_u8 prototype consistent
twl6030: twl6030_i2c_[read|write]_u8 prototype consistent
twl6030: move twl6030 register access functions to common header file
twl6030: add header guard
twl6035: rename to palmas
palmas: rename init_settings to an generic palmas init
palmas: rename twl6035_mmc1_poweron_ldo with an palmas generic
function
palmas: use palmas_i2c_[read|write]_u8
palmas: add header guard

 board/cm_t35/cm_t35.c                 |   24 +++++------
 board/nokia/rx51/rx51.c               |   52 +++++++++++------------
 board/pandora/pandora.c               |    3 +-
 board/ti/dra7xx/evm.c                 |    2 +-
 board/ti/omap5_evm/evm.c              |    6 +--
 drivers/misc/twl4030_led.c            |    4 +-
 drivers/mmc/omap_hsmmc.c              |    8 ++--
 drivers/power/Makefile                |    2 +-
 drivers/power/{twl6035.c => palmas.c} |   34 +++------------
 drivers/power/twl4030.c               |   16 +++----
 drivers/power/twl6030.c               |   75 ++++++++++++++-------------------
 drivers/usb/phy/twl4030.c             |   48 ++++++++++-----------
 include/configs/omap5_evm.h           |    2 +-
 include/{twl6035.h => palmas.h}       |   28 +++++++++---
 include/twl4030.h                     |    4 +-
 include/twl6030.h                     |   16 +++++++
 16 files changed, 162 insertions(+), 162 deletions(-)
 rename drivers/power/{twl6035.c => palmas.c} (61%)
 rename include/{twl6035.h => palmas.h} (68%)
Quoted 2 lines

Regards,
Nishanth Menon

Regards,
Sricharan

#12 lore raw

v3 cover OMAP3-5: TWL[46]03[05]: cleanup register access and misc minimal cleanups

Quoted 3 lines · Sricharan R
Quoted 2 lines · Nishanth Menon

This series helps standardize register parameters for TWL4030, 6030 and 6035 used in various OMAP3,4,5 based platforms.

[..]

Quoted 2 lines

Gentle ping on this series. It probably might be a good idea to merge it prior to any further usage of said functions.

Signature · 2 lines
Regards,
Nishanth Menon
#13 lore raw

v3 cover OMAP3-5: TWL[46]03[05]: cleanup register access and misc minimal cleanups

In reply to Nishanth Menon
Quoted 87 lines · Nishanth Menon

This series helps standardize register parameters for TWL4030, 6030 and 6035 used in various OMAP3,4,5 based platforms.

For historical reasons, we have been following val, reg as the order of parameters while we have reg, val in every other i2c apis including i2c mw/mr command @ u-boot cmd line, with kernel APIs, i2cget, i2cset utilities.

Instead of maintaining this forked implementation, it is never too late to fix them.

Since TPS659038/TWL6035/TWL6037 all belong to the Palmas family of TI PMICs and are mostly compatible among each other, we rename twl6035 to palmas as part of this cleanup.

Build tested (MAKEALL) platforms-at least these seem to be be impacted ones:
cm_t35
devkit8000
dig297
igep0020
igep0020_nand
igep0030
igep0030_nand
nokia_rx51
omap3_beagle
omap3_evm
omap3_evm_quick_mmc
omap3_evm_quick_nand
omap3_logic
omap3_mvblx
omap3_overo
omap3_pandora
omap3_sdp3430
omap3_zoom1
omap3_zoom2
omap4_panda
omap4_sdp4430
omap5_evm
tricorder
dra7xx_evm

Boot tested platforms (upto kernel+shell with dtb):
omap3_beagle - tested on beagle XM (C1), beagle(C1D) - TWL4030 omap4_panda - tested on PandaBoard(A3) and PandaBoard-ES(EB3) - TWL6030 omap5_evm - OMAP5 uEVM - TWL6035

twl4030 changes are little wider in scope, so I have split them into two patches to help review

Series is based on u-boot master:
master 8b906a9 Merge branch 'spi' of git://git.denx.de/u-boot-x86
(rationale being the changes if done on v2013.04-rc1 have much changes to
allow this series to apply cleanly on the latest)

NOTE: the series tries to cleanup existing indentation style to allow the new code to be in sync with checkpatch suggestions.

V2: http://marc.info/?t=136398816800006&r=1&w=2
V1: http://patchwork.ozlabs.org/patch/227112/

Changes since V2 in this series:
- rename of twl6035 to palmas and associated changes
- minor updates to cleaup checkpatch warnings

Nishanth Menon (10):
twl4030: make twl4030_i2c_write_u8 prototype consistent
twl4030: make twl4030_i2c_read_u8 prototype consistent
twl6030: twl6030_i2c_[read|write]_u8 prototype consistent
twl6030: move twl6030 register access functions to common header file
twl6030: add header guard
twl6035: rename to palmas
palmas: rename init_settings to an generic palmas init
palmas: rename twl6035_mmc1_poweron_ldo with an palmas generic
function
palmas: use palmas_i2c_[read|write]_u8
palmas: add header guard

 board/cm_t35/cm_t35.c                 |   24 +++++------
 board/nokia/rx51/rx51.c               |   52 +++++++++++------------
 board/pandora/pandora.c               |    3 +-
 board/ti/dra7xx/evm.c                 |    2 +-
 board/ti/omap5_evm/evm.c              |    6 +--
 drivers/misc/twl4030_led.c            |    4 +-
 drivers/mmc/omap_hsmmc.c              |    8 ++--
 drivers/power/Makefile                |    2 +-
 drivers/power/{twl6035.c => palmas.c} |   34 +++------------
 drivers/power/twl4030.c               |   16 +++----
 drivers/power/twl6030.c               |   75 ++++++++++++++-------------------
Quoted 8 lines
 drivers/usb/phy/twl4030.c             |   48 ++++++++++-----------
 include/configs/omap5_evm.h           |    2 +-
 include/{twl6035.h => palmas.h}       |   28 +++++++++---
 include/twl4030.h                     |    4 +-
 include/twl6030.h                     |   16 +++++++
 16 files changed, 162 insertions(+), 162 deletions(-)
 rename drivers/power/{twl6035.c => palmas.c} (61%)
 rename include/{twl6035.h => palmas.h} (68%)

Applied to u-boot-ti/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130415/0c8c9ef6/attachment.pgp>