blob: 74fd028bbe57109ab23191ecb4c52794247fe779 [file] [log] [blame]
Nico Huberae7c9682013-05-23 18:13:23 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20/* =================== Generic PnP Device =================== */
21
22/*
23 * Generic setup for PnP devices.
24 *
25 * Controlled by the following preprocessor defines:
26 *
27 * SUPERIO_CHIP_NAME The name of the super i/o chip (unique, required)
28 * SUPERIO_PNP_LDN The logical device number on the super i/o
29 * chip for this device (required)
30 * SUPERIO_PNP_DDN A string literal that identifies the dos device
31 * name (DDN) of this device (e.g. "COM1", optional)
32 * SUPERIO_PNP_PM_REG Identifier of a 1-bit register to power down
33 * the logical device (optional)
Nico Huberdd94fa92013-07-01 16:29:16 +020034 * SUPERIO_PNP_PM_VAL The value for SUPERIO_PNP_PM_REG to power the logical
35 * device down (required if SUPERIO_PNP_PM_REG is defined)
Nico Huberae7c9682013-05-23 18:13:23 +020036 * SUPERIO_PNP_PM_LDN The logical device number to access the PM_REG
37 * bit (required if SUPERIO_PNP_PM_REG is defined)
38 * SUPERIO_PNP_IO0 The alignment and length of the first PnP i/o
39 * resource (comma seperated, e.g. `0x02, 0x08`,
40 * optional)
41 * SUPERIO_PNP_IO1 The alignment and length of the second PnP i/o
42 * resource (comma seperated, e.g. `0x02, 0x08`,
43 * optional)
44 * SUPERIO_PNP_IRQ0 If defined, the first PnP IRQ register is enabled
45 * SUPERIO_PNP_IRQ1 If defined, the second PnP IRQ register is enabled
46 * SUPERIO_PNP_DMA If defined, the PnP DMA register is enabled
47 */
48
49#include "pnp.asl"
50
51#ifndef SUPERIO_CHIP_NAME
52# error "SUPERIO_CHIP_NAME is not defined."
53#endif
54
55#ifndef SUPERIO_PNP_LDN
56# error "SUPERIO_PNP_LDN is not defined."
57#endif
58
59Device (SUPERIO_ID(PN, SUPERIO_PNP_LDN)) {
60 Name (_HID, EisaId ("PNP0c02")) /* TODO: Better fitting EisaId? */
61 Name (_UID, SUPERIO_UID(PN, SUPERIO_PNP_LDN))
62 #ifdef SUPERIO_PNP_DDN
63 Name (_DDN, SUPERIO_PNP_DDN)
64 #endif
65
66 Method (_STA)
67 {
68 PNP_GENERIC_STA(SUPERIO_PNP_LDN)
69 }
70
71 Method (_DIS)
72 {
73 PNP_GENERIC_DIS(SUPERIO_PNP_LDN)
74 }
75
76#ifdef SUPERIO_PNP_PM_REG
77 Method (_PSC) {
Nico Huberdd94fa92013-07-01 16:29:16 +020078 PNP_GENERIC_PSC(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020079 }
80
81 Method (_PS0) {
Nico Huberdd94fa92013-07-01 16:29:16 +020082 PNP_GENERIC_PS0(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020083 }
84
85 Method (_PS1) {
Nico Huberdd94fa92013-07-01 16:29:16 +020086 PNP_GENERIC_PS1(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020087 }
88#else
89 Method (_PSC) {
90 PNP_DEFAULT_PSC
91 }
92#endif
93
94 Method (_CRS)
95 {
96 Name (CRS, ResourceTemplate () {
97#ifdef SUPERIO_PNP_IO0
98 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0)
99#endif
100#ifdef SUPERIO_PNP_IO1
101 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1)
102#endif
103#ifdef SUPERIO_PNP_IRQ0
104 IRQNoFlags (IR0) {}
105#endif
106#ifdef SUPERIO_PNP_IRQ1
107 IRQNoFlags (IR1) {}
108#endif
109#ifdef SUPERIO_PNP_DMA
110 DMA (Compatibility, NotBusMaster, Transfer8, DM0) {}
111#endif
112 })
113 ENTER_CONFIG_MODE (SUPERIO_PNP_LDN)
114#ifdef SUPERIO_PNP_IO0
115 PNP_READ_IO(PNP_IO0, CRS, IO0)
116#endif
117#ifdef SUPERIO_PNP_IO1
118 PNP_READ_IO(PNP_IO1, CRS, IO1)
119#endif
120#ifdef SUPERIO_PNP_IRQ0
121 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
122#endif
123#ifdef SUPERIO_PNP_IRQ1
124 PNP_READ_IRQ(PNP_IRQ1, CRS, IR1)
125#endif
126#ifdef SUPERIO_PNP_DMA
127 PNP_READ_DMA(PNP_DMA0, CRS, DM0)
128#endif
129 EXIT_CONFIG_MODE ()
130 Return (CRS)
131 }
132
133 Method (_SRS, 1, Serialized)
134 {
135 Name (TMPL, ResourceTemplate () {
136#ifdef SUPERIO_PNP_IO0
137 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0)
138#endif
139#ifdef SUPERIO_PNP_IO1
140 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1)
141#endif
142#ifdef SUPERIO_PNP_IRQ0
143 IRQNoFlags (IR0) {}
144#endif
145#ifdef SUPERIO_PNP_IRQ1
146 IRQNoFlags (IR1) {}
147#endif
148#ifdef SUPERIO_PNP_DMA
149 DMA (Compatibility, NotBusMaster, Transfer8, DM0) {}
150#endif
151 })
152 ENTER_CONFIG_MODE (SUPERIO_PNP_LDN)
153#ifdef SUPERIO_PNP_IO0
154 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
155#endif
156#ifdef SUPERIO_PNP_IO1
157 PNP_WRITE_IO(PNP_IO1, Arg0, IO1)
158#endif
159#ifdef SUPERIO_PNP_IRQ0
160 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
161#endif
162#ifdef SUPERIO_PNP_IRQ1
163 PNP_WRITE_IRQ(PNP_IRQ1, Arg0, IR1)
164#endif
165#ifdef SUPERIO_PNP_DMA
166 PNP_WRITE_DMA(PNP_DMA0, Arg0, DM0)
167#endif
168 Store (One, PNP_DEVICE_ACTIVE)
169 EXIT_CONFIG_MODE ()
170 }
171}