[U-Boot] TI:OMAP: [PATCH] API to select twl4030 voltage and dev group

From cc1b24cb290d428f2e1aefec9c7878b46380f592 Mon Sep 17 00:00:00 2001
From: Syed Mohammed Khasim khasim@ti.com Date: Sat, 9 Jan 2010 09:28:03 +0530 Subject: [PATCH] API to select twl4030 voltage and dev group
Adds a new API "twl4030_pmrecv_vsel_cfg" to select voltage and its device group
Signed-off-by: Syed Mohammed Khasim khasim@ti.com --- drivers/power/twl4030.c | 24 +++++++++++++++--------- include/twl4030.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c index eb066cb..d68e515 100644 --- a/drivers/power/twl4030.c +++ b/drivers/power/twl4030.c @@ -59,16 +59,9 @@ void twl4030_power_reset_init(void) } }
- /* * Power Init */ -#define DEV_GRP_P1 0x20 -#define VAUX3_VSEL_28 0x03 -#define DEV_GRP_ALL 0xE0 -#define VPLL2_VSEL_18 0x05 -#define VDAC_VSEL_18 0x03 - void twl4030_power_init(void) { unsigned char byte; @@ -98,8 +91,6 @@ void twl4030_power_init(void) TWL4030_PM_RECEIVER_VDAC_DEDICATED); }
-#define VMMC1_VSEL_30 0x02 - void twl4030_power_mmc_init(void) { unsigned char byte; @@ -113,3 +104,18 @@ void twl4030_power_mmc_init(void) twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VMMC1_DEDICATED); } + +/* + * Generic function to select Device Group and Voltage + */ +void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val, + u8 dev_grp, u8 dev_grp_sel) +{ + /* Select the Device Group */ + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel, + dev_grp); + + /* Select the Voltage */ + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val, + vsel_reg); +} diff --git a/include/twl4030.h b/include/twl4030.h index f260ecb..b96c96c 100644 --- a/include/twl4030.h +++ b/include/twl4030.h @@ -359,6 +359,22 @@ #define TWL4030_USB_PHY_DPLL_CLK (1 << 0)
/* + * Voltage Selection in PM Receiver Module + */ +#define VAUX2_VSEL_18 0x05 +#define VDD1_VSEL_14 0x40 +#define VAUX3_VSEL_28 0x03 +#define VPLL2_VSEL_18 0x05 +#define VDAC_VSEL_18 0x03 +#define VMMC1_VSEL_30 0x02 + +/* + * Device Selection + */ +#define DEV_GRP_P1 0x20 +#define DEV_GRP_ALL 0xE0 + +/* * Convience functions to read and write from TWL4030 * * chip_no is the i2c address, it must be one of the chip addresses

On Sat, Jan 9, 2010 at 6:42 AM, Khasim Syed Mohammed khasim@beagleboard.org wrote:
From cc1b24cb290d428f2e1aefec9c7878b46380f592 Mon Sep 17 00:00:00 2001 From: Syed Mohammed Khasim khasim@ti.com Date: Sat, 9 Jan 2010 09:28:03 +0530 Subject: [PATCH] API to select twl4030 voltage and dev group
Adds a new API "twl4030_pmrecv_vsel_cfg" to select voltage and its device group
Signed-off-by: Syed Mohammed Khasim khasim@ti.com
<snip>
@@ -113,3 +104,18 @@ void twl4030_power_mmc_init(void) twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VMMC1_DEDICATED); }
+/*
- Generic function to select Device Group and Voltage
- */
+void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
- u8 dev_grp, u8 dev_grp_sel)
+{
- /* Select the Device Group */
- twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
- dev_grp);
- /* Select the Voltage */
- twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
- vsel_reg);
+}
I was always wondering why TI code first sets the device group (which effectively enables the supply), and configures voltage after that. Doesn't that cause wrong voltage output for a short interval of time (knowing that i2c transfers take some time to complete)? What happens if second write fails due to some i2c error?

On Mon, Jan 11, 2010 at 6:30 PM, Grazvydas Ignotas notasas@gmail.com wrote:
On Sat, Jan 9, 2010 at 6:42 AM, Khasim Syed Mohammed khasim@beagleboard.org wrote:
From cc1b24cb290d428f2e1aefec9c7878b46380f592 Mon Sep 17 00:00:00 2001 From: Syed Mohammed Khasim khasim@ti.com Date: Sat, 9 Jan 2010 09:28:03 +0530 Subject: [PATCH] API to select twl4030 voltage and dev group
Adds a new API "twl4030_pmrecv_vsel_cfg" to select voltage and its device group
Signed-off-by: Syed Mohammed Khasim khasim@ti.com
<snip>
@@ -113,3 +104,18 @@ void twl4030_power_mmc_init(void) twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VMMC1_DEDICATED); }
+/*
- Generic function to select Device Group and Voltage
- */
+void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
- u8 dev_grp, u8 dev_grp_sel)
+{
- /* Select the Device Group */
- twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel,
- dev_grp);
- /* Select the Voltage */
- twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val,
- vsel_reg);
+}
I was always wondering why TI code first sets the device group (which effectively enables the supply), and configures voltage after that. Doesn't that cause wrong voltage output for a short interval of time (knowing that i2c transfers take some time to complete)? What happens if second write fails due to some i2c error?
Good / Wonderful Catch, I will correct them in my patch.
Regards, Khasim
participants (2)
-
Grazvydas Ignotas
-
Khasim Syed Mohammed