Skip to content

Commit 2b94d6f

Browse files
smalaeasmellby
authored andcommitted
drivers: adc: siwx91x: Add ref_internal to device API
The Siwx91x ADC reference voltage is configurable rather than fixed. Expose `ref_internal` in the device API so the driver can retrieve the reference voltage from the device tree instead of assuming a constant value. Signed-off-by: Sai Santhosh Malae <[email protected]> (cherry picked from commit f4c152a) Upstream-status: available
1 parent 382e25f commit 2b94d6f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/adc/adc_silabs_siwx91x.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,16 @@ static void adc_siwx91x_isr(const struct device *dev)
378378
}
379379
}
380380

381-
static DEVICE_API(adc, adc_siwx91x_driver_api) = {
382-
.channel_setup = adc_siwx91x_channel_setup,
383-
.read = adc_siwx91x_read,
384-
};
381+
#define ADC_SIWX91X_DRIVER_API(inst) \
382+
static DEVICE_API(adc, adc_siwx91x_driver_api_##inst) = { \
383+
.channel_setup = adc_siwx91x_channel_setup, \
384+
.read = adc_siwx91x_read, \
385+
.ref_internal = DT_INST_PROP(inst, silabs_adc_ref_voltage), \
386+
};
385387

386388
#define SIWX91X_ADC_INIT(inst) \
387389
PINCTRL_DT_INST_DEFINE(inst); \
390+
ADC_SIWX91X_DRIVER_API(inst); \
388391
\
389392
static struct adc_siwx91x_chan_data adc_chan_data_##inst[DT_CHILD_NUM(DT_DRV_INST(inst))]; \
390393
\
@@ -414,6 +417,7 @@ static DEVICE_API(adc, adc_siwx91x_driver_api) = {
414417
}; \
415418
\
416419
DEVICE_DT_INST_DEFINE(inst, adc_siwx91x_init, NULL, &adc_data_##inst, &adc_cfg_##inst, \
417-
PRE_KERNEL_1, CONFIG_ADC_INIT_PRIORITY, &adc_siwx91x_driver_api);
420+
PRE_KERNEL_1, CONFIG_ADC_INIT_PRIORITY, \
421+
&adc_siwx91x_driver_api_##inst);
418422

419423
DT_INST_FOREACH_STATUS_OKAY(SIWX91X_ADC_INIT)

0 commit comments

Comments
 (0)