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