coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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>
9 
10 /*
11  * Define platform specific Memory Down Configure structure.
12  *
13  * If CONFIG(ENABLE_FSP_MEMORY_DOWN) is enabled, the MEMORY_DOWN_CONFIG
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 
64 void mainboard_config_gpios(void);
65 void mainboard_memory_init_params(FSPM_UPD *mupd);
66 
67 /*
68 * Configure GPIO depend on platform
69 */
71 {
72  size_t num;
73  const struct dnv_pad_config *table;
74  uint32_t boardid = board_id();
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;
83  break;
84  default:
85  table = NULL;
86  num = 0;
87  break;
88  }
89 
90  if ((!table) || (!num)) {
91  printk(BIOS_ERR, "No valid GPIO table found!\n");
92  return;
93  }
94 
95  printk(BIOS_INFO, "GPIO table: 0x%x, entry num: 0x%x!\n",
96  (uint32_t)table, (uint32_t)num);
97  gpio_configure_dnv_pads(table, num);
98 }
99 
100 void mainboard_memory_init_params(FSPM_UPD *mupd)
101 {
102  if (!CONFIG(ENABLE_FSP_MEMORY_DOWN))
103  return;
104 
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 =
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  }
126 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
void gpio_configure_dnv_pads(const struct dnv_pad_config *gpio, size_t num)
Definition: gpio_dnv.c:120
#define BoardIdHarcuvar
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void mainboard_memory_init_params(FSPM_UPD *mupd)
Definition: romstage.c:22
const struct dnv_pad_config harcuvar_gpio_table[]
Definition: gpio.h:9
const MEMORY_DOWN_CONFIG mMemoryDownConfig
Definition: romstage.c:52
void mainboard_config_gpios(void)
Definition: romstage.c:70
uint8_t * mainboard_find_spd_data()
Definition: spd.c:9
#define NULL
Definition: stddef.h:19
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8