blob: ce55aa0afe9a283508b41633dcd2e440fd4604a0 [file] [log] [blame]
Jens Rottmannf31ca162008-11-19 12:19:09 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 LiPPERT Embedded Computers GmbH
5 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 *
7 * Based on cache_as_ram_auto.c from AMD's DB800 and DBM690T mainboards.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#define ASSEMBLY 1
25
26#include <stdlib.h>
27#include <stdint.h>
28#include <device/pci_def.h>
29#include <arch/io.h>
30#include <device/pnp_def.h>
31#include <arch/hlt.h>
32#include "pc80/serial.c"
33#include "arch/i386/lib/console.c"
34#include "ram/ramtest.c"
35#include "cpu/x86/bist.h"
36#include "cpu/x86/msr.h"
37#include <cpu/amd/lxdef.h>
38#include <cpu/amd/geode_post_code.h>
39#include "southbridge/amd/cs5536/cs5536.h"
40
41#define POST_CODE(x) outb(x, 0x80)
42
43#include "southbridge/amd/cs5536/cs5536_early_smbus.c"
44#include "southbridge/amd/cs5536/cs5536_early_setup.c"
45#include "superio/ite/it8712f/it8712f_early_serial.c"
46
47#define ManualConf 1 /* No automatic strapped PLL config */
48#define PLLMSRhi 0x0000049C /* Manual settings for the PLL */
49#define PLLMSRlo 0x00DE6001
50#define DIMM0 0xA0
51#define DIMM1 0xA2
52
53static inline int spd_read_byte(unsigned int device, unsigned int address)
54{
55 if (device != DIMM0) return 0xFF; // no DIMM1, don't even try
56 return smbus_read_byte(device, address);
57}
58
59#include "northbridge/amd/lx/raminit.h"
60#include "northbridge/amd/lx/pll_reset.c"
61#include "northbridge/amd/lx/raminit.c"
62#include "sdram/generic_sdram.c"
63#include "cpu/amd/model_lx/cpureginit.c"
64#include "cpu/amd/model_lx/syspreinit.c"
65
66static void msr_init(void)
67{
68 msr_t msr;
69
70 /* Setup access to the cache for under 1MB. */
71 msr.hi = 0x24fffc02;
72 msr.lo = 0x1000A000; /* 0-A0000 write back */
73 wrmsr(CPU_RCONF_DEFAULT, msr);
74
75 msr.hi = 0x0; /* Write back */
76 msr.lo = 0x0;
77 wrmsr(CPU_RCONF_A0_BF, msr);
78 wrmsr(CPU_RCONF_C0_DF, msr);
79 wrmsr(CPU_RCONF_E0_FF, msr);
80
81 /* Setup access to the cache for under 640K. Note MC not setup yet. */
82 msr.hi = 0x20000000;
83 msr.lo = 0xfff80;
84 wrmsr(MSR_GLIU0 + 0x20, msr);
85
86 msr.hi = 0x20000000;
87 msr.lo = 0x80fffe0;
88 wrmsr(MSR_GLIU0 + 0x21, msr);
89
90 msr.hi = 0x20000000;
91 msr.lo = 0xfff80;
92 wrmsr(MSR_GLIU1 + 0x20, msr);
93
94 msr.hi = 0x20000000;
95 msr.lo = 0x80fffe0;
96 wrmsr(MSR_GLIU1 + 0x21, msr);
97}
98
99static const u16 sio_init_table[] = { // hi=data, lo=index
100 0x0707, // select LDN 7 (GPIO, SPI, watchdog, ...)
101 0x1E2C, // disable ATXPowerGood - will cause a reboot!
102 0x0423, // don't delay POWerOK1/2
103 0x9072, // watchdog triggers POWOK, counts seconds
104#if !USE_WATCHDOG_ON_BOOT
105 0x0073, 0x0074, // disable watchdog by setting timeout to 0
106#endif
107 0xBF25, 0x372A, 0xF326, // select GPIO function for most pins
108 0xBF27, 0xFF28, 0x2529, // (GP36=FAN_CTL3, GP13=PWROK1)
109 0x1E2C, // VIN6=enabled?, FAN4/5 enabled, VIN7=internal, VIN3=enabled
110 0x46B8, 0x0CB9, // enable pullups
111 0x36C0, // enable Simple-I/O for GP15,14,12,11= LIVE_LED, WD_ACTIVE, RS485_EN2,1
112 0xFFC3, // enable Simple-I/O for GP47-40 (GPIOs on Supervisory Connector)
113 0x26C8, // config GP15,12,11 as output; GP14 as input
114 0x2DF5, // map Hw Monitor Thermal Output to GP55
115 0x0DF8, // map GP LED Blinking 1 to GP15=LIVE_LED (deactivate Simple-I/O to use)
116};
117
118/* Early mainboard specific GPIO setup. */
119static void mb_gpio_init(void)
120{
121 int i;
122
123 /* Init SuperIO WDT, GPIOs. Done early, WDT init may trigger reset! */
124 it8712f_enter_conf();
125 for (i=0; i<ARRAY_SIZE(sio_init_table); i++) {
126 u16 val = sio_init_table[i];
127 outb((u8)val, SIO_INDEX); outb(val>>8, SIO_DATA);
128 }
129 it8712f_exit_conf();
130}
131
132void cache_as_ram_main(void)
133{
134 POST_CODE(0x01);
135
136 static const struct mem_controller memctrl[] = {
137 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
138 };
139
140 SystemPreInit();
141 msr_init();
142
143 cs5536_early_setup();
144
145 /* Note: must do this AFTER the early_setup! It is counting on some
146 * early MSR setup for CS5536.
147 */
148 it8712f_enable_serial(0, TTYS0_BASE); // does not use its 1st parameter
149 mb_gpio_init();
150 uart_init();
151 console_init();
152
153 pll_reset(ManualConf);
154
155 cpuRegInit();
156
157 sdram_initialize(1, memctrl);
158
159 /* Check memory. */
160 /* ram_check(0x00000000, 640 * 1024); */
161
162 /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
163 return;
164}