]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ARM: OMAP4+: pmic: Make generic bus init and write functions
authorLokesh Vutla <lokeshvutla@ti.com>
Thu, 30 May 2013 02:54:33 +0000 (02:54 +0000)
committerTom Rini <trini@ti.com>
Mon, 10 Jun 2013 12:43:09 +0000 (08:43 -0400)
Voltage scaling can be done in two ways:
-> Using SR I2C
-> Using GP I2C
In order to support both, have a function pointer in pmic_data
so that we can call as per our requirement.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
arch/arm/cpu/armv7/omap-common/clocks-common.c
arch/arm/cpu/armv7/omap-common/vc.c
arch/arm/cpu/armv7/omap4/hw_data.c
arch/arm/cpu/armv7/omap5/hw_data.c
arch/arm/include/asm/arch-omap4/sys_proto.h
arch/arm/include/asm/arch-omap5/sys_proto.h
arch/arm/include/asm/omap_common.h

index 403b672f7e4f2491509fe9cd0cabba229e09582c..6c8e0632c1f36e0cf1bbcf73d00bde17ec3f15bb 100644 (file)
@@ -487,6 +487,7 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
        u32 offset = volt_mv;
        int ret = 0;
 
+       pmic->pmic_bus_init();
        /* See if we can first get the GPIO if needed */
        if (pmic->gpio_en)
                ret = gpio_request(pmic->gpio, "PMIC_GPIO");
@@ -509,8 +510,7 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
        debug("do_scale_vcore: volt - %d offset_code - 0x%x\n", volt_mv,
                offset_code);
 
-       if (omap_vc_bypass_send_value(SMPS_I2C_SLAVE_ADDR,
-                               vcore_reg, offset_code))
+       if (pmic->pmic_write(pmic->i2c_slave_addr, vcore_reg, offset_code))
                printf("Scaling voltage failed for 0x%x\n", vcore_reg);
 
        if (pmic->gpio_en)
@@ -525,8 +525,6 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
  */
 void scale_vcores(struct vcores_data const *vcores)
 {
-       omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
-
        do_scale_vcore(vcores->core.addr, vcores->core.value,
                                          vcores->core.pmic);
 
index e6e5f7893c2c0a1c2b5eb3f1f29a77a3bc8de7a9..a68f1d145dcb480a50ed1d38dd8a2fb533a4c116 100644 (file)
@@ -17,6 +17,7 @@
 #include <common.h>
 #include <asm/omap_common.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/clock.h>
 
 /*
  * Define Master code if there are multiple masters on the I2C_SR bus.
@@ -57,7 +58,7 @@
  * omap_vc_init() - Initialization for Voltage controller
  * @speed_khz: I2C buspeed in KHz
  */
-void omap_vc_init(u16 speed_khz)
+static void omap_vc_init(u16 speed_khz)
 {
        u32 val;
        u32 sys_clk_khz, cycles_hi, cycles_low;
@@ -137,3 +138,14 @@ int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data)
        /* All good.. */
        return 0;
 }
+
+void sri2c_init(void)
+{
+       static int sri2c = 1;
+
+       if (sri2c) {
+               omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
+               sri2c = 0;
+       }
+       return;
+}
index 650319ad36807c3fd4fcc89fc1862eb8991b5b29..b97cad436457931d00965cbf31c2f1616606ac75 100644 (file)
@@ -219,6 +219,9 @@ struct pmic_data twl6030_4430es1 = {
        .step = 12660, /* 12.66 mV represented in uV */
        /* The code starts at 1 not 0 */
        .start_code = 1,
+       .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
+       .pmic_bus_init  = sri2c_init,
+       .pmic_write     = omap_vc_bypass_send_value,
 };
 
 struct pmic_data twl6030 = {
@@ -226,6 +229,9 @@ struct pmic_data twl6030 = {
        .step = 12660, /* 12.66 mV represented in uV */
        /* The code starts at 1 not 0 */
        .start_code = 1,
+       .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
+       .pmic_bus_init  = sri2c_init,
+       .pmic_write     = omap_vc_bypass_send_value,
 };
 
 struct pmic_data tps62361 = {
@@ -233,7 +239,10 @@ struct pmic_data tps62361 = {
        .step = 10000, /* 10 mV represented in uV */
        .start_code = 0,
        .gpio = TPS62361_VSEL0_GPIO,
-       .gpio_en = 1
+       .gpio_en = 1,
+       .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
+       .pmic_bus_init  = sri2c_init,
+       .pmic_write     = omap_vc_bypass_send_value,
 };
 
 struct vcores_data omap4430_volts_es1 = {
index d2f59000131a2839a9742fb4c2490d00519dcb03..585e318671f7af973798a7d4a6ba22efaad3689b 100644 (file)
@@ -289,6 +289,9 @@ struct pmic_data palmas = {
         * Offset code 0 switches OFF the SMPS
         */
        .start_code = 6,
+       .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
+       .pmic_bus_init  = sri2c_init,
+       .pmic_write     = omap_vc_bypass_send_value,
 };
 
 struct vcores_data omap5430_volts = {
index 0126a85bd39fa02f07cb915b9ae69d18952cad03..15e368224fc77edd902cdd26af44b75d0bc2fa5c 100644 (file)
@@ -57,7 +57,7 @@ u32 cortex_rev(void);
 void save_omap_boot_params(void);
 void init_omap_revision(void);
 void do_io_settings(void);
-void omap_vc_init(u16 speed_khz);
+void sri2c_init(void);
 int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
 u32 warm_reset(void);
 void force_emif_self_refresh(void);
index fb35a82d4e3d238fac1f98b91a362b1007bc721a..91eb36cf8b872e57c14b8b386759c5c7fa396e0b 100644 (file)
@@ -61,7 +61,7 @@ u32 cortex_rev(void);
 void save_omap_boot_params(void);
 void init_omap_revision(void);
 void do_io_settings(void);
-void omap_vc_init(u16 speed_khz);
+void sri2c_init(void);
 int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
 u32 warm_reset(void);
 void force_emif_self_refresh(void);
index 712d78b0a6145141cdb8368a124f161f6d71f775..b70575b1b51892ed65adc270e7da404c831d68c0 100644 (file)
@@ -501,6 +501,9 @@ struct pmic_data {
        u32 start_code;
        unsigned gpio;
        int gpio_en;
+       u32 i2c_slave_addr;
+       void (*pmic_bus_init)(void);
+       int (*pmic_write)(u8 sa, u8 reg_addr, u8 reg_data);
 };
 
 struct volts {