blob: 44551a2edfb75fe5f9904ee54274572ecb1d9885 [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
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020010/*
11 * Define platform specific Memory Down Configure structure.
12 *
Martin Rothf48acbd2020-07-24 12:24:27 -060013 * If CONFIG(ENABLE_FSP_MEMORY_DOWN) is enabled, the MEMORY_DOWN_CONFIG
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020014 * 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
52const 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 Szafranskifaf7a8e2017-08-02 18:51:47 +020064void mainboard_config_gpios(void);
65void mainboard_memory_init_params(FSPM_UPD *mupd);
66
67/*
68* Configure GPIO depend on platform
69*/
70void mainboard_config_gpios(void)
71{
72 size_t num;
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +010073 const struct dnv_pad_config *table;
Jacob Garber069cd672020-02-18 23:29:21 -070074 uint32_t boardid = board_id();
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020075
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 Wernere9665952022-01-21 17:06:20 -080091 printk(BIOS_ERR, "No valid GPIO table found!\n");
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020092 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 Galbert7ebb6b02018-03-01 16:03:31 +010097 gpio_configure_dnv_pads(table, num);
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020098}
99
100void mainboard_memory_init_params(FSPM_UPD *mupd)
101{
Angel Pons2a58e182021-02-19 11:11:34 +0100102 if (!CONFIG(ENABLE_FSP_MEMORY_DOWN))
103 return;
104
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200105 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 Szafranskifaf7a8e2017-08-02 18:51:47 +0200126}