Subrata Banik | 16e4106 | 2020-10-06 20:13:06 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | #include <assert.h> |
| 3 | #include <console/console.h> |
| 4 | #include <fsp/api.h> |
| 5 | #include <soc/romstage.h> |
| 6 | #include <spd_bin.h> |
| 7 | #include <string.h> |
| 8 | #include <soc/meminit.h> |
| 9 | #include <baseboard/variants.h> |
| 10 | #include <cbfs.h> |
| 11 | #include "board_id.h" |
| 12 | |
| 13 | #define SPD_ID_MASK 0x7 |
| 14 | |
| 15 | static size_t get_spd_index(void) |
| 16 | { |
| 17 | uint8_t board_id = get_board_id(); |
| 18 | size_t spd_index; |
| 19 | |
| 20 | printk(BIOS_INFO, "board id is 0x%x\n", board_id); |
| 21 | |
| 22 | spd_index = board_id & SPD_ID_MASK; |
| 23 | |
| 24 | printk(BIOS_INFO, "SPD index is 0x%x\n", (unsigned int)spd_index); |
| 25 | return spd_index; |
| 26 | } |
| 27 | |
| 28 | void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 29 | { |
| 30 | const struct mb_cfg *mem_config = variant_memory_params(); |
| 31 | int board_id = get_board_id(); |
| 32 | const bool half_populated = false; |
| 33 | |
Sridhar Siricilla | ae81d59 | 2020-10-28 22:28:07 +0530 | [diff] [blame^] | 34 | const struct spd_info lp4_lp5_spd_info = { |
Subrata Banik | 16e4106 | 2020-10-06 20:13:06 +0530 | [diff] [blame] | 35 | .read_type = READ_SPD_CBFS, |
| 36 | .spd_spec.spd_index = get_spd_index(), |
| 37 | }; |
| 38 | |
Subrata Banik | 7029665 | 2020-10-28 13:50:19 +0530 | [diff] [blame] | 39 | const struct spd_info ddr4_ddr5_spd_info = { |
Subrata Banik | 16e4106 | 2020-10-06 20:13:06 +0530 | [diff] [blame] | 40 | .read_type = READ_SMBUS, |
| 41 | .spd_spec = { |
| 42 | .spd_smbus_address = { |
| 43 | [0] = 0xa0, |
| 44 | [1] = 0xa2, |
| 45 | [8] = 0xa4, |
| 46 | [9] = 0xa6, |
| 47 | }, |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | switch (board_id) { |
| 52 | case ADL_P_DDR4_1: |
| 53 | case ADL_P_DDR4_2: |
Subrata Banik | 7029665 | 2020-10-28 13:50:19 +0530 | [diff] [blame] | 54 | case ADL_P_DDR5: |
| 55 | memcfg_init(&mupd->FspmConfig, mem_config, &ddr4_ddr5_spd_info, half_populated); |
Subrata Banik | 16e4106 | 2020-10-06 20:13:06 +0530 | [diff] [blame] | 56 | break; |
| 57 | case ADL_P_LP4_1: |
| 58 | case ADL_P_LP4_2: |
Sridhar Siricilla | ae81d59 | 2020-10-28 22:28:07 +0530 | [diff] [blame^] | 59 | case ADL_P_LP5: |
| 60 | memcfg_init(&mupd->FspmConfig, mem_config, &lp4_lp5_spd_info, half_populated); |
Subrata Banik | 16e4106 | 2020-10-06 20:13:06 +0530 | [diff] [blame] | 61 | break; |
| 62 | default: |
| 63 | die("Unknown board id = 0x%x\n", board_id); |
| 64 | break; |
| 65 | } |
| 66 | } |