1/* arch/arm/plat-samsung/include/plat/pm.h 2 * 3 * Copyright (c) 2004 Simtec Electronics 4 * http://armlinux.simtec.co.uk/ 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 12/* s3c_pm_init 13 * 14 * called from board at initialisation time to setup the power 15 * management 16*/ 17 18#include <linux/irq.h> 19 20struct device; 21 22#ifdef CONFIG_PM 23 24extern __init int s3c_pm_init(void); 25extern __init int s3c64xx_pm_init(void); 26 27#else 28 29static inline int s3c_pm_init(void) 30{ 31 return 0; 32} 33 34static inline int s3c64xx_pm_init(void) 35{ 36 return 0; 37} 38#endif 39 40/* configuration for the IRQ mask over sleep */ 41extern unsigned long s3c_irqwake_intmask; 42extern unsigned long s3c_irqwake_eintmask; 43 44/* IRQ masks for IRQs allowed to go to sleep (see irq.c) */ 45extern unsigned long s3c_irqwake_intallow; 46extern unsigned long s3c_irqwake_eintallow; 47 48/* per-cpu sleep functions */ 49 50extern void (*pm_cpu_prep)(void); 51extern int (*pm_cpu_sleep)(unsigned long); 52 53/* Flags for PM Control */ 54 55extern unsigned long s3c_pm_flags; 56 57extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */ 58 59/* from sleep.S */ 60 61extern void s3c_cpu_resume(void); 62 63extern int s3c2410_cpu_suspend(unsigned long); 64 65/* sleep save info */ 66 67/** 68 * struct sleep_save - save information for shared peripherals. 69 * @reg: Pointer to the register to save. 70 * @val: Holder for the value saved from reg. 71 * 72 * This describes a list of registers which is used by the pm core and 73 * other subsystem to save and restore register values over suspend. 74 */ 75struct sleep_save { 76 void __iomem *reg; 77 unsigned long val; 78}; 79 80#define SAVE_ITEM(x) \ 81 { .reg = (x) } 82 83/** 84 * struct pm_uart_save - save block for core UART 85 * @ulcon: Save value for S3C2410_ULCON 86 * @ucon: Save value for S3C2410_UCON 87 * @ufcon: Save value for S3C2410_UFCON 88 * @umcon: Save value for S3C2410_UMCON 89 * @ubrdiv: Save value for S3C2410_UBRDIV 90 * 91 * Save block for UART registers to be held over sleep and restored if they 92 * are needed (say by debug). 93*/ 94struct pm_uart_save { 95 u32 ulcon; 96 u32 ucon; 97 u32 ufcon; 98 u32 umcon; 99 u32 ubrdiv; 100 u32 udivslot; 101}; 102 103/* helper functions to save/restore lists of registers. */ 104 105extern void s3c_pm_do_save(struct sleep_save *ptr, int count); 106extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); 107extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); 108 109#ifdef CONFIG_PM 110extern int s3c_irq_wake(struct irq_data *data, unsigned int state); 111extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); 112#else 113#define s3c_irq_wake NULL 114#define s3c_irqext_wake NULL 115#endif 116 117/* PM debug functions */ 118 119#ifdef CONFIG_SAMSUNG_PM_DEBUG 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 */ 128extern 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 134 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 */ 141extern void s3c_pm_debug_smdkled(u32 set, u32 clear); 142 143#else 144static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { } 145#endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */ 146 147/* suspend memory checking */ 148 149#ifdef CONFIG_SAMSUNG_PM_CHECK 150extern void s3c_pm_check_prepare(void); 151extern void s3c_pm_check_restore(void); 152extern void s3c_pm_check_cleanup(void); 153extern 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) 157#define s3c_pm_check_cleanup() do { } while(0) 158#define s3c_pm_check_store() do { } while(0) 159#endif 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 */ 167extern void s3c_pm_configure_extint(void); 168 169/** 170 * samsung_pm_restore_gpios() - restore the state of the gpios after sleep. 171 * 172 * Restore the state of the GPIO pins after sleep, which may involve ensuring 173 * that we do not glitch the state of the pins from that the bootloader's 174 * resume code has done. 175*/ 176extern void samsung_pm_restore_gpios(void); 177 178/** 179 * samsung_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. 180 * 181 * Save the GPIO states for resotration on resume. See samsung_pm_restore_gpios(). 182 */ 183extern void samsung_pm_save_gpios(void); 184 185extern void s3c_pm_save_core(void); 186extern void s3c_pm_restore_core(void); 187