blob: 459c2461ca7b6e8daeb8ad4d694e3db3166bc9ff [file] [log] [blame]
Sven Schnellee2ca71e2011-02-14 20:02:47 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
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.
Sven Schnellee2ca71e2011-02-14 20:02:47 +000016 */
17
Arthur Heymansc5839202019-11-12 23:48:42 +010018#include <bootblock_common.h>
Kyösti Mälkki7fbed222019-07-11 08:14:07 +030019#include <delay.h>
Arthur Heymansdc584c32019-11-12 20:37:21 +010020#include <stdint.h>
21#include <device/pnp_def.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +020022#include <device/pnp_ops.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020023#include <device/pci_ops.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <northbridge/intel/i945/i945.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110025#include <southbridge/intel/i82801gx/i82801gx.h>
Arthur Heymans62902ca2016-11-29 14:13:43 +010026#include <southbridge/intel/common/gpio.h>
Sven Schnellefea6bd12011-04-01 07:28:56 +000027#include "dock.h"
Sven Schnellee2ca71e2011-02-14 20:02:47 +000028
Arthur Heymansfecf7772019-11-09 14:19:04 +010029/* Override the default lpc decode ranges */
Arthur Heymansdc584c32019-11-12 20:37:21 +010030void mainboard_lpc_decode(void)
Sven Schnellee2ca71e2011-02-14 20:02:47 +000031{
Sven Schnellee2ca71e2011-02-14 20:02:47 +000032 // decode range
Arthur Heymansb451df22017-08-15 20:59:09 +020033 pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_IO_DEC, 0x0210);
Sven Schnellee2ca71e2011-02-14 20:02:47 +000034}
35
Sven Schnellee2ca71e2011-02-14 20:02:47 +000036static void early_superio_config(void)
37{
Sven Schnelledf6fd562011-04-05 13:00:33 +000038 int timeout = 100000;
Antonello Dettori4bf48e82016-08-30 22:15:49 +020039 pnp_devfn_t dev = PNP_DEV(0x2e, 3);
Sven Schnellee2ca71e2011-02-14 20:02:47 +000040
Sven Schnelledf6fd562011-04-05 13:00:33 +000041 pnp_write_config(dev, 0x29, 0x06);
42
Paul Menzelc2f17772013-04-29 23:05:44 +020043 while (!(pnp_read_config(dev, 0x29) & 0x08) && timeout--)
Sven Schnelledf6fd562011-04-05 13:00:33 +000044 udelay(1000);
Sven Schnellee2ca71e2011-02-14 20:02:47 +000045
46 /* Enable COM1 */
Sven Schnelledf6fd562011-04-05 13:00:33 +000047 pnp_set_logical_device(dev);
48 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
49 pnp_set_enable(dev, 1);
Sven Schnellee2ca71e2011-02-14 20:02:47 +000050}
51
Arthur Heymansc5839202019-11-12 23:48:42 +010052void bootblock_mainboard_early_init(void)
Arthur Heymansdc584c32019-11-12 20:37:21 +010053{
54 /* Set up GPIO's early since it is needed for dock init */
55 i82801gx_setup_bars();
56 setup_pch_gpios(&mainboard_gpio_map);
57
58 dlpc_init();
59 /* dock_init initializes the DLPC switch on
60 * thinpad side, so this is required even
61 * if we're undocked.
62 */
63 if (dock_present()) {
64 dock_connect();
65 early_superio_config();
66 }
67}
68
69void mainboard_late_rcba_config(void)
Sven Schnellee2ca71e2011-02-14 20:02:47 +000070{
71 /* Set up virtual channel 0 */
Peter Lemenkove2324552018-10-23 11:17:32 +020072 RCBA32(V0CTL) = 0x80000001;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000073
74 /* Device 1f interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +020075 RCBA32(D31IP) = 0x00001230;
76 RCBA32(D29IP) = 0x40004321;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000077
78 /* PCIe Interrupts */
Arthur Heymansb451df22017-08-15 20:59:09 +020079 RCBA32(D28IP) = 0x00004321;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000080 /* HD Audio Interrupt */
Arthur Heymansb451df22017-08-15 20:59:09 +020081 RCBA32(D27IP) = 0x00000002;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000082
83 /* dev irq route register */
Arthur Heymansb451df22017-08-15 20:59:09 +020084 RCBA16(D31IR) = 0x1007;
85 RCBA16(D30IR) = 0x0076;
86 RCBA16(D29IR) = 0x3210;
87 RCBA16(D28IR) = 0x7654;
88 RCBA16(D27IR) = 0x0010;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000089
Sven Schnellee2ca71e2011-02-14 20:02:47 +000090 /* Disable unused devices */
Arthur Heymans6267f5d2018-12-15 23:46:48 +010091 RCBA32(FD) |= FD_INTLAN;
Sven Schnelleddb3f0a2011-02-16 13:12:41 +000092
93 /* Set up I/O Trap #0 for 0xfe00 (SMIC) */
Peter Lemenkov522a1b52019-01-10 12:19:01 +010094 RCBA64(IOTR0) = 0x000200010000fe01ULL;
Sven Schnelleddb3f0a2011-02-16 13:12:41 +000095
96 /* Set up I/O Trap #3 for 0x800-0x80c (Trap) */
Peter Lemenkov522a1b52019-01-10 12:19:01 +010097 RCBA64(IOTR3) = 0x000200f0000c0801ULL;
Sven Schnellee2ca71e2011-02-14 20:02:47 +000098}
99
Arthur Heymansdc584c32019-11-12 20:37:21 +0100100
101void mainboard_get_spd_map(u8 spd_map[4])
Sven Schnellee2ca71e2011-02-14 20:02:47 +0000102{
Arthur Heymansdc584c32019-11-12 20:37:21 +0100103 spd_map[0] = 0x50;
104 spd_map[2] = 0x51;
Sven Schnellee2ca71e2011-02-14 20:02:47 +0000105}