xref: /openbmc/u-boot/arch/arm/include/asm/arch-aspeed/sdram_ast2600.h (revision a77d558c9dc3b0edc974344f278369023e92d005)
14665e277SDylan Hung /* SPDX-License-Identifier: GPL-2.0+ */
24665e277SDylan Hung /*
34665e277SDylan Hung  * Copyright (c) 2016 Google, Inc
44665e277SDylan Hung  */
54665e277SDylan Hung #ifndef _ASM_ARCH_SDRAM_AST2600_H
64665e277SDylan Hung #define _ASM_ARCH_SDRAM_AST2600_H
74665e277SDylan Hung 
8b3c25758SDylan Hung /* keys for unlocking HW */
963d9b49fSDylan Hung #define SDRAM_UNLOCK_KEY		0xFC600309
10956e9a0eSDylan Hung #define SDRAM_VIDEO_UNLOCK_KEY		0x00440003
114665e277SDylan Hung 
12b3c25758SDylan Hung /* Fixed priority DRAM Requests mask */
13b3c25758SDylan Hung #define REQ_PRI_VGA_HW_CURSOR_R         0
14b3c25758SDylan Hung #define REQ_PRI_VGA_CRT_R               1
15b3c25758SDylan Hung #define REQ_PRI_SOC_DISPLAY_CTRL_R      2
16b3c25758SDylan Hung #define REQ_PRI_PCIE_BUS1_RW            3
17b3c25758SDylan Hung #define REQ_PRI_VIDEO_HIGH_PRI_W        4
18b3c25758SDylan Hung #define REQ_PRI_CPU_RW                  5
19b3c25758SDylan Hung #define REQ_PRI_SLI_RW                  6
20b3c25758SDylan Hung #define REQ_PRI_PCIE_BUS2_RW            7
21b3c25758SDylan Hung #define REQ_PRI_USB2_0_HUB_EHCI1_DMA_RW 8
22b3c25758SDylan Hung #define REQ_PRI_USB2_0_DEV_EHCI2_DMA_RW 9
23b3c25758SDylan Hung #define REQ_PRI_USB1_1_UHCI_HOST_RW     10
24b3c25758SDylan Hung #define REQ_PRI_AHB_BUS_RW              11
25b3c25758SDylan Hung #define REQ_PRI_CM3_DATA_RW             12
26b3c25758SDylan Hung #define REQ_PRI_CM3_INST_R              13
27b3c25758SDylan Hung #define REQ_PRI_MAC0_DMA_RW             14
28b3c25758SDylan Hung #define REQ_PRI_MAC1_DMA_RW             15
29b3c25758SDylan Hung #define REQ_PRI_SDIO_DMA_RW             16
30b3c25758SDylan Hung #define REQ_PRI_PILOT_ENGINE_RW         17
31b3c25758SDylan Hung #define REQ_PRI_XDMA1_RW                18
32b3c25758SDylan Hung #define REQ_PRI_MCTP1_RW                19
33b3c25758SDylan Hung #define REQ_PRI_VIDEO_FLAG_RW           20
34b3c25758SDylan Hung #define REQ_PRI_VIDEO_LOW_PRI_W         21
35b3c25758SDylan Hung #define REQ_PRI_2D_ENGINE_DATA_RW       22
36b3c25758SDylan Hung #define REQ_PRI_ENC_ENGINE_RW           23
37b3c25758SDylan Hung #define REQ_PRI_MCTP2_RW                24
38b3c25758SDylan Hung #define REQ_PRI_XDMA2_RW                25
39b3c25758SDylan Hung #define REQ_PRI_ECC_RSA_RW              26
40b3c25758SDylan Hung 
41cd4a75e9SDylan Hung #define MCR30_RESET_DLL_DELAY_EN	BIT(4)
42cd4a75e9SDylan Hung #define MCR30_MODE_REG_SEL_SHIFT	1
43abeb6036SDylan Hung #define MCR30_MODE_REG_SEL_MASK		GENMASK(3, 1)
44cd4a75e9SDylan Hung #define MCR30_SET_MODE_REG		BIT(0)
45cd4a75e9SDylan Hung 
46e3b40f11SDylan Hung #define MCR30_SET_MR(mr) ((mr << MCR30_MODE_REG_SEL_SHIFT) | MCR30_SET_MODE_REG)
47cd4a75e9SDylan Hung 
48abeb6036SDylan Hung #define MCR34_SELF_REFRESH_STATUS_MASK	GENMASK(30, 28)
4963d9b49fSDylan Hung 
5063d9b49fSDylan Hung #define MCR34_ODT_DELAY_SHIFT		12
51abeb6036SDylan Hung #define MCR34_ODT_DELAY_MASK		GENMASK(15, 12)
5263d9b49fSDylan Hung #define MCR34_ODT_EXT_SHIFT		10
53abeb6036SDylan Hung #define MCR34_ODT_EXT_MASK		GENMASK(11, 10)
54abeb6036SDylan Hung #define MCR34_ODT_AUTO_ON		BIT(9)
55abeb6036SDylan Hung #define MCR34_ODT_EN			BIT(8)
56abeb6036SDylan Hung #define MCR34_RESETN_DIS		BIT(7)
57abeb6036SDylan Hung #define MCR34_MREQI_DIS			BIT(6)
58abeb6036SDylan Hung #define MCR34_MREQ_BYPASS_DIS		BIT(5)
59abeb6036SDylan Hung #define MCR34_RGAP_CTRL_EN		BIT(4)
60abeb6036SDylan Hung #define MCR34_CKE_OUT_IN_SELF_REF_DIS	BIT(3)
61abeb6036SDylan Hung #define MCR34_FOURCE_SELF_REF_EN	BIT(2)
62abeb6036SDylan Hung #define MCR34_AUTOPWRDN_EN		BIT(1)
63abeb6036SDylan Hung #define MCR34_CKE_EN			BIT(0)
6463d9b49fSDylan Hung 
65b3c25758SDylan Hung #define MCR38_RW_MAX_GRANT_CNT_RQ_SHIFT	16
66abeb6036SDylan Hung #define MCR38_RW_MAX_GRANT_CNT_RQ_MASK	GENMASK(20, 16)
674665e277SDylan Hung 
68b3c25758SDylan Hung /* default request queued limitation mask (0xFFBBFFF4) */
69b3c25758SDylan Hung #define MCR3C_DEFAULT_MASK                                                     \
70b3c25758SDylan Hung 	~(REQ_PRI_VGA_HW_CURSOR_R | REQ_PRI_VGA_CRT_R | REQ_PRI_PCIE_BUS1_RW | \
71b3c25758SDylan Hung 	  REQ_PRI_XDMA1_RW | REQ_PRI_2D_ENGINE_DATA_RW)
724665e277SDylan Hung 
73abeb6036SDylan Hung #define MCR50_RESET_ALL_INTR		BIT(31)
74d6f57adbSDylan Hung #define SDRAM_CONF_ECC_AUTO_SCRUBBING	BIT(9)
75abeb6036SDylan Hung #define SDRAM_CONF_SCRAMBLE		BIT(8)
76abeb6036SDylan Hung #define SDRAM_CONF_ECC_EN		BIT(7)
77abeb6036SDylan Hung #define SDRAM_CONF_DUALX8		BIT(5)
78abeb6036SDylan Hung #define SDRAM_CONF_DDR4			BIT(4)
797a45b4a0SDylan Hung #define SDRAM_CONF_VGA_SIZE_SHIFT	2
806667c99aSDylan Hung #define SDRAM_CONF_VGA_SIZE_MASK	GENMASK(3, 2)
814665e277SDylan Hung #define SDRAM_CONF_CAP_SHIFT		0
826667c99aSDylan Hung #define SDRAM_CONF_CAP_MASK		GENMASK(1, 0)
834665e277SDylan Hung 
84a3d01e86SDylan Hung #define SDRAM_CONF_CAP_256M		0
85a3d01e86SDylan Hung #define SDRAM_CONF_CAP_512M		1
86a3d01e86SDylan Hung #define SDRAM_CONF_CAP_1024M		2
87a3d01e86SDylan Hung #define SDRAM_CONF_CAP_2048M		3
88589d5c0cSDylan Hung #define SDRAM_CONF_ECC_SETUP		(SDRAM_CONF_ECC_AUTO_SCRUBBING | SDRAM_CONF_ECC_EN)
894665e277SDylan Hung 
904665e277SDylan Hung #define SDRAM_MISC_DDR4_TREFRESH	(1 << 3)
914665e277SDylan Hung 
927a45b4a0SDylan Hung #define SDRAM_PHYCTRL0_PLL_LOCKED	BIT(4)
937a45b4a0SDylan Hung #define SDRAM_PHYCTRL0_NRST		BIT(2)
947a45b4a0SDylan Hung #define SDRAM_PHYCTRL0_INIT		BIT(0)
954665e277SDylan Hung 
96abeb6036SDylan Hung /* MCR0C */
97cd4a75e9SDylan Hung #define SDRAM_REFRESH_PERIOD_ZQCS_SHIFT	16
98abeb6036SDylan Hung #define SDRAM_REFRESH_PERIOD_ZQCS_MASK	GENMASK(31, 16)
994665e277SDylan Hung #define SDRAM_REFRESH_PERIOD_SHIFT	8
100abeb6036SDylan Hung #define SDRAM_REFRESH_PERIOD_MASK	GENMASK(15, 8)
101cd4a75e9SDylan Hung #define SDRAM_REFRESH_ZQCS_EN		BIT(7)
102cd4a75e9SDylan Hung #define SDRAM_RESET_DLL_ZQCL_EN		BIT(6)
103cd4a75e9SDylan Hung #define SDRAM_LOW_PRI_REFRESH_EN	BIT(5)
104cd4a75e9SDylan Hung #define SDRAM_FORCE_PRECHARGE_EN	BIT(4)
105cd4a75e9SDylan Hung #define SDRAM_REFRESH_EN		BIT(0)
1064665e277SDylan Hung 
107*a77d558cSDylan Hung /* MCR14 */
108*a77d558cSDylan Hung #define SDRAM_WL_SETTING		GENMASK(23, 20)
109*a77d558cSDylan Hung #define SDRAM_CL_SETTING		GENMASK(19, 16)
110*a77d558cSDylan Hung 
1114665e277SDylan Hung #define SDRAM_TEST_LEN_SHIFT		4
1124665e277SDylan Hung #define SDRAM_TEST_LEN_MASK		0xfffff
1134665e277SDylan Hung #define SDRAM_TEST_START_ADDR_SHIFT	24
1144665e277SDylan Hung #define SDRAM_TEST_START_ADDR_MASK	0x3f
1154665e277SDylan Hung 
1164665e277SDylan Hung #define SDRAM_TEST_EN			(1 << 0)
1174665e277SDylan Hung #define SDRAM_TEST_MODE_SHIFT		1
118e3b40f11SDylan Hung #define SDRAM_TEST_MODE_MASK		(0x3 << SDRAM_TEST_MODE_SHIFT)
119e3b40f11SDylan Hung #define SDRAM_TEST_MODE_WO		(0x0 << SDRAM_TEST_MODE_SHIFT)
120e3b40f11SDylan Hung #define SDRAM_TEST_MODE_RB		(0x1 << SDRAM_TEST_MODE_SHIFT)
121e3b40f11SDylan Hung #define SDRAM_TEST_MODE_RW		(0x2 << SDRAM_TEST_MODE_SHIFT)
122e3b40f11SDylan Hung 
1234665e277SDylan Hung #define SDRAM_TEST_GEN_MODE_SHIFT	3
124e3b40f11SDylan Hung #define SDRAM_TEST_GEN_MODE_MASK	(7 << SDRAM_TEST_GEN_MODE_SHIFT)
1254665e277SDylan Hung #define SDRAM_TEST_TWO_MODES		(1 << 6)
1264665e277SDylan Hung #define SDRAM_TEST_ERRSTOP		(1 << 7)
1274665e277SDylan Hung #define SDRAM_TEST_DONE			(1 << 12)
1284665e277SDylan Hung #define SDRAM_TEST_FAIL			(1 << 13)
1294665e277SDylan Hung 
1304665e277SDylan Hung #define SDRAM_AC_TRFC_SHIFT		0
1314665e277SDylan Hung #define SDRAM_AC_TRFC_MASK		0xff
1324665e277SDylan Hung 
1334665e277SDylan Hung #ifndef __ASSEMBLY__
1344665e277SDylan Hung 
1354665e277SDylan Hung struct ast2600_sdrammc_regs {
136a3d01e86SDylan Hung 	u32 protection_key;		/* offset 0x00 */
137a3d01e86SDylan Hung 	u32 config;			/* offset 0x04 */
138a3d01e86SDylan Hung 	u32 gm_protection_key;		/* offset 0x08 */
139a3d01e86SDylan Hung 	u32 refresh_timing;		/* offset 0x0C */
140a3d01e86SDylan Hung 	u32 ac_timing[4];		/* offset 0x10 ~ 0x1C */
141a3d01e86SDylan Hung 	u32 mr01_mode_setting;		/* offset 0x20 */
142a3d01e86SDylan Hung 	u32 mr23_mode_setting;		/* offset 0x24 */
143a3d01e86SDylan Hung 	u32 mr45_mode_setting;		/* offset 0x28 */
144a3d01e86SDylan Hung 	u32 mr6_mode_setting;		/* offset 0x2C */
145a3d01e86SDylan Hung 	u32 mode_setting_control;	/* offset 0x30 */
146a3d01e86SDylan Hung 	u32 power_ctrl;			/* offset 0x34 */
147a3d01e86SDylan Hung 	u32 arbitration_ctrl;		/* offset 0x38 */
148b3c25758SDylan Hung 	u32 req_limit_mask;		/* offset 0x3C */
149b3c25758SDylan Hung 	u32 max_grant_len[4];		/* offset 0x40 ~ 0x4C */
150b3c25758SDylan Hung 	u32 intr_ctrl;			/* offset 0x50 */
151b3c25758SDylan Hung 	u32 ecc_range_ctrl;		/* offset 0x54 */
152b3c25758SDylan Hung 	u32 first_ecc_err_addr;		/* offset 0x58 */
153b3c25758SDylan Hung 	u32 last_ecc_err_addr;		/* offset 0x5C */
154b3c25758SDylan Hung 	u32 phy_ctrl[4];		/* offset 0x60 ~ 0x6C */
155b3c25758SDylan Hung 	u32 ecc_test_ctrl;		/* offset 0x70 */
156b3c25758SDylan Hung 	u32 test_addr;			/* offset 0x74 */
157b3c25758SDylan Hung 	u32 test_fail_dq_bit;		/* offset 0x78 */
158b3c25758SDylan Hung 	u32 test_init_val;		/* offset 0x7C */
159b3c25758SDylan Hung 	u32 req_input_ctrl;		/* offset 0x80 */
160b3c25758SDylan Hung 	u32 req_high_pri_ctrl;		/* offset 0x84 */
161635b2a54SDylan Hung 	u32 reserved0[6];		/* offset 0x88 ~ 0x9C */
1624665e277SDylan Hung };
1634665e277SDylan Hung 
1644665e277SDylan Hung #endif  /* __ASSEMBLY__ */
1654665e277SDylan Hung 
1664665e277SDylan Hung #endif  /* _ASM_ARCH_SDRAM_AST2600_H */
167