blob: 6a07436059cd5ca4cd7da3ab3b197c97a4866e8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2020 Rockchip Electronics Co., Ltd
*/
#ifndef _ASM_ARCH_SDRAM_RK1126_H
#define _ASM_ARCH_SDRAM_RK1126_H
#include <asm/arch-rockchip/dram_spec_timing.h>
#include <asm/arch-rockchip/sdram.h>
#include <asm/arch-rockchip/sdram_common.h>
#include <asm/arch-rockchip/sdram_msch.h>
#include <asm/arch-rockchip/sdram_pctl_px30.h>
#include <asm/arch-rockchip/sdram_phy_rv1126.h>
#define AGINGX0_VAL (4)
#define AGING_CPU_VAL (0xff)
#define AGING_NPU_VAL (0xff)
#define AGING_OTHER_VAL (0x33)
#define PATTERN (0x5aa5f00f)
#define PHY_DDR3_RON_DISABLE (0)
#define PHY_DDR3_RON_455ohm (1)
#define PHY_DDR3_RON_230ohm (2)
#define PHY_DDR3_RON_153ohm (3)
#define PHY_DDR3_RON_115ohm (4)
#define PHY_DDR3_RON_91ohm (5)
#define PHY_DDR3_RON_76ohm (6)
#define PHY_DDR3_RON_65ohm (7)
#define PHY_DDR3_RON_57ohm (16)
#define PHY_DDR3_RON_51ohm (17)
#define PHY_DDR3_RON_46ohm (18)
#define PHY_DDR3_RON_41ohm (19)
#define PHY_DDR3_RON_38ohm (20)
#define PHY_DDR3_RON_35ohm (21)
#define PHY_DDR3_RON_32ohm (22)
#define PHY_DDR3_RON_30ohm (23)
#define PHY_DDR3_RON_28ohm (24)
#define PHY_DDR3_RON_27ohm (25)
#define PHY_DDR3_RON_25ohm (26)
#define PHY_DDR3_RON_24ohm (27)
#define PHY_DDR3_RON_23ohm (28)
#define PHY_DDR3_RON_22ohm (29)
#define PHY_DDR3_RON_21ohm (30)
#define PHY_DDR3_RON_20ohm (31)
#define PHY_DDR3_RTT_DISABLE (0)
#define PHY_DDR3_RTT_561ohm (1)
#define PHY_DDR3_RTT_282ohm (2)
#define PHY_DDR3_RTT_188ohm (3)
#define PHY_DDR3_RTT_141ohm (4)
#define PHY_DDR3_RTT_113ohm (5)
#define PHY_DDR3_RTT_94ohm (6)
#define PHY_DDR3_RTT_81ohm (7)
#define PHY_DDR3_RTT_72ohm (16)
#define PHY_DDR3_RTT_64ohm (17)
#define PHY_DDR3_RTT_58ohm (18)
#define PHY_DDR3_RTT_52ohm (19)
#define PHY_DDR3_RTT_48ohm (20)
#define PHY_DDR3_RTT_44ohm (21)
#define PHY_DDR3_RTT_41ohm (22)
#define PHY_DDR3_RTT_38ohm (23)
#define PHY_DDR3_RTT_37ohm (24)
#define PHY_DDR3_RTT_34ohm (25)
#define PHY_DDR3_RTT_32ohm (26)
#define PHY_DDR3_RTT_31ohm (27)
#define PHY_DDR3_RTT_29ohm (28)
#define PHY_DDR3_RTT_28ohm (29)
#define PHY_DDR3_RTT_27ohm (30)
#define PHY_DDR3_RTT_25ohm (31)
#define PHY_DDR4_LPDDR3_RON_DISABLE (0)
#define PHY_DDR4_LPDDR3_RON_482ohm (1)
#define PHY_DDR4_LPDDR3_RON_244ohm (2)
#define PHY_DDR4_LPDDR3_RON_162ohm (3)
#define PHY_DDR4_LPDDR3_RON_122ohm (4)
#define PHY_DDR4_LPDDR3_RON_97ohm (5)
#define PHY_DDR4_LPDDR3_RON_81ohm (6)
#define PHY_DDR4_LPDDR3_RON_69ohm (7)
#define PHY_DDR4_LPDDR3_RON_61ohm (16)
#define PHY_DDR4_LPDDR3_RON_54ohm (17)
#define PHY_DDR4_LPDDR3_RON_48ohm (18)
#define PHY_DDR4_LPDDR3_RON_44ohm (19)
#define PHY_DDR4_LPDDR3_RON_40ohm (20)
#define PHY_DDR4_LPDDR3_RON_37ohm (21)
#define PHY_DDR4_LPDDR3_RON_34ohm (22)
#define PHY_DDR4_LPDDR3_RON_32ohm (23)
#define PHY_DDR4_LPDDR3_RON_30ohm (24)
#define PHY_DDR4_LPDDR3_RON_28ohm (25)
#define PHY_DDR4_LPDDR3_RON_27ohm (26)
#define PHY_DDR4_LPDDR3_RON_25ohm (27)
#define PHY_DDR4_LPDDR3_RON_24ohm (28)
#define PHY_DDR4_LPDDR3_RON_23ohm (29)
#define PHY_DDR4_LPDDR3_RON_22ohm (30)
#define PHY_DDR4_LPDDR3_RON_21ohm (31)
#define PHY_DDR4_LPDDR3_RTT_DISABLE (0)
#define PHY_DDR4_LPDDR3_RTT_586ohm (1)
#define PHY_DDR4_LPDDR3_RTT_294ohm (2)
#define PHY_DDR4_LPDDR3_RTT_196ohm (3)
#define PHY_DDR4_LPDDR3_RTT_148ohm (4)
#define PHY_DDR4_LPDDR3_RTT_118ohm (5)
#define PHY_DDR4_LPDDR3_RTT_99ohm (6)
#define PHY_DDR4_LPDDR3_RTT_85ohm (7)
#define PHY_DDR4_LPDDR3_RTT_76ohm (16)
#define PHY_DDR4_LPDDR3_RTT_67ohm (17)
#define PHY_DDR4_LPDDR3_RTT_60ohm (18)
#define PHY_DDR4_LPDDR3_RTT_55ohm (19)
#define PHY_DDR4_LPDDR3_RTT_50ohm (20)
#define PHY_DDR4_LPDDR3_RTT_46ohm (21)
#define PHY_DDR4_LPDDR3_RTT_43ohm (22)
#define PHY_DDR4_LPDDR3_RTT_40ohm (23)
#define PHY_DDR4_LPDDR3_RTT_38ohm (24)
#define PHY_DDR4_LPDDR3_RTT_36ohm (25)
#define PHY_DDR4_LPDDR3_RTT_34ohm (26)
#define PHY_DDR4_LPDDR3_RTT_32ohm (27)
#define PHY_DDR4_LPDDR3_RTT_31ohm (28)
#define PHY_DDR4_LPDDR3_RTT_29ohm (29)
#define PHY_DDR4_LPDDR3_RTT_28ohm (30)
#define PHY_DDR4_LPDDR3_RTT_27ohm (31)
#define PHY_LPDDR4_RON_DISABLE (0)
#define PHY_LPDDR4_RON_501ohm (1)
#define PHY_LPDDR4_RON_253ohm (2)
#define PHY_LPDDR4_RON_168ohm (3)
#define PHY_LPDDR4_RON_126ohm (4)
#define PHY_LPDDR4_RON_101ohm (5)
#define PHY_LPDDR4_RON_84ohm (6)
#define PHY_LPDDR4_RON_72ohm (7)
#define PHY_LPDDR4_RON_63ohm (16)
#define PHY_LPDDR4_RON_56ohm (17)
#define PHY_LPDDR4_RON_50ohm (18)
#define PHY_LPDDR4_RON_46ohm (19)
#define PHY_LPDDR4_RON_42ohm (20)
#define PHY_LPDDR4_RON_38ohm (21)
#define PHY_LPDDR4_RON_36ohm (22)
#define PHY_LPDDR4_RON_33ohm (23)
#define PHY_LPDDR4_RON_31ohm (24)
#define PHY_LPDDR4_RON_29ohm (25)
#define PHY_LPDDR4_RON_28ohm (26)
#define PHY_LPDDR4_RON_26ohm (27)
#define PHY_LPDDR4_RON_25ohm (28)
#define PHY_LPDDR4_RON_24ohm (29)
#define PHY_LPDDR4_RON_23ohm (30)
#define PHY_LPDDR4_RON_22ohm (31)
#define PHY_LPDDR4_RTT_DISABLE (0)
#define PHY_LPDDR4_RTT_604ohm (1)
#define PHY_LPDDR4_RTT_303ohm (2)
#define PHY_LPDDR4_RTT_202ohm (3)
#define PHY_LPDDR4_RTT_152ohm (4)
#define PHY_LPDDR4_RTT_122ohm (5)
#define PHY_LPDDR4_RTT_101ohm (6)
#define PHY_LPDDR4_RTT_87ohm (7)
#define PHY_LPDDR4_RTT_78ohm (16)
#define PHY_LPDDR4_RTT_69ohm (17)
#define PHY_LPDDR4_RTT_62ohm (18)
#define PHY_LPDDR4_RTT_56ohm (19)
#define PHY_LPDDR4_RTT_52ohm (20)
#define PHY_LPDDR4_RTT_48ohm (21)
#define PHY_LPDDR4_RTT_44ohm (22)
#define PHY_LPDDR4_RTT_41ohm (23)
#define PHY_LPDDR4_RTT_39ohm (24)
#define PHY_LPDDR4_RTT_37ohm (25)
#define PHY_LPDDR4_RTT_35ohm (26)
#define PHY_LPDDR4_RTT_33ohm (27)
#define PHY_LPDDR4_RTT_32ohm (28)
#define PHY_LPDDR4_RTT_30ohm (29)
#define PHY_LPDDR4_RTT_29ohm (30)
#define PHY_LPDDR4_RTT_27ohm (31)
#define ADD_CMD_CA (0x150)
#define ADD_GROUP_CS0_A (0x170)
#define ADD_GROUP_CS0_B (0x1d0)
#define ADD_GROUP_CS1_A (0x1a0)
#define ADD_GROUP_CS1_B (0x200)
/* PMUGRF */
#define PMUGRF_OS_REG0 (0x200)
#define PMUGRF_OS_REG(n) (PMUGRF_OS_REG0 + (n) * 4)
#define PMUGRF_CON_DDRPHY_BUFFEREN_MASK (0x3 << (12 + 16))
#define PMUGRF_CON_DDRPHY_BUFFEREN_EN (0x1 << 12)
#define PMUGRF_CON_DDRPHY_BUFFEREN_DIS (0x2 << 12)
/* DDR GRF */
#define DDR_GRF_CON(n) (0 + (n) * 4)
#define DDR_GRF_STATUS_BASE (0X100)
#define DDR_GRF_STATUS(n) (DDR_GRF_STATUS_BASE + (n) * 4)
#define DDR_GRF_LP_CON (0x20)
#define SPLIT_MODE_32_L16_VALID (0)
#define SPLIT_MODE_32_H16_VALID (1)
#define SPLIT_MODE_16_L8_VALID (2)
#define SPLIT_MODE_16_H8_VALID (3)
#define DDR_GRF_SPLIT_CON (0x10)
#define SPLIT_MODE_MASK (0x3)
#define SPLIT_MODE_OFFSET (9)
#define SPLIT_BYPASS_MASK (1)
#define SPLIT_BYPASS_OFFSET (8)
#define SPLIT_SIZE_MASK (0xff)
#define SPLIT_SIZE_OFFSET (0)
/* SGRF SOC_CON13 */
#define UPCTL2_ASRSTN_REQ(n) (((0x1 << 0) << 16) | ((n) << 0))
#define UPCTL2_PSRSTN_REQ(n) (((0x1 << 1) << 16) | ((n) << 1))
#define UPCTL2_SRSTN_REQ(n) (((0x1 << 2) << 16) | ((n) << 2))
/* CRU define */
/* CRU_PLL_CON0 */
#define PB(n) ((0x1 << (15 + 16)) | ((n) << 15))
#define POSTDIV1(n) ((0x7 << (12 + 16)) | ((n) << 12))
#define FBDIV(n) ((0xFFF << 16) | (n))
/* CRU_PLL_CON1 */
#define RSTMODE(n) ((0x1 << (15 + 16)) | ((n) << 15))
#define RST(n) ((0x1 << (14 + 16)) | ((n) << 14))
#define PD(n) ((0x1 << (13 + 16)) | ((n) << 13))
#define DSMPD(n) ((0x1 << (12 + 16)) | ((n) << 12))
#define LOCK(n) (((n) >> 10) & 0x1)
#define POSTDIV2(n) ((0x7 << (6 + 16)) | ((n) << 6))
#define REFDIV(n) ((0x3F << 16) | (n))
/* CRU_PLL_CON3 */
#define SSMOD_SPREAD(n) ((0x1f << (8 + 16)) | ((n) << 8))
#define SSMOD_DIVVAL(n) ((0xf << (4 + 16)) | ((n) << 4))
#define SSMOD_DOWNSPREAD(n) ((0x1 << (3 + 16)) | ((n) << 3))
#define SSMOD_RESET(n) ((0x1 << (2 + 16)) | ((n) << 2))
#define SSMOD_DIS_SSCG(n) ((0x1 << (1 + 16)) | ((n) << 1))
#define SSMOD_BP(n) ((0x1 << (0 + 16)) | ((n) << 0))
/* CRU_MODE */
#define CLOCK_FROM_XIN_OSC (0)
#define CLOCK_FROM_PLL (1)
#define CLOCK_FROM_RTC_32K (2)
#define DPLL_MODE(n) ((0x3 << (2 + 16)) | ((n) << 2))
/* CRU_SOFTRESET_CON1 */
#define DDRPHY_PSRSTN_REQ(n) (((0x1 << 14) << 16) | ((n) << 14))
#define DDRPHY_SRSTN_REQ(n) (((0x1 << 15) << 16) | ((n) << 15))
/* CRU_CLKGATE_CON2 */
#define DDR_MSCH_EN_MASK ((0x1 << 10) << 16)
#define DDR_MSCH_EN_SHIFT (10)
/* CRU register */
#define CRU_PLL_CON(pll_id, n) ((pll_id) * 0x20 + (n) * 4)
#define CRU_MODE (0xa0)
#define CRU_GLB_CNT_TH (0xb0)
#define CRU_CLKSEL_CON_BASE 0x100
#define CRU_CLKSELS_CON(i) (CRU_CLKSEL_CON_BASE + ((i) * 4))
#define CRU_CLKGATE_CON_BASE 0x230
#define CRU_CLKGATE_CON(i) (CRU_CLKGATE_CON_BASE + ((i) * 4))
#define CRU_CLKSFTRST_CON_BASE 0x300
#define CRU_CLKSFTRST_CON(i) (CRU_CLKSFTRST_CON_BASE + ((i) * 4))
/* SGRF_SOC_CON2 */
#define MSCH_AXI_BYPASS_ALL_MASK (1)
#define MSCH_AXI_BYPASS_ALL_SHIFT (15)
/* SGRF_SOC_CON12 */
#define CLK_DDR_UPCTL_EN_MASK ((0x1 << 2) << 16)
#define CLK_DDR_UPCTL_EN_SHIFT (2)
#define ACLK_DDR_UPCTL_EN_MASK ((0x1 << 0) << 16)
#define ACLK_DDR_UPCTL_EN_SHIFT (0)
/* DDRGRF DDR CON2 */
#define DFI_FREQ_CHANGE_ACK BIT(10)
/* DDRGRF status8 */
#define DFI_FREQ_CHANGE_REQ BIT(19)
struct rv1126_ddrgrf {
u32 ddr_grf_con[4];
u32 grf_ddrsplit_con;
u32 reserved1[(0x20 - 0x10) / 4 - 1];
u32 ddr_grf_lp_con;
u32 reserved2[(0x40 - 0x20) / 4 - 1];
u32 grf_ddrphy_con[6];
u32 reserved3[(0x100 - 0x54) / 4 - 1];
u32 ddr_grf_status[18];
u32 reserved4[(0x150 - 0x144) / 4 - 1];
u32 grf_ddrhold_status;
u32 reserved5[(0x160 - 0x150) / 4 - 1];
u32 grf_ddrphy_status[2];
};
struct rv1126_ddr_phy_regs {
u32 phy[8][2];
};
struct msch_regs {
u32 coreid;
u32 revisionid;
u32 deviceconf;
u32 devicesize;
u32 ddrtiminga0;
u32 ddrtimingb0;
u32 ddrtimingc0;
u32 devtodev0;
u32 reserved1[(0x110 - 0x20) / 4];
u32 ddrmode;
u32 ddr4timing;
u32 reserved2[(0x1000 - 0x118) / 4];
u32 agingx0;
u32 reserved3[(0x1040 - 0x1004) / 4];
u32 aging0;
u32 aging1;
u32 aging2;
u32 aging3;
};
struct sdram_msch_timings {
union noc_ddrtiminga0 ddrtiminga0;
union noc_ddrtimingb0 ddrtimingb0;
union noc_ddrtimingc0 ddrtimingc0;
union noc_devtodev_rv1126 devtodev0;
union noc_ddrmode ddrmode;
union noc_ddr4timing ddr4timing;
u32 agingx0;
u32 aging0;
u32 aging1;
u32 aging2;
u32 aging3;
};
struct rv1126_sdram_channel {
struct sdram_cap_info cap_info;
struct sdram_msch_timings noc_timings;
};
struct rv1126_sdram_params {
struct rv1126_sdram_channel ch;
struct sdram_base_params base;
struct ddr_pctl_regs pctl_regs;
struct rv1126_ddr_phy_regs phy_regs;
};
struct rv1126_fsp_param {
u32 flag;
u32 freq_mhz;
/* dram size */
u32 dq_odt;
u32 ca_odt;
u32 ds_pdds;
u32 vref_ca[2];
u32 vref_dq[2];
/* phy side */
u32 wr_dq_drv;
u32 wr_ca_drv;
u32 wr_ckcs_drv;
u32 rd_odt;
u32 rd_odt_up_en;
u32 rd_odt_down_en;
u32 vref_inner;
u32 vref_out;
u32 lp4_drv_pd_en;
struct sdram_msch_timings noc_timings;
};
#define MAX_IDX (4)
#define FSP_FLAG (0xfead0001)
#define SHARE_MEM_BASE (0x100000)
/*
* Borrow share memory space to temporarily store FSP parame.
* In the stage of DDR init write FSP parame to this space.
* In the stage of trust init move FSP parame to SRAM space
* from share memory space.
*/
#define FSP_PARAM_STORE_ADDR (SHARE_MEM_BASE)
/* store result of read and write training, for ddr_dq_eye tool in u-boot */
#define RW_TRN_RESULT_ADDR (0x2000000 + 0x8000) /* 32M + 32k */
#define PRINT_STEP 1
#undef FSP_NUM
#undef CS_NUM
#undef BYTE_NUM
#define FSP_NUM 4
#define CS_NUM 2
#define BYTE_NUM 4
#define RD_DESKEW_NUM 64
#define WR_DESKEW_NUM 64
#define LP4_WIDTH_REF_MHZ_H 1056
#define LP4_RD_WIDTH_REF_H 12
#define LP4_WR_WIDTH_REF_H 13
#define LP4_WIDTH_REF_MHZ_L 924
#define LP4_RD_WIDTH_REF_L 15
#define LP4_WR_WIDTH_REF_L 15
#define DDR4_WIDTH_REF_MHZ_H 1056
#define DDR4_RD_WIDTH_REF_H 13
#define DDR4_WR_WIDTH_REF_H 9
#define DDR4_WIDTH_REF_MHZ_L 924
#define DDR4_RD_WIDTH_REF_L 15
#define DDR4_WR_WIDTH_REF_L 11
#define LP3_WIDTH_REF_MHZ_H 1056
#define LP3_RD_WIDTH_REF_H 15
#define LP3_WR_WIDTH_REF_H 13
#define LP3_WIDTH_REF_MHZ_L 924
#define LP3_RD_WIDTH_REF_L 16
#define LP3_WR_WIDTH_REF_L 15
#define DDR3_WIDTH_REF_MHZ_H 1056
#define DDR3_RD_WIDTH_REF_H 14
#define DDR3_WR_WIDTH_REF_H 14
#define DDR3_WIDTH_REF_MHZ_L 924
#define DDR3_RD_WIDTH_REF_L 17
#define DDR3_WR_WIDTH_REF_L 17
#endif /* _ASM_ARCH_SDRAM_RK1126_H */
|