Message ID | 20230928122427.313271-1-christophe.roullier@foss.st.com |
---|---|
Headers | show |
Series | Series to deliver Ethernets for STM32MP13 | expand |
> +static int phy_power_on(struct stm32_dwmac *bsp_priv, bool enable) I find this function name confusing, since 50% of the time it does not actually power the PHY on. You never call it with anything other than a static true/false value. So it might was well be two functions, phy_power_on() and phy_power_off(). > +{ > + int ret; > + struct device *dev = bsp_priv->dev; > + > + if (!bsp_priv->regulator) > + return 0; > + > + if (enable) { > + ret = regulator_enable(bsp_priv->regulator); > + if (ret) > + dev_err(dev, "fail to enable phy-supply\n"); Not all PHYs are usable in 0 picoseconds. You probably want a delay here. Otherwise the first few accesses to it might not work. Andrew
On 9/28/23 19:53, Andrew Lunn wrote: >> +static int phy_power_on(struct stm32_dwmac *bsp_priv, bool enable) > I find this function name confusing, since 50% of the time it does not > actually power the PHY on. You never call it with anything other than > a static true/false value. So it might was well be two functions, > phy_power_on() and phy_power_off(). Hi, I wanted to keep same implementation of all others Ethernet glues (dwmac-rk.c ...) to be consistent. >> +{ >> + int ret; >> + struct device *dev = bsp_priv->dev; >> + >> + if (!bsp_priv->regulator) >> + return 0; >> + >> + if (enable) { >> + ret = regulator_enable(bsp_priv->regulator); >> + if (ret) >> + dev_err(dev, "fail to enable phy-supply\n"); > Not all PHYs are usable in 0 picoseconds. You probably want a delay > here. Otherwise the first few accesses to it might not work. > > Andrew You're right I will add a delay. Thanks Christophe