blob: 57f5e6e7654cfef133b90fc31abcd8ac1e376287 [file] [log] [blame]
Angel Pons11ba3532020-04-05 13:21:58 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Junzhi Zhao66ee65f2018-06-13 16:20:00 +08002
3#include <boardid.h>
4#include <cbfs.h>
5#include <console/console.h>
6#include <soc/emi.h>
7
Hung-Te Lin45701fd2020-07-28 10:59:00 +08008/*
9 * The RAM_CODE ADC on Kukui can support only 12 different levels. Each model
10 * can create its own mapping if needed, with an offset (0x10, 0x20, ...,
11 * defined as CONFIG_BOARD_SDRAM_TABLE_OFFSET) applied in ram_code().
12 */
Junzhi Zhao66ee65f2018-06-13 16:20:00 +080013static const char *const sdram_configs[] = {
Hung-Te Lin45701fd2020-07-28 10:59:00 +080014 /* Standard table. */
Kevin Chiu2ee5dcb2020-09-04 11:07:39 +080015 [0x00] = "sdram-lpddr4x-K4UBE3D4AA-MGCR-4GB",
Hung-Te Lin45701fd2020-07-28 10:59:00 +080016 [0x01] = "sdram-lpddr4x-H9HCNNNCPMALHR-4GB",
17 [0x02] = "sdram-lpddr4x-MT53E1G32D4NQ-4GB",
18 [0x03] = "sdram-lpddr4x-KMDH6001DA-B422-4GB",
19 [0x04] = "sdram-lpddr4x-KMDP6001DA-B425-4GB",
20 [0x05] = "sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB",
21 [0x06] = "sdram-lpddr4x-KMDV6001DA-B620-4GB",
22 [0x07] = "sdram-lpddr4x-SDADA4CR-128G-4GB",
23 [0x08] = "sdram-lpddr4x-K4UBE3D4AA-MGCL-4GB",
24 [0x09] = "sdram-lpddr4x-MT53E2G32D4NQ-046-8GB",
25 [0x0a] = "sdram-lpddr4x-H9HCNNNCPMMLXR-NEE-4GB",
26
27 /* Table shared by Burnet and its variants, offset = 0x10 */
Kevin Chiu144c5ae2020-08-26 18:10:33 +080028 [0x10] = "sdram-lpddr4x-K4UBE3D4AA-MGCR-4GB",
Hung-Te Lin45701fd2020-07-28 10:59:00 +080029 [0x11] = "sdram-lpddr4x-H9HCNNNCPMALHR-4GB",
30 [0x12] = "sdram-lpddr4x-MT53E1G32D4NQ-4GB",
31 [0x13] = "sdram-lpddr4x-K4UBE3D4AA-MGCL-4GB",
32 [0x14] = "sdram-lpddr4x-H9HCNNNCPMMLXR-NEE-4GB",
Kevin Chiudda2de82020-08-17 18:04:16 +080033 [0x16] = "sdram-lpddr4x-MT53E2G32D4NQ-046-8GB",
Junzhi Zhao66ee65f2018-06-13 16:20:00 +080034};
35
36static struct sdram_params params;
37
38const struct sdram_params *get_sdram_config(void)
39{
40 uint32_t ramcode = ram_code();
Hung-Te Lin45701fd2020-07-28 10:59:00 +080041 const char *name = NULL;
Junzhi Zhao66ee65f2018-06-13 16:20:00 +080042
Hung-Te Lin45701fd2020-07-28 10:59:00 +080043 if (ramcode < ARRAY_SIZE(sdram_configs))
44 name = sdram_configs[ramcode];
45
Julius Werner834b3ec2020-03-04 16:52:08 -080046 if (!name || cbfs_load(name, &params, sizeof(params)) != sizeof(params))
Hung-Te Lin45701fd2020-07-28 10:59:00 +080047 die("Cannot load SDRAM parameter file for RAM code %#02x: %s!",
48 ramcode, name ? name : "unknown");
Junzhi Zhao66ee65f2018-06-13 16:20:00 +080049
50 return &params;
51}