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) 2011 Christoph Grenz <christophg+cb@grenz-bonn.de> |
| 5 | * Copyright (C) 2013 secunet Security Networks AG |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | /* ========================== UART ========================== */ |
| 22 | |
| 23 | /* |
| 24 | * Generic setup for 16550A compatible UARTs. |
| 25 | * |
| 26 | * Controlled by the following preprocessor defines: |
| 27 | * |
| 28 | * SUPERIO_CHIP_NAME The name of the super i/o chip (unique, required) |
| 29 | * SUPERIO_UART_LDN The logical device number on the super i/o |
| 30 | * chip for this UART (required) |
| 31 | * SUPERIO_UART_DDN A string literal that identifies the dos device |
| 32 | * name (DDN) of this uart (e.g. "COM1", optional) |
| 33 | * SUPERIO_UART_PM_REG Identifier of a 1-bit register to power down |
| 34 | * the UART (optional) |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 35 | * SUPERIO_UART_PM_VAL The value for SUPERIO_UART_PM_REG to power the logical |
| 36 | * device down (required if SUPERIO_UART_PM_REG is defined) |
| 37 | * 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] | 38 | * bit (required if SUPERIO_UART_PM_REG is defined) |
| 39 | */ |
| 40 | |
| 41 | #include "pnp.asl" |
| 42 | |
| 43 | #ifndef SUPERIO_CHIP_NAME |
| 44 | # error "SUPERIO_CHIP_NAME is not defined." |
| 45 | #endif |
| 46 | |
| 47 | #ifndef SUPERIO_UART_LDN |
| 48 | # error "SUPERIO_UART_LDN is not defined." |
| 49 | #endif |
| 50 | |
| 51 | Device (SUPERIO_ID(SER, SUPERIO_UART_LDN)) { |
| 52 | Name (_HID, EisaId ("PNP0501")) |
| 53 | Name (_UID, SUPERIO_UID(SER, SUPERIO_UART_LDN)) |
| 54 | #ifdef SUPERIO_UART_DDN |
| 55 | Name (_DDN, SUPERIO_UART_DDN) |
| 56 | #endif |
| 57 | |
| 58 | Method (_STA) |
| 59 | { |
| 60 | PNP_GENERIC_STA(SUPERIO_UART_LDN) |
| 61 | } |
| 62 | |
| 63 | Method (_DIS) |
| 64 | { |
| 65 | PNP_GENERIC_DIS(SUPERIO_UART_LDN) |
| 66 | } |
| 67 | |
| 68 | #ifdef SUPERIO_UART_PM_REG |
| 69 | Method (_PSC) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 70 | 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] | 71 | } |
| 72 | |
| 73 | Method (_PS0) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 74 | 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] | 75 | } |
| 76 | |
| 77 | Method (_PS1) { |
Nico Huber | dd94fa9 | 2013-07-01 16:29:16 +0200 | [diff] [blame] | 78 | PNP_GENERIC_PS1(SUPERIO_UART_PM_REG, SUPERIO_UART_PM_VAL, SUPERIO_UART_PM_LDN) |
Nico Huber | ae7c968 | 2013-05-23 18:13:23 +0200 | [diff] [blame] | 79 | } |
| 80 | #else |
| 81 | Method (_PSC) { |
| 82 | PNP_DEFAULT_PSC |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | Method (_CRS) |
| 87 | { |
| 88 | Name (CRS, ResourceTemplate () { |
| 89 | IO (Decode16, 0x0000, 0x0000, 0x08, 0x08, IO0) |
| 90 | IRQNoFlags (IR0) {} |
| 91 | }) |
| 92 | ENTER_CONFIG_MODE (SUPERIO_UART_LDN) |
| 93 | PNP_READ_IO(PNP_IO0, CRS, IO0) |
| 94 | PNP_READ_IRQ(PNP_IRQ0, CRS, IR0) |
| 95 | EXIT_CONFIG_MODE () |
| 96 | Return (CRS) |
| 97 | } |
| 98 | |
| 99 | Name (_PRS, ResourceTemplate () |
| 100 | { |
| 101 | StartDependentFn (0,0) { |
| 102 | IO (Decode16, 0x03f8, 0x03f8, 0x08, 0x08) |
| 103 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 104 | } |
| 105 | StartDependentFn (0,0) { |
| 106 | IO (Decode16, 0x02f8, 0x02f8, 0x08, 0x08) |
| 107 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 108 | } |
| 109 | StartDependentFn (1,0) { |
| 110 | IO (Decode16, 0x03e8, 0x03e8, 0x08, 0x08) |
| 111 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 112 | } |
| 113 | StartDependentFn (1,0) { |
| 114 | IO (Decode16, 0x02e8, 0x02e8, 0x08, 0x08) |
| 115 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 116 | } |
| 117 | StartDependentFn (2,0) { |
| 118 | IO (Decode16, 0x0100, 0x0ff8, 0x08, 0x08) |
| 119 | IRQNoFlags () {3,4,5,7,9,10,11,12} |
| 120 | } |
| 121 | EndDependentFn() |
| 122 | }) |
| 123 | |
| 124 | Method (_SRS, 1, Serialized) |
| 125 | { |
| 126 | Name (TMPL, ResourceTemplate () { |
| 127 | IO (Decode16, 0x0000, 0x0000, 0x00, 0x00, IO0) |
| 128 | IRQNoFlags (IR0) {} |
| 129 | }) |
| 130 | ENTER_CONFIG_MODE (SUPERIO_UART_LDN) |
| 131 | PNP_WRITE_IO(PNP_IO0, Arg0, IO0) |
| 132 | PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0) |
| 133 | Store (One, PNP_DEVICE_ACTIVE) |
| 134 | EXIT_CONFIG_MODE () |
| 135 | } |
| 136 | } |