blob: 20e5b6a1a91548454bfef171f9b4d207e865c0f0 [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 *
Jens Rottmannf31ca162008-11-19 12:19:09 +00007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Stefan Reinauer38f147e2010-02-08 12:20:50 +000022/* Based on romstage.c from AMD's DB800 and DBM690T mainboards. */
Uwe Hermann86c9b882008-11-19 13:42:14 +000023
Jens Rottmannf31ca162008-11-19 12:19:09 +000024#include <stdlib.h>
25#include <stdint.h>
26#include <device/pci_def.h>
27#include <arch/io.h>
28#include <device/pnp_def.h>
29#include <arch/hlt.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000030#include <console/console.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000031#include "cpu/x86/bist.h"
32#include "cpu/x86/msr.h"
33#include <cpu/amd/lxdef.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000034#include "southbridge/amd/cs5536/cs5536.h"
Patrick Georgi9bd9a902010-11-20 10:31:00 +000035#include <spd.h>
stepan836ae292010-12-08 05:42:47 +000036#include "southbridge/amd/cs5536/early_smbus.c"
37#include "southbridge/amd/cs5536/early_setup.c"
stepan8301d832010-12-08 07:07:33 +000038#include "superio/ite/it8712f/early_serial.c"
Jens Rottmannf31ca162008-11-19 12:19:09 +000039
40#define ManualConf 1 /* No automatic strapped PLL config */
41#define PLLMSRhi 0x0000049C /* Manual settings for the PLL */
42#define PLLMSRlo 0x00DE6001
Jens Rottmannf31ca162008-11-19 12:19:09 +000043
44static inline int spd_read_byte(unsigned int device, unsigned int address)
45{
Uwe Hermann86c9b882008-11-19 13:42:14 +000046 if (device != DIMM0)
47 return 0xFF; /* No DIMM1, don't even try. */
48
Jens Rottmannf31ca162008-11-19 12:19:09 +000049 return smbus_read_byte(device, address);
50}
51
52#include "northbridge/amd/lx/raminit.h"
53#include "northbridge/amd/lx/pll_reset.c"
54#include "northbridge/amd/lx/raminit.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000055#include "lib/generic_sdram.c"
Kyösti Mälkki7916f4c2012-02-09 16:07:41 +020056#include "cpu/amd/geode_lx/cpureginit.c"
57#include "cpu/amd/geode_lx/syspreinit.c"
58#include "cpu/amd/geode_lx/msrinit.c"
Jens Rottmannf31ca162008-11-19 12:19:09 +000059
60static const u16 sio_init_table[] = { // hi=data, lo=index
61 0x0707, // select LDN 7 (GPIO, SPI, watchdog, ...)
Jens Rottmannc9140532010-09-03 15:16:36 +000062 0x1E2C, // disable ATXPG; VIN6,FAN4/5,VIN3 enabled, VIN7 internal
63 0x1423, // don't delay PoWeROK1/2 - triggers 2nd reset
64 0x9072, // watchdog triggers PWROK, counts seconds
Stefan Reinauer08670622009-06-30 15:17:49 +000065#if !CONFIG_USE_WATCHDOG_ON_BOOT
Jens Rottmannc9140532010-09-03 15:16:36 +000066 0x0073, 0x0074, // disarm watchdog by changing 56 s timeout to 0
Jens Rottmannf31ca162008-11-19 12:19:09 +000067#endif
68 0xBF25, 0x372A, 0xF326, // select GPIO function for most pins
69 0xBF27, 0xFF28, 0x2529, // (GP36=FAN_CTL3, GP13=PWROK1)
Jens Rottmannc9140532010-09-03 15:16:36 +000070 0x46B8, 0x0CB9, // enable pullups on RS485_EN
Jens Rottmannf31ca162008-11-19 12:19:09 +000071 0x36C0, // enable Simple-I/O for GP15,14,12,11= LIVE_LED, WD_ACTIVE, RS485_EN2,1
72 0xFFC3, // enable Simple-I/O for GP47-40 (GPIOs on Supervisory Connector)
73 0x26C8, // config GP15,12,11 as output; GP14 as input
74 0x2DF5, // map Hw Monitor Thermal Output to GP55
75 0x0DF8, // map GP LED Blinking 1 to GP15=LIVE_LED (deactivate Simple-I/O to use)
76};
77
78/* Early mainboard specific GPIO setup. */
79static void mb_gpio_init(void)
80{
81 int i;
82
Uwe Hermann86c9b882008-11-19 13:42:14 +000083 /* Init Super I/O WDT, GPIOs. Done early, WDT init may trigger reset! */
Jens Rottmannf31ca162008-11-19 12:19:09 +000084 it8712f_enter_conf();
Uwe Hermann86c9b882008-11-19 13:42:14 +000085 for (i = 0; i < ARRAY_SIZE(sio_init_table); i++) {
Jens Rottmannf31ca162008-11-19 12:19:09 +000086 u16 val = sio_init_table[i];
Uwe Hermann86c9b882008-11-19 13:42:14 +000087 outb((u8)val, SIO_INDEX);
88 outb(val >> 8, SIO_DATA);
Jens Rottmannf31ca162008-11-19 12:19:09 +000089 }
90 it8712f_exit_conf();
91}
92
Stefan Reinauer9839cbd2010-04-21 20:06:10 +000093void main(unsigned long bist)
Jens Rottmannf31ca162008-11-19 12:19:09 +000094{
Jens Rottmannf31ca162008-11-19 12:19:09 +000095
96 static const struct mem_controller memctrl[] = {
Uwe Hermann6dc92f02010-11-21 11:36:03 +000097 {.channel0 = {DIMM0, DIMM1}}
Jens Rottmannf31ca162008-11-19 12:19:09 +000098 };
99
100 SystemPreInit();
101 msr_init();
102
103 cs5536_early_setup();
104
Uwe Hermann86c9b882008-11-19 13:42:14 +0000105 /*
106 * Note: must do this AFTER the early_setup! It is counting on some
Jens Rottmannf31ca162008-11-19 12:19:09 +0000107 * early MSR setup for CS5536.
108 */
Stefan Reinauer08670622009-06-30 15:17:49 +0000109 it8712f_enable_serial(0, CONFIG_TTYS0_BASE); // Does not use its 1st parameter
Jens Rottmannf31ca162008-11-19 12:19:09 +0000110 mb_gpio_init();
Jens Rottmannf31ca162008-11-19 12:19:09 +0000111 console_init();
112
Stefan Reinauer9839cbd2010-04-21 20:06:10 +0000113 /* Halt if there was a built in self test failure */
114 report_bist_failure(bist);
115
Jens Rottmannf31ca162008-11-19 12:19:09 +0000116 pll_reset(ManualConf);
117
Edwin Beasantf333ba02010-06-10 15:24:57 +0000118 cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
Jens Rottmannf31ca162008-11-19 12:19:09 +0000119
120 sdram_initialize(1, memctrl);
121
Jens Rottmannf31ca162008-11-19 12:19:09 +0000122 /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
Jens Rottmannf31ca162008-11-19 12:19:09 +0000123}