Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 4 | * |
| 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 Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 14 | #include <assert.h> |
| 15 | #include <console/console.h> |
Ravi Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 16 | #include <fsp/api.h> |
| 17 | #include <soc/romstage.h> |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 18 | #include <spd_bin.h> |
| 19 | #include <string.h> |
| 20 | #include <soc/meminit_tgl.h> |
| 21 | #include <baseboard/variants.h> |
| 22 | #include <cbfs.h> |
| 23 | #include "board_id.h" |
| 24 | #include "spd/spd.h" |
| 25 | |
| 26 | static 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 Kaushik | 9900cf8 | 2020-03-06 16:46:39 -0800 | [diff] [blame] | 34 | case TGL_UP3_LP4_MICRON: |
| 35 | case TGL_UP4_LP4_MICRON: |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 36 | spd_index = SPD_ID_MICRON; |
| 37 | break; |
Srinidhi N Kaushik | 9900cf8 | 2020-03-06 16:46:39 -0800 | [diff] [blame] | 38 | case TGL_UP3_LP4_SAMSUNG: |
| 39 | case TGL_UP4_LP4_SAMSUNG: |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 40 | spd_index = SPD_ID_SAMSUNG; |
| 41 | break; |
Srinidhi N Kaushik | 9900cf8 | 2020-03-06 16:46:39 -0800 | [diff] [blame] | 42 | case TGL_UP3_LP4_HYNIX: |
| 43 | case TGL_UP4_LP4_HYNIX: |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 44 | 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 Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 54 | |
| 55 | void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 56 | { |
Srinidhi N Kaushik | fdba0cd | 2020-02-19 00:48:55 -0800 | [diff] [blame] | 57 | 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 Sarawadi | ebb2d3c | 2019-12-19 23:01:48 -0800 | [diff] [blame] | 68 | } |