Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +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. |
| 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 |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 22 | #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> |
| 27 | #include <arch/romcc_io.h> |
| 28 | #include <arch/hlt.h> |
| 29 | #include "pc80/serial.c" |
Stefan Reinauer | 5a1f597 | 2010-03-31 14:34:40 +0000 | [diff] [blame] | 30 | #include "console/console.c" |
Stefan Reinauer | c13093b | 2009-09-23 18:51:03 +0000 | [diff] [blame] | 31 | #include "lib/ramtest.c" |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 32 | #include "northbridge/via/cn700/raminit.h" |
| 33 | #include "cpu/x86/mtrr/earlymtrr.c" |
| 34 | #include "cpu/x86/bist.h" |
| 35 | #include "pc80/udelay_io.c" |
| 36 | #include "lib/delay.c" |
| 37 | #include "cpu/x86/lapic/boot_cpu.c" |
| 38 | #include "southbridge/via/vt8237r/vt8237r_early_smbus.c" |
| 39 | #include "southbridge/via/vt8235/vt8235_early_serial.c" |
| 40 | |
| 41 | static void memreset_setup(void) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | static inline int spd_read_byte(unsigned device, unsigned address) |
| 46 | { |
| 47 | return smbus_read_byte(device, address); |
| 48 | } |
| 49 | |
| 50 | #include "northbridge/via/cn700/raminit.c" |
| 51 | |
| 52 | static void enable_mainboard_devices(void) |
| 53 | { |
| 54 | device_t dev; |
| 55 | u8 reg; |
Bari Ari | d4759d0 | 2008-09-01 01:48:07 +0000 | [diff] [blame] | 56 | |
| 57 | dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 58 | if (dev == PCI_DEV_INVALID) |
Bari Ari | d4759d0 | 2008-09-01 01:48:07 +0000 | [diff] [blame] | 59 | die("Southbridge not found!!!\n"); |
| 60 | |
| 61 | /* bit=0 means enable function (per CX700 datasheet) |
| 62 | * 5 16.1 USB 2 |
| 63 | * 4 16.0 USB 1 |
| 64 | * 3 15.0 SATA and PATA |
| 65 | * 2 16.2 USB 3 |
| 66 | * 1 16.4 USB EHCI |
| 67 | */ |
| 68 | pci_write_config8(dev, 0x50, 0x80); |
| 69 | |
| 70 | /* bit=1 means enable internal function (per CX700 datasheet) |
| 71 | * 3 Internal RTC |
| 72 | * 2 Internal PS2 Mouse |
| 73 | * 1 Internal KBC Configuration |
| 74 | * 0 Internal Keyboard Controller |
| 75 | */ |
| 76 | pci_write_config8(dev, 0x51, 0x1d); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static const struct mem_controller ctrl = { |
| 80 | .d0f0 = 0x0000, |
| 81 | .d0f2 = 0x2000, |
| 82 | .d0f3 = 0x3000, |
| 83 | .d0f4 = 0x4000, |
| 84 | .d0f7 = 0x7000, |
| 85 | .d1f0 = 0x8000, |
| 86 | .channel0 = { 0x50 }, |
| 87 | }; |
| 88 | |
Stefan Reinauer | 314e551 | 2010-04-09 20:36:29 +0000 | [diff] [blame^] | 89 | void main(unsigned long bist) |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 90 | { |
| 91 | unsigned long x; |
| 92 | device_t dev; |
| 93 | |
| 94 | /* Enable multifunction for northbridge. */ |
| 95 | pci_write_config8(ctrl.d0f0, 0x4f, 0x01); |
| 96 | |
| 97 | enable_vt8235_serial(); |
| 98 | uart_init(); |
| 99 | console_init(); |
| 100 | |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 101 | print_spew("In romstage.c:main()\n"); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 102 | |
| 103 | enable_smbus(); |
| 104 | smbus_fixup(&ctrl); |
| 105 | |
| 106 | if (bist == 0) { |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 107 | print_debug("doing early_mtrr\n"); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 108 | early_mtrr_init(); |
| 109 | } |
| 110 | |
| 111 | /* Halt if there was a built-in self test failure. */ |
| 112 | report_bist_failure(bist); |
| 113 | |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 114 | print_debug("Enabling mainboard devices\n"); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 115 | enable_mainboard_devices(); |
| 116 | |
| 117 | ddr_ram_setup(&ctrl); |
| 118 | |
| 119 | /* ram_check(0, 640 * 1024); */ |
| 120 | |
Stefan Reinauer | 64ed2b7 | 2010-03-31 14:47:43 +0000 | [diff] [blame] | 121 | print_spew("Leaving romstage.c:main()\n"); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 122 | } |
Stefan Reinauer | 798ef28 | 2010-03-29 22:08:01 +0000 | [diff] [blame] | 123 | |