blob: 7091d30ff03b7c0c2131af2bc5e3904ddff5dbf6 [file] [log] [blame]
Googler695f9d92023-09-11 15:38:29 +08001/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2/*
3 * arch/arm/include/asm/arch-txhd/ddr_define.h
4 *
5 * Copyright (C) 2020 Amlogic, Inc. All rights reserved.
6 *
7 */
8
9#define CONFIG_DDR_TYPE_DDR3 0
10#define CONFIG_DDR_TYPE_DDR4 1
11#define CONFIG_DDR_TYPE_LPDDR3 2
12#define CONFIG_DDR_TYPE_LPDDR2 3
13#define CONFIG_DDR_TYPE_AUTO 0xf /* support ddr3/ddr4 */
14
15/* ddr channel defines */
16#define CONFIG_DDR0_16BIT 1
17#define CONFIG_DDR0_RANK0 2
18#define CONFIG_DDR0_RANK01 3
19#define CONFIG_DDR0_16BIT_2 4
20/* CONFIG_DDR_CHL_AUTO mode support RANK0 and RANK0+1 mode auto detect */
21#define CONFIG_DDR_CHL_AUTO 0xF
22
23#define CFG_DDR_BASE_ADDR 0X0
24#define CFG_DDR_START_OFFSET 0X00000000 //TXLX SKIP 0MB
25
26/* ddr type identifier */
27#define CONFIG_DDR_TIMMING_LPDDR2 0x02
28#define CONFIG_DDR_TIMMING_LPDDR3 0x03
29#define CONFIG_DDR_TIMMING_DDR3_7 0x07
30#define CONFIG_DDR_TIMMING_DDR3_9 0x09
31#define CONFIG_DDR_TIMMING_DDR3_11 0x0B
32#define CONFIG_DDR_TIMMING_DDR3_12 0x0C
33#define CONFIG_DDR_TIMMING_DDR3_13 0x0D
34#define CONFIG_DDR_TIMMING_DDR3_14 0x0E
35
36#define CONFIG_DDR_TIMMING_DDR4_1600 0x0F
37#define CONFIG_DDR_TIMMING_DDR4_1866 0x10
38#define CONFIG_DDR_TIMMING_DDR4_2133 0x11
39#define CONFIG_DDR_TIMMING_DDR4_2400 0x12
40#define CONFIG_DDR_TIMMING_DDR4_2666 0x13
41#define CONFIG_DDR_TIMMING_DDR4_3200 0x14
42
43#define CONFIG_DDR_FUNC_TEST (1<<0)
44
45#define CONFIG_DDR_INIT_RETRY_TOTAL (10)
46#define CONFIG_DDR_PCTL_RETRY_TOTAL (100)
47
48#define DDR_USE_1_RANK(chl_set) ((chl_set == CONFIG_DDR0_RANK0) || \
49 (chl_set == CONFIG_DDR0_16BIT))
50#define DDR_USE_2_RANK(chl_set) ((chl_set == CONFIG_DDR0_RANK01))
51
52/* DMC_DDR_CTRL defines */
53#define DDR_DDR4_ENABLE (1<<22)
54#define DDR_RANK1_ENABLE (1<<21)
55#define DDR_DDR4_BG_ENABLE (1<<20)
56#define DDR_16BIT_ENABLE (1<<16)
57
58#define DDR_RANK1_SIZE_CTRL (3)
59#define DDR_RANK0_SIZE_CTRL (0)
60
61
62/* how to add a new ddr function?
63 1. add CONFIG_DDR_FUNC_XXX in (config).h file
64 2. add define in this file.
65 2.1 add
66 #ifndef CONFIG_DDR_FUNC_XXX
67 #define CONFIG_DDR_FUNC_XXX 0
68 #endif
69 2.2 add
70 #define DDR_FUNC_XXX (CONFIG_FUNC_XXX<<X)
71 2.3 add DDR_FUNC_XXX |\ in DDR_FUNC
72 3. add same define and parser in bl2 code
73 */
74/* 2.1, 2,2, 2,3 example */
75/*
76#ifndef CONFIG_CMD_DDR_D2PLL
77#define CONFIG_CMD_DDR_D2PLL 0
78#endif
79#define DDR_FUNC_D2PLL (CONFIG_CMD_DDR_D2PLL<<0)
80#define DDR_FUNC (EXISTING_FUNCTIONS) |\
81 (DDR_FUNC_D2PLL)
82*/
83
84/* d2pll support */
85#ifndef CONFIG_CMD_DDR_D2PLL
86#define CONFIG_CMD_DDR_D2PLL 0
87#endif
88#define DDR_FUNC_D2PLL (CONFIG_CMD_DDR_D2PLL<<0)
89
90/* ddr low power function support */
91#ifndef CONFIG_DDR_LOW_POWER
92#define CONFIG_DDR_LOW_POWER 0
93#endif
94#define DDR_FUNC_LP (CONFIG_DDR_LOW_POWER<<1)
95
96/* ddr zq power down support */
97#ifndef CONFIG_DDR_ZQ_PD
98#define CONFIG_DDR_ZQ_PD 0
99#endif
100#define DDR_FUNC_ZQ_PD (CONFIG_DDR_ZQ_PD<<2)
101
102/* ddr vref function */
103#ifndef CONFIG_DDR_USE_EXT_VREF
104#define CONFIG_DDR_USE_EXT_VREF 0
105#endif
106#define DDR_FUNC_EXT_VREF (CONFIG_DDR_USE_EXT_VREF<<3)
107
108/* ddr4 timing test function */
109#ifndef CONFIG_DDR4_TIMING_TEST
110#define CONFIG_DDR4_TIMING_TEST 0
111#endif
112#define DDR_FUNC_DDR4_TIMING_TEST (CONFIG_DDR4_TIMING_TEST<<4)
113
114/* ddr pll bypass */
115#ifndef CONFIG_DDR_PLL_BYPASS
116#define CONFIG_DDR_PLL_BYPASS 0
117#endif
118#define DDR_FUNC_DDR_PLL_BYPASS (CONFIG_DDR_PLL_BYPASS<<5)
119
120/* ddr rdbi function */
121#ifndef CONFIG_DDR_FUNC_RDBI
122#define CONFIG_DDR_FUNC_RDBI 0
123#endif
124#define DDR_FUNC_RDBI (CONFIG_DDR_FUNC_RDBI<<6)
125
126/* print ddr training window */
127#ifndef CONFIG_DDR_FUNC_PRINT_WINDOW
128#define CONFIG_DDR_FUNC_PRINT_WINDOW 0
129#endif
130#define DDR_FUNC_PRINT_WINDOW (CONFIG_DDR_FUNC_PRINT_WINDOW<<7)
131
132#define DDR_FUNC (DDR_FUNC_D2PLL | \
133 DDR_FUNC_LP | \
134 DDR_FUNC_ZQ_PD | \
135 DDR_FUNC_EXT_VREF | \
136 DDR_FUNC_DDR4_TIMING_TEST | \
137 DDR_FUNC_DDR_PLL_BYPASS | \
138 DDR_FUNC_RDBI | \
139 DDR_FUNC_PRINT_WINDOW | \
140 (1 << 31) \
141 )