Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 4 | * Copyright (C) 2019-2020 Intel Corporation. |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 15 | #include <assert.h> |
| 16 | #include <console/console.h> |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 17 | #include <fsp/api.h> |
| 18 | #include <soc/romstage.h> |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 19 | #include <spd_bin.h> |
| 20 | #include <string.h> |
| 21 | #include <soc/meminit_tgl.h> |
| 22 | #include <baseboard/variants.h> |
| 23 | #include <cbfs.h> |
| 24 | #include "board_id.h" |
| 25 | #include "spd/spd.h" |
| 26 | |
| 27 | static uintptr_t mainboard_get_spd_index(void) |
| 28 | { |
| 29 | uint8_t board_id = (get_board_id() & 0xFF); |
| 30 | int spd_index; |
| 31 | |
| 32 | printk(BIOS_INFO, "board id is 0x%x\n", board_id); |
| 33 | |
| 34 | switch (board_id) { |
| 35 | case TGL_U_LP4_MICRON: |
| 36 | spd_index = SPD_ID_MICRON; |
| 37 | break; |
| 38 | case TGL_U_LP4_SAMSUNG: |
| 39 | spd_index = SPD_ID_SAMSUNG; |
| 40 | break; |
| 41 | case TGL_U_LP4_HYNIX: |
| 42 | spd_index = SPD_ID_HYNIX; |
| 43 | break; |
| 44 | default: |
| 45 | spd_index = SPD_ID_MICRON; |
| 46 | printk(BIOS_WARNING, "Invalid board_id 0x%x\n", board_id); |
| 47 | } |
| 48 | |
| 49 | printk(BIOS_INFO, "SPD index is 0x%x\n", spd_index); |
| 50 | return spd_index; |
| 51 | } |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 52 | |
| 53 | void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 54 | { |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 55 | FSP_M_CONFIG *mem_cfg = &mupd->FspmConfig; |
| 56 | |
| 57 | const struct mb_lpddr4x_cfg *mem_config = variant_memory_params(); |
| 58 | const struct spd_info spd_info = { |
| 59 | .read_type = READ_SPD_CBFS, |
| 60 | .spd_spec.spd_index = mainboard_get_spd_index(), |
| 61 | }; |
| 62 | bool half_populated = false; |
| 63 | |
| 64 | meminit_lpddr4x_dimm0(mem_cfg, mem_config, &spd_info, half_populated); |
| 65 | |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 66 | } |