[PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe

Caesar Wang wxt at rock-chips.com
Mon Jul 25 19:51:34 PDT 2016


Hi Guenter,

Thanks for fixing it.

On 2016年07月26日 03:39, Guenter Roeck wrote:
> If the ADC is read for the first time, the caller gets a timeout error,
> and the kernel log shows
>
> read channel() error: -110
>
> The ADC may be enabled on boot, and needs to be explicitly disabled
> for a read sequence to work (otherwise there is no completion interrupt).
> Disaple it explicitly in the probe function.
>
> Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
> Signed-off-by: Guenter Roeck <linux at roeck-us.net>
> ---
>   drivers/iio/adc/rockchip_saradc.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> index f9ad6c2d6821..6aa3271d86b5 100644
> --- a/drivers/iio/adc/rockchip_saradc.c
> +++ b/drivers/iio/adc/rockchip_saradc.c
> @@ -280,6 +280,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
>   		goto err_pclk;
>   	}
>   
> +	/* Make sure ADC is disabled */
> +	writel_relaxed(0, info->regs + SARADC_CTRL);

I think we should reset the saradc controller.
Since make sure the reset value is 0 and loader-->kernel may even cause 
harm, as my experience on tsadc. (drivers/thermal/rockchip_thermal.c)


e.g.:
/**
* Reset SARADC Controller, reset all saradc registers.
*/
static void rockchip_saradc_reset_controller(struct reset_control *reset)
{
reset_control_assert(reset);
usleep_range(10, 20);
reset_control_deassert(reset);
}

..probe()
{
...
rockchip_saradc_reset_controller();
...
}


-
Caesar

> +
>   	platform_set_drvdata(pdev, indio_dev);
>   
>   	indio_dev->name = dev_name(&pdev->dev);


-- 
caesar wang | software engineer | wxt at rock-chip.com





More information about the Linux-rockchip mailing list