119
119
#define MV88Q2XXX_LED_INDEX_GPIO 1
120
120
121
121
struct mv88q2xxx_priv {
122
- bool enable_temp ;
123
122
bool enable_led0 ;
124
123
};
125
124
@@ -482,49 +481,6 @@ static int mv88q2xxx_config_aneg(struct phy_device *phydev)
482
481
return phydev -> drv -> soft_reset (phydev );
483
482
}
484
483
485
- static int mv88q2xxx_config_init (struct phy_device * phydev )
486
- {
487
- struct mv88q2xxx_priv * priv = phydev -> priv ;
488
- int ret ;
489
-
490
- /* The 88Q2XXX PHYs do have the extended ability register available, but
491
- * register MDIO_PMA_EXTABLE where they should signalize it does not
492
- * work according to specification. Therefore, we force it here.
493
- */
494
- phydev -> pma_extable = MDIO_PMA_EXTABLE_BT1 ;
495
-
496
- /* Configure interrupt with default settings, output is driven low for
497
- * active interrupt and high for inactive.
498
- */
499
- if (phy_interrupt_is_valid (phydev )) {
500
- ret = phy_set_bits_mmd (phydev , MDIO_MMD_PCS ,
501
- MDIO_MMD_PCS_MV_GPIO_INT_CTRL ,
502
- MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS );
503
- if (ret < 0 )
504
- return ret ;
505
- }
506
-
507
- /* Enable LED function and disable TX disable feature on LED/TX_ENABLE */
508
- if (priv -> enable_led0 ) {
509
- ret = phy_clear_bits_mmd (phydev , MDIO_MMD_PCS ,
510
- MDIO_MMD_PCS_MV_RESET_CTRL ,
511
- MDIO_MMD_PCS_MV_RESET_CTRL_TX_DISABLE );
512
- if (ret < 0 )
513
- return ret ;
514
- }
515
-
516
- /* Enable temperature sense */
517
- if (priv -> enable_temp ) {
518
- ret = phy_modify_mmd (phydev , MDIO_MMD_PCS ,
519
- MDIO_MMD_PCS_MV_TEMP_SENSOR2 ,
520
- MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK , 0 );
521
- if (ret < 0 )
522
- return ret ;
523
- }
524
-
525
- return 0 ;
526
- }
527
-
528
484
static int mv88q2xxx_get_sqi (struct phy_device * phydev )
529
485
{
530
486
int ret ;
@@ -667,6 +623,12 @@ static int mv88q2xxx_resume(struct phy_device *phydev)
667
623
}
668
624
669
625
#if IS_ENABLED (CONFIG_HWMON )
626
+ static int mv88q2xxx_enable_temp_sense (struct phy_device * phydev )
627
+ {
628
+ return phy_modify_mmd (phydev , MDIO_MMD_PCS , MDIO_MMD_PCS_MV_TEMP_SENSOR2 ,
629
+ MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK , 0 );
630
+ }
631
+
670
632
static const struct hwmon_channel_info * const mv88q2xxx_hwmon_info [] = {
671
633
HWMON_CHANNEL_INFO (temp , HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_ALARM ),
672
634
NULL
@@ -762,11 +724,13 @@ static const struct hwmon_chip_info mv88q2xxx_hwmon_chip_info = {
762
724
763
725
static int mv88q2xxx_hwmon_probe (struct phy_device * phydev )
764
726
{
765
- struct mv88q2xxx_priv * priv = phydev -> priv ;
766
727
struct device * dev = & phydev -> mdio .dev ;
767
728
struct device * hwmon ;
729
+ int ret ;
768
730
769
- priv -> enable_temp = true;
731
+ ret = mv88q2xxx_enable_temp_sense (phydev );
732
+ if (ret < 0 )
733
+ return ret ;
770
734
771
735
hwmon = devm_hwmon_device_register_with_info (dev , NULL , phydev ,
772
736
& mv88q2xxx_hwmon_chip_info ,
@@ -776,6 +740,11 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
776
740
}
777
741
778
742
#else
743
+ static int mv88q2xxx_enable_temp_sense (struct phy_device * phydev )
744
+ {
745
+ return 0 ;
746
+ }
747
+
779
748
static int mv88q2xxx_hwmon_probe (struct phy_device * phydev )
780
749
{
781
750
return 0 ;
@@ -843,6 +812,48 @@ static int mv88q2xxx_probe(struct phy_device *phydev)
843
812
return mv88q2xxx_hwmon_probe (phydev );
844
813
}
845
814
815
+ static int mv88q2xxx_config_init (struct phy_device * phydev )
816
+ {
817
+ struct mv88q2xxx_priv * priv = phydev -> priv ;
818
+ int ret ;
819
+
820
+ /* The 88Q2XXX PHYs do have the extended ability register available, but
821
+ * register MDIO_PMA_EXTABLE where they should signalize it does not
822
+ * work according to specification. Therefore, we force it here.
823
+ */
824
+ phydev -> pma_extable = MDIO_PMA_EXTABLE_BT1 ;
825
+
826
+ /* Configure interrupt with default settings, output is driven low for
827
+ * active interrupt and high for inactive.
828
+ */
829
+ if (phy_interrupt_is_valid (phydev )) {
830
+ ret = phy_set_bits_mmd (phydev , MDIO_MMD_PCS ,
831
+ MDIO_MMD_PCS_MV_GPIO_INT_CTRL ,
832
+ MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS );
833
+ if (ret < 0 )
834
+ return ret ;
835
+ }
836
+
837
+ /* Enable LED function and disable TX disable feature on LED/TX_ENABLE */
838
+ if (priv -> enable_led0 ) {
839
+ ret = phy_clear_bits_mmd (phydev , MDIO_MMD_PCS ,
840
+ MDIO_MMD_PCS_MV_RESET_CTRL ,
841
+ MDIO_MMD_PCS_MV_RESET_CTRL_TX_DISABLE );
842
+ if (ret < 0 )
843
+ return ret ;
844
+ }
845
+
846
+ /* Enable temperature sense again. There might have been a hard reset
847
+ * of the PHY and in this case the register content is restored to
848
+ * defaults and we need to enable it again.
849
+ */
850
+ ret = mv88q2xxx_enable_temp_sense (phydev );
851
+ if (ret < 0 )
852
+ return ret ;
853
+
854
+ return 0 ;
855
+ }
856
+
846
857
static int mv88q2110_config_init (struct phy_device * phydev )
847
858
{
848
859
int ret ;
0 commit comments