1 /* 2 * Copyright (C) 2013 Samsung Electronics Co., Ltd. 3 * Tomasz Figa <t.figa@samsung.com> 4 * Copyright (c) 2004 Simtec Electronics 5 * http://armlinux.simtec.co.uk/ 6 * Written by Ben Dooks, <ben@simtec.co.uk> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 13 #ifndef __PLAT_SAMSUNG_PM_COMMON_H 14 #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__ 15 16 #include <linux/irq.h> 17 18 /* sleep save info */ 19 20 /** 21 * struct sleep_save - save information for shared peripherals. 22 * @reg: Pointer to the register to save. 23 * @val: Holder for the value saved from reg. 24 * 25 * This describes a list of registers which is used by the pm core and 26 * other subsystem to save and restore register values over suspend. 27 */ 28 struct sleep_save { 29 void __iomem *reg; 30 unsigned long val; 31 }; 32 33 #define SAVE_ITEM(x) \ 34 { .reg = (x) } 35 36 /* helper functions to save/restore lists of registers. */ 37 38 extern void s3c_pm_do_save(struct sleep_save *ptr, int count); 39 extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count); 40 extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count); 41 42 /* PM debug functions */ 43 44 /** 45 * struct pm_uart_save - save block for core UART 46 * @ulcon: Save value for S3C2410_ULCON 47 * @ucon: Save value for S3C2410_UCON 48 * @ufcon: Save value for S3C2410_UFCON 49 * @umcon: Save value for S3C2410_UMCON 50 * @ubrdiv: Save value for S3C2410_UBRDIV 51 * 52 * Save block for UART registers to be held over sleep and restored if they 53 * are needed (say by debug). 54 */ 55 struct pm_uart_save { 56 u32 ulcon; 57 u32 ucon; 58 u32 ufcon; 59 u32 umcon; 60 u32 ubrdiv; 61 u32 udivslot; 62 }; 63 64 #ifdef CONFIG_SAMSUNG_PM_DEBUG 65 /** 66 * s3c_pm_dbg() - low level debug function for use in suspend/resume. 67 * @msg: The message to print. 68 * 69 * This function is used mainly to debug the resume process before the system 70 * can rely on printk/console output. It uses the low-level debugging output 71 * routine printascii() to do its work. 72 */ 73 extern void s3c_pm_dbg(const char *msg, ...); 74 75 /** 76 * s3c_pm_debug_init() - suspend/resume low level debug initialization. 77 * @base: Virtual base of UART to use for suspend/resume debugging. 78 * 79 * This function needs to be called before S3C_PMDBG() can be used, to set up 80 * UART port base address and configuration. 81 */ 82 extern void s3c_pm_debug_init(void); 83 84 #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) 85 86 extern void s3c_pm_save_uarts(void); 87 extern void s3c_pm_restore_uarts(void); 88 #else 89 #define S3C_PMDBG(fmt...) pr_debug(fmt) 90 #define s3c_pm_debug_init() do { } while (0) 91 s3c_pm_save_uarts(void)92static inline void s3c_pm_save_uarts(void) { } s3c_pm_restore_uarts(void)93static inline void s3c_pm_restore_uarts(void) { } 94 #endif 95 96 /* suspend memory checking */ 97 98 #ifdef CONFIG_SAMSUNG_PM_CHECK 99 extern void s3c_pm_check_prepare(void); 100 extern void s3c_pm_check_restore(void); 101 extern void s3c_pm_check_cleanup(void); 102 extern void s3c_pm_check_store(void); 103 #else 104 #define s3c_pm_check_prepare() do { } while (0) 105 #define s3c_pm_check_restore() do { } while (0) 106 #define s3c_pm_check_cleanup() do { } while (0) 107 #define s3c_pm_check_store() do { } while (0) 108 #endif 109 110 #endif 111