pm.h 4.9 KB
Newer Older
1
/* arch/arm/plat-samsung/include/plat/pm.h
L
Linus Torvalds 已提交
2 3
 *
 * Copyright (c) 2004 Simtec Electronics
4
 *	http://armlinux.simtec.co.uk/
L
Linus Torvalds 已提交
5 6 7 8 9 10 11
 *	Written by Ben Dooks, <ben@simtec.co.uk>
 *
 * 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.
*/

12
/* s3c_pm_init
L
Linus Torvalds 已提交
13 14 15 16 17
 *
 * called from board at initialisation time to setup the power
 * management
*/

18 19
#include <linux/irq.h>

20
struct device;
21

22
#ifdef CONFIG_SAMSUNG_PM
L
Linus Torvalds 已提交
23

24
extern __init int s3c_pm_init(void);
25
extern __init int s3c64xx_pm_init(void);
L
Linus Torvalds 已提交
26 27 28

#else

29
static inline int s3c_pm_init(void)
L
Linus Torvalds 已提交
30 31 32
{
	return 0;
}
33 34 35 36 37

static inline int s3c64xx_pm_init(void)
{
	return 0;
}
L
Linus Torvalds 已提交
38 39 40 41 42 43 44 45 46 47
#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;

48 49 50
/* per-cpu sleep functions */

extern void (*pm_cpu_prep)(void);
51
extern int (*pm_cpu_sleep)(unsigned long);
52

L
Linus Torvalds 已提交
53 54 55 56
/* Flags for PM Control */

extern unsigned long s3c_pm_flags;

57 58
extern unsigned char pm_uart_udivslot;  /* true to save UART UDIVSLOT */

L
Linus Torvalds 已提交
59 60
/* from sleep.S */

61
extern int s3c2410_cpu_suspend(unsigned long);
L
Linus Torvalds 已提交
62 63 64

/* sleep save info */

65 66 67 68 69 70 71 72
/**
 * 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.
 */
L
Linus Torvalds 已提交
73 74 75 76 77 78 79 80
struct sleep_save {
	void __iomem	*reg;
	unsigned long	val;
};

#define SAVE_ITEM(x) \
	{ .reg = (x) }

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
/**
 * 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;
98
	u32	udivslot;
99 100
};

101 102 103 104 105
/* 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);
106

107
#ifdef CONFIG_SAMSUNG_PM
108
extern int s3c_irq_wake(struct irq_data *data, unsigned int state);
109
extern int s3c_irqext_wake(struct irq_data *data, unsigned int state);
110
extern void s3c_cpu_resume(void);
111
#else
112
#define s3c_irq_wake NULL
113
#define s3c_irqext_wake NULL
114
#define s3c_cpu_resume NULL
115
#endif
116 117 118

/* PM debug functions */

119
#ifdef CONFIG_SAMSUNG_PM_DEBUG
120 121 122 123 124 125 126 127 128 129 130 131 132 133
/**
 * 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
134

135 136 137 138 139 140 141 142 143 144 145 146
#ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
/**
 * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs
 * @set: set bits for the state of the LEDs
 * @clear: clear bits for the state of the LEDs.
 */
extern void s3c_pm_debug_smdkled(u32 set, u32 clear);

#else
static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { }
#endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */

147 148
/* suspend memory checking */

149
#ifdef CONFIG_SAMSUNG_PM_CHECK
150 151
extern void s3c_pm_check_prepare(void);
extern void s3c_pm_check_restore(void);
152
extern void s3c_pm_check_cleanup(void);
153 154 155 156
extern void s3c_pm_check_store(void);
#else
#define s3c_pm_check_prepare() do { } while(0)
#define s3c_pm_check_restore() do { } while(0)
157
#define s3c_pm_check_cleanup() do { } while(0)
158 159
#define s3c_pm_check_store()   do { } while(0)
#endif
160 161 162 163 164 165 166 167 168

/**
 * 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);

169
#ifdef CONFIG_GPIO_SAMSUNG
170
/**
171
 * samsung_pm_restore_gpios() - restore the state of the gpios after sleep.
172 173 174 175 176
 *
 * 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.
*/
177
extern void samsung_pm_restore_gpios(void);
178 179

/**
180
 * samsung_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
181
 *
182
 * Save the GPIO states for resotration on resume. See samsung_pm_restore_gpios().
183
 */
184
extern void samsung_pm_save_gpios(void);
185 186 187 188
#else
static inline void samsung_pm_restore_gpios(void) {}
static inline void samsung_pm_save_gpios(void) {}
#endif
189 190 191

extern void s3c_pm_save_core(void);
extern void s3c_pm_restore_core(void);