aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLokesh Vutla2013-05-22 01:05:04 -0500
committerLokesh Vutla2013-05-29 04:34:11 -0500
commita39a6b09f645f095fcf76968d21244ad800426ff (patch)
treee1876f1cad64177c39c1b25344eaa62dc16d8f9f
parente1f586bc2c5b2c5f9823d0baac08ae514feeb371 (diff)
downloadu-boot-a39a6b09f645f095fcf76968d21244ad800426ff.tar.gz
u-boot-a39a6b09f645f095fcf76968d21244ad800426ff.tar.xz
u-boot-a39a6b09f645f095fcf76968d21244ad800426ff.zip
ARM: OMAP4+: pmic: Make generic bus init and write functions
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>
-rw-r--r--arch/arm/cpu/armv7/omap-common/clocks-common.c6
-rw-r--r--arch/arm/cpu/armv7/omap-common/vc.c14
-rw-r--r--arch/arm/cpu/armv7/omap4/hw_data.c11
-rw-r--r--arch/arm/cpu/armv7/omap5/hw_data.c3
-rw-r--r--arch/arm/include/asm/arch-omap4/sys_proto.h2
-rw-r--r--arch/arm/include/asm/arch-omap5/sys_proto.h2
-rw-r--r--arch/arm/include/asm/omap_common.h3
7 files changed, 33 insertions, 8 deletions
diff --git a/arch/arm/cpu/armv7/omap-common/clocks-common.c b/arch/arm/cpu/armv7/omap-common/clocks-common.c
index 99910cdcb0..0daf98cad9 100644
--- a/arch/arm/cpu/armv7/omap-common/clocks-common.c
+++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c
@@ -487,6 +487,7 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
487 u32 offset = volt_mv; 487 u32 offset = volt_mv;
488 int ret = 0; 488 int ret = 0;
489 489
490 pmic->pmic_bus_init();
490 /* See if we can first get the GPIO if needed */ 491 /* See if we can first get the GPIO if needed */
491 if (pmic->gpio_en) 492 if (pmic->gpio_en)
492 ret = gpio_request(pmic->gpio, "PMIC_GPIO"); 493 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)
509 debug("do_scale_vcore: volt - %d offset_code - 0x%x\n", volt_mv, 510 debug("do_scale_vcore: volt - %d offset_code - 0x%x\n", volt_mv,
510 offset_code); 511 offset_code);
511 512
512 if (omap_vc_bypass_send_value(SMPS_I2C_SLAVE_ADDR, 513 if (pmic->pmic_write(pmic->i2c_slave_addr, vcore_reg, offset_code))
513 vcore_reg, offset_code))
514 printf("Scaling voltage failed for 0x%x\n", vcore_reg); 514 printf("Scaling voltage failed for 0x%x\n", vcore_reg);
515 515
516 if (pmic->gpio_en) 516 if (pmic->gpio_en)
@@ -525,8 +525,6 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
525 */ 525 */
526void scale_vcores(struct vcores_data const *vcores) 526void scale_vcores(struct vcores_data const *vcores)
527{ 527{
528 omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
529
530 do_scale_vcore(vcores->core.addr, vcores->core.value, 528 do_scale_vcore(vcores->core.addr, vcores->core.value,
531 vcores->core.pmic); 529 vcores->core.pmic);
532 530
diff --git a/arch/arm/cpu/armv7/omap-common/vc.c b/arch/arm/cpu/armv7/omap-common/vc.c
index e6e5f7893c..911191dde6 100644
--- a/arch/arm/cpu/armv7/omap-common/vc.c
+++ b/arch/arm/cpu/armv7/omap-common/vc.c
@@ -17,6 +17,7 @@
17#include <common.h> 17#include <common.h>
18#include <asm/omap_common.h> 18#include <asm/omap_common.h>
19#include <asm/arch/sys_proto.h> 19#include <asm/arch/sys_proto.h>
20#include <asm/arch/clocks.h>
20 21
21/* 22/*
22 * Define Master code if there are multiple masters on the I2C_SR bus. 23 * Define Master code if there are multiple masters on the I2C_SR bus.
@@ -57,7 +58,7 @@
57 * omap_vc_init() - Initialization for Voltage controller 58 * omap_vc_init() - Initialization for Voltage controller
58 * @speed_khz: I2C buspeed in KHz 59 * @speed_khz: I2C buspeed in KHz
59 */ 60 */
60void omap_vc_init(u16 speed_khz) 61static void omap_vc_init(u16 speed_khz)
61{ 62{
62 u32 val; 63 u32 val;
63 u32 sys_clk_khz, cycles_hi, cycles_low; 64 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)
137 /* All good.. */ 138 /* All good.. */
138 return 0; 139 return 0;
139} 140}
141
142void sri2c_init(void)
143{
144 static int sri2c = 1;
145
146 if (sri2c) {
147 omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
148 sri2c = 0;
149 }
150 return;
151}
diff --git a/arch/arm/cpu/armv7/omap4/hw_data.c b/arch/arm/cpu/armv7/omap4/hw_data.c
index 06a2fc8c2f..02322cc69b 100644
--- a/arch/arm/cpu/armv7/omap4/hw_data.c
+++ b/arch/arm/cpu/armv7/omap4/hw_data.c
@@ -219,6 +219,9 @@ struct pmic_data twl6030_4430es1 = {
219 .step = 12660, /* 12.66 mV represented in uV */ 219 .step = 12660, /* 12.66 mV represented in uV */
220 /* The code starts at 1 not 0 */ 220 /* The code starts at 1 not 0 */
221 .start_code = 1, 221 .start_code = 1,
222 .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
223 .pmic_bus_init = sri2c_init,
224 .pmic_write = omap_vc_bypass_send_value,
222}; 225};
223 226
224struct pmic_data twl6030 = { 227struct pmic_data twl6030 = {
@@ -226,6 +229,9 @@ struct pmic_data twl6030 = {
226 .step = 12660, /* 12.66 mV represented in uV */ 229 .step = 12660, /* 12.66 mV represented in uV */
227 /* The code starts at 1 not 0 */ 230 /* The code starts at 1 not 0 */
228 .start_code = 1, 231 .start_code = 1,
232 .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
233 .pmic_bus_init = sri2c_init,
234 .pmic_write = omap_vc_bypass_send_value,
229}; 235};
230 236
231struct pmic_data tps62361 = { 237struct pmic_data tps62361 = {
@@ -233,7 +239,10 @@ struct pmic_data tps62361 = {
233 .step = 10000, /* 10 mV represented in uV */ 239 .step = 10000, /* 10 mV represented in uV */
234 .start_code = 0, 240 .start_code = 0,
235 .gpio = TPS62361_VSEL0_GPIO, 241 .gpio = TPS62361_VSEL0_GPIO,
236 .gpio_en = 1 242 .gpio_en = 1,
243 .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
244 .pmic_bus_init = sri2c_init,
245 .pmic_write = omap_vc_bypass_send_value,
237}; 246};
238 247
239struct vcores_data omap4430_volts_es1 = { 248struct vcores_data omap4430_volts_es1 = {
diff --git a/arch/arm/cpu/armv7/omap5/hw_data.c b/arch/arm/cpu/armv7/omap5/hw_data.c
index 842cf279c1..74e473d83a 100644
--- a/arch/arm/cpu/armv7/omap5/hw_data.c
+++ b/arch/arm/cpu/armv7/omap5/hw_data.c
@@ -289,6 +289,9 @@ struct pmic_data palmas = {
289 * Offset code 0 switches OFF the SMPS 289 * Offset code 0 switches OFF the SMPS
290 */ 290 */
291 .start_code = 6, 291 .start_code = 6,
292 .i2c_slave_addr = SMPS_I2C_SLAVE_ADDR,
293 .pmic_bus_init = sri2c_init,
294 .pmic_write = omap_vc_bypass_send_value,
292}; 295};
293 296
294struct vcores_data omap5430_volts = { 297struct vcores_data omap5430_volts = {
diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h
index 039a1f2604..37d6c69352 100644
--- a/arch/arm/include/asm/arch-omap4/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap4/sys_proto.h
@@ -56,7 +56,7 @@ u32 omap_sdram_size(void);
56u32 cortex_rev(void); 56u32 cortex_rev(void);
57void init_omap_revision(void); 57void init_omap_revision(void);
58void do_io_settings(void); 58void do_io_settings(void);
59void omap_vc_init(u16 speed_khz); 59void sri2c_init(void);
60int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data); 60int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
61u32 warm_reset(void); 61u32 warm_reset(void);
62void force_emif_self_refresh(void); 62void force_emif_self_refresh(void);
diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h
index b79161d79a..32ced5fbde 100644
--- a/arch/arm/include/asm/arch-omap5/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap5/sys_proto.h
@@ -60,7 +60,7 @@ u32 omap_sdram_size(void);
60u32 cortex_rev(void); 60u32 cortex_rev(void);
61void init_omap_revision(void); 61void init_omap_revision(void);
62void do_io_settings(void); 62void do_io_settings(void);
63void omap_vc_init(u16 speed_khz); 63void sri2c_init(void);
64int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data); 64int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
65u32 warm_reset(void); 65u32 warm_reset(void);
66void force_emif_self_refresh(void); 66void force_emif_self_refresh(void);
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index 8747bff07b..3f1d31dbd9 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -495,6 +495,9 @@ struct pmic_data {
495 u32 start_code; 495 u32 start_code;
496 unsigned gpio; 496 unsigned gpio;
497 int gpio_en; 497 int gpio_en;
498 u32 i2c_slave_addr;
499 void (*pmic_bus_init)(void);
500 int (*pmic_write)(u8 sa, u8 reg_addr, u8 reg_data);
498}; 501};
499 502
500struct volts { 503struct volts {