Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [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 | |
Kyösti Mälkki | f21c2ac | 2014-10-19 09:35:18 +0300 | [diff] [blame] | 20 | #include <northbridge/amd/agesa/agesawrapper.h> |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 21 | |
| 22 | #include <arch/acpi.h> |
| 23 | #include <arch/cpu.h> |
| 24 | #include <arch/io.h> |
| 25 | #include <arch/stages.h> |
| 26 | #include <cbmem.h> |
| 27 | #include <console/console.h> |
| 28 | #include <cpu/amd/agesa/s3_resume.h> |
| 29 | #include <cpu/x86/bist.h> |
| 30 | #include <cpu/x86/lapic.h> |
| 31 | #include <cpu/amd/car.h> |
| 32 | #include <device/pci_def.h> |
| 33 | #include <device/pci_ids.h> |
| 34 | #include <stdint.h> |
| 35 | #include <string.h> |
| 36 | #include <southbridge/amd/agesa/hudson/hudson.h> |
| 37 | |
| 38 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 39 | { |
| 40 | u32 val; |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 41 | agesawrapper_amdinitmmio(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 42 | |
Kyösti Mälkki | 88ff8b5 | 2014-11-21 17:40:37 +0200 | [diff] [blame] | 43 | /* Set LPC decode enables. */ |
| 44 | pci_devfn_t dev = PCI_DEV(0, 0x14, 3); |
| 45 | pci_write_config32(dev, 0x44, 0xff03ffd5); |
| 46 | |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 47 | hudson_lpc_port80(); |
| 48 | |
| 49 | if (!cpu_init_detectedx && boot_cpu()) { |
| 50 | post_code(0x30); |
| 51 | |
| 52 | post_code(0x31); |
| 53 | console_init(); |
| 54 | } |
| 55 | |
| 56 | /* Halt if there was a built in self test failure */ |
| 57 | post_code(0x34); |
| 58 | report_bist_failure(bist); |
| 59 | |
| 60 | /* Load MPB */ |
| 61 | val = cpuid_eax(1); |
| 62 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 63 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
| 64 | |
| 65 | post_code(0x37); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 66 | agesawrapper_amdinitreset(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 67 | post_code(0x39); |
| 68 | |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 69 | agesawrapper_amdinitearly(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 70 | int s3resume = acpi_is_wakeup_early() && acpi_s3_resume_allowed(); |
| 71 | if (!s3resume) { |
| 72 | post_code(0x40); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 73 | agesawrapper_amdinitpost(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 74 | post_code(0x41); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 75 | agesawrapper_amdinitenv(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 76 | disable_cache_as_ram(); |
| 77 | } else { /* S3 detect */ |
| 78 | printk(BIOS_INFO, "S3 detected\n"); |
| 79 | |
| 80 | post_code(0x60); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 81 | agesawrapper_amdinitresume(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 82 | |
Kyösti Mälkki | b139b5e | 2014-10-20 07:41:20 +0300 | [diff] [blame] | 83 | agesawrapper_amdinitcpuio(); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame^] | 84 | agesawrapper_amds3laterestore(); |
Edward O'Callaghan | 32960e3 | 2014-11-23 17:38:52 +1100 | [diff] [blame] | 85 | |
| 86 | post_code(0x61); |
| 87 | prepare_for_resume(); |
| 88 | } |
| 89 | |
| 90 | post_code(0x50); |
| 91 | copy_and_run(); |
| 92 | |
| 93 | post_code(0x54); /* Should never see this post code. */ |
| 94 | } |