blob: 82ce3d3fc9cd9818fb357efe856100036e86ff7d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Kever Yang5db9e672017-06-23 16:11:05 +08002/*
3 * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
Kever Yang5db9e672017-06-23 16:11:05 +08004 */
5
6#ifndef _ASM_ARCH_SDRAM_COMMON_H
7#define _ASM_ARCH_SDRAM_COMMON_H
Jagan Teki3d401b22019-07-15 23:51:07 +05308
9struct sdram_cap_info {
10 unsigned int rank;
11 /* dram column number, 0 means this channel is invalid */
12 unsigned int col;
13 /* dram bank number, 3:8bank, 2:4bank */
14 unsigned int bk;
15 /* channel buswidth, 2:32bit, 1:16bit, 0:8bit */
16 unsigned int bw;
17 /* die buswidth, 2:32bit, 1:16bit, 0:8bit */
18 unsigned int dbw;
19 /*
20 * row_3_4 = 1: 6Gb or 12Gb die
21 * row_3_4 = 0: normal die, power of 2
22 */
23 unsigned int row_3_4;
24 unsigned int cs0_row;
25 unsigned int cs1_row;
26 unsigned int ddrconfig;
27};
28
29struct sdram_base_params {
30 unsigned int ddr_freq;
31 unsigned int dramtype;
32 unsigned int num_channels;
33 unsigned int stride;
34 unsigned int odt;
35};
36
Kever Yang5db9e672017-06-23 16:11:05 +080037/*
38 * sys_reg bitfield struct
39 * [31] row_3_4_ch1
40 * [30] row_3_4_ch0
41 * [29:28] chinfo
42 * [27] rank_ch1
43 * [26:25] col_ch1
44 * [24] bk_ch1
45 * [23:22] cs0_row_ch1
46 * [21:20] cs1_row_ch1
47 * [19:18] bw_ch1
48 * [17:16] dbw_ch1;
49 * [15:13] ddrtype
50 * [12] channelnum
51 * [11] rank_ch0
52 * [10:9] col_ch0
53 * [8] bk_ch0
54 * [7:6] cs0_row_ch0
55 * [5:4] cs1_row_ch0
56 * [3:2] bw_ch0
57 * [1:0] dbw_ch0
58*/
59#define SYS_REG_DDRTYPE_SHIFT 13
60#define SYS_REG_DDRTYPE_MASK 7
61#define SYS_REG_NUM_CH_SHIFT 12
62#define SYS_REG_NUM_CH_MASK 1
63#define SYS_REG_ROW_3_4_SHIFT(ch) (30 + (ch))
64#define SYS_REG_ROW_3_4_MASK 1
65#define SYS_REG_CHINFO_SHIFT(ch) (28 + (ch))
66#define SYS_REG_RANK_SHIFT(ch) (11 + (ch) * 16)
67#define SYS_REG_RANK_MASK 1
68#define SYS_REG_COL_SHIFT(ch) (9 + (ch) * 16)
69#define SYS_REG_COL_MASK 3
70#define SYS_REG_BK_SHIFT(ch) (8 + (ch) * 16)
71#define SYS_REG_BK_MASK 1
72#define SYS_REG_CS0_ROW_SHIFT(ch) (6 + (ch) * 16)
73#define SYS_REG_CS0_ROW_MASK 3
74#define SYS_REG_CS1_ROW_SHIFT(ch) (4 + (ch) * 16)
75#define SYS_REG_CS1_ROW_MASK 3
76#define SYS_REG_BW_SHIFT(ch) (2 + (ch) * 16)
77#define SYS_REG_BW_MASK 3
78#define SYS_REG_DBW_SHIFT(ch) ((ch) * 16)
79#define SYS_REG_DBW_MASK 3
80
81/* Get sdram size decode from reg */
82size_t rockchip_sdram_size(phys_addr_t reg);
83
84/* Called by U-Boot board_init_r for Rockchip SoCs */
85int dram_init(void);
86#endif