Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 1 | /* |
| 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 Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 7 | * 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Stefan Reinauer | 38f147e | 2010-02-08 12:20:50 +0000 | [diff] [blame] | 22 | /* Based on romstage.c from AMD's DB800 and DBM690T mainboards. */ |
Uwe Hermann | 86c9b88 | 2008-11-19 13:42:14 +0000 | [diff] [blame] | 23 | |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 24 | #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 Georgi | 12584e2 | 2010-05-08 09:14:51 +0000 | [diff] [blame] | 30 | #include <console/console.h> |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 31 | #include "cpu/x86/bist.h" |
| 32 | #include "cpu/x86/msr.h" |
| 33 | #include <cpu/amd/lxdef.h> |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 34 | #include "southbridge/amd/cs5536/cs5536.h" |
Patrick Georgi | 9bd9a90 | 2010-11-20 10:31:00 +0000 | [diff] [blame] | 35 | #include <spd.h> |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 36 | #include "southbridge/amd/cs5536/early_smbus.c" |
| 37 | #include "southbridge/amd/cs5536/early_setup.c" |
Edward O'Callaghan | f292002 | 2014-04-27 00:41:50 +1000 | [diff] [blame^] | 38 | #include <superio/ite/common/ite.h> |
| 39 | #include <superio/ite/it8712f/it8712f.h> |
Christian Gmeiner | 4eb5aa2 | 2013-06-04 17:27:22 +0200 | [diff] [blame] | 40 | #include "northbridge/amd/lx/raminit.h" |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 41 | |
Edward O'Callaghan | f292002 | 2014-04-27 00:41:50 +1000 | [diff] [blame^] | 42 | #define SERIAL_DEV PNP_DEV(0x2e, IT8712F_SP1) |
| 43 | #define GPIO_DEV PNP_DEV(0x2e, IT8712F_GPIO) |
| 44 | |
Christian Gmeiner | c4e07bb | 2013-06-04 17:34:35 +0200 | [diff] [blame] | 45 | int spd_read_byte(unsigned int device, unsigned int address) |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 46 | { |
Uwe Hermann | 86c9b88 | 2008-11-19 13:42:14 +0000 | [diff] [blame] | 47 | if (device != DIMM0) |
| 48 | return 0xFF; /* No DIMM1, don't even try. */ |
| 49 | |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 50 | return smbus_read_byte(device, address); |
| 51 | } |
| 52 | |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 53 | #include "northbridge/amd/lx/pll_reset.c" |
Stefan Reinauer | c13093b | 2009-09-23 18:51:03 +0000 | [diff] [blame] | 54 | #include "lib/generic_sdram.c" |
Kyösti Mälkki | 7916f4c | 2012-02-09 16:07:41 +0200 | [diff] [blame] | 55 | #include "cpu/amd/geode_lx/cpureginit.c" |
| 56 | #include "cpu/amd/geode_lx/syspreinit.c" |
| 57 | #include "cpu/amd/geode_lx/msrinit.c" |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 58 | |
| 59 | static const u16 sio_init_table[] = { // hi=data, lo=index |
Jens Rottmann | c914053 | 2010-09-03 15:16:36 +0000 | [diff] [blame] | 60 | 0x1E2C, // disable ATXPG; VIN6,FAN4/5,VIN3 enabled, VIN7 internal |
| 61 | 0x1423, // don't delay PoWeROK1/2 - triggers 2nd reset |
| 62 | 0x9072, // watchdog triggers PWROK, counts seconds |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 63 | #if !CONFIG_USE_WATCHDOG_ON_BOOT |
Jens Rottmann | c914053 | 2010-09-03 15:16:36 +0000 | [diff] [blame] | 64 | 0x0073, 0x0074, // disarm watchdog by changing 56 s timeout to 0 |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 65 | #endif |
| 66 | 0xBF25, 0x372A, 0xF326, // select GPIO function for most pins |
| 67 | 0xBF27, 0xFF28, 0x2529, // (GP36=FAN_CTL3, GP13=PWROK1) |
Jens Rottmann | c914053 | 2010-09-03 15:16:36 +0000 | [diff] [blame] | 68 | 0x46B8, 0x0CB9, // enable pullups on RS485_EN |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 69 | 0x36C0, // enable Simple-I/O for GP15,14,12,11= LIVE_LED, WD_ACTIVE, RS485_EN2,1 |
| 70 | 0xFFC3, // enable Simple-I/O for GP47-40 (GPIOs on Supervisory Connector) |
| 71 | 0x26C8, // config GP15,12,11 as output; GP14 as input |
| 72 | 0x2DF5, // map Hw Monitor Thermal Output to GP55 |
| 73 | 0x0DF8, // map GP LED Blinking 1 to GP15=LIVE_LED (deactivate Simple-I/O to use) |
| 74 | }; |
| 75 | |
| 76 | /* Early mainboard specific GPIO setup. */ |
| 77 | static void mb_gpio_init(void) |
| 78 | { |
| 79 | int i; |
| 80 | |
Uwe Hermann | 86c9b88 | 2008-11-19 13:42:14 +0000 | [diff] [blame] | 81 | /* Init Super I/O WDT, GPIOs. Done early, WDT init may trigger reset! */ |
Uwe Hermann | 86c9b88 | 2008-11-19 13:42:14 +0000 | [diff] [blame] | 82 | for (i = 0; i < ARRAY_SIZE(sio_init_table); i++) { |
Edward O'Callaghan | f292002 | 2014-04-27 00:41:50 +1000 | [diff] [blame^] | 83 | u16 reg = sio_init_table[i]; |
| 84 | ite_reg_write(GPIO_DEV, (u8) reg, (reg >> 8)); |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 85 | } |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 88 | void main(unsigned long bist) |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 89 | { |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 90 | |
| 91 | static const struct mem_controller memctrl[] = { |
Uwe Hermann | 6dc92f0 | 2010-11-21 11:36:03 +0000 | [diff] [blame] | 92 | {.channel0 = {DIMM0, DIMM1}} |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | SystemPreInit(); |
| 96 | msr_init(); |
| 97 | |
| 98 | cs5536_early_setup(); |
| 99 | |
Uwe Hermann | 86c9b88 | 2008-11-19 13:42:14 +0000 | [diff] [blame] | 100 | /* |
| 101 | * Note: must do this AFTER the early_setup! It is counting on some |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 102 | * early MSR setup for CS5536. |
| 103 | */ |
Edward O'Callaghan | f292002 | 2014-04-27 00:41:50 +1000 | [diff] [blame^] | 104 | ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 105 | mb_gpio_init(); |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 106 | console_init(); |
| 107 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 108 | /* Halt if there was a built in self test failure */ |
| 109 | report_bist_failure(bist); |
| 110 | |
Patrick Georgi | 7dc2864 | 2012-07-13 19:06:22 +0200 | [diff] [blame] | 111 | pll_reset(); |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 112 | |
Edwin Beasant | f333ba0 | 2010-06-10 15:24:57 +0000 | [diff] [blame] | 113 | cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED); |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 114 | |
| 115 | sdram_initialize(1, memctrl); |
| 116 | |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 117 | /* Memory is setup. Return to cache_as_ram.inc and continue to boot. */ |
Jens Rottmann | f31ca16 | 2008-11-19 12:19:09 +0000 | [diff] [blame] | 118 | } |