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 Memory32Fixed (ReadWrite, 0, 0, COM3)
19 Memory32Fixed (ReadWrite, 0, 0, COM4)
20 Memory32Fixed (ReadWrite, 0, 0, COM5)
21 Interrupt (ResourceConsumer, Level, ActiveLow, Shared,,, GIRQ)
24 Method (_CRS, 0, NotSerialized)
26 /* GPIO Community 0 */
27 CreateDWordField (^RBUF, ^COM0._BAS, BAS0)
28 CreateDWordField (^RBUF, ^COM0._LEN, LEN0)
29 BAS0 = ^^PCRB (PID_GPIOCOM0)
32 /* GPIO Community 1 */
33 CreateDWordField (^RBUF, ^COM1._BAS, BAS1)
34 CreateDWordField (^RBUF, ^COM1._LEN, LEN1)
35 BAS1 = ^^PCRB (PID_GPIOCOM1)
38 /* GPIO Community 3 */
39 CreateDWordField (^RBUF, ^COM3._BAS, BAS3)
40 CreateDWordField (^RBUF, ^COM3._LEN, LEN3)
41 BAS3 = ^^PCRB (PID_GPIOCOM3)
44 /* GPIO Community 4 */
45 CreateDWordField (^RBUF, ^COM4._BAS, BAS4)
46 CreateDWordField (^RBUF, ^COM4._LEN, LEN4)
47 BAS4 = ^^PCRB (PID_GPIOCOM4)
50 /* GPIO Community 5 */
51 CreateDWordField (^RBUF, ^COM5._BAS, BAS5)
52 CreateDWordField (^RBUF, ^COM5._LEN, LEN5)
53 BAS5 = ^^PCRB (PID_GPIOCOM5)
59 Method (_STA, 0, NotSerialized)
66 * Get GPIO DW0 Address
69 Method (GADD, 1, NotSerialized)
71 /* GPIO Community 0 */
72 If (Arg0 >= GPIO_COM0_START && Arg0 <= GPIO_COM0_END)
75 Local1 = Arg0 - GPIO_COM0_START
77 /* GPIO Community 1 */
78 If (Arg0 >= GPIO_COM1_START && Arg0 <= GPIO_COM1_END)
81 Local1 = Arg0 - GPIO_COM1_START
83 /* GPIO Community 3 */
84 If (Arg0 >= GPIO_COM3_START && Arg0 <= GPIO_COM3_END)
87 Local1 = Arg0 - GPIO_COM3_START
89 /* GPIO Community 4 */
90 If (Arg0 >= GPIO_COM4_START && Arg0 <= GPIO_COM4_END)
93 Local1 = Arg0 - GPIO_COM4_START
96 If (Arg0 >= GPIO_COM5_START && Arg0 <= GPIO_COM5_END)
99 Local1 = Arg0 - GPIO_COM5_START
102 Local2 = PCRB(Local0) + PAD_CFG_BASE + (Local1 * 16)
107 * Return PCR Port ID of GPIO Communities
109 * Arg0: GPIO Community (0-5)
111 Method (GPID, 1, Serialized)
113 Switch (ToInteger (Arg0))
116 Local0 = PID_GPIOCOM0
119 Local0 = PID_GPIOCOM1
122 Local0 = PID_GPIOCOM3
125 Local0 = PID_GPIOCOM4
128 Local0 = PID_GPIOCOM5
138 /* GPIO Power Management bits */
139 Name(GPMB, Package(TOTAL_GPIO_COMM) {0, 0, 0, 0, 0})
142 * Save GPIO Power Management bits
144 Method (SGPM, 0, Serialized)
146 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
148 Local1 = GPID (Local0)
149 GPMB[Local0] = PCRR (Local1, GPIO_MISCCFG)
154 * Restore GPIO Power Management bits
156 Method (RGPM, 0, Serialized)
158 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
160 CGPM (Local0, DerefOf(GPMB[Local0]))
165 * Save current setting of GPIO Power Management bits and
166 * enable all Power Management bits for all communities
168 Method (EGPM, 0, Serialized)
170 /* Save current setting and will restore it when resuming */
173 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
175 CGPM (Local0, MISCCFG_GPIO_PM_CONFIG_BITS)