1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/acpimmio_map.h>
4 #include <amdblocks/gpio_defs.h>
7 /* Get pin control MMIO address */
10 /* Arg0 - GPIO pin number */
11 Return ((Arg0 * 4) + ACPIMMIO_GPIO0_BASE)
14 /* Read pin control dword */
15 Method (GPRD, 0x1, Serialized)
17 /* Arg0 - GPIO pin control MMIO address */
19 OperationRegion (GPDW, SystemMemory, Local0, 4)
20 Field (GPDW, AnyAcc, NoLock, Preserve) {
26 /* Write pin control dword */
27 Method (GPWR, 0x2, Serialized)
29 /* Arg0 - GPIO pin control MMIO address */
30 /* Arg1 - Value for control register */
32 OperationRegion (GPDW, SystemMemory, Local0, 4)
33 Field (GPDW, AnyAcc, NoLock, Preserve) {
40 * Set GPIO Output Value
43 Method (STXS, 1, Serialized)
45 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
46 Field (GPDW, AnyAcc, NoLock, Preserve)
50 VAL0 |= GPIO_OUTPUT_VALUE
54 * Clear GPIO Output Value
57 Method (CTXS, 1, Serialized)
59 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
60 Field (GPDW, AnyAcc, NoLock, Preserve)
64 VAL0 &= ~GPIO_OUTPUT_VALUE
68 * Get GPIO Input Value
71 Method (GRXS, 1, Serialized)
73 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
74 Field (GPDW, AnyAcc, NoLock, Preserve)
78 Local0 = (GPIO_PIN_STS & VAL0) >> GPIO_PIN_STS_SHIFT
84 * Get GPIO Output Value
87 Method (GTXS, 1, Serialized)
89 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
90 Field (GPDW, AnyAcc, NoLock, Preserve)
94 Local0 = (GPIO_OUTPUT_VALUE & VAL0) >> GPIO_OUTPUT_SHIFT