linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: igal.liberman@freescale.com
Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	madalin.bucur@freescale.com, pebolle@tiscali.nl
Subject: Re: [v2,3/9] fsl/fman: Add the FMan MAC FLIB
Date: Thu, 25 Jun 2015 20:55:51 -0500	[thread overview]
Message-ID: <1435283751.4306.13.camel@freescale.com> (raw)
In-Reply-To: <1435174458-452-1-git-send-email-igal.liberman@freescale.com>

On Wed, 2015-06-24 at 22:34 +0300, igal.liberman@freescale.com wrote:
> From: Igal Liberman <Igal.Liberman@freescale.com>
> 
> The FMan MAC FLib provides basic API used by the drivers to
> configure and control the FMan MAC hardware.
> 
> Signed-off-by: Igal Liberman <Igal.Liberman@freescale.com>
...
> > +int fman_dtsec_mii_write_reg(struct dtsec_mii_reg __iomem *regs, uint8_t 
> addr,
> +                          uint8_t reg, uint16_t data, uint16_t dtsec_freq)
> +{
> +     uint32_t tmp;
> +
> +     /* Setup the MII Mgmt clock speed */
> +     iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Stop the MII management read cycle */
> +     iowrite32be(0, &regs->miimcom);
> +     /* Dummy read to make sure MIIMCOM is written */
> +     tmp = ioread32be(&regs->miimcom);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Setting up MII Management Address Register */
> +     tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
> +     iowrite32be(tmp, &regs->miimadd);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Setting up MII Management Control Register with data */
> +     iowrite32be((uint32_t)data, &regs->miimcon);
> +     /* Dummy read to make sure MIIMCON is written */
> +     tmp = ioread32be(&regs->miimcon);
> +     /* Memory barrier */
> +     wmb();

iowrite32be() should already contain a memory barrier.

> +
> +     /* Wait until MII management write is complete */
> +     /* todo: a timeout could be useful here */
> +     while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
> +             ; /* busy wait */
> +
> +     return 0;
> +}

Please add the timeout.

> +     /* Read MII management status  */
> +     *data = (uint16_t)ioread32be(&regs->miimstat);

Unnecessary cast (please check for these throughout the patchset).

There are also casts in this patchset that are only needed because a variable 
was unnecessarily defined with a smaller-than-32-bit data type.


> +void fman_memac_reset(struct memac_regs __iomem *regs)
> +{
> +     uint32_t tmp;
> +
> +     tmp = ioread32be(&regs->command_config);
> +
> +     tmp |= CMD_CFG_SW_RESET;
> +
> +     iowrite32be(tmp, &regs->command_config);
> +
> +     while (ioread32be(&regs->command_config) & CMD_CFG_SW_RESET)
> +             ;
> +}

Timeout, here and in all such loops.

-Scott

      reply	other threads:[~2015-06-26  1:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24 19:34 [v2,3/9] fsl/fman: Add the FMan MAC FLIB igal.liberman
2015-06-26  1:55 ` Scott Wood [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=1435283751.4306.13.camel@freescale.com \
    --to=scottwood@freescale.com \
    --cc=igal.liberman@freescale.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=madalin.bucur@freescale.com \
    --cc=netdev@vger.kernel.org \
    --cc=pebolle@tiscali.nl \
    /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;
as well as URLs for NNTP newsgroup(s).