All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] dm: net: macb: Implement link speed change callback
Date: Wed, 22 May 2019 14:55:20 +0800	[thread overview]
Message-ID: <CAEUhbmXbJW29FZoXvbTmp1qtr-JONWRY9bzaD-_0O3YRsu5HMA@mail.gmail.com> (raw)
In-Reply-To: <6a2d75bb46d063ae058f81f2aff32615f2da1330.camel@aisec.fraunhofer.de>

Hi Lukas,

On Mon, May 20, 2019 at 7:29 PM Auer, Lukas
<lukas.auer@aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Thu, 2019-05-16 at 02:12 -0700, Bin Meng wrote:
> > At present the link speed change callback is a nop. According to
> > macb device tree bindings, an optional "tx_clk" is used to clock
> > the ethernet controller's TX_CLK under different link speed.
> >
> > In 10/100 MII mode, transmit logic must be clocked from a free
> > running clock generated by the external PHY. In gigabit GMII mode,
> > the controller, not the external PHY, must generate the 125 MHz
> > transmit clock towards the PHY.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  drivers/net/macb.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> >
> > diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> > index b7f404e..7d86fa1 100644
> > --- a/drivers/net/macb.c
> > +++ b/drivers/net/macb.c
> > @@ -497,6 +497,32 @@ static int macb_phy_find(struct macb_device *macb, const char *name)
> >  #ifdef CONFIG_DM_ETH
> >  int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed)
> >  {
> > +#ifdef CONFIG_CLK
> > +     struct clk tx_clk;
> > +     ulong rate;
> > +     int ret;
> > +
> > +     ret = clk_get_by_name(dev, "tx_clk", &tx_clk);
> > +     if (ret)
> > +             return 0;
>
> Can you return errors in ret here?

No, we should ignore DT that does not contain the "tx_clk" source
hence cannot return error here. I will add a comment in v2.

>
> > +
> > +     switch (speed) {
> > +     case _10BASET:
> > +             rate = 2500000;
> > +             break;
> > +     case _100BASET:
> > +             rate = 25000000;
> > +             break;
> > +     case _1000BASET:
> > +     default:
> > +             rate = 125000000;
> > +             break;
>
> The Linux driver simply returns in the default case, without changing
> tx_clk. I am wondering if we should do the same in U-Boot?

Sure.

>
> > +     }
> > +
> > +     if (tx_clk.dev)
> > +             clk_set_rate(&tx_clk, rate);
>
> Can you also check the return value of clk_set_rate() here?

Will add the return value check in v2.

Regards,
Bin

  reply	other threads:[~2019-05-22  6:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16  9:12 [U-Boot] [PATCH 0/4] riscv: sifive: fu540: Make GEM 10/100 Mbps work Bin Meng
2019-05-16  9:12 ` [U-Boot] [PATCH 1/4] clk: sifive: Add clock driver for GEMGXL MGMT Bin Meng
2019-05-20 11:26   ` Auer, Lukas
2019-05-22  6:53     ` Bin Meng
2019-05-16  9:12 ` [U-Boot] [PATCH 2/4] dm: net: macb: Update macb_linkspd_cb() signature Bin Meng
2019-05-20 11:27   ` Auer, Lukas
2019-05-16  9:12 ` [U-Boot] [PATCH 3/4] dm: net: macb: Implement link speed change callback Bin Meng
2019-05-20 11:29   ` Auer, Lukas
2019-05-22  6:55     ` Bin Meng [this message]
2019-05-16  9:12 ` [U-Boot] [PATCH 4/4] sifive: fu540: Enable GEMGXL MGMT driver Bin Meng
2019-05-20 11:32   ` Auer, Lukas

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=CAEUhbmXbJW29FZoXvbTmp1qtr-JONWRY9bzaD-_0O3YRsu5HMA@mail.gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.