mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 6/7] net: phy: at803x: add disable hibernation mode support
Date: Mon, 10 Jul 2023 12:07:54 +0200	[thread overview]
Message-ID: <5639fc1b-c36e-dac6-3b23-5482a9bdbac2@pengutronix.de> (raw)
In-Reply-To: <20230710063653.660040-6-m.felsch@pengutronix.de>

On 10.07.23 08:36, Marco Felsch wrote:
> This commit ports Linux commit:
> 
> | commit 9ecf04016c87bcb33b44e24489d33618e2592f41
> | Author: Wei Fang <wei.fang@nxp.com>
> | Date:   Thu Aug 18 11:00:54 2022 +0800
> |
> |     net: phy: at803x: add disable hibernation mode support
> |
> |     When the cable is unplugged, the Atheros AR803x PHYs will enter
> |     hibernation mode after about 10 seconds if the hibernation mode
> |     is enabled and will not provide any clock to the MAC. But for
> |     some MACs, this feature might cause unexpected issues due to the
> |     logic of MACs.
> |     Taking SYNP MAC (stmmac) as an example, if the cable is unplugged
> |     and the "eth0" interface is down, the AR803x PHY will enter
> |     hibernation mode. Then perform the "ifconfig eth0 up" operation,
> |     the stmmac can't be able to complete the software reset operation
> |     and fail to init it's own DMA. Therefore, the "eth0" interface is
> |     failed to ifconfig up. Why does it cause this issue? The truth is
> |     that the software reset operation of the stmmac is designed to
> |     depend on the RX_CLK of PHY.
> |     So, this patch offers an option for the user to determine whether
> |     to disable the hibernation mode of AR803x PHYs.
> |
> |     Signed-off-by: Wei Fang <wei.fang@nxp.com>
> |     Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> |     Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

IMO we should just makes AT803X_DISABLE_HIBERNATION_MODE the default and
never hibernate the PHY. Let Linux worry about that.

> ---
>  drivers/net/phy/at803x.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index cc425c318f..d8a9c3588f 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -32,6 +32,9 @@
>  #define AT803X_DEBUG_REG_5			0x05
>  #define AT803X_DEBUG_TX_CLK_DLY_EN		BIT(8)
>  
> +#define AT803X_DEBUG_REG_HIB_CTRL		0x0b
> +#define   AT803X_DEBUG_HIB_CTRL_PS_HIB_EN	BIT(15)
> +
>  /* AT803x supports either the XTAL input pad, an internal PLL or the
>   * DSP as clock reference for the clock output pad. The XTAL reference
>   * is only used for 25 MHz output, all other frequencies need the PLL.
> @@ -140,6 +143,20 @@ static int at803x_disable_tx_delay(struct phy_device *phydev)
>  				     AT803X_DEBUG_TX_CLK_DLY_EN, 0);
>  }
>  
> +static int at803x_hibernation_mode_config(struct phy_device *phydev)
> +{
> +	struct at803x_priv *priv = phydev->priv;
> +
> +	/* The default after hardware reset is hibernation mode enabled. After
> +	 * software reset, the value is retained.
> +	 */
> +	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE))
> +		return 0;
> +
> +	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,
> +				     AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, 0);
> +}
> +
>  static bool at803x_match_phy_id(struct phy_device *phydev, u32 phy_id)
>  {
>  	struct phy_driver *drv = to_phy_driver(phydev->dev.driver);
> @@ -160,6 +177,9 @@ static int at803x_parse_dt(struct phy_device *phydev)
>  	if (of_property_read_bool(node, "qca,disable-smarteee"))
>  		priv->flags |= AT803X_DISABLE_SMARTEEE;
>  
> +	if (of_property_read_bool(node, "qca,disable-hibernation-mode"))
> +		priv->flags |= AT803X_DISABLE_HIBERNATION_MODE;
> +
>  	if (!of_property_read_u32(node, "qca,smarteee-tw-us-1g", &tw)) {
>  		if (!tw || tw > 255) {
>  			phydev_err(phydev, "invalid qca,smarteee-tw-us-1g\n");
> @@ -341,6 +361,10 @@ static int at803x_config_init(struct phy_device *phydev)
>  	if (ret < 0)
>  		return ret;
>  
> +	ret = at803x_hibernation_mode_config(phydev);
> +	if (ret < 0)
> +		return ret;
> +
>  	return 0;
>  }
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2023-07-10 10:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10  6:36 [PATCH 1/7] ARM: boards: make use of MDIO_MMD register defines Marco Felsch
2023-07-10  6:36 ` [PATCH 2/7] net: phy: micrel: " Marco Felsch
2023-07-10  9:56   ` Ahmad Fatoum
2023-07-10 10:37     ` Marco Felsch
2023-07-10  6:36 ` [PATCH 3/7] net: phy: sync phy_{write,read,modify}_mmd_indirect with linux Marco Felsch
2023-07-10  9:59   ` Ahmad Fatoum
2023-07-10 10:49     ` Marco Felsch
2023-07-10 10:53       ` Ahmad Fatoum
2023-07-10 11:01         ` Marco Felsch
2023-07-10 11:03           ` Ahmad Fatoum
2023-07-10 12:43             ` Marco Felsch
2023-07-10 12:52               ` Ahmad Fatoum
2023-07-10  6:36 ` [PATCH 4/7] net: phy: add phydev_{err,err_probe,info,warn,dbg} macros Marco Felsch
2023-07-10 10:01   ` Ahmad Fatoum
2023-07-10  6:36 ` [PATCH 5/7] net: phy: at803x: add support for configuring SmartEEE Marco Felsch
2023-07-10 10:10   ` Ahmad Fatoum
2023-07-10 12:10     ` Oleksij Rempel
2023-07-10  6:36 ` [PATCH 6/7] net: phy: at803x: add disable hibernation mode support Marco Felsch
2023-07-10 10:07   ` Ahmad Fatoum [this message]
2023-07-10 10:53     ` Marco Felsch
2023-07-10 11:07       ` Ahmad Fatoum
2023-07-10  6:36 ` [PATCH 7/7] net: phy: at803x: disable extended next page bit Marco Felsch
2023-07-10 10:03   ` Ahmad Fatoum
2023-07-10  9:55 ` [PATCH 1/7] ARM: boards: make use of MDIO_MMD register defines Ahmad Fatoum

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=5639fc1b-c36e-dac6-3b23-5482a9bdbac2@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /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