* [PATCH 0/3] OMAP PM core updates for 2.6.35
@ 2010-05-03 21:41 Kevin Hilman
2010-05-03 21:41 ` [PATCH 1/3] OMAP3: Serial: Improved sleep logic Kevin Hilman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kevin Hilman @ 2010-05-03 21:41 UTC (permalink / raw)
To: linux-arm-kernel
A small series of OMAP PM core updates for 2.6.35.
Series based on Tony's omap-fixes branch and also availailable here:
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git pm-next
Kevin
Ari Kauppi (1):
OMAP3: PM: Add milliseconds interface to suspend wakeup timer
Kevin Hilman (1):
OMAP3: PRCM interrupt: only check and clear enabled PRCM IRQs
Tero Kristo (1):
OMAP3: Serial: Improved sleep logic
arch/arm/mach-omap2/pm-debug.c | 3 ++
arch/arm/mach-omap2/pm.h | 1 +
arch/arm/mach-omap2/pm34xx.c | 34 ++++++++++++-------
arch/arm/mach-omap2/serial.c | 71 ++++++++++++++++++++++++++++++++++------
4 files changed, 87 insertions(+), 22 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] OMAP3: Serial: Improved sleep logic
2010-05-03 21:41 [PATCH 0/3] OMAP PM core updates for 2.6.35 Kevin Hilman
@ 2010-05-03 21:41 ` Kevin Hilman
2010-05-03 21:41 ` [PATCH 2/3] OMAP3: PRCM interrupt: only check and clear enabled PRCM IRQs Kevin Hilman
2010-05-03 21:41 ` [PATCH 3/3] OMAP3: PM: Add milliseconds interface to suspend wakeup timer Kevin Hilman
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2010-05-03 21:41 UTC (permalink / raw)
To: linux-arm-kernel
From: Tero Kristo <tero.kristo@nokia.com>
This patch contains following improvements:
- Only RX interrupt will now kick the sleep prevent timer
- TX fifo status is checked before disabling clocks, this will prevent
on-going transmission to be cut
- Smartidle is now enabled/disabled only while switching clocks, as having
smartidle enabled while RX/TX prevents any wakeups from being received
from UART module
- Added workqueue for wakeup checks, as jiffy timer access within the
idle loop results into skewed timers as jiffy timers are stopped
- Added garbage_timer for ignoring the first character received during
the first tick after clock enable, this prevents garbage characters to be
received in low sleep states
- omap_uart_enable_irqs() changed to use enable_irq / disable_irq instead
of request / free. Using request/free changes the behavior after first
suspend due to reversed interrupt handler ordering
Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/serial.c | 71 ++++++++++++++++++++++++++++++++++++------
1 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3771254..b709cf8 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -24,6 +24,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/delay.h>
+#include <linux/workqueue.h>
#include <plat/common.h>
#include <plat/board.h>
@@ -49,7 +50,10 @@ struct omap_uart_state {
int num;
int can_sleep;
struct timer_list timer;
+ struct timer_list garbage_timer;
+ struct work_struct wakeup_work;
u32 timeout;
+ u8 garbage_ignore;
void __iomem *wk_st;
void __iomem *wk_en;
@@ -239,6 +243,11 @@ static inline void omap_uart_save_context(struct omap_uart_state *uart) {}
static inline void omap_uart_restore_context(struct omap_uart_state *uart) {}
#endif /* CONFIG_PM && CONFIG_ARCH_OMAP3 */
+#ifdef CONFIG_PM
+static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
+ int enable);
+#endif
+
static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
{
if (uart->clocked)
@@ -248,6 +257,9 @@ static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
clk_enable(uart->fck);
uart->clocked = 1;
omap_uart_restore_context(uart);
+#ifdef CONFIG_PM
+ omap_uart_smart_idle_enable(uart, 0);
+#endif
}
#ifdef CONFIG_PM
@@ -259,8 +271,13 @@ static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
omap_uart_save_context(uart);
uart->clocked = 0;
+ omap_uart_smart_idle_enable(uart, 1);
clk_disable(uart->ick);
clk_disable(uart->fck);
+ if (uart->garbage_ignore) {
+ del_timer(&uart->garbage_timer);
+ uart->garbage_ignore = 0;
+ }
}
static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
@@ -316,7 +333,6 @@ static void omap_uart_block_sleep(struct omap_uart_state *uart)
{
omap_uart_enable_clocks(uart);
- omap_uart_smart_idle_enable(uart, 0);
uart->can_sleep = 0;
if (uart->timeout)
mod_timer(&uart->timer, jiffies + uart->timeout);
@@ -334,7 +350,6 @@ static void omap_uart_allow_sleep(struct omap_uart_state *uart)
if (!uart->clocked)
return;
- omap_uart_smart_idle_enable(uart, 1);
uart->can_sleep = 1;
del_timer(&uart->timer);
}
@@ -346,18 +361,46 @@ static void omap_uart_idle_timer(unsigned long data)
omap_uart_allow_sleep(uart);
}
+static void omap_uart_garbage_timer(unsigned long data)
+{
+ struct omap_uart_state *uart = (struct omap_uart_state *)data;
+
+ uart->garbage_ignore = 0;
+}
+
+static void omap_uart_wakeup_work(struct work_struct *work)
+{
+ struct omap_uart_state *uart =
+ container_of(work, struct omap_uart_state, wakeup_work);
+
+ omap_uart_block_sleep(uart);
+
+ /* Set up garbage timer to ignore RX during first jiffy */
+ if (uart->timeout)
+ mod_timer(&uart->garbage_timer, jiffies + 1);
+}
+
void omap_uart_prepare_idle(int num)
{
struct omap_uart_state *uart;
list_for_each_entry(uart, &uart_list, node) {
if (num == uart->num && uart->can_sleep) {
- omap_uart_disable_clocks(uart);
+ if (serial_read_reg(uart->p, UART_LSR) &
+ UART_LSR_TEMT)
+ omap_uart_disable_clocks(uart);
return;
}
}
}
+static void serial_wakeup(struct omap_uart_state *uart)
+{
+ if (uart->timeout)
+ uart->garbage_ignore = 1;
+ schedule_work(&uart->wakeup_work);
+}
+
void omap_uart_resume_idle(int num)
{
struct omap_uart_state *uart;
@@ -371,12 +414,12 @@ void omap_uart_resume_idle(int num)
u16 p = omap_ctrl_readw(uart->padconf);
if (p & OMAP3_PADCONF_WAKEUPEVENT0)
- omap_uart_block_sleep(uart);
+ serial_wakeup(uart);
}
/* Check for normal UART wakeup */
if (__raw_readl(uart->wk_st) & uart->wk_mask)
- omap_uart_block_sleep(uart);
+ serial_wakeup(uart);
return;
}
}
@@ -425,7 +468,14 @@ static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
{
struct omap_uart_state *uart = dev_id;
- omap_uart_block_sleep(uart);
+ /* Check for receive interrupt */
+ while (serial_read_reg(uart->p, UART_LSR) & UART_LSR_DR) {
+ omap_uart_block_sleep(uart);
+ if (uart->garbage_ignore)
+ serial_read_reg(uart->p, UART_RX);
+ else
+ break;
+ }
return IRQ_NONE;
}
@@ -439,6 +489,9 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
uart->timeout = DEFAULT_TIMEOUT;
setup_timer(&uart->timer, omap_uart_idle_timer,
(unsigned long) uart);
+ setup_timer(&uart->garbage_timer, omap_uart_garbage_timer,
+ (unsigned long) uart);
+ INIT_WORK(&uart->wakeup_work, omap_uart_wakeup_work);
if (uart->timeout)
mod_timer(&uart->timer, jiffies + uart->timeout);
omap_uart_smart_idle_enable(uart, 0);
@@ -503,15 +556,13 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
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);
+ enable_irq(uart->p->irq);
else
- free_irq(uart->p->irq, (void *)uart);
+ disable_irq(uart->p->irq);
}
}
--
1.7.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] OMAP3: PRCM interrupt: only check and clear enabled PRCM IRQs
2010-05-03 21:41 [PATCH 0/3] OMAP PM core updates for 2.6.35 Kevin Hilman
2010-05-03 21:41 ` [PATCH 1/3] OMAP3: Serial: Improved sleep logic Kevin Hilman
@ 2010-05-03 21:41 ` Kevin Hilman
2010-05-03 21:41 ` [PATCH 3/3] OMAP3: PM: Add milliseconds interface to suspend wakeup timer Kevin Hilman
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2010-05-03 21:41 UTC (permalink / raw)
To: linux-arm-kernel
While handling PRCM IRQs, mask out interrupts that are not enabled in
PRM_IRQENABLE_MPU. If these are not masked out, non-enabled
interrupts are caught, a WARN() is printed due to no 'handler' and the
events are cleared. In addition to being noisy, this can also
interfere with independent polling of this register by SR/VP code.
This was noticed using SmartReflex transitions which cause the VPx_*
interrupts to be handled since they are set in PRM_IRQSTATUS_MPU even
but not enabled in PRM_IRQENABLE_MPU.
Acked-by: Mike Turquette <mturquette@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/pm34xx.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index fee2efb..c38016b 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -266,13 +266,16 @@ static int _prcm_int_handle_wakeup(void)
*/
static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
{
- u32 irqstatus_mpu;
+ u32 irqenable_mpu, irqstatus_mpu;
int c = 0;
- do {
- irqstatus_mpu = prm_read_mod_reg(OCP_MOD,
- OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
+ irqenable_mpu = prm_read_mod_reg(OCP_MOD,
+ OMAP3_PRM_IRQENABLE_MPU_OFFSET);
+ irqstatus_mpu = prm_read_mod_reg(OCP_MOD,
+ OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
+ irqstatus_mpu &= irqenable_mpu;
+ do {
if (irqstatus_mpu & (OMAP3430_WKUP_ST | OMAP3430_IO_ST)) {
c = _prcm_int_handle_wakeup();
@@ -291,7 +294,11 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id)
prm_write_mod_reg(irqstatus_mpu, OCP_MOD,
OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
- } while (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET));
+ irqstatus_mpu = prm_read_mod_reg(OCP_MOD,
+ OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
+ irqstatus_mpu &= irqenable_mpu;
+
+ } while (irqstatus_mpu);
return IRQ_HANDLED;
}
--
1.7.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] OMAP3: PM: Add milliseconds interface to suspend wakeup timer
2010-05-03 21:41 [PATCH 0/3] OMAP PM core updates for 2.6.35 Kevin Hilman
2010-05-03 21:41 ` [PATCH 1/3] OMAP3: Serial: Improved sleep logic Kevin Hilman
2010-05-03 21:41 ` [PATCH 2/3] OMAP3: PRCM interrupt: only check and clear enabled PRCM IRQs Kevin Hilman
@ 2010-05-03 21:41 ` Kevin Hilman
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2010-05-03 21:41 UTC (permalink / raw)
To: linux-arm-kernel
From: Ari Kauppi <Ext-Ari.Kauppi@nokia.com>
Millisecond resolution is possible and there are use cases for it
(automatic testing).
Seconds-based interface is preserved for compatibility.
Signed-off-by: Ari Kauppi <Ext-Ari.Kauppi@nokia.com>
Reviewed-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
arch/arm/mach-omap2/pm-debug.c | 3 +++
arch/arm/mach-omap2/pm.h | 1 +
arch/arm/mach-omap2/pm34xx.c | 17 ++++++++++-------
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index c18f7f2..a895468 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -547,6 +547,9 @@ static int option_set(void *data, u64 val)
{
u32 *option = data;
+ if (option == &wakeup_timer_milliseconds && val >= 1000)
+ return -EINVAL;
+
*option = val;
if (option == &enable_off_mode)
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index bd6466a..3de6ece 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -43,6 +43,7 @@ extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
extern u32 wakeup_timer_seconds;
+extern u32 wakeup_timer_milliseconds;
extern struct omap_dm_timer *gptimer_wakeup;
#ifdef CONFIG_PM_DEBUG
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index c38016b..ea13d3a 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -57,6 +57,7 @@
u32 enable_off_mode;
u32 sleep_while_idle;
u32 wakeup_timer_seconds;
+u32 wakeup_timer_milliseconds;
struct power_state {
struct powerdomain *pwrdm;
@@ -554,20 +555,21 @@ out:
#ifdef CONFIG_SUSPEND
static suspend_state_t suspend_state;
-static void omap2_pm_wakeup_on_timer(u32 seconds)
+static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
{
u32 tick_rate, cycles;
- if (!seconds)
+ if (!seconds && !milliseconds)
return;
tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
- cycles = tick_rate * seconds;
+ cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
omap_dm_timer_stop(gptimer_wakeup);
omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
- pr_info("PM: Resume timer in %d secs (%d ticks at %d ticks/sec.)\n",
- seconds, cycles, tick_rate);
+ pr_info("PM: Resume timer in %u.%03u secs"
+ " (%d ticks at %d ticks/sec.)\n",
+ seconds, milliseconds, cycles, tick_rate);
}
static int omap3_pm_prepare(void)
@@ -581,8 +583,9 @@ static int omap3_pm_suspend(void)
struct power_state *pwrst;
int state, ret = 0;
- if (wakeup_timer_seconds)
- omap2_pm_wakeup_on_timer(wakeup_timer_seconds);
+ if (wakeup_timer_seconds || wakeup_timer_milliseconds)
+ omap2_pm_wakeup_on_timer(wakeup_timer_seconds,
+ wakeup_timer_milliseconds);
/* Read current next_pwrsts */
list_for_each_entry(pwrst, &pwrst_list, node)
--
1.7.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-03 21:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03 21:41 [PATCH 0/3] OMAP PM core updates for 2.6.35 Kevin Hilman
2010-05-03 21:41 ` [PATCH 1/3] OMAP3: Serial: Improved sleep logic Kevin Hilman
2010-05-03 21:41 ` [PATCH 2/3] OMAP3: PRCM interrupt: only check and clear enabled PRCM IRQs Kevin Hilman
2010-05-03 21:41 ` [PATCH 3/3] OMAP3: PM: Add milliseconds interface to suspend wakeup timer Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).