Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 5 | * Copyright 2013 Google Inc. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 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. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #include <console/console.h> |
| 23 | #include <device/device.h> |
| 24 | #include <device/pci.h> |
| 25 | #include <device/pci_ids.h> |
| 26 | #include <pc80/mc146818rtc.h> |
| 27 | #include <pc80/isa-dma.h> |
| 28 | #include <pc80/i8259.h> |
| 29 | #include <arch/io.h> |
| 30 | #include <arch/ioapic.h> |
| 31 | #include <arch/acpi.h> |
| 32 | #include <cpu/cpu.h> |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 33 | #include <cpu/x86/smm.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 34 | #include <elog.h> |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 35 | #include <cbmem.h> |
| 36 | #include <string.h> |
| 37 | #include "nvs.h" |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 38 | #include "pch.h" |
| 39 | |
| 40 | #define NMI_OFF 0 |
| 41 | |
| 42 | #define ENABLE_ACPI_MODE_IN_COREBOOT 0 |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 43 | |
| 44 | typedef struct southbridge_intel_lynxpoint_config config_t; |
| 45 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 46 | /** |
| 47 | * Set miscellanous static southbridge features. |
| 48 | * |
| 49 | * @param dev PCI device with I/O APIC control registers |
| 50 | */ |
| 51 | static void pch_enable_ioapic(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 52 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 53 | u32 reg32; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 54 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 55 | /* Enable ACPI I/O range decode */ |
| 56 | pci_write_config8(dev, ACPI_CNTL, ACPI_EN); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 57 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 58 | set_ioapic_id(IO_APIC_ADDR, 0x02); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 59 | |
| 60 | /* affirm full set of redirection table entries ("write once") */ |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 61 | reg32 = io_apic_read(IO_APIC_ADDR, 0x01); |
Duncan Laurie | c593999 | 2013-05-24 11:06:49 -0700 | [diff] [blame] | 62 | if (pch_is_lp()) { |
| 63 | /* PCH-LP has 39 redirection entries */ |
| 64 | reg32 &= ~0x00ff0000; |
| 65 | reg32 |= 0x00270000; |
| 66 | } |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 67 | io_apic_write(IO_APIC_ADDR, 0x01, reg32); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 68 | |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 69 | /* |
| 70 | * Select Boot Configuration register (0x03) and |
| 71 | * use Processor System Bus (0x01) to deliver interrupts. |
| 72 | */ |
| 73 | io_apic_write(IO_APIC_ADDR, 0x03, 0x01); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void pch_enable_serial_irqs(struct device *dev) |
| 77 | { |
| 78 | /* Set packet length and toggle silent mode bit for one frame. */ |
| 79 | pci_write_config8(dev, SERIRQ_CNTL, |
| 80 | (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0)); |
| 81 | #if !CONFIG_SERIRQ_CONTINUOUS_MODE |
| 82 | pci_write_config8(dev, SERIRQ_CNTL, |
| 83 | (1 << 7) | (0 << 6) | ((21 - 17) << 2) | (0 << 0)); |
| 84 | #endif |
| 85 | } |
| 86 | |
| 87 | /* PIRQ[n]_ROUT[3:0] - PIRQ Routing Control |
| 88 | * 0x00 - 0000 = Reserved |
| 89 | * 0x01 - 0001 = Reserved |
| 90 | * 0x02 - 0010 = Reserved |
| 91 | * 0x03 - 0011 = IRQ3 |
| 92 | * 0x04 - 0100 = IRQ4 |
| 93 | * 0x05 - 0101 = IRQ5 |
| 94 | * 0x06 - 0110 = IRQ6 |
| 95 | * 0x07 - 0111 = IRQ7 |
| 96 | * 0x08 - 1000 = Reserved |
| 97 | * 0x09 - 1001 = IRQ9 |
| 98 | * 0x0A - 1010 = IRQ10 |
| 99 | * 0x0B - 1011 = IRQ11 |
| 100 | * 0x0C - 1100 = IRQ12 |
| 101 | * 0x0D - 1101 = Reserved |
| 102 | * 0x0E - 1110 = IRQ14 |
| 103 | * 0x0F - 1111 = IRQ15 |
| 104 | * PIRQ[n]_ROUT[7] - PIRQ Routing Control |
| 105 | * 0x80 - The PIRQ is not routed. |
| 106 | */ |
| 107 | |
| 108 | static void pch_pirq_init(device_t dev) |
| 109 | { |
| 110 | device_t irq_dev; |
| 111 | /* Get the chip configuration */ |
| 112 | config_t *config = dev->chip_info; |
| 113 | |
| 114 | pci_write_config8(dev, PIRQA_ROUT, config->pirqa_routing); |
| 115 | pci_write_config8(dev, PIRQB_ROUT, config->pirqb_routing); |
| 116 | pci_write_config8(dev, PIRQC_ROUT, config->pirqc_routing); |
| 117 | pci_write_config8(dev, PIRQD_ROUT, config->pirqd_routing); |
| 118 | |
| 119 | pci_write_config8(dev, PIRQE_ROUT, config->pirqe_routing); |
| 120 | pci_write_config8(dev, PIRQF_ROUT, config->pirqf_routing); |
| 121 | pci_write_config8(dev, PIRQG_ROUT, config->pirqg_routing); |
| 122 | pci_write_config8(dev, PIRQH_ROUT, config->pirqh_routing); |
| 123 | |
| 124 | /* Eric Biederman once said we should let the OS do this. |
| 125 | * I am not so sure anymore he was right. |
| 126 | */ |
| 127 | |
| 128 | for(irq_dev = all_devices; irq_dev; irq_dev = irq_dev->next) { |
| 129 | u8 int_pin=0, int_line=0; |
| 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 | |
| 136 | switch (int_pin) { |
| 137 | case 1: /* INTA# */ int_line = config->pirqa_routing; break; |
| 138 | case 2: /* INTB# */ int_line = config->pirqb_routing; break; |
| 139 | case 3: /* INTC# */ int_line = config->pirqc_routing; break; |
| 140 | case 4: /* INTD# */ int_line = config->pirqd_routing; break; |
| 141 | } |
| 142 | |
| 143 | if (!int_line) |
| 144 | continue; |
| 145 | |
| 146 | pci_write_config8(irq_dev, PCI_INTERRUPT_LINE, int_line); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | static void pch_gpi_routing(device_t dev) |
| 151 | { |
| 152 | /* Get the chip configuration */ |
| 153 | config_t *config = dev->chip_info; |
| 154 | u32 reg32 = 0; |
| 155 | |
| 156 | /* An array would be much nicer here, or some |
| 157 | * other method of doing this. |
| 158 | */ |
| 159 | reg32 |= (config->gpi0_routing & 0x03) << 0; |
| 160 | reg32 |= (config->gpi1_routing & 0x03) << 2; |
| 161 | reg32 |= (config->gpi2_routing & 0x03) << 4; |
| 162 | reg32 |= (config->gpi3_routing & 0x03) << 6; |
| 163 | reg32 |= (config->gpi4_routing & 0x03) << 8; |
| 164 | reg32 |= (config->gpi5_routing & 0x03) << 10; |
| 165 | reg32 |= (config->gpi6_routing & 0x03) << 12; |
| 166 | reg32 |= (config->gpi7_routing & 0x03) << 14; |
| 167 | reg32 |= (config->gpi8_routing & 0x03) << 16; |
| 168 | reg32 |= (config->gpi9_routing & 0x03) << 18; |
| 169 | reg32 |= (config->gpi10_routing & 0x03) << 20; |
| 170 | reg32 |= (config->gpi11_routing & 0x03) << 22; |
| 171 | reg32 |= (config->gpi12_routing & 0x03) << 24; |
| 172 | reg32 |= (config->gpi13_routing & 0x03) << 26; |
| 173 | reg32 |= (config->gpi14_routing & 0x03) << 28; |
| 174 | reg32 |= (config->gpi15_routing & 0x03) << 30; |
| 175 | |
| 176 | pci_write_config32(dev, 0xb8, reg32); |
| 177 | } |
| 178 | |
| 179 | static void pch_power_options(device_t dev) |
| 180 | { |
| 181 | u8 reg8; |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 182 | u16 reg16; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 183 | u32 reg32; |
| 184 | const char *state; |
| 185 | /* Get the chip configuration */ |
| 186 | config_t *config = dev->chip_info; |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 187 | u16 pmbase = get_pmbase(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 188 | int pwr_on=CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL; |
| 189 | int nmi_option; |
| 190 | |
| 191 | /* Which state do we want to goto after g3 (power restored)? |
| 192 | * 0 == S0 Full On |
| 193 | * 1 == S5 Soft Off |
| 194 | * |
| 195 | * If the option is not existent (Laptops), use Kconfig setting. |
| 196 | */ |
| 197 | get_option(&pwr_on, "power_on_after_fail"); |
| 198 | |
| 199 | reg16 = pci_read_config16(dev, GEN_PMCON_3); |
| 200 | reg16 &= 0xfffe; |
| 201 | switch (pwr_on) { |
| 202 | case MAINBOARD_POWER_OFF: |
| 203 | reg16 |= 1; |
| 204 | state = "off"; |
| 205 | break; |
| 206 | case MAINBOARD_POWER_ON: |
| 207 | reg16 &= ~1; |
| 208 | state = "on"; |
| 209 | break; |
| 210 | case MAINBOARD_POWER_KEEP: |
| 211 | reg16 &= ~1; |
| 212 | state = "state keep"; |
| 213 | break; |
| 214 | default: |
| 215 | state = "undefined"; |
| 216 | } |
| 217 | |
| 218 | reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */ |
| 219 | reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */ |
| 220 | |
| 221 | reg16 &= ~(1 << 10); |
| 222 | reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */ |
| 223 | |
| 224 | reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */ |
| 225 | |
| 226 | pci_write_config16(dev, GEN_PMCON_3, reg16); |
| 227 | printk(BIOS_INFO, "Set power %s after power failure.\n", state); |
| 228 | |
| 229 | /* Set up NMI on errors. */ |
| 230 | reg8 = inb(0x61); |
| 231 | reg8 &= 0x0f; /* Higher Nibble must be 0 */ |
| 232 | reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */ |
| 233 | // reg8 &= ~(1 << 2); /* PCI SERR# Enable */ |
| 234 | reg8 |= (1 << 2); /* PCI SERR# Disable for now */ |
| 235 | outb(reg8, 0x61); |
| 236 | |
| 237 | reg8 = inb(0x70); |
| 238 | nmi_option = NMI_OFF; |
| 239 | get_option(&nmi_option, "nmi"); |
| 240 | if (nmi_option) { |
| 241 | printk(BIOS_INFO, "NMI sources enabled.\n"); |
| 242 | reg8 &= ~(1 << 7); /* Set NMI. */ |
| 243 | } else { |
| 244 | printk(BIOS_INFO, "NMI sources disabled.\n"); |
| 245 | reg8 |= ( 1 << 7); /* Can't mask NMI from PCI-E and NMI_NOW */ |
| 246 | } |
| 247 | outb(reg8, 0x70); |
| 248 | |
| 249 | /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */ |
| 250 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 251 | reg16 &= ~(3 << 0); // SMI# rate 1 minute |
| 252 | reg16 &= ~(1 << 10); // Disable BIOS_PCI_EXP_EN for native PME |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 253 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 254 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 255 | /* |
| 256 | * Set the board's GPI routing on LynxPoint-H. |
| 257 | * This is done as part of GPIO configuration on LynxPoint-LP. |
| 258 | */ |
| 259 | if (pch_is_lp()) |
| 260 | pch_gpi_routing(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 261 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 262 | /* GPE setup based on device tree configuration */ |
| 263 | enable_all_gpe(config->gpe0_en_1, config->gpe0_en_2, |
| 264 | config->gpe0_en_3, config->gpe0_en_4); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 265 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 266 | /* SMI setup based on device tree configuration */ |
| 267 | enable_alt_smi(config->alt_gp_smi_en); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 268 | |
| 269 | /* Set up power management block and determine sleep mode */ |
| 270 | reg32 = inl(pmbase + 0x04); // PM1_CNT |
| 271 | reg32 &= ~(7 << 10); // SLP_TYP |
| 272 | reg32 |= (1 << 0); // SCI_EN |
| 273 | outl(reg32, pmbase + 0x04); |
| 274 | |
| 275 | /* Clear magic status bits to prevent unexpected wake */ |
| 276 | reg32 = RCBA32(0x3310); |
| 277 | reg32 |= (1 << 4)|(1 << 5)|(1 << 0); |
| 278 | RCBA32(0x3310) = reg32; |
| 279 | |
| 280 | reg32 = RCBA32(0x3f02); |
| 281 | reg32 &= ~0xf; |
| 282 | RCBA32(0x3f02) = reg32; |
| 283 | } |
| 284 | |
| 285 | static void pch_rtc_init(struct device *dev) |
| 286 | { |
| 287 | u8 reg8; |
| 288 | int rtc_failed; |
| 289 | |
| 290 | reg8 = pci_read_config8(dev, GEN_PMCON_3); |
| 291 | rtc_failed = reg8 & RTC_BATTERY_DEAD; |
| 292 | if (rtc_failed) { |
| 293 | reg8 &= ~RTC_BATTERY_DEAD; |
| 294 | pci_write_config8(dev, GEN_PMCON_3, reg8); |
| 295 | #if CONFIG_ELOG |
| 296 | elog_add_event(ELOG_TYPE_RTC_RESET); |
| 297 | #endif |
| 298 | } |
| 299 | printk(BIOS_DEBUG, "rtc_failed = 0x%x\n", rtc_failed); |
| 300 | |
| 301 | rtc_init(rtc_failed); |
| 302 | } |
| 303 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 304 | /* LynxPoint PCH Power Management init */ |
| 305 | static void lpt_pm_init(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 306 | { |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 307 | printk(BIOS_DEBUG, "LynxPoint PM init\n"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 308 | } |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 309 | |
| 310 | const struct rcba_config_instruction lpt_lp_pm_rcba[] = { |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame^] | 311 | RCBA_RMW_REG_32(0x232c, ~1, 0x00000000), |
| 312 | RCBA_RMW_REG_32(0x1100, ~0xc000, 0xc000), |
| 313 | RCBA_RMW_REG_32(0x1100, ~0, 0x00000100), |
| 314 | RCBA_RMW_REG_32(0x1100, ~0, 0x0000003f), |
| 315 | RCBA_RMW_REG_32(0x2320, ~0x60, 0x10), |
| 316 | RCBA_RMW_REG_32(0x3314, 0, 0x00012fff), |
| 317 | RCBA_RMW_REG_32(0x3318, 0, 0x0dcf0400), |
| 318 | RCBA_RMW_REG_32(0x3324, 0, 0x04000000), |
| 319 | RCBA_RMW_REG_32(0x3368, 0, 0x00041400), |
| 320 | RCBA_RMW_REG_32(0x3388, 0, 0x3f8ddbff), |
| 321 | RCBA_RMW_REG_32(0x33ac, 0, 0x00007001), |
| 322 | RCBA_RMW_REG_32(0x33b0, 0, 0x00181900), |
| 323 | RCBA_RMW_REG_32(0x33c0, 0, 0x00060A00), |
| 324 | RCBA_RMW_REG_32(0x33d0, 0, 0x06200840), |
| 325 | RCBA_RMW_REG_32(0x3a28, 0, 0x01010101), |
| 326 | RCBA_RMW_REG_32(0x3a2c, 0, 0x04040404), |
| 327 | RCBA_RMW_REG_32(0x2b1c, 0, 0x03808033), |
| 328 | RCBA_RMW_REG_32(0x2b34, 0, 0x80000009), |
| 329 | RCBA_RMW_REG_32(0x3348, 0, 0x022ddfff), |
| 330 | RCBA_RMW_REG_32(0x334c, 0, 0x00000001), |
| 331 | RCBA_RMW_REG_32(0x3358, 0, 0x0001c000), |
| 332 | RCBA_RMW_REG_32(0x3380, 0, 0x3f8ddbff), |
| 333 | RCBA_RMW_REG_32(0x3384, 0, 0x0001c7e1), |
| 334 | RCBA_RMW_REG_32(0x338c, 0, 0x0001c7e1), |
| 335 | RCBA_RMW_REG_32(0x3398, 0, 0x0001c000), |
| 336 | RCBA_RMW_REG_32(0x33a8, 0, 0x00181900), |
| 337 | RCBA_RMW_REG_32(0x33dc, 0, 0x00080000), |
| 338 | RCBA_RMW_REG_32(0x33e0, 0, 0x00000001), |
| 339 | RCBA_RMW_REG_32(0x3a20, 0, 0x00000404), |
| 340 | RCBA_RMW_REG_32(0x3a24, 0, 0x01010101), |
| 341 | RCBA_RMW_REG_32(0x3a30, 0, 0x01010101), |
| 342 | RCBA_RMW_REG_32(0x0410, ~0, 0x00000003), |
| 343 | RCBA_RMW_REG_32(0x2618, ~0, 0x08000000), |
| 344 | RCBA_RMW_REG_32(0x2300, ~0, 0x00000002), |
| 345 | RCBA_RMW_REG_32(0x2600, ~0, 0x00000008), |
| 346 | RCBA_RMW_REG_32(0x33b4, 0, 0x00007001), |
| 347 | RCBA_RMW_REG_32(0x3350, 0, 0x022ddfff), |
| 348 | RCBA_RMW_REG_32(0x3354, 0, 0x00000001), |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 349 | RCBA_RMW_REG_32(0x33d4, ~0, 0x08000000), /* Power Optimizer */ |
| 350 | RCBA_RMW_REG_32(0x33c8, ~0, 0x08000080), /* Power Optimizer */ |
| 351 | RCBA_RMW_REG_32(0x2b10, 0, 0x0000883c), /* Power Optimizer */ |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 352 | RCBA_RMW_REG_32(0x2b14, 0, 0x1e0a4616), /* Power Optimizer */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 353 | RCBA_RMW_REG_32(0x2b24, 0, 0x40000005), /* Power Optimizer */ |
| 354 | RCBA_RMW_REG_32(0x2b20, 0, 0x0005db01), /* Power Optimizer */ |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame^] | 355 | RCBA_RMW_REG_32(0x3a80, 0, 0x05145005), |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 356 | RCBA_END_CONFIG |
| 357 | }; |
| 358 | |
| 359 | /* LynxPoint LP PCH Power Management init */ |
| 360 | static void lpt_lp_pm_init(struct device *dev) |
| 361 | { |
| 362 | struct southbridge_intel_lynxpoint_config *config = dev->chip_info; |
| 363 | u32 data; |
| 364 | |
| 365 | printk(BIOS_DEBUG, "LynxPoint LP PM init\n"); |
| 366 | |
| 367 | pci_write_config8(dev, 0xa9, 0x46); |
| 368 | |
| 369 | pch_config_rcba(lpt_lp_pm_rcba); |
| 370 | |
| 371 | pci_write_config32(dev, 0xac, |
| 372 | pci_read_config32(dev, 0xac) | (1 << 21)); |
| 373 | |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame^] | 374 | pch_iobp_update(0xED00015C, ~(1<<11), 0x00003700); |
| 375 | pch_iobp_update(0xED000118, ~0UL, 0x00c00000); |
| 376 | pch_iobp_update(0xED000120, ~0UL, 0x00240000); |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 377 | pch_iobp_update(0xCA000000, ~0UL, 0x00000009); |
| 378 | |
| 379 | /* Set RCBA CIR28 0x3A84 based on SATA port enables */ |
| 380 | data = 0x00001005; |
| 381 | /* Port 3 and 2 disabled */ |
| 382 | if ((config->sata_port_map & ((1 << 3)|(1 << 2))) == 0) |
| 383 | data |= (1 << 24) | (1 << 26); |
| 384 | /* Port 1 and 0 disabled */ |
| 385 | if ((config->sata_port_map & ((1 << 1)|(1 << 0))) == 0) |
| 386 | data |= (1 << 20) | (1 << 18); |
| 387 | RCBA32(0x3a84) = data; |
| 388 | |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 389 | /* Set RCBA 0x2b1c[29]=1 if DSP disabled */ |
| 390 | if (RCBA32(FD) & PCH_DISABLE_ADSPD) |
| 391 | RCBA32_OR(0x2b1c, (1 << 29)); |
| 392 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 393 | /* Lock */ |
| 394 | RCBA32_OR(0x3a6c, 0x00000001); |
| 395 | |
| 396 | /* Set RCBA 0x33D4 after other setup */ |
| 397 | RCBA32_OR(0x33d4, 0x2fff2fb1); |
| 398 | |
| 399 | /* Set RCBA 0x33C8[15]=1 as last step */ |
| 400 | RCBA32_OR(0x33c8, (1 << 15)); |
| 401 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 402 | |
| 403 | static void enable_hpet(void) |
| 404 | { |
| 405 | u32 reg32; |
| 406 | |
| 407 | /* Move HPET to default address 0xfed00000 and enable it */ |
| 408 | reg32 = RCBA32(HPTC); |
| 409 | reg32 |= (1 << 7); // HPET Address Enable |
| 410 | reg32 &= ~(3 << 0); |
| 411 | RCBA32(HPTC) = reg32; |
| 412 | /* Read it back to stick. It's affected by posted write syndrome. */ |
| 413 | reg32 = RCBA32(HPTC); |
| 414 | } |
| 415 | |
| 416 | static void enable_clock_gating(device_t dev) |
| 417 | { |
Duncan Laurie | 74c0d05 | 2012-12-17 11:31:40 -0800 | [diff] [blame] | 418 | /* LynxPoint Mobile */ |
| 419 | u32 reg32; |
| 420 | u16 reg16; |
| 421 | |
| 422 | /* DMI */ |
| 423 | RCBA32_AND_OR(0x2234, ~0UL, 0xf); |
| 424 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 425 | reg16 |= (1 << 11) | (1 << 12) | (1 << 14); |
| 426 | reg16 |= (1 << 2); // PCI CLKRUN# Enable |
| 427 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 428 | RCBA32_OR(0x900, (1 << 14)); |
| 429 | |
| 430 | reg32 = RCBA32(CG); |
| 431 | reg32 |= (1 << 22); // HDA Dynamic |
| 432 | reg32 |= (1 << 31); // LPC Dynamic |
| 433 | reg32 |= (1 << 16); // PCIe Dynamic |
| 434 | reg32 |= (1 << 27); // HPET Dynamic |
| 435 | reg32 |= (1 << 28); // GPIO Dynamic |
| 436 | RCBA32(CG) = reg32; |
| 437 | |
| 438 | RCBA32_OR(0x38c0, 0x7); // SPI Dynamic |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | static void enable_lp_clock_gating(device_t dev) |
| 442 | { |
| 443 | /* LynxPoint LP */ |
| 444 | u32 reg32; |
| 445 | u16 reg16; |
| 446 | |
| 447 | /* DMI */ |
| 448 | RCBA32_AND_OR(0x2234, ~0UL, 0xf); |
| 449 | reg16 = pci_read_config16(dev, GEN_PMCON_1); |
| 450 | reg16 &= ~((1 << 11) | (1 << 14)); |
| 451 | reg16 |= (1 << 5) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 13); |
| 452 | reg16 |= (1 << 2); // PCI CLKRUN# Enable |
| 453 | pci_write_config16(dev, GEN_PMCON_1, reg16); |
| 454 | |
| 455 | reg32 = pci_read_config32(dev, 0x64); |
| 456 | reg32 |= (1 << 6); |
| 457 | pci_write_config32(dev, 0x64, reg32); |
| 458 | |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame^] | 459 | /* |
| 460 | * RCBA + 0x2614[27:25,14:13,10,8] = 101,11,1,1 |
| 461 | * RCBA + 0x2614[23:16] = 0x20 |
| 462 | * RCBA + 0x2614[30:28] = 0x0 |
| 463 | * RCBA + 0x2614[26] = 1 (IF B2 STEP && 0:31.0@0xFA > 4) |
| 464 | */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 465 | RCBA32_AND_OR(0x2614, 0x8bffffff, 0x0a206500); |
Duncan Laurie | 4bc107b | 2013-06-24 13:14:44 -0700 | [diff] [blame^] | 466 | |
| 467 | /* Check for LPT-LP B2 stepping and 0:31.0@0xFA > 4 */ |
| 468 | if (pch_silicon_revision() >= LPT_LP_STEP_B2 && |
| 469 | pci_read_config8(dev, 0xfa) > 4) |
| 470 | RCBA32_OR(0x2614, (1<<26)); |
| 471 | |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 472 | RCBA32_OR(0x900, 0x0000031f); |
| 473 | |
| 474 | reg32 = RCBA32(CG); |
Duncan Laurie | a2d6a40 | 2013-03-22 11:24:45 -0700 | [diff] [blame] | 475 | if (RCBA32(0x3454) & (1 << 4)) |
| 476 | reg32 &= ~(1 << 29); // LPC Dynamic |
| 477 | else |
| 478 | reg32 |= (1 << 29); // LPC Dynamic |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 479 | reg32 |= (1 << 31); // LP LPC |
| 480 | reg32 |= (1 << 30); // LP BLA |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 481 | reg32 |= (1 << 28); // GPIO Dynamic |
| 482 | reg32 |= (1 << 27); // HPET Dynamic |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 483 | reg32 |= (1 << 26); // Generic Platform Event Clock |
| 484 | if (RCBA32(BUC) & PCH_DISABLE_GBE) |
| 485 | reg32 |= (1 << 23); // GbE Static |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 486 | reg32 |= (1 << 22); // HDA Dynamic |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 487 | reg32 |= (1 << 16); // PCI Dynamic |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 488 | RCBA32(CG) = reg32; |
| 489 | |
| 490 | RCBA32_OR(0x3434, 0x7); // LP LPC |
| 491 | |
| 492 | RCBA32_AND_OR(0x333c, 0xffcfffff, 0x00c00000); // SATA |
| 493 | |
| 494 | RCBA32_OR(0x38c0, 0x3c07); // SPI Dynamic |
| 495 | |
| 496 | pch_iobp_update(0xCF000000, ~0UL, 0x00007001); |
Duncan Laurie | 5cf34ce | 2013-04-26 10:41:33 -0700 | [diff] [blame] | 497 | 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] | 498 | } |
| 499 | |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 500 | static void pch_set_acpi_mode(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 501 | { |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 502 | #if CONFIG_HAVE_SMI_HANDLER |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 503 | if (acpi_slp_type != 3) { |
| 504 | #if ENABLE_ACPI_MODE_IN_COREBOOT |
| 505 | printk(BIOS_DEBUG, "Enabling ACPI via APMC:\n"); |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 506 | outb(APM_CNT_ACPI_ENABLE, APM_CNT); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 507 | printk(BIOS_DEBUG, "done.\n"); |
| 508 | #else |
| 509 | printk(BIOS_DEBUG, "Disabling ACPI via APMC:\n"); |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 510 | outb(APM_CNT_ACPI_DISABLE, APM_CNT); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 511 | printk(BIOS_DEBUG, "done.\n"); |
| 512 | #endif |
| 513 | } |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 514 | #endif /* CONFIG_HAVE_SMI_HANDLER */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 515 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 516 | |
| 517 | static void pch_disable_smm_only_flashing(struct device *dev) |
| 518 | { |
| 519 | u8 reg8; |
| 520 | |
| 521 | printk(BIOS_SPEW, "Enabling BIOS updates outside of SMM... "); |
| 522 | reg8 = pci_read_config8(dev, 0xdc); /* BIOS_CNTL */ |
| 523 | reg8 &= ~(1 << 5); |
| 524 | pci_write_config8(dev, 0xdc, reg8); |
| 525 | } |
| 526 | |
| 527 | static void pch_fixups(struct device *dev) |
| 528 | { |
| 529 | u8 gen_pmcon_2; |
| 530 | |
| 531 | /* Indicate DRAM init done for MRC S3 to know it can resume */ |
| 532 | gen_pmcon_2 = pci_read_config8(dev, GEN_PMCON_2); |
| 533 | gen_pmcon_2 |= (1 << 7); |
| 534 | pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2); |
| 535 | |
| 536 | /* |
| 537 | * Enable DMI ASPM in the PCH |
| 538 | */ |
| 539 | RCBA32_AND_OR(0x2304, ~(1 << 10), 0); |
| 540 | RCBA32_OR(0x21a4, (1 << 11)|(1 << 10)); |
| 541 | RCBA32_OR(0x21a8, 0x3); |
| 542 | } |
| 543 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 544 | static void lpc_init(struct device *dev) |
| 545 | { |
| 546 | printk(BIOS_DEBUG, "pch: lpc_init\n"); |
| 547 | |
| 548 | /* Set the value for PCI command register. */ |
| 549 | pci_write_config16(dev, PCI_COMMAND, 0x000f); |
| 550 | |
| 551 | /* IO APIC initialization. */ |
Paul Menzel | 373a20c | 2013-05-03 12:17:02 +0200 | [diff] [blame] | 552 | pch_enable_ioapic(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 553 | |
| 554 | pch_enable_serial_irqs(dev); |
| 555 | |
| 556 | /* Setup the PIRQ. */ |
| 557 | pch_pirq_init(dev); |
| 558 | |
| 559 | /* Setup power options. */ |
| 560 | pch_power_options(dev); |
| 561 | |
| 562 | /* Initialize power management */ |
Duncan Laurie | deb90f4 | 2013-03-08 17:22:37 -0800 | [diff] [blame] | 563 | if (pch_is_lp()) { |
| 564 | lpt_lp_pm_init(dev); |
| 565 | enable_lp_clock_gating(dev); |
| 566 | } else { |
| 567 | lpt_pm_init(dev); |
| 568 | enable_clock_gating(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 569 | } |
| 570 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 571 | /* Initialize the real time clock. */ |
| 572 | pch_rtc_init(dev); |
| 573 | |
| 574 | /* Initialize ISA DMA. */ |
| 575 | isa_dma_init(); |
| 576 | |
| 577 | /* Initialize the High Precision Event Timers, if present. */ |
| 578 | enable_hpet(); |
| 579 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 580 | setup_i8259(); |
| 581 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 582 | /* Interrupt 9 should be level triggered (SCI) */ |
| 583 | i8259_configure_irq_trigger(9, 1); |
| 584 | |
| 585 | pch_disable_smm_only_flashing(dev); |
| 586 | |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 587 | pch_set_acpi_mode(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 588 | |
| 589 | pch_fixups(dev); |
| 590 | } |
| 591 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 592 | static void pch_lpc_add_mmio_resources(device_t dev) |
| 593 | { |
| 594 | u32 reg; |
| 595 | struct resource *res; |
| 596 | const u32 default_decode_base = IO_APIC_ADDR; |
| 597 | |
| 598 | /* |
| 599 | * Just report all resources from IO-APIC base to 4GiB. Don't mark |
| 600 | * them reserved as that may upset the OS if this range is marked |
| 601 | * as reserved in the e820. |
| 602 | */ |
| 603 | res = new_resource(dev, OIC); |
| 604 | res->base = default_decode_base; |
| 605 | res->size = 0 - default_decode_base; |
| 606 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 607 | |
| 608 | /* RCBA */ |
| 609 | if (DEFAULT_RCBA < default_decode_base) { |
| 610 | res = new_resource(dev, RCBA); |
| 611 | res->base = DEFAULT_RCBA; |
| 612 | res->size = 16 * 1024; |
| 613 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 614 | IORESOURCE_FIXED | IORESOURCE_RESERVE; |
| 615 | } |
| 616 | |
| 617 | /* Check LPC Memory Decode register. */ |
| 618 | reg = pci_read_config32(dev, LGMR); |
| 619 | if (reg & 1) { |
| 620 | reg &= ~0xffff; |
| 621 | if (reg < default_decode_base) { |
| 622 | res = new_resource(dev, LGMR); |
| 623 | res->base = reg; |
| 624 | res->size = 16 * 1024; |
| 625 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 626 | IORESOURCE_FIXED | IORESOURCE_RESERVE; |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /* Default IO range claimed by the LPC device. The upper bound is exclusive. */ |
| 632 | #define LPC_DEFAULT_IO_RANGE_LOWER 0 |
| 633 | #define LPC_DEFAULT_IO_RANGE_UPPER 0x1000 |
| 634 | |
| 635 | static inline int pch_io_range_in_default(u16 base, u16 size) |
| 636 | { |
| 637 | /* Does it start above the range? */ |
| 638 | if (base >= LPC_DEFAULT_IO_RANGE_UPPER) |
| 639 | return 0; |
| 640 | |
| 641 | /* Is it entirely contained? */ |
| 642 | if (base >= LPC_DEFAULT_IO_RANGE_LOWER && |
| 643 | (base + size) < LPC_DEFAULT_IO_RANGE_UPPER) |
| 644 | return 1; |
| 645 | |
| 646 | /* This will return not in range for partial overlaps. */ |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | /* |
| 651 | * Note: this function assumes there is no overlap with the default LPC device's |
| 652 | * claimed range: LPC_DEFAULT_IO_RANGE_LOWER -> LPC_DEFAULT_IO_RANGE_UPPER. |
| 653 | */ |
| 654 | static void pch_lpc_add_io_resource(device_t dev, u16 base, u16 size, int index) |
| 655 | { |
| 656 | struct resource *res; |
| 657 | |
| 658 | if (pch_io_range_in_default(base, size)) |
| 659 | return; |
| 660 | |
| 661 | res = new_resource(dev, index); |
| 662 | res->base = base; |
| 663 | res->size = size; |
| 664 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 665 | } |
| 666 | |
| 667 | static void pch_lpc_add_gen_io_resources(device_t dev, int reg_value, int index) |
| 668 | { |
| 669 | /* |
| 670 | * Check if the register is enabled. If so and the base exceeds the |
| 671 | * device's deafult claim range add the resoure. |
| 672 | */ |
| 673 | if (reg_value & 1) { |
| 674 | u16 base = reg_value & 0xfffc; |
| 675 | u16 size = (0x3 | ((reg_value >> 16) & 0xfc)) + 1; |
| 676 | pch_lpc_add_io_resource(dev, base, size, index); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | static void pch_lpc_add_io_resources(device_t dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 681 | { |
| 682 | struct resource *res; |
| 683 | config_t *config = dev->chip_info; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 684 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 685 | /* Add the default claimed IO range for the LPC device. */ |
| 686 | res = new_resource(dev, 0); |
| 687 | res->base = LPC_DEFAULT_IO_RANGE_LOWER; |
| 688 | res->size = LPC_DEFAULT_IO_RANGE_UPPER - LPC_DEFAULT_IO_RANGE_LOWER; |
| 689 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 690 | |
| 691 | /* GPIOBASE */ |
Duncan Laurie | 7922b46 | 2013-03-08 16:34:33 -0800 | [diff] [blame] | 692 | pch_lpc_add_io_resource(dev, get_gpiobase(), DEFAULT_GPIOSIZE, |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 693 | GPIO_BASE); |
| 694 | |
| 695 | /* PMBASE */ |
Duncan Laurie | 7922b46 | 2013-03-08 16:34:33 -0800 | [diff] [blame] | 696 | pch_lpc_add_io_resource(dev, get_pmbase(), 256, PMBASE); |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 697 | |
| 698 | /* LPC Generic IO Decode range. */ |
| 699 | pch_lpc_add_gen_io_resources(dev, config->gen1_dec, LPC_GEN1_DEC); |
| 700 | pch_lpc_add_gen_io_resources(dev, config->gen2_dec, LPC_GEN2_DEC); |
| 701 | pch_lpc_add_gen_io_resources(dev, config->gen3_dec, LPC_GEN3_DEC); |
| 702 | pch_lpc_add_gen_io_resources(dev, config->gen4_dec, LPC_GEN4_DEC); |
| 703 | } |
| 704 | |
| 705 | static void pch_lpc_read_resources(device_t dev) |
| 706 | { |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 707 | global_nvs_t *gnvs; |
| 708 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 709 | /* Get the normal PCI resources of this device. */ |
| 710 | pci_dev_read_resources(dev); |
| 711 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 712 | /* Add non-standard MMIO resources. */ |
| 713 | pch_lpc_add_mmio_resources(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 714 | |
Aaron Durbin | 6f561af | 2012-12-19 14:38:01 -0600 | [diff] [blame] | 715 | /* Add IO resources. */ |
| 716 | pch_lpc_add_io_resources(dev); |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 717 | |
| 718 | /* Allocate ACPI NVS in CBMEM */ |
| 719 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(global_nvs_t)); |
Duncan Laurie | a522cf0 | 2013-05-29 07:49:55 -0700 | [diff] [blame] | 720 | if (acpi_slp_type != 3 && gnvs) |
Duncan Laurie | 9c07c8f | 2013-03-22 11:08:39 -0700 | [diff] [blame] | 721 | memset(gnvs, 0, sizeof(global_nvs_t)); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 722 | } |
| 723 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 724 | static void pch_lpc_enable(device_t dev) |
| 725 | { |
| 726 | /* Enable PCH Display Port */ |
| 727 | RCBA16(DISPBDF) = 0x0010; |
| 728 | RCBA32_OR(FD2, PCH_ENABLE_DBDF); |
| 729 | |
| 730 | pch_enable(dev); |
| 731 | } |
| 732 | |
| 733 | static void set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 734 | { |
| 735 | if (!vendor || !device) { |
| 736 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 737 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 738 | } else { |
| 739 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 740 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | static struct pci_operations pci_ops = { |
| 745 | .set_subsystem = set_subsystem, |
| 746 | }; |
| 747 | |
| 748 | static struct device_operations device_ops = { |
| 749 | .read_resources = pch_lpc_read_resources, |
| 750 | .set_resources = pci_dev_set_resources, |
Duncan Laurie | 8d783b8 | 2013-05-14 11:16:34 -0700 | [diff] [blame] | 751 | .enable_resources = pci_dev_enable_resources, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 752 | .init = lpc_init, |
| 753 | .enable = pch_lpc_enable, |
| 754 | .scan_bus = scan_static_bus, |
| 755 | .ops_pci = &pci_ops, |
| 756 | }; |
| 757 | |
| 758 | |
Aaron Durbin | c1989c4 | 2012-12-11 17:13:17 -0600 | [diff] [blame] | 759 | /* IDs for LPC device of Intel 8 Series Chipset (Lynx Point) */ |
| 760 | static const unsigned short pci_device_ids[] = { |
| 761 | 0x8c41, /* Mobile Full Featured Engineering Sample. */ |
| 762 | 0x8c42, /* Desktop Full Featured Engineering Sample. */ |
| 763 | 0x8c44, /* Z87 SKU */ |
| 764 | 0x8c46, /* Z85 SKU */ |
| 765 | 0x8c49, /* HM86 SKU */ |
| 766 | 0x8c4a, /* H87 SKU */ |
| 767 | 0x8c4b, /* HM87 SKU */ |
| 768 | 0x8c4c, /* Q85 SKU */ |
| 769 | 0x8c4e, /* Q87 SKU */ |
| 770 | 0x8c4f, /* QM87 SKU */ |
Duncan Laurie | 74c0d05 | 2012-12-17 11:31:40 -0800 | [diff] [blame] | 771 | 0x9c41, /* LP Full Featured Engineering Sample */ |
| 772 | 0x9c43, /* LP Premium SKU */ |
| 773 | 0x9c45, /* LP Mainstream SKU */ |
| 774 | 0x9c47, /* LP Value SKU */ |
Aaron Durbin | c1989c4 | 2012-12-11 17:13:17 -0600 | [diff] [blame] | 775 | 0 }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 776 | |
| 777 | static const struct pci_driver pch_lpc __pci_driver = { |
| 778 | .ops = &device_ops, |
| 779 | .vendor = PCI_VENDOR_ID_INTEL, |
| 780 | .devices = pci_device_ids, |
| 781 | }; |
| 782 | |
| 783 | |