blob: 1bbdb37fa6ccc533274d88d361b251cf31d26d8c [file] [log] [blame]
Nico Huberae7c9682013-05-23 18:13:23 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Christoph Grenz <christophg+cb@grenz-bonn.de>
5 * Copyright (C) 2013 secunet Security Networks AG
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Nico Huberae7c9682013-05-23 18:13:23 +020015 */
16
17/* ========================== UART ========================== */
18
19/*
20 * Generic setup for 16550A compatible UARTs.
21 *
22 * Controlled by the following preprocessor defines:
23 *
24 * SUPERIO_CHIP_NAME The name of the super i/o chip (unique, required)
25 * SUPERIO_UART_LDN The logical device number on the super i/o
26 * chip for this UART (required)
27 * SUPERIO_UART_DDN A string literal that identifies the dos device
28 * name (DDN) of this uart (e.g. "COM1", optional)
29 * SUPERIO_UART_PM_REG Identifier of a 1-bit register to power down
30 * the UART (optional)
Nico Huberdd94fa92013-07-01 16:29:16 +020031 * SUPERIO_UART_PM_VAL The value for SUPERIO_UART_PM_REG to power the logical
32 * device down (required if SUPERIO_UART_PM_REG is defined)
33 * SUPERIO_UART_PM_LDN The logical device number to access the PM_REG
Nico Huberae7c9682013-05-23 18:13:23 +020034 * bit (required if SUPERIO_UART_PM_REG is defined)
35 */
36
37#include "pnp.asl"
38
39#ifndef SUPERIO_CHIP_NAME
40# error "SUPERIO_CHIP_NAME is not defined."
41#endif
42
43#ifndef SUPERIO_UART_LDN
44# error "SUPERIO_UART_LDN is not defined."
45#endif
46
47Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) {
48 Name (_HID, EisaId ("PNP0501"))
49 Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN))
50 #ifdef SUPERIO_UART_DDN
51 Name (_DDN, SUPERIO_UART_DDN)
52 #endif
53
54 Method (_STA)
55 {
56 PNP_GENERIC_STA(SUPERIO_UART_LDN)
57 }
58
59 Method (_DIS)
60 {
61 PNP_GENERIC_DIS(SUPERIO_UART_LDN)
62 }
63
64#ifdef SUPERIO_UART_PM_REG
65 Method (_PSC) {
Nico Huberdd94fa92013-07-01 16:29:16 +020066 PNP_GENERIC_PSC(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020067 }
68
69 Method (_PS0) {
Nico Huberdd94fa92013-07-01 16:29:16 +020070 PNP_GENERIC_PS0(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020071 }
72
73 Method (_PS1) {
Nico Huberdd94fa92013-07-01 16:29:16 +020074 PNP_GENERIC_PS1(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020075 }
76#else
77 Method (_PSC) {
78 PNP_DEFAULT_PSC
79 }
80#endif
81
82 Method (_CRS)
83 {
84 Name (CRS, ResourceTemplate () {
85 IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0)
86 IRQNoFlags (IR0) {}
87 })
88 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
89 PNP_READ_IO(PNP_IO0, CRS, IO0)
90 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
91 EXIT_CONFIG_MODE ()
92 Return (CRS)
93 }
94
95 Name (_PRS, ResourceTemplate ()
96 {
97 StartDependentFn (0,0) {
98 IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08)
99 IRQNoFlags () {3,4,5,7,9,10,11,12}
100 }
101 StartDependentFn (0,0) {
102 IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08)
103 IRQNoFlags () {3,4,5,7,9,10,11,12}
104 }
105 StartDependentFn (1,0) {
106 IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08)
107 IRQNoFlags () {3,4,5,7,9,10,11,12}
108 }
109 StartDependentFn (1,0) {
110 IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08)
111 IRQNoFlags () {3,4,5,7,9,10,11,12}
112 }
113 StartDependentFn (2,0) {
114 IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08)
115 IRQNoFlags () {3,4,5,7,9,10,11,12}
116 }
117 EndDependentFn()
118 })
119
120 Method (_SRS, 1, Serialized)
121 {
122 Name (TMPL, ResourceTemplate () {
123 IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0)
124 IRQNoFlags (IR0) {}
125 })
126 ENTER_CONFIG_MODE (SUPERIO_UART_LDN)
127 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
128 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
129 Store (One, PNP_DEVICE_ACTIVE)
130 EXIT_CONFIG_MODE ()
131 }
132}