mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Yegor Yefremov <yegorslists@googlemail.com>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net: phy: add driver for MotorComm PHY
Date: Thu, 1 Jun 2023 10:51:06 +0200	[thread overview]
Message-ID: <CAGm1_ku_jsmK1Jji3YN+BXcnZpzDJ56tNbNf_TCnRJ8hRo2=AQ@mail.gmail.com> (raw)
In-Reply-To: <20230601081716.GK18491@pengutronix.de>

Hi Sascha,

On Thu, Jun 1, 2023 at 10:17 AM Sascha Hauer <sha@pengutronix.de> wrote:
>
> Hi Yegor,
>
> On Wed, May 31, 2023 at 04:35:00PM +0200, yegorslists@googlemail.com wrote:
> > From: Yegor Yefremov <yegorslists@googlemail.com>
> >
>
> 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@googlemail.com>
> > ---
> >  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 |



      reply	other threads:[~2023-06-01  8:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 14:35 yegorslists
2023-06-01  8:17 ` Sascha Hauer
2023-06-01  8:51   ` Yegor Yefremov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGm1_ku_jsmK1Jji3YN+BXcnZpzDJ56tNbNf_TCnRJ8hRo2=AQ@mail.gmail.com' \
    --to=yegorslists@googlemail.com \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox