drivers: spi: enable pinctrl for spi_mcux_lpspi
Enable pinctrl for lpspi driver Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
d6d49dbe09
commit
6545a3d0fa
2 changed files with 28 additions and 3 deletions
|
@ -14,6 +14,9 @@
|
|||
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
|
||||
#include <drivers/dma.h>
|
||||
#endif
|
||||
#ifdef CONFIG_PINCTRL
|
||||
#include <drivers/pinctrl.h>
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
LOG_MODULE_REGISTER(spi_mcux_lpspi, CONFIG_SPI_LOG_LEVEL);
|
||||
|
||||
|
@ -30,6 +33,9 @@ struct spi_mcux_config {
|
|||
uint32_t pcs_sck_delay;
|
||||
uint32_t sck_pcs_delay;
|
||||
uint32_t transfer_delay;
|
||||
#ifdef CONFIG_PINCTRL
|
||||
const struct pinctrl_dev_config *pincfg;
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
|
||||
|
@ -543,6 +549,13 @@ static int spi_mcux_init(const struct device *dev)
|
|||
}
|
||||
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
|
||||
|
||||
#ifdef CONFIG_PINCTRL
|
||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -586,9 +599,20 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
}
|
||||
#else
|
||||
#define SPI_DMA_CHANNELS(n)
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
|
||||
|
||||
#ifdef CONFIG_PINCTRL
|
||||
#define SPI_MCUX_LPSPI_PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
||||
#define SPI_MCUX_LPSPI_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
||||
#else
|
||||
#define SPI_MCUX_LPSPI_PINCTRL_DEFINE(n)
|
||||
#define SPI_MCUX_LPSPI_PINCTRL_INIT(n)
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
|
||||
#define SPI_MCUX_LPSPI_INIT(n) \
|
||||
SPI_MCUX_LPSPI_PINCTRL_DEFINE(n) \
|
||||
\
|
||||
static void spi_mcux_config_func_##n(const struct device *dev); \
|
||||
\
|
||||
static const struct spi_mcux_config spi_mcux_config_##n = { \
|
||||
|
@ -606,13 +630,14 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
.transfer_delay = UTIL_AND( \
|
||||
DT_INST_NODE_HAS_PROP(n, transfer_delay), \
|
||||
DT_INST_PROP(n, transfer_delay)), \
|
||||
SPI_MCUX_LPSPI_PINCTRL_INIT(n) \
|
||||
}; \
|
||||
\
|
||||
static struct spi_mcux_data spi_mcux_data_##n = { \
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##n, ctx), \
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_##n, ctx), \
|
||||
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \
|
||||
SPI_DMA_CHANNELS(n) \
|
||||
SPI_DMA_CHANNELS(n) \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(n, &spi_mcux_init, NULL, \
|
||||
|
|
|
@ -5,7 +5,7 @@ description: NXP i.MX LPSPI controller
|
|||
|
||||
compatible: "nxp,imx-lpspi"
|
||||
|
||||
include: spi-controller.yaml
|
||||
include: ["spi-controller.yaml", "pinctrl-device.yaml"]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue