OMAP3: PM: disable twl4030 sleep sequence before reboot
Subsystems (5)
When TWL4030 power scripts are enabled, the sleep script must be disabled before rebooting, if using DPLL3 reset. DPLL3 reset drives SYS_OFFMODE low, causing TWL4030 to initiate the sleep script. This script collapses VDD1 and VDD2 voltages, usually after the warm reset has happened but while ROM code is executing. In this situation MPU watchdog typically saves the day. This happens for every single reboot. It has also been observed that when VDD1 and VDD2 voltages collapse the WDT does not kick in and the system becomes irrecoverable.
[PATCH 1/2] MFD: TWL4030: introduce remove_script function Introduces new function to twl4030-power.c for disabling any script. This is done by programming the start address for the specified script to 0x3f, the END_OF_SCRIPT value.
[PATCH 2/2] OMAP3: PM: remove TWL4030 A2S script before reboot Calls new function introduced above from omap2_clk_prepare_for_reboot in clock34xx.c. So far this issue is only known to affect 3430 and 3630. No word yet if OMAP4 and Phoenix have a similar integration issue.
arch/arm/mach-omap2/clock34xx.c | 15 +++++++++++ drivers/mfd/twl4030-power.c | 50 +++++++++++++++++++++++++++++++++++++++ include/linux/i2c/twl.h | 1 + 3 files changed, 66 insertions(+), 0 deletions(-)
PATCH 1/2 MFD: TWL4030: introduce remove_script function
New function twl4030_remove_script(u8 flags) takes a script type as defined in twl.h and prevents any script already loaded in that position from running. This is accomplished by programming SEQ_ADD_* to 0x3f, the END_OF_SCRIPT value, where SEQ_ADD_* is determined by flags.
--- drivers/mfd/twl4030-power.c | 50 +++++++++++++++++++++++++++++++++++++++++++ include/linux/i2c/twl.h | 1 + 2 files changed, 51 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-power.c +50 -0
@@ -477,6 +477,56 @@ out:return err; } +int twl4030_remove_script (u8 flags) +{ +int err =0 ; + + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,R_KEY_1 , +R_PROTECT_KEY ); +if (err) { +pr_err ("twl4030: unable to unlock PROTECT_KEY\n" ); +return err; + } + + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,R_KEY_2 , +R_PROTECT_KEY ); +if (err) { +pr_err ("twl4030: unable to unlock PROTECT_KEY\n" ); +return err; + } + +if (flags &TWL4030_WRST_SCRIPT ) { + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,END_OF_SCRIPT , +R_SEQ_ADD_WARM ); +if (err) +return err; + } +if (flags &TWL4030_WAKEUP12_SCRIPT ) { +if (err) + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,END_OF_SCRIPT , +R_SEQ_ADD_S2A12 ); +return err; + } +if (flags &TWL4030_WAKEUP3_SCRIPT ) { + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,END_OF_SCRIPT , +R_SEQ_ADD_S2A3 ); +if (err) +return err; + } +if (flags &TWL4030_SLEEP_SCRIPT ) { + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,END_OF_SCRIPT , +R_SEQ_ADD_A2S ); +if (err) +return err; + } + + err =twl_i2c_write_u8 (TWL4030_MODULE_PM_MASTER ,0 ,R_PROTECT_KEY ); +if (err) +pr_err ("TWL4030 Unable to relock registers\n" ); + +return err; +} +void __init twl4030_power_init (struct twl4030_power_data *twl4030_scripts) {int err =0 ;
include/linux/i2c/twl.h +1 -0
@@ -534,6 +534,7 @@ struct twl4030_power_data { };extern void twl4030_power_init (struct twl4030_power_data *triton2_scripts); +extern int twl4030_remove_script (u8 flags);struct twl4030_codec_audio_data {unsigned int audio_mclk;
Signature · 1 line
1.6.3.2
PATCH 2/2 OMAP3: PM: remove TWL4030 A2S script before reboot
Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes SYS_OFFMODE pin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang.
--- arch/arm/mach-omap2/clock34xx.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clock34xx.c +15 -0
@@ -28,6 +28,7 @@#include <linux/bitops.h> #include <linux/err.h> #include <linux/cpufreq.h> +#include <linux/i2c/twl.h> #include <plat/cpu.h> #include <plat/clock.h>
@@ -311,6 +312,8 @@ struct clk_functions omap2_clk_functions = {*/ void omap2_clk_prepare_for_reboot (void ) { +int err =0 ; +/* REVISIT: Not ready for 343x */ #if 0 u32 rate;
@@ -321,6 +324,18 @@ void omap2_clk_prepare_for_reboot(void) rate =clk_get_rate (sclk);clk_set_rate (vclk, rate);#endif + +/* +* 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. +*/ +#ifdef CONFIG_TWL4030_POWER + err =twl4030_remove_script (TWL4030_SLEEP_SCRIPT ); +if (err) +pr_err ("twl4030: error trying to disable sleep script!\n" ); +#endif }void omap3_clk_lock_dpll5 (void )
Signature · 1 line
1.6.3.2
Tony Lindgren
maintainerRe: [PATCH 2/2] OMAP3: PM: remove TWL4030 A2S script before reboot
Hi,
Quoted 5 lines · Mike Turquette
Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang.
The first patch is OK is for Samuel, but this needs to be updated against Paul's clock changes. One comment below too.
Quoted 32 lines
Signed-off-by Mike Turquette <[email protected]>--- arch/arm/mach-omap2/clock34xx.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)arch/arm/mach-omap2/clock34xx.c +5
-0@@ -28,6 +28,7 @@#include <linux/bitops.h> #include <linux/err.h> #include <linux/cpufreq.h> +#include <linux/i2c/twl.h> #include <plat/cpu.h> #include <plat/clock.h> @@ -311,6 +312,8 @@ struct clk_functions omap2_clk_functions = {*/ void omap2_clk_prepare_for_reboot (void ) { +int err =0 ; +/* REVISIT: Not ready for 343x */ #if 0 u32 rate;@@ -321,6 +324,18 @@ void omap2_clk_prepare_for_reboot(void) rate =clk_get_rate (sclk);clk_set_rate (vclk, rate);#endif + +/*
arch/arm/mach-omap2/clock34xx.c void omap2_clk_prepare_for_reboot(void) · line 338
Quoted 10 lines
arch/arm/mach-omap2/clock34xx.c +10
-0+* 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. +*/ +#ifdef CONFIG_TWL4030_POWER + err =twl4030_remove_script (TWL4030_SLEEP_SCRIPT ); +if (err) +pr_err ("twl4030: error trying to disable sleep script!\n" ); +#endif
This needs to work in cases where we have multiple companion chips compiled in. You may have twl4030 support compiled in, but no twl4030 hardware on the board. It needs to be based on I2C detected chips during init somehow.
In the omap for-next branch we already support booting 2420, 34xx, 36xx and 4430 with the same kernel binary. So please update accordingly.
Regards,
Tony
PATCH 1/1 twl4030 reboot workaround
In reply to Mike TurquetteFrom: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes SYS_OFFMODE pin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."
Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo &
sync();
reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT
...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)
Fix is to move reboot preparations into a reboot notifier.
--- drivers/mfd/twl4030-power.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-power.c +29 -0
@@ -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,29 @@ 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 +573,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:
Signature · 1 line
1.5.6.5
RE: [PATCH] twl4030 reboot workaround
Quoted 65 lines
Quoted 65 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mikko Rapeli
Sent: Wednesday, July 28, 2010 3:12 PM
To: [email protected]
Cc: Turquette, Mike; [email protected]
Subject: [PATCH] twl4030 reboot workaroundFrom: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)Fix is to move reboot preparations into a reboot notifier.
Signed-off-by Mikko Rapeli <[email protected]>---
drivers/mfd/twl4030-power.c| 29 +++++++++++++++++++++++++++++1 files changed, 29 insertions(+), 0 deletions(-)drivers/mfd/twl4030-power.c +1
-0@@ -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,29 @@ static u8 res_config_addrs[] = { [RES_Main_Ref] = 0x94, };
Quoted 10 lines
drivers/mfd/twl4030-power.c static u8 res_config_addrs[] = { · line 140
Quoted 10 lines
drivers/mfd/twl4030-power.c +10
-0+/* +* 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;
Minor nit. Insert a blank line.
Regards
Thara
Quoted 35 lines
Quoted 35 lines
drivers/mfd/twl4030-power.c +18
-0+ 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 +573,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:
--
1.5.6.5--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] twl4030 reboot workaround
Quoted 1 line · Thara
Minor nit. Insert a blank line.
Thanks, will send a new version.
-Mikko
Re: [PATCH] twl4030 reboot workaround
In reply to Mikko RapeliQuoted 32 lines · Rapeli Mikko (EXT-Ixonos/Oulu)
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)
Quoted 2 lines
Fix is to move reboot preparations into a reboot notifier.
And what if we get an OMAP3 watchdog reset ? In this case there is no software to remove the script...
Cheers,
Peter.
Re: [PATCH] twl4030 reboot workaround
Quoted 34 lines · De-Schrijver Peter (Nokia-MS/Helsinki)
Quoted 32 lines · Rapeli Mikko (EXT-Ixonos/Oulu)
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)
Quoted 5 lines
Quoted 2 lines
Fix is to move reboot preparations into a reboot notifier.
And what if we get an OMAP3 watchdog reset ? In this case there is no software to remove the script...
Well, I don't know. We have seen boot and reboot failures and this remove script patch set has helped to reduce those failures.
-Mikko
Re: [PATCH] twl4030 reboot workaround
In reply to Mikko RapeliQuoted 3 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
I forgot about this one...
Quoted 78 lines
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)Fix is to move reboot preparations into a reboot notifier.
Signed-off-by Mikko Rapeli <[email protected]>--- drivers/mfd/twl4030-power.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)drivers/mfd/twl4030-power.c +24
-0@@ -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,29 @@ 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;
drivers/mfd/twl4030-power.c void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) · line 577
Quoted 5 lines
drivers/mfd/twl4030-power.c +2
-0@@ -549,6 +573,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);
This method is much better than the method I proposed before. Taking into account the comments from others, ACK.
Mike
Quoted 6 lines
drivers/mfd/twl4030-power.c +3
-0+if (err) +pr_err ("TWL4030 Failed to register reboot notifier\n" ); +return ; unlock:
Re: [PATCH] twl4030 reboot workaround
Quoted 2 lines · ext Mike Turquette
This method is much better than the method I proposed before. Taking into account the comments from others, ACK.
Thanks, I'll send an updated version with that one new line. Do you have an idea how the watchdog reset case should be handled? Can the boot loader do something about this or must the script removal be done before reboot?
-Mikko
PATCH v2 1/1 twl4030 reboot workaround
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes SYS_OFFMODE pin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."
Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);
Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT
...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)
Fix is to move reboot preparations into a reboot notifier.
---
v2: added a new line after variable declarations
v1: http://marc.info/?l=linux-omap&m=128031011323970&w=2
drivers/mfd/twl4030-power.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/mfd/twl4030-power.c +30 -0
@@ -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:
Signature · 1 line
1.5.6.5
Re: [PATCH v2] twl4030 reboot workaround
Hi
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.
Quoted 98 lines
Original patch resulted in a crash due to sleeping i2c calls late in the reboot sequence. Here's how to trigger the crash:
# cat /dev/urandom > /foo & sync(); reboot(LINUX_REBOOT_CMD_RESTART2);Kernel trace from 2.6.32:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#2] PREEMPT...
[<c00b3210>] (exit_mmap+0x1d4/0x1f8) from [<c006069c>] (mmput+0x34/0x110) [<c006069c>] (mmput+0x34/0x110) from [<c0064a90>] (exit_mm+0x140/0x180) [<c0064a90>] (exit_mm+0x140/0x180) from [<c00668ec>] (do_exit+0x5d8/0x6ac) [<c00668ec>] (do_exit+0x5d8/0x6ac) from [<c0035858>] (die+0x2d4/0x2e0) [<c0035858>] (die+0x2d4/0x2e0) from [<c0035904>] (baddataabort+0x0/0x50) [<c0035904>] (baddataabort+0x0/0x50) from [<c0274ff4>] (i2c_transfer+0xec/0x104) [<c0274ff4>] (i2c_transfer+0xec/0x104) from [<00000001>] (0x1)Fix is to move reboot preparations into a reboot notifier.
Signed-off-by Mikko Rapeli <[email protected]>Acked-by Mike Turquette <[email protected]>---
v2: added a new line after variable declarations
v1: http://marc.info/?l=linux-omap&m=128031011323970&w=2
drivers/mfd/twl4030-power.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)drivers/mfd/twl4030-power.c +30
-0@@ -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:
--
1.5.6.5--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Sincerely Yours, Mike. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] twl4030 reboot workaround
Quoted 12 lines · ext Mike Rapoport
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."
Quoted 6 lines
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.
Yes, I think this patch would be a good idea too since it fixes a real issue.
-Mikko
RE: [PATCH v2] twl4030 reboot workaround
In reply to Mike RapoportQuoted 24 lines
Quoted 24 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Rapoport
Sent: Friday, July 30, 2010 12:41 AM
To: Mikko Rapeli
Cc: [email protected]; Turquette, Mike; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundHi
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."
Quoted 6 lines
Quoted 6 lines
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.
How do you hit the off state(Vdd's at 0 V) in the idle path then? Or do you do this every time in the idle thread also?
Regards
Thara
Re: [PATCH v2] twl4030 reboot workaround
Quoted 29 lines · Thara
Quoted 22 lines
Quoted 22 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Rapoport
Sent: Friday, July 30, 2010 12:41 AM
To: Mikko Rapeli
Cc: [email protected]; Turquette, Mike; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundHi
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Quoted 6 lines
Quoted 6 lines
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.
Quoted 2 lines
How do you hit the off state(Vdd's at 0 V) in the idle path then? Or do you do this every time in the idle thread also?
I do not think it is appropriate to add/remove the sleep script before/after every OFF mode case. The script should be programmed once and left alone EXCEPT in the case of warm reset.
If there are other corner cases where SYS_OFFMODE goes low, then we should cover those with similar fixes to the warm reset fix, but in general I think the policy should be to leave the scripts alone once programmed
Dynamically programming/removing the scripts around OFF transitions increases software overhead for those transitions even more which is very undesirable.
Mike
Quoted 2 lines
Regards
Thara
RE: [PATCH v2] twl4030 reboot workaround
Quoted 47 lines
Quoted 47 lines
-----Original Message-----
From: Turquette, Mike
Sent: Saturday, July 31, 2010 12:09 AM
To: Gopinath, Thara
Cc: Mike Rapoport; Mikko Rapeli; [email protected]; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundQuoted 3 lines · Thara
Quoted 3 lines
Quoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf OfMike
Quoted 26 lines
Quoted 19 lines
Quoted 19 lines
Rapoport
Sent: Friday, July 30, 2010 12:41 AM
To: Mikko Rapeli
Cc: [email protected]; Turquette, Mike; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundHi
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Quoted 6 lines
Quoted 6 lines
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.Quoted 2 lines
How do you hit the off state(Vdd's at 0 V) in the idle path then? Or do you do this every time in the idle thread also?
I do not think it is appropriate to add/remove the sleep script before/after every OFF mode case. The script should be programmed once and left alone EXCEPT in the case of warm reset.
Quoted 8 lines
Quoted 8 lines
If there are other corner cases where
SYS_OFFMODEgoes low, then we should cover those with similar fixes to the warm reset fix, but in general I think the policy should be to leave the scripts alone once programmedDynamically programming/removing the scripts around OFF transitions increases software overhead for those transitions even more which is very undesirable.
This was exactly my concern. The latency increase due to the dynamic addition and removal of sleep scripts around off transitions might not be justifiable. Maybe Mike does not want to hit 0V for Vdd's in the idle thread in which case it can be acceptable to dynamically add the script in the system suspend path and remove it in the resume path. Else I also do not think this approach is acceptable.
Regards
Thara
Re: [PATCH v2] twl4030 reboot workaround
Quoted 52 lines · Thara
Quoted 43 lines
Quoted 43 lines
-----Original Message-----
From: Turquette, Mike
Sent: Saturday, July 31, 2010 12:09 AM
To: Gopinath, Thara
Cc: Mike Rapoport; Mikko Rapeli; [email protected]; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundQuoted 2 lines · Thara
Quoted 2 lines
Quoted 2 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf OfMike
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Rapoport
Sent: Friday, July 30, 2010 12:41 AM
To: Mikko Rapeli
Cc: [email protected]; Turquette, Mike; [email protected]
Subject: Re: [PATCH v2] twl4030 reboot workaroundHi
Quoted 9 lines · Mikko Rapeli
From: Mikko Rapeli <[email protected]>
Original patch: http://marc.info/?l=linux-omap&m=126522625032441&w=2
"Removes TWL4030 sleep script prior to rebooting, only on OMAP3. This is necessary since DPLL3 reset causes
SYS_OFFMODEpin to go low, resulting in the sleep script being executed on TWL4030. This usually results in VDD1 & VDD2 voltage collapse while ROM code is executing, followed by an MPU Watch Dog reset or worse, an irrecoverable hang."Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
I had a similar issue when my system hanged on hard reset when there was a TWL sleep script installed.
The workaround I've found was to install the sleep script immediately before entering the suspend state and remove the script on the resume path.
If you think that such approach is appropriate I can send a patch.How do you hit the off state(Vdd's at 0 V) in the idle path then? Or do you do this every time in the idle thread also?
I do not think it is appropriate to add/remove the sleep script before/after every OFF mode case. The script should be programmed once and left alone EXCEPT in the case of warm reset.
Quoted 8 lines
Quoted 8 lines
If there are other corner cases where
SYS_OFFMODEgoes low, then we should cover those with similar fixes to the warm reset fix, but in general I think the policy should be to leave the scripts alone once programmedDynamically programming/removing the scripts around OFF transitions increases software overhead for those transitions even more which is very undesirable.
Quoted 5 lines
This was exactly my concern. The latency increase due to the dynamic addition and removal of sleep scripts around off transitions might not be justifiable. Maybe Mike does not want to hit 0V for Vdd's in the idle thread in which case it can be acceptable to dynamically add the script in the system suspend path and remove it in the resume path. Else I also do not think this approach is acceptable.
I've missed the idle case indeed and I agree that dynamic addition and removal of sleep scripts is not an acceptable solution.
Quoted 7 lines
Regards
Thara--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Sincerely yours, Mike.