Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2010 coresystems GmbH |
| 5 | * Copyright (C) 2011 Google Inc. |
| 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 Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | #include <string.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 19 | #include <timestamp.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 20 | #include <arch/io.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 21 | #include <device/pci.h> |
| 22 | #include <device/pci_def.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 23 | #include <cpu/x86/lapic.h> |
Kyösti Mälkki | 6722f8d | 2014-06-16 09:14:49 +0300 | [diff] [blame] | 24 | #include <arch/acpi.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 25 | #include <console/console.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 26 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 27 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 28 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 29 | #include <southbridge/intel/common/gpio.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 30 | #include "ec/google/chromeec/ec.h" |
Patrick Georgi | bd79c5e | 2014-11-28 22:35:36 +0100 | [diff] [blame] | 31 | #include <halt.h> |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 32 | #include <cbfs.h> |
| 33 | |
| 34 | #include <southbridge/intel/bd82x6x/chip.h> |
| 35 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 36 | void pch_enable_lpc(void) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 37 | { |
| 38 | const struct device *lpc; |
| 39 | const struct southbridge_intel_bd82x6x_config *config = NULL; |
| 40 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 41 | lpc = pcidev_on_root(0x1f, 0); |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 42 | if (!lpc) |
| 43 | return; |
| 44 | if (lpc->chip_info) |
| 45 | config = lpc->chip_info; |
| 46 | if (!config) |
| 47 | return; |
| 48 | |
| 49 | /* Set COM1/COM2 decode range */ |
| 50 | pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); |
| 51 | |
| 52 | /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */ |
| 53 | pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | \ |
| 54 | GAMEL_LPC_EN | COMA_LPC_EN); |
| 55 | |
| 56 | pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec); |
| 57 | pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec); |
| 58 | pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec); |
| 59 | pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec); |
| 60 | } |
| 61 | |
Nico Huber | ff4025c | 2018-01-14 12:34:43 +0100 | [diff] [blame] | 62 | void mainboard_rcba_config(void) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 63 | { |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 64 | /* |
| 65 | * GFX INTA -> PIRQA (MSI) |
| 66 | * D28IP_P3IP WLAN INTA -> PIRQB |
| 67 | * D29IP_E1P EHCI1 INTA -> PIRQD |
| 68 | * D26IP_E2P EHCI2 INTA -> PIRQF |
| 69 | * D31IP_SIP SATA INTA -> PIRQF (MSI) |
| 70 | * D31IP_SMIP SMBUS INTB -> PIRQH |
| 71 | * D31IP_TTIP THRT INTC -> PIRQA |
| 72 | * D27IP_ZIP HDA INTA -> PIRQA (MSI) |
| 73 | * |
| 74 | * TRACKPAD -> PIRQE (Edge Triggered) |
| 75 | * TOUCHSCREEN -> PIRQG (Edge Triggered) |
| 76 | */ |
| 77 | |
| 78 | /* Device interrupt pin register (board specific) */ |
| 79 | RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 80 | (INTB << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 81 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 82 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 83 | RCBA32(D28IP) = (INTA << D28IP_P3IP); |
| 84 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 85 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 86 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 87 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 88 | |
| 89 | /* Device interrupt route registers */ |
| 90 | DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC); |
| 91 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG); |
| 92 | DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE); |
| 93 | DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB); |
| 94 | DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH); |
| 95 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 96 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 97 | |
| 98 | /* Enable IOAPIC (generic) */ |
Arthur Heymans | 58a8953 | 2018-06-12 22:58:19 +0200 | [diff] [blame] | 99 | RCBA16(OIC) = 0x0100; |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 100 | /* PCH BWG says to read back the IOAPIC enable register */ |
Arthur Heymans | 58a8953 | 2018-06-12 22:58:19 +0200 | [diff] [blame] | 101 | (void) RCBA16(OIC); |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 102 | } |
| 103 | |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 104 | static uint8_t *locate_spd(void) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 105 | { |
| 106 | const int gpio_vector[] = {41, 42, 43, 10, -1}; |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 107 | uint8_t *spd_file; |
Vladimir Serbinenko | 1287416 | 2014-01-12 14:12:15 +0100 | [diff] [blame] | 108 | size_t spd_file_len; |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 109 | int spd_index = get_gpios(gpio_vector); |
| 110 | |
| 111 | printk(BIOS_DEBUG, "spd index %d\n", spd_index); |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 112 | spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, |
| 113 | &spd_file_len); |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 114 | if (!spd_file) |
| 115 | die("SPD data not found."); |
| 116 | |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 117 | if (spd_file_len < ((spd_index + 1) * 256)) { |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 118 | printk(BIOS_ERR, "spd index override to 0 - old hardware?\n"); |
| 119 | spd_index = 0; |
| 120 | } |
| 121 | |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 122 | if (spd_file_len < 256) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 123 | die("Missing SPD data."); |
| 124 | |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 125 | return spd_file + spd_index * 256; |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 128 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 129 | { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 130 | struct pei_data pei_data_template = { |
Edward O'Callaghan | 6cec824 | 2014-05-24 04:16:57 +1000 | [diff] [blame] | 131 | .pei_version = PEI_VERSION, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 132 | .mchbar = (uintptr_t)DEFAULT_MCHBAR, |
| 133 | .dmibar = (uintptr_t)DEFAULT_DMIBAR, |
Edward O'Callaghan | 6cec824 | 2014-05-24 04:16:57 +1000 | [diff] [blame] | 134 | .epbar = DEFAULT_EPBAR, |
| 135 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
| 136 | .smbusbar = SMBUS_IO_BASE, |
| 137 | .wdbbar = 0x4000000, |
| 138 | .wdbsize = 0x1000, |
| 139 | .hpet_address = CONFIG_HPET_ADDRESS, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 140 | .rcba = (uintptr_t)DEFAULT_RCBABASE, |
Edward O'Callaghan | 6cec824 | 2014-05-24 04:16:57 +1000 | [diff] [blame] | 141 | .pmbase = DEFAULT_PMBASE, |
| 142 | .gpiobase = DEFAULT_GPIOBASE, |
| 143 | .thermalbase = 0xfed08000, |
| 144 | .system_type = 0, // 0 Mobile, 1 Desktop/Server |
| 145 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 146 | .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, |
| 147 | .ec_present = 1, |
| 148 | .ddr3lv_support = 1, |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 149 | // 0 = leave channel enabled |
| 150 | // 1 = disable dimm 0 on channel |
| 151 | // 2 = disable dimm 1 on channel |
| 152 | // 3 = disable dimm 0+1 on channel |
Edward O'Callaghan | 6cec824 | 2014-05-24 04:16:57 +1000 | [diff] [blame] | 153 | .dimm_channel0_disabled = 2, |
| 154 | .dimm_channel1_disabled = 2, |
| 155 | .max_ddr3_freq = 1600, |
| 156 | .usb_port_config = { |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 157 | /* Empty and onboard Ports 0-7, set to un-used pin OC3 */ |
| 158 | { 0, 3, 0x0000 }, /* P0: Empty */ |
| 159 | { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */ |
| 160 | { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */ |
| 161 | { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */ |
| 162 | { 0, 3, 0x0000 }, /* P4: Empty */ |
| 163 | { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */ |
| 164 | { 0, 3, 0x0000 }, /* P6: Empty */ |
| 165 | { 0, 3, 0x0000 }, /* P7: Empty */ |
| 166 | /* Empty and onboard Ports 8-13, set to un-used pin OC4 */ |
| 167 | { 1, 4, 0x0040 }, /* P8: Camera (no OC) */ |
| 168 | { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */ |
| 169 | { 0, 4, 0x0000 }, /* P10: Empty */ |
| 170 | { 0, 4, 0x0000 }, /* P11: Empty */ |
| 171 | { 0, 4, 0x0000 }, /* P12: Empty */ |
| 172 | { 0, 4, 0x0000 }, /* P13: Empty */ |
| 173 | }, |
| 174 | }; |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 175 | *pei_data = pei_data_template; |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 176 | memcpy(pei_data->spd_data[0], locate_spd(), |
| 177 | sizeof(pei_data->spd_data[0])); |
| 178 | } |
| 179 | |
| 180 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 181 | /* enabled power usb oc pin */ |
| 182 | { 0, 0, -1 }, /* P0: Empty */ |
| 183 | { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */ |
| 184 | { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */ |
| 185 | { 1, 0, -1 }, /* P3: SDCARD (no OC) */ |
| 186 | { 0, 0, -1 }, /* P4: Empty */ |
| 187 | { 1, 0, -1 }, /* P5: WWAN (no OC) */ |
| 188 | { 0, 0, -1 }, /* P6: Empty */ |
| 189 | { 0, 0, -1 }, /* P7: Empty */ |
| 190 | { 1, 0, -1 }, /* P8: Camera (no OC) */ |
| 191 | { 1, 0, -1 }, /* P9: Bluetooth (no OC) */ |
| 192 | { 0, 0, -1 }, /* P10: Empty */ |
| 193 | { 0, 0, -1 }, /* P11: Empty */ |
| 194 | { 0, 0, -1 }, /* P12: Empty */ |
| 195 | { 0, 0, -1 }, /* P13: Empty */ |
| 196 | }; |
| 197 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 198 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) { |
Vladimir Serbinenko | b2ad810 | 2016-02-10 03:07:42 +0100 | [diff] [blame] | 199 | memcpy(&spd[0], locate_spd(), 128); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 200 | } |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 201 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 202 | void mainboard_early_init(int s3resume) |
| 203 | { |
| 204 | if (!s3resume) { |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 205 | /* This is the fastest way to let users know |
| 206 | * the Intel CPU is now alive. |
| 207 | */ |
| 208 | google_chromeec_kbbacklight(100); |
| 209 | } |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 210 | } |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 211 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 212 | int mainboard_should_reset_usb(int s3resume) |
| 213 | { |
| 214 | return !s3resume; |
| 215 | } |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 216 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 217 | void mainboard_config_superio(void) |
| 218 | { |
Stefan Reinauer | 49428d8 | 2013-02-21 15:48:37 -0800 | [diff] [blame] | 219 | } |