blob: dc503ed9ce60bb4443dccf84bed5ace8641b3f94 [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
Paul Menzela46a7122013-02-23 18:37:27 +010019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Jens Rottmannf31ca162008-11-19 12:19:09 +000020 */
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>
Patrick Georgi12584e22010-05-08 09:14:51 +000029#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110030#include <cpu/x86/bist.h>
31#include <cpu/x86/msr.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000032#include <cpu/amd/lxdef.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110033#include <southbridge/amd/cs5536/cs5536.h>
Patrick Georgi9bd9a902010-11-20 10:31:00 +000034#include <spd.h>
stepan836ae292010-12-08 05:42:47 +000035#include "southbridge/amd/cs5536/early_smbus.c"
36#include "southbridge/amd/cs5536/early_setup.c"
Edward O'Callaghanf2920022014-04-27 00:41:50 +100037#include <superio/ite/common/ite.h>
38#include <superio/ite/it8712f/it8712f.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110039#include <northbridge/amd/lx/raminit.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000040
Edward O'Callaghanf2920022014-04-27 00:41:50 +100041#define SERIAL_DEV PNP_DEV(0x2e, IT8712F_SP1)
42#define GPIO_DEV PNP_DEV(0x2e, IT8712F_GPIO)
43
Christian Gmeinerc4e07bb2013-06-04 17:34:35 +020044int spd_read_byte(unsigned int device, unsigned int address)
Jens Rottmannf31ca162008-11-19 12:19:09 +000045{
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
Jens Rottmannf31ca162008-11-19 12:19:09 +000052#include "northbridge/amd/lx/pll_reset.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000053#include "lib/generic_sdram.c"
Kyösti Mälkki7916f4c2012-02-09 16:07:41 +020054#include "cpu/amd/geode_lx/cpureginit.c"
55#include "cpu/amd/geode_lx/syspreinit.c"
56#include "cpu/amd/geode_lx/msrinit.c"
Jens Rottmannf31ca162008-11-19 12:19:09 +000057
58static const u16 sio_init_table[] = { // hi=data, lo=index
Jens Rottmannc9140532010-09-03 15:16:36 +000059 0x1E2C, // disable ATXPG; VIN6,FAN4/5,VIN3 enabled, VIN7 internal
60 0x1423, // don't delay PoWeROK1/2 - triggers 2nd reset
61 0x9072, // watchdog triggers PWROK, counts seconds
Stefan Reinauer08670622009-06-30 15:17:49 +000062#if !CONFIG_USE_WATCHDOG_ON_BOOT
Jens Rottmannc9140532010-09-03 15:16:36 +000063 0x0073, 0x0074, // disarm watchdog by changing 56 s timeout to 0
Jens Rottmannf31ca162008-11-19 12:19:09 +000064#endif
65 0xBF25, 0x372A, 0xF326, // select GPIO function for most pins
66 0xBF27, 0xFF28, 0x2529, // (GP36=FAN_CTL3, GP13=PWROK1)
Jens Rottmannc9140532010-09-03 15:16:36 +000067 0x46B8, 0x0CB9, // enable pullups on RS485_EN
Jens Rottmannf31ca162008-11-19 12:19:09 +000068 0x36C0, // enable Simple-I/O for GP15,14,12,11= LIVE_LED, WD_ACTIVE, RS485_EN2,1
69 0xFFC3, // enable Simple-I/O for GP47-40 (GPIOs on Supervisory Connector)
70 0x26C8, // config GP15,12,11 as output; GP14 as input
71 0x2DF5, // map Hw Monitor Thermal Output to GP55
72 0x0DF8, // map GP LED Blinking 1 to GP15=LIVE_LED (deactivate Simple-I/O to use)
73};
74
75/* Early mainboard specific GPIO setup. */
76static void mb_gpio_init(void)
77{
78 int i;
79
Uwe Hermann86c9b882008-11-19 13:42:14 +000080 /* Init Super I/O WDT, GPIOs. Done early, WDT init may trigger reset! */
Uwe Hermann86c9b882008-11-19 13:42:14 +000081 for (i = 0; i < ARRAY_SIZE(sio_init_table); i++) {
Edward O'Callaghanf2920022014-04-27 00:41:50 +100082 u16 reg = sio_init_table[i];
83 ite_reg_write(GPIO_DEV, (u8) reg, (reg >> 8));
Jens Rottmannf31ca162008-11-19 12:19:09 +000084 }
Jens Rottmannf31ca162008-11-19 12:19:09 +000085}
86
Aaron Durbina0a37272014-08-14 08:35:11 -050087#include <cpu/intel/romstage.h>
Stefan Reinauer9839cbd2010-04-21 20:06:10 +000088void main(unsigned long bist)
Jens Rottmannf31ca162008-11-19 12:19:09 +000089{
Jens Rottmannf31ca162008-11-19 12:19:09 +000090
91 static const struct mem_controller memctrl[] = {
Uwe Hermann6dc92f02010-11-21 11:36:03 +000092 {.channel0 = {DIMM0, DIMM1}}
Jens Rottmannf31ca162008-11-19 12:19:09 +000093 };
94
95 SystemPreInit();
96 msr_init();
97
98 cs5536_early_setup();
99
Uwe Hermann86c9b882008-11-19 13:42:14 +0000100 /*
101 * Note: must do this AFTER the early_setup! It is counting on some
Jens Rottmannf31ca162008-11-19 12:19:09 +0000102 * early MSR setup for CS5536.
103 */
Edward O'Callaghanf2920022014-04-27 00:41:50 +1000104 ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Jens Rottmannf31ca162008-11-19 12:19:09 +0000105 mb_gpio_init();
Jens Rottmannf31ca162008-11-19 12:19:09 +0000106 console_init();
107
Stefan Reinauer9839cbd2010-04-21 20:06:10 +0000108 /* Halt if there was a built in self test failure */
109 report_bist_failure(bist);
110
Patrick Georgi7dc28642012-07-13 19:06:22 +0200111 pll_reset();
Jens Rottmannf31ca162008-11-19 12:19:09 +0000112
Edwin Beasantf333ba02010-06-10 15:24:57 +0000113 cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
Jens Rottmannf31ca162008-11-19 12:19:09 +0000114
115 sdram_initialize(1, memctrl);
116
Jens Rottmannf31ca162008-11-19 12:19:09 +0000117 /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
Jens Rottmannf31ca162008-11-19 12:19:09 +0000118}