Debian Codegraph @

src/mainboard/lenovo/s230u/early_init.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <device/pci_ops.h>
4 #include <console/console.h>
5 #include <gpio.h>
6 #include <northbridge/intel/sandybridge/raminit.h>
7 #include <southbridge/intel/bd82x6x/pch.h>
8 #include "ec.h"
9
10 void mainboard_pch_lpc_setup(void)
11 {
12 /* Memory map KB9012 EC registers */
13 pci_write_config32(
14 PCH_LPC_DEV, LGMR,
15 CONFIG_EC_BASE_ADDRESS | 1);
16 pci_write_config16(PCH_LPC_DEV, BIOS_DEC_EN1, 0xffc0);
17
18 /* Enable external USB port power. */
19 if (CONFIG(USBDEBUG))
20 ec_mm_set_bit(0x3b, 4);
21 }
22
23 static 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
35 static unsigned int get_spd_index(void)
36 {
37 const gpio_t spd_gpios[] = {71, 70, 16, 48};
38
39 unsigned int spd_index = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios));
40 if (spd_index >= ARRAY_SIZE(mainboard_spd_names)) {
41 /* Fallback to pessimistic 2GB image (ELPIDA 2GB) */
42 spd_index = 6;
43 }
44
45 return spd_index;
46 }
47
48 void mb_get_spd_map(struct spd_info *spdi)
49 {
50 unsigned int spd_index = get_spd_index();
51
52 printk(BIOS_INFO, "SPD index %d (%s)\n",
53 spd_index, mainboard_spd_names[spd_index]);
54
55 /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */
56 spdi->addresses[0] = SPD_MEMORY_DOWN;
57 spdi->spd_index = spd_index;
58 }