blob: 726e561e397078713c06c845e02f09a44884962e [file] [log] [blame]
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08001/*
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 Reinauerd7bd4eb2013-02-11 11:11:36 -080015 */
16
17#include <stdint.h>
18#include <string.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080020#include <device/pci_def.h>
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080021#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030022#include <arch/acpi.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110023#include <northbridge/intel/sandybridge/sandybridge.h>
Vladimir Serbinenko421b3402016-02-10 02:39:51 +010024#include <northbridge/intel/sandybridge/raminit.h>
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -060025#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010027#include <southbridge/intel/common/gpio.h>
Patrick Georgibd79c5e2014-11-28 22:35:36 +010028#include <halt.h>
Julius Wernercd49cce2019-03-05 16:53:33 -080029#if CONFIG(CHROMEOS)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080030#include <vendorcode/google/chromeos/chromeos.h>
31#endif
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080032
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -060033void pch_enable_lpc(void)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080034{
35 /* EC Decode Range Port60/64 and Port62/66 */
36 /* Enable EC and PS/2 Keyboard/Mouse*/
37 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN);
38
39 /* EC Decode Range Port68/6C */
40 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (0x68 & ~3) | 0x40001);
41
42 /* EC Decode Range Port 380-387 */
43 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0x380 | 0x40001);
44
45}
46
Nico Huberff4025c2018-01-14 12:34:43 +010047void mainboard_rcba_config(void)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080048{
49 u32 reg32;
50
Kyösti Mälkki6f499062015-06-06 11:52:24 +030051 /*
52 * GFX INTA -> PIRQA (MSI)
53 * D28IP_P1IP WLAN INTA -> PIRQB
54 * D28IP_P2IP ETH0 INTB -> PIRQF
55 * D28IP_P3IP SDCARD INTC -> PIRQD
56 * D29IP_E1P EHCI1 INTA -> PIRQD
57 * D26IP_E2P EHCI2 INTA -> PIRQF
58 * D31IP_SIP SATA INTA -> PIRQB (MSI)
59 * D31IP_SMIP SMBUS INTB -> PIRQH
60 * D31IP_TTIP THRT INTC -> PIRQA
61 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
62 *
63 * Trackpad interrupt is edge triggered and cannot be shared.
64 * TRACKPAD -> PIRQG
65
66 */
67
68 /* Device interrupt pin register (board specific) */
69 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
70 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
71 RCBA32(D29IP) = (INTA << D29IP_E1P);
72 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTB << D28IP_P2IP) |
73 (INTC << D28IP_P3IP);
74 RCBA32(D27IP) = (INTA << D27IP_ZIP);
75 RCBA32(D26IP) = (INTA << D26IP_E2P);
76 RCBA32(D25IP) = (NOINT << D25IP_LIP);
77 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
78
79 /* Device interrupt route registers */
80 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
81 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
82 DIR_ROUTE(D28IR, PIRQB, PIRQF, PIRQD, PIRQE);
83 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
84 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
85 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
86 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
87
88 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020089 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030090 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +020091 (void) RCBA16(OIC);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080092
93 /* Disable unused devices (board specific) */
94 reg32 = RCBA32(FD);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080095 /* Disable PCI bridge so MRC does not probe this bus */
96 reg32 |= PCH_DISABLE_P2P;
97 RCBA32(FD) = reg32;
98}
99
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -0600100const struct southbridge_usb_port mainboard_usb_ports[] = {
Vladimir Serbinenko4a84e472016-02-10 02:51:48 +0100101 /* enabled power usb oc pin */
102 { 1, 0, -1 }, /* P0: Right USB 3.0 #1 (no OC) */
103 { 1, 0, -1 }, /* P1: Right USB 3.0 #2 (no OC) */
104 { 1, 0, -1 }, /* P2: Camera (no OC) */
105 { 0, 0, -1 }, /* P3: Empty */
106 { 0, 0, -1 }, /* P4: Empty */
107 { 0, 0, -1 }, /* P5: Empty */
108 { 0, 0, -1 }, /* P6: Empty */
109 { 0, 0, -1 }, /* P7: Empty */
110 { 0, 0, -1 }, /* P8: Empty */
111 { 1, 1, -1 }, /* P9: Left USB 1 (no OC) */
112 { 1, 0, -1 }, /* P10: Mini PCIe - WLAN / BT (no OC) */
113 { 0, 0, -1 }, /* P11: Empty */
114 { 0, 0, -1 }, /* P12: Empty */
115 { 0, 0, -1 }, /* P13: Empty */
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -0600116};
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800117
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100118void mainboard_get_spd(spd_raw_data *spd, bool id_only)
119{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200120 read_spd(&spd[0], 0x50, id_only);
121 read_spd(&spd[2], 0x52, id_only);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800122}
Vladimir Serbinenko609bd942016-01-31 14:00:54 +0100123
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100124void mainboard_early_init(int s3resume)
125{
Vladimir Serbinenko609bd942016-01-31 14:00:54 +0100126}
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100127
128void mainboard_config_superio(void)
129{
130}
Vladimir Serbinenko421b3402016-02-10 02:39:51 +0100131
132
133void mainboard_fill_pei_data(struct pei_data *pei_data)
134{
135 struct pei_data pei_data_template = {
136 .pei_version = PEI_VERSION,
137 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
138 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
139 .epbar = DEFAULT_EPBAR,
140 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
141 .smbusbar = SMBUS_IO_BASE,
142 .wdbbar = 0x4000000,
143 .wdbsize = 0x1000,
144 .hpet_address = CONFIG_HPET_ADDRESS,
145 .rcba = (uintptr_t)DEFAULT_RCBABASE,
146 .pmbase = DEFAULT_PMBASE,
147 .gpiobase = DEFAULT_GPIOBASE,
148 .thermalbase = 0xfed08000,
149 .system_type = 0, // 0 Mobile, 1 Desktop/Server
150 .tseg_size = CONFIG_SMM_TSEG_SIZE,
151 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
152 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
153 .ec_present = 1,
154 .ddr3lv_support = 0,
155 // 0 = leave channel enabled
156 // 1 = disable dimm 0 on channel
157 // 2 = disable dimm 1 on channel
158 // 3 = disable dimm 0+1 on channel
159 .dimm_channel0_disabled = 2,
160 .dimm_channel1_disabled = 2,
161 .max_ddr3_freq = 1600,
162 .usb_port_config = {
163 /* enabled usb oc pin length */
164 { 1, 0, 0x0040 }, /* P0: Right USB 3.0 #1 (no OC) */
165 { 1, 0, 0x0040 }, /* P1: Right USB 3.0 #2 (no OC) */
166 { 1, 0, 0x0040 }, /* P2: Camera (no OC) */
167 { 0, 0, 0x0000 }, /* P3: Empty */
168 { 0, 0, 0x0000 }, /* P4: Empty */
169 { 0, 0, 0x0000 }, /* P5: Empty */
170 { 0, 0, 0x0000 }, /* P6: Empty */
171 { 0, 0, 0x0000 }, /* P7: Empty */
172 { 0, 4, 0x0000 }, /* P8: Empty */
173 { 1, 4, 0x0080 }, /* P9: Left USB 1 (no OC) */
174 { 1, 4, 0x0040 }, /* P10: Mini PCIe - WLAN / BT (no OC) */
175 { 0, 4, 0x0000 }, /* P11: Empty */
176 { 0, 4, 0x0000 }, /* P12: Empty */
177 { 0, 4, 0x0000 }, /* P13: Empty */
178 },
179 .ddr_refresh_rate_config = 2, /* Force double refresh rate */
180 };
181 *pei_data = pei_data_template;
182}
Matt DeVillierc35a1e82017-07-11 23:59:53 -0500183
184int mainboard_should_reset_usb(int s3resume)
185{
186 return !s3resume;
187}