blob: 00c89005505536e2643b987abf7c4bc40e9620e6 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03003
Michał Żygowskif3db2ae2019-11-24 13:26:10 +01004#include <amdblocks/acpimmio.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03005#include <console/console.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03006#include <arch/io.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +02007#include <device/mmio.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07008#include <acpi/acpi.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03009#include <device/device.h>
10#include <device/pci.h>
Kyösti Mälkki0bc06ab2018-05-20 15:41:05 +030011#include <device/pci_def.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030012#include <device/pci_ids.h>
13#include <device/pci_ops.h>
Elyes HAOUASab89edb2019-05-15 21:10:44 +020014#include <types.h>
15
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030016#include "hudson.h"
17#include "smbus.h"
18#include "smi.h"
WANG Siyuanc7667f02015-06-23 22:28:17 +080019#include "fchec.h"
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030020
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030021int acpi_get_sleep_type(void)
22{
23 u16 tmp = inw(ACPI_PM1_CNT_BLK);
24 tmp = ((tmp & (7 << 10)) >> 10);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030025 return (int)tmp;
26}
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030027
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020028void hudson_enable(struct device *dev)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030029{
30 printk(BIOS_DEBUG, "hudson_enable()\n");
31 switch (dev->path.pci.devfn) {
Kyösti Mälkkib11d4e32018-05-20 10:39:10 +030032 case PCI_DEVFN(0x14, 7): /* SD */
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030033 if (dev->enabled == 0) {
Kyösti Mälkki0bc06ab2018-05-20 15:41:05 +030034 u32 sd_device_id = pci_read_config16(dev, PCI_DEVICE_ID);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030035 /* turn off the SDHC controller in the PM reg */
36 u8 reg8;
37 if (sd_device_id == PCI_DEVICE_ID_AMD_HUDSON_SD) {
Marc Jonesd7717862017-04-09 17:55:56 -060038 reg8 = pm_read8(PM_HUD_SD_FLASH_CTRL);
39 reg8 &= ~BIT(0);
40 pm_write8(PM_HUD_SD_FLASH_CTRL, reg8);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030041 }
42 else if (sd_device_id == PCI_DEVICE_ID_AMD_YANGTZE_SD) {
Marc Jonesd7717862017-04-09 17:55:56 -060043 reg8 = pm_read8(PM_YANG_SD_FLASH_CTRL);
44 reg8 &= ~BIT(0);
45 pm_write8(PM_YANG_SD_FLASH_CTRL, reg8);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030046 }
47 /* remove device 0:14.7 from PCI space */
Marc Jonesd7717862017-04-09 17:55:56 -060048 reg8 = pm_read8(PM_MANUAL_RESET);
49 reg8 &= ~BIT(6);
50 pm_write8(PM_MANUAL_RESET, reg8);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030051 }
52 break;
53 default:
54 break;
55 }
56}
57
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030058static void hudson_init_acpi_ports(void)
59{
60 /* We use some of these ports in SMM regardless of whether or not
61 * ACPI tables are generated. Enable these ports indiscriminately.
62 */
63
Marc Jonesd7717862017-04-09 17:55:56 -060064 pm_write16(PM_EVT_BLK, ACPI_PM_EVT_BLK);
65 pm_write16(PM1_CNT_BLK, ACPI_PM1_CNT_BLK);
66 pm_write16(PM_TMR_BLK, ACPI_PM_TMR_BLK);
67 pm_write16(PM_GPE0_BLK, ACPI_GPE0_BLK);
Timothy Pearson033bb4b2015-02-10 22:21:39 -060068 /* CpuControl is in \_PR.CP00, 6 bytes */
Marc Jonesd7717862017-04-09 17:55:56 -060069 pm_write16(PM_CPU_CTRL, ACPI_CPU_CONTROL);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030070
Julius Wernercd49cce2019-03-05 16:53:33 -080071 if (CONFIG(HAVE_SMI_HANDLER)) {
Marc Jonesd7717862017-04-09 17:55:56 -060072 pm_write16(PM_ACPI_SMI_CMD, ACPI_SMI_CTL_PORT);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030073 hudson_enable_acpi_cmd_smi();
74 } else {
Marc Jonesd7717862017-04-09 17:55:56 -060075 pm_write16(PM_ACPI_SMI_CMD, 0);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030076 }
77
78 /* AcpiDecodeEnable, When set, SB uses the contents of the PM registers
79 * at index 60-6B to decode ACPI I/O address. AcpiSmiEn & SmiCmdEn
80 */
Marc Jonesd7717862017-04-09 17:55:56 -060081 pm_write8(PM_ACPI_CONF, BIT(0) | BIT(1) | BIT(4) | BIT(2));
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030082}
83
84static void hudson_init(void *chip_info)
85{
86 hudson_init_acpi_ports();
87}
88
89static void hudson_final(void *chip_info)
90{
Julius Wernercd49cce2019-03-05 16:53:33 -080091 if (CONFIG(HUDSON_IMC_FWM)) {
Kyösti Mälkkieb064b32017-08-24 21:20:10 +030092 agesawrapper_fchecfancontrolservice();
Julius Wernercd49cce2019-03-05 16:53:33 -080093 if (!CONFIG(ACPI_ENABLE_THERMAL_ZONE))
Kyösti Mälkkieb064b32017-08-24 21:20:10 +030094 enable_imc_thermal_zone();
95 }
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030096}
97
Dave Frodinbc21a412015-01-19 11:40:38 -070098struct chip_operations southbridge_amd_pi_hudson_ops = {
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030099 CHIP_NAME("ATI HUDSON")
100 .enable_dev = hudson_enable,
101 .init = hudson_init,
102 .final = hudson_final
103};