1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Include this file into a mainboard's DSDT _SB device tree and it will
5 * expose the F81803A SuperIO and some of its functionality.
7 * It allows the change of IO ports, IRQs and DMA settings on logical
8 * devices, disabling and reenabling logical devices and controlling power
9 * saving mode on logical devices or the whole chip.
12 * 0x1 UARTA Implemented, partially tested
13 * 0x2 UARTB Implemented, partially tested
14 * 0x4 HWM Not implemented
15 * 0x5 KBC Not implemented
16 * 0x6 GPIO6 Not implemented
17 * 0x7 WDT0&PLED Not implemented
18 * 0xa ACPI/PME/ERP Partially implemented
20 * Controllable through preprocessor defines:
21 * SUPERIO_DEV Device identifier for this SIO (e.g. SIO0)
22 * SUPERIO_PNP_BASE I/o address of the first PnP configuration register
23 * F81803A_SHOW_UARTA If defined, UARTA will be exposed.
24 * F81803A_SHOW_UARTB If defined, UARTB will be exposed.
25 * F81803A_SHOW_HWMON If defined, the hardware monitor will be exposed.
26 * F81803A_SHOW_PME If defined, the PME/EARP/ACPI will be exposed.
29 * Do not enable UARTA and UARTB simultaneously, Linux boot will crash.
30 * Select one or the other.
32 #undef SUPERIO_CHIP_NAME
33 #define SUPERIO_CHIP_NAME F81803A
34 #include <superio/acpi/pnp.asl>
36 #undef PNP_DEFAULT_PSC
37 #define PNP_DEFAULT_PSC Return (0) /* no power management */
40 Name (_HID, EisaId("PNP0A05"))
41 Name (_STR, Unicode("Fintek F81803A Super I/O"))
42 Name (_UID, SUPERIO_UID(SUPERIO_DEV,))
44 /* Mutex for accesses to the configuration ports */
47 /* SuperIO configuration ports */
48 OperationRegion (CREG, SystemIO, SUPERIO_PNP_BASE, 0x02)
49 Field (CREG, ByteAcc, NoLock, Preserve)
54 IndexField (PNP_ADDR_REG, PNP_DATA_REG, ByteAcc, NoLock, Preserve)
57 PNP_LOGICAL_DEVICE, 8, /* Logical device selector */
59 PNP_DEVICE_ACTIVE, 1, /* Logical device activation */
61 PNP_IO0_HIGH_BYTE, 8, /* First I/O port base - high byte */
62 PNP_IO0_LOW_BYTE, 8, /* First I/O port base - low byte */
64 PNP_IO1_HIGH_BYTE, 8, /* Second I/O port base - high byte */
65 PNP_IO1_LOW_BYTE, 8, /* Second I/O port base - low byte */
67 PNP_IRQ0, 8, /* First IRQ */
69 APC5, 8, /* PME ACPI Control Register 5 */
74 /* Announce the used i/o ports to the OS */
75 Return (ResourceTemplate () {
76 IO (Decode16, SUPERIO_PNP_BASE, SUPERIO_PNP_BASE, 0x01, 0x02)
80 #undef PNP_ENTER_MAGIC_1ST
81 #undef PNP_ENTER_MAGIC_2ND
82 #undef PNP_ENTER_MAGIC_3RD
83 #undef PNP_ENTER_MAGIC_4TH
84 #undef PNP_EXIT_MAGIC_1ST
85 #undef PNP_EXIT_SPECIAL_REG
86 #undef PNP_EXIT_SPECIAL_VAL
87 #define PNP_ENTER_MAGIC_1ST 0x87
88 #define PNP_ENTER_MAGIC_2ND 0x87
89 #define PNP_EXIT_MAGIC_1ST 0xaa
90 #include <superio/acpi/pnp_config.asl>
92 #ifdef F81803A_SHOW_UARTA
93 #undef SUPERIO_UART_LDN
94 #undef SUPERIO_UART_PM_REG
95 #undef SUPERIO_UART_PM_VAL
96 #undef SUPERIO_UART_PM_LDN
97 #define SUPERIO_UART_LDN 1
99 Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) {
100 Name (_HID, EisaId ("PNP0501"))
101 Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN))
105 PNP_GENERIC_STA(SUPERIO_UART_LDN)
108 Method (_CRS, 0, Serialized)
110 Name (CRS, ResourceTemplate () {
111 IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0)
114 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
115 PNP_READ_IO(PNP_IO0, CRS, IO0)
116 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
121 Name (_PRS, ResourceTemplate ()
123 StartDependentFn (0,0) {
124 IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08)
125 IRQNoFlags () {3,4,5,7,9,10,11,12}
127 StartDependentFn (0,0) {
128 IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08)
129 IRQNoFlags () {3,4,5,7,9,10,11,12}
131 StartDependentFn (1,0) {
132 IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08)
133 IRQNoFlags () {3,4,5,7,9,10,11,12}
135 StartDependentFn (1,0) {
136 IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08)
137 IRQNoFlags () {3,4,5,7,9,10,11,12}
139 StartDependentFn (2,0) {
140 IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08)
141 IRQNoFlags () {3,4,5,7,9,10,11,12}
146 Method (_SRS, 1, Serialized)
148 Name (TMPL, ResourceTemplate () {
149 IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0)
152 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
153 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
154 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
155 PNP_DEVICE_ACTIVE = 1
161 #ifdef F81803A_SHOW_UARTB
162 #undef SUPERIO_UART_LDN
163 #undef SUPERIO_UART_PM_REG
164 #undef SUPERIO_UART_PM_VAL
165 #undef SUPERIO_UART_PM_LDN
166 #define SUPERIO_UART_LDN 2
168 Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) {
169 Name (_HID, EisaId ("PNP0501"))
170 Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN))
174 PNP_GENERIC_STA(SUPERIO_UART_LDN)
177 Method (_CRS, 0, Serialized)
179 Name (CRS, ResourceTemplate () {
180 IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0)
183 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
184 PNP_READ_IO(PNP_IO0, CRS, IO0)
185 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
190 Name (_PRS, ResourceTemplate ()
192 StartDependentFn (0,0) {
193 IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08)
194 IRQNoFlags () {3,4,5,7,9,10,11,12}
196 StartDependentFn (0,0) {
197 IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08)
198 IRQNoFlags () {3,4,5,7,9,10,11,12}
200 StartDependentFn (1,0) {
201 IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08)
202 IRQNoFlags () {3,4,5,7,9,10,11,12}
204 StartDependentFn (1,0) {
205 IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08)
206 IRQNoFlags () {3,4,5,7,9,10,11,12}
208 StartDependentFn (2,0) {
209 IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08)
210 IRQNoFlags () {3,4,5,7,9,10,11,12}
215 Method (_SRS, 1, Serialized)
217 Name (TMPL, ResourceTemplate () {
218 IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0)
221 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
222 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
223 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
224 PNP_DEVICE_ACTIVE = 1
230 #ifdef F81803A_SHOW_PME
231 #undef SUPERIO_PME_LDN
232 #define SUPERIO_PME_LDN 0x0A
234 OperationRegion(APCx, SystemIO, APC5, 0x01)
235 Field(APCx, ByteAcc, Nolock, Preserve) /* bits in PME ACPI CONTROL Reg 5*/
237 , 7, /*Control Reg 5 */
238 PSIN, 1 /* PSIN_FLAG */
241 /* routine to clear PSIN_FLAG in ACPI_CONTROL_REG_5 of SIO */
242 Method(CPSI, 0, Serialized)
244 /* DBG0("SIO CPSI") */
245 ENTER_CONFIG_MODE(SUPERIO_PME_LDN)