Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * Copyright (C) 2013 Vladimir Serbinenko |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; version 2 of |
| 10 | * the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <device/pci_ids.h> |
| 22 | #include <pc80/mc146818rtc.h> |
| 23 | #include <pc80/isa-dma.h> |
| 24 | #include <pc80/i8259.h> |
| 25 | #include <arch/io.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 26 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 27 | #include <device/pci_ops.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 28 | #include <arch/ioapic.h> |
| 29 | #include <arch/acpi.h> |
Elyes HAOUAS | d2b9ec1 | 2018-10-27 09:41:02 +0200 | [diff] [blame] | 30 | #include <arch/cpu.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 31 | #include <elog.h> |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 32 | #include <arch/acpigen.h> |
| 33 | #include <drivers/intel/gma/i915.h> |
| 34 | #include <cbmem.h> |
Vladimir Serbinenko | 7309c64 | 2014-10-05 11:07:33 +0200 | [diff] [blame] | 35 | #include <string.h> |
Vladimir Serbinenko | 67bfbfd | 2014-10-25 15:49:23 +0200 | [diff] [blame] | 36 | #include <cpu/x86/smm.h> |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame] | 37 | #include "chip.h" |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 38 | #include "pch.h" |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 39 | #include "nvs.h" |
Vladimir Serbinenko | 36fa5b8 | 2014-10-28 23:43:20 +0100 | [diff] [blame] | 40 | #include <southbridge/intel/common/pciehp.h> |
Kyösti Mälkki | 9099395 | 2018-05-01 19:36:25 +0300 | [diff] [blame] | 41 | #include <southbridge/intel/common/acpi_pirq_gen.h> |
Arthur Heymans | aadd1d0 | 2019-05-28 13:39:20 +0200 | [diff] [blame] | 42 | #include <southbridge/intel/common/spi.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 43 | |
| 44 | #define NMI_OFF 0 |
| 45 | |
| 46 | #define ENABLE_ACPI_MODE_IN_COREBOOT 0 |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 47 | |
Vladimir Serbinenko | 4695705 | 2013-11-26 01:16:20 +0100 | [diff] [blame] | 48 | typedef struct southbridge_intel_ibexpeak_config config_t; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Set miscellanous static southbridge features. |
| 52 | * |
| 53 | * @param dev PCI device with I/O APIC control registers |
| 54 | */ |
| 55 | static void pch_enable_ioapic(struct device *dev) |
| 56 | { |
| 57 | u32 reg32; |
| 58 | |
| 59 | /* Enable ACPI I/O range decode */ |
| 60 | pci_write_config8(dev, ACPI_CNTL, ACPI_EN); |
| 61 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 62 | set_ioapic_id(VIO_APIC_VADDR, 0x01); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 63 | /* affirm full set of redirection table entries ("write once") */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 64 | reg32 = io_apic_read(VIO_APIC_VADDR, 0x01); |
| 65 | io_apic_write(VIO_APIC_VADDR, 0x01, reg32); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * Select Boot Configuration register (0x03) and |
| 69 | * use Processor System Bus (0x01) to deliver interrupts. |
| 70 | */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 71 | io_apic_write(VIO_APIC_VADDR, 0x03, 0x01); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static void pch_enable_serial_irqs(struct device *dev) |
| 75 | { |
| 76 | /* Set packet length and toggle silent mode bit for one frame. */ |
| 77 | pci_write_config8(dev, SERIRQ_CNTL, |
| 78 | (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0)); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 79 | #if !CONFIG(SERIRQ_CONTINUOUS_MODE) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 80 | pci_write_config8(dev, SERIRQ_CNTL, |
| 81 | (1 << 7) | (0 << 6) | ((21 - 17) << 2) | (0 << 0)); |
| 82 | #endif |
| 83 | } |
| 84 | |
| 85 | /* PIRQ[n]_ROUT[3:0] - PIRQ Routing Control |
| 86 | * 0x00 - 0000 = Reserved |
| 87 | * 0x01 - 0001 = Reserved |
| 88 | * 0x02 - 0010 = Reserved |
| 89 | * 0x03 - 0011 = IRQ3 |
| 90 | * 0x04 - 0100 = IRQ4 |
| 91 | * 0x05 - 0101 = IRQ5 |
| 92 | * 0x06 - 0110 = IRQ6 |
| 93 | * 0x07 - 0111 = IRQ7 |
| 94 | * 0x08 - 1000 = Reserved |
| 95 | * 0x09 - 1001 = IRQ9 |
| 96 | * 0x0A - 1010 = IRQ10 |
| 97 | * 0x0B - 1011 = IRQ11 |
| 98 | * 0x0C - 1100 = IRQ12 |
| 99 | * 0x0D - 1101 = Reserved |
| 100 | * 0x0E - 1110 = IRQ14 |
| 101 | * 0x0F - 1111 = IRQ15 |
| 102 | * PIRQ[n]_ROUT[7] - PIRQ Routing Control |
| 103 | * 0x80 - The PIRQ is not routed. |
| 104 | */ |
| 105 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 106 | static void pch_pirq_init(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 107 | { |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 108 | struct device *irq_dev; |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 109 | /* Interrupt 11 is not used by legacy devices and so can always be used for |
| 110 | PCI interrupts. Full legacy IRQ routing is complicated and hard to |
| 111 | get right. Fortunately all modern OS use MSI and so it's not that big of |
| 112 | an issue anyway. Still we have to provide a reasonable default. Using |
| 113 | interrupt 11 for it everywhere is a working default. ACPI-aware OS can |
| 114 | move it to any interrupt and others will just leave them at default. |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 115 | */ |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 116 | const u8 pirq_routing = 11; |
| 117 | |
| 118 | pci_write_config8(dev, PIRQA_ROUT, pirq_routing); |
| 119 | pci_write_config8(dev, PIRQB_ROUT, pirq_routing); |
| 120 | pci_write_config8(dev, PIRQC_ROUT, pirq_routing); |
| 121 | pci_write_config8(dev, PIRQD_ROUT, pirq_routing); |
| 122 | |
| 123 | pci_write_config8(dev, PIRQE_ROUT, pirq_routing); |
| 124 | pci_write_config8(dev, PIRQF_ROUT, pirq_routing); |
| 125 | pci_write_config8(dev, PIRQG_ROUT, pirq_routing); |
| 126 | pci_write_config8(dev, PIRQH_ROUT, pirq_routing); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 127 | |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 128 | for (irq_dev = all_devices; irq_dev; irq_dev = irq_dev->next) { |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 129 | u8 int_pin=0; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 130 | |
| 131 | if (!irq_dev->enabled || irq_dev->path.type != DEVICE_PATH_PCI) |
| 132 | continue; |
| 133 | |
| 134 | int_pin = pci_read_config8(irq_dev, PCI_INTERRUPT_PIN); |
| 135 | |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 136 | if (int_pin == 0) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 137 | continue; |
| 138 | |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 139 | pci_write_config8(irq_dev, PCI_INTERRUPT_LINE, pirq_routing); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 143 | static void pch_gpi_routing(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 144 | { |
| 145 | /* Get the chip configuration */ |
| 146 | config_t *config = dev->chip_info; |
| 147 | u32 reg32 = 0; |
| 148 | |
| 149 | /* An array would be much nicer here, or some |
| 150 | * other method of doing this. |
| 151 | */ |
| 152 | reg32 |= (config->gpi0_routing & 0x03) << 0; |
| 153 | reg32 |= (config->gpi1_routing & 0x03) << 2; |
| 154 | reg32 |= (config->gpi2_routing & 0x03) << 4; |
| 155 | reg32 |= (config->gpi3_routing & 0x03) << 6; |
| 156 | reg32 |= (config->gpi4_routing & 0x03) << 8; |
| 157 | reg32 |= (config->gpi5_routing & 0x03) << 10; |
| 158 | reg32 |= (config->gpi6_routing & 0x03) << 12; |
| 159 | reg32 |= (config->gpi7_routing & 0x03) << 14; |
| 160 | reg32 |= (config->gpi8_routing & 0x03) << 16; |
| 161 | reg32 |= (config->gpi9_routing & 0x03) << 18; |
| 162 | reg32 |= (config->gpi10_routing & 0x03) << 20; |
| 163 | reg32 |= (config->gpi11_routing & 0x03) << 22; |
| 164 | reg32 |= (config->gpi12_routing & 0x03) << 24; |
| 165 | reg32 |= (config->gpi13_routing & 0x03) << 26; |
| 166 | reg32 |= (config->gpi14_routing & 0x03) << 28; |
| 167 | reg32 |= (config->gpi15_routing & 0x03) << 30; |
| 168 | |
Kyösti Mälkki | b85a87b | 2014-12-29 11:32:27 +0200 | [diff] [blame] | 169 | pci_write_config32(dev, GPIO_ROUT, reg32); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 172 | static void pch_power_options(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 173 | { |
| 174 | u8 reg8; |
| 175 | u16 reg16, pmbase; |
| 176 | u32 reg32; |
| 177 | const char *state; |
| 178 | /* Get the chip configuration */ |
| 179 | config_t *config = dev->chip_info; |
| 180 | |
Nico Huber | 9faae2b | 2018-11-14 00:00:35 +0100 | [diff] [blame] | 181 | int pwr_on = CONFIG_MAINBOARD_POWER_FAILURE_STATE; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 182 | int nmi_option; |
| 183 | |
| 184 | /* Which state do we want to goto after g3 (power restored)? |
| 185 | * 0 == S0 Full On |
| 186 | * 1 == S5 Soft Off |
| 187 | * |
| 188 | * If the option is not existent (Laptops), use Kconfig setting. |
| 189 | */ |
| 190 | get_option(&pwr_on, "power_on_after_fail"); |
| 191 | |
| 192 | reg16 = pci_read_config16(dev, GEN_PMCON_3); |
| 193 | reg16 &= 0xfffe; |
| 194 | switch (pwr_on) { |
| 195 | case MAINBOARD_POWER_OFF: |
| 196 | reg16 |= 1; |
| 197 | state = "off"; |
| 198 | break; |
| 199 | case MAINBOARD_POWER_ON: |
| 200 | reg16 &= ~1; |
| 201 | state = "on"; |
| 202 | break; |
| 203 | case MAINBOARD_POWER_KEEP: |
| 204 | reg16 &= ~1; |
| 205 | state = "state keep"; |
| 206 | break; |
| 207 | default: |
| 208 | state = "undefined"; |
| 209 | } |
| 210 | |
| 211 | reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */ |
| 212 | reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */ |
| 213 | |
| 214 | reg16 &= ~(1 << 10); |
| 215 | reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */ |
| 216 | |
| 217 | reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */ |
| 218 | |
| 219 | pci_write_config16(dev, GEN_PMCON_3, reg16); |
| 220 | printk(BIOS_INFO, "Set power %s after power failure.\n", state); |
| 221 | |
| 222 | /* Set up NMI on errors. */ |
| 223 | reg8 = inb(0x61); |
| 224 | reg8 &= 0x0f; /* Higher Nibble must be 0 */ |
| 225 | reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */ |
| 226 | // reg8 &= ~(1 << 2); /* PCI SERR# Enable */ |
| 227 | reg8 |= (1 << 2); /* PCI SERR# Disable for now */ |
| 228 | outb(reg8, 0x61); |
| 229 | |
| 230 | reg8 = inb(0x70); |
| 231 | nmi_option = NMI_OFF; |
| 232 | get_option(&nmi_option, "nmi"); |
| 233 | if (nmi_option) { |
| 234 | printk(BIOS_INFO, "NMI sources enabled.\n"); |
| 235 | reg8 &= ~(1 << 7); /* Set NMI. */ |
| 236 | } else { |
| 237 | printk(BIOS_INFO, "NMI sources disabled.\n"); |
Elyes HAOUAS | 9c5d463 | 2018-04-26 22:21:21 +0200 | [diff] [blame] | 238 | reg8 |= (1 << 7); /* Can't mask NMI from PCI-E and NMI_NOW */ |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 239 | } |
| 240 | outb(reg8, 0x70); |
| 241 | |
| 242 | /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */ |
| 243 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 244 | reg16 &= ~(3 << 0); // SMI# rate 1 minute |
| 245 | reg16 &= ~(1 << 10); // Disable BIOS_PCI_EXP_EN for native PME |
| 246 | #if DEBUG_PERIODIC_SMIS |
| 247 | /* Set DEBUG_PERIODIC_SMIS in pch.h to debug using |
| 248 | * periodic SMIs. |
| 249 | */ |
| 250 | reg16 |= (3 << 0); // Periodic SMI every 8s |
| 251 | #endif |
| 252 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 253 | |
| 254 | // Set the board's GPI routing. |
| 255 | pch_gpi_routing(dev); |
| 256 | |
| 257 | pmbase = pci_read_config16(dev, 0x40) & 0xfffe; |
| 258 | |
| 259 | outl(config->gpe0_en, pmbase + GPE0_EN); |
| 260 | outw(config->alt_gp_smi_en, pmbase + ALT_GP_SMI_EN); |
| 261 | |
| 262 | /* Set up power management block and determine sleep mode */ |
| 263 | reg32 = inl(pmbase + 0x04); // PM1_CNT |
| 264 | reg32 &= ~(7 << 10); // SLP_TYP |
| 265 | reg32 |= (1 << 0); // SCI_EN |
| 266 | outl(reg32, pmbase + 0x04); |
| 267 | |
| 268 | /* Clear magic status bits to prevent unexpected wake */ |
Angel Pons | 42b4e4e | 2019-09-18 10:58:53 +0200 | [diff] [blame] | 269 | reg32 = RCBA32(PRSTS); |
| 270 | reg32 |= (1 << 5) | (1 << 4) | (1 << 0); |
| 271 | RCBA32(PRSTS) = reg32; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 272 | |
Angel Pons | 42b4e4e | 2019-09-18 10:58:53 +0200 | [diff] [blame] | 273 | /* FIXME: Does this even exist? */ |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 274 | reg32 = RCBA32(0x3f02); |
| 275 | reg32 &= ~0xf; |
| 276 | RCBA32(0x3f02) = reg32; |
| 277 | } |
| 278 | |
| 279 | static void pch_rtc_init(struct device *dev) |
| 280 | { |
| 281 | u8 reg8; |
| 282 | int rtc_failed; |
| 283 | |
| 284 | reg8 = pci_read_config8(dev, GEN_PMCON_3); |
| 285 | rtc_failed = reg8 & RTC_BATTERY_DEAD; |
| 286 | if (rtc_failed) { |
| 287 | reg8 &= ~RTC_BATTERY_DEAD; |
| 288 | pci_write_config8(dev, GEN_PMCON_3, reg8); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 289 | #if CONFIG(ELOG) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 290 | elog_add_event(ELOG_TYPE_RTC_RESET); |
| 291 | #endif |
| 292 | } |
| 293 | printk(BIOS_DEBUG, "rtc_failed = 0x%x\n", rtc_failed); |
| 294 | |
Gabe Black | b3f08c6 | 2014-04-30 17:12:25 -0700 | [diff] [blame] | 295 | cmos_init(rtc_failed); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | static void mobile5_pm_init(struct device *dev) |
| 299 | { |
| 300 | int i; |
| 301 | |
| 302 | printk(BIOS_DEBUG, "Mobile 5 PM init\n"); |
| 303 | pci_write_config8(dev, 0xa9, 0x47); |
| 304 | |
| 305 | RCBA32 (0x1d44) = 0x00000000; |
| 306 | (void) RCBA32 (0x1d44); |
| 307 | RCBA32 (0x1d48) = 0x00030000; |
| 308 | (void) RCBA32 (0x1d48); |
| 309 | RCBA32 (0x1e80) = 0x000c0801; |
| 310 | (void) RCBA32 (0x1e80); |
| 311 | RCBA32 (0x1e84) = 0x000200f0; |
| 312 | (void) RCBA32 (0x1e84); |
| 313 | |
| 314 | const u32 rcba2010[] = |
| 315 | { |
| 316 | /* 2010: */ 0x00188200, 0x14000016, 0xbc4abcb5, 0x00000000, |
| 317 | /* 2020: */ 0xf0c9605b, 0x13683040, 0x04c8f16e, 0x09e90170 |
| 318 | }; |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 319 | for (i = 0; i < sizeof(rcba2010) / sizeof(rcba2010[0]); i++) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 320 | { |
| 321 | RCBA32 (0x2010 + 4 * i) = rcba2010[i]; |
| 322 | RCBA32 (0x2010 + 4 * i); |
| 323 | } |
| 324 | |
| 325 | RCBA32 (0x2100) = 0x00000000; |
| 326 | (void) RCBA32 (0x2100); |
| 327 | RCBA32 (0x2104) = 0x00000757; |
| 328 | (void) RCBA32 (0x2104); |
| 329 | RCBA32 (0x2108) = 0x00170001; |
| 330 | (void) RCBA32 (0x2108); |
| 331 | |
| 332 | RCBA32 (0x211c) = 0x00000000; |
| 333 | (void) RCBA32 (0x211c); |
| 334 | RCBA32 (0x2120) = 0x00010000; |
| 335 | (void) RCBA32 (0x2120); |
| 336 | |
| 337 | RCBA32 (0x21fc) = 0x00000000; |
| 338 | (void) RCBA32 (0x21fc); |
| 339 | RCBA32 (0x2200) = 0x20000044; |
| 340 | (void) RCBA32 (0x2200); |
| 341 | RCBA32 (0x2204) = 0x00000001; |
| 342 | (void) RCBA32 (0x2204); |
| 343 | RCBA32 (0x2208) = 0x00003457; |
| 344 | (void) RCBA32 (0x2208); |
| 345 | |
| 346 | const u32 rcba2210[] = |
| 347 | { |
| 348 | /* 2210 */ 0x00000000, 0x00000001, 0xa0fff210, 0x0000df00, |
| 349 | /* 2220 */ 0x00e30880, 0x00000070, 0x00004000, 0x00000000, |
| 350 | /* 2230 */ 0x00e30880, 0x00000070, 0x00004000, 0x00000000, |
| 351 | /* 2240 */ 0x00002301, 0x36000000, 0x00010107, 0x00160000, |
| 352 | /* 2250 */ 0x00001b01, 0x36000000, 0x00010107, 0x00160000, |
| 353 | /* 2260 */ 0x00000601, 0x16000000, 0x00010107, 0x00160000, |
| 354 | /* 2270 */ 0x00001c01, 0x16000000, 0x00010107, 0x00160000 |
| 355 | }; |
| 356 | |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 357 | for (i = 0; i < sizeof(rcba2210) / sizeof(rcba2210[0]); i++) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 358 | { |
| 359 | RCBA32 (0x2210 + 4 * i) = rcba2210[i]; |
| 360 | RCBA32 (0x2210 + 4 * i); |
| 361 | } |
| 362 | |
| 363 | const u32 rcba2300[] = |
| 364 | { |
| 365 | /* 2300: */ 0x00000000, 0x40000000, 0x4646827b, 0x6e803131, |
| 366 | /* 2310: */ 0x32c77887, 0x00077733, 0x00007447, 0x00000040, |
| 367 | /* 2320: */ 0xcccc0cfc, 0x0fbb0fff |
| 368 | }; |
| 369 | |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 370 | for (i = 0; i < sizeof(rcba2300) / sizeof(rcba2300[0]); i++) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 371 | { |
| 372 | RCBA32 (0x2300 + 4 * i) = rcba2300[i]; |
| 373 | RCBA32 (0x2300 + 4 * i); |
| 374 | } |
| 375 | |
| 376 | RCBA32 (0x37fc) = 0x00000000; |
| 377 | (void) RCBA32 (0x37fc); |
| 378 | RCBA32 (0x3dfc) = 0x00000000; |
| 379 | (void) RCBA32 (0x3dfc); |
| 380 | RCBA32 (0x3e7c) = 0xffffffff; |
| 381 | (void) RCBA32 (0x3e7c); |
| 382 | RCBA32 (0x3efc) = 0x00000000; |
| 383 | (void) RCBA32 (0x3efc); |
| 384 | RCBA32 (0x3f00) = 0x0000010b; |
| 385 | (void) RCBA32 (0x3f00); |
| 386 | } |
| 387 | |
| 388 | static void enable_hpet(void) |
| 389 | { |
| 390 | u32 reg32; |
| 391 | |
| 392 | /* Move HPET to default address 0xfed00000 and enable it */ |
| 393 | reg32 = RCBA32(HPTC); |
| 394 | reg32 |= (1 << 7); // HPET Address Enable |
| 395 | reg32 &= ~(3 << 0); |
| 396 | RCBA32(HPTC) = reg32; |
Arthur Heymans | 37e1d93 | 2019-10-02 14:33:34 +0200 | [diff] [blame] | 397 | RCBA32(HPTC); /* Read back for it to work */ |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 398 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 399 | write32((u32 *)0xfed00010, read32((u32 *)0xfed00010) | 1); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 400 | } |
| 401 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 402 | static void enable_clock_gating(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 403 | { |
| 404 | u32 reg32; |
| 405 | u16 reg16; |
| 406 | |
| 407 | RCBA32_AND_OR(0x2234, ~0UL, 0xf); |
| 408 | |
| 409 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 410 | reg16 |= (1 << 2) | (1 << 11); |
| 411 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 412 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 413 | reg32 = RCBA32(CG); |
| 414 | reg32 |= (1 << 31); |
| 415 | reg32 |= (1 << 29) | (1 << 28); |
| 416 | reg32 |= (1 << 27) | (1 << 26) | (1 << 25) | (1 << 24); |
| 417 | reg32 |= (1 << 16); |
| 418 | reg32 |= (1 << 17); |
| 419 | reg32 |= (1 << 18); |
| 420 | reg32 |= (1 << 22); |
| 421 | reg32 |= (1 << 23); |
| 422 | reg32 &= ~(1 << 20); |
| 423 | reg32 |= (1 << 19); |
| 424 | reg32 |= (1 << 0); |
| 425 | reg32 |= (0xf << 1); |
| 426 | RCBA32(CG) = reg32; |
| 427 | |
| 428 | RCBA32_OR(0x38c0, 0x7); |
| 429 | RCBA32_OR(0x36d4, 0x6680c004); |
| 430 | RCBA32_OR(0x3564, 0x3); |
| 431 | } |
| 432 | |
Vladimir Serbinenko | 456f495 | 2015-05-28 20:42:32 +0200 | [diff] [blame] | 433 | static void pch_set_acpi_mode(void) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 434 | { |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 435 | if (!acpi_is_wakeup_s3() && CONFIG(HAVE_SMI_HANDLER)) { |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 436 | #if ENABLE_ACPI_MODE_IN_COREBOOT |
| 437 | printk(BIOS_DEBUG, "Enabling ACPI via APMC:\n"); |
Vladimir Serbinenko | 456f495 | 2015-05-28 20:42:32 +0200 | [diff] [blame] | 438 | outb(APM_CNT_ACPI_ENABLE, APM_CNT); // Enable ACPI mode |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 439 | printk(BIOS_DEBUG, "done.\n"); |
| 440 | #else |
| 441 | printk(BIOS_DEBUG, "Disabling ACPI via APMC:\n"); |
Vladimir Serbinenko | 456f495 | 2015-05-28 20:42:32 +0200 | [diff] [blame] | 442 | outb(APM_CNT_ACPI_DISABLE, APM_CNT); // Disable ACPI mode |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 443 | printk(BIOS_DEBUG, "done.\n"); |
| 444 | #endif |
| 445 | } |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 446 | } |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 447 | |
| 448 | static void pch_disable_smm_only_flashing(struct device *dev) |
| 449 | { |
| 450 | u8 reg8; |
| 451 | |
| 452 | printk(BIOS_SPEW, "Enabling BIOS updates outside of SMM... "); |
Elyes HAOUAS | 0c22d2f | 2018-12-01 12:19:52 +0100 | [diff] [blame] | 453 | reg8 = pci_read_config8(dev, BIOS_CNTL); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 454 | reg8 &= ~(1 << 5); |
Elyes HAOUAS | 0c22d2f | 2018-12-01 12:19:52 +0100 | [diff] [blame] | 455 | pci_write_config8(dev, BIOS_CNTL, reg8); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static void pch_fixups(struct device *dev) |
| 459 | { |
| 460 | /* |
| 461 | * Enable DMI ASPM in the PCH |
| 462 | */ |
| 463 | RCBA32_AND_OR(0x2304, ~(1 << 10), 0); |
| 464 | RCBA32_OR(0x21a4, (1 << 11)|(1 << 10)); |
| 465 | RCBA32_OR(0x21a8, 0x3); |
| 466 | } |
| 467 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 468 | static void lpc_init(struct device *dev) |
| 469 | { |
| 470 | printk(BIOS_DEBUG, "pch: lpc_init\n"); |
| 471 | |
| 472 | /* Set the value for PCI command register. */ |
| 473 | pci_write_config16(dev, PCI_COMMAND, 0x000f); |
| 474 | |
| 475 | /* IO APIC initialization. */ |
| 476 | pch_enable_ioapic(dev); |
| 477 | |
| 478 | pch_enable_serial_irqs(dev); |
| 479 | |
| 480 | /* Setup the PIRQ. */ |
| 481 | pch_pirq_init(dev); |
| 482 | |
| 483 | /* Setup power options. */ |
| 484 | pch_power_options(dev); |
| 485 | |
| 486 | /* Initialize power management */ |
Arthur Heymans | d0310fa | 2019-10-02 00:21:01 +0200 | [diff] [blame] | 487 | mobile5_pm_init(dev); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 488 | |
| 489 | /* Set the state of the GPIO lines. */ |
| 490 | //gpio_init(dev); |
| 491 | |
| 492 | /* Initialize the real time clock. */ |
| 493 | pch_rtc_init(dev); |
| 494 | |
| 495 | /* Initialize ISA DMA. */ |
| 496 | isa_dma_init(); |
| 497 | |
| 498 | /* Initialize the High Precision Event Timers, if present. */ |
| 499 | enable_hpet(); |
| 500 | |
| 501 | /* Initialize Clock Gating */ |
| 502 | enable_clock_gating(dev); |
| 503 | |
| 504 | setup_i8259(); |
| 505 | |
| 506 | /* The OS should do this? */ |
| 507 | /* Interrupt 9 should be level triggered (SCI) */ |
| 508 | i8259_configure_irq_trigger(9, 1); |
| 509 | |
| 510 | pch_disable_smm_only_flashing(dev); |
| 511 | |
Vladimir Serbinenko | 456f495 | 2015-05-28 20:42:32 +0200 | [diff] [blame] | 512 | pch_set_acpi_mode(); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 513 | |
| 514 | pch_fixups(dev); |
| 515 | } |
| 516 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 517 | static void pch_lpc_read_resources(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 518 | { |
| 519 | struct resource *res; |
| 520 | config_t *config = dev->chip_info; |
| 521 | u8 io_index = 0; |
| 522 | |
| 523 | /* Get the normal PCI resources of this device. */ |
| 524 | pci_dev_read_resources(dev); |
| 525 | |
| 526 | /* Add an extra subtractive resource for both memory and I/O. */ |
| 527 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 528 | res->base = 0; |
| 529 | res->size = 0x1000; |
| 530 | res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | |
| 531 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 532 | |
| 533 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 534 | res->base = 0xff800000; |
| 535 | res->size = 0x00800000; /* 8 MB for flash */ |
| 536 | res->flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | |
| 537 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 538 | |
| 539 | res = new_resource(dev, 3); /* IOAPIC */ |
| 540 | res->base = IO_APIC_ADDR; |
| 541 | res->size = 0x00001000; |
| 542 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 543 | |
| 544 | /* Set PCH IO decode ranges if required.*/ |
| 545 | if ((config->gen1_dec & 0xFFFC) > 0x1000) { |
| 546 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 547 | res->base = config->gen1_dec & 0xFFFC; |
| 548 | res->size = (config->gen1_dec >> 16) & 0xFC; |
| 549 | res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | |
| 550 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 551 | } |
| 552 | |
| 553 | if ((config->gen2_dec & 0xFFFC) > 0x1000) { |
| 554 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 555 | res->base = config->gen2_dec & 0xFFFC; |
| 556 | res->size = (config->gen2_dec >> 16) & 0xFC; |
| 557 | res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | |
| 558 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 559 | } |
| 560 | |
| 561 | if ((config->gen3_dec & 0xFFFC) > 0x1000) { |
| 562 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 563 | res->base = config->gen3_dec & 0xFFFC; |
| 564 | res->size = (config->gen3_dec >> 16) & 0xFC; |
| 565 | res->flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | |
| 566 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 567 | } |
| 568 | |
| 569 | if ((config->gen4_dec & 0xFFFC) > 0x1000) { |
| 570 | res = new_resource(dev, IOINDEX_SUBTRACTIVE(io_index++, 0)); |
| 571 | res->base = config->gen4_dec & 0xFFFC; |
| 572 | res->size = (config->gen4_dec >> 16) & 0xFC; |
| 573 | res->flags = IORESOURCE_IO| IORESOURCE_SUBTRACTIVE | |
| 574 | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 575 | } |
| 576 | } |
| 577 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 578 | static void pch_lpc_enable(struct device *dev) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 579 | { |
| 580 | /* Enable PCH Display Port */ |
| 581 | RCBA16(DISPBDF) = 0x0010; |
| 582 | RCBA32_OR(FD2, PCH_ENABLE_DBDF); |
| 583 | |
| 584 | pch_enable(dev); |
| 585 | } |
| 586 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 587 | static void southbridge_inject_dsdt(struct device *dev) |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 588 | { |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 589 | global_nvs_t *gnvs = cbmem_add (CBMEM_ID_ACPI_GNVS, sizeof(*gnvs)); |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 590 | |
| 591 | if (gnvs) { |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 592 | const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info(); |
Elyes HAOUAS | 035df00 | 2016-10-03 21:54:16 +0200 | [diff] [blame] | 593 | memset(gnvs, 0, sizeof(*gnvs)); |
Vladimir Serbinenko | 7309c64 | 2014-10-05 11:07:33 +0200 | [diff] [blame] | 594 | |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 595 | acpi_create_gnvs(gnvs); |
Vladimir Serbinenko | 9d45d69 | 2014-10-20 19:16:44 +0200 | [diff] [blame] | 596 | |
| 597 | gnvs->apic = 1; |
| 598 | gnvs->mpen = 1; /* Enable Multi Processing */ |
| 599 | gnvs->pcnt = dev_count_cpu(); |
Nico Huber | 744d6bd | 2019-01-12 14:58:20 +0100 | [diff] [blame] | 600 | |
| 601 | if (gfx) { |
| 602 | gnvs->ndid = gfx->ndid; |
| 603 | memcpy(gnvs->did, gfx->did, sizeof(gnvs->did)); |
| 604 | } |
Vladimir Serbinenko | 9d45d69 | 2014-10-20 19:16:44 +0200 | [diff] [blame] | 605 | |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 606 | /* And tell SMI about it */ |
| 607 | smm_setup_structures(gnvs, NULL, NULL); |
| 608 | |
| 609 | /* Add it to SSDT. */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 610 | acpigen_write_scope("\\"); |
| 611 | acpigen_write_name_dword("NVSA", (u32) gnvs); |
| 612 | acpigen_pop_len(); |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 613 | } |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Vladimir Serbinenko | 67bfbfd | 2014-10-25 15:49:23 +0200 | [diff] [blame] | 616 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 617 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 618 | struct device *dev = pcidev_on_root(0x1f, 0); |
Vladimir Serbinenko | 67bfbfd | 2014-10-25 15:49:23 +0200 | [diff] [blame] | 619 | config_t *chip = dev->chip_info; |
| 620 | u16 pmbase = pci_read_config16(dev, 0x40) & 0xfffe; |
| 621 | int c2_latency; |
| 622 | |
Elyes HAOUAS | 0d4de2a | 2019-02-28 13:04:29 +0100 | [diff] [blame] | 623 | fadt->reserved = 0; |
Vladimir Serbinenko | 67bfbfd | 2014-10-25 15:49:23 +0200 | [diff] [blame] | 624 | |
| 625 | fadt->sci_int = 0x9; |
| 626 | fadt->smi_cmd = APM_CNT; |
| 627 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 628 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 629 | fadt->s4bios_req = 0x0; |
| 630 | fadt->pstate_cnt = 0; |
| 631 | |
| 632 | fadt->pm1a_evt_blk = pmbase; |
| 633 | fadt->pm1b_evt_blk = 0x0; |
| 634 | fadt->pm1a_cnt_blk = pmbase + 0x4; |
| 635 | fadt->pm1b_cnt_blk = 0x0; |
| 636 | fadt->pm2_cnt_blk = pmbase + 0x50; |
| 637 | fadt->pm_tmr_blk = pmbase + 0x8; |
| 638 | fadt->gpe0_blk = pmbase + 0x20; |
| 639 | fadt->gpe1_blk = 0; |
| 640 | |
| 641 | fadt->pm1_evt_len = 4; |
| 642 | fadt->pm1_cnt_len = 2; |
| 643 | fadt->pm2_cnt_len = 1; |
| 644 | fadt->pm_tmr_len = 4; |
| 645 | fadt->gpe0_blk_len = 16; |
| 646 | fadt->gpe1_blk_len = 0; |
| 647 | fadt->gpe1_base = 0; |
| 648 | fadt->cst_cnt = 0; |
| 649 | c2_latency = chip->c2_latency; |
| 650 | if (!c2_latency) { |
| 651 | c2_latency = 101; /* c2 unsupported */ |
| 652 | } |
| 653 | fadt->p_lvl2_lat = c2_latency; |
| 654 | fadt->p_lvl3_lat = 87; |
| 655 | fadt->flush_size = 1024; |
| 656 | fadt->flush_stride = 16; |
Patrick Rudolph | b30a47b | 2019-07-15 18:04:23 +0200 | [diff] [blame] | 657 | /* P_CNT not supported */ |
| 658 | fadt->duty_offset = 0; |
| 659 | fadt->duty_width = 0; |
| 660 | |
Vladimir Serbinenko | 67bfbfd | 2014-10-25 15:49:23 +0200 | [diff] [blame] | 661 | fadt->day_alrm = 0xd; |
| 662 | fadt->mon_alrm = 0x00; |
| 663 | fadt->century = 0x32; |
| 664 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; |
| 665 | |
| 666 | fadt->flags = ACPI_FADT_WBINVD | |
| 667 | ACPI_FADT_C1_SUPPORTED | |
| 668 | ACPI_FADT_SLEEP_BUTTON | |
| 669 | ACPI_FADT_RESET_REGISTER | |
| 670 | ACPI_FADT_S4_RTC_WAKE | |
| 671 | ACPI_FADT_PLATFORM_CLOCK; |
| 672 | if (chip->docking_supported) { |
| 673 | fadt->flags |= ACPI_FADT_DOCKING_SUPPORTED; |
| 674 | } |
| 675 | if (c2_latency < 100) { |
| 676 | fadt->flags |= ACPI_FADT_C2_MP_SUPPORTED; |
| 677 | } |
| 678 | |
| 679 | fadt->reset_reg.space_id = 1; |
| 680 | fadt->reset_reg.bit_width = 8; |
| 681 | fadt->reset_reg.bit_offset = 0; |
| 682 | fadt->reset_reg.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 683 | fadt->reset_reg.addrl = 0xcf9; |
| 684 | fadt->reset_reg.addrh = 0; |
| 685 | |
| 686 | fadt->reset_value = 6; |
| 687 | |
| 688 | fadt->x_pm1a_evt_blk.space_id = 1; |
| 689 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 690 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 691 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 692 | fadt->x_pm1a_evt_blk.addrl = pmbase; |
| 693 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 694 | |
| 695 | fadt->x_pm1b_evt_blk.space_id = 1; |
| 696 | fadt->x_pm1b_evt_blk.bit_width = 0; |
| 697 | fadt->x_pm1b_evt_blk.bit_offset = 0; |
| 698 | fadt->x_pm1b_evt_blk.access_size = 0; |
| 699 | fadt->x_pm1b_evt_blk.addrl = 0x0; |
| 700 | fadt->x_pm1b_evt_blk.addrh = 0x0; |
| 701 | |
| 702 | fadt->x_pm1a_cnt_blk.space_id = 1; |
| 703 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 704 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 705 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 706 | fadt->x_pm1a_cnt_blk.addrl = pmbase + 0x4; |
| 707 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 708 | |
| 709 | fadt->x_pm1b_cnt_blk.space_id = 1; |
| 710 | fadt->x_pm1b_cnt_blk.bit_width = 0; |
| 711 | fadt->x_pm1b_cnt_blk.bit_offset = 0; |
| 712 | fadt->x_pm1b_cnt_blk.access_size = 0; |
| 713 | fadt->x_pm1b_cnt_blk.addrl = 0x0; |
| 714 | fadt->x_pm1b_cnt_blk.addrh = 0x0; |
| 715 | |
| 716 | fadt->x_pm2_cnt_blk.space_id = 1; |
| 717 | fadt->x_pm2_cnt_blk.bit_width = 8; |
| 718 | fadt->x_pm2_cnt_blk.bit_offset = 0; |
| 719 | fadt->x_pm2_cnt_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 720 | fadt->x_pm2_cnt_blk.addrl = pmbase + 0x50; |
| 721 | fadt->x_pm2_cnt_blk.addrh = 0x0; |
| 722 | |
| 723 | fadt->x_pm_tmr_blk.space_id = 1; |
| 724 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 725 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 726 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 727 | fadt->x_pm_tmr_blk.addrl = pmbase + 0x8; |
| 728 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 729 | |
| 730 | fadt->x_gpe0_blk.space_id = 1; |
| 731 | fadt->x_gpe0_blk.bit_width = 128; |
| 732 | fadt->x_gpe0_blk.bit_offset = 0; |
| 733 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 734 | fadt->x_gpe0_blk.addrl = pmbase + 0x20; |
| 735 | fadt->x_gpe0_blk.addrh = 0x0; |
| 736 | |
| 737 | fadt->x_gpe1_blk.space_id = 1; |
| 738 | fadt->x_gpe1_blk.bit_width = 0; |
| 739 | fadt->x_gpe1_blk.bit_offset = 0; |
| 740 | fadt->x_gpe1_blk.access_size = 0; |
| 741 | fadt->x_gpe1_blk.addrl = 0x0; |
| 742 | fadt->x_gpe1_blk.addrh = 0x0; |
| 743 | } |
| 744 | |
Kyösti Mälkki | 9099395 | 2018-05-01 19:36:25 +0300 | [diff] [blame] | 745 | static const char *lpc_acpi_name(const struct device *dev) |
| 746 | { |
| 747 | return "LPCB"; |
| 748 | } |
| 749 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 750 | static void southbridge_fill_ssdt(struct device *device) |
Vladimir Serbinenko | 36fa5b8 | 2014-10-28 23:43:20 +0100 | [diff] [blame] | 751 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 752 | struct device *dev = pcidev_on_root(0x1f, 0); |
Vladimir Serbinenko | 36fa5b8 | 2014-10-28 23:43:20 +0100 | [diff] [blame] | 753 | config_t *chip = dev->chip_info; |
| 754 | |
| 755 | intel_acpi_pcie_hotplug_generator(chip->pcie_hotplug_map, 8); |
Kyösti Mälkki | 9099395 | 2018-05-01 19:36:25 +0300 | [diff] [blame] | 756 | intel_acpi_gen_def_acpi_pirq(dev); |
Vladimir Serbinenko | 36fa5b8 | 2014-10-28 23:43:20 +0100 | [diff] [blame] | 757 | } |
| 758 | |
Bill XIE | d533b16 | 2017-08-22 16:26:22 +0800 | [diff] [blame] | 759 | static void lpc_final(struct device *dev) |
| 760 | { |
Arthur Heymans | aadd1d0 | 2019-05-28 13:39:20 +0200 | [diff] [blame] | 761 | spi_finalize_ops(); |
| 762 | |
Bill XIE | d533b16 | 2017-08-22 16:26:22 +0800 | [diff] [blame] | 763 | /* Call SMM finalize() handlers before resume */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 764 | if (CONFIG(HAVE_SMI_HANDLER)) { |
| 765 | if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || |
Bill XIE | d533b16 | 2017-08-22 16:26:22 +0800 | [diff] [blame] | 766 | acpi_is_wakeup_s3()) { |
| 767 | outb(APM_CNT_FINALIZE, APM_CNT); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 772 | static struct pci_operations pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 773 | .set_subsystem = pci_dev_set_subsystem, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 774 | }; |
| 775 | |
| 776 | static struct device_operations device_ops = { |
| 777 | .read_resources = pch_lpc_read_resources, |
| 778 | .set_resources = pci_dev_set_resources, |
Arthur Heymans | 3b452e0 | 2019-10-03 09:16:10 +0200 | [diff] [blame] | 779 | .enable_resources = pci_dev_enable_resources, |
Vladimir Serbinenko | 334fd8e | 2014-10-05 11:10:35 +0200 | [diff] [blame] | 780 | .acpi_inject_dsdt_generator = southbridge_inject_dsdt, |
Vladimir Serbinenko | 36fa5b8 | 2014-10-28 23:43:20 +0100 | [diff] [blame] | 781 | .acpi_fill_ssdt_generator = southbridge_fill_ssdt, |
Kyösti Mälkki | 9099395 | 2018-05-01 19:36:25 +0300 | [diff] [blame] | 782 | .acpi_name = lpc_acpi_name, |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 783 | .write_acpi_tables = acpi_write_hpet, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 784 | .init = lpc_init, |
Bill XIE | d533b16 | 2017-08-22 16:26:22 +0800 | [diff] [blame] | 785 | .final = lpc_final, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 786 | .enable = pch_lpc_enable, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 787 | .scan_bus = scan_lpc_bus, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 788 | .ops_pci = &pci_ops, |
| 789 | }; |
| 790 | |
| 791 | |
Vladimir Serbinenko | b7d8788 | 2014-02-19 22:01:35 +0100 | [diff] [blame] | 792 | static const unsigned short pci_device_ids[] = { 0x3b07, 0x3b09, 0 }; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 793 | |
| 794 | static const struct pci_driver pch_lpc __pci_driver = { |
| 795 | .ops = &device_ops, |
| 796 | .vendor = PCI_VENDOR_ID_INTEL, |
| 797 | .devices = pci_device_ids, |
| 798 | }; |