This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / mainboard / rca / rm4100 / auto.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 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
23 #include <stdint.h>
24 #include <stdlib.h>
25 #include <device/pci_def.h>
26 #include <arch/io.h>
27 #include <device/pnp_def.h>
28 #include <arch/romcc_io.h>
29 #include <arch/hlt.h>
30 #include "pc80/serial.c"
31 #include "pc80/udelay_io.c"
32 #include "arch/i386/lib/console.c"
33 #include "ram/ramtest.c"
34 #include "superio/smsc/smscsuperio/smscsuperio_early_serial.c"
35 #include "northbridge/intel/i82830/raminit.h"
36 #include "northbridge/intel/i82830/memory_initialized.c"
37 #include "southbridge/intel/i82801xx/i82801xx.h"
38 #include "southbridge/intel/i82801xx/i82801xx_reset.c"
39 #include "cpu/x86/mtrr/earlymtrr.c"
40 #include "cpu/x86/bist.h"
41 #include "spd_table.h"
42 #include "gpio.c"
43
44 #define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
45
46 #include "southbridge/intel/i82801xx/i82801xx_early_smbus.c"
47 #include "southbridge/intel/i82801xx/i82801xx_early_lpc.c"
48
49 /**
50  * The onboard 128MB PC133 memory does not have a SPD EEPROM so the
51  * values have to be set manually, the SO-DIMM socket is located in
52  * socket0 (0x50), and the onboard memory is located in socket1 (0x51).
53  */
54 static inline int spd_read_byte(unsigned device, unsigned address)
55 {
56         int i;
57
58         if (device == 0x50) {
59                 return smbus_read_byte(device, address);
60         } else if (device == 0x51) {
61                 for (i = 0; i < ARRAY_SIZE(spd_table); i++) {
62                         if (spd_table[i].address == address)
63                                 return spd_table[i].data;
64                 }
65                 return 0xFF; /* Return 0xFF when address is not found. */
66         } else {
67                 return 0xFF; /* Return 0xFF on any failures. */
68         }
69 }
70
71 #include "northbridge/intel/i82830/raminit.c"
72 #include "sdram/generic_sdram.c"
73
74 /**
75  * The AC'97 Audio Controller I/O space registers are read only by default
76  * so we need to enable them by setting register 0x41 to 0x01.
77  */
78 static void ac97_io_enable(void)
79 {
80         device_t dev;
81
82         /* Set the ac97 audio device staticly. */
83         dev = PCI_DEV(0x0, 0x1f, 0x5);
84
85         /* Enable access to the IO space. */
86         pci_write_config8(dev, 0x41, 0x01);
87 }
88
89 static void main(unsigned long bist)
90 {
91         static const struct mem_controller memctrl[] = {
92                 {
93                         .d0 = PCI_DEV(0, 0, 0),
94                         .channel0 = {0x50, 0x51},
95                 }
96         };
97
98         if (bist == 0)
99                 early_mtrr_init();
100                 if (memory_initialized()) {
101                         hard_reset();
102                 }
103
104         smscsuperio_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
105         mb_gpio_init();
106         uart_init();
107         console_init();
108
109         enable_smbus();
110
111         /* Prevent the TCO timer from rebooting us */
112         i82801xx_halt_tco_timer();
113
114         /* Halt if there was a built in self test failure. */
115         report_bist_failure(bist);
116
117         sdram_set_registers(memctrl);
118         sdram_set_spd_registers(memctrl);
119         sdram_enable(0, memctrl);
120
121         /* Check RAM. */
122         /* ram_check(0, 640 * 1024); */
123         /* ram_check(130048 * 1024, 131072 * 1024); */
124
125         ac97_io_enable();
126 }