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. |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +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> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 24 | #include <lib.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 25 | #include <northbridge/via/cn700/raminit.h> |
| 26 | #include <cpu/x86/bist.h> |
Kyösti Mälkki | 5276941 | 2016-06-17 07:55:03 +0300 | [diff] [blame] | 27 | #include <cpu/amd/car.h> |
Edward O'Callaghan | ebe3a7a | 2015-01-05 00:27:54 +1100 | [diff] [blame] | 28 | #include <delay.h> |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 29 | #include "southbridge/via/vt8237r/early_smbus.c" |
Stefan Reinauer | 8de452d | 2014-12-19 13:45:24 -0800 | [diff] [blame] | 30 | #include "southbridge/via/vt8237r/early_serial.c" |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 31 | #include <spd.h> |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 32 | |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 33 | static inline int spd_read_byte(unsigned device, unsigned address) |
| 34 | { |
| 35 | return smbus_read_byte(device, address); |
| 36 | } |
| 37 | |
| 38 | #include "northbridge/via/cn700/raminit.c" |
| 39 | |
| 40 | static void enable_mainboard_devices(void) |
| 41 | { |
Antonello Dettori | 825b801 | 2016-11-08 18:44:46 +0100 | [diff] [blame] | 42 | pci_devfn_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 43 | |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 44 | dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, |
| 45 | PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 46 | if (dev == PCI_DEV_INVALID) |
Bari Ari | d4759d0 | 2008-09-01 01:48:07 +0000 | [diff] [blame] | 47 | die("Southbridge not found!!!\n"); |
| 48 | |
Elyes HAOUAS | a5aad2e | 2016-09-19 09:47:16 -0600 | [diff] [blame] | 49 | /* bit = 0 means enable function (per CX700 datasheet) |
Bari Ari | d4759d0 | 2008-09-01 01:48:07 +0000 | [diff] [blame] | 50 | * 5 16.1 USB 2 |
| 51 | * 4 16.0 USB 1 |
| 52 | * 3 15.0 SATA and PATA |
| 53 | * 2 16.2 USB 3 |
| 54 | * 1 16.4 USB EHCI |
| 55 | */ |
| 56 | pci_write_config8(dev, 0x50, 0x80); |
| 57 | |
Elyes HAOUAS | a5aad2e | 2016-09-19 09:47:16 -0600 | [diff] [blame] | 58 | /* bit = 1 means enable internal function (per CX700 datasheet) |
Bari Ari | d4759d0 | 2008-09-01 01:48:07 +0000 | [diff] [blame] | 59 | * 3 Internal RTC |
| 60 | * 2 Internal PS2 Mouse |
| 61 | * 1 Internal KBC Configuration |
| 62 | * 0 Internal Keyboard Controller |
| 63 | */ |
| 64 | pci_write_config8(dev, 0x51, 0x1d); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static const struct mem_controller ctrl = { |
| 68 | .d0f0 = 0x0000, |
| 69 | .d0f2 = 0x2000, |
| 70 | .d0f3 = 0x3000, |
| 71 | .d0f4 = 0x4000, |
| 72 | .d0f7 = 0x7000, |
| 73 | .d1f0 = 0x8000, |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 74 | .channel0 = { DIMM0 }, |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
Stefan Reinauer | 314e551 | 2010-04-09 20:36:29 +0000 | [diff] [blame] | 77 | void main(unsigned long bist) |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 78 | { |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 79 | /* Enable multifunction for northbridge. */ |
| 80 | pci_write_config8(ctrl.d0f0, 0x4f, 0x01); |
| 81 | |
Stefan Reinauer | 8de452d | 2014-12-19 13:45:24 -0800 | [diff] [blame] | 82 | enable_vt8237r_serial(); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 83 | console_init(); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 84 | enable_smbus(); |
| 85 | smbus_fixup(&ctrl); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 86 | report_bist_failure(bist); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 87 | enable_mainboard_devices(); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 88 | ddr_ram_setup(&ctrl); |
Aaron Lwe | fcb2a31 | 2008-05-19 12:17:43 +0000 | [diff] [blame] | 89 | } |