From 2261e0e6e3991d4c5f33e9fedadfc465eedc05a7 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:08 +0000 Subject: [ARM] S3C: Move plat-s3c24xx pm.c support into plat-s3c Move parts of the core and debug suspend code into the plat-s3c for use with the new s3c64xx code. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 27 +++++ arch/arm/plat-s3c/pm.c | 211 ++++++++++++++++++++++++++++++++++++ 2 files changed, 238 insertions(+) (limited to 'arch/arm/plat-s3c') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index 95c2612d497..42c75e6d2ba 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -113,3 +113,30 @@ extern void s3c_pm_check_store(void); #define s3c_pm_check_restore() do { } while(0) #define s3c_pm_check_store() do { } while(0) #endif + +/** + * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ + * + * Setup all the necessary GPIO pins for waking the system on external + * interrupt. + */ +extern void s3c_pm_configure_extint(void); + +/** + * s3c_pm_restore_gpios() - restore the state of the gpios after sleep. + * + * Restore the state of the GPIO pins after sleep, which may involve ensuring + * that we do not glitch the state of the pins from that the bootloader's + * resume code has done. +*/ +extern void s3c_pm_restore_gpios(void); + +/** + * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. + * + * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios(). + */ +extern void s3c_pm_save_gpios(void); + +extern void s3c_pm_save_core(void); +extern void s3c_pm_restore_core(void); diff --git a/arch/arm/plat-s3c/pm.c b/arch/arm/plat-s3c/pm.c index 122e9b91a7f..fea58bea973 100644 --- a/arch/arm/plat-s3c/pm.c +++ b/arch/arm/plat-s3c/pm.c @@ -15,14 +15,32 @@ #include #include #include +#include +#include #include +#include +#include + +#include +#include +#include +#include +#include + #include +#include /* for external use */ unsigned long s3c_pm_flags; +/* Debug code: + * + * This code supports debug output to the low level UARTs for use on + * resume before the console layer is available. +*/ + #ifdef CONFIG_S3C2410_PM_DEBUG extern void printascii(const char *); @@ -37,8 +55,51 @@ void s3c_pm_dbg(const char *fmt, ...) printascii(buff); } + +static inline void s3c_pm_debug_init(void) +{ + /* restart uart clocks so we can use them to output */ + s3c_pm_debug_init_uart(); +} + +#else +#define s3c_pm_debug_init() do { } while(0) + #endif /* CONFIG_S3C2410_PM_DEBUG */ +/* Save the UART configurations if we are configured for debug. */ + +#ifdef CONFIG_S3C2410_PM_DEBUG + +#define SAVE_UART(va) \ + SAVE_ITEM((va) + S3C2410_ULCON), \ + SAVE_ITEM((va) + S3C2410_UCON), \ + SAVE_ITEM((va) + S3C2410_UFCON), \ + SAVE_ITEM((va) + S3C2410_UMCON), \ + SAVE_ITEM((va) + S3C2410_UBRDIV) + +static struct sleep_save uart_save[] = { + SAVE_UART(S3C_VA_UART0), + SAVE_UART(S3C_VA_UART1), +#ifndef CONFIG_CPU_S3C2400 + SAVE_UART(S3C_VA_UART2), +#endif +}; + +static void s3c_pm_save_uart(void) +{ + s3c_pm_do_save(uart_save, ARRAY_SIZE(uart_save)); +} + +static void s3c_pm_restore_uart(void) +{ + s3c_pm_do_restore(uart_save, ARRAY_SIZE(uart_save)); +} +#else +static void s3c_pm_save_uart(void) { } +static void s3c_pm_restore_uart(void) { } +#endif + /* helper functions to save and restore register state */ @@ -95,3 +156,153 @@ void s3c_pm_do_restore_core(struct sleep_save *ptr, int count) for (; count > 0; count--, ptr++) __raw_writel(ptr->val, ptr->reg); } + +/* s3c2410_pm_show_resume_irqs + * + * print any IRQs asserted at resume time (ie, we woke from) +*/ +static void s3c_pm_show_resume_irqs(int start, unsigned long which, + unsigned long mask) +{ + int i; + + which &= ~mask; + + for (i = 0; i <= 31; i++) { + if (which & (1L<