Subject: [PATCH 3/7 v2] ARM OMAP3: API to set twl4030 voltage and dev group From: Khasim Syed Mohammed API to set twl4030 voltage and dev group Signed-off-by: Syed Mohammed Khasim Signed-off-by: Dirk Behme --- Changes in v2: - Remain consistent with existing naming. Use the TWL4030_PM_RECEIVER prefix V3: Incorporated review comments to set voltage first and then dev group V2: Incorporated review comments to split the patch and add generic API to set the voltage and device group. http://www.mail-archive.com/u-boot@lists.denx.de/msg27136.html V1: Added support for 720 Mhz http://www.mail-archive.com/u-boot@lists.denx.de/msg27035.html drivers/power/twl4030.c | 32 +++++++++++++++++++------------- include/twl4030.h | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) Index: u-boot-main/drivers/power/twl4030.c =================================================================== --- u-boot-main.orig/drivers/power/twl4030.c +++ u-boot-main/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; @@ -77,7 +70,7 @@ void twl4030_power_init(void) byte = DEV_GRP_P1; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VAUX3_DEV_GRP); - byte = VAUX3_VSEL_28; + byte = TWL4030_PM_RECEIVER_VAUX3_VSEL_28; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VAUX3_DEDICATED); @@ -85,7 +78,7 @@ void twl4030_power_init(void) byte = DEV_GRP_ALL; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VPLL2_DEV_GRP); - byte = VPLL2_VSEL_18; + byte = TWL4030_PM_RECEIVER_VPLL2_VSEL_18; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VPLL2_DEDICATED); @@ -93,13 +86,11 @@ void twl4030_power_init(void) byte = DEV_GRP_P1; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VDAC_DEV_GRP); - byte = VDAC_VSEL_18; + byte = TWL4030_PM_RECEIVER_VDAC_VSEL_18; twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte, TWL4030_PM_RECEIVER_VDAC_DEDICATED); } -#define VMMC1_VSEL_30 0x02 - void twl4030_power_mmc_init(void) { unsigned char byte; @@ -109,7 +100,22 @@ void twl4030_power_mmc_init(void) TWL4030_PM_RECEIVER_VMMC1_DEV_GRP); /* 3 Volts */ - byte = VMMC1_VSEL_30; + byte = TWL4030_PM_RECEIVER_VMMC1_VSEL_30; 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 Voltage */ + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, vsel_val, + vsel_reg); + + /* Select the Device Group */ + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, dev_grp_sel, + dev_grp); +} Index: u-boot-main/include/twl4030.h =================================================================== --- u-boot-main.orig/include/twl4030.h +++ u-boot-main/include/twl4030.h @@ -471,6 +471,22 @@ #define TWL4030_USB_PHY_CLK_CTRL_STS 0xFF /* + * Voltage Selection in PM Receiver Module + */ +#define TWL4030_PM_RECEIVER_VAUX2_VSEL_18 0x05 +#define TWL4030_PM_RECEIVER_VDD1_VSEL_14 0x40 +#define TWL4030_PM_RECEIVER_VAUX3_VSEL_28 0x03 +#define TWL4030_PM_RECEIVER_VPLL2_VSEL_18 0x05 +#define TWL4030_PM_RECEIVER_VDAC_VSEL_18 0x03 +#define TWL4030_PM_RECEIVER_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