1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <soc/intel/common/acpi/gpio.asl>
4 #include <soc/intel/common/block/acpi/acpi/gpio_op.asl>
6 #include <soc/pcr_ids.h>
10 Name (_HID, CROS_GPIO_NAME)
12 Name (_DDN, "GPIO Controller")
14 Name (RBUF, ResourceTemplate()
16 Memory32Fixed (ReadWrite, 0, 0, COM0)
17 Memory32Fixed (ReadWrite, 0, 0, COM1)
18 #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_S)
19 Memory32Fixed (ReadWrite, 0, 0, COM3)
21 Memory32Fixed (ReadWrite, 0, 0, COM4)
22 Memory32Fixed (ReadWrite, 0, 0, COM5)
23 Interrupt (ResourceConsumer, Level, ActiveLow, Shared,,, GIRQ)
26 Method (_CRS, 0, NotSerialized)
28 /* GPIO Community 0 */
29 CreateDWordField (^RBUF, ^COM0._BAS, BAS0)
30 CreateDWordField (^RBUF, ^COM0._LEN, LEN0)
31 BAS0 = ^^PCRB (PID_GPIOCOM0)
34 /* GPIO Community 1 */
35 CreateDWordField (^RBUF, ^COM1._BAS, BAS1)
36 CreateDWordField (^RBUF, ^COM1._LEN, LEN1)
37 BAS1 = ^^PCRB (PID_GPIOCOM1)
40 #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_S)
41 /* GPIO Community 3 */
42 CreateDWordField (^RBUF, ^COM3._BAS, BAS3)
43 CreateDWordField (^RBUF, ^COM3._LEN, LEN3)
44 BAS3 = ^^PCRB (PID_GPIOCOM3)
48 /* GPIO Community 4 */
49 CreateDWordField (^RBUF, ^COM4._BAS, BAS4)
50 CreateDWordField (^RBUF, ^COM4._LEN, LEN4)
51 BAS4 = ^^PCRB (PID_GPIOCOM4)
54 /* GPIO Community 5 */
55 CreateDWordField (^RBUF, ^COM5._BAS, BAS5)
56 CreateDWordField (^RBUF, ^COM5._LEN, LEN5)
57 BAS5 = ^^PCRB (PID_GPIOCOM5)
63 Method (_STA, 0, NotSerialized)
70 * Get GPIO DW0 Address
73 Method (GADD, 1, NotSerialized)
75 /* GPIO Community 0 */
76 If (Arg0 >= GPIO_COM0_START && Arg0 <= GPIO_COM0_END)
79 Local1 = Arg0 - GPIO_COM0_START
81 /* GPIO Community 1 */
82 If (Arg0 >= GPIO_COM1_START && Arg0 <= GPIO_COM1_END)
85 Local1 = Arg0 - GPIO_COM1_START
87 /* GPIO Community 2 */
88 If (Arg0 >= GPIO_COM2_START && Arg0 <= GPIO_COM2_END)
91 Local1 = Arg0 - GPIO_COM2_START
93 /* GPIO Community 3 */
94 If (Arg0 >= GPIO_COM3_START && Arg0 <= GPIO_COM3_END)
97 Local1 = Arg0 - GPIO_COM3_START
99 /* GPIO Community 4 */
100 If (Arg0 >= GPIO_COM4_START && Arg0 <= GPIO_COM4_END)
102 Local0 = PID_GPIOCOM4
103 Local1 = Arg0 - GPIO_COM4_START
105 /* GPIO Community 5*/
106 If (Arg0 >= GPIO_COM5_START && Arg0 <= GPIO_COM5_END)
108 Local0 = PID_GPIOCOM5
109 Local1 = Arg0 - GPIO_COM5_START
112 Local2 = PCRB(Local0) + PAD_CFG_BASE + (Local1 * 16)
117 * Return PCR Port ID of GPIO Communities
119 * Arg0: GPIO Community (0-5)
121 Method (GPID, 1, Serialized)
123 Switch (ToInteger (Arg0))
126 Local0 = PID_GPIOCOM0
129 Local0 = PID_GPIOCOM1
132 Local0 = PID_GPIOCOM2
135 Local0 = PID_GPIOCOM3
138 Local0 = PID_GPIOCOM4
141 Local0 = PID_GPIOCOM5
151 /* GPIO Power Management bits */
152 Name(GPMB, Package(TOTAL_GPIO_COMM) {0, 0, 0, 0, 0, 0})
155 * Save GPIO Power Management bits
157 Method (SGPM, 0, Serialized)
159 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
161 Local1 = GPID (Local0)
162 GPMB[Local0] = PCRR (Local1, GPIO_MISCCFG)
167 * Restore GPIO Power Management bits
169 Method (RGPM, 0, Serialized)
171 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
173 CGPM (Local0, DerefOf(GPMB[Local0]))
178 * Save current setting of GPIO Power Management bits and
179 * enable all Power Management bits for all communities
181 Method (EGPM, 0, Serialized)
183 /* Save current setting and will restore it when resuming */
186 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
188 CGPM (Local0, MISCCFG_GPIO_PM_CONFIG_BITS)