1 /*
2  * Copyright (C) Marvell International Ltd. and its affiliates
3  *
4  * SPDX-License-Identifier:	GPL-2.0
5  */
6 
7 #ifndef __HIGHSPEED_ENV_SPEC_H
8 #define __HIGHSPEED_ENV_SPEC_H
9 
10 #include "../../../drivers/ddr/mvebu/ddr3_hw_training.h"
11 
12 typedef enum {
13 	SERDES_UNIT_UNCONNECTED	= 0x0,
14 	SERDES_UNIT_PEX		= 0x1,
15 	SERDES_UNIT_SATA	= 0x2,
16 	SERDES_UNIT_SGMII0	= 0x3,
17 	SERDES_UNIT_SGMII1	= 0x4,
18 	SERDES_UNIT_SGMII2	= 0x5,
19 	SERDES_UNIT_SGMII3	= 0x6,
20 	SERDES_UNIT_QSGMII	= 0x7,
21 	SERDES_UNIT_SETM        = 0x8,
22 	SERDES_LAST_UNIT
23 } MV_BIN_SERDES_UNIT_INDX;
24 
25 
26 typedef enum {
27 	PEX_BUS_DISABLED	= 0,
28 	PEX_BUS_MODE_X1		= 1,
29 	PEX_BUS_MODE_X4		= 2,
30 	PEX_BUS_MODE_X8		= 3
31 } MV_PEX_UNIT_CFG;
32 
33 typedef enum pex_type {
34 	MV_PEX_ROOT_COMPLEX,	/* root complex device */
35 	MV_PEX_END_POINT	/* end point device */
36 } MV_PEX_TYPE;
37 
38 typedef struct serdes_change_m_phy {
39 	MV_BIN_SERDES_UNIT_INDX type;
40 	u32 reg_low_speed;
41 	u32 val_low_speed;
42 	u32 reg_hi_speed;
43 	u32 val_hi_speed;
44 } MV_SERDES_CHANGE_M_PHY;
45 
46 /*
47  * Configuration per SERDES line. Each nibble is MV_SERDES_LINE_TYPE
48  */
49 typedef struct board_serdes_conf {
50 	MV_PEX_TYPE pex_type; /* MV_PEX_ROOT_COMPLEX MV_PEX_END_POINT */
51 	u32 line0_7; /* Lines 0 to 7 SERDES MUX one nibble per line */
52 	u32 line8_15; /* Lines 8 to 15 SERDES MUX one nibble per line */
53 	MV_PEX_UNIT_CFG pex_mode[4];
54 
55 	/*
56 	 * Bus speed - one bit per SERDES line:
57 	 *		Low speed (0)		High speed (1)
58 	 * PEX		2.5 G (10 bit)		5 G (20 bit)
59 	 * SATA		1.5 G			3 G
60 	 * SGMII	1.25 Gbps		3.125 Gbps
61 	 */
62 	u32	bus_speed;
63 
64 	MV_SERDES_CHANGE_M_PHY *serdes_m_phy_change;
65 } MV_BIN_SERDES_CFG;
66 
67 
68 #define BIN_SERDES_CFG {	\
69 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 0 */	\
70 	{0, 1, -1 , -1, -1, -1, -1, -1,  2}, /* Lane 1 */	\
71 	{0, 1, -1 ,  2, -1, -1, -1, -1,  3}, /* Lane 2 */	\
72 	{0, 1, -1 , -1,  2, -1, -1,  3, -1}, /* Lane 3 */	\
73 	{0, 1,  2 , -1, -1,  3, -1, -1,  4}, /* Lane 4 */	\
74 	{0, 1,  2 , -1,  3, -1, -1,  4, -1}, /* Lane 5 */	\
75 	{0, 1,  2 ,  4, -1,  3, -1, -1, -1}, /* Lane 6 */	\
76 	{0, 1, -1 ,  2, -1, -1,  3, -1,  4}, /* Lane 7*/	\
77 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 8 */	\
78 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 9 */	\
79 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 10 */	\
80 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 11 */	\
81 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 12 */	\
82 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 13 */	\
83 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 14 */	\
84 	{0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 15 */	\
85 }
86 
87 #endif /* __HIGHSPEED_ENV_SPEC_H */
88