drivers: spi: Use the NXP Flexcomm driver for interrupt handling
The Low Power Flexcomm driver manages the interrupt handling and provides an API to register interrupt callbacks. Register the NXP LPSPI interrupt handler. Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This commit is contained in:
parent
e5ecc96b3c
commit
8b7cff7d33
2 changed files with 26 additions and 2 deletions
|
@ -9,6 +9,7 @@ config SPI_MCUX_LPSPI
|
|||
depends on DT_HAS_NXP_IMX_LPSPI_ENABLED
|
||||
depends on CLOCK_CONTROL
|
||||
select PINCTRL
|
||||
select MFD if DT_HAS_NXP_LP_FLEXCOMM_ENABLED
|
||||
help
|
||||
Enable support for mcux spi driver.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, NXP
|
||||
* Copyright 2018, 2024 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
@ -10,6 +10,9 @@
|
|||
#include <zephyr/drivers/spi.h>
|
||||
#include <zephyr/drivers/clock_control.h>
|
||||
#include <fsl_lpspi.h>
|
||||
#if CONFIG_NXP_LP_FLEXCOMM
|
||||
#include <zephyr/drivers/mfd/nxp_lp_flexcomm.h>
|
||||
#endif
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/irq.h>
|
||||
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
|
||||
|
@ -35,6 +38,9 @@ LOG_MODULE_REGISTER(spi_mcux_lpspi, CONFIG_SPI_LOG_LEVEL);
|
|||
|
||||
struct spi_mcux_config {
|
||||
DEVICE_MMIO_NAMED_ROM(reg_base);
|
||||
#ifdef CONFIG_NXP_LP_FLEXCOMM
|
||||
const struct device *parent_dev;
|
||||
#endif
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
|
@ -664,7 +670,16 @@ static int spi_mcux_init(const struct device *dev)
|
|||
|
||||
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
|
||||
|
||||
#if CONFIG_NXP_LP_FLEXCOMM
|
||||
/* When using LP Flexcomm driver, register the interrupt handler
|
||||
* so we receive notification from the LP Flexcomm interrupt handler.
|
||||
*/
|
||||
nxp_lp_flexcomm_setirqhandler(config->parent_dev, dev,
|
||||
LP_FLEXCOMM_PERIPH_LPSPI, spi_mcux_isr);
|
||||
#else
|
||||
/* Interrupt is managed by this driver */
|
||||
config->irq_config_func(dev);
|
||||
#endif
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
|
@ -913,6 +928,13 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
|
||||
(SPI_MCUX_LPSPI_MODULE_IRQ_CONNECT(n)))
|
||||
|
||||
#ifdef CONFIG_NXP_LP_FLEXCOMM
|
||||
#define PARENT_DEV(n) \
|
||||
.parent_dev = DEVICE_DT_GET(DT_INST_PARENT(n)),
|
||||
#else
|
||||
#define PARENT_DEV(n)
|
||||
#endif /* CONFIG_NXP_LP_FLEXCOMM */
|
||||
|
||||
#define SPI_MCUX_LPSPI_INIT(n) \
|
||||
PINCTRL_DT_INST_DEFINE(n); \
|
||||
COND_CODE_1(CONFIG_SPI_RTIO, (SPI_MCUX_RTIO_DEFINE(n)), ()); \
|
||||
|
@ -921,6 +943,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
\
|
||||
static const struct spi_mcux_config spi_mcux_config_##n = { \
|
||||
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
|
||||
PARENT_DEV(n) \
|
||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue