drivers: dac: add pinctrl support to dac_mcux_dac32 driver

add pinctrl support to dac_mcux_dac32 driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2022-03-08 14:43:29 -06:00 committed by Carles Cufí
parent f1b3f00114
commit 9e12d23f11
3 changed files with 10 additions and 2 deletions

View file

@ -13,6 +13,7 @@ config DAC_MCUX_DAC
config DAC_MCUX_DAC32
bool "NXP Kinetis MCUX DAC32 driver"
depends on HAS_MCUX_DAC32
select PINCTRL
help
Enable the driver for the NXP Kinetis MCUX DAC32.

View file

@ -9,6 +9,7 @@
#include <zephyr.h>
#include <drivers/dac.h>
#include <logging/log.h>
#include <drivers/pinctrl.h>
#include <fsl_dac32.h>
@ -19,6 +20,7 @@ struct mcux_dac32_config {
dac32_reference_voltage_source_t reference;
bool buffered;
bool low_power;
const struct pinctrl_dev_config *pincfg;
};
struct mcux_dac32_data {
@ -89,7 +91,9 @@ static int mcux_dac32_write_value(const struct device *dev, uint8_t channel,
static int mcux_dac32_init(const struct device *dev)
{
return 0;
const struct mcux_dac32_config *config = dev->config;
return pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
}
static const struct dac_driver_api mcux_dac32_driver_api = {
@ -103,12 +107,15 @@ static const struct dac_driver_api mcux_dac32_driver_api = {
#define MCUX_DAC32_INIT(n) \
static struct mcux_dac32_data mcux_dac32_data_##n; \
\
PINCTRL_DT_INST_DEFINE(n); \
\
static const struct mcux_dac32_config mcux_dac32_config_##n = { \
.base = (DAC_Type *)DT_INST_REG_ADDR(n), \
.reference = \
TO_DAC32_VREF_SRC(DT_INST_PROP(n, voltage_reference)), \
.buffered = DT_INST_PROP(n, buffered), \
.low_power = DT_INST_PROP(n, low_power_mode), \
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
}; \
\
DEVICE_DT_INST_DEFINE(n, mcux_dac32_init, NULL, \

View file

@ -5,7 +5,7 @@ description: NXP Kinetis MCUX DAC32
compatible: "nxp,kinetis-dac32"
include: dac-controller.yaml
include: [dac-controller.yaml, pinctrl-device.yaml]
properties:
reg: