[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250804100219.63325-8-varshini.rajendran@microchip.com>
Date: Mon, 4 Aug 2025 15:32:11 +0530
From: Varshini Rajendran <varshini.rajendran@...rochip.com>
To: <eugen.hristev@...aro.org>, <jic23@...nel.org>, <dlechner@...libre.com>,
<nuno.sa@...log.com>, <andy@...nel.org>, <robh@...nel.org>,
<krzk+dt@...nel.org>, <conor+dt@...nel.org>, <nicolas.ferre@...rochip.com>,
<alexandre.belloni@...tlin.com>, <claudiu.beznea@...on.dev>,
<srini@...nel.org>, <linux-iio@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <varshini.rajendran@...rochip.com>
Subject: [PATCH 07/15] iio: adc: at91-sama5d2_adc: add temp init function as callback
Adding the temperature sensor init function as a callback function.
The temperature sensor initialisation sequence is handled differently
for each platform. The same is added to the platform data of the
corresponding device. This allows us to handle new devices like
sama7d65.
Signed-off-by: Varshini Rajendran <varshini.rajendran@...rochip.com>
---
drivers/iio/adc/at91-sama5d2_adc.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index d952109a64a9..916682e326c7 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -453,6 +453,10 @@ static const struct at91_adc_reg_layout sama7g5_layout = {
*/
#define AT91_TEMP_CALIB_TAG 0x41435354
+struct at91_adc_state;
+static int at91_adc_temp_sensor_init(struct at91_adc_state *st,
+ struct device *dev);
+
/**
* struct at91_adc_platform - at91-sama5d2 platform information struct
* @layout: pointer to the reg layout struct
@@ -472,6 +476,8 @@ static const struct at91_adc_reg_layout sama7g5_layout = {
* @chan_realbits: realbits for registered channels
* @temp_chan: temperature channel index
* @temp_sensor: temperature sensor supported
+ * @temp_init: callback function to initialize the temperature sensor
+ * with its calibration data
*/
struct at91_adc_platform {
const struct at91_adc_reg_layout *layout;
@@ -489,6 +495,7 @@ struct at91_adc_platform {
unsigned int chan_realbits;
unsigned int temp_chan;
bool temp_sensor;
+ int (*temp_init)(struct at91_adc_state *st, struct device *dev);
};
/**
@@ -729,6 +736,7 @@ static const struct at91_adc_platform sama5d2_platform = {
.oversampling_avail = { 1, 4, 16, },
.oversampling_avail_no = 3,
.chan_realbits = 14,
+ .temp_init = at91_adc_temp_sensor_init,
};
static const struct at91_adc_platform sama7g5_platform = {
@@ -753,6 +761,7 @@ static const struct at91_adc_platform sama7g5_platform = {
.chan_realbits = 16,
.temp_sensor = true,
.temp_chan = AT91_SAMA7G5_ADC_TEMP_CHANNEL,
+ .temp_init = at91_adc_temp_sensor_init,
};
static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan)
@@ -2328,7 +2337,7 @@ static int at91_adc_probe(struct platform_device *pdev)
st->soc_info.platform = device_get_match_data(dev);
- ret = at91_adc_temp_sensor_init(st, &pdev->dev);
+ ret = st->soc_info.platform->temp_init(st, &pdev->dev);
/* Don't register temperature channel if initialization failed. */
if (ret)
num_channels = st->soc_info.platform->max_channels - 1;
--
2.34.1
Powered by blists - more mailing lists