blob: e874a95f12cf3816ad6e0473cb4ed9d821899ee1 [file] [log] [blame]
Corey Osgood33d1af372007-05-09 08:11:52 +00001/*
2 * This file is part of the LinuxBIOS project.
3 *
4 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
Richard Smith924f92f2006-07-29 17:40:36 +000021#define ASSEMBLY 1
22
23#include <stdint.h>
24#include <device/pci_def.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"
30#include "arch/i386/lib/console.c"
31#include "ram/ramtest.c"
Stefan Reinauerac4ca2b2006-08-04 08:58:17 +000032#include "southbridge/intel/i82371eb/i82371eb_early_smbus.c"
Richard Smith924f92f2006-07-29 17:40:36 +000033#include "superio/winbond/w83977tf/w83977tf_early_serial.c"
34#include "northbridge/intel/i440bx/raminit.h"
35#include "cpu/x86/mtrr/earlymtrr.c"
36#include "cpu/x86/bist.h"
37
38#define SERIAL_DEV PNP_DEV(0x3f0, W83977TF_SP1)
39
Richard Smith924f92f2006-07-29 17:40:36 +000040void udelay(int usecs)
41{
42 int i;
43 for(i = 0; i < usecs; i++)
44 outb(i&0xff, 0x80);
45}
46
47#include "debug.c"
48#include "lib/delay.c"
49
Richard Smith924f92f2006-07-29 17:40:36 +000050static void enable_shadow_ram(void)
51{
Corey Osgood33d1af372007-05-09 08:11:52 +000052 uint8_t shadowreg;
53 /* dev 0 for northbridge */
54 shadowreg = pci_read_config8(0, 0x59);
Richard Smith924f92f2006-07-29 17:40:36 +000055 /* 0xf0000-0xfffff */
56 shadowreg |= 0x30;
Corey Osgood33d1af372007-05-09 08:11:52 +000057 pci_write_config8(0, 0x59, shadowreg);
Richard Smith924f92f2006-07-29 17:40:36 +000058}
59
60static inline int spd_read_byte(unsigned device, unsigned address)
61{
Uwe Hermann4c0d39f2007-05-15 10:26:16 +000062 return smbus_read_byte(device, address);
Richard Smith924f92f2006-07-29 17:40:36 +000063}
64
Richard Smith924f92f2006-07-29 17:40:36 +000065#include "northbridge/intel/i440bx/raminit.c"
66#include "northbridge/intel/i440bx/debug.c"
67#include "sdram/generic_sdram.c"
68
69static void main(unsigned long bist)
70{
Corey Osgood33d1af372007-05-09 08:11:52 +000071 static const struct mem_controller memctrl[] = {
Richard Smith924f92f2006-07-29 17:40:36 +000072 {
Corey Osgood33d1af372007-05-09 08:11:52 +000073 .d0 = PCI_DEV(0, 0, 0),
Richard Smith924f92f2006-07-29 17:40:36 +000074 .channel0 = {
Corey Osgood33d1af372007-05-09 08:11:52 +000075 (0xa << 3) | 0,
76 (0xa << 3) | 1,
77 (0xa << 3) | 2,
78 (0xa << 3) | 3,
79 },
Richard Smith924f92f2006-07-29 17:40:36 +000080 }
81 };
Richard Smith924f92f2006-07-29 17:40:36 +000082
83 if (bist == 0) {
84 early_mtrr_init();
85 }
86 w83977tf_enable_serial(SERIAL_DEV, TTYS0_BASE);
87 uart_init();
88 console_init();
89
90 /* Halt if there was a built in self test failure */
91 report_bist_failure(bist);
92
Richard Smith924f92f2006-07-29 17:40:36 +000093 enable_shadow_ram();
Corey Osgood33d1af372007-05-09 08:11:52 +000094
95 enable_smbus();
96
97 dump_spd_registers(&memctrl[0]);
98
99 sdram_initialize(sizeof(memctrl) / sizeof(memctrl[0]), memctrl);
100
101 /* Check whether RAM is working.
102 *
103 * Do _not_ check the area from 640 KB - 1 MB, as that's not really
104 * RAM, but rather reserved for various other things:
105 *
106 * - 640 KB - 768 KB: Video Buffer Area
107 * - 768 KB - 896 KB: Expansion Area
108 * - 896 KB - 960 KB: Extended System BIOS Area
109 * - 960 KB - 1 MB: Memory (BIOS Area) - System BIOS Area
110 *
111 * Trying to check these areas will fail.
112 */
113 /* TODO: This is currently hardcoded to check 64 MB. */
114 ram_check(0x00000000, 0x0009ffff); /* 0 - 640 KB */
115 ram_check(0x00100000, 0x007c0000); /* 1 MB - 64 MB */
Richard Smith924f92f2006-07-29 17:40:36 +0000116}