blob: a0453efd5f022f4fe97e77c1d9cd5d5703c57737 [file] [log] [blame]
Subrata Banik16e41062020-10-06 20:13:06 +05301/* SPDX-License-Identifier: GPL-2.0-only */
Elyes HAOUAS865db962021-01-30 22:44:21 +01002
Subrata Banik16e41062020-10-06 20:13:06 +05303#include <assert.h>
4#include <console/console.h>
5#include <fsp/api.h>
6#include <soc/romstage.h>
7#include <spd_bin.h>
Subrata Banik16e41062020-10-06 20:13:06 +05308#include <soc/meminit.h>
9#include <baseboard/variants.h>
Subrata Banik16e41062020-10-06 20:13:06 +053010#include "board_id.h"
11
12#define SPD_ID_MASK 0x7
13
14static size_t get_spd_index(void)
15{
16 uint8_t board_id = get_board_id();
17 size_t spd_index;
18
19 printk(BIOS_INFO, "board id is 0x%x\n", board_id);
20
21 spd_index = board_id & SPD_ID_MASK;
22
23 printk(BIOS_INFO, "SPD index is 0x%x\n", (unsigned int)spd_index);
24 return spd_index;
25}
26
Subrata Banikde6b4892021-12-08 16:23:39 +053027/*
28 * ADL-P silicon can support 7 SRC CLK's and 10 CLKREQ signals. Out of 7 SRCCLK's
29 * 3 will be used for CPU, the rest are for PCH. If more than 4 PCH devices are
30 * connected on the platform, an external differential buffer chip needs to be placed at
31 * the platform level.
32 *
33 * GEN3_EXTERNAL_CLOCK_BUFFER Kconfig is selected for ADL-P RVP (not applicable for
34 * ADL-M/N RVP)
35 *
36 * CONFIG_CLKSRC_FOR_EXTERNAL_BUFFER provides the CLKSRC that feed clock to discrete
37 * buffer for further distribution to platform.
38 */
39static void configure_external_clksrc(FSP_M_CONFIG *m_cfg)
40{
41 for (unsigned int i = CONFIG_MAX_PCIE_CLOCK_SRC; i < CONFIG_MAX_PCIE_CLOCK_REQ; i++)
42 m_cfg->PcieClkSrcUsage[i] = CONFIG_CLKSRC_FOR_EXTERNAL_BUFFER;
43}
44
Zhuohao Lee09f3b6c2022-01-20 21:30:12 +080045void mainboard_memory_init_params(FSPM_UPD *memupd)
Subrata Banik16e41062020-10-06 20:13:06 +053046{
Zhuohao Lee09f3b6c2022-01-20 21:30:12 +080047 FSP_M_CONFIG *m_cfg = &memupd->FspmConfig;
Subrata Banik16e41062020-10-06 20:13:06 +053048 const struct mb_cfg *mem_config = variant_memory_params();
49 int board_id = get_board_id();
50 const bool half_populated = false;
51
Meera Ravindranatheb32a852021-08-10 20:28:49 +053052 const struct mem_spd memory_down_spd_info = {
Furquan Shaikha1c247b2020-12-31 22:50:14 -080053 .topo = MEM_TOPO_MEMORY_DOWN,
54 .cbfs_index = get_spd_index(),
Subrata Banik16e41062020-10-06 20:13:06 +053055 };
56
Meera Ravindranatheb32a852021-08-10 20:28:49 +053057 const struct mem_spd dimm_module_spd_info = {
Furquan Shaikha1c247b2020-12-31 22:50:14 -080058 .topo = MEM_TOPO_DIMM_MODULE,
59 .smbus = {
60 [0] = {
Subrata Banikd93a5bc2021-02-15 21:48:51 +053061 .addr_dimm[0] = 0x50,
62 .addr_dimm[1] = 0x51,
Furquan Shaikha1c247b2020-12-31 22:50:14 -080063 },
64 [1] = {
Subrata Banikd93a5bc2021-02-15 21:48:51 +053065 .addr_dimm[0] = 0x52,
66 .addr_dimm[1] = 0x53,
Subrata Banik16e41062020-10-06 20:13:06 +053067 },
68 },
69 };
70
71 switch (board_id) {
72 case ADL_P_DDR4_1:
73 case ADL_P_DDR4_2:
Deepti Deshatty193203f2021-04-29 21:32:58 +053074 case ADL_P_DDR5_1:
Meera Ravindranatheb32a852021-08-10 20:28:49 +053075 memcfg_init(m_cfg, mem_config, &dimm_module_spd_info, half_populated);
Subrata Banik16e41062020-10-06 20:13:06 +053076 break;
Meera Ravindranathbcc74af2021-08-09 16:06:21 +053077 case ADL_P_DDR5_2:
Subrata Banik16e41062020-10-06 20:13:06 +053078 case ADL_P_LP4_1:
79 case ADL_P_LP4_2:
Subrata Banik40f53f42021-02-20 13:52:52 +053080 case ADL_P_LP5_1:
81 case ADL_P_LP5_2:
Maulik V Vaghelafb670fe2021-02-03 15:10:50 +053082 case ADL_M_LP4:
Maulik V Vaghela2d22f822021-02-03 15:20:04 +053083 case ADL_M_LP5:
Krishna Prasad Bhat351d3a12021-12-17 16:08:04 +053084 case ADL_N_LP5:
Meera Ravindranatheb32a852021-08-10 20:28:49 +053085 memcfg_init(m_cfg, mem_config, &memory_down_spd_info, half_populated);
Subrata Banik16e41062020-10-06 20:13:06 +053086 break;
87 default:
88 die("Unknown board id = 0x%x\n", board_id);
89 break;
90 }
Subrata Banikde6b4892021-12-08 16:23:39 +053091
92 if (CONFIG(GEN3_EXTERNAL_CLOCK_BUFFER))
93 configure_external_clksrc(m_cfg);
Subrata Banik16e41062020-10-06 20:13:06 +053094}