• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* SPDX-License-Identifier: GPL-2.0-only */
2
3/* ========================== UART ========================== */
4
5/*
6 * Generic setup for 16550A compatible UARTs.
7 *
8 * Controlled by the following preprocessor defines:
9 *
10 * 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
12 *			chip for this UART (required)
13 * SUPERIO_UART_DDN	A string literal that identifies the dos device
14 *			name (DDN) of this uart (e.g. "COM1", optional)
15 * SUPERIO_UART_PM_REG	Identifier of a 1-bit register to power down
16 *			the UART (optional)
17 * 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
20 *			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) {
52		PNP_GENERIC_PSC(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
53	}
54
55	Method (_PS0) {
56		PNP_GENERIC_PS0(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
57	}
58
59	Method (_PS3) {
60		PNP_GENERIC_PS3(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
61	}
62#else
63	Method (_PSC) {
64		PNP_DEFAULT_PSC
65	}
66#endif
67
68	Method (_CRS, 0, Serialized)
69	{
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)
115		  PNP_DEVICE_ACTIVE = 1
116		EXIT_CONFIG_MODE ()
117	}
118}
119