Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 2 | |
| 3 | #include "harcuvar_boardid.h" |
| 4 | #include "gpio.h" |
| 5 | #include "spd/spd.h" |
| 6 | #include <console/console.h> |
| 7 | #include <fsp/api.h> |
| 8 | #include <fsp/soc_binding.h> |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 9 | |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 10 | /* |
| 11 | * Define platform specific Memory Down Configure structure. |
| 12 | * |
Martin Roth | f48acbd | 2020-07-24 12:24:27 -0600 | [diff] [blame] | 13 | * If CONFIG(ENABLE_FSP_MEMORY_DOWN) is enabled, the MEMORY_DOWN_CONFIG |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 14 | * structure should be customized to match the design. |
| 15 | * |
| 16 | * .SlotState indicates the memory down state of the specific channel/DIMM. |
| 17 | * |
| 18 | * SlotState options: |
| 19 | * |
| 20 | * STATE_MEMORY_DOWN: Memory down. |
| 21 | * STATE_MEMORY_SLOT: Physical memory slot. |
| 22 | * |
| 23 | * .SpdDataLen should always be MAX_SPD_BYTES/512. |
| 24 | * |
| 25 | * .SpdDataPtr is pointing to the SPD data structure when memory modules |
| 26 | * are memory down. |
| 27 | * |
| 28 | * SpdDataPtr options: |
| 29 | * |
| 30 | * Non-NULL: Pointing to SPD data structure. |
| 31 | * NULL: Physical memory slot, no SPD data used. |
| 32 | * |
| 33 | * DIMM Mapping of SlotState & SpdDataPtr: |
| 34 | * |
| 35 | * {{CH0DIMM0, CH0DIMM1}, {CH1DIMM0, CH1DIMM1}} |
| 36 | * |
| 37 | * Sample: Channel 0 is memory down and channel 1 is physical slot. |
| 38 | * |
| 39 | * const MEMORY_DOWN_CONFIG mMemoryDownConfig = { |
| 40 | * .SlotState = { |
| 41 | * {STATE_MEMORY_DOWN, STATE_MEMORY_DOWN}, |
| 42 | * {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT} |
| 43 | * }, |
| 44 | * .SpdDataLen = MAX_SPD_BYTES, |
| 45 | * .SpdDataPtr = { |
| 46 | * {(void *)CONFIG_SPD_LOC, (void *)CONFIG_SPD_LOC}, |
| 47 | * {(void *)NULL, (void *)NULL} |
| 48 | * } |
| 49 | * } |
| 50 | */ |
| 51 | |
| 52 | const MEMORY_DOWN_CONFIG mMemoryDownConfig = { |
| 53 | .SlotState = { |
| 54 | {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT}, |
| 55 | {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT} |
| 56 | }, |
| 57 | .SpdDataLen = MAX_SPD_BYTES, |
| 58 | .SpdDataPtr = { |
| 59 | {(void *)NULL, (void *)NULL}, |
| 60 | {(void *)NULL, (void *)NULL} |
| 61 | } |
| 62 | }; |
| 63 | |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 64 | void mainboard_config_gpios(void); |
| 65 | void mainboard_memory_init_params(FSPM_UPD *mupd); |
| 66 | |
| 67 | /* |
| 68 | * Configure GPIO depend on platform |
| 69 | */ |
| 70 | void mainboard_config_gpios(void) |
| 71 | { |
| 72 | size_t num; |
Julien Viard de Galbert | 7ebb6b0 | 2018-03-01 16:03:31 +0100 | [diff] [blame] | 73 | const struct dnv_pad_config *table; |
Jacob Garber | 069cd67 | 2020-02-18 23:29:21 -0700 | [diff] [blame] | 74 | uint32_t boardid = board_id(); |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 75 | |
| 76 | /* Configure pads prior to SiliconInit() in case there's any |
| 77 | * dependencies during hardware initialization. |
| 78 | */ |
| 79 | switch (boardid) { |
| 80 | case BoardIdHarcuvar: |
| 81 | table = harcuvar_gpio_table; |
| 82 | num = ARRAY_SIZE(harcuvar_gpio_table); |
| 83 | break; |
| 84 | default: |
| 85 | table = NULL; |
| 86 | num = 0; |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | if ((!table) || (!num)) { |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame^] | 91 | printk(BIOS_ERR, "No valid GPIO table found!\n"); |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 92 | return; |
| 93 | } |
| 94 | |
| 95 | printk(BIOS_INFO, "GPIO table: 0x%x, entry num: 0x%x!\n", |
| 96 | (uint32_t)table, (uint32_t)num); |
Julien Viard de Galbert | 7ebb6b0 | 2018-03-01 16:03:31 +0100 | [diff] [blame] | 97 | gpio_configure_dnv_pads(table, num); |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void mainboard_memory_init_params(FSPM_UPD *mupd) |
| 101 | { |
Angel Pons | 2a58e18 | 2021-02-19 11:11:34 +0100 | [diff] [blame] | 102 | if (!CONFIG(ENABLE_FSP_MEMORY_DOWN)) |
| 103 | return; |
| 104 | |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 105 | uint8_t *spd_data_ptr = NULL; |
| 106 | |
| 107 | /* Get SPD data pointer */ |
| 108 | spd_data_ptr = mainboard_find_spd_data(); |
| 109 | |
| 110 | if (spd_data_ptr != NULL) { |
| 111 | printk(BIOS_DEBUG, "Memory Down function is enabled!\n"); |
| 112 | |
| 113 | /* Enable Memory Down function, set Memory |
| 114 | * Down Configure structure pointer. |
| 115 | */ |
| 116 | mupd->FspmConfig.PcdMemoryDown = 1; |
| 117 | mupd->FspmConfig.PcdMemoryDownConfigPtr = |
| 118 | (uint32_t)&mMemoryDownConfig; |
| 119 | } else { |
| 120 | printk(BIOS_DEBUG, "Memory Down function is disabled!\n"); |
| 121 | |
| 122 | /* Disable Memory Down function */ |
| 123 | mupd->FspmConfig.PcdMemoryDown = 0; |
| 124 | mupd->FspmConfig.PcdMemoryDownConfigPtr = 0; |
| 125 | } |
Mariusz Szafranski | faf7a8e | 2017-08-02 18:51:47 +0200 | [diff] [blame] | 126 | } |