1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <intelblocks/gpio.h>
4 #include <soc/gpio_defs.h>
5 #include <soc/intel/common/acpi/gpio.asl>
6 #include <soc/intel/common/block/acpi/acpi/gpio_op.asl>
8 #include <soc/pcr_ids.h>
12 Name (_HID, CROS_GPIO_NAME)
14 Name (_DDN, "GPIO Controller")
16 Name (RBUF, ResourceTemplate()
18 Memory32Fixed (ReadWrite, 0, 0, COM0)
19 Memory32Fixed (ReadWrite, 0, 0, COM1)
20 Memory32Fixed (ReadWrite, 0, 0, COM2)
21 Memory32Fixed (ReadWrite, 0, 0, COM4)
22 Memory32Fixed (ReadWrite, 0, 0, COM5)
23 Interrupt (ResourceConsumer, Level, ActiveLow, Shared,,, GIRQ)
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 2 */
42 CreateDWordField (^RBUF, ^COM2._BAS, BAS2)
43 CreateDWordField (^RBUF, ^COM2._LEN, LEN2)
44 BAS2 = ^^PCRB (PID_GPIOCOM2)
47 /* GPIO Community 4 */
48 CreateDWordField (^RBUF, ^COM4._BAS, BAS4)
49 CreateDWordField (^RBUF, ^COM4._LEN, LEN4)
50 BAS4 = ^^PCRB (PID_GPIOCOM4)
53 /* GPIO Community 5 */
54 CreateDWordField (^RBUF, ^COM5._BAS, BAS5)
55 CreateDWordField (^RBUF, ^COM5._LEN, LEN5)
56 BAS5 = ^^PCRB (PID_GPIOCOM5)
62 Method (_STA, 0, NotSerialized)
68 * Get GPIO DW0 Address
71 Method (GADD, 1, NotSerialized)
73 /* GPIO Community 0 */
74 If (Arg0 >= GPIO_COM0_START && Arg0 <= GPIO_COM0_END)
77 Local1 = Arg0 - GPIO_COM0_START
79 /* GPIO Community 1 */
80 If (Arg0 >= GPIO_COM1_START && Arg0 <= GPIO_COM1_END)
83 Local1 = Arg0 - GPIO_COM1_START
85 /* GPIO Community 2 */
86 If (Arg0 >= GPIO_COM2_START && Arg0 <= GPIO_COM2_END)
89 Local1 = Arg0 - GPIO_COM2_START
91 /* GPIO Community 4 */
92 If (Arg0 >= GPIO_COM4_START && Arg0 <= GPIO_COM4_END)
95 Local1 = Arg0 - GPIO_COM4_START
97 /* GPIO Community 05*/
98 If (Arg0 >= GPIO_COM5_START && Arg0 <= GPIO_COM5_END)
100 Local0 = PID_GPIOCOM5
101 Local1 = Arg0 - GPIO_COM5_START
104 Local2 = PCRB(Local0) + PAD_CFG_BASE + (Local1 * 16)
109 * Return PCR Port ID of GPIO Communities
111 * Arg0: GPIO Community (0-5)
113 Method (GPID, 1, Serialized)
115 Switch (ToInteger (Arg0))
118 Local0 = PID_GPIOCOM0
121 Local0 = PID_GPIOCOM1
124 Local0 = PID_GPIOCOM2
127 Local0 = PID_GPIOCOM4
130 Local0 = PID_GPIOCOM5