[PATCH 2/4] iio: adc: at91-sama5d2: initialize hardware after clock is started

From: Eugen Hristev
Date: Mon Mar 01 2021 - 09:35:02 EST


The hw_init hardware init call must happen after the clock is prepared and
enabled. Otherwise, writing to the registers might lead to a block or
external abort.

Signed-off-by: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
---
drivers/iio/adc/at91-sama5d2_adc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index a7826f097b95..63325f037f09 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -1832,12 +1832,12 @@ static int at91_adc_probe(struct platform_device *pdev)
goto vref_disable;
}

- at91_adc_hw_init(indio_dev);
-
ret = clk_prepare_enable(st->per_clk);
if (ret)
goto vref_disable;

+ at91_adc_hw_init(indio_dev);
+
platform_set_drvdata(pdev, indio_dev);

ret = at91_adc_buffer_and_trigger_init(&pdev->dev, indio_dev);
--
2.25.1