blob: cf5959eceecc11862e170bfa432fade66a3292b1 [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
Duncan Laurie467f31d2013-03-08 17:00:37 -08005 * Copyright 2013 Google Inc.
Aaron Durbin76c37002012-10-30 09:03:43 -05006 *
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.
Aaron Durbin76c37002012-10-30 09:03:43 -050016 */
17
18#include <console/console.h>
19#include <device/device.h>
20#include <device/pci.h>
21#include <device/pci_ids.h>
Patrick Rudolphe56189c2018-04-18 10:11:59 +020022#include <device/pci_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050023#include <pc80/mc146818rtc.h>
24#include <pc80/isa-dma.h>
25#include <pc80/i8259.h>
26#include <arch/io.h>
27#include <arch/ioapic.h>
28#include <arch/acpi.h>
29#include <cpu/cpu.h>
Aaron Durbin29ffa542012-12-21 21:21:48 -060030#include <cpu/x86/smm.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050031#include <elog.h>
Duncan Laurie9c07c8f2013-03-22 11:08:39 -070032#include <cbmem.h>
33#include <string.h>
34#include "nvs.h"
Aaron Durbin76c37002012-10-30 09:03:43 -050035#include "pch.h"
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +020036#include <arch/acpigen.h>
37#include <cbmem.h>
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010038#include <drivers/intel/gma/i915.h>
Tristan Corrickf3127d42018-10-31 02:25:54 +130039#include <southbridge/intel/common/acpi_pirq_gen.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050040
41#define NMI_OFF 0
42
43#define ENABLE_ACPI_MODE_IN_COREBOOT 0
Aaron Durbin76c37002012-10-30 09:03:43 -050044
45typedef struct southbridge_intel_lynxpoint_config config_t;
46
Paul Menzel373a20c2013-05-03 12:17:02 +020047/**
48 * Set miscellanous static southbridge features.
49 *
50 * @param dev PCI device with I/O APIC control registers
51 */
52static void pch_enable_ioapic(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -050053{
Aaron Durbin76c37002012-10-30 09:03:43 -050054 u32 reg32;
Aaron Durbin76c37002012-10-30 09:03:43 -050055
Matt DeVilliera51e3792018-03-04 01:44:15 -060056 /* Assign unique bus/dev/fn for I/O APIC */
57 pci_write_config16(dev, LPC_IBDF,
58 PCH_IOAPIC_PCI_BUS << 8 | PCH_IOAPIC_PCI_SLOT << 3);
59
Paul Menzel373a20c2013-05-03 12:17:02 +020060 /* Enable ACPI I/O range decode */
61 pci_write_config8(dev, ACPI_CNTL, ACPI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -050062
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080063 set_ioapic_id(VIO_APIC_VADDR, 0x02);
Aaron Durbin76c37002012-10-30 09:03:43 -050064
65 /* affirm full set of redirection table entries ("write once") */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080066 reg32 = io_apic_read(VIO_APIC_VADDR, 0x01);
Duncan Lauriec5939992013-05-24 11:06:49 -070067 if (pch_is_lp()) {
68 /* PCH-LP has 39 redirection entries */
69 reg32 &= ~0x00ff0000;
70 reg32 |= 0x00270000;
71 }
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080072 io_apic_write(VIO_APIC_VADDR, 0x01, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -050073
Paul Menzel373a20c2013-05-03 12:17:02 +020074 /*
75 * Select Boot Configuration register (0x03) and
76 * use Processor System Bus (0x01) to deliver interrupts.
77 */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080078 io_apic_write(VIO_APIC_VADDR, 0x03, 0x01);
Aaron Durbin76c37002012-10-30 09:03:43 -050079}
80
81static void pch_enable_serial_irqs(struct device *dev)
82{
83 /* Set packet length and toggle silent mode bit for one frame. */
84 pci_write_config8(dev, SERIRQ_CNTL,
85 (1 << 7) | (1 << 6) | ((21 - 17) << 2) | (0 << 0));
Martin Roth7a1a3ad2017-06-24 21:29:38 -060086#if !IS_ENABLED(CONFIG_SERIRQ_CONTINUOUS_MODE)
Aaron Durbin76c37002012-10-30 09:03:43 -050087 pci_write_config8(dev, SERIRQ_CNTL,
88 (1 << 7) | (0 << 6) | ((21 - 17) << 2) | (0 << 0));
89#endif
90}
91
92/* PIRQ[n]_ROUT[3:0] - PIRQ Routing Control
93 * 0x00 - 0000 = Reserved
94 * 0x01 - 0001 = Reserved
95 * 0x02 - 0010 = Reserved
96 * 0x03 - 0011 = IRQ3
97 * 0x04 - 0100 = IRQ4
98 * 0x05 - 0101 = IRQ5
99 * 0x06 - 0110 = IRQ6
100 * 0x07 - 0111 = IRQ7
101 * 0x08 - 1000 = Reserved
102 * 0x09 - 1001 = IRQ9
103 * 0x0A - 1010 = IRQ10
104 * 0x0B - 1011 = IRQ11
105 * 0x0C - 1100 = IRQ12
106 * 0x0D - 1101 = Reserved
107 * 0x0E - 1110 = IRQ14
108 * 0x0F - 1111 = IRQ15
109 * PIRQ[n]_ROUT[7] - PIRQ Routing Control
110 * 0x80 - The PIRQ is not routed.
111 */
112
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200113static void pch_pirq_init(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500114{
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200115 struct device *irq_dev;
Aaron Durbin76c37002012-10-30 09:03:43 -0500116 /* Get the chip configuration */
117 config_t *config = dev->chip_info;
118
119 pci_write_config8(dev, PIRQA_ROUT, config->pirqa_routing);
120 pci_write_config8(dev, PIRQB_ROUT, config->pirqb_routing);
121 pci_write_config8(dev, PIRQC_ROUT, config->pirqc_routing);
122 pci_write_config8(dev, PIRQD_ROUT, config->pirqd_routing);
123
124 pci_write_config8(dev, PIRQE_ROUT, config->pirqe_routing);
125 pci_write_config8(dev, PIRQF_ROUT, config->pirqf_routing);
126 pci_write_config8(dev, PIRQG_ROUT, config->pirqg_routing);
127 pci_write_config8(dev, PIRQH_ROUT, config->pirqh_routing);
128
129 /* Eric Biederman once said we should let the OS do this.
130 * I am not so sure anymore he was right.
131 */
132
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200133 for (irq_dev = all_devices; irq_dev; irq_dev = irq_dev->next) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500134 u8 int_pin=0, int_line=0;
135
136 if (!irq_dev->enabled || irq_dev->path.type != DEVICE_PATH_PCI)
137 continue;
138
139 int_pin = pci_read_config8(irq_dev, PCI_INTERRUPT_PIN);
140
141 switch (int_pin) {
142 case 1: /* INTA# */ int_line = config->pirqa_routing; break;
143 case 2: /* INTB# */ int_line = config->pirqb_routing; break;
144 case 3: /* INTC# */ int_line = config->pirqc_routing; break;
145 case 4: /* INTD# */ int_line = config->pirqd_routing; break;
146 }
147
148 if (!int_line)
149 continue;
150
151 pci_write_config8(irq_dev, PCI_INTERRUPT_LINE, int_line);
152 }
153}
154
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200155static void pch_gpi_routing(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500156{
157 /* Get the chip configuration */
158 config_t *config = dev->chip_info;
159 u32 reg32 = 0;
160
161 /* An array would be much nicer here, or some
162 * other method of doing this.
163 */
164 reg32 |= (config->gpi0_routing & 0x03) << 0;
165 reg32 |= (config->gpi1_routing & 0x03) << 2;
166 reg32 |= (config->gpi2_routing & 0x03) << 4;
167 reg32 |= (config->gpi3_routing & 0x03) << 6;
168 reg32 |= (config->gpi4_routing & 0x03) << 8;
169 reg32 |= (config->gpi5_routing & 0x03) << 10;
170 reg32 |= (config->gpi6_routing & 0x03) << 12;
171 reg32 |= (config->gpi7_routing & 0x03) << 14;
172 reg32 |= (config->gpi8_routing & 0x03) << 16;
173 reg32 |= (config->gpi9_routing & 0x03) << 18;
174 reg32 |= (config->gpi10_routing & 0x03) << 20;
175 reg32 |= (config->gpi11_routing & 0x03) << 22;
176 reg32 |= (config->gpi12_routing & 0x03) << 24;
177 reg32 |= (config->gpi13_routing & 0x03) << 26;
178 reg32 |= (config->gpi14_routing & 0x03) << 28;
179 reg32 |= (config->gpi15_routing & 0x03) << 30;
180
Kyösti Mälkkib85a87b2014-12-29 11:32:27 +0200181 pci_write_config32(dev, GPIO_ROUT, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -0500182}
183
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200184static void pch_power_options(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500185{
186 u8 reg8;
Duncan Laurie467f31d2013-03-08 17:00:37 -0800187 u16 reg16;
Aaron Durbin76c37002012-10-30 09:03:43 -0500188 u32 reg32;
189 const char *state;
190 /* Get the chip configuration */
191 config_t *config = dev->chip_info;
Duncan Laurie467f31d2013-03-08 17:00:37 -0800192 u16 pmbase = get_pmbase();
Aaron Durbin76c37002012-10-30 09:03:43 -0500193 int pwr_on=CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL;
194 int nmi_option;
195
196 /* Which state do we want to goto after g3 (power restored)?
197 * 0 == S0 Full On
198 * 1 == S5 Soft Off
199 *
200 * If the option is not existent (Laptops), use Kconfig setting.
201 */
202 get_option(&pwr_on, "power_on_after_fail");
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200203 pwr_on = MAINBOARD_POWER_KEEP;
Aaron Durbin76c37002012-10-30 09:03:43 -0500204
205 reg16 = pci_read_config16(dev, GEN_PMCON_3);
206 reg16 &= 0xfffe;
207 switch (pwr_on) {
208 case MAINBOARD_POWER_OFF:
209 reg16 |= 1;
210 state = "off";
211 break;
212 case MAINBOARD_POWER_ON:
213 reg16 &= ~1;
214 state = "on";
215 break;
216 case MAINBOARD_POWER_KEEP:
217 reg16 &= ~1;
218 state = "state keep";
219 break;
220 default:
221 state = "undefined";
222 }
223
224 reg16 &= ~(3 << 4); /* SLP_S4# Assertion Stretch 4s */
225 reg16 |= (1 << 3); /* SLP_S4# Assertion Stretch Enable */
226
227 reg16 &= ~(1 << 10);
228 reg16 |= (1 << 11); /* SLP_S3# Min Assertion Width 50ms */
229
230 reg16 |= (1 << 12); /* Disable SLP stretch after SUS well */
231
232 pci_write_config16(dev, GEN_PMCON_3, reg16);
233 printk(BIOS_INFO, "Set power %s after power failure.\n", state);
234
235 /* Set up NMI on errors. */
236 reg8 = inb(0x61);
237 reg8 &= 0x0f; /* Higher Nibble must be 0 */
238 reg8 &= ~(1 << 3); /* IOCHK# NMI Enable */
239 // reg8 &= ~(1 << 2); /* PCI SERR# Enable */
240 reg8 |= (1 << 2); /* PCI SERR# Disable for now */
241 outb(reg8, 0x61);
242
243 reg8 = inb(0x70);
244 nmi_option = NMI_OFF;
245 get_option(&nmi_option, "nmi");
246 if (nmi_option) {
247 printk(BIOS_INFO, "NMI sources enabled.\n");
248 reg8 &= ~(1 << 7); /* Set NMI. */
249 } else {
250 printk(BIOS_INFO, "NMI sources disabled.\n");
Elyes HAOUAS9c5d4632018-04-26 22:21:21 +0200251 reg8 |= (1 << 7); /* Can't mask NMI from PCI-E and NMI_NOW */
Aaron Durbin76c37002012-10-30 09:03:43 -0500252 }
253 outb(reg8, 0x70);
254
255 /* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */
256 reg16 = pci_read_config16(dev, GEN_PMCON_1);
257 reg16 &= ~(3 << 0); // SMI# rate 1 minute
258 reg16 &= ~(1 << 10); // Disable BIOS_PCI_EXP_EN for native PME
Aaron Durbin76c37002012-10-30 09:03:43 -0500259 pci_write_config16(dev, GEN_PMCON_1, reg16);
260
Duncan Laurie467f31d2013-03-08 17:00:37 -0800261 /*
262 * Set the board's GPI routing on LynxPoint-H.
263 * This is done as part of GPIO configuration on LynxPoint-LP.
264 */
265 if (pch_is_lp())
266 pch_gpi_routing(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500267
Duncan Laurie467f31d2013-03-08 17:00:37 -0800268 /* GPE setup based on device tree configuration */
269 enable_all_gpe(config->gpe0_en_1, config->gpe0_en_2,
270 config->gpe0_en_3, config->gpe0_en_4);
Aaron Durbin76c37002012-10-30 09:03:43 -0500271
Duncan Laurie467f31d2013-03-08 17:00:37 -0800272 /* SMI setup based on device tree configuration */
273 enable_alt_smi(config->alt_gp_smi_en);
Aaron Durbin76c37002012-10-30 09:03:43 -0500274
275 /* Set up power management block and determine sleep mode */
276 reg32 = inl(pmbase + 0x04); // PM1_CNT
277 reg32 &= ~(7 << 10); // SLP_TYP
278 reg32 |= (1 << 0); // SCI_EN
279 outl(reg32, pmbase + 0x04);
280
281 /* Clear magic status bits to prevent unexpected wake */
282 reg32 = RCBA32(0x3310);
283 reg32 |= (1 << 4)|(1 << 5)|(1 << 0);
284 RCBA32(0x3310) = reg32;
285
Ryan Salsamendi889ce9c2017-06-30 17:45:14 -0700286 reg16 = RCBA16(0x3f02);
287 reg16 &= ~0xf;
288 RCBA16(0x3f02) = reg16;
Aaron Durbin76c37002012-10-30 09:03:43 -0500289}
290
291static void pch_rtc_init(struct device *dev)
292{
Aaron Durbincfe7ad12017-09-15 14:59:27 -0600293 int rtc_failed = rtc_failure();
Aaron Durbin76c37002012-10-30 09:03:43 -0500294
Aaron Durbin76c37002012-10-30 09:03:43 -0500295 if (rtc_failed) {
Aaron Durbincfe7ad12017-09-15 14:59:27 -0600296 if (IS_ENABLED(CONFIG_ELOG))
297 elog_add_event(ELOG_TYPE_RTC_RESET);
298 pci_update_config8(dev, GEN_PMCON_3, ~RTC_BATTERY_DEAD, 0);
Aaron Durbin76c37002012-10-30 09:03:43 -0500299 }
Aaron Durbincfe7ad12017-09-15 14:59:27 -0600300
Aaron Durbin76c37002012-10-30 09:03:43 -0500301 printk(BIOS_DEBUG, "rtc_failed = 0x%x\n", rtc_failed);
302
Gabe Blackb3f08c62014-04-30 17:12:25 -0700303 cmos_init(rtc_failed);
Aaron Durbin76c37002012-10-30 09:03:43 -0500304}
305
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800306/* LynxPoint PCH Power Management init */
307static void lpt_pm_init(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500308{
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800309 printk(BIOS_DEBUG, "LynxPoint PM init\n");
Aaron Durbin76c37002012-10-30 09:03:43 -0500310}
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800311
312const struct rcba_config_instruction lpt_lp_pm_rcba[] = {
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700313 RCBA_RMW_REG_32(0x232c, ~1, 0x00000000),
314 RCBA_RMW_REG_32(0x1100, ~0xc000, 0xc000),
315 RCBA_RMW_REG_32(0x1100, ~0, 0x00000100),
316 RCBA_RMW_REG_32(0x1100, ~0, 0x0000003f),
317 RCBA_RMW_REG_32(0x2320, ~0x60, 0x10),
318 RCBA_RMW_REG_32(0x3314, 0, 0x00012fff),
319 RCBA_RMW_REG_32(0x3318, 0, 0x0dcf0400),
320 RCBA_RMW_REG_32(0x3324, 0, 0x04000000),
321 RCBA_RMW_REG_32(0x3368, 0, 0x00041400),
322 RCBA_RMW_REG_32(0x3388, 0, 0x3f8ddbff),
323 RCBA_RMW_REG_32(0x33ac, 0, 0x00007001),
324 RCBA_RMW_REG_32(0x33b0, 0, 0x00181900),
325 RCBA_RMW_REG_32(0x33c0, 0, 0x00060A00),
326 RCBA_RMW_REG_32(0x33d0, 0, 0x06200840),
327 RCBA_RMW_REG_32(0x3a28, 0, 0x01010101),
328 RCBA_RMW_REG_32(0x3a2c, 0, 0x04040404),
329 RCBA_RMW_REG_32(0x2b1c, 0, 0x03808033),
330 RCBA_RMW_REG_32(0x2b34, 0, 0x80000009),
331 RCBA_RMW_REG_32(0x3348, 0, 0x022ddfff),
332 RCBA_RMW_REG_32(0x334c, 0, 0x00000001),
333 RCBA_RMW_REG_32(0x3358, 0, 0x0001c000),
334 RCBA_RMW_REG_32(0x3380, 0, 0x3f8ddbff),
335 RCBA_RMW_REG_32(0x3384, 0, 0x0001c7e1),
336 RCBA_RMW_REG_32(0x338c, 0, 0x0001c7e1),
337 RCBA_RMW_REG_32(0x3398, 0, 0x0001c000),
338 RCBA_RMW_REG_32(0x33a8, 0, 0x00181900),
339 RCBA_RMW_REG_32(0x33dc, 0, 0x00080000),
340 RCBA_RMW_REG_32(0x33e0, 0, 0x00000001),
341 RCBA_RMW_REG_32(0x3a20, 0, 0x00000404),
342 RCBA_RMW_REG_32(0x3a24, 0, 0x01010101),
343 RCBA_RMW_REG_32(0x3a30, 0, 0x01010101),
344 RCBA_RMW_REG_32(0x0410, ~0, 0x00000003),
345 RCBA_RMW_REG_32(0x2618, ~0, 0x08000000),
346 RCBA_RMW_REG_32(0x2300, ~0, 0x00000002),
347 RCBA_RMW_REG_32(0x2600, ~0, 0x00000008),
348 RCBA_RMW_REG_32(0x33b4, 0, 0x00007001),
349 RCBA_RMW_REG_32(0x3350, 0, 0x022ddfff),
350 RCBA_RMW_REG_32(0x3354, 0, 0x00000001),
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800351 RCBA_RMW_REG_32(0x33d4, ~0, 0x08000000), /* Power Optimizer */
Matt DeVillierc97e0422017-02-16 11:36:16 -0600352 RCBA_RMW_REG_32(0x33c8, ~0, 0x00000080), /* Power Optimizer */
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800353 RCBA_RMW_REG_32(0x2b10, 0, 0x0000883c), /* Power Optimizer */
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700354 RCBA_RMW_REG_32(0x2b14, 0, 0x1e0a4616), /* Power Optimizer */
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800355 RCBA_RMW_REG_32(0x2b24, 0, 0x40000005), /* Power Optimizer */
356 RCBA_RMW_REG_32(0x2b20, 0, 0x0005db01), /* Power Optimizer */
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700357 RCBA_RMW_REG_32(0x3a80, 0, 0x05145005),
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800358 RCBA_END_CONFIG
359};
360
361/* LynxPoint LP PCH Power Management init */
362static void lpt_lp_pm_init(struct device *dev)
363{
364 struct southbridge_intel_lynxpoint_config *config = dev->chip_info;
365 u32 data;
366
367 printk(BIOS_DEBUG, "LynxPoint LP PM init\n");
368
369 pci_write_config8(dev, 0xa9, 0x46);
370
371 pch_config_rcba(lpt_lp_pm_rcba);
372
373 pci_write_config32(dev, 0xac,
374 pci_read_config32(dev, 0xac) | (1 << 21));
375
Elyes HAOUASa0aea562017-07-03 21:38:53 +0200376 pch_iobp_update(0xED00015C, ~(1 << 11), 0x00003700);
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700377 pch_iobp_update(0xED000118, ~0UL, 0x00c00000);
378 pch_iobp_update(0xED000120, ~0UL, 0x00240000);
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800379 pch_iobp_update(0xCA000000, ~0UL, 0x00000009);
380
381 /* Set RCBA CIR28 0x3A84 based on SATA port enables */
382 data = 0x00001005;
383 /* Port 3 and 2 disabled */
384 if ((config->sata_port_map & ((1 << 3)|(1 << 2))) == 0)
385 data |= (1 << 24) | (1 << 26);
386 /* Port 1 and 0 disabled */
387 if ((config->sata_port_map & ((1 << 1)|(1 << 0))) == 0)
388 data |= (1 << 20) | (1 << 18);
389 RCBA32(0x3a84) = data;
390
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700391 /* Set RCBA 0x2b1c[29]=1 if DSP disabled */
392 if (RCBA32(FD) & PCH_DISABLE_ADSPD)
393 RCBA32_OR(0x2b1c, (1 << 29));
394
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800395 /* Lock */
396 RCBA32_OR(0x3a6c, 0x00000001);
397
398 /* Set RCBA 0x33D4 after other setup */
399 RCBA32_OR(0x33d4, 0x2fff2fb1);
400
401 /* Set RCBA 0x33C8[15]=1 as last step */
402 RCBA32_OR(0x33c8, (1 << 15));
403}
Aaron Durbin76c37002012-10-30 09:03:43 -0500404
Matt DeVilliera51e3792018-03-04 01:44:15 -0600405static void enable_hpet(struct device *const dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500406{
407 u32 reg32;
Matt DeVilliera51e3792018-03-04 01:44:15 -0600408 size_t i;
409
410 /* Assign unique bus/dev/fn for each HPET */
411 for (i = 0; i < 8; ++i)
412 pci_write_config16(dev, LPC_HnBDF(i),
413 PCH_HPET_PCI_BUS << 8 | PCH_HPET_PCI_SLOT << 3 | i);
Aaron Durbin76c37002012-10-30 09:03:43 -0500414
415 /* Move HPET to default address 0xfed00000 and enable it */
416 reg32 = RCBA32(HPTC);
417 reg32 |= (1 << 7); // HPET Address Enable
418 reg32 &= ~(3 << 0);
419 RCBA32(HPTC) = reg32;
420 /* Read it back to stick. It's affected by posted write syndrome. */
421 reg32 = RCBA32(HPTC);
422}
423
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200424static void enable_clock_gating(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500425{
Duncan Laurie74c0d052012-12-17 11:31:40 -0800426 /* LynxPoint Mobile */
427 u32 reg32;
428 u16 reg16;
429
430 /* DMI */
431 RCBA32_AND_OR(0x2234, ~0UL, 0xf);
432 reg16 = pci_read_config16(dev, GEN_PMCON_1);
433 reg16 |= (1 << 11) | (1 << 12) | (1 << 14);
434 reg16 |= (1 << 2); // PCI CLKRUN# Enable
435 pci_write_config16(dev, GEN_PMCON_1, reg16);
436 RCBA32_OR(0x900, (1 << 14));
437
438 reg32 = RCBA32(CG);
439 reg32 |= (1 << 22); // HDA Dynamic
Ryan Salsamendi0d9b3602017-06-30 17:15:57 -0700440 reg32 |= (1UL << 31); // LPC Dynamic
Duncan Laurie74c0d052012-12-17 11:31:40 -0800441 reg32 |= (1 << 16); // PCIe Dynamic
442 reg32 |= (1 << 27); // HPET Dynamic
443 reg32 |= (1 << 28); // GPIO Dynamic
444 RCBA32(CG) = reg32;
445
446 RCBA32_OR(0x38c0, 0x7); // SPI Dynamic
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800447}
448
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200449static void enable_lp_clock_gating(struct device *dev)
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800450{
451 /* LynxPoint LP */
452 u32 reg32;
453 u16 reg16;
454
455 /* DMI */
456 RCBA32_AND_OR(0x2234, ~0UL, 0xf);
457 reg16 = pci_read_config16(dev, GEN_PMCON_1);
458 reg16 &= ~((1 << 11) | (1 << 14));
459 reg16 |= (1 << 5) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 13);
460 reg16 |= (1 << 2); // PCI CLKRUN# Enable
461 pci_write_config16(dev, GEN_PMCON_1, reg16);
462
463 reg32 = pci_read_config32(dev, 0x64);
464 reg32 |= (1 << 6);
465 pci_write_config32(dev, 0x64, reg32);
466
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700467 /*
468 * RCBA + 0x2614[27:25,14:13,10,8] = 101,11,1,1
469 * RCBA + 0x2614[23:16] = 0x20
470 * RCBA + 0x2614[30:28] = 0x0
Duncan Lauried8c7d732013-07-16 09:01:43 -0700471 * RCBA + 0x2614[26] = 1 (IF 0:2.0@0x08 >= 0x0b)
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700472 */
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800473 RCBA32_AND_OR(0x2614, 0x8bffffff, 0x0a206500);
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700474
475 /* Check for LPT-LP B2 stepping and 0:31.0@0xFA > 4 */
Duncan Lauried8c7d732013-07-16 09:01:43 -0700476 if (pci_read_config8(dev_find_slot(0, PCI_DEVFN(2, 0)), 0x8) >= 0x0b)
Elyes HAOUASa0aea562017-07-03 21:38:53 +0200477 RCBA32_OR(0x2614, (1 << 26));
Duncan Laurie4bc107b2013-06-24 13:14:44 -0700478
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800479 RCBA32_OR(0x900, 0x0000031f);
480
481 reg32 = RCBA32(CG);
Duncan Lauriea2d6a402013-03-22 11:24:45 -0700482 if (RCBA32(0x3454) & (1 << 4))
483 reg32 &= ~(1 << 29); // LPC Dynamic
484 else
485 reg32 |= (1 << 29); // LPC Dynamic
Ryan Salsamendi3f2fe182017-07-04 13:14:16 -0700486 reg32 |= (1UL << 31); // LP LPC
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700487 reg32 |= (1 << 30); // LP BLA
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800488 reg32 |= (1 << 28); // GPIO Dynamic
489 reg32 |= (1 << 27); // HPET Dynamic
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700490 reg32 |= (1 << 26); // Generic Platform Event Clock
491 if (RCBA32(BUC) & PCH_DISABLE_GBE)
492 reg32 |= (1 << 23); // GbE Static
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800493 reg32 |= (1 << 22); // HDA Dynamic
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700494 reg32 |= (1 << 16); // PCI Dynamic
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800495 RCBA32(CG) = reg32;
496
497 RCBA32_OR(0x3434, 0x7); // LP LPC
498
499 RCBA32_AND_OR(0x333c, 0xffcfffff, 0x00c00000); // SATA
500
501 RCBA32_OR(0x38c0, 0x3c07); // SPI Dynamic
502
503 pch_iobp_update(0xCF000000, ~0UL, 0x00007001);
Duncan Laurie5cf34ce2013-04-26 10:41:33 -0700504 pch_iobp_update(0xCE00C000, ~1UL, 0x00000000); // bit0=0 in BWG 1.4.0
Aaron Durbin76c37002012-10-30 09:03:43 -0500505}
506
Aaron Durbin29ffa542012-12-21 21:21:48 -0600507static void pch_set_acpi_mode(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500508{
Martin Roth7a1a3ad2017-06-24 21:29:38 -0600509#if IS_ENABLED(CONFIG_HAVE_SMI_HANDLER)
Kyösti Mälkkic3ed8862014-06-19 19:50:51 +0300510 if (!acpi_is_wakeup_s3()) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500511#if ENABLE_ACPI_MODE_IN_COREBOOT
512 printk(BIOS_DEBUG, "Enabling ACPI via APMC:\n");
Aaron Durbin29ffa542012-12-21 21:21:48 -0600513 outb(APM_CNT_ACPI_ENABLE, APM_CNT);
Aaron Durbin76c37002012-10-30 09:03:43 -0500514 printk(BIOS_DEBUG, "done.\n");
515#else
516 printk(BIOS_DEBUG, "Disabling ACPI via APMC:\n");
Aaron Durbin29ffa542012-12-21 21:21:48 -0600517 outb(APM_CNT_ACPI_DISABLE, APM_CNT);
Aaron Durbin76c37002012-10-30 09:03:43 -0500518 printk(BIOS_DEBUG, "done.\n");
519#endif
520 }
Aaron Durbin29ffa542012-12-21 21:21:48 -0600521#endif /* CONFIG_HAVE_SMI_HANDLER */
Aaron Durbin76c37002012-10-30 09:03:43 -0500522}
Aaron Durbin76c37002012-10-30 09:03:43 -0500523
524static void pch_disable_smm_only_flashing(struct device *dev)
525{
526 u8 reg8;
527
528 printk(BIOS_SPEW, "Enabling BIOS updates outside of SMM... ");
529 reg8 = pci_read_config8(dev, 0xdc); /* BIOS_CNTL */
530 reg8 &= ~(1 << 5);
531 pci_write_config8(dev, 0xdc, reg8);
532}
533
534static void pch_fixups(struct device *dev)
535{
536 u8 gen_pmcon_2;
537
538 /* Indicate DRAM init done for MRC S3 to know it can resume */
539 gen_pmcon_2 = pci_read_config8(dev, GEN_PMCON_2);
540 gen_pmcon_2 |= (1 << 7);
541 pci_write_config8(dev, GEN_PMCON_2, gen_pmcon_2);
542
543 /*
544 * Enable DMI ASPM in the PCH
545 */
546 RCBA32_AND_OR(0x2304, ~(1 << 10), 0);
547 RCBA32_OR(0x21a4, (1 << 11)|(1 << 10));
548 RCBA32_OR(0x21a8, 0x3);
549}
550
Aaron Durbin76c37002012-10-30 09:03:43 -0500551static void lpc_init(struct device *dev)
552{
553 printk(BIOS_DEBUG, "pch: lpc_init\n");
554
555 /* Set the value for PCI command register. */
556 pci_write_config16(dev, PCI_COMMAND, 0x000f);
557
558 /* IO APIC initialization. */
Paul Menzel373a20c2013-05-03 12:17:02 +0200559 pch_enable_ioapic(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500560
561 pch_enable_serial_irqs(dev);
562
563 /* Setup the PIRQ. */
564 pch_pirq_init(dev);
565
566 /* Setup power options. */
567 pch_power_options(dev);
568
569 /* Initialize power management */
Duncan Lauriedeb90f42013-03-08 17:22:37 -0800570 if (pch_is_lp()) {
571 lpt_lp_pm_init(dev);
572 enable_lp_clock_gating(dev);
573 } else {
574 lpt_pm_init(dev);
575 enable_clock_gating(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500576 }
577
Aaron Durbin76c37002012-10-30 09:03:43 -0500578 /* Initialize the real time clock. */
579 pch_rtc_init(dev);
580
581 /* Initialize ISA DMA. */
582 isa_dma_init();
583
584 /* Initialize the High Precision Event Timers, if present. */
Matt DeVilliera51e3792018-03-04 01:44:15 -0600585 enable_hpet(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500586
Aaron Durbin76c37002012-10-30 09:03:43 -0500587 setup_i8259();
588
Aaron Durbin76c37002012-10-30 09:03:43 -0500589 /* Interrupt 9 should be level triggered (SCI) */
590 i8259_configure_irq_trigger(9, 1);
591
592 pch_disable_smm_only_flashing(dev);
593
Aaron Durbin29ffa542012-12-21 21:21:48 -0600594 pch_set_acpi_mode();
Aaron Durbin76c37002012-10-30 09:03:43 -0500595
596 pch_fixups(dev);
597}
598
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200599static void pch_lpc_add_mmio_resources(struct device *dev)
Aaron Durbin6f561af2012-12-19 14:38:01 -0600600{
601 u32 reg;
602 struct resource *res;
603 const u32 default_decode_base = IO_APIC_ADDR;
604
605 /*
606 * Just report all resources from IO-APIC base to 4GiB. Don't mark
607 * them reserved as that may upset the OS if this range is marked
608 * as reserved in the e820.
609 */
610 res = new_resource(dev, OIC);
611 res->base = default_decode_base;
612 res->size = 0 - default_decode_base;
613 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
614
615 /* RCBA */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800616 if ((uintptr_t)DEFAULT_RCBA < default_decode_base) {
Aaron Durbin6f561af2012-12-19 14:38:01 -0600617 res = new_resource(dev, RCBA);
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800618 res->base = (resource_t)(uintptr_t)DEFAULT_RCBA;
Aaron Durbin6f561af2012-12-19 14:38:01 -0600619 res->size = 16 * 1024;
620 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED |
621 IORESOURCE_FIXED | IORESOURCE_RESERVE;
622 }
623
624 /* Check LPC Memory Decode register. */
625 reg = pci_read_config32(dev, LGMR);
626 if (reg & 1) {
627 reg &= ~0xffff;
628 if (reg < default_decode_base) {
629 res = new_resource(dev, LGMR);
630 res->base = reg;
631 res->size = 16 * 1024;
632 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED |
633 IORESOURCE_FIXED | IORESOURCE_RESERVE;
634 }
635 }
636}
637
638/* Default IO range claimed by the LPC device. The upper bound is exclusive. */
639#define LPC_DEFAULT_IO_RANGE_LOWER 0
640#define LPC_DEFAULT_IO_RANGE_UPPER 0x1000
641
642static inline int pch_io_range_in_default(u16 base, u16 size)
643{
644 /* Does it start above the range? */
645 if (base >= LPC_DEFAULT_IO_RANGE_UPPER)
646 return 0;
647
648 /* Is it entirely contained? */
649 if (base >= LPC_DEFAULT_IO_RANGE_LOWER &&
650 (base + size) < LPC_DEFAULT_IO_RANGE_UPPER)
651 return 1;
652
653 /* This will return not in range for partial overlaps. */
654 return 0;
655}
656
657/*
658 * Note: this function assumes there is no overlap with the default LPC device's
659 * claimed range: LPC_DEFAULT_IO_RANGE_LOWER -> LPC_DEFAULT_IO_RANGE_UPPER.
660 */
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200661static void pch_lpc_add_io_resource(struct device *dev, u16 base, u16 size,
662 int index)
Aaron Durbin6f561af2012-12-19 14:38:01 -0600663{
664 struct resource *res;
665
666 if (pch_io_range_in_default(base, size))
667 return;
668
669 res = new_resource(dev, index);
670 res->base = base;
671 res->size = size;
672 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
673}
674
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200675static void pch_lpc_add_gen_io_resources(struct device *dev, int reg_value,
676 int index)
Aaron Durbin6f561af2012-12-19 14:38:01 -0600677{
678 /*
679 * Check if the register is enabled. If so and the base exceeds the
680 * device's deafult claim range add the resoure.
681 */
682 if (reg_value & 1) {
683 u16 base = reg_value & 0xfffc;
684 u16 size = (0x3 | ((reg_value >> 16) & 0xfc)) + 1;
685 pch_lpc_add_io_resource(dev, base, size, index);
686 }
687}
688
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200689static void pch_lpc_add_io_resources(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500690{
691 struct resource *res;
692 config_t *config = dev->chip_info;
Aaron Durbin76c37002012-10-30 09:03:43 -0500693
Aaron Durbin6f561af2012-12-19 14:38:01 -0600694 /* Add the default claimed IO range for the LPC device. */
695 res = new_resource(dev, 0);
696 res->base = LPC_DEFAULT_IO_RANGE_LOWER;
697 res->size = LPC_DEFAULT_IO_RANGE_UPPER - LPC_DEFAULT_IO_RANGE_LOWER;
698 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
699
700 /* GPIOBASE */
Duncan Laurie7922b462013-03-08 16:34:33 -0800701 pch_lpc_add_io_resource(dev, get_gpiobase(), DEFAULT_GPIOSIZE,
Aaron Durbin6f561af2012-12-19 14:38:01 -0600702 GPIO_BASE);
703
704 /* PMBASE */
Duncan Laurie7922b462013-03-08 16:34:33 -0800705 pch_lpc_add_io_resource(dev, get_pmbase(), 256, PMBASE);
Aaron Durbin6f561af2012-12-19 14:38:01 -0600706
707 /* LPC Generic IO Decode range. */
708 pch_lpc_add_gen_io_resources(dev, config->gen1_dec, LPC_GEN1_DEC);
709 pch_lpc_add_gen_io_resources(dev, config->gen2_dec, LPC_GEN2_DEC);
710 pch_lpc_add_gen_io_resources(dev, config->gen3_dec, LPC_GEN3_DEC);
711 pch_lpc_add_gen_io_resources(dev, config->gen4_dec, LPC_GEN4_DEC);
712}
713
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200714static void pch_lpc_read_resources(struct device *dev)
Aaron Durbin6f561af2012-12-19 14:38:01 -0600715{
Duncan Laurie9c07c8f2013-03-22 11:08:39 -0700716 global_nvs_t *gnvs;
717
Aaron Durbin76c37002012-10-30 09:03:43 -0500718 /* Get the normal PCI resources of this device. */
719 pci_dev_read_resources(dev);
720
Aaron Durbin6f561af2012-12-19 14:38:01 -0600721 /* Add non-standard MMIO resources. */
722 pch_lpc_add_mmio_resources(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500723
Aaron Durbin6f561af2012-12-19 14:38:01 -0600724 /* Add IO resources. */
725 pch_lpc_add_io_resources(dev);
Duncan Laurie9c07c8f2013-03-22 11:08:39 -0700726
727 /* Allocate ACPI NVS in CBMEM */
728 gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(global_nvs_t));
Kyösti Mälkkic3ed8862014-06-19 19:50:51 +0300729 if (!acpi_is_wakeup_s3() && gnvs)
Duncan Laurie9c07c8f2013-03-22 11:08:39 -0700730 memset(gnvs, 0, sizeof(global_nvs_t));
Aaron Durbin76c37002012-10-30 09:03:43 -0500731}
732
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200733static void pch_lpc_enable(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500734{
735 /* Enable PCH Display Port */
736 RCBA16(DISPBDF) = 0x0010;
737 RCBA32_OR(FD2, PCH_ENABLE_DBDF);
738
739 pch_enable(dev);
740}
741
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200742static void set_subsystem(struct device *dev, unsigned vendor, unsigned device)
Aaron Durbin76c37002012-10-30 09:03:43 -0500743{
744 if (!vendor || !device) {
745 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
746 pci_read_config32(dev, PCI_VENDOR_ID));
747 } else {
748 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
749 ((device & 0xffff) << 16) | (vendor & 0xffff));
750 }
751}
752
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200753static void southbridge_inject_dsdt(struct device *dev)
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200754{
Vladimir Serbinenko7309c642014-10-05 11:07:33 +0200755 global_nvs_t *gnvs;
756
757 gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
758 if (!gnvs) {
Elyes HAOUAS035df002016-10-03 21:54:16 +0200759 gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(*gnvs));
Vladimir Serbinenko7309c642014-10-05 11:07:33 +0200760 if (gnvs)
761 memset(gnvs, 0, sizeof(*gnvs));
762 }
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200763
764 if (gnvs) {
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100765 const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info();
766
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200767 acpi_create_gnvs(gnvs);
Vladimir Serbinenko1b409fd2014-10-12 00:26:21 +0200768
769 gnvs->apic = 1;
770 gnvs->mpen = 1; /* Enable Multi Processing */
771 gnvs->pcnt = dev_count_cpu();
772
Martin Roth7a1a3ad2017-06-24 21:29:38 -0600773#if IS_ENABLED(CONFIG_CHROMEOS)
Joel Kitching6fbd8742018-08-23 14:56:25 +0800774 chromeos_init_chromeos_acpi(&(gnvs->chromeos));
Vladimir Serbinenko1b409fd2014-10-12 00:26:21 +0200775#endif
776
777 /* Update the mem console pointer. */
778 gnvs->cbmc = (u32)cbmem_find(CBMEM_ID_CONSOLE);
779
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100780 gnvs->ndid = gfx->ndid;
781 memcpy(gnvs->did, gfx->did, sizeof(gnvs->did));
782
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200783 /* And tell SMI about it */
784 smm_setup_structures(gnvs, NULL, NULL);
785
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200786 /* Add it to DSDT. */
Vladimir Serbinenkobe0fd0a2014-11-04 21:10:59 +0100787 acpigen_write_scope("\\");
788 acpigen_write_name_dword("NVSA", (u32) gnvs);
789 acpigen_pop_len();
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200790 }
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200791}
792
Tristan Corrickf3127d42018-10-31 02:25:54 +1300793static const char *lpc_acpi_name(const struct device *dev)
794{
795 return "LPCB";
796}
797
798static void southbridge_fill_ssdt(struct device *dev)
799{
800 intel_acpi_gen_def_acpi_pirq(dev);
801}
802
Elyes HAOUAS7a5f7712018-06-08 17:20:38 +0200803static unsigned long southbridge_write_acpi_tables(struct device *device,
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200804 unsigned long start,
805 struct acpi_rsdp *rsdp)
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200806{
807 unsigned long current;
808 acpi_hpet_t *hpet;
809 acpi_header_t *ssdt;
810
811 current = start;
812
813 /* Align ACPI tables to 16byte */
Aaron Durbin07a1b282015-12-10 17:07:38 -0600814 current = acpi_align_current(current);
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200815
816 /*
817 * We explicitly add these tables later on:
818 */
819 printk(BIOS_DEBUG, "ACPI: * HPET\n");
820
821 hpet = (acpi_hpet_t *) current;
822 current += sizeof(acpi_hpet_t);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600823 current = acpi_align_current(current);
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200824 acpi_create_intel_hpet(hpet);
825 acpi_add_table(rsdp, hpet);
826
Aaron Durbin07a1b282015-12-10 17:07:38 -0600827 current = acpi_align_current(current);
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200828
829 printk(BIOS_DEBUG, "ACPI: * SSDT2\n");
830 ssdt = (acpi_header_t *)current;
831 acpi_create_serialio_ssdt(ssdt);
832 current += ssdt->length;
833 acpi_add_table(rsdp, ssdt);
Aaron Durbin07a1b282015-12-10 17:07:38 -0600834 current = acpi_align_current(current);
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200835
836 printk(BIOS_DEBUG, "current = %lx\n", current);
837 return current;
838}
839
840
Aaron Durbin76c37002012-10-30 09:03:43 -0500841static struct pci_operations pci_ops = {
842 .set_subsystem = set_subsystem,
843};
844
845static struct device_operations device_ops = {
846 .read_resources = pch_lpc_read_resources,
847 .set_resources = pci_dev_set_resources,
Duncan Laurie8d783b82013-05-14 11:16:34 -0700848 .enable_resources = pci_dev_enable_resources,
Tristan Corrickf3127d42018-10-31 02:25:54 +1300849 .acpi_fill_ssdt_generator = southbridge_fill_ssdt,
Vladimir Serbinenko334fd8e2014-10-05 11:10:35 +0200850 .acpi_inject_dsdt_generator = southbridge_inject_dsdt,
Tristan Corrickf3127d42018-10-31 02:25:54 +1300851 .acpi_name = lpc_acpi_name,
Vladimir Serbinenkoc6e566a2014-08-31 17:43:51 +0200852 .write_acpi_tables = southbridge_write_acpi_tables,
Aaron Durbin76c37002012-10-30 09:03:43 -0500853 .init = lpc_init,
854 .enable = pch_lpc_enable,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +0200855 .scan_bus = scan_lpc_bus,
Aaron Durbin76c37002012-10-30 09:03:43 -0500856 .ops_pci = &pci_ops,
857};
858
859
Aaron Durbinc1989c42012-12-11 17:13:17 -0600860/* IDs for LPC device of Intel 8 Series Chipset (Lynx Point) */
861static const unsigned short pci_device_ids[] = {
862 0x8c41, /* Mobile Full Featured Engineering Sample. */
863 0x8c42, /* Desktop Full Featured Engineering Sample. */
864 0x8c44, /* Z87 SKU */
865 0x8c46, /* Z85 SKU */
866 0x8c49, /* HM86 SKU */
867 0x8c4a, /* H87 SKU */
868 0x8c4b, /* HM87 SKU */
869 0x8c4c, /* Q85 SKU */
870 0x8c4e, /* Q87 SKU */
871 0x8c4f, /* QM87 SKU */
Tristan Corrick9a085742018-10-31 02:20:28 +1300872 0x8c50, /* B85 SKU */
873 0x8c52, /* C222 SKU */
874 0x8c54, /* C224 SKU */
875 0x8c56, /* C226 SKU */
876 0x8c5c, /* H81 SKU */
Duncan Laurie74c0d052012-12-17 11:31:40 -0800877 0x9c41, /* LP Full Featured Engineering Sample */
878 0x9c43, /* LP Premium SKU */
879 0x9c45, /* LP Mainstream SKU */
880 0x9c47, /* LP Value SKU */
Aaron Durbinc1989c42012-12-11 17:13:17 -0600881 0 };
Aaron Durbin76c37002012-10-30 09:03:43 -0500882
883static const struct pci_driver pch_lpc __pci_driver = {
884 .ops = &device_ops,
885 .vendor = PCI_VENDOR_ID_INTEL,
886 .devices = pci_device_ids,
887};