Skip to content

Commit 921fece

Browse files
spectrum70jic23
authored andcommitted
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: e61d717 ("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>
1 parent 89944d8 commit 921fece

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/iio/dac/adi-axi-dac.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
707707
{
708708
struct axi_dac_state *st = iio_backend_get_priv(back);
709709
int ret;
710+
u32 ival;
710711

711712
guard(mutex)(&st->lock);
712713

@@ -719,6 +720,13 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
719720
if (ret)
720721
return ret;
721722

723+
ret = regmap_read_poll_timeout(st->regmap,
724+
AXI_DAC_UI_STATUS_REG, ival,
725+
FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0,
726+
10, 100 * KILO);
727+
if (ret)
728+
return ret;
729+
722730
return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val);
723731
}
724732

0 commit comments

Comments
 (0)