blob: b5b22f7bb7e1feec61036bb7c729e38a379a945b [file] [log] [blame]
Felix Held3f3eca92020-01-23 17:12:32 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Nico Huberae7c9682013-05-23 18:13:23 +02002
3/* ========================== UART ========================== */
4
5/*
6 * Generic setup for 16550A compatible UARTs.
7 *
8 * Controlled by the following preprocessor defines:
9 *
Elyes HAOUAS495bb662019-09-23 13:15:41 +020010 * SUPERIO_CHIP_NAME The name of the Super I/O chip (unique, required)
11 * SUPERIO_UART_LDN The logical device number on the Super I/O
Nico Huberae7c9682013-05-23 18:13:23 +020012 * chip for this UART (required)
13 * SUPERIO_UART_DDN A string literal that identifies the dos device
Elyes HAOUAS45808392020-03-30 16:43:34 +020014 * name (DDN) of this uart (e.g. "COM1", optional)
Nico Huberae7c9682013-05-23 18:13:23 +020015 * SUPERIO_UART_PM_REG Identifier of a 1-bit register to power down
16 * the UART (optional)
Nico Huberdd94fa92013-07-01 16:29:16 +020017 * SUPERIO_UART_PM_VAL The value for SUPERIO_UART_PM_REG to power the logical
18 * device down (required if SUPERIO_UART_PM_REG is defined)
19 * SUPERIO_UART_PM_LDN The logical device number to access the PM_REG
Nico Huberae7c9682013-05-23 18:13:23 +020020 * bit (required if SUPERIO_UART_PM_REG is defined)
21 */
22
23#include "pnp.asl"
24
25#ifndef SUPERIO_CHIP_NAME
26# error "SUPERIO_CHIP_NAME is not defined."
27#endif
28
29#ifndef SUPERIO_UART_LDN
30# error "SUPERIO_UART_LDN is not defined."
31#endif
32
33Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) {
34 Name (_HID, EisaId ("PNP0501"))
35 Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN))
36 #ifdef SUPERIO_UART_DDN
37 Name (_DDN, SUPERIO_UART_DDN)
38 #endif
39
40 Method (_STA)
41 {
42 PNP_GENERIC_STA(SUPERIO_UART_LDN)
43 }
44
45 Method (_DIS)
46 {
47 PNP_GENERIC_DIS(SUPERIO_UART_LDN)
48 }
49
50#ifdef SUPERIO_UART_PM_REG
51 Method (_PSC) {
Nico Huberdd94fa92013-07-01 16:29:16 +020052 PNP_GENERIC_PSC(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020053 }
54
55 Method (_PS0) {
Nico Huberdd94fa92013-07-01 16:29:16 +020056 PNP_GENERIC_PS0(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020057 }
58
Nico Huber79dfa902020-03-22 01:17:54 +010059 Method (_PS3) {
60 PNP_GENERIC_PS3(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020061 }
62#else
63 Method (_PSC) {
64 PNP_DEFAULT_PSC
65 }
66#endif
67
Tristan Corrick8f731b82018-08-01 03:08:53 +120068 Method (_CRS, 0, Serialized)
Nico Huberae7c9682013-05-23 18:13:23 +020069 {
70 Name (CRS, ResourceTemplate () {
71 IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0)
72 IRQNoFlags (IR0) {}
73 })
74 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
75 PNP_READ_IO(PNP_IO0, CRS, IO0)
76 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
77 EXIT_CONFIG_MODE ()
78 Return (CRS)
79 }
80
81 Name (_PRS, ResourceTemplate ()
82 {
83 StartDependentFn (0,0) {
84 IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08)
85 IRQNoFlags () {3,4,5,7,9,10,11,12}
86 }
87 StartDependentFn (0,0) {
88 IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08)
89 IRQNoFlags () {3,4,5,7,9,10,11,12}
90 }
91 StartDependentFn (1,0) {
92 IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08)
93 IRQNoFlags () {3,4,5,7,9,10,11,12}
94 }
95 StartDependentFn (1,0) {
96 IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08)
97 IRQNoFlags () {3,4,5,7,9,10,11,12}
98 }
99 StartDependentFn (2,0) {
100 IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08)
101 IRQNoFlags () {3,4,5,7,9,10,11,12}
102 }
103 EndDependentFn()
104 })
105
106 Method (_SRS, 1, Serialized)
107 {
108 Name (TMPL, ResourceTemplate () {
109 IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0)
110 IRQNoFlags (IR0) {}
111 })
112 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
113 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
114 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
Felix Singerca4b5872022-12-26 08:17:06 +0100115 PNP_DEVICE_ACTIVE = 1
Nico Huberae7c9682013-05-23 18:13:23 +0200116 EXIT_CONFIG_MODE ()
117 }
118}