@@ -583,139 +583,6 @@ static int at803x_resume(struct phy_device *phydev)
583
583
return phy_modify (phydev , MII_BMCR , BMCR_PDOWN | BMCR_ISOLATE , 0 );
584
584
}
585
585
586
- static int at8031_rgmii_reg_set_voltage_sel (struct regulator_dev * rdev ,
587
- unsigned int selector )
588
- {
589
- struct phy_device * phydev = rdev_get_drvdata (rdev );
590
-
591
- if (selector )
592
- return at803x_debug_reg_mask (phydev , AT803X_DEBUG_REG_1F ,
593
- 0 , AT803X_DEBUG_RGMII_1V8 );
594
- else
595
- return at803x_debug_reg_mask (phydev , AT803X_DEBUG_REG_1F ,
596
- AT803X_DEBUG_RGMII_1V8 , 0 );
597
- }
598
-
599
- static int at8031_rgmii_reg_get_voltage_sel (struct regulator_dev * rdev )
600
- {
601
- struct phy_device * phydev = rdev_get_drvdata (rdev );
602
- int val ;
603
-
604
- val = at803x_debug_reg_read (phydev , AT803X_DEBUG_REG_1F );
605
- if (val < 0 )
606
- return val ;
607
-
608
- return (val & AT803X_DEBUG_RGMII_1V8 ) ? 1 : 0 ;
609
- }
610
-
611
- static const struct regulator_ops vddio_regulator_ops = {
612
- .list_voltage = regulator_list_voltage_table ,
613
- .set_voltage_sel = at8031_rgmii_reg_set_voltage_sel ,
614
- .get_voltage_sel = at8031_rgmii_reg_get_voltage_sel ,
615
- };
616
-
617
- static const unsigned int vddio_voltage_table [] = {
618
- 1500000 ,
619
- 1800000 ,
620
- };
621
-
622
- static const struct regulator_desc vddio_desc = {
623
- .name = "vddio" ,
624
- .of_match = of_match_ptr ("vddio-regulator" ),
625
- .n_voltages = ARRAY_SIZE (vddio_voltage_table ),
626
- .volt_table = vddio_voltage_table ,
627
- .ops = & vddio_regulator_ops ,
628
- .type = REGULATOR_VOLTAGE ,
629
- .owner = THIS_MODULE ,
630
- };
631
-
632
- static const struct regulator_ops vddh_regulator_ops = {
633
- };
634
-
635
- static const struct regulator_desc vddh_desc = {
636
- .name = "vddh" ,
637
- .of_match = of_match_ptr ("vddh-regulator" ),
638
- .n_voltages = 1 ,
639
- .fixed_uV = 2500000 ,
640
- .ops = & vddh_regulator_ops ,
641
- .type = REGULATOR_VOLTAGE ,
642
- .owner = THIS_MODULE ,
643
- };
644
-
645
- static int at8031_register_regulators (struct phy_device * phydev )
646
- {
647
- struct at803x_priv * priv = phydev -> priv ;
648
- struct device * dev = & phydev -> mdio .dev ;
649
- struct regulator_config config = { };
650
-
651
- config .dev = dev ;
652
- config .driver_data = phydev ;
653
-
654
- priv -> vddio_rdev = devm_regulator_register (dev , & vddio_desc , & config );
655
- if (IS_ERR (priv -> vddio_rdev )) {
656
- phydev_err (phydev , "failed to register VDDIO regulator\n" );
657
- return PTR_ERR (priv -> vddio_rdev );
658
- }
659
-
660
- priv -> vddh_rdev = devm_regulator_register (dev , & vddh_desc , & config );
661
- if (IS_ERR (priv -> vddh_rdev )) {
662
- phydev_err (phydev , "failed to register VDDH regulator\n" );
663
- return PTR_ERR (priv -> vddh_rdev );
664
- }
665
-
666
- return 0 ;
667
- }
668
-
669
- static int at8031_sfp_insert (void * upstream , const struct sfp_eeprom_id * id )
670
- {
671
- struct phy_device * phydev = upstream ;
672
- __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_support );
673
- __ETHTOOL_DECLARE_LINK_MODE_MASK (sfp_support );
674
- DECLARE_PHY_INTERFACE_MASK (interfaces );
675
- phy_interface_t iface ;
676
-
677
- linkmode_zero (phy_support );
678
- phylink_set (phy_support , 1000b aseX_Full );
679
- phylink_set (phy_support , 1000b aseT_Full );
680
- phylink_set (phy_support , Autoneg );
681
- phylink_set (phy_support , Pause );
682
- phylink_set (phy_support , Asym_Pause );
683
-
684
- linkmode_zero (sfp_support );
685
- sfp_parse_support (phydev -> sfp_bus , id , sfp_support , interfaces );
686
- /* Some modules support 10G modes as well as others we support.
687
- * Mask out non-supported modes so the correct interface is picked.
688
- */
689
- linkmode_and (sfp_support , phy_support , sfp_support );
690
-
691
- if (linkmode_empty (sfp_support )) {
692
- dev_err (& phydev -> mdio .dev , "incompatible SFP module inserted\n" );
693
- return - EINVAL ;
694
- }
695
-
696
- iface = sfp_select_interface (phydev -> sfp_bus , sfp_support );
697
-
698
- /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
699
- * interface for use with SFP modules.
700
- * However, some copper modules detected as having a preferred SGMII
701
- * interface do default to and function in 1000Base-X mode, so just
702
- * print a warning and allow such modules, as they may have some chance
703
- * of working.
704
- */
705
- if (iface == PHY_INTERFACE_MODE_SGMII )
706
- dev_warn (& phydev -> mdio .dev , "module may not function if 1000Base-X not supported\n" );
707
- else if (iface != PHY_INTERFACE_MODE_1000BASEX )
708
- return - EINVAL ;
709
-
710
- return 0 ;
711
- }
712
-
713
- static const struct sfp_upstream_ops at8031_sfp_ops = {
714
- .attach = phy_sfp_attach ,
715
- .detach = phy_sfp_detach ,
716
- .module_insert = at8031_sfp_insert ,
717
- };
718
-
719
586
static int at803x_parse_dt (struct phy_device * phydev )
720
587
{
721
588
struct device_node * node = phydev -> mdio .dev .of_node ;
@@ -1498,6 +1365,139 @@ static int at803x_cable_test_start(struct phy_device *phydev)
1498
1365
return 0 ;
1499
1366
}
1500
1367
1368
+ static int at8031_rgmii_reg_set_voltage_sel (struct regulator_dev * rdev ,
1369
+ unsigned int selector )
1370
+ {
1371
+ struct phy_device * phydev = rdev_get_drvdata (rdev );
1372
+
1373
+ if (selector )
1374
+ return at803x_debug_reg_mask (phydev , AT803X_DEBUG_REG_1F ,
1375
+ 0 , AT803X_DEBUG_RGMII_1V8 );
1376
+ else
1377
+ return at803x_debug_reg_mask (phydev , AT803X_DEBUG_REG_1F ,
1378
+ AT803X_DEBUG_RGMII_1V8 , 0 );
1379
+ }
1380
+
1381
+ static int at8031_rgmii_reg_get_voltage_sel (struct regulator_dev * rdev )
1382
+ {
1383
+ struct phy_device * phydev = rdev_get_drvdata (rdev );
1384
+ int val ;
1385
+
1386
+ val = at803x_debug_reg_read (phydev , AT803X_DEBUG_REG_1F );
1387
+ if (val < 0 )
1388
+ return val ;
1389
+
1390
+ return (val & AT803X_DEBUG_RGMII_1V8 ) ? 1 : 0 ;
1391
+ }
1392
+
1393
+ static const struct regulator_ops vddio_regulator_ops = {
1394
+ .list_voltage = regulator_list_voltage_table ,
1395
+ .set_voltage_sel = at8031_rgmii_reg_set_voltage_sel ,
1396
+ .get_voltage_sel = at8031_rgmii_reg_get_voltage_sel ,
1397
+ };
1398
+
1399
+ static const unsigned int vddio_voltage_table [] = {
1400
+ 1500000 ,
1401
+ 1800000 ,
1402
+ };
1403
+
1404
+ static const struct regulator_desc vddio_desc = {
1405
+ .name = "vddio" ,
1406
+ .of_match = of_match_ptr ("vddio-regulator" ),
1407
+ .n_voltages = ARRAY_SIZE (vddio_voltage_table ),
1408
+ .volt_table = vddio_voltage_table ,
1409
+ .ops = & vddio_regulator_ops ,
1410
+ .type = REGULATOR_VOLTAGE ,
1411
+ .owner = THIS_MODULE ,
1412
+ };
1413
+
1414
+ static const struct regulator_ops vddh_regulator_ops = {
1415
+ };
1416
+
1417
+ static const struct regulator_desc vddh_desc = {
1418
+ .name = "vddh" ,
1419
+ .of_match = of_match_ptr ("vddh-regulator" ),
1420
+ .n_voltages = 1 ,
1421
+ .fixed_uV = 2500000 ,
1422
+ .ops = & vddh_regulator_ops ,
1423
+ .type = REGULATOR_VOLTAGE ,
1424
+ .owner = THIS_MODULE ,
1425
+ };
1426
+
1427
+ static int at8031_register_regulators (struct phy_device * phydev )
1428
+ {
1429
+ struct at803x_priv * priv = phydev -> priv ;
1430
+ struct device * dev = & phydev -> mdio .dev ;
1431
+ struct regulator_config config = { };
1432
+
1433
+ config .dev = dev ;
1434
+ config .driver_data = phydev ;
1435
+
1436
+ priv -> vddio_rdev = devm_regulator_register (dev , & vddio_desc , & config );
1437
+ if (IS_ERR (priv -> vddio_rdev )) {
1438
+ phydev_err (phydev , "failed to register VDDIO regulator\n" );
1439
+ return PTR_ERR (priv -> vddio_rdev );
1440
+ }
1441
+
1442
+ priv -> vddh_rdev = devm_regulator_register (dev , & vddh_desc , & config );
1443
+ if (IS_ERR (priv -> vddh_rdev )) {
1444
+ phydev_err (phydev , "failed to register VDDH regulator\n" );
1445
+ return PTR_ERR (priv -> vddh_rdev );
1446
+ }
1447
+
1448
+ return 0 ;
1449
+ }
1450
+
1451
+ static int at8031_sfp_insert (void * upstream , const struct sfp_eeprom_id * id )
1452
+ {
1453
+ struct phy_device * phydev = upstream ;
1454
+ __ETHTOOL_DECLARE_LINK_MODE_MASK (phy_support );
1455
+ __ETHTOOL_DECLARE_LINK_MODE_MASK (sfp_support );
1456
+ DECLARE_PHY_INTERFACE_MASK (interfaces );
1457
+ phy_interface_t iface ;
1458
+
1459
+ linkmode_zero (phy_support );
1460
+ phylink_set (phy_support , 1000b aseX_Full );
1461
+ phylink_set (phy_support , 1000b aseT_Full );
1462
+ phylink_set (phy_support , Autoneg );
1463
+ phylink_set (phy_support , Pause );
1464
+ phylink_set (phy_support , Asym_Pause );
1465
+
1466
+ linkmode_zero (sfp_support );
1467
+ sfp_parse_support (phydev -> sfp_bus , id , sfp_support , interfaces );
1468
+ /* Some modules support 10G modes as well as others we support.
1469
+ * Mask out non-supported modes so the correct interface is picked.
1470
+ */
1471
+ linkmode_and (sfp_support , phy_support , sfp_support );
1472
+
1473
+ if (linkmode_empty (sfp_support )) {
1474
+ dev_err (& phydev -> mdio .dev , "incompatible SFP module inserted\n" );
1475
+ return - EINVAL ;
1476
+ }
1477
+
1478
+ iface = sfp_select_interface (phydev -> sfp_bus , sfp_support );
1479
+
1480
+ /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
1481
+ * interface for use with SFP modules.
1482
+ * However, some copper modules detected as having a preferred SGMII
1483
+ * interface do default to and function in 1000Base-X mode, so just
1484
+ * print a warning and allow such modules, as they may have some chance
1485
+ * of working.
1486
+ */
1487
+ if (iface == PHY_INTERFACE_MODE_SGMII )
1488
+ dev_warn (& phydev -> mdio .dev , "module may not function if 1000Base-X not supported\n" );
1489
+ else if (iface != PHY_INTERFACE_MODE_1000BASEX )
1490
+ return - EINVAL ;
1491
+
1492
+ return 0 ;
1493
+ }
1494
+
1495
+ static const struct sfp_upstream_ops at8031_sfp_ops = {
1496
+ .attach = phy_sfp_attach ,
1497
+ .detach = phy_sfp_detach ,
1498
+ .module_insert = at8031_sfp_insert ,
1499
+ };
1500
+
1501
1501
static int at8031_parse_dt (struct phy_device * phydev )
1502
1502
{
1503
1503
struct device_node * node = phydev -> mdio .dev .of_node ;
0 commit comments