From 52d23bb47644c1a48d10d552066ac86885137e8a Mon Sep 17 00:00:00 2001
From: Tero Kristo <t-kristo@ti.com>
Date: Thu, 16 Jun 2011 15:21:14 +0300
Subject: [PATCH 2/2] OMAP: serial: use chained interrupt handler for IO pad wakeup
Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
arch/arm/mach-omap2/serial.c | 31 +++++++++++--------------------
drivers/tty/serial/omap-serial.c | 6 ++++++
2 files changed, 17 insertions(+), 20 deletions(-)
@@ -39,6 +39,7 @@
#include <plat/dma.h>
#include <plat/omap_hwmod.h>
#include <plat/omap_device.h>
+#include <plat/prcm.h>
#include "prm2xxx_3xxx.h"
#include "pm.h"
@@ -386,6 +387,7 @@ static void omap_uart_allow_sleep(struct omap_uart_state *uart)
omap_uart_smart_idle_enable(uart, 1);
uart->can_sleep = 1;
del_timer(&uart->timer);
+ omap_uart_disable_clocks(uart);
}
static void omap_uart_idle_timer(unsigned long data)
@@ -397,36 +399,23 @@ static void omap_uart_idle_timer(unsigned long data)
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);
- return;
- }
- }
}
void omap_uart_resume_idle(int num)
{
struct omap_uart_state *uart;
+ u32 wkst;
list_for_each_entry(uart, &uart_list, node) {
if (num == uart->num && uart->can_sleep) {
- omap_uart_enable_clocks(uart);
-
- /* Check for IO pad wakeup */
- if (cpu_is_omap34xx() && uart->padconf) {
- u16 p = omap_ctrl_readw(uart->padconf);
+ omap_uart_block_sleep(uart);
- if (p & OMAP3_PADCONF_WAKEUPEVENT0)
- omap_uart_block_sleep(uart);
+ /* Check for normal UART wakeup (and clear it) */
+ if (uart->wk_st && uart->wk_mask) {
+ wkst = __raw_readl(uart->wk_st) & uart->wk_mask;
+ if (wkst)
+ __raw_writel(wkst, uart->wk_st);
}
-
- /* Check for normal UART wakeup */
- if (uart->wk_st && uart->wk_mask)
- if (__raw_readl(uart->wk_st) & uart->wk_mask)
- omap_uart_block_sleep(uart);
return;
}
}
@@ -574,6 +563,8 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
ret = request_threaded_irq(uart->irq, NULL, omap_uart_interrupt,
IRQF_SHARED, "serial idle", (void *)uart);
WARN_ON(ret);
+ ret = omap_prcm_register_pad_irq(uart->padconf, uart->irq);
+ WARN_ON(ret);
}
void omap_uart_enable_irqs(int enable)
@@ -261,6 +261,8 @@ static void serial_omap_start_tx(struct uart_port *port)
unsigned int start;
int ret = 0;
+ omap_uart_resume_idle(up->pdev->id);
+
if (!up->use_dma) {
serial_omap_enable_ier_thri(up);
return;
@@ -354,6 +356,8 @@ static inline irqreturn_t serial_omap_irq(int irq, void *dev_id)
unsigned int iir, lsr;
unsigned long flags;
+ omap_uart_resume_idle(up->pdev->id);
+
iir = serial_in(up, UART_IIR);
if (iir & UART_IIR_NO_INT)
return IRQ_NONE;
@@ -947,6 +951,8 @@ serial_omap_console_write(struct console *co, const char *s,
unsigned int ier;
int locked = 1;
+ omap_uart_resume_idle(up->pdev->id);
+
local_irq_save(flags);
if (up->port.sysrq)
locked = 0;
--
1.7.4.1