blob: 3c4835f99ede19817933567a45825be7ae66bd33 [file] [log] [blame]
Alex Mauer9196dd52008-09-10 20:40:46 +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.
Alex Mauer9196dd52008-09-10 20:40:46 +000016 */
17
Alex Mauer9196dd52008-09-10 20:40:46 +000018#include <stdint.h>
19#include <device/pci_def.h>
20#include <device/pci_ids.h>
21#include <arch/io.h>
22#include <device/pnp_def.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000023#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <northbridge/via/cn700/raminit.h>
25#include <cpu/x86/bist.h>
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020026#include "drivers/pc80/udelay_io.c"
Edward O'Callaghanebe3a7a2015-01-05 00:27:54 +110027#include <delay.h>
stepan836ae292010-12-08 05:42:47 +000028#include "southbridge/via/vt8237r/early_smbus.c"
Edward O'Callaghancf7b4982014-04-23 21:52:25 +100029#include <superio/fintek/common/fintek.h>
Edward O'Callaghanfbdc3ef2014-03-31 15:01:16 +110030#include <superio/fintek/f71805f/f71805f.h>
Patrick Georgid0835952010-10-05 09:07:10 +000031#include <lib.h>
Uwe Hermann6dc92f02010-11-21 11:36:03 +000032#include <spd.h>
Corey Osgood716e5672008-12-19 03:33:37 +000033
Stefan Reinauer08670622009-06-30 15:17:49 +000034#if CONFIG_TTYS0_BASE == 0x2f8
Corey Osgood716e5672008-12-19 03:33:37 +000035#define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP2)
36#else
37#define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP1)
38#endif
Alex Mauer9196dd52008-09-10 20:40:46 +000039
Alex Mauer9196dd52008-09-10 20:40:46 +000040static inline int spd_read_byte(unsigned device, unsigned address)
41{
42 return smbus_read_byte(device, address);
43}
44
45#include "northbridge/via/cn700/raminit.c"
46
47static void enable_mainboard_devices(void)
48{
49 device_t dev;
Corey Osgood716e5672008-12-19 03:33:37 +000050
Uwe Hermann7b997052010-11-21 22:47:22 +000051 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
52 PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
Alex Mauer9196dd52008-09-10 20:40:46 +000053 if (dev == PCI_DEV_INVALID)
54 die("Southbridge not found!!!\n");
55
56 /* bit=0 means enable function (per CX700 datasheet)
57 * 5 16.1 USB 2
58 * 4 16.0 USB 1
59 * 3 15.0 SATA and PATA
60 * 2 16.2 USB 3
61 * 1 16.4 USB EHCI
62 */
63 pci_write_config8(dev, 0x50, 0x80);
64
65 /* bit=1 means enable internal function (per CX700 datasheet)
66 * 3 Internal RTC
67 * 2 Internal PS2 Mouse
68 * 1 Internal KBC Configuration
69 * 0 Internal Keyboard Controller
70 */
71 pci_write_config8(dev, 0x51, 0x1d);
72}
73
74static const struct mem_controller ctrl = {
75 .d0f0 = 0x0000,
76 .d0f2 = 0x2000,
77 .d0f3 = 0x3000,
78 .d0f4 = 0x4000,
79 .d0f7 = 0x7000,
80 .d1f0 = 0x8000,
Uwe Hermannd773fd32010-11-20 20:23:08 +000081 .channel0 = { DIMM0 },
Alex Mauer9196dd52008-09-10 20:40:46 +000082};
83
Aaron Durbina0a37272014-08-14 08:35:11 -050084#include <cpu/intel/romstage.h>
Stefan Reinauer314e5512010-04-09 20:36:29 +000085void main(unsigned long bist)
Alex Mauer9196dd52008-09-10 20:40:46 +000086{
Alex Mauer9196dd52008-09-10 20:40:46 +000087 /* Enable multifunction for northbridge. */
88 pci_write_config8(ctrl.d0f0, 0x4f, 0x01);
89
Edward O'Callaghancf7b4982014-04-23 21:52:25 +100090 fintek_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Alex Mauer9196dd52008-09-10 20:40:46 +000091 console_init();
92
Alex Mauer9196dd52008-09-10 20:40:46 +000093 enable_smbus();
94 smbus_fixup(&ctrl);
95
Alex Mauer9196dd52008-09-10 20:40:46 +000096 /* Halt if there was a built-in self test failure. */
97 report_bist_failure(bist);
98
Alex Mauer9196dd52008-09-10 20:40:46 +000099 enable_mainboard_devices();
100
101 ddr_ram_setup(&ctrl);
Alex Mauer9196dd52008-09-10 20:40:46 +0000102}