drivers/spi: fsl_qspi: fix controller busy check
PATCH 1/1 drivers/spi: fsl_qspi: fix controller busy check
From: Thomas Schaefer <[email protected]>
During QSPI reads, current is_busy_controller function sporadically fails with -ETIMEDOUT due to fixed number of 5 test loops. This patch fixes this by using the readl_poll_timeout function with 1000 us timeout.
--- drivers/spi/fsl_qspi.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/spi/fsl_qspi.c +6 -12
@@ -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,20 +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 int retry =5 ; +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 ; - -udelay (1 ); - }while (--retry); - -return -ETIMEDOUT ; +return readl_poll_timeout (&priv->regs->sr, val, !(val & mask),1000 ); }/* QSPI support swapping the flash read/write data
Signature · 1 line
2.11.0
PATCH 1/1 drivers/spi: fsl_qspi: fix controller busy check
Quoted 7 lines · Fabio Estevam
From: Thomas Schaefer <[email protected]>
During QSPI reads, current
is_busy_controllerfunction sporadically fails with-ETIMEDOUTdue to fixed number of 5 test loops. This patch fixes this by using thereadl_poll_timeoutfunction with 1000 us timeout.
This sounds like two different functionalities into one patch. better create a timeout fix in one patch and another patch to migrate read_poll.