2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
5 * Copyright (C) 2014 Sage Electronic Engineering, LLC
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
23 #include <device/pci_def.h>
24 #include <device/pci_ids.h>
25 #include <arch/acpi.h>
27 #include <arch/stages.h>
28 #include <device/pnp_def.h>
30 #include <cpu/x86/lapic.h>
31 #include <console/console.h>
32 #include <console/loglevel.h>
33 #include <cpu/amd/car.h>
34 #include <northbridge/amd/agesa/agesawrapper.h>
35 #include <cpu/x86/bist.h>
36 #include <cpu/x86/lapic.h>
37 #include <southbridge/amd/agesa/hudson/hudson.h>
38 #include <cpu/amd/agesa/s3_resume.h>
40 #include <superio/nuvoton/common/nuvoton.h>
41 #include <superio/nuvoton/nct5104d/nct5104d.h>
43 #define SERIAL_DEV PNP_DEV(0x4E, NCT5104D_SP4)
45 void cache_as_ram_main(unsigned long bist
, unsigned long cpu_init_detectedx
)
53 /* Set LPC decode enables. */
54 pci_devfn_t dev
= PCI_DEV(0, 0x14, 3);
55 pci_write_config32(dev
, 0x44, 0xff03ffd5);
59 /* Enable the AcpiMmio space */
63 /* Set auxiliary output clock frequency on OSCOUT1 pin to be 25MHz */
64 /* Set auxiliary output clock frequency on OSCOUT2 pin to be 48MHz */
65 addr32
= (u32
*)0xfed80e28;
67 t32
&= 0xffc0ffff; // Clr bits [21:19] & [18:16]
68 t32
|= 0x00010000; // Set bit 16 for 25MHz
71 /* Enable Auxiliary OSCOUT1/OSCOUT2 */
72 addr32
= (u32
*)0xfed80e40;
74 t32
&= 0xffffff7b; // clear 2, 7
77 if (!cpu_init_detectedx
&& boot_cpu()) {
81 nct5104d_enable_uartd(SERIAL_DEV
);
82 nuvoton_enable_serial(SERIAL_DEV
, CONFIG_TTYS0_BASE
);
86 /* Halt if there was a built in self test failure */
88 report_bist_failure(bist
);
92 printk(BIOS_DEBUG
, "BSP Family_Model: %08x\n", val
);
93 printk(BIOS_DEBUG
, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx
);
96 agesawrapper_amdinitreset();
98 printk(BIOS_DEBUG
, "Got past yangtze_early_setup\n");
102 agesawrapper_amdinitearly();
103 int s3resume
= acpi_is_wakeup_s3();
106 agesawrapper_amdinitpost();
108 agesawrapper_amdinitenv();
109 /* TODO: Disable cache is not ok. */
110 disable_cache_as_ram();
111 } else { /* S3 detect */
112 printk(BIOS_INFO
, "S3 detected\n");
115 agesawrapper_amdinitresume();
118 agesawrapper_amds3laterestore();
121 prepare_for_resume();
130 post_code(0x54); /* Should never see this post code. */