Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 1 | /* |
| 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 Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 18 | #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 Georgi | 12584e2 | 2010-05-08 09:14:51 +0000 | [diff] [blame] | 23 | #include <console/console.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 24 | #include <northbridge/via/cn700/raminit.h> |
| 25 | #include <cpu/x86/bist.h> |
Stefan Reinauer | ae5e11d | 2012-04-27 02:31:28 +0200 | [diff] [blame] | 26 | #include "drivers/pc80/udelay_io.c" |
Edward O'Callaghan | ebe3a7a | 2015-01-05 00:27:54 +1100 | [diff] [blame] | 27 | #include <delay.h> |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 28 | #include "southbridge/via/vt8237r/early_smbus.c" |
Edward O'Callaghan | cf7b498 | 2014-04-23 21:52:25 +1000 | [diff] [blame] | 29 | #include <superio/fintek/common/fintek.h> |
Edward O'Callaghan | fbdc3ef | 2014-03-31 15:01:16 +1100 | [diff] [blame] | 30 | #include <superio/fintek/f71805f/f71805f.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 31 | #include <lib.h> |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 32 | #include <spd.h> |
Corey Osgood | 716e567 | 2008-12-19 03:33:37 +0000 | [diff] [blame] | 33 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 34 | #if CONFIG_TTYS0_BASE == 0x2f8 |
Corey Osgood | 716e567 | 2008-12-19 03:33:37 +0000 | [diff] [blame] | 35 | #define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP2) |
| 36 | #else |
| 37 | #define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP1) |
| 38 | #endif |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 39 | |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 40 | static 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 | |
| 47 | static void enable_mainboard_devices(void) |
| 48 | { |
| 49 | device_t dev; |
Corey Osgood | 716e567 | 2008-12-19 03:33:37 +0000 | [diff] [blame] | 50 | |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 51 | dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, |
| 52 | PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 53 | 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 | |
| 74 | static const struct mem_controller ctrl = { |
| 75 | .d0f0 = 0x0000, |
| 76 | .d0f2 = 0x2000, |
| 77 | .d0f3 = 0x3000, |
| 78 | .d0f4 = 0x4000, |
| 79 | .d0f7 = 0x7000, |
| 80 | .d1f0 = 0x8000, |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 81 | .channel0 = { DIMM0 }, |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
Aaron Durbin | a0a3727 | 2014-08-14 08:35:11 -0500 | [diff] [blame] | 84 | #include <cpu/intel/romstage.h> |
Stefan Reinauer | 314e551 | 2010-04-09 20:36:29 +0000 | [diff] [blame] | 85 | void main(unsigned long bist) |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 86 | { |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 87 | /* Enable multifunction for northbridge. */ |
| 88 | pci_write_config8(ctrl.d0f0, 0x4f, 0x01); |
| 89 | |
Edward O'Callaghan | cf7b498 | 2014-04-23 21:52:25 +1000 | [diff] [blame] | 90 | fintek_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 91 | console_init(); |
| 92 | |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 93 | enable_smbus(); |
| 94 | smbus_fixup(&ctrl); |
| 95 | |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 96 | /* Halt if there was a built-in self test failure. */ |
| 97 | report_bist_failure(bist); |
| 98 | |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 99 | enable_mainboard_devices(); |
| 100 | |
| 101 | ddr_ram_setup(&ctrl); |
Alex Mauer | 9196dd5 | 2008-09-10 20:40:46 +0000 | [diff] [blame] | 102 | } |