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 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 20 | struct device; |
Mark Brown | a09e2b2 | 2011-02-07 10:51:04 +0900 | [diff] [blame] | 21 | |
Amit Daniel Kachhap | 8969301 | 2013-07-24 14:06:13 +0900 | [diff] [blame] | 22 | #ifdef CONFIG_SAMSUNG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 24 | extern __init int s3c_pm_init(void); |
Mark Brown | c656c30 | 2011-12-08 23:27:48 +0100 | [diff] [blame] | 25 | extern __init int s3c64xx_pm_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #else |
| 28 | |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 29 | static inline int s3c_pm_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
| 31 | return 0; |
| 32 | } |
Mark Brown | c656c30 | 2011-12-08 23:27:48 +0100 | [diff] [blame] | 33 | |
| 34 | static inline int s3c64xx_pm_init(void) |
| 35 | { |
| 36 | return 0; |
| 37 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #endif |
| 39 | |
| 40 | /* configuration for the IRQ mask over sleep */ |
| 41 | extern unsigned long s3c_irqwake_intmask; |
| 42 | extern unsigned long s3c_irqwake_eintmask; |
| 43 | |
| 44 | /* IRQ masks for IRQs allowed to go to sleep (see irq.c) */ |
| 45 | extern unsigned long s3c_irqwake_intallow; |
| 46 | extern unsigned long s3c_irqwake_eintallow; |
| 47 | |
Ben Dooks | 0033a2f | 2006-09-19 09:51:32 +0100 | [diff] [blame] | 48 | /* per-cpu sleep functions */ |
| 49 | |
| 50 | extern void (*pm_cpu_prep)(void); |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 51 | extern int (*pm_cpu_sleep)(unsigned long); |
Ben Dooks | 0033a2f | 2006-09-19 09:51:32 +0100 | [diff] [blame] | 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* Flags for PM Control */ |
| 54 | |
| 55 | extern unsigned long s3c_pm_flags; |
| 56 | |
Ben Dooks | 4b637dc | 2008-12-12 00:24:24 +0000 | [diff] [blame] | 57 | extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */ |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /* from sleep.S */ |
| 60 | |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 61 | extern int s3c2410_cpu_suspend(unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | /* sleep save info */ |
| 64 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 65 | /** |
| 66 | * struct sleep_save - save information for shared peripherals. |
| 67 | * @reg: Pointer to the register to save. |
| 68 | * @val: Holder for the value saved from reg. |
| 69 | * |
| 70 | * This describes a list of registers which is used by the pm core and |
| 71 | * other subsystem to save and restore register values over suspend. |
| 72 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | struct sleep_save { |
| 74 | void __iomem *reg; |
| 75 | unsigned long val; |
| 76 | }; |
| 77 | |
| 78 | #define SAVE_ITEM(x) \ |
| 79 | { .reg = (x) } |
| 80 | |
Ben Dooks | d2b07fe | 2008-12-12 00:24:20 +0000 | [diff] [blame] | 81 | /** |
| 82 | * struct pm_uart_save - save block for core UART |
| 83 | * @ulcon: Save value for S3C2410_ULCON |
| 84 | * @ucon: Save value for S3C2410_UCON |
| 85 | * @ufcon: Save value for S3C2410_UFCON |
| 86 | * @umcon: Save value for S3C2410_UMCON |
| 87 | * @ubrdiv: Save value for S3C2410_UBRDIV |
| 88 | * |
| 89 | * Save block for UART registers to be held over sleep and restored if they |
| 90 | * are needed (say by debug). |
| 91 | */ |
| 92 | struct pm_uart_save { |
| 93 | u32 ulcon; |
| 94 | u32 ucon; |
| 95 | u32 ufcon; |
| 96 | u32 umcon; |
| 97 | u32 ubrdiv; |
Ben Dooks | 4b637dc | 2008-12-12 00:24:24 +0000 | [diff] [blame] | 98 | u32 udivslot; |
Ben Dooks | d2b07fe | 2008-12-12 00:24:20 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 101 | /* helper functions to save/restore lists of registers. */ |
| 102 | |
| 103 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); |
| 104 | extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); |
| 105 | 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] | 106 | |
Amit Daniel Kachhap | 8969301 | 2013-07-24 14:06:13 +0900 | [diff] [blame] | 107 | #ifdef CONFIG_SAMSUNG_PM |
Inderpal Singh | 3445513 | 2012-11-22 14:46:21 +0900 | [diff] [blame] | 108 | extern int s3c_irq_wake(struct irq_data *data, unsigned int state); |
Mark Brown | f5aeffb | 2010-12-02 14:35:38 +0900 | [diff] [blame] | 109 | extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); |
Amit Daniel Kachhap | 8969301 | 2013-07-24 14:06:13 +0900 | [diff] [blame] | 110 | extern void s3c_cpu_resume(void); |
Ben Dooks | 1e582fc | 2006-09-16 00:01:39 +0100 | [diff] [blame] | 111 | #else |
Inderpal Singh | 3445513 | 2012-11-22 14:46:21 +0900 | [diff] [blame] | 112 | #define s3c_irq_wake NULL |
Ben Dooks | 56b3442 | 2008-12-12 00:24:12 +0000 | [diff] [blame] | 113 | #define s3c_irqext_wake NULL |
Amit Daniel Kachhap | 8969301 | 2013-07-24 14:06:13 +0900 | [diff] [blame] | 114 | #define s3c_cpu_resume NULL |
Ben Dooks | 1e582fc | 2006-09-16 00:01:39 +0100 | [diff] [blame] | 115 | #endif |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 116 | |
| 117 | /* PM debug functions */ |
| 118 | |
Ben Dooks | 8005745 | 2010-01-20 12:29:25 +0900 | [diff] [blame] | 119 | #ifdef CONFIG_SAMSUNG_PM_DEBUG |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 120 | /** |
| 121 | * s3c_pm_dbg() - low level debug function for use in suspend/resume. |
| 122 | * @msg: The message to print. |
| 123 | * |
| 124 | * This function is used mainly to debug the resume process before the system |
| 125 | * can rely on printk/console output. It uses the low-level debugging output |
| 126 | * routine printascii() to do its work. |
| 127 | */ |
| 128 | extern void s3c_pm_dbg(const char *msg, ...); |
| 129 | |
| 130 | #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) |
| 131 | #else |
| 132 | #define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt) |
| 133 | #endif |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 134 | |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 135 | #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK |
| 136 | /** |
| 137 | * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs |
| 138 | * @set: set bits for the state of the LEDs |
| 139 | * @clear: clear bits for the state of the LEDs. |
| 140 | */ |
| 141 | extern void s3c_pm_debug_smdkled(u32 set, u32 clear); |
| 142 | |
| 143 | #else |
| 144 | static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { } |
| 145 | #endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */ |
| 146 | |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 147 | /* suspend memory checking */ |
| 148 | |
Ben Dooks | 8005745 | 2010-01-20 12:29:25 +0900 | [diff] [blame] | 149 | #ifdef CONFIG_SAMSUNG_PM_CHECK |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 150 | extern void s3c_pm_check_prepare(void); |
| 151 | extern void s3c_pm_check_restore(void); |
Ben Dooks | aa8aba6 | 2008-12-12 00:24:34 +0000 | [diff] [blame] | 152 | extern void s3c_pm_check_cleanup(void); |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 153 | extern void s3c_pm_check_store(void); |
| 154 | #else |
| 155 | #define s3c_pm_check_prepare() do { } while(0) |
| 156 | #define s3c_pm_check_restore() do { } while(0) |
Ben Dooks | aa8aba6 | 2008-12-12 00:24:34 +0000 | [diff] [blame] | 157 | #define s3c_pm_check_cleanup() do { } while(0) |
Ben Dooks | 549c7e3 | 2008-12-12 00:24:07 +0000 | [diff] [blame] | 158 | #define s3c_pm_check_store() do { } while(0) |
| 159 | #endif |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 160 | |
| 161 | /** |
| 162 | * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ |
| 163 | * |
| 164 | * Setup all the necessary GPIO pins for waking the system on external |
| 165 | * interrupt. |
| 166 | */ |
| 167 | extern void s3c_pm_configure_extint(void); |
| 168 | |
Tomasz Figa | 880cf07 | 2013-06-19 01:22:20 +0900 | [diff] [blame] | 169 | #ifdef CONFIG_GPIO_SAMSUNG |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 170 | /** |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 171 | * samsung_pm_restore_gpios() - restore the state of the gpios after sleep. |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 172 | * |
| 173 | * Restore the state of the GPIO pins after sleep, which may involve ensuring |
| 174 | * that we do not glitch the state of the pins from that the bootloader's |
| 175 | * resume code has done. |
| 176 | */ |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 177 | extern void samsung_pm_restore_gpios(void); |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 178 | |
| 179 | /** |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 180 | * samsung_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 181 | * |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 182 | * Save the GPIO states for resotration on resume. See samsung_pm_restore_gpios(). |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 183 | */ |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 184 | extern void samsung_pm_save_gpios(void); |
Tomasz Figa | 880cf07 | 2013-06-19 01:22:20 +0900 | [diff] [blame] | 185 | #else |
| 186 | static inline void samsung_pm_restore_gpios(void) {} |
| 187 | static inline void samsung_pm_save_gpios(void) {} |
| 188 | #endif |
Ben Dooks | 2261e0e | 2008-12-12 00:24:08 +0000 | [diff] [blame] | 189 | |
| 190 | extern void s3c_pm_save_core(void); |
| 191 | extern void s3c_pm_restore_core(void); |