Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
Patrick Rudolph | e56189c | 2018-04-18 10:11:59 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Kyösti Mälkki | cbf9571 | 2020-01-05 08:05:45 +0200 | [diff] [blame] | 8 | #include <option.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 9 | #include <pc80/isa-dma.h> |
| 10 | #include <pc80/i8259.h> |
| 11 | #include <arch/io.h> |
| 12 | #include <arch/ioapic.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 13 | #include <acpi/acpi.h> |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 14 | #include <cpu/x86/smm.h> |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 15 | #include <cbmem.h> |
| 16 | #include <string.h> |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame] | 17 | #include "chip.h" |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 18 | #include "nvs.h" |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 19 | #include "pch.h" |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 20 | #include <acpi/acpigen.h> |
Tristan Corrick | f3127d4 | 2018-10-31 02:25:54 +1300 | [diff] [blame] | 21 | #include <southbridge/intel/common/acpi_pirq_gen.h> |
Patrick Rudolph | 6b93112 | 2018-11-01 17:48:37 +0100 | [diff] [blame] | 22 | #include <southbridge/intel/common/rtc.h> |
Arthur Heymans | a3121b0 | 2019-05-28 13:46:49 +0200 | [diff] [blame] | 23 | #include <southbridge/intel/common/spi.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 24 | |
| 25 | #define NMI_OFF 0 |
| 26 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 27 | typedef struct southbridge_intel_lynxpoint_config config_t; |
| 28 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 29 | /** |
| 30 | * Set miscellanous static southbridge features. |
| 31 | * |
| 32 | * @param dev PCI device with I/O APIC control registers |
| 33 | */ |
| 34 | static void pch_enable_ioapic(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 35 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 36 | u32 reg32; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 37 | |
Matt DeVillier | a51e379 | 2018-03-04 01:44:15 -0600 | [diff] [blame] | 38 | /* Assign unique bus/dev/fn for I/O APIC */ |
| 39 | pci_write_config16(dev, LPC_IBDF, |
| 40 | PCH_IOAPIC_PCI_BUS << 8 | PCH_IOAPIC_PCI_SLOT << 3); |
| 41 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 42 | /* Enable ACPI I/O range decode */ |
| 43 | pci_write_config8(dev, ACPI_CNTL, ACPI_EN); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 44 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 45 | set_ioapic_id(VIO_APIC_VADDR, 0x02); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 46 | |
| 47 | /* affirm full set of redirection table entries ("write once") */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 48 | reg32 = io_apic_read(VIO_APIC_VADDR, 0x01); |
Duncan Laurie | c593999 | 2013-05-24 11:06:49 -0700 | [diff] [blame] | 49 | if (pch_is_lp()) { |
| 50 | /* PCH-LP has 39 redirection entries */ |
| 51 | reg32 &= ~0x00ff0000; |
| 52 | reg32 |= 0x00270000; |
| 53 | } |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 54 | io_apic_write(VIO_APIC_VADDR, 0x01, reg32); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 55 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 56 | /* |
| 57 | * Select Boot Configuration register (0x03) and |
| 58 | * use Processor System Bus (0x01) to deliver interrupts. |
| 59 | */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 60 | io_apic_write(VIO_APIC_VADDR, 0x03, 0x01); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | static void pch_enable_serial_irqs(struct device *dev) |
| 64 | { |
| 65 | /* Set packet length and toggle silent mode bit for one frame. */ |
| 66 | pci_write_config8(dev, SERIRQ_CNTL, |
| 67 | (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0)); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 68 | #if !CONFIG(SERIRQ_CONTINUOUS_MODE) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 69 | pci_write_config8(dev, SERIRQ_CNTL, |
| 70 | (1 << 7) | (0 << 6) | ((21 - 17) << 2) | (0 << 0)); |
| 71 | #endif |
| 72 | } |
| 73 | |
| 74 | /* PIRQ[n]_ROUT[3:0] - PIRQ Routing Control |
| 75 | * 0x00 - 0000 = Reserved |
| 76 | * 0x01 - 0001 = Reserved |
| 77 | * 0x02 - 0010 = Reserved |
| 78 | * 0x03 - 0011 = IRQ3 |
| 79 | * 0x04 - 0100 = IRQ4 |
| 80 | * 0x05 - 0101 = IRQ5 |
| 81 | * 0x06 - 0110 = IRQ6 |
| 82 | * 0x07 - 0111 = IRQ7 |
| 83 | * 0x08 - 1000 = Reserved |
| 84 | * 0x09 - 1001 = IRQ9 |
| 85 | * 0x0A - 1010 = IRQ10 |
| 86 | * 0x0B - 1011 = IRQ11 |
| 87 | * 0x0C - 1100 = IRQ12 |
| 88 | * 0x0D - 1101 = Reserved |
| 89 | * 0x0E - 1110 = IRQ14 |
| 90 | * 0x0F - 1111 = IRQ15 |
| 91 | * PIRQ[n]_ROUT[7] - PIRQ Routing Control |
| 92 | * 0x80 - The PIRQ is not routed. |
| 93 | */ |
| 94 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 95 | static void pch_pirq_init(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 96 | { |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 97 | struct device *irq_dev; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 98 | /* Get the chip configuration */ |
| 99 | config_t *config = dev->chip_info; |
| 100 | |
| 101 | pci_write_config8(dev, PIRQA_ROUT, config->pirqa_routing); |
| 102 | pci_write_config8(dev, PIRQB_ROUT, config->pirqb_routing); |
| 103 | pci_write_config8(dev, PIRQC_ROUT, config->pirqc_routing); |
| 104 | pci_write_config8(dev, PIRQD_ROUT, config->pirqd_routing); |
| 105 | |
| 106 | pci_write_config8(dev, PIRQE_ROUT, config->pirqe_routing); |
| 107 | pci_write_config8(dev, PIRQF_ROUT, config->pirqf_routing); |
| 108 | pci_write_config8(dev, PIRQG_ROUT, config->pirqg_routing); |
| 109 | pci_write_config8(dev, PIRQH_ROUT, config->pirqh_routing); |
| 110 | |
| 111 | /* Eric Biederman once said we should let the OS do this. |
| 112 | * I am not so sure anymore he was right. |
| 113 | */ |
| 114 | |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 115 | for (irq_dev = all_devices; irq_dev; irq_dev = irq_dev->next) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 116 | u8 int_pin=0, int_line=0; |
| 117 | |
| 118 | if (!irq_dev->enabled || irq_dev->path.type != DEVICE_PATH_PCI) |
| 119 | continue; |
| 120 | |
| 121 | int_pin = pci_read_config8(irq_dev, PCI_INTERRUPT_PIN); |
| 122 | |
| 123 | switch (int_pin) { |
| 124 | case 1: /* INTA# */ int_line = config->pirqa_routing; break; |
| 125 | case 2: /* INTB# */ int_line = config->pirqb_routing; break; |
| 126 | case 3: /* INTC# */ int_line = config->pirqc_routing; break; |
| 127 | case 4: /* INTD# */ int_line = config->pirqd_routing; break; |
| 128 | } |
| 129 | |
| 130 | if (!int_line) |
| 131 | continue; |
| 132 | |
| 133 | pci_write_config8(irq_dev, PCI_INTERRUPT_LINE, int_line); |
| 134 | } |
| 135 | } |
| 136 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 137 | static void pch_gpi_routing(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 138 | { |
| 139 | /* Get the chip configuration */ |
| 140 | config_t *config = dev->chip_info; |
| 141 | u32 reg32 = 0; |
| 142 | |
| 143 | /* An array would be much nicer here, or some |
| 144 | * other method of doing this. |
| 145 | */ |
| 146 | reg32 |= (config->gpi0_routing & 0x03) << 0; |
| 147 | reg32 |= (config->gpi1_routing & 0x03) << 2; |
| 148 | reg32 |= (config->gpi2_routing & 0x03) << 4; |
| 149 | reg32 |= (config->gpi3_routing & 0x03) << 6; |
| 150 | reg32 |= (config->gpi4_routing & 0x03) << 8; |
| 151 | reg32 |= (config->gpi5_routing & 0x03) << 10; |
| 152 | reg32 |= (config->gpi6_routing & 0x03) << 12; |
| 153 | reg32 |= (config->gpi7_routing & 0x03) << 14; |
| 154 | reg32 |= (config->gpi8_routing & 0x03) << 16; |
| 155 | reg32 |= (config->gpi9_routing & 0x03) << 18; |
| 156 | reg32 |= (config->gpi10_routing & 0x03) << 20; |
| 157 | reg32 |= (config->gpi11_routing & 0x03) << 22; |
| 158 | reg32 |= (config->gpi12_routing & 0x03) << 24; |
| 159 | reg32 |= (config->gpi13_routing & 0x03) << 26; |
| 160 | reg32 |= (config->gpi14_routing & 0x03) << 28; |
| 161 | reg32 |= (config->gpi15_routing & 0x03) << 30; |
| 162 | |
Kyösti Mälkki | b85a87b | 2014-12-29 11:32:27 +0200 | [diff] [blame] | 163 | pci_write_config32(dev, GPIO_ROUT, reg32); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 164 | } |
| 165 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 166 | static void pch_power_options(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 167 | { |
| 168 | u8 reg8; |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 169 | u16 reg16; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 170 | u32 reg32; |
| 171 | const char *state; |
| 172 | /* Get the chip configuration */ |
| 173 | config_t *config = dev->chip_info; |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 174 | u16 pmbase = get_pmbase(); |
Nico Huber | 9faae2b | 2018-11-14 00:00:35 +0100 | [diff] [blame] | 175 | int pwr_on = CONFIG_MAINBOARD_POWER_FAILURE_STATE; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 176 | int nmi_option; |
| 177 | |
| 178 | /* Which state do we want to goto after g3 (power restored)? |
| 179 | * 0 == S0 Full On |
| 180 | * 1 == S5 Soft Off |
| 181 | * |
| 182 | * If the option is not existent (Laptops), use Kconfig setting. |
| 183 | */ |
| 184 | get_option(&pwr_on, "power_on_after_fail"); |
| 185 | |
| 186 | reg16 = pci_read_config16(dev, GEN_PMCON_3); |
| 187 | reg16 &= 0xfffe; |
| 188 | switch (pwr_on) { |
| 189 | case MAINBOARD_POWER_OFF: |
| 190 | reg16 |= 1; |
| 191 | state = "off"; |
| 192 | break; |
| 193 | case MAINBOARD_POWER_ON: |
| 194 | reg16 &= ~1; |
| 195 | state = "on"; |
| 196 | break; |
| 197 | case MAINBOARD_POWER_KEEP: |
| 198 | reg16 &= ~1; |
| 199 | state = "state keep"; |
| 200 | break; |
| 201 | default: |
| 202 | state = "undefined"; |
| 203 | } |
| 204 | |
| 205 | reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */ |
| 206 | reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */ |
| 207 | |
| 208 | reg16 &= ~(1 << 10); |
| 209 | reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */ |
| 210 | |
| 211 | reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */ |
| 212 | |
| 213 | pci_write_config16(dev, GEN_PMCON_3, reg16); |
| 214 | printk(BIOS_INFO, "Set power %s after power failure.\n", state); |
| 215 | |
| 216 | /* Set up NMI on errors. */ |
| 217 | reg8 = inb(0x61); |
| 218 | reg8 &= 0x0f; /* Higher Nibble must be 0 */ |
| 219 | reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */ |
| 220 | // reg8 &= ~(1 << 2); /* PCI SERR# Enable */ |
| 221 | reg8 |= (1 << 2); /* PCI SERR# Disable for now */ |
| 222 | outb(reg8, 0x61); |
| 223 | |
| 224 | reg8 = inb(0x70); |
| 225 | nmi_option = NMI_OFF; |
| 226 | get_option(&nmi_option, "nmi"); |
| 227 | if (nmi_option) { |
| 228 | printk(BIOS_INFO, "NMI sources enabled.\n"); |
| 229 | reg8 &= ~(1 << 7); /* Set NMI. */ |
| 230 | } else { |
| 231 | printk(BIOS_INFO, "NMI sources disabled.\n"); |
Elyes HAOUAS | 9c5d463 | 2018-04-26 22:21:21 +0200 | [diff] [blame] | 232 | reg8 |= (1 << 7); /* Can't mask NMI from PCI-E and NMI_NOW */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 233 | } |
| 234 | outb(reg8, 0x70); |
| 235 | |
| 236 | /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */ |
| 237 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 238 | reg16 &= ~(3 << 0); // SMI# rate 1 minute |
| 239 | reg16 &= ~(1 << 10); // Disable BIOS_PCI_EXP_EN for native PME |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 240 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 241 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 242 | /* |
| 243 | * Set the board's GPI routing on LynxPoint-H. |
| 244 | * This is done as part of GPIO configuration on LynxPoint-LP. |
| 245 | */ |
| 246 | if (pch_is_lp()) |
| 247 | pch_gpi_routing(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 248 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 249 | /* GPE setup based on device tree configuration */ |
| 250 | enable_all_gpe(config->gpe0_en_1, config->gpe0_en_2, |
| 251 | config->gpe0_en_3, config->gpe0_en_4); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 252 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 253 | /* SMI setup based on device tree configuration */ |
| 254 | enable_alt_smi(config->alt_gp_smi_en); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 255 | |
| 256 | /* Set up power management block and determine sleep mode */ |
| 257 | reg32 = inl(pmbase + 0x04); // PM1_CNT |
| 258 | reg32 &= ~(7 << 10); // SLP_TYP |
| 259 | reg32 |= (1 << 0); // SCI_EN |
| 260 | outl(reg32, pmbase + 0x04); |
| 261 | |
| 262 | /* Clear magic status bits to prevent unexpected wake */ |
| 263 | reg32 = RCBA32(0x3310); |
| 264 | reg32 |= (1 << 4)|(1 << 5)|(1 << 0); |
| 265 | RCBA32(0x3310) = reg32; |
| 266 | |
Ryan Salsamendi | 889ce9c | 2017-06-30 17:45:14 -0700 | [diff] [blame] | 267 | reg16 = RCBA16(0x3f02); |
| 268 | reg16 &= ~0xf; |
| 269 | RCBA16(0x3f02) = reg16; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 270 | } |
| 271 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 272 | /* LynxPoint PCH Power Management init */ |
| 273 | static void lpt_pm_init(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 274 | { |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 275 | printk(BIOS_DEBUG, "LynxPoint PM init\n"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 276 | } |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 277 | |
| 278 | const struct rcba_config_instruction lpt_lp_pm_rcba[] = { |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 279 | RCBA_RMW_REG_32(0x232c, ~1, 0x00000000), |
| 280 | RCBA_RMW_REG_32(0x1100, ~0xc000, 0xc000), |
| 281 | RCBA_RMW_REG_32(0x1100, ~0, 0x00000100), |
| 282 | RCBA_RMW_REG_32(0x1100, ~0, 0x0000003f), |
| 283 | RCBA_RMW_REG_32(0x2320, ~0x60, 0x10), |
| 284 | RCBA_RMW_REG_32(0x3314, 0, 0x00012fff), |
| 285 | RCBA_RMW_REG_32(0x3318, 0, 0x0dcf0400), |
| 286 | RCBA_RMW_REG_32(0x3324, 0, 0x04000000), |
| 287 | RCBA_RMW_REG_32(0x3368, 0, 0x00041400), |
| 288 | RCBA_RMW_REG_32(0x3388, 0, 0x3f8ddbff), |
| 289 | RCBA_RMW_REG_32(0x33ac, 0, 0x00007001), |
| 290 | RCBA_RMW_REG_32(0x33b0, 0, 0x00181900), |
| 291 | RCBA_RMW_REG_32(0x33c0, 0, 0x00060A00), |
| 292 | RCBA_RMW_REG_32(0x33d0, 0, 0x06200840), |
| 293 | RCBA_RMW_REG_32(0x3a28, 0, 0x01010101), |
| 294 | RCBA_RMW_REG_32(0x3a2c, 0, 0x04040404), |
| 295 | RCBA_RMW_REG_32(0x2b1c, 0, 0x03808033), |
| 296 | RCBA_RMW_REG_32(0x2b34, 0, 0x80000009), |
| 297 | RCBA_RMW_REG_32(0x3348, 0, 0x022ddfff), |
| 298 | RCBA_RMW_REG_32(0x334c, 0, 0x00000001), |
| 299 | RCBA_RMW_REG_32(0x3358, 0, 0x0001c000), |
| 300 | RCBA_RMW_REG_32(0x3380, 0, 0x3f8ddbff), |
| 301 | RCBA_RMW_REG_32(0x3384, 0, 0x0001c7e1), |
| 302 | RCBA_RMW_REG_32(0x338c, 0, 0x0001c7e1), |
| 303 | RCBA_RMW_REG_32(0x3398, 0, 0x0001c000), |
| 304 | RCBA_RMW_REG_32(0x33a8, 0, 0x00181900), |
| 305 | RCBA_RMW_REG_32(0x33dc, 0, 0x00080000), |
| 306 | RCBA_RMW_REG_32(0x33e0, 0, 0x00000001), |
| 307 | RCBA_RMW_REG_32(0x3a20, 0, 0x00000404), |
| 308 | RCBA_RMW_REG_32(0x3a24, 0, 0x01010101), |
| 309 | RCBA_RMW_REG_32(0x3a30, 0, 0x01010101), |
| 310 | RCBA_RMW_REG_32(0x0410, ~0, 0x00000003), |
| 311 | RCBA_RMW_REG_32(0x2618, ~0, 0x08000000), |
| 312 | RCBA_RMW_REG_32(0x2300, ~0, 0x00000002), |
| 313 | RCBA_RMW_REG_32(0x2600, ~0, 0x00000008), |
| 314 | RCBA_RMW_REG_32(0x33b4, 0, 0x00007001), |
| 315 | RCBA_RMW_REG_32(0x3350, 0, 0x022ddfff), |
| 316 | RCBA_RMW_REG_32(0x3354, 0, 0x00000001), |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 317 | RCBA_RMW_REG_32(0x33d4, ~0, 0x08000000), /* Power Optimizer */ |
Matt DeVillier | c97e042 | 2017-02-16 11:36:16 -0600 | [diff] [blame] | 318 | RCBA_RMW_REG_32(0x33c8, ~0, 0x00000080), /* Power Optimizer */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 319 | RCBA_RMW_REG_32(0x2b10, 0, 0x0000883c), /* Power Optimizer */ |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 320 | RCBA_RMW_REG_32(0x2b14, 0, 0x1e0a4616), /* Power Optimizer */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 321 | RCBA_RMW_REG_32(0x2b24, 0, 0x40000005), /* Power Optimizer */ |
| 322 | RCBA_RMW_REG_32(0x2b20, 0, 0x0005db01), /* Power Optimizer */ |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 323 | RCBA_RMW_REG_32(0x3a80, 0, 0x05145005), |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 324 | RCBA_END_CONFIG |
| 325 | }; |
| 326 | |
| 327 | /* LynxPoint LP PCH Power Management init */ |
| 328 | static void lpt_lp_pm_init(struct device *dev) |
| 329 | { |
| 330 | struct southbridge_intel_lynxpoint_config *config = dev->chip_info; |
| 331 | u32 data; |
| 332 | |
| 333 | printk(BIOS_DEBUG, "LynxPoint LP PM init\n"); |
| 334 | |
| 335 | pci_write_config8(dev, 0xa9, 0x46); |
| 336 | |
| 337 | pch_config_rcba(lpt_lp_pm_rcba); |
| 338 | |
| 339 | pci_write_config32(dev, 0xac, |
| 340 | pci_read_config32(dev, 0xac) | (1 << 21)); |
| 341 | |
Elyes HAOUAS | a0aea56 | 2017-07-03 21:38:53 +0200 | [diff] [blame] | 342 | pch_iobp_update(0xED00015C, ~(1 << 11), 0x00003700); |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 343 | pch_iobp_update(0xED000118, ~0UL, 0x00c00000); |
| 344 | pch_iobp_update(0xED000120, ~0UL, 0x00240000); |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 345 | pch_iobp_update(0xCA000000, ~0UL, 0x00000009); |
| 346 | |
| 347 | /* Set RCBA CIR28 0x3A84 based on SATA port enables */ |
| 348 | data = 0x00001005; |
| 349 | /* Port 3 and 2 disabled */ |
| 350 | if ((config->sata_port_map & ((1 << 3)|(1 << 2))) == 0) |
| 351 | data |= (1 << 24) | (1 << 26); |
| 352 | /* Port 1 and 0 disabled */ |
| 353 | if ((config->sata_port_map & ((1 << 1)|(1 << 0))) == 0) |
| 354 | data |= (1 << 20) | (1 << 18); |
| 355 | RCBA32(0x3a84) = data; |
| 356 | |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 357 | /* Set RCBA 0x2b1c[29]=1 if DSP disabled */ |
| 358 | if (RCBA32(FD) & PCH_DISABLE_ADSPD) |
| 359 | RCBA32_OR(0x2b1c, (1 << 29)); |
| 360 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 361 | /* Lock */ |
| 362 | RCBA32_OR(0x3a6c, 0x00000001); |
| 363 | |
| 364 | /* Set RCBA 0x33D4 after other setup */ |
| 365 | RCBA32_OR(0x33d4, 0x2fff2fb1); |
| 366 | |
| 367 | /* Set RCBA 0x33C8[15]=1 as last step */ |
| 368 | RCBA32_OR(0x33c8, (1 << 15)); |
| 369 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 370 | |
Matt DeVillier | a51e379 | 2018-03-04 01:44:15 -0600 | [diff] [blame] | 371 | static void enable_hpet(struct device *const dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 372 | { |
| 373 | u32 reg32; |
Matt DeVillier | a51e379 | 2018-03-04 01:44:15 -0600 | [diff] [blame] | 374 | size_t i; |
| 375 | |
| 376 | /* Assign unique bus/dev/fn for each HPET */ |
| 377 | for (i = 0; i < 8; ++i) |
| 378 | pci_write_config16(dev, LPC_HnBDF(i), |
| 379 | PCH_HPET_PCI_BUS << 8 | PCH_HPET_PCI_SLOT << 3 | i); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 380 | |
| 381 | /* Move HPET to default address 0xfed00000 and enable it */ |
| 382 | reg32 = RCBA32(HPTC); |
| 383 | reg32 |= (1 << 7); // HPET Address Enable |
| 384 | reg32 &= ~(3 << 0); |
| 385 | RCBA32(HPTC) = reg32; |
| 386 | /* Read it back to stick. It's affected by posted write syndrome. */ |
Elyes HAOUAS | 6de151e | 2019-10-18 16:43:30 +0200 | [diff] [blame] | 387 | RCBA32(HPTC); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 388 | } |
| 389 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 390 | static void enable_clock_gating(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 391 | { |
Duncan Laurie | 74c0d05 | 2012-12-17 11:31:40 -0800 | [diff] [blame] | 392 | /* LynxPoint Mobile */ |
| 393 | u32 reg32; |
| 394 | u16 reg16; |
| 395 | |
| 396 | /* DMI */ |
| 397 | RCBA32_AND_OR(0x2234, ~0UL, 0xf); |
| 398 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 399 | reg16 |= (1 << 11) | (1 << 12) | (1 << 14); |
| 400 | reg16 |= (1 << 2); // PCI CLKRUN# Enable |
| 401 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 402 | RCBA32_OR(0x900, (1 << 14)); |
| 403 | |
| 404 | reg32 = RCBA32(CG); |
| 405 | reg32 |= (1 << 22); // HDA Dynamic |
Ryan Salsamendi | 0d9b360 | 2017-06-30 17:15:57 -0700 | [diff] [blame] | 406 | reg32 |= (1UL << 31); // LPC Dynamic |
Duncan Laurie | 74c0d05 | 2012-12-17 11:31:40 -0800 | [diff] [blame] | 407 | reg32 |= (1 << 16); // PCIe Dynamic |
| 408 | reg32 |= (1 << 27); // HPET Dynamic |
| 409 | reg32 |= (1 << 28); // GPIO Dynamic |
| 410 | RCBA32(CG) = reg32; |
| 411 | |
| 412 | RCBA32_OR(0x38c0, 0x7); // SPI Dynamic |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 415 | static void enable_lp_clock_gating(struct device *dev) |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 416 | { |
| 417 | /* LynxPoint LP */ |
| 418 | u32 reg32; |
| 419 | u16 reg16; |
| 420 | |
| 421 | /* DMI */ |
| 422 | RCBA32_AND_OR(0x2234, ~0UL, 0xf); |
| 423 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 424 | reg16 &= ~((1 << 11) | (1 << 14)); |
| 425 | reg16 |= (1 << 5) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 13); |
| 426 | reg16 |= (1 << 2); // PCI CLKRUN# Enable |
| 427 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 428 | |
| 429 | reg32 = pci_read_config32(dev, 0x64); |
| 430 | reg32 |= (1 << 6); |
| 431 | pci_write_config32(dev, 0x64, reg32); |
| 432 | |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 433 | /* |
| 434 | * RCBA + 0x2614[27:25,14:13,10,8] = 101,11,1,1 |
| 435 | * RCBA + 0x2614[23:16] = 0x20 |
| 436 | * RCBA + 0x2614[30:28] = 0x0 |
Duncan Laurie | d8c7d73 | 2013-07-16 09:01:43 -0700 | [diff] [blame] | 437 | * RCBA + 0x2614[26] = 1 (IF 0:2.0@0x08 >= 0x0b) |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 438 | */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 439 | RCBA32_AND_OR(0x2614, 0x8bffffff, 0x0a206500); |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 440 | |
| 441 | /* Check for LPT-LP B2 stepping and 0:31.0@0xFA > 4 */ |
Nico Huber | 744d6bd | 2019-01-12 14:58:20 +0100 | [diff] [blame] | 442 | struct device *const gma = pcidev_on_root(2, 0); |
| 443 | if (gma && pci_read_config8(gma, 0x8) >= 0x0b) |
Elyes HAOUAS | a0aea56 | 2017-07-03 21:38:53 +0200 | [diff] [blame] | 444 | RCBA32_OR(0x2614, (1 << 26)); |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame] | 445 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 446 | RCBA32_OR(0x900, 0x0000031f); |
| 447 | |
| 448 | reg32 = RCBA32(CG); |
Duncan Laurie | a2d6a40 | 2013-03-22 11:24:45 -0700 | [diff] [blame] | 449 | if (RCBA32(0x3454) & (1 << 4)) |
| 450 | reg32 &= ~(1 << 29); // LPC Dynamic |
| 451 | else |
| 452 | reg32 |= (1 << 29); // LPC Dynamic |
Ryan Salsamendi | 3f2fe18 | 2017-07-04 13:14:16 -0700 | [diff] [blame] | 453 | reg32 |= (1UL << 31); // LP LPC |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 454 | reg32 |= (1 << 30); // LP BLA |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 455 | reg32 |= (1 << 28); // GPIO Dynamic |
| 456 | reg32 |= (1 << 27); // HPET Dynamic |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 457 | reg32 |= (1 << 26); // Generic Platform Event Clock |
| 458 | if (RCBA32(BUC) & PCH_DISABLE_GBE) |
| 459 | reg32 |= (1 << 23); // GbE Static |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 460 | reg32 |= (1 << 22); // HDA Dynamic |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 461 | reg32 |= (1 << 16); // PCI Dynamic |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 462 | RCBA32(CG) = reg32; |
| 463 | |
| 464 | RCBA32_OR(0x3434, 0x7); // LP LPC |
| 465 | |
| 466 | RCBA32_AND_OR(0x333c, 0xffcfffff, 0x00c00000); // SATA |
| 467 | |
| 468 | RCBA32_OR(0x38c0, 0x3c07); // SPI Dynamic |
| 469 | |
| 470 | pch_iobp_update(0xCF000000, ~0UL, 0x00007001); |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 471 | pch_iobp_update(0xCE00C000, ~1UL, 0x00000000); // bit0=0 in BWG 1.4.0 |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 472 | } |
| 473 | |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 474 | static void pch_set_acpi_mode(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 475 | { |
Kyösti Mälkki | b490562 | 2019-07-12 08:02:35 +0300 | [diff] [blame] | 476 | if (CONFIG(HAVE_SMI_HANDLER) && !acpi_is_wakeup_s3()) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 477 | printk(BIOS_DEBUG, "Disabling ACPI via APMC:\n"); |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 478 | outb(APM_CNT_ACPI_DISABLE, APM_CNT); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 479 | printk(BIOS_DEBUG, "done.\n"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 480 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 481 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 482 | |
| 483 | static void pch_disable_smm_only_flashing(struct device *dev) |
| 484 | { |
| 485 | u8 reg8; |
| 486 | |
| 487 | printk(BIOS_SPEW, "Enabling BIOS updates outside of SMM... "); |
Elyes HAOUAS | 0c22d2f | 2018-12-01 12:19:52 +0100 | [diff] [blame] | 488 | reg8 = pci_read_config8(dev, BIOS_CNTL); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 489 | reg8 &= ~(1 << 5); |
Elyes HAOUAS | 0c22d2f | 2018-12-01 12:19:52 +0100 | [diff] [blame] | 490 | pci_write_config8(dev, BIOS_CNTL, reg8); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | static void pch_fixups(struct device *dev) |
| 494 | { |
| 495 | u8 gen_pmcon_2; |
| 496 | |
| 497 | /* Indicate DRAM init done for MRC S3 to know it can resume */ |
| 498 | gen_pmcon_2 = pci_read_config8(dev, GEN_PMCON_2); |
| 499 | gen_pmcon_2 |= (1 << 7); |
| 500 | pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2); |
| 501 | |
| 502 | /* |
| 503 | * Enable DMI ASPM in the PCH |
| 504 | */ |
| 505 | RCBA32_AND_OR(0x2304, ~(1 << 10), 0); |
| 506 | RCBA32_OR(0x21a4, (1 << 11)|(1 << 10)); |
| 507 | RCBA32_OR(0x21a8, 0x3); |
| 508 | } |
| 509 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 510 | static void lpc_init(struct device *dev) |
| 511 | { |
Elyes HAOUAS | bfc255a | 2020-03-07 13:05:14 +0100 | [diff] [blame^] | 512 | printk(BIOS_DEBUG, "pch: %s\n", __func__); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 513 | |
| 514 | /* Set the value for PCI command register. */ |
| 515 | pci_write_config16(dev, PCI_COMMAND, 0x000f); |
| 516 | |
| 517 | /* IO APIC initialization. */ |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 518 | pch_enable_ioapic(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 519 | |
| 520 | pch_enable_serial_irqs(dev); |
| 521 | |
| 522 | /* Setup the PIRQ. */ |
| 523 | pch_pirq_init(dev); |
| 524 | |
| 525 | /* Setup power options. */ |
| 526 | pch_power_options(dev); |
| 527 | |
| 528 | /* Initialize power management */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 529 | if (pch_is_lp()) { |
| 530 | lpt_lp_pm_init(dev); |
| 531 | enable_lp_clock_gating(dev); |
| 532 | } else { |
| 533 | lpt_pm_init(dev); |
| 534 | enable_clock_gating(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 535 | } |
| 536 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 537 | /* Initialize the real time clock. */ |
Patrick Rudolph | 6b93112 | 2018-11-01 17:48:37 +0100 | [diff] [blame] | 538 | sb_rtc_init(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 539 | |
| 540 | /* Initialize ISA DMA. */ |
| 541 | isa_dma_init(); |
| 542 | |
| 543 | /* Initialize the High Precision Event Timers, if present. */ |
Matt DeVillier | a51e379 | 2018-03-04 01:44:15 -0600 | [diff] [blame] | 544 | enable_hpet(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 545 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 546 | setup_i8259(); |
| 547 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 548 | /* Interrupt 9 should be level triggered (SCI) */ |
| 549 | i8259_configure_irq_trigger(9, 1); |
| 550 | |
| 551 | pch_disable_smm_only_flashing(dev); |
| 552 | |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 553 | pch_set_acpi_mode(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 554 | |
| 555 | pch_fixups(dev); |
| 556 | } |
| 557 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 558 | static void pch_lpc_add_mmio_resources(struct device *dev) |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 559 | { |
| 560 | u32 reg; |
| 561 | struct resource *res; |
| 562 | const u32 default_decode_base = IO_APIC_ADDR; |
| 563 | |
| 564 | /* |
| 565 | * Just report all resources from IO-APIC base to 4GiB. Don't mark |
| 566 | * them reserved as that may upset the OS if this range is marked |
| 567 | * as reserved in the e820. |
| 568 | */ |
| 569 | res = new_resource(dev, OIC); |
| 570 | res->base = default_decode_base; |
| 571 | res->size = 0 - default_decode_base; |
| 572 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 573 | |
| 574 | /* RCBA */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 575 | if ((uintptr_t)DEFAULT_RCBA < default_decode_base) { |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 576 | res = new_resource(dev, RCBA); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 577 | res->base = (resource_t)(uintptr_t)DEFAULT_RCBA; |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 578 | res->size = 16 * 1024; |
| 579 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 580 | IORESOURCE_FIXED | IORESOURCE_RESERVE; |
| 581 | } |
| 582 | |
| 583 | /* Check LPC Memory Decode register. */ |
| 584 | reg = pci_read_config32(dev, LGMR); |
| 585 | if (reg & 1) { |
| 586 | reg &= ~0xffff; |
| 587 | if (reg < default_decode_base) { |
| 588 | res = new_resource(dev, LGMR); |
| 589 | res->base = reg; |
| 590 | res->size = 16 * 1024; |
| 591 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 592 | IORESOURCE_FIXED | IORESOURCE_RESERVE; |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | /* Default IO range claimed by the LPC device. The upper bound is exclusive. */ |
| 598 | #define LPC_DEFAULT_IO_RANGE_LOWER 0 |
| 599 | #define LPC_DEFAULT_IO_RANGE_UPPER 0x1000 |
| 600 | |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 601 | static inline int pch_io_range_in_default(int base, int size) |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 602 | { |
| 603 | /* Does it start above the range? */ |
| 604 | if (base >= LPC_DEFAULT_IO_RANGE_UPPER) |
| 605 | return 0; |
| 606 | |
| 607 | /* Is it entirely contained? */ |
| 608 | if (base >= LPC_DEFAULT_IO_RANGE_LOWER && |
| 609 | (base + size) < LPC_DEFAULT_IO_RANGE_UPPER) |
| 610 | return 1; |
| 611 | |
| 612 | /* This will return not in range for partial overlaps. */ |
| 613 | return 0; |
| 614 | } |
| 615 | |
| 616 | /* |
| 617 | * Note: this function assumes there is no overlap with the default LPC device's |
| 618 | * claimed range: LPC_DEFAULT_IO_RANGE_LOWER -> LPC_DEFAULT_IO_RANGE_UPPER. |
| 619 | */ |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 620 | static void pch_lpc_add_io_resource(struct device *dev, u16 base, u16 size, |
| 621 | int index) |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 622 | { |
| 623 | struct resource *res; |
| 624 | |
| 625 | if (pch_io_range_in_default(base, size)) |
| 626 | return; |
| 627 | |
| 628 | res = new_resource(dev, index); |
| 629 | res->base = base; |
| 630 | res->size = size; |
| 631 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 632 | } |
| 633 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 634 | static void pch_lpc_add_gen_io_resources(struct device *dev, int reg_value, |
| 635 | int index) |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 636 | { |
| 637 | /* |
| 638 | * Check if the register is enabled. If so and the base exceeds the |
Kyösti Mälkki | b544c00 | 2019-01-06 10:41:41 +0200 | [diff] [blame] | 639 | * device's default, claim range and add the resource. |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 640 | */ |
| 641 | if (reg_value & 1) { |
| 642 | u16 base = reg_value & 0xfffc; |
| 643 | u16 size = (0x3 | ((reg_value >> 16) & 0xfc)) + 1; |
| 644 | pch_lpc_add_io_resource(dev, base, size, index); |
| 645 | } |
| 646 | } |
| 647 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 648 | static void pch_lpc_add_io_resources(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 649 | { |
| 650 | struct resource *res; |
| 651 | config_t *config = dev->chip_info; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 652 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 653 | /* Add the default claimed IO range for the LPC device. */ |
| 654 | res = new_resource(dev, 0); |
| 655 | res->base = LPC_DEFAULT_IO_RANGE_LOWER; |
| 656 | res->size = LPC_DEFAULT_IO_RANGE_UPPER - LPC_DEFAULT_IO_RANGE_LOWER; |
| 657 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 658 | |
| 659 | /* GPIOBASE */ |
Duncan Laurie | 7922b46 | 2013-03-08 16:34:33 -0800 | [diff] [blame] | 660 | pch_lpc_add_io_resource(dev, get_gpiobase(), DEFAULT_GPIOSIZE, |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 661 | GPIO_BASE); |
| 662 | |
| 663 | /* PMBASE */ |
Duncan Laurie | 7922b46 | 2013-03-08 16:34:33 -0800 | [diff] [blame] | 664 | pch_lpc_add_io_resource(dev, get_pmbase(), 256, PMBASE); |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 665 | |
| 666 | /* LPC Generic IO Decode range. */ |
| 667 | pch_lpc_add_gen_io_resources(dev, config->gen1_dec, LPC_GEN1_DEC); |
| 668 | pch_lpc_add_gen_io_resources(dev, config->gen2_dec, LPC_GEN2_DEC); |
| 669 | pch_lpc_add_gen_io_resources(dev, config->gen3_dec, LPC_GEN3_DEC); |
| 670 | pch_lpc_add_gen_io_resources(dev, config->gen4_dec, LPC_GEN4_DEC); |
| 671 | } |
| 672 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 673 | static void pch_lpc_read_resources(struct device *dev) |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 674 | { |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 675 | global_nvs_t *gnvs; |
| 676 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 677 | /* Get the normal PCI resources of this device. */ |
| 678 | pci_dev_read_resources(dev); |
| 679 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 680 | /* Add non-standard MMIO resources. */ |
| 681 | pch_lpc_add_mmio_resources(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 682 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 683 | /* Add IO resources. */ |
| 684 | pch_lpc_add_io_resources(dev); |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 685 | |
| 686 | /* Allocate ACPI NVS in CBMEM */ |
| 687 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(global_nvs_t)); |
Kyösti Mälkki | c3ed886 | 2014-06-19 19:50:51 +0300 | [diff] [blame] | 688 | if (!acpi_is_wakeup_s3() && gnvs) |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 689 | memset(gnvs, 0, sizeof(global_nvs_t)); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 690 | } |
| 691 | |
Elyes HAOUAS | 7a5f771 | 2018-06-08 17:20:38 +0200 | [diff] [blame] | 692 | static void pch_lpc_enable(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 693 | { |
| 694 | /* Enable PCH Display Port */ |
| 695 | RCBA16(DISPBDF) = 0x0010; |
| 696 | RCBA32_OR(FD2, PCH_ENABLE_DBDF); |
| 697 | |
| 698 | pch_enable(dev); |
| 699 | } |
| 700 | |
Furquan Shaikh | 338fd9a | 2020-04-24 22:57:05 -0700 | [diff] [blame] | 701 | static void southbridge_inject_dsdt(const struct device *dev) |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 702 | { |
Vladimir Serbinenko | 7309c64 | 2014-10-05 11:07:33 +0200 | [diff] [blame] | 703 | global_nvs_t *gnvs; |
| 704 | |
| 705 | gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); |
| 706 | if (!gnvs) { |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 707 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(*gnvs)); |
Vladimir Serbinenko | 7309c64 | 2014-10-05 11:07:33 +0200 | [diff] [blame] | 708 | if (gnvs) |
| 709 | memset(gnvs, 0, sizeof(*gnvs)); |
| 710 | } |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 711 | |
| 712 | if (gnvs) { |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 713 | acpi_create_gnvs(gnvs); |
Vladimir Serbinenko | 1b409fd | 2014-10-12 00:26:21 +0200 | [diff] [blame] | 714 | |
| 715 | gnvs->apic = 1; |
| 716 | gnvs->mpen = 1; /* Enable Multi Processing */ |
| 717 | gnvs->pcnt = dev_count_cpu(); |
| 718 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 719 | #if CONFIG(CHROMEOS) |
Joel Kitching | 6fbd874 | 2018-08-23 14:56:25 +0800 | [diff] [blame] | 720 | chromeos_init_chromeos_acpi(&(gnvs->chromeos)); |
Vladimir Serbinenko | 1b409fd | 2014-10-12 00:26:21 +0200 | [diff] [blame] | 721 | #endif |
| 722 | |
| 723 | /* Update the mem console pointer. */ |
| 724 | gnvs->cbmc = (u32)cbmem_find(CBMEM_ID_CONSOLE); |
| 725 | |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 726 | /* And tell SMI about it */ |
| 727 | smm_setup_structures(gnvs, NULL, NULL); |
| 728 | |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 729 | /* Add it to DSDT. */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 730 | acpigen_write_scope("\\"); |
| 731 | acpigen_write_name_dword("NVSA", (u32) gnvs); |
| 732 | acpigen_pop_len(); |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 733 | } |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 734 | } |
| 735 | |
Tristan Corrick | b2632ce | 2018-10-31 02:28:13 +1300 | [diff] [blame] | 736 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 737 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 738 | struct device *dev = pcidev_on_root(0x1f, 0); |
Tristan Corrick | b2632ce | 2018-10-31 02:28:13 +1300 | [diff] [blame] | 739 | struct southbridge_intel_lynxpoint_config *cfg = dev->chip_info; |
| 740 | u16 pmbase = get_pmbase(); |
| 741 | |
| 742 | fadt->sci_int = 0x9; |
| 743 | fadt->smi_cmd = APM_CNT; |
| 744 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 745 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 746 | fadt->s4bios_req = 0x0; |
| 747 | fadt->pstate_cnt = 0; |
| 748 | |
| 749 | fadt->pm1a_evt_blk = pmbase + PM1_STS; |
| 750 | fadt->pm1b_evt_blk = 0x0; |
| 751 | fadt->pm1a_cnt_blk = pmbase + PM1_CNT; |
| 752 | fadt->pm1b_cnt_blk = 0x0; |
| 753 | fadt->pm2_cnt_blk = pmbase + PM2_CNT; |
| 754 | fadt->pm_tmr_blk = pmbase + PM1_TMR; |
| 755 | if (pch_is_lp()) |
| 756 | fadt->gpe0_blk = pmbase + LP_GPE0_STS_1; |
| 757 | else |
| 758 | fadt->gpe0_blk = pmbase + GPE0_STS; |
| 759 | fadt->gpe1_blk = 0; |
| 760 | |
| 761 | /* |
| 762 | * Some of the lengths here are doubled. This is because they describe |
| 763 | * blocks containing two registers, where the size of each register |
| 764 | * is found by halving the block length. See Table 5-34 and section |
| 765 | * 4.8.3 of the ACPI specification for details. |
| 766 | */ |
| 767 | fadt->pm1_evt_len = 2 * 2; |
| 768 | fadt->pm1_cnt_len = 2; |
| 769 | fadt->pm2_cnt_len = 1; |
| 770 | fadt->pm_tmr_len = 4; |
| 771 | if (pch_is_lp()) |
| 772 | fadt->gpe0_blk_len = 2 * 16; |
| 773 | else |
| 774 | fadt->gpe0_blk_len = 2 * 8; |
| 775 | fadt->gpe1_blk_len = 0; |
| 776 | fadt->gpe1_base = 0; |
| 777 | |
| 778 | fadt->cst_cnt = 0; |
| 779 | fadt->p_lvl2_lat = 1; |
| 780 | fadt->p_lvl3_lat = 87; |
| 781 | fadt->flush_size = 0; |
| 782 | fadt->flush_stride = 0; |
| 783 | fadt->duty_offset = 0; |
| 784 | fadt->duty_width = 0; |
| 785 | fadt->day_alrm = 0xd; |
| 786 | fadt->mon_alrm = 0x00; |
| 787 | fadt->century = 0x00; |
| 788 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 789 | |
| 790 | fadt->flags = ACPI_FADT_WBINVD | |
| 791 | ACPI_FADT_C1_SUPPORTED | |
| 792 | ACPI_FADT_C2_MP_SUPPORTED | |
| 793 | ACPI_FADT_SLEEP_BUTTON | |
| 794 | ACPI_FADT_RESET_REGISTER | |
| 795 | ACPI_FADT_SEALED_CASE | |
| 796 | ACPI_FADT_S4_RTC_WAKE | |
| 797 | ACPI_FADT_PLATFORM_CLOCK; |
| 798 | |
| 799 | if (cfg->docking_supported) |
| 800 | fadt->flags |= ACPI_FADT_DOCKING_SUPPORTED; |
| 801 | |
| 802 | fadt->reset_reg.space_id = ACPI_ADDRESS_SPACE_IO; |
| 803 | fadt->reset_reg.bit_width = 8; |
| 804 | fadt->reset_reg.bit_offset = 0; |
| 805 | fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 806 | fadt->reset_reg.addrl = 0xcf9; |
| 807 | fadt->reset_reg.addrh = 0; |
| 808 | |
| 809 | fadt->reset_value = 6; |
| 810 | |
| 811 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 812 | fadt->x_pm1a_evt_blk.bit_width = 2 * 16; |
| 813 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 814 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 815 | fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS; |
| 816 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 817 | |
| 818 | fadt->x_pm1b_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 819 | fadt->x_pm1b_evt_blk.bit_width = 0; |
| 820 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 821 | fadt->x_pm1b_evt_blk.access_size = 0; |
| 822 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 823 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 824 | |
| 825 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 826 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 827 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 828 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 829 | fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT; |
| 830 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 831 | |
| 832 | fadt->x_pm1b_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 833 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
| 834 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 835 | fadt->x_pm1b_cnt_blk.access_size = 0; |
| 836 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 837 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 838 | |
| 839 | fadt->x_pm2_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 840 | fadt->x_pm2_cnt_blk.bit_width = 8; |
| 841 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 842 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 843 | fadt->x_pm2_cnt_blk.addrl = pmbase + PM2_CNT; |
| 844 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 845 | |
| 846 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 847 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 848 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 849 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 850 | fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR; |
| 851 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 852 | |
| 853 | /* |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 854 | * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5. |
| 855 | * The bit_width field intentionally overflows here. |
| 856 | * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which |
| 857 | * seems to work fine on Linux 5.0 and Windows 10. |
Tristan Corrick | b2632ce | 2018-10-31 02:28:13 +1300 | [diff] [blame] | 858 | */ |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 859 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 860 | fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8; |
| 861 | fadt->x_gpe0_blk.bit_offset = 0; |
| 862 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 863 | fadt->x_gpe0_blk.addrl = fadt->gpe0_blk; |
| 864 | fadt->x_gpe0_blk.addrh = 0x0; |
Tristan Corrick | b2632ce | 2018-10-31 02:28:13 +1300 | [diff] [blame] | 865 | |
| 866 | fadt->x_gpe1_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 867 | fadt->x_gpe1_blk.bit_width = 0; |
| 868 | fadt->x_gpe1_blk.bit_offset = 0; |
| 869 | fadt->x_gpe1_blk.access_size = 0; |
| 870 | fadt->x_gpe1_blk.addrl = 0x0; |
| 871 | fadt->x_gpe1_blk.addrh = 0x0; |
| 872 | } |
| 873 | |
Tristan Corrick | f3127d4 | 2018-10-31 02:25:54 +1300 | [diff] [blame] | 874 | static const char *lpc_acpi_name(const struct device *dev) |
| 875 | { |
| 876 | return "LPCB"; |
| 877 | } |
| 878 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 879 | static void southbridge_fill_ssdt(const struct device *dev) |
Tristan Corrick | f3127d4 | 2018-10-31 02:25:54 +1300 | [diff] [blame] | 880 | { |
| 881 | intel_acpi_gen_def_acpi_pirq(dev); |
| 882 | } |
| 883 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 884 | static unsigned long southbridge_write_acpi_tables(const struct device *device, |
Alexander Couzens | 83fc32f | 2015-04-12 22:28:37 +0200 | [diff] [blame] | 885 | unsigned long start, |
| 886 | struct acpi_rsdp *rsdp) |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 887 | { |
| 888 | unsigned long current; |
| 889 | acpi_hpet_t *hpet; |
| 890 | acpi_header_t *ssdt; |
| 891 | |
| 892 | current = start; |
| 893 | |
| 894 | /* Align ACPI tables to 16byte */ |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 895 | current = acpi_align_current(current); |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 896 | |
| 897 | /* |
| 898 | * We explicitly add these tables later on: |
| 899 | */ |
| 900 | printk(BIOS_DEBUG, "ACPI: * HPET\n"); |
| 901 | |
| 902 | hpet = (acpi_hpet_t *) current; |
| 903 | current += sizeof(acpi_hpet_t); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 904 | current = acpi_align_current(current); |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 905 | acpi_create_intel_hpet(hpet); |
| 906 | acpi_add_table(rsdp, hpet); |
| 907 | |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 908 | current = acpi_align_current(current); |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 909 | |
| 910 | printk(BIOS_DEBUG, "ACPI: * SSDT2\n"); |
| 911 | ssdt = (acpi_header_t *)current; |
| 912 | acpi_create_serialio_ssdt(ssdt); |
| 913 | current += ssdt->length; |
| 914 | acpi_add_table(rsdp, ssdt); |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 915 | current = acpi_align_current(current); |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 916 | |
| 917 | printk(BIOS_DEBUG, "current = %lx\n", current); |
| 918 | return current; |
| 919 | } |
| 920 | |
Tristan Corrick | 32ceed8 | 2018-11-30 22:53:27 +1300 | [diff] [blame] | 921 | static void lpc_final(struct device *dev) |
| 922 | { |
Arthur Heymans | a3121b0 | 2019-05-28 13:46:49 +0200 | [diff] [blame] | 923 | spi_finalize_ops(); |
Tristan Corrick | 63626b1 | 2018-11-30 22:53:50 +1300 | [diff] [blame] | 924 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 925 | if (acpi_is_wakeup_s3() || CONFIG(INTEL_CHIPSET_LOCKDOWN)) |
Tristan Corrick | 32ceed8 | 2018-11-30 22:53:27 +1300 | [diff] [blame] | 926 | outb(APM_CNT_FINALIZE, APM_CNT); |
| 927 | } |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 928 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 929 | static struct pci_operations pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 930 | .set_subsystem = pci_dev_set_subsystem, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 931 | }; |
| 932 | |
| 933 | static struct device_operations device_ops = { |
| 934 | .read_resources = pch_lpc_read_resources, |
| 935 | .set_resources = pci_dev_set_resources, |
Duncan Laurie | 8d783b8 | 2013-05-14 11:16:34 -0700 | [diff] [blame] | 936 | .enable_resources = pci_dev_enable_resources, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 937 | .acpi_fill_ssdt = southbridge_fill_ssdt, |
| 938 | .acpi_inject_dsdt = southbridge_inject_dsdt, |
Tristan Corrick | f3127d4 | 2018-10-31 02:25:54 +1300 | [diff] [blame] | 939 | .acpi_name = lpc_acpi_name, |
Vladimir Serbinenko | c6e566a | 2014-08-31 17:43:51 +0200 | [diff] [blame] | 940 | .write_acpi_tables = southbridge_write_acpi_tables, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 941 | .init = lpc_init, |
Tristan Corrick | 32ceed8 | 2018-11-30 22:53:27 +1300 | [diff] [blame] | 942 | .final = lpc_final, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 943 | .enable = pch_lpc_enable, |
Nico Huber | 51b75ae | 2019-03-14 16:02:05 +0100 | [diff] [blame] | 944 | .scan_bus = scan_static_bus, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 945 | .ops_pci = &pci_ops, |
| 946 | }; |
| 947 | |
| 948 | |
Aaron Durbin | c1989c4 | 2012-12-11 17:13:17 -0600 | [diff] [blame] | 949 | /* IDs for LPC device of Intel 8 Series Chipset (Lynx Point) */ |
| 950 | static const unsigned short pci_device_ids[] = { |
| 951 | 0x8c41, /* Mobile Full Featured Engineering Sample. */ |
| 952 | 0x8c42, /* Desktop Full Featured Engineering Sample. */ |
| 953 | 0x8c44, /* Z87 SKU */ |
| 954 | 0x8c46, /* Z85 SKU */ |
| 955 | 0x8c49, /* HM86 SKU */ |
| 956 | 0x8c4a, /* H87 SKU */ |
| 957 | 0x8c4b, /* HM87 SKU */ |
| 958 | 0x8c4c, /* Q85 SKU */ |
| 959 | 0x8c4e, /* Q87 SKU */ |
| 960 | 0x8c4f, /* QM87 SKU */ |
Tristan Corrick | 9a08574 | 2018-10-31 02:20:28 +1300 | [diff] [blame] | 961 | 0x8c50, /* B85 SKU */ |
| 962 | 0x8c52, /* C222 SKU */ |
| 963 | 0x8c54, /* C224 SKU */ |
| 964 | 0x8c56, /* C226 SKU */ |
| 965 | 0x8c5c, /* H81 SKU */ |
Duncan Laurie | 74c0d05 | 2012-12-17 11:31:40 -0800 | [diff] [blame] | 966 | 0x9c41, /* LP Full Featured Engineering Sample */ |
| 967 | 0x9c43, /* LP Premium SKU */ |
| 968 | 0x9c45, /* LP Mainstream SKU */ |
| 969 | 0x9c47, /* LP Value SKU */ |
Aaron Durbin | c1989c4 | 2012-12-11 17:13:17 -0600 | [diff] [blame] | 970 | 0 }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 971 | |
| 972 | static const struct pci_driver pch_lpc __pci_driver = { |
| 973 | .ops = &device_ops, |
| 974 | .vendor = PCI_VENDOR_ID_INTEL, |
| 975 | .devices = pci_device_ids, |
| 976 | }; |