diff mbox

[V4] OMAP3: PM: Set/clear T2 bit for Smartreflex on TWL

Message ID 20110216134523.ba5d3917.jhnikula@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Kevin Hilman
Headers show

Commit Message

Jarkko Nikula Feb. 16, 2011, 11:45 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 16422de0..e767b0f 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -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:
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 61b9609..1f64e3e 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -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)
 };