1111
1212#include <drivers/adc.h>
1313#include <fsl_adc12.h>
14+ #include <drivers/pinctrl.h>
1415
1516#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL
1617#include <logging/log.h>
@@ -26,6 +27,7 @@ struct mcux_adc12_config {
2627 adc12_reference_voltage_source_t ref_src ;
2728 uint32_t sample_clk_count ;
2829 void (* irq_config_func )(const struct device * dev );
30+ const struct pinctrl_dev_config * pincfg ;
2931};
3032
3133struct mcux_adc12_data {
@@ -216,6 +218,7 @@ static int mcux_adc12_init(const struct device *dev)
216218 struct mcux_adc12_data * data = dev -> data ;
217219 ADC_Type * base = config -> base ;
218220 adc12_config_t adc_config ;
221+ int err ;
219222
220223 ADC12_GetDefaultConfig (& adc_config );
221224
@@ -233,6 +236,11 @@ static int mcux_adc12_init(const struct device *dev)
233236 config -> irq_config_func (dev );
234237 data -> dev = dev ;
235238
239+ err = pinctrl_apply_state (config -> pincfg , PINCTRL_STATE_DEFAULT );
240+ if (err ) {
241+ return err ;
242+ }
243+
236244 adc_context_unlock_unconditionally (& data -> ctx );
237245
238246 return 0 ;
@@ -261,6 +269,8 @@ static const struct adc_driver_api mcux_adc12_driver_api = {
261269#define ACD12_MCUX_INIT (n ) \
262270 static void mcux_adc12_config_func_##n(const struct device *dev); \
263271 \
272+ PINCTRL_DT_INST_DEFINE(n); \
273+ \
264274 ASSERT_WITHIN_RANGE(DT_INST_PROP(n, clk_source), 0, 3, \
265275 "Invalid clock source"); \
266276 ASSERT_ADC12_CLK_DIV_VALID(DT_INST_PROP(n, clk_divider), \
@@ -275,6 +285,7 @@ static const struct adc_driver_api mcux_adc12_driver_api = {
275285 .ref_src = ADC12_REF_SRC(n), \
276286 .sample_clk_count = DT_INST_PROP(n, sample_time), \
277287 .irq_config_func = mcux_adc12_config_func_##n, \
288+ .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
278289 }; \
279290 \
280291 static struct mcux_adc12_data mcux_adc12_data_##n = { \
0 commit comments