blob: d4ab9791e966b4cbbab0a0c91bbe8407118df30a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ashish Kumar1ef4c772017-08-31 16:12:55 +05302/*
3 * Copyright 2017 NXP
Ashish Kumar1ef4c772017-08-31 16:12:55 +05304 */
5
6#include <common.h>
Ashish Kumarbc6ceca2018-04-13 12:28:45 +05307#include <command.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -06008#include <env.h>
Ashish Kumar1ef4c772017-08-31 16:12:55 +05309#include <netdev.h>
10#include <asm/io.h>
11#include <asm/arch/fsl_serdes.h>
12#include <hwconfig.h>
13#include <fsl_mdio.h>
14#include <malloc.h>
Ashish Kumarbc6ceca2018-04-13 12:28:45 +053015#include <phy.h>
Ashish Kumar1ef4c772017-08-31 16:12:55 +053016#include <fm_eth.h>
17#include <i2c.h>
18#include <miiphy.h>
Bogdan Purcareata33ba9392017-10-05 06:56:53 +000019#include <fsl-mc/fsl_mc.h>
Ashish Kumar1ef4c772017-08-31 16:12:55 +053020#include <fsl-mc/ldpaa_wriop.h>
21
22#include "../common/qixis.h"
23
24#include "ls1088a_qixis.h"
25
Ashish Kumar1ef4c772017-08-31 16:12:55 +053026#ifdef CONFIG_FSL_MC_ENET
27
28#define SFP_TX 0
29
30 /* - In LS1088A A there are only 16 SERDES lanes, spread across 2 SERDES banks.
31 * Bank 1 -> Lanes A, B, C, D,
32 * Bank 2 -> Lanes A,B, C, D,
33 */
34
35 /* Mapping of 8 SERDES lanes to LS1088A QDS board slots. A value of '0' here
36 * means that the mapping must be determined dynamically, or that the lane
37 * maps to something other than a board slot.
38 */
39
40static u8 lane_to_slot_fsm1[] = {
41 0, 0, 0, 0, 0, 0, 0, 0
42};
43
44/* On the Vitesse VSC8234XHG SGMII riser card there are 4 SGMII PHYs
45 * housed.
46 */
47
48static int xqsgii_riser_phy_addr[] = {
49 XQSGMII_CARD_PHY1_PORT0_ADDR,
50 XQSGMII_CARD_PHY2_PORT0_ADDR,
51 XQSGMII_CARD_PHY3_PORT0_ADDR,
52 XQSGMII_CARD_PHY4_PORT0_ADDR,
53 XQSGMII_CARD_PHY3_PORT2_ADDR,
54 XQSGMII_CARD_PHY1_PORT2_ADDR,
55 XQSGMII_CARD_PHY4_PORT2_ADDR,
56 XQSGMII_CARD_PHY2_PORT2_ADDR,
57};
58
59static int sgmii_riser_phy_addr[] = {
60 SGMII_CARD_PORT1_PHY_ADDR,
61 SGMII_CARD_PORT2_PHY_ADDR,
62 SGMII_CARD_PORT3_PHY_ADDR,
63 SGMII_CARD_PORT4_PHY_ADDR,
64};
65
66/* Slot2 does not have EMI connections */
67#define EMI_NONE 0xFF
68#define EMI1_RGMII1 0
69#define EMI1_RGMII2 1
70#define EMI1_SLOT1 2
71
72static const char * const mdio_names[] = {
73 "LS1088A_QDS_MDIO0",
74 "LS1088A_QDS_MDIO1",
75 "LS1088A_QDS_MDIO2",
76 DEFAULT_WRIOP_MDIO2_NAME,
77};
78
79struct ls1088a_qds_mdio {
80 u8 muxval;
81 struct mii_dev *realbus;
82};
83
84static void sgmii_configure_repeater(int dpmac)
85{
86 struct mii_dev *bus;
87 uint8_t a = 0xf;
88 int i, j, ret;
89 unsigned short value;
90 const char *dev = "LS1088A_QDS_MDIO2";
91 int i2c_addr[] = {0x58, 0x59, 0x5a, 0x5b};
92 int i2c_phy_addr = 0;
93 int phy_addr = 0;
94
95 uint8_t ch_a_eq[] = {0x1, 0x2, 0x3, 0x7};
96 uint8_t ch_a_ctl2[] = {0x81, 0x82, 0x83, 0x84};
97 uint8_t ch_b_eq[] = {0x1, 0x2, 0x3, 0x7};
98 uint8_t ch_b_ctl2[] = {0x81, 0x82, 0x83, 0x84};
99
100 /* Set I2c to Slot 1 */
101 i2c_write(0x77, 0, 0, &a, 1);
102
103 switch (dpmac) {
104 case 1:
105 i2c_phy_addr = i2c_addr[1];
106 phy_addr = 4;
107 break;
108 case 2:
109 i2c_phy_addr = i2c_addr[0];
110 phy_addr = 0;
111 break;
112 case 3:
113 i2c_phy_addr = i2c_addr[3];
114 phy_addr = 0xc;
115 break;
116 case 7:
117 i2c_phy_addr = i2c_addr[2];
118 phy_addr = 8;
119 break;
120 }
121
122 /* Check the PHY status */
123 ret = miiphy_set_current_dev(dev);
124 if (ret > 0)
125 goto error;
126
127 bus = mdio_get_current_dev();
128 debug("Reading from bus %s\n", bus->name);
129
130 ret = miiphy_write(dev, phy_addr, 0x1f, 3);
131 if (ret > 0)
132 goto error;
133
134 mdelay(10);
135 ret = miiphy_read(dev, phy_addr, 0x11, &value);
136 if (ret > 0)
137 goto error;
138
139 mdelay(10);
140
141 if ((value & 0xfff) == 0x401) {
142 miiphy_write(dev, phy_addr, 0x1f, 0);
143 printf("DPMAC %d:PHY is ..... Configured\n", dpmac);
144 return;
145 }
146
147 for (i = 0; i < 4; i++) {
148 for (j = 0; j < 4; j++) {
149 a = 0x18;
150 i2c_write(i2c_phy_addr, 6, 1, &a, 1);
151 a = 0x38;
152 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
153 a = 0x4;
154 i2c_write(i2c_phy_addr, 8, 1, &a, 1);
155
156 i2c_write(i2c_phy_addr, 0xf, 1,
157 &ch_a_eq[i], 1);
158 i2c_write(i2c_phy_addr, 0x11, 1,
159 &ch_a_ctl2[j], 1);
160
161 i2c_write(i2c_phy_addr, 0x16, 1,
162 &ch_b_eq[i], 1);
163 i2c_write(i2c_phy_addr, 0x18, 1,
164 &ch_b_ctl2[j], 1);
165
166 a = 0x14;
167 i2c_write(i2c_phy_addr, 0x23, 1, &a, 1);
168 a = 0xb5;
169 i2c_write(i2c_phy_addr, 0x2d, 1, &a, 1);
170 a = 0x20;
171 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
172 mdelay(100);
173 ret = miiphy_read(dev, phy_addr, 0x11, &value);
174 if (ret > 0)
175 goto error;
176
177 mdelay(100);
178 ret = miiphy_read(dev, phy_addr, 0x11, &value);
179 if (ret > 0)
180 goto error;
181
182 if ((value & 0xfff) == 0x401) {
183 printf("DPMAC %d :PHY is configured ",
184 dpmac);
185 printf("after setting repeater 0x%x\n",
186 value);
187 i = 5;
188 j = 5;
189 } else {
190 printf("DPMAC %d :PHY is failed to ",
191 dpmac);
192 printf("configure the repeater 0x%x\n", value);
193 }
194 }
195 }
196 miiphy_write(dev, phy_addr, 0x1f, 0);
197error:
198 if (ret)
199 printf("DPMAC %d ..... FAILED to configure PHY\n", dpmac);
200 return;
201}
202
203static void qsgmii_configure_repeater(int dpmac)
204{
205 uint8_t a = 0xf;
206 int i, j;
207 int i2c_phy_addr = 0;
208 int phy_addr = 0;
209 int i2c_addr[] = {0x58, 0x59, 0x5a, 0x5b};
210
211 uint8_t ch_a_eq[] = {0x1, 0x2, 0x3, 0x7};
212 uint8_t ch_a_ctl2[] = {0x81, 0x82, 0x83, 0x84};
213 uint8_t ch_b_eq[] = {0x1, 0x2, 0x3, 0x7};
214 uint8_t ch_b_ctl2[] = {0x81, 0x82, 0x83, 0x84};
215
216 const char *dev = mdio_names[EMI1_SLOT1];
217 int ret = 0;
218 unsigned short value;
219
220 /* Set I2c to Slot 1 */
221 i2c_write(0x77, 0, 0, &a, 1);
222
223 switch (dpmac) {
224 case 7:
225 case 8:
226 case 9:
227 case 10:
228 i2c_phy_addr = i2c_addr[2];
229 phy_addr = 8;
230 break;
231
232 case 3:
233 case 4:
234 case 5:
235 case 6:
236 i2c_phy_addr = i2c_addr[3];
237 phy_addr = 0xc;
238 break;
239 }
240
241 /* Check the PHY status */
242 ret = miiphy_set_current_dev(dev);
243 ret = miiphy_write(dev, phy_addr, 0x1f, 3);
244 mdelay(10);
245 ret = miiphy_read(dev, phy_addr, 0x11, &value);
246 mdelay(10);
247 ret = miiphy_read(dev, phy_addr, 0x11, &value);
248 mdelay(10);
249 if ((value & 0xf) == 0xf) {
250 miiphy_write(dev, phy_addr, 0x1f, 0);
251 printf("DPMAC %d :PHY is ..... Configured\n", dpmac);
252 return;
253 }
254
255 for (i = 0; i < 4; i++) {
256 for (j = 0; j < 4; j++) {
257 a = 0x18;
258 i2c_write(i2c_phy_addr, 6, 1, &a, 1);
259 a = 0x38;
260 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
261 a = 0x4;
262 i2c_write(i2c_phy_addr, 8, 1, &a, 1);
263
264 i2c_write(i2c_phy_addr, 0xf, 1, &ch_a_eq[i], 1);
265 i2c_write(i2c_phy_addr, 0x11, 1, &ch_a_ctl2[j], 1);
266
267 i2c_write(i2c_phy_addr, 0x16, 1, &ch_b_eq[i], 1);
268 i2c_write(i2c_phy_addr, 0x18, 1, &ch_b_ctl2[j], 1);
269
270 a = 0x14;
271 i2c_write(i2c_phy_addr, 0x23, 1, &a, 1);
272 a = 0xb5;
273 i2c_write(i2c_phy_addr, 0x2d, 1, &a, 1);
274 a = 0x20;
275 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
276 mdelay(100);
277 ret = miiphy_read(dev, phy_addr, 0x11, &value);
278 if (ret > 0)
279 goto error;
280 mdelay(1);
281 ret = miiphy_read(dev, phy_addr, 0x11, &value);
282 if (ret > 0)
283 goto error;
284 mdelay(10);
285 if ((value & 0xf) == 0xf) {
286 miiphy_write(dev, phy_addr, 0x1f, 0);
287 printf("DPMAC %d :PHY is ..... Configured\n",
288 dpmac);
289 return;
290 }
291 }
292 }
293error:
294 printf("DPMAC %d :PHY ..... FAILED to configure PHY\n", dpmac);
295 return;
296}
297
298static const char *ls1088a_qds_mdio_name_for_muxval(u8 muxval)
299{
300 return mdio_names[muxval];
301}
302
303struct mii_dev *mii_dev_for_muxval(u8 muxval)
304{
305 struct mii_dev *bus;
306 const char *name = ls1088a_qds_mdio_name_for_muxval(muxval);
307
308 if (!name) {
309 printf("No bus for muxval %x\n", muxval);
310 return NULL;
311 }
312
313 bus = miiphy_get_dev_by_name(name);
314
315 if (!bus) {
316 printf("No bus by name %s\n", name);
317 return NULL;
318 }
319
320 return bus;
321}
322
323static void ls1088a_qds_enable_SFP_TX(u8 muxval)
324{
325 u8 brdcfg9;
326
327 brdcfg9 = QIXIS_READ(brdcfg[9]);
328 brdcfg9 &= ~BRDCFG9_SFPTX_MASK;
329 brdcfg9 |= (muxval << BRDCFG9_SFPTX_SHIFT);
330 QIXIS_WRITE(brdcfg[9], brdcfg9);
331}
332
333static void ls1088a_qds_mux_mdio(u8 muxval)
334{
335 u8 brdcfg4;
336
337 if (muxval <= 5) {
338 brdcfg4 = QIXIS_READ(brdcfg[4]);
339 brdcfg4 &= ~BRDCFG4_EMISEL_MASK;
340 brdcfg4 |= (muxval << BRDCFG4_EMISEL_SHIFT);
341 QIXIS_WRITE(brdcfg[4], brdcfg4);
342 }
343}
344
345static int ls1088a_qds_mdio_read(struct mii_dev *bus, int addr,
346 int devad, int regnum)
347{
348 struct ls1088a_qds_mdio *priv = bus->priv;
349
350 ls1088a_qds_mux_mdio(priv->muxval);
351
352 return priv->realbus->read(priv->realbus, addr, devad, regnum);
353}
354
355static int ls1088a_qds_mdio_write(struct mii_dev *bus, int addr, int devad,
356 int regnum, u16 value)
357{
358 struct ls1088a_qds_mdio *priv = bus->priv;
359
360 ls1088a_qds_mux_mdio(priv->muxval);
361
362 return priv->realbus->write(priv->realbus, addr, devad, regnum, value);
363}
364
365static int ls1088a_qds_mdio_reset(struct mii_dev *bus)
366{
367 struct ls1088a_qds_mdio *priv = bus->priv;
368
369 return priv->realbus->reset(priv->realbus);
370}
371
372static int ls1088a_qds_mdio_init(char *realbusname, u8 muxval)
373{
374 struct ls1088a_qds_mdio *pmdio;
375 struct mii_dev *bus = mdio_alloc();
376
377 if (!bus) {
378 printf("Failed to allocate ls1088a_qds MDIO bus\n");
379 return -1;
380 }
381
382 pmdio = malloc(sizeof(*pmdio));
383 if (!pmdio) {
384 printf("Failed to allocate ls1088a_qds private data\n");
385 free(bus);
386 return -1;
387 }
388
389 bus->read = ls1088a_qds_mdio_read;
390 bus->write = ls1088a_qds_mdio_write;
391 bus->reset = ls1088a_qds_mdio_reset;
392 sprintf(bus->name, ls1088a_qds_mdio_name_for_muxval(muxval));
393
394 pmdio->realbus = miiphy_get_dev_by_name(realbusname);
395
396 if (!pmdio->realbus) {
397 printf("No bus with name %s\n", realbusname);
398 free(bus);
399 free(pmdio);
400 return -1;
401 }
402
403 pmdio->muxval = muxval;
404 bus->priv = pmdio;
405
406 return mdio_register(bus);
407}
408
409/*
410 * Initialize the dpmac_info array.
411 *
412 */
413static void initialize_dpmac_to_slot(void)
414{
415 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
416 u32 serdes1_prtcl, cfg;
417
418 cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) &
419 FSL_CHASSIS3_SRDS1_PRTCL_MASK;
420 cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
421 serdes1_prtcl = serdes_get_number(FSL_SRDS_1, cfg);
422
423 switch (serdes1_prtcl) {
424 case 0x12:
425 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
426 serdes1_prtcl);
427 lane_to_slot_fsm1[0] = EMI1_SLOT1 - 1;
428 lane_to_slot_fsm1[1] = EMI1_SLOT1 - 1;
429 lane_to_slot_fsm1[2] = EMI1_SLOT1 - 1;
430 lane_to_slot_fsm1[3] = EMI1_SLOT1 - 1;
431 break;
432 case 0x15:
433 case 0x1D:
434 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
435 serdes1_prtcl);
436 lane_to_slot_fsm1[0] = EMI1_SLOT1 - 1;
437 lane_to_slot_fsm1[1] = EMI1_SLOT1 - 1;
438 lane_to_slot_fsm1[2] = EMI_NONE;
439 lane_to_slot_fsm1[3] = EMI_NONE;
440 break;
441 case 0x1E:
442 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
443 serdes1_prtcl);
444 lane_to_slot_fsm1[0] = EMI1_SLOT1 - 1;
445 lane_to_slot_fsm1[1] = EMI1_SLOT1 - 1;
446 lane_to_slot_fsm1[2] = EMI1_SLOT1 - 1;
447 lane_to_slot_fsm1[3] = EMI_NONE;
448 break;
449 case 0x3A:
450 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
451 serdes1_prtcl);
452 lane_to_slot_fsm1[0] = EMI1_SLOT1 - 1;
453 lane_to_slot_fsm1[1] = EMI_NONE;
454 lane_to_slot_fsm1[2] = EMI1_SLOT1 - 1;
455 lane_to_slot_fsm1[3] = EMI1_SLOT1 - 1;
456 break;
457
458 default:
459 printf("%s qds: WRIOP: Unsupported SerDes1 Protocol 0x%02x\n",
460 __func__, serdes1_prtcl);
461 break;
462 }
463}
464
465void ls1088a_handle_phy_interface_sgmii(int dpmac_id)
466{
467 struct mii_dev *bus;
468 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
469 u32 serdes1_prtcl, cfg;
470
471 cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) &
472 FSL_CHASSIS3_SRDS1_PRTCL_MASK;
473 cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
474 serdes1_prtcl = serdes_get_number(FSL_SRDS_1, cfg);
475
476 int *riser_phy_addr;
477 char *env_hwconfig = env_get("hwconfig");
478
479 if (hwconfig_f("xqsgmii", env_hwconfig))
480 riser_phy_addr = &xqsgii_riser_phy_addr[0];
481 else
482 riser_phy_addr = &sgmii_riser_phy_addr[0];
483
484 switch (serdes1_prtcl) {
485 case 0x12:
486 case 0x15:
487 case 0x1E:
488 case 0x3A:
489 switch (dpmac_id) {
490 case 1:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530491 wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[1]);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530492 break;
493 case 2:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530494 wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[0]);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530495 break;
496 case 3:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530497 wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[3]);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530498 break;
499 case 7:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530500 wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[2]);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530501 break;
502 default:
503 printf("WRIOP: Wrong DPMAC%d set to SGMII", dpmac_id);
504 break;
505 }
506 break;
507 default:
508 printf("%s qds: WRIOP: Unsupported SerDes1 Protocol 0x%02x\n",
509 __func__, serdes1_prtcl);
510 return;
511 }
512 dpmac_info[dpmac_id].board_mux = EMI1_SLOT1;
513 bus = mii_dev_for_muxval(EMI1_SLOT1);
514 wriop_set_mdio(dpmac_id, bus);
515}
516
517void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)
518{
519 struct mii_dev *bus;
520 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
521 u32 serdes1_prtcl, cfg;
522
523 cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) &
524 FSL_CHASSIS3_SRDS1_PRTCL_MASK;
525 cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
526 serdes1_prtcl = serdes_get_number(FSL_SRDS_1, cfg);
527
528 switch (serdes1_prtcl) {
529 case 0x1D:
530 case 0x1E:
531 switch (dpmac_id) {
532 case 3:
533 case 4:
534 case 5:
535 case 6:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530536 wriop_set_phy_address(dpmac_id, 0, dpmac_id + 9);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530537 break;
538 case 7:
539 case 8:
540 case 9:
541 case 10:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530542 wriop_set_phy_address(dpmac_id, 0, dpmac_id + 1);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530543 break;
544 }
545
546 dpmac_info[dpmac_id].board_mux = EMI1_SLOT1;
547 bus = mii_dev_for_muxval(EMI1_SLOT1);
548 wriop_set_mdio(dpmac_id, bus);
549 break;
550 default:
551 printf("qds: WRIOP: Unsupported SerDes Protocol 0x%02x\n",
552 serdes1_prtcl);
553 break;
554 }
555}
556
557void ls1088a_handle_phy_interface_xsgmii(int i)
558{
559 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
560 u32 serdes1_prtcl, cfg;
561
562 cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) &
563 FSL_CHASSIS3_SRDS1_PRTCL_MASK;
564 cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
565 serdes1_prtcl = serdes_get_number(FSL_SRDS_1, cfg);
566
567 switch (serdes1_prtcl) {
568 case 0x15:
569 case 0x1D:
570 case 0x1E:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530571 wriop_set_phy_address(i, 0, i + 26);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530572 ls1088a_qds_enable_SFP_TX(SFP_TX);
573 break;
574 default:
575 printf("qds: WRIOP: Unsupported SerDes Protocol 0x%02x\n",
576 serdes1_prtcl);
577 break;
578 }
579}
Prabhakar Kushwaha05f37b02017-08-31 16:37:32 +0530580
581static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)
582{
583 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
584 u32 serdes1_prtcl, cfg;
585 struct mii_dev *bus;
586
587 cfg = in_le32(&gur->rcwsr[FSL_CHASSIS3_SRDS1_REGSR - 1]) &
588 FSL_CHASSIS3_SRDS1_PRTCL_MASK;
589 cfg >>= FSL_CHASSIS3_SRDS1_PRTCL_SHIFT;
590 serdes1_prtcl = serdes_get_number(FSL_SRDS_1, cfg);
591
592 switch (dpmac_id) {
593 case 4:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530594 wriop_set_phy_address(dpmac_id, 0, RGMII_PHY1_ADDR);
Prabhakar Kushwaha05f37b02017-08-31 16:37:32 +0530595 dpmac_info[dpmac_id].board_mux = EMI1_RGMII1;
596 bus = mii_dev_for_muxval(EMI1_RGMII1);
597 wriop_set_mdio(dpmac_id, bus);
598 break;
599 case 5:
Pankaj Bansal50adb5e2018-10-10 14:08:34 +0530600 wriop_set_phy_address(dpmac_id, 0, RGMII_PHY2_ADDR);
Prabhakar Kushwaha05f37b02017-08-31 16:37:32 +0530601 dpmac_info[dpmac_id].board_mux = EMI1_RGMII2;
602 bus = mii_dev_for_muxval(EMI1_RGMII2);
603 wriop_set_mdio(dpmac_id, bus);
604 break;
605 default:
606 printf("qds: WRIOP: Unsupported RGMII SerDes Protocol 0x%02x\n",
607 serdes1_prtcl);
608 break;
609 }
610}
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530611#endif
612
613int board_eth_init(bd_t *bis)
614{
615 int error = 0, i;
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530616#ifdef CONFIG_FSL_MC_ENET
617 struct memac_mdio_info *memac_mdio0_info;
618 char *env_hwconfig = env_get("hwconfig");
619
620 initialize_dpmac_to_slot();
621
622 memac_mdio0_info = (struct memac_mdio_info *)malloc(
623 sizeof(struct memac_mdio_info));
624 memac_mdio0_info->regs =
625 (struct memac_mdio_controller *)
626 CONFIG_SYS_FSL_WRIOP1_MDIO1;
627 memac_mdio0_info->name = DEFAULT_WRIOP_MDIO1_NAME;
628
629 /* Register the real MDIO1 bus */
630 fm_memac_mdio_init(bis, memac_mdio0_info);
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530631 /* Register the muxing front-ends to the MDIO buses */
632 ls1088a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_RGMII1);
633 ls1088a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_RGMII2);
634 ls1088a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT1);
635
636 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
637 switch (wriop_get_enet_if(i)) {
Prabhakar Kushwaha05f37b02017-08-31 16:37:32 +0530638 case PHY_INTERFACE_MODE_RGMII:
Ashish Kumar856c9dc2017-10-12 15:21:54 +0530639 case PHY_INTERFACE_MODE_RGMII_ID:
Prabhakar Kushwaha05f37b02017-08-31 16:37:32 +0530640 ls1088a_handle_phy_interface_rgmii(i);
641 break;
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530642 case PHY_INTERFACE_MODE_QSGMII:
643 ls1088a_handle_phy_interface_qsgmii(i);
644 break;
645 case PHY_INTERFACE_MODE_SGMII:
646 ls1088a_handle_phy_interface_sgmii(i);
647 break;
648 case PHY_INTERFACE_MODE_XGMII:
649 ls1088a_handle_phy_interface_xsgmii(i);
650 break;
651 default:
652 break;
653
654 if (i == 16)
655 i = NUM_WRIOP_PORTS;
656 }
657 }
658
Ashish Kumar1ef4c772017-08-31 16:12:55 +0530659 error = cpu_eth_init(bis);
660
661 if (hwconfig_f("xqsgmii", env_hwconfig)) {
662 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
663 switch (wriop_get_enet_if(i)) {
664 case PHY_INTERFACE_MODE_QSGMII:
665 qsgmii_configure_repeater(i);
666 break;
667 case PHY_INTERFACE_MODE_SGMII:
668 sgmii_configure_repeater(i);
669 break;
670 default:
671 break;
672 }
673
674 if (i == 16)
675 i = NUM_WRIOP_PORTS;
676 }
677 }
678#endif
679 error = pci_eth_init(bis);
680 return error;
681}
Bogdan Purcareata33ba9392017-10-05 06:56:53 +0000682
683#if defined(CONFIG_RESET_PHY_R)
684void reset_phy(void)
685{
686 mc_env_boot();
687}
688#endif /* CONFIG_RESET_PHY_R */