blob: bec4be822f29279293cd6e88ccbb2d21a75dd000 [file] [log] [blame]
Joseph Smith6a1dc862008-03-09 13:24:46 +00001/*
2 * This file is part of the coreboot project.
3 *
Joseph Smith6f0074e2010-01-30 14:56:15 +00004 * Copyright (C) 2008-2010 Joseph Smith <joe@settoplinux.org>
Joseph Smith6a1dc862008-03-09 13:24:46 +00005 *
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.
Joseph Smith6a1dc862008-03-09 13:24:46 +000015 */
16
Joseph Smith6a1dc862008-03-09 13:24:46 +000017#include <stdint.h>
18#include <stdlib.h>
19#include <device/pci_def.h>
20#include <arch/io.h>
21#include <device/pnp_def.h>
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020022#include "drivers/pc80/udelay_io.c"
Patrick Georgi12584e22010-05-08 09:14:51 +000023#include <console/console.h>
Patrick Georgid0835952010-10-05 09:07:10 +000024#include <lib.h>
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100025#include <superio/smsc/smscsuperio/smscsuperio.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <northbridge/intel/i82830/raminit.h>
Joseph Smithda695822008-05-15 13:44:33 +000027#include "northbridge/intel/i82830/memory_initialized.c"
Edward O'Callaghan77757c22015-01-04 21:33:39 +110028#include <southbridge/intel/i82801dx/i82801dx.h>
stepan836ae292010-12-08 05:42:47 +000029#include "southbridge/intel/i82801dx/reset.c"
Edward O'Callaghan77757c22015-01-04 21:33:39 +110030#include <cpu/x86/bist.h>
Joseph Smith6a1dc862008-03-09 13:24:46 +000031#include "spd_table.h"
32#include "gpio.c"
stepan836ae292010-12-08 05:42:47 +000033#include "southbridge/intel/i82801dx/tco_timer.c"
Joseph Smith6a1dc862008-03-09 13:24:46 +000034
Uwe Hermann57b2ff82010-11-21 17:29:59 +000035#define SERIAL_DEV PNP_DEV(0x2e, SMSCSUPERIO_SP1)
36
Joseph Smith6a1dc862008-03-09 13:24:46 +000037/**
Joseph Smith89e45772010-01-29 19:15:10 +000038 * The onboard 64MB PC133 memory does not have a SPD EEPROM so the
Joseph Smith6a1dc862008-03-09 13:24:46 +000039 * values have to be set manually, the SO-DIMM socket is located in
Uwe Hermannd773fd32010-11-20 20:23:08 +000040 * socket0 (0x50/DIMM0), and the onboard memory is located in socket1
41 * (0x51/DIMM1).
Joseph Smith6a1dc862008-03-09 13:24:46 +000042 */
43static inline int spd_read_byte(unsigned device, unsigned address)
44{
45 int i;
46
Uwe Hermannd773fd32010-11-20 20:23:08 +000047 if (device == DIMM0) {
Joseph Smith6a1dc862008-03-09 13:24:46 +000048 return smbus_read_byte(device, address);
Uwe Hermannd773fd32010-11-20 20:23:08 +000049 } else if (device == DIMM1) {
Joseph Smith6a1dc862008-03-09 13:24:46 +000050 for (i = 0; i < ARRAY_SIZE(spd_table); i++) {
51 if (spd_table[i].address == address)
52 return spd_table[i].data;
53 }
54 return 0xFF; /* Return 0xFF when address is not found. */
55 } else {
56 return 0xFF; /* Return 0xFF on any failures. */
57 }
58}
59
60#include "northbridge/intel/i82830/raminit.c"
Joseph Smith6a1dc862008-03-09 13:24:46 +000061
62/**
Joseph Smith89e45772010-01-29 19:15:10 +000063 * Setup mainboard specific registers pre raminit.
Joseph Smith6a1dc862008-03-09 13:24:46 +000064 */
Joseph Smith89e45772010-01-29 19:15:10 +000065static void mb_early_setup(void)
Joseph Smith6a1dc862008-03-09 13:24:46 +000066{
Joseph Smith89e45772010-01-29 19:15:10 +000067 /* - Hub Interface to PCI Bridge Registers - */
68 /* 12-Clock Retry Enable */
69 pci_write_config16(PCI_DEV(0, 0x1e, 0), 0x50, 0x1402);
70 /* Master Latency Timer Count */
71 pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20);
72 /* I/O Address Base */
73 pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1c, 0xf0);
Joseph Smith6a1dc862008-03-09 13:24:46 +000074
Joseph Smith89e45772010-01-29 19:15:10 +000075 /* - LPC Interface Bridge Registers - */
76 /* Delayed Transaction Enable */
77 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xd0, 0x00000002);
78 /* Disable the TCO Timer system reboot feature */
79 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd4, 0x02);
80 /* CPU Frequency Strap */
81 pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xd5, 0x02);
82 /* ACPI base address and enable Resource Indicator */
Stefan Reinauer14e22772010-04-27 06:56:47 +000083 pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, (PMBASE_ADDR | 1));
Joseph Smith89e45772010-01-29 19:15:10 +000084 /* Enable the SMBUS */
85 enable_smbus();
86 /* ACPI base address and disable Resource Indicator */
Stefan Reinauer14e22772010-04-27 06:56:47 +000087 pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, (PMBASE_ADDR));
Joseph Smith89e45772010-01-29 19:15:10 +000088 /* ACPI Enable */
89 pci_write_config8(PCI_DEV(0, 0x1f, 0), ACPI_CNTL, 0x10);
Joseph Smith6a1dc862008-03-09 13:24:46 +000090}
91
Aaron Durbina0a37272014-08-14 08:35:11 -050092#include <cpu/intel/romstage.h>
Stefan Reinauerccdd20a2010-04-14 07:47:07 +000093void main(unsigned long bist)
Joseph Smith6a1dc862008-03-09 13:24:46 +000094{
Stefan Reinauer800379f2010-03-01 08:34:19 +000095 if (bist == 0) {
Uwe Hermann7b997052010-11-21 22:47:22 +000096 if (memory_initialized())
Joseph Smithda695822008-05-15 13:44:33 +000097 hard_reset();
Stefan Reinauer800379f2010-03-01 08:34:19 +000098 }
Joseph Smith6a1dc862008-03-09 13:24:46 +000099
Joseph Smith89e45772010-01-29 19:15:10 +0000100 /* Set southbridge and superio gpios */
Joseph Smith6a1dc862008-03-09 13:24:46 +0000101 mb_gpio_init();
Joseph Smith89e45772010-01-29 19:15:10 +0000102
103 smscsuperio_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Joseph Smith6a1dc862008-03-09 13:24:46 +0000104 console_init();
105
106 /* Halt if there was a built in self test failure. */
107 report_bist_failure(bist);
108
Stefan Reinauer800379f2010-03-01 08:34:19 +0000109 /* disable TCO timers */
110 i82801dx_halt_tco_timer();
111
Joseph Smith89e45772010-01-29 19:15:10 +0000112 /* Setup mainboard specific registers */
113 mb_early_setup();
114
Joseph Smithfa742da2010-02-01 22:51:18 +0000115 /* Initialize memory */
116 sdram_initialize();
Stefan Reinauer138be832010-02-27 01:50:21 +0000117}