Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 2 | |
Michał Żygowski | f3db2ae | 2019-11-24 13:26:10 +0100 | [diff] [blame] | 3 | #include <amdblocks/acpimmio.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 4 | #include <console/console.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 5 | #include <arch/io.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 6 | #include <device/mmio.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 7 | #include <acpi/acpi.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
| 10 | #include <device/pci_ids.h> |
| 11 | #include <device/pci_ops.h> |
Elyes HAOUAS | ab89edb | 2019-05-15 21:10:44 +0200 | [diff] [blame] | 12 | #include <types.h> |
| 13 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 14 | #include "hudson.h" |
| 15 | #include "smbus.h" |
| 16 | #include "smi.h" |
WANG Siyuan | c7667f0 | 2015-06-23 22:28:17 +0800 | [diff] [blame] | 17 | #include "fchec.h" |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 18 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 19 | int acpi_get_sleep_type(void) |
| 20 | { |
| 21 | u16 tmp = inw(ACPI_PM1_CNT_BLK); |
| 22 | tmp = ((tmp & (7 << 10)) >> 10); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 23 | return (int)tmp; |
| 24 | } |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 25 | |
Elyes HAOUAS | d9ef546 | 2018-05-19 17:08:23 +0200 | [diff] [blame] | 26 | void hudson_enable(struct device *dev) |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 27 | { |
Elyes HAOUAS | bfc255a | 2020-03-07 13:05:14 +0100 | [diff] [blame] | 28 | printk(BIOS_DEBUG, "%s()\n", __func__); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 29 | switch (dev->path.pci.devfn) { |
Kyösti Mälkki | b11d4e3 | 2018-05-20 10:39:10 +0300 | [diff] [blame] | 30 | case PCI_DEVFN(0x14, 7): /* SD */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 31 | if (dev->enabled == 0) { |
Kyösti Mälkki | 0bc06ab | 2018-05-20 15:41:05 +0300 | [diff] [blame] | 32 | u32 sd_device_id = pci_read_config16(dev, PCI_DEVICE_ID); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 33 | /* turn off the SDHC controller in the PM reg */ |
| 34 | u8 reg8; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 35 | if (sd_device_id == PCI_DID_AMD_HUDSON_SD) { |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 36 | reg8 = pm_read8(PM_HUD_SD_FLASH_CTRL); |
| 37 | reg8 &= ~BIT(0); |
| 38 | pm_write8(PM_HUD_SD_FLASH_CTRL, reg8); |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 39 | } else if (sd_device_id == PCI_DID_AMD_YANGTZE_SD) { |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 40 | reg8 = pm_read8(PM_YANG_SD_FLASH_CTRL); |
| 41 | reg8 &= ~BIT(0); |
| 42 | pm_write8(PM_YANG_SD_FLASH_CTRL, reg8); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 43 | } |
| 44 | /* remove device 0:14.7 from PCI space */ |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 45 | reg8 = pm_read8(PM_MANUAL_RESET); |
| 46 | reg8 &= ~BIT(6); |
| 47 | pm_write8(PM_MANUAL_RESET, reg8); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 48 | } |
| 49 | break; |
| 50 | default: |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 55 | static void hudson_init_acpi_ports(void) |
| 56 | { |
| 57 | /* We use some of these ports in SMM regardless of whether or not |
| 58 | * ACPI tables are generated. Enable these ports indiscriminately. |
| 59 | */ |
| 60 | |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 61 | pm_write16(PM_EVT_BLK, ACPI_PM_EVT_BLK); |
| 62 | pm_write16(PM1_CNT_BLK, ACPI_PM1_CNT_BLK); |
| 63 | pm_write16(PM_TMR_BLK, ACPI_PM_TMR_BLK); |
| 64 | pm_write16(PM_GPE0_BLK, ACPI_GPE0_BLK); |
Timothy Pearson | 033bb4b | 2015-02-10 22:21:39 -0600 | [diff] [blame] | 65 | /* CpuControl is in \_PR.CP00, 6 bytes */ |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 66 | pm_write16(PM_CPU_CTRL, ACPI_CPU_CONTROL); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 67 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 68 | if (CONFIG(HAVE_SMI_HANDLER)) { |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 69 | pm_write16(PM_ACPI_SMI_CMD, ACPI_SMI_CTL_PORT); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 70 | hudson_enable_acpi_cmd_smi(); |
| 71 | } else { |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 72 | pm_write16(PM_ACPI_SMI_CMD, 0); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /* AcpiDecodeEnable, When set, SB uses the contents of the PM registers |
| 76 | * at index 60-6B to decode ACPI I/O address. AcpiSmiEn & SmiCmdEn |
| 77 | */ |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 78 | pm_write8(PM_ACPI_CONF, BIT(0) | BIT(1) | BIT(4) | BIT(2)); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static void hudson_init(void *chip_info) |
| 82 | { |
| 83 | hudson_init_acpi_ports(); |
| 84 | } |
| 85 | |
| 86 | static void hudson_final(void *chip_info) |
| 87 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 88 | if (CONFIG(HUDSON_IMC_FWM)) { |
Kyösti Mälkki | eb064b3 | 2017-08-24 21:20:10 +0300 | [diff] [blame] | 89 | agesawrapper_fchecfancontrolservice(); |
Arthur Heymans | 03a6ccd | 2022-11-01 23:38:19 +0100 | [diff] [blame] | 90 | enable_imc_thermal_zone(); |
Kyösti Mälkki | eb064b3 | 2017-08-24 21:20:10 +0300 | [diff] [blame] | 91 | } |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 92 | } |
| 93 | |
Dave Frodin | bc21a41 | 2015-01-19 11:40:38 -0700 | [diff] [blame] | 94 | struct chip_operations southbridge_amd_pi_hudson_ops = { |
Nicholas Sudsgaard | bfb11be | 2024-01-30 09:53:46 +0900 | [diff] [blame] | 95 | .name = "ATI HUDSON", |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 96 | .enable_dev = hudson_enable, |
| 97 | .init = hudson_init, |
| 98 | .final = hudson_final |
| 99 | }; |