drivers: adc: adc_mcux_adc12: enable pinctrl for adc12 driver
enable pinctrl for adc12 driver Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
93bbbb1e27
commit
a9587deaa4
3 changed files with 13 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
config ADC_MCUX_ADC12
|
config ADC_MCUX_ADC12
|
||||||
bool "MCUX ADC12 driver"
|
bool "MCUX ADC12 driver"
|
||||||
depends on HAS_MCUX_ADC12
|
depends on HAS_MCUX_ADC12
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
Enable the MCUX ADC12 driver.
|
Enable the MCUX ADC12 driver.
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <drivers/adc.h>
|
#include <drivers/adc.h>
|
||||||
#include <fsl_adc12.h>
|
#include <fsl_adc12.h>
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
|
|
||||||
#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL
|
#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
|
@ -26,6 +27,7 @@ struct mcux_adc12_config {
|
||||||
adc12_reference_voltage_source_t ref_src;
|
adc12_reference_voltage_source_t ref_src;
|
||||||
uint32_t sample_clk_count;
|
uint32_t sample_clk_count;
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
|
const struct pinctrl_dev_config *pincfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mcux_adc12_data {
|
struct mcux_adc12_data {
|
||||||
|
@ -216,6 +218,7 @@ static int mcux_adc12_init(const struct device *dev)
|
||||||
struct mcux_adc12_data *data = dev->data;
|
struct mcux_adc12_data *data = dev->data;
|
||||||
ADC_Type *base = config->base;
|
ADC_Type *base = config->base;
|
||||||
adc12_config_t adc_config;
|
adc12_config_t adc_config;
|
||||||
|
int err;
|
||||||
|
|
||||||
ADC12_GetDefaultConfig(&adc_config);
|
ADC12_GetDefaultConfig(&adc_config);
|
||||||
|
|
||||||
|
@ -233,6 +236,11 @@ static int mcux_adc12_init(const struct device *dev)
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
data->dev = dev;
|
data->dev = dev;
|
||||||
|
|
||||||
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
adc_context_unlock_unconditionally(&data->ctx);
|
adc_context_unlock_unconditionally(&data->ctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -261,6 +269,8 @@ static const struct adc_driver_api mcux_adc12_driver_api = {
|
||||||
#define ACD12_MCUX_INIT(n) \
|
#define ACD12_MCUX_INIT(n) \
|
||||||
static void mcux_adc12_config_func_##n(const struct device *dev); \
|
static void mcux_adc12_config_func_##n(const struct device *dev); \
|
||||||
\
|
\
|
||||||
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
|
\
|
||||||
ASSERT_WITHIN_RANGE(DT_INST_PROP(n, clk_source), 0, 3, \
|
ASSERT_WITHIN_RANGE(DT_INST_PROP(n, clk_source), 0, 3, \
|
||||||
"Invalid clock source"); \
|
"Invalid clock source"); \
|
||||||
ASSERT_ADC12_CLK_DIV_VALID(DT_INST_PROP(n, clk_divider), \
|
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 = {
|
||||||
.ref_src = ADC12_REF_SRC(n), \
|
.ref_src = ADC12_REF_SRC(n), \
|
||||||
.sample_clk_count = DT_INST_PROP(n, sample_time), \
|
.sample_clk_count = DT_INST_PROP(n, sample_time), \
|
||||||
.irq_config_func = mcux_adc12_config_func_##n, \
|
.irq_config_func = mcux_adc12_config_func_##n, \
|
||||||
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct mcux_adc12_data mcux_adc12_data_##n = { \
|
static struct mcux_adc12_data mcux_adc12_data_##n = { \
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: NXP Kinetis ADC12
|
||||||
|
|
||||||
compatible: "nxp,kinetis-adc12"
|
compatible: "nxp,kinetis-adc12"
|
||||||
|
|
||||||
include: adc-controller.yaml
|
include: [adc-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue