blob: f4396cb617e2b2fc4bb8242526f4c07c85add2d6 [file] [log] [blame]
Angel Pons89ab2502020-04-03 01:22:28 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Tobias Diedrichcee930a2017-02-12 14:09:06 +01002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Tobias Diedrichcee930a2017-02-12 14:09:06 +01004#include <console/console.h>
Keith Hui45e4ab42023-07-22 12:49:05 -04005#include <northbridge/intel/sandybridge/raminit.h>
Elyes HAOUAS4ad14462018-06-16 18:29:33 +02006#include <southbridge/intel/bd82x6x/pch.h>
Tobias Diedrichcee930a2017-02-12 14:09:06 +01007#include <southbridge/intel/common/gpio.h>
Tobias Diedrichcee930a2017-02-12 14:09:06 +01008#include "ec.h"
9
Arthur Heymans2b28a162019-11-12 17:21:08 +010010void mainboard_pch_lpc_setup(void)
Tobias Diedrichcee930a2017-02-12 14:09:06 +010011{
Tobias Diedrichcee930a2017-02-12 14:09:06 +010012 /* Memory map KB9012 EC registers */
13 pci_write_config32(
Peter Lemenkov9b7ae2f2018-10-09 13:09:07 +020014 PCH_LPC_DEV, LGMR,
Tobias Diedrichcee930a2017-02-12 14:09:06 +010015 CONFIG_EC_BASE_ADDRESS | 1);
Peter Lemenkov9b7ae2f2018-10-09 13:09:07 +020016 pci_write_config16(PCH_LPC_DEV, BIOS_DEC_EN1, 0xffc0);
Tobias Diedrichcee930a2017-02-12 14:09:06 +010017
Tobias Diedrichcee930a2017-02-12 14:09:06 +010018 /* Enable external USB port power. */
Julius Wernercd49cce2019-03-05 16:53:33 -080019 if (CONFIG(USBDEBUG))
Martin Roth5ef5c002017-03-24 11:08:32 -060020 ec_mm_set_bit(0x3b, 4);
Tobias Diedrichcee930a2017-02-12 14:09:06 +010021}
22
Tobias Diedrichcee930a2017-02-12 14:09:06 +010023static const char *mainboard_spd_names[9] = {
24 "ELPIDA 4GB",
25 "SAMSUNG 4GB",
26 "HYNIX 4GB",
27 "ELPIDA 8GB",
28 "SAMSUNG 8GB",
29 "HYNIX 8GB",
30 "ELPIDA 2GB",
31 "SAMSUNG 2GB",
32 "HYNIX 2GB",
33};
34
Keith Hui45e4ab42023-07-22 12:49:05 -040035static unsigned int get_spd_index(void)
Tobias Diedrichcee930a2017-02-12 14:09:06 +010036{
Tobias Diedrichcee930a2017-02-12 14:09:06 +010037 const int spd_gpios[] = {71, 70, 16, 48, -1};
38
Keith Hui45e4ab42023-07-22 12:49:05 -040039 unsigned int spd_index = get_gpios(spd_gpios);
Tobias Diedrichcee930a2017-02-12 14:09:06 +010040 if (spd_index >= ARRAY_SIZE(mainboard_spd_names)) {
41 /* Fallback to pessimistic 2GB image (ELPIDA 2GB) */
42 spd_index = 6;
43 }
44
Keith Hui45e4ab42023-07-22 12:49:05 -040045 return spd_index;
46}
47
48void mb_get_spd_map(struct spd_info *spdi)
49{
50 unsigned int spd_index = get_spd_index();
51
Tobias Diedrichcee930a2017-02-12 14:09:06 +010052 printk(BIOS_INFO, "SPD index %d (%s)\n",
53 spd_index, mainboard_spd_names[spd_index]);
54
Peter Lemenkov6b7d40a2020-01-22 11:40:16 +010055 /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */
Keith Hui45e4ab42023-07-22 12:49:05 -040056 spdi->addresses[0] = SPD_MEMORY_DOWN;
57 spdi->spd_index = spd_index;
Tobias Diedrichcee930a2017-02-12 14:09:06 +010058}