Skip to content

Commit 1046536

Browse files
Dimitri FedrauPaolo Abeni
authored andcommitted
net: phy: marvell-88q2xxx: Enable temperature measurement in probe again
Enabling of the temperature sensor was moved from mv88q2xxx_hwmon_probe to mv88q222x_config_init with the consequence that the sensor is only usable when the PHY is configured. Enable the sensor in mv88q2xxx_hwmon_probe as well to fix this. Signed-off-by: Dimitri Fedrau <[email protected]> Link: https://patch.msgid.link/20250512-marvell-88q2xxx-hwmon-enable-at-probe-v4-1-9256a5c8f603@gmail.com Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4cde0e4 commit 1046536

File tree

1 file changed

+57
-46
lines changed

1 file changed

+57
-46
lines changed

drivers/net/phy/marvell-88q2xxx.c

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
#define MV88Q2XXX_LED_INDEX_GPIO 1
120120

121121
struct mv88q2xxx_priv {
122-
bool enable_temp;
123122
bool enable_led0;
124123
};
125124

@@ -482,49 +481,6 @@ static int mv88q2xxx_config_aneg(struct phy_device *phydev)
482481
return phydev->drv->soft_reset(phydev);
483482
}
484483

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-
528484
static int mv88q2xxx_get_sqi(struct phy_device *phydev)
529485
{
530486
int ret;
@@ -667,6 +623,12 @@ static int mv88q2xxx_resume(struct phy_device *phydev)
667623
}
668624

669625
#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+
670632
static const struct hwmon_channel_info * const mv88q2xxx_hwmon_info[] = {
671633
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_ALARM),
672634
NULL
@@ -762,11 +724,13 @@ static const struct hwmon_chip_info mv88q2xxx_hwmon_chip_info = {
762724

763725
static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
764726
{
765-
struct mv88q2xxx_priv *priv = phydev->priv;
766727
struct device *dev = &phydev->mdio.dev;
767728
struct device *hwmon;
729+
int ret;
768730

769-
priv->enable_temp = true;
731+
ret = mv88q2xxx_enable_temp_sense(phydev);
732+
if (ret < 0)
733+
return ret;
770734

771735
hwmon = devm_hwmon_device_register_with_info(dev, NULL, phydev,
772736
&mv88q2xxx_hwmon_chip_info,
@@ -776,6 +740,11 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
776740
}
777741

778742
#else
743+
static int mv88q2xxx_enable_temp_sense(struct phy_device *phydev)
744+
{
745+
return 0;
746+
}
747+
779748
static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
780749
{
781750
return 0;
@@ -843,6 +812,48 @@ static int mv88q2xxx_probe(struct phy_device *phydev)
843812
return mv88q2xxx_hwmon_probe(phydev);
844813
}
845814

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+
846857
static int mv88q2110_config_init(struct phy_device *phydev)
847858
{
848859
int ret;

0 commit comments

Comments
 (0)