blob: 3070569d73defc3dd2e9a5ae878da980bbec9972 [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -08002#include <assert.h>
3#include <console/console.h>
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -08004#include <fsp/api.h>
5#include <soc/romstage.h>
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -08006#include <spd_bin.h>
Aamir Bohra555c9b62020-03-23 10:13:10 +05307#include <soc/meminit.h>
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -08008#include <baseboard/variants.h>
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -08009#include "board_id.h"
10#include "spd/spd.h"
11
12static uintptr_t mainboard_get_spd_index(void)
13{
14 uint8_t board_id = (get_board_id() & 0xFF);
15 int spd_index;
16
17 printk(BIOS_INFO, "board id is 0x%x\n", board_id);
18
19 switch (board_id) {
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080020 case TGL_UP3_LP4_MICRON:
21 case TGL_UP4_LP4_MICRON:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080022 spd_index = SPD_ID_MICRON;
23 break;
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080024 case TGL_UP3_LP4_SAMSUNG:
25 case TGL_UP4_LP4_SAMSUNG:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080026 spd_index = SPD_ID_SAMSUNG;
27 break;
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080028 case TGL_UP3_LP4_HYNIX:
29 case TGL_UP4_LP4_HYNIX:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080030 spd_index = SPD_ID_HYNIX;
31 break;
32 default:
33 spd_index = SPD_ID_MICRON;
34 printk(BIOS_WARNING, "Invalid board_id 0x%x\n", board_id);
35 }
36
37 printk(BIOS_INFO, "SPD index is 0x%x\n", spd_index);
38 return spd_index;
39}
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -080040
41void mainboard_memory_init_params(FSPM_UPD *mupd)
42{
Furquan Shaikhf06d0462020-12-31 21:15:34 -080043 const struct mb_cfg *mem_config = variant_memory_params();
44 const struct mem_spd spd_info = {
45 .topo = MEM_TOPO_MEMORY_DOWN,
Furquan Shaikh5b1f3352020-03-26 15:36:19 -070046 .cbfs_index = mainboard_get_spd_index(),
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080047 };
48 bool half_populated = false;
49
Subrata Banik2eb51aa2022-03-10 17:53:14 +053050 memcfg_init(mupd, mem_config, &spd_info, half_populated);
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -080051}