[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210824091243.9393-7-billy_tsai@aspeedtech.com>
Date: Tue, 24 Aug 2021 17:12:34 +0800
From: Billy Tsai <billy_tsai@...eedtech.com>
To: <jic23@...nel.org>, <lars@...afoo.de>, <pmeerw@...erw.net>,
<robh+dt@...nel.org>, <joel@....id.au>, <andrew@...id.au>,
<p.zabel@...gutronix.de>, <lgirdwood@...il.com>,
<broonie@...nel.org>, <linux-iio@...r.kernel.org>,
<devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-aspeed@...ts.ozlabs.org>, <linux-kernel@...r.kernel.org>
CC: <BMC-SW@...eedtech.com>
Subject: [RESEND v4 06/15] iio: adc: aspeed: Add vref config function
Add the function to check the vref_fixed and set the value to driver
data.
Signed-off-by: Billy Tsai <billy_tsai@...eedtech.com>
---
drivers/iio/adc/aspeed_adc.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index f03c7921d534..f260e40ab9b2 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -122,7 +122,7 @@ static int aspeed_adc_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- *val = data->model_data->vref_fixed;
+ *val = data->vref;
*val2 = ASPEED_RESOLUTION_BITS;
return IIO_VAL_FRACTIONAL_LOG2;
@@ -187,6 +187,17 @@ static const struct iio_info aspeed_adc_iio_info = {
.debugfs_reg_access = aspeed_adc_reg_access,
};
+static int aspeed_adc_vref_config(struct iio_dev *indio_dev)
+{
+ struct aspeed_adc_data *data = iio_priv(indio_dev);
+
+ if (data->model_data->vref_fixed) {
+ data->vref = data->model_data->vref_fixed;
+ return 0;
+ }
+ return 0;
+}
+
static int aspeed_adc_probe(struct platform_device *pdev)
{
struct iio_dev *indio_dev;
@@ -242,6 +253,10 @@ static int aspeed_adc_probe(struct platform_device *pdev)
}
reset_control_deassert(data->rst);
+ ret = aspeed_adc_vref_config(indio_dev);
+ if (ret)
+ goto vref_config_error;
+
if (data->model_data->wait_init_sequence) {
/* Enable engine in normal mode. */
writel(FIELD_PREP(ASPEED_ADC_OP_MODE,
@@ -290,6 +305,7 @@ static int aspeed_adc_probe(struct platform_device *pdev)
clk_disable_unprepare(data->clk_scaler->clk);
clk_enable_error:
poll_timeout_error:
+vref_config_error:
reset_control_assert(data->rst);
reset_error:
clk_hw_unregister_divider(data->clk_scaler);
--
2.25.1
Powered by blists - more mailing lists