Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2003 Linux Networx |
| 5 | * Copyright (C) 2004 SuSE Linux AG |
| 6 | * Copyright (C) 2004 Tyan Computer |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 7 | * Copyright (C) 2010 Joseph Smith <joe@settoplinux.org> |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; version 2 of |
| 12 | * the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 18 | */ |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 19 | |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <device/device.h> |
| 22 | #include <device/pci.h> |
| 23 | #include <device/pci_ids.h> |
| 24 | #include <device/pci_ops.h> |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 25 | #include <pc80/mc146818rtc.h> |
Steven J. Magnani | ef79223 | 2005-09-21 13:53:44 +0000 | [diff] [blame] | 26 | #include <pc80/isa-dma.h> |
| 27 | #include <arch/io.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 28 | #include <arch/ioapic.h> |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 29 | #include "i82801dx.h" |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 30 | |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 31 | #define NMI_OFF 0 |
| 32 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 33 | typedef struct southbridge_intel_i82801dx_config config_t; |
| 34 | |
Kyösti Mälkki | e614353 | 2013-02-26 17:24:41 +0200 | [diff] [blame] | 35 | /** |
| 36 | * Enable ACPI I/O range. |
| 37 | * |
| 38 | * @param dev PCI device with ACPI and PM BAR's |
| 39 | */ |
| 40 | static void i82801dx_enable_acpi(struct device *dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 41 | { |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 42 | /* Set ACPI base address (I/O space). */ |
| 43 | pci_write_config32(dev, PMBASE, (PMBASE_ADDR | 1)); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 44 | |
Kyösti Mälkki | e614353 | 2013-02-26 17:24:41 +0200 | [diff] [blame] | 45 | /* Enable ACPI I/O range decode and ACPI power management. */ |
| 46 | pci_write_config8(dev, ACPI_CNTL, ACPI_EN); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Set miscellanous static southbridge features. |
| 51 | * |
| 52 | * @param dev PCI device with I/O APIC control registers |
| 53 | */ |
| 54 | static void i82801dx_enable_ioapic(struct device *dev) |
| 55 | { |
| 56 | u32 reg32; |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 57 | |
| 58 | reg32 = pci_read_config32(dev, GEN_CNTL); |
Kyösti Mälkki | e614353 | 2013-02-26 17:24:41 +0200 | [diff] [blame] | 59 | reg32 |= (1 << 13); /* Coprocessor error enable (COPR_ERR_EN) */ |
| 60 | reg32 |= (3 << 7); /* IOAPIC enable (APIC_EN) */ |
| 61 | reg32 |= (1 << 2); /* DMA collection buffer enable (DCB_EN) */ |
| 62 | reg32 |= (1 << 1); /* Delayed transaction enable (DTE) */ |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 63 | pci_write_config32(dev, GEN_CNTL, reg32); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 64 | printk(BIOS_DEBUG, "IOAPIC Southbridge enabled %x\n", reg32); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 65 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 66 | set_ioapic_id(VIO_APIC_VADDR, 0x02); |
Kyösti Mälkki | 8351243 | 2013-06-05 07:19:31 +0300 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * Select Boot Configuration register (0x03) and |
| 70 | * use Processor System Bus (0x01) to deliver interrupts. |
| 71 | */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 72 | io_apic_write(VIO_APIC_VADDR, 0x03, 0x01); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 73 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 74 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 75 | static void i82801dx_enable_serial_irqs(struct device *dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 76 | { |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 77 | /* Set packet length and toggle silent mode bit. */ |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 78 | pci_write_config8(dev, SERIRQ_CNTL, |
| 79 | (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0)); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 80 | pci_write_config8(dev, SERIRQ_CNTL, |
| 81 | (1 << 7) | (0 << 6) | ((21 - 17) << 2) | (0 << 0)); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 82 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 83 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 84 | static void i82801dx_pirq_init(device_t dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 85 | { |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 86 | /* Get the chip configuration */ |
| 87 | config_t *config = dev->chip_info; |
| 88 | |
| 89 | pci_write_config8(dev, PIRQA_ROUT, config->pirqa_routing); |
| 90 | pci_write_config8(dev, PIRQB_ROUT, config->pirqb_routing); |
| 91 | pci_write_config8(dev, PIRQC_ROUT, config->pirqc_routing); |
| 92 | pci_write_config8(dev, PIRQD_ROUT, config->pirqd_routing); |
| 93 | pci_write_config8(dev, PIRQE_ROUT, config->pirqe_routing); |
| 94 | pci_write_config8(dev, PIRQF_ROUT, config->pirqf_routing); |
| 95 | pci_write_config8(dev, PIRQG_ROUT, config->pirqg_routing); |
| 96 | pci_write_config8(dev, PIRQH_ROUT, config->pirqh_routing); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 97 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 98 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 99 | static void i82801dx_power_options(device_t dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 100 | { |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 101 | u8 reg8; |
| 102 | u16 reg16, pmbase; |
| 103 | u32 reg32; |
| 104 | const char *state; |
| 105 | |
| 106 | int pwr_on = CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL; |
Luc Verhaegen | a9c5ea0 | 2009-06-03 14:19:33 +0000 | [diff] [blame] | 107 | int nmi_option; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 108 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 109 | /* Which state do we want to goto after g3 (power restored)? |
| 110 | * 0 == S0 Full On |
| 111 | * 1 == S5 Soft Off |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 112 | * |
| 113 | * If the option is not existent (Laptops), use MAINBOARD_POWER_ON. |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 114 | */ |
Varad Gautam | 06ef046 | 2015-03-11 09:54:41 +0530 | [diff] [blame] | 115 | pwr_on = MAINBOARD_POWER_ON; |
| 116 | get_option(&pwr_on, "power_on_after_fail"); |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 117 | |
| 118 | reg8 = pci_read_config8(dev, GEN_PMCON_3); |
| 119 | reg8 &= 0xfe; |
| 120 | switch (pwr_on) { |
| 121 | case MAINBOARD_POWER_OFF: |
| 122 | reg8 |= 1; |
| 123 | state = "off"; |
| 124 | break; |
| 125 | case MAINBOARD_POWER_ON: |
| 126 | reg8 &= ~1; |
| 127 | state = "on"; |
| 128 | break; |
| 129 | case MAINBOARD_POWER_KEEP: |
| 130 | reg8 &= ~1; |
| 131 | state = "state keep"; |
| 132 | break; |
| 133 | default: |
| 134 | state = "undefined"; |
| 135 | } |
| 136 | |
| 137 | reg8 &= ~(1 << 3); /* minimum asssertion is 1 to 2 RTCCLK */ |
| 138 | |
| 139 | pci_write_config8(dev, GEN_PMCON_3, reg8); |
Stefan Reinauer | f0aa09b | 2010-03-23 13:23:40 +0000 | [diff] [blame] | 140 | printk(BIOS_INFO, "Set power %s after power failure.\n", state); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 141 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 142 | /* Set up NMI on errors. */ |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 143 | reg8 = inb(0x61); |
| 144 | reg8 &= 0x0f; /* Higher Nibble must be 0 */ |
| 145 | reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */ |
| 146 | // reg8 &= ~(1 << 2); /* PCI SERR# Enable */ |
| 147 | reg8 |= (1 << 2); /* PCI SERR# Disable for now */ |
| 148 | outb(reg8, 0x61); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 149 | |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 150 | reg8 = inb(0x70); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 151 | nmi_option = NMI_OFF; |
Luc Verhaegen | a9c5ea0 | 2009-06-03 14:19:33 +0000 | [diff] [blame] | 152 | get_option(&nmi_option, "nmi"); |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 153 | if (nmi_option) { |
Stefan Reinauer | f0aa09b | 2010-03-23 13:23:40 +0000 | [diff] [blame] | 154 | printk(BIOS_INFO, "NMI sources enabled.\n"); |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 155 | reg8 &= ~(1 << 7); /* Set NMI. */ |
| 156 | } else { |
Stefan Reinauer | f0aa09b | 2010-03-23 13:23:40 +0000 | [diff] [blame] | 157 | printk(BIOS_INFO, "NMI sources disabled.\n"); |
Elyes HAOUAS | 9c5d463 | 2018-04-26 22:21:21 +0200 | [diff] [blame] | 158 | reg8 |= (1 << 7); /* Disable NMI. */ |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 159 | } |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 160 | outb(reg8, 0x70); |
| 161 | |
| 162 | /* Set SMI# rate down and enable CPU_SLP# */ |
| 163 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 164 | reg16 &= ~(3 << 0); // SMI# rate 1 minute |
| 165 | reg16 |= (1 << 5); // CPUSLP_EN Desktop only |
| 166 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 167 | |
| 168 | pmbase = pci_read_config16(dev, 0x40) & 0xfffe; |
| 169 | |
| 170 | /* Set up power management block and determine sleep mode */ |
| 171 | reg32 = inl(pmbase + 0x04); // PM1_CNT |
| 172 | |
| 173 | reg32 &= ~(7 << 10); // SLP_TYP |
| 174 | reg32 |= (1 << 0); // SCI_EN |
| 175 | outl(reg32, pmbase + 0x04); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 176 | } |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 177 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 178 | static void gpio_init(device_t dev) |
| 179 | { |
| 180 | /* This should be done in romstage.c already */ |
| 181 | pci_write_config32(dev, GPIO_BASE, (GPIOBASE_ADDR | 1)); |
| 182 | pci_write_config8(dev, GPIO_CNTL, 0x10); |
| 183 | } |
| 184 | |
| 185 | static void i82801dx_rtc_init(struct device *dev) |
| 186 | { |
| 187 | u8 reg8; |
| 188 | u32 reg32; |
| 189 | int rtc_failed; |
| 190 | |
| 191 | reg8 = pci_read_config8(dev, GEN_PMCON_3); |
| 192 | rtc_failed = reg8 & RTC_BATTERY_DEAD; |
| 193 | if (rtc_failed) { |
| 194 | reg8 &= ~(1 << 1); /* Preserve the power fail state. */ |
| 195 | pci_write_config8(dev, GEN_PMCON_3, reg8); |
| 196 | } |
| 197 | reg32 = pci_read_config32(dev, GEN_STS); |
| 198 | rtc_failed |= reg32 & (1 << 2); |
Gabe Black | b3f08c6 | 2014-04-30 17:12:25 -0700 | [diff] [blame] | 199 | cmos_init(rtc_failed); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 200 | |
| 201 | /* Enable access to the upper 128 byte bank of CMOS RAM. */ |
| 202 | pci_write_config8(dev, RTC_CONF, 0x04); |
| 203 | } |
| 204 | |
| 205 | static void i82801dx_lpc_route_dma(struct device *dev, u8 mask) |
| 206 | { |
| 207 | u16 reg16; |
| 208 | int i; |
| 209 | |
| 210 | reg16 = pci_read_config16(dev, PCI_DMA_CFG); |
| 211 | reg16 &= 0x300; |
| 212 | for (i = 0; i < 8; i++) { |
| 213 | if (i == 4) |
| 214 | continue; |
| 215 | reg16 |= ((mask & (1 << i)) ? 3 : 1) << (i * 2); |
| 216 | } |
| 217 | pci_write_config16(dev, PCI_DMA_CFG, reg16); |
| 218 | } |
| 219 | |
| 220 | static void i82801dx_lpc_decode_en(device_t dev) |
| 221 | { |
| 222 | /* Decode 0x3F8-0x3FF (COM1) for COMA port, 0x2F8-0x2FF (COM2) for COMB. |
| 223 | * LPT decode defaults to 0x378-0x37F and 0x778-0x77F. |
| 224 | * Floppy decode defaults to 0x3F0-0x3F5, 0x3F7. |
| 225 | * We also need to set the value for LPC I/F Enables Register. |
| 226 | */ |
| 227 | pci_write_config8(dev, COM_DEC, 0x10); |
| 228 | pci_write_config16(dev, LPC_EN, 0x300F); |
| 229 | } |
| 230 | |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 231 | /* ICH4 does not mention HPET in the docs, but |
| 232 | * all ICH3 and ICH4 do have HPETs built in. |
| 233 | */ |
| 234 | static void enable_hpet(struct device *dev) |
| 235 | { |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 236 | u32 reg32, hpet, val; |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 237 | |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 238 | /* Set HPET base address and enable it */ |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 239 | printk(BIOS_DEBUG, "Enabling HPET at 0x%x\n", CONFIG_HPET_ADDRESS); |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 240 | reg32 = pci_read_config32(dev, GEN_CNTL); |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 241 | /* |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 242 | * Bit 17 is HPET enable bit. |
| 243 | * Bit 16:15 control the HPET base address. |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 244 | */ |
| 245 | reg32 &= ~(3 << 15); /* Clear it */ |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 246 | |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 247 | hpet = CONFIG_HPET_ADDRESS >> 12; |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 248 | hpet &= 0x3; |
| 249 | |
| 250 | reg32 |= (hpet << 15); |
| 251 | reg32 |= (1 << 17); /* Enable HPET. */ |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 252 | pci_write_config32(dev, GEN_CNTL, reg32); |
| 253 | |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 254 | /* Check to see whether it took */ |
| 255 | reg32 = pci_read_config32(dev, GEN_CNTL); |
| 256 | val = reg32 >> 15; |
| 257 | val &= 0x7; |
| 258 | |
| 259 | if ((val & 0x4) && (hpet == (val & 0x3))) { |
Patrick Georgi | 9aeb694 | 2012-10-05 21:54:38 +0200 | [diff] [blame] | 260 | printk(BIOS_INFO, "HPET enabled at 0x%x\n", CONFIG_HPET_ADDRESS); |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 261 | } else { |
Stefan Reinauer | f0aa09b | 2010-03-23 13:23:40 +0000 | [diff] [blame] | 262 | printk(BIOS_WARNING, "HPET was not enabled correctly\n"); |
Joseph Smith | b5466b0 | 2010-03-22 23:10:53 +0000 | [diff] [blame] | 263 | reg32 &= ~(1 << 17); /* Clear Enable */ |
| 264 | pci_write_config32(dev, GEN_CNTL, reg32); |
| 265 | } |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 268 | static void lpc_init(struct device *dev) |
| 269 | { |
| 270 | /* Set the value for PCI command register. */ |
| 271 | pci_write_config16(dev, PCI_COMMAND, 0x000f); |
| 272 | |
Kyösti Mälkki | e614353 | 2013-02-26 17:24:41 +0200 | [diff] [blame] | 273 | i82801dx_enable_acpi(dev); |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 274 | /* IO APIC initialization. */ |
| 275 | i82801dx_enable_ioapic(dev); |
| 276 | |
| 277 | i82801dx_enable_serial_irqs(dev); |
| 278 | |
| 279 | /* Setup the PIRQ. */ |
| 280 | i82801dx_pirq_init(dev); |
| 281 | |
| 282 | /* Setup power options. */ |
| 283 | i82801dx_power_options(dev); |
| 284 | |
| 285 | /* Set the state of the GPIO lines. */ |
| 286 | gpio_init(dev); |
| 287 | |
| 288 | /* Initialize the real time clock. */ |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 289 | i82801dx_rtc_init(dev); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 290 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 291 | /* Route DMA. */ |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 292 | i82801dx_lpc_route_dma(dev, 0xff); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 293 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 294 | /* Initialize ISA DMA. */ |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 295 | isa_dma_init(); |
| 296 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 297 | /* Setup decode ports and LPC I/F enables. */ |
| 298 | i82801dx_lpc_decode_en(dev); |
Stefan Reinauer | 527aedc | 2010-03-17 22:08:51 +0000 | [diff] [blame] | 299 | |
| 300 | /* Initialize the High Precision Event Timers */ |
| 301 | enable_hpet(dev); |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 302 | } |
| 303 | |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 304 | static void i82801dx_lpc_read_resources(device_t dev) |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 305 | { |
Eric Biederman | 4f9265f | 2004-10-22 02:33:51 +0000 | [diff] [blame] | 306 | struct resource *res; |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 307 | |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 308 | /* Get the normal PCI resources of this device. */ |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 309 | pci_dev_read_resources(dev); |
| 310 | |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 311 | /* Add an extra subtractive resource for both memory and I/O. */ |
Eric Biederman | 4f9265f | 2004-10-22 02:33:51 +0000 | [diff] [blame] | 312 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(0, 0)); |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 313 | res->base = 0; |
| 314 | res->size = 0x1000; |
| 315 | res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 316 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
Eric Biederman | 4f9265f | 2004-10-22 02:33:51 +0000 | [diff] [blame] | 317 | |
| 318 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(1, 0)); |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 319 | res->base = 0xff800000; |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 320 | res->size = 0x00800000; /* 8 MB for flash */ |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 321 | res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 322 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 323 | |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 324 | res = new_resource(dev, 3); /* IOAPIC */ |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 325 | res->base = IO_APIC_ADDR; |
Myles Watson | 29cc9ed | 2009-07-02 18:56:24 +0000 | [diff] [blame] | 326 | res->size = 0x00001000; |
| 327 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
Eric Biederman | 4f9265f | 2004-10-22 02:33:51 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 330 | static struct device_operations lpc_ops = { |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 331 | .read_resources = i82801dx_lpc_read_resources, |
| 332 | .set_resources = pci_dev_set_resources, |
Myles Watson | 7eac445 | 2010-06-17 16:16:56 +0000 | [diff] [blame] | 333 | .enable_resources = pci_dev_enable_resources, |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 334 | .init = lpc_init, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 335 | .scan_bus = scan_lpc_bus, |
Joseph Smith | 48f3e2b | 2010-03-17 03:37:18 +0000 | [diff] [blame] | 336 | .enable = i82801dx_enable, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 337 | }; |
| 338 | |
Stefan Reinauer | 8702ab5 | 2010-03-14 17:01:08 +0000 | [diff] [blame] | 339 | /* 82801DB/DBL */ |
| 340 | static const struct pci_driver lpc_driver_db __pci_driver = { |
| 341 | .ops = &lpc_ops, |
| 342 | .vendor = PCI_VENDOR_ID_INTEL, |
| 343 | .device = PCI_DEVICE_ID_INTEL_82801DB_LPC, |
| 344 | }; |
| 345 | |
| 346 | /* 82801DBM */ |
| 347 | static const struct pci_driver lpc_driver_dbm __pci_driver = { |
| 348 | .ops = &lpc_ops, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 349 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | a29ec06 | 2007-11-04 03:21:37 +0000 | [diff] [blame] | 350 | .device = PCI_DEVICE_ID_INTEL_82801DBM_LPC, |
Ronald G. Minnich | 182615d | 2004-08-24 16:20:46 +0000 | [diff] [blame] | 351 | }; |