xref: /openbmc/u-boot/cmd/aspeed/dptest.h (revision f586eef6)
1 /* SPDX-License-Identifier: GPL-2.0+
2  *
3  * Copyright (C) ASPEED Technology Inc.
4  */
5 
6 /* Define register */
7 /* MCU */
8 #define SYS_REST		0x1e6e2040
9 #define SYS_REST_CLR		0x1e6e2044
10 
11 /* DP TX */
12 #define DP_TX_INT_CLEAR		0x1e6eb040
13 #define DP_TX_INT_STATUS	0x1e6eb044
14 
15 #define DP_TX_IRQ_CFG		0x1e6eb080
16 #define DP_TX_EVENT_CFG		0x1e6eb084
17 
18 #define DP_AUX_REQ_CFG		0x1e6eb088
19 #define DP_AUX_ADDR_LEN		0x1e6eb08c
20 #define DP_AUX_STATUS		0x1e6eb0b0
21 
22 #define DP_AUX_W_D_0		0x1e6eb090
23 #define DP_AUX_W_D_4		0x1e6eb094
24 #define DP_AUX_W_D_8		0x1e6eb098
25 #define DP_AUX_W_D_C		0x1e6eb09c
26 
27 #define DP_AUX_R_D_0		0x1e6eb0a0
28 #define DP_AUX_R_D_4		0x1e6eb0a4
29 #define DP_AUX_R_D_8		0x1e6eb0a8
30 #define DP_AUX_R_D_C		0x1e6eb0ac
31 
32 #define DP_TX_MAIN_SET		0x1e6eb0c0
33 #define DP_TX_MAIN_PAT		0x1e6eb0e4
34 #define DP_TX_PHY_PAT		0x1e6eb0e8
35 #define DP_TX_CUS_PAT_0		0x1e6eb0ec
36 #define DP_TX_CUS_PAT_1		0x1e6eb0f0
37 #define DP_TX_CUS_PAT_2		0x1e6eb0f4
38 #define DP_TX_MAIN_CFG		0x1e6eb0fc
39 #define DP_TX_PHY_SET		0x1e6eb104
40 #define DP_TX_PHY_CFG		0x1e6eb108
41 #define DP_TX_RES_CFG		0x1e6eb118
42 
43 /* i2c control */
44 #define MP_SCU410		0x1e6e2410
45 #define MP_SCU414		0x1e6e2414
46 #define MP_SCU418		0x1e6e2418
47 #define MP_SCU4b0		0x1e6e24b0
48 #define MP_SCU4b4		0x1e6e24b4
49 #define MP_SCU4b8		0x1e6e24b8
50 
51 #define I2C_GBASE		0x1e78a000
52 #define I2C_DEV_OFFSET		0x80
53 
54 #define I2C0_BASE		0x1e78a080
55 #define I2C0_TIMMING_O		0x04
56 #define I2C0_COUNT_O		0x0c
57 #define I2C0_INT_O		0x10
58 #define I2C0_INT_STATUS_O	0x14
59 #define I2C0_EXECUTE_O		0x18
60 
61 #define I2C0_BUFF		0x1e78ac00
62 #define I2C_BUFF_OFFSET		0x20
63 
64 /* Re-driver setting  */
65 #define RD_EQ3			0x80
66 #define RD_EQ2			0x40
67 #define RD_EQ1			0x20
68 #define RD_EQ0			0x10
69 #define RD_FG1			0x08
70 #define RD_FG0			0x04
71 #define RD_SW1			0x02
72 #define RD_SW0			0x01
73 
74 /* Aux write command */
75 #define AUX_CMD_W		0x80000010
76 
77 /* Aux read command */
78 #define AUX_CMD_R		0x90000010
79 
80 /* I2C write over AUX command with MOT */
81 #define I2C_M_CMD_W		0x40000010
82 /* I2C write over AUX command with MOT and stop by addr */
83 #define I2C_M_EA_CMD_W	0x40010010
84 
85 /* I2C read over AUX command with MOT */
86 #define I2C_M_CMD_R		0x50000010
87 /* I2C read over AUX command with MOT and stop by addr */
88 #define I2C_M_EA_CMD_R		0x50010010
89 
90 /* I2C write over AUX command */
91 #define I2C_CMD_W		0x00000010
92 /* I2C write over AUX command stop by addr */
93 #define I2C_EA_CMD_W		0x00010010
94 
95 /* I2C read over AUX command */
96 #define I2C_CMD_R		0x10000010
97 /* I2C read over AUX command stop by addr */
98 #define I2C_EA_CMD_R		0x10010010
99 
100 #define AUX_CMD_TIMEOUT		0x8000
101 #define AUX_CMD_DONE		0x4000
102 
103 /* DP Rate / Lane */
104 #define DP_RATE_1_62		0x0000
105 #define DP_RATE_2_70		0x0100
106 #define DP_RATE_5_40		0x0200
107 
108 /* DP Deemphasis setting */
109 #define DP_DEEMP_0		0x00000000
110 #define DP_DEEMP_1		0x11000000
111 #define DP_DEEMP_2		0x22000000
112 
113 /* DP Main link SSCG setting */
114 #define DP_SSCG_ON		0x00000010
115 #define DP_SSCG_OFF		0x00000000
116 
117 /* Status */
118 #define DP_TX_RDY_TEST		0x11003300
119 #define DP_PHY_INIT_CFG		0x00113021
120 #define DP_TX_PAT_HBR2		0x00050100
121 #define DP_TX_PAT_TPS1		0x10000100
122 
123 #define DP_TX_PLTPAT_0		0x3e0f83e0
124 #define DP_TX_PLTPAT_1		0x0f83e0f8
125 #define DP_TX_PLTPAT_2		0x0000f83e
126 
127 #define DP_PY_PAT		0x00000642
128 #define DP_PY_PAT_PRB7		0x01000000
129 #define DP_PY_PAT_SCRB		0x00001000
130 #define DP_PY_PAT_CUS		0x10000000
131 
132 #define DP_TX_MAIN_NOR		0x00000020
133 #define DP_TX_MAIN_ADV		0x00001020
134 #define DP_TX_PY_RESET		0x00000001
135 #define DP_TX_MAIN_TRA		0x03000000
136 #define DP_TX_RDY_25201		0x00000200
137 
138 #define DP_TX_HIGH_SPEED	0x000C0000
139 #define DP_TX_NOR_SPEED		0x00000000
140 
141 #define DP_TX_D_INT_CFG		0x00C00000
142 #define DP_TX_A_INT_CFG		0x00F80000
143 
144 /* Flag */
145 #define F_EMPHASIS_NULL		0x00000001	// No emphasis	: 2
146 #define F_EMPHASIS		0x00000002	// Emphasis	: 1-0-2
147 #define F_EMPHASIS_1		0x00000004	// Emphasis 1	: 2-0-1
148 #define F_RES_HIGH		0x00000008
149 #define F_PAT_PRBS7		0x00000010	// PRBS7 pattern
150 #define F_PAT_PLTPAT		0x00000020	// PLTPAT pattern
151 #define F_PAT_HBR2CPAT		0x00000040	// HBR2CPAT pattern
152 #define F_PAT_D10_2		0x00000080	// D10_2 and TPS1 pattern
153 #define F_PAT_AUX		0x00000100	// Aux testing pattern
154 #define F_SHOW_SWING		0x00000200	// Show swing level
155 #define F_EXE_AUTO		0x00000400	// Enter auto mode
156 
157 /* Print message define */
158 #define PRINT_RATE_1_62		printf("DP Rate 1.62 Gbps !\n")
159 #define PRINT_RATE_2_70		printf("DP Rate 2.70 Gbps !\n")
160 #define PRINT_RATE_5_40		printf("DP Rate 5.40 Gbps !\n")
161 
162 #define PRINT_SWING_0		printf("DP Swing Level 0!\n")
163 #define PRINT_SWING_1		printf("DP Swing Level 1!\n")
164 #define PRINT_SWING_2		printf("DP Swing Level 2!\n")
165 
166 #define PRINT_DEEMP_0		printf("DP Pre - Emphasis Level 0!\n")
167 #define PRINT_DEEMP_1		printf("DP Pre - Emphasis Level 1!\n")
168 #define PRINT_DEEMP_2		printf("DP Pre - Emphasis Level 2!\n")
169 
170 #define PRINT_EMPVAL_0		printf("DP Pre - Emphasis Level 0 !\n")
171 #define PRINT_EMPVAL_1		printf("DP Pre - Emphasis Level 1 !\n")
172 #define PRINT_EMPVAL_2		printf("DP Pre - Emphasis Level 2 !\n")
173 
174 #define PRINT_SSCG_ON		printf("DP SSCG ON !\n")
175 #define PRINT_SSCG_OFF		printf("DP SSCG OFF !\n")
176 
177 #define PRINT_INVALID		printf("This parameter is invalid : \t")
178 
179 #define PRINT_ITEM_A		printf("3.1 Eye Diagram Test - PRBS7\n");\
180 				printf("3.4 Inter Pair Skew Test -PRBS7\n");\
181 				printf("3.11 Non ISI Jitter Test -PRBS7\n");\
182 				printf("3.12 Total Jitter Test -PRBS7\n")\
183 
184 #define PRINT_ITEM_B		printf("3.3 Peak to Peak Voltage Test - PRBS7\n")
185 
186 #define PRINT_ITEM_C		printf("3.3 Peak to Peak Voltage Test -PLTPAT\n");\
187 				printf("3.3 Pre-Emphasis Level Test and Pre-Emphasis Level Delta Test -PLTPAT\n")\
188 
189 #define PRINT_ITEM_D		printf("3.3  Non-Transition Voltage Range Measurement -PLTPAT\n")
190 
191 #define PRINT_ITEM_E		printf("3.3 Pre-Emphasis Level Test and Pre-Emphasis Level Delta Test -PRBS7\n")
192 
193 #define PRINT_ITEM_F		printf("3.3 Non-Transition Voltage Range Measurement - PRBS7\n")
194 
195 #define PRINT_ITEM_G		printf("3.12 Total Jitter Test with No Cable Model -D10.2\n");\
196 				printf("3.12 Total Jitter Test -D10.2\n");\
197 				printf("3.12 Deterministic Jitter Test with No Cable Model -D10.2\n");\
198 				printf("3.12 Deterministic Jitter Test -D10.2\n");\
199 				printf("3.12 Random Jitter Test with No Cable Model -D10.2\n");\
200 				printf("3.12 Random Jitter Test -D10.2\n");\
201 				printf("3.14 Main Link Frequency Compliance -D10.2\n");\
202 				printf("3.15 SSC Modulation Frequency Test -D10.2\n");\
203 				printf("3.16 SSC Modulation Deviation Test -D10.2\n")\
204 
205 #define PRINT_ITEM_H		printf("3.2 Non Pre-Emphasis Level Test - PRBS7\n")
206 
207 #define PRINT_ITEM_I		printf("3.2 Non Pre-Emphasis Level Test - PLTPAT\n")
208 
209 #define PRINT_ITEM_J		printf("8.1 AUX Channel Measurement\n")
210 
211 #define PRINT_ITEM_K		printf("3.1 Eye Diagram Test with No Cable Mode - HBR2CPAT\n");\
212 				printf("3.1 Eye Diagram Test - HBR2CPAT\n");\
213 				printf("3.12 Total Jitter Test with No Cable Model -HBR2CPAT\n");\
214 				printf("3.12 Total Jitter Test -HBR2CPAT\n");\
215 				printf("3.12 Deterministic Jitter Test with No Cable Model -HBR2CPAT\n");\
216 				printf("3.12 Deterministic Jitter Test -HBR2CPAT\n")\
217 
218 #define PRINT_ITEM_X		printf("Auto DP Measurement\n")
219 
220 /* Function prototype */
221 void DPTX_MCU_Reset(void);
222 void DPPHY_Set(void);
223 char DPPHYTX_Show_Cfg(void);
224 void DPPHYTX_Show_Item(char received);
225 
226 /* I2c set */
227 void I2C_G_Initial(void);
228 void I2C_L_Initial(void);
229 void Set_Redriver(void);
230 
231 void Set_PRBS7(void);
232 void Set_HBR2CPAT(void);
233 void Set_PLTPAT(void);
234 void Set_D10_1(void);
235 
236 uchar AUX_R(int aux_cmd, int aux_addr, int *aux_r_data, uchar *length, uchar *status);
237 uchar AUX_W(int aux_cmd, int aux_addr, int *aux_w_data, uchar *length, uchar *status);
238 
239 void Apply_HPD_Normal(void);
240 void Apply_HPD_Auto_Test(void);
241 
242 uchar Link_Train_Flow(char Link_Level);
243 uchar Adjust_CR_EQ_Train(int TrainPat, uchar ADJStatus);
244 
245 void Apply_EDID_Reading(void);
246 void Read_EDID_128(char Offset);
247 
248 void Apply_Auto_Preset(char Init);
249 
250 void Apply_Auto_Mesument(void);
251 void Apply_Main_Mesument(int flag);
252 void Apply_AUX_Mesument(int flag);
253