mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-30 15:11:43 +01:00
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>
This commit is contained in:
parent
c6d0c5eb30
commit
733391e84b
@ -10,6 +10,7 @@
|
|||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <linux/sizes.h>
|
#include <linux/sizes.h>
|
||||||
|
#include <linux/iopoll.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <watchdog.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)
|
static inline int is_controller_busy(const struct fsl_qspi_priv *priv)
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
|
u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK |
|
||||||
QSPI_SR_IP_ACC_MASK;
|
QSPI_SR_IP_ACC_MASK;
|
||||||
unsigned long timeout = timer_get_us() + 1000;
|
|
||||||
|
|
||||||
do {
|
if (priv->flags & QSPI_FLAG_REGMAP_ENDIAN_BIG)
|
||||||
val = qspi_read32(priv->flags, &priv->regs->sr);
|
mask = (u32)cpu_to_be32(mask);
|
||||||
|
|
||||||
if ((~val & mask) == mask)
|
return readl_poll_timeout(&priv->regs->sr, val, !(val & mask), 1000);
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (timer_get_us() > timeout )
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
} while (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* QSPI support swapping the flash read/write data
|
/* QSPI support swapping the flash read/write data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user