b3aff80af41f4ced08a1602a882c8732b551d985
[coreboot.git] / src / mainboard / traverse / geos / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
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 #include <stdint.h>
22 #include <stdlib.h>
23 #include <device/pci_def.h>
24 #include <arch/io.h>
25 #include <device/pnp_def.h>
26 #include <arch/hlt.h>
27 #include <console/console.h>
28 #include <lib.h>
29 #include "cpu/x86/bist.h"
30 #include "cpu/x86/msr.h"
31 #include <cpu/amd/lxdef.h>
32 #include <cpu/amd/geode_post_code.h>
33 #include "southbridge/amd/cs5536/cs5536.h"
34 #include <spd.h>
35
36 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
37 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
38
39 static inline int spd_read_byte(unsigned int device, unsigned int address)
40 {
41         return smbus_read_byte(device, address);
42 }
43
44 #define ManualConf 1            /* Do automatic strapped PLL config */
45 #define PLLMSRhi 0x0000059C     /* manual settings for the PLL */
46 #define PLLMSRlo 0x00DE602E
47
48 #include "northbridge/amd/lx/raminit.h"
49 #include "northbridge/amd/lx/pll_reset.c"
50 #include "northbridge/amd/lx/raminit.c"
51 #include "lib/generic_sdram.c"
52 #include "cpu/amd/model_lx/cpureginit.c"
53 #include "cpu/amd/model_lx/syspreinit.c"
54 #include "cpu/amd/model_lx/msrinit.c"
55
56 static void mb_gpio_init(void)
57 {
58         /* Early mainboard specific GPIO setup. */
59 }
60
61 void main(unsigned long bist)
62 {
63         post_code(0x01);
64
65         static const struct mem_controller memctrl[] = {
66                 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
67         };
68
69         SystemPreInit();
70         msr_init();
71
72         cs5536_early_setup();
73
74         /* Note: must do this AFTER the early_setup! It is counting on some
75          * early MSR setup for CS5536.
76          */
77         /* cs5536_disable_internal_uart: disable them for now, set them
78          * up later...
79          */
80         /* If debug. real setup done in chipset init via devicetree.cb. */
81         cs5536_setup_onchipuart(1);
82         mb_gpio_init();
83         uart_init();
84         console_init();
85
86         /* Halt if there was a built in self test failure */
87         report_bist_failure(bist);
88
89         pll_reset(ManualConf);
90
91         cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
92
93         sdram_initialize(1, memctrl);
94
95         /* Check memory. */
96         /* ram_check(0x00000000, 640 * 1024); */
97
98         /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
99         return;
100 }