Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Eric Lai | 56868b8 | 2020-12-08 14:08:12 +0800 | [diff] [blame] | 3 | #include <baseboard/gpio.h> |
| 4 | #include <baseboard/variants.h> |
Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 5 | #include <fsp/api.h> |
Eric Lai | 56868b8 | 2020-12-08 14:08:12 +0800 | [diff] [blame] | 6 | #include <gpio.h> |
Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 7 | #include <soc/romstage.h> |
David Wu | 126162c | 2021-07-23 11:36:33 +0800 | [diff] [blame] | 8 | #include <string.h> |
Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 9 | |
Zhuohao Lee | 09f3b6c | 2022-01-20 21:30:12 +0800 | [diff] [blame] | 10 | void mainboard_memory_init_params(FSPM_UPD *memupd) |
Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 11 | { |
Zhuohao Lee | 09f3b6c | 2022-01-20 21:30:12 +0800 | [diff] [blame] | 12 | FSP_M_CONFIG *m_cfg = &memupd->FspmConfig; |
Eric Lai | 56868b8 | 2020-12-08 14:08:12 +0800 | [diff] [blame] | 13 | const struct mb_cfg *mem_config = variant_memory_params(); |
| 14 | bool half_populated = variant_is_half_populated(); |
David Wu | 126162c | 2021-07-23 11:36:33 +0800 | [diff] [blame] | 15 | struct mem_spd spd_info; |
Zhuohao Lee | b8b4096 | 2022-01-20 23:36:37 +0800 | [diff] [blame^] | 16 | bool dimms_changed = false; |
David Wu | 126162c | 2021-07-23 11:36:33 +0800 | [diff] [blame] | 17 | |
| 18 | memset(&spd_info, 0, sizeof(spd_info)); |
| 19 | variant_get_spd_info(&spd_info); |
| 20 | |
Tim Wawrzynczak | f55e82c | 2021-09-09 16:12:51 -0600 | [diff] [blame] | 21 | const struct pad_config *pads; |
| 22 | size_t pads_num; |
Eric Lai | 56868b8 | 2020-12-08 14:08:12 +0800 | [diff] [blame] | 23 | |
Zhuohao Lee | b8b4096 | 2022-01-20 23:36:37 +0800 | [diff] [blame^] | 24 | memcfg_init(m_cfg, mem_config, &spd_info, half_populated, &dimms_changed); |
| 25 | if (dimms_changed) { |
| 26 | memupd->FspmArchUpd.NvsBufferPtr = 0; |
| 27 | memupd->FspmArchUpd.BootMode = FSP_BOOT_WITH_FULL_CONFIGURATION; |
| 28 | } |
Tim Wawrzynczak | f55e82c | 2021-09-09 16:12:51 -0600 | [diff] [blame] | 29 | |
| 30 | pads = variant_romstage_gpio_table(&pads_num); |
| 31 | gpio_configure_pads(pads, pads_num); |
Eric Lai | 5088682 | 2020-11-26 12:10:39 +0800 | [diff] [blame] | 32 | } |