1 /*
2  * Copyright (C) 2011
3  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 #ifndef _DV_DDR2_DEFS_H_
8 #define _DV_DDR2_DEFS_H_
9 
10 /*
11  * DDR2 Memory Ctrl Register structure
12  * See sprueh7d.pdf for more details.
13  */
14 struct dv_ddr2_regs_ctrl {
15 	unsigned char	rsvd0[4];	/* 0x00 */
16 	unsigned int	sdrstat;	/* 0x04 */
17 	unsigned int	sdbcr;		/* 0x08 */
18 	unsigned int	sdrcr;		/* 0x0C */
19 	unsigned int	sdtimr;		/* 0x10 */
20 	unsigned int	sdtimr2;	/* 0x14 */
21 	unsigned char	rsvd1[4];	/* 0x18 */
22 	unsigned int	sdbcr2;		/* 0x1C */
23 	unsigned int	pbbpr;		/* 0x20 */
24 	unsigned char	rsvd2[156];	/* 0x24 */
25 	unsigned int	irr;		/* 0xC0 */
26 	unsigned int	imr;		/* 0xC4 */
27 	unsigned int	imsr;		/* 0xC8 */
28 	unsigned int	imcr;		/* 0xCC */
29 	unsigned char	rsvd3[20];	/* 0xD0 */
30 	unsigned int	ddrphycr;	/* 0xE4 */
31 	unsigned int	ddrphycr2;	/* 0xE8 */
32 	unsigned char	rsvd4[4];	/* 0xEC */
33 };
34 
35 #define DV_DDR_PHY_PWRDNEN		0x40
36 #define DV_DDR_PHY_EXT_STRBEN	0x80
37 #define DV_DDR_PHY_RD_LATENCY_SHIFT	0
38 
39 #define DV_DDR_SDTMR1_RFC_SHIFT	25
40 #define DV_DDR_SDTMR1_RP_SHIFT	22
41 #define DV_DDR_SDTMR1_RCD_SHIFT	19
42 #define DV_DDR_SDTMR1_WR_SHIFT	16
43 #define DV_DDR_SDTMR1_RAS_SHIFT	11
44 #define DV_DDR_SDTMR1_RC_SHIFT	6
45 #define DV_DDR_SDTMR1_RRD_SHIFT	3
46 #define DV_DDR_SDTMR1_WTR_SHIFT	0
47 
48 #define DV_DDR_SDTMR2_RASMAX_SHIFT	27
49 #define DV_DDR_SDTMR2_XP_SHIFT	25
50 #define DV_DDR_SDTMR2_ODT_SHIFT	23
51 #define DV_DDR_SDTMR2_XSNR_SHIFT	16
52 #define DV_DDR_SDTMR2_XSRD_SHIFT	8
53 #define DV_DDR_SDTMR2_RTP_SHIFT	5
54 #define DV_DDR_SDTMR2_CKE_SHIFT	0
55 
56 #define DV_DDR_SDCR_DDR2TERM1_SHIFT	27
57 #define DV_DDR_SDCR_IBANK_POS_SHIFT	26
58 #define DV_DDR_SDCR_MSDRAMEN_SHIFT	25
59 #define DV_DDR_SDCR_DDRDRIVE1_SHIFT	24
60 #define DV_DDR_SDCR_BOOTUNLOCK_SHIFT	23
61 #define DV_DDR_SDCR_DDR_DDQS_SHIFT	22
62 #define DV_DDR_SDCR_DDR2EN_SHIFT	20
63 #define DV_DDR_SDCR_DDRDRIVE0_SHIFT	18
64 #define DV_DDR_SDCR_DDREN_SHIFT	17
65 #define DV_DDR_SDCR_SDRAMEN_SHIFT	16
66 #define DV_DDR_SDCR_TIMUNLOCK_SHIFT	15
67 #define DV_DDR_SDCR_BUS_WIDTH_SHIFT	14
68 #define DV_DDR_SDCR_CL_SHIFT		9
69 #define DV_DDR_SDCR_IBANK_SHIFT	4
70 #define DV_DDR_SDCR_PAGESIZE_SHIFT	0
71 
72 #define DV_DDR_SDRCR_LPMODEN	(1 << 31)
73 #define DV_DDR_SDRCR_MCLKSTOPEN	(1 << 30)
74 
75 #define DV_DDR_SRCR_LPMODEN_SHIFT	31
76 #define DV_DDR_SRCR_MCLKSTOPEN_SHIFT	30
77 
78 #define DV_DDR_BOOTUNLOCK	(1 << DV_DDR_SDCR_BOOTUNLOCK_SHIFT)
79 #define DV_DDR_TIMUNLOCK	(1 << DV_DDR_SDCR_TIMUNLOCK_SHIFT)
80 
81 #define dv_ddr2_regs_ctrl \
82 	((struct dv_ddr2_regs_ctrl *)DAVINCI_DDR_EMIF_CTRL_BASE)
83 
84 #endif /* _DV_DDR2_DEFS_H_ */
85