coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
meminit_util_apl.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <cbmem.h>
4 #include <console/console.h>
5 #include <fsp/util.h>
6 #include <memory_info.h>
8 #include <soc/meminit.h>
9 #include <string.h>
10 
11 #define FSP_SMBIOS_MEMORY_INFO_GUID \
12 { \
13  0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49, \
14  0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89 \
15 }
16 
17 void save_lpddr4_dimm_info_part_num(const char *dram_part_num)
18 {
19  int channel, dimm, dimm_max, index;
20  size_t hob_size;
21  const DIMM_INFO *src_dimm;
22  struct dimm_info *dest_dimm;
23  struct memory_info *mem_info;
24  const CHANNEL_INFO *channel_info;
25  const FSP_SMBIOS_MEMORY_INFO *memory_info_hob;
28 
29  if (!dram_part_num)
30  dram_part_num = "Unknown";
31 
32  /* Locate the memory info HOB */
33  memory_info_hob = fsp_find_extension_hob_by_guid(
35  &hob_size);
36 
37  if (memory_info_hob == NULL || hob_size == 0) {
38  printk(BIOS_ERR, "SMBIOS memory info HOB is missing\n");
39  return;
40  }
41 
42  /*
43  * Allocate CBMEM area for DIMM information used to populate SMBIOS
44  * table 17
45  */
46  mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info));
47  if (mem_info == NULL) {
48  printk(BIOS_ERR, "CBMEM entry for DIMM info missing\n");
49  return;
50  }
51  memset(mem_info, 0, sizeof(*mem_info));
52 
53  /* Describe the first N DIMMs in the system */
54  index = 0;
55  dimm_max = ARRAY_SIZE(mem_info->dimm);
56 
57  for (channel = 0; channel < memory_info_hob->ChannelCount; channel++) {
58  if (index >= dimm_max)
59  break;
60  channel_info = &memory_info_hob->ChannelInfo[channel];
61  for (dimm = 0; dimm < channel_info->DimmCount; dimm++) {
62  if (index >= dimm_max)
63  break;
64  src_dimm = &channel_info->DimmInfo[dimm];
65  dest_dimm = &mem_info->dimm[index];
66 
67  if (!src_dimm->SizeInMb)
68  continue;
69 
70  /* Populate the DIMM information */
71  dimm_info_fill(dest_dimm,
72  src_dimm->SizeInMb,
73  memory_info_hob->MemoryType,
74  memory_info_hob->MemoryFrequencyInMHz,
75  0,
76  channel_info->ChannelId,
77  src_dimm->DimmId,
78  dram_part_num,
79  strlen(dram_part_num),
80  NULL, /* SPD not available */
81  memory_info_hob->DataWidth,
82  0,
83  0,
84  src_dimm->MfgId,
85  0);
86  index++;
87  }
88  }
89  mem_info->dimm_cnt = index;
90  printk(BIOS_DEBUG, "%d DIMMs found\n", mem_info->dimm_cnt);
91 }
92 
93 void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku)
94 {
95  const char *part_num = NULL;
96 
97  if (mem_sku >= lp4cfg->num_skus) {
98  printk(BIOS_ERR, "Too few LPDDR4 SKUs: 0x%zx/0x%zx\n",
99  mem_sku, lp4cfg->num_skus);
100  } else {
101  part_num = lp4cfg->skus[mem_sku].part_num;
102  }
103 
105 }
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void * cbmem_add(u32 id, u64 size)
Definition: imd_cbmem.c:144
#define CBMEM_ID_MEMINFO
Definition: cbmem_id.h:33
#define printk(level,...)
Definition: stdlib.h:16
static const uint8_t smbios_memory_info_guid[16]
Definition: hob_display.c:55
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
static const struct lpddr4_cfg lp4cfg
Definition: memory.c:150
void save_lpddr4_dimm_info(const struct lpddr4_cfg *lp4cfg, size_t mem_sku)
#define FSP_SMBIOS_MEMORY_INFO_GUID
void save_lpddr4_dimm_info_part_num(const char *dram_part_num)
void dimm_info_fill(struct dimm_info *dimm, u32 dimm_capacity, u8 ddr_type, u32 frequency, u8 rank_per_dimm, u8 channel_id, u8 dimm_id, const char *module_part_num, size_t module_part_number_size, const u8 *module_serial_num, u16 data_width, u32 vdd_voltage, bool ecc_support, u16 mod_id, u8 mod_type)
Definition: smbios.c:13
#define NULL
Definition: stddef.h:19
unsigned char uint8_t
Definition: stdint.h:8
size_t strlen(const char *src)
Definition: string.c:42
If this table is filled and put in CBMEM, then these info in CBMEM will be used to generate smbios ty...
Definition: memory_info.h:19
size_t num_skus
Definition: meminit.h:113
const struct lpddr4_sku * skus
Definition: meminit.h:112
const char * part_num
Definition: meminit.h:107
struct dimm_info dimm[DIMM_INFO_TOTAL]
Definition: memory_info.h:110
uint8_t dimm_cnt
Definition: memory_info.h:109