blob: 22f5ed687532c58d4095a45f7e9e7e4ae5911985 [file] [log] [blame]
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011-2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * Inspired from the EPIA-M700
22 */
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050023#include <stdint.h>
24#include <device/pci_def.h>
25#include <device/pci_ids.h>
26#include <arch/io.h>
27#include <device/pnp_def.h>
28#include <arch/io.h>
29#include <arch/hlt.h>
30#include <console/console.h>
31#include <lib.h>
32#include <cpu/x86/bist.h>
33#include <string.h>
34#include <timestamp.h>
35#include <console/cbmem_console.h>
36
37#include "northbridge/via/vx900/early_vx900.h"
38#include "northbridge/via/vx900/raminit.h"
Edward O'Callaghand3043312014-03-29 20:28:03 +110039#include <superio/fintek/f81865f/f81865f.h>
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050040
41#define SERIAL_DEV PNP_DEV(0x4e, 0x10)
42
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050043/* cache_as_ram.inc jumps to here. */
44void main(unsigned long bist)
45{
46 u32 tolm;
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030047
48 timestamp_init(rdtsc());
49 timestamp_add_now(TS_START_ROMSTAGE);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050050
51 /* First thing we need to do on the VX900, before anything else */
52 vx900_enable_pci_config_space();
53
54 /* Serial console is easy to take care of */
55 f81865f_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
56 console_init();
57 print_debug("Console initialized. \n");
58
59 vx900_cpu_bus_interface_setup();
60
61 /* Be smart. Get this info */
62 vx900_print_strapping_info();
63 /* DEVEL helper */
64 vx900_disable_auto_reboot();
65 /* Halt if there was a built-in self test failure. */
66 report_bist_failure(bist);
67
68 /* Oh, almighty, give us the SMBUS */
69 enable_smbus();
70
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030071 timestamp_add_now(TS_BEFORE_INITRAM);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050072 /* Now we can worry about raminit.
73 * This board only has DDR3, so no need to worry about which DRAM type
74 * to use */
75 dimm_layout dimms = { {0x50, 0x51, SPD_END_LIST} };
76 vx900_init_dram_ddr3(&dimms);
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030077 timestamp_add_now(TS_AFTER_INITRAM);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050078
79 /* TODO: All these ram_checks are here to ensure we test most of the RAM
80 * below 4G. They should not be needed once VX900 raminit is stable */
81 ram_check(0, 0x80);
82 ram_check(512 << 10, 0x80);
83 ram_check((1 << 20) - (1 << 10), 0x80);
84 ram_check((1 << 24), 0x80);
85 ram_check((512 + 256 - 1) << 20, 0x80);
86 ram_check(0x80c0000, 0x80);
87 tolm = ((pci_read_config16(MCU, 0x84) & 0xfff0) >> 4) << 20;
88 if (tolm > (1 * (u32) GiB))
89 ram_check(1024 << 10, 0x80);
90 if (tolm > (2 * (u32) GiB))
91 ram_check(2048 << 20, 0x80);
92
93 print_debug("We passed RAM verify\n");
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030094
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050095 /* We got RAM working, now we can write the timestamps to RAM */
Kyösti Mälkkif8bf5a12013-10-11 22:08:02 +030096#if CONFIG_EARLY_CBMEM_INIT
Kyösti Mälkki2d8520b2014-01-06 17:20:31 +020097 cbmem_recovery(0);
Kyösti Mälkkif8bf5a12013-10-11 22:08:02 +030098#endif
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030099 timestamp_add_now(TS_END_ROMSTAGE);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -0500100 /* FIXME: See if this is needed or take this out please */
101 /* Disable Memcard and SDIO */
102 pci_mod_config8(LPC, 0x51, 0, (1 << 7) | (1 << 4));
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -0500103}