Re: [PATCH] net: phy: add driver for MotorComm PHY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sascha,

On Thu, Jun 1, 2023 at 10:17 AM Sascha Hauer <sha@xxxxxxxxxxxxxx> wrote:
>
> 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.

The driver corresponds to the kernel 6.1.x. The upstream kernel driver
supports more chips. But I have only this one. So, I cannot test other
chips. Is it OK for you to merge the reduced version or should I port
the complete one?

>
> > 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().

If I understand it correctly, phy_restore_page() will also propagate
the ret it gets as a parameter [1] under some circumstances.

[1] https://github.com/barebox/barebox/blob/master/drivers/net/phy/phy-core.c#L91

Yegor

> 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 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux