Skip to contentSkip to conversation

Problems with powermanagement (suspend/wake/shutdown) on OMAP3530.

PATCH Tasslehoff Kjappfot 1 participant 1 message Mar 21, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

We have a board with OMAP3530 (based on BeagleBoard C3), but with PWRON connected. I want to be able to put the board in suspend and shutdown from sw, and make it wake when it senses PWRON.

Currently I compile my own Angstrom-rootfs with OpenEmbedded, and therefore run the linux-omap-psp 2.6.32 kernel from git://arago-project.org/git/projects/linux-omap3.git.

By default the powerbutton worked, but pressing for 8 seconds did nothing. I pulled in some twl4030_scripts and setup from a TI Android Kernel with working powermanagement (patch attached), and that got the 8 second reboot working, but I don't know how to get suspend/wake/shutdown working.

Suspend:
The following was output in my serial console:

root@board1:~# echo mem > /sys/power/state
[ 4042.726776] PM: Syncing filesystems ... done.

Then I pressed Ctrl-C and got some more output:

^C[ 4046.452270] Freezing user space processes ... (elapsed 0.01 seconds) done.

[ 4046.478424] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
[ 4046.501892] Suspending console(s) (use no_console_suspend to debug)

I tried using no_console_suspend, and saw a crash in mmc_suspend_host (attached).

Shutdown:
The patch gives me "pm_power_off = twl4030_poweroff", but I don't know how to shutdown my board in a way that would cause this function to be run.

And that's pretty much where I am now. I've collected some pieces of the puzzle, but I'm not entirely sure it's the right puzzle. Should I be able to achieve my goals with this kernel? If so, what's missing/wrong?

Regards,
Tasslehoff

Quoted 1 line

From c8d51a054bc5c6f926846aa8b1e61bc0c705cb83 Mon Sep 17 00:00:00 2001

From: tasslehoff <[email protected]>
Date: Tue, 15 Mar 2011 15:33:33 +0100
Subject: [PATCH] Add powerscript and i2c driver for twl4030_poweroff.

---
 arch/arm/mach-omap2/board-omap3beagle.c |  109 +++++++++++++++++
 drivers/i2c/chips/Makefile              |    1 +
 drivers/i2c/chips/twl4030-poweroff.c    |  200 +++++++++++++++++++++++++++++++
 3 files changed, 310 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/chips/twl4030-poweroff.c
arch/arm/mach-omap2/board-omap3beagle.c +109 -0
index 6dc7b23..fd247d1 100644
@@ -404,6 +404,105 @@ static int beagle_twl_gpio_setup(struct device *dev,
 	return 0;
 }
 
+
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+	/* Turn OFF VAUX2 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VAUX2, RES_STATE_OFF), 2},
+	/* Turn off HFCLKOUT */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_OFF), 2},
+	/* Turn OFF VDD1 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_OFF), 2},
+	/* Turn OFF VDD2 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_OFF), 2},
+	/* Turn OFF VPLL1 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_OFF), 2},
+};
+
+static struct twl4030_script sleep_on_script __initdata = {
+	.script	= sleep_on_seq,
+	.size	= ARRAY_SIZE(sleep_on_seq),
+	.flags	= TWL4030_SLEEP_SCRIPT,
+};
+
+static struct twl4030_ins wakeup_p12_seq[] __initdata = {
+	/* Turn on VAUX2 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VAUX2, RES_STATE_ACTIVE), 2},
+	/* Turn on HFCLKOUT */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
+	/* Turn ON VDD1 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_ACTIVE), 2},
+	/* Turn ON VDD2 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_ACTIVE), 2},
+	/* Turn ON VPLL1 */
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wakeup_p12_script __initdata = {
+	.script	= wakeup_p12_seq,
+	.size	= ARRAY_SIZE(wakeup_p12_seq),
+	.flags	= TWL4030_WAKEUP12_SCRIPT,
+};
+
+static struct twl4030_ins wakeup_p3_seq[] __initdata = {
+	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wakeup_p3_script __initdata = {
+	.script = wakeup_p3_seq,
+	.size   = ARRAY_SIZE(wakeup_p3_seq),
+	.flags  = TWL4030_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_ins wrst_seq[] __initdata = {
+/*
+ * Reset twl4030.
+ * Reset VDD1 regulator.
+ * Reset VDD2 regulator.
+ * Reset VPLL1 regulator.
+ * Enable sysclk output.
+ * Reenable twl4030.
+ */
+	{MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_WRST), 15},
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_WRST), 15},
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_WRST), 0x60},
+	{MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
+	{MSG_SINGULAR(DEV_GRP_P1, RES_VAUX2, RES_STATE_ACTIVE), 2},
+	{MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wrst_script __initdata = {
+	.script = wrst_seq,
+	.size   = ARRAY_SIZE(wrst_seq),
+	.flags  = TWL4030_WRST_SCRIPT,
+};
+
+static struct twl4030_script *twl4030_scripts[] __initdata = {
+	&sleep_on_script,
+	&wakeup_p12_script,
+	&wakeup_p3_script,
+	&wrst_script,
+};
+
+static struct twl4030_resconfig twl4030_rconfig[] = {
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
+		.type2 = -1 },
+/* XXX removed, breaks booting after power-off
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
+		.type2 = -1 },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
+		.type2 = -1 },
+*/
+	{ 0, 0},
+};
+
+static struct twl4030_power_data beagle_power_data __initdata = {
+	.scripts	= twl4030_scripts,
+	.num		= ARRAY_SIZE(twl4030_scripts),
+	.resource_config = twl4030_rconfig,
+};
+
+
 static struct twl4030_gpio_platform_data beagle_gpio_data = {
 	.gpio_base	= OMAP_MAX_GPIO_LINES,
 	.irq_base	= TWL4030_GPIO_IRQ_BASE,
@@ -544,6 +643,7 @@ static struct twl4030_platform_data beagle_twldata = {
 	/* platform_data for children goes here */
 	.usb		= &beagle_usb_data,
 	.gpio		= &beagle_gpio_data,
+        .power          = &beagle_power_data,
 	.codec		= &beagle_codec_data,
 	.madc		= &beagle_madc_data,
 	.vmmc1		= &beagle_vmmc1,
@@ -799,6 +899,13 @@ static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
 	.reset_gpio_port[2]  = -EINVAL
 };
 
+static void enable_board_wakeup_source(void)
+{
+	/* T2 interrupt line (keypad) */
+	omap_mux_init_signal("sys_nirq",
+		OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
+}
+
 #ifdef CONFIG_OMAP_MUX
 static struct omap_board_mux board_mux[] __initdata = {
 	/* Camera - Parallel Data */
@@ -925,6 +1032,8 @@ static void __init omap3_beagle_init(void)
 
 	usb_musb_init();
 	usb_ehci_init(&ehci_pdata);
+	enable_board_wakeup_source();
+
 	omap3beagle_flash_init();
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
drivers/i2c/chips/Makefile +1 -0
index fe0af0f..d085c59 100644
@@ -11,6 +11,7 @@
 #
 
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
+obj-$(CONFIG_TWL4030_POWER)     += twl4030-poweroff.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/i2c/chips/twl4030-poweroff.c new file +200 -0

200 lines not on this page · raw message

Signature · 1 line
1.7.1
root@board1:~# echo mem > /sys/power/state 
[  469.046936] PM: Syncing filesystems ... done.

^C[ 478.647308] Freezing user space processes ... (elapsed 0.01 seconds) done.

[  478.673461] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
[  478.765441] Unable to handle kernel paging request at virtual address 3d454341
[  478.772735] pgd = cf0c0000
[  478.775451] [3d454341] *pgd=00000000
[  478.779052] Internal error: Oops: 805 [#1] PREEMPT
[  478.783874] last sysfs file: /sys/devices/platform/ehci-omap.0/usb2/2-2/2-2.4/devnum
[  478.791656] Modules linked in: sdmak lpm_omap3530 dsplinkk cmemk ipv6 rtc_twl rtc_core
[  478.799682] CPU: 0    Tainted: G        W   (2.6.32 #3)
[  478.804931] PC is at del_timer+0xbc/0x138
[  478.808959] LR is at lock_timer_base+0x34/0x6c
[  478.813446] pc : [<c0075dcc>]    lr : [<c0075cd8>]    psr: 60000093
[  478.813446] sp : cfb81e78  ip : cfb81e60  fp : cfb81ec8
[  478.824981] r10: c064f240  r9 : 00000005  r8 : 00000002
[  478.830230] r7 : 00000000  r6 : 656e0064  r5 : c05c70dd  r4 : c05c6f15
[  478.836791] r3 : 00000000  r2 : 46524554  r1 : 3d454341  r0 : 46524554
[  478.843383] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  478.850646] Control: 10c5387d  Table: 8f0c0019  DAC: 00000015
[  478.856414] Process sh (pid: 809, stack limit = 0xcfb802f0)
[  478.861999] Stack: (0xcfb81e78 to 0xcfb82000)
[  478.866394] 1e60:                                                       c0632c08 20000013
[  478.874633] 1e80: c05c6f15 00000000 cf887808 c03826f8 cfa28240 00000000 cf887808 c038bc24
[  478.882843] 1ea0: c04a8c58 00000000 cf887860 00000002 cf88783c c02b7d7c cf887808 c02ba8bc
[  478.891082] 1ec0: cf887808 c02badc4 cf887660 cfbe7658 c056cf42 00000000 00000003 00000003
[  478.899291] 1ee0: c0485878 cfbe8000 cf21e4d8 00000004 000a3008 c009da34 c05707a0 00000000
[  478.907531] 1f00: c056cf42 c009dca0 c056cf42 00000003 00000003 c009d324 4001e000 00000004
[  478.915740] 1f20: cf80eba8 cf21e4c0 cf81ba00 c0649d08 cfb81f80 c0252534 cf80eba8 c013dbd8
[  478.923980] 1f40: cf11cec0 4001e000 cfb81f80 4001e000 00000004 cfb80000 00000001 c00e89b4
[  478.932220] 1f60: 00000003 00000007 00000000 00000000 cf11cec0 4001e000 00000004 c00e8b60
[  478.940429] 1f80: 00000000 00000000 c0039144 00000000 00000004 4001e000 401bc5d0 00000004
[  478.948669] 1fa0: c0039144 c0038fc0 00000004 4001e000 00000001 4001e000 00000004 00000000
[  478.956878] 1fc0: 00000004 4001e000 401bc5d0 00000004 00000004 000a33f0 00000001 000a3008
[  478.965118] 1fe0: 00000000 bed5a5b0 400fa028 4014d32c 60000010 00000001 00000000 00000000
[  478.973358] [<c0075dcc>] (del_timer+0xbc/0x138) from [<c03826f8>] (mmc_suspend_host+0x44/0x1c4)
[  478.982116] [<c03826f8>] (mmc_suspend_host+0x44/0x1c4) from [<c038bc24>] (omap_hsmmc_suspend+0x74/0x104)
[  478.991668] [<c038bc24>] (omap_hsmmc_suspend+0x74/0x104) from [<c02b7d7c>] (platform_pm_suspend+0x4c/0x5c)
[  479.001403] [<c02b7d7c>] (platform_pm_suspend+0x4c/0x5c) from [<c02ba8bc>] (pm_op+0x30/0x7c)
[  479.009887] [<c02ba8bc>] (pm_op+0x30/0x7c) from [<c02badc4>] (dpm_suspend_start+0x36c/0x4a0)
[  479.018402] [<c02badc4>] (dpm_suspend_start+0x36c/0x4a0) from [<c009da34>] (suspend_devices_and_enter+0x40/0x1cc)
[  479.028717] [<c009da34>] (suspend_devices_and_enter+0x40/0x1cc) from [<c009dca0>] (enter_state+0xe0/0x138)
[  479.038452] [<c009dca0>] (enter_state+0xe0/0x138) from [<c009d324>] (state_store+0x94/0xc8)
[  479.046844] [<c009d324>] (state_store+0x94/0xc8) from [<c0252534>] (kobj_attr_store+0x1c/0x24)
[  479.055511] [<c0252534>] (kobj_attr_store+0x1c/0x24) from [<c013dbd8>] (sysfs_write_file+0x104/0x138)
[  479.064788] [<c013dbd8>] (sysfs_write_file+0x104/0x138) from [<c00e89b4>] (vfs_write+0xac/0x1a0)
[  479.073638] [<c00e89b4>] (vfs_write+0xac/0x1a0) from [<c00e8b60>] (sys_write+0x40/0x6c)
[  479.081695] [<c00e8b60>] (sys_write+0x40/0x6c) from [<c0038fc0>] (ret_fast_syscall+0x0/0x2c)
[  479.090209] Code: eb102aaa e5952000 e5951004 e3a03000 (e5812000)