Skip to content

Commit a3236be

Browse files
ffainelliopsiff
authored andcommitted
net: mdio: mdio-bcm-unimac: Correct rate fallback logic
[ Upstream commit a81649a4efd382497bf3d34a623360263adc6993 ] When the parent clock is a gated clock which has multiple parents, the clock provider (clk-scmi typically) might return a rate of 0 since there is not one of those particular parent clocks that should be chosen for returning a rate. Prior to ee97535 ("net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses"), we would not always be passing a clock reference depending upon how mdio-bcm-unimac was instantiated. In that case, we would take the fallback path where the rate is hard coded to 250MHz. Make sure that we still fallback to using a fixed rate for the divider calculation, otherwise we simply ignore the desired MDIO bus clock frequency which can prevent us from interfacing with Ethernet PHYs properly. Fixes: ee97535 ("net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses") Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 714b8465384112828e3e3bf124bc98e9a3bc4a9b)
1 parent 0cab471 commit a3236be

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/net/mdio/mdio-bcm-unimac.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,9 @@ static int unimac_mdio_clk_set(struct unimac_mdio_priv *priv)
209209
if (ret)
210210
return ret;
211211

212-
if (!priv->clk)
212+
rate = clk_get_rate(priv->clk);
213+
if (!rate)
213214
rate = 250000000;
214-
else
215-
rate = clk_get_rate(priv->clk);
216215

217216
div = (rate / (2 * priv->clk_freq)) - 1;
218217
if (div & ~MDIO_CLK_DIV_MASK) {

0 commit comments

Comments
 (0)