drivers: lpc_lpadc: enable pinctrl for lpadc driver
enable pinctrl for mcux lpc lpadc driver Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
6c0bcdc6e9
commit
053eaf7545
2 changed files with 26 additions and 1 deletions
|
@ -14,6 +14,10 @@
|
|||
#include <drivers/adc.h>
|
||||
#include <fsl_lpadc.h>
|
||||
|
||||
#if CONFIG_PINCTRL
|
||||
#include <drivers/pinctrl.h>
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_SOC_SERIES_IMX_RT11XX)
|
||||
#include <fsl_power.h>
|
||||
#endif
|
||||
|
@ -41,6 +45,9 @@ struct mcux_lpadc_config {
|
|||
uint32_t offset_a;
|
||||
uint32_t offset_b;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
#if CONFIG_PINCTRL
|
||||
const struct pinctrl_dev_config *pincfg;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct mcux_lpadc_data {
|
||||
|
@ -271,6 +278,14 @@ static int mcux_lpadc_init(const struct device *dev)
|
|||
struct mcux_lpadc_data *data = dev->data;
|
||||
ADC_Type *base = config->base;
|
||||
lpadc_config_t adc_config;
|
||||
#ifdef CONFIG_PINCTRL
|
||||
int err;
|
||||
|
||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_SOC_SERIES_IMX_RT11XX)
|
||||
#if defined(CONFIG_SOC_SERIES_IMX_RT6XX)
|
||||
|
@ -390,6 +405,14 @@ static const struct adc_driver_api mcux_lpadc_driver_api = {
|
|||
#define TO_LPADC_POWER_LEVEL(val) \
|
||||
_DO_CONCAT(kLPADC_PowerLevelAlt, val)
|
||||
|
||||
#if CONFIG_PINCTRL
|
||||
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
||||
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
||||
#else
|
||||
#define PINCTRL_DEFINE(n)
|
||||
#define PINCTRL_INIT(n)
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
#define LPADC_MCUX_INIT(n) \
|
||||
static void mcux_lpadc_config_func_##n(const struct device *dev); \
|
||||
\
|
||||
|
@ -404,6 +427,7 @@ static const struct adc_driver_api mcux_lpadc_driver_api = {
|
|||
"Invalid conversion average number for auto-calibration time"); \
|
||||
ASSERT_WITHIN_RANGE(DT_INST_PROP(n, power_level), 1, 4, \
|
||||
"Invalid power level"); \
|
||||
PINCTRL_DEFINE(n) \
|
||||
static const struct mcux_lpadc_config mcux_lpadc_config_##n = { \
|
||||
.base = (ADC_Type *)DT_INST_REG_ADDR(n), \
|
||||
.clock_source = TO_LPADC_CLOCK_SOURCE(DT_INST_PROP(n, clk_source)), \
|
||||
|
@ -416,6 +440,7 @@ static const struct adc_driver_api mcux_lpadc_driver_api = {
|
|||
.offset_a = DT_INST_PROP(n, offset_value_a), \
|
||||
.offset_a = DT_INST_PROP(n, offset_value_b), \
|
||||
.irq_config_func = mcux_lpadc_config_func_##n, \
|
||||
PINCTRL_INIT(n) \
|
||||
}; \
|
||||
\
|
||||
static struct mcux_lpadc_data mcux_lpadc_data_##n = { \
|
||||
|
|
|
@ -5,7 +5,7 @@ description: LPC LPADC
|
|||
|
||||
compatible: "nxp,lpc-lpadc"
|
||||
|
||||
include: adc-controller.yaml
|
||||
include: [adc-controller.yaml, pinctrl-device.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue