blob: 8fb9da2824692c86ef6949e75f16c30931824a92 [file] [log] [blame]
Michał Żygowskifba08302020-04-13 20:51:32 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3/*
4 * Include this file into a mainboard's DSDT _SB device tree and it will
5 * expose the SCH5545 SuperIO and some of its functionality.
6 *
7 * It allows the change of IO ports, IRQs and DMA settings on logical
8 * devices, disabling and reenabling logical devices and controlling power
9 * saving mode on logical devices or the whole chip.
10 *
11 * LDN State
12 * 0x0 FDC Not implemented
13 * 0x3 PP Not implemented
14 * 0x4 UARTA Implemented and tested
15 * 0x5 UARTB Implemented
16 * 0x7 KBC Implemented and tested
17 *
18 * Controllable through preprocessor defines:
19 * SUPERIO_PNP_BASE I/O address of the first PnP configuration register
20 * SCH5545_SHOW_UARTA If defined, UARTA will be exposed.
21 * SCH5545_SHOW_UARTB If defined, UARTB will be exposed.
22 * SCH5545_SHOW_KBC If defined, the KBC will be exposed.
23 * SCH5545_EMI_BASE If defined, the Embedded Memory Interface resource will be exposed.
24 * SCH5545_RUNTIME_BASE If defined, The Runtime Registers resource will be exposed.
25 */
26
27#undef SUPERIO_CHIP_NAME
28#define SUPERIO_CHIP_NAME SCH5545
29#include <superio/acpi/pnp.asl>
30
31#undef PNP_DEFAULT_PSC
32#define PNP_DEFAULT_PSC Return (0) /* no power management */
33
34/*
35* Common helpers will not work on this chip. IO, DMA and IRQ resources.
36* These are accessed via LPC interface LDN 0xC.
37*/
38#undef PNP_READ_IO
39#undef PNP_READ_IRQ
40#undef PNP_READ_DMA
41#undef PNP_WRITE_IO
42#undef PNP_WRITE_IRQ
43#undef PNP_WRITE_DMA
44
45Device(SIO1) {
46 Name (_HID, EisaId("PNP0A05"))
47 Name (_STR, Unicode("SMSC SCH5545 Super I/O"))
48 Name (_UID, SUPERIO_UID(SIO1,))
49
50#ifdef SCH5545_EMI_BASE
51 Name (IO1B, SCH5545_EMI_BASE)
52#endif
53#ifdef SCH5545_RUNTIME_BASE
54 Name (IO2B, SCH5545_RUNTIME_BASE)
55#endif
56 Name (IOST, 0x0001) /* IO decoding status */
Felix Singerca4b5872022-12-26 08:17:06 +010057 Name (MSFG, 1) /* Mouse wake config */
58 Name (KBFG, 1) /* Keyboard wake config */
Michał Żygowskifba08302020-04-13 20:51:32 +020059 Name (PMFG, Zero) /* Wake config */
60
61 /* SuperIO configuration ports */
62 OperationRegion (CREG, SystemIO, SUPERIO_PNP_BASE, 0x02)
63 Field (CREG, ByteAcc, NoLock, Preserve)
64 {
65 PNP_ADDR_REG, 8,
66 PNP_DATA_REG, 8
67 }
68 IndexField (PNP_ADDR_REG, PNP_DATA_REG, ByteAcc, NoLock, Preserve)
69 {
70 Offset (0x07),
71 PNP_LOGICAL_DEVICE, 8, /* Logical device selector */
72
73 Offset (0x30),
74 PNP_DEVICE_ACTIVE, 1, /* Logical device activation */
75
76 Offset (0x69),
77 CR69, 8, /* UART1 Base address Registers */
78 CR6A, 8,
79 CR6B, 8,
80 Offset (0x6D),
81 CR6D, 8, /* UART2 Base address Registers */
82 CR6E, 8,
83 CR6F, 8,
84 Offset (0x7D),
85 CR7D, 8, /* FD Base address Registers */
86 CR7E, 8,
87 CR7F, 8,
88 Offset (0x81),
89 CR81, 8, /* LPT Base address Registers */
90 CR82, 8,
91 CR83, 8,
92 Offset (0xF0),
93 OPT0, 8, /* MISC registers */
94 OPT1, 8,
95 OPT2, 8,
96 OPT3, 8,
97 OPT4, 8,
98 OPT5, 8
99 }
100
101#ifdef SCH5545_RUNTIME_BASE
102 /* Runtime registers */
103 OperationRegion (RNTR, SystemIO, SCH5545_RUNTIME_BASE, 0x40)
104 Field (RNTR, ByteAcc, NoLock, Preserve)
105 {
106 PMES, 1, /* PME Global Status */
107 Offset (0x01),
108 PMEN, 1, /* PME Global Enable */
109 Offset (0x02),
110 PMS1, 8, /* PME Status 1 for KBD and PS2M */
111 PMS2, 8, /* PME Status 2 for EC, WDT, Bat, Intruder */
112 PMS3, 8, /* PME Status 3 for GPIOs */
113 PME1, 8, /* PME Enable 1 for KBD and PS2M */
114 PME2, 8, /* PME Enable 2 for EC, WDT, Bat, Intruder */
115 PME3, 8, /* PME Enable 3 for GPIOs */
116 Offset (0x10),
117 SOIS, 1, /* SMI Global Status*/
118 Offset (0x11),
119 SOIE, 1, /* SMI Global Enable */
120 Offset (0x12),
121 SST1, 8, /* SMI Status 1 for UARTs, LPT, FD, EC, Bat */
122 SST2, 8, /* SMI Status 2 for KBD, PS2M, WDT, Intruder */
123 SST3, 8, /* SMI Status 3 for GPIOs */
124 Offset (0x16),
125 SEN1, 8, /* SMI Enable 1 for UARTs, LPT, FD, EC, Bat */
126 SEN2, 8, /* SMI Enable 2 for KBD, PS2M, WDT, Intruder */
127 SEN3, 8, /* SMI Enable 3 for GPIOs */
128 Offset (0x25),
129 LED1, 8, /* LED control register */
130 Offset (0x28),
131 GPSR, 8, /* GPIO Select Register */
132 GPRR, 8 /* GPIO Read Register */
133 }
134#endif
135 Name (CRS, ResourceTemplate ()
136 {
137 IO (Decode16,
138 0x0000,
139 0x0000,
140 0x00,
141 0x00,
142 _Y11)
143#ifdef SCH5545_EMI_BASE
144 IO (Decode16,
145 0x0000,
146 0x0000,
147 0x00,
148 0x00,
149 _Y12)
150#endif
151#ifdef SCH5545_RUNTIME_BASE
152 IO (Decode16,
153 0x0000,
154 0x0000,
155 0x00,
156 0x00,
157 _Y13)
158#endif
159 })
160 Method (_CRS, 0, NotSerialized)
161 {
162 If (SUPERIO_PNP_BASE)
163 {
164 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y11._MIN, GPI0)
165 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y11._MAX, GPI1)
166 CreateByteField (CRS, \_SB.PCI0.LPCB.SIO1._Y11._LEN, GPIL)
167 GPI0 = SUPERIO_PNP_BASE
168 GPI1 = SUPERIO_PNP_BASE
169 GPIL = 0x02
170 }
171#ifdef SCH5545_EMI_BASE
172 If (IO1B)
173 {
174 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y12._MIN, GP10)
175 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y12._MAX, GP11)
176 CreateByteField (CRS, \_SB.PCI0.LPCB.SIO1._Y12._LEN, GPL1)
177 GP10 = SCH5545_EMI_BASE
178 GP11 = SCH5545_EMI_BASE
179 GPL1 = 0x10
180 }
181#endif
182#ifdef SCH5545_RUNTIME_BASE
183 If (IO2B)
184 {
185 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y13._MIN, GP20)
186 CreateWordField (CRS, \_SB.PCI0.LPCB.SIO1._Y13._MAX, GP21)
187 CreateByteField (CRS, \_SB.PCI0.LPCB.SIO1._Y13._LEN, GPL2)
188 GP20 = SCH5545_RUNTIME_BASE
189 GP21 = SCH5545_RUNTIME_BASE
190 GPL2 = 0x40
191 }
192#endif
193 Return (CRS)
194 }
195
196 #undef PNP_ENTER_MAGIC_1ST
197 #undef PNP_ENTER_MAGIC_2ND
198 #undef PNP_ENTER_MAGIC_3RD
199 #undef PNP_ENTER_MAGIC_4TH
200 #undef PNP_EXIT_MAGIC_1ST
201 #undef PNP_EXIT_SPECIAL_REG
202 #undef PNP_EXIT_SPECIAL_VAL
203 #define PNP_ENTER_MAGIC_1ST 0x55
204 #define PNP_EXIT_MAGIC_1ST 0xaa
205 #include <superio/acpi/pnp_config.asl>
206 #define SUPERIO_LPC_LDN 0x0C
207 #include "resource_helpers.asl"
208
209#ifdef SCH5545_SHOW_KBC
210 Device (PS2K)
211 {
212 Name (_HID, EisaId ("PNP0303"))
213 Name (_CID, EisaId ("PNP030B"))
214 Method (_STA, 0, NotSerialized)
215 {
216 Return (DSTA (0xa))
217 }
218
219 Name (_CRS, ResourceTemplate ()
220 {
221 IO (Decode16,
222 0x0060,
223 0x0060,
224 0x00,
225 0x01,
226 )
227 IO (Decode16,
228 0x0064,
229 0x0064,
230 0x00,
231 0x01,
232 )
233 IRQ (Edge, ActiveHigh, Exclusive) {1}
234 })
Michał Żygowskifba08302020-04-13 20:51:32 +0200235 Method (_PSW, 1, NotSerialized) // _PSW: Power State Wake
236 {
237 KBFG = Arg0
238 }
239 Name (_PRW, Package() { 8, 3 })
240 }
241
242 Device (PS2M)
243 {
244 Name (_HID, EisaId ("PNP0F13"))
245 Method (_STA, 0, NotSerialized)
246 {
247 Return (DSTA (0xe))
248 }
249
250 Name (_CRS, ResourceTemplate ()
251 {
252 IRQ (Edge, ActiveHigh, Exclusive) {12}
253 })
254
Michał Żygowskifba08302020-04-13 20:51:32 +0200255 Method (_PSW, 1, NotSerialized)
256 {
257 MSFG = Arg0
258 }
259
260 Name (_PRW, Package() { 8, 3 })
261 }
262
263 OperationRegion (IOKP, SystemIO, 0x60, 0x05)
264 Field (IOKP, ByteAcc, NoLock, Preserve)
265 {
266 KP60, 8,
267 Offset (0x04),
268 KP64, 8
269 }
270
Felix Singerca4b5872022-12-26 08:17:06 +0100271 OperationRegion (KB64, SystemIO, 0x64, 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200272 Field (KB64, ByteAcc, NoLock, Preserve)
273 {
274 , 1,
275 KRDY, 1,
276 Offset (0x01)
277 }
278#ifdef SCH5545_RUNTIME_BASE
279 /* SIO prepare to sleep */
280 Method (SIOS, 1, NotSerialized)
281 {
Felix Singerca4b5872022-12-26 08:17:06 +0100282 If ((Arg0 == 0x03) | (Arg0 == 1))
Michał Żygowskifba08302020-04-13 20:51:32 +0200283 {
Felix Singerca4b5872022-12-26 08:17:06 +0100284 ENTER_CONFIG_MODE (1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200285 Local0 = OPT0
286 OPT0 = (Local0 | 0x60)
287 EXIT_CONFIG_MODE ()
288 Local0 = PMS1
289 PMS1 = (Local0 | 0x18)
290 Local0 = PMES
Felix Singerca4b5872022-12-26 08:17:06 +0100291 PMES = (Local0 | 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200292
293 Local0 = PME1
294 If (KBFG)
295 {
296 PME1 = (Local0 | 0x08)
297 }
298 Else
299 {
300 PME1 = (Local0 & 0xF7)
301 }
302
303 Local0 = PME1
304 If (MSFG)
305 {
306 PME1 = (Local0 | 0x10)
307 }
308 Else
309 {
310 PME1 = (Local0 & 0xEF)
311 }
312
313 Local0 = PMEN
Felix Singerca4b5872022-12-26 08:17:06 +0100314 PMEN = (Local0 | 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200315
316 While (KRDY) {}
317 KP60 = 0xED
318 While (KRDY) {}
319 KP60 = Zero
320 While (KRDY) {}
321 KP60 = 0xF4
Felix Singerca4b5872022-12-26 08:17:06 +0100322 Sleep (1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200323 }
324 }
325
326 Method (GPKM, 0, NotSerialized)
327 {
328 Local0 = PME1
329 PME1 = (Local0 & 0xE7)
330 Local0 = PMEN
331 PMEN = (Local0 & 0xFE)
332 Local0 = PMS1
333 PMS1 = (Local0 & 0x18)
334 Local0 = PMES
Felix Singerca4b5872022-12-26 08:17:06 +0100335 PMES = (Local0 & 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200336 }
337
338 /* SIO wake method */
339 Method (SIOW, 1, NotSerialized)
340 {
341 PMFG = PMS1
Felix Singerca4b5872022-12-26 08:17:06 +0100342 If (Arg0 == 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200343 {
344 GPKM ()
Felix Singerca4b5872022-12-26 08:17:06 +0100345 ENTER_CONFIG_MODE (1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200346 Local0 = OPT0
347 OPT0 = (Local0 & 0x9F)
348 EXIT_CONFIG_MODE ()
349 }
350
351 If (Arg0 == 0x03)
352 {
353 GPKM ()
Felix Singerca4b5872022-12-26 08:17:06 +0100354 ENTER_CONFIG_MODE (1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200355 Local0 = OPT0
356 OPT0 = (Local0 & 0x9F)
Felix Singerca4b5872022-12-26 08:17:06 +0100357 OPT2 |= 1
Michał Żygowskifba08302020-04-13 20:51:32 +0200358 OPT2 &= 0xFE
359 EXIT_CONFIG_MODE ()
360 }
361 }
362
363 Method (SIOH, 0, NotSerialized)
364 {
365 If (PMFG & 0x08)
366 {
367 Notify (PS2K, 0x02) // Device Wake
368 }
369
370 If (PMFG & 0x10)
371 {
372 Notify (PS2M, 0x02) // Device Wake
373 }
374 }
375#endif // SCH5545_RUNTIME_BASE
376#endif // SCH5545_SHOW_KBC
377
378#ifdef SCH5545_SHOW_UARTA
379#define SUPERIO_UARTA_LDN 7
380 Device (UAR1)
381 {
382 Name (_HID, EisaId ("PNP0501"))
383 Name (_UID, SUPERIO_UID(SER, SUPERIO_UARTA_LDN))
384 Method (_STA, 0, NotSerialized)
385 {
386 Return (DSTA (Zero))
387 }
388
389 Method (_DIS, 0, NotSerialized)
390 {
391 DCNT (Zero, Zero)
392 }
393
394 Method (_CRS, 0, NotSerialized)
395 {
396 Return (DCRS (Zero, Zero))
397 }
398
399 Method (_SRS, 1, NotSerialized)
400 {
401 CreateWordField (Arg0, 0x02, IO11)
402 CreateWordField (Arg0, 0x09, IRQM)
403 ENTER_CONFIG_MODE (SUPERIO_LPC_LDN)
404 STIO (0x6A, IO11)
405 SIRQ (Zero, IRQM)
406 EXIT_CONFIG_MODE ()
Felix Singerca4b5872022-12-26 08:17:06 +0100407 DCNT (Zero, 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200408 }
409
410 Name (_PRS, ResourceTemplate ()
411 {
412 StartDependentFn (0x00, 0x00)
413 {
414 IO (Decode16,
415 0x03F8,
416 0x03F8,
417 0x01,
418 0x08,
419 )
420 IRQNoFlags ()
421 {4}
422 DMA (Compatibility, NotBusMaster, Transfer8, )
423 {}
424 }
425 StartDependentFn (0x00, 0x00)
426 {
427 IO (Decode16,
428 0x02F8,
429 0x02F8,
430 0x01,
431 0x08,
432 )
433 IRQNoFlags ()
434 {3}
435 DMA (Compatibility, NotBusMaster, Transfer8, )
436 {}
437 }
438 StartDependentFn (0x00, 0x00)
439 {
440 IO (Decode16,
441 0x03E8,
442 0x03E8,
443 0x01,
444 0x08,
445 )
446 IRQNoFlags ()
447 {4}
448 DMA (Compatibility, NotBusMaster, Transfer8, )
449 {}
450 }
451 StartDependentFn (0x00, 0x00)
452 {
453 IO (Decode16,
454 0x02E8,
455 0x02E8,
456 0x01,
457 0x08,
458 )
459 IRQNoFlags ()
460 {3}
461 DMA (Compatibility, NotBusMaster, Transfer8, )
462 {}
463 }
464 EndDependentFn ()
465 })
466
467 Name (_PRW, Package() { 8, 3 })
468 }
469#endif
470
471#ifdef SCH5545_SHOW_UARTB
472#define SUPERIO_UARTB_LDN 8
473 Device (UAR1)
474 {
475 Name (_HID, EisaId ("PNP0501"))
476 Name (_UID, SUPERIO_UID(SER, SUPERIO_UARTB_LDN))
477 Method (_STA, 0, NotSerialized)
478 {
Felix Singerca4b5872022-12-26 08:17:06 +0100479 Return (DSTA (1))
Michał Żygowskifba08302020-04-13 20:51:32 +0200480 }
481
482 Method (_DIS, 0, NotSerialized)
483 {
Felix Singerca4b5872022-12-26 08:17:06 +0100484 DCNT (1, Zero)
Michał Żygowskifba08302020-04-13 20:51:32 +0200485 }
486
487 Method (_CRS, 0, NotSerialized)
488 {
Felix Singerca4b5872022-12-26 08:17:06 +0100489 Return (DCRS (1, Zero))
Michał Żygowskifba08302020-04-13 20:51:32 +0200490 }
491
492 Method (_SRS, 1, NotSerialized)
493 {
494 CreateWordField (Arg0, 0x02, IO11)
495 CreateWordField (Arg0, 0x09, IRQM)
496 ENTER_CONFIG_MODE (SUPERIO_LPC_LDN)
497 STIO (0x6E, IO11)
Felix Singerca4b5872022-12-26 08:17:06 +0100498 SIRQ (1, IRQM)
Michał Żygowskifba08302020-04-13 20:51:32 +0200499 EXIT_CONFIG_MODE ()
Felix Singerca4b5872022-12-26 08:17:06 +0100500 DCNT (1, 1)
Michał Żygowskifba08302020-04-13 20:51:32 +0200501 }
502
503 Name (_PRS, ResourceTemplate ()
504 {
505 StartDependentFn (0x00, 0x00)
506 {
507 IO (Decode16,
508 0x03F8,
509 0x03F8,
510 0x01,
511 0x08,
512 )
513 IRQNoFlags ()
514 {4}
515 DMA (Compatibility, NotBusMaster, Transfer8, )
516 {}
517 }
518 StartDependentFn (0x00, 0x00)
519 {
520 IO (Decode16,
521 0x02F8,
522 0x02F8,
523 0x01,
524 0x08,
525 )
526 IRQNoFlags ()
527 {3}
528 DMA (Compatibility, NotBusMaster, Transfer8, )
529 {}
530 }
531 StartDependentFn (0x00, 0x00)
532 {
533 IO (Decode16,
534 0x03E8,
535 0x03E8,
536 0x01,
537 0x08,
538 )
539 IRQNoFlags ()
540 {4}
541 DMA (Compatibility, NotBusMaster, Transfer8, )
542 {}
543 }
544 StartDependentFn (0x00, 0x00)
545 {
546 IO (Decode16,
547 0x02E8,
548 0x02E8,
549 0x01,
550 0x08,
551 )
552 IRQNoFlags ()
553 {3}
554 DMA (Compatibility, NotBusMaster, Transfer8, )
555 {}
556 }
557 EndDependentFn ()
558 })
559
560 Name (_PRW, Package() { 8, 3 })
561 }
562
563#endif
564}