This patch implements MBI (modular bios interface) support to the i830 chipset.
[coreboot.git] / src / mainboard / rca / rm4100 / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org>
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
21 #define ASSEMBLY 1
22 #define __PRE_RAM__
23
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <device/pci_def.h>
27 #include <arch/io.h>
28 #include <device/pnp_def.h>
29 #include <arch/romcc_io.h>
30 #include <arch/hlt.h>
31 #include "pc80/serial.c"
32 #include "pc80/udelay_io.c"
33 #include "arch/i386/lib/console.c"
34 #include "lib/ramtest.c"
35 #include "superio/smsc/smscsuperio/smscsuperio_early_serial.c"
36 #include "northbridge/intel/i82830/raminit.h"
37 #include "northbridge/intel/i82830/memory_initialized.c"
38 #include "southbridge/intel/i82801dx/i82801dx.h"
39 #include "southbridge/intel/i82801dx/i82801dx_reset.c"
40 #include "cpu/x86/mtrr/earlymtrr.c"
41 #include "cpu/x86/bist.h"
42 #include "spd_table.h"
43 #include "gpio.c"
44
45 #define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
46
47 #include "southbridge/intel/i82801dx/i82801dx_early_smbus.c"
48 #include "southbridge/intel/i82801dx/i82801dx_tco_timer.c"
49
50 /**
51  * The onboard 64MB PC133 memory does not have a SPD EEPROM so the
52  * values have to be set manually, the SO-DIMM socket is located in
53  * socket0 (0x50), and the onboard memory is located in socket1 (0x51).
54  */
55 static inline int spd_read_byte(unsigned device, unsigned address)
56 {
57         int i;
58
59         if (device == 0x50) {
60                 return smbus_read_byte(device, address);
61         } else if (device == 0x51) {
62                 for (i = 0; i < ARRAY_SIZE(spd_table); i++) {
63                         if (spd_table[i].address == address)
64                                 return spd_table[i].data;
65                 }
66                 return 0xFF; /* Return 0xFF when address is not found. */
67         } else {
68                 return 0xFF; /* Return 0xFF on any failures. */
69         }
70 }
71
72 #include "northbridge/intel/i82830/raminit.c"
73
74 /**
75  * Setup mainboard specific registers pre raminit.
76  */
77 static void mb_early_setup(void)
78 {
79         /* - Hub Interface to PCI Bridge Registers - */
80         /* 12-Clock Retry Enable */
81         pci_write_config16(PCI_DEV(0, 0x1e, 0), 0x50, 0x1402);
82         /* Master Latency Timer Count */
83         pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
84         /* I/O Address Base */
85         pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1c, 0xf0);
86
87         /* - LPC Interface Bridge Registers - */
88         /* Delayed Transaction Enable */
89         pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xd0, 0x00000002);
90         /* Disable the TCO Timer system reboot feature */
91         pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, 0x02);
92         /* CPU Frequency Strap */
93         pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd5, 0x02);
94         /* ACPI base address and enable Resource Indicator */
95         pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, (PMBASE_ADDR | 1)); 
96         /* Enable the SMBUS */
97         enable_smbus();
98         /* ACPI base address and disable Resource Indicator */
99         pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, (PMBASE_ADDR)); 
100         /*  ACPI Enable */
101         pci_write_config8(PCI_DEV(0, 0x1f, 0), ACPI_CNTL, 0x10);
102 }
103
104 static void main(unsigned long bist)
105 {
106         if (bist == 0) {
107                 early_mtrr_init();
108                 if (memory_initialized()) {
109                         hard_reset();
110                 }
111         }
112
113         /* Set southbridge and superio gpios */
114         mb_gpio_init();
115
116         smscsuperio_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
117         uart_init();
118         console_init();
119
120         /* Halt if there was a built in self test failure. */
121         report_bist_failure(bist);
122
123         /* disable TCO timers */
124         i82801dx_halt_tco_timer();
125
126         /* Setup mainboard specific registers */
127         mb_early_setup();
128
129         /* Initialize memory */
130         sdram_initialize();
131
132         /* Check RAM. */
133         /* ram_check(0, 640 * 1024); */
134         /* ram_check(64512 * 1024, 65536 * 1024); */
135 }