Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [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 | |
| 16 | #include <stdint.h> |
| 17 | #include <string.h> |
| 18 | #include <device/pci_def.h> |
| 19 | #include <device/pci_ids.h> |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 20 | #include <arch/io.h> |
| 21 | #include <arch/stages.h> |
| 22 | #include <device/pnp_def.h> |
| 23 | #include <arch/cpu.h> |
| 24 | #include <cpu/x86/lapic.h> |
| 25 | #include <console/console.h> |
| 26 | #include <commonlib/loglevel.h> |
| 27 | #include <cpu/amd/car.h> |
| 28 | #include <northbridge/amd/pi/agesawrapper.h> |
| 29 | #include <northbridge/amd/pi/agesawrapper_call.h> |
| 30 | #include <cpu/x86/bist.h> |
| 31 | #include <cpu/x86/lapic.h> |
| 32 | #include <southbridge/amd/pi/hudson/hudson.h> |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 33 | #include <superio/fintek/common/fintek.h> |
| 34 | #include <superio/fintek/f81866d/f81866d.h> |
| 35 | |
| 36 | #define SERIAL_DEV1 PNP_DEV(0x4e, F81866D_SP1) |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 37 | |
| 38 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 39 | { |
| 40 | u32 val; |
| 41 | |
Kyösti Mälkki | 187543c | 2016-11-20 11:03:13 +0200 | [diff] [blame] | 42 | /* Must come first to enable PCI MMCONF. */ |
| 43 | amd_initmmio(); |
| 44 | |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 45 | /* |
| 46 | * In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for |
| 47 | * LpcClk[1:0]". This following register setting has been |
| 48 | * replicated in every reference design since Parmer, so it is |
| 49 | * believed to be required even though it is not documented in |
| 50 | * the SoC BKDGs. Without this setting, there is no serial |
| 51 | * output. |
| 52 | */ |
| 53 | outb(0xD2, 0xcd6); |
| 54 | outb(0x00, 0xcd7); |
| 55 | |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 56 | hudson_lpc_port80(); |
| 57 | |
| 58 | if (!cpu_init_detectedx && boot_cpu()) { |
| 59 | post_code(0x30); |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 60 | fintek_enable_serial(SERIAL_DEV1, CONFIG_TTYS0_BASE); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 61 | post_code(0x31); |
| 62 | console_init(); |
| 63 | } |
| 64 | |
| 65 | /* Halt if there was a built in self test failure */ |
| 66 | post_code(0x34); |
| 67 | report_bist_failure(bist); |
| 68 | |
| 69 | /* Load MPB */ |
| 70 | val = cpuid_eax(1); |
Elyes HAOUAS | e53e488c | 2016-08-21 12:19:25 +0200 | [diff] [blame] | 71 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 72 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 73 | |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 74 | post_code(0x37); |
| 75 | AGESAWRAPPER(amdinitreset); |
| 76 | |
| 77 | post_code(0x38); |
| 78 | printk(BIOS_DEBUG, "Got past avalon_early_setup\n"); |
| 79 | |
| 80 | post_code(0x39); |
| 81 | AGESAWRAPPER(amdinitearly); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 82 | |
Kyösti Mälkki | 1b183aa | 2017-02-26 10:11:21 +0200 | [diff] [blame] | 83 | post_code(0x40); |
| 84 | AGESAWRAPPER(amdinitpost); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 85 | |
Kyösti Mälkki | 1b183aa | 2017-02-26 10:11:21 +0200 | [diff] [blame] | 86 | //PspMboxBiosCmdDramInfo(); |
| 87 | post_code(0x41); |
| 88 | AGESAWRAPPER(amdinitenv); |
| 89 | /* |
| 90 | If code hangs here, please check cahaltasm.S |
| 91 | */ |
| 92 | disable_cache_as_ram(); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 93 | |
| 94 | outb(0xEA, 0xCD6); |
| 95 | outb(0x1, 0xcd7); |
| 96 | |
| 97 | post_code(0x50); |
| 98 | copy_and_run(); |
| 99 | |
| 100 | post_code(0x54); /* Should never see this post code. */ |
| 101 | } |