blob: 0373c01c60767c4e2acb1bc6865bbc242c907b0f [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02002
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 Szafranskifaf7a8e2017-08-02 18:51:47 +02009
Julius Wernercd49cce2019-03-05 16:53:33 -080010#if CONFIG(ENABLE_FSP_MEMORY_DOWN)
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020011
12/*
13 * Define platform specific Memory Down Configure structure.
14 *
Martin Rothf48acbd2020-07-24 12:24:27 -060015 * If CONFIG(ENABLE_FSP_MEMORY_DOWN) is enabled, the MEMORY_DOWN_CONFIG
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020016 * 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
54const 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
68void mainboard_config_gpios(void);
69void mainboard_memory_init_params(FSPM_UPD *mupd);
70
71/*
72* Configure GPIO depend on platform
73*/
74void mainboard_config_gpios(void)
75{
76 size_t num;
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +010077 const struct dnv_pad_config *table;
Jacob Garber069cd672020-02-18 23:29:21 -070078 uint32_t boardid = board_id();
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020079
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 Galbert7ebb6b02018-03-01 16:03:31 +0100101 gpio_configure_dnv_pads(table, num);
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200102}
103
104void mainboard_memory_init_params(FSPM_UPD *mupd)
105{
Julius Wernercd49cce2019-03-05 16:53:33 -0800106#if CONFIG(ENABLE_FSP_MEMORY_DOWN)
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200107 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}