Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Elyes HAOUAS | 0c31a67 | 2016-09-28 21:24:40 +0200 | [diff] [blame] | 4 | * Copyright (C) 2011-2012 Alexandru Gagniuc <mr.nuke.me@gmail.com> |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [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, either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * Inspired from the EPIA-M700 |
| 19 | */ |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | #include <device/pci_def.h> |
| 22 | #include <device/pci_ids.h> |
| 23 | #include <arch/io.h> |
| 24 | #include <device/pnp_def.h> |
| 25 | #include <arch/io.h> |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 26 | #include <console/console.h> |
| 27 | #include <lib.h> |
| 28 | #include <cpu/x86/bist.h> |
Kyösti Mälkki | 5276941 | 2016-06-17 07:55:03 +0300 | [diff] [blame] | 29 | #include <cpu/amd/car.h> |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 30 | #include <string.h> |
| 31 | #include <timestamp.h> |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 32 | |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 33 | #include <northbridge/via/vx900/early_vx900.h> |
| 34 | #include <northbridge/via/vx900/raminit.h> |
Edward O'Callaghan | cf7b498 | 2014-04-23 21:52:25 +1000 | [diff] [blame] | 35 | #include <superio/fintek/common/fintek.h> |
Edward O'Callaghan | d304331 | 2014-03-29 20:28:03 +1100 | [diff] [blame] | 36 | #include <superio/fintek/f81865f/f81865f.h> |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 37 | |
Edward O'Callaghan | cf7b498 | 2014-04-23 21:52:25 +1000 | [diff] [blame] | 38 | #define SERIAL_DEV PNP_DEV(0x4e, F81865F_SP1) |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 39 | |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 40 | /* cache_as_ram.inc jumps to here. */ |
| 41 | void main(unsigned long bist) |
| 42 | { |
| 43 | u32 tolm; |
Kyösti Mälkki | c0beb6d | 2013-09-08 13:48:36 +0300 | [diff] [blame] | 44 | |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 45 | timestamp_init(timestamp_get()); |
Kyösti Mälkki | c0beb6d | 2013-09-08 13:48:36 +0300 | [diff] [blame] | 46 | timestamp_add_now(TS_START_ROMSTAGE); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 47 | |
| 48 | /* First thing we need to do on the VX900, before anything else */ |
| 49 | vx900_enable_pci_config_space(); |
| 50 | |
| 51 | /* Serial console is easy to take care of */ |
Edward O'Callaghan | cf7b498 | 2014-04-23 21:52:25 +1000 | [diff] [blame] | 52 | fintek_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 53 | console_init(); |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 54 | printk(BIOS_DEBUG, "Console initialized.\n"); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 55 | |
| 56 | vx900_cpu_bus_interface_setup(); |
| 57 | |
| 58 | /* Be smart. Get this info */ |
| 59 | vx900_print_strapping_info(); |
| 60 | /* DEVEL helper */ |
| 61 | vx900_disable_auto_reboot(); |
| 62 | /* Halt if there was a built-in self test failure. */ |
| 63 | report_bist_failure(bist); |
| 64 | |
| 65 | /* Oh, almighty, give us the SMBUS */ |
| 66 | enable_smbus(); |
| 67 | |
Kyösti Mälkki | c0beb6d | 2013-09-08 13:48:36 +0300 | [diff] [blame] | 68 | timestamp_add_now(TS_BEFORE_INITRAM); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 69 | /* Now we can worry about raminit. |
| 70 | * This board only has DDR3, so no need to worry about which DRAM type |
| 71 | * to use */ |
| 72 | dimm_layout dimms = { {0x50, 0x51, SPD_END_LIST} }; |
| 73 | vx900_init_dram_ddr3(&dimms); |
Kyösti Mälkki | c0beb6d | 2013-09-08 13:48:36 +0300 | [diff] [blame] | 74 | timestamp_add_now(TS_AFTER_INITRAM); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 75 | |
| 76 | /* TODO: All these ram_checks are here to ensure we test most of the RAM |
| 77 | * below 4G. They should not be needed once VX900 raminit is stable */ |
| 78 | ram_check(0, 0x80); |
| 79 | ram_check(512 << 10, 0x80); |
| 80 | ram_check((1 << 20) - (1 << 10), 0x80); |
| 81 | ram_check((1 << 24), 0x80); |
| 82 | ram_check((512 + 256 - 1) << 20, 0x80); |
| 83 | ram_check(0x80c0000, 0x80); |
| 84 | tolm = ((pci_read_config16(MCU, 0x84) & 0xfff0) >> 4) << 20; |
| 85 | if (tolm > (1 * (u32) GiB)) |
| 86 | ram_check(1024 << 10, 0x80); |
| 87 | if (tolm > (2 * (u32) GiB)) |
| 88 | ram_check(2048 << 20, 0x80); |
| 89 | |
Stefan Reinauer | 069f476 | 2015-01-05 13:02:32 -0800 | [diff] [blame] | 90 | printk(BIOS_DEBUG, "We passed RAM verify\n"); |
Kyösti Mälkki | c0beb6d | 2013-09-08 13:48:36 +0300 | [diff] [blame] | 91 | |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 92 | /* We got RAM working, now we can write the timestamps to RAM */ |
Kyösti Mälkki | f8bf5a1 | 2013-10-11 22:08:02 +0300 | [diff] [blame] | 93 | #if CONFIG_EARLY_CBMEM_INIT |
Kyösti Mälkki | 2d8520b | 2014-01-06 17:20:31 +0200 | [diff] [blame] | 94 | cbmem_recovery(0); |
Kyösti Mälkki | f8bf5a1 | 2013-10-11 22:08:02 +0300 | [diff] [blame] | 95 | #endif |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 96 | /* FIXME: See if this is needed or take this out please */ |
| 97 | /* Disable Memcard and SDIO */ |
| 98 | pci_mod_config8(LPC, 0x51, 0, (1 << 7) | (1 << 4)); |
Alexandru Gagniuc | 37a8a8b | 2013-05-21 14:51:26 -0500 | [diff] [blame] | 99 | } |