diff options
author | Thomas Schaefer <thomas.schaefer@kontron.com> | 2019-07-01 17:37:35 +0200 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2019-07-18 17:11:16 +0530 |
commit | 733391e84bd9d67582b2ecd719b35585b70fe74c (patch) | |
tree | a61f49dffda80e10f15c2c70436f9f34f1036dee /drivers/spi | |
parent | c6d0c5eb30b5d677a6eeca5079a4e9a27630b530 (diff) | |
download | u-boot-733391e84bd9d67582b2ecd719b35585b70fe74c.tar.gz |
drivers/spi: fsl_qspi: improve timeout calculation
Use readl_poll_timeout instead of explicit calculation
Signed-off-by: Thomas Schaefer <thomas.schaefer@kontron.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/fsl_qspi.c | 17 |
1 files 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); - if ((~val & mask) == mask) - return 0; - - if (timer_get_us() > timeout ) - return -ETIMEDOUT; - } while (1); + return readl_poll_timeout(&priv->regs->sr, val, !(val & mask), 1000); } /* QSPI support swapping the flash read/write data |