blob: 3ad89444df5976fb20f7ae3a02e7e01be7701e87 [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.
Jens Rottmannf31ca162008-11-19 12:19:09 +000016 */
17
Stefan Reinauer38f147e2010-02-08 12:20:50 +000018/* Based on romstage.c from AMD's DB800 and DBM690T mainboards. */
Uwe Hermann86c9b882008-11-19 13:42:14 +000019
Jens Rottmannf31ca162008-11-19 12:19:09 +000020#include <stdlib.h>
21#include <stdint.h>
22#include <device/pci_def.h>
23#include <arch/io.h>
24#include <device/pnp_def.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000025#include <console/console.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <cpu/x86/bist.h>
27#include <cpu/x86/msr.h>
Kyösti Mälkki52769412016-06-17 07:55:03 +030028#include <cpu/amd/car.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000029#include <cpu/amd/lxdef.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110030#include <southbridge/amd/cs5536/cs5536.h>
Patrick Georgi9bd9a902010-11-20 10:31:00 +000031#include <spd.h>
stepan836ae292010-12-08 05:42:47 +000032#include "southbridge/amd/cs5536/early_smbus.c"
33#include "southbridge/amd/cs5536/early_setup.c"
Edward O'Callaghanf2920022014-04-27 00:41:50 +100034#include <superio/ite/common/ite.h>
35#include <superio/ite/it8712f/it8712f.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110036#include <northbridge/amd/lx/raminit.h>
Jens Rottmannf31ca162008-11-19 12:19:09 +000037
Edward O'Callaghanf2920022014-04-27 00:41:50 +100038#define SERIAL_DEV PNP_DEV(0x2e, IT8712F_SP1)
39#define GPIO_DEV PNP_DEV(0x2e, IT8712F_GPIO)
40
Christian Gmeinerc4e07bb2013-06-04 17:34:35 +020041int spd_read_byte(unsigned int device, unsigned int address)
Jens Rottmannf31ca162008-11-19 12:19:09 +000042{
Uwe Hermann86c9b882008-11-19 13:42:14 +000043 if (device != DIMM0)
44 return 0xFF; /* No DIMM1, don't even try. */
45
Jens Rottmannf31ca162008-11-19 12:19:09 +000046 return smbus_read_byte(device, address);
47}
48
Jens Rottmannf31ca162008-11-19 12:19:09 +000049#include "northbridge/amd/lx/pll_reset.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000050#include "lib/generic_sdram.c"
Kyösti Mälkki7916f4c2012-02-09 16:07:41 +020051#include "cpu/amd/geode_lx/cpureginit.c"
52#include "cpu/amd/geode_lx/syspreinit.c"
53#include "cpu/amd/geode_lx/msrinit.c"
Jens Rottmannf31ca162008-11-19 12:19:09 +000054
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060055static const u16 sio_init_table[] = { // hi = data, lo = index
Jens Rottmannc9140532010-09-03 15:16:36 +000056 0x1E2C, // disable ATXPG; VIN6,FAN4/5,VIN3 enabled, VIN7 internal
57 0x1423, // don't delay PoWeROK1/2 - triggers 2nd reset
58 0x9072, // watchdog triggers PWROK, counts seconds
Stefan Reinauer08670622009-06-30 15:17:49 +000059#if !CONFIG_USE_WATCHDOG_ON_BOOT
Jens Rottmannc9140532010-09-03 15:16:36 +000060 0x0073, 0x0074, // disarm watchdog by changing 56 s timeout to 0
Jens Rottmannf31ca162008-11-19 12:19:09 +000061#endif
62 0xBF25, 0x372A, 0xF326, // select GPIO function for most pins
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060063 0xBF27, 0xFF28, 0x2529, // (GP36 = FAN_CTL3, GP13 = PWROK1)
Jens Rottmannc9140532010-09-03 15:16:36 +000064 0x46B8, 0x0CB9, // enable pullups on RS485_EN
Jens Rottmannf31ca162008-11-19 12:19:09 +000065 0x36C0, // enable Simple-I/O for GP15,14,12,11= LIVE_LED, WD_ACTIVE, RS485_EN2,1
66 0xFFC3, // enable Simple-I/O for GP47-40 (GPIOs on Supervisory Connector)
67 0x26C8, // config GP15,12,11 as output; GP14 as input
68 0x2DF5, // map Hw Monitor Thermal Output to GP55
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060069 0x0DF8, // map GP LED Blinking 1 to GP15 = LIVE_LED (deactivate Simple-I/O to use)
Jens Rottmannf31ca162008-11-19 12:19:09 +000070};
71
72/* Early mainboard specific GPIO setup. */
73static void mb_gpio_init(void)
74{
75 int i;
76
Uwe Hermann86c9b882008-11-19 13:42:14 +000077 /* Init Super I/O WDT, GPIOs. Done early, WDT init may trigger reset! */
Uwe Hermann86c9b882008-11-19 13:42:14 +000078 for (i = 0; i < ARRAY_SIZE(sio_init_table); i++) {
Edward O'Callaghanf2920022014-04-27 00:41:50 +100079 u16 reg = sio_init_table[i];
80 ite_reg_write(GPIO_DEV, (u8) reg, (reg >> 8));
Jens Rottmannf31ca162008-11-19 12:19:09 +000081 }
Jens Rottmannf31ca162008-11-19 12:19:09 +000082}
83
Kyösti Mälkki8e1f9082017-03-07 11:10:55 +020084void asmlinkage mainboard_romstage_entry(unsigned long bist)
Jens Rottmannf31ca162008-11-19 12:19:09 +000085{
Jens Rottmannf31ca162008-11-19 12:19:09 +000086
87 static const struct mem_controller memctrl[] = {
Uwe Hermann6dc92f02010-11-21 11:36:03 +000088 {.channel0 = {DIMM0, DIMM1}}
Jens Rottmannf31ca162008-11-19 12:19:09 +000089 };
90
91 SystemPreInit();
92 msr_init();
93
94 cs5536_early_setup();
95
Uwe Hermann86c9b882008-11-19 13:42:14 +000096 /*
97 * Note: must do this AFTER the early_setup! It is counting on some
Jens Rottmannf31ca162008-11-19 12:19:09 +000098 * early MSR setup for CS5536.
99 */
Edward O'Callaghanf2920022014-04-27 00:41:50 +1000100 ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Jens Rottmannf31ca162008-11-19 12:19:09 +0000101 mb_gpio_init();
Jens Rottmannf31ca162008-11-19 12:19:09 +0000102 console_init();
103
Stefan Reinauer9839cbd2010-04-21 20:06:10 +0000104 /* Halt if there was a built in self test failure */
105 report_bist_failure(bist);
106
Patrick Georgi7dc28642012-07-13 19:06:22 +0200107 pll_reset();
Jens Rottmannf31ca162008-11-19 12:19:09 +0000108
Edwin Beasantf333ba02010-06-10 15:24:57 +0000109 cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
Jens Rottmannf31ca162008-11-19 12:19:09 +0000110
111 sdram_initialize(1, memctrl);
112
Jens Rottmannf31ca162008-11-19 12:19:09 +0000113 /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */
Jens Rottmannf31ca162008-11-19 12:19:09 +0000114}