@@ -28,6 +28,7 @@
#include <linux/pm.h>
#include <linux/i2c/twl.h>
#include <linux/platform_device.h>
+#include <linux/reboot.h>
#include <asm/mach-types.h>
@@ -127,6 +128,30 @@ static u8 res_config_addrs[] = {
[RES_Main_Ref] = 0x94,
};
+/*
+ * PRCM on OMAP3 will drive SYS_OFFMODE low during DPLL3 warm reset.
+ * This causes Gaia sleep script to execute, usually killing VDD1 and
+ * VDD2 while code is running. WA is to disable the sleep script
+ * before warm reset.
+ */
+static int twl4030_prepare_for_reboot(struct notifier_block *this,
+ unsigned long cmd, void *p)
+{
+ int err;
+
+ err = twl4030_remove_script(TWL4030_SLEEP_SCRIPT);
+ if (err)
+ pr_err("TWL4030: error trying to disable sleep script!\n");
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block twl4030_reboot_notifier = {
+ .notifier_call = twl4030_prepare_for_reboot,
+ .next = NULL,
+ .priority = 0
+};
+
static int __init twl4030_write_script_byte(u8 address, u8 byte)
{
int err;
@@ -549,6 +574,11 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
if (err)
pr_err("TWL4030 Unable to relock registers\n");
+
+ err = register_reboot_notifier(&twl4030_reboot_notifier);
+ if (err)
+ pr_err("TWL4030 Failed to register reboot notifier\n");
+
return;
unlock: