blob: cf2a7b7d105fd3665220447051a186b7e50b0f74 [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
Kever Yange47db832019-11-15 11:04:33 +08006#ifndef _ASM_ARCH_SDRAM_H
7#define _ASM_ARCH_SDRAM_H
Jagan Teki3d401b22019-07-15 23:51:07 +05308
Jagan Teki7ab369c2019-07-15 23:51:08 +05309enum {
Jagan Teki90974d42019-07-15 23:51:09 +053010 DDR4 = 0,
Jagan Teki7ab369c2019-07-15 23:51:08 +053011 DDR3 = 0x3,
12 LPDDR2 = 0x5,
13 LPDDR3 = 0x6,
14 LPDDR4 = 0x7,
15 UNUSED = 0xFF
16};
17
Kever Yang5db9e672017-06-23 16:11:05 +080018/*
Kever Yang117585a2019-11-15 11:04:35 +080019 * sys_reg2 bitfield struct
Kever Yang5db9e672017-06-23 16:11:05 +080020 * [31] row_3_4_ch1
21 * [30] row_3_4_ch0
22 * [29:28] chinfo
23 * [27] rank_ch1
24 * [26:25] col_ch1
25 * [24] bk_ch1
Kever Yang117585a2019-11-15 11:04:35 +080026 * [23:22] low bits of cs0_row_ch1
27 * [21:20] low bits of cs1_row_ch1
Kever Yang5db9e672017-06-23 16:11:05 +080028 * [19:18] bw_ch1
29 * [17:16] dbw_ch1;
30 * [15:13] ddrtype
31 * [12] channelnum
32 * [11] rank_ch0
Kever Yang117585a2019-11-15 11:04:35 +080033 * [10:9] col_ch0,
Kever Yang5db9e672017-06-23 16:11:05 +080034 * [8] bk_ch0
Kever Yang117585a2019-11-15 11:04:35 +080035 * [7:6] low bits of cs0_row_ch0
36 * [5:4] low bits of cs1_row_ch0
Kever Yang5db9e672017-06-23 16:11:05 +080037 * [3:2] bw_ch0
38 * [1:0] dbw_ch0
Kever Yang117585a2019-11-15 11:04:35 +080039 */
Kever Yang5db9e672017-06-23 16:11:05 +080040#define SYS_REG_DDRTYPE_SHIFT 13
41#define SYS_REG_DDRTYPE_MASK 7
42#define SYS_REG_NUM_CH_SHIFT 12
43#define SYS_REG_NUM_CH_MASK 1
44#define SYS_REG_ROW_3_4_SHIFT(ch) (30 + (ch))
45#define SYS_REG_ROW_3_4_MASK 1
46#define SYS_REG_CHINFO_SHIFT(ch) (28 + (ch))
47#define SYS_REG_RANK_SHIFT(ch) (11 + (ch) * 16)
48#define SYS_REG_RANK_MASK 1
49#define SYS_REG_COL_SHIFT(ch) (9 + (ch) * 16)
50#define SYS_REG_COL_MASK 3
51#define SYS_REG_BK_SHIFT(ch) (8 + (ch) * 16)
52#define SYS_REG_BK_MASK 1
53#define SYS_REG_CS0_ROW_SHIFT(ch) (6 + (ch) * 16)
54#define SYS_REG_CS0_ROW_MASK 3
55#define SYS_REG_CS1_ROW_SHIFT(ch) (4 + (ch) * 16)
56#define SYS_REG_CS1_ROW_MASK 3
57#define SYS_REG_BW_SHIFT(ch) (2 + (ch) * 16)
58#define SYS_REG_BW_MASK 3
59#define SYS_REG_DBW_SHIFT(ch) ((ch) * 16)
60#define SYS_REG_DBW_MASK 3
Jagan Teki9d8769c2019-07-16 17:27:01 +053061
Kever Yang117585a2019-11-15 11:04:35 +080062/*
63 * sys_reg3 bitfield struct
64 * [7] high bit of cs0_row_ch1
65 * [6] high bit of cs1_row_ch1
66 * [5] high bit of cs0_row_ch0
67 * [4] high bit of cs1_row_ch0
68 * [3:2] cs1_col_ch1
69 * [1:0] cs1_col_ch0
70 */
71#define SYS_REG_VERSION_SHIFT 28
72#define SYS_REG_VERSION_MASK 0xf
73#define SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) (5 + (ch) * 2)
74#define SYS_REG_EXTEND_CS0_ROW_MASK 1
75#define SYS_REG_EXTEND_CS1_ROW_SHIFT(ch) (4 + (ch) * 2)
76#define SYS_REG_EXTEND_CS1_ROW_MASK 1
77#define SYS_REG_CS1_COL_SHIFT(ch) (0 + (ch) * 2)
78#define SYS_REG_CS1_COL_MASK 3
Jagan Teki9d8769c2019-07-16 17:27:01 +053079
Kever Yang5db9e672017-06-23 16:11:05 +080080/* Get sdram size decode from reg */
81size_t rockchip_sdram_size(phys_addr_t reg);
82
83/* Called by U-Boot board_init_r for Rockchip SoCs */
84int dram_init(void);
Jagan Tekiced3ea62019-07-15 23:58:48 +053085
Kever Yang5db9e672017-06-23 16:11:05 +080086#endif