Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2008 coresystems GmbH |
| 5 | * Copyright (C) 2009 Thomas Jourdan <thomas.jourdan@gmail.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; version 2 of |
| 10 | * the License. |
| 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, |
| 20 | * MA 02110-1301 USA |
| 21 | */ |
| 22 | |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 23 | #include <delay.h> |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 24 | #include <stdint.h> |
| 25 | #include <arch/io.h> |
| 26 | #include <arch/romcc_io.h> |
| 27 | #include <device/pci_def.h> |
| 28 | #include <device/pnp_def.h> |
| 29 | #include <cpu/x86/lapic.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 30 | #include <pc80/mc146818rtc.h> |
Patrick Georgi | 12584e2 | 2010-05-08 09:14:51 +0000 | [diff] [blame] | 31 | #include <console/console.h> |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 32 | #include <cpu/x86/bist.h> |
Nico Huber | 41392df | 2012-10-01 15:53:14 +0200 | [diff] [blame^] | 33 | #include <cpu/intel/speedstep.h> |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 34 | #include "southbridge/intel/i3100/early_smbus.c" |
| 35 | #include "southbridge/intel/i3100/early_lpc.c" |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 36 | #include "reset.c" |
stepan | 8301d83 | 2010-12-08 07:07:33 +0000 | [diff] [blame] | 37 | #include "superio/intel/i3100/early_serial.c" |
| 38 | #include "superio/smsc/smscsuperio/early_serial.c" |
Patrick Georgi | c2bf26d | 2010-11-15 19:44:42 +0000 | [diff] [blame] | 39 | #include "northbridge/intel/i3100/i3100.h" |
Patrick Georgi | 9e18038 | 2010-11-18 10:48:15 +0000 | [diff] [blame] | 40 | #include "southbridge/intel/i3100/i3100.h" |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 41 | |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 42 | #define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0) |
| 43 | #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0) |
| 44 | |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 45 | #define RCBA_RPC 0x0224 /* 32 bit */ |
| 46 | |
| 47 | #define RCBA_TCTL 0x3000 /* 8 bit */ |
| 48 | |
| 49 | #define RCBA_D31IP 0x3100 /* 32 bit */ |
| 50 | #define RCBA_D30IP 0x3104 /* 32 bit */ |
| 51 | #define RCBA_D29IP 0x3108 /* 32 bit */ |
| 52 | #define RCBA_D28IP 0x310C /* 32 bit */ |
| 53 | #define RCBA_D31IR 0x3140 /* 16 bit */ |
| 54 | #define RCBA_D30IR 0x3142 /* 16 bit */ |
| 55 | #define RCBA_D29IR 0x3144 /* 16 bit */ |
| 56 | #define RCBA_D28IR 0x3146 /* 16 bit */ |
| 57 | |
| 58 | #define RCBA_RTC 0x3400 /* 32 bit */ |
| 59 | #define RCBA_HPTC 0x3404 /* 32 bit */ |
| 60 | #define RCBA_GCS 0x3410 /* 32 bit */ |
| 61 | #define RCBA_BUC 0x3414 /* 8 bit */ |
| 62 | #define RCBA_FD 0x3418 /* 32 bit */ |
| 63 | #define RCBA_PRC 0x341C /* 32 bit */ |
| 64 | |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 65 | static inline int spd_read_byte(u16 device, u8 address) |
| 66 | { |
| 67 | return smbus_read_byte(device, address); |
| 68 | } |
| 69 | |
| 70 | #include "northbridge/intel/i3100/raminit.h" |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 71 | #include "northbridge/intel/i3100/memory_initialized.c" |
| 72 | #include "northbridge/intel/i3100/raminit.c" |
Stefan Reinauer | c13093b | 2009-09-23 18:51:03 +0000 | [diff] [blame] | 73 | #include "lib/generic_sdram.c" |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 74 | #include "northbridge/intel/i3100/reset_test.c" |
| 75 | #include "debug.c" |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 76 | #include <spd.h> |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 77 | |
Uwe Hermann | d1a1d57 | 2010-11-10 18:22:11 +0000 | [diff] [blame] | 78 | #define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1) |
| 79 | |
Stefan Reinauer | 5d3dee8 | 2010-04-14 11:40:34 +0000 | [diff] [blame] | 80 | static void early_config(void) |
| 81 | { |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 82 | u32 gcs, rpc, fd; |
| 83 | |
| 84 | /* Enable RCBA */ |
| 85 | pci_write_config32(PCI_DEV(0, 0x1F, 0), RCBA, DEFAULT_RCBA | 1); |
| 86 | |
| 87 | /* Disable watchdog */ |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 88 | gcs = read32(DEFAULT_RCBA + RCBA_GCS); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 89 | gcs |= (1 << 5); /* No reset */ |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 90 | write32(DEFAULT_RCBA + RCBA_GCS, gcs); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 91 | |
| 92 | /* Configure PCIe port B as 4x */ |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 93 | rpc = read32(DEFAULT_RCBA + RCBA_RPC); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 94 | rpc |= (3 << 0); |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 95 | write32(DEFAULT_RCBA + RCBA_RPC, rpc); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 96 | |
| 97 | /* Disable Modem, Audio, PCIe ports 2/3/4 */ |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 98 | fd = read32(DEFAULT_RCBA + RCBA_FD); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 99 | fd |= (1 << 19) | (1 << 18) | (1 << 17) | (1 << 6) | (1 << 5); |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 100 | write32(DEFAULT_RCBA + RCBA_FD, fd); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 101 | |
| 102 | /* Enable HPET */ |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 103 | write32(DEFAULT_RCBA + RCBA_HPTC, (1 << 7)); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 104 | |
| 105 | /* Improve interrupt routing |
| 106 | * D31:F2 SATA INTB# -> PIRQD |
| 107 | * D31:F3 SMBUS INTB# -> PIRQD |
| 108 | * D31:F4 CHAP INTD# -> PIRQA |
| 109 | * D29:F0 USB1#1 INTA# -> PIRQH |
| 110 | * D29:F1 USB1#2 INTB# -> PIRQD |
| 111 | * D29:F7 USB2 INTA# -> PIRQH |
| 112 | * D28:F0 PCIe Port 1 INTA# -> PIRQE |
| 113 | */ |
| 114 | |
Stefan Reinauer | 9fe4d79 | 2010-01-16 17:53:38 +0000 | [diff] [blame] | 115 | write16(DEFAULT_RCBA + RCBA_D31IR, 0x0230); |
| 116 | write16(DEFAULT_RCBA + RCBA_D30IR, 0x3210); |
| 117 | write16(DEFAULT_RCBA + RCBA_D29IR, 0x3237); |
| 118 | write16(DEFAULT_RCBA + RCBA_D28IR, 0x3214); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 119 | |
| 120 | /* Setup sata mode */ |
| 121 | pci_write_config8(PCI_DEV(0, 0x1F, 2), SATA_MAP, (SATA_MODE_AHCI << 6) | (0 << 0)); |
| 122 | } |
| 123 | |
Stefan Reinauer | 6d1b0d8 | 2010-04-13 00:02:20 +0000 | [diff] [blame] | 124 | void main(unsigned long bist) |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 125 | { |
| 126 | /* int boot_mode = 0; */ |
| 127 | |
| 128 | static const struct mem_controller mch[] = { |
| 129 | { |
| 130 | .node_id = 0, |
| 131 | .f0 = PCI_DEV(0, 0x00, 0), |
| 132 | .f1 = PCI_DEV(0, 0x00, 1), |
| 133 | .f2 = PCI_DEV(0, 0x00, 2), |
| 134 | .f3 = PCI_DEV(0, 0x00, 3), |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 135 | .channel0 = { DIMM3, DIMM2, DIMM1, DIMM0 }, |
| 136 | .channel1 = { DIMM7, DIMM6, DIMM5, DIMM4 }, |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 137 | } |
| 138 | }; |
| 139 | |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 140 | if (bist == 0) |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 141 | enable_lapic(); |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 142 | |
| 143 | /* Setup the console */ |
| 144 | i3100_enable_superio(); |
Uwe Hermann | d1a1d57 | 2010-11-10 18:22:11 +0000 | [diff] [blame] | 145 | i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 146 | i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26); |
| 147 | |
Thomas Jourdan | 1a692d8 | 2009-07-01 17:01:17 +0000 | [diff] [blame] | 148 | console_init(); |
| 149 | |
| 150 | /* Halt if there was a built in self test failure */ |
| 151 | report_bist_failure(bist); |
| 152 | |
| 153 | /* Perform early board specific init */ |
| 154 | early_config(); |
| 155 | |
| 156 | /* Prevent the TCO timer from rebooting us */ |
| 157 | i3100_halt_tco_timer(); |
| 158 | |
| 159 | /* Enable SPD ROMs and DDR-II DRAM */ |
| 160 | enable_smbus(); |
| 161 | |
| 162 | /* Enable SpeedStep and automatic thermal throttling */ |
| 163 | { |
| 164 | msr_t msr; |
| 165 | u16 perf; |
| 166 | |
| 167 | msr = rdmsr(IA32_MISC_ENABLES); |
| 168 | msr.lo |= (1 << 3) | (1 << 16); |
| 169 | wrmsr(IA32_MISC_ENABLES, msr); |
| 170 | |
| 171 | /* Set CPU frequency/voltage to maximum */ |
| 172 | |
| 173 | /* Read performance status register and keep |
| 174 | * bits 47:32, where BUS_RATIO_MAX and VID_MAX |
| 175 | * are encoded |
| 176 | */ |
| 177 | msr = rdmsr(IA32_PERF_STS); |
| 178 | perf = msr.hi & 0x0000ffff; |
| 179 | |
| 180 | /* Write VID_MAX & BUS_RATIO_MAX to |
| 181 | * performance control register |
| 182 | */ |
| 183 | msr = rdmsr(IA32_PERF_CTL); |
| 184 | msr.lo &= 0xffff0000; |
| 185 | msr.lo |= perf; |
| 186 | wrmsr(IA32_PERF_CTL, msr); |
| 187 | } |
| 188 | |
| 189 | /* Initialize memory */ |
| 190 | sdram_initialize(ARRAY_SIZE(mch), mch); |
| 191 | } |