Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 - 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. |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <lib.h> |
| 17 | #include <reset.h> |
| 18 | #include <stdint.h> |
| 19 | #include <arch/io.h> |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 20 | #include <arch/cpu.h> |
| 21 | #include <console/console.h> |
| 22 | #include <arch/stages.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 23 | #include <cpu/x86/bist.h> |
| 24 | #include <cpu/x86/lapic.h> |
Edward O'Callaghan | bf9d122 | 2014-10-29 09:26:00 +1100 | [diff] [blame] | 25 | #include <cpu/amd/car.h> |
Kyösti Mälkki | f21c2ac | 2014-10-19 09:35:18 +0300 | [diff] [blame] | 26 | #include <northbridge/amd/agesa/agesawrapper.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 27 | #include <northbridge/amd/agesa/family10/reset_test.h> |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 28 | #include <nb_cimx.h> |
| 29 | #include <sb_cimx.h> |
Edward O'Callaghan | 74834e0 | 2015-01-04 04:17:35 +1100 | [diff] [blame] | 30 | #include <superio/nuvoton/wpcm450/wpcm450.h> |
Edward O'Callaghan | ffe460d | 2014-04-27 22:51:40 +1000 | [diff] [blame] | 31 | #include <superio/winbond/common/winbond.h> |
| 32 | #include <superio/winbond/w83627dhg/w83627dhg.h> |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 33 | |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 34 | |
| 35 | #define SERIAL_DEV PNP_DEV(0x2e, W83627DHG_SP1) |
| 36 | #define DUMMY_DEV PNP_DEV(0x2e, 0) |
| 37 | |
| 38 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 39 | { |
| 40 | u32 val; |
| 41 | |
| 42 | post_code(0x30); |
Kyösti Mälkki | 48518f0 | 2014-11-25 14:20:57 +0200 | [diff] [blame] | 43 | amd_initmmio(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 44 | post_code(0x31); |
| 45 | |
| 46 | /* Halt if there was a built in self test failure */ |
| 47 | post_code(0x33); |
| 48 | report_bist_failure(bist); |
| 49 | |
| 50 | sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */ |
| 51 | wpcm450_enable_dev(WPCM450_SP1, 0x164E, CONFIG_TTYS0_BASE); |
| 52 | sb7xx_51xx_disable_wideio(0); |
| 53 | post_code(0x34); |
| 54 | |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 55 | post_code(0x35); |
| 56 | console_init(); |
| 57 | |
| 58 | val = cpuid_eax(1); |
Elyes HAOUAS | aedcc10 | 2014-07-21 08:07:19 +0200 | [diff] [blame] | 59 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 60 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 61 | |
| 62 | post_code(0x37); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 63 | agesawrapper_amdinitreset(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 64 | |
| 65 | if (!cpu_init_detectedx && boot_cpu()) { |
| 66 | post_code(0x38); |
| 67 | /* |
| 68 | * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR, |
| 69 | * Disable all Pcie Bridges to work around It. |
| 70 | */ |
| 71 | sr56x0_rd890_disable_pcie_bridge(); |
| 72 | post_code(0x39); |
| 73 | nb_Poweron_Init(); |
| 74 | post_code(0x3A); |
| 75 | sb_Poweron_Init(); |
| 76 | } |
| 77 | post_code(0x3B); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 78 | agesawrapper_amdinitearly(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 79 | |
| 80 | post_code(0x3C); |
| 81 | nb_Ht_Init(); |
| 82 | |
| 83 | post_code(0x3D); |
| 84 | /* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */ |
| 85 | if (!warm_reset_detect(0)) { |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 86 | printk(BIOS_INFO, "...WARM RESET...\n\n\n"); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 87 | distinguish_cpu_resets(0); |
| 88 | soft_reset(); |
| 89 | die("After soft_reset_x - shouldn't see this message!!!\n"); |
| 90 | } |
| 91 | |
| 92 | post_code(0x40); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 93 | agesawrapper_amdinitpost(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 94 | |
| 95 | post_code(0x41); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 96 | agesawrapper_amdinitenv(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 97 | post_code(0x42); |
| 98 | |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 99 | post_code(0x50); |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 100 | printk(BIOS_DEBUG, "Disabling cache as ram "); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 101 | disable_cache_as_ram(); |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 102 | printk(BIOS_DEBUG, "done\n"); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 103 | |
| 104 | post_code(0x51); |
Stefan Reinauer | 648d166 | 2013-05-06 18:05:39 -0700 | [diff] [blame] | 105 | copy_and_run(); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 106 | |
| 107 | /* We will not return, Should never see this message and post code. */ |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 108 | printk(BIOS_DEBUG, "should not be here -\n"); |
Siyuan Wang | 8ff97b2 | 2012-10-28 18:19:38 +0800 | [diff] [blame] | 109 | post_code(0x54); |
| 110 | } |