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>
This commit is contained in:
parent
af1d002f89
commit
4ca94d8186
|
@ -487,6 +487,7 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
|
||||||
u32 offset = volt_mv;
|
u32 offset = volt_mv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
pmic->pmic_bus_init();
|
||||||
/* See if we can first get the GPIO if needed */
|
/* See if we can first get the GPIO if needed */
|
||||||
if (pmic->gpio_en)
|
if (pmic->gpio_en)
|
||||||
ret = gpio_request(pmic->gpio, "PMIC_GPIO");
|
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,
|
debug("do_scale_vcore: volt - %d offset_code - 0x%x\n", volt_mv,
|
||||||
offset_code);
|
offset_code);
|
||||||
|
|
||||||
if (omap_vc_bypass_send_value(SMPS_I2C_SLAVE_ADDR,
|
if (pmic->pmic_write(pmic->i2c_slave_addr, vcore_reg, offset_code))
|
||||||
vcore_reg, offset_code))
|
|
||||||
printf("Scaling voltage failed for 0x%x\n", vcore_reg);
|
printf("Scaling voltage failed for 0x%x\n", vcore_reg);
|
||||||
|
|
||||||
if (pmic->gpio_en)
|
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)
|
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,
|
do_scale_vcore(vcores->core.addr, vcores->core.value,
|
||||||
vcores->core.pmic);
|
vcores->core.pmic);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <asm/omap_common.h>
|
#include <asm/omap_common.h>
|
||||||
#include <asm/arch/sys_proto.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.
|
* Define Master code if there are multiple masters on the I2C_SR bus.
|
||||||
|
@ -57,7 +58,7 @@
|
||||||
* omap_vc_init() - Initialization for Voltage controller
|
* omap_vc_init() - Initialization for Voltage controller
|
||||||
* @speed_khz: I2C buspeed in KHz
|
* @speed_khz: I2C buspeed in KHz
|
||||||
*/
|
*/
|
||||||
void omap_vc_init(u16 speed_khz)
|
static void omap_vc_init(u16 speed_khz)
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
u32 sys_clk_khz, cycles_hi, cycles_low;
|
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.. */
|
/* All good.. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sri2c_init(void)
|
||||||
|
{
|
||||||
|
static int sri2c = 1;
|
||||||
|
|
||||||
|
if (sri2c) {
|
||||||
|
omap_vc_init(PRM_VC_I2C_CHANNEL_FREQ_KHZ);
|
||||||
|
sri2c = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -219,6 +219,9 @@ struct pmic_data twl6030_4430es1 = {
|
||||||
.step = 12660, /* 12.66 mV represented in uV */
|
.step = 12660, /* 12.66 mV represented in uV */
|
||||||
/* The code starts at 1 not 0 */
|
/* The code starts at 1 not 0 */
|
||||||
.start_code = 1,
|
.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 = {
|
struct pmic_data twl6030 = {
|
||||||
|
@ -226,6 +229,9 @@ struct pmic_data twl6030 = {
|
||||||
.step = 12660, /* 12.66 mV represented in uV */
|
.step = 12660, /* 12.66 mV represented in uV */
|
||||||
/* The code starts at 1 not 0 */
|
/* The code starts at 1 not 0 */
|
||||||
.start_code = 1,
|
.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 = {
|
struct pmic_data tps62361 = {
|
||||||
|
@ -233,7 +239,10 @@ struct pmic_data tps62361 = {
|
||||||
.step = 10000, /* 10 mV represented in uV */
|
.step = 10000, /* 10 mV represented in uV */
|
||||||
.start_code = 0,
|
.start_code = 0,
|
||||||
.gpio = TPS62361_VSEL0_GPIO,
|
.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 = {
|
struct vcores_data omap4430_volts_es1 = {
|
||||||
|
|
|
@ -289,6 +289,9 @@ struct pmic_data palmas = {
|
||||||
* Offset code 0 switches OFF the SMPS
|
* Offset code 0 switches OFF the SMPS
|
||||||
*/
|
*/
|
||||||
.start_code = 6,
|
.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 = {
|
struct vcores_data omap5430_volts = {
|
||||||
|
|
|
@ -57,7 +57,7 @@ u32 cortex_rev(void);
|
||||||
void save_omap_boot_params(void);
|
void save_omap_boot_params(void);
|
||||||
void init_omap_revision(void);
|
void init_omap_revision(void);
|
||||||
void do_io_settings(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);
|
int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
|
||||||
u32 warm_reset(void);
|
u32 warm_reset(void);
|
||||||
void force_emif_self_refresh(void);
|
void force_emif_self_refresh(void);
|
||||||
|
|
|
@ -61,7 +61,7 @@ u32 cortex_rev(void);
|
||||||
void save_omap_boot_params(void);
|
void save_omap_boot_params(void);
|
||||||
void init_omap_revision(void);
|
void init_omap_revision(void);
|
||||||
void do_io_settings(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);
|
int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
|
||||||
u32 warm_reset(void);
|
u32 warm_reset(void);
|
||||||
void force_emif_self_refresh(void);
|
void force_emif_self_refresh(void);
|
||||||
|
|
|
@ -501,6 +501,9 @@ struct pmic_data {
|
||||||
u32 start_code;
|
u32 start_code;
|
||||||
unsigned gpio;
|
unsigned gpio;
|
||||||
int gpio_en;
|
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 {
|
struct volts {
|
||||||
|
|
Loading…
Reference in New Issue