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