From a3f66351b3cc89011e8a34068c245b413ce696d6 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:05 +0000 Subject: [ARM] S3C: Nove from plat-s3c24xx to plat-s3fc Move the header to plat-s3c as preparation for moving parts of the s3c24xx pm support which are common into the plat-s3c support. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 arch/arm/plat-s3c/include/plat/pm.h (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h new file mode 100644 index 00000000000..cc623667e48 --- /dev/null +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -0,0 +1,73 @@ +/* linux/include/asm-arm/plat-s3c24xx/pm.h + * + * Copyright (c) 2004 Simtec Electronics + * Written by Ben Dooks, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +/* s3c2410_pm_init + * + * called from board at initialisation time to setup the power + * management +*/ + +#ifdef CONFIG_PM + +extern __init int s3c2410_pm_init(void); + +#else + +static inline int s3c2410_pm_init(void) +{ + return 0; +} +#endif + +/* configuration for the IRQ mask over sleep */ +extern unsigned long s3c_irqwake_intmask; +extern unsigned long s3c_irqwake_eintmask; + +/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */ +extern unsigned long s3c_irqwake_intallow; +extern unsigned long s3c_irqwake_eintallow; + +/* per-cpu sleep functions */ + +extern void (*pm_cpu_prep)(void); +extern void (*pm_cpu_sleep)(void); + +/* Flags for PM Control */ + +extern unsigned long s3c_pm_flags; + +/* from sleep.S */ + +extern int s3c2410_cpu_save(unsigned long *saveblk); +extern void s3c2410_cpu_suspend(void); +extern void s3c2410_cpu_resume(void); + +extern unsigned long s3c2410_sleep_save_phys; + +/* sleep save info */ + +struct sleep_save { + void __iomem *reg; + unsigned long val; +}; + +#define SAVE_ITEM(x) \ + { .reg = (x) } + +extern void s3c2410_pm_do_save(struct sleep_save *ptr, int count); +extern void s3c2410_pm_do_restore(struct sleep_save *ptr, int count); + +#ifdef CONFIG_PM +extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state); +extern int s3c24xx_irq_resume(struct sys_device *dev); +#else +#define s3c24xx_irq_suspend NULL +#define s3c24xx_irq_resume NULL +#endif -- cgit v1.2.3 From 6419711a164ba1304fa8fbb75ae9485455e04dcd Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:06 +0000 Subject: [ARM] S3C: Move PM support functions to common location Start moving the PM code by moving all the common support functions to a common location in arch/arm/plat-s3c. With the move we rename the functions from s3cxxx_ to s3c_ to fit the new location. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index cc623667e48..a1520997ab8 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -1,6 +1,7 @@ /* linux/include/asm-arm/plat-s3c24xx/pm.h * * Copyright (c) 2004 Simtec Electronics + * http://armlinux.simtec.co.uk/ * Written by Ben Dooks, * * This program is free software; you can redistribute it and/or modify @@ -49,10 +50,18 @@ extern int s3c2410_cpu_save(unsigned long *saveblk); extern void s3c2410_cpu_suspend(void); extern void s3c2410_cpu_resume(void); -extern unsigned long s3c2410_sleep_save_phys; +extern unsigned long s3c_sleep_save_phys; /* sleep save info */ +/** + * struct sleep_save - save information for shared peripherals. + * @reg: Pointer to the register to save. + * @val: Holder for the value saved from reg. + * + * This describes a list of registers which is used by the pm core and + * other subsystem to save and restore register values over suspend. + */ struct sleep_save { void __iomem *reg; unsigned long val; @@ -61,8 +70,11 @@ struct sleep_save { #define SAVE_ITEM(x) \ { .reg = (x) } -extern void s3c2410_pm_do_save(struct sleep_save *ptr, int count); -extern void s3c2410_pm_do_restore(struct sleep_save *ptr, int count); +/* helper functions to save/restore lists of registers. */ + +extern void s3c_pm_do_save(struct sleep_save *ptr, int count); +extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); +extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); #ifdef CONFIG_PM extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state); @@ -71,3 +83,21 @@ extern int s3c24xx_irq_resume(struct sys_device *dev); #define s3c24xx_irq_suspend NULL #define s3c24xx_irq_resume NULL #endif + +/* PM debug functions */ + +#ifdef CONFIG_S3C2410_PM_DEBUG +/** + * s3c_pm_dbg() - low level debug function for use in suspend/resume. + * @msg: The message to print. + * + * This function is used mainly to debug the resume process before the system + * can rely on printk/console output. It uses the low-level debugging output + * routine printascii() to do its work. + */ +extern void s3c_pm_dbg(const char *msg, ...); + +#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) +#else +#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt) +#endif -- cgit v1.2.3 From 549c7e33aeb9bfe441ecf68639d2227bb90978e7 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:07 +0000 Subject: [ARM] S3C: Split the resume memory check code from pm.c Split the optional memory check code out of the pm.c file as it is quite a big #ifdef block and as-such can be moved out and simply compiled when the configuration is set. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index a1520997ab8..95c2612d497 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -101,3 +101,15 @@ extern void s3c_pm_dbg(const char *msg, ...); #else #define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt) #endif + +/* suspend memory checking */ + +#ifdef CONFIG_S3C2410_PM_CHECK +extern void s3c_pm_check_prepare(void); +extern void s3c_pm_check_restore(void); +extern void s3c_pm_check_store(void); +#else +#define s3c_pm_check_prepare() do { } while(0) +#define s3c_pm_check_restore() do { } while(0) +#define s3c_pm_check_store() do { } while(0) +#endif -- cgit v1.2.3 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 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'arch/arm/plat-s3c/include') 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); -- cgit v1.2.3 From 56b34426888d35b3b6367c216bbfb17b82b4f0ac Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:12 +0000 Subject: [ARM] S3C: Make IRQ_EINT sleep control common Move the IRQ_EINT sleep control to be available to all s3c impelmentations. Since s3c_irqext_wake is not large, place it in arch/arm/plat-s3c/pm.c as adding it to a new file would be a waste of compile time. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index 42c75e6d2ba..5e27de955da 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -77,9 +77,11 @@ extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); #ifdef CONFIG_PM +extern int s3c_irqext_wake(unsigned int irqno, unsigned int state); extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state); extern int s3c24xx_irq_resume(struct sys_device *dev); #else +#define s3c_irqext_wake NULL #define s3c24xx_irq_suspend NULL #define s3c24xx_irq_resume NULL #endif -- cgit v1.2.3 From 4e59c25dcbc1f033d043f1009a7f6aaa1f2aef26 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:18 +0000 Subject: [ARM] S3C: Rename s3c2410_pm_init to s3c_pm_init. Since we have moved a large proportion of the PM code to the common support area, remove the cpu specific name from the initialisation function. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index 5e27de955da..a6104c8055f 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -9,7 +9,7 @@ * published by the Free Software Foundation. */ -/* s3c2410_pm_init +/* s3c_pm_init * * called from board at initialisation time to setup the power * management @@ -17,11 +17,11 @@ #ifdef CONFIG_PM -extern __init int s3c2410_pm_init(void); +extern __init int s3c_pm_init(void); #else -static inline int s3c2410_pm_init(void) +static inline int s3c_pm_init(void) { return 0; } -- cgit v1.2.3 From ef30e14420df546bc6576b00f9caf3379b6699d1 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:19 +0000 Subject: [ARM] S3C: Rename sleep.S functions to be non-cpu specific Rename s3c2410_cpu_resume to s3c_cpu_resume and s3c2410_cpu_save to s3c_cpu_save to remove the CPU specific naming of these functions which are now in the generic PM code. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index a6104c8055f..f121a5ac742 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -46,9 +46,10 @@ extern unsigned long s3c_pm_flags; /* from sleep.S */ -extern int s3c2410_cpu_save(unsigned long *saveblk); +extern int s3c_cpu_save(unsigned long *saveblk); +extern void s3c_cpu_resume(void); + extern void s3c2410_cpu_suspend(void); -extern void s3c2410_cpu_resume(void); extern unsigned long s3c_sleep_save_phys; -- cgit v1.2.3 From d2b07fe2a3e35d8e58cceb63ab58831d706da939 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:20 +0000 Subject: [ARM] S3C: Update UART save over PM suspend/resume Change the way the UART state is saved over suspend to allow the s3c64xx code to modify the settings on resume to avoid any illegal state changes to the UART clocks. This will also allow us to save the UDIVSLOT register on newer SoCs. Move to using a structure for the UART use the extant Kconfig configuration specifying the number of UARTs. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index f121a5ac742..c27b8cf5d89 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -71,6 +71,25 @@ struct sleep_save { #define SAVE_ITEM(x) \ { .reg = (x) } +/** + * struct pm_uart_save - save block for core UART + * @ulcon: Save value for S3C2410_ULCON + * @ucon: Save value for S3C2410_UCON + * @ufcon: Save value for S3C2410_UFCON + * @umcon: Save value for S3C2410_UMCON + * @ubrdiv: Save value for S3C2410_UBRDIV + * + * Save block for UART registers to be held over sleep and restored if they + * are needed (say by debug). +*/ +struct pm_uart_save { + u32 ulcon; + u32 ucon; + u32 ufcon; + u32 umcon; + u32 ubrdiv; +}; + /* helper functions to save/restore lists of registers. */ extern void s3c_pm_do_save(struct sleep_save *ptr, int count); -- cgit v1.2.3 From aa8aba6944203a17a7e941b42d8415153c649660 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Fri, 12 Dec 2008 00:24:34 +0000 Subject: [ARM] S3C: Do not kmalloc/kfree during inner suspend code. The PM CRC checking code kmallocs an area to save a set of CRC values during suspend. This triggers a warning due to the call of a function that might sleep whilst the system is not in a valid state to do so. Move the allocation and free to points in the suspend and resume process where they can call a function that might-sleep. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index c27b8cf5d89..5ee26da2702 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -129,10 +129,12 @@ extern void s3c_pm_dbg(const char *msg, ...); #ifdef CONFIG_S3C2410_PM_CHECK extern void s3c_pm_check_prepare(void); extern void s3c_pm_check_restore(void); +extern void s3c_pm_check_cleanup(void); extern void s3c_pm_check_store(void); #else #define s3c_pm_check_prepare() do { } while(0) #define s3c_pm_check_restore() do { } while(0) +#define s3c_pm_check_cleanup() do { } while(0) #define s3c_pm_check_store() do { } while(0) #endif -- cgit v1.2.3 From fff94cd9f5527bbba13aa5ea5719d16531ca8e65 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 10 Mar 2009 11:48:07 +0000 Subject: [ARM] S3C: Tidy sleep code path to fix call flow As noted by Russell King, the sleep code path is not elegant and makes use of leaving items on the stack between calls. Change the code that does the following: if (s3c_cpu_save(regs_save) == 0) { flush_cache_all(); S3C_PMDBG("preparing to sleep\n"); pm_cpu_sleep(); } to simply call s3c_cpu_save, and let that do the necessary calls to quiesce and sleep the system. Signed-off-by: Ben Dooks --- arch/arm/plat-s3c/include/plat/pm.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'arch/arm/plat-s3c/include') diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index 5ee26da2702..3779775133a 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h @@ -162,5 +162,13 @@ extern void s3c_pm_restore_gpios(void); */ extern void s3c_pm_save_gpios(void); +/** + * s3c_pm_cb_flushcache - callback for assembly code + * + * Callback to issue flush_cache_all() as this call is + * not a directly callable object. + */ +extern void s3c_pm_cb_flushcache(void); + extern void s3c_pm_save_core(void); extern void s3c_pm_restore_core(void); -- cgit v1.2.3