Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 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 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <arch/acpi.h> |
| 21 | #include <bootstate.h> |
| 22 | #include <console/console.h> |
Bruce Griffith | 230fe0e | 2014-08-31 22:40:57 -0600 | [diff] [blame^] | 23 | #include <device/device.h> |
| 24 | #include <device/pci_def.h> |
| 25 | #include <device/pci_ops.h> |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 26 | |
Bruce Griffith | 230fe0e | 2014-08-31 22:40:57 -0600 | [diff] [blame^] | 27 | #include <agesawrapper.h> |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 28 | #include <northbridge/amd/agesa/agesawrapper_call.h> |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 29 | |
Kyösti Mälkki | 9248bb3 | 2014-07-22 15:56:59 +0300 | [diff] [blame] | 30 | #if IS_ENABLED(CONFIG_HUDSON_IMC_FWM) |
| 31 | #include <southbridge/amd/agesa/hudson/imc.h> |
| 32 | #endif |
Kyösti Mälkki | b6f3da4 | 2014-07-07 15:06:00 +0300 | [diff] [blame] | 33 | #if CONFIG_AMD_SB_CIMX |
| 34 | #include <sb_cimx.h> |
| 35 | #endif |
| 36 | |
Bruce Griffith | 230fe0e | 2014-08-31 22:40:57 -0600 | [diff] [blame^] | 37 | #define NORTHBRIDGE_00700F00 IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY_16KB) |
| 38 | #define NORTHBRIDGE_00730F01 IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_00730F01) |
| 39 | |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 40 | static void agesawrapper_post_device(void *unused) |
| 41 | { |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 42 | if (acpi_is_wakeup_s3()) |
| 43 | return; |
| 44 | |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 45 | AGESAWRAPPER(amdinitlate); |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 46 | |
Bruce Griffith | 230fe0e | 2014-08-31 22:40:57 -0600 | [diff] [blame^] | 47 | #if (NORTHBRIDGE_00700F00) || (NORTHBRIDGE_00730F01) |
Kyösti Mälkki | 32d9e92 | 2014-07-22 19:27:52 +0300 | [diff] [blame] | 48 | device_t dev; |
| 49 | u32 value; |
| 50 | dev = dev_find_slot(0, PCI_DEVFN(0, 0)); /* clear IoapicSbFeatureEn */ |
| 51 | pci_write_config32(dev, 0xF8, 0); |
| 52 | pci_write_config32(dev, 0xFC, 5); /* TODO: move it to dsdt.asl */ |
| 53 | |
| 54 | /* disable No Snoop */ |
| 55 | dev = dev_find_slot(0, PCI_DEVFN(1, 1)); |
| 56 | value = pci_read_config32(dev, 0x60); |
| 57 | value &= ~(1 << 11); |
| 58 | pci_write_config32(dev, 0x60, value); |
| 59 | #endif |
| 60 | |
Kyösti Mälkki | 9248bb3 | 2014-07-22 15:56:59 +0300 | [diff] [blame] | 61 | #if IS_ENABLED(CONFIG_HUDSON_IMC_FWM) |
| 62 | /* AMD AGESA does not enable thermal zone, so we enable it here. */ |
| 63 | enable_imc_thermal_zone(); |
| 64 | #endif |
| 65 | |
Kyösti Mälkki | b6f3da4 | 2014-07-07 15:06:00 +0300 | [diff] [blame] | 66 | #if CONFIG_AMD_SB_CIMX |
| 67 | sb_Late_Post(); |
| 68 | #endif |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 69 | if (!acpi_s3_resume_allowed()) |
| 70 | return; |
| 71 | |
Kyösti Mälkki | 7b23ae0 | 2014-07-04 16:14:37 +0300 | [diff] [blame] | 72 | AGESAWRAPPER(amdS3Save); |
Kyösti Mälkki | 005028e | 2014-06-19 23:12:15 +0300 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | BOOT_STATE_INIT_ENTRIES(agesa_bscb) = { |
| 76 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT, |
| 77 | agesawrapper_post_device, NULL), |
| 78 | }; |