blob: a06466c01e5d6efc28f9db07367a496a65b60095 [file] [log] [blame]
Bin Mengab702be2017-04-21 07:24:28 -07001/*
2 * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef __ASM_ACPI_S3_H__
8#define __ASM_ACPI_S3_H__
9
Bin Meng215596c2017-04-21 07:24:35 -070010#define WAKEUP_BASE 0x600
11
Bin Mengab702be2017-04-21 07:24:28 -070012/* PM1_STATUS register */
13#define WAK_STS (1 << 15)
14#define PCIEXPWAK_STS (1 << 14)
15#define RTC_STS (1 << 10)
16#define SLPBTN_STS (1 << 9)
17#define PWRBTN_STS (1 << 8)
18#define GBL_STS (1 << 5)
19#define BM_STS (1 << 4)
20#define TMR_STS (1 << 0)
21
22/* PM1_CNT register */
23#define SLP_EN (1 << 13)
24#define SLP_TYP_SHIFT 10
25#define SLP_TYP (7 << SLP_TYP_SHIFT)
26#define SLP_TYP_S0 0
27#define SLP_TYP_S1 1
28#define SLP_TYP_S3 5
29#define SLP_TYP_S4 6
30#define SLP_TYP_S5 7
31
Bin Meng215596c2017-04-21 07:24:35 -070032#ifndef __ASSEMBLY__
33
34extern char __wakeup[];
35extern int __wakeup_size;
36
Bin Mengab702be2017-04-21 07:24:28 -070037enum acpi_sleep_state {
38 ACPI_S0,
39 ACPI_S1,
40 ACPI_S2,
41 ACPI_S3,
42 ACPI_S4,
43 ACPI_S5,
44};
45
46/**
Bin Mengef61f772017-04-21 07:24:32 -070047 * acpi_ss_string() - get ACPI-defined sleep state string
48 *
49 * @pm1_cnt: ACPI-defined sleep state
50 * @return: a pointer to the sleep state string.
51 */
52static inline char *acpi_ss_string(enum acpi_sleep_state state)
53{
54 char *ss_string[] = { "S0", "S1", "S2", "S3", "S4", "S5"};
55
56 return ss_string[state];
57}
58
59/**
Bin Mengab702be2017-04-21 07:24:28 -070060 * acpi_sleep_from_pm1() - get ACPI-defined sleep state from PM1_CNT register
61 *
62 * @pm1_cnt: PM1_CNT register value
63 * @return: ACPI-defined sleep state if given valid PM1_CNT register value,
64 * -EINVAL otherwise.
65 */
66static inline enum acpi_sleep_state acpi_sleep_from_pm1(u32 pm1_cnt)
67{
68 switch ((pm1_cnt & SLP_TYP) >> SLP_TYP_SHIFT) {
69 case SLP_TYP_S0:
70 return ACPI_S0;
71 case SLP_TYP_S1:
72 return ACPI_S1;
73 case SLP_TYP_S3:
74 return ACPI_S3;
75 case SLP_TYP_S4:
76 return ACPI_S4;
77 case SLP_TYP_S5:
78 return ACPI_S5;
79 }
80
81 return -EINVAL;
82}
83
Bin Mengacb4bf92017-04-21 07:24:31 -070084/**
85 * chipset_prev_sleep_state() - Get chipset previous sleep state
86 *
87 * This returns chipset previous sleep state from ACPI registers.
88 * Platform codes must supply this routine in order to support ACPI S3.
89 *
90 * @return ACPI_S0/S1/S2/S3/S4/S5.
91 */
92enum acpi_sleep_state chipset_prev_sleep_state(void);
93
94/**
95 * chipset_clear_sleep_state() - Clear chipset sleep state
96 *
97 * This clears chipset sleep state in ACPI registers.
98 * Platform codes must supply this routine in order to support ACPI S3.
99 */
100void chipset_clear_sleep_state(void);
101
Bin Meng215596c2017-04-21 07:24:35 -0700102#endif /* __ASSEMBLY__ */
103
Bin Mengab702be2017-04-21 07:24:28 -0700104#endif /* __ASM_ACPI_S3_H__ */