summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo Dureghello <adureghello@baylibre.com>2025-04-09 12:16:54 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2025-05-07 21:40:38 +0300
commit921fece3268c3bf2e8c20dd17ff9e5454fa16fda (patch)
treecb982229f6b2f385fbc7cb4ee0e4862b352da5d1
parent89944d88f8795c6c89b9514cb365998145511cd4 (diff)
downloadlinux-921fece3268c3bf2e8c20dd17ff9e5454fa16fda.tar.xz
iio: dac: adi-axi-dac: fix bus read
Fix bus read function. Testing the driver, on a random basis, wrong reads was detected, mainly by a wrong DAC chip ID read at first boot. Before reading the expected value from the AXI regmap, need always to wait for busy flag to be cleared. Fixes: e61d7178429a ("iio: dac: adi-axi-dac: extend features") Signed-off-by: Angelo Dureghello <adureghello@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250409-ad3552r-fix-bus-read-v2-1-34d3b21e8ca0@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/dac/adi-axi-dac.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index 892d770aec69..05b374e137d3 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -707,6 +707,7 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
{
struct axi_dac_state *st = iio_backend_get_priv(back);
int ret;
+ u32 ival;
guard(mutex)(&st->lock);
@@ -719,6 +720,13 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
if (ret)
return ret;
+ ret = regmap_read_poll_timeout(st->regmap,
+ AXI_DAC_UI_STATUS_REG, ival,
+ FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0,
+ 10, 100 * KILO);
+ if (ret)
+ return ret;
+
return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val);
}