1
2
3
4
5
6
7#include <common.h>
8#include <spl.h>
9#include <asm/io.h>
10#include <asm/arch/cpu.h>
11#include <asm/arch/soc.h>
12
13#include "high_speed_env_spec.h"
14#include "sys_env_lib.h"
15#include "ctrl_pex.h"
16
17#if defined(CONFIG_ARMADA_38X)
18#elif defined(CONFIG_ARMADA_39X)
19#else
20#error "No device is defined"
21#endif
22
23
24
25
26
27
28struct cfg_seq serdes_seq_db[SERDES_LAST_SEQ];
29
30#define SERDES_VERION "2.0"
31#define ENDED_OK "High speed PHY - Ended Successfully\n"
32
33#define LINK_WAIT_CNTR 100
34#define LINK_WAIT_SLEEP 100
35
36#define MAX_UNIT_NUMB 4
37#define TOPOLOGY_TEST_OK 0
38#define WRONG_NUMBER_OF_UNITS 1
39#define SERDES_ALREADY_IN_USE 2
40#define UNIT_NUMBER_VIOLATION 3
41
42
43
44
45
46u8 serdes_lane_in_use_count[MAX_UNITS_ID][MAX_UNIT_NUMB] = {
47
48 { 1, 1, 1, 1 },
49 { 1, 1, 1, 1 },
50 { 1, 1, 0, 0 },
51 { 1, 1, 1, 0 },
52 { 1, 1, 1, 1 },
53 { 1, 0, 0, 0 },
54 { 4, 0, 0, 0 },
55 { 2, 0, 0, 0 }
56};
57
58
59
60
61
62u8 serdes_unit_count[MAX_UNITS_ID] = { 0 };
63
64
65u8 selectors_serdes_rev2_map[LAST_SERDES_TYPE][MAX_SERDES_LANES] = {
66
67 { 0x1, 0x1, NA, NA, NA, NA, NA },
68 { NA, NA, 0x1, NA, 0x1, NA, 0x1 },
69 { NA, NA, NA, NA, 0x7, 0x1, NA },
70 { NA, NA, NA, 0x1, NA, NA, NA },
71 { 0x2, 0x3, NA, NA, NA, NA, NA },
72 { NA, NA, 0x3, NA, NA, NA, NA },
73 { NA, NA, NA, NA, 0x6, 0x2, NA },
74 { NA, NA, NA, 0x3, NA, NA, NA },
75 { 0x3, 0x4, NA, NA, NA, NA, NA },
76 { NA, 0x5, 0x4, NA, 0x3, NA, NA },
77 { NA, NA, NA, 0x4, NA, 0x3, NA },
78 { NA, 0x7, NA, NA, NA, NA, NA },
79 { NA, 0x6, NA, NA, 0x4, NA, NA },
80 { NA, NA, NA, 0x5, NA, 0x4, NA },
81 { NA, NA, NA, 0x6, 0x5, 0x5, NA },
82#ifdef CONFIG_ARMADA_39X
83 { NA, NA, 0x5, NA, 0x8, NA, 0x2 },
84 { NA, NA, NA, 0x8, 0x9, 0x8, 0x4 },
85 { NA, NA, NA, NA, NA, 0x8, 0x4 },
86#endif
87 { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, NA }
88};
89
90
91u8 common_phys_selectors_pex_by4_lanes[] = { 0x1, 0x2, 0x2, 0x2 };
92
93static const char *const serdes_type_to_string[] = {
94 "PCIe0",
95 "PCIe1",
96 "PCIe2",
97 "PCIe3",
98 "SATA0",
99 "SATA1",
100 "SATA2",
101 "SATA3",
102 "SGMII0",
103 "SGMII1",
104 "SGMII2",
105 "QSGMII",
106 "USB3 HOST0",
107 "USB3 HOST1",
108 "USB3 DEVICE",
109 "SGMII3",
110 "XAUI",
111 "RXAUI",
112 "DEFAULT SERDES",
113 "LAST_SERDES_TYPE"
114};
115
116struct serdes_unit_data {
117 u8 serdes_unit_id;
118 u8 serdes_unit_num;
119};
120
121static struct serdes_unit_data serdes_type_to_unit_info[] = {
122 {PEX_UNIT_ID, 0,},
123 {PEX_UNIT_ID, 1,},
124 {PEX_UNIT_ID, 2,},
125 {PEX_UNIT_ID, 3,},
126 {SATA_UNIT_ID, 0,},
127 {SATA_UNIT_ID, 1,},
128 {SATA_UNIT_ID, 2,},
129 {SATA_UNIT_ID, 3,},
130 {ETH_GIG_UNIT_ID, 0,},
131 {ETH_GIG_UNIT_ID, 1,},
132 {ETH_GIG_UNIT_ID, 2,},
133 {QSGMII_UNIT_ID, 0,},
134 {USB3H_UNIT_ID, 0,},
135 {USB3H_UNIT_ID, 1,},
136 {USB3D_UNIT_ID, 0,},
137 {ETH_GIG_UNIT_ID, 3,},
138 {XAUI_UNIT_ID, 0,},
139 {RXAUI_UNIT_ID, 0,},
140};
141
142
143
144
145
146
147
148struct op_params sata_port0_power_up_params[] = {
149
150
151
152
153
154 {SATA_VENDOR_PORT_0_REG_ADDR, 0x38000, 0xffffffff, {0x48,}, 0, 0},
155
156 {SATA_VENDOR_PORT_0_REG_DATA, 0x38000, 0xf03f, {0x6018,}, 0, 0},
157
158 {SATA_VENDOR_PORT_0_REG_ADDR, 0x38000, 0xffffffff, {0xa,}, 0, 0},
159
160 {SATA_VENDOR_PORT_0_REG_DATA, 0x38000, 0x3000, {0x0,}, 0, 0},
161
162 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x0,}, 0, 0},
163
164 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffff00ff, {0xc40040,}, 0, 0},
165};
166
167struct op_params sata_port1_power_up_params[] = {
168
169
170
171
172
173 {SATA_VENDOR_PORT_1_REG_ADDR, 0x38000, 0xffffffff, {0x48,}, 0, 0},
174
175 {SATA_VENDOR_PORT_1_REG_DATA, 0x38000, 0xf03f, {0x6018,}, 0, 0},
176
177 {SATA_VENDOR_PORT_1_REG_ADDR, 0x38000, 0xffffffff, {0xa,}, 0, 0},
178
179 {SATA_VENDOR_PORT_1_REG_DATA, 0x38000, 0x3000, {0x0,}, 0, 0},
180
181 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x0,}, 0, 0},
182
183 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffffff00, {0xc44000,}, 0, 0},
184};
185
186
187struct op_params sata_and_sgmii_power_up_params[] = {
188
189
190
191
192
193 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x90006, {0x80002, 0x80002},
194 0, 0},
195
196 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x7800, {0x6000, 0x6000}, 0, 0},
197
198 {POWER_AND_PLL_CTRL_REG, 0x800, 0x0e0, {0x0, 0x80}, 0, 0},
199
200 {MISC_REG, 0x800, 0x440, {0x440, 0x400}, 0, 0}
201};
202
203
204struct op_params sata_and_sgmii_speed_config_params[] = {
205
206
207
208
209
210 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x3fc00000,
211 {0x8800000, 0x19800000, 0x22000000}, 0, 0},
212
213 {INTERFACE_REG, 0x800, 0xc00, {0x800, NO_DATA, NO_DATA}, 0, 0},
214
215 {ISOLATE_REG, 0x800, 0xff, {NO_DATA, 0x66, 0x66}, 0, 0},
216
217 {LOOPBACK_REG, 0x800, 0xe, {0x4, 0x2, 0x2}, 0, 0}
218};
219
220
221struct op_params sata_and_sgmii_tx_config_params1[] = {
222
223
224
225
226 {GLUE_REG, 0x800, 0x1800, {NO_DATA, 0x800}, 0, 0},
227
228 {RESET_DFE_REG, 0x800, 0x401, {0x401, 0x401}, 0, 0},
229
230 {RESET_DFE_REG, 0x800, 0x401, {0x0, 0x0}, 0, 0},
231
232 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0xf0000, {0x70000, 0x70000},
233 0, 0}
234};
235
236struct op_params sata_port0_tx_config_params[] = {
237
238
239
240
241
242 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x0}, 0, 0},
243
244 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffff00ff, {0xc40000}, 0, 0},
245
246 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x4}, 0, 0},
247
248 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffffffff, {0x80}, 0, 0}
249};
250
251struct op_params sata_port1_tx_config_params[] = {
252
253
254
255
256
257 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x0}, 0, 0},
258
259 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffffff00, {0xc40000}, 0, 0},
260
261 {SATA_CTRL_REG_IND_ADDR, 0x38000, 0xffffffff, {0x4}, 0, 0},
262
263 {SATA_CTRL_REG_IND_DATA, 0x38000, 0xffffffff, {0x80}, 0, 0}
264};
265
266struct op_params sata_and_sgmii_tx_config_serdes_rev1_params2[] = {
267
268
269
270
271
272 {COMMON_PHY_STATUS1_REG, 0x28, 0xc, {0xc, 0xc}, 10, 1000},
273
274 {COMMON_PHY_STATUS1_REG, 0x28, 0x1, {0x1, 0x1}, 1, 1000}
275};
276
277struct op_params sata_and_sgmii_tx_config_serdes_rev2_params2[] = {
278
279
280
281
282
283 {COMMON_PHY_STATUS1_REG, 0x28, 0xc, {0xc, 0xc}, 10, 1000},
284
285 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x40000000, {NA, 0x40000000},
286 0, 0},
287
288 {ISOLATE_REG, 0x800, 0x400, {0x400, NA}, 0, 0},
289
290 {COMMON_PHY_STATUS1_REG, 0x28, 0x1, {0x1, 0x1}, 1, 1000},
291
292 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x40000000, {NA, 0x0}, 0, 0},
293
294 {ISOLATE_REG, 0x800, 0x400, {0x0, NA}, 0, 0},
295
296 {RX_REG3, 0x800, 0xff, {0xde, NO_DATA}, 0, 0},
297
298 {RX_REG3, 0x800, 0x100, {0x100, NO_DATA}, 0, 0},
299
300 {RX_REG3, 0x800, 0x100, {0x0, NO_DATA}, 0, 0},
301};
302
303struct op_params sata_electrical_config_serdes_rev1_params[] = {
304
305
306
307
308
309 {COMMON_PHY_CONFIGURATION4_REG, 0x28, 0x400008, {0x400000,}, 0, 0},
310
311 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x4000,}, 0, 0},
312
313 {SQUELCH_FFE_SETTING_REG, 0x800, 0xfff, {0x6cf,}, 0, 0},
314
315 {G1_SETTINGS_0_REG, 0x800, 0xffff, {0x8a32,}, 0, 0},
316
317 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9,}, 0, 0},
318
319 {G2_SETTINGS_0_REG, 0x800, 0xffff, {0x8b5c,}, 0, 0},
320
321 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3d2,}, 0, 0},
322
323 {G3_SETTINGS_0_REG, 0x800, 0xffff, {0xe6e,}, 0, 0},
324
325 {G3_SETTINGS_1_REG, 0x800, 0x3ff, {0x3d2,}, 0, 0},
326
327 {CAL_REG6, 0x800, 0xff00, {0xdd00,}, 0, 0},
328
329 {RX_REG2, 0x800, 0xf0, {0x70,}, 0, 0},
330};
331
332struct op_params sata_electrical_config_serdes_rev2_params[] = {
333
334
335
336
337
338 {SQUELCH_FFE_SETTING_REG, 0x800, 0xf00, {0x600}, 0, 0},
339
340 {COMMON_PHY_CONFIGURATION4_REG, 0x28, 0x400008, {0x400000}, 0, 0},
341
342 {G1_SETTINGS_0_REG, 0x800, 0xffff, {0x8a32}, 0, 0},
343
344 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9}, 0, 0},
345
346 {G2_SETTINGS_0_REG, 0x800, 0xffff, {0x8b5c}, 0, 0},
347
348 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3d2}, 0, 0},
349
350 {G3_SETTINGS_0_REG, 0x800, 0xffff, {0xe6e}, 0, 0},
351
352
353
354
355 {G3_SETTINGS_1_REG, 0x800, 0x47ff, {0x7d2}, 0, 0},
356
357 {PCIE_REG0, 0x800, 0x1000, {0x0}, 0, 0},
358
359 {RX_REG2, 0x800, 0xf0, {0x70,}, 0, 0},
360
361 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x3000}, 0, 0},
362
363 {DFE_REG0, 0x800, 0xa00f, {0x800a}, 0, 0},
364
365 {DFE_REG3, 0x800, 0xc000, {0x0}, 0, 0},
366
367 {G1_SETTINGS_3_REG, 0x800, 0xff, {0xcf}, 0, 0},
368
369 {G2_SETTINGS_3_REG, 0x800, 0xff, {0xbf}, 0, 0},
370
371 {G3_SETTINGS_3_REG, 0x800, 0xff, {0xcf}, 0, 0},
372
373 {G3_SETTINGS_4_REG, 0x800, 0x300, {0x300}, 0, 0},
374};
375
376struct op_params sgmii_electrical_config_serdes_rev1_params[] = {
377
378
379
380
381
382 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9, 0x3c9}, 0, 0},
383
384 {SQUELCH_FFE_SETTING_REG, 0x800, 0xfff, {0x8f, 0xbf}, 0, 0},
385
386 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x4000, 0x4000}, 0, 0},
387};
388
389struct op_params sgmii_electrical_config_serdes_rev2_params[] = {
390
391
392
393
394
395 {G1_SETTINGS_0_REG, 0x800, 0xffff, {0x8fa, 0x8fa}, 0, 0},
396
397 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9, 0x3c9}, 0, 0},
398
399 {RX_REG2, 0x800, 0x4, {0x0, 0x0}, 0, 0},
400
401 {G1_SETTINGS_3_REG, 0x800, 0xff, {0x8f, 0xbf}, 0, 0},
402
403 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x3000, 0x3000}, 0, 0},
404};
405
406
407
408
409
410
411struct op_params pex_and_usb3_power_up_serdes_rev1_params[] = {
412
413
414
415
416 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x3fc7f806,
417 {0x4471804, 0x4479804}, 0, 0},
418 {COMMON_PHY_CONFIGURATION2_REG, 0x28, 0x5c, {0x58, 0x58}, 0, 0},
419 {COMMON_PHY_CONFIGURATION4_REG, 0x28, 0x3, {0x1, 0x1}, 0, 0},
420 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x7800, {0x6000, 0xe000}, 0, 0},
421 {GLOBAL_CLK_CTRL, 0x800, 0xd, {0x5, 0x1}, 0, 0},
422
423 {MISC_REG, 0x800, 0x4c0, {0x80, 0x4c0}, 0, 0}
424};
425
426
427struct op_params pex_and_usb3_power_up_serdes_rev2_params[] = {
428
429
430
431
432 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x3fc7f806,
433 {0x4471804, 0x4479804}, 0, 0},
434 {COMMON_PHY_CONFIGURATION2_REG, 0x28, 0x5c, {0x58, 0x58}, 0, 0},
435 {COMMON_PHY_CONFIGURATION4_REG, 0x28, 0x3, {0x1, 0x1}, 0, 0},
436 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x7800, {0x6000, 0xe000}, 0, 0},
437 {GLOBAL_CLK_CTRL, 0x800, 0xd, {0x5, 0x1}, 0, 0},
438 {GLOBAL_MISC_CTRL, 0x800, 0xc0, {0x0, NO_DATA}, 0, 0},
439
440 {MISC_REG, 0x800, 0x4c0, {0x80, 0x4c0}, 0, 0}
441};
442
443
444struct op_params pex_and_usb3_speed_config_params[] = {
445
446
447
448
449
450 {INTERFACE_REG, 0x800, 0xc00, {0x400, 0x400, 0x400, 0x400, 0x400},
451 0, 0},
452};
453
454struct op_params usb3_electrical_config_serdes_rev1_params[] = {
455
456 {LANE_CFG4_REG, 0x800, 0x80, {0x80}, 0, 0},
457
458 {G2_SETTINGS_2_REG, 0x800, 0xfe40, {0x4440}, 0, 0},
459
460 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x4000}, 0, 0},
461
462 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3d2}, 0, 0},
463
464 {SQUELCH_FFE_SETTING_REG, 0x800, 0xff, {0xef}, 0, 0},
465
466 {RX_REG2, 0x800, 0xf0, {0x70}, 0, 0},
467
468 {CAL_REG6, 0x800, 0xff00, {0xd500}, 0, 0},
469
470 {REF_REG0, 0x800, 0x38, {0x20}, 0, 0},
471};
472
473struct op_params usb3_electrical_config_serdes_rev2_params[] = {
474
475 {LANE_CFG4_REG, 0x800, 0x80, {0x80}, 0, 0},
476
477 {G2_SETTINGS_2_REG, 0x800, 0xfe40, {0x4440}, 0, 0},
478
479 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3d2}, 0, 0},
480
481 {RX_REG2, 0x800, 0xf0, {0x70}, 0, 0},
482
483 {REF_REG0, 0x800, 0x38, {0x20}, 0, 0},
484
485 {LANE_CFG5_REG, 0x800, 0x4, {0x4}, 0, 0},
486};
487
488
489
490
491
492
493
494
495
496struct op_params pex_and_usb3_tx_config_params1[] = {
497
498
499
500
501 {GLOBAL_CLK_CTRL, 0x800, 0x1, {0x0, 0x0}, 0, 0},
502
503 {0x0, 0x0, 0x0, {0x0, 0x0}, 10, 0},
504
505 {RX_REG3, 0x800, 0xff, {0xdc, NO_DATA}, 0, 0},
506
507 {RX_REG3, 0x800, 0x100, {0x100, NO_DATA}, 0, 0},
508
509 {RX_REG3, 0x800, 0x100, {0x0, NO_DATA}, 0, 0},
510};
511
512struct op_params pex_and_usb3_tx_config_params2[] = {
513
514
515
516
517
518 {RESET_DFE_REG, 0x800, 0x401, {0x401, 0x401}, 0, 0},
519};
520
521struct op_params pex_and_usb3_tx_config_params3[] = {
522
523
524
525
526
527 {RESET_DFE_REG, 0x800, 0x401, {0x0, 0x0}, 0, 0},
528
529 {0x0, 0x0, 0x0, {0x0, 0x0}, 10, 0}
530};
531
532
533struct op_params pex_by4_config_params[] = {
534
535 {GLOBAL_CLK_SRC_HI, 0x800, 0x7, {0x5, 0x0, 0x0, 0x2}, 0, 0},
536
537 {LANE_ALIGN_REG0, 0x800, 0x1000, {0x0, 0x0, 0x0, 0x0}, 0, 0},
538
539 {CALIBRATION_CTRL_REG, 0x800, 0x1000, {0x1000, 0x1000, 0x1000, 0x1000},
540 0, 0},
541
542 {LANE_CFG1_REG, 0x800, 0x600, {0x600, 0x600, 0x600, 0x600}, 0, 0},
543};
544
545
546struct op_params usb3_device_config_params[] = {
547
548 {LANE_CFG4_REG, 0x800, 0x200, {0x200}, 0, 0}
549};
550
551
552struct op_params pex_electrical_config_serdes_rev1_params[] = {
553
554
555
556
557
558 {G1_SETTINGS_0_REG, 0x800, 0xf000, {0xb000}, 0, 0},
559
560 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9}, 0, 0},
561
562 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9}, 0, 0},
563
564 {LANE_CFG4_REG, 0x800, 0x8, {0x8}, 0, 0},
565
566 {SQUELCH_FFE_SETTING_REG, 0x800, 0xff, {0xaf}, 0, 0},
567
568 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x3000}, 0, 0},
569
570 {CAL_REG6, 0x800, 0xff00, {0xdc00}, 0, 0},
571};
572
573
574struct op_params pex_electrical_config_serdes_rev2_params[] = {
575
576
577
578
579
580 {G1_SETTINGS_0_REG, 0x800, 0xf000, {0xb000}, 0, 0},
581
582 {G1_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9}, 0, 0},
583
584 {G1_SETTINGS_3_REG, 0x800, 0xff, {0xcf}, 0, 0},
585
586 {G2_SETTINGS_1_REG, 0x800, 0x3ff, {0x3c9}, 0, 0},
587
588 {G2_SETTINGS_3_REG, 0x800, 0xff, {0xaf}, 0, 0},
589
590 {G2_SETTINGS_4_REG, 0x800, 0x300, {0x300}, 0, 0},
591
592 {DFE_REG0, 0x800, 0x8000, {0x8000}, 0, 0},
593
594 {PCIE_REG1, 0x800, 0xf80, {0xd00}, 0, 0},
595
596 {PCIE_REG3, 0x800, 0xff00, {0xaf00}, 0, 0},
597
598 {LANE_CFG4_REG, 0x800, 0x8, {0x8}, 0, 0},
599
600 {VTHIMPCAL_CTRL_REG, 0x800, 0xff00, {0x3000}, 0, 0},
601};
602
603
604struct op_params pex_config_ref_clock25_m_hz[] = {
605
606
607
608
609
610 {POWER_AND_PLL_CTRL_REG, 0x800, 0x1f, {0x2}, 0, 0},
611
612 {MISC_REG, 0x800, 0x400, {0x400}, 0, 0},
613
614 {GLOBAL_PM_CTRL, 0x800, 0xff, {0x7}, 0, 0},
615};
616
617
618struct op_params pex_config_ref_clock40_m_hz[] = {
619
620
621
622
623
624 {POWER_AND_PLL_CTRL_REG, 0x800, 0x1f, {0x3}, 0, 0},
625
626 {MISC_REG, 0x800, 0x400, {0x400}, 0, 0},
627
628 {GLOBAL_PM_CTRL, 0x800, 0xff, {0xc}, 0, 0},
629};
630
631
632struct op_params pex_config_ref_clock100_m_hz[] = {
633
634
635
636
637
638 {POWER_AND_PLL_CTRL_REG, 0x800, 0x1f, {0x0}, 0, 0},
639
640 {MISC_REG, 0x800, 0x400, {0x0}, 0, 0},
641
642 {GLOBAL_PM_CTRL, 0x800, 0xff, {0x1e}, 0, 0},
643};
644
645
646
647
648
649struct op_params usb2_power_up_params[] = {
650
651
652
653
654
655 {0x18440, 0x0 , 0xffffffff, {0x62}, 0, 0},
656
657 {0x18444, 0x0 , 0xffffffff, {0x62}, 0, 0},
658
659 {0x18448, 0x0 , 0xffffffff, {0x62}, 0, 0},
660
661 {0xc0000, 0x0 , 0xffffffff, {0x40605205}, 0, 0},
662 {0xc001c, 0x0 , 0xffffffff, {0x39f16ce}, 0, 0},
663 {0xc201c, 0x0 , 0xffffffff, {0x39f16ce}, 0, 0},
664 {0xc401c, 0x0 , 0xffffffff, {0x39f16ce}, 0, 0},
665
666 {0xc0004, 0x0 , 0x1, {0x1}, 0, 0},
667
668 {0xc000c, 0x0 , 0x1000000, {0x1000000}, 0, 0},
669
670 {0xc200c, 0x0 , 0x1000000, {0x1000000}, 0, 0},
671
672 {0xc400c, 0x0 , 0x1000000, {0x1000000}, 0, 0},
673
674 {0xc0008, 0x0 , 0x80800000, {0x80800000}, 1, 1000},
675
676 {0xc0018, 0x0 , 0x80000000, {0x80000000}, 1, 1000},
677
678 {0xc0000, 0x0 , 0x80000000, {0x80000000}, 1, 1000}
679};
680
681
682
683
684
685
686struct op_params qsgmii_port_power_up_params[] = {
687
688
689
690
691
692 {QSGMII_CONTROL_REG1, 0x0, 0x40000000, {0x40000000}, 0, 0},
693
694 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0xf0006, {0x80002}, 0, 0},
695
696 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x7800, {0x6000}, 0, 0},
697
698 {POWER_AND_PLL_CTRL_REG, 0x800, 0xff, {0xfc81}, 0, 0},
699
700 {MISC_REG, 0x800, 0x4c0, {0x480}, 0, 0}
701};
702
703
704struct op_params qsgmii_port_speed_config_params[] = {
705
706
707
708
709
710 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x3fc00000, {0xcc00000}, 0, 0},
711
712 {ISOLATE_REG, 0x800, 0xff, {0x33}, 0, 0},
713
714 {LOOPBACK_REG, 0x800, 0xe, {0x2}, 0, 0}
715};
716
717
718struct op_params qsgmii_port_electrical_config_params[] = {
719
720
721
722
723
724 {G1_SETTINGS_0_REG, 0x800, 0x8000, {0x0}, 0, 0}
725};
726
727
728struct op_params qsgmii_port_tx_config_params1[] = {
729
730
731
732
733 {GLUE_REG, 0x800, 0x1800, {0x800}, 0, 0},
734
735 {RESET_DFE_REG, 0x800, 0x401, {0x401}, 0, 0},
736
737 {RESET_DFE_REG, 0x800, 0x401, {0x0}, 0, 0},
738
739 {LANE_ALIGN_REG0, 0x800, 0x1000, {0x1000}, 0, 0},
740
741 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x70000, {0x70000}, 0, 0},
742
743 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x80000, {0x80000}, 0, 0}
744};
745
746struct op_params qsgmii_port_tx_config_params2[] = {
747
748
749
750
751
752 {COMMON_PHY_STATUS1_REG, 0x28, 0xc, {0xc}, 10, 1000},
753
754 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x40080000, {0x40000000}, 0, 0},
755
756 {COMMON_PHY_STATUS1_REG, 0x28, 0x1, {0x1}, 1, 1000},
757
758 {COMMON_PHY_CONFIGURATION1_REG, 0x28, 0x40000000, {0x0}, 0, 0}
759};
760
761
762struct op_params serdes_power_down_params[] = {
763 {COMMON_PHY_CONFIGURATION1_REG, 0x28, (0xf << 11), {(0x3 << 11)},
764 0, 0},
765 {COMMON_PHY_CONFIGURATION1_REG, 0x28, (0x7 << 16), {0}, 0, 0}
766};
767
768
769
770
771
772
773
774
775
776
777
778
779
780u8 hws_ctrl_serdes_rev_get(void)
781{
782#ifdef CONFIG_ARMADA_38X
783
784 if (sys_env_device_rev_get() == MV_88F68XX_Z1_ID)
785 return MV_SERDES_REV_1_2;
786#endif
787
788
789 return MV_SERDES_REV_2_1;
790}
791
792u32 hws_serdes_topology_verify(enum serdes_type serdes_type, u32 serdes_id,
793 enum serdes_mode serdes_mode)
794{
795 u32 test_result = 0;
796 u8 serd_max_num, unit_numb;
797 enum unit_id unit_id;
798
799 if (serdes_type > RXAUI) {
800 printf("%s: Warning: Wrong serdes type %s serdes#%d\n",
801 __func__, serdes_type_to_string[serdes_type], serdes_id);
802 return MV_FAIL;
803 }
804
805 unit_id = serdes_type_to_unit_info[serdes_type].serdes_unit_id;
806 unit_numb = serdes_type_to_unit_info[serdes_type].serdes_unit_num;
807 serd_max_num = sys_env_unit_max_num_get(unit_id);
808
809
810 if (serdes_lane_in_use_count[unit_id][unit_numb] != 0) {
811
812 serdes_lane_in_use_count[unit_id][unit_numb]--;
813
814
815
816
817
818 if (serdes_lane_in_use_count[unit_id][unit_numb] == 0) {
819 if (((serdes_type <= PEX3)) &&
820 ((serdes_mode == PEX_END_POINT_X4) ||
821 (serdes_mode == PEX_ROOT_COMPLEX_X4))) {
822
823 serdes_unit_count[PEX_UNIT_ID] += 2;
824 } else {
825 serdes_unit_count[unit_id]++;
826 }
827
828
829 if (serdes_unit_count[unit_id] > serd_max_num) {
830 test_result = WRONG_NUMBER_OF_UNITS;
831 } else if (unit_numb >= serd_max_num) {
832
833 test_result = UNIT_NUMBER_VIOLATION;
834 }
835 }
836 } else {
837 test_result = SERDES_ALREADY_IN_USE;
838 }
839
840 if (test_result == SERDES_ALREADY_IN_USE) {
841 printf("%s: Error: serdes lane %d is configured to type %s: type already in use\n",
842 __func__, serdes_id,
843 serdes_type_to_string[serdes_type]);
844 return MV_FAIL;
845 } else if (test_result == WRONG_NUMBER_OF_UNITS) {
846 printf("%s: Warning: serdes lane %d is set to type %s.\n",
847 __func__, serdes_id,
848 serdes_type_to_string[serdes_type]);
849 printf("%s: Maximum supported lanes are already set to this type (limit = %d)\n",
850 __func__, serd_max_num);
851 return MV_FAIL;
852 } else if (test_result == UNIT_NUMBER_VIOLATION) {
853 printf("%s: Warning: serdes lane %d type is %s: current device support only %d units of this type.\n",
854 __func__, serdes_id,
855 serdes_type_to_string[serdes_type],
856 serd_max_num);
857 return MV_FAIL;
858 }
859
860 return MV_OK;
861}
862
863void hws_serdes_xaui_topology_verify(void)
864{
865
866
867
868
869 if ((serdes_lane_in_use_count[XAUI_UNIT_ID][0] != 0) &&
870 (serdes_lane_in_use_count[XAUI_UNIT_ID][0] != 4)) {
871 printf("%s: Warning: wrong number of lanes is set to XAUI - %d\n",
872 __func__, serdes_lane_in_use_count[XAUI_UNIT_ID][0]);
873 printf("%s: XAUI has to be defined on 4 lanes\n", __func__);
874 }
875
876
877
878
879
880 if ((serdes_lane_in_use_count[RXAUI_UNIT_ID][0] != 0) &&
881 (serdes_lane_in_use_count[RXAUI_UNIT_ID][0] != 2)) {
882 printf("%s: Warning: wrong number of lanes is set to RXAUI - %d\n",
883 __func__, serdes_lane_in_use_count[RXAUI_UNIT_ID][0]);
884 printf("%s: RXAUI has to be defined on 2 lanes\n", __func__);
885 }
886}
887
888int hws_serdes_seq_db_init(void)
889{
890 u8 serdes_rev = hws_ctrl_serdes_rev_get();
891
892 DEBUG_INIT_FULL_S("\n### serdes_seq38x_init ###\n");
893
894 if (serdes_rev == MV_SERDES_REV_NA) {
895 printf("hws_serdes_seq_db_init: serdes revision number is not supported\n");
896 return MV_NOT_SUPPORTED;
897 }
898
899
900 serdes_seq_db[SATA_PORT_0_ONLY_POWER_UP_SEQ].op_params_ptr =
901 sata_port0_power_up_params;
902 serdes_seq_db[SATA_PORT_0_ONLY_POWER_UP_SEQ].cfg_seq_size =
903 sizeof(sata_port0_power_up_params) / sizeof(struct op_params);
904 serdes_seq_db[SATA_PORT_0_ONLY_POWER_UP_SEQ].data_arr_idx = SATA;
905
906
907 serdes_seq_db[SATA_PORT_1_ONLY_POWER_UP_SEQ].op_params_ptr =
908 sata_port1_power_up_params;
909 serdes_seq_db[SATA_PORT_1_ONLY_POWER_UP_SEQ].cfg_seq_size =
910 sizeof(sata_port1_power_up_params) / sizeof(struct op_params);
911 serdes_seq_db[SATA_PORT_1_ONLY_POWER_UP_SEQ].data_arr_idx = SATA;
912
913
914 serdes_seq_db[SATA_POWER_UP_SEQ].op_params_ptr =
915 sata_and_sgmii_power_up_params;
916 serdes_seq_db[SATA_POWER_UP_SEQ].cfg_seq_size =
917 sizeof(sata_and_sgmii_power_up_params) / sizeof(struct op_params);
918 serdes_seq_db[SATA_POWER_UP_SEQ].data_arr_idx = SATA;
919
920
921 serdes_seq_db[SATA_1_5_SPEED_CONFIG_SEQ].op_params_ptr =
922 sata_and_sgmii_speed_config_params;
923 serdes_seq_db[SATA_1_5_SPEED_CONFIG_SEQ].cfg_seq_size =
924 sizeof(sata_and_sgmii_speed_config_params) /
925 sizeof(struct op_params);
926 serdes_seq_db[SATA_1_5_SPEED_CONFIG_SEQ].data_arr_idx = SATA;
927
928
929 serdes_seq_db[SATA_3_SPEED_CONFIG_SEQ].op_params_ptr =
930 sata_and_sgmii_speed_config_params;
931 serdes_seq_db[SATA_3_SPEED_CONFIG_SEQ].cfg_seq_size =
932 sizeof(sata_and_sgmii_speed_config_params) /
933 sizeof(struct op_params);
934 serdes_seq_db[SATA_3_SPEED_CONFIG_SEQ].data_arr_idx = SATA;
935
936
937 serdes_seq_db[SATA_6_SPEED_CONFIG_SEQ].op_params_ptr =
938 sata_and_sgmii_speed_config_params;
939 serdes_seq_db[SATA_6_SPEED_CONFIG_SEQ].cfg_seq_size =
940 sizeof(sata_and_sgmii_speed_config_params) /
941 sizeof(struct op_params);
942 serdes_seq_db[SATA_6_SPEED_CONFIG_SEQ].data_arr_idx = SATA;
943
944
945 if (serdes_rev == MV_SERDES_REV_1_2) {
946 serdes_seq_db[SATA_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
947 sata_electrical_config_serdes_rev1_params;
948 serdes_seq_db[SATA_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
949 sizeof(sata_electrical_config_serdes_rev1_params) /
950 sizeof(struct op_params);
951 } else {
952 serdes_seq_db[SATA_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
953 sata_electrical_config_serdes_rev2_params;
954 serdes_seq_db[SATA_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
955 sizeof(sata_electrical_config_serdes_rev2_params) /
956 sizeof(struct op_params);
957 }
958 serdes_seq_db[SATA_ELECTRICAL_CONFIG_SEQ].data_arr_idx = SATA;
959
960
961 serdes_seq_db[SATA_TX_CONFIG_SEQ1].op_params_ptr =
962 sata_and_sgmii_tx_config_params1;
963 serdes_seq_db[SATA_TX_CONFIG_SEQ1].cfg_seq_size =
964 sizeof(sata_and_sgmii_tx_config_params1) / sizeof(struct op_params);
965 serdes_seq_db[SATA_TX_CONFIG_SEQ1].data_arr_idx = SATA;
966
967
968 serdes_seq_db[SATA_PORT_0_ONLY_TX_CONFIG_SEQ].op_params_ptr =
969 sata_port0_tx_config_params;
970 serdes_seq_db[SATA_PORT_0_ONLY_TX_CONFIG_SEQ].cfg_seq_size =
971 sizeof(sata_port0_tx_config_params) / sizeof(struct op_params);
972 serdes_seq_db[SATA_PORT_0_ONLY_TX_CONFIG_SEQ].data_arr_idx = SATA;
973
974
975 serdes_seq_db[SATA_PORT_1_ONLY_TX_CONFIG_SEQ].op_params_ptr =
976 sata_port1_tx_config_params;
977 serdes_seq_db[SATA_PORT_1_ONLY_TX_CONFIG_SEQ].cfg_seq_size =
978 sizeof(sata_port1_tx_config_params) / sizeof(struct op_params);
979 serdes_seq_db[SATA_PORT_1_ONLY_TX_CONFIG_SEQ].data_arr_idx = SATA;
980
981
982 if (serdes_rev == MV_SERDES_REV_1_2) {
983 serdes_seq_db[SATA_TX_CONFIG_SEQ2].op_params_ptr =
984 sata_and_sgmii_tx_config_serdes_rev1_params2;
985 serdes_seq_db[SATA_TX_CONFIG_SEQ2].cfg_seq_size =
986 sizeof(sata_and_sgmii_tx_config_serdes_rev1_params2) /
987 sizeof(struct op_params);
988 } else {
989 serdes_seq_db[SATA_TX_CONFIG_SEQ2].op_params_ptr =
990 sata_and_sgmii_tx_config_serdes_rev2_params2;
991 serdes_seq_db[SATA_TX_CONFIG_SEQ2].cfg_seq_size =
992 sizeof(sata_and_sgmii_tx_config_serdes_rev2_params2) /
993 sizeof(struct op_params);
994 }
995 serdes_seq_db[SATA_TX_CONFIG_SEQ2].data_arr_idx = SATA;
996
997
998 serdes_seq_db[SGMII_POWER_UP_SEQ].op_params_ptr =
999 sata_and_sgmii_power_up_params;
1000 serdes_seq_db[SGMII_POWER_UP_SEQ].cfg_seq_size =
1001 sizeof(sata_and_sgmii_power_up_params) / sizeof(struct op_params);
1002 serdes_seq_db[SGMII_POWER_UP_SEQ].data_arr_idx = SGMII;
1003
1004
1005 serdes_seq_db[SGMII_1_25_SPEED_CONFIG_SEQ].op_params_ptr =
1006 sata_and_sgmii_speed_config_params;
1007 serdes_seq_db[SGMII_1_25_SPEED_CONFIG_SEQ].cfg_seq_size =
1008 sizeof(sata_and_sgmii_speed_config_params) /
1009 sizeof(struct op_params);
1010 serdes_seq_db[SGMII_1_25_SPEED_CONFIG_SEQ].data_arr_idx = SGMII;
1011
1012
1013 serdes_seq_db[SGMII_3_125_SPEED_CONFIG_SEQ].op_params_ptr =
1014 sata_and_sgmii_speed_config_params;
1015 serdes_seq_db[SGMII_3_125_SPEED_CONFIG_SEQ].cfg_seq_size =
1016 sizeof(sata_and_sgmii_speed_config_params) /
1017 sizeof(struct op_params);
1018 serdes_seq_db[SGMII_3_125_SPEED_CONFIG_SEQ].data_arr_idx = SGMII_3_125;
1019
1020
1021 if (serdes_rev == MV_SERDES_REV_1_2) {
1022 serdes_seq_db[SGMII_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1023 sgmii_electrical_config_serdes_rev1_params;
1024 serdes_seq_db[SGMII_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1025 sizeof(sgmii_electrical_config_serdes_rev1_params) /
1026 sizeof(struct op_params);
1027 } else {
1028 serdes_seq_db[SGMII_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1029 sgmii_electrical_config_serdes_rev2_params;
1030 serdes_seq_db[SGMII_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1031 sizeof(sgmii_electrical_config_serdes_rev2_params) /
1032 sizeof(struct op_params);
1033 }
1034 serdes_seq_db[SGMII_ELECTRICAL_CONFIG_SEQ].data_arr_idx = SGMII;
1035
1036
1037 serdes_seq_db[SGMII_TX_CONFIG_SEQ1].op_params_ptr =
1038 sata_and_sgmii_tx_config_params1;
1039 serdes_seq_db[SGMII_TX_CONFIG_SEQ1].cfg_seq_size =
1040 sizeof(sata_and_sgmii_tx_config_params1) / sizeof(struct op_params);
1041 serdes_seq_db[SGMII_TX_CONFIG_SEQ1].data_arr_idx = SGMII;
1042
1043
1044 if (serdes_rev == MV_SERDES_REV_1_2) {
1045 serdes_seq_db[SGMII_TX_CONFIG_SEQ2].op_params_ptr =
1046 sata_and_sgmii_tx_config_serdes_rev1_params2;
1047 serdes_seq_db[SGMII_TX_CONFIG_SEQ2].cfg_seq_size =
1048 sizeof(sata_and_sgmii_tx_config_serdes_rev1_params2) /
1049 sizeof(struct op_params);
1050 } else {
1051 serdes_seq_db[SGMII_TX_CONFIG_SEQ2].op_params_ptr =
1052 sata_and_sgmii_tx_config_serdes_rev2_params2;
1053 serdes_seq_db[SGMII_TX_CONFIG_SEQ2].cfg_seq_size =
1054 sizeof(sata_and_sgmii_tx_config_serdes_rev2_params2) /
1055 sizeof(struct op_params);
1056 }
1057 serdes_seq_db[SGMII_TX_CONFIG_SEQ2].data_arr_idx = SGMII;
1058
1059
1060 if (serdes_rev == MV_SERDES_REV_1_2) {
1061 serdes_seq_db[PEX_POWER_UP_SEQ].op_params_ptr =
1062 pex_and_usb3_power_up_serdes_rev1_params;
1063 serdes_seq_db[PEX_POWER_UP_SEQ].cfg_seq_size =
1064 sizeof(pex_and_usb3_power_up_serdes_rev1_params) /
1065 sizeof(struct op_params);
1066 } else {
1067 serdes_seq_db[PEX_POWER_UP_SEQ].op_params_ptr =
1068 pex_and_usb3_power_up_serdes_rev2_params;
1069 serdes_seq_db[PEX_POWER_UP_SEQ].cfg_seq_size =
1070 sizeof(pex_and_usb3_power_up_serdes_rev2_params) /
1071 sizeof(struct op_params);
1072 }
1073 serdes_seq_db[PEX_POWER_UP_SEQ].data_arr_idx = PEX;
1074
1075
1076 serdes_seq_db[PEX_2_5_SPEED_CONFIG_SEQ].op_params_ptr =
1077 pex_and_usb3_speed_config_params;
1078 serdes_seq_db[PEX_2_5_SPEED_CONFIG_SEQ].cfg_seq_size =
1079 sizeof(pex_and_usb3_speed_config_params) / sizeof(struct op_params);
1080 serdes_seq_db[PEX_2_5_SPEED_CONFIG_SEQ].data_arr_idx =
1081 PEXSERDES_SPEED_2_5_GBPS;
1082
1083
1084 serdes_seq_db[PEX_5_SPEED_CONFIG_SEQ].op_params_ptr =
1085 pex_and_usb3_speed_config_params;
1086 serdes_seq_db[PEX_5_SPEED_CONFIG_SEQ].cfg_seq_size =
1087 sizeof(pex_and_usb3_speed_config_params) / sizeof(struct op_params);
1088 serdes_seq_db[PEX_5_SPEED_CONFIG_SEQ].data_arr_idx =
1089 PEXSERDES_SPEED_5_GBPS;
1090
1091
1092 if (serdes_rev == MV_SERDES_REV_1_2) {
1093 serdes_seq_db[PEX_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1094 pex_electrical_config_serdes_rev1_params;
1095 serdes_seq_db[PEX_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1096 sizeof(pex_electrical_config_serdes_rev1_params) /
1097 sizeof(struct op_params);
1098 } else {
1099 serdes_seq_db[PEX_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1100 pex_electrical_config_serdes_rev2_params;
1101 serdes_seq_db[PEX_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1102 sizeof(pex_electrical_config_serdes_rev2_params) /
1103 sizeof(struct op_params);
1104 }
1105 serdes_seq_db[PEX_ELECTRICAL_CONFIG_SEQ].data_arr_idx = PEX;
1106
1107
1108 serdes_seq_db[PEX_TX_CONFIG_SEQ1].op_params_ptr =
1109 pex_and_usb3_tx_config_params1;
1110 serdes_seq_db[PEX_TX_CONFIG_SEQ1].cfg_seq_size =
1111 sizeof(pex_and_usb3_tx_config_params1) / sizeof(struct op_params);
1112 serdes_seq_db[PEX_TX_CONFIG_SEQ1].data_arr_idx = PEX;
1113
1114
1115 serdes_seq_db[PEX_TX_CONFIG_SEQ2].op_params_ptr =
1116 pex_and_usb3_tx_config_params2;
1117 serdes_seq_db[PEX_TX_CONFIG_SEQ2].cfg_seq_size =
1118 sizeof(pex_and_usb3_tx_config_params2) / sizeof(struct op_params);
1119 serdes_seq_db[PEX_TX_CONFIG_SEQ2].data_arr_idx = PEX;
1120
1121
1122 serdes_seq_db[PEX_TX_CONFIG_SEQ3].op_params_ptr =
1123 pex_and_usb3_tx_config_params3;
1124 serdes_seq_db[PEX_TX_CONFIG_SEQ3].cfg_seq_size =
1125 sizeof(pex_and_usb3_tx_config_params3) / sizeof(struct op_params);
1126 serdes_seq_db[PEX_TX_CONFIG_SEQ3].data_arr_idx = PEX;
1127
1128
1129 serdes_seq_db[PEX_BY_4_CONFIG_SEQ].op_params_ptr =
1130 pex_by4_config_params;
1131 serdes_seq_db[PEX_BY_4_CONFIG_SEQ].cfg_seq_size =
1132 sizeof(pex_by4_config_params) / sizeof(struct op_params);
1133 serdes_seq_db[PEX_BY_4_CONFIG_SEQ].data_arr_idx = PEX;
1134
1135
1136 serdes_seq_db[PEX_CONFIG_REF_CLOCK_25MHZ_SEQ].op_params_ptr =
1137 pex_config_ref_clock25_m_hz;
1138 serdes_seq_db[PEX_CONFIG_REF_CLOCK_25MHZ_SEQ].cfg_seq_size =
1139 sizeof(pex_config_ref_clock25_m_hz) / sizeof(struct op_params);
1140 serdes_seq_db[PEX_CONFIG_REF_CLOCK_25MHZ_SEQ].data_arr_idx = PEX;
1141
1142
1143 serdes_seq_db[PEX_CONFIG_REF_CLOCK_40MHZ_SEQ].op_params_ptr =
1144 pex_config_ref_clock40_m_hz;
1145 serdes_seq_db[PEX_CONFIG_REF_CLOCK_40MHZ_SEQ].cfg_seq_size =
1146 sizeof(pex_config_ref_clock40_m_hz) / sizeof(struct op_params);
1147 serdes_seq_db[PEX_CONFIG_REF_CLOCK_40MHZ_SEQ].data_arr_idx = PEX;
1148
1149
1150 serdes_seq_db[PEX_CONFIG_REF_CLOCK_100MHZ_SEQ].op_params_ptr =
1151 pex_config_ref_clock100_m_hz;
1152 serdes_seq_db[PEX_CONFIG_REF_CLOCK_100MHZ_SEQ].cfg_seq_size =
1153 sizeof(pex_config_ref_clock100_m_hz) / sizeof(struct op_params);
1154 serdes_seq_db[PEX_CONFIG_REF_CLOCK_100MHZ_SEQ].data_arr_idx = PEX;
1155
1156
1157 if (serdes_rev == MV_SERDES_REV_1_2) {
1158 serdes_seq_db[USB3_POWER_UP_SEQ].op_params_ptr =
1159 pex_and_usb3_power_up_serdes_rev1_params;
1160 serdes_seq_db[USB3_POWER_UP_SEQ].cfg_seq_size =
1161 sizeof(pex_and_usb3_power_up_serdes_rev1_params) /
1162 sizeof(struct op_params);
1163 } else {
1164 serdes_seq_db[USB3_POWER_UP_SEQ].op_params_ptr =
1165 pex_and_usb3_power_up_serdes_rev2_params;
1166 serdes_seq_db[USB3_POWER_UP_SEQ].cfg_seq_size =
1167 sizeof(pex_and_usb3_power_up_serdes_rev2_params) /
1168 sizeof(struct op_params);
1169 }
1170 serdes_seq_db[USB3_POWER_UP_SEQ].data_arr_idx = USB3;
1171
1172
1173 serdes_seq_db[USB3_HOST_SPEED_CONFIG_SEQ].op_params_ptr =
1174 pex_and_usb3_speed_config_params;
1175 serdes_seq_db[USB3_HOST_SPEED_CONFIG_SEQ].cfg_seq_size =
1176 sizeof(pex_and_usb3_speed_config_params) / sizeof(struct op_params);
1177 serdes_seq_db[USB3_HOST_SPEED_CONFIG_SEQ].data_arr_idx =
1178 USB3SERDES_SPEED_5_GBPS_HOST;
1179
1180
1181 serdes_seq_db[USB3_DEVICE_SPEED_CONFIG_SEQ].op_params_ptr =
1182 pex_and_usb3_speed_config_params;
1183 serdes_seq_db[USB3_DEVICE_SPEED_CONFIG_SEQ].cfg_seq_size =
1184 sizeof(pex_and_usb3_speed_config_params) / sizeof(struct op_params);
1185 serdes_seq_db[USB3_DEVICE_SPEED_CONFIG_SEQ].data_arr_idx =
1186 USB3SERDES_SPEED_5_GBPS_DEVICE;
1187
1188
1189 if (serdes_rev == MV_SERDES_REV_1_2) {
1190 serdes_seq_db[USB3_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1191 usb3_electrical_config_serdes_rev1_params;
1192 serdes_seq_db[USB3_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1193 sizeof(usb3_electrical_config_serdes_rev1_params) /
1194 sizeof(struct op_params);
1195 } else {
1196 serdes_seq_db[USB3_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1197 usb3_electrical_config_serdes_rev2_params;
1198 serdes_seq_db[USB3_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1199 sizeof(usb3_electrical_config_serdes_rev2_params) /
1200 sizeof(struct op_params);
1201 }
1202 serdes_seq_db[USB3_ELECTRICAL_CONFIG_SEQ].data_arr_idx = USB3;
1203
1204
1205 serdes_seq_db[USB3_TX_CONFIG_SEQ1].op_params_ptr =
1206 pex_and_usb3_tx_config_params1;
1207 serdes_seq_db[USB3_TX_CONFIG_SEQ1].cfg_seq_size =
1208 sizeof(pex_and_usb3_tx_config_params1) / sizeof(struct op_params);
1209 serdes_seq_db[USB3_TX_CONFIG_SEQ1].data_arr_idx = USB3;
1210
1211
1212 serdes_seq_db[USB3_TX_CONFIG_SEQ2].op_params_ptr =
1213 pex_and_usb3_tx_config_params2;
1214 serdes_seq_db[USB3_TX_CONFIG_SEQ2].cfg_seq_size =
1215 sizeof(pex_and_usb3_tx_config_params2) / sizeof(struct op_params);
1216 serdes_seq_db[USB3_TX_CONFIG_SEQ2].data_arr_idx = USB3;
1217
1218
1219 serdes_seq_db[USB3_TX_CONFIG_SEQ3].op_params_ptr =
1220 pex_and_usb3_tx_config_params3;
1221 serdes_seq_db[USB3_TX_CONFIG_SEQ3].cfg_seq_size =
1222 sizeof(pex_and_usb3_tx_config_params3) / sizeof(struct op_params);
1223 serdes_seq_db[USB3_TX_CONFIG_SEQ3].data_arr_idx = USB3;
1224
1225
1226 serdes_seq_db[USB2_POWER_UP_SEQ].op_params_ptr = usb2_power_up_params;
1227 serdes_seq_db[USB2_POWER_UP_SEQ].cfg_seq_size =
1228 sizeof(usb2_power_up_params) / sizeof(struct op_params);
1229 serdes_seq_db[USB2_POWER_UP_SEQ].data_arr_idx = 0;
1230
1231
1232 serdes_seq_db[USB3_DEVICE_CONFIG_SEQ].op_params_ptr =
1233 usb3_device_config_params;
1234 serdes_seq_db[USB3_DEVICE_CONFIG_SEQ].cfg_seq_size =
1235 sizeof(usb3_device_config_params) / sizeof(struct op_params);
1236 serdes_seq_db[USB3_DEVICE_CONFIG_SEQ].data_arr_idx = 0;
1237
1238
1239 serdes_seq_db[SERDES_POWER_DOWN_SEQ].op_params_ptr =
1240 serdes_power_down_params;
1241 serdes_seq_db[SERDES_POWER_DOWN_SEQ].cfg_seq_size =
1242 sizeof(serdes_power_down_params) /
1243 sizeof(struct op_params);
1244 serdes_seq_db[SERDES_POWER_DOWN_SEQ].data_arr_idx = FIRST_CELL;
1245
1246 if (serdes_rev == MV_SERDES_REV_2_1) {
1247
1248 serdes_seq_db[QSGMII_POWER_UP_SEQ].op_params_ptr =
1249 qsgmii_port_power_up_params;
1250 serdes_seq_db[QSGMII_POWER_UP_SEQ].cfg_seq_size =
1251 sizeof(qsgmii_port_power_up_params) /
1252 sizeof(struct op_params);
1253 serdes_seq_db[QSGMII_POWER_UP_SEQ].data_arr_idx =
1254 QSGMII_SEQ_IDX;
1255
1256
1257 serdes_seq_db[QSGMII_5_SPEED_CONFIG_SEQ].op_params_ptr =
1258 qsgmii_port_speed_config_params;
1259 serdes_seq_db[QSGMII_5_SPEED_CONFIG_SEQ].cfg_seq_size =
1260 sizeof(qsgmii_port_speed_config_params) /
1261 sizeof(struct op_params);
1262 serdes_seq_db[QSGMII_5_SPEED_CONFIG_SEQ].data_arr_idx =
1263 QSGMII_SEQ_IDX;
1264
1265
1266 serdes_seq_db[QSGMII_ELECTRICAL_CONFIG_SEQ].op_params_ptr =
1267 qsgmii_port_electrical_config_params;
1268 serdes_seq_db[QSGMII_ELECTRICAL_CONFIG_SEQ].cfg_seq_size =
1269 sizeof(qsgmii_port_electrical_config_params) /
1270 sizeof(struct op_params);
1271 serdes_seq_db[QSGMII_ELECTRICAL_CONFIG_SEQ].data_arr_idx =
1272 QSGMII_SEQ_IDX;
1273
1274
1275 serdes_seq_db[QSGMII_TX_CONFIG_SEQ1].op_params_ptr =
1276 qsgmii_port_tx_config_params1;
1277 serdes_seq_db[QSGMII_TX_CONFIG_SEQ1].cfg_seq_size =
1278 sizeof(qsgmii_port_tx_config_params1) /
1279 sizeof(struct op_params);
1280 serdes_seq_db[QSGMII_TX_CONFIG_SEQ1].data_arr_idx =
1281 QSGMII_SEQ_IDX;
1282
1283
1284 serdes_seq_db[QSGMII_TX_CONFIG_SEQ2].op_params_ptr =
1285 qsgmii_port_tx_config_params2;
1286 serdes_seq_db[QSGMII_TX_CONFIG_SEQ2].cfg_seq_size =
1287 sizeof(qsgmii_port_tx_config_params2) /
1288 sizeof(struct op_params);
1289 serdes_seq_db[QSGMII_TX_CONFIG_SEQ2].data_arr_idx =
1290 QSGMII_SEQ_IDX;
1291 }
1292
1293 return MV_OK;
1294}
1295
1296enum serdes_seq serdes_type_and_speed_to_speed_seq(enum serdes_type serdes_type,
1297 enum serdes_speed baud_rate)
1298{
1299 enum serdes_seq seq_id = SERDES_LAST_SEQ;
1300
1301 DEBUG_INIT_FULL_S("\n### serdes_type_and_speed_to_speed_seq ###\n");
1302 switch (serdes_type) {
1303 case PEX0:
1304 case PEX1:
1305 case PEX2:
1306 case PEX3:
1307 if (baud_rate == SERDES_SPEED_2_5_GBPS)
1308 seq_id = PEX_2_5_SPEED_CONFIG_SEQ;
1309 else if (baud_rate == SERDES_SPEED_5_GBPS)
1310 seq_id = PEX_5_SPEED_CONFIG_SEQ;
1311 break;
1312 case USB3_HOST0:
1313 case USB3_HOST1:
1314 if (baud_rate == SERDES_SPEED_5_GBPS)
1315 seq_id = USB3_HOST_SPEED_CONFIG_SEQ;
1316 break;
1317 case USB3_DEVICE:
1318 if (baud_rate == SERDES_SPEED_5_GBPS)
1319 seq_id = USB3_DEVICE_SPEED_CONFIG_SEQ;
1320 break;
1321 case SATA0:
1322 case SATA1:
1323 case SATA2:
1324 case SATA3:
1325 if (baud_rate == SERDES_SPEED_1_5_GBPS)
1326 seq_id = SATA_1_5_SPEED_CONFIG_SEQ;
1327 else if (baud_rate == SERDES_SPEED_3_GBPS)
1328 seq_id = SATA_3_SPEED_CONFIG_SEQ;
1329 else if (baud_rate == SERDES_SPEED_6_GBPS)
1330 seq_id = SATA_6_SPEED_CONFIG_SEQ;
1331 break;
1332 case SGMII0:
1333 case SGMII1:
1334 case SGMII2:
1335#ifdef CONFIG_ARMADA_39X
1336 case SGMII3:
1337#endif
1338 if (baud_rate == SERDES_SPEED_1_25_GBPS)
1339 seq_id = SGMII_1_25_SPEED_CONFIG_SEQ;
1340 else if (baud_rate == SERDES_SPEED_3_125_GBPS)
1341 seq_id = SGMII_3_125_SPEED_CONFIG_SEQ;
1342 break;
1343 case QSGMII:
1344 seq_id = QSGMII_5_SPEED_CONFIG_SEQ;
1345 break;
1346#ifdef CONFIG_ARMADA_39X
1347 case XAUI:
1348 seq_id = XAUI_3_125_SPEED_CONFIG_SEQ;
1349 break;
1350 case RXAUI:
1351 seq_id = RXAUI_6_25_SPEED_CONFIG_SEQ;
1352 break;
1353#endif
1354 default:
1355 return SERDES_LAST_SEQ;
1356 }
1357
1358 return seq_id;
1359}
1360
1361static void print_topology_details(const struct serdes_map *serdes_map,
1362 u8 count)
1363{
1364 u32 lane_num;
1365
1366 DEBUG_INIT_S("board SerDes lanes topology details:\n");
1367
1368 DEBUG_INIT_S(" | Lane # | Speed | Type |\n");
1369 DEBUG_INIT_S(" --------------------------------\n");
1370 for (lane_num = 0; lane_num < count; lane_num++) {
1371 if (serdes_map[lane_num].serdes_type == DEFAULT_SERDES)
1372 continue;
1373 DEBUG_INIT_S(" | ");
1374 DEBUG_INIT_D(hws_get_physical_serdes_num(lane_num), 1);
1375 DEBUG_INIT_S(" | ");
1376 DEBUG_INIT_D(serdes_map[lane_num].serdes_speed, 2);
1377 DEBUG_INIT_S(" | ");
1378 DEBUG_INIT_S((char *)
1379 serdes_type_to_string[serdes_map[lane_num].
1380 serdes_type]);
1381 DEBUG_INIT_S("\t|\n");
1382 }
1383 DEBUG_INIT_S(" --------------------------------\n");
1384}
1385
1386int hws_pre_serdes_init_config(void)
1387{
1388 u32 data;
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401 reg_write(CORE_PLL_PARAMETERS_REG, 0x42e9f003);
1402
1403
1404 data = reg_read(CORE_PLL_CONFIG_REG);
1405 data = SET_BIT(data, 9);
1406 reg_write(CORE_PLL_CONFIG_REG, data);
1407
1408 return MV_OK;
1409}
1410
1411int serdes_phy_config(void)
1412{
1413 struct serdes_map *serdes_map;
1414 u8 serdes_count;
1415
1416 DEBUG_INIT_FULL_S("\n### ctrl_high_speed_serdes_phy_config ###\n");
1417
1418 DEBUG_INIT_S("High speed PHY - Version: ");
1419 DEBUG_INIT_S(SERDES_VERION);
1420 DEBUG_INIT_S("\n");
1421
1422
1423 if (hws_serdes_seq_init() != MV_OK) {
1424 printf("hws_ctrl_high_speed_serdes_phy_config: Error: Serdes initialization fail\n");
1425 return MV_FAIL;
1426 }
1427
1428
1429 DEBUG_INIT_FULL_S
1430 ("ctrl_high_speed_serdes_phy_config: Loading board topology..\n");
1431 CHECK_STATUS(hws_board_topology_load(&serdes_map, &serdes_count));
1432 if (serdes_count > hws_serdes_get_max_lane()) {
1433 printf("Error: too many serdes lanes specified by board\n");
1434 return MV_FAIL;
1435 }
1436
1437
1438 print_topology_details(serdes_map, serdes_count);
1439 CHECK_STATUS(hws_pre_serdes_init_config());
1440
1441
1442 DEBUG_INIT_FULL_S
1443 ("ctrl_high_speed_serdes_phy_config: Starting serdes power up sequence\n");
1444
1445 CHECK_STATUS(hws_power_up_serdes_lanes(serdes_map, serdes_count));
1446
1447 DEBUG_INIT_FULL_S
1448 ("\n### ctrl_high_speed_serdes_phy_config ended successfully ###\n");
1449
1450 DEBUG_INIT_S(ENDED_OK);
1451
1452 return MV_OK;
1453}
1454
1455int serdes_polarity_config(u32 serdes_num, int is_rx)
1456{
1457 u32 data;
1458 u32 reg_addr;
1459 u8 bit_off = (is_rx) ? 11 : 10;
1460
1461 reg_addr = SERDES_REGS_LANE_BASE_OFFSET(serdes_num) + SYNC_PATTERN_REG;
1462 data = reg_read(reg_addr);
1463 data = SET_BIT(data, bit_off);
1464 reg_write(reg_addr, data);
1465
1466 return MV_OK;
1467}
1468
1469int hws_power_up_serdes_lanes(struct serdes_map *serdes_map, u8 count)
1470{
1471 u32 serdes_id, serdes_lane_num;
1472 enum ref_clock ref_clock;
1473 enum serdes_type serdes_type;
1474 enum serdes_speed serdes_speed;
1475 enum serdes_mode serdes_mode;
1476 int serdes_rx_polarity_swap;
1477 int serdes_tx_polarity_swap;
1478 int is_pex_enabled = 0;
1479
1480
1481
1482
1483
1484
1485
1486 DEBUG_INIT_FULL_S("\n### hws_power_up_serdes_lanes ###\n");
1487
1488
1489 DEBUG_INIT_FULL_S
1490 ("hws_power_up_serdes_lanes: Updating COMMON PHYS SELECTORS reg\n");
1491 CHECK_STATUS(hws_update_serdes_phy_selectors(serdes_map, count));
1492
1493
1494 for (serdes_id = 0; serdes_id < count; serdes_id++) {
1495 DEBUG_INIT_FULL_S
1496 ("calling serdes_power_up_ctrl: serdes lane number ");
1497 DEBUG_INIT_FULL_D_10(serdes_lane_num, 1);
1498 DEBUG_INIT_FULL_S("\n");
1499
1500 serdes_lane_num = hws_get_physical_serdes_num(serdes_id);
1501 serdes_type = serdes_map[serdes_id].serdes_type;
1502 serdes_speed = serdes_map[serdes_id].serdes_speed;
1503 serdes_mode = serdes_map[serdes_id].serdes_mode;
1504 serdes_rx_polarity_swap = serdes_map[serdes_id].swap_rx;
1505 serdes_tx_polarity_swap = serdes_map[serdes_id].swap_tx;
1506
1507
1508 if (serdes_type == DEFAULT_SERDES)
1509 continue;
1510 else if (serdes_type <= PEX3)
1511 is_pex_enabled = 1;
1512
1513 ref_clock = hws_serdes_get_ref_clock_val(serdes_type);
1514 if (ref_clock == REF_CLOCK_UNSUPPORTED) {
1515 DEBUG_INIT_S
1516 ("hws_power_up_serdes_lanes: unsupported ref clock\n");
1517 return MV_NOT_SUPPORTED;
1518 }
1519 CHECK_STATUS(serdes_power_up_ctrl(serdes_lane_num,
1520 1,
1521 serdes_type,
1522 serdes_speed,
1523 serdes_mode, ref_clock));
1524
1525
1526 if (serdes_rx_polarity_swap)
1527 CHECK_STATUS(serdes_polarity_config
1528 (serdes_lane_num, 1));
1529
1530
1531 if (serdes_tx_polarity_swap)
1532 CHECK_STATUS(serdes_polarity_config
1533 (serdes_lane_num, 0));
1534 }
1535
1536 if (is_pex_enabled) {
1537
1538
1539
1540 CHECK_STATUS(hws_pex_tx_config_seq(serdes_map, count));
1541
1542
1543 CHECK_STATUS(hws_pex_config(serdes_map, count));
1544 }
1545
1546
1547 DEBUG_INIT_FULL_S("hws_power_up_serdes_lanes: init USB2 Phys\n");
1548 CHECK_STATUS(mv_seq_exec(0 , USB2_POWER_UP_SEQ));
1549
1550 DEBUG_INIT_FULL_S
1551 ("### hws_power_up_serdes_lanes ended successfully ###\n");
1552
1553 return MV_OK;
1554}
1555
1556int ctrl_high_speed_serdes_phy_config(void)
1557{
1558 return hws_ctrl_high_speed_serdes_phy_config();
1559}
1560
1561static int serdes_pex_usb3_pipe_delay_w_a(u32 serdes_num, u8 serdes_type)
1562{
1563 u32 reg_data;
1564
1565
1566 if (serdes_num >= 3) {
1567 reg_data = reg_read(GENERAL_PURPOSE_RESERVED0_REG);
1568
1569
1570
1571
1572
1573
1574
1575
1576 if (serdes_type == PEX)
1577 reg_data |= 1 << (7 + (serdes_num - 3));
1578 if (serdes_type == USB3) {
1579
1580 reg_data &= ~(1 << (7 + (serdes_num - 3)));
1581 }
1582 reg_write(GENERAL_PURPOSE_RESERVED0_REG, reg_data);
1583 }
1584
1585 return MV_OK;
1586}
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609int hws_serdes_pex_ref_clock_satr_get(enum serdes_type serdes_type, u32 *pex_satr)
1610{
1611 u32 data, reg_satr1;
1612
1613 reg_satr1 = reg_read(DEVICE_SAMPLE_AT_RESET1_REG);
1614
1615 switch (serdes_type) {
1616 case PEX0:
1617 data = REF_CLK_SELECTOR_VAL_PEX0(reg_satr1);
1618 break;
1619 case PEX1:
1620 data = REF_CLK_SELECTOR_VAL_PEX1(reg_satr1);
1621 break;
1622 case PEX2:
1623 data = REF_CLK_SELECTOR_VAL_PEX2(reg_satr1);
1624 break;
1625 case PEX3:
1626 data = REF_CLK_SELECTOR_VAL_PEX3(reg_satr1);
1627 break;
1628 default:
1629 printf("%s: Error: SerDes type %d is not supported\n",
1630 __func__, serdes_type);
1631 return MV_BAD_PARAM;
1632 }
1633
1634 *pex_satr = data;
1635
1636 return MV_OK;
1637}
1638
1639u32 hws_serdes_get_ref_clock_val(enum serdes_type serdes_type)
1640{
1641 u32 pex_satr;
1642 enum ref_clock ref_clock;
1643
1644 DEBUG_INIT_FULL_S("\n### hws_serdes_get_ref_clock_val ###\n");
1645
1646 if (serdes_type >= LAST_SERDES_TYPE)
1647 return REF_CLOCK_UNSUPPORTED;
1648
1649
1650 ref_clock = hws_serdes_silicon_ref_clock_get();
1651
1652 if (serdes_type > PEX3) {
1653
1654 return ref_clock;
1655 }
1656
1657
1658 CHECK_STATUS(hws_serdes_pex_ref_clock_satr_get
1659 (serdes_type, &pex_satr));
1660
1661 if (pex_satr == 0) {
1662 return REF_CLOCK_100MHZ;
1663 } else if (pex_satr == 1) {
1664
1665 return ref_clock;
1666 } else {
1667 printf
1668 ("%s: Error: REF_CLK_SELECTOR_VAL for SerDes type %d is wrong\n",
1669 __func__, serdes_type);
1670 return REF_CLOCK_UNSUPPORTED;
1671 }
1672}
1673
1674int serdes_power_up_ctrl(u32 serdes_num, int serdes_power_up,
1675 enum serdes_type serdes_type,
1676 enum serdes_speed baud_rate,
1677 enum serdes_mode serdes_mode, enum ref_clock ref_clock)
1678{
1679 u32 sata_idx, pex_idx, sata_port;
1680 enum serdes_seq speed_seq_id;
1681 u32 reg_data;
1682 int is_pex_by1;
1683
1684 DEBUG_INIT_FULL_S("\n### serdes_power_up_ctrl ###\n");
1685
1686 if (serdes_power_up == 1) {
1687 DEBUG_INIT_FULL_S
1688 ("serdes_power_up_ctrl: executing power up.. ");
1689 DEBUG_INIT_FULL_C("serdes num = ", serdes_num, 2);
1690 DEBUG_INIT_FULL_C("serdes type = ", serdes_type, 2);
1691
1692 DEBUG_INIT_FULL_S("Going access 1");
1693
1694
1695 speed_seq_id =
1696 serdes_type_and_speed_to_speed_seq(serdes_type,
1697 baud_rate);
1698 if (speed_seq_id == SERDES_LAST_SEQ) {
1699 printf
1700 ("serdes_power_up_ctrl: serdes type %d and speed %d are not supported together\n",
1701 serdes_type, baud_rate);
1702
1703 return MV_BAD_PARAM;
1704 }
1705
1706
1707 switch (serdes_type) {
1708 case PEX0:
1709 case PEX1:
1710 case PEX2:
1711 case PEX3:
1712 if (hws_ctrl_serdes_rev_get() == MV_SERDES_REV_1_2) {
1713 CHECK_STATUS(serdes_pex_usb3_pipe_delay_w_a
1714 (serdes_num, PEX));
1715 }
1716
1717 is_pex_by1 = (serdes_mode == PEX_ROOT_COMPLEX_X1) ||
1718 (serdes_mode == PEX_END_POINT_X1);
1719 pex_idx = serdes_type - PEX0;
1720
1721 if ((is_pex_by1 == 1) || (serdes_type == PEX0)) {
1722
1723 reg_data = reg_read(SOC_CONTROL_REG1);
1724 if (is_pex_by1 == 1)
1725 reg_data |= 0x4000;
1726 else
1727 reg_data &= ~0x4000;
1728 reg_write(SOC_CONTROL_REG1, reg_data);
1729
1730 reg_data =
1731 reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
1732 0x6c));
1733 reg_data &= ~0x3f0;
1734 if (is_pex_by1 == 1)
1735 reg_data |= 0x10;
1736 else
1737 reg_data |= 0x40;
1738 reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x6c),
1739 reg_data);
1740
1741 reg_data =
1742 reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
1743 0x6c));
1744 reg_data &= ~0xf;
1745 reg_data |= 0x2;
1746 reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x6c),
1747 reg_data);
1748
1749 reg_data =
1750 reg_read(((PEX_IF_REGS_BASE(pex_idx)) +
1751 0x70));
1752 reg_data &= ~0x40;
1753 reg_data |= 0x40;
1754 reg_write(((PEX_IF_REGS_BASE(pex_idx)) + 0x70),
1755 reg_data);
1756 }
1757
1758 CHECK_STATUS(mv_seq_exec(serdes_num, PEX_POWER_UP_SEQ));
1759 if (is_pex_by1 == 0) {
1760
1761
1762
1763
1764 serdes_seq_db[PEX_BY_4_CONFIG_SEQ].
1765 data_arr_idx = pex_idx;
1766 CHECK_STATUS(mv_seq_exec
1767 (serdes_num, PEX_BY_4_CONFIG_SEQ));
1768 }
1769
1770 CHECK_STATUS(hws_ref_clock_set
1771 (serdes_num, serdes_type, ref_clock));
1772 CHECK_STATUS(mv_seq_exec(serdes_num, speed_seq_id));
1773 CHECK_STATUS(mv_seq_exec
1774 (serdes_num, PEX_ELECTRICAL_CONFIG_SEQ));
1775
1776 if (is_pex_by1 == 1) {
1777 CHECK_STATUS(mv_seq_exec
1778 (serdes_num, PEX_TX_CONFIG_SEQ2));
1779 CHECK_STATUS(mv_seq_exec
1780 (serdes_num, PEX_TX_CONFIG_SEQ3));
1781 CHECK_STATUS(mv_seq_exec
1782 (serdes_num, PEX_TX_CONFIG_SEQ1));
1783 }
1784 udelay(20);
1785
1786 break;
1787 case USB3_HOST0:
1788 case USB3_HOST1:
1789 case USB3_DEVICE:
1790 if (hws_ctrl_serdes_rev_get() == MV_SERDES_REV_1_2) {
1791 CHECK_STATUS(serdes_pex_usb3_pipe_delay_w_a
1792 (serdes_num, USB3));
1793 }
1794 CHECK_STATUS(mv_seq_exec
1795 (serdes_num, USB3_POWER_UP_SEQ));
1796 CHECK_STATUS(hws_ref_clock_set
1797 (serdes_num, serdes_type, ref_clock));
1798 CHECK_STATUS(mv_seq_exec(serdes_num, speed_seq_id));
1799 if (serdes_type == USB3_DEVICE) {
1800 CHECK_STATUS(mv_seq_exec
1801 (serdes_num,
1802 USB3_DEVICE_CONFIG_SEQ));
1803 }
1804 CHECK_STATUS(mv_seq_exec
1805 (serdes_num, USB3_ELECTRICAL_CONFIG_SEQ));
1806 CHECK_STATUS(mv_seq_exec
1807 (serdes_num, USB3_TX_CONFIG_SEQ1));
1808 CHECK_STATUS(mv_seq_exec
1809 (serdes_num, USB3_TX_CONFIG_SEQ2));
1810 CHECK_STATUS(mv_seq_exec
1811 (serdes_num, USB3_TX_CONFIG_SEQ3));
1812
1813 udelay(10000);
1814 break;
1815 case SATA0:
1816 case SATA1:
1817 case SATA2:
1818 case SATA3:
1819 sata_idx = ((serdes_type == SATA0) ||
1820 (serdes_type == SATA1)) ? 0 : 1;
1821 sata_port = ((serdes_type == SATA0) ||
1822 (serdes_type == SATA2)) ? 0 : 1;
1823
1824 CHECK_STATUS(mv_seq_exec
1825 (sata_idx, (sata_port == 0) ?
1826 SATA_PORT_0_ONLY_POWER_UP_SEQ :
1827 SATA_PORT_1_ONLY_POWER_UP_SEQ));
1828 CHECK_STATUS(mv_seq_exec
1829 (serdes_num, SATA_POWER_UP_SEQ));
1830 CHECK_STATUS(hws_ref_clock_set
1831 (serdes_num, serdes_type, ref_clock));
1832 CHECK_STATUS(mv_seq_exec(serdes_num, speed_seq_id));
1833 CHECK_STATUS(mv_seq_exec
1834 (serdes_num, SATA_ELECTRICAL_CONFIG_SEQ));
1835 CHECK_STATUS(mv_seq_exec
1836 (serdes_num, SATA_TX_CONFIG_SEQ1));
1837 CHECK_STATUS(mv_seq_exec
1838 (sata_idx, (sata_port == 0) ?
1839 SATA_PORT_0_ONLY_TX_CONFIG_SEQ :
1840 SATA_PORT_1_ONLY_TX_CONFIG_SEQ));
1841 CHECK_STATUS(mv_seq_exec
1842 (serdes_num, SATA_TX_CONFIG_SEQ2));
1843
1844 udelay(10000);
1845 break;
1846 case SGMII0:
1847 case SGMII1:
1848 case SGMII2:
1849 CHECK_STATUS(mv_seq_exec
1850 (serdes_num, SGMII_POWER_UP_SEQ));
1851 CHECK_STATUS(hws_ref_clock_set
1852 (serdes_num, serdes_type, ref_clock));
1853 CHECK_STATUS(mv_seq_exec(serdes_num, speed_seq_id));
1854 CHECK_STATUS(mv_seq_exec
1855 (serdes_num, SGMII_ELECTRICAL_CONFIG_SEQ));
1856 CHECK_STATUS(mv_seq_exec
1857 (serdes_num, SGMII_TX_CONFIG_SEQ1));
1858 CHECK_STATUS(mv_seq_exec
1859 (serdes_num, SGMII_TX_CONFIG_SEQ2));
1860
1861
1862 reg_data = reg_read(GBE_CONFIGURATION_REG);
1863
1864 reg_data |= 0x1 << (serdes_type - SGMII0);
1865 reg_write(GBE_CONFIGURATION_REG, reg_data);
1866
1867 break;
1868 case QSGMII:
1869 if (hws_ctrl_serdes_rev_get() < MV_SERDES_REV_2_1)
1870 return MV_NOT_SUPPORTED;
1871
1872 CHECK_STATUS(mv_seq_exec
1873 (serdes_num, QSGMII_POWER_UP_SEQ));
1874 CHECK_STATUS(hws_ref_clock_set
1875 (serdes_num, serdes_type, ref_clock));
1876 CHECK_STATUS(mv_seq_exec(serdes_num, speed_seq_id));
1877 CHECK_STATUS(mv_seq_exec
1878 (serdes_num,
1879 QSGMII_ELECTRICAL_CONFIG_SEQ));
1880 CHECK_STATUS(mv_seq_exec
1881 (serdes_num, QSGMII_TX_CONFIG_SEQ1));
1882 CHECK_STATUS(mv_seq_exec
1883 (serdes_num, QSGMII_TX_CONFIG_SEQ2));
1884 break;
1885 case SGMII3:
1886 case XAUI:
1887 case RXAUI:
1888 CHECK_STATUS(serdes_power_up_ctrl_ext
1889 (serdes_num, serdes_power_up, serdes_type,
1890 baud_rate, serdes_mode, ref_clock));
1891 break;
1892 default:
1893 DEBUG_INIT_S
1894 ("serdes_power_up_ctrl: bad serdes_type parameter\n");
1895 return MV_BAD_PARAM;
1896 }
1897 } else {
1898 DEBUG_INIT_FULL_S("serdes_power_up: executing power down.. ");
1899 DEBUG_INIT_FULL_C("serdes num = ", serdes_num, 1);
1900
1901 CHECK_STATUS(mv_seq_exec(serdes_num, SERDES_POWER_DOWN_SEQ));
1902 }
1903
1904 DEBUG_INIT_FULL_C(
1905 "serdes_power_up_ctrl ended successfully for serdes ",
1906 serdes_num, 2);
1907
1908 return MV_OK;
1909}
1910
1911int hws_update_serdes_phy_selectors(struct serdes_map *serdes_map, u8 count)
1912{
1913 u32 lane_data, idx, serdes_lane_hw_num, reg_data = 0;
1914 enum serdes_type serdes_type;
1915 enum serdes_mode serdes_mode;
1916 u8 select_bit_off;
1917 int is_pex_x4 = 0;
1918 int updated_topology_print = 0;
1919
1920 DEBUG_INIT_FULL_S("\n### hws_update_serdes_phy_selectors ###\n");
1921 DEBUG_INIT_FULL_S
1922 ("Updating the COMMON PHYS SELECTORS register with the serdes types\n");
1923
1924 if (hws_ctrl_serdes_rev_get() == MV_SERDES_REV_1_2)
1925 select_bit_off = 3;
1926 else
1927 select_bit_off = 4;
1928
1929
1930
1931
1932
1933 for (idx = 0; idx < count; idx++) {
1934 serdes_type = serdes_map[idx].serdes_type;
1935 serdes_mode = serdes_map[idx].serdes_mode;
1936 serdes_lane_hw_num = hws_get_physical_serdes_num(idx);
1937
1938 lane_data =
1939 hws_serdes_get_phy_selector_val(serdes_lane_hw_num,
1940 serdes_type);
1941
1942 if (serdes_type == DEFAULT_SERDES)
1943 continue;
1944
1945 if (hws_serdes_topology_verify
1946 (serdes_type, idx, serdes_mode) != MV_OK) {
1947 serdes_map[idx].serdes_type =
1948 DEFAULT_SERDES;
1949 printf("%s: SerDes lane #%d is disabled\n", __func__,
1950 serdes_lane_hw_num);
1951 updated_topology_print = 1;
1952 continue;
1953 }
1954
1955
1956
1957
1958
1959 if ((serdes_mode == PEX_END_POINT_X4) ||
1960 (serdes_mode == PEX_ROOT_COMPLEX_X4)) {
1961
1962 lane_data =
1963 common_phys_selectors_pex_by4_lanes
1964 [serdes_lane_hw_num];
1965 if (serdes_type == PEX0)
1966 is_pex_x4 = 1;
1967 }
1968
1969 if (lane_data == NA) {
1970 printf
1971 ("%s: Warning: SerDes lane #%d and type %d are not supported together\n",
1972 __func__, serdes_lane_hw_num, serdes_mode);
1973 serdes_map[idx].serdes_type = DEFAULT_SERDES;
1974 printf("%s: SerDes lane #%d is disabled\n", __func__,
1975 serdes_lane_hw_num);
1976 continue;
1977 }
1978
1979
1980
1981
1982
1983 reg_data |= (lane_data <<
1984 (select_bit_off * serdes_lane_hw_num));
1985 }
1986
1987
1988
1989
1990
1991 hws_serdes_xaui_topology_verify();
1992
1993
1994 if (updated_topology_print)
1995 print_topology_details(serdes_map, count);
1996
1997
1998
1999
2000
2001 reg_data |= (is_pex_x4 == 1) ? (0x1 << PEX_X4_ENABLE_OFFS) : 0;
2002
2003
2004 reg_write(COMMON_PHYS_SELECTORS_REG, reg_data);
2005
2006 return MV_OK;
2007}
2008
2009int hws_ref_clock_set(u32 serdes_num, enum serdes_type serdes_type,
2010 enum ref_clock ref_clock)
2011{
2012 u32 data1 = 0, data2 = 0, data3 = 0, reg_data;
2013
2014 DEBUG_INIT_FULL_S("\n### hws_ref_clock_set ###\n");
2015
2016 if (hws_is_serdes_active(serdes_num) != 1) {
2017 printf("%s: SerDes lane #%d is not Active\n", __func__,
2018 serdes_num);
2019 return MV_BAD_PARAM;
2020 }
2021
2022 switch (serdes_type) {
2023 case PEX0:
2024 case PEX1:
2025 case PEX2:
2026 case PEX3:
2027 switch (ref_clock) {
2028 case REF_CLOCK_25MHZ:
2029 CHECK_STATUS(mv_seq_exec
2030 (serdes_num,
2031 PEX_CONFIG_REF_CLOCK_25MHZ_SEQ));
2032 return MV_OK;
2033 case REF_CLOCK_100MHZ:
2034 CHECK_STATUS(mv_seq_exec
2035 (serdes_num,
2036 PEX_CONFIG_REF_CLOCK_100MHZ_SEQ));
2037 return MV_OK;
2038#ifdef CONFIG_ARMADA_39X
2039 case REF_CLOCK_40MHZ:
2040 CHECK_STATUS(mv_seq_exec
2041 (serdes_num,
2042 PEX_CONFIG_REF_CLOCK_40MHZ_SEQ));
2043 return MV_OK;
2044#endif
2045 default:
2046 printf
2047 ("%s: Error: ref_clock %d for SerDes lane #%d, type %d is not supported\n",
2048 __func__, ref_clock, serdes_num, serdes_type);
2049 return MV_BAD_PARAM;
2050 }
2051 case USB3_HOST0:
2052 case USB3_HOST1:
2053 case USB3_DEVICE:
2054 if (ref_clock == REF_CLOCK_25MHZ) {
2055 data1 = POWER_AND_PLL_CTRL_REG_25MHZ_VAL_2;
2056 data2 = GLOBAL_PM_CTRL_REG_25MHZ_VAL;
2057 data3 = LANE_CFG4_REG_25MHZ_VAL;
2058 } else if (ref_clock == REF_CLOCK_40MHZ) {
2059 data1 = POWER_AND_PLL_CTRL_REG_40MHZ_VAL;
2060 data2 = GLOBAL_PM_CTRL_REG_40MHZ_VAL;
2061 data3 = LANE_CFG4_REG_40MHZ_VAL;
2062 } else {
2063 printf
2064 ("hws_ref_clock_set: ref clock is not valid for serdes type %d\n",
2065 serdes_type);
2066 return MV_BAD_PARAM;
2067 }
2068 break;
2069 case SATA0:
2070 case SATA1:
2071 case SATA2:
2072 case SATA3:
2073 case SGMII0:
2074 case SGMII1:
2075 case SGMII2:
2076 case QSGMII:
2077 if (ref_clock == REF_CLOCK_25MHZ) {
2078 data1 = POWER_AND_PLL_CTRL_REG_25MHZ_VAL_1;
2079 } else if (ref_clock == REF_CLOCK_40MHZ) {
2080 data1 = POWER_AND_PLL_CTRL_REG_40MHZ_VAL;
2081 } else {
2082 printf
2083 ("hws_ref_clock_set: ref clock is not valid for serdes type %d\n",
2084 serdes_type);
2085 return MV_BAD_PARAM;
2086 }
2087 break;
2088#ifdef CONFIG_ARMADA_39X
2089 case SGMII3:
2090 case XAUI:
2091 case RXAUI:
2092 if (ref_clock == REF_CLOCK_25MHZ) {
2093 data1 = POWER_AND_PLL_CTRL_REG_25MHZ_VAL_1;
2094 } else if (ref_clock == REF_CLOCK_40MHZ) {
2095 data1 = POWER_AND_PLL_CTRL_REG_40MHZ_VAL;
2096 } else {
2097 printf
2098 ("hws_ref_clock_set: ref clock is not valid for serdes type %d\n",
2099 serdes_type);
2100 return MV_BAD_PARAM;
2101 }
2102 break;
2103#endif
2104 default:
2105 DEBUG_INIT_S("hws_ref_clock_set: not supported serdes type\n");
2106 return MV_BAD_PARAM;
2107 }
2108
2109
2110
2111
2112
2113 reg_data = reg_read(POWER_AND_PLL_CTRL_REG +
2114 SERDES_REGS_LANE_BASE_OFFSET(serdes_num));
2115 reg_data &= POWER_AND_PLL_CTRL_REG_MASK;
2116 reg_data |= data1;
2117 reg_write(POWER_AND_PLL_CTRL_REG +
2118 SERDES_REGS_LANE_BASE_OFFSET(serdes_num), reg_data);
2119
2120 if ((serdes_type == USB3_HOST0) || (serdes_type == USB3_HOST1) ||
2121 (serdes_type == USB3_DEVICE)) {
2122 reg_data = reg_read(GLOBAL_PM_CTRL +
2123 SERDES_REGS_LANE_BASE_OFFSET(serdes_num));
2124 reg_data &= GLOBAL_PM_CTRL_REG_MASK;
2125 reg_data |= data2;
2126 reg_write(GLOBAL_PM_CTRL +
2127 SERDES_REGS_LANE_BASE_OFFSET(serdes_num), reg_data);
2128
2129 reg_data = reg_read(LANE_CFG4_REG +
2130 SERDES_REGS_LANE_BASE_OFFSET(serdes_num));
2131 reg_data &= LANE_CFG4_REG_MASK;
2132 reg_data |= data3;
2133 reg_write(LANE_CFG4_REG +
2134 SERDES_REGS_LANE_BASE_OFFSET(serdes_num), reg_data);
2135 }
2136
2137 return MV_OK;
2138}
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149int hws_pex_tx_config_seq(const struct serdes_map *serdes_map, u8 count)
2150{
2151 enum serdes_mode serdes_mode;
2152 u32 serdes_lane_id, serdes_lane_hw_num;
2153
2154 DEBUG_INIT_FULL_S("\n### hws_pex_tx_config_seq ###\n");
2155
2156
2157
2158
2159
2160
2161
2162
2163 for (serdes_lane_id = 0; serdes_lane_id < count; serdes_lane_id++) {
2164 serdes_mode = serdes_map[serdes_lane_id].serdes_mode;
2165 serdes_lane_hw_num =
2166 hws_get_physical_serdes_num(serdes_lane_id);
2167
2168 if ((serdes_mode == PEX_ROOT_COMPLEX_X4) ||
2169 (serdes_mode == PEX_END_POINT_X4)) {
2170 CHECK_STATUS(mv_seq_exec
2171 (serdes_lane_hw_num, PEX_TX_CONFIG_SEQ1));
2172 }
2173 }
2174
2175
2176 for (serdes_lane_id = 0; serdes_lane_id < count; serdes_lane_id++) {
2177 serdes_mode = serdes_map[serdes_lane_id].serdes_mode;
2178 serdes_lane_hw_num =
2179 hws_get_physical_serdes_num(serdes_lane_id);
2180 if ((serdes_mode == PEX_ROOT_COMPLEX_X4) ||
2181 (serdes_mode == PEX_END_POINT_X4)) {
2182 CHECK_STATUS(mv_seq_exec
2183 (serdes_lane_hw_num, PEX_TX_CONFIG_SEQ2));
2184 }
2185 }
2186
2187
2188 for (serdes_lane_id = 0; serdes_lane_id < count; serdes_lane_id++) {
2189 serdes_mode = serdes_map[serdes_lane_id].serdes_mode;
2190 serdes_lane_hw_num =
2191 hws_get_physical_serdes_num(serdes_lane_id);
2192 if ((serdes_mode == PEX_ROOT_COMPLEX_X4) ||
2193 (serdes_mode == PEX_END_POINT_X4)) {
2194 CHECK_STATUS(mv_seq_exec
2195 (serdes_lane_hw_num, PEX_TX_CONFIG_SEQ3));
2196 }
2197 }
2198
2199 return MV_OK;
2200}
2201