iio: adc: axi-adc: make sure AXI clock is enabled
authorNuno Sa <nuno.sa@analog.com>
Fri, 26 Apr 2024 15:42:13 +0000 (17:42 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 29 Apr 2024 19:53:26 +0000 (20:53 +0100)
We can only access the IP core registers if the bus clock is enabled. As
such we need to get and enable it and not rely on anyone else to do it.

Note this clock is a very fundamental one that is typically enabled
pretty early during boot. Independently of that, we should really rely on
it to be enabled.

Fixes: ef04070692a2 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240426-ad9467-new-features-v2-4-6361fc3ba1cc@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/adi-axi-adc.c

index 9444b0c5a93c6a32fcf91e1660e51b73740ad40c..f54830658da89718806efdb8e4eebcbdde2c80c5 100644 (file)
@@ -161,6 +161,7 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
        struct adi_axi_adc_state *st;
        void __iomem *base;
        unsigned int ver;
+       struct clk *clk;
        int ret;
 
        st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
@@ -181,6 +182,10 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
        if (!expected_ver)
                return -ENODEV;
 
+       clk = devm_clk_get_enabled(&pdev->dev, NULL);
+       if (IS_ERR(clk))
+               return PTR_ERR(clk);
+
        /*
         * Force disable the core. Up to the frontend to enable us. And we can
         * still read/write registers...