@@ -405,13 +405,80 @@ static int phy_mc_vsc8541_get_link(const struct device *dev, struct phy_link_sta
405
405
}
406
406
407
407
/**
408
- * @brief Reconfigure the link speed; currently unused
408
+ * @brief Reconfigure the link speed
409
409
*
410
+ * @param dev device structure to phy
411
+ * @param adv_speeds speeds to be advertised
410
412
*/
411
- static int phy_mc_vsc8541_cfg_link (const struct device * dev , enum phy_link_speed speeds )
413
+ static int phy_mc_vsc8541_cfg_link (const struct device * dev , enum phy_link_speed adv_speeds )
412
414
{
413
- /* the initial version does not support reconfiguration */
414
- return - ENOTSUP ;
415
+ uint16_t anar_reg ;
416
+ uint16_t bmcr_reg ;
417
+ uint16_t c1kt_reg ;
418
+
419
+ if (phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_ADV , & anar_reg ) < 0 ) {
420
+ return - EIO ;
421
+ }
422
+
423
+ if (phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_BMCR , & bmcr_reg ) < 0 ) {
424
+ return - EIO ;
425
+ }
426
+
427
+ if (phy_mc_vsc8541_read (dev , PHY_REG_PAGE0_CTRL1000 , & c1kt_reg ) < 0 ) {
428
+ return - EIO ;
429
+ }
430
+
431
+ if (adv_speeds & LINK_FULL_10BASE ) {
432
+ anar_reg |= MII_ADVERTISE_10_FULL ;
433
+ } else {
434
+ anar_reg &= ~MII_ADVERTISE_10_FULL ;
435
+ }
436
+
437
+ if (adv_speeds & LINK_HALF_10BASE ) {
438
+ anar_reg |= MII_ADVERTISE_10_HALF ;
439
+ } else {
440
+ anar_reg &= ~MII_ADVERTISE_10_HALF ;
441
+ }
442
+
443
+ if (adv_speeds & LINK_FULL_100BASE ) {
444
+ anar_reg |= MII_ADVERTISE_100_FULL ;
445
+ } else {
446
+ anar_reg &= ~MII_ADVERTISE_100_FULL ;
447
+ }
448
+
449
+ if (adv_speeds & LINK_HALF_100BASE ) {
450
+ anar_reg |= MII_ADVERTISE_100_HALF ;
451
+ } else {
452
+ anar_reg &= ~MII_ADVERTISE_100_HALF ;
453
+ }
454
+
455
+ if (adv_speeds & LINK_FULL_1000BASE ) {
456
+ c1kt_reg |= MII_ADVERTISE_1000_FULL ;
457
+ } else {
458
+ c1kt_reg &= ~MII_ADVERTISE_1000_FULL ;
459
+ }
460
+
461
+ if (adv_speeds & LINK_HALF_1000BASE ) {
462
+ c1kt_reg |= MII_ADVERTISE_1000_HALF ;
463
+ } else {
464
+ c1kt_reg &= ~MII_ADVERTISE_1000_HALF ;
465
+ }
466
+
467
+ if (phy_mc_vsc8541_write (dev , PHY_REG_PAGE0_CTRL1000 , c1kt_reg ) < 0 ) {
468
+ return - EIO ;
469
+ }
470
+
471
+ bmcr_reg |= MII_BMCR_AUTONEG_ENABLE ;
472
+
473
+ if (phy_mc_vsc8541_write (dev , PHY_REG_PAGE0_ADV , anar_reg ) < 0 ) {
474
+ return - EIO ;
475
+ }
476
+
477
+ if (phy_mc_vsc8541_write (dev , PHY_REG_PAGE0_BMCR , bmcr_reg ) < 0 ) {
478
+ return - EIO ;
479
+ }
480
+
481
+ return 0 ;
415
482
}
416
483
417
484
/**
0 commit comments