blob: 450f7d7a63accf6a23facf5dd0f4112fb4b57abd [file] [log] [blame]
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -05001/*
2 * This file is part of the coreboot project.
3 *
Elyes HAOUAS0c31a672016-09-28 21:24:40 +02004 * Copyright (C) 2011-2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -05005 *
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 Gagniuc37a8a8b2013-05-21 14:51:26 -050015 */
16
17/*
18 * Inspired from the EPIA-M700
19 */
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050020#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 Gagniuc37a8a8b2013-05-21 14:51:26 -050026#include <console/console.h>
27#include <lib.h>
28#include <cpu/x86/bist.h>
Kyösti Mälkki52769412016-06-17 07:55:03 +030029#include <cpu/amd/car.h>
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050030#include <string.h>
31#include <timestamp.h>
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050032
Edward O'Callaghan77757c22015-01-04 21:33:39 +110033#include <northbridge/via/vx900/early_vx900.h>
34#include <northbridge/via/vx900/raminit.h>
Edward O'Callaghancf7b4982014-04-23 21:52:25 +100035#include <superio/fintek/common/fintek.h>
Edward O'Callaghand3043312014-03-29 20:28:03 +110036#include <superio/fintek/f81865f/f81865f.h>
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050037
Edward O'Callaghancf7b4982014-04-23 21:52:25 +100038#define SERIAL_DEV PNP_DEV(0x4e, F81865F_SP1)
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050039
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050040/* cache_as_ram.inc jumps to here. */
41void main(unsigned long bist)
42{
43 u32 tolm;
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030044
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070045 timestamp_init(timestamp_get());
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030046 timestamp_add_now(TS_START_ROMSTAGE);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050047
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'Callaghancf7b4982014-04-23 21:52:25 +100052 fintek_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050053 console_init();
Stefan Reinauer069f4762015-01-05 13:02:32 -080054 printk(BIOS_DEBUG, "Console initialized.\n");
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050055
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älkkic0beb6d2013-09-08 13:48:36 +030068 timestamp_add_now(TS_BEFORE_INITRAM);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050069 /* 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älkkic0beb6d2013-09-08 13:48:36 +030074 timestamp_add_now(TS_AFTER_INITRAM);
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050075
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 Reinauer069f4762015-01-05 13:02:32 -080090 printk(BIOS_DEBUG, "We passed RAM verify\n");
Kyösti Mälkkic0beb6d2013-09-08 13:48:36 +030091
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050092 /* We got RAM working, now we can write the timestamps to RAM */
Kyösti Mälkkif8bf5a12013-10-11 22:08:02 +030093#if CONFIG_EARLY_CBMEM_INIT
Kyösti Mälkki2d8520b2014-01-06 17:20:31 +020094 cbmem_recovery(0);
Kyösti Mälkkif8bf5a12013-10-11 22:08:02 +030095#endif
Alexandru Gagniuc37a8a8b2013-05-21 14:51:26 -050096 /* 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 Gagniuc37a8a8b2013-05-21 14:51:26 -050099}