All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shawn Guo <shawn.guo@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/3] net: add higmacv300 Ethernet driver for HiSilicon platform
Date: Thu, 7 Mar 2019 16:29:20 +0800	[thread overview]
Message-ID: <20190307082914.GA19519@dragon> (raw)
In-Reply-To: <CANr=Z=ZeEG-ncho52f6gpOzmpYzpj5MvoT7kz1z0ZtFqifUtiA@mail.gmail.com>

On Wed, Mar 06, 2019 at 08:48:40PM +0000, Joe Hershberger wrote:
> On Tue, Mar 5, 2019 at 7:42 PM Shawn Guo <shawn.guo@linaro.org> wrote:
> >
> > On Tue, Mar 05, 2019 at 11:58:26PM +0000, Joe Hershberger wrote:
> > > > +static int higmac_recv(struct udevice *dev, int flags, uchar **packetp)
> > > > +{
> > > > +       struct higmac_priv *priv = dev_get_priv(dev);
> > > > +       struct higmac_desc *fqd = priv->rxfq;
> > > > +       struct higmac_desc *bqd = priv->rxbq;
> > > > +       int fqw_pos, fqr_pos, bqw_pos, bqr_pos;
> > > > +       int timeout = 100000;
> > > > +       int len = 0;
> > > > +       int space;
> > > > +       int i;
> > > > +
> > > > +       fqw_pos = DESC_CNT(readl(priv->base + RX_FQ_WR_ADDR));
> > > > +       fqr_pos = DESC_CNT(readl(priv->base + RX_FQ_RD_ADDR));
> > > > +
> > > > +       if (fqw_pos >= fqr_pos)
> > > > +               space = RX_DESC_NUM - (fqw_pos - fqr_pos);
> > > > +       else
> > > > +               space = fqr_pos - fqw_pos;
> > > > +
> > > > +       /* Leave one free to distinguish full filled from empty buffer */
> > > > +       for (i = 0; i < space - 1; i++) {
> > > > +               fqd = priv->rxfq + fqw_pos;
> > > > +               invalidate_dcache_range(fqd->buf_addr,
> > > > +                                       fqd->buf_addr + MAC_MAX_FRAME_SIZE);
> > > > +
> > > > +               if (++fqw_pos >= RX_DESC_NUM)
> > > > +                       fqw_pos = 0;
> > > > +
> > > > +               writel(DESC_BYTE(fqw_pos), priv->base + RX_FQ_WR_ADDR);
> > > > +       }
> > > > +
> > > > +       bqr_pos = DESC_CNT(readl(priv->base + RX_BQ_RD_ADDR));
> > > > +       bqd += bqr_pos;
> > > > +       /* BQ is only ever written by GMAC */
> > > > +       invalidate_desc(bqd);
> > > > +
> > > > +       do {
> > > > +               bqw_pos = DESC_CNT(readl(priv->base + RX_BQ_WR_ADDR));
> > > > +               udelay(1);
> > > > +       } while (--timeout && bqw_pos == bqr_pos);
> > >
> > > Did you look into using wait bit macros?
> >
> > I may miss your point, but this is not a loop waiting for some bits set
> > or clear.  It's waiting for a given number.
> 
> OK, I see that, thanks. Should you make these "breakable" in the same
> way that wait_for_bit_* does? The timeout seems quite long.

I assume that you mean the "breakable" as user interaction (CTRL-C)?
I'm not sure 100000 us (0.1 s) is so long for user to break.

<snip>

> > > > +       reset_assert(&priv->rst_phy);
> > > > +       mdelay(30);
> > >
> > > Why is this reasserted?
> >
> > I have to admit this is a bit hackish.  Ideally, the reset sequence
> > should be: deassert -> assert -> deassert.  But this reset signal gets
> > an opposite polarity than others that reset driver handles.  I can add a
> > comment to explain it if you can tolerate this little hack, or I will
> > add polarity support to reset driver to handle this phy reset quirk.
> > Please let me know your preference.
> 
> I would prefer a polarity to be defined in the DT for this reset.

OK, I will implement it in v3.  Thanks for the comment.

Shawn

  reply	other threads:[~2019-03-07  8:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-18  3:37 [U-Boot] [PATCH v2 0/3] Add Ethernet support for Poplar board Shawn Guo
2019-02-18  3:37 ` [U-Boot] [PATCH v2 1/3] reset: add reset driver for HiSilicon platform Shawn Guo
2019-02-18  3:37 ` [U-Boot] [PATCH v2 2/3] net: add higmacv300 Ethernet " Shawn Guo
2019-03-05 23:58   ` Joe Hershberger
2019-03-06  1:41     ` Shawn Guo
2019-03-06 20:48       ` Joe Hershberger
2019-03-07  8:29         ` Shawn Guo [this message]
2019-02-18  3:37 ` [U-Boot] [PATCH v2 3/3] poplar: enable Ethernet driver support Shawn Guo
2019-03-04  6:28 ` [U-Boot] [PATCH v2 0/3] Add Ethernet support for Poplar board Shawn Guo

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=20190307082914.GA19519@dragon \
    --to=shawn.guo@linaro.org \
    --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.