127b4d80792e892c56734e47c8b1521f9485ef20
[coreboot.git] / src / mainboard / amd / norwich / auto.c
1 /*
2  * This file is part of the LinuxBIOS 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 #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"
32 #include "cpu/x86/bist.h"
33 #include "cpu/x86/msr.h"
34 #include <cpu/amd/lxdef.h>
35 #include <cpu/amd/geode_post_code.h>
36 #include "southbridge/amd/cs5536/cs5536.h"
37
38 #define POST_CODE(x) outb(x, 0x80)
39
40 #include "southbridge/amd/cs5536/cs5536_early_smbus.c"
41 #include "southbridge/amd/cs5536/cs5536_early_setup.c"
42
43 static inline int spd_read_byte(unsigned device, unsigned address)
44 {
45         return smbus_read_byte(device, address);
46 }
47
48 #define ManualConf 0            /* Do automatic strapped PLL config */
49 #define PLLMSRhi 0x00001490     /* manual settings for the PLL */
50 #define PLLMSRlo 0x02000030
51 #define DIMM0 0xA0
52 #define DIMM1 0xA2
53 #include "northbridge/amd/lx/raminit.h"
54 #include "northbridge/amd/lx/pll_reset.c"
55 #include "northbridge/amd/lx/raminit.c"
56 #include "sdram/generic_sdram.c"
57 #include "cpu/amd/model_lx/cpureginit.c"
58 #include "cpu/amd/model_lx/syspreinit.c"
59
60 static void msr_init(void)
61 {
62         /* Setup access to the MC for low memory. Note MC not setup yet. */
63         __builtin_wrmsr(CPU_RCONF_DEFAULT, 0x10f3bf00, 0x24fffc02);
64
65         __builtin_wrmsr(MSR_GLIU0 + 0x20, 0xfff80, 0x20000000);
66         __builtin_wrmsr(MSR_GLIU0 + 0x21, 0x80fffe0, 0x20000000);
67
68         __builtin_wrmsr(MSR_GLIU1 + 0x20, 0xfff80, 0x20000000);
69         __builtin_wrmsr(MSR_GLIU1 + 0x21, 0x80fffe0, 0x20000000);
70 }
71
72 static void mb_gpio_init(void)
73 {
74         /* Early mainboard specific GPIO setup */
75 }
76
77 static void main(unsigned long bist)
78 {
79         static const struct mem_controller memctrl[] = {
80                 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
81         };
82
83         SystemPreInit();
84         msr_init();
85
86         cs5536_early_setup();
87
88         /* NOTE: must do this AFTER the early_setup!
89          * it is counting on some early MSR setup
90          * for cs5536
91          */
92         /* cs5536_disable_internal_uart  disable them for now, set them up later... */
93         cs5536_setup_onchipuart();      /* if debug. real setup done in chipset init via config.lb */
94         mb_gpio_init();
95         uart_init();
96         console_init();
97
98         pll_reset(ManualConf);
99
100         cpuRegInit();
101
102         sdram_initialize(1, memctrl);
103
104         /* Check all of memory */
105         //ram_check(0x00000000, 640*1024);
106 }