1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <soc/intel/common/block/acpi/acpi/gpio_op.asl>
5 #include <soc/pcr_ids.h>
11 Name (_DDN, "GPIO Controller")
13 Name (RBUF, ResourceTemplate()
15 Memory32Fixed (ReadWrite, 0, 0, COM0)
16 Memory32Fixed (ReadWrite, 0, 0, COM1)
17 Memory32Fixed (ReadWrite, 0, 0, COM4)
18 Interrupt (ResourceConsumer, Level, ActiveLow, Shared,,, GIRQ)
23 * GPIO communities 0, 1, and 4 are exported for the OS.
24 * This is based on the Linux kernel provided community map at
25 * drivers/pinctrl/intel/pinctrl-cannonlake.c:cnllp_communities[]
27 Method (_CRS, 0, NotSerialized)
29 /* GPIO Community 0 */
30 CreateDWordField (^RBUF, ^COM0._BAS, BAS0)
31 CreateDWordField (^RBUF, ^COM0._LEN, LEN0)
32 BAS0 = ^^PCRB (PID_GPIOCOM0)
35 /* GPIO Community 1 */
36 CreateDWordField (^RBUF, ^COM1._BAS, BAS1)
37 CreateDWordField (^RBUF, ^COM1._LEN, LEN1)
38 BAS1 = ^^PCRB (PID_GPIOCOM1)
41 /* GPIO Community 4 */
42 CreateDWordField (^RBUF, ^COM4._BAS, BAS4)
43 CreateDWordField (^RBUF, ^COM4._LEN, LEN4)
44 BAS4 = ^^PCRB (PID_GPIOCOM4)
50 Method (_STA, 0, NotSerialized)
57 * Get GPIO DW0 Address
60 Method (GADD, 1, NotSerialized)
62 /* GPIO Community 0 */
63 If (Arg0 >= GPP_A0 && Arg0 <= SPI0_CLK_LOOPBK)
66 Local1 = Arg0 - GPP_A0
68 /* GPIO Community 1 */
69 If (Arg0 >= GPP_D0 && Arg0 <= vSD3_CD_B)
72 Local1 = Arg0 - GPP_D0
74 /* GPIO Community 2 */
75 If (Arg0 >= GPD0 && Arg0 <= DRAM_RESET_B)
80 /* GPIO Community 3 */
81 If (Arg0 >= HDA_BCLK && Arg0 <= TRIGGER_OUT)
84 Local1 = Arg0 - HDA_BCLK
87 If (Arg0 >= GPP_C0 && Arg0 <= CL_RST_B)
90 Local1 = Arg0 - GPP_C0
92 Local2 = PCRB (Local0)
93 Local2 += PAD_CFG_BASE
94 Return (Local2 + Local1 * 16)
98 * Return PCR Port ID of GPIO Communities
100 * Arg0: GPIO Community (0-4)
102 Method (GPID, 1, Serialized)
104 Switch (ToInteger (Arg0))
107 Local0 = PID_GPIOCOM0
110 Local0 = PID_GPIOCOM1
113 Local0 = PID_GPIOCOM2
116 Local0 = PID_GPIOCOM3
119 Local0 = PID_GPIOCOM4
130 * Configure GPIO Power Management bits
132 * Arg0: GPIO community (0-4)
133 * Arg1: PM bits in MISCCFG
135 Method (CGPM, 2, Serialized)
139 /* Mask off current PM bits */
140 PCRA (Local0, GPIO_MISCCFG, ~MISCCFG_GPIO_PM_CONFIG_BITS)
141 /* Mask in requested bits */
142 PCRO (Local0, GPIO_MISCCFG, Arg1 & MISCCFG_GPIO_PM_CONFIG_BITS)
146 /* GPIO Power Management bits */
147 Name(GPMB, Package(TOTAL_GPIO_COMM) {0, 0, 0, 0, 0})
150 * Save GPIO Power Management bits
152 Method (SGPM, 0, Serialized)
154 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
156 Local1 = GPID (Local0)
157 GPMB[Local0] = PCRR (Local1, GPIO_MISCCFG)
162 * Restore GPIO Power Management bits
164 Method (RGPM, 0, Serialized)
166 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
168 CGPM (Local0, DerefOf(GPMB[Local0]))
173 * Save current setting of GPIO Power Management bits and
174 * enable all Power Management bits for all communities
176 Method (EGPM, 0, Serialized)
178 /* Save current setting and will restore it when resuming */
181 For (Local0 = 0, Local0 < TOTAL_GPIO_COMM, Local0++)
183 CGPM (Local0, MISCCFG_GPIO_PM_CONFIG_BITS)