Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <dima.fedrau@gmail.com>
Link: https://patch.msgid.link/20250512-marvell-88q2xxx-hwmon-enable-at-probe-v4-1-9256a5c8f603@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Dimitri Fedrau and committed by
Paolo Abeni
10465365 4cde0e42

+57 -46
+57 -46
drivers/net/phy/marvell-88q2xxx.c
··· 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 ··· 481 482 return phydev->drv->soft_reset(phydev); 482 483 } 483 484 484 - static int mv88q2xxx_config_init(struct phy_device *phydev) 485 - { 486 - struct mv88q2xxx_priv *priv = phydev->priv; 487 - int ret; 488 - 489 - /* The 88Q2XXX PHYs do have the extended ability register available, but 490 - * register MDIO_PMA_EXTABLE where they should signalize it does not 491 - * work according to specification. Therefore, we force it here. 492 - */ 493 - phydev->pma_extable = MDIO_PMA_EXTABLE_BT1; 494 - 495 - /* Configure interrupt with default settings, output is driven low for 496 - * active interrupt and high for inactive. 497 - */ 498 - if (phy_interrupt_is_valid(phydev)) { 499 - ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, 500 - MDIO_MMD_PCS_MV_GPIO_INT_CTRL, 501 - MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS); 502 - if (ret < 0) 503 - return ret; 504 - } 505 - 506 - /* Enable LED function and disable TX disable feature on LED/TX_ENABLE */ 507 - if (priv->enable_led0) { 508 - ret = phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, 509 - MDIO_MMD_PCS_MV_RESET_CTRL, 510 - MDIO_MMD_PCS_MV_RESET_CTRL_TX_DISABLE); 511 - if (ret < 0) 512 - return ret; 513 - } 514 - 515 - /* Enable temperature sense */ 516 - if (priv->enable_temp) { 517 - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, 518 - MDIO_MMD_PCS_MV_TEMP_SENSOR2, 519 - MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0); 520 - if (ret < 0) 521 - return ret; 522 - } 523 - 524 - return 0; 525 - } 526 - 527 485 static int mv88q2xxx_get_sqi(struct phy_device *phydev) 528 486 { 529 487 int ret; ··· 623 667 } 624 668 625 669 #if IS_ENABLED(CONFIG_HWMON) 670 + static int mv88q2xxx_enable_temp_sense(struct phy_device *phydev) 671 + { 672 + return phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TEMP_SENSOR2, 673 + MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0); 674 + } 675 + 626 676 static const struct hwmon_channel_info * const mv88q2xxx_hwmon_info[] = { 627 677 HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_ALARM), 628 678 NULL ··· 724 762 725 763 static int mv88q2xxx_hwmon_probe(struct phy_device *phydev) 726 764 { 727 - struct mv88q2xxx_priv *priv = phydev->priv; 728 765 struct device *dev = &phydev->mdio.dev; 729 766 struct device *hwmon; 767 + int ret; 730 768 731 - priv->enable_temp = true; 769 + ret = mv88q2xxx_enable_temp_sense(phydev); 770 + if (ret < 0) 771 + return ret; 732 772 733 773 hwmon = devm_hwmon_device_register_with_info(dev, NULL, phydev, 734 774 &mv88q2xxx_hwmon_chip_info, ··· 740 776 } 741 777 742 778 #else 779 + static int mv88q2xxx_enable_temp_sense(struct phy_device *phydev) 780 + { 781 + return 0; 782 + } 783 + 743 784 static int mv88q2xxx_hwmon_probe(struct phy_device *phydev) 744 785 { 745 786 return 0; ··· 810 841 return ret; 811 842 812 843 return mv88q2xxx_hwmon_probe(phydev); 844 + } 845 + 846 + static int mv88q2xxx_config_init(struct phy_device *phydev) 847 + { 848 + struct mv88q2xxx_priv *priv = phydev->priv; 849 + int ret; 850 + 851 + /* The 88Q2XXX PHYs do have the extended ability register available, but 852 + * register MDIO_PMA_EXTABLE where they should signalize it does not 853 + * work according to specification. Therefore, we force it here. 854 + */ 855 + phydev->pma_extable = MDIO_PMA_EXTABLE_BT1; 856 + 857 + /* Configure interrupt with default settings, output is driven low for 858 + * active interrupt and high for inactive. 859 + */ 860 + if (phy_interrupt_is_valid(phydev)) { 861 + ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, 862 + MDIO_MMD_PCS_MV_GPIO_INT_CTRL, 863 + MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS); 864 + if (ret < 0) 865 + return ret; 866 + } 867 + 868 + /* Enable LED function and disable TX disable feature on LED/TX_ENABLE */ 869 + if (priv->enable_led0) { 870 + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, 871 + MDIO_MMD_PCS_MV_RESET_CTRL, 872 + MDIO_MMD_PCS_MV_RESET_CTRL_TX_DISABLE); 873 + if (ret < 0) 874 + return ret; 875 + } 876 + 877 + /* Enable temperature sense again. There might have been a hard reset 878 + * of the PHY and in this case the register content is restored to 879 + * defaults and we need to enable it again. 880 + */ 881 + ret = mv88q2xxx_enable_temp_sense(phydev); 882 + if (ret < 0) 883 + return ret; 884 + 885 + return 0; 813 886 } 814 887 815 888 static int mv88q2110_config_init(struct phy_device *phydev)