88#include <zephyr/device.h>
99#include <zephyr/kernel.h>
1010#include <zephyr/drivers/adc.h>
11+ #include <zephyr/drivers/pinctrl.h>
1112
1213#define ADC_CONTEXT_USES_KERNEL_TIMER
1314#include "adc_context.h"
@@ -97,6 +98,7 @@ enum ti_adc_irq {
9798
9899struct ti_adc_cfg {
99100 DEVICE_MMIO_ROM ;
101+ const struct pinctrl_dev_config * pinctrl ;
100102 void (* irq_func )(const struct device * dev );
101103 uint32_t open_delay [TI_ADC_TOTAL_CHANNELS ];
102104 uint8_t oversampling [TI_ADC_TOTAL_CHANNELS ];
@@ -293,10 +295,19 @@ static int ti_adc_init(const struct device *dev)
293295{
294296 const struct ti_adc_cfg * cfg = DEV_CFG (dev );
295297 struct ti_adc_data * data = DEV_DATA (dev );
296- struct ti_adc_regs * regs = DEV_REGS (dev );
298+ struct ti_adc_regs * regs ;
299+ int ret ;
297300
298301 DEVICE_MMIO_MAP (dev , K_MEM_CACHE_NONE );
299302
303+ regs = DEV_REGS (dev );
304+
305+ ret = pinctrl_apply_state (cfg -> pinctrl , PINCTRL_STATE_DEFAULT );
306+ if (ret < 0 ) {
307+ LOG_ERR ("failed to apply pinctrl" );
308+ return ret ;
309+ }
310+
300311 cfg -> irq_func (dev );
301312
302313 if (cfg -> fifo == 0 ) {
@@ -384,6 +395,7 @@ static DEVICE_API(adc, ti_adc_driver_api) = {
384395};
385396
386397#define TI_ADC_INIT (n ) \
398+ PINCTRL_DT_INST_DEFINE(n); \
387399 static void ti_adc_irq_setup_##n(const struct device *dev) \
388400 { \
389401 IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), ti_adc_isr, \
@@ -393,6 +405,7 @@ static DEVICE_API(adc, ti_adc_driver_api) = {
393405 \
394406 static const struct ti_adc_cfg ti_adc_cfg_##n = { \
395407 DEVICE_MMIO_ROM_INIT(DT_DRV_INST(n)), \
408+ .pinctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
396409 .irq_func = &ti_adc_irq_setup_##n, \
397410 .open_delay = CHAN_PROP_LIST(n, ti_open_delay), \
398411 .oversampling = CHAN_PROP_LIST(n, zephyr_oversampling), \
0 commit comments