@@ -92,6 +92,9 @@ static u8 twl4030_start_script_address = 0x2b;
#define OFF_STATE_SHIFT 4
#define OFF_STATE_MASK (0xf << OFF_STATE_SHIFT)
+#define TWL4030_DCDC_GLOBAL_CFG PHY_TO_OFF_PM_RECEIVER(0x61)
+#define SMARTREFLEX_ENABLE BIT(3)
+
static u8 res_config_addrs[] = {
[RES_VAUX1] = 0x17,
[RES_VAUX2] = 0x1b,
@@ -510,6 +513,22 @@ int twl4030_remove_script(u8 flags)
return err;
}
+int __init twl4030_sr_enable(void)
+{
+ u8 temp;
+ int ret;
+
+ ret = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &temp,
+ TWL4030_DCDC_GLOBAL_CFG);
+ if (ret)
+ return ret;
+
+ temp |= SMARTREFLEX_ENABLE;
+
+ return twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, temp,
+ TWL4030_DCDC_GLOBAL_CFG);
+}
+
void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
{
int err = 0;
@@ -549,8 +568,15 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
TWL4030_PM_MASTER_PROTECT_KEY);
- if (err)
+ if (err) {
pr_err("TWL4030 Unable to relock registers\n");
+ return;
+ }
+
+ if (twl4030_scripts->sr_enable)
+ err = twl4030_sr_enable();
+ if (err)
+ pr_err("TWL4030 Unable to set smartreflex. %d\n", err);
return;
unlock:
@@ -630,6 +630,7 @@ struct twl4030_power_data {
struct twl4030_script **scripts;
unsigned num;
struct twl4030_resconfig *resource_config;
+ bool sr_enable; /* Smartreflex enable state */
#define TWL4030_RESCONFIG_UNDEF ((u8)-1)
};