blob: b947be123f375ed775775d729680ae376679744c [file] [log] [blame]
Marc Jones24484842017-05-04 21:17:45 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
5 *
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>
19#include <arch/acpi.h>
Marshall Dawson8a906df2017-06-13 14:19:02 -060020#include <bootstate.h>
Marshall Dawsone9b862e2017-09-22 15:14:46 -060021#include <cpu/x86/smm.h>
Marc Jones24484842017-05-04 21:17:45 -060022#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <device/pci_ops.h>
26#include <cbmem.h>
Marshall Dawson8a906df2017-06-13 14:19:02 -060027#include <amd_pci_util.h>
Marc Jonesdfeb1c42017-08-07 19:08:24 -060028#include <soc/southbridge.h>
Marc Jones24484842017-05-04 21:17:45 -060029#include <soc/smbus.h>
30#include <soc/smi.h>
Marc Jones24484842017-05-04 21:17:45 -060031#include <fchec.h>
Marc Jones24484842017-05-04 21:17:45 -060032
33
34int acpi_get_sleep_type(void)
35{
36 u16 tmp = inw(ACPI_PM1_CNT_BLK);
37 tmp = ((tmp & (7 << 10)) >> 10);
38 return (int)tmp;
39}
40
Marc Jonesdfeb1c42017-08-07 19:08:24 -060041void sb_enable(device_t dev)
Marc Jones24484842017-05-04 21:17:45 -060042{
Marc Jonesdfeb1c42017-08-07 19:08:24 -060043 printk(BIOS_DEBUG, "%s\n", __func__);
Marc Jones24484842017-05-04 21:17:45 -060044}
45
Marc Jonesdfeb1c42017-08-07 19:08:24 -060046static void sb_init_acpi_ports(void)
Marc Jones24484842017-05-04 21:17:45 -060047{
48 /* We use some of these ports in SMM regardless of whether or not
49 * ACPI tables are generated. Enable these ports indiscriminately.
50 */
51
52 pm_write16(PM_EVT_BLK, ACPI_PM_EVT_BLK);
53 pm_write16(PM1_CNT_BLK, ACPI_PM1_CNT_BLK);
54 pm_write16(PM_TMR_BLK, ACPI_PM_TMR_BLK);
55 pm_write16(PM_GPE0_BLK, ACPI_GPE0_BLK);
56 /* CpuControl is in \_PR.CP00, 6 bytes */
57 pm_write16(PM_CPU_CTRL, ACPI_CPU_CONTROL);
58
59 if (IS_ENABLED(CONFIG_HAVE_SMI_HANDLER)) {
Marshall Dawsona05fdcb2017-09-27 15:01:37 -060060 /* APMC - SMI Command Port */
Marshall Dawsone9b862e2017-09-22 15:14:46 -060061 pm_write16(PM_ACPI_SMI_CMD, APM_CNT);
Marshall Dawsona05fdcb2017-09-27 15:01:37 -060062 configure_smi(SMITYPE_SMI_CMD_PORT, SMI_MODE_SMI);
Marc Jones24484842017-05-04 21:17:45 -060063 } else {
64 pm_write16(PM_ACPI_SMI_CMD, 0);
65 }
66
67 /* AcpiDecodeEnable, When set, SB uses the contents of the PM registers
68 * at index 60-6B to decode ACPI I/O address. AcpiSmiEn & SmiCmdEn
69 */
70 pm_write8(PM_ACPI_CONF, BIT(0) | BIT(1) | BIT(4) | BIT(2));
71}
72
Marc Jonesdfeb1c42017-08-07 19:08:24 -060073void southbridge_init(void *chip_info)
Marc Jones24484842017-05-04 21:17:45 -060074{
Marc Jonesdfeb1c42017-08-07 19:08:24 -060075 sb_init_acpi_ports();
Marc Jones24484842017-05-04 21:17:45 -060076}
77
Marc Jonesdfeb1c42017-08-07 19:08:24 -060078void southbridge_final(void *chip_info)
Marc Jones24484842017-05-04 21:17:45 -060079{
Richard Spiegel38f19402017-09-29 11:39:46 -070080 if (IS_ENABLED(CONFIG_STONEYRIDGE_IMC_FWM)) {
81 agesawrapper_fchecfancontrolservice();
82 if (!IS_ENABLED(CONFIG_ACPI_ENABLE_THERMAL_ZONE))
83 enable_imc_thermal_zone();
84 }
Marc Jones24484842017-05-04 21:17:45 -060085}
Marshall Dawson8a906df2017-06-13 14:19:02 -060086
87/*
88 * Update the PCI devices with a valid IRQ number
89 * that is set in the mainboard PCI_IRQ structures.
90 */
91static void set_pci_irqs(void *unused)
92{
93 /* Write PCI_INTR regs 0xC00/0xC01 */
94 write_pci_int_table();
95
96 /* Write IRQs for all devicetree enabled devices */
97 write_pci_cfg_irqs();
98}
99
100/*
101 * Hook this function into the PCI state machine
102 * on entry into BS_DEV_ENABLE.
103 */
104BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);