blob: f6749916d194b8d1e2a2e0a59cc35ccfa44ded16 [file] [log] [blame]
Ben Dooksc116c1d2010-01-29 09:02:12 +00001/* arch/arm/plat-samsung/include/plat/pm.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * Copyright (c) 2004 Simtec Electronics
Ben Dooks64197112008-12-12 00:24:06 +00004 * http://armlinux.simtec.co.uk/
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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 Dooks4e59c252008-12-12 00:24:18 +000012/* s3c_pm_init
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
14 * called from board at initialisation time to setup the power
15 * management
16*/
17
Mark Brownf5aeffb2010-12-02 14:35:38 +090018#include <linux/irq.h>
19
Mark Browna09e2b22011-02-07 10:51:04 +090020struct sys_device;
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#ifdef CONFIG_PM
23
Ben Dooks4e59c252008-12-12 00:24:18 +000024extern __init int s3c_pm_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#else
27
Ben Dooks4e59c252008-12-12 00:24:18 +000028static inline int s3c_pm_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029{
30 return 0;
31}
32#endif
33
34/* configuration for the IRQ mask over sleep */
35extern unsigned long s3c_irqwake_intmask;
36extern unsigned long s3c_irqwake_eintmask;
37
38/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
39extern unsigned long s3c_irqwake_intallow;
40extern unsigned long s3c_irqwake_eintallow;
41
Ben Dooks0033a2f2006-09-19 09:51:32 +010042/* per-cpu sleep functions */
43
44extern void (*pm_cpu_prep)(void);
Russell King29cb3cd2011-07-02 09:54:01 +010045extern int (*pm_cpu_sleep)(unsigned long);
Ben Dooks0033a2f2006-09-19 09:51:32 +010046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047/* Flags for PM Control */
48
49extern unsigned long s3c_pm_flags;
50
Ben Dooks4b637dc2008-12-12 00:24:24 +000051extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/* from sleep.S */
54
Ben Dooksef30e142008-12-12 00:24:19 +000055extern void s3c_cpu_resume(void);
56
Russell King29cb3cd2011-07-02 09:54:01 +010057extern int s3c2410_cpu_suspend(unsigned long);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* sleep save info */
60
Ben Dooks64197112008-12-12 00:24:06 +000061/**
62 * struct sleep_save - save information for shared peripherals.
63 * @reg: Pointer to the register to save.
64 * @val: Holder for the value saved from reg.
65 *
66 * This describes a list of registers which is used by the pm core and
67 * other subsystem to save and restore register values over suspend.
68 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069struct sleep_save {
70 void __iomem *reg;
71 unsigned long val;
72};
73
74#define SAVE_ITEM(x) \
75 { .reg = (x) }
76
Ben Dooksd2b07fe2008-12-12 00:24:20 +000077/**
78 * struct pm_uart_save - save block for core UART
79 * @ulcon: Save value for S3C2410_ULCON
80 * @ucon: Save value for S3C2410_UCON
81 * @ufcon: Save value for S3C2410_UFCON
82 * @umcon: Save value for S3C2410_UMCON
83 * @ubrdiv: Save value for S3C2410_UBRDIV
84 *
85 * Save block for UART registers to be held over sleep and restored if they
86 * are needed (say by debug).
87*/
88struct pm_uart_save {
89 u32 ulcon;
90 u32 ucon;
91 u32 ufcon;
92 u32 umcon;
93 u32 ubrdiv;
Ben Dooks4b637dc2008-12-12 00:24:24 +000094 u32 udivslot;
Ben Dooksd2b07fe2008-12-12 00:24:20 +000095};
96
Ben Dooks64197112008-12-12 00:24:06 +000097/* helper functions to save/restore lists of registers. */
98
99extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
100extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
101extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
Ben Dooks1e582fc2006-09-16 00:01:39 +0100102
103#ifdef CONFIG_PM
Mark Brownf5aeffb2010-12-02 14:35:38 +0900104extern int s3c_irqext_wake(struct irq_data *data, unsigned int state);
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200105extern int s3c24xx_irq_suspend(void);
106extern void s3c24xx_irq_resume(void);
Ben Dooks1e582fc2006-09-16 00:01:39 +0100107#else
Ben Dooks56b34422008-12-12 00:24:12 +0000108#define s3c_irqext_wake NULL
Ben Dooks1e582fc2006-09-16 00:01:39 +0100109#define s3c24xx_irq_suspend NULL
110#define s3c24xx_irq_resume NULL
111#endif
Ben Dooks64197112008-12-12 00:24:06 +0000112
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200113extern struct syscore_ops s3c24xx_irq_syscore_ops;
114
Ben Dooks64197112008-12-12 00:24:06 +0000115/* PM debug functions */
116
Ben Dooks80057452010-01-20 12:29:25 +0900117#ifdef CONFIG_SAMSUNG_PM_DEBUG
Ben Dooks64197112008-12-12 00:24:06 +0000118/**
119 * s3c_pm_dbg() - low level debug function for use in suspend/resume.
120 * @msg: The message to print.
121 *
122 * This function is used mainly to debug the resume process before the system
123 * can rely on printk/console output. It uses the low-level debugging output
124 * routine printascii() to do its work.
125 */
126extern void s3c_pm_dbg(const char *msg, ...);
127
128#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
129#else
130#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
131#endif
Ben Dooks549c7e32008-12-12 00:24:07 +0000132
Ben Dooksbd117bd2009-03-10 18:19:35 +0000133#ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
134/**
135 * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs
136 * @set: set bits for the state of the LEDs
137 * @clear: clear bits for the state of the LEDs.
138 */
139extern void s3c_pm_debug_smdkled(u32 set, u32 clear);
140
141#else
142static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { }
143#endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */
144
Ben Dooks549c7e32008-12-12 00:24:07 +0000145/* suspend memory checking */
146
Ben Dooks80057452010-01-20 12:29:25 +0900147#ifdef CONFIG_SAMSUNG_PM_CHECK
Ben Dooks549c7e32008-12-12 00:24:07 +0000148extern void s3c_pm_check_prepare(void);
149extern void s3c_pm_check_restore(void);
Ben Dooksaa8aba62008-12-12 00:24:34 +0000150extern void s3c_pm_check_cleanup(void);
Ben Dooks549c7e32008-12-12 00:24:07 +0000151extern void s3c_pm_check_store(void);
152#else
153#define s3c_pm_check_prepare() do { } while(0)
154#define s3c_pm_check_restore() do { } while(0)
Ben Dooksaa8aba62008-12-12 00:24:34 +0000155#define s3c_pm_check_cleanup() do { } while(0)
Ben Dooks549c7e32008-12-12 00:24:07 +0000156#define s3c_pm_check_store() do { } while(0)
157#endif
Ben Dooks2261e0e2008-12-12 00:24:08 +0000158
159/**
160 * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ
161 *
162 * Setup all the necessary GPIO pins for waking the system on external
163 * interrupt.
164 */
165extern void s3c_pm_configure_extint(void);
166
167/**
168 * s3c_pm_restore_gpios() - restore the state of the gpios after sleep.
169 *
170 * Restore the state of the GPIO pins after sleep, which may involve ensuring
171 * that we do not glitch the state of the pins from that the bootloader's
172 * resume code has done.
173*/
174extern void s3c_pm_restore_gpios(void);
175
176/**
177 * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
178 *
179 * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios().
180 */
181extern void s3c_pm_save_gpios(void);
182
183extern void s3c_pm_save_core(void);
184extern void s3c_pm_restore_core(void);