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