blob: 0af774bbf62005b7cc6e914549cf823660847c7d [file] [log] [blame]
Marc Jones24484842017-05-04 21:17:45 -06001/*
2 * This file is part of the coreboot project.
3 *
Richard Spiegel376dc822017-12-01 08:24:26 -07004 * Copyright (C) 2010-2017 Advanced Micro Devices, Inc.
Marc Jones24484842017-05-04 21:17:45 -06005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <console/console.h>
17
18#include <arch/io.h>
Marshall Dawson8a906df2017-06-13 14:19:02 -060019#include <bootstate.h>
Marshall Dawsone9b862e2017-09-22 15:14:46 -060020#include <cpu/x86/smm.h>
Marc Jones24484842017-05-04 21:17:45 -060021#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <device/pci_ops.h>
25#include <cbmem.h>
Richard Spiegel2bbc3dc2017-12-06 16:14:58 -070026#include <amdblocks/amd_pci_util.h>
Marc Jonesdfeb1c42017-08-07 19:08:24 -060027#include <soc/southbridge.h>
Marc Jones24484842017-05-04 21:17:45 -060028#include <soc/smi.h>
Richard Spiegel376dc822017-12-01 08:24:26 -070029#include <soc/amd_pci_int_defs.h>
Marc Jones24484842017-05-04 21:17:45 -060030#include <fchec.h>
Richard Spiegelbec44f22017-11-24 07:41:29 -070031#include <delay.h>
32#include <soc/pci_devs.h>
Marshall Dawson2942db62017-12-14 10:00:27 -070033#include <agesa_headers.h>
34
35static int is_sata_config(void)
36{
37 return !((CONFIG_STONEYRIDGE_SATA_MODE == SataNativeIde)
38 || (CONFIG_STONEYRIDGE_SATA_MODE == SataLegacyIde));
39}
40
Richard Spiegel7ea8e022018-01-16 14:40:10 -070041static inline int sb_sata_enable(void)
42{
43 /* True if IDE or AHCI. */
44 return (CONFIG_STONEYRIDGE_SATA_MODE == SataNativeIde) ||
45 (CONFIG_STONEYRIDGE_SATA_MODE == SataAhci);
46}
47
48static inline int sb_ide_enable(void)
49{
50 /* True if IDE or LEGACY IDE. */
51 return (CONFIG_STONEYRIDGE_SATA_MODE == SataNativeIde) ||
52 (CONFIG_STONEYRIDGE_SATA_MODE == SataLegacyIde);
53}
54
Marshall Dawson2942db62017-12-14 10:00:27 -070055void SetFchResetParams(FCH_RESET_INTERFACE *params)
56{
57 params->Xhci0Enable = IS_ENABLED(CONFIG_STONEYRIDGE_XHCI_ENABLE);
Richard Spiegela318d282018-01-16 13:25:40 -070058 params->SataEnable = sb_sata_enable();
59 params->IdeEnable = sb_ide_enable();
Marshall Dawson2942db62017-12-14 10:00:27 -070060}
61
62void SetFchEnvParams(FCH_INTERFACE *params)
63{
64 params->AzaliaController = AzEnable;
65 params->SataClass = CONFIG_STONEYRIDGE_SATA_MODE;
66 params->SataEnable = is_sata_config();
67 params->IdeEnable = !params->SataEnable;
68 params->SataIdeMode = (CONFIG_STONEYRIDGE_SATA_MODE == SataLegacyIde);
69}
70
71void SetFchMidParams(FCH_INTERFACE *params)
72{
73 SetFchEnvParams(params);
74}
Marc Jones24484842017-05-04 21:17:45 -060075
Richard Spiegel376dc822017-12-01 08:24:26 -070076/*
77 * Table of APIC register index and associated IRQ name. Using IDX_XXX_NAME
78 * provides a visible association with the index, therefor helping
79 * maintainability of table. If a new index/name is defined in
80 * amd_pci_int_defs.h, just add the pair at the end of this table.
81 * Order is not important.
82 */
83const static struct irq_idx_name irq_association[] = {
Richard Spiegele89d4442017-12-08 07:52:42 -070084 { PIRQ_A, "INTA#" },
85 { PIRQ_B, "INTB#" },
86 { PIRQ_C, "INTC#" },
87 { PIRQ_D, "INTD#" },
88 { PIRQ_E, "INTE#" },
89 { PIRQ_F, "INTF#" },
90 { PIRQ_G, "INTG#" },
91 { PIRQ_H, "INTH#" },
92 { PIRQ_MISC, "Misc" },
93 { PIRQ_MISC0, "Misc0" },
94 { PIRQ_MISC1, "Misc1" },
95 { PIRQ_MISC2, "Misc2" },
Richard Spiegel376dc822017-12-01 08:24:26 -070096 { PIRQ_SIRQA, "Ser IRQ INTA" },
97 { PIRQ_SIRQB, "Ser IRQ INTB" },
98 { PIRQ_SIRQC, "Ser IRQ INTC" },
99 { PIRQ_SIRQD, "Ser IRQ INTD" },
Richard Spiegele89d4442017-12-08 07:52:42 -0700100 { PIRQ_SCI, "SCI" },
101 { PIRQ_SMBUS, "SMBUS" },
102 { PIRQ_ASF, "ASF" },
103 { PIRQ_HDA, "HDA" },
104 { PIRQ_FC, "FC" },
105 { PIRQ_PMON, "PerMon" },
106 { PIRQ_SD, "SD" },
107 { PIRQ_SDIO, "SDIOt" },
108 { PIRQ_IMC0, "IMC INT0" },
109 { PIRQ_IMC1, "IMC INT1" },
110 { PIRQ_IMC2, "IMC INT2" },
111 { PIRQ_IMC3, "IMC INT3" },
112 { PIRQ_IMC4, "IMC INT4" },
113 { PIRQ_IMC5, "IMC INT5" },
114 { PIRQ_EHCI, "EHCI" },
115 { PIRQ_XHCI, "XHCI" },
116 { PIRQ_SATA, "SATA" },
117 { PIRQ_GPIO, "GPIO" },
118 { PIRQ_I2C0, "I2C0" },
119 { PIRQ_I2C1, "I2C1" },
120 { PIRQ_I2C2, "I2C2" },
121 { PIRQ_I2C3, "I2C3" },
122 { PIRQ_UART0, "UART0" },
123 { PIRQ_UART1, "UART1" },
Richard Spiegel376dc822017-12-01 08:24:26 -0700124};
125
Richard Spiegelebf3aa82017-11-24 07:47:42 -0700126/*
127 * Structure to simplify code obtaining the total of used wide IO
128 * registers and the size assigned to each.
129 */
130static struct wide_io_ioport_and_bits {
131 uint32_t enable;
132 uint16_t port;
133 uint8_t alt;
134} wio_io_en[TOTAL_WIDEIO_PORTS] = {
135 {
136 LPC_WIDEIO0_ENABLE,
137 LPC_WIDEIO_GENERIC_PORT,
138 LPC_ALT_WIDEIO0_ENABLE
139 },
140 {
141 LPC_WIDEIO1_ENABLE,
142 LPC_WIDEIO1_GENERIC_PORT,
143 LPC_ALT_WIDEIO1_ENABLE
144 },
145 {
146 LPC_WIDEIO2_ENABLE,
147 LPC_WIDEIO2_GENERIC_PORT,
148 LPC_ALT_WIDEIO2_ENABLE
149 }
150};
151
Richard Spiegel376dc822017-12-01 08:24:26 -0700152const struct irq_idx_name *sb_get_apic_reg_association(size_t *size)
153{
154 *size = ARRAY_SIZE(irq_association);
155 return irq_association;
156}
157
Richard Spiegelebf3aa82017-11-24 07:47:42 -0700158/**
159 * @brief Find the size of a particular wide IO
160 *
161 * @param index = index of desired wide IO
162 *
163 * @return size of desired wide IO
164 */
165uint16_t sb_wideio_size(int index)
166{
167 uint32_t enable_register;
168 uint16_t size = 0;
169 uint8_t alternate_register;
170
171 if (index >= TOTAL_WIDEIO_PORTS)
172 return size;
173 enable_register = pci_read_config32(SOC_LPC_DEV,
174 LPC_IO_OR_MEM_DECODE_ENABLE);
175 alternate_register = pci_read_config8(SOC_LPC_DEV,
176 LPC_ALT_WIDEIO_RANGE_ENABLE);
177 if (enable_register & wio_io_en[index].enable)
178 size = (alternate_register & wio_io_en[index].alt) ?
179 16 : 512;
180 return size;
181}
182
183/**
184 * @brief Identify if any LPC wide IO is covering the IO range
185 *
186 * @param start = start of IO range
187 * @param size = size of IO range
188 *
189 * @return Index of wide IO covering the range or error
190 */
191int sb_find_wideio_range(uint16_t start, uint16_t size)
192{
193 uint32_t enable_register;
194 int i, index = WIDEIO_RANGE_ERROR;
195 uint16_t end, current_size, start_wideio, end_wideio;
196
197 end = start + size;
198 enable_register = pci_read_config32(SOC_LPC_DEV,
199 LPC_IO_OR_MEM_DECODE_ENABLE);
200 for (i = 0; i < TOTAL_WIDEIO_PORTS; i++) {
201 current_size = sb_wideio_size(i);
202 if (current_size == 0)
203 continue;
204 start_wideio = pci_read_config16(SOC_LPC_DEV,
205 wio_io_en[i].port);
206 end_wideio = start_wideio + current_size;
207 if ((start >= start_wideio) && (end <= end_wideio)) {
208 index = i;
209 break;
210 }
211 }
212 return index;
213}
214
215/**
216 * @brief Program a LPC wide IO to support an IO range
217 *
218 * @param start = start of range to be routed through wide IO
219 * @param size = size of range to be routed through wide IO
220 *
221 * @return Index of wide IO register used or error
222 */
223int sb_set_wideio_range(uint16_t start, uint16_t size)
224{
225 int i, index = WIDEIO_RANGE_ERROR;
226 uint32_t enable_register;
227 uint8_t alternate_register;
228
229 enable_register = pci_read_config32(SOC_LPC_DEV,
230 LPC_IO_OR_MEM_DECODE_ENABLE);
231 alternate_register = pci_read_config8(SOC_LPC_DEV,
232 LPC_ALT_WIDEIO_RANGE_ENABLE);
233 for (i = 0; i < TOTAL_WIDEIO_PORTS; i++) {
234 if (enable_register & wio_io_en[i].enable)
235 continue;
236 index = i;
237 pci_write_config16(SOC_LPC_DEV, wio_io_en[i].port, start);
238 enable_register |= wio_io_en[i].enable;
239 pci_write_config32(SOC_LPC_DEV, LPC_IO_OR_MEM_DECODE_ENABLE,
240 enable_register);
241 if (size <= 16)
242 alternate_register |= wio_io_en[i].alt;
243 else
244 alternate_register &= ~wio_io_en[i].alt;
245 pci_write_config8(SOC_LPC_DEV,
246 LPC_ALT_WIDEIO_RANGE_ENABLE,
247 alternate_register);
248 break;
249 }
250 return index;
251}
252
Richard Spiegelbec44f22017-11-24 07:41:29 -0700253void configure_stoneyridge_uart(void)
254{
255 u8 byte, byte2;
256
257 if (CONFIG_UART_FOR_CONSOLE < 0 || CONFIG_UART_FOR_CONSOLE > 1)
258 return;
259
260 /* Power on the UART and AMBA devices */
261 byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG56
262 + CONFIG_UART_FOR_CONSOLE * 2);
263 byte |= AOAC_PWR_ON_DEV;
264 write8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG56
265 + CONFIG_UART_FOR_CONSOLE * 2, byte);
266
267 byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG62);
268 byte |= AOAC_PWR_ON_DEV;
269 write8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG62, byte);
270
271 /* Set the GPIO mux to UART */
272 write8((void *)FCH_IOMUXx89_UART0_RTS_L_EGPIO137, 0);
273 write8((void *)FCH_IOMUXx8A_UART0_TXD_EGPIO138, 0);
274 write8((void *)FCH_IOMUXx8E_UART1_RTS_L_EGPIO142, 0);
275 write8((void *)FCH_IOMUXx8F_UART1_TXD_EGPIO143, 0);
276
277 /* Wait for the UART and AMBA devices to indicate power and clock OK */
278 do {
279 udelay(100);
280 byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG57
281 + CONFIG_UART_FOR_CONSOLE * 2);
282 byte &= (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE);
283 byte2 = read8((void *)ACPI_MMIO_BASE + AOAC_BASE
284 + FCH_AOAC_REG63);
285 byte2 &= (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE);
286 } while (!((byte == (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE)) &&
287 (byte2 == (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE))));
288
289}
290
291void sb_pci_port80(void)
292{
293 u8 byte;
294
295 byte = pci_read_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DEC_EN_HIGH);
296 byte &= ~DECODE_IO_PORT_ENABLE4_H; /* disable lpc port 80 */
297 pci_write_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DEC_EN_HIGH, byte);
298}
299
300void sb_lpc_port80(void)
301{
302 u8 byte;
303
304 /* Enable LPC controller */
305 outb(PM_LPC_GATING, PM_INDEX);
306 byte = inb(PM_DATA);
307 byte |= PM_LPC_ENABLE;
308 outb(PM_LPC_GATING, PM_INDEX);
309 outb(byte, PM_DATA);
310
311 /* Enable port 80 LPC decode in pci function 3 configuration space. */
312 byte = pci_read_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DEC_EN_HIGH);
313 byte |= DECODE_IO_PORT_ENABLE4_H; /* enable port 80 */
314 pci_write_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DEC_EN_HIGH, byte);
315}
316
317void sb_lpc_decode(void)
318{
319 u32 tmp = 0;
320
321 /* Enable I/O decode to LPC bus */
322 tmp = DECODE_ENABLE_PARALLEL_PORT0 | DECODE_ENABLE_PARALLEL_PORT2
323 | DECODE_ENABLE_PARALLEL_PORT4 | DECODE_ENABLE_SERIAL_PORT0
324 | DECODE_ENABLE_SERIAL_PORT1 | DECODE_ENABLE_SERIAL_PORT2
325 | DECODE_ENABLE_SERIAL_PORT3 | DECODE_ENABLE_SERIAL_PORT4
326 | DECODE_ENABLE_SERIAL_PORT5 | DECODE_ENABLE_SERIAL_PORT6
327 | DECODE_ENABLE_SERIAL_PORT7 | DECODE_ENABLE_AUDIO_PORT0
328 | DECODE_ENABLE_AUDIO_PORT1 | DECODE_ENABLE_AUDIO_PORT2
329 | DECODE_ENABLE_AUDIO_PORT3 | DECODE_ENABLE_MSS_PORT2
330 | DECODE_ENABLE_MSS_PORT3 | DECODE_ENABLE_FDC_PORT0
331 | DECODE_ENABLE_FDC_PORT1 | DECODE_ENABLE_GAME_PORT
332 | DECODE_ENABLE_KBC_PORT | DECODE_ENABLE_ACPIUC_PORT
333 | DECODE_ENABLE_ADLIB_PORT;
334
335 pci_write_config32(SOC_LPC_DEV, LPC_IO_PORT_DECODE_ENABLE, tmp);
336}
337
338void sb_clk_output_48Mhz(void)
339{
340 u32 ctrl;
341
342 /*
343 * Enable the X14M_25M_48M_OSC pin and leaving it at it's default so
344 * 48Mhz will be on ball AP13 (FT3b package)
345 */
346 ctrl = read32((void *)(ACPI_MMIO_BASE + MISC_BASE + FCH_MISC_REG40));
347
348 /* clear the OSCOUT1_ClkOutputEnb to enable the 48 Mhz clock */
349 ctrl &= ~FCH_MISC_REG40_OSCOUT1_EN;
350 write32((void *)(ACPI_MMIO_BASE + MISC_BASE + FCH_MISC_REG40), ctrl);
351}
352
353static uintptr_t sb_spibase(void)
354{
355 u32 base, enables;
356
357 /* Make sure the base address is predictable */
358 base = pci_read_config32(SOC_LPC_DEV, SPIROM_BASE_ADDRESS_REGISTER);
359 enables = base & 0xf;
360 base &= ~0x3f;
361
362 if (!base) {
363 base = SPI_BASE_ADDRESS;
364 pci_write_config32(SOC_LPC_DEV, SPIROM_BASE_ADDRESS_REGISTER,
365 base | enables | SPI_ROM_ENABLE);
366 /* PCI_COMMAND_MEMORY is read-only and enabled. */
367 }
368 return (uintptr_t)base;
369}
370
371void sb_set_spi100(u16 norm, u16 fast, u16 alt, u16 tpm)
372{
373 uintptr_t base = sb_spibase();
374 write16((void *)base + SPI100_SPEED_CONFIG,
375 (norm << SPI_NORM_SPEED_NEW_SH) |
376 (fast << SPI_FAST_SPEED_NEW_SH) |
377 (alt << SPI_ALT_SPEED_NEW_SH) |
378 (tpm << SPI_TPM_SPEED_NEW_SH));
379 write16((void *)base + SPI100_ENABLE, SPI_USE_SPI100);
380}
381
382void sb_disable_4dw_burst(void)
383{
384 uintptr_t base = sb_spibase();
385 write16((void *)base + SPI100_HOST_PREF_CONFIG,
386 read16((void *)base + SPI100_HOST_PREF_CONFIG)
387 & ~SPI_RD4DW_EN_HOST);
388}
389
390void sb_set_readspeed(u16 norm, u16 fast)
391{
392 uintptr_t base = sb_spibase();
393 write16((void *)base + SPI_CNTRL1, (read16((void *)base + SPI_CNTRL1)
394 & ~SPI_CNTRL1_SPEED_MASK)
395 | (norm << SPI_NORM_SPEED_SH)
396 | (fast << SPI_FAST_SPEED_SH));
397}
398
399void sb_read_mode(u32 mode)
400{
401 uintptr_t base = sb_spibase();
402 write32((void *)base + SPI_CNTRL0,
403 (read32((void *)base + SPI_CNTRL0)
404 & ~SPI_READ_MODE_MASK) | mode);
405}
406
407void sb_tpm_decode_spi(void)
408{
409 u32 spibase = pci_read_config32(SOC_LPC_DEV,
410 SPIROM_BASE_ADDRESS_REGISTER);
411 pci_write_config32(SOC_LPC_DEV, SPIROM_BASE_ADDRESS_REGISTER, spibase
412 | ROUTE_TPM_2_SPI);
413}
414
415/*
416 * Enable 4MB (LPC) ROM access at 0xFFC00000 - 0xFFFFFFFF.
417 *
418 * Hardware should enable LPC ROM by pin straps. This function does not
419 * handle the theoretically possible PCI ROM, FWH, or SPI ROM configurations.
420 *
421 * The southbridge power-on default is to map 512K ROM space.
422 *
423 */
424void sb_enable_rom(void)
425{
426 u8 reg8;
427
428 /*
429 * Decode variable LPC ROM address ranges 1 and 2.
430 * Bits 3-4 are not defined in any publicly available datasheet
431 */
432 reg8 = pci_read_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DECODE_ENABLE);
433 reg8 |= (1 << 3) | (1 << 4);
434 pci_write_config8(SOC_LPC_DEV, LPC_IO_OR_MEM_DECODE_ENABLE, reg8);
435
436 /*
437 * LPC ROM address range 1:
438 * Enable LPC ROM range mirroring start at 0x000e(0000).
439 */
440 pci_write_config16(SOC_LPC_DEV, ROM_ADDRESS_RANGE1_START, 0x000e);
441
442 /* Enable LPC ROM range mirroring end at 0x000f(ffff). */
443 pci_write_config16(SOC_LPC_DEV, ROM_ADDRESS_RANGE1_END, 0x000f);
444
445 /*
446 * LPC ROM address range 2:
447 *
448 * Enable LPC ROM range start at:
449 * 0xfff8(0000): 512KB
450 * 0xfff0(0000): 1MB
451 * 0xffe0(0000): 2MB
452 * 0xffc0(0000): 4MB
453 */
454 pci_write_config16(SOC_LPC_DEV, ROM_ADDRESS_RANGE2_START, 0x10000
455 - (CONFIG_COREBOOT_ROMSIZE_KB >> 6));
456
457 /* Enable LPC ROM range end at 0xffff(ffff). */
458 pci_write_config16(SOC_LPC_DEV, ROM_ADDRESS_RANGE2_END, 0xffff);
459}
460
461void bootblock_fch_early_init(void)
462{
463 sb_enable_rom();
464 sb_lpc_port80();
465 sb_lpc_decode();
466}
467
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600468void sb_enable(device_t dev)
Marc Jones24484842017-05-04 21:17:45 -0600469{
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600470 printk(BIOS_DEBUG, "%s\n", __func__);
Marc Jones24484842017-05-04 21:17:45 -0600471}
472
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600473static void sb_init_acpi_ports(void)
Marc Jones24484842017-05-04 21:17:45 -0600474{
Marshall Dawson91b80412017-09-27 16:44:40 -0600475 u32 reg;
476
Marc Jones24484842017-05-04 21:17:45 -0600477 /* We use some of these ports in SMM regardless of whether or not
478 * ACPI tables are generated. Enable these ports indiscriminately.
479 */
480
481 pm_write16(PM_EVT_BLK, ACPI_PM_EVT_BLK);
482 pm_write16(PM1_CNT_BLK, ACPI_PM1_CNT_BLK);
483 pm_write16(PM_TMR_BLK, ACPI_PM_TMR_BLK);
484 pm_write16(PM_GPE0_BLK, ACPI_GPE0_BLK);
485 /* CpuControl is in \_PR.CP00, 6 bytes */
486 pm_write16(PM_CPU_CTRL, ACPI_CPU_CONTROL);
487
488 if (IS_ENABLED(CONFIG_HAVE_SMI_HANDLER)) {
Marshall Dawsona05fdcb2017-09-27 15:01:37 -0600489 /* APMC - SMI Command Port */
Marshall Dawsone9b862e2017-09-22 15:14:46 -0600490 pm_write16(PM_ACPI_SMI_CMD, APM_CNT);
Marshall Dawsona05fdcb2017-09-27 15:01:37 -0600491 configure_smi(SMITYPE_SMI_CMD_PORT, SMI_MODE_SMI);
Marshall Dawson91b80412017-09-27 16:44:40 -0600492
493 /* SMI on SlpTyp requires sending SMI before completion
494 * response of the I/O write. The BKDG also specifies
495 * clearing ForceStpClkRetry for SMI trapping.
496 */
497 reg = pm_read32(PM_PCI_CTRL);
498 reg |= FORCE_SLPSTATE_RETRY;
499 reg &= ~FORCE_STPCLK_RETRY;
500 pm_write32(PM_PCI_CTRL, reg);
501
502 /* Disable SlpTyp feature */
503 reg = pm_read8(PM_RST_CTRL1);
504 reg &= ~SLPTYPE_CONTROL_EN;
505 pm_write8(PM_RST_CTRL1, reg);
506
507 configure_smi(SMITYPE_SLP_TYP, SMI_MODE_SMI);
Marc Jones24484842017-05-04 21:17:45 -0600508 } else {
509 pm_write16(PM_ACPI_SMI_CMD, 0);
510 }
511
Marshall Dawson5e2e74f2017-11-10 09:59:56 -0700512 /* Decode ACPI registers and enable standard features */
513 pm_write8(PM_ACPI_CONF, PM_ACPI_DECODE_STD |
514 PM_ACPI_GLOBAL_EN |
515 PM_ACPI_RTC_EN_EN |
516 PM_ACPI_TIMER_EN_EN);
Marc Jones24484842017-05-04 21:17:45 -0600517}
518
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600519void southbridge_init(void *chip_info)
Marc Jones24484842017-05-04 21:17:45 -0600520{
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600521 sb_init_acpi_ports();
Marc Jones24484842017-05-04 21:17:45 -0600522}
523
Marc Jonesdfeb1c42017-08-07 19:08:24 -0600524void southbridge_final(void *chip_info)
Marc Jones24484842017-05-04 21:17:45 -0600525{
Richard Spiegel38f19402017-09-29 11:39:46 -0700526 if (IS_ENABLED(CONFIG_STONEYRIDGE_IMC_FWM)) {
527 agesawrapper_fchecfancontrolservice();
528 if (!IS_ENABLED(CONFIG_ACPI_ENABLE_THERMAL_ZONE))
529 enable_imc_thermal_zone();
530 }
Marc Jones24484842017-05-04 21:17:45 -0600531}
Marshall Dawson8a906df2017-06-13 14:19:02 -0600532
533/*
534 * Update the PCI devices with a valid IRQ number
535 * that is set in the mainboard PCI_IRQ structures.
536 */
537static void set_pci_irqs(void *unused)
538{
539 /* Write PCI_INTR regs 0xC00/0xC01 */
540 write_pci_int_table();
541
542 /* Write IRQs for all devicetree enabled devices */
543 write_pci_cfg_irqs();
544}
545
546/*
547 * Hook this function into the PCI state machine
548 * on entry into BS_DEV_ENABLE.
549 */
550BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);