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