coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sdram_configs.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <boardid.h>
4 #include <cbfs.h>
5 #include <console/console.h>
6 #include <gpio.h>
7 #include <soc/sdram.h>
8 #include <string.h>
9 #include <types.h>
10 
11 static const char *sdram_configs[] = {
12 
13  /* Samsung K4E6E304EB-EGCE */
14  [0] = "sdram-lpddr3-generic-4GB",
15 
16  /* Hynix H9CCNNNBJTALAR */
17  [1] = "sdram-lpddr3-generic-4GB",
18 
19  /* Samsung K4E8E324EB-EGCF */
20  [3] = "sdram-lpddr3-generic-2GB",
21 
22  /* Micron MT52L256M32D1PF */
23  [4] = "sdram-lpddr3-generic-2GB",
24 
25  /* Samsung K4E6E304EB-EGCE, duplicate to 0 */
26  [5] = "sdram-lpddr3-generic-4GB",
27 
28  /* Micron MT52L512M32D2PF */
29  [6] = "sdram-lpddr3-generic-4GB",
30 };
31 
32 static struct rk3399_sdram_params params;
33 
35  dram_800MHz = 800,
36  dram_928MHz = 928,
37 };
38 
39 static enum dram_speeds get_sdram_target_mhz(void)
40 {
41  if (CONFIG(BOARD_GOOGLE_BOB) && board_id() < 4)
42  return dram_800MHz;
43 
44  return dram_928MHz;
45 }
46 
48 {
49  char config_file[64];
50  uint32_t ramcode;
51 
52  ramcode = ram_code();
53  if (ramcode >= ARRAY_SIZE(sdram_configs) ||
54  !snprintf(config_file, sizeof(config_file), "%s-%d",
55  sdram_configs[ramcode], get_sdram_target_mhz()) ||
56  (cbfs_load(config_file, &params, sizeof(params)) != sizeof(params)))
57  die("Cannot load SDRAM parameter file!");
58 
59  return &params;
60 }
const struct sdram_info * get_sdram_config(void)
Definition: sdram_configs.c:85
uint32_t ram_code(void)
#define ARRAY_SIZE(a)
Definition: helpers.h:12
static size_t cbfs_load(const char *name, void *buf, size_t size)
Definition: cbfs.h:282
void __noreturn die(const char *fmt,...)
Definition: die.c:17
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
static enum dram_speeds get_sdram_target_mhz(void)
Definition: sdram_configs.c:39
static struct rk3399_sdram_params params
Definition: sdram_configs.c:32
dram_speeds
Definition: sdram_configs.c:34
@ dram_800MHz
Definition: sdram_configs.c:35
@ dram_928MHz
Definition: sdram_configs.c:36
static const char * sdram_configs[]
Definition: sdram_configs.c:11
unsigned int uint32_t
Definition: stdint.h:14
int snprintf(char *buf, size_t size, const char *fmt,...)
Note: This file is only for POSIX compatibility, and is meant to be chain-included via string....
Definition: vsprintf.c:35