blob: b2dffc63b868631d526b26759015a2bdbdecc8ba [file] [log] [blame]
Felix Held3f3eca92020-01-23 17:12:32 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Christoph Grenz8ae574c2011-09-18 22:53:18 +02002
3/*
Christoph Grenze3e641c2011-11-05 22:14:41 +01004 * include this file into a mainboard's DSDT _SB device tree and it will expose the
5 * W83627HF SuperIO and its functionality.
Christoph Grenz8ae574c2011-09-18 22:53:18 +02006 *
Martin Roth2ed0aa22016-01-05 20:58:58 -07007 * Devices are marked as nonexistent if they got 0x00000000 as I/O base address
Christoph Grenz8ae574c2011-09-18 22:53:18 +02008 * (compatibility with legacy bios, which disables logical devices that way)
9 *
10 * It allows the change of IO ports, IRQs and DMA settings on most logical
11 * devices, disabling and reenabling logical devices and controlling power
12 * saving mode on logical devices or the whole chip.
13 *
14 * Notes:
15 * - ECP mode of parallel port not implemented, DMA settings of parallel port
16 * will be reset on DSDT init
17 * - Hardware monitor is only shown as "Motherboard Resource", shows no real
18 * functionality
19 *
20 * Controllable through preprocessor macros:
21 * NO_W83627HF_FDC: don't expose the floppy disk controller
22 * NO_W83627HF_FDC_ENUM: don't try to enumerate the connected floppy drives
23 * NO_W83627HF_PPORT: don't expose the parallel port
24 * NO_W83627HF_UARTA: don't expose the first serial port
25 * NO_W83627HF_UARTB: don't expose the second serial port (already hidden
26 * if UARTB is configured as IRDA port by firmware)
27 * NO_W83627HF_IRDA: don't expose the IRDA port (already hidden if UARTB is
28 * configured as serial port by firmware)
29 * NO_W83627HF_CIR: don't expose the Consumer Infrared functionality
30 * NO_W83627HF_KBC: don't expose the keyboard controller
31 * NO_W83627HF_PS2M: don't expose the PS/2 mouse functionality of the
32 * keyboard controller
33 * NO_W83627HF_GAME: don't expose the game port
34 * NO_W83627HF_MIDI: don't expose the MIDI port
35 * NO_W83627HF_HWMON: don't expose the hardware monitor as
Martin Roth26f97f92021-10-01 14:53:22 -060036 * PnP "Motherboard Resource"
Christoph Grenz287ca502011-11-05 23:39:20 +010037 * W83627HF_KBC_COMPAT: show the keyboard controller and the PS/2 mouse as
38 * enabled if it is disabled but an address is assigned
Martin Roth26f97f92021-10-01 14:53:22 -060039 * to it. This may be necessary in some cases.
Christoph Grenz8ae574c2011-09-18 22:53:18 +020040 *
41 * Datasheet: "W83627HF/F WINBOND I/O" rev. 6.0
42 * http://www.itox.com/pages/support/wdt/W83627HF.pdf
43 */
44
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +020045#include <superio/acpi/pnp.asl>
46
Christoph Grenze3e641c2011-11-05 22:14:41 +010047Device(SIO) {
48 Name (_HID, EisaId("PNP0A05"))
49 Name (_STR, Unicode("Winbond W83627HF SuperIO"))
50 Name (_UID, "w83627hf")
Christoph Grenz8ae574c2011-09-18 22:53:18 +020051
Christoph Grenze3e641c2011-11-05 22:14:41 +010052 /* Mutex for accesses to the configuration ports (prolog and epilog commands are used, so synchronization is useful) */
53 Mutex(CRMX, 1)
Christoph Grenz8ae574c2011-09-18 22:53:18 +020054
Christoph Grenze3e641c2011-11-05 22:14:41 +010055 /* SuperIO configuration ports */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +020056 OperationRegion (CREG, SystemIO, SUPERIO_PNP_BASE, 0x02)
Christoph Grenze3e641c2011-11-05 22:14:41 +010057 Field (CREG, ByteAcc, NoLock, Preserve)
58 {
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +020059 PNP_ADDR_REG, 8,
60 PNP_DATA_REG, 8
Christoph Grenze3e641c2011-11-05 22:14:41 +010061 }
Elyes HAOUAS007af422019-11-03 14:31:35 +010062 IndexField (PNP_ADDR_REG, PNP_DATA_REG, ByteAcc, NoLock, Preserve)
Christoph Grenze3e641c2011-11-05 22:14:41 +010063 {
64 Offset (0x02),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +020065 RST, 1, /* Soft reset */
66 , 7,
Christoph Grenze3e641c2011-11-05 22:14:41 +010067 Offset (0x07),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +020068 LDN, 8, /* Logical device selector */
Christoph Grenze3e641c2011-11-05 22:14:41 +010069 Offset (0x20),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +020070 DID, 8, /* Device ID */
71 DREV, 8, /* Device Revision */
72 FDPW, 1, /* FDC Power Down */
73 , 2,
74 PRPW, 1, /* PRT Power Down */
75 UAPW, 1, /* UART A Power Down */
76 UBPW, 1, /* UART B Power Down */
77 HWPW, 1, /* HWM Power Down */
78 , 1,
79 IPD, 1, /* Immediate Chip Power Down */
80 , 7,
81 PNPS, 1, /* PnP Address Select Register Default Value Mode */
82 , 1,
83 KBCR, 1, /* KBC enabled after system reset (read-only) */
84 , 3,
85 CLKS, 1, /* Clock select */
86 AQ16, 1, /* 16bit Address Qualification */
87 FDCT, 1, /* Tristate FDC (?) */
88 , 2,
89 PRTT, 1, /* Tristate parallel port (?) */
90 URAT, 1, /* Tristate UART A (?) */
91 URBT, 1, /* Tristate UART B (?) */
92 , 2,
93 URAI, 1, /* UART A Legacy IRQ Select Disable */
94 URBI, 1, /* UART B Legacy IRQ Select Disable */
95 PRTI, 1, /* Parallel Port Legacy IRQ/DRQ Select Disable */
96 FDCI, 1, /* FDC Legacy IRQ/DRQ Select Disable */
97 , 1,
98 LCKC, 1, /* Lock Configuration Registers */
Christoph Grenze3e641c2011-11-05 22:14:41 +010099 Offset (0x29),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200100 IO3S, 8, /* GPIO3 pin selection register */
Nico Huberf66dd692013-07-03 12:07:43 +0200101 Offset (0x30),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200102 ACTR, 1, /* Logical device activation */
103 ACT1, 1, /* Logical part activation 1 (mostly unused) */
104 ACT2, 1, /* Logical part activation 2 (mostly unused) */
105 , 5,
Christoph Grenze3e641c2011-11-05 22:14:41 +0100106 Offset (0x60),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200107 IO1H, 8, /* First I/O port base - high byte */
108 IO1L, 8, /* First I/O port base - low byte */
109 IO2H, 8, /* Second I/O port base - high byte */
110 IO2L, 8, /* Second I/O port base - low byte */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100111 Offset (0x70),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200112 IRQ0, 8, /* First IRQ */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100113 Offset (0x72),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200114 IRQ1, 8, /* First IRQ */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100115 Offset (0x74),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200116 DMA0, 8, /* DMA */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100117 Offset (0xE0),
Martin Roth26f97f92021-10-01 14:53:22 -0600118 /* CRE0-CRE4: function logical device dependent, seems to be reserved for ACPI settings */
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200119 CRE0, 8,
120 CRE1, 8,
121 CRE2, 8,
122 CRE3, 8,
123 CRE4, 8,
Christoph Grenze3e641c2011-11-05 22:14:41 +0100124 Offset (0xF0),
Martin Roth26f97f92021-10-01 14:53:22 -0600125 /* OPT1-OPTA aka CRF0-CRF9: function logical device dependent */
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200126 OPT1, 8,
127 OPT2, 8,
128 OPT3, 8,
129 OPT4, 8,
130 OPT5, 8,
131 OPT6, 8,
132 OPT7, 8,
133 OPT8, 8,
134 OPT9, 8,
135 OPTA, 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100136 }
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200137
Christoph Grenz287ca502011-11-05 23:39:20 +0100138 Method (_CRS)
139 {
140 Return (ResourceTemplate () {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200141 /* Announce the used I/O ports to the OS */
142 IO (Decode16, SUPERIO_PNP_BASE, SUPERIO_PNP_BASE, 0x02, 0x01)
Christoph Grenz287ca502011-11-05 23:39:20 +0100143 })
144 }
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200145
Martin Roth26f97f92021-10-01 14:53:22 -0600146 /* Enter configuration mode (and acquire mutex)
Elyes HAOUAS89c05c52021-02-09 14:18:19 +0100147 Method must be run before accessing the configuration region.
Christoph Grenz287ca502011-11-05 23:39:20 +0100148 Parameter is the LDN which should be accessed. Values >= 0xFF mean
149 no LDN switch should be done.
Christoph Grenze3e641c2011-11-05 22:14:41 +0100150 */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200151 Method (ENTER_CONFIG_MODE, 1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100152 {
153 Acquire (CRMX, 0xFFFF)
Felix Singerfa070962022-12-12 04:43:21 +0100154 ADDR = 0x87
155 ADDR = 0x87
Felix Singerd67ed592022-01-02 01:42:31 +0100156 If (Arg0 < 0xFF) {
Felix Singerfa070962022-12-12 04:43:21 +0100157 LDN = Arg0
Christoph Grenz287ca502011-11-05 23:39:20 +0100158 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100159 }
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200160
Christoph Grenze3e641c2011-11-05 22:14:41 +0100161 /* Exit configuration mode (and release mutex)
162 Method must be run after accessing the configuration region.
163 */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200164 Method (EXIT_CONFIG_MODE)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100165 {
Felix Singerfa070962022-12-12 04:43:21 +0100166 ADDR = 0xAA
Christoph Grenz287ca502011-11-05 23:39:20 +0100167 Release (CRMX)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100168 }
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200169
Nico Huber79dfa902020-03-22 01:17:54 +0100170 /* PM: indicate IPD (Immediate Power Down) bit state as D0/D3 */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100171 Method (_PSC) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200172 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100173 Local0 = IPD
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200174 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100175 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100176 Else { Return (0) }
177 }
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200178
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200179 /* PM: Switch to D0 by setting IPD low */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100180 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200181 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100182 IPD = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200183 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100184 }
185
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200186 /* PM: Switch to D3 by setting IPD high */
Nico Huber79dfa902020-03-22 01:17:54 +0100187 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200188 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100189 IPD = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200190 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100191 }
192
193 #ifndef NO_W83627HF_FDC
194 /* =================== Floppy Disk Controller ================ */
195 Device (FDC0) {
196 Name (_HID, EisaId ("PNP0700"))
197 Name (_STR, Unicode ("W83627HF Floppy Disk Controller"))
198 Name (_UID, "w83627hf-fdc")
199
Christoph Grenze3e641c2011-11-05 22:14:41 +0100200 Method (_STA)
201 {
Felix Singerfa070962022-12-12 04:43:21 +0100202 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200203 ENTER_CONFIG_MODE (0)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100204 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100205 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100206 }
Felix Singer5a303b02021-12-31 13:12:16 +0100207 ElseIf (IO1H || IO1L)
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200208 {
Felix Singerfa070962022-12-12 04:43:21 +0100209 Local0 = 0x0D
Christoph Grenz8ae574c2011-09-18 22:53:18 +0200210 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200211 EXIT_CONFIG_MODE ()
Christoph Grenzb9da3cd2011-10-19 02:25:08 +0200212 Return (Local0)
213 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100214
Christoph Grenz287ca502011-11-05 23:39:20 +0100215 /* Current power state (Returns 1 if LDN in power saving mode,
216 * 2 if whole chip is powered down), 0 else
217 */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100218 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100219 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100220 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200221 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100222 Local0 = FDPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200223 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100224 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100225 Else { Return (0) }
226 }
Christoph Grenz287ca502011-11-05 23:39:20 +0100227 /* Disable power saving mode */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100228 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200229 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100230 FDPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200231 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100232 }
Christoph Grenz287ca502011-11-05 23:39:20 +0100233 /* Enable power saving mode */
Nico Huber79dfa902020-03-22 01:17:54 +0100234 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200235 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100236 FDPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200237 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100238 }
239
240 Method (_DIS)
241 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200242 ENTER_CONFIG_MODE (0)
Felix Singerfa070962022-12-12 04:43:21 +0100243 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200244 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100245 }
246
247 Method (_CRS)
248 {
249 Name (CRS, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +0100250 IO (Decode16, 0x0000, 0x0000, 0x01, 0x07, IO0)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100251 IRQNoFlags () {6}
252 DMA (Compatibility, NotBusMaster, Transfer8) {2}
253 })
Christoph Grenz287ca502011-11-05 23:39:20 +0100254
255 /* Get IO port info */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200256 ENTER_CONFIG_MODE (0)
Felix Singerfa070962022-12-12 04:43:21 +0100257 Local0 = IO1L
258 Local1 = IO1H
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200259 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100260
Christoph Grenz287ca502011-11-05 23:39:20 +0100261 /* Calculate full IO port address */
Felix Singer86bc2e72022-12-16 04:40:39 +0100262 Local0 |= Local1 << 8
Christoph Grenz287ca502011-11-05 23:39:20 +0100263
264 /* Modify the resource template and return it */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100265 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100266 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100267 IMIN = Local0
268 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100269 Return (CRS)
270 }
271
Christoph Grenz287ca502011-11-05 23:39:20 +0100272 Method (_PRS)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100273 {
Christoph Grenz287ca502011-11-05 23:39:20 +0100274 Return (ResourceTemplate ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100275 {
Christoph Grenz287ca502011-11-05 23:39:20 +0100276 StartDependentFnNoPri ()
277 {
278 IO (Decode16, 0x03F0, 0x03F0, 0x01, 0x07)
279 IRQNoFlags () {6}
280 DMA (Compatibility, NotBusMaster, Transfer8) {2}
281 }
282 EndDependentFn ()
283 })
284 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100285
286 #ifndef NO_W83627HF_FDC_ENUM
Christoph Grenz70378402013-07-04 03:06:26 +0200287 Method (_FDE, 0) {
288 /* Try probing drives.
Christoph Grenze3e641c2011-11-05 22:14:41 +0100289 Probing is done through selecting and activating a drive
290 and reading 0x03F7 aka the "shared IDE and floppy register"
291 as any value there besides zero seems to indicate a
292 connected drive.
293 */
Christoph Grenz70378402013-07-04 03:06:26 +0200294 // Create template
295 Name(FDE, Buffer(){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
296 CreateByteField (FDE, 1, FD1)
297 CreateByteField (FDE, 4, FD2)
298 CreateByteField (FDE, 8, FD3)
299 CreateByteField (FDE, 12, FD4)
300
301 // Get resources from logical device
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200302 ENTER_CONFIG_MODE (0)
Felix Singerfa070962022-12-12 04:43:21 +0100303 Local0 = ACTR
304 Local1 = IO1H
305 Local2 = IO1L
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200306 EXIT_CONFIG_MODE ()
Felix Singer3c9291b2022-12-16 02:43:56 +0100307 Local1 <<= 8
Felix Singer86bc2e72022-12-16 04:40:39 +0100308 Local1 |= Local2
Felix Singer1a6925c2021-12-31 14:35:35 +0100309 If (!Local0) {
Christoph Grenz70378402013-07-04 03:06:26 +0200310 Return (FDE)
311 }
312
313 OperationRegion (FIO1, SystemIO, Local1, 0x06)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100314 Field (FIO1, ByteAcc, NoLock, Preserve)
315 {
316 Offset(0x02),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200317 SELE, 2,
318 RSTL, 1,
319 IDMA, 1,
320 ACT1, 1,
321 ACT2, 1,
322 ACT3, 1,
323 ACT4, 1,
Christoph Grenze3e641c2011-11-05 22:14:41 +0100324 Offset(0x04),
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200325 BSY1, 1,
326 BSY2, 1,
327 BSY3, 1,
328 BSY4, 1,
329 BUSY, 1,
330 NDMA, 1,
331 IODI, 1,
332 RDY, 1,
333 DATA, 8,
Christoph Grenze3e641c2011-11-05 22:14:41 +0100334 }
335 OperationRegion (FIO2, SystemIO, 0x3F7, 0x01)
Christoph Grenz0bd5dff2013-07-04 02:54:04 +0200336 Field (FIO2, ByteAcc, NoLock, Preserve)
337 {
338 SIFR, 8
339 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100340
Felix Singerfa070962022-12-12 04:43:21 +0100341 ACT1 = One
342 SELE = 0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100343 Sleep(0x64)
Felix Singerfa070962022-12-12 04:43:21 +0100344 If (SIFR) { FD1 = One }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100345
Felix Singerfa070962022-12-12 04:43:21 +0100346 ACT1 = Zero
347 ACT2 = One
348 SELE = 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100349 Sleep(0x64)
Felix Singerfa070962022-12-12 04:43:21 +0100350 If (SIFR) { FD2 = One }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100351
Felix Singerfa070962022-12-12 04:43:21 +0100352 ACT2 = Zero
353 ACT3 = One
354 SELE = 2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100355 Sleep(0x64)
Felix Singerfa070962022-12-12 04:43:21 +0100356 If (SIFR) { FD3 = One }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100357
Felix Singerfa070962022-12-12 04:43:21 +0100358 ACT3 = Zero
359 ACT4 = One
360 SELE = 3
Christoph Grenze3e641c2011-11-05 22:14:41 +0100361 Sleep(0x64)
Felix Singerfa070962022-12-12 04:43:21 +0100362 If (SIFR) { FD4 = One }
363 ACT4 = Zero
364 SELE = Zero
Christoph Grenz70378402013-07-04 03:06:26 +0200365
366 Return (FDE)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100367 }
Christoph Grenz70378402013-07-04 03:06:26 +0200368 #endif
Christoph Grenze3e641c2011-11-05 22:14:41 +0100369
370
371 Method (_SRS, 1, Serialized)
372 {
373 Name (TMPL, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +0100374 IO (Decode16, 0, 0, 1, 7, IO0)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100375 IRQNoFlags (IRQ0) {}
376 DMA (Compatibility, NotBusMaster, Transfer8, DMA0) {}
377 })
378 CreateWordField (Arg0, IO0._MIN, IOA0)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100379 CreateByteField (Arg0, IRQ0._INT, IRQL)
380 CreateByteField (Arg0, DMA0._DMA, DMCH)
381
382 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100383
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200384 ENTER_CONFIG_MODE (0)
Felix Singerfa070962022-12-12 04:43:21 +0100385 IO1L = Local0
386 IO1H = Local1
387 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200388 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100389 }
390 }
391 #endif
392
393 #ifndef NO_W83627HF_PPORT
394 /* ======================== Parallel Port ======================== */
395 /* Currently no ECP support */
396 Device (PAR0) {
397 Name (_HID, EisaId ("PNP0400"))
398 Name (_DDN, "LPT1")
399 Name (_UID, "w83627hf-pport")
400
401 Method (MODE, 1) {
402 And(Arg0, 0x07, Local0)
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200403 ENTER_CONFIG_MODE (1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100404 And(OPT1, 0x3, Local1)
Felix Singer86bc2e72022-12-16 04:40:39 +0100405 OPT1 = Local1 | Local0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200406 EXIT_CONFIG_MODE()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100407 }
408
409 Method (_INI)
410 {
411 /* Deactivate DMA, even if set by BIOS. We don't announce it
412 through _CRS and it's only useful in ECP mode which we
413 don't support at the moment. */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200414 ENTER_CONFIG_MODE (1)
Felix Singerfa070962022-12-12 04:43:21 +0100415 DMA0 = 0x04
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200416 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100417 }
418
419 Method (_STA)
420 {
Felix Singerfa070962022-12-12 04:43:21 +0100421 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200422 ENTER_CONFIG_MODE (1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100423 And(OPT1, 0x3, Local1)
424 If (ACTR) {
Felix Singer3cfbe8a2022-01-02 02:44:04 +0100425 If (Local1 != 2) {
Felix Singerfa070962022-12-12 04:43:21 +0100426 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100427 } Else {
Felix Singerfa070962022-12-12 04:43:21 +0100428 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100429 }
430 }
Felix Singer5a303b02021-12-31 13:12:16 +0100431 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100432 {
Felix Singerfa070962022-12-12 04:43:21 +0100433 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100434 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200435 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100436 Return (Local0)
437 }
438
439 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100440 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100441 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200442 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100443 Local0 = PRPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200444 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100445 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100446 Else { Return (0) }
447 }
448 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200449 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100450 PRPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200451 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100452 }
Nico Huber79dfa902020-03-22 01:17:54 +0100453 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200454 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100455 PRPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200456 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100457 }
458
459 Method (_DIS) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200460 ENTER_CONFIG_MODE (1)
Felix Singerfa070962022-12-12 04:43:21 +0100461 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200462 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100463 }
464
465 Method (_CRS)
466 {
467 Name (CRS, ResourceTemplate ()
468 {
469 IO (Decode16, 0x0000, 0x0000, 0x04, 0x08, IO0)
470 IRQNoFlags (IRQX) {}
471 })
472 CreateWordField (CRS, IO0._MIN, IOP0)
473 CreateWordField (CRS, IO0._MAX, IOR0)
474 CreateByteField (CRS, IO0._ALN, IOAL)
475 CreateByteField (CRS, IO0._LEN, IOLE)
476 CreateWordField (CRS, IRQX._INT, IRQW)
477
Christoph Grenz287ca502011-11-05 23:39:20 +0100478 /* Get device settings */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200479 ENTER_CONFIG_MODE (1)
Felix Singerfa070962022-12-12 04:43:21 +0100480 Local0 = IO1L
481 Local1 = IO1H
482 Local2 = OPT1
483 Local5 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200484 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +0100485 /* Calculate IO port and modify template */
Felix Singer86bc2e72022-12-16 04:40:39 +0100486 Local0 |= Local1 << 8
Felix Singerfa070962022-12-12 04:43:21 +0100487 IOP0 = Local1
488 IOR0 = Local1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100489
Christoph Grenz287ca502011-11-05 23:39:20 +0100490 /* Set align and length based on active parallel port mode */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100491 And(Local2, 0x3, Local3)
492 And(Local2, 0x4, Local4)
493 If (Local4) {
Felix Singerfa070962022-12-12 04:43:21 +0100494 IOAL = 0x04
Christoph Grenze3e641c2011-11-05 22:14:41 +0100495 }
Felix Singer3f37d7a2022-01-02 00:31:21 +0100496 If (Local0 == 0xBC)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100497 {
Felix Singerfa070962022-12-12 04:43:21 +0100498 IOLE = 0x04
Christoph Grenze3e641c2011-11-05 22:14:41 +0100499 }
500 Else
501 {
Felix Singerfa070962022-12-12 04:43:21 +0100502 IOLE = 0x08
Christoph Grenze3e641c2011-11-05 22:14:41 +0100503 }
Christoph Grenz287ca502011-11-05 23:39:20 +0100504 /* Calculate IRQ bitmap */
Felix Singerfa070962022-12-12 04:43:21 +0100505 Local0 = One
Felix Singer3c9291b2022-12-16 02:43:56 +0100506 IRQW = Local0 << Local5
Christoph Grenz287ca502011-11-05 23:39:20 +0100507 /* Return resource template */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100508 Return (CRS)
509 }
510
511 Name (_PRS, ResourceTemplate ()
512 {
Christoph Grenzdda40952013-06-18 01:26:50 +0200513 /* Traditional configurations (SPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100514 StartDependentFn (0,1)
515 {
516 IO (Decode16, 0x0378, 0x0378, 0x04, 0x08)
517 IRQNoFlags () {3,4,5,7,9,10,11,12}
518 }
519 StartDependentFn (0,1)
520 {
521 IO (Decode16, 0x0278, 0x0278, 0x04, 0x08)
522 IRQNoFlags () {3,4,5,7,9,10,11,12}
523 }
524 StartDependentFn (0,1)
525 {
526 IO (Decode16, 0x03BC, 0x03BC, 0x04, 0x04)
527 IRQNoFlags () {3,4,5,7,9,10,11,12}
528 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200529 /* Traditional configurations (EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100530 StartDependentFn (0,0)
531 {
532 IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
533 IRQNoFlags () {3,4,5,7,9,10,11,12}
534 }
535 StartDependentFn (0,0)
536 {
537 IO (Decode16, 0x0278, 0x0278, 0x08, 0x08)
538 IRQNoFlags () {3,4,5,7,9,10,11,12}
539 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200540 /* Any configurable address (EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100541 StartDependentFn (2,0)
542 {
Christoph Grenzbbf09692013-07-06 17:09:39 +0200543 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100544 IRQNoFlags () {3,4,5,7,9,10,11,12}
545 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200546 /* Any configurable address (No EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100547 StartDependentFn (2,1)
548 {
549 IO (Decode16, 0x0100, 0x0FFC, 0x04, 0x08)
550 IRQNoFlags () {3,4,5,7,9,10,11,12}
551 }
552 EndDependentFn ()
553 })
554
555 Method (_SRS, 1, Serialized)
556 {
557 Name (TMPL, ResourceTemplate () {
558 IO (Decode16, 0, 0, 4, 4, IO0)
559 IRQNoFlags (IRQX) {}
560 })
561 CreateWordField (Arg0, IO0._MIN, IOA0)
562 CreateWordField (Arg0, IO0._MIN, IOA1)
563 CreateByteField (Arg0, IO0._ALN, IOAL)
564 CreateByteField (Arg0, IO0._LEN, IOLE)
565 CreateWordField (Arg0, IRQX._INT, IRQL)
566
Felix Singer3f37d7a2022-01-02 00:31:21 +0100567 If (IOAL == 4) {
Felix Singerfa070962022-12-12 04:43:21 +0100568 Local2 = 0x0
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200569 } else {
Felix Singerfa070962022-12-12 04:43:21 +0100570 Local2 = 0x1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100571 }
572
573 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100574
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200575 ENTER_CONFIG_MODE (1)
Christoph Grenz287ca502011-11-05 23:39:20 +0100576 /* IO port */
Felix Singerfa070962022-12-12 04:43:21 +0100577 IO1L = Local0
578 IO1H = Local1
Christoph Grenz287ca502011-11-05 23:39:20 +0100579 /* Mode */
Felix Singerfa070962022-12-12 04:43:21 +0100580 Local3 = OPT1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100581 And (Local3, 0xF8, Local3)
Felix Singer86bc2e72022-12-16 04:40:39 +0100582 OPT1 = Local2 | Local3
Christoph Grenz287ca502011-11-05 23:39:20 +0100583 /* DMA off */
Felix Singerfa070962022-12-12 04:43:21 +0100584 DMA0 = 0x04
Christoph Grenz287ca502011-11-05 23:39:20 +0100585 /* IRQ */
Felix Singerf5b162e2021-12-30 00:21:21 +0100586 IRQ0 = FindSetLeftBit (IRQL) - 1
Christoph Grenz287ca502011-11-05 23:39:20 +0100587 /* Activate */
Felix Singerfa070962022-12-12 04:43:21 +0100588 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200589 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100590 }
591 }
592 #endif
593
594 #ifndef NO_W83627HF_UARTA
595 /* =========================== UART A ============================ */
596 Device (SER0) {
597 Name (_HID, EisaId ("PNP0501"))
598 Name (_UID, "w83627hf-uarta")
599 Name (_DDN, "COM1")
600
601 Method (_STA)
602 {
Felix Singerfa070962022-12-12 04:43:21 +0100603 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200604 ENTER_CONFIG_MODE (2)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100605 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100606 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100607 }
Felix Singer5a303b02021-12-31 13:12:16 +0100608 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100609 {
Felix Singerfa070962022-12-12 04:43:21 +0100610 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100611 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200612 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100613 Return (Local0)
614 }
615
616 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100617 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100618 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200619 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100620 Local0 = UAPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200621 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100622 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100623 Else { Return (0) }
624 }
625 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200626 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100627 UAPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200628 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100629 }
Nico Huber79dfa902020-03-22 01:17:54 +0100630 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200631 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100632 UAPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200633 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100634 }
635
636 Method (_DIS)
637 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200638 ENTER_CONFIG_MODE (2)
Felix Singerfa070962022-12-12 04:43:21 +0100639 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200640 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100641 }
642
Oskar Enoksson42283e72014-02-11 23:19:02 +0100643 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100644 {
645 Name (CRS, ResourceTemplate () {
646 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
647 IRQNoFlags (IRQX) {6}
648 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200649 ENTER_CONFIG_MODE (2)
Felix Singerfa070962022-12-12 04:43:21 +0100650 Local0 = IO1L
651 Local1 = IO1H
652 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200653 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100654 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100655
656 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100657 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100658 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100659 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100660
661 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +0100662 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +0100663 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100664
665 Return (CRS)
666 }
667
668 Name (_PRS, ResourceTemplate ()
669 {
670 StartDependentFn (0,0) {
671 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
672 IRQNoFlags () {3,4,5,7,9,10,11,12}
673 }
674 StartDependentFn (0,0) {
675 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
676 IRQNoFlags () {3,4,5,7,9,10,11,12}
677 }
678 StartDependentFn (1,0) {
679 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
680 IRQNoFlags () {3,4,5,7,9,10,11,12}
681 }
682 StartDependentFn (1,0) {
683 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
684 IRQNoFlags () {3,4,5,7,9,10,11,12}
685 }
686 StartDependentFn (2,0) {
687 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
688 IRQNoFlags () {3,4,5,7,9,10,11,12}
689 }
690 EndDependentFn()
691 })
692
693 Method (_SRS, 1, Serialized)
694 {
695 Name (TMPL, ResourceTemplate () {
696 IO (Decode16, 0, 0, 1, 6, IO0)
697 IRQNoFlags (IRQX) {}
698 })
699 CreateWordField (Arg0, IO0._MIN, IOA0)
Oskar Enoksson411bf972014-02-11 23:20:14 +0100700 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100701
702 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100703
Felix Singerf5b162e2021-12-30 00:21:21 +0100704 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100705
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200706 ENTER_CONFIG_MODE (2)
Felix Singerfa070962022-12-12 04:43:21 +0100707 IO1L = Local0
708 IO1H = Local1
709 IRQ0 = Local3
710 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200711 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100712 }
713 }
714 #endif
715
716 #ifndef NO_W83627HF_UARTB
717 /* =========================== UART B ============================ */
718 Device (SER1) {
719 Name (_HID, EisaId ("PNP0501"))
720 Name (_UID, "w83627hf-uartb")
721 Name (_DDN, "COM2")
722
723 Method (_STA)
724 {
Felix Singerfa070962022-12-12 04:43:21 +0100725 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200726 ENTER_CONFIG_MODE (3)
Felix Singer1a6925c2021-12-31 14:35:35 +0100727 If (!And(OPT2, 0x30))
Christoph Grenze3e641c2011-11-05 22:14:41 +0100728 {
729 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100730 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100731 }
Felix Singer5a303b02021-12-31 13:12:16 +0100732 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100733 {
Felix Singerfa070962022-12-12 04:43:21 +0100734 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100735 }
736 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200737 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100738 Return (Local0)
739 }
740
741 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100742 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100743 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200744 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100745 Local0 = UBPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200746 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100747 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100748 Else { Return (0) }
749 }
750 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200751 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100752 UBPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200753 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100754 }
Nico Huber79dfa902020-03-22 01:17:54 +0100755 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200756 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100757 UBPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200758 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100759 }
760
761 Method (_DIS)
762 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200763 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100764 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200765 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100766 }
767
768 Method (_CRS)
769 {
770 Name (CRS, ResourceTemplate () {
771 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
772 IRQNoFlags (IRQX) {6}
773 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200774 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100775 Local0 = IO1L
776 Local1 = IO1H
777 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200778 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100779 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100780
781 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100782 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100783 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100784 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100785
786 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +0100787 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +0100788 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100789
790 Return (CRS)
791 }
792
793 Name (_PRS, ResourceTemplate ()
794 {
795 StartDependentFn (0,0) {
796 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
797 IRQNoFlags () {3,4,5,7,9,10,11,12}
798 }
799 StartDependentFn (0,0) {
800 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
801 IRQNoFlags () {3,4,5,7,9,10,11,12}
802 }
803 StartDependentFn (1,0) {
804 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
805 IRQNoFlags () {3,4,5,7,9,10,11,12}
806 }
807 StartDependentFn (1,0) {
808 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
809 IRQNoFlags () {3,4,5,7,9,10,11,12}
810 }
811 StartDependentFn (2,0) {
812 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
813 IRQNoFlags () {3,4,5,7,9,10,11,12}
814 }
815 EndDependentFn()
816 })
817
818 Method (_SRS, 1, Serialized)
819 {
820 Name (TMPL, ResourceTemplate () {
821 IO (Decode16, 0, 0, 1, 8, IO0)
822 IRQNoFlags (IRQX) {}
823 })
824 CreateWordField (Arg0, IO0._MIN, IOA0)
825 CreateByteField (Arg0, IRQX._INT, IRQL)
826
827 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100828
Felix Singerf5b162e2021-12-30 00:21:21 +0100829 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100830
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200831 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100832 IO1L = Local0
833 IO1H = Local1
834 IRQ0 = Local3
835 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200836 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100837 }
838 }
839 #endif
840
841 #ifndef NO_W83627HF_IRDA
842 /* ======================== UART B (IRDA) ======================== */
843 Device (IRDA) {
844 Name (_HID, EisaId ("PNP0510"))
845 Name (_UID, "w83627hf-irda")
846 Name (_STR, Unicode("IrDA Port"))
847
848 Method (_STA)
849 {
Felix Singerfa070962022-12-12 04:43:21 +0100850 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200851 ENTER_CONFIG_MODE (3)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100852 If (And(OPT2, 0x30))
853 {
854 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100855 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100856 }
Felix Singer5a303b02021-12-31 13:12:16 +0100857 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100858 {
Felix Singerfa070962022-12-12 04:43:21 +0100859 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100860 }
861 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200862 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100863 Return (Local0)
864 }
865
866 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100867 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100868 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200869 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100870 Local0 = UBPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200871 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100872 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100873 Else { Return (0) }
874 }
875 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200876 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100877 UBPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200878 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100879 }
Nico Huber79dfa902020-03-22 01:17:54 +0100880 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200881 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100882 UBPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200883 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100884 }
885
886 Method (_DIS)
887 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200888 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100889 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200890 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100891 }
892
893 Method (_CRS)
894 {
895 Name (CRS, ResourceTemplate () {
896 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
897 IRQNoFlags (IRQX) {6}
898 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200899 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100900 Local1 = IO1H
901 Local0 = IO1L
902 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200903 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100904 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100905
906 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100907 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100908 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100909 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100910
911 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +0100912 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +0100913 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100914
915 Return (CRS)
916 }
917
918 Name (_PRS, ResourceTemplate ()
919 {
920 StartDependentFn (0,0) {
921 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
922 IRQNoFlags () {3,4,5,7,9,10,11,12}
923 }
924 StartDependentFn (1,0) {
925 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
926 IRQNoFlags () {3,4,5,7,9,10,11,12}
927 }
928 StartDependentFn (0,0) {
929 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
930 IRQNoFlags () {3,4,5,7,9,10,11,12}
931 }
932 StartDependentFn (0,0) {
933 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
934 IRQNoFlags () {3,4,5,7,9,10,11,12}
935 }
936 StartDependentFn (2,0) {
937 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
938 IRQNoFlags () {3,4,5,7,9,10,11,12}
939 }
940 EndDependentFn()
941 })
942
943 Method (_SRS, 1, Serialized)
944 {
945 Name (TMPL, ResourceTemplate () {
946 IO (Decode16, 0, 0, 1, 8, IO0)
947 IRQNoFlags (IRQX) {}
948 })
949 CreateWordField (Arg0, IO0._MIN, IOA0)
950 CreateByteField (Arg0, IRQX._INT, IRQL)
951
952 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100953
Felix Singerf5b162e2021-12-30 00:21:21 +0100954 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100955
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200956 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100957 IO1L = Local0
958 IO1H = Local1
959 IRQ0 = Local3
960 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200961 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100962 }
963 }
964 #endif
965
966 #ifndef NO_W83627HF_CIR
967 /* ========================= Consumer IR ========================= */
Christoph Grenz287ca502011-11-05 23:39:20 +0100968 Device (CIR0)
969 {
Christoph Grenze3e641c2011-11-05 22:14:41 +0100970 Name (_HID, EisaId ("WEC1022")) /* Should be the correct one */
971 Name (_UID, "w83627hf-cir")
972 Name (_STR, Unicode("Winbond Consumer Infrared Transceiver"))
973
974 Method (_STA)
975 {
Felix Singerfa070962022-12-12 04:43:21 +0100976 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200977 ENTER_CONFIG_MODE (6)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100978 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100979 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100980 }
Felix Singer5a303b02021-12-31 13:12:16 +0100981 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100982 {
Felix Singerfa070962022-12-12 04:43:21 +0100983 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100984 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200985 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100986 Return (Local0)
987 }
988
989 Method (_DIS)
990 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200991 ENTER_CONFIG_MODE (6)
Felix Singerfa070962022-12-12 04:43:21 +0100992 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200993 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100994 }
995
996 Method (_CRS)
997 {
998 Name (CRS, ResourceTemplate () {
999 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
1000 IRQNoFlags (IRQX) {6}
1001 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001002 ENTER_CONFIG_MODE (6)
Felix Singerfa070962022-12-12 04:43:21 +01001003 Local0 = IO1L
1004 Local1 = IO1H
1005 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001006 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +01001007 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001008
1009 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +01001010 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001011 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001012 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001013
1014 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001015 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001016 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001017
1018 Return (CRS)
1019 }
1020
1021 Name (_PRS, ResourceTemplate ()
1022 {
1023 StartDependentFn (0,0) {
1024 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
1025 IRQNoFlags () {3,4,5,7,9,10,11,12}
1026 }
1027 EndDependentFn()
1028 })
1029
1030 Method (_SRS, 1, Serialized)
1031 {
1032 Name (TMPL, ResourceTemplate () {
1033 IO (Decode16, 0, 0, 1, 8, IO0)
1034 IRQNoFlags (IRQX) {}
1035 })
1036 CreateWordField (Arg0, IO0._MIN, IOA0)
1037 CreateByteField (Arg0, IRQX._INT, IRQL)
1038
1039 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001040
Felix Singerf5b162e2021-12-30 00:21:21 +01001041 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001042
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001043 ENTER_CONFIG_MODE (6)
Felix Singerfa070962022-12-12 04:43:21 +01001044 IO1L = Local0
1045 IO1H = Local1
1046 IRQ0 = Local3
1047 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001048 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001049 }
1050 }
1051 #endif
1052
1053 #ifndef NO_W83627HF_KBC
1054 /* ===================== Keyboard Controller ===================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001055 Device (KBD0)
1056 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001057 Name (_HID, EisaId ("PNP0303"))
Christoph Grenze3e641c2011-11-05 22:14:41 +01001058 Name (_UID, "w83627hf-kbc")
1059
1060 Method (_STA)
1061 {
Felix Singerfa070962022-12-12 04:43:21 +01001062 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001063 ENTER_CONFIG_MODE (5)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001064 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +01001065 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001066 }
Felix Singer5a303b02021-12-31 13:12:16 +01001067 ElseIf (IO1H || IO1L || IO2H || IO2L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001068 {
Christoph Grenz287ca502011-11-05 23:39:20 +01001069 #ifdef W83627HF_KBC_COMPAT
Felix Singerfa070962022-12-12 04:43:21 +01001070 Local0 = 0x0F
Christoph Grenz287ca502011-11-05 23:39:20 +01001071 #else
Felix Singerfa070962022-12-12 04:43:21 +01001072 Local0 = 0x0D
Christoph Grenz287ca502011-11-05 23:39:20 +01001073 #endif
Christoph Grenze3e641c2011-11-05 22:14:41 +01001074 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001075 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001076 Return (Local0)
1077 }
1078
1079 Method (_DIS)
1080 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001081 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001082 ACTR = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001083 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001084 Notify(PS2M, 1)
1085 }
1086
Oskar Enoksson42283e72014-02-11 23:19:02 +01001087 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001088 {
1089 Name (CRS, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +01001090 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001091 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
1092 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001093 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001094 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001095 Local0 = IO1L
1096 Local1 = IO1H
1097 Local2 = IO2L
1098 Local3 = IO2H
1099 Local4 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001100 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001101
Felix Singer86bc2e72022-12-16 04:40:39 +01001102 Local0 |= Local1 << 8
1103 Local2 |= Local3 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001104
1105 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +01001106 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001107 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001108 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001109
1110 CreateWordField (CRS, IO1._MIN, I1MI)
Felix Singerfa070962022-12-12 04:43:21 +01001111 I1MI = Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001112 CreateWordField (CRS, IO1._MAX, I1MA)
Felix Singerfa070962022-12-12 04:43:21 +01001113 I1MA = Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001114
1115 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001116 Local5 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001117 IRQW = Local5 << Local4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001118
1119 Return (CRS)
1120 }
1121
1122 Name (_PRS, ResourceTemplate ()
1123 {
1124 StartDependentFn (0,0) {
Christoph Grenz287ca502011-11-05 23:39:20 +01001125 IRQNoFlags () {1}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001126 IO (Decode16, 0x0060, 0x0060, 0x01, 0x01)
1127 IO (Decode16, 0x0064, 0x0064, 0x01, 0x01)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001128 }
1129 EndDependentFn()
1130 })
1131
1132 Method (_SRS, 1, Serialized)
1133 {
1134 Name (TMPL, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +01001135 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001136 IO (Decode16, 0, 0, 1, 1, IO0)
1137 IO (Decode16, 0, 0, 1, 1, IO1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001138 })
1139 CreateWordField (Arg0, IO0._MIN, IOA0)
1140 CreateWordField (Arg0, IO1._MIN, IOA1)
Oskar Enoksson411bf972014-02-11 23:20:14 +01001141 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001142
1143 Divide(IOA0, 256, Local0, Local1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001144 Divide(IOA1, 256, Local2, Local3)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001145
Felix Singerf5b162e2021-12-30 00:21:21 +01001146 Local4 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001147
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001148 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001149 IO1L = Local0
1150 IO1H = Local1
1151 IO2L = Local2
1152 IO2H = Local3
1153 IRQ0 = Local4
1154 ACTR = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001155 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001156 Notify(PS2M, 1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001157 }
1158 }
1159 #ifndef NO_W83627HF_PS2M
Christoph Grenz287ca502011-11-05 23:39:20 +01001160 Device (PS2M)
1161 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001162 Name (_HID, EisaId ("PNP0F13"))
1163 Name (_UID, "w83627hf-ps2m")
1164
1165 Method (_STA)
1166 {
Felix Singerfa070962022-12-12 04:43:21 +01001167 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001168 ENTER_CONFIG_MODE (5)
Felix Singerdb4cf7f2021-12-31 12:32:08 +01001169 If (ACTR && IRQ1) {
Felix Singerfa070962022-12-12 04:43:21 +01001170 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001171 }
Felix Singer5a303b02021-12-31 13:12:16 +01001172 ElseIf (IO1H || IO1L || IO2H || IO2L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001173 {
Christoph Grenz287ca502011-11-05 23:39:20 +01001174 #ifdef W83627HF_KBC_COMPAT
Felix Singerfa070962022-12-12 04:43:21 +01001175 Local0 = 0x0F
Christoph Grenz287ca502011-11-05 23:39:20 +01001176 #else
Felix Singerfa070962022-12-12 04:43:21 +01001177 Local0 = 0x0D
Christoph Grenz287ca502011-11-05 23:39:20 +01001178 #endif
Christoph Grenze3e641c2011-11-05 22:14:41 +01001179 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001180 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001181 Return (Local0)
1182 }
1183
1184 Method (_DIS)
1185 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001186 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001187 IRQ1 = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001188 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001189 }
1190
Oskar Enoksson42283e72014-02-11 23:19:02 +01001191 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001192 {
1193 Name (CRS, ResourceTemplate () {
1194 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001195 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001196 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001197 Local4 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001198 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001199
1200 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001201 Local5 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001202 IRQW = Local5 << Local4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001203
1204 Return (CRS)
1205 }
1206
1207 Name (_PRS, ResourceTemplate ()
1208 {
1209 StartDependentFn (0,0) {
1210 IRQNoFlags () {12}
1211 }
1212 StartDependentFn (2,0) {
Christoph Grenz287ca502011-11-05 23:39:20 +01001213 IRQNoFlags () {1,3,4,5,6,7,9,10,11}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001214 }
1215 EndDependentFn()
1216 })
1217
1218 Method (_SRS, 1, Serialized)
1219 {
1220 Name (TMPL, ResourceTemplate () {
1221 IRQNoFlags (IRQX) {}
1222 })
Oskar Enoksson411bf972014-02-11 23:20:14 +01001223 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001224
Felix Singerf5b162e2021-12-30 00:21:21 +01001225 Local0 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001226
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001227 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001228 IRQ1 = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001229 /* Only activates if KBD is active */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001230 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001231 }
1232 }
1233 #endif
1234 #endif
1235
1236 #ifndef NO_W83627HF_GAME
1237 /* ========================== Game Port ========================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001238 Device (GAME)
1239 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001240 Name (_HID, EisaId ("PNPB02F"))
1241 Name (_STR, Unicode ("Joystick/Game Port"))
1242 Name (_UID, "w83627hf-game")
1243
1244 Method (_STA) {
Felix Singerfa070962022-12-12 04:43:21 +01001245 Local0 = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001246 ENTER_CONFIG_MODE (7)
Felix Singer5a303b02021-12-31 13:12:16 +01001247 If (IO1L || IO1H) {
1248 If (ACTR || ACT1) {
Felix Singerfa070962022-12-12 04:43:21 +01001249 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001250 }
1251 Else {
Felix Singerfa070962022-12-12 04:43:21 +01001252 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001253 }
1254 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001255 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001256 Return (Local0)
1257 }
1258
1259 Method (_CRS)
1260 {
1261 Name (CRS, ResourceTemplate () {
1262 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
1263 IRQNoFlags (IRQX) {}
1264 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001265 ENTER_CONFIG_MODE (7)
Felix Singerfa070962022-12-12 04:43:21 +01001266 Local0 = IO1L
1267 Local1 = IO1H
1268 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001269 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001270
Felix Singer86bc2e72022-12-16 04:40:39 +01001271 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001272
1273 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001274 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001275 IMIN = Local0
1276 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001277
1278 If (Local2) {
1279 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001280 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001281 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001282 }
1283
1284 Return (CRS)
1285 }
1286
1287 }
1288 #endif
1289
1290 #ifndef NO_W83627HF_MIDI
1291 /* ========================== MIDI Port ========================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001292 Device (MIDI)
1293 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001294 Name (_HID, EisaId ("PNPB006"))
1295 Name (_STR, Unicode ("MPU-401 Compatible MIDI Port"))
1296 Name (_UID, "w83627hf-midi")
1297
Christoph Grenz287ca502011-11-05 23:39:20 +01001298 Method (_STA)
1299 {
Felix Singerfa070962022-12-12 04:43:21 +01001300 Local0 = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001301 ENTER_CONFIG_MODE (7)
Felix Singer5a303b02021-12-31 13:12:16 +01001302 If (IO2L || IO2H) {
1303 If (ACTR || ACT2) {
Felix Singerfa070962022-12-12 04:43:21 +01001304 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001305 }
1306 Else {
Felix Singerfa070962022-12-12 04:43:21 +01001307 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001308 }
1309 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001310 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001311 Return (Local0)
1312 }
1313
1314 Method (_CRS)
1315 {
1316 Name (CRS, ResourceTemplate () {
1317 IO (Decode16, 0x0000, 0x0000, 0x02, 0x02, IO0)
1318 IRQNoFlags (IRQX) {}
1319 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001320 ENTER_CONFIG_MODE (7)
Felix Singerfa070962022-12-12 04:43:21 +01001321 Local0 = IO2L
1322 Local1 = IO2H
1323 Local2 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001324 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001325
Felix Singer86bc2e72022-12-16 04:40:39 +01001326 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001327
1328 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001329 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001330 IMIN = Local0
1331 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001332
1333 If (Local2) {
1334 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001335 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001336 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001337 }
1338
1339 Return (CRS)
1340 }
1341
1342 }
1343 #endif
1344
1345 /* ==== Suspend LED control if it is connected to the SuperIO ==== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001346 Method (SLED, 1)
1347 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001348 ENTER_CONFIG_MODE (9)
Felix Singerfa070962022-12-12 04:43:21 +01001349 Local0 = OPT4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001350 And(Local0, 63, Local0)
Felix Singer86bc2e72022-12-16 04:40:39 +01001351 OPT4 = Local0 | (And(Arg0, 0x03) << 6)
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001352 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001353 }
1354
1355 /* ===== Power LED control if it is connected to the SuperIO ===== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001356 Method (PLED, 1)
1357 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001358 ENTER_CONFIG_MODE (8)
Felix Singerfa070962022-12-12 04:43:21 +01001359 Local0 = OPT4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001360 And(Local0, 63, Local0)
Felix Singer86bc2e72022-12-16 04:40:39 +01001361 OPT4 = Local0 | (And(Arg0, 0x03) << 6)
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001362 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001363 }
1364
1365 #ifndef NO_W83627HF_HWMON
1366 /* ====================== Hardware Monitor ======================= */
Christoph Grenz287ca502011-11-05 23:39:20 +01001367 Device (HMON)
1368 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001369 Name (_HID, EisaId ("PNP0C02")) // TODO: find better matching ID
1370 Name (_STR, Unicode("W83627 Hardware Monitor"))
1371 Name (_UID, "w83627hf-hwmon")
1372
1373 Method (_STA)
1374 {
Felix Singerfa070962022-12-12 04:43:21 +01001375 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001376 ENTER_CONFIG_MODE (11)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001377 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +01001378 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001379 }
Felix Singer5a303b02021-12-31 13:12:16 +01001380 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001381 {
Felix Singerfa070962022-12-12 04:43:21 +01001382 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001383 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001384 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001385 Return (Local0)
1386 }
1387
Christoph Grenz287ca502011-11-05 23:39:20 +01001388 Method (_PSC)
1389 {
Felix Singerfa070962022-12-12 04:43:21 +01001390 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001391 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001392 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +01001393 Local0 = HWPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001394 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +01001395 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +01001396 Else { Return (0) }
1397 }
Christoph Grenz287ca502011-11-05 23:39:20 +01001398
1399 Method (_PS0)
1400 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001401 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +01001402 HWPW = One
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001403 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001404 }
Christoph Grenz287ca502011-11-05 23:39:20 +01001405
Nico Huber79dfa902020-03-22 01:17:54 +01001406 Method (_PS3)
Christoph Grenz287ca502011-11-05 23:39:20 +01001407 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001408 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +01001409 HWPW = Zero
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001410 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001411 }
1412
Oskar Enoksson42283e72014-02-11 23:19:02 +01001413 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001414 {
1415 Name (CRS, ResourceTemplate () {
1416 IO (Decode16, 0x0000, 0x0000, 0x08, 0x02, IO0)
1417 IRQNoFlags (IRQX) {}
1418 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001419 ENTER_CONFIG_MODE (11)
Felix Singerfa070962022-12-12 04:43:21 +01001420 Local0 = IO1L
1421 Local1 = IO1H
1422 Local2 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001423 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001424
Felix Singer86bc2e72022-12-16 04:40:39 +01001425 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001426
1427 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001428 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001429 IMIN = Local0
1430 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001431
1432 If (Local2) {
1433 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerfa070962022-12-12 04:43:21 +01001434 Local3 = One
Felix Singer3c9291b2022-12-16 02:43:56 +01001435 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001436 }
1437 Return (CRS)
1438 }
1439 }
1440 #endif
1441
1442 /* Returns the wake source register.
1443 It is cleared after reading.
1444 Bit 0: Keyboard wake-up event
1445 Bit 1: Mouse wake-up event
1446 Bit 2: Power button event
1447 Bit 3: CIR wake-up event
1448 Bit 4: Power loss event
1449 Bit 5: VSB power loss status
1450 */
Christoph Grenz287ca502011-11-05 23:39:20 +01001451 Method (WAKS)
1452 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001453 ENTER_CONFIG_MODE (10)
Felix Singerfa070962022-12-12 04:43:21 +01001454 Local0 = CRE3
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001455 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001456 Return (Local0)
Christoph Grenz8ae574c2011-09-18 22:53:18 +02001457 }
Christoph Grenzd17f3d72011-10-19 02:24:23 +02001458}