public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Dimitri Fedrau <dima.fedrau@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Gregor Herburger <gregor.herburger@ew.tq-group.com>,
	Stefan Eichenberger <eichest@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: phy: marvell-88q2xxx: Fix temperature measurement with reset-gpios
Date: Fri, 17 Jan 2025 11:19:21 +0100	[thread overview]
Message-ID: <20250117101921.GE873961@ragnatech.se> (raw)
In-Reply-To: <20250116-marvell-88q2xxx-fix-hwmon-v1-1-ee5cfda4be87@gmail.com>

Hello Dimitri,

Thanks for your work.

On 2025-01-16 16:37:44 +0100, Dimitri Fedrau wrote:
> When using temperature measurement on Marvell 88Q2XXX devices and the
> reset-gpios property is set in DT, the device does a hardware reset when
> interface is brought down and up again. That means that the content of
> the register MDIO_MMD_PCS_MV_TEMP_SENSOR2 is reset to default and that
> leads to permanent deactivation of the temperature measurement, because
> activation is done in mv88q2xxx_probe. To fix this move activation of
> temperature measurement to mv88q222x_config_init.

I only have access to a mv88q2110 device so I can't test the change, but 
it looks good.

> 
> Signed-off-by: Dimitri Fedrau <dima.fedrau@gmail.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/net/phy/marvell-88q2xxx.c | 33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/phy/marvell-88q2xxx.c b/drivers/net/phy/marvell-88q2xxx.c
> index 4494b3e39ce2b672efe49d53d7021b765def6aa6..a3996471a1c9a5d4060d5d19ce44aa70e902a83f 100644
> --- a/drivers/net/phy/marvell-88q2xxx.c
> +++ b/drivers/net/phy/marvell-88q2xxx.c
> @@ -95,6 +95,10 @@
>  
>  #define MDIO_MMD_PCS_MV_TDR_OFF_CUTOFF			65246
>  
> +struct mv88q2xxx_priv {
> +	bool enable_temp;
> +};
> +
>  struct mmd_val {
>  	int devad;
>  	u32 regnum;
> @@ -710,17 +714,12 @@ static const struct hwmon_chip_info mv88q2xxx_hwmon_chip_info = {
>  
>  static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
>  {
> +	struct mv88q2xxx_priv *priv = phydev->priv;
>  	struct device *dev = &phydev->mdio.dev;
>  	struct device *hwmon;
>  	char *hwmon_name;
> -	int ret;
> -
> -	/* Enable temperature sense */
> -	ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, MDIO_MMD_PCS_MV_TEMP_SENSOR2,
> -			     MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0);
> -	if (ret < 0)
> -		return ret;
>  
> +	priv->enable_temp = true;
>  	hwmon_name = devm_hwmon_sanitize_name(dev, dev_name(dev));
>  	if (IS_ERR(hwmon_name))
>  		return PTR_ERR(hwmon_name);
> @@ -743,6 +742,14 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)
>  
>  static int mv88q2xxx_probe(struct phy_device *phydev)
>  {
> +	struct mv88q2xxx_priv *priv;
> +
> +	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	phydev->priv = priv;
> +
>  	return mv88q2xxx_hwmon_probe(phydev);
>  }
>  
> @@ -810,6 +817,18 @@ static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev)
>  
>  static int mv88q222x_config_init(struct phy_device *phydev)
>  {
> +	struct mv88q2xxx_priv *priv = phydev->priv;
> +	int ret;
> +
> +	/* Enable temperature sense */
> +	if (priv->enable_temp) {
> +		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
> +				     MDIO_MMD_PCS_MV_TEMP_SENSOR2,
> +				     MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK, 0);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
>  	if (phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] == PHY_ID_88Q2220_REVB0)
>  		return mv88q222x_revb0_config_init(phydev);
>  	else
> 
> ---
> base-commit: b44e27b4df1a1cd3fd84cf26c82156ed0301575f
> change-id: 20250116-marvell-88q2xxx-fix-hwmon-d6700aae9227
> 
> Best regards,
> -- 
> Dimitri Fedrau <dima.fedrau@gmail.com>
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2025-01-17 10:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 15:37 [PATCH] net: phy: marvell-88q2xxx: Fix temperature measurement with reset-gpios Dimitri Fedrau
2025-01-17 10:19 ` Niklas Söderlund [this message]
2025-01-17 13:22 ` Andrew Lunn
2025-01-17 15:08   ` Dimitri Fedrau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250117101921.GE873961@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dima.fedrau@gmail.com \
    --cc=edumazet@google.com \
    --cc=eichest@gmail.com \
    --cc=gregor.herburger@ew.tq-group.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox