blob: 373756faeab3f491a999bd9288a4ca94c2420bb0 [file] [log] [blame]
Aaron Lwefcb2a312008-05-19 12:17:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 VIA Technologies, Inc.
5 * (Written by Aaron Lwe <aaron.lwe@gmail.com> for VIA)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Aaron Lwefcb2a312008-05-19 12:17:43 +000020 */
21
Aaron Lwefcb2a312008-05-19 12:17:43 +000022#include <stdint.h>
23#include <device/pci_def.h>
24#include <device/pci_ids.h>
25#include <arch/io.h>
26#include <device/pnp_def.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000027#include <console/console.h>
Patrick Georgid0835952010-10-05 09:07:10 +000028#include <lib.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110029#include <northbridge/via/cn700/raminit.h>
30#include <cpu/x86/bist.h>
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020031#include "drivers/pc80/udelay_io.c"
Aaron Lwefcb2a312008-05-19 12:17:43 +000032#include "lib/delay.c"
stepan836ae292010-12-08 05:42:47 +000033#include "southbridge/via/vt8237r/early_smbus.c"
34#include "southbridge/via/vt8235/early_serial.c"
Uwe Hermann6dc92f02010-11-21 11:36:03 +000035#include <spd.h>
Aaron Lwefcb2a312008-05-19 12:17:43 +000036
Aaron Lwefcb2a312008-05-19 12:17:43 +000037static inline int spd_read_byte(unsigned device, unsigned address)
38{
39 return smbus_read_byte(device, address);
40}
41
42#include "northbridge/via/cn700/raminit.c"
43
44static void enable_mainboard_devices(void)
45{
46 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000047
Uwe Hermann7b997052010-11-21 22:47:22 +000048 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
49 PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
Aaron Lwefcb2a312008-05-19 12:17:43 +000050 if (dev == PCI_DEV_INVALID)
Bari Arid4759d02008-09-01 01:48:07 +000051 die("Southbridge not found!!!\n");
52
53 /* bit=0 means enable function (per CX700 datasheet)
54 * 5 16.1 USB 2
55 * 4 16.0 USB 1
56 * 3 15.0 SATA and PATA
57 * 2 16.2 USB 3
58 * 1 16.4 USB EHCI
59 */
60 pci_write_config8(dev, 0x50, 0x80);
61
62 /* bit=1 means enable internal function (per CX700 datasheet)
63 * 3 Internal RTC
64 * 2 Internal PS2 Mouse
65 * 1 Internal KBC Configuration
66 * 0 Internal Keyboard Controller
67 */
68 pci_write_config8(dev, 0x51, 0x1d);
Aaron Lwefcb2a312008-05-19 12:17:43 +000069}
70
71static const struct mem_controller ctrl = {
72 .d0f0 = 0x0000,
73 .d0f2 = 0x2000,
74 .d0f3 = 0x3000,
75 .d0f4 = 0x4000,
76 .d0f7 = 0x7000,
77 .d1f0 = 0x8000,
Uwe Hermannd773fd32010-11-20 20:23:08 +000078 .channel0 = { DIMM0 },
Aaron Lwefcb2a312008-05-19 12:17:43 +000079};
80
Aaron Durbina0a37272014-08-14 08:35:11 -050081#include <cpu/intel/romstage.h>
Stefan Reinauer314e5512010-04-09 20:36:29 +000082void main(unsigned long bist)
Aaron Lwefcb2a312008-05-19 12:17:43 +000083{
Aaron Lwefcb2a312008-05-19 12:17:43 +000084 /* Enable multifunction for northbridge. */
85 pci_write_config8(ctrl.d0f0, 0x4f, 0x01);
86
87 enable_vt8235_serial();
Aaron Lwefcb2a312008-05-19 12:17:43 +000088 console_init();
Aaron Lwefcb2a312008-05-19 12:17:43 +000089 enable_smbus();
90 smbus_fixup(&ctrl);
Aaron Lwefcb2a312008-05-19 12:17:43 +000091 report_bist_failure(bist);
Aaron Lwefcb2a312008-05-19 12:17:43 +000092 enable_mainboard_devices();
Aaron Lwefcb2a312008-05-19 12:17:43 +000093 ddr_ram_setup(&ctrl);
Aaron Lwefcb2a312008-05-19 12:17:43 +000094}