WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 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. |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <arch/acpi.h> |
zbao | 1897c2c | 2015-11-05 20:25:59 +0800 | [diff] [blame] | 18 | #include <arch/io.h> |
Elyes HAOUAS | d2b9ec1 | 2018-10-27 09:41:02 +0200 | [diff] [blame] | 19 | #include <arch/cpu.h> |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 20 | #include <cpu/x86/lapic.h> |
| 21 | #include <cpu/x86/bist.h> |
| 22 | #include <cpu/amd/car.h> |
Kyösti Mälkki | bebd766 | 2017-04-13 15:25:43 +0300 | [diff] [blame] | 23 | #include <northbridge/amd/agesa/state_machine.h> |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 24 | #include <northbridge/amd/pi/agesawrapper.h> |
| 25 | #include <northbridge/amd/pi/agesawrapper_call.h> |
| 26 | #include <southbridge/amd/pi/hudson/hudson.h> |
| 27 | |
| 28 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 29 | { |
| 30 | u32 val; |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 31 | |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 32 | hudson_lpc_port80(); |
| 33 | |
| 34 | if (!cpu_init_detectedx && boot_cpu()) { |
| 35 | post_code(0x30); |
| 36 | |
Zheng Bao | 2286138 | 2015-11-21 12:19:22 +0800 | [diff] [blame] | 37 | #if IS_ENABLED(CONFIG_HUDSON_UART) |
| 38 | configure_hudson_uart(); |
| 39 | #endif |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 40 | post_code(0x31); |
| 41 | console_init(); |
| 42 | } |
| 43 | |
| 44 | /* Halt if there was a built in self test failure */ |
| 45 | post_code(0x34); |
zbao | fe234c4 | 2015-07-02 16:53:09 -0400 | [diff] [blame] | 46 | report_bist_failure(bist & 0x7FFFFFFF); /* Mask bit 31. One result of Silicon Observation */ |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 47 | |
| 48 | /* Load MPB */ |
| 49 | val = cpuid_eax(1); |
Elyes HAOUAS | e53e488c | 2016-08-21 12:19:25 +0200 | [diff] [blame] | 50 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 51 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 52 | |
| 53 | post_code(0x37); |
| 54 | AGESAWRAPPER(amdinitreset); |
| 55 | post_code(0x38); |
| 56 | printk(BIOS_DEBUG, "Got past agesawrapper_amdinitreset\n"); |
| 57 | |
| 58 | post_code(0x39); |
| 59 | AGESAWRAPPER(amdinitearly); |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 60 | |
Kyösti Mälkki | 1b183aa | 2017-02-26 10:11:21 +0200 | [diff] [blame] | 61 | post_code(0x40); |
| 62 | AGESAWRAPPER(amdinitpost); |
Kyösti Mälkki | bebd766 | 2017-04-13 15:25:43 +0300 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void agesa_postcar(struct sysinfo *cb) |
| 66 | { |
Kyösti Mälkki | 1b183aa | 2017-02-26 10:11:21 +0200 | [diff] [blame] | 67 | post_code(0x41); |
| 68 | AGESAWRAPPER(amdinitenv); |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 69 | |
Kyösti Mälkki | 1b183aa | 2017-02-26 10:11:21 +0200 | [diff] [blame] | 70 | if (acpi_is_wakeup_s4()) { |
zbao | 1897c2c | 2015-11-05 20:25:59 +0800 | [diff] [blame] | 71 | outb(0xEE, PM_INDEX); |
| 72 | outb(0x8, PM_DATA); |
| 73 | } |
WANG Siyuan | 01e3e06 | 2015-05-20 14:47:58 +0800 | [diff] [blame] | 74 | } |