blob: 25fdb4b042110d55cdc8c16caf2b146ad4cd6456 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sunbcf7b3d2012-10-08 07:44:20 +00002/*
3 * Copyright 2012 Freescale Semiconductor, Inc.
York Sunbcf7b3d2012-10-08 07:44:20 +00004 */
5
York Sunbcf7b3d2012-10-08 07:44:20 +00006#include <asm/fsl_serdes.h>
7#include <asm/processor.h>
8#include <asm/io.h>
9#include "fsl_corenet2_serdes.h"
10
11struct serdes_config {
12 u8 protocol;
13 u8 lanes[SRDS_MAX_LANES];
14};
15
York Sun68eaa9a2016-11-18 11:44:43 -080016#ifdef CONFIG_ARCH_B4860
York Sunbcf7b3d2012-10-08 07:44:20 +000017static struct serdes_config serdes1_cfg_tbl[] = {
18 /* SerDes 1 */
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +053019 {0x01, {AURORA, AURORA, CPRI6, CPRI5,
20 CPRI4, CPRI3, CPRI2, CPRI1} },
Shaveta Leekha8d2ba982014-02-26 16:06:30 +053021 {0x02, {AURORA, AURORA, CPRI6, CPRI5,
22 CPRI4, CPRI3, CPRI2, CPRI1} },
23 {0x04, {AURORA, AURORA, CPRI6, CPRI5,
24 CPRI4, CPRI3, CPRI2, CPRI1} },
25 {0x05, {AURORA, AURORA, CPRI6, CPRI5,
26 CPRI4, CPRI3, CPRI2, CPRI1} },
27 {0x06, {AURORA, AURORA, CPRI6, CPRI5,
28 CPRI4, CPRI3, CPRI2, CPRI1} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +053029 {0x07, {AURORA, AURORA, CPRI6, CPRI5,
30 CPRI4, CPRI3, CPRI2, CPRI1} },
Shaveta Leekha8d2ba982014-02-26 16:06:30 +053031 {0x08, {AURORA, AURORA, CPRI6, CPRI5,
32 CPRI4, CPRI3, CPRI2, CPRI1} },
33 {0x09, {AURORA, AURORA, CPRI6, CPRI5,
34 CPRI4, CPRI3, CPRI2, CPRI1} },
35 {0x0A, {AURORA, AURORA, CPRI6, CPRI5,
36 CPRI4, CPRI3, CPRI2, CPRI1} },
37 {0x0B, {AURORA, AURORA, CPRI6, CPRI5,
38 CPRI4, CPRI3, CPRI2, CPRI1} },
39 {0x0C, {AURORA, AURORA, CPRI6, CPRI5,
40 CPRI4, CPRI3, CPRI2, CPRI1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000041 {0x0D, {CPRI8, CPRI7, CPRI6, CPRI5,
42 CPRI4, CPRI3, CPRI2, CPRI1}},
43 {0x0E, {CPRI8, CPRI7, CPRI6, CPRI5,
44 CPRI4, CPRI3, CPRI2, CPRI1}},
45 {0x12, {CPRI8, CPRI7, CPRI6, CPRI5,
46 CPRI4, CPRI3, CPRI2, CPRI1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +053047 {0x29, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
48 CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000049 {0x2a, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
50 CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1}},
Poonam Aggrwal1c859552012-12-23 19:22:33 +000051 {0x2C, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
52 CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1}},
53 {0x2D, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
54 CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1}},
55 {0x2E, {SGMII_FM1_DTSEC5, SGMII_FM1_DTSEC6,
56 CPRI6, CPRI5, CPRI4, CPRI3, CPRI2, CPRI1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +053057 {0x2F, {AURORA, AURORA,
58 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
59 CPRI4, CPRI3, CPRI2, CPRI1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000060 {0x30, {AURORA, AURORA,
61 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
62 CPRI4, CPRI3, CPRI2, CPRI1}},
63 {0x32, {AURORA, AURORA,
64 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
65 CPRI4, CPRI3, CPRI2, CPRI1}},
66 {0x33, {AURORA, AURORA,
67 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
68 CPRI4, CPRI3, CPRI2, CPRI1}},
69 {0x34, {AURORA, AURORA,
70 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
71 CPRI4, CPRI3, CPRI2, CPRI1}},
Shaveta Leekha8d2ba982014-02-26 16:06:30 +053072 {0x39, {AURORA, AURORA, CPRI6, CPRI5,
73 CPRI4, CPRI3, CPRI2, CPRI1} },
74 {0x3A, {AURORA, AURORA, CPRI6, CPRI5,
75 CPRI4, CPRI3, CPRI2, CPRI1} },
76 {0x3C, {AURORA, AURORA, CPRI6, CPRI5,
77 CPRI4, CPRI3, CPRI2, CPRI1} },
78 {0x3D, {AURORA, AURORA, CPRI6, CPRI5,
79 CPRI4, CPRI3, CPRI2, CPRI1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000080 {0x3E, {CPRI8, CPRI7, CPRI6, CPRI5,
81 CPRI4, CPRI3, CPRI2, CPRI1}},
Shaveta Leekha8d2ba982014-02-26 16:06:30 +053082 {0x5C, {AURORA, AURORA,
83 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
84 CPRI4, CPRI3, CPRI2, CPRI1} },
85 {0x5D, {AURORA, AURORA,
86 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
87 CPRI4, CPRI3, CPRI2, CPRI1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000088 {}
89};
90static struct serdes_config serdes2_cfg_tbl[] = {
91 /* SerDes 2 */
poonam aggrwal331dd1d2014-02-17 08:38:58 +053092 {0x17, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
93 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
94 AURORA, AURORA, SRIO1, SRIO1} },
York Sunbcf7b3d2012-10-08 07:44:20 +000095 {0x18, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
96 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
97 AURORA, AURORA, SRIO1, SRIO1}},
98 {0x1D, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
99 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
100 AURORA, AURORA, SRIO1, SRIO1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530101 {0x2A, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
102 SRIO2, SRIO2,
103 AURORA, AURORA, SRIO1, SRIO1} },
York Sunbcf7b3d2012-10-08 07:44:20 +0000104 {0x2B, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
105 SRIO2, SRIO2,
106 AURORA, AURORA, SRIO1, SRIO1}},
107 {0x30, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
108 SRIO2, SRIO2,
109 AURORA, AURORA,
110 SRIO1, SRIO1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530111 {0x48, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
112 SGMII_FM1_DTSEC3, AURORA,
113 SRIO1, SRIO1, SRIO1, SRIO1} },
York Sunbcf7b3d2012-10-08 07:44:20 +0000114 {0x49, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
115 SGMII_FM1_DTSEC3, AURORA,
116 SRIO1, SRIO1, SRIO1, SRIO1}},
117 {0x4A, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
118 SGMII_FM1_DTSEC3, AURORA,
119 SRIO1, SRIO1, SRIO1, SRIO1}},
120 {0x4C, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
121 SGMII_FM1_DTSEC3, AURORA,
122 SRIO1, SRIO1, SRIO1, SRIO1}},
123 {0x4E, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
124 SGMII_FM1_DTSEC3, AURORA,
125 SRIO1, SRIO1, SRIO1, SRIO1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530126 {0x79, {SRIO2, SRIO2, SRIO2, SRIO2,
127 SRIO1, SRIO1, SRIO1, SRIO1} },
Poonam Aggrwal1c859552012-12-23 19:22:33 +0000128 {0x7A, {SRIO2, SRIO2, SRIO2, SRIO2,
129 SRIO1, SRIO1, SRIO1, SRIO1}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530130 {0x83, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
131 SRIO2, SRIO2, AURORA, AURORA,
132 XFI_FM1_MAC9, XFI_FM1_MAC10} },
York Sunbcf7b3d2012-10-08 07:44:20 +0000133 {0x84, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
134 SRIO2, SRIO2, AURORA, AURORA,
135 XFI_FM1_MAC9, XFI_FM1_MAC10}},
136 {0x85, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
137 SRIO2, SRIO2, AURORA, AURORA,
138 XFI_FM1_MAC9, XFI_FM1_MAC10}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530139 {0x86, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
140 SRIO2, SRIO2,
141 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
142 XFI_FM1_MAC9, XFI_FM1_MAC10} },
York Sunbcf7b3d2012-10-08 07:44:20 +0000143 {0x87, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
144 SRIO2, SRIO2,
145 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
146 XFI_FM1_MAC9, XFI_FM1_MAC10}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530147 {0x8C, {SRIO2, SRIO2, SRIO2, SRIO2,
148 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
149 XFI_FM1_MAC9, XFI_FM1_MAC10} },
Poonam Aggrwal1c859552012-12-23 19:22:33 +0000150 {0x8D, {SRIO2, SRIO2, SRIO2, SRIO2,
151 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
152 XFI_FM1_MAC9, XFI_FM1_MAC10}},
York Sunbcf7b3d2012-10-08 07:44:20 +0000153 {0x93, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
154 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
155 XAUI_FM1_MAC10, XAUI_FM1_MAC10,
156 XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
157 {0x9E, {PCIE1, PCIE1, PCIE1, PCIE1,
158 XAUI_FM1_MAC10, XAUI_FM1_MAC10,
159 XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
160 {0x9A, {PCIE1, PCIE1,
161 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
162 XAUI_FM1_MAC10, XAUI_FM1_MAC10,
163 XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
poonam aggrwal331dd1d2014-02-17 08:38:58 +0530164 {0xB1, {PCIE1, PCIE1, PCIE1, PCIE1,
165 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
166 XFI_FM1_MAC9, XFI_FM1_MAC10} },
York Sunbcf7b3d2012-10-08 07:44:20 +0000167 {0xB2, {PCIE1, PCIE1, PCIE1, PCIE1,
168 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
169 XFI_FM1_MAC9, XFI_FM1_MAC10}},
170 {0xC3, {XAUI_FM1_MAC9, XAUI_FM1_MAC9,
171 XAUI_FM1_MAC9, XAUI_FM1_MAC9,
172 SRIO1, SRIO1, SRIO1, SRIO1}},
Poonam Aggrwal1c859552012-12-23 19:22:33 +0000173 {0x98, {XAUI_FM1_MAC9, XAUI_FM1_MAC9,
174 XAUI_FM1_MAC9, XAUI_FM1_MAC9,
175 XAUI_FM1_MAC10, XAUI_FM1_MAC10,
176 XAUI_FM1_MAC10, XAUI_FM1_MAC10}},
York Sunbcf7b3d2012-10-08 07:44:20 +0000177 {}
178};
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000179#endif
180
York Sunfda566d2016-11-18 11:56:57 -0800181#ifdef CONFIG_ARCH_B4420
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000182static struct serdes_config serdes1_cfg_tbl[] = {
183 {0x0D, {NONE, NONE, CPRI6, CPRI5,
184 CPRI4, CPRI3, NONE, NONE} },
185 {0x0E, {NONE, NONE, CPRI8, CPRI5,
186 CPRI4, CPRI3, NONE, NONE} },
187 {0x0F, {NONE, NONE, CPRI6, CPRI5,
188 CPRI4, CPRI3, NONE, NONE} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530189 {0x17, {NONE, NONE,
190 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
191 NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000192 {0x18, {NONE, NONE,
193 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
194 NONE, NONE, NONE, NONE} },
195 {0x1B, {NONE, NONE,
196 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
197 NONE, NONE, NONE, NONE} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530198 {0x1D, {NONE, NONE, AURORA, AURORA,
199 NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000200 {0x1E, {NONE, NONE, AURORA, AURORA,
201 NONE, NONE, NONE, NONE} },
202 {0x21, {NONE, NONE, AURORA, AURORA,
203 NONE, NONE, NONE, NONE} },
204 {0x3E, {NONE, NONE, CPRI6, CPRI5,
205 CPRI4, CPRI3, NONE, NONE} },
206 {}
207};
208static struct serdes_config serdes2_cfg_tbl[] = {
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530209 {0x48, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
210 SGMII_FM1_DTSEC3, AURORA,
211 NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000212 {0x49, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
213 SGMII_FM1_DTSEC3, AURORA,
214 NONE, NONE, NONE, NONE} },
215 {0x4A, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
216 SGMII_FM1_DTSEC3, AURORA,
217 NONE, NONE, NONE, NONE} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530218 {0x6E, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
219 AURORA, AURORA, NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000220 {0x6F, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
221 AURORA, AURORA, NONE, NONE, NONE, NONE} },
222 {0x70, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
223 AURORA, AURORA, NONE, NONE, NONE, NONE} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530224 {0x99, {PCIE1, PCIE1,
225 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
226 NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000227 {0x9A, {PCIE1, PCIE1,
228 SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC4,
229 NONE, NONE, NONE, NONE} },
Shaveta Leekhab4d75ed2014-11-12 16:02:25 +0530230 {0x9D, {PCIE1, PCIE1, PCIE1, PCIE1,
231 NONE, NONE, NONE, NONE} },
Poonam Aggrwal248865e2012-12-23 19:24:16 +0000232 {0x9E, {PCIE1, PCIE1, PCIE1, PCIE1,
233 NONE, NONE, NONE, NONE} },
234 {}
235};
236#endif
237
York Sunbcf7b3d2012-10-08 07:44:20 +0000238static struct serdes_config *serdes_cfg_tbl[] = {
239 serdes1_cfg_tbl,
240 serdes2_cfg_tbl,
241};
242
243enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane)
244{
245 struct serdes_config *ptr;
246
247 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
248 return 0;
249
250 ptr = serdes_cfg_tbl[serdes];
251 while (ptr->protocol) {
252 if (ptr->protocol == cfg)
253 return ptr->lanes[lane];
254 ptr++;
255 }
256
257 return 0;
258}
259
260int is_serdes_prtcl_valid(int serdes, u32 prtcl)
261{
262 int i;
263 struct serdes_config *ptr;
264
265 if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
266 return 0;
267
268 ptr = serdes_cfg_tbl[serdes];
269 while (ptr->protocol) {
270 if (ptr->protocol == prtcl)
271 break;
272 ptr++;
273 }
274
275 if (!ptr->protocol)
276 return 0;
277
278 for (i = 0; i < SRDS_MAX_LANES; i++) {
279 if (ptr->lanes[i] != NONE)
280 return 1;
281 }
282
283 return 0;
284}