Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [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. |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdint.h> |
Kyösti Mälkki | 3855c01 | 2019-03-03 08:45:19 +0200 | [diff] [blame] | 18 | #include <device/pnp_ops.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 19 | #include <device/pci_ops.h> |
Elyes HAOUAS | 8c905a8 | 2019-02-07 09:00:47 +0100 | [diff] [blame] | 20 | #include <cpu/x86/lapic.h> |
| 21 | #include <cpu/x86/msr.h> |
| 22 | #include <device/pci_def.h> |
Vladimir Serbinenko | a50478f | 2016-02-10 03:03:41 +0100 | [diff] [blame] | 23 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Elyes HAOUAS | 8c905a8 | 2019-02-07 09:00:47 +0100 | [diff] [blame] | 24 | #include <northbridge/intel/sandybridge/raminit.h> |
| 25 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 26 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 27 | #include <southbridge/intel/common/gpio.h> |
Elyes HAOUAS | e051dc0 | 2018-08-06 10:55:59 +0200 | [diff] [blame] | 28 | #include <superio/winbond/common/winbond.h> |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 29 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 30 | void pch_enable_lpc(void) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 31 | { |
| 32 | /* Set COM3/COM1 decode ranges: 0x3e8/0x3f8 */ |
| 33 | pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0070); |
| 34 | |
| 35 | /* Enable KBC on 0x06/0x64 (KBC), |
| 36 | * EC on 0x62/0x66 (MC), |
| 37 | * EC on 0x20c-0x20f (GAMEH), |
| 38 | * Super I/O on 0x2e/0x2f (CNF1), |
| 39 | * COM1/COM3 decode ranges. */ |
| 40 | pci_write_config16(PCH_LPC_DEV, LPC_EN, |
| 41 | KBC_LPC_EN | MC_LPC_EN | |
| 42 | CNF1_LPC_EN | GAMEH_LPC_EN | |
| 43 | COMA_LPC_EN | COMB_LPC_EN); |
| 44 | } |
| 45 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame^] | 46 | void mainboard_late_rcba_config(void) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 47 | { |
| 48 | u32 reg32; |
| 49 | |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 50 | /* Disable unused devices (board specific) */ |
| 51 | reg32 = RCBA32(FD); |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 52 | /* Disable PCI bridge so MRC does not probe this bus */ |
| 53 | reg32 |= PCH_DISABLE_P2P; |
| 54 | RCBA32(FD) = reg32; |
| 55 | } |
| 56 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 57 | void mainboard_config_superio(void) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 58 | { |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 59 | int lvds_3v = 0; /* 0 (5V) or 1 (3V3) */ |
| 60 | int dis_bl_inv = 1; /* backlight inversion: 1 = disabled, 0 = enabled */ |
Antonello Dettori | 82fcc1a | 2016-11-08 18:44:46 +0100 | [diff] [blame] | 61 | pnp_devfn_t dev = PNP_DEV(0x2e, 0x9); |
Elyes HAOUAS | e051dc0 | 2018-08-06 10:55:59 +0200 | [diff] [blame] | 62 | pnp_enter_conf_state(dev); |
Nico Huber | 40f9ce9 | 2013-10-22 11:07:23 +0200 | [diff] [blame] | 63 | pnp_write_config(dev, 0x29, 0x02); /* Pins 119, 120 are GPIO21, 20 */ |
| 64 | pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO2+3 */ |
| 65 | pnp_write_config(dev, 0x2a, 0x01); /* Pins 62, 63, 65, 66 are |
| 66 | GPIO27, 26, 25, 24 */ |
| 67 | pnp_write_config(dev, 0x2c, 0xc3); /* Pin 90 is GPIO32, |
| 68 | Pins 78~85 are UART B */ |
| 69 | pnp_write_config(dev, 0x2d, 0x00); /* Pins 67, 68, 70~73, 75, 77 are |
| 70 | GPIO57~50 */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 71 | pnp_set_logical_device(dev); |
| 72 | /* Values can only be changed, when devices are enabled. */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 73 | pnp_write_config(dev, 0xe3, 0xdd); /* GPIO2 bits 1, 5 are output */ |
Nico Huber | 40f9ce9 | 2013-10-22 11:07:23 +0200 | [diff] [blame] | 74 | pnp_write_config(dev, 0xe4, (dis_bl_inv << 5) | (lvds_3v << 1)); /* GPIO2 bits 1, 5 */ |
Nico Huber | a90c785 | 2015-04-15 13:46:08 +0200 | [diff] [blame] | 75 | pnp_write_config(dev, 0xf3, 0x40); /* Disable suspend LED during normal operation */ |
Elyes HAOUAS | e051dc0 | 2018-08-06 10:55:59 +0200 | [diff] [blame] | 76 | pnp_exit_conf_state(dev); |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 77 | } |
| 78 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 79 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 80 | { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 81 | struct pei_data pei_data_template = { |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 82 | .pei_version = PEI_VERSION, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 83 | .mchbar = (uintptr_t)DEFAULT_MCHBAR, |
| 84 | .dmibar = (uintptr_t)DEFAULT_DMIBAR, |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 85 | .epbar = DEFAULT_EPBAR, |
| 86 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
| 87 | .smbusbar = SMBUS_IO_BASE, |
| 88 | .wdbbar = 0x4000000, |
| 89 | .wdbsize = 0x1000, |
| 90 | .hpet_address = CONFIG_HPET_ADDRESS, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 91 | .rcba = (uintptr_t)DEFAULT_RCBABASE, |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 92 | .pmbase = DEFAULT_PMBASE, |
| 93 | .gpiobase = DEFAULT_GPIOBASE, |
| 94 | .thermalbase = 0xfed08000, |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 95 | .system_type = 0, /* 0 Mobile, 1 Desktop/Server */ |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 96 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 97 | .spd_addresses = { 0xA0, 0x00,0xA4,0x00 }, |
| 98 | .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, |
| 99 | .ec_present = 1, |
| 100 | .gbe_enable = 1, |
| 101 | .ddr3lv_support = 0, |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 102 | /* |
| 103 | * 0 = leave channel enabled |
| 104 | * 1 = disable dimm 0 on channel |
| 105 | * 2 = disable dimm 1 on channel |
| 106 | * 3 = disable dimm 0+1 on channel |
| 107 | */ |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 108 | .dimm_channel0_disabled = 2, |
| 109 | .dimm_channel1_disabled = 2, |
| 110 | .max_ddr3_freq = 1600, |
| 111 | .usb_port_config = { |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 112 | /* enabled usb oc pin length */ |
| 113 | { 1, 0, 0x0040 }, /* P0: lower left USB 3.0 (OC0) */ |
| 114 | { 1, 0, 0x0040 }, /* P1: upper left USB 3.0 (OC0) */ |
| 115 | { 1, 0, 0x0040 }, /* P2: lower right USB 3.0 (OC0) */ |
| 116 | { 1, 0, 0x0040 }, /* P3: upper right USB 3.0 (OC0) */ |
| 117 | { 1, 0, 0x0040 }, /* P4: lower USB 2.0 (OC0) */ |
| 118 | { 1, 0, 0x0040 }, /* P5: upper USB 2.0 (OC0) */ |
| 119 | { 1, 0, 0x0040 }, /* P6: front panel USB 2.0 (OC0) */ |
| 120 | { 1, 0, 0x0040 }, /* P7: front panel USB 2.0 (OC0) */ |
| 121 | { 1, 4, 0x0040 }, /* P8: internal USB 2.0 (OC4) */ |
| 122 | { 1, 4, 0x0040 }, /* P9: internal USB 2.0 (OC4) */ |
| 123 | { 1, 4, 0x0040 }, /* P10: internal USB 2.0 (OC4) */ |
| 124 | { 1, 4, 0x0040 }, /* P11: internal USB 2.0 (OC4) */ |
| 125 | { 1, 4, 0x0040 }, /* P12: internal USB 2.0 (OC4) */ |
| 126 | { 1, 4, 0x0040 }, /* P13: internal USB 2.0 (OC4) */ |
| 127 | }, |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 128 | .usb3 = { |
| 129 | .mode = 3, /* Smart Auto? */ |
| 130 | .hs_port_switch_mask = 0xf, /* All four ports. */ |
| 131 | .preboot_support = 1, /* preOS driver? */ |
| 132 | .xhci_streams = 1, /* Enable. */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 133 | }, |
Edward O'Callaghan | 6f49f69 | 2014-05-24 02:04:52 +1000 | [diff] [blame] | 134 | .pcie_init = 1, |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 135 | }; |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 136 | *pei_data = pei_data_template; |
| 137 | } |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 138 | |
Vladimir Serbinenko | a50478f | 2016-02-10 03:03:41 +0100 | [diff] [blame] | 139 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 140 | /* enabled power usb oc pin */ |
| 141 | { 1, 0, 0 }, /* P0: lower left USB 3.0 (OC0) */ |
| 142 | { 1, 0, 0 }, /* P1: upper left USB 3.0 (OC0) */ |
| 143 | { 1, 0, 0 }, /* P2: lower right USB 3.0 (OC0) */ |
| 144 | { 1, 0, 0 }, /* P3: upper right USB 3.0 (OC0) */ |
| 145 | { 1, 0, 0 }, /* P4: lower USB 2.0 (OC0) */ |
| 146 | { 1, 0, 0 }, /* P5: upper USB 2.0 (OC0) */ |
| 147 | { 1, 0, 0 }, /* P6: front panel USB 2.0 (OC0) */ |
| 148 | { 1, 0, 0 }, /* P7: front panel USB 2.0 (OC0) */ |
| 149 | { 1, 0, 4 }, /* P8: internal USB 2.0 (OC4) */ |
| 150 | { 1, 0, 4 }, /* P9: internal USB 2.0 (OC4) */ |
| 151 | { 1, 0, 4 }, /* P10: internal USB 2.0 (OC4) */ |
| 152 | { 1, 0, 4 }, /* P11: internal USB 2.0 (OC4) */ |
| 153 | { 1, 0, 4 }, /* P12: internal USB 2.0 (OC4) */ |
| 154 | { 1, 0, 4 }, /* P13: internal USB 2.0 (OC4) */ |
| 155 | }; |
| 156 | |
Peter Lemenkov | 498f1cc | 2019-02-07 10:48:10 +0100 | [diff] [blame] | 157 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
| 158 | { |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 159 | read_spd(&spd[0], 0x50, id_only); |
| 160 | read_spd(&spd[2], 0x52, id_only); |
Vladimir Serbinenko | a50478f | 2016-02-10 03:03:41 +0100 | [diff] [blame] | 161 | } |
| 162 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 163 | void mainboard_early_init(int s3resume) |
| 164 | { |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 165 | /* Enable PEG10 (1x16) */ |
| 166 | pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, |
| 167 | pci_read_config32(PCI_DEV(0, 0, 0), DEVEN) | |
| 168 | DEVEN_PEG10); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 169 | } |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 170 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 171 | int mainboard_should_reset_usb(int s3resume) |
| 172 | { |
| 173 | return !s3resume; |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 174 | } |