1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4 * (C) Copyright 2019 Amarula Solutions.
5 * Author: Jagan Teki <jagan@amarulasolutions.com>
9 #include <debug_uart.h>
10 #include <asm/arch-rockchip/sdram_common.h>
12 void sdram_print_dram_type(unsigned char dramtype)
31 printascii("Unknown Device");
40 * note: it didn't consider about row_3_4
42 u64 sdram_get_cs_cap(struct sdram_cap_info *cap_info, u32 cs, u32 dram_type)
47 if (dram_type == DDR4)
48 /* DDR4 8bit dram BG = 2(4bank groups),
49 * 16bit dram BG = 1 (2 bank groups)
51 bg = (cap_info->dbw == 0) ? 2 : 1;
55 cap[0] = 1llu << (cap_info->bw + cap_info->col +
56 bg + cap_info->bk + cap_info->cs0_row);
58 if (cap_info->rank == 2)
59 cap[1] = 1llu << (cap_info->bw + cap_info->col +
60 bg + cap_info->bk + cap_info->cs1_row);
69 return (cap[0] + cap[1]);
72 void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
73 struct sdram_base_params *base)
77 bg = (cap_info->dbw == 0) ? 2 : 1;
79 sdram_print_dram_type(base->dramtype);
82 printdec(base->ddr_freq);
86 printdec(8 << cap_info->bw);
89 printdec(cap_info->col);
92 printdec(0x1 << cap_info->bk);
93 if (base->dramtype == DDR4) {
98 printascii(" CS0 Row=");
99 printdec(cap_info->cs0_row);
100 if (cap_info->rank > 1) {
101 printascii(" CS1 Row=");
102 printdec(cap_info->cs1_row);
106 printdec(cap_info->rank);
108 printascii(" Die BW=");
109 printdec(8 << cap_info->dbw);
111 cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
112 if (cap_info->row_3_4)
115 printascii(" Size=");
120 void sdram_print_stride(unsigned int stride)
124 printf("128B stride\n");
131 printf("256B stride\n");
136 printf("512B stride\n");
139 printf("4K stride\n");
142 printf("32MB + 256B stride\n");
145 printf("no stride\n");