1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) Marvell International Ltd. and its affiliates
4  */
5 
6 #ifndef _DDR3_TRAINING_IP_DEF_H
7 #define _DDR3_TRAINING_IP_DEF_H
8 
9 #define PATTERN_55			0x55555555
10 #define PATTERN_AA			0xaaaaaaaa
11 #define PATTERN_80			0x80808080
12 #define PATTERN_20			0x20202020
13 #define PATTERN_01			0x01010101
14 #define PATTERN_FF			0xffffffff
15 #define PATTERN_00			0x00000000
16 
17 /* 16bit bus width patterns */
18 #define PATTERN_55AA			0x5555aaaa
19 #define PATTERN_00FF			0x0000ffff
20 #define PATTERN_0080			0x00008080
21 
22 #define INVALID_VALUE			0xffffffff
23 #define MAX_NUM_OF_DUNITS		32
24 /*
25  * length *2 = length in words of pattern, first low address,
26  * second high address
27  */
28 #define TEST_PATTERN_LENGTH		4
29 #define KILLER_PATTERN_DQ_NUMBER	8
30 #define SSO_DQ_NUMBER			4
31 #define PATTERN_MAXIMUM_LENGTH		64
32 #define ADLL_TX_LENGTH			64
33 #define ADLL_RX_LENGTH			32
34 
35 #define PARAM_NOT_CARE			0
36 #define PARAM_UNDEFINED			0xffffffff
37 
38 #define READ_LEVELING_PHY_OFFSET	2
39 #define WRITE_LEVELING_PHY_OFFSET	0
40 
41 #define MASK_ALL_BITS			0xffffffff
42 
43 #define CS_BIT_MASK			0xf
44 
45 /* DFX access */
46 #define BROADCAST_ID			28
47 #define MULTICAST_ID			29
48 
49 #define XSB_BASE_ADDR			0x00004000
50 #define XSB_CTRL_0_REG			0x00000000
51 #define XSB_CTRL_1_REG			0x00000004
52 #define XSB_CMD_REG			0x00000008
53 #define XSB_ADDRESS_REG			0x0000000c
54 #define XSB_DATA_REG			0x00000010
55 #define PIPE_ENABLE_ADDR		0x000f8000
56 #define ENABLE_DDR_TUNING_ADDR		0x000f829c
57 
58 #define CLIENT_BASE_ADDR		0x00002000
59 #define CLIENT_CTRL_REG			0x00000000
60 
61 #define TARGET_INT			0x1801
62 #define TARGET_EXT			0x180e
63 #define BYTE_EN				0
64 #define CMD_READ			0
65 #define CMD_WRITE			1
66 
67 #define INTERNAL_ACCESS_PORT		1
68 #define EXECUTING			1
69 #define ACCESS_EXT			1
70 #define CS2_EXIST_BIT			2
71 #define TRAINING_ID			0xf
72 #define EXT_TRAINING_ID			1
73 #define EXT_MODE			0x4
74 
75 #define GET_RESULT_STATE(res)		(res)
76 #define SET_RESULT_STATE(res, state)	(res = state)
77 
78 #define ADDR_SIZE_512MB			0x04000000
79 #define ADDR_SIZE_1GB			0x08000000
80 #define ADDR_SIZE_2GB			0x10000000
81 #define ADDR_SIZE_4GB			0x20000000
82 #define ADDR_SIZE_8GB			0x40000000
83 
84 enum hws_edge_compare {
85 	EDGE_PF,
86 	EDGE_FP,
87 	EDGE_FPF,
88 	EDGE_PFP
89 };
90 
91 enum hws_control_element {
92 	HWS_CONTROL_ELEMENT_ADLL,		/* per bit 1 edge */
93 	HWS_CONTROL_ELEMENT_DQ_SKEW,
94 	HWS_CONTROL_ELEMENT_DQS_SKEW
95 };
96 
97 enum hws_search_dir {
98 	HWS_LOW2HIGH,
99 	HWS_HIGH2LOW,
100 	HWS_SEARCH_DIR_LIMIT
101 };
102 
103 enum hws_operation {
104 	OPERATION_READ = 0,
105 	OPERATION_WRITE = 1
106 };
107 
108 enum hws_training_ip_stat {
109 	HWS_TRAINING_IP_STATUS_FAIL,
110 	HWS_TRAINING_IP_STATUS_SUCCESS,
111 	HWS_TRAINING_IP_STATUS_TIMEOUT
112 };
113 
114 enum hws_ddr_cs {
115 	CS_SINGLE,
116 	CS_NON_SINGLE
117 };
118 
119 enum hws_ddr_phy {
120 	DDR_PHY_DATA = 0,
121 	DDR_PHY_CONTROL = 1
122 };
123 
124 enum hws_dir {
125 	OPER_WRITE,
126 	OPER_READ,
127 	OPER_WRITE_AND_READ
128 };
129 
130 enum hws_wl_supp {
131 	PHASE_SHIFT,
132 	CLOCK_SHIFT,
133 	ALIGN_SHIFT
134 };
135 
136 enum  mv_ddr_tip_bit_state {
137 	BIT_LOW_UI,
138 	BIT_HIGH_UI,
139 	BIT_SPLIT_IN,
140 	BIT_SPLIT_OUT,
141 	BIT_STATE_LAST
142 };
143 
144 enum  mv_ddr_tip_byte_state{
145 	BYTE_NOT_DEFINED,
146 	BYTE_HOMOGENEOUS_LOW = 0x1,
147 	BYTE_HOMOGENEOUS_HIGH = 0x2,
148 	BYTE_HOMOGENEOUS_SPLIT_IN = 0x4,
149 	BYTE_HOMOGENEOUS_SPLIT_OUT = 0x8,
150 	BYTE_SPLIT_OUT_MIX = 0x10,
151 	BYTE_STATE_LAST
152 };
153 
154 struct reg_data {
155 	unsigned int reg_addr;
156 	unsigned int reg_data;
157 	unsigned int reg_mask;
158 };
159 
160 enum dm_direction {
161 	DM_DIR_INVERSE,
162 	DM_DIR_DIRECT
163 };
164 
165 #endif /* _DDR3_TRAINING_IP_DEF_H */
166