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