Skip to contentSkip to conversation

iio: adc: rockchip_saradc: Explicitly disable ADC on probe

PATCH In review Guenter Roeck 4 participants 7 messages Jul 25, 2016 – Aug 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: rockchip_saradc: Explicitly disable ADC on probe

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")
---
 drivers/iio/adc/rockchip_saradc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +3 -0
index f9ad6c2d6821..6aa3271d86b5 100644
@@ -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);
Signature · 1 line
2.5.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am Montag, 25. Juli 2016, 12:39:00 schrieb Guenter Roeck:

Quoted 11 lines

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")

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

#2 lore raw
In reply to Guenter Roeck

Hi Guenter,

Thanks for fixing it.

Quoted 20 lines · 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")
---
  drivers/iio/adc/rockchip_saradc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +0 -0
index f9ad6c2d6821..6aa3271d86b5 100644

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 284

Quoted 5 lines
drivers/iio/adc/rockchip_saradc.c +2 -0
@@ -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

Quoted 4 lines
drivers/iio/adc/rockchip_saradc.c +1 -0
+
  	platform_set_drvdata(pdev, indio_dev);
 
  	indio_dev->name = dev_name(&pdev->dev);
Signature · 1 line
caesar wang | software engineer | [email protected]
#3 lore raw
Quoted 45 lines · Caesar Wang

Hi Guenter,

Thanks for fixing it.

Quoted 20 lines · 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")
---
  drivers/iio/adc/rockchip_saradc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +0 -0
index f9ad6c2d6821..6aa3271d86b5 100644

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 283

Quoted 4 lines
drivers/iio/adc/rockchip_saradc.c +2 -0
@@ -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);
}

Quoted 7 lines

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

Ok, I'll give it a try.

Guenter

Quoted 9 lines

-
Caesar

Quoted 3 lines
drivers/iio/adc/rockchip_saradc.c +1 -0
+
      platform_set_drvdata(pdev, indio_dev);
      indio_dev->name = dev_name(&pdev->dev);
#4 lore raw
Quoted 55 lines · Guenter Roeck
Quoted 46 lines · Caesar Wang

Hi Guenter,

Thanks for fixing it.

Quoted 20 lines · 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")
---
  drivers/iio/adc/rockchip_saradc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +0 -0
index f9ad6c2d6821..6aa3271d86b5 100644

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct · line 284

Quoted 5 lines
drivers/iio/adc/rockchip_saradc.c +2 -0
@@ -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);
}

Quoted 7 lines

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

Quoted 2 lines

Ok, I'll give it a try.

I posted it on https://patchwork.kernel.org/patch/9247661/

Quoted 17 lines

Guenter

Quoted 9 lines

-
Caesar

Quoted 3 lines
drivers/iio/adc/rockchip_saradc.c +1 -0
+
      platform_set_drvdata(pdev, indio_dev);
      indio_dev->name = dev_name(&pdev->dev);

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | [email protected]
maintainer
#5 lore raw
In reply to Guenter Roeck
Quoted 54 lines · Guenter Roeck
Quoted 45 lines · Caesar Wang

Hi Guenter,

Thanks for fixing it.

Quoted 20 lines · 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")
---
  drivers/iio/adc/rockchip_saradc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +0 -0
index f9ad6c2d6821..6aa3271d86b5 100644

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 283

Quoted 4 lines
drivers/iio/adc/rockchip_saradc.c +2 -0
@@ -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);
}

Quoted 7 lines

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

Quoted 3 lines

Ok, I'll give it a try.

Guenter

Could you confirm if this patch is superseded by that change or not?

Quoted 15 lines
Quoted 10 lines

-
Caesar

Quoted 3 lines
drivers/iio/adc/rockchip_saradc.c +1 -0
+
      platform_set_drvdata(pdev, indio_dev);
      indio_dev->name = dev_name(&pdev->dev);
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Hi Jonathan,

Quoted 55 lines · Jonathan Cameron
Quoted 54 lines · Guenter Roeck
Quoted 52 lines · Caesar Wang

Hi Guenter,

Thanks for fixing it.

Quoted 20 lines · 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")
---
  drivers/iio/adc/rockchip_saradc.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/iio/adc/rockchip_saradc.c +0 -0
index f9ad6c2d6821..6aa3271d86b5 100644

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 283

Quoted 4 lines
drivers/iio/adc/rockchip_saradc.c +2 -0
@@ -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();
...
}

Quoted 5 lines
Quoted 3 lines

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