public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] OMAP fixes from PM branch for .31-rc
@ 2009-06-25 16:41 Kevin Hilman
  2009-06-25 16:41 ` [PATCH 01/11] OMAP: SDRC: Add several new register definitions Kevin Hilman
  2009-06-25 17:08 ` [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy Kevin Hilman
  0 siblings, 2 replies; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

This series is a set of fixes/cleanups from the PM branch targeted for
the .31-rc series.

Applies on top of 'omap-fixes' branch of linux-omap.

Kevin Hilman (9):
  OMAP2/3: PM: make PM __init calls static
  OMAP3: PM: CM_REGADDR macros using wrong name
  OMAP3: PM: Ensure PRCM interrupts are cleared at boot
  OMAP3: PM: Clear pending PRCM reset flags on init
  OMAP3: PM: prevent module wakeups from waking IVA2
  OMAP3: PM: Do not build suspend code if SUSPEND is not enabled
  OMAP3: PM: reset USB OTG module on boot
  OMAP4: UART: cleanup special case IRQ handling
  OMAP2/3/4: UART: Allow per-UART disabling wakeup for serial ports

Tero Kristo (2):
  OMAP: SDRC: Add several new register definitions
  OMAP3: Fixed crash bug with serial + suspend

 arch/arm/mach-omap2/cm.h                 |    6 +-
 arch/arm/mach-omap2/pm.h                 |    3 -
 arch/arm/mach-omap2/pm24xx.c             |    2 +-
 arch/arm/mach-omap2/pm34xx.c             |   49 +++++++-
 arch/arm/mach-omap2/serial.c             |  195 ++++++++++++++++++++----------
 arch/arm/mach-omap2/usb-musb.c           |   22 +++-
 arch/arm/plat-omap/include/mach/sdrc.h   |   13 ++
 arch/arm/plat-omap/include/mach/serial.h |    1 +
 8 files changed, 215 insertions(+), 76 deletions(-)


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/11] OMAP: SDRC: Add several new register definitions
  2009-06-25 16:41 [PATCH 00/11] OMAP fixes from PM branch for .31-rc Kevin Hilman
@ 2009-06-25 16:41 ` Kevin Hilman
  2009-06-25 16:41   ` [PATCH 02/11] OMAP2/3: PM: make PM __init calls static Kevin Hilman
  2009-06-25 17:08 ` [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy Kevin Hilman
  1 sibling, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Tero Kristo

From: Tero Kristo <tero.kristo@nokia.com>

Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/plat-omap/include/mach/sdrc.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/include/mach/sdrc.h b/arch/arm/plat-omap/include/mach/sdrc.h
index adc7352..7cc6568 100644
--- a/arch/arm/plat-omap/include/mach/sdrc.h
+++ b/arch/arm/plat-omap/include/mach/sdrc.h
@@ -21,15 +21,28 @@
 /* SDRC register offsets - read/write with sdrc_{read,write}_reg() */
 
 #define SDRC_SYSCONFIG		0x010
+#define SDRC_CS_CFG		0x040
+#define SDRC_SHARING		0x044
+#define SDRC_ERR_TYPE		0x04C
 #define SDRC_DLLA_CTRL		0x060
 #define SDRC_DLLA_STATUS	0x064
 #define SDRC_DLLB_CTRL		0x068
 #define SDRC_DLLB_STATUS	0x06C
 #define SDRC_POWER		0x070
+#define SDRC_MCFG_0		0x080
 #define SDRC_MR_0		0x084
+#define SDRC_EMR2_0		0x08c
 #define SDRC_ACTIM_CTRL_A_0	0x09c
 #define SDRC_ACTIM_CTRL_B_0	0x0a0
 #define SDRC_RFR_CTRL_0		0x0a4
+#define SDRC_MANUAL_0		0x0a8
+#define SDRC_MCFG_1		0x0B0
+#define SDRC_MR_1		0x0B4
+#define SDRC_EMR2_1		0x0BC
+#define SDRC_ACTIM_CTRL_A_1	0x0C4
+#define SDRC_ACTIM_CTRL_B_1	0x0C8
+#define SDRC_RFR_CTRL_1		0x0D4
+#define SDRC_MANUAL_1		0x0D8
 
 /*
  * These values represent the number of memory clock cycles between
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/11] OMAP2/3: PM: make PM __init calls static
  2009-06-25 16:41 ` [PATCH 01/11] OMAP: SDRC: Add several new register definitions Kevin Hilman
@ 2009-06-25 16:41   ` Kevin Hilman
  2009-06-25 16:41     ` [PATCH 03/11] OMAP3: PM: CM_REGADDR macros using wrong name Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm.h     |    3 ---
 arch/arm/mach-omap2/pm24xx.c |    2 +-
 arch/arm/mach-omap2/pm34xx.c |    2 +-
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index f7b3baf..21201cd 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -11,9 +11,6 @@
 #ifndef __ARCH_ARM_MACH_OMAP2_PM_H
 #define __ARCH_ARM_MACH_OMAP2_PM_H
 
-extern int omap2_pm_init(void);
-extern int omap3_pm_init(void);
-
 #ifdef CONFIG_PM_DEBUG
 extern void omap2_pm_dump(int mode, int resume, unsigned int us);
 extern int omap2_pm_debug;
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index db10255..528dbdc 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -470,7 +470,7 @@ static void __init prcm_setup_regs(void)
 			  WKUP_MOD, PM_WKEN);
 }
 
-int __init omap2_pm_init(void)
+static int __init omap2_pm_init(void)
 {
 	u32 l;
 
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 841d4c5..765cdc0 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -652,7 +652,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm)
 	return 0;
 }
 
-int __init omap3_pm_init(void)
+static int __init omap3_pm_init(void)
 {
 	struct power_state *pwrst, *tmp;
 	int ret;
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/11] OMAP3: PM: CM_REGADDR macros using wrong name
  2009-06-25 16:41   ` [PATCH 02/11] OMAP2/3: PM: make PM __init calls static Kevin Hilman
@ 2009-06-25 16:41     ` Kevin Hilman
  2009-06-25 16:41       ` [PATCH 04/11] OMAP3: PM: Ensure PRCM interrupts are cleared at boot Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/cm.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/cm.h b/arch/arm/mach-omap2/cm.h
index 1d3c93b..f3c91a1 100644
--- a/arch/arm/mach-omap2/cm.h
+++ b/arch/arm/mach-omap2/cm.h
@@ -29,9 +29,9 @@
  * These registers appear once per CM module.
  */
 
-#define OMAP3430_CM_REVISION		OMAP_CM_REGADDR(OCP_MOD, 0x0000)
-#define OMAP3430_CM_SYSCONFIG		OMAP_CM_REGADDR(OCP_MOD, 0x0010)
-#define OMAP3430_CM_POLCTRL		OMAP_CM_REGADDR(OCP_MOD, 0x009c)
+#define OMAP3430_CM_REVISION		OMAP34XX_CM_REGADDR(OCP_MOD, 0x0000)
+#define OMAP3430_CM_SYSCONFIG		OMAP34XX_CM_REGADDR(OCP_MOD, 0x0010)
+#define OMAP3430_CM_POLCTRL		OMAP34XX_CM_REGADDR(OCP_MOD, 0x009c)
 
 #define OMAP3_CM_CLKOUT_CTRL_OFFSET	0x0070
 #define OMAP3430_CM_CLKOUT_CTRL		OMAP_CM_REGADDR(OMAP3430_CCR_MOD, 0x0070)
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/11] OMAP3: PM: Ensure PRCM interrupts are cleared at boot
  2009-06-25 16:41     ` [PATCH 03/11] OMAP3: PM: CM_REGADDR macros using wrong name Kevin Hilman
@ 2009-06-25 16:41       ` Kevin Hilman
  2009-06-25 16:41         ` [PATCH 05/11] OMAP3: PM: Clear pending PRCM reset flags on init Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Any pending PRCM interrupts can prevent retention.  Ensure
they are cleared during boot.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 765cdc0..cc83dfc 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -613,6 +613,9 @@ static void __init prcm_setup_regs(void)
 	/* Clear any pending PRCM interrupts */
 	prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
 
+	/* Clear any pending PRCM interrupts */
+	prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
+
 	omap3_iva_idle();
 	omap3_d2d_idle();
 }
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 05/11] OMAP3: PM: Clear pending PRCM reset flags on init
  2009-06-25 16:41       ` [PATCH 04/11] OMAP3: PM: Ensure PRCM interrupts are cleared at boot Kevin Hilman
@ 2009-06-25 16:41         ` Kevin Hilman
  2009-06-25 16:41           ` [PATCH 06/11] OMAP3: PM: prevent module wakeups from waking IVA2 Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Any pending reset flags can prevent retention.  Ensure they are all
cleared during boot.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index cc83dfc..1422e93 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -613,6 +613,15 @@ static void __init prcm_setup_regs(void)
 	/* Clear any pending PRCM interrupts */
 	prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
 
+	/* Clear any pending 'reset' flags */
+	prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST);
+	prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST);
+
 	/* Clear any pending PRCM interrupts */
 	prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
 
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 06/11] OMAP3: PM: prevent module wakeups from waking IVA2
  2009-06-25 16:41         ` [PATCH 05/11] OMAP3: PM: Clear pending PRCM reset flags on init Kevin Hilman
@ 2009-06-25 16:41           ` Kevin Hilman
  2009-06-25 16:42             ` [PATCH 07/11] OMAP3: PM: Do not build suspend code if SUSPEND is not enabled Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:41 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

By default, prevent functional wakeups from inside a module from
waking up the IVA2.  Let DSP Bridge code handle this when loaded.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 1422e93..c813a08 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -613,6 +613,12 @@ static void __init prcm_setup_regs(void)
 	/* Clear any pending PRCM interrupts */
 	prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
 
+	/* Don't attach IVA interrupts */
+	prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
+	prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
+	prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
+	prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
+
 	/* Clear any pending 'reset' flags */
 	prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
 	prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/11] OMAP3: PM: Do not build suspend code if SUSPEND is not enabled
  2009-06-25 16:41           ` [PATCH 06/11] OMAP3: PM: prevent module wakeups from waking IVA2 Kevin Hilman
@ 2009-06-25 16:42             ` Kevin Hilman
  2009-06-25 16:42               ` [PATCH 08/11] OMAP3: PM: reset USB OTG module on boot Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:42 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Jouni Hogander

Signed-off-by: Jouni Hogander <jouni.hogander@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index c813a08..528f725 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -39,7 +39,9 @@
 struct power_state {
 	struct powerdomain *pwrdm;
 	u32 next_state;
+#ifdef CONFIG_SUSPEND
 	u32 saved_state;
+#endif
 	struct list_head node;
 };
 
@@ -293,6 +295,7 @@ out:
 	local_irq_enable();
 }
 
+#ifdef CONFIG_SUSPEND
 static int omap3_pm_prepare(void)
 {
 	disable_hlt();
@@ -366,6 +369,7 @@ static struct platform_suspend_ops omap_pm_ops = {
 	.finish		= omap3_pm_finish,
 	.valid		= suspend_valid_only_mem,
 };
+#endif /* CONFIG_SUSPEND */
 
 
 /**
@@ -710,7 +714,9 @@ static int __init omap3_pm_init(void)
 	_omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
 					 omap34xx_cpu_suspend_sz);
 
+#ifdef CONFIG_SUSPEND
 	suspend_set_ops(&omap_pm_ops);
+#endif /* CONFIG_SUSPEND */
 
 	pm_idle = omap3_pm_idle;
 
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 08/11] OMAP3: PM: reset USB OTG module on boot
  2009-06-25 16:42             ` [PATCH 07/11] OMAP3: PM: Do not build suspend code if SUSPEND is not enabled Kevin Hilman
@ 2009-06-25 16:42               ` Kevin Hilman
  2009-06-25 16:42                 ` [PATCH 09/11] OMAP4: UART: cleanup special case IRQ handling Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:42 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Rather than simply setting force-idle mode on boot, do a reset of the
OTG module.  This really ensures that any bootloader/bootstrap code
that leaves it active will not prevent future retention.  After reset,
OTG module will be in force-idle, force-standby mode.

Problem reported by Mike Chan <mikechan@google.com>

Tested-by: Mike Chan <mikechan@google.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/usb-musb.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index d85296d..3efa19c 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -26,18 +26,32 @@
 
 #include <linux/usb/musb.h>
 
+#include <asm/sizes.h>
+
 #include <mach/hardware.h>
 #include <mach/irqs.h>
 #include <mach/mux.h>
 #include <mach/usb.h>
 
-#define OTG_SYSCONFIG	(OMAP34XX_HSUSB_OTG_BASE + 0x404)
+#define OTG_SYSCONFIG	   0x404
+#define OTG_SYSC_SOFTRESET BIT(1)
 
 static void __init usb_musb_pm_init(void)
 {
-	/* Ensure force-idle mode for OTG controller */
-	if (cpu_is_omap34xx())
-		omap_writel(0, OTG_SYSCONFIG);
+	void __iomem *otg_base;
+
+	if (!cpu_is_omap34xx())
+		return;
+
+	otg_base = ioremap(OMAP34XX_HSUSB_OTG_BASE, SZ_4K);
+	if (WARN_ON(!otg_base))
+		return;
+
+	/* Reset OTG controller.  After reset, it will be in
+	 * force-idle, force-standby mode. */
+	__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
+
+	iounmap(otg_base);
 }
 
 #ifdef CONFIG_USB_MUSB_SOC
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/11] OMAP4: UART: cleanup special case IRQ handling
  2009-06-25 16:42               ` [PATCH 08/11] OMAP3: PM: reset USB OTG module on boot Kevin Hilman
@ 2009-06-25 16:42                 ` Kevin Hilman
  2009-06-25 16:42                   ` [PATCH 10/11] OMAP3: Fixed crash bug with serial + suspend Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:42 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/serial.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index b094c15..c82ec95 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -496,10 +496,6 @@ void __init omap_serial_init(void)
 
 	if (info == NULL)
 		return;
-	if (cpu_is_omap44xx()) {
-		for (i = 0; i < OMAP_MAX_NR_PORTS; i++)
-			serial_platform_data[i].irq += 32;
-	}
 
 	for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
 		struct plat_serial8250_port *p = serial_platform_data + i;
@@ -533,6 +529,9 @@ void __init omap_serial_init(void)
 		uart->p = p;
 		list_add(&uart->node, &uart_list);
 
+		if (cpu_is_omap44xx())
+			p->irq += 32;
+
 		omap_uart_enable_clocks(uart);
 		omap_uart_reset(uart);
 		omap_uart_idle_init(uart);
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/11] OMAP3: Fixed crash bug with serial + suspend
  2009-06-25 16:42                 ` [PATCH 09/11] OMAP4: UART: cleanup special case IRQ handling Kevin Hilman
@ 2009-06-25 16:42                   ` Kevin Hilman
  2009-06-25 16:42                     ` [PATCH 11/11] OMAP2/3/4: UART: Allow per-UART disabling wakeup for serial ports Kevin Hilman
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:42 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Tero Kristo

From: Tero Kristo <tero.kristo@nokia.com>

It was possible for an unhandled interrupt to occur if there was incoming
serial traffic during wakeup from suspend. This was caused by the code
in arch-arm/mach-omap2/serial.c keeping interrupt enabled all the time,
but not acking its interrupts. Applies on top of PM branch.

Use the PM begin/end hooks to ensure that the "serial idle" interrupts
are disabled during the suspend path.  Also, since begin/end hooks are
now used, use the suspend_state that is passed in the begin hook instead
of the enter hook as per the platform_suspend_ops docs.

Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c             |   23 +++++++++++++++++++++--
 arch/arm/mach-omap2/serial.c             |   14 ++++++++++++++
 arch/arm/plat-omap/include/mach/serial.h |    1 +
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 528f725..b07efb2 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -296,6 +296,8 @@ out:
 }
 
 #ifdef CONFIG_SUSPEND
+static suspend_state_t suspend_state;
+
 static int omap3_pm_prepare(void)
 {
 	disable_hlt();
@@ -342,11 +344,11 @@ restore:
 	return ret;
 }
 
-static int omap3_pm_enter(suspend_state_t state)
+static int omap3_pm_enter(suspend_state_t unused)
 {
 	int ret = 0;
 
-	switch (state) {
+	switch (suspend_state) {
 	case PM_SUSPEND_STANDBY:
 	case PM_SUSPEND_MEM:
 		ret = omap3_pm_suspend();
@@ -363,7 +365,24 @@ static void omap3_pm_finish(void)
 	enable_hlt();
 }
 
+/* Hooks to enable / disable UART interrupts during suspend */
+static int omap3_pm_begin(suspend_state_t state)
+{
+	suspend_state = state;
+	omap_uart_enable_irqs(0);
+	return 0;
+}
+
+static void omap3_pm_end(void)
+{
+	suspend_state = PM_SUSPEND_ON;
+	omap_uart_enable_irqs(1);
+	return;
+}
+
 static struct platform_suspend_ops omap_pm_ops = {
+	.begin		= omap3_pm_begin,
+	.end		= omap3_pm_end,
 	.prepare	= omap3_pm_prepare,
 	.enter		= omap3_pm_enter,
 	.finish		= omap3_pm_finish,
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index c82ec95..5352d05 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -435,6 +435,20 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 	WARN_ON(ret);
 }
 
+void omap_uart_enable_irqs(int enable)
+{
+	int ret;
+	struct omap_uart_state *uart;
+
+	list_for_each_entry(uart, &uart_list, node) {
+		if (enable)
+			ret = request_irq(uart->p->irq, omap_uart_interrupt,
+				IRQF_SHARED, "serial idle", (void *)uart);
+		else
+			free_irq(uart->p->irq, (void *)uart);
+	}
+}
+
 static ssize_t sleep_timeout_show(struct kobject *kobj,
 				  struct kobj_attribute *attr,
 				  char *buf)
diff --git a/arch/arm/plat-omap/include/mach/serial.h b/arch/arm/plat-omap/include/mach/serial.h
index 13abd02..def0529 100644
--- a/arch/arm/plat-omap/include/mach/serial.h
+++ b/arch/arm/plat-omap/include/mach/serial.h
@@ -59,6 +59,7 @@ extern void omap_uart_check_wakeup(void);
 extern void omap_uart_prepare_suspend(void);
 extern void omap_uart_prepare_idle(int num);
 extern void omap_uart_resume_idle(int num);
+extern void omap_uart_enable_irqs(int enable);
 #endif
 
 #endif
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 11/11] OMAP2/3/4: UART: Allow per-UART disabling wakeup for serial ports
  2009-06-25 16:42                   ` [PATCH 10/11] OMAP3: Fixed crash bug with serial + suspend Kevin Hilman
@ 2009-06-25 16:42                     ` Kevin Hilman
  0 siblings, 0 replies; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 16:42 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Russ Dill

This patch causes the OMAP uarts to honor the sysfs power/wakeup file
for IOPAD wakeups. Before the OMAP was always woken up from off mode
on a rs232 signal change.  This patch also creates a different
platform device for each serial port so that the wakeup properties can
be control per port.

By default, IOPAD wakeups are enabled for each UART.  To disable,

  # echo disabled > /sys/devices/platform/serial8250.0/power/wakeup

Where serial8250.0 can be replaced by .1, or .2 to control the other
ports.

Original idea and original patch from Russ Dill <russ.dill@gmail.com>

Cc: Russ Dill <russ.dill@gmail.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/serial.c |  174 ++++++++++++++++++++++++++++--------------
 1 files changed, 116 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 5352d05..6f35a7e 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -54,6 +54,7 @@ struct omap_uart_state {
 
 	struct plat_serial8250_port *p;
 	struct list_head node;
+	struct platform_device pdev;
 
 #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
 	int context_valid;
@@ -68,10 +69,9 @@ struct omap_uart_state {
 #endif
 };
 
-static struct omap_uart_state omap_uart[OMAP_MAX_NR_PORTS];
 static LIST_HEAD(uart_list);
 
-static struct plat_serial8250_port serial_platform_data[] = {
+static struct plat_serial8250_port serial_platform_data0[] = {
 	{
 		.membase	= IO_ADDRESS(OMAP_UART1_BASE),
 		.mapbase	= OMAP_UART1_BASE,
@@ -81,6 +81,12 @@ static struct plat_serial8250_port serial_platform_data[] = {
 		.regshift	= 2,
 		.uartclk	= OMAP24XX_BASE_BAUD * 16,
 	}, {
+		.flags		= 0
+	}
+};
+
+static struct plat_serial8250_port serial_platform_data1[] = {
+	{
 		.membase	= IO_ADDRESS(OMAP_UART2_BASE),
 		.mapbase	= OMAP_UART2_BASE,
 		.irq		= 73,
@@ -89,6 +95,12 @@ static struct plat_serial8250_port serial_platform_data[] = {
 		.regshift	= 2,
 		.uartclk	= OMAP24XX_BASE_BAUD * 16,
 	}, {
+		.flags		= 0
+	}
+};
+
+static struct plat_serial8250_port serial_platform_data2[] = {
+	{
 		.membase	= IO_ADDRESS(OMAP_UART3_BASE),
 		.mapbase	= OMAP_UART3_BASE,
 		.irq		= 74,
@@ -217,6 +229,40 @@ static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
 	clk_disable(uart->fck);
 }
 
+static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
+{
+	/* Set wake-enable bit */
+	if (uart->wk_en && uart->wk_mask) {
+		u32 v = __raw_readl(uart->wk_en);
+		v |= uart->wk_mask;
+		__raw_writel(v, uart->wk_en);
+	}
+
+	/* Ensure IOPAD wake-enables are set */
+	if (cpu_is_omap34xx() && uart->padconf) {
+		u16 v = omap_ctrl_readw(uart->padconf);
+		v |= OMAP3_PADCONF_WAKEUPENABLE0;
+		omap_ctrl_writew(v, uart->padconf);
+	}
+}
+
+static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
+{
+	/* Clear wake-enable bit */
+	if (uart->wk_en && uart->wk_mask) {
+		u32 v = __raw_readl(uart->wk_en);
+		v &= ~uart->wk_mask;
+		__raw_writel(v, uart->wk_en);
+	}
+
+	/* Ensure IOPAD wake-enables are cleared */
+	if (cpu_is_omap34xx() && uart->padconf) {
+		u16 v = omap_ctrl_readw(uart->padconf);
+		v &= ~OMAP3_PADCONF_WAKEUPENABLE0;
+		omap_ctrl_writew(v, uart->padconf);
+	}
+}
+
 static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
 					  int enable)
 {
@@ -246,6 +292,11 @@ static void omap_uart_block_sleep(struct omap_uart_state *uart)
 
 static void omap_uart_allow_sleep(struct omap_uart_state *uart)
 {
+	if (device_may_wakeup(&uart->pdev.dev))
+		omap_uart_enable_wakeup(uart);
+	else
+		omap_uart_disable_wakeup(uart);
+
 	if (!uart->clocked)
 		return;
 
@@ -292,7 +343,6 @@ void omap_uart_resume_idle(int num)
 			/* Check for normal UART wakeup */
 			if (__raw_readl(uart->wk_st) & uart->wk_mask)
 				omap_uart_block_sleep(uart);
-
 			return;
 		}
 	}
@@ -346,16 +396,13 @@ static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static u32 sleep_timeout = DEFAULT_TIMEOUT;
-
 static void omap_uart_idle_init(struct omap_uart_state *uart)
 {
-	u32 v;
 	struct plat_serial8250_port *p = uart->p;
 	int ret;
 
 	uart->can_sleep = 0;
-	uart->timeout = sleep_timeout;
+	uart->timeout = DEFAULT_TIMEOUT;
 	setup_timer(&uart->timer, omap_uart_idle_timer,
 		    (unsigned long) uart);
 	mod_timer(&uart->timer, jiffies + uart->timeout);
@@ -413,22 +460,6 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 		uart->padconf = 0;
 	}
 
-	/* Set wake-enable bit */
-	if (uart->wk_en && uart->wk_mask) {
-		v = __raw_readl(uart->wk_en);
-		v |= uart->wk_mask;
-		__raw_writel(v, uart->wk_en);
-	}
-
-	/* Ensure IOPAD wake-enables are set */
-	if (cpu_is_omap34xx() && uart->padconf) {
-		u16 v;
-
-		v = omap_ctrl_readw(uart->padconf);
-		v |= OMAP3_PADCONF_WAKEUPENABLE0;
-		omap_ctrl_writew(v, uart->padconf);
-	}
-
 	p->flags |= UPF_SHARE_IRQ;
 	ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED,
 			  "serial idle", (void *)uart);
@@ -449,54 +480,81 @@ void omap_uart_enable_irqs(int enable)
 	}
 }
 
-static ssize_t sleep_timeout_show(struct kobject *kobj,
-				  struct kobj_attribute *attr,
+static ssize_t sleep_timeout_show(struct device *dev,
+				  struct device_attribute *attr,
 				  char *buf)
 {
-	return sprintf(buf, "%u\n", sleep_timeout / HZ);
+	struct platform_device *pdev = container_of(dev,
+					struct platform_device, dev);
+	struct omap_uart_state *uart = container_of(pdev,
+					struct omap_uart_state, pdev);
+
+	return sprintf(buf, "%u\n", uart->timeout / HZ);
 }
 
-static ssize_t sleep_timeout_store(struct kobject *kobj,
-				   struct kobj_attribute *attr,
+static ssize_t sleep_timeout_store(struct device *dev,
+				   struct device_attribute *attr,
 				   const char *buf, size_t n)
 {
-	struct omap_uart_state *uart;
+	struct platform_device *pdev = container_of(dev,
+					struct platform_device, dev);
+	struct omap_uart_state *uart = container_of(pdev,
+					struct omap_uart_state, pdev);
 	unsigned int value;
 
 	if (sscanf(buf, "%u", &value) != 1) {
 		printk(KERN_ERR "sleep_timeout_store: Invalid value\n");
 		return -EINVAL;
 	}
-	sleep_timeout = value * HZ;
-	list_for_each_entry(uart, &uart_list, node) {
-		uart->timeout = sleep_timeout;
-		if (uart->timeout)
-			mod_timer(&uart->timer, jiffies + uart->timeout);
-		else
-			/* A zero value means disable timeout feature */
-			omap_uart_block_sleep(uart);
-	}
+
+	uart->timeout = value * HZ;
+	if (uart->timeout)
+		mod_timer(&uart->timer, jiffies + uart->timeout);
+	else
+		/* A zero value means disable timeout feature */
+		omap_uart_block_sleep(uart);
+
 	return n;
 }
 
-static struct kobj_attribute sleep_timeout_attr =
-	__ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store);
-
+DEVICE_ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store);
+#define DEV_CREATE_FILE(dev, attr) WARN_ON(device_create_file(dev, attr))
 #else
 static inline void omap_uart_idle_init(struct omap_uart_state *uart) {}
+#define DEV_CREATE_FILE(dev, attr)
 #endif /* CONFIG_PM */
 
-static struct platform_device serial_device = {
-	.name			= "serial8250",
-	.id			= PLAT8250_DEV_PLATFORM,
-	.dev			= {
-		.platform_data	= serial_platform_data,
+static struct omap_uart_state omap_uart[OMAP_MAX_NR_PORTS] = {
+	{
+		.pdev = {
+			.name			= "serial8250",
+			.id			= PLAT8250_DEV_PLATFORM,
+			.dev			= {
+				.platform_data	= serial_platform_data0,
+			},
+		},
+	}, {
+		.pdev = {
+			.name			= "serial8250",
+			.id			= PLAT8250_DEV_PLATFORM1,
+			.dev			= {
+				.platform_data	= serial_platform_data1,
+			},
+		},
+	}, {
+		.pdev = {
+			.name			= "serial8250",
+			.id			= PLAT8250_DEV_PLATFORM2,
+			.dev			= {
+				.platform_data	= serial_platform_data2,
+			},
+		},
 	},
 };
 
 void __init omap_serial_init(void)
 {
-	int i, err;
+	int i;
 	const struct omap_uart_config *info;
 	char name[16];
 
@@ -512,8 +570,10 @@ void __init omap_serial_init(void)
 		return;
 
 	for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
-		struct plat_serial8250_port *p = serial_platform_data + i;
 		struct omap_uart_state *uart = &omap_uart[i];
+		struct platform_device *pdev = &uart->pdev;
+		struct device *dev = &pdev->dev;
+		struct plat_serial8250_port *p = dev->platform_data;
 
 		if (!(info->enabled_uarts & (1 << i))) {
 			p->membase = NULL;
@@ -549,15 +609,13 @@ void __init omap_serial_init(void)
 		omap_uart_enable_clocks(uart);
 		omap_uart_reset(uart);
 		omap_uart_idle_init(uart);
-	}
-
-	err = platform_device_register(&serial_device);
-
-#ifdef CONFIG_PM
-	if (!err)
-		err = sysfs_create_file(&serial_device.dev.kobj,
-					&sleep_timeout_attr.attr);
-#endif
 
+		if (WARN_ON(platform_device_register(pdev)))
+			continue;
+		if ((cpu_is_omap34xx() && uart->padconf) ||
+		    (uart->wk_en && uart->wk_mask)) {
+			device_init_wakeup(dev, true);
+			DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
+		}
+	}
 }
-
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy
  2009-06-25 16:41 [PATCH 00/11] OMAP fixes from PM branch for .31-rc Kevin Hilman
  2009-06-25 16:41 ` [PATCH 01/11] OMAP: SDRC: Add several new register definitions Kevin Hilman
@ 2009-06-25 17:08 ` Kevin Hilman
  2009-06-25 17:17   ` Kevin Hilman
  1 sibling, 1 reply; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 17:08 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>

Use the min/max settings from CPUfreq policy rather than
processor defined min/max settings.

Without this patch, it's possible to scale frequency outside
the current policy range.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/plat-omap/cpu-omap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index 843e8af..1868c0d 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -78,10 +78,10 @@ static int omap_target(struct cpufreq_policy *policy,
 
 	/* Ensure desired rate is within allowed range.  Some govenors
 	 * (ondemand) will just pass target_freq=0 to get the minimum. */
-	if (target_freq < policy->cpuinfo.min_freq)
-		target_freq = policy->cpuinfo.min_freq;
-	if (target_freq > policy->cpuinfo.max_freq)
-		target_freq = policy->cpuinfo.max_freq;
+	if (target_freq < policy->min)
+		target_freq = policy->min;
+	if (target_freq > policy->max)
+		target_freq = policy->max;
 
 	freqs.old = omap_getspeed(0);
 	freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
-- 
1.6.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy
  2009-06-25 17:08 ` [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy Kevin Hilman
@ 2009-06-25 17:17   ` Kevin Hilman
  0 siblings, 0 replies; 14+ messages in thread
From: Kevin Hilman @ 2009-06-25 17:17 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Eero Nurkkala

yes, this is patch 12 of 11. :)

It's an extra patch that should've been included in the original
series.

Kevin

Kevin Hilman <khilman@deeprootsystems.com> writes:

> From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
>
> Use the min/max settings from CPUfreq policy rather than
> processor defined min/max settings.
>
> Without this patch, it's possible to scale frequency outside
> the current policy range.
>
> Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
> ---
>  arch/arm/plat-omap/cpu-omap.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
> index 843e8af..1868c0d 100644
> --- a/arch/arm/plat-omap/cpu-omap.c
> +++ b/arch/arm/plat-omap/cpu-omap.c
> @@ -78,10 +78,10 @@ static int omap_target(struct cpufreq_policy *policy,
>  
>  	/* Ensure desired rate is within allowed range.  Some govenors
>  	 * (ondemand) will just pass target_freq=0 to get the minimum. */
> -	if (target_freq < policy->cpuinfo.min_freq)
> -		target_freq = policy->cpuinfo.min_freq;
> -	if (target_freq > policy->cpuinfo.max_freq)
> -		target_freq = policy->cpuinfo.max_freq;
> +	if (target_freq < policy->min)
> +		target_freq = policy->min;
> +	if (target_freq > policy->max)
> +		target_freq = policy->max;
>  
>  	freqs.old = omap_getspeed(0);
>  	freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
> -- 
> 1.6.3.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-06-25 17:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-25 16:41 [PATCH 00/11] OMAP fixes from PM branch for .31-rc Kevin Hilman
2009-06-25 16:41 ` [PATCH 01/11] OMAP: SDRC: Add several new register definitions Kevin Hilman
2009-06-25 16:41   ` [PATCH 02/11] OMAP2/3: PM: make PM __init calls static Kevin Hilman
2009-06-25 16:41     ` [PATCH 03/11] OMAP3: PM: CM_REGADDR macros using wrong name Kevin Hilman
2009-06-25 16:41       ` [PATCH 04/11] OMAP3: PM: Ensure PRCM interrupts are cleared at boot Kevin Hilman
2009-06-25 16:41         ` [PATCH 05/11] OMAP3: PM: Clear pending PRCM reset flags on init Kevin Hilman
2009-06-25 16:41           ` [PATCH 06/11] OMAP3: PM: prevent module wakeups from waking IVA2 Kevin Hilman
2009-06-25 16:42             ` [PATCH 07/11] OMAP3: PM: Do not build suspend code if SUSPEND is not enabled Kevin Hilman
2009-06-25 16:42               ` [PATCH 08/11] OMAP3: PM: reset USB OTG module on boot Kevin Hilman
2009-06-25 16:42                 ` [PATCH 09/11] OMAP4: UART: cleanup special case IRQ handling Kevin Hilman
2009-06-25 16:42                   ` [PATCH 10/11] OMAP3: Fixed crash bug with serial + suspend Kevin Hilman
2009-06-25 16:42                     ` [PATCH 11/11] OMAP2/3/4: UART: Allow per-UART disabling wakeup for serial ports Kevin Hilman
2009-06-25 17:08 ` [PATCH 12/11] OMAP: PM: CPUfreq: obey min/max settings of policy Kevin Hilman
2009-06-25 17:17   ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox