Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 1 | /* |
| 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 Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 21 | #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 Reinauer | ac4ca2b | 2006-08-04 08:58:17 +0000 | [diff] [blame] | 32 | #include "southbridge/intel/i82371eb/i82371eb_early_smbus.c" |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 33 | #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 Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 40 | void 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 Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 50 | static void enable_shadow_ram(void) |
| 51 | { |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 52 | uint8_t shadowreg; |
| 53 | /* dev 0 for northbridge */ |
| 54 | shadowreg = pci_read_config8(0, 0x59); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 55 | /* 0xf0000-0xfffff */ |
| 56 | shadowreg |= 0x30; |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 57 | pci_write_config8(0, 0x59, shadowreg); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static inline int spd_read_byte(unsigned device, unsigned address) |
| 61 | { |
Uwe Hermann | 4c0d39f | 2007-05-15 10:26:16 +0000 | [diff] [blame^] | 62 | return smbus_read_byte(device, address); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 65 | #include "northbridge/intel/i440bx/raminit.c" |
| 66 | #include "northbridge/intel/i440bx/debug.c" |
| 67 | #include "sdram/generic_sdram.c" |
| 68 | |
| 69 | static void main(unsigned long bist) |
| 70 | { |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 71 | static const struct mem_controller memctrl[] = { |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 72 | { |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 73 | .d0 = PCI_DEV(0, 0, 0), |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 74 | .channel0 = { |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 75 | (0xa << 3) | 0, |
| 76 | (0xa << 3) | 1, |
| 77 | (0xa << 3) | 2, |
| 78 | (0xa << 3) | 3, |
| 79 | }, |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 80 | } |
| 81 | }; |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 82 | |
| 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 Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 93 | enable_shadow_ram(); |
Corey Osgood | 33d1af37 | 2007-05-09 08:11:52 +0000 | [diff] [blame] | 94 | |
| 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 Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 116 | } |