blob: 980404efddfb7675bf81afbfd781477feb0a2110 [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.
Nico Huberae7c9682013-05-23 18:13:23 +020014 */
15
16/* =================== Generic PnP Device =================== */
17
18/*
19 * Generic setup for PnP devices.
20 *
21 * Controlled by the following preprocessor defines:
22 *
23 * SUPERIO_CHIP_NAME The name of the super i/o chip (unique, required)
Samuel Hollandd2a86da2017-06-06 20:23:40 -050024 * SUPERIO_PNP_HID The EisaId string that identifies this device (optional)
Nico Huberae7c9682013-05-23 18:13:23 +020025 * SUPERIO_PNP_LDN The logical device number on the super i/o
26 * chip for this device (required)
27 * SUPERIO_PNP_DDN A string literal that identifies the dos device
28 * name (DDN) of this device (e.g. "COM1", optional)
29 * SUPERIO_PNP_PM_REG Identifier of a 1-bit register to power down
30 * the logical device (optional)
Nico Huberdd94fa92013-07-01 16:29:16 +020031 * SUPERIO_PNP_PM_VAL The value for SUPERIO_PNP_PM_REG to power the logical
32 * device down (required if SUPERIO_PNP_PM_REG is defined)
Nico Huberae7c9682013-05-23 18:13:23 +020033 * SUPERIO_PNP_PM_LDN The logical device number to access the PM_REG
34 * bit (required if SUPERIO_PNP_PM_REG is defined)
35 * SUPERIO_PNP_IO0 The alignment and length of the first PnP i/o
Samuel Hollandeeef6452017-06-03 05:51:10 -050036 * resource (comma separated, e.g. `0x02, 0x08`,
Nico Huberae7c9682013-05-23 18:13:23 +020037 * optional)
38 * SUPERIO_PNP_IO1 The alignment and length of the second PnP i/o
Samuel Hollandeeef6452017-06-03 05:51:10 -050039 * resource (comma separated, e.g. `0x02, 0x08`,
40 * optional)
41 * SUPERIO_PNP_IO2 The alignment and length of the third PnP i/o
42 * resource (comma separated, e.g. `0x02, 0x08`,
Nico Huberae7c9682013-05-23 18:13:23 +020043 * 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)) {
Samuel Hollandd2a86da2017-06-06 20:23:40 -050060 #ifdef SUPERIO_PNP_HID
61 Name (_HID, EisaId (SUPERIO_PNP_HID))
62 #else
Nico Huberae7c9682013-05-23 18:13:23 +020063 Name (_HID, EisaId ("PNP0c02")) /* TODO: Better fitting EisaId? */
Samuel Hollandd2a86da2017-06-06 20:23:40 -050064 #endif
Nico Huberae7c9682013-05-23 18:13:23 +020065 Name (_UID, SUPERIO_UID(PN, SUPERIO_PNP_LDN))
66 #ifdef SUPERIO_PNP_DDN
67 Name (_DDN, SUPERIO_PNP_DDN)
68 #endif
69
70 Method (_STA)
71 {
72 PNP_GENERIC_STA(SUPERIO_PNP_LDN)
73 }
74
75 Method (_DIS)
76 {
77 PNP_GENERIC_DIS(SUPERIO_PNP_LDN)
78 }
79
80#ifdef SUPERIO_PNP_PM_REG
81 Method (_PSC) {
Nico Huberdd94fa92013-07-01 16:29:16 +020082 PNP_GENERIC_PSC(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020083 }
84
85 Method (_PS0) {
Nico Huberdd94fa92013-07-01 16:29:16 +020086 PNP_GENERIC_PS0(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020087 }
88
89 Method (_PS1) {
Nico Huberdd94fa92013-07-01 16:29:16 +020090 PNP_GENERIC_PS1(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN)
Nico Huberae7c9682013-05-23 18:13:23 +020091 }
92#else
93 Method (_PSC) {
94 PNP_DEFAULT_PSC
95 }
96#endif
97
Tristan Corrick8f731b82018-08-01 03:08:53 +120098 Method (_CRS, 0, Serialized)
Nico Huberae7c9682013-05-23 18:13:23 +020099 {
100 Name (CRS, ResourceTemplate () {
101#ifdef SUPERIO_PNP_IO0
102 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0)
103#endif
104#ifdef SUPERIO_PNP_IO1
105 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1)
106#endif
Samuel Hollandeeef6452017-06-03 05:51:10 -0500107#ifdef SUPERIO_PNP_IO2
108 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO2, IO2)
109#endif
Nico Huberae7c9682013-05-23 18:13:23 +0200110#ifdef SUPERIO_PNP_IRQ0
111 IRQNoFlags (IR0) {}
112#endif
113#ifdef SUPERIO_PNP_IRQ1
114 IRQNoFlags (IR1) {}
115#endif
116#ifdef SUPERIO_PNP_DMA
117 DMA (Compatibility, NotBusMaster, Transfer8, DM0) {}
118#endif
119 })
120 ENTER_CONFIG_MODE (SUPERIO_PNP_LDN)
121#ifdef SUPERIO_PNP_IO0
122 PNP_READ_IO(PNP_IO0, CRS, IO0)
123#endif
124#ifdef SUPERIO_PNP_IO1
125 PNP_READ_IO(PNP_IO1, CRS, IO1)
126#endif
Samuel Hollandeeef6452017-06-03 05:51:10 -0500127#ifdef SUPERIO_PNP_IO2
128 PNP_READ_IO(PNP_IO2, CRS, IO2)
129#endif
Nico Huberae7c9682013-05-23 18:13:23 +0200130#ifdef SUPERIO_PNP_IRQ0
131 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
132#endif
133#ifdef SUPERIO_PNP_IRQ1
134 PNP_READ_IRQ(PNP_IRQ1, CRS, IR1)
135#endif
136#ifdef SUPERIO_PNP_DMA
137 PNP_READ_DMA(PNP_DMA0, CRS, DM0)
138#endif
139 EXIT_CONFIG_MODE ()
140 Return (CRS)
141 }
142
143 Method (_SRS, 1, Serialized)
144 {
145 Name (TMPL, ResourceTemplate () {
146#ifdef SUPERIO_PNP_IO0
147 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0)
148#endif
149#ifdef SUPERIO_PNP_IO1
150 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1)
151#endif
Samuel Hollandeeef6452017-06-03 05:51:10 -0500152#ifdef SUPERIO_PNP_IO2
153 IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO2, IO2)
154#endif
Nico Huberae7c9682013-05-23 18:13:23 +0200155#ifdef SUPERIO_PNP_IRQ0
156 IRQNoFlags (IR0) {}
157#endif
158#ifdef SUPERIO_PNP_IRQ1
159 IRQNoFlags (IR1) {}
160#endif
161#ifdef SUPERIO_PNP_DMA
162 DMA (Compatibility, NotBusMaster, Transfer8, DM0) {}
163#endif
164 })
165 ENTER_CONFIG_MODE (SUPERIO_PNP_LDN)
166#ifdef SUPERIO_PNP_IO0
167 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
168#endif
169#ifdef SUPERIO_PNP_IO1
170 PNP_WRITE_IO(PNP_IO1, Arg0, IO1)
171#endif
Samuel Hollandeeef6452017-06-03 05:51:10 -0500172#ifdef SUPERIO_PNP_IO2
173 PNP_WRITE_IO(PNP_IO2, Arg0, IO2)
174#endif
Nico Huberae7c9682013-05-23 18:13:23 +0200175#ifdef SUPERIO_PNP_IRQ0
176 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
177#endif
178#ifdef SUPERIO_PNP_IRQ1
179 PNP_WRITE_IRQ(PNP_IRQ1, Arg0, IR1)
180#endif
181#ifdef SUPERIO_PNP_DMA
182 PNP_WRITE_DMA(PNP_DMA0, Arg0, DM0)
183#endif
184 Store (One, PNP_DEVICE_ACTIVE)
185 EXIT_CONFIG_MODE ()
186 }
187}