blob: 267649fda4cb6fc82b280c024319edc9f8cb568d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Kever Yang50fb9982017-02-22 16:56:35 +08002/*
3 * Copyright (C) 2016-2017 Rockchip Electronics Co., Ltd
Kever Yang50fb9982017-02-22 16:56:35 +08004 */
5
6#ifndef _ASM_ARCH_SDRAM_RK3399_H
7#define _ASM_ARCH_SDRAM_RK3399_H
Kever Yang38a99b62019-11-15 11:04:34 +08008#include <asm/arch-rockchip/sdram_common.h>
YouMin Chen23ae72e2019-11-15 11:04:45 +08009#include <asm/arch-rockchip/sdram_msch.h>
Kever Yang50fb9982017-02-22 16:56:35 +080010
Kever Yang50fb9982017-02-22 16:56:35 +080011struct rk3399_ddr_pctl_regs {
12 u32 denali_ctl[332];
13};
14
15struct rk3399_ddr_publ_regs {
16 u32 denali_phy[959];
17};
18
19struct rk3399_ddr_pi_regs {
20 u32 denali_pi[200];
21};
22
Kever Yang50fb9982017-02-22 16:56:35 +080023struct rk3399_ddr_cic_regs {
24 u32 cic_ctrl0;
25 u32 cic_ctrl1;
26 u32 cic_idle_th;
27 u32 cic_cg_wait_th;
28 u32 cic_status0;
29 u32 cic_status1;
30 u32 cic_ctrl2;
31 u32 cic_ctrl3;
32 u32 cic_ctrl4;
33};
34
35/* DENALI_CTL_00 */
36#define START 1
37
38/* DENALI_CTL_68 */
YouMin Chen23ae72e2019-11-15 11:04:45 +080039#define PWRUP_SREFRESH_EXIT BIT(16)
Kever Yang50fb9982017-02-22 16:56:35 +080040
41/* DENALI_CTL_274 */
42#define MEM_RST_VALID 1
43
YouMin Chen23ae72e2019-11-15 11:04:45 +080044struct msch_regs {
45 u32 coreid;
46 u32 revisionid;
47 u32 ddrconf;
48 u32 ddrsize;
49 union noc_ddrtiminga0 ddrtiminga0;
50 union noc_ddrtimingb0 ddrtimingb0;
51 union noc_ddrtimingc0 ddrtimingc0;
52 union noc_devtodev0 devtodev0;
53 u32 reserved0[(0x110 - 0x20) / 4];
54 union noc_ddrmode ddrmode;
55 u32 reserved1[(0x1000 - 0x114) / 4];
56 u32 agingx0;
57};
58
59struct sdram_msch_timings {
60 union noc_ddrtiminga0 ddrtiminga0;
61 union noc_ddrtimingb0 ddrtimingb0;
62 union noc_ddrtimingc0 ddrtimingc0;
63 union noc_devtodev0 devtodev0;
64 union noc_ddrmode ddrmode;
65 u32 agingx0;
66};
67
Jagan Teki97867c82019-07-15 23:51:05 +053068struct rk3399_sdram_channel {
69 struct sdram_cap_info cap_info;
YouMin Chen23ae72e2019-11-15 11:04:45 +080070 struct sdram_msch_timings noc_timings;
Kever Yang50fb9982017-02-22 16:56:35 +080071};
72
Kever Yang50fb9982017-02-22 16:56:35 +080073struct rk3399_sdram_params {
74 struct rk3399_sdram_channel ch[2];
Jagan Tekid2f92d02019-07-15 23:51:06 +053075 struct sdram_base_params base;
Kever Yang50fb9982017-02-22 16:56:35 +080076 struct rk3399_ddr_pctl_regs pctl_regs;
77 struct rk3399_ddr_pi_regs pi_regs;
78 struct rk3399_ddr_publ_regs phy_regs;
79};
80
YouMin Chen23ae72e2019-11-15 11:04:45 +080081#define PI_CA_TRAINING BIT(0)
82#define PI_WRITE_LEVELING BIT(1)
83#define PI_READ_GATE_TRAINING BIT(2)
84#define PI_READ_LEVELING BIT(3)
85#define PI_WDQ_LEVELING BIT(4)
Kever Yang50fb9982017-02-22 16:56:35 +080086#define PI_FULL_TRAINING 0xff
87
Kever Yange2b64fd2019-11-15 11:04:52 +080088enum {
89 STRIDE_128B = 0,
90 STRIDE_256B = 1,
91 STRIDE_512B = 2,
92 STRIDE_4KB = 3,
93 UN_STRIDE = 4,
94 PART_STRIDE = 5,
95};
96
Kever Yang50fb9982017-02-22 16:56:35 +080097#endif