blob: f01e2c826892b0163af646908a0b38a2ad2ab825 [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Patrick Georgiac959032020-05-05 22:49:26 +02002/* SPDX-License-Identifier: GPL-2.0-or-later */
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +02003
4#include "harcuvar_boardid.h"
5#include "gpio.h"
6#include "spd/spd.h"
7#include <console/console.h>
8#include <fsp/api.h>
9#include <fsp/soc_binding.h>
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020010
Julius Wernercd49cce2019-03-05 16:53:33 -080011#if CONFIG(ENABLE_FSP_MEMORY_DOWN)
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020012
13/*
14 * Define platform specific Memory Down Configure structure.
15 *
16 * If CONFIG_ENABLE_FSP_MEMORY_DOWN is enabled, the MEMORY_DOWN_CONFIG
17 * structure should be customized to match the design.
18 *
19 * .SlotState indicates the memory down state of the specific channel/DIMM.
20 *
21 * SlotState options:
22 *
23 * STATE_MEMORY_DOWN: Memory down.
24 * STATE_MEMORY_SLOT: Physical memory slot.
25 *
26 * .SpdDataLen should always be MAX_SPD_BYTES/512.
27 *
28 * .SpdDataPtr is pointing to the SPD data structure when memory modules
29 * are memory down.
30 *
31 * SpdDataPtr options:
32 *
33 * Non-NULL: Pointing to SPD data structure.
34 * NULL: Physical memory slot, no SPD data used.
35 *
36 * DIMM Mapping of SlotState & SpdDataPtr:
37 *
38 * {{CH0DIMM0, CH0DIMM1}, {CH1DIMM0, CH1DIMM1}}
39 *
40 * Sample: Channel 0 is memory down and channel 1 is physical slot.
41 *
42 * const MEMORY_DOWN_CONFIG mMemoryDownConfig = {
43 * .SlotState = {
44 * {STATE_MEMORY_DOWN, STATE_MEMORY_DOWN},
45 * {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT}
46 * },
47 * .SpdDataLen = MAX_SPD_BYTES,
48 * .SpdDataPtr = {
49 * {(void *)CONFIG_SPD_LOC, (void *)CONFIG_SPD_LOC},
50 * {(void *)NULL, (void *)NULL}
51 * }
52 * }
53 */
54
55const MEMORY_DOWN_CONFIG mMemoryDownConfig = {
56 .SlotState = {
57 {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT},
58 {STATE_MEMORY_SLOT, STATE_MEMORY_SLOT}
59 },
60 .SpdDataLen = MAX_SPD_BYTES,
61 .SpdDataPtr = {
62 {(void *)NULL, (void *)NULL},
63 {(void *)NULL, (void *)NULL}
64 }
65};
66
67#endif /* CONFIG_ENABLE_FSP_MEMORY_DOWN */
68
69void mainboard_config_gpios(void);
70void mainboard_memory_init_params(FSPM_UPD *mupd);
71
72/*
73* Configure GPIO depend on platform
74*/
75void mainboard_config_gpios(void)
76{
77 size_t num;
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +010078 const struct dnv_pad_config *table;
Jacob Garber069cd672020-02-18 23:29:21 -070079 uint32_t boardid = board_id();
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +020080
81 /* Configure pads prior to SiliconInit() in case there's any
82 * dependencies during hardware initialization.
83 */
84 switch (boardid) {
85 case BoardIdHarcuvar:
86 table = harcuvar_gpio_table;
87 num = ARRAY_SIZE(harcuvar_gpio_table);
88 break;
89 default:
90 table = NULL;
91 num = 0;
92 break;
93 }
94
95 if ((!table) || (!num)) {
96 printk(BIOS_ERR, "ERROR: No valid GPIO table found!\n");
97 return;
98 }
99
100 printk(BIOS_INFO, "GPIO table: 0x%x, entry num: 0x%x!\n",
101 (uint32_t)table, (uint32_t)num);
Julien Viard de Galbert7ebb6b02018-03-01 16:03:31 +0100102 gpio_configure_dnv_pads(table, num);
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200103}
104
105void mainboard_memory_init_params(FSPM_UPD *mupd)
106{
Julius Wernercd49cce2019-03-05 16:53:33 -0800107#if CONFIG(ENABLE_FSP_MEMORY_DOWN)
Mariusz Szafranskifaf7a8e2017-08-02 18:51:47 +0200108 uint8_t *spd_data_ptr = NULL;
109
110 /* Get SPD data pointer */
111 spd_data_ptr = mainboard_find_spd_data();
112
113 if (spd_data_ptr != NULL) {
114 printk(BIOS_DEBUG, "Memory Down function is enabled!\n");
115
116 /* Enable Memory Down function, set Memory
117 * Down Configure structure pointer.
118 */
119 mupd->FspmConfig.PcdMemoryDown = 1;
120 mupd->FspmConfig.PcdMemoryDownConfigPtr =
121 (uint32_t)&mMemoryDownConfig;
122 } else {
123 printk(BIOS_DEBUG, "Memory Down function is disabled!\n");
124
125 /* Disable Memory Down function */
126 mupd->FspmConfig.PcdMemoryDown = 0;
127 mupd->FspmConfig.PcdMemoryDownConfigPtr = 0;
128 }
129#endif /* CONFIG_ENABLE_FSP_MEMORY_DOWN */
130}