sdram_configs.c
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 <stdio.h> 9 #include <types.h> 10 11 static const char *sdram_configs[] = { 12 /* Samsung K4E6E304EB-EGCE */ 13 [0] = "sdram-lpddr3-generic-4GB", 14 15 /* Hynix H9CCNNNBJTALAR */ 16 [1] = "sdram-lpddr3-generic-4GB", 17 18 /* Samsung K4E8E324EB-EGCF */ 19 [3] = "sdram-lpddr3-generic-2GB", 20 21 /* Micron MT52L256M32D1PF */ 22 [4] = "sdram-lpddr3-generic-2GB", 23 24 /* Samsung K4E6E304EB-EGCE, duplicate to 0 */ 25 [5] = "sdram-lpddr3-generic-4GB", 26 27 /* Micron MT52L512M32D2PF */ 28 [6] = "sdram-lpddr3-generic-4GB", 29 }; 30 31 static struct rk3399_sdram_params params; 32 33 enum dram_speeds { 34 dram_800MHz = 800, 35 dram_928MHz = 928, 36 }; 37 38 static enum dram_speeds get_sdram_target_mhz(void) 39 { 40 if (CONFIG(BOARD_GOOGLE_BOB) && board_id() < 4) 41 return dram_800MHz; 42 43 return dram_928MHz; 44 } 45 46 const struct rk3399_sdram_params *get_sdram_config(void) 47 { 48 char config_file[64]; 49 uint32_t ramcode; 50 51 ramcode = ram_code(); 52 if (ramcode >= ARRAY_SIZE(sdram_configs) || 53 !snprintf(config_file, sizeof(config_file), "%s-%d", 54 sdram_configs[ramcode], get_sdram_target_mhz()) || 55 (cbfs_load(config_file, ¶ms, sizeof(params)) != sizeof(params))) 56 die("Cannot load SDRAM parameter file!"); 57 58 return ¶ms; 59 }