* [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
@ 2016-07-25 19:39 Guenter Roeck
2016-07-25 19:41 ` Heiko Stübner
2016-07-26 2:51 ` Caesar Wang
0 siblings, 2 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-07-25 19:39 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Heiko Stuebner, linux-iio, linux-rockchip, linux-kernel,
Caesar Wang, dianders, Guenter Roeck
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@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);
+
platform_set_drvdata(pdev, indio_dev);
indio_dev->name = dev_name(&pdev->dev);
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-07-25 19:39 [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe Guenter Roeck
@ 2016-07-25 19:41 ` Heiko Stübner
2016-07-26 2:51 ` Caesar Wang
1 sibling, 0 replies; 7+ messages in thread
From: Heiko Stübner @ 2016-07-25 19:41 UTC (permalink / raw)
To: Guenter Roeck
Cc: Jonathan Cameron, linux-iio, linux-rockchip, linux-kernel,
Caesar Wang, dianders
Am Montag, 25. Juli 2016, 12:39:00 schrieb Guenter Roeck:
> 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@roeck-us.net>
in my tests I hadn't notices that issue before, but that is likely because the
bootloaders I had didn't enable the saradc. Anyway, that looks definitly sane,
so
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-07-25 19:39 [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe Guenter Roeck
2016-07-25 19:41 ` Heiko Stübner
@ 2016-07-26 2:51 ` Caesar Wang
2016-07-26 3:22 ` Guenter Roeck
1 sibling, 1 reply; 7+ messages in thread
From: Caesar Wang @ 2016-07-26 2:51 UTC (permalink / raw)
To: Guenter Roeck, Jonathan Cameron, Heiko Stuebner
Cc: linux-iio, dianders, linux-kernel, linux-rockchip, Caesar Wang
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@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@rock-chip.com
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-07-26 2:51 ` Caesar Wang
@ 2016-07-26 3:22 ` Guenter Roeck
2016-07-26 6:48 ` Caesar Wang
2016-08-15 18:04 ` Jonathan Cameron
0 siblings, 2 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-07-26 3:22 UTC (permalink / raw)
To: Caesar Wang, Jonathan Cameron, Heiko Stuebner
Cc: linux-iio, dianders, linux-kernel, linux-rockchip
On 07/25/2016 07:51 PM, Caesar Wang wrote:
> 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@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();
> ...
> }
>
Ok, I'll give it a try.
Guenter
>
> -
> Caesar
>
>> +
>> platform_set_drvdata(pdev, indio_dev);
>> indio_dev->name = dev_name(&pdev->dev);
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-07-26 3:22 ` Guenter Roeck
@ 2016-07-26 6:48 ` Caesar Wang
2016-08-15 18:04 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Caesar Wang @ 2016-07-26 6:48 UTC (permalink / raw)
To: Guenter Roeck, Jonathan Cameron, Heiko Stuebner
Cc: Caesar Wang, linux-iio, linux-rockchip, dianders, linux-kernel
On 2016年07月26日 11:22, Guenter Roeck wrote:
> On 07/25/2016 07:51 PM, Caesar Wang wrote:
>> 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@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();
>> ...
>> }
>>
>
> Ok, I'll give it a try.
>
I posted it on https://patchwork.kernel.org/patch/9247661/
> Guenter
>
>>
>> -
>> Caesar
>>
>>> +
>>> platform_set_drvdata(pdev, indio_dev);
>>> indio_dev->name = dev_name(&pdev->dev);
>>
>>
>
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
--
caesar wang | software engineer | wxt@rock-chip.com
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-07-26 3:22 ` Guenter Roeck
2016-07-26 6:48 ` Caesar Wang
@ 2016-08-15 18:04 ` Jonathan Cameron
2016-08-15 19:52 ` Guenter Roeck
1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2016-08-15 18:04 UTC (permalink / raw)
To: Guenter Roeck, Caesar Wang, Heiko Stuebner
Cc: linux-iio, dianders, linux-kernel, linux-rockchip
On 26/07/16 04:22, Guenter Roeck wrote:
> On 07/25/2016 07:51 PM, Caesar Wang wrote:
>> 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@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();
>> ...
>> }
>>
>
> Ok, I'll give it a try.
>
> Guenter
Could you confirm if this patch is superseded by that
change or not?
>
>>
>> -
>> Caesar
>>
>>> +
>>> platform_set_drvdata(pdev, indio_dev);
>>> indio_dev->name = dev_name(&pdev->dev);
>>
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe
2016-08-15 18:04 ` Jonathan Cameron
@ 2016-08-15 19:52 ` Guenter Roeck
0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2016-08-15 19:52 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Caesar Wang, Heiko Stuebner, linux-iio, dianders, linux-kernel,
linux-rockchip
Hi Jonathan,
On Mon, Aug 15, 2016 at 07:04:31PM +0100, Jonathan Cameron wrote:
> On 26/07/16 04:22, Guenter Roeck wrote:
> > On 07/25/2016 07:51 PM, Caesar Wang wrote:
> >> 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@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();
> >> ...
> >> }
> >>
> >
> > Ok, I'll give it a try.
> >
> > Guenter
> Could you confirm if this patch is superseded by that
> change or not?
Yes, that is correct. The version using the reset has been applied to
chromeos-4.4 [1] with commit 86aeb7c3f ("FROMLIST: iio: adc: rockchip_saradc:
reset saradc controller before programming it").
Thanks,
Guenter
---
[1] https://chromium.googlesource.com/chromiumos/third_party/kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-08-15 19:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-25 19:39 [PATCH] iio: adc: rockchip_saradc: Explicitly disable ADC on probe Guenter Roeck
2016-07-25 19:41 ` Heiko Stübner
2016-07-26 2:51 ` Caesar Wang
2016-07-26 3:22 ` Guenter Roeck
2016-07-26 6:48 ` Caesar Wang
2016-08-15 18:04 ` Jonathan Cameron
2016-08-15 19:52 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).