linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Varshini Rajendran <varshini.rajendran@microchip.com>
To: <eugen.hristev@linaro.org>, <jic23@kernel.org>,
	<dlechner@baylibre.com>, <nuno.sa@analog.com>, <andy@kernel.org>,
	<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
	<claudiu.beznea@tuxon.dev>, <srini@kernel.org>,
	<linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: <varshini.rajendran@microchip.com>
Subject: [PATCH 07/15] iio: adc: at91-sama5d2_adc: add temp init function as callback
Date: Mon, 4 Aug 2025 15:32:11 +0530	[thread overview]
Message-ID: <20250804100219.63325-8-varshini.rajendran@microchip.com> (raw)
In-Reply-To: <20250804100219.63325-1-varshini.rajendran@microchip.com>

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@microchip.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



  parent reply	other threads:[~2025-08-04 10:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04 10:02 [PATCH 00/15] Add thermal management support for sama7d65 Varshini Rajendran
2025-08-04 10:02 ` [PATCH 01/15] ARM: dts: microchip: sama7d65: add cpu opps Varshini Rajendran
2025-08-04 10:02 ` [PATCH 02/15] nvmem: microchip-otpc: rework to access packets based on tag Varshini Rajendran
2025-08-04 13:05   ` Andy Shevchenko
2025-08-04 17:49   ` kernel test robot
2025-08-05  6:50   ` Krzysztof Kozlowski
2025-08-04 10:02 ` [PATCH 03/15] dt-bindings: microchip-otpc: update dt node example Varshini Rajendran
2025-08-05  6:49   ` Krzysztof Kozlowski
2025-08-04 10:02 ` [PATCH 04/15] iio: adc: at91-sama5d2_adc: update calibration index, validation condition Varshini Rajendran
2025-08-04 13:11   ` Andy Shevchenko
2025-08-06 15:26   ` Jonathan Cameron
2025-08-04 10:02 ` [PATCH 05/15] ARM: dts: microchip: sama7g5: add packet tag as offset for calib Varshini Rajendran
2025-08-05  6:51   ` Krzysztof Kozlowski
2025-08-04 10:02 ` [PATCH 06/15] dt-bindings: nvmem: microchip-otpc: remove stride details Varshini Rajendran
2025-08-05  6:54   ` Krzysztof Kozlowski
2025-08-04 10:02 ` Varshini Rajendran [this message]
2025-08-04 13:13   ` [PATCH 07/15] iio: adc: at91-sama5d2_adc: add temp init function as callback Andy Shevchenko
2025-08-04 10:02 ` [PATCH 08/15] dt-bindings: iio: adc: at91-sama5d2: document sama7d65 Varshini Rajendran
2025-08-05  6:55   ` Krzysztof Kozlowski
2025-08-04 10:02 ` [PATCH 09/15] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 Varshini Rajendran
2025-08-04 13:19   ` Andy Shevchenko
2025-08-06 15:31   ` Jonathan Cameron
2025-08-04 10:02 ` [PATCH 10/15] ARM: dts: microchip: sama7d65: add node for the ADC Varshini Rajendran
2025-08-04 10:02 ` [PATCH 11/15] dt-bindings: microchip-otpc: document sama7d65 Varshini Rajendran
2025-08-05  6:53   ` Krzysztof Kozlowski
2025-08-04 10:02 ` [PATCH 12/15] ARM: dts: microchip: sama7d65: add otpc node Varshini Rajendran
2025-08-04 10:02 ` [PATCH 13/15] ARM: dts: microchip: sama7d65: add cells for temperature calibration Varshini Rajendran
2025-08-04 10:02 ` [PATCH 14/15] ARM: dts: microchip: sama7d65: add temperature sensor Varshini Rajendran
2025-08-04 10:02 ` [PATCH 15/15] ARM: dts: microchip: sama7d65: add thermal zones node Varshini Rajendran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250804100219.63325-8-varshini.rajendran@microchip.com \
    --to=varshini.rajendran@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=eugen.hristev@linaro.org \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=srini@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).