blob: 6dfbfcb8a02b9035ee2dbaa0d580791d4dfd7bfd [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>
Julius Wernercd49cce2019-03-05 16:53:33 -080028#if CONFIG(CHROMEOS)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080029#include <vendorcode/google/chromeos/chromeos.h>
30#endif
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080031
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -060032void pch_enable_lpc(void)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080033{
34 /* EC Decode Range Port60/64 and Port62/66 */
35 /* Enable EC and PS/2 Keyboard/Mouse*/
36 pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN);
37
38 /* EC Decode Range Port68/6C */
39 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (0x68 & ~3) | 0x40001);
40
41 /* EC Decode Range Port 380-387 */
42 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0x380 | 0x40001);
43
44}
45
Nico Huberff4025c2018-01-14 12:34:43 +010046void mainboard_rcba_config(void)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080047{
48 u32 reg32;
49
Kyösti Mälkki6f499062015-06-06 11:52:24 +030050 /*
51 * GFX INTA -> PIRQA (MSI)
52 * D28IP_P1IP WLAN INTA -> PIRQB
53 * D28IP_P2IP ETH0 INTB -> PIRQF
54 * D28IP_P3IP SDCARD INTC -> PIRQD
55 * D29IP_E1P EHCI1 INTA -> PIRQD
56 * D26IP_E2P EHCI2 INTA -> PIRQF
57 * D31IP_SIP SATA INTA -> PIRQB (MSI)
58 * D31IP_SMIP SMBUS INTB -> PIRQH
59 * D31IP_TTIP THRT INTC -> PIRQA
60 * D27IP_ZIP HDA INTA -> PIRQA (MSI)
61 *
62 * Trackpad interrupt is edge triggered and cannot be shared.
63 * TRACKPAD -> PIRQG
64
65 */
66
67 /* Device interrupt pin register (board specific) */
68 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
69 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
70 RCBA32(D29IP) = (INTA << D29IP_E1P);
71 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTB << D28IP_P2IP) |
72 (INTC << D28IP_P3IP);
73 RCBA32(D27IP) = (INTA << D27IP_ZIP);
74 RCBA32(D26IP) = (INTA << D26IP_E2P);
75 RCBA32(D25IP) = (NOINT << D25IP_LIP);
76 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
77
78 /* Device interrupt route registers */
79 DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC);
80 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
81 DIR_ROUTE(D28IR, PIRQB, PIRQF, PIRQD, PIRQE);
82 DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB);
83 DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH);
84 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
85 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
86
87 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +020088 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +030089 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +020090 (void) RCBA16(OIC);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080091
92 /* Disable unused devices (board specific) */
93 reg32 = RCBA32(FD);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080094 /* Disable PCI bridge so MRC does not probe this bus */
95 reg32 |= PCH_DISABLE_P2P;
96 RCBA32(FD) = reg32;
97}
98
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -060099const struct southbridge_usb_port mainboard_usb_ports[] = {
Vladimir Serbinenko4a84e472016-02-10 02:51:48 +0100100 /* enabled power usb oc pin */
101 { 1, 0, -1 }, /* P0: Right USB 3.0 #1 (no OC) */
102 { 1, 0, -1 }, /* P1: Right USB 3.0 #2 (no OC) */
103 { 1, 0, -1 }, /* P2: Camera (no OC) */
104 { 0, 0, -1 }, /* P3: Empty */
105 { 0, 0, -1 }, /* P4: Empty */
106 { 0, 0, -1 }, /* P5: Empty */
107 { 0, 0, -1 }, /* P6: Empty */
108 { 0, 0, -1 }, /* P7: Empty */
109 { 0, 0, -1 }, /* P8: Empty */
110 { 1, 1, -1 }, /* P9: Left USB 1 (no OC) */
111 { 1, 0, -1 }, /* P10: Mini PCIe - WLAN / BT (no OC) */
112 { 0, 0, -1 }, /* P11: Empty */
113 { 0, 0, -1 }, /* P12: Empty */
114 { 0, 0, -1 }, /* P13: Empty */
Alexandru Gagniuc83b05eb2015-02-15 14:09:21 -0600115};
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800116
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100117void mainboard_get_spd(spd_raw_data *spd, bool id_only)
118{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200119 read_spd(&spd[0], 0x50, id_only);
120 read_spd(&spd[2], 0x52, id_only);
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -0800121}
Vladimir Serbinenko609bd942016-01-31 14:00:54 +0100122
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100123void mainboard_early_init(int s3resume)
124{
Vladimir Serbinenko609bd942016-01-31 14:00:54 +0100125}
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100126
127void mainboard_config_superio(void)
128{
129}
Vladimir Serbinenko421b3402016-02-10 02:39:51 +0100130
131
132void mainboard_fill_pei_data(struct pei_data *pei_data)
133{
134 struct pei_data pei_data_template = {
135 .pei_version = PEI_VERSION,
136 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
137 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
138 .epbar = DEFAULT_EPBAR,
139 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
140 .smbusbar = SMBUS_IO_BASE,
141 .wdbbar = 0x4000000,
142 .wdbsize = 0x1000,
143 .hpet_address = CONFIG_HPET_ADDRESS,
144 .rcba = (uintptr_t)DEFAULT_RCBABASE,
145 .pmbase = DEFAULT_PMBASE,
146 .gpiobase = DEFAULT_GPIOBASE,
147 .thermalbase = 0xfed08000,
148 .system_type = 0, // 0 Mobile, 1 Desktop/Server
149 .tseg_size = CONFIG_SMM_TSEG_SIZE,
150 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
151 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
152 .ec_present = 1,
153 .ddr3lv_support = 0,
154 // 0 = leave channel enabled
155 // 1 = disable dimm 0 on channel
156 // 2 = disable dimm 1 on channel
157 // 3 = disable dimm 0+1 on channel
158 .dimm_channel0_disabled = 2,
159 .dimm_channel1_disabled = 2,
160 .max_ddr3_freq = 1600,
161 .usb_port_config = {
162 /* enabled usb oc pin length */
163 { 1, 0, 0x0040 }, /* P0: Right USB 3.0 #1 (no OC) */
164 { 1, 0, 0x0040 }, /* P1: Right USB 3.0 #2 (no OC) */
165 { 1, 0, 0x0040 }, /* P2: Camera (no OC) */
166 { 0, 0, 0x0000 }, /* P3: Empty */
167 { 0, 0, 0x0000 }, /* P4: Empty */
168 { 0, 0, 0x0000 }, /* P5: Empty */
169 { 0, 0, 0x0000 }, /* P6: Empty */
170 { 0, 0, 0x0000 }, /* P7: Empty */
171 { 0, 4, 0x0000 }, /* P8: Empty */
172 { 1, 4, 0x0080 }, /* P9: Left USB 1 (no OC) */
173 { 1, 4, 0x0040 }, /* P10: Mini PCIe - WLAN / BT (no OC) */
174 { 0, 4, 0x0000 }, /* P11: Empty */
175 { 0, 4, 0x0000 }, /* P12: Empty */
176 { 0, 4, 0x0000 }, /* P13: Empty */
177 },
178 .ddr_refresh_rate_config = 2, /* Force double refresh rate */
179 };
180 *pei_data = pei_data_template;
181}
Matt DeVillierc35a1e82017-07-11 23:59:53 -0500182
183int mainboard_should_reset_usb(int s3resume)
184{
185 return !s3resume;
186}