Hi Yegor, On Wed, May 31, 2023 at 04:35:00PM +0200, yegorslists@xxxxxxxxxxxxxx wrote: > From: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx> > Could you add a word here on which kernel version this is based on? It will help synchronizing with newer kernels later. > Signed-off-by: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx> > --- > drivers/net/phy/Kconfig | 5 ++ > drivers/net/phy/Makefile | 1 + > drivers/net/phy/motorcomm.c | 128 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 134 insertions(+) > create mode 100644 drivers/net/phy/motorcomm.c > [...] > +static int yt8511_config_init(struct phy_device *phydev) > +{ > + int oldpage, ret = 0; > + unsigned int ge, fe; > + > + oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE); > + if (oldpage < 0) > + goto err_restore_page; > + > + /* set rgmii delay mode */ > + switch (phydev->interface) { > + case PHY_INTERFACE_MODE_RGMII: > + ge = YT8511_DELAY_GE_TX_DIS; > + fe = YT8511_DELAY_FE_TX_DIS; > + break; > + case PHY_INTERFACE_MODE_RGMII_RXID: > + ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS; > + fe = YT8511_DELAY_FE_TX_DIS; > + break; > + case PHY_INTERFACE_MODE_RGMII_TXID: > + ge = YT8511_DELAY_GE_TX_EN; > + fe = YT8511_DELAY_FE_TX_EN; > + break; > + case PHY_INTERFACE_MODE_RGMII_ID: > + ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN; > + fe = YT8511_DELAY_FE_TX_EN; > + break; > + default: /* do not support other modes */ > + ret = -EOPNOTSUPP; > + goto err_restore_page; > + } > + > + ret = phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge); > + if (ret < 0) > + goto err_restore_page; > + > + /* set clock mode to 125mhz */ > + ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M); > + if (ret < 0) > + goto err_restore_page; > + > + /* fast ethernet delay is in a separate page */ > + ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE); > + if (ret < 0) > + goto err_restore_page; > + > + ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe); > + if (ret < 0) > + goto err_restore_page; > + > + /* leave pll enabled in sleep */ > + ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL); > + if (ret < 0) > + goto err_restore_page; > + > + ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP); > + if (ret < 0) > + goto err_restore_page; > + > +err_restore_page: > + return phy_restore_page(phydev, oldpage, ret); This should likely return 'ret' and not the return value of phy_restore_page(). Sascha -- 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 |