blob: 0795d541c2f3a8c7f25e81d02ea9f0bc5d4cca4f [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 Singer42efd7f2022-12-26 09:38:45 +0100182 IPD = 0
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 Singerca4b5872022-12-26 08:17:06 +0100189 IPD = 1
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 Singerca4b5872022-12-26 08:17:06 +0100230 FDPW = 1
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 Singer42efd7f2022-12-26 09:38:45 +0100236 FDPW = 0
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 Singer42efd7f2022-12-26 09:38:45 +0100243 ACTR = 0
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 Singerca4b5872022-12-26 08:17:06 +0100341 ACT1 = 1
Felix Singerfa070962022-12-12 04:43:21 +0100342 SELE = 0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100343 Sleep(0x64)
Felix Singerca4b5872022-12-26 08:17:06 +0100344 If (SIFR) { FD1 = 1 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100345
Felix Singer42efd7f2022-12-26 09:38:45 +0100346 ACT1 = 0
Felix Singerca4b5872022-12-26 08:17:06 +0100347 ACT2 = 1
Felix Singerfa070962022-12-12 04:43:21 +0100348 SELE = 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100349 Sleep(0x64)
Felix Singerca4b5872022-12-26 08:17:06 +0100350 If (SIFR) { FD2 = 1 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100351
Felix Singer42efd7f2022-12-26 09:38:45 +0100352 ACT2 = 0
Felix Singerca4b5872022-12-26 08:17:06 +0100353 ACT3 = 1
Felix Singerfa070962022-12-12 04:43:21 +0100354 SELE = 2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100355 Sleep(0x64)
Felix Singerca4b5872022-12-26 08:17:06 +0100356 If (SIFR) { FD3 = 1 }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100357
Felix Singer42efd7f2022-12-26 09:38:45 +0100358 ACT3 = 0
Felix Singerca4b5872022-12-26 08:17:06 +0100359 ACT4 = 1
Felix Singerfa070962022-12-12 04:43:21 +0100360 SELE = 3
Christoph Grenze3e641c2011-11-05 22:14:41 +0100361 Sleep(0x64)
Felix Singerca4b5872022-12-26 08:17:06 +0100362 If (SIFR) { FD4 = 1 }
Felix Singer42efd7f2022-12-26 09:38:45 +0100363 ACT4 = 0
364 SELE = 0
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
Elyes Haouas1e934442022-12-25 07:55:38 +0100382 Local0 = IOA0 % 256
383 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +0100384
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200385 ENTER_CONFIG_MODE (0)
Felix Singerfa070962022-12-12 04:43:21 +0100386 IO1L = Local0
387 IO1H = Local1
Felix Singerca4b5872022-12-26 08:17:06 +0100388 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200389 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100390 }
391 }
392 #endif
393
394 #ifndef NO_W83627HF_PPORT
395 /* ======================== Parallel Port ======================== */
396 /* Currently no ECP support */
397 Device (PAR0) {
398 Name (_HID, EisaId ("PNP0400"))
399 Name (_DDN, "LPT1")
400 Name (_UID, "w83627hf-pport")
401
402 Method (MODE, 1) {
Felix Singer35e65a82022-12-16 07:11:17 +0100403 Local0 = Arg0 & 7
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200404 ENTER_CONFIG_MODE (1)
Felix Singer35e65a82022-12-16 07:11:17 +0100405 Local1 = OPT1 & 3
Felix Singer86bc2e72022-12-16 04:40:39 +0100406 OPT1 = Local1 | Local0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200407 EXIT_CONFIG_MODE()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100408 }
409
410 Method (_INI)
411 {
412 /* Deactivate DMA, even if set by BIOS. We don't announce it
413 through _CRS and it's only useful in ECP mode which we
414 don't support at the moment. */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200415 ENTER_CONFIG_MODE (1)
Felix Singerfa070962022-12-12 04:43:21 +0100416 DMA0 = 0x04
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200417 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100418 }
419
420 Method (_STA)
421 {
Felix Singerfa070962022-12-12 04:43:21 +0100422 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200423 ENTER_CONFIG_MODE (1)
Felix Singer35e65a82022-12-16 07:11:17 +0100424 Local1 = OPT1 & 3
Christoph Grenze3e641c2011-11-05 22:14:41 +0100425 If (ACTR) {
Felix Singer3cfbe8a2022-01-02 02:44:04 +0100426 If (Local1 != 2) {
Felix Singerfa070962022-12-12 04:43:21 +0100427 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100428 } Else {
Felix Singerfa070962022-12-12 04:43:21 +0100429 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100430 }
431 }
Felix Singer5a303b02021-12-31 13:12:16 +0100432 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100433 {
Felix Singerfa070962022-12-12 04:43:21 +0100434 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100435 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200436 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100437 Return (Local0)
438 }
439
440 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100441 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100442 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200443 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100444 Local0 = PRPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200445 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100446 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100447 Else { Return (0) }
448 }
449 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200450 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerca4b5872022-12-26 08:17:06 +0100451 PRPW = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200452 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100453 }
Nico Huber79dfa902020-03-22 01:17:54 +0100454 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200455 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singer42efd7f2022-12-26 09:38:45 +0100456 PRPW = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200457 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100458 }
459
460 Method (_DIS) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200461 ENTER_CONFIG_MODE (1)
Felix Singer42efd7f2022-12-26 09:38:45 +0100462 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200463 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100464 }
465
466 Method (_CRS)
467 {
468 Name (CRS, ResourceTemplate ()
469 {
470 IO (Decode16, 0x0000, 0x0000, 0x04, 0x08, IO0)
471 IRQNoFlags (IRQX) {}
472 })
473 CreateWordField (CRS, IO0._MIN, IOP0)
474 CreateWordField (CRS, IO0._MAX, IOR0)
475 CreateByteField (CRS, IO0._ALN, IOAL)
476 CreateByteField (CRS, IO0._LEN, IOLE)
477 CreateWordField (CRS, IRQX._INT, IRQW)
478
Christoph Grenz287ca502011-11-05 23:39:20 +0100479 /* Get device settings */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200480 ENTER_CONFIG_MODE (1)
Felix Singerfa070962022-12-12 04:43:21 +0100481 Local0 = IO1L
482 Local1 = IO1H
483 Local2 = OPT1
484 Local5 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200485 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +0100486 /* Calculate IO port and modify template */
Felix Singer86bc2e72022-12-16 04:40:39 +0100487 Local0 |= Local1 << 8
Felix Singerfa070962022-12-12 04:43:21 +0100488 IOP0 = Local1
489 IOR0 = Local1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100490
Christoph Grenz287ca502011-11-05 23:39:20 +0100491 /* Set align and length based on active parallel port mode */
Felix Singer35e65a82022-12-16 07:11:17 +0100492 Local3 = Local2 & 3
493 Local4 = Local2 & 4
Christoph Grenze3e641c2011-11-05 22:14:41 +0100494 If (Local4) {
Felix Singerfa070962022-12-12 04:43:21 +0100495 IOAL = 0x04
Christoph Grenze3e641c2011-11-05 22:14:41 +0100496 }
Felix Singer3f37d7a2022-01-02 00:31:21 +0100497 If (Local0 == 0xBC)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100498 {
Felix Singerfa070962022-12-12 04:43:21 +0100499 IOLE = 0x04
Christoph Grenze3e641c2011-11-05 22:14:41 +0100500 }
501 Else
502 {
Felix Singerfa070962022-12-12 04:43:21 +0100503 IOLE = 0x08
Christoph Grenze3e641c2011-11-05 22:14:41 +0100504 }
Christoph Grenz287ca502011-11-05 23:39:20 +0100505 /* Calculate IRQ bitmap */
Felix Singerca4b5872022-12-26 08:17:06 +0100506 Local0 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +0100507 IRQW = Local0 << Local5
Christoph Grenz287ca502011-11-05 23:39:20 +0100508 /* Return resource template */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100509 Return (CRS)
510 }
511
512 Name (_PRS, ResourceTemplate ()
513 {
Christoph Grenzdda40952013-06-18 01:26:50 +0200514 /* Traditional configurations (SPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100515 StartDependentFn (0,1)
516 {
517 IO (Decode16, 0x0378, 0x0378, 0x04, 0x08)
518 IRQNoFlags () {3,4,5,7,9,10,11,12}
519 }
520 StartDependentFn (0,1)
521 {
522 IO (Decode16, 0x0278, 0x0278, 0x04, 0x08)
523 IRQNoFlags () {3,4,5,7,9,10,11,12}
524 }
525 StartDependentFn (0,1)
526 {
527 IO (Decode16, 0x03BC, 0x03BC, 0x04, 0x04)
528 IRQNoFlags () {3,4,5,7,9,10,11,12}
529 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200530 /* Traditional configurations (EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100531 StartDependentFn (0,0)
532 {
533 IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
534 IRQNoFlags () {3,4,5,7,9,10,11,12}
535 }
536 StartDependentFn (0,0)
537 {
538 IO (Decode16, 0x0278, 0x0278, 0x08, 0x08)
539 IRQNoFlags () {3,4,5,7,9,10,11,12}
540 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200541 /* Any configurable address (EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100542 StartDependentFn (2,0)
543 {
Christoph Grenzbbf09692013-07-06 17:09:39 +0200544 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100545 IRQNoFlags () {3,4,5,7,9,10,11,12}
546 }
Christoph Grenzdda40952013-06-18 01:26:50 +0200547 /* Any configurable address (No EPP mode) */
Christoph Grenze3e641c2011-11-05 22:14:41 +0100548 StartDependentFn (2,1)
549 {
550 IO (Decode16, 0x0100, 0x0FFC, 0x04, 0x08)
551 IRQNoFlags () {3,4,5,7,9,10,11,12}
552 }
553 EndDependentFn ()
554 })
555
556 Method (_SRS, 1, Serialized)
557 {
558 Name (TMPL, ResourceTemplate () {
559 IO (Decode16, 0, 0, 4, 4, IO0)
560 IRQNoFlags (IRQX) {}
561 })
562 CreateWordField (Arg0, IO0._MIN, IOA0)
563 CreateWordField (Arg0, IO0._MIN, IOA1)
564 CreateByteField (Arg0, IO0._ALN, IOAL)
565 CreateByteField (Arg0, IO0._LEN, IOLE)
566 CreateWordField (Arg0, IRQX._INT, IRQL)
567
Felix Singer3f37d7a2022-01-02 00:31:21 +0100568 If (IOAL == 4) {
Felix Singerfa070962022-12-12 04:43:21 +0100569 Local2 = 0x0
Elyes HAOUASe8fcf1b2020-03-30 16:47:28 +0200570 } else {
Felix Singerfa070962022-12-12 04:43:21 +0100571 Local2 = 0x1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100572 }
573
Elyes Haouas1e934442022-12-25 07:55:38 +0100574 Local0 = IOA0 % 256
575 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +0100576
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200577 ENTER_CONFIG_MODE (1)
Christoph Grenz287ca502011-11-05 23:39:20 +0100578 /* IO port */
Felix Singerfa070962022-12-12 04:43:21 +0100579 IO1L = Local0
580 IO1H = Local1
Christoph Grenz287ca502011-11-05 23:39:20 +0100581 /* Mode */
Felix Singerfa070962022-12-12 04:43:21 +0100582 Local3 = OPT1
Felix Singer35e65a82022-12-16 07:11:17 +0100583 Local3 &= 0xF8
Felix Singer86bc2e72022-12-16 04:40:39 +0100584 OPT1 = Local2 | Local3
Christoph Grenz287ca502011-11-05 23:39:20 +0100585 /* DMA off */
Felix Singerfa070962022-12-12 04:43:21 +0100586 DMA0 = 0x04
Christoph Grenz287ca502011-11-05 23:39:20 +0100587 /* IRQ */
Felix Singerf5b162e2021-12-30 00:21:21 +0100588 IRQ0 = FindSetLeftBit (IRQL) - 1
Christoph Grenz287ca502011-11-05 23:39:20 +0100589 /* Activate */
Felix Singerca4b5872022-12-26 08:17:06 +0100590 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200591 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100592 }
593 }
594 #endif
595
596 #ifndef NO_W83627HF_UARTA
597 /* =========================== UART A ============================ */
598 Device (SER0) {
599 Name (_HID, EisaId ("PNP0501"))
600 Name (_UID, "w83627hf-uarta")
601 Name (_DDN, "COM1")
602
603 Method (_STA)
604 {
Felix Singerfa070962022-12-12 04:43:21 +0100605 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200606 ENTER_CONFIG_MODE (2)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100607 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100608 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100609 }
Felix Singer5a303b02021-12-31 13:12:16 +0100610 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100611 {
Felix Singerfa070962022-12-12 04:43:21 +0100612 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100613 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200614 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100615 Return (Local0)
616 }
617
618 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100619 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100620 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200621 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100622 Local0 = UAPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200623 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100624 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100625 Else { Return (0) }
626 }
627 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200628 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerca4b5872022-12-26 08:17:06 +0100629 UAPW = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200630 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100631 }
Nico Huber79dfa902020-03-22 01:17:54 +0100632 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200633 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singer42efd7f2022-12-26 09:38:45 +0100634 UAPW = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200635 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100636 }
637
638 Method (_DIS)
639 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200640 ENTER_CONFIG_MODE (2)
Felix Singer42efd7f2022-12-26 09:38:45 +0100641 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200642 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100643 }
644
Oskar Enoksson42283e72014-02-11 23:19:02 +0100645 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100646 {
647 Name (CRS, ResourceTemplate () {
648 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
649 IRQNoFlags (IRQX) {6}
650 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200651 ENTER_CONFIG_MODE (2)
Felix Singerfa070962022-12-12 04:43:21 +0100652 Local0 = IO1L
653 Local1 = IO1H
654 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200655 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100656 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100657
658 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100659 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100660 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100661 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100662
663 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +0100664 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +0100665 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100666
667 Return (CRS)
668 }
669
670 Name (_PRS, ResourceTemplate ()
671 {
672 StartDependentFn (0,0) {
673 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
674 IRQNoFlags () {3,4,5,7,9,10,11,12}
675 }
676 StartDependentFn (0,0) {
677 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
678 IRQNoFlags () {3,4,5,7,9,10,11,12}
679 }
680 StartDependentFn (1,0) {
681 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
682 IRQNoFlags () {3,4,5,7,9,10,11,12}
683 }
684 StartDependentFn (1,0) {
685 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
686 IRQNoFlags () {3,4,5,7,9,10,11,12}
687 }
688 StartDependentFn (2,0) {
689 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
690 IRQNoFlags () {3,4,5,7,9,10,11,12}
691 }
692 EndDependentFn()
693 })
694
695 Method (_SRS, 1, Serialized)
696 {
697 Name (TMPL, ResourceTemplate () {
698 IO (Decode16, 0, 0, 1, 6, IO0)
699 IRQNoFlags (IRQX) {}
700 })
701 CreateWordField (Arg0, IO0._MIN, IOA0)
Oskar Enoksson411bf972014-02-11 23:20:14 +0100702 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100703
Elyes Haouas1e934442022-12-25 07:55:38 +0100704 Local0 = IOA0 % 256
705 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +0100706
Felix Singerf5b162e2021-12-30 00:21:21 +0100707 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100708
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200709 ENTER_CONFIG_MODE (2)
Felix Singerfa070962022-12-12 04:43:21 +0100710 IO1L = Local0
711 IO1H = Local1
712 IRQ0 = Local3
Felix Singerca4b5872022-12-26 08:17:06 +0100713 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200714 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100715 }
716 }
717 #endif
718
719 #ifndef NO_W83627HF_UARTB
720 /* =========================== UART B ============================ */
721 Device (SER1) {
722 Name (_HID, EisaId ("PNP0501"))
723 Name (_UID, "w83627hf-uartb")
724 Name (_DDN, "COM2")
725
726 Method (_STA)
727 {
Felix Singerfa070962022-12-12 04:43:21 +0100728 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200729 ENTER_CONFIG_MODE (3)
Felix Singerd2527762022-12-16 07:54:16 +0100730 If (!(OPT2 & 0x30))
Christoph Grenze3e641c2011-11-05 22:14:41 +0100731 {
732 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100733 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100734 }
Felix Singer5a303b02021-12-31 13:12:16 +0100735 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100736 {
Felix Singerfa070962022-12-12 04:43:21 +0100737 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100738 }
739 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200740 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100741 Return (Local0)
742 }
743
744 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100745 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100746 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200747 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100748 Local0 = UBPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200749 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100750 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100751 Else { Return (0) }
752 }
753 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200754 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerca4b5872022-12-26 08:17:06 +0100755 UBPW = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200756 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100757 }
Nico Huber79dfa902020-03-22 01:17:54 +0100758 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200759 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singer42efd7f2022-12-26 09:38:45 +0100760 UBPW = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200761 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100762 }
763
764 Method (_DIS)
765 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200766 ENTER_CONFIG_MODE (3)
Felix Singer42efd7f2022-12-26 09:38:45 +0100767 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200768 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100769 }
770
771 Method (_CRS)
772 {
773 Name (CRS, ResourceTemplate () {
774 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
775 IRQNoFlags (IRQX) {6}
776 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200777 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100778 Local0 = IO1L
779 Local1 = IO1H
780 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200781 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100782 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100783
784 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100785 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100786 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100787 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100788
789 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +0100790 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +0100791 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100792
793 Return (CRS)
794 }
795
796 Name (_PRS, ResourceTemplate ()
797 {
798 StartDependentFn (0,0) {
799 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
800 IRQNoFlags () {3,4,5,7,9,10,11,12}
801 }
802 StartDependentFn (0,0) {
803 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
804 IRQNoFlags () {3,4,5,7,9,10,11,12}
805 }
806 StartDependentFn (1,0) {
807 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
808 IRQNoFlags () {3,4,5,7,9,10,11,12}
809 }
810 StartDependentFn (1,0) {
811 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
812 IRQNoFlags () {3,4,5,7,9,10,11,12}
813 }
814 StartDependentFn (2,0) {
815 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
816 IRQNoFlags () {3,4,5,7,9,10,11,12}
817 }
818 EndDependentFn()
819 })
820
821 Method (_SRS, 1, Serialized)
822 {
823 Name (TMPL, ResourceTemplate () {
824 IO (Decode16, 0, 0, 1, 8, IO0)
825 IRQNoFlags (IRQX) {}
826 })
827 CreateWordField (Arg0, IO0._MIN, IOA0)
828 CreateByteField (Arg0, IRQX._INT, IRQL)
829
Elyes Haouas1e934442022-12-25 07:55:38 +0100830 Local0 = IOA0 % 256
831 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +0100832
Felix Singerf5b162e2021-12-30 00:21:21 +0100833 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100834
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200835 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100836 IO1L = Local0
837 IO1H = Local1
838 IRQ0 = Local3
Felix Singerca4b5872022-12-26 08:17:06 +0100839 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200840 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100841 }
842 }
843 #endif
844
845 #ifndef NO_W83627HF_IRDA
846 /* ======================== UART B (IRDA) ======================== */
847 Device (IRDA) {
848 Name (_HID, EisaId ("PNP0510"))
849 Name (_UID, "w83627hf-irda")
850 Name (_STR, Unicode("IrDA Port"))
851
852 Method (_STA)
853 {
Felix Singerfa070962022-12-12 04:43:21 +0100854 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200855 ENTER_CONFIG_MODE (3)
Felix Singerd2527762022-12-16 07:54:16 +0100856 If (OPT2 & 0x30)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100857 {
858 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100859 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100860 }
Felix Singer5a303b02021-12-31 13:12:16 +0100861 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100862 {
Felix Singerfa070962022-12-12 04:43:21 +0100863 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100864 }
865 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200866 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100867 Return (Local0)
868 }
869
870 Method (_PSC) {
Felix Singerfa070962022-12-12 04:43:21 +0100871 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100872 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200873 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +0100874 Local0 = UBPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200875 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +0100876 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +0100877 Else { Return (0) }
878 }
879 Method (_PS0) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200880 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerca4b5872022-12-26 08:17:06 +0100881 UBPW = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200882 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100883 }
Nico Huber79dfa902020-03-22 01:17:54 +0100884 Method (_PS3) {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200885 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singer42efd7f2022-12-26 09:38:45 +0100886 UBPW = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200887 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100888 }
889
890 Method (_DIS)
891 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200892 ENTER_CONFIG_MODE (3)
Felix Singer42efd7f2022-12-26 09:38:45 +0100893 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200894 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100895 }
896
897 Method (_CRS)
898 {
899 Name (CRS, ResourceTemplate () {
900 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
901 IRQNoFlags (IRQX) {6}
902 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200903 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100904 Local1 = IO1H
905 Local0 = IO1L
906 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200907 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +0100908 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +0100909
910 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +0100911 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100912 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +0100913 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +0100914
915 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +0100916 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +0100917 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +0100918
919 Return (CRS)
920 }
921
922 Name (_PRS, ResourceTemplate ()
923 {
924 StartDependentFn (0,0) {
925 IO (Decode16, 0x02F8, 0x02F8, 0x08, 0x08)
926 IRQNoFlags () {3,4,5,7,9,10,11,12}
927 }
928 StartDependentFn (1,0) {
929 IO (Decode16, 0x03F8, 0x03F8, 0x08, 0x08)
930 IRQNoFlags () {3,4,5,7,9,10,11,12}
931 }
932 StartDependentFn (0,0) {
933 IO (Decode16, 0x03E8, 0x03E8, 0x08, 0x08)
934 IRQNoFlags () {3,4,5,7,9,10,11,12}
935 }
936 StartDependentFn (0,0) {
937 IO (Decode16, 0x02E8, 0x02E8, 0x08, 0x08)
938 IRQNoFlags () {3,4,5,7,9,10,11,12}
939 }
940 StartDependentFn (2,0) {
941 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
942 IRQNoFlags () {3,4,5,7,9,10,11,12}
943 }
944 EndDependentFn()
945 })
946
947 Method (_SRS, 1, Serialized)
948 {
949 Name (TMPL, ResourceTemplate () {
950 IO (Decode16, 0, 0, 1, 8, IO0)
951 IRQNoFlags (IRQX) {}
952 })
953 CreateWordField (Arg0, IO0._MIN, IOA0)
954 CreateByteField (Arg0, IRQX._INT, IRQL)
955
Elyes Haouas1e934442022-12-25 07:55:38 +0100956 Local0 = IOA0 % 256
957 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +0100958
Felix Singerf5b162e2021-12-30 00:21:21 +0100959 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +0100960
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200961 ENTER_CONFIG_MODE (3)
Felix Singerfa070962022-12-12 04:43:21 +0100962 IO1L = Local0
963 IO1H = Local1
964 IRQ0 = Local3
Felix Singerca4b5872022-12-26 08:17:06 +0100965 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200966 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100967 }
968 }
969 #endif
970
971 #ifndef NO_W83627HF_CIR
972 /* ========================= Consumer IR ========================= */
Christoph Grenz287ca502011-11-05 23:39:20 +0100973 Device (CIR0)
974 {
Christoph Grenze3e641c2011-11-05 22:14:41 +0100975 Name (_HID, EisaId ("WEC1022")) /* Should be the correct one */
976 Name (_UID, "w83627hf-cir")
977 Name (_STR, Unicode("Winbond Consumer Infrared Transceiver"))
978
979 Method (_STA)
980 {
Felix Singerfa070962022-12-12 04:43:21 +0100981 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200982 ENTER_CONFIG_MODE (6)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100983 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +0100984 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +0100985 }
Felix Singer5a303b02021-12-31 13:12:16 +0100986 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +0100987 {
Felix Singerfa070962022-12-12 04:43:21 +0100988 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +0100989 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200990 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100991 Return (Local0)
992 }
993
994 Method (_DIS)
995 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200996 ENTER_CONFIG_MODE (6)
Felix Singer42efd7f2022-12-26 09:38:45 +0100997 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +0200998 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +0100999 }
1000
1001 Method (_CRS)
1002 {
1003 Name (CRS, ResourceTemplate () {
1004 IO (Decode16, 0x0000, 0x0000, 0x01, 0x08, IO0)
1005 IRQNoFlags (IRQX) {6}
1006 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001007 ENTER_CONFIG_MODE (6)
Felix Singerfa070962022-12-12 04:43:21 +01001008 Local0 = IO1L
1009 Local1 = IO1H
1010 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001011 EXIT_CONFIG_MODE ()
Felix Singer86bc2e72022-12-16 04:40:39 +01001012 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001013
1014 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +01001015 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001016 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001017 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001018
1019 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001020 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001021 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001022
1023 Return (CRS)
1024 }
1025
1026 Name (_PRS, ResourceTemplate ()
1027 {
1028 StartDependentFn (0,0) {
1029 IO (Decode16, 0x0100, 0x0FF8, 0x08, 0x08)
1030 IRQNoFlags () {3,4,5,7,9,10,11,12}
1031 }
1032 EndDependentFn()
1033 })
1034
1035 Method (_SRS, 1, Serialized)
1036 {
1037 Name (TMPL, ResourceTemplate () {
1038 IO (Decode16, 0, 0, 1, 8, IO0)
1039 IRQNoFlags (IRQX) {}
1040 })
1041 CreateWordField (Arg0, IO0._MIN, IOA0)
1042 CreateByteField (Arg0, IRQX._INT, IRQL)
1043
Elyes Haouas1e934442022-12-25 07:55:38 +01001044 Local0 = IOA0 % 256
1045 Local1 = IOA0 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +01001046
Felix Singerf5b162e2021-12-30 00:21:21 +01001047 Local3 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001048
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001049 ENTER_CONFIG_MODE (6)
Felix Singerfa070962022-12-12 04:43:21 +01001050 IO1L = Local0
1051 IO1H = Local1
1052 IRQ0 = Local3
Felix Singerca4b5872022-12-26 08:17:06 +01001053 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001054 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001055 }
1056 }
1057 #endif
1058
1059 #ifndef NO_W83627HF_KBC
1060 /* ===================== Keyboard Controller ===================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001061 Device (KBD0)
1062 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001063 Name (_HID, EisaId ("PNP0303"))
Christoph Grenze3e641c2011-11-05 22:14:41 +01001064 Name (_UID, "w83627hf-kbc")
1065
1066 Method (_STA)
1067 {
Felix Singerfa070962022-12-12 04:43:21 +01001068 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001069 ENTER_CONFIG_MODE (5)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001070 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +01001071 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001072 }
Felix Singer5a303b02021-12-31 13:12:16 +01001073 ElseIf (IO1H || IO1L || IO2H || IO2L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001074 {
Christoph Grenz287ca502011-11-05 23:39:20 +01001075 #ifdef W83627HF_KBC_COMPAT
Felix Singerfa070962022-12-12 04:43:21 +01001076 Local0 = 0x0F
Christoph Grenz287ca502011-11-05 23:39:20 +01001077 #else
Felix Singerfa070962022-12-12 04:43:21 +01001078 Local0 = 0x0D
Christoph Grenz287ca502011-11-05 23:39:20 +01001079 #endif
Christoph Grenze3e641c2011-11-05 22:14:41 +01001080 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001081 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001082 Return (Local0)
1083 }
1084
1085 Method (_DIS)
1086 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001087 ENTER_CONFIG_MODE (5)
Felix Singer42efd7f2022-12-26 09:38:45 +01001088 ACTR = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001089 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001090 Notify(PS2M, 1)
1091 }
1092
Oskar Enoksson42283e72014-02-11 23:19:02 +01001093 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001094 {
1095 Name (CRS, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +01001096 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001097 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
1098 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001099 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001100 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001101 Local0 = IO1L
1102 Local1 = IO1H
1103 Local2 = IO2L
1104 Local3 = IO2H
1105 Local4 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001106 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001107
Felix Singer86bc2e72022-12-16 04:40:39 +01001108 Local0 |= Local1 << 8
1109 Local2 |= Local3 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001110
1111 CreateWordField (CRS, IO0._MIN, IMIN)
Felix Singerfa070962022-12-12 04:43:21 +01001112 IMIN = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001113 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001114 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001115
1116 CreateWordField (CRS, IO1._MIN, I1MI)
Felix Singerfa070962022-12-12 04:43:21 +01001117 I1MI = Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001118 CreateWordField (CRS, IO1._MAX, I1MA)
Felix Singerfa070962022-12-12 04:43:21 +01001119 I1MA = Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001120
1121 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001122 Local5 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001123 IRQW = Local5 << Local4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001124
1125 Return (CRS)
1126 }
1127
1128 Name (_PRS, ResourceTemplate ()
1129 {
1130 StartDependentFn (0,0) {
Christoph Grenz287ca502011-11-05 23:39:20 +01001131 IRQNoFlags () {1}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001132 IO (Decode16, 0x0060, 0x0060, 0x01, 0x01)
1133 IO (Decode16, 0x0064, 0x0064, 0x01, 0x01)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001134 }
1135 EndDependentFn()
1136 })
1137
1138 Method (_SRS, 1, Serialized)
1139 {
1140 Name (TMPL, ResourceTemplate () {
Christoph Grenz287ca502011-11-05 23:39:20 +01001141 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001142 IO (Decode16, 0, 0, 1, 1, IO0)
1143 IO (Decode16, 0, 0, 1, 1, IO1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001144 })
1145 CreateWordField (Arg0, IO0._MIN, IOA0)
1146 CreateWordField (Arg0, IO1._MIN, IOA1)
Oskar Enoksson411bf972014-02-11 23:20:14 +01001147 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001148
Elyes Haouas1e934442022-12-25 07:55:38 +01001149 Local0 = IOA0 % 256
1150 Local1 = IOA0 / 256
1151 Local2 = IOA1 % 256
1152 Local3 = IOA1 / 256
Christoph Grenze3e641c2011-11-05 22:14:41 +01001153
Felix Singerf5b162e2021-12-30 00:21:21 +01001154 Local4 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001155
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001156 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001157 IO1L = Local0
1158 IO1H = Local1
1159 IO2L = Local2
1160 IO2H = Local3
1161 IRQ0 = Local4
Felix Singerca4b5872022-12-26 08:17:06 +01001162 ACTR = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001163 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001164 Notify(PS2M, 1)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001165 }
1166 }
1167 #ifndef NO_W83627HF_PS2M
Christoph Grenz287ca502011-11-05 23:39:20 +01001168 Device (PS2M)
1169 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001170 Name (_HID, EisaId ("PNP0F13"))
1171 Name (_UID, "w83627hf-ps2m")
1172
1173 Method (_STA)
1174 {
Felix Singerfa070962022-12-12 04:43:21 +01001175 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001176 ENTER_CONFIG_MODE (5)
Felix Singerdb4cf7f2021-12-31 12:32:08 +01001177 If (ACTR && IRQ1) {
Felix Singerfa070962022-12-12 04:43:21 +01001178 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001179 }
Felix Singer5a303b02021-12-31 13:12:16 +01001180 ElseIf (IO1H || IO1L || IO2H || IO2L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001181 {
Christoph Grenz287ca502011-11-05 23:39:20 +01001182 #ifdef W83627HF_KBC_COMPAT
Felix Singerfa070962022-12-12 04:43:21 +01001183 Local0 = 0x0F
Christoph Grenz287ca502011-11-05 23:39:20 +01001184 #else
Felix Singerfa070962022-12-12 04:43:21 +01001185 Local0 = 0x0D
Christoph Grenz287ca502011-11-05 23:39:20 +01001186 #endif
Christoph Grenze3e641c2011-11-05 22:14:41 +01001187 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001188 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001189 Return (Local0)
1190 }
1191
1192 Method (_DIS)
1193 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001194 ENTER_CONFIG_MODE (5)
Felix Singer42efd7f2022-12-26 09:38:45 +01001195 IRQ1 = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001196 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001197 }
1198
Oskar Enoksson42283e72014-02-11 23:19:02 +01001199 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001200 {
1201 Name (CRS, ResourceTemplate () {
1202 IRQNoFlags (IRQX) {}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001203 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001204 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001205 Local4 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001206 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001207
1208 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001209 Local5 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001210 IRQW = Local5 << Local4
Christoph Grenze3e641c2011-11-05 22:14:41 +01001211
1212 Return (CRS)
1213 }
1214
1215 Name (_PRS, ResourceTemplate ()
1216 {
1217 StartDependentFn (0,0) {
1218 IRQNoFlags () {12}
1219 }
1220 StartDependentFn (2,0) {
Christoph Grenz287ca502011-11-05 23:39:20 +01001221 IRQNoFlags () {1,3,4,5,6,7,9,10,11}
Christoph Grenze3e641c2011-11-05 22:14:41 +01001222 }
1223 EndDependentFn()
1224 })
1225
1226 Method (_SRS, 1, Serialized)
1227 {
1228 Name (TMPL, ResourceTemplate () {
1229 IRQNoFlags (IRQX) {}
1230 })
Oskar Enoksson411bf972014-02-11 23:20:14 +01001231 CreateWordField (Arg0, IRQX._INT, IRQL)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001232
Felix Singerf5b162e2021-12-30 00:21:21 +01001233 Local0 = FindSetLeftBit (IRQL) - 1
Christoph Grenze3e641c2011-11-05 22:14:41 +01001234
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001235 ENTER_CONFIG_MODE (5)
Felix Singerfa070962022-12-12 04:43:21 +01001236 IRQ1 = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001237 /* Only activates if KBD is active */
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001238 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001239 }
1240 }
1241 #endif
1242 #endif
1243
1244 #ifndef NO_W83627HF_GAME
1245 /* ========================== Game Port ========================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001246 Device (GAME)
1247 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001248 Name (_HID, EisaId ("PNPB02F"))
1249 Name (_STR, Unicode ("Joystick/Game Port"))
1250 Name (_UID, "w83627hf-game")
1251
1252 Method (_STA) {
Felix Singerfa070962022-12-12 04:43:21 +01001253 Local0 = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001254 ENTER_CONFIG_MODE (7)
Felix Singer5a303b02021-12-31 13:12:16 +01001255 If (IO1L || IO1H) {
1256 If (ACTR || ACT1) {
Felix Singerfa070962022-12-12 04:43:21 +01001257 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001258 }
1259 Else {
Felix Singerfa070962022-12-12 04:43:21 +01001260 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001261 }
1262 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001263 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001264 Return (Local0)
1265 }
1266
1267 Method (_CRS)
1268 {
1269 Name (CRS, ResourceTemplate () {
1270 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
1271 IRQNoFlags (IRQX) {}
1272 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001273 ENTER_CONFIG_MODE (7)
Felix Singerfa070962022-12-12 04:43:21 +01001274 Local0 = IO1L
1275 Local1 = IO1H
1276 Local2 = IRQ0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001277 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001278
Felix Singer86bc2e72022-12-16 04:40:39 +01001279 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001280
1281 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001282 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001283 IMIN = Local0
1284 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001285
1286 If (Local2) {
1287 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001288 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001289 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001290 }
1291
1292 Return (CRS)
1293 }
1294
1295 }
1296 #endif
1297
1298 #ifndef NO_W83627HF_MIDI
1299 /* ========================== MIDI Port ========================== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001300 Device (MIDI)
1301 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001302 Name (_HID, EisaId ("PNPB006"))
1303 Name (_STR, Unicode ("MPU-401 Compatible MIDI Port"))
1304 Name (_UID, "w83627hf-midi")
1305
Christoph Grenz287ca502011-11-05 23:39:20 +01001306 Method (_STA)
1307 {
Felix Singerfa070962022-12-12 04:43:21 +01001308 Local0 = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001309 ENTER_CONFIG_MODE (7)
Felix Singer5a303b02021-12-31 13:12:16 +01001310 If (IO2L || IO2H) {
1311 If (ACTR || ACT2) {
Felix Singerfa070962022-12-12 04:43:21 +01001312 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001313 }
1314 Else {
Felix Singerfa070962022-12-12 04:43:21 +01001315 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001316 }
1317 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001318 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001319 Return (Local0)
1320 }
1321
1322 Method (_CRS)
1323 {
1324 Name (CRS, ResourceTemplate () {
1325 IO (Decode16, 0x0000, 0x0000, 0x02, 0x02, IO0)
1326 IRQNoFlags (IRQX) {}
1327 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001328 ENTER_CONFIG_MODE (7)
Felix Singerfa070962022-12-12 04:43:21 +01001329 Local0 = IO2L
1330 Local1 = IO2H
1331 Local2 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001332 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001333
Felix Singer86bc2e72022-12-16 04:40:39 +01001334 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001335
1336 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001337 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001338 IMIN = Local0
1339 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001340
1341 If (Local2) {
1342 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001343 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001344 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001345 }
1346
1347 Return (CRS)
1348 }
1349
1350 }
1351 #endif
1352
1353 /* ==== Suspend LED control if it is connected to the SuperIO ==== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001354 Method (SLED, 1)
1355 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001356 ENTER_CONFIG_MODE (9)
Felix Singerfa070962022-12-12 04:43:21 +01001357 Local0 = OPT4
Felix Singer35e65a82022-12-16 07:11:17 +01001358 Local0 &= 63
Felix Singerd2527762022-12-16 07:54:16 +01001359 OPT4 = Local0 | ((Arg0 & 3) << 6)
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001360 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001361 }
1362
1363 /* ===== Power LED control if it is connected to the SuperIO ===== */
Christoph Grenz287ca502011-11-05 23:39:20 +01001364 Method (PLED, 1)
1365 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001366 ENTER_CONFIG_MODE (8)
Felix Singerfa070962022-12-12 04:43:21 +01001367 Local0 = OPT4
Felix Singer35e65a82022-12-16 07:11:17 +01001368 Local0 &= 63
Felix Singerd2527762022-12-16 07:54:16 +01001369 OPT4 = Local0 | ((Arg0 & 3) << 6)
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001370 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001371 }
1372
1373 #ifndef NO_W83627HF_HWMON
1374 /* ====================== Hardware Monitor ======================= */
Christoph Grenz287ca502011-11-05 23:39:20 +01001375 Device (HMON)
1376 {
Christoph Grenze3e641c2011-11-05 22:14:41 +01001377 Name (_HID, EisaId ("PNP0C02")) // TODO: find better matching ID
1378 Name (_STR, Unicode("W83627 Hardware Monitor"))
1379 Name (_UID, "w83627hf-hwmon")
1380
1381 Method (_STA)
1382 {
Felix Singerfa070962022-12-12 04:43:21 +01001383 Local0 = 0x00
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001384 ENTER_CONFIG_MODE (11)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001385 If (ACTR) {
Felix Singerfa070962022-12-12 04:43:21 +01001386 Local0 = 0x0F
Christoph Grenze3e641c2011-11-05 22:14:41 +01001387 }
Felix Singer5a303b02021-12-31 13:12:16 +01001388 ElseIf (IO1H || IO1L)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001389 {
Felix Singerfa070962022-12-12 04:43:21 +01001390 Local0 = 0x0D
Christoph Grenze3e641c2011-11-05 22:14:41 +01001391 }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001392 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001393 Return (Local0)
1394 }
1395
Christoph Grenz287ca502011-11-05 23:39:20 +01001396 Method (_PSC)
1397 {
Felix Singerfa070962022-12-12 04:43:21 +01001398 Local0 = ^^_PSC ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001399 If (Local0) { Return (Local0) }
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001400 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerfa070962022-12-12 04:43:21 +01001401 Local0 = HWPW
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001402 EXIT_CONFIG_MODE ()
Nico Huber79dfa902020-03-22 01:17:54 +01001403 If (Local0) { Return (3) }
Christoph Grenze3e641c2011-11-05 22:14:41 +01001404 Else { Return (0) }
1405 }
Christoph Grenz287ca502011-11-05 23:39:20 +01001406
1407 Method (_PS0)
1408 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001409 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singerca4b5872022-12-26 08:17:06 +01001410 HWPW = 1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001411 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001412 }
Christoph Grenz287ca502011-11-05 23:39:20 +01001413
Nico Huber79dfa902020-03-22 01:17:54 +01001414 Method (_PS3)
Christoph Grenz287ca502011-11-05 23:39:20 +01001415 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001416 ENTER_CONFIG_MODE (PNP_NO_LDN_CHANGE)
Felix Singer42efd7f2022-12-26 09:38:45 +01001417 HWPW = 0
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001418 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001419 }
1420
Oskar Enoksson42283e72014-02-11 23:19:02 +01001421 Method (_CRS, 0, Serialized)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001422 {
1423 Name (CRS, ResourceTemplate () {
1424 IO (Decode16, 0x0000, 0x0000, 0x08, 0x02, IO0)
1425 IRQNoFlags (IRQX) {}
1426 })
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001427 ENTER_CONFIG_MODE (11)
Felix Singerfa070962022-12-12 04:43:21 +01001428 Local0 = IO1L
1429 Local1 = IO1H
1430 Local2 = IRQ1
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001431 EXIT_CONFIG_MODE ()
Christoph Grenz287ca502011-11-05 23:39:20 +01001432
Felix Singer86bc2e72022-12-16 04:40:39 +01001433 Local0 |= Local1 << 8
Christoph Grenze3e641c2011-11-05 22:14:41 +01001434
1435 CreateWordField (CRS, IO0._MIN, IMIN)
Christoph Grenze3e641c2011-11-05 22:14:41 +01001436 CreateWordField (CRS, IO0._MAX, IMAX)
Felix Singerfa070962022-12-12 04:43:21 +01001437 IMIN = Local0
1438 IMAX = Local0
Christoph Grenze3e641c2011-11-05 22:14:41 +01001439
1440 If (Local2) {
1441 CreateWordField (CRS, IRQX._INT, IRQW)
Felix Singerca4b5872022-12-26 08:17:06 +01001442 Local3 = 1
Felix Singer3c9291b2022-12-16 02:43:56 +01001443 IRQW = Local3 << Local2
Christoph Grenze3e641c2011-11-05 22:14:41 +01001444 }
1445 Return (CRS)
1446 }
1447 }
1448 #endif
1449
1450 /* Returns the wake source register.
1451 It is cleared after reading.
1452 Bit 0: Keyboard wake-up event
1453 Bit 1: Mouse wake-up event
1454 Bit 2: Power button event
1455 Bit 3: CIR wake-up event
1456 Bit 4: Power loss event
1457 Bit 5: VSB power loss status
1458 */
Christoph Grenz287ca502011-11-05 23:39:20 +01001459 Method (WAKS)
1460 {
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001461 ENTER_CONFIG_MODE (10)
Felix Singerfa070962022-12-12 04:43:21 +01001462 Local0 = CRE3
Elyes HAOUAScfaf4c72020-03-29 17:29:48 +02001463 EXIT_CONFIG_MODE ()
Christoph Grenze3e641c2011-11-05 22:14:41 +01001464 Return (Local0)
Christoph Grenz8ae574c2011-09-18 22:53:18 +02001465 }
Christoph Grenzd17f3d72011-10-19 02:24:23 +02001466}