Angel Pons | d28443e | 2020-04-05 13:22:44 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 3 | |
Elyes HAOUAS | 282171c | 2019-06-30 00:16:40 +0200 | [diff] [blame] | 4 | #include <stddef.h> |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 5 | #include <stdint.h> |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 6 | #include <string.h> |
| 7 | #include <cbfs.h> |
| 8 | #include <console/console.h> |
| 9 | #include <cpu/intel/haswell/haswell.h> |
| 10 | #include <northbridge/intel/haswell/haswell.h> |
| 11 | #include <northbridge/intel/haswell/raminit.h> |
| 12 | #include <southbridge/intel/lynxpoint/pch.h> |
| 13 | #include <southbridge/intel/lynxpoint/lp_gpio.h> |
| 14 | #include <variant/gpio.h> |
| 15 | #include "../../variant.h" |
| 16 | |
| 17 | const struct rcba_config_instruction rcba_config[] = { |
| 18 | |
| 19 | /* |
| 20 | * GFX INTA -> PIRQA (MSI) |
| 21 | * D28IP_P1IP PCIE INTA -> PIRQA |
| 22 | * D29IP_E1P EHCI INTA -> PIRQD |
| 23 | * D20IP_XHCI XHCI INTA -> PIRQC (MSI) |
| 24 | * D31IP_SIP SATA INTA -> PIRQF (MSI) |
| 25 | * D31IP_SMIP SMBUS INTB -> PIRQG |
| 26 | * D31IP_TTIP THRT INTC -> PIRQA |
| 27 | * D27IP_ZIP HDA INTA -> PIRQG (MSI) |
| 28 | */ |
| 29 | |
| 30 | /* Device interrupt pin register (board specific) */ |
| 31 | RCBA_SET_REG_32(D31IP, (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 32 | (INTB << D31IP_SMIP) | (INTA << D31IP_SIP)), |
| 33 | RCBA_SET_REG_32(D29IP, (INTA << D29IP_E1P)), |
| 34 | RCBA_SET_REG_32(D28IP, (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) | |
| 35 | (INTB << D28IP_P4IP)), |
| 36 | RCBA_SET_REG_32(D27IP, (INTA << D27IP_ZIP)), |
| 37 | RCBA_SET_REG_32(D26IP, (INTA << D26IP_E2P)), |
| 38 | RCBA_SET_REG_32(D22IP, (NOINT << D22IP_MEI1IP)), |
| 39 | RCBA_SET_REG_32(D20IP, (INTA << D20IP_XHCI)), |
| 40 | |
| 41 | /* Device interrupt route registers */ |
| 42 | RCBA_SET_REG_32(D31IR, DIR_ROUTE(PIRQG, PIRQC, PIRQB, PIRQA)),/* LPC */ |
| 43 | RCBA_SET_REG_32(D29IR, DIR_ROUTE(PIRQD, PIRQD, PIRQD, PIRQD)),/* EHCI */ |
| 44 | RCBA_SET_REG_32(D28IR, DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD)),/* PCIE */ |
| 45 | RCBA_SET_REG_32(D27IR, DIR_ROUTE(PIRQG, PIRQG, PIRQG, PIRQG)),/* HDA */ |
| 46 | RCBA_SET_REG_32(D22IR, DIR_ROUTE(PIRQA, PIRQA, PIRQA, PIRQA)),/* ME */ |
| 47 | RCBA_SET_REG_32(D21IR, DIR_ROUTE(PIRQE, PIRQF, PIRQF, PIRQF)),/* SIO */ |
| 48 | RCBA_SET_REG_32(D20IR, DIR_ROUTE(PIRQC, PIRQC, PIRQC, PIRQC)),/* XHCI */ |
| 49 | RCBA_SET_REG_32(D23IR, DIR_ROUTE(PIRQH, PIRQH, PIRQH, PIRQH)),/* SDIO */ |
| 50 | |
| 51 | /* Disable unused devices (board specific) */ |
| 52 | RCBA_RMW_REG_32(FD, ~0, PCH_DISABLE_ALWAYS), |
| 53 | |
| 54 | RCBA_END_CONFIG, |
| 55 | }; |
| 56 | |
| 57 | /* Copy SPD data for on-board memory */ |
| 58 | static void copy_spd(struct pei_data *peid) |
| 59 | { |
| 60 | const int gpio_vector[] = {13, 9, 47, -1}; |
| 61 | int spd_index = get_gpios(gpio_vector); |
| 62 | char *spd_file; |
| 63 | size_t spd_file_len; |
Matt DeVillier | cadd7c7 | 2017-05-29 19:10:57 -0500 | [diff] [blame] | 64 | size_t spd_len = sizeof(peid->spd_data[0]); |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 65 | |
| 66 | printk(BIOS_DEBUG, "SPD index %d\n", spd_index); |
| 67 | spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, |
| 68 | &spd_file_len); |
| 69 | if (!spd_file) |
| 70 | die("SPD data not found."); |
| 71 | |
Matt DeVillier | cadd7c7 | 2017-05-29 19:10:57 -0500 | [diff] [blame] | 72 | if (spd_file_len < ((spd_index + 1) * spd_len)) { |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 73 | printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n"); |
| 74 | spd_index = 0; |
| 75 | } |
| 76 | |
Matt DeVillier | cadd7c7 | 2017-05-29 19:10:57 -0500 | [diff] [blame] | 77 | if (spd_file_len < spd_len) |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 78 | die("Missing SPD data."); |
| 79 | |
Matt DeVillier | cadd7c7 | 2017-05-29 19:10:57 -0500 | [diff] [blame] | 80 | memcpy(peid->spd_data[0], spd_file + (spd_index * spd_len), spd_len); |
| 81 | |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 82 | /* Index 0-2,6 are 4GB config with both CH0 and CH1 |
| 83 | * Index 3-5,7 are 2GB config with CH0 only |
| 84 | */ |
| 85 | switch (spd_index) { |
Matt DeVillier | cadd7c7 | 2017-05-29 19:10:57 -0500 | [diff] [blame] | 86 | case 0: case 1: case 2: case 6: |
| 87 | memcpy(peid->spd_data[1], |
| 88 | spd_file + (spd_index * spd_len), spd_len); |
| 89 | break; |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 90 | case 3: case 4: case 5: case 7: |
| 91 | peid->dimm_channel1_disabled = 3; |
| 92 | } |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 93 | } |
| 94 | |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 95 | void variant_romstage_entry(void) |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 96 | { |
| 97 | struct pei_data pei_data = { |
| 98 | .pei_version = PEI_VERSION, |
| 99 | .mchbar = (uintptr_t)DEFAULT_MCHBAR, |
| 100 | .dmibar = (uintptr_t)DEFAULT_DMIBAR, |
| 101 | .epbar = DEFAULT_EPBAR, |
Kyösti Mälkki | 503d324 | 2019-03-05 07:54:28 +0200 | [diff] [blame] | 102 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 103 | .smbusbar = SMBUS_IO_BASE, |
| 104 | .wdbbar = 0x4000000, |
| 105 | .wdbsize = 0x1000, |
| 106 | .hpet_address = HPET_ADDR, |
| 107 | .rcba = (uintptr_t)DEFAULT_RCBA, |
| 108 | .pmbase = DEFAULT_PMBASE, |
| 109 | .gpiobase = DEFAULT_GPIOBASE, |
| 110 | .temp_mmio_base = 0xfed08000, |
| 111 | .system_type = 5, /* ULT */ |
| 112 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 113 | .spd_addresses = { 0xff, 0x00, 0xff, 0x00 }, |
| 114 | .ec_present = 1, |
| 115 | // 0 = leave channel enabled |
| 116 | // 1 = disable dimm 0 on channel |
| 117 | // 2 = disable dimm 1 on channel |
| 118 | // 3 = disable dimm 0+1 on channel |
| 119 | .dimm_channel0_disabled = 2, |
| 120 | .dimm_channel1_disabled = 2, |
| 121 | // Enable 2x refresh mode |
| 122 | .ddr_refresh_2x = 1, |
| 123 | .max_ddr3_freq = 1600, |
| 124 | .usb_xhci_on_resume = 1, |
| 125 | .usb2_ports = { |
| 126 | /* Length, Enable, OCn#, Location */ |
| 127 | { 0x0064, 1, 0, /* P0: Port A, CN8 */ |
| 128 | USB_PORT_BACK_PANEL }, |
| 129 | { 0x0052, 1, 0, /* P1: Port B, CN9 */ |
| 130 | USB_PORT_BACK_PANEL }, |
| 131 | { 0x0040, 1, USB_OC_PIN_SKIP, /* P2: CCD */ |
| 132 | USB_PORT_INTERNAL }, |
| 133 | { 0x0040, 1, USB_OC_PIN_SKIP, /* P3: BT */ |
| 134 | USB_PORT_INTERNAL }, |
| 135 | { 0x0040, 1, USB_OC_PIN_SKIP, /* P4: LTE */ |
| 136 | USB_PORT_INTERNAL }, |
| 137 | { 0x0040, 1, USB_OC_PIN_SKIP, /* P5: TOUCH */ |
| 138 | USB_PORT_INTERNAL }, |
| 139 | { 0x0040, 1, USB_OC_PIN_SKIP, /* P6: SD Card */ |
| 140 | USB_PORT_INTERNAL }, |
| 141 | { 0x0123, 1, 3, /* P7: USB2 Port */ |
| 142 | USB_PORT_INTERNAL }, |
| 143 | }, |
| 144 | .usb3_ports = { |
| 145 | /* Enable, OCn# */ |
| 146 | { 1, 0 }, /* P1; Port A, CN8 */ |
| 147 | { 1, 0 }, /* P2; Port B, CN9 */ |
| 148 | { 0, USB_OC_PIN_SKIP }, /* P3; */ |
| 149 | { 0, USB_OC_PIN_SKIP }, /* P4; */ |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | struct romstage_params romstage_params = { |
| 154 | .pei_data = &pei_data, |
| 155 | .gpio_map = &mainboard_gpio_map, |
| 156 | .rcba_config = &rcba_config[0], |
Matt DeVillier | c12e5ae | 2016-11-27 02:19:02 -0600 | [diff] [blame] | 157 | .copy_spd = copy_spd, |
| 158 | }; |
| 159 | |
| 160 | /* Call into the real romstage main with this board's attributes. */ |
| 161 | romstage_common(&romstage_params); |
| 162 | } |