]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARMV7: OMAP: add convenience function to set TWL4030 regulator voltages
authorSteve Sakoman <steve@sakoman.com>
Tue, 10 Aug 2010 19:58:39 +0000 (12:58 -0700)
committerSandeep Paulraj <s-paulraj@ti.com>
Wed, 8 Sep 2010 18:50:23 +0000 (14:50 -0400)
This patch adds a function to allow one to easily set the target
voltage for the TWL4030 regulators.  It also modifies the existing
code to use this new function.  Applicable definitions are moved
out of the driver file and into the header file so that they are
generally accessible

Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
drivers/power/twl4030.c
include/twl4030.h

index eb066cb58dff11c78b4498e3d3264a23c7b748a6..1a5408959e11cc8ec3791f2da9db80f4547bdf5a 100644 (file)
@@ -59,57 +59,48 @@ void twl4030_power_reset_init(void)
        }
 }
 
-
 /*
- * Power Init
+ * Set Device Group and Voltage
  */
-#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_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);
+}
 
 void twl4030_power_init(void)
 {
-       unsigned char byte;
-
        /* set VAUX3 to 2.8V */
-       byte = DEV_GRP_P1;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VAUX3_DEV_GRP);
-       byte = VAUX3_VSEL_28;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VAUX3_DEDICATED);
+       twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX3_DEDICATED,
+                               TWL4030_PM_RECEIVER_VAUX3_VSEL_28,
+                               TWL4030_PM_RECEIVER_VAUX3_DEV_GRP,
+                               TWL4030_PM_RECEIVER_DEV_GRP_P1);
 
        /* set VPLL2 to 1.8V */
-       byte = DEV_GRP_ALL;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VPLL2_DEV_GRP);
-       byte = VPLL2_VSEL_18;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VPLL2_DEDICATED);
+       twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VPLL2_DEDICATED,
+                               TWL4030_PM_RECEIVER_VPLL2_VSEL_18,
+                               TWL4030_PM_RECEIVER_VPLL2_DEV_GRP,
+                               TWL4030_PM_RECEIVER_DEV_GRP_ALL);
 
        /* set VDAC to 1.8V */
-       byte = DEV_GRP_P1;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VDAC_DEV_GRP);
-       byte = VDAC_VSEL_18;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VDAC_DEDICATED);
+       twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VDAC_DEDICATED,
+                               TWL4030_PM_RECEIVER_VDAC_VSEL_18,
+                               TWL4030_PM_RECEIVER_VDAC_DEV_GRP,
+                               TWL4030_PM_RECEIVER_DEV_GRP_P1);
 }
 
-#define VMMC1_VSEL_30          0x02
-
 void twl4030_power_mmc_init(void)
 {
-       unsigned char byte;
-
-       byte = DEV_GRP_P1;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VMMC1_DEV_GRP);
-
-       /* 3 Volts */
-       byte = VMMC1_VSEL_30;
-       twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, byte,
-                            TWL4030_PM_RECEIVER_VMMC1_DEDICATED);
+       /* Set VMMC1 to 3 Volts */
+       twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VMMC1_DEDICATED,
+                               TWL4030_PM_RECEIVER_VMMC1_VSEL_30,
+                               TWL4030_PM_RECEIVER_VMMC1_DEV_GRP,
+                               TWL4030_PM_RECEIVER_DEV_GRP_P1);
 }
+
index 2b2f5ae6cde8dbe74a7580b1b43ba17f71edefab..930c285c26fee2ffbc6237bd33acb2162bce6ce4 100644 (file)
 #define TWL4030_PM_RECEIVER_MAINREF_TYPE               0xF0
 #define TWL4030_PM_RECEIVER_MAINREF_REMAP              0xF1
 
+/* Voltage Selection in PM Receiver Module */
+#define TWL4030_PM_RECEIVER_VAUX2_VSEL_18              0x05
+#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 in PM Receiver Module */
+#define TWL4030_PM_RECEIVER_DEV_GRP_P1                 0x20
+#define TWL4030_PM_RECEIVER_DEV_GRP_ALL                        0xE0
+
 /* LED */
 #define TWL4030_LED_LEDEN                              0xEE
 #define TWL4030_LED_LEDEN_LEDAON                       (1 << 0)
@@ -500,6 +511,9 @@ static inline int twl4030_i2c_read_u8(u8 chip_no, u8 *val, u8 reg)
 
 /* For hardware resetting */
 void twl4030_power_reset_init(void);
+/* For setting device group and voltage */
+void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
+                            u8 dev_grp, u8 dev_grp_sel);
 /* For initializing power device */
 void twl4030_power_init(void);
 /* For initializing mmc power */