Ben Dooks | c116c1d | 2010-01-29 09:02:12 +0000 | [diff] [blame] | 1 | /* arch/arm/plat-samsung/include/plat/pm.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (c) 2004 Simtec Electronics |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 4 | * http://armlinux.simtec.co.uk/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Written by Ben Dooks, <ben@simtec.co.uk> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 12 | /* s3c_pm_init |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
| 14 | * called from board at initialisation time to setup the power |
| 15 | * management |
| 16 | */ |
| 17 | |
Mark Brown | f5aeffb | 2010-12-02 14:35:38 +0900 | [diff] [blame] | 18 | #include <linux/irq.h> |
| 19 | |
Mark Brown | a09e2b2 | 2011-02-07 10:51:04 +0900 | [diff] [blame] | 20 | struct sys_device; |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #ifdef CONFIG_PM |
| 23 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 24 | extern __init int s3c_pm_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #else |
| 27 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 28 | static inline int s3c_pm_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
| 30 | return 0; |
| 31 | } |
| 32 | #endif |
| 33 | |
| 34 | /* configuration for the IRQ mask over sleep */ |
| 35 | extern unsigned long s3c_irqwake_intmask; |
| 36 | extern unsigned long s3c_irqwake_eintmask; |
| 37 | |
| 38 | /* IRQ masks for IRQs allowed to go to sleep (see irq.c) */ |
| 39 | extern unsigned long s3c_irqwake_intallow; |
| 40 | extern unsigned long s3c_irqwake_eintallow; |
| 41 | |
Ben Dooks | 0033a2f | 2006-09-19 09:51:32 +0100 | [diff] [blame] | 42 | /* per-cpu sleep functions */ |
| 43 | |
| 44 | extern void (*pm_cpu_prep)(void); |
| 45 | extern void (*pm_cpu_sleep)(void); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* Flags for PM Control */ |
| 48 | |
| 49 | extern unsigned long s3c_pm_flags; |
| 50 | |
Ben Dooks | 4b637dc | 2008-12-12 00:24:24 +0000 | [diff] [blame] | 51 | extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */ |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* from sleep.S */ |
| 54 | |
Russell King | 2e2f3d3 | 2011-02-06 17:39:31 +0000 | [diff] [blame] | 55 | extern int s3c_cpu_save(unsigned long *saveblk, long); |
Ben Dooks | ef30e14 | 2008-12-12 00:24:19 +0000 | [diff] [blame] | 56 | extern void s3c_cpu_resume(void); |
| 57 | |
Ben Dooks | 58095d7 | 2006-09-16 00:04:23 +0100 | [diff] [blame] | 58 | extern void s3c2410_cpu_suspend(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | /* sleep save info */ |
| 61 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 62 | /** |
| 63 | * struct sleep_save - save information for shared peripherals. |
| 64 | * @reg: Pointer to the register to save. |
| 65 | * @val: Holder for the value saved from reg. |
| 66 | * |
| 67 | * This describes a list of registers which is used by the pm core and |
| 68 | * other subsystem to save and restore register values over suspend. |
| 69 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | struct sleep_save { |
| 71 | void __iomem *reg; |
| 72 | unsigned long val; |
| 73 | }; |
| 74 | |
| 75 | #define SAVE_ITEM(x) \ |
| 76 | { .reg = (x) } |
| 77 | |
Ben Dooks | d2b07fe | 2008-12-12 00:24:20 +0000 | [diff] [blame] | 78 | /** |
| 79 | * struct pm_uart_save - save block for core UART |
| 80 | * @ulcon: Save value for S3C2410_ULCON |
| 81 | * @ucon: Save value for S3C2410_UCON |
| 82 | * @ufcon: Save value for S3C2410_UFCON |
| 83 | * @umcon: Save value for S3C2410_UMCON |
| 84 | * @ubrdiv: Save value for S3C2410_UBRDIV |
| 85 | * |
| 86 | * Save block for UART registers to be held over sleep and restored if they |
| 87 | * are needed (say by debug). |
| 88 | */ |
| 89 | struct pm_uart_save { |
| 90 | u32 ulcon; |
| 91 | u32 ucon; |
| 92 | u32 ufcon; |
| 93 | u32 umcon; |
| 94 | u32 ubrdiv; |
Ben Dooks | 4b637dc | 2008-12-12 00:24:24 +0000 | [diff] [blame] | 95 | u32 udivslot; |
Ben Dooks | d2b07fe | 2008-12-12 00:24:20 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 98 | /* helper functions to save/restore lists of registers. */ |
| 99 | |
| 100 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); |
| 101 | extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); |
| 102 | extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); |
Ben Dooks | 1e582fc | 2006-09-16 00:01:39 +0100 | [diff] [blame] | 103 | |
| 104 | #ifdef CONFIG_PM |
Mark Brown | f5aeffb | 2010-12-02 14:35:38 +0900 | [diff] [blame] | 105 | extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame^] | 106 | extern int s3c24xx_irq_suspend(void); |
| 107 | extern void s3c24xx_irq_resume(void); |
Ben Dooks | 1e582fc | 2006-09-16 00:01:39 +0100 | [diff] [blame] | 108 | #else |
Ben Dooks | 56b3442 | 2008-12-12 00:24:12 +0000 | [diff] [blame] | 109 | #define s3c_irqext_wake NULL |
Ben Dooks | 1e582fc | 2006-09-16 00:01:39 +0100 | [diff] [blame] | 110 | #define s3c24xx_irq_suspend NULL |
| 111 | #define s3c24xx_irq_resume NULL |
| 112 | #endif |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 113 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame^] | 114 | extern struct syscore_ops s3c24xx_irq_syscore_ops; |
| 115 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 116 | /* PM debug functions */ |
| 117 | |
Ben Dooks | 8005745 | 2010-01-20 12:29:25 +0900 | [diff] [blame] | 118 | #ifdef CONFIG_SAMSUNG_PM_DEBUG |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 119 | /** |
| 120 | * s3c_pm_dbg() - low level debug function for use in suspend/resume. |
| 121 | * @msg: The message to print. |
| 122 | * |
| 123 | * This function is used mainly to debug the resume process before the system |
| 124 | * can rely on printk/console output. It uses the low-level debugging output |
| 125 | * routine printascii() to do its work. |
| 126 | */ |
| 127 | extern void s3c_pm_dbg(const char *msg, ...); |
| 128 | |
| 129 | #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) |
| 130 | #else |
| 131 | #define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt) |
| 132 | #endif |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 133 | |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 134 | #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK |
| 135 | /** |
| 136 | * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs |
| 137 | * @set: set bits for the state of the LEDs |
| 138 | * @clear: clear bits for the state of the LEDs. |
| 139 | */ |
| 140 | extern void s3c_pm_debug_smdkled(u32 set, u32 clear); |
| 141 | |
| 142 | #else |
| 143 | static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { } |
| 144 | #endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */ |
| 145 | |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 146 | /* suspend memory checking */ |
| 147 | |
Ben Dooks | 8005745 | 2010-01-20 12:29:25 +0900 | [diff] [blame] | 148 | #ifdef CONFIG_SAMSUNG_PM_CHECK |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 149 | extern void s3c_pm_check_prepare(void); |
| 150 | extern void s3c_pm_check_restore(void); |
Ben Dooks | aa8aba6 | 2008-12-12 00:24:34 +0000 | [diff] [blame] | 151 | extern void s3c_pm_check_cleanup(void); |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 152 | extern void s3c_pm_check_store(void); |
| 153 | #else |
| 154 | #define s3c_pm_check_prepare() do { } while(0) |
| 155 | #define s3c_pm_check_restore() do { } while(0) |
Ben Dooks | aa8aba6 | 2008-12-12 00:24:34 +0000 | [diff] [blame] | 156 | #define s3c_pm_check_cleanup() do { } while(0) |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 157 | #define s3c_pm_check_store() do { } while(0) |
| 158 | #endif |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ |
| 162 | * |
| 163 | * Setup all the necessary GPIO pins for waking the system on external |
| 164 | * interrupt. |
| 165 | */ |
| 166 | extern void s3c_pm_configure_extint(void); |
| 167 | |
| 168 | /** |
| 169 | * s3c_pm_restore_gpios() - restore the state of the gpios after sleep. |
| 170 | * |
| 171 | * Restore the state of the GPIO pins after sleep, which may involve ensuring |
| 172 | * that we do not glitch the state of the pins from that the bootloader's |
| 173 | * resume code has done. |
| 174 | */ |
| 175 | extern void s3c_pm_restore_gpios(void); |
| 176 | |
| 177 | /** |
| 178 | * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. |
| 179 | * |
| 180 | * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios(). |
| 181 | */ |
| 182 | extern void s3c_pm_save_gpios(void); |
| 183 | |
| 184 | extern void s3c_pm_save_core(void); |
| 185 | extern void s3c_pm_restore_core(void); |