xref: /rk3399_ARM-atf/include/drivers/st/stm32mp1_ddr_regs.h (revision f7a92518f66d5b5aa51f9effad0494b1a2405a8f)
110a511ceSYann Gautier /*
25def13ebSNicolas Le Bayon  * Copyright (c) 2017-2022, STMicroelectronics - All Rights Reserved
310a511ceSYann Gautier  *
410a511ceSYann Gautier  * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
510a511ceSYann Gautier  */
610a511ceSYann Gautier 
7c3cf06f1SAntonio Nino Diaz #ifndef STM32MP1_DDR_REGS_H
8c3cf06f1SAntonio Nino Diaz #define STM32MP1_DDR_REGS_H
910a511ceSYann Gautier 
10*06e55dc8SNicolas Le Bayon #include <drivers/st/stm32mp_ddrctrl_regs.h>
1109d40e0eSAntonio Nino Diaz #include <lib/utils_def.h>
1210a511ceSYann Gautier 
1310a511ceSYann Gautier /* DDR Physical Interface Control (DDRPHYC) registers*/
14*06e55dc8SNicolas Le Bayon struct stm32mp_ddrphy {
1510a511ceSYann Gautier 	uint32_t ridr;		/* 0x00 R Revision Identification */
1610a511ceSYann Gautier 	uint32_t pir;		/* 0x04 R/W PHY Initialization */
1710a511ceSYann Gautier 	uint32_t pgcr;		/* 0x08 R/W PHY General Configuration */
1810a511ceSYann Gautier 	uint32_t pgsr;		/* 0x0C PHY General Status */
1910a511ceSYann Gautier 	uint32_t dllgcr;	/* 0x10 R/W DLL General Control */
2010a511ceSYann Gautier 	uint32_t acdllcr;	/* 0x14 R/W AC DLL Control */
2110a511ceSYann Gautier 	uint32_t ptr0;		/* 0x18 R/W PHY Timing 0 */
2210a511ceSYann Gautier 	uint32_t ptr1;		/* 0x1C R/W PHY Timing 1 */
2310a511ceSYann Gautier 	uint32_t ptr2;		/* 0x20 R/W PHY Timing 2 */
2410a511ceSYann Gautier 	uint32_t aciocr;	/* 0x24 AC I/O Configuration */
2510a511ceSYann Gautier 	uint32_t dxccr;		/* 0x28 DATX8 Common Configuration */
2610a511ceSYann Gautier 	uint32_t dsgcr;		/* 0x2C DDR System General Configuration */
2710a511ceSYann Gautier 	uint32_t dcr;		/* 0x30 DRAM Configuration */
2810a511ceSYann Gautier 	uint32_t dtpr0;		/* 0x34 DRAM Timing Parameters0 */
2910a511ceSYann Gautier 	uint32_t dtpr1;		/* 0x38 DRAM Timing Parameters1 */
3010a511ceSYann Gautier 	uint32_t dtpr2;		/* 0x3C DRAM Timing Parameters2 */
3110a511ceSYann Gautier 	uint32_t mr0;		/* 0x40 Mode 0 */
3210a511ceSYann Gautier 	uint32_t mr1;		/* 0x44 Mode 1 */
3310a511ceSYann Gautier 	uint32_t mr2;		/* 0x48 Mode 2 */
3410a511ceSYann Gautier 	uint32_t mr3;		/* 0x4C Mode 3 */
3510a511ceSYann Gautier 	uint32_t odtcr;		/* 0x50 ODT Configuration */
3610a511ceSYann Gautier 	uint32_t dtar;		/* 0x54 data training address */
3710a511ceSYann Gautier 	uint32_t dtdr0;		/* 0x58 */
3810a511ceSYann Gautier 	uint32_t dtdr1;		/* 0x5c */
3910a511ceSYann Gautier 	uint8_t res1[0x0c0 - 0x060];	/* 0x60 */
4010a511ceSYann Gautier 	uint32_t dcuar;		/* 0xc0 Address */
4110a511ceSYann Gautier 	uint32_t dcudr;		/* 0xc4 DCU Data */
4210a511ceSYann Gautier 	uint32_t dcurr;		/* 0xc8 DCU Run */
4310a511ceSYann Gautier 	uint32_t dculr;		/* 0xcc DCU Loop */
4410a511ceSYann Gautier 	uint32_t dcugcr;	/* 0xd0 DCU General Configuration */
4510a511ceSYann Gautier 	uint32_t dcutpr;	/* 0xd4 DCU Timing Parameters */
4610a511ceSYann Gautier 	uint32_t dcusr0;	/* 0xd8 DCU Status 0 */
4710a511ceSYann Gautier 	uint32_t dcusr1;	/* 0xdc DCU Status 1 */
4810a511ceSYann Gautier 	uint8_t res2[0x100 - 0xe0];	/* 0xe0 */
4910a511ceSYann Gautier 	uint32_t bistrr;	/* 0x100 BIST Run */
5010a511ceSYann Gautier 	uint32_t bistmskr0;	/* 0x104 BIST Mask 0 */
5110a511ceSYann Gautier 	uint32_t bistmskr1;	/* 0x108 BIST Mask 0 */
5210a511ceSYann Gautier 	uint32_t bistwcr;	/* 0x10c BIST Word Count */
5310a511ceSYann Gautier 	uint32_t bistlsr;	/* 0x110 BIST LFSR Seed */
5410a511ceSYann Gautier 	uint32_t bistar0;	/* 0x114 BIST Address 0 */
5510a511ceSYann Gautier 	uint32_t bistar1;	/* 0x118 BIST Address 1 */
5610a511ceSYann Gautier 	uint32_t bistar2;	/* 0x11c BIST Address 2 */
5710a511ceSYann Gautier 	uint32_t bistupdr;	/* 0x120 BIST User Data Pattern */
5810a511ceSYann Gautier 	uint32_t bistgsr;	/* 0x124 BIST General Status */
5910a511ceSYann Gautier 	uint32_t bistwer;	/* 0x128 BIST Word Error */
6010a511ceSYann Gautier 	uint32_t bistber0;	/* 0x12c BIST Bit Error 0 */
6110a511ceSYann Gautier 	uint32_t bistber1;	/* 0x130 BIST Bit Error 1 */
6210a511ceSYann Gautier 	uint32_t bistber2;	/* 0x134 BIST Bit Error 2 */
6310a511ceSYann Gautier 	uint32_t bistwcsr;	/* 0x138 BIST Word Count Status */
6410a511ceSYann Gautier 	uint32_t bistfwr0;	/* 0x13c BIST Fail Word 0 */
6510a511ceSYann Gautier 	uint32_t bistfwr1;	/* 0x140 BIST Fail Word 1 */
6610a511ceSYann Gautier 	uint8_t res3[0x178 - 0x144];	/* 0x144 */
6710a511ceSYann Gautier 	uint32_t gpr0;		/* 0x178 General Purpose 0 (GPR0) */
6810a511ceSYann Gautier 	uint32_t gpr1;		/* 0x17C General Purpose 1 (GPR1) */
6910a511ceSYann Gautier 	uint32_t zq0cr0;	/* 0x180 zq 0 control 0 */
7010a511ceSYann Gautier 	uint32_t zq0cr1;	/* 0x184 zq 0 control 1 */
7110a511ceSYann Gautier 	uint32_t zq0sr0;	/* 0x188 zq 0 status 0 */
7210a511ceSYann Gautier 	uint32_t zq0sr1;	/* 0x18C zq 0 status 1 */
7310a511ceSYann Gautier 	uint8_t res4[0x1C0 - 0x190];	/* 0x190 */
7410a511ceSYann Gautier 	uint32_t dx0gcr;	/* 0x1c0 Byte lane 0 General Configuration */
7510a511ceSYann Gautier 	uint32_t dx0gsr0;	/* 0x1c4 Byte lane 0 General Status 0 */
7610a511ceSYann Gautier 	uint32_t dx0gsr1;	/* 0x1c8 Byte lane 0 General Status 1 */
7710a511ceSYann Gautier 	uint32_t dx0dllcr;	/* 0x1cc Byte lane 0 DLL Control */
7810a511ceSYann Gautier 	uint32_t dx0dqtr;	/* 0x1d0 Byte lane 0 DQ Timing */
7910a511ceSYann Gautier 	uint32_t dx0dqstr;	/* 0x1d4 Byte lane 0 DQS Timing */
8010a511ceSYann Gautier 	uint8_t res5[0x200 - 0x1d8];	/* 0x1d8 */
8110a511ceSYann Gautier 	uint32_t dx1gcr;	/* 0x200 Byte lane 1 General Configuration */
8210a511ceSYann Gautier 	uint32_t dx1gsr0;	/* 0x204 Byte lane 1 General Status 0 */
8310a511ceSYann Gautier 	uint32_t dx1gsr1;	/* 0x208 Byte lane 1 General Status 1 */
8410a511ceSYann Gautier 	uint32_t dx1dllcr;	/* 0x20c Byte lane 1 DLL Control */
8510a511ceSYann Gautier 	uint32_t dx1dqtr;	/* 0x210 Byte lane 1 DQ Timing */
8610a511ceSYann Gautier 	uint32_t dx1dqstr;	/* 0x214 Byte lane 1 QS Timing */
8710a511ceSYann Gautier 	uint8_t res6[0x240 - 0x218];	/* 0x218 */
8888f4fb8fSYann Gautier #if STM32MP_DDR_32BIT_INTERFACE
8910a511ceSYann Gautier 	uint32_t dx2gcr;	/* 0x240 Byte lane 2 General Configuration */
9010a511ceSYann Gautier 	uint32_t dx2gsr0;	/* 0x244 Byte lane 2 General Status 0 */
9110a511ceSYann Gautier 	uint32_t dx2gsr1;	/* 0x248 Byte lane 2 General Status 1 */
9210a511ceSYann Gautier 	uint32_t dx2dllcr;	/* 0x24c Byte lane 2 DLL Control */
9310a511ceSYann Gautier 	uint32_t dx2dqtr;	/* 0x250 Byte lane 2 DQ Timing */
9410a511ceSYann Gautier 	uint32_t dx2dqstr;	/* 0x254 Byte lane 2 QS Timing */
9510a511ceSYann Gautier 	uint8_t res7[0x280 - 0x258];	/* 0x258 */
9610a511ceSYann Gautier 	uint32_t dx3gcr;	/* 0x280 Byte lane 3 General Configuration */
9710a511ceSYann Gautier 	uint32_t dx3gsr0;	/* 0x284 Byte lane 3 General Status 0 */
9810a511ceSYann Gautier 	uint32_t dx3gsr1;	/* 0x288 Byte lane 3 General Status 1 */
9910a511ceSYann Gautier 	uint32_t dx3dllcr;	/* 0x28c Byte lane 3 DLL Control */
10010a511ceSYann Gautier 	uint32_t dx3dqtr;	/* 0x290 Byte lane 3 DQ Timing */
10110a511ceSYann Gautier 	uint32_t dx3dqstr;	/* 0x294 Byte lane 3 QS Timing */
10288f4fb8fSYann Gautier #endif
10310a511ceSYann Gautier } __packed;
10410a511ceSYann Gautier 
10510a511ceSYann Gautier /* DDR PHY registers offsets */
10610a511ceSYann Gautier #define DDRPHYC_PIR				0x004
10710a511ceSYann Gautier #define DDRPHYC_PGCR				0x008
10810a511ceSYann Gautier #define DDRPHYC_PGSR				0x00C
10910a511ceSYann Gautier #define DDRPHYC_DLLGCR				0x010
11010a511ceSYann Gautier #define DDRPHYC_ACDLLCR				0x014
11110a511ceSYann Gautier #define DDRPHYC_PTR0				0x018
11210a511ceSYann Gautier #define DDRPHYC_ACIOCR				0x024
11310a511ceSYann Gautier #define DDRPHYC_DXCCR				0x028
11410a511ceSYann Gautier #define DDRPHYC_DSGCR				0x02C
11510a511ceSYann Gautier #define DDRPHYC_ZQ0CR0				0x180
11610a511ceSYann Gautier #define DDRPHYC_DX0GCR				0x1C0
11710a511ceSYann Gautier #define DDRPHYC_DX0DLLCR			0x1CC
11810a511ceSYann Gautier #define DDRPHYC_DX1GCR				0x200
11910a511ceSYann Gautier #define DDRPHYC_DX1DLLCR			0x20C
12088f4fb8fSYann Gautier #if STM32MP_DDR_32BIT_INTERFACE
12110a511ceSYann Gautier #define DDRPHYC_DX2GCR				0x240
12210a511ceSYann Gautier #define DDRPHYC_DX2DLLCR			0x24C
12310a511ceSYann Gautier #define DDRPHYC_DX3GCR				0x280
12410a511ceSYann Gautier #define DDRPHYC_DX3DLLCR			0x28C
12588f4fb8fSYann Gautier #endif
12610a511ceSYann Gautier 
12710a511ceSYann Gautier /* DDR PHY Register fields */
12810a511ceSYann Gautier #define DDRPHYC_PIR_INIT			BIT(0)
12910a511ceSYann Gautier #define DDRPHYC_PIR_DLLSRST			BIT(1)
13010a511ceSYann Gautier #define DDRPHYC_PIR_DLLLOCK			BIT(2)
13110a511ceSYann Gautier #define DDRPHYC_PIR_ZCAL			BIT(3)
13210a511ceSYann Gautier #define DDRPHYC_PIR_ITMSRST			BIT(4)
13310a511ceSYann Gautier #define DDRPHYC_PIR_DRAMRST			BIT(5)
13410a511ceSYann Gautier #define DDRPHYC_PIR_DRAMINIT			BIT(6)
13510a511ceSYann Gautier #define DDRPHYC_PIR_QSTRN			BIT(7)
1365def13ebSNicolas Le Bayon #define DDRPHYC_PIR_RVTRN			BIT(8)
13710a511ceSYann Gautier #define DDRPHYC_PIR_ICPC			BIT(16)
13810a511ceSYann Gautier #define DDRPHYC_PIR_ZCALBYP			BIT(30)
13910a511ceSYann Gautier #define DDRPHYC_PIR_INITSTEPS_MASK		GENMASK(31, 7)
14010a511ceSYann Gautier 
14110a511ceSYann Gautier #define DDRPHYC_PGCR_DFTCMP			BIT(2)
14210a511ceSYann Gautier #define DDRPHYC_PGCR_PDDISDX			BIT(24)
14310a511ceSYann Gautier #define DDRPHYC_PGCR_RFSHDT_MASK		GENMASK(28, 25)
14410a511ceSYann Gautier 
14510a511ceSYann Gautier #define DDRPHYC_PGSR_IDONE			BIT(0)
14610a511ceSYann Gautier #define DDRPHYC_PGSR_DTERR			BIT(5)
14710a511ceSYann Gautier #define DDRPHYC_PGSR_DTIERR			BIT(6)
14810a511ceSYann Gautier #define DDRPHYC_PGSR_DFTERR			BIT(7)
14910a511ceSYann Gautier #define DDRPHYC_PGSR_RVERR			BIT(8)
15010a511ceSYann Gautier #define DDRPHYC_PGSR_RVEIRR			BIT(9)
15110a511ceSYann Gautier 
15210a511ceSYann Gautier #define DDRPHYC_DLLGCR_BPS200			BIT(23)
15310a511ceSYann Gautier 
1544156d4daSYann Gautier #define DDRPHYC_ACDLLCR_DLLSRST			BIT(30)
15510a511ceSYann Gautier #define DDRPHYC_ACDLLCR_DLLDIS			BIT(31)
15610a511ceSYann Gautier 
15710a511ceSYann Gautier #define DDRPHYC_PTR0_TDLLSRST_OFFSET		0
15810a511ceSYann Gautier #define DDRPHYC_PTR0_TDLLSRST_MASK		GENMASK(5, 0)
15910a511ceSYann Gautier #define DDRPHYC_PTR0_TDLLLOCK_OFFSET		6
16010a511ceSYann Gautier #define DDRPHYC_PTR0_TDLLLOCK_MASK		GENMASK(17, 6)
16110a511ceSYann Gautier #define DDRPHYC_PTR0_TITMSRST_OFFSET		18
16210a511ceSYann Gautier #define DDRPHYC_PTR0_TITMSRST_MASK		GENMASK(21, 18)
16310a511ceSYann Gautier 
16410a511ceSYann Gautier #define DDRPHYC_ACIOCR_ACPDD			BIT(3)
16510a511ceSYann Gautier #define DDRPHYC_ACIOCR_ACPDR			BIT(4)
16610a511ceSYann Gautier #define DDRPHYC_ACIOCR_CKPDD_MASK		GENMASK(10, 8)
16710a511ceSYann Gautier #define DDRPHYC_ACIOCR_CKPDD_0			BIT(8)
16810a511ceSYann Gautier #define DDRPHYC_ACIOCR_CKPDR_MASK		GENMASK(13, 11)
16910a511ceSYann Gautier #define DDRPHYC_ACIOCR_CKPDR_0			BIT(11)
17010a511ceSYann Gautier #define DDRPHYC_ACIOCR_CSPDD_MASK		GENMASK(21, 18)
17110a511ceSYann Gautier #define DDRPHYC_ACIOCR_CSPDD_0			BIT(18)
17210a511ceSYann Gautier #define DDRPHYC_ACIOCR_RSTPDD			BIT(27)
17310a511ceSYann Gautier #define DDRPHYC_ACIOCR_RSTPDR			BIT(28)
17410a511ceSYann Gautier 
17510a511ceSYann Gautier #define DDRPHYC_DXCCR_DXPDD			BIT(2)
17610a511ceSYann Gautier #define DDRPHYC_DXCCR_DXPDR			BIT(3)
17710a511ceSYann Gautier 
17810a511ceSYann Gautier #define DDRPHYC_DSGCR_CKEPDD_MASK		GENMASK(19, 16)
17910a511ceSYann Gautier #define DDRPHYC_DSGCR_CKEPDD_0			BIT(16)
18010a511ceSYann Gautier #define DDRPHYC_DSGCR_ODTPDD_MASK		GENMASK(23, 20)
18110a511ceSYann Gautier #define DDRPHYC_DSGCR_ODTPDD_0			BIT(20)
18210a511ceSYann Gautier #define DDRPHYC_DSGCR_NL2PD			BIT(24)
18310a511ceSYann Gautier 
18410a511ceSYann Gautier #define DDRPHYC_ZQ0CRN_ZDATA_MASK		GENMASK(27, 0)
18510a511ceSYann Gautier #define DDRPHYC_ZQ0CRN_ZDATA_SHIFT		0
18610a511ceSYann Gautier #define DDRPHYC_ZQ0CRN_ZDEN			BIT(28)
18710a511ceSYann Gautier #define DDRPHYC_ZQ0CRN_ZQPD			BIT(31)
18810a511ceSYann Gautier 
18910a511ceSYann Gautier #define DDRPHYC_DXNGCR_DXEN			BIT(0)
19010a511ceSYann Gautier 
19110a511ceSYann Gautier #define DDRPHYC_DXNDLLCR_DLLSRST		BIT(30)
19210a511ceSYann Gautier #define DDRPHYC_DXNDLLCR_DLLDIS			BIT(31)
19310a511ceSYann Gautier #define DDRPHYC_DXNDLLCR_SDPHASE_MASK		GENMASK(17, 14)
19410a511ceSYann Gautier #define DDRPHYC_DXNDLLCR_SDPHASE_SHIFT		14
19510a511ceSYann Gautier 
196c3cf06f1SAntonio Nino Diaz #endif /* STM32MP1_DDR_REGS_H */
197