blob: 30800e8eb06b000b1fd775c3417a06070180263f [file] [log] [blame]
Nico Huberefe1fed2013-04-29 18:00:57 +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.
Nico Huberefe1fed2013-04-29 18:00:57 +020015 */
16
17#include <stdint.h>
18#include <string.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030019#include <arch/acpi.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +020020#include <device/pnp_ops.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Elyes HAOUAS8c905a82019-02-07 09:00:47 +010022#include <cpu/x86/lapic.h>
23#include <cpu/x86/msr.h>
24#include <device/pci_def.h>
25#include <halt.h>
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +010026#include <northbridge/intel/sandybridge/raminit_native.h>
Elyes HAOUAS8c905a82019-02-07 09:00:47 +010027#include <northbridge/intel/sandybridge/raminit.h>
28#include <northbridge/intel/sandybridge/sandybridge.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110029#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010030#include <southbridge/intel/common/gpio.h>
Elyes HAOUASe051dc02018-08-06 10:55:59 +020031#include <superio/winbond/common/winbond.h>
Elyes HAOUAS8c905a82019-02-07 09:00:47 +010032#include <timestamp.h>
33
Nico Huberefe1fed2013-04-29 18:00:57 +020034
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010035void pch_enable_lpc(void)
Nico Huberefe1fed2013-04-29 18:00:57 +020036{
37 /* Set COM3/COM1 decode ranges: 0x3e8/0x3f8 */
38 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0070);
39
40 /* Enable KBC on 0x06/0x64 (KBC),
41 * EC on 0x62/0x66 (MC),
42 * EC on 0x20c-0x20f (GAMEH),
43 * Super I/O on 0x2e/0x2f (CNF1),
44 * COM1/COM3 decode ranges. */
45 pci_write_config16(PCH_LPC_DEV, LPC_EN,
46 KBC_LPC_EN | MC_LPC_EN |
47 CNF1_LPC_EN | GAMEH_LPC_EN |
48 COMA_LPC_EN | COMB_LPC_EN);
49}
50
Nico Huberff4025c2018-01-14 12:34:43 +010051void mainboard_rcba_config(void)
Nico Huberefe1fed2013-04-29 18:00:57 +020052{
53 u32 reg32;
54
Nico Huberefe1fed2013-04-29 18:00:57 +020055 /* Disable unused devices (board specific) */
56 reg32 = RCBA32(FD);
Nico Huberefe1fed2013-04-29 18:00:57 +020057 /* Disable PCI bridge so MRC does not probe this bus */
58 reg32 |= PCH_DISABLE_P2P;
59 RCBA32(FD) = reg32;
60}
61
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010062void mainboard_config_superio(void)
Nico Huberefe1fed2013-04-29 18:00:57 +020063{
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020064 int lvds_3v = 0; /* 0 (5V) or 1 (3V3) */
65 int dis_bl_inv = 1; /* backlight inversion: 1 = disabled, 0 = enabled */
Antonello Dettori82fcc1a2016-11-08 18:44:46 +010066 pnp_devfn_t dev = PNP_DEV(0x2e, 0x9);
Elyes HAOUASe051dc02018-08-06 10:55:59 +020067 pnp_enter_conf_state(dev);
Nico Huber40f9ce92013-10-22 11:07:23 +020068 pnp_write_config(dev, 0x29, 0x02); /* Pins 119, 120 are GPIO21, 20 */
69 pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO2+3 */
70 pnp_write_config(dev, 0x2a, 0x01); /* Pins 62, 63, 65, 66 are
71 GPIO27, 26, 25, 24 */
72 pnp_write_config(dev, 0x2c, 0xc3); /* Pin 90 is GPIO32,
73 Pins 78~85 are UART B */
74 pnp_write_config(dev, 0x2d, 0x00); /* Pins 67, 68, 70~73, 75, 77 are
75 GPIO57~50 */
Nico Huberefe1fed2013-04-29 18:00:57 +020076 pnp_set_logical_device(dev);
77 /* Values can only be changed, when devices are enabled. */
Nico Huberefe1fed2013-04-29 18:00:57 +020078 pnp_write_config(dev, 0xe3, 0xdd); /* GPIO2 bits 1, 5 are output */
Nico Huber40f9ce92013-10-22 11:07:23 +020079 pnp_write_config(dev, 0xe4, (dis_bl_inv << 5) | (lvds_3v << 1)); /* GPIO2 bits 1, 5 */
Nico Hubera90c7852015-04-15 13:46:08 +020080 pnp_write_config(dev, 0xf3, 0x40); /* Disable suspend LED during normal operation */
Elyes HAOUASe051dc02018-08-06 10:55:59 +020081 pnp_exit_conf_state(dev);
Nico Huberefe1fed2013-04-29 18:00:57 +020082}
83
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010084void mainboard_fill_pei_data(struct pei_data *pei_data)
Nico Huberefe1fed2013-04-29 18:00:57 +020085{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010086 struct pei_data pei_data_template = {
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100087 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080088 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
89 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100090 .epbar = DEFAULT_EPBAR,
91 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
92 .smbusbar = SMBUS_IO_BASE,
93 .wdbbar = 0x4000000,
94 .wdbsize = 0x1000,
95 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080096 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100097 .pmbase = DEFAULT_PMBASE,
98 .gpiobase = DEFAULT_GPIOBASE,
99 .thermalbase = 0xfed08000,
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200100 .system_type = 0, /* 0 Mobile, 1 Desktop/Server */
Edward O'Callaghan6f49f692014-05-24 02:04:52 +1000101 .tseg_size = CONFIG_SMM_TSEG_SIZE,
102 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
103 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
104 .ec_present = 1,
105 .gbe_enable = 1,
106 .ddr3lv_support = 0,
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200107 /*
108 * 0 = leave channel enabled
109 * 1 = disable dimm 0 on channel
110 * 2 = disable dimm 1 on channel
111 * 3 = disable dimm 0+1 on channel
112 */
Edward O'Callaghan6f49f692014-05-24 02:04:52 +1000113 .dimm_channel0_disabled = 2,
114 .dimm_channel1_disabled = 2,
115 .max_ddr3_freq = 1600,
116 .usb_port_config = {
Nico Huberefe1fed2013-04-29 18:00:57 +0200117 /* enabled usb oc pin length */
118 { 1, 0, 0x0040 }, /* P0: lower left USB 3.0 (OC0) */
119 { 1, 0, 0x0040 }, /* P1: upper left USB 3.0 (OC0) */
120 { 1, 0, 0x0040 }, /* P2: lower right USB 3.0 (OC0) */
121 { 1, 0, 0x0040 }, /* P3: upper right USB 3.0 (OC0) */
122 { 1, 0, 0x0040 }, /* P4: lower USB 2.0 (OC0) */
123 { 1, 0, 0x0040 }, /* P5: upper USB 2.0 (OC0) */
124 { 1, 0, 0x0040 }, /* P6: front panel USB 2.0 (OC0) */
125 { 1, 0, 0x0040 }, /* P7: front panel USB 2.0 (OC0) */
126 { 1, 4, 0x0040 }, /* P8: internal USB 2.0 (OC4) */
127 { 1, 4, 0x0040 }, /* P9: internal USB 2.0 (OC4) */
128 { 1, 4, 0x0040 }, /* P10: internal USB 2.0 (OC4) */
129 { 1, 4, 0x0040 }, /* P11: internal USB 2.0 (OC4) */
130 { 1, 4, 0x0040 }, /* P12: internal USB 2.0 (OC4) */
131 { 1, 4, 0x0040 }, /* P13: internal USB 2.0 (OC4) */
132 },
Edward O'Callaghan6f49f692014-05-24 02:04:52 +1000133 .usb3 = {
134 .mode = 3, /* Smart Auto? */
135 .hs_port_switch_mask = 0xf, /* All four ports. */
136 .preboot_support = 1, /* preOS driver? */
137 .xhci_streams = 1, /* Enable. */
Nico Huberefe1fed2013-04-29 18:00:57 +0200138 },
Edward O'Callaghan6f49f692014-05-24 02:04:52 +1000139 .pcie_init = 1,
Nico Huberefe1fed2013-04-29 18:00:57 +0200140 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100141 *pei_data = pei_data_template;
142}
Nico Huberefe1fed2013-04-29 18:00:57 +0200143
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +0100144const struct southbridge_usb_port mainboard_usb_ports[] = {
145 /* enabled power usb oc pin */
146 { 1, 0, 0 }, /* P0: lower left USB 3.0 (OC0) */
147 { 1, 0, 0 }, /* P1: upper left USB 3.0 (OC0) */
148 { 1, 0, 0 }, /* P2: lower right USB 3.0 (OC0) */
149 { 1, 0, 0 }, /* P3: upper right USB 3.0 (OC0) */
150 { 1, 0, 0 }, /* P4: lower USB 2.0 (OC0) */
151 { 1, 0, 0 }, /* P5: upper USB 2.0 (OC0) */
152 { 1, 0, 0 }, /* P6: front panel USB 2.0 (OC0) */
153 { 1, 0, 0 }, /* P7: front panel USB 2.0 (OC0) */
154 { 1, 0, 4 }, /* P8: internal USB 2.0 (OC4) */
155 { 1, 0, 4 }, /* P9: internal USB 2.0 (OC4) */
156 { 1, 0, 4 }, /* P10: internal USB 2.0 (OC4) */
157 { 1, 0, 4 }, /* P11: internal USB 2.0 (OC4) */
158 { 1, 0, 4 }, /* P12: internal USB 2.0 (OC4) */
159 { 1, 0, 4 }, /* P13: internal USB 2.0 (OC4) */
160};
161
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100162void mainboard_get_spd(spd_raw_data *spd, bool id_only)
163{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200164 read_spd(&spd[0], 0x50, id_only);
165 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +0100166}
167
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100168void mainboard_early_init(int s3resume)
169{
Nico Huberefe1fed2013-04-29 18:00:57 +0200170 /* Enable PEG10 (1x16) */
171 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN,
172 pci_read_config32(PCI_DEV(0, 0, 0), DEVEN) |
173 DEVEN_PEG10);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100174}
Nico Huberefe1fed2013-04-29 18:00:57 +0200175
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100176int mainboard_should_reset_usb(int s3resume)
177{
178 return !s3resume;
Nico Huberefe1fed2013-04-29 18:00:57 +0200179}