blob: 87fa97fd6e8bfd957b35c5dd247f5a781999f26b [file] [log] [blame]
Krzysztof Kozlowski4490e3c2017-12-25 20:54:35 +01001/* SPDX-License-Identifier: GPL-2.0 */
Tomasz Figa72551f62014-03-18 07:28:09 +09002/*
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 Kozlowski4490e3c2017-12-25 20:54:35 +01008 */
Tomasz Figa72551f62014-03-18 07:28:09 +09009
10#ifndef __PLAT_SAMSUNG_PM_COMMON_H
11#define __PLAT_SAMSUNG_PM_COMMON_H __FILE__
12
Tomasz Figab2789912014-03-18 07:28:10 +090013#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
Tomasz Figa72551f62014-03-18 07:28:09 +090039/* 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
Tomasz Figa72551f62014-03-18 07:28:09 +090072#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
73
Arnd Bergmanndbd6fef2020-08-06 20:20:29 +020074extern void s3c_pm_save_uarts(bool is_s3c24xx);
75extern void s3c_pm_restore_uarts(bool is_s3c24xx);
76
77#ifdef CONFIG_ARCH_S3C64XX
78extern void s3c_pm_arch_update_uart(void __iomem *regs,
79 struct pm_uart_save *save);
80#else
81static inline void
82s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save)
83{
84}
85#endif
86
Tomasz Figa72551f62014-03-18 07:28:09 +090087#else
88#define S3C_PMDBG(fmt...) pr_debug(fmt)
Tomasz Figa72551f62014-03-18 07:28:09 +090089
Arnd Bergmanndbd6fef2020-08-06 20:20:29 +020090static inline void s3c_pm_save_uarts(bool is_s3c24xx) { }
91static inline void s3c_pm_restore_uarts(bool is_s3c24xx) { }
Tomasz Figa72551f62014-03-18 07:28:09 +090092#endif
93
Tomasz Figaf6824262014-03-18 07:28:10 +090094/* suspend memory checking */
95
96#ifdef CONFIG_SAMSUNG_PM_CHECK
97extern void s3c_pm_check_prepare(void);
98extern void s3c_pm_check_restore(void);
99extern void s3c_pm_check_cleanup(void);
100extern 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 Figa72551f62014-03-18 07:28:09 +0900108#endif