blob: 069b6adb35644d4318957423767766dc6f389690 [file] [log] [blame]
Stefan Reinauer6651da32012-04-27 23:16:30 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 *
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; version 2 of the License.
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.
Stefan Reinauer6651da32012-04-27 23:16:30 +020015 */
16
17#include <stdint.h>
18#include <string.h>
19#include <lib.h>
20#include <timestamp.h>
21#include <arch/io.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020022#include <device/pci_def.h>
23#include <device/pnp_def.h>
24#include <cpu/x86/lapic.h>
25#include <pc80/mc146818rtc.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030026#include <arch/acpi.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020027#include <cbmem.h>
28#include <console/console.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110029#include <superio/smsc/sio1007/chip.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110030#include <northbridge/intel/sandybridge/sandybridge.h>
31#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010032#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110033#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010034#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020035#include <arch/cpu.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020036#include <cpu/x86/msr.h>
Patrick Georgibd79c5e2014-11-28 22:35:36 +010037#include <halt.h>
Vladimir Serbinenko0e90dae2015-05-18 10:29:06 +020038#include <tpm.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020039
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070040#define SIO_PORT 0x164e
41
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010042void pch_enable_lpc(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020043{
44 device_t dev = PCH_LPC_DEV;
Stefan Reinauer6651da32012-04-27 23:16:30 +020045
46 /* Set COM1/COM2 decode range */
47 pci_write_config16(dev, LPC_IO_DEC, 0x0010);
48
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070049 /* Enable SuperIO + PS/2 Keyboard/Mouse */
50 u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | KBC_LPC_EN;
Stefan Reinauer6651da32012-04-27 23:16:30 +020051 pci_write_config16(dev, LPC_EN, lpc_config);
52
53 /* Map 256 bytes at 0x1600 to the LPC bus. */
54 pci_write_config32(dev, LPC_GEN1_DEC, 0xfc1601);
55
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070056 /* Map a range for the runtime_port registers to the LPC bus. */
Stefan Reinauer6651da32012-04-27 23:16:30 +020057 pci_write_config32(dev, LPC_GEN2_DEC, 0xc0181);
58
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070059 /* Enable COM1 */
60 if (sio1007_enable_uart_at(SIO_PORT)) {
61 pci_write_config16(dev, LPC_EN,
62 lpc_config | COMA_LPC_EN);
Stefan Reinauer6651da32012-04-27 23:16:30 +020063 }
64}
65
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010066void rcba_config(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020067{
68 u32 reg32;
69
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020070 southbridge_configure_default_intmap();
Stefan Reinauer6651da32012-04-27 23:16:30 +020071
Stefan Reinauer6651da32012-04-27 23:16:30 +020072 /* Disable unused devices (board specific) */
73 reg32 = RCBA32(FD);
74 reg32 |= PCH_DISABLE_ALWAYS;
75 RCBA32(FD) = reg32;
76}
77
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010078void mainboard_config_superio(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020079{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070080 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020081 const u16 runtime_port = 0x180;
82
83 /* Turn on configuration mode. */
84 outb(0x55, port);
85
86 /* Set the GPIO direction, polarity, and type. */
87 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
88 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
89 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
90
91 /* Set the base address for the runtime register block. */
92 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
93 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
94
95 /* Turn on address decoding for it. */
96 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
97
98 /* Set the value of GPIO 10 by changing GP1, bit 0. */
99 u8 byte;
100 byte = inb(runtime_port + 0xc);
101 byte |= (1 << 0);
102 outb(byte, runtime_port + 0xc);
103
104 /* Turn off address decoding for it. */
105 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
106
107 /* Turn off configuration mode. */
108 outb(0xaa, port);
109}
110
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100111void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +0200112{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100113 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000114 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800115 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
116 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000117 .epbar = DEFAULT_EPBAR,
118 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
119 .smbusbar = SMBUS_IO_BASE,
120 .wdbbar = 0x4000000,
121 .wdbsize = 0x1000,
122 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800123 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000124 .pmbase = DEFAULT_PMBASE,
125 .gpiobase = DEFAULT_GPIOBASE,
126 .thermalbase = 0xfed08000,
127 .system_type = 0, // 0 Mobile, 1 Desktop/Server
128 .tseg_size = CONFIG_SMM_TSEG_SIZE,
129 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
130 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
131 .ec_present = 0,
Stefan Reinauer6651da32012-04-27 23:16:30 +0200132 // 0 = leave channel enabled
133 // 1 = disable dimm 0 on channel
134 // 2 = disable dimm 1 on channel
135 // 3 = disable dimm 0+1 on channel
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000136 .dimm_channel0_disabled = 2,
137 .dimm_channel1_disabled = 2,
138 .max_ddr3_freq = 1600,
139 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +0200140 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
141 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
142 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
143 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
144 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
145 { 0, 0, 0x0000 }, /* P5: Empty */
146 { 0, 0, 0x0000 }, /* P6: Empty */
147 { 0, 0, 0x0000 }, /* P7: Empty */
148 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
149 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
150 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
151 { 0, 4, 0x0000 }, /* P11: Empty */
152 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
153 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
154 },
155 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100156 *pei_data = pei_data_template;
157}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200158
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100159const struct southbridge_usb_port mainboard_usb_ports[] = {
160 /* enabled power usb oc pin */
161 { 1, 0, 0 }, /* P0: Front port (OC0) */
162 { 1, 0, 1 }, /* P1: Back port (OC1) */
163 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
164 { 1, 0, -1 }, /* P3: MMC (no OC) */
165 { 1, 0, 2 }, /* P4: Front port (OC2) */
166 { 0, 0, -1 }, /* P5: Empty */
167 { 0, 0, -1 }, /* P6: Empty */
168 { 0, 0, -1 }, /* P7: Empty */
169 { 1, 0, 4 }, /* P8: Back port (OC4) */
170 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
171 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
172 { 0, 0, -1 }, /* P11: Empty */
173 { 1, 0, 6 }, /* P12: Back port (OC6) */
174 { 1, 0, 5 }, /* P13: Back port (OC5) */
175};
176
177void mainboard_get_spd(spd_raw_data *spd) {
178 read_spd(&spd[0], 0x50);
179 read_spd(&spd[2], 0x52);
180}
181
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100182void mainboard_early_init(int s3resume)
183{
184}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200185
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100186int mainboard_should_reset_usb(int s3resume)
187{
188 return !s3resume;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200189}