[PATCH v1 12/17] rockchip: adc: fix the hangups

Johan Jonker jbx6244 at gmail.com
Sun May 8 17:08:20 CEST 2022


The Rockchip saradc behaves strange when doing an "adc scan"
with hang ups. Fix by adding an adc power down before the
settings are made. Similair to what TRM recommands follow
this flow below:

Power-down A/D Converter in SARADC_CTRL[3]
Power-up A/D Converter in SARADC_CTRL[3] and select input channel of A/D
Converter in SARADC_CTRL[2:0] bit
Wait an A/D interrupt or poll the SARADC_STAS register to determine
when the conversion is completed
Read the conversion result in the SARADC_DATA register

Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
---
 drivers/adc/rockchip-saradc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
index e6a0341d..fb0f2e03 100644
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <asm/io.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <power/regulator.h>
 
@@ -82,6 +83,10 @@ int rockchip_saradc_start_channel(struct udevice *dev, int channel)
 		return -EINVAL;
 	}
 
+	writel(0, &priv->regs->ctrl);
+
+	udelay(1);
+
 	/* 8 clock periods as delay between power up and start cmd */
 	writel(8, &priv->regs->dly_pu_soc);
 
-- 
2.20.1



More information about the U-Boot mailing list