blob: 0af394494f140fed154f1de419c51150e721f22b [file] [log] [blame]
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -08001/*
2 * This file is part of the coreboot project.
3 *
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -08004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080014#include <assert.h>
15#include <console/console.h>
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -080016#include <fsp/api.h>
17#include <soc/romstage.h>
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080018#include <spd_bin.h>
19#include <string.h>
Aamir Bohra555c9b62020-03-23 10:13:10 +053020#include <soc/meminit.h>
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080021#include <baseboard/variants.h>
22#include <cbfs.h>
23#include "board_id.h"
24#include "spd/spd.h"
25
26static uintptr_t mainboard_get_spd_index(void)
27{
28 uint8_t board_id = (get_board_id() & 0xFF);
29 int spd_index;
30
31 printk(BIOS_INFO, "board id is 0x%x\n", board_id);
32
33 switch (board_id) {
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080034 case TGL_UP3_LP4_MICRON:
35 case TGL_UP4_LP4_MICRON:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080036 spd_index = SPD_ID_MICRON;
37 break;
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080038 case TGL_UP3_LP4_SAMSUNG:
39 case TGL_UP4_LP4_SAMSUNG:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080040 spd_index = SPD_ID_SAMSUNG;
41 break;
Srinidhi N Kaushik9900cf82020-03-06 16:46:39 -080042 case TGL_UP3_LP4_HYNIX:
43 case TGL_UP4_LP4_HYNIX:
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080044 spd_index = SPD_ID_HYNIX;
45 break;
46 default:
47 spd_index = SPD_ID_MICRON;
48 printk(BIOS_WARNING, "Invalid board_id 0x%x\n", board_id);
49 }
50
51 printk(BIOS_INFO, "SPD index is 0x%x\n", spd_index);
52 return spd_index;
53}
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -080054
55void mainboard_memory_init_params(FSPM_UPD *mupd)
56{
Srinidhi N Kaushikfdba0cd2020-02-19 00:48:55 -080057 FSP_M_CONFIG *mem_cfg = &mupd->FspmConfig;
58
59 const struct mb_lpddr4x_cfg *mem_config = variant_memory_params();
60 const struct spd_info spd_info = {
61 .read_type = READ_SPD_CBFS,
62 .spd_spec.spd_index = mainboard_get_spd_index(),
63 };
64 bool half_populated = false;
65
66 meminit_lpddr4x_dimm0(mem_cfg, mem_config, &spd_info, half_populated);
67
Ravi Sarawadiebb2d3c2019-12-19 23:01:48 -080068}