blob: c7927dc7c1873b742aebab8e024b2ebe0ef73b0e [file] [log] [blame]
Kyösti Mälkki005028e2014-06-19 23:12:15 +03001/*
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 Griffith230fe0e2014-08-31 22:40:57 -060023#include <device/device.h>
24#include <device/pci_def.h>
25#include <device/pci_ops.h>
Kyösti Mälkki005028e2014-06-19 23:12:15 +030026
Bruce Griffith230fe0e2014-08-31 22:40:57 -060027#include <agesawrapper.h>
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030028#include <northbridge/amd/agesa/agesawrapper_call.h>
Kyösti Mälkki005028e2014-06-19 23:12:15 +030029
Kyösti Mälkki9248bb32014-07-22 15:56:59 +030030#if IS_ENABLED(CONFIG_HUDSON_IMC_FWM)
31#include <southbridge/amd/agesa/hudson/imc.h>
32#endif
Kyösti Mälkkib6f3da42014-07-07 15:06:00 +030033#if CONFIG_AMD_SB_CIMX
34#include <sb_cimx.h>
35#endif
36
Bruce Griffith230fe0e2014-08-31 22:40:57 -060037#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älkki005028e2014-06-19 23:12:15 +030040static void agesawrapper_post_device(void *unused)
41{
Kyösti Mälkki005028e2014-06-19 23:12:15 +030042 if (acpi_is_wakeup_s3())
43 return;
44
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030045 AGESAWRAPPER(amdinitlate);
Kyösti Mälkki005028e2014-06-19 23:12:15 +030046
Bruce Griffith230fe0e2014-08-31 22:40:57 -060047#if (NORTHBRIDGE_00700F00) || (NORTHBRIDGE_00730F01)
Kyösti Mälkki32d9e922014-07-22 19:27:52 +030048 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älkki9248bb32014-07-22 15:56:59 +030061#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älkkib6f3da42014-07-07 15:06:00 +030066#if CONFIG_AMD_SB_CIMX
67 sb_Late_Post();
68#endif
Kyösti Mälkki005028e2014-06-19 23:12:15 +030069 if (!acpi_s3_resume_allowed())
70 return;
71
Kyösti Mälkki7b23ae02014-07-04 16:14:37 +030072 AGESAWRAPPER(amdS3Save);
Kyösti Mälkki005028e2014-06-19 23:12:15 +030073}
74
75BOOT_STATE_INIT_ENTRIES(agesa_bscb) = {
76 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT,
77 agesawrapper_post_device, NULL),
78};