Krzysztof Kozlowski | 4490e3c | 2017-12-25 20:54:35 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 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> |
Krzysztof Kozlowski | 4490e3c | 2017-12-25 20:54:35 +0100 | [diff] [blame] | 8 | */ |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 9 | |
| 10 | #ifndef __PLAT_SAMSUNG_PM_COMMON_H |
| 11 | #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__ |
| 12 | |
Tomasz Figa | b278991 | 2014-03-18 07:28:10 +0900 | [diff] [blame] | 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 | */ |
| 25 | struct 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 | |
| 35 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); |
| 36 | extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count); |
| 37 | extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count); |
| 38 | |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 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 | */ |
| 52 | struct 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 | */ |
| 70 | extern void s3c_pm_dbg(const char *msg, ...); |
| 71 | |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 72 | #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) |
| 73 | |
Arnd Bergmann | dbd6fef | 2020-08-06 20:20:29 +0200 | [diff] [blame] | 74 | extern void s3c_pm_save_uarts(bool is_s3c24xx); |
| 75 | extern void s3c_pm_restore_uarts(bool is_s3c24xx); |
| 76 | |
| 77 | #ifdef CONFIG_ARCH_S3C64XX |
| 78 | extern void s3c_pm_arch_update_uart(void __iomem *regs, |
| 79 | struct pm_uart_save *save); |
| 80 | #else |
| 81 | static inline void |
| 82 | s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save) |
| 83 | { |
| 84 | } |
| 85 | #endif |
| 86 | |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 87 | #else |
| 88 | #define S3C_PMDBG(fmt...) pr_debug(fmt) |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 89 | |
Arnd Bergmann | dbd6fef | 2020-08-06 20:20:29 +0200 | [diff] [blame] | 90 | static inline void s3c_pm_save_uarts(bool is_s3c24xx) { } |
| 91 | static inline void s3c_pm_restore_uarts(bool is_s3c24xx) { } |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 92 | #endif |
| 93 | |
Tomasz Figa | f682426 | 2014-03-18 07:28:10 +0900 | [diff] [blame] | 94 | /* suspend memory checking */ |
| 95 | |
| 96 | #ifdef CONFIG_SAMSUNG_PM_CHECK |
| 97 | extern void s3c_pm_check_prepare(void); |
| 98 | extern void s3c_pm_check_restore(void); |
| 99 | extern void s3c_pm_check_cleanup(void); |
| 100 | extern void s3c_pm_check_store(void); |
| 101 | #else |
| 102 | #define s3c_pm_check_prepare() do { } while (0) |
| 103 | #define s3c_pm_check_restore() do { } while (0) |
| 104 | #define s3c_pm_check_cleanup() do { } while (0) |
| 105 | #define s3c_pm_check_store() do { } while (0) |
| 106 | #endif |
| 107 | |
Tomasz Figa | 72551f6 | 2014-03-18 07:28:09 +0900 | [diff] [blame] | 108 | #endif |