RE: [PATCH] net: phy: at803x: Improve hibernation support on start up

From
Wei Fang <wei.fang@nxp.com>
Date
2023-08-09 05:37:49
Reply to
Oleksij Rempel, 2023-08-09
quoted
For the patch, I think your approach is better than mine, but I have a
suggestion, is the following modification more appropriate?
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -991,12 +991,28 @@ static int at8031_pll_config(struct phy_device
*phydev)  static int at803x_hibernation_mode_config(struct phy_device
*phydev)  {
        struct at803x_priv *priv = phydev->priv;
+       int ret;

        /* The default after hardware reset is hibernation mode enabled.
After
quoted
         * software reset, the value is retained.
         */
-       if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE))
-               return 0;
+       if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE)) {
+               /* Toggle hibernation mode OFF and ON to wake the
PHY up and
quoted
+                * make it generate clock on RX_CLK pin for about 10
seconds.
quoted
+                * These clock are needed during start up by MACs like
DWMAC
quoted
+                * in NXP i.MX8M Plus to release their DMA from reset.
After
quoted
+                * the MAC has started up, the PHY can enter
hibernation and
quoted
+                * disable the RX_CLK clock, this poses no problem for
the MAC.
quoted
+                */
+               ret = at803x_debug_reg_mask(phydev,
AT803X_DEBUG_REG_HIB_CTRL,
quoted
+
AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, 0);
quoted
+               if (ret < 0)
+                       return ret;
+
+               return at803x_debug_reg_mask(phydev,
AT803X_DEBUG_REG_HIB_CTRL,
quoted
+
AT803X_DEBUG_HIB_CTRL_PS_HIB_EN,
quoted
+
AT803X_DEBUG_HIB_CTRL_PS_HIB_EN);
quoted
+       }

        return at803x_debug_reg_mask(phydev,
AT803X_DEBUG_REG_HIB_CTRL,
Hm.. how about officially defining this PHY as the clock provider and disable
PHY automatic hibernation as long as clock is acquired?
Sorry, I don't know much about the clock provider/consumer, but I think there
will be more changes if we use clock provider/consume mechanism. Furthermore,
we would expect the hibernation mode is enabled when the ethernet interface
is brought up but the cable is not plugged, that is to say, we only need the PHY to
provide the clock for a while to make the MAC reset successfully. Therefore, I think
the current approach is more simple and effective, and it takes full advantage of the
characteristics of the hardware (The PHY will continue to provide the clock about
10 seconds after hibernation mode is enabled when the cable is not plugged and
automatically disable the clock after 10 seconds, so the 10 seconds is enough for
the MAC to reset successfully).
Thread (32 messages) 32 messages, 6 authors, last reply 2023-12-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help