blob: c27b8cf5d8918abaed8d1a03057c0e75ee76f29e [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/include/asm-arm/plat-s3c24xx/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
18#ifdef CONFIG_PM
19
Ben Dooks4e59c252008-12-12 00:24:18 +000020extern __init int s3c_pm_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22#else
23
Ben Dooks4e59c252008-12-12 00:24:18 +000024static inline int s3c_pm_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025{
26 return 0;
27}
28#endif
29
30/* configuration for the IRQ mask over sleep */
31extern unsigned long s3c_irqwake_intmask;
32extern unsigned long s3c_irqwake_eintmask;
33
34/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
35extern unsigned long s3c_irqwake_intallow;
36extern unsigned long s3c_irqwake_eintallow;
37
Ben Dooks0033a2f2006-09-19 09:51:32 +010038/* per-cpu sleep functions */
39
40extern void (*pm_cpu_prep)(void);
41extern void (*pm_cpu_sleep)(void);
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043/* Flags for PM Control */
44
45extern unsigned long s3c_pm_flags;
46
47/* from sleep.S */
48
Ben Dooksef30e142008-12-12 00:24:19 +000049extern int s3c_cpu_save(unsigned long *saveblk);
50extern void s3c_cpu_resume(void);
51
Ben Dooks58095d72006-09-16 00:04:23 +010052extern void s3c2410_cpu_suspend(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Ben Dooks64197112008-12-12 00:24:06 +000054extern unsigned long s3c_sleep_save_phys;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/* sleep save info */
57
Ben Dooks64197112008-12-12 00:24:06 +000058/**
59 * struct sleep_save - save information for shared peripherals.
60 * @reg: Pointer to the register to save.
61 * @val: Holder for the value saved from reg.
62 *
63 * This describes a list of registers which is used by the pm core and
64 * other subsystem to save and restore register values over suspend.
65 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066struct sleep_save {
67 void __iomem *reg;
68 unsigned long val;
69};
70
71#define SAVE_ITEM(x) \
72 { .reg = (x) }
73
Ben Dooksd2b07fe2008-12-12 00:24:20 +000074/**
75 * struct pm_uart_save - save block for core UART
76 * @ulcon: Save value for S3C2410_ULCON
77 * @ucon: Save value for S3C2410_UCON
78 * @ufcon: Save value for S3C2410_UFCON
79 * @umcon: Save value for S3C2410_UMCON
80 * @ubrdiv: Save value for S3C2410_UBRDIV
81 *
82 * Save block for UART registers to be held over sleep and restored if they
83 * are needed (say by debug).
84*/
85struct pm_uart_save {
86 u32 ulcon;
87 u32 ucon;
88 u32 ufcon;
89 u32 umcon;
90 u32 ubrdiv;
91};
92
Ben Dooks64197112008-12-12 00:24:06 +000093/* helper functions to save/restore lists of registers. */
94
95extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
96extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
97extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
Ben Dooks1e582fc2006-09-16 00:01:39 +010098
99#ifdef CONFIG_PM
Ben Dooks56b34422008-12-12 00:24:12 +0000100extern int s3c_irqext_wake(unsigned int irqno, unsigned int state);
Ben Dooks1e582fc2006-09-16 00:01:39 +0100101extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state);
102extern int s3c24xx_irq_resume(struct sys_device *dev);
103#else
Ben Dooks56b34422008-12-12 00:24:12 +0000104#define s3c_irqext_wake NULL
Ben Dooks1e582fc2006-09-16 00:01:39 +0100105#define s3c24xx_irq_suspend NULL
106#define s3c24xx_irq_resume NULL
107#endif
Ben Dooks64197112008-12-12 00:24:06 +0000108
109/* PM debug functions */
110
111#ifdef CONFIG_S3C2410_PM_DEBUG
112/**
113 * s3c_pm_dbg() - low level debug function for use in suspend/resume.
114 * @msg: The message to print.
115 *
116 * This function is used mainly to debug the resume process before the system
117 * can rely on printk/console output. It uses the low-level debugging output
118 * routine printascii() to do its work.
119 */
120extern void s3c_pm_dbg(const char *msg, ...);
121
122#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
123#else
124#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
125#endif
Ben Dooks549c7e32008-12-12 00:24:07 +0000126
127/* suspend memory checking */
128
129#ifdef CONFIG_S3C2410_PM_CHECK
130extern void s3c_pm_check_prepare(void);
131extern void s3c_pm_check_restore(void);
132extern void s3c_pm_check_store(void);
133#else
134#define s3c_pm_check_prepare() do { } while(0)
135#define s3c_pm_check_restore() do { } while(0)
136#define s3c_pm_check_store() do { } while(0)
137#endif
Ben Dooks2261e0e2008-12-12 00:24:08 +0000138
139/**
140 * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ
141 *
142 * Setup all the necessary GPIO pins for waking the system on external
143 * interrupt.
144 */
145extern void s3c_pm_configure_extint(void);
146
147/**
148 * s3c_pm_restore_gpios() - restore the state of the gpios after sleep.
149 *
150 * Restore the state of the GPIO pins after sleep, which may involve ensuring
151 * that we do not glitch the state of the pins from that the bootloader's
152 * resume code has done.
153*/
154extern void s3c_pm_restore_gpios(void);
155
156/**
157 * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
158 *
159 * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios().
160 */
161extern void s3c_pm_save_gpios(void);
162
163extern void s3c_pm_save_core(void);
164extern void s3c_pm_restore_core(void);