Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -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 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 Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | #include <string.h> |
| 19 | #include <lib.h> |
| 20 | #include <timestamp.h> |
| 21 | #include <arch/io.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 22 | #include <device/pci_def.h> |
| 23 | #include <device/pnp_def.h> |
| 24 | #include <cpu/x86/lapic.h> |
| 25 | #include <pc80/mc146818rtc.h> |
Kyösti Mälkki | 6722f8d | 2014-06-16 09:14:49 +0300 | [diff] [blame] | 26 | #include <arch/acpi.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 27 | #include <cbmem.h> |
| 28 | #include <console/console.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 29 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 30 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | 144eea0 | 2016-02-10 02:36:04 +0100 | [diff] [blame] | 31 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 32 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 33 | #include <southbridge/intel/common/gpio.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 34 | #include <arch/cpu.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 35 | #include <cpu/x86/msr.h> |
Patrick Georgi | bd79c5e | 2014-11-28 22:35:36 +0100 | [diff] [blame] | 36 | #include <halt.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 37 | #include <cbfs.h> |
Vladimir Serbinenko | 0e90dae | 2015-05-18 10:29:06 +0200 | [diff] [blame] | 38 | #include <tpm.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 39 | #include "ec/compal/ene932/ec.h" |
| 40 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 41 | void pch_enable_lpc(void) |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 42 | { |
| 43 | /* Parrot EC Decode Range Port60/64, Port62/66 */ |
| 44 | /* Enable EC, PS/2 Keyboard/Mouse */ |
| 45 | pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN); |
| 46 | |
| 47 | /* Map EC_IO decode to the LPC bus */ |
| 48 | pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (EC_IO & ~3) | 0x00040001); |
| 49 | |
| 50 | /* Map EC registers 68/6C decode to the LPC bus */ |
| 51 | pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, (68 & ~3) | 0x00040001); |
| 52 | } |
| 53 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 54 | void rcba_config(void) |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 55 | { |
| 56 | u32 reg32; |
| 57 | |
Kyösti Mälkki | 6f49906 | 2015-06-06 11:52:24 +0300 | [diff] [blame] | 58 | /* |
| 59 | * GFX INTA -> PIRQA (MSI) |
| 60 | * D28IP_P2IP WLAN INTA -> PIRQB |
| 61 | * D28IP_P3IP ETH0 INTC -> PIRQD |
| 62 | * D29IP_E1P EHCI1 INTA -> PIRQE |
| 63 | * D26IP_E2P EHCI2 INTA -> PIRQE |
| 64 | * D31IP_SIP SATA INTA -> PIRQF (MSI) |
| 65 | * D31IP_SMIP SMBUS INTB -> PIRQG |
| 66 | * D31IP_TTIP THRT INTC -> PIRQH |
| 67 | * D27IP_ZIP HDA INTA -> PIRQG (MSI) |
| 68 | * |
| 69 | * Trackpad DVT PIRQA (16) |
| 70 | * Trackpad DVT PIRQE (20) |
| 71 | */ |
| 72 | |
| 73 | /* Device interrupt pin register (board specific) */ |
| 74 | RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) | |
| 75 | (INTB << D31IP_SMIP) | (INTA << D31IP_SIP); |
| 76 | RCBA32(D30IP) = (NOINT << D30IP_PIP); |
| 77 | RCBA32(D29IP) = (INTA << D29IP_E1P); |
| 78 | RCBA32(D28IP) = (NOINT << D28IP_P1IP) | (INTA << D28IP_P2IP) | |
| 79 | (INTC << D28IP_P3IP) | (NOINT << D28IP_P4IP) | |
| 80 | (NOINT << D28IP_P5IP) | (NOINT << D28IP_P6IP) | |
| 81 | (NOINT << D28IP_P7IP) | (NOINT << D28IP_P8IP); |
| 82 | RCBA32(D27IP) = (INTA << D27IP_ZIP); |
| 83 | RCBA32(D26IP) = (INTA << D26IP_E2P); |
| 84 | RCBA32(D25IP) = (NOINT << D25IP_LIP); |
| 85 | RCBA32(D22IP) = (NOINT << D22IP_MEI1IP); |
| 86 | |
| 87 | /* Device interrupt route registers */ |
| 88 | DIR_ROUTE(D31IR, PIRQB, PIRQH, PIRQA, PIRQC); |
| 89 | DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG); |
| 90 | DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE); |
| 91 | DIR_ROUTE(D27IR, PIRQA, PIRQH, PIRQA, PIRQB); |
| 92 | DIR_ROUTE(D26IR, PIRQF, PIRQE, PIRQG, PIRQH); |
| 93 | DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 94 | DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD); |
| 95 | |
| 96 | /* Enable IOAPIC (generic) */ |
| 97 | RCBA16(OIC) = 0x0100; |
| 98 | /* PCH BWG says to read back the IOAPIC enable register */ |
| 99 | (void) RCBA16(OIC); |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 100 | |
| 101 | /* Disable unused devices (board specific) */ |
| 102 | reg32 = RCBA32(FD); |
| 103 | reg32 |= PCH_DISABLE_ALWAYS; |
| 104 | /* Disable PCI bridge so MRC does not probe this bus */ |
| 105 | reg32 |= PCH_DISABLE_P2P; |
| 106 | RCBA32(FD) = reg32; |
| 107 | } |
| 108 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 109 | void mainboard_early_init(int s3resume) |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 110 | { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 111 | } |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 112 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 113 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
| 114 | { |
| 115 | struct pei_data pei_data_template = { |
Edward O'Callaghan | f5037bd | 2014-05-23 08:36:01 +1000 | [diff] [blame] | 116 | .pei_version = PEI_VERSION, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 117 | .mchbar = (uintptr_t)DEFAULT_MCHBAR, |
| 118 | .dmibar = (uintptr_t)DEFAULT_DMIBAR, |
Edward O'Callaghan | f5037bd | 2014-05-23 08:36:01 +1000 | [diff] [blame] | 119 | .epbar = DEFAULT_EPBAR, |
| 120 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
| 121 | .smbusbar = SMBUS_IO_BASE, |
| 122 | .wdbbar = 0x4000000, |
| 123 | .wdbsize = 0x1000, |
| 124 | .hpet_address = CONFIG_HPET_ADDRESS, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 125 | .rcba = (uintptr_t)DEFAULT_RCBABASE, |
Edward O'Callaghan | f5037bd | 2014-05-23 08:36:01 +1000 | [diff] [blame] | 126 | .pmbase = DEFAULT_PMBASE, |
| 127 | .gpiobase = DEFAULT_GPIOBASE, |
| 128 | .thermalbase = 0xfed08000, |
| 129 | .system_type = 0, // 0 Mobile, 1 Desktop/Server |
| 130 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 131 | .spd_addresses = { 0xA0, 0x00,0xA4,0x00 }, |
| 132 | .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, |
| 133 | .ec_present = 1, |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 134 | // 0 = leave channel enabled |
| 135 | // 1 = disable dimm 0 on channel |
| 136 | // 2 = disable dimm 1 on channel |
| 137 | // 3 = disable dimm 0+1 on channel |
Edward O'Callaghan | f5037bd | 2014-05-23 08:36:01 +1000 | [diff] [blame] | 138 | .dimm_channel0_disabled = 2, |
| 139 | .dimm_channel1_disabled = 2, |
| 140 | .max_ddr3_freq = 1600, |
| 141 | .usb_port_config = { |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 142 | /* Empty and onboard Ports 0-7, set to un-used pin OC3 */ |
| 143 | { 0, 3, 0x0000 }, /* P0: Empty */ |
| 144 | { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */ |
| 145 | { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */ |
| 146 | { 1, 1, 0x0040 }, /* P3: Left USB 3 (OC1) */ |
| 147 | { 0, 3, 0x0000 }, /* P4: Empty */ |
| 148 | { 0, 3, 0x0000 }, /* P5: Empty */ |
| 149 | { 0, 3, 0x0000 }, /* P6: Empty */ |
| 150 | { 0, 3, 0x0000 }, /* P7: Empty */ |
| 151 | /* Empty and onboard Ports 8-13, set to un-used pin OC4 */ |
| 152 | { 1, 4, 0x0040 }, /* P8: MiniPCIe (WLAN) (no OC) */ |
| 153 | { 0, 4, 0x0000 }, /* P9: Empty */ |
| 154 | { 1, 4, 0x0040 }, /* P10: Camera (no OC) */ |
| 155 | { 0, 4, 0x0000 }, /* P11: Empty */ |
| 156 | { 0, 4, 0x0000 }, /* P12: Empty */ |
| 157 | { 0, 4, 0x0000 }, /* P13: Empty */ |
| 158 | }, |
| 159 | }; |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 160 | *pei_data = pei_data_template; |
| 161 | } |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 162 | |
Vladimir Serbinenko | 144eea0 | 2016-02-10 02:36:04 +0100 | [diff] [blame] | 163 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 164 | /* enabled power usb oc pin */ |
| 165 | { 0, 0, -1 }, /* P0: Empty */ |
| 166 | { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */ |
| 167 | { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */ |
| 168 | { 1, 0, 1 }, /* P3: Left USB 3 (OC1) */ |
| 169 | { 0, 0, -1 }, /* P4: Empty */ |
| 170 | { 0, 0, -1 }, /* P5: Empty */ |
| 171 | { 0, 0, -1 }, /* P6: Empty */ |
| 172 | { 0, 0, -1 }, /* P7: Empty */ |
| 173 | /* Empty and onboard Ports 8-13, set to un-used pin OC4 */ |
| 174 | { 1, 0, -1 }, /* P8: MiniPCIe (WLAN) (no OC) */ |
| 175 | { 0, 0, -1 }, /* P9: Empty */ |
| 176 | { 1, 0, -1 }, /* P10: Camera (no OC) */ |
| 177 | { 0, 0, -1 }, /* P11: Empty */ |
| 178 | { 0, 0, -1 }, /* P12: Empty */ |
| 179 | { 0, 0, -1 }, /* P13: Empty */ |
| 180 | }; |
| 181 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame^] | 182 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) { |
| 183 | read_spd(&spd[0], 0x50, id_only); |
| 184 | read_spd(&spd[2], 0x52, id_only); |
Vladimir Serbinenko | 144eea0 | 2016-02-10 02:36:04 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 187 | void mainboard_config_superio(void) |
| 188 | { |
| 189 | } |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 190 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 191 | int mainboard_should_reset_usb(int s3resume) |
| 192 | { |
| 193 | return !s3resume; |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 194 | } |