1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/dram/lpddr4.h>
6 #include <memory_info.h>
10 enum lpddr4_speed_grade
{
22 struct lpddr4_speed_attr
{
23 uint32_t min_clock_mhz
; // inclusive
24 uint32_t max_clock_mhz
; // inclusive
25 uint32_t reported_mts
;
29 * LPDDR4 speed attributes derived from JEDEC 209-4C and industry norms
31 * min_clock_mhz = Previous max_clock_mhz + 1
32 * max_clock_mhz = 1000/min_tCk_avg(ns)
33 * reported_mts = Standard reported DDR4 speed in MT/s
34 * May be slightly less than the actual max MT/s
36 static const struct lpddr4_speed_attr lpddr4_speeds
[] = {
54 .max_clock_mhz
= 1067,
58 .min_clock_mhz
= 1068,
59 .max_clock_mhz
= 1200,
63 .min_clock_mhz
= 1201,
64 .max_clock_mhz
= 1333,
68 .min_clock_mhz
= 1334,
69 .max_clock_mhz
= 1600,
73 .min_clock_mhz
= 1601,
74 .max_clock_mhz
= 1867,
78 .min_clock_mhz
= 1868,
79 .max_clock_mhz
= 2134,
85 * Converts LPDDR4 clock speed in MHz to the standard reported speed in MT/s
87 uint16_t lpddr4_speed_mhz_to_reported_mts(uint16_t speed_mhz
)
89 for (enum lpddr4_speed_grade speed
= 0; speed
< ARRAY_SIZE(lpddr4_speeds
); speed
++) {
90 const struct lpddr4_speed_attr
*speed_attr
= &lpddr4_speeds
[speed
];
91 if (speed_mhz
>= speed_attr
->min_clock_mhz
&&
92 speed_mhz
<= speed_attr
->max_clock_mhz
) {
93 return speed_attr
->reported_mts
;
96 printk(BIOS_ERR
, "LPDDR4 speed of %d MHz is out of range\n", speed_mhz
);