blob: 43cd7ac4754777ff33c877a0d1516d4fddca4661 [file] [log] [blame]
Angel Ponsa21dff62020-04-03 01:22:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Nico Huberefe1fed2013-04-29 18:00:57 +02002
Felix Held972d9f22022-02-23 16:32:20 +01003#include <arch/hpet.h>
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01004#include <bootblock_common.h>
Nico Huberefe1fed2013-04-29 18:00:57 +02005#include <stdint.h>
Elyes HAOUAS92c4bc12020-08-26 20:07:31 +02006#include <device/pnp_def.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +02007#include <device/pnp_ops.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02008#include <device/pci_ops.h>
Elyes HAOUAS8c905a82019-02-07 09:00:47 +01009#include <device/pci_def.h>
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +010010#include <northbridge/intel/sandybridge/raminit_native.h>
Elyes HAOUAS8c905a82019-02-07 09:00:47 +010011#include <northbridge/intel/sandybridge/raminit.h>
12#include <northbridge/intel/sandybridge/sandybridge.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110013#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010014#include <southbridge/intel/common/gpio.h>
Elyes HAOUASe051dc02018-08-06 10:55:59 +020015#include <superio/winbond/common/winbond.h>
Nico Huberefe1fed2013-04-29 18:00:57 +020016
Arthur Heymans2b28a162019-11-12 17:21:08 +010017void mainboard_pch_lpc_setup(void)
Nico Huberefe1fed2013-04-29 18:00:57 +020018{
19 /* Set COM3/COM1 decode ranges: 0x3e8/0x3f8 */
20 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0070);
21
22 /* Enable KBC on 0x06/0x64 (KBC),
23 * EC on 0x62/0x66 (MC),
24 * EC on 0x20c-0x20f (GAMEH),
25 * Super I/O on 0x2e/0x2f (CNF1),
26 * COM1/COM3 decode ranges. */
27 pci_write_config16(PCH_LPC_DEV, LPC_EN,
28 KBC_LPC_EN | MC_LPC_EN |
29 CNF1_LPC_EN | GAMEH_LPC_EN |
30 COMA_LPC_EN | COMB_LPC_EN);
31}
32
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010033void bootblock_mainboard_early_init(void)
Nico Huberefe1fed2013-04-29 18:00:57 +020034{
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020035 int lvds_3v = 0; /* 0 (5V) or 1 (3V3) */
36 int dis_bl_inv = 1; /* backlight inversion: 1 = disabled, 0 = enabled */
Elyes HAOUASefc3d042020-04-08 12:15:16 +020037 const pnp_devfn_t dev = PNP_DEV(0x2e, 0x9);
Elyes HAOUASe051dc02018-08-06 10:55:59 +020038 pnp_enter_conf_state(dev);
Nico Huber40f9ce92013-10-22 11:07:23 +020039 pnp_write_config(dev, 0x29, 0x02); /* Pins 119, 120 are GPIO21, 20 */
Elyes HAOUAS92c4bc12020-08-26 20:07:31 +020040 pnp_write_config(dev, PNP_IDX_EN, 0x03); /* Enable GPIO2+3 */
Nico Huber40f9ce92013-10-22 11:07:23 +020041 pnp_write_config(dev, 0x2a, 0x01); /* Pins 62, 63, 65, 66 are
42 GPIO27, 26, 25, 24 */
43 pnp_write_config(dev, 0x2c, 0xc3); /* Pin 90 is GPIO32,
44 Pins 78~85 are UART B */
45 pnp_write_config(dev, 0x2d, 0x00); /* Pins 67, 68, 70~73, 75, 77 are
46 GPIO57~50 */
Nico Huberefe1fed2013-04-29 18:00:57 +020047 pnp_set_logical_device(dev);
48 /* Values can only be changed, when devices are enabled. */
Nico Huberefe1fed2013-04-29 18:00:57 +020049 pnp_write_config(dev, 0xe3, 0xdd); /* GPIO2 bits 1, 5 are output */
Nico Huber40f9ce92013-10-22 11:07:23 +020050 pnp_write_config(dev, 0xe4, (dis_bl_inv << 5) | (lvds_3v << 1)); /* GPIO2 bits 1, 5 */
Elyes HAOUAS92c4bc12020-08-26 20:07:31 +020051 /* Disable suspend LED during normal operation */
52 pnp_write_config(dev, PNP_IDX_MSC3, 0x40);
Elyes HAOUASe051dc02018-08-06 10:55:59 +020053 pnp_exit_conf_state(dev);
Nico Huberefe1fed2013-04-29 18:00:57 +020054}
55
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010056void mainboard_fill_pei_data(struct pei_data *pei_data)
Nico Huberefe1fed2013-04-29 18:00:57 +020057{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010058 struct pei_data pei_data_template = {
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100059 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010060 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
61 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
62 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070063 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020064 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100065 .wdbbar = 0x4000000,
66 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +010067 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020068 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100069 .pmbase = DEFAULT_PMBASE,
70 .gpiobase = DEFAULT_GPIOBASE,
71 .thermalbase = 0xfed08000,
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020072 .system_type = 0, /* 0 Mobile, 1 Desktop/Server */
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100073 .tseg_size = CONFIG_SMM_TSEG_SIZE,
74 .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
75 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
76 .ec_present = 1,
77 .gbe_enable = 1,
78 .ddr3lv_support = 0,
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100079 .max_ddr3_freq = 1600,
80 .usb_port_config = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +010081 /* enabled USB oc pin length */
Nico Huberefe1fed2013-04-29 18:00:57 +020082 { 1, 0, 0x0040 }, /* P0: lower left USB 3.0 (OC0) */
83 { 1, 0, 0x0040 }, /* P1: upper left USB 3.0 (OC0) */
84 { 1, 0, 0x0040 }, /* P2: lower right USB 3.0 (OC0) */
85 { 1, 0, 0x0040 }, /* P3: upper right USB 3.0 (OC0) */
86 { 1, 0, 0x0040 }, /* P4: lower USB 2.0 (OC0) */
87 { 1, 0, 0x0040 }, /* P5: upper USB 2.0 (OC0) */
88 { 1, 0, 0x0040 }, /* P6: front panel USB 2.0 (OC0) */
89 { 1, 0, 0x0040 }, /* P7: front panel USB 2.0 (OC0) */
90 { 1, 4, 0x0040 }, /* P8: internal USB 2.0 (OC4) */
91 { 1, 4, 0x0040 }, /* P9: internal USB 2.0 (OC4) */
92 { 1, 4, 0x0040 }, /* P10: internal USB 2.0 (OC4) */
93 { 1, 4, 0x0040 }, /* P11: internal USB 2.0 (OC4) */
94 { 1, 4, 0x0040 }, /* P12: internal USB 2.0 (OC4) */
95 { 1, 4, 0x0040 }, /* P13: internal USB 2.0 (OC4) */
96 },
Edward O'Callaghan6f49f692014-05-24 02:04:52 +100097 .usb3 = {
98 .mode = 3, /* Smart Auto? */
99 .hs_port_switch_mask = 0xf, /* All four ports. */
100 .preboot_support = 1, /* preOS driver? */
101 .xhci_streams = 1, /* Enable. */
Nico Huberefe1fed2013-04-29 18:00:57 +0200102 },
Edward O'Callaghan6f49f692014-05-24 02:04:52 +1000103 .pcie_init = 1,
Nico Huberefe1fed2013-04-29 18:00:57 +0200104 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100105 *pei_data = pei_data_template;
106}
Nico Huberefe1fed2013-04-29 18:00:57 +0200107
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +0100108const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100109 /* enabled power USB oc pin */
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +0100110 { 1, 0, 0 }, /* P0: lower left USB 3.0 (OC0) */
111 { 1, 0, 0 }, /* P1: upper left USB 3.0 (OC0) */
112 { 1, 0, 0 }, /* P2: lower right USB 3.0 (OC0) */
113 { 1, 0, 0 }, /* P3: upper right USB 3.0 (OC0) */
114 { 1, 0, 0 }, /* P4: lower USB 2.0 (OC0) */
115 { 1, 0, 0 }, /* P5: upper USB 2.0 (OC0) */
116 { 1, 0, 0 }, /* P6: front panel USB 2.0 (OC0) */
117 { 1, 0, 0 }, /* P7: front panel USB 2.0 (OC0) */
118 { 1, 0, 4 }, /* P8: internal USB 2.0 (OC4) */
119 { 1, 0, 4 }, /* P9: internal USB 2.0 (OC4) */
120 { 1, 0, 4 }, /* P10: internal USB 2.0 (OC4) */
121 { 1, 0, 4 }, /* P11: internal USB 2.0 (OC4) */
122 { 1, 0, 4 }, /* P12: internal USB 2.0 (OC4) */
123 { 1, 0, 4 }, /* P13: internal USB 2.0 (OC4) */
124};
125
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100126void mainboard_get_spd(spd_raw_data *spd, bool id_only)
127{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200128 read_spd(&spd[0], 0x50, id_only);
129 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkoa50478f2016-02-10 03:03:41 +0100130}
131
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100132void mainboard_early_init(int s3resume)
133{
Nico Huberefe1fed2013-04-29 18:00:57 +0200134 /* Enable PEG10 (1x16) */
135 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN,
136 pci_read_config32(PCI_DEV(0, 0, 0), DEVEN) |
137 DEVEN_PEG10);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100138}