summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-amd.c
diff options
context:
space:
mode:
authorAndré Almeida <andrealmeid@collabora.com>2022-02-11 17:31:53 +0300
committerMark Brown <broonie@kernel.org>2022-02-14 15:53:03 +0300
commit715bea3568e78b80b1d127d8452eac0e3cb6f299 (patch)
tree86c841218fb25f7dd859c670123c176f6c8066ed /drivers/spi/spi-amd.c
parent2cbfa2128662c6b841f68cd2fe54df199457e38a (diff)
downloadlinux-715bea3568e78b80b1d127d8452eac0e3cb6f299.tar.xz
spi: amd: Use iopoll for busy waiting
Instead of implementing a custom IO busy wait function, just use readl_poll_timeout(). Signed-off-by: André Almeida <andrealmeid@collabora.com> Link: https://lore.kernel.org/r/20220211143155.75513-2-andrealmeid@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-amd.c')
-rw-r--r--drivers/spi/spi-amd.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index 4b3ac7aceaf6..899b8d90ff61 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -12,6 +12,7 @@
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/spi/spi.h>
+#include <linux/iopoll.h>
#define AMD_SPI_CTRL0_REG 0x00
#define AMD_SPI_EXEC_CMD BIT(16)
@@ -103,16 +104,10 @@ static inline void amd_spi_set_tx_count(struct amd_spi *amd_spi, u8 tx_count)
static int amd_spi_busy_wait(struct amd_spi *amd_spi)
{
- int timeout = 100000;
+ u32 val;
- /* poll for SPI bus to become idle */
- while (amd_spi_readreg32(amd_spi, AMD_SPI_CTRL0_REG) & AMD_SPI_BUSY) {
- usleep_range(10, 20);
- if (timeout-- < 0)
- return -ETIMEDOUT;
- }
-
- return 0;
+ return readl_poll_timeout(amd_spi->io_remap_addr + AMD_SPI_CTRL0_REG,
+ val, !(val & AMD_SPI_BUSY), 20, 2000000);
}
static int amd_spi_execute_opcode(struct amd_spi *amd_spi)