Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 secunet Security Networks AG |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | /* =================== Generic PnP Device =================== */ |
| 17 | |
| 18 | /* |
| 19 | * Generic setup for PnP devices. |
| 20 | * |
| 21 | * Controlled by the following preprocessor defines: |
| 22 | * |
| 23 | * SUPERIO_CHIP_NAME The name of the super i/o chip (unique, required) |
Samuel Holland | d2a86da | 2017-06-06 20:23:40 -0500 | [diff] [blame] | 24 | * SUPERIO_PNP_HID The EisaId string that identifies this device (optional) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 25 | * SUPERIO_PNP_LDN The logical device number on the super i/o |
| 26 | * chip for this device (required) |
| 27 | * SUPERIO_PNP_DDN A string literal that identifies the dos device |
| 28 | * name (DDN) of this device (e.g. "COM1", optional) |
| 29 | * SUPERIO_PNP_PM_REG Identifier of a 1-bit register to power down |
| 30 | * the logical device (optional) |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 31 | * SUPERIO_PNP_PM_VAL The value for SUPERIO_PNP_PM_REG to power the logical |
| 32 | * device down (required if SUPERIO_PNP_PM_REG is defined) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 33 | * SUPERIO_PNP_PM_LDN The logical device number to access the PM_REG |
| 34 | * bit (required if SUPERIO_PNP_PM_REG is defined) |
| 35 | * SUPERIO_PNP_IO0 The alignment and length of the first PnP i/o |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 36 | * resource (comma separated, e.g. `0x02, 0x08`, |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 37 | * optional) |
| 38 | * SUPERIO_PNP_IO1 The alignment and length of the second PnP i/o |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 39 | * resource (comma separated, e.g. `0x02, 0x08`, |
| 40 | * optional) |
| 41 | * SUPERIO_PNP_IO2 The alignment and length of the third PnP i/o |
| 42 | * resource (comma separated, e.g. `0x02, 0x08`, |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 43 | * optional) |
| 44 | * SUPERIO_PNP_IRQ0 If defined, the first PnP IRQ register is enabled |
| 45 | * SUPERIO_PNP_IRQ1 If defined, the second PnP IRQ register is enabled |
| 46 | * SUPERIO_PNP_DMA If defined, the PnP DMA register is enabled |
| 47 | */ |
| 48 | |
| 49 | #include "pnp.asl" |
| 50 | |
| 51 | #ifndef SUPERIO_CHIP_NAME |
| 52 | # error "SUPERIO_CHIP_NAME is not defined." |
| 53 | #endif |
| 54 | |
| 55 | #ifndef SUPERIO_PNP_LDN |
| 56 | # error "SUPERIO_PNP_LDN is not defined." |
| 57 | #endif |
| 58 | |
| 59 | Device (SUPERIO_ID(PN, SUPERIO_PNP_LDN)) { |
Samuel Holland | d2a86da | 2017-06-06 20:23:40 -0500 | [diff] [blame] | 60 | #ifdef SUPERIO_PNP_HID |
| 61 | Name (_HID, EisaId (SUPERIO_PNP_HID)) |
| 62 | #else |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 63 | Name (_HID, EisaId ("PNP0c02")) /* TODO: Better fitting EisaId? */ |
Samuel Holland | d2a86da | 2017-06-06 20:23:40 -0500 | [diff] [blame] | 64 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 65 | Name (_UID, SUPERIO_UID(PN, SUPERIO_PNP_LDN)) |
| 66 | #ifdef SUPERIO_PNP_DDN |
| 67 | Name (_DDN, SUPERIO_PNP_DDN) |
| 68 | #endif |
| 69 | |
| 70 | Method (_STA) |
| 71 | { |
| 72 | PNP_GENERIC_STA(SUPERIO_PNP_LDN) |
| 73 | } |
| 74 | |
| 75 | Method (_DIS) |
| 76 | { |
| 77 | PNP_GENERIC_DIS(SUPERIO_PNP_LDN) |
| 78 | } |
| 79 | |
| 80 | #ifdef SUPERIO_PNP_PM_REG |
| 81 | Method (_PSC) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 82 | PNP_GENERIC_PSC(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | Method (_PS0) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 86 | PNP_GENERIC_PS0(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | Method (_PS1) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 90 | PNP_GENERIC_PS1(SUPERIO_PNP_PM_REG, SUPERIO_PNP_PM_VAL, SUPERIO_PNP_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 91 | } |
| 92 | #else |
| 93 | Method (_PSC) { |
| 94 | PNP_DEFAULT_PSC |
| 95 | } |
| 96 | #endif |
| 97 | |
Tristan Corrick | 8f731b8 | 2018-08-01 03:08:53 +1200 | [diff] [blame] | 98 | Method (_CRS, 0, Serialized) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 99 | { |
| 100 | Name (CRS, ResourceTemplate () { |
| 101 | #ifdef SUPERIO_PNP_IO0 |
| 102 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0) |
| 103 | #endif |
| 104 | #ifdef SUPERIO_PNP_IO1 |
| 105 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1) |
| 106 | #endif |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 107 | #ifdef SUPERIO_PNP_IO2 |
| 108 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO2, IO2) |
| 109 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 110 | #ifdef SUPERIO_PNP_IRQ0 |
| 111 | IRQNoFlags (IR0) {} |
| 112 | #endif |
| 113 | #ifdef SUPERIO_PNP_IRQ1 |
| 114 | IRQNoFlags (IR1) {} |
| 115 | #endif |
| 116 | #ifdef SUPERIO_PNP_DMA |
| 117 | DMA (Compatibility, NotBusMaster, Transfer8, DM0) {} |
| 118 | #endif |
| 119 | }) |
| 120 | ENTER_CONFIG_MODE (SUPERIO_PNP_LDN) |
| 121 | #ifdef SUPERIO_PNP_IO0 |
| 122 | PNP_READ_IO(PNP_IO0, CRS, IO0) |
| 123 | #endif |
| 124 | #ifdef SUPERIO_PNP_IO1 |
| 125 | PNP_READ_IO(PNP_IO1, CRS, IO1) |
| 126 | #endif |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 127 | #ifdef SUPERIO_PNP_IO2 |
| 128 | PNP_READ_IO(PNP_IO2, CRS, IO2) |
| 129 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 130 | #ifdef SUPERIO_PNP_IRQ0 |
| 131 | PNP_READ_IRQ(PNP_IRQ0, CRS, IR0) |
| 132 | #endif |
| 133 | #ifdef SUPERIO_PNP_IRQ1 |
| 134 | PNP_READ_IRQ(PNP_IRQ1, CRS, IR1) |
| 135 | #endif |
| 136 | #ifdef SUPERIO_PNP_DMA |
| 137 | PNP_READ_DMA(PNP_DMA0, CRS, DM0) |
| 138 | #endif |
| 139 | EXIT_CONFIG_MODE () |
| 140 | Return (CRS) |
| 141 | } |
| 142 | |
| 143 | Method (_SRS, 1, Serialized) |
| 144 | { |
| 145 | Name (TMPL, ResourceTemplate () { |
| 146 | #ifdef SUPERIO_PNP_IO0 |
| 147 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO0, IO0) |
| 148 | #endif |
| 149 | #ifdef SUPERIO_PNP_IO1 |
| 150 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO1, IO1) |
| 151 | #endif |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 152 | #ifdef SUPERIO_PNP_IO2 |
| 153 | IO (Decode16, 0x0000, 0x0000, SUPERIO_PNP_IO2, IO2) |
| 154 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 155 | #ifdef SUPERIO_PNP_IRQ0 |
| 156 | IRQNoFlags (IR0) {} |
| 157 | #endif |
| 158 | #ifdef SUPERIO_PNP_IRQ1 |
| 159 | IRQNoFlags (IR1) {} |
| 160 | #endif |
| 161 | #ifdef SUPERIO_PNP_DMA |
| 162 | DMA (Compatibility, NotBusMaster, Transfer8, DM0) {} |
| 163 | #endif |
| 164 | }) |
| 165 | ENTER_CONFIG_MODE (SUPERIO_PNP_LDN) |
| 166 | #ifdef SUPERIO_PNP_IO0 |
| 167 | PNP_WRITE_IO(PNP_IO0, Arg0, IO0) |
| 168 | #endif |
| 169 | #ifdef SUPERIO_PNP_IO1 |
| 170 | PNP_WRITE_IO(PNP_IO1, Arg0, IO1) |
| 171 | #endif |
Samuel Holland | eeef645 | 2017-06-03 05:51:10 -0500 | [diff] [blame] | 172 | #ifdef SUPERIO_PNP_IO2 |
| 173 | PNP_WRITE_IO(PNP_IO2, Arg0, IO2) |
| 174 | #endif |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 175 | #ifdef SUPERIO_PNP_IRQ0 |
| 176 | PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0) |
| 177 | #endif |
| 178 | #ifdef SUPERIO_PNP_IRQ1 |
| 179 | PNP_WRITE_IRQ(PNP_IRQ1, Arg0, IR1) |
| 180 | #endif |
| 181 | #ifdef SUPERIO_PNP_DMA |
| 182 | PNP_WRITE_DMA(PNP_DMA0, Arg0, DM0) |
| 183 | #endif |
| 184 | Store (One, PNP_DEVICE_ACTIVE) |
| 185 | EXIT_CONFIG_MODE () |
| 186 | } |
| 187 | } |