[U-Boot] [PATCH 2/2] drivers/spi: fsl_qspi: improve timeout calculation

Jagan Teki jagan at amarulasolutions.com
Wed Jul 3 08:40:45 UTC 2019


On Tue, Jul 2, 2019 at 5:13 PM Thomas Schaefer
<Thomas.Schaefer at kontron.com> wrote:
>
> > Von: Jagan Teki <jagan at amarulasolutions.com>
> > Gesendet: Dienstag, 2. Juli 2019 13:12
> >
> > On Mon, Jul 1, 2019 at 9:07 PM Thomas Schaefer <thomas.schaefer at kontron.com> wrote:
> > >
> > > Use readl_poll_timeout instead of explicit calculation
> > >
> > > Signed-off-by: Thomas Schaefer <thomas.schaefer at kontron.com>
> > > ---
> > >  drivers/spi/fsl_qspi.c | 17 ++++++-----------
> > >  1 file changed, 6 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index
> > > 2c5937509f..41abe1996f 100644
> > > --- a/drivers/spi/fsl_qspi.c
> > > +++ b/drivers/spi/fsl_qspi.c
> > > @@ -10,6 +10,7 @@
> > >  #include <spi.h>
> > >  #include <asm/io.h>
> > >  #include <linux/sizes.h>
> > > +#include <linux/iopoll.h>
> > >  #include <dm.h>
> > >  #include <errno.h>
> > >  #include <watchdog.h>
> > > @@ -150,19 +151,13 @@ static void qspi_write32(u32 flags, u32 *addr,
> > > u32 val)  static inline int is_controller_busy(const struct
> > > fsl_qspi_priv *priv)  {
> > >         u32 val;
> > > -       const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
> > > -                        QSPI_SR_IP_ACC_MASK;
> > > -       unsigned long timeout = timer_get_us() + 1000;
> > > +       u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
> > > +                  QSPI_SR_IP_ACC_MASK;
> > >
> > > -       do {
> > > -               val = qspi_read32(priv->flags, &priv->regs->sr);
> > > +       if (priv->flags & QSPI_FLAG_REGMAP_ENDIAN_BIG)
> > > +               mask = (u32)cpu_to_be32(mask);
> >
> > This look like a BE check, which was not there before isn't it?
> >
>
> Hi Jagan,
>
> The previous implementation was using the qspi_read32 function, that
> implemented this endianess checking. As the readl_poll_timeout macro finally
> ends with
>
> #define __arch_getl(a)  (*(volatile unsigned int *)(a))
>
> in arch/arm/include/asm/io.h. When swapping the 'mask' in case of BE, the
> result is the same as when using qspi_read32 before.

Okay, it was supported before. thanks for the clarity.


More information about the U-Boot mailing list