blob: 8412e3317084673c3646b8ca31b04c448ded6d09 [file] [log] [blame]
Nikolay Petukhov202625e2008-04-24 13:37:01 +00001/*
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
Nikolay Petukhov202625e2008-04-24 13:37:01 +000021#include <stdint.h>
Edwin Beasantf333ba02010-06-10 15:24:57 +000022#include <stdlib.h>
Nikolay Petukhov202625e2008-04-24 13:37:01 +000023#include <device/pci_def.h>
24#include <arch/io.h>
25#include <device/pnp_def.h>
26#include <arch/hlt.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000027#include <console/console.h>
Nikolay Petukhov202625e2008-04-24 13:37:01 +000028#include "cpu/x86/bist.h"
29#include "cpu/x86/msr.h"
30#include <cpu/amd/lxdef.h>
31#include <cpu/amd/geode_post_code.h>
32#include "southbridge/amd/cs5536/cs5536.h"
Patrick Georgi9bd9a902010-11-20 10:31:00 +000033#include <spd.h>
Nikolay Petukhov202625e2008-04-24 13:37:01 +000034
Nikolay Petukhov202625e2008-04-24 13:37:01 +000035#define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
36
37#include "southbridge/amd/cs5536/cs5536_early_smbus.c"
38#include "southbridge/amd/cs5536/cs5536_early_setup.c"
39#include "superio/winbond/w83627hf/w83627hf_early_serial.c"
40
41static inline int spd_read_byte(unsigned int device, unsigned int address)
42{
43 return smbus_read_byte(device, address);
44}
45
46#define ManualConf 1 /* Do automatic strapped PLL config */
47//#define PLLMSRhi 0x0000059C /* CPU and GLIU mult/div 500/400*/
48//#define PLLMSRhi 0x0000049C /* CPU and GLIU mult/div 500/333*/
49#define PLLMSRhi 0x0000039C /* CPU and GLIU mult/div 500/266*/
50//0x0000059C 0000 0000 0000 0000 0000 |0101 1|0|01 110|0
51/* Hold Count - how long we will sit in reset */
52#define PLLMSRlo 0x00DE6000
53
Nikolay Petukhov202625e2008-04-24 13:37:01 +000054#include "northbridge/amd/lx/raminit.h"
55#include "northbridge/amd/lx/pll_reset.c"
56#include "northbridge/amd/lx/raminit.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000057#include "lib/generic_sdram.c"
Nikolay Petukhov202625e2008-04-24 13:37:01 +000058#include "cpu/amd/model_lx/cpureginit.c"
59#include "cpu/amd/model_lx/syspreinit.c"
Stefan Reinauer9839cbd2010-04-21 20:06:10 +000060#include "cpu/amd/model_lx/msrinit.c"
Nikolay Petukhov202625e2008-04-24 13:37:01 +000061
62static void mb_gpio_init(void)
63{
64 /* Early mainboard specific GPIO setup. */
65}
66
Stefan Reinauer9839cbd2010-04-21 20:06:10 +000067void main(unsigned long bist)
Nikolay Petukhov202625e2008-04-24 13:37:01 +000068{
Stefan Reinauer0c781b22010-04-01 09:50:32 +000069 post_code(0x01);
Nikolay Petukhov202625e2008-04-24 13:37:01 +000070
71 static const struct mem_controller memctrl[] = {
72 {.channel0 = {(0xa << 3) | 0, (0xa << 3) | 1}}
73 };
74
75 SystemPreInit();
76 msr_init();
77
78 cs5536_early_setup();
79
80 /* Note: must do this AFTER the early_setup! It is counting on some
81 * early MSR setup for CS5536.
82 */
Stefan Reinauer08670622009-06-30 15:17:49 +000083 w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Nikolay Petukhov202625e2008-04-24 13:37:01 +000084 mb_gpio_init();
85 uart_init();
86 console_init();
87
Stefan Reinauer9839cbd2010-04-21 20:06:10 +000088 /* Halt if there was a built in self test failure */
89 report_bist_failure(bist);
90
Nikolay Petukhov202625e2008-04-24 13:37:01 +000091 pll_reset(ManualConf);
92
Edwin Beasantf333ba02010-06-10 15:24:57 +000093 cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
Nikolay Petukhov202625e2008-04-24 13:37:01 +000094
95 sdram_initialize(1, memctrl);
96
97 /* ram_check(0, 640 * 1024); */
98
99 /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
100 return;
101}
Stefan Reinauer798ef282010-03-29 22:08:01 +0000102