Debian Codegraph @

src/soc/amd/common/acpi/gpio_bank_lib.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <amdblocks/acpimmio_map.h>
4 #include <amdblocks/gpio_defs.h>
5 #include <soc/iomap.h>
6
7 /* Get pin control MMIO address */
8 Method (GPAD, 0x1)
9 {
10 /* Arg0 - GPIO pin number */
11 Return ((Arg0 * 4) + ACPIMMIO_GPIO0_BASE)
12 }
13
14 /* Read pin control dword */
15 Method (GPRD, 0x1, Serialized)
16 {
17 /* Arg0 - GPIO pin control MMIO address */
18 Local0 = Arg0
19 OperationRegion (GPDW, SystemMemory, Local0, 4)
20 Field (GPDW, AnyAcc, NoLock, Preserve) {
21 TEMP, 32
22 }
23 Return (TEMP)
24 }
25
26 /* Write pin control dword */
27 Method (GPWR, 0x2, Serialized)
28 {
29 /* Arg0 - GPIO pin control MMIO address */
30 /* Arg1 - Value for control register */
31 Local0 = Arg0
32 OperationRegion (GPDW, SystemMemory, Local0, 4)
33 Field (GPDW, AnyAcc, NoLock, Preserve) {
34 TEMP,32
35 }
36 TEMP = Arg1
37 }
38
39 /*
40 * Set GPIO Output Value
41 * Arg0 - GPIO Number
42 */
43 Method (STXS, 1, Serialized)
44 {
45 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
46 Field (GPDW, AnyAcc, NoLock, Preserve)
47 {
48 VAL0, 32
49 }
50 VAL0 |= GPIO_OUTPUT_VALUE
51 }
52
53 /*
54 * Clear GPIO Output Value
55 * Arg0 - GPIO Number
56 */
57 Method (CTXS, 1, Serialized)
58 {
59 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
60 Field (GPDW, AnyAcc, NoLock, Preserve)
61 {
62 VAL0, 32
63 }
64 VAL0 &= ~GPIO_OUTPUT_VALUE
65 }
66
67 /*
68 * Get GPIO Input Value
69 * Arg0 - GPIO Number
70 */
71 Method (GRXS, 1, Serialized)
72 {
73 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
74 Field (GPDW, AnyAcc, NoLock, Preserve)
75 {
76 VAL0, 32
77 }
78 Local0 = (GPIO_PIN_STS & VAL0) >> GPIO_PIN_STS_SHIFT
79
80 Return (Local0)
81 }
82
83 /*
84 * Get GPIO Output Value
85 * Arg0 - GPIO Number
86 */
87 Method (GTXS, 1, Serialized)
88 {
89 OperationRegion (GPDW, SystemMemory, GPAD (Arg0), 4)
90 Field (GPDW, AnyAcc, NoLock, Preserve)
91 {
92 VAL0, 32
93 }
94 Local0 = (GPIO_OUTPUT_VALUE & VAL0) >> GPIO_OUTPUT_SHIFT
95
96 Return (Local0)
97 }