Felix Held | 3f3eca9 | 2020-01-23 17:12:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 2 | |
| 3 | /* ========================== UART ========================== */ |
| 4 | |
| 5 | /* |
| 6 | * Generic setup for 16550A compatible UARTs. |
| 7 | * |
| 8 | * Controlled by the following preprocessor defines: |
| 9 | * |
Elyes HAOUAS | 495bb66 | 2019-09-23 13:15:41 +0200 | [diff] [blame] | 10 | * SUPERIO_CHIP_NAME The name of the Super I/O chip (unique, required) |
| 11 | * SUPERIO_UART_LDN The logical device number on the Super I/O |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 12 | * chip for this UART (required) |
| 13 | * SUPERIO_UART_DDN A string literal that identifies the dos device |
Elyes HAOUAS | 4580839 | 2020-03-30 16:43:34 +0200 | [diff] [blame] | 14 | * name (DDN) of this uart (e.g. "COM1", optional) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 15 | * SUPERIO_UART_PM_REG Identifier of a 1-bit register to power down |
| 16 | * the UART (optional) |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 17 | * SUPERIO_UART_PM_VAL The value for SUPERIO_UART_PM_REG to power the logical |
| 18 | * device down (required if SUPERIO_UART_PM_REG is defined) |
| 19 | * SUPERIO_UART_PM_LDN The logical device number to access the PM_REG |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 20 | * bit (required if SUPERIO_UART_PM_REG is defined) |
| 21 | */ |
| 22 | |
| 23 | #include "pnp.asl" |
| 24 | |
| 25 | #ifndef SUPERIO_CHIP_NAME |
| 26 | # error "SUPERIO_CHIP_NAME is not defined." |
| 27 | #endif |
| 28 | |
| 29 | #ifndef SUPERIO_UART_LDN |
| 30 | # error "SUPERIO_UART_LDN is not defined." |
| 31 | #endif |
| 32 | |
| 33 | Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) { |
| 34 | Name (_HID, EisaId ("PNP0501")) |
| 35 | Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN)) |
| 36 | #ifdef SUPERIO_UART_DDN |
| 37 | Name (_DDN, SUPERIO_UART_DDN) |
| 38 | #endif |
| 39 | |
| 40 | Method (_STA) |
| 41 | { |
| 42 | PNP_GENERIC_STA(SUPERIO_UART_LDN) |
| 43 | } |
| 44 | |
| 45 | Method (_DIS) |
| 46 | { |
| 47 | PNP_GENERIC_DIS(SUPERIO_UART_LDN) |
| 48 | } |
| 49 | |
| 50 | #ifdef SUPERIO_UART_PM_REG |
| 51 | Method (_PSC) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 52 | PNP_GENERIC_PSC(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | Method (_PS0) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 56 | PNP_GENERIC_PS0(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 57 | } |
| 58 | |
Nico Huber | 79dfa90 | 2020-03-22 01:17:54 +0100 | [diff] [blame] | 59 | Method (_PS3) { |
| 60 | PNP_GENERIC_PS3(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 61 | } |
| 62 | #else |
| 63 | Method (_PSC) { |
| 64 | PNP_DEFAULT_PSC |
| 65 | } |
| 66 | #endif |
| 67 | |
Tristan Corrick | 8f731b8 | 2018-08-01 03:08:53 +1200 | [diff] [blame] | 68 | Method (_CRS, 0, Serialized) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 69 | { |
| 70 | Name (CRS, ResourceTemplate () { |
| 71 | IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0) |
| 72 | IRQNoFlags (IR0) {} |
| 73 | }) |
| 74 | ENTER_CONFIG_MODE (SUPERIO_UART_LDN) |
| 75 | PNP_READ_IO(PNP_IO0, CRS, IO0) |
| 76 | PNP_READ_IRQ(PNP_IRQ0, CRS, IR0) |
| 77 | EXIT_CONFIG_MODE () |
| 78 | Return (CRS) |
| 79 | } |
| 80 | |
| 81 | Name (_PRS, ResourceTemplate () |
| 82 | { |
| 83 | StartDependentFn (0,0) { |
| 84 | IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08) |
| 85 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 86 | } |
| 87 | StartDependentFn (0,0) { |
| 88 | IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08) |
| 89 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 90 | } |
| 91 | StartDependentFn (1,0) { |
| 92 | IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08) |
| 93 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 94 | } |
| 95 | StartDependentFn (1,0) { |
| 96 | IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08) |
| 97 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 98 | } |
| 99 | StartDependentFn (2,0) { |
| 100 | IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08) |
| 101 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 102 | } |
| 103 | EndDependentFn() |
| 104 | }) |
| 105 | |
| 106 | Method (_SRS, 1, Serialized) |
| 107 | { |
| 108 | Name (TMPL, ResourceTemplate () { |
| 109 | IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0) |
| 110 | IRQNoFlags (IR0) {} |
| 111 | }) |
| 112 | ENTER_CONFIG_MODE (SUPERIO_UART_LDN) |
| 113 | PNP_WRITE_IO(PNP_IO0, Arg0, IO0) |
| 114 | PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0) |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 115 | PNP_DEVICE_ACTIVE = 1 |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 116 | EXIT_CONFIG_MODE () |
| 117 | } |
| 118 | } |