efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 4 | * Copyright (C) 2011 - 2012 Advanced Micro Devices, Inc. |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 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. |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <lib.h> |
| 17 | #include <reset.h> |
| 18 | #include <stdint.h> |
| 19 | #include <arch/io.h> |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [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> |
Kerry Sheh | a3f0607 | 2012-02-07 20:32: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> |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 33 | |
Edward O'Callaghan | c94d73e | 2014-06-16 17:24:14 +1000 | [diff] [blame] | 34 | /* though UARTs are on the NUVOTON BMC, port 0x164E |
| 35 | * PS2 keyboard and mouse are on SUPERIO_WINBOND_W83627DHG, port 0x2E |
| 36 | */ |
| 37 | #define SIO_PORT 0x164e |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 38 | |
| 39 | void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) |
| 40 | { |
| 41 | u32 val; |
| 42 | |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 43 | post_code(0x30); |
Kyösti Mälkki | 48518f0 | 2014-11-25 14:20:57 +0200 | [diff] [blame] | 44 | amd_initmmio(); |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 45 | post_code(0x31); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 46 | |
| 47 | /* Halt if there was a built in self test failure */ |
| 48 | post_code(0x33); |
| 49 | report_bist_failure(bist); |
| 50 | |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 51 | sb7xx_51xx_enable_wideio(0, 0x1600); /* though UARTs are on the NUVOTON BMC */ |
Edward O'Callaghan | c94d73e | 2014-06-16 17:24:14 +1000 | [diff] [blame] | 52 | wpcm450_enable_dev(WPCM450_SP1, SIO_PORT, CONFIG_TTYS0_BASE); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 53 | sb7xx_51xx_disable_wideio(0); |
| 54 | post_code(0x34); |
| 55 | |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 56 | post_code(0x35); |
| 57 | console_init(); |
| 58 | |
| 59 | val = cpuid_eax(1); |
Elyes HAOUAS | aedcc10 | 2014-07-21 08:07:19 +0200 | [diff] [blame] | 60 | printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); |
| 61 | printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 62 | |
| 63 | post_code(0x37); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 64 | agesawrapper_amdinitreset(); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 65 | |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 66 | if (!cpu_init_detectedx && boot_cpu()) { |
| 67 | post_code(0x38); |
| 68 | /* |
| 69 | * SR5650/5670/5690 RD890 chipset, read pci config space hang at POR, |
| 70 | * Disable all Pcie Bridges to work around It. |
| 71 | */ |
| 72 | sr56x0_rd890_disable_pcie_bridge(); |
| 73 | post_code(0x39); |
| 74 | nb_Poweron_Init(); |
| 75 | post_code(0x3A); |
| 76 | sb_Poweron_Init(); |
| 77 | } |
| 78 | post_code(0x3B); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 79 | agesawrapper_amdinitearly(); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 80 | |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 81 | post_code(0x3C); |
Kerry Sheh | 134d8a9 | 2012-02-07 20:33:21 +0800 | [diff] [blame] | 82 | /* W83627DHG pin89,90 function select is RSTOUT3#, RSTOUT2# by default. |
| 83 | * In order to access W83795G/ADG HWM using I2C protocol, |
| 84 | * we select function to SDA, SCL function (or GP33, GP32 function). |
| 85 | */ |
| 86 | w83627dhg_enable_i2c(PNP_DEV(0x2E, W83627DHG_SPI)); |
| 87 | |
Kerry Sheh | a3f0607 | 2012-02-07 20:32:38 +0800 | [diff] [blame] | 88 | nb_Ht_Init(); |
| 89 | post_code(0x3D); |
| 90 | /* Reset for HT, FIDVID, PLL and ucode patch(errata) changes to take affect. */ |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 91 | if (!warm_reset_detect(0)) { |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 92 | printk(BIOS_INFO, "...WARM RESET...\n\n\n"); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 93 | distinguish_cpu_resets(0); |
| 94 | soft_reset(); |
| 95 | die("After soft_reset_x - shouldn't see this message!!!\n"); |
| 96 | } |
| 97 | |
| 98 | post_code(0x40); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 99 | agesawrapper_amdinitpost(); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 100 | |
| 101 | post_code(0x41); |
Kyösti Mälkki | 1aa35c6 | 2014-10-21 14:19:04 +0300 | [diff] [blame] | 102 | agesawrapper_amdinitenv(); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 103 | post_code(0x42); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 104 | |
| 105 | post_code(0x50); |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 106 | printk(BIOS_DEBUG, "Disabling cache as ram "); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 107 | disable_cache_as_ram(); |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 108 | printk(BIOS_DEBUG, "done\n"); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 109 | |
| 110 | post_code(0x51); |
Stefan Reinauer | 648d166 | 2013-05-06 18:05:39 -0700 | [diff] [blame] | 111 | copy_and_run(); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 112 | |
| 113 | /* We will not return, Should never see this message and post code. */ |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 114 | printk(BIOS_DEBUG, "should not be here -\n"); |
efdesign98 | 95b6611 | 2011-07-20 13:23:04 -0600 | [diff] [blame] | 115 | post_code(0x54); |
| 116 | } |