[PATCH 2/2] KJH: use CPU PM for UART
Kevin Hilman
khilman at ti.com
Wed Jun 15 19:23:29 EDT 2011
---
arch/arm/mach-omap2/pm24xx.c | 8 -------
arch/arm/mach-omap2/pm34xx.c | 8 -------
arch/arm/mach-omap2/serial.c | 33 ++++++++++++++++++++++++++++-
arch/arm/plat-omap/include/plat/serial.h | 2 -
4 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 9f7e551..e66c412 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -139,10 +139,6 @@ static void omap2_enter_full_retention(void)
if (!console_trylock())
goto no_sleep;
- omap_uart_prepare_idle(0);
- omap_uart_prepare_idle(1);
- omap_uart_prepare_idle(2);
-
cpu_pm_enter();
/* Jump to SRAM suspend code */
@@ -152,10 +148,6 @@ static void omap2_enter_full_retention(void)
cpu_pm_exit();
- omap_uart_resume_idle(2);
- omap_uart_resume_idle(1);
- omap_uart_resume_idle(0);
-
if (!is_suspending())
console_unlock();
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index b167c7f..04f7075 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -392,8 +392,6 @@ void omap_sram_idle(void)
/* PER */
if (per_next_state < PWRDM_POWER_ON) {
per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
- omap_uart_prepare_idle(2);
- omap_uart_prepare_idle(3);
omap2_gpio_prepare_for_idle(per_going_off);
if (per_next_state == PWRDM_POWER_OFF)
omap3_per_save_context();
@@ -401,8 +399,6 @@ void omap_sram_idle(void)
/* CORE */
if (core_next_state < PWRDM_POWER_ON) {
- omap_uart_prepare_idle(0);
- omap_uart_prepare_idle(1);
if (core_next_state == PWRDM_POWER_OFF) {
omap3_core_save_context();
omap3_cm_save_context();
@@ -449,8 +445,6 @@ void omap_sram_idle(void)
omap3_sram_restore_context();
omap2_sms_restore_context();
}
- omap_uart_resume_idle(0);
- omap_uart_resume_idle(1);
if (core_next_state == PWRDM_POWER_OFF)
omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
OMAP3430_GR_MOD,
@@ -464,8 +458,6 @@ void omap_sram_idle(void)
omap2_gpio_resume_after_idle();
if (per_prev_state == PWRDM_POWER_OFF)
omap3_per_restore_context();
- omap_uart_resume_idle(2);
- omap_uart_resume_idle(3);
}
cpu_pm_exit();
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 466fc722..1961484 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -28,6 +28,7 @@
#include <linux/serial_8250.h>
#include <linux/pm_runtime.h>
#include <linux/console.h>
+#include <linux/cpu_pm.h>
#ifdef CONFIG_SERIAL_OMAP
#include <plat/omap-serial.h>
@@ -102,6 +103,8 @@ struct omap_uart_state {
u16 wer;
u16 mcr;
#endif
+
+ struct notifier_block nb;
};
static LIST_HEAD(uart_list);
@@ -389,7 +392,7 @@ static void omap_uart_idle_timer(unsigned long data)
omap_uart_allow_sleep(uart);
}
-void omap_uart_prepare_idle(int num)
+static void omap_uart_prepare_idle(int num)
{
struct omap_uart_state *uart;
@@ -401,7 +404,7 @@ void omap_uart_prepare_idle(int num)
}
}
-void omap_uart_resume_idle(int num)
+static void omap_uart_resume_idle(int num)
{
struct omap_uart_state *uart;
@@ -855,6 +858,30 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
uart->errata |= UART_ERRATA_i202_MDR1_ACCESS;
}
+
+static int uart_notifier_call(struct notifier_block *nb,
+ unsigned long val, void *p)
+{
+ struct omap_uart_state *uart =
+ container_of(nb, struct omap_uart_state, nb);
+
+ switch (val) {
+ case CPU_PM_ENTER:
+ case CPU_CLUSTER_PM_ENTER:
+ omap_uart_prepare_idle(uart->num);
+ break;
+ case CPU_PM_EXIT:
+ case CPU_CLUSTER_PM_EXIT:
+ omap_uart_resume_idle(uart->num);
+ break;
+ default:
+ WARN(1,"%s: un-handled notifier value: 0x%lx\n", __func__, val);
+ break;
+ }
+
+ return 0;
+}
+
/**
* omap_serial_init() - initialize all supported serial ports
*
@@ -874,5 +901,7 @@ void __init omap_serial_init(void)
bdata.pads_cnt = 0;
omap_serial_init_port(&bdata);
+ uart->nb.notifier_call = uart_notifier_call;
+ cpu_pm_register_notifier(&uart->nb);
}
}
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index de3b10c..0e78f6d 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -112,8 +112,6 @@ extern void omap_serial_init_port(struct omap_board_data *bdata);
extern int omap_uart_can_sleep(void);
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
--
1.7.6
More information about the linux-arm-kernel
mailing list