<div dir="ltr">Huh. We've been getting valid readings without this on our AST2500 systems. Regardless, it is correct for AST2500. On AST2400 though, there is no INIT_RDY bit.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 13, 2017 at 7:28 AM, Mykola Kostenok <span dir="ltr"><<a href="mailto:c_mykolak@mellanox.com" target="_blank">c_mykolak@mellanox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch enables adc engine at initialization time and waits<br>
for the initial sequence completion before enabling adc channels.<br>
<br>
Without this code adc channels are not functional and shows<br>
zeros for all connected channels.<br>
<br>
Tested on mellanox msn platform.<br>
<br>
Signed-off-by: Mykola Kostenok <<a href="mailto:c_mykolak@mellanox.com">c_mykolak@mellanox.com</a>><br>
---<br>
drivers/iio/adc/aspeed_adc.c | 20 ++++++++++++++++++++<br>
1 file changed, 20 insertions(+)<br>
<br>
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c<br>
index 2283ed2..e4ad6ef 100644<br>
--- a/drivers/iio/adc/aspeed_adc.c<br>
+++ b/drivers/iio/adc/aspeed_adc.c<br>
@@ -22,6 +22,7 @@<br>
<br>
#include <linux/iio/iio.h><br>
#include <linux/iio/driver.h><br>
+#include <linux/iopoll.h><br>
<br>
#define ASPEED_RESOLUTION_BITS 10<br>
#define ASPEED_CLOCKS_PER_SAMPLE 12<br>
@@ -38,6 +39,11 @@<br>
<br>
#define ASPEED_ENGINE_ENABLE BIT(0)<br>
<br>
+#define ASPEED_ADC_CTRL_INIT_RDY BIT(8)<br>
+<br>
+#define ASPEED_ADC_INIT_POLLING_TIME 500<br>
+#define ASPEED_ADC_INIT_TIMEOUT 500000<br>
+<br>
struct aspeed_adc_model_data {<br>
const char *model_name;<br>
unsigned int min_sampling_rate; // Hz<br>
@@ -210,6 +216,20 @@ static int aspeed_adc_probe(struct platform_device *pdev)<br>
goto scaler_error;<br>
}<br>
<br>
+ /* Enable engine in normal mode. */<br>
+ writel(ASPEED_OPERATION_MODE_<wbr>NORMAL | ASPEED_ENGINE_ENABLE,<br>
+ data->base + ASPEED_REG_ENGINE_CONTROL);<br>
+<br>
+ /* Wait for initial sequence complete. */<br>
+ ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL,<br>
+ adc_engine_control_reg_val,<br>
+ adc_engine_control_reg_val &<br>
+ ASPEED_ADC_CTRL_INIT_RDY,<br>
+ ASPEED_ADC_INIT_POLLING_TIME,<br>
+ ASPEED_ADC_INIT_TIMEOUT);<br>
+ if (ret)<br>
+ goto scaler_error;<br>
+<br>
/* Start all channels in normal mode. */<br>
clk_prepare_enable(data->clk_<wbr>scaler->clk);<br>
adc_engine_control_reg_val = GENMASK(31, 16) |<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.8.4<br>
<br>
</font></span></blockquote></div><br></div>