drivers: spi: mcux_lpspi: Convert to DT_INST
Convert driver to use new DT_INST macros throughout. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
df302727dc
commit
fac0d7d90e
1 changed files with 32 additions and 114 deletions
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT nxp_imx_lpspi
|
||||
|
||||
#include <errno.h>
|
||||
#include <drivers/spi.h>
|
||||
#include <drivers/clock_control.h>
|
||||
|
@ -273,118 +275,34 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
.release = spi_mcux_release,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPI_0
|
||||
static void spi_mcux_config_func_0(struct device *dev);
|
||||
#define SPI_MCUX_LPSPI_INIT(n) \
|
||||
static void spi_mcux_config_func_##n(struct device *dev); \
|
||||
\
|
||||
static const struct spi_mcux_config spi_mcux_config_##n = { \
|
||||
.base = (LPSPI_Type *) DT_INST_REG_ADDR(n), \
|
||||
.clock_name = DT_INST_CLOCKS_LABEL(n), \
|
||||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
|
||||
.irq_config_func = spi_mcux_config_func_##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), \
|
||||
}; \
|
||||
\
|
||||
DEVICE_AND_API_INIT(spi_mcux_##n, DT_INST_LABEL(n), \
|
||||
&spi_mcux_init, &spi_mcux_data_##n, \
|
||||
&spi_mcux_config_##n, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
&spi_mcux_driver_api); \
|
||||
\
|
||||
static void spi_mcux_config_func_##n(struct device *dev) \
|
||||
{ \
|
||||
IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \
|
||||
spi_mcux_isr, DEVICE_GET(spi_mcux_##n), 0); \
|
||||
\
|
||||
irq_enable(DT_INST_IRQN(n)); \
|
||||
}
|
||||
|
||||
static const struct spi_mcux_config spi_mcux_config_0 = {
|
||||
.base = (LPSPI_Type *) DT_NXP_IMX_LPSPI_SPI_0_BASE_ADDRESS,
|
||||
.clock_name = DT_NXP_IMX_LPSPI_SPI_0_CLOCK_CONTROLLER,
|
||||
.clock_subsys = (clock_control_subsys_t) DT_NXP_IMX_LPSPI_SPI_0_CLOCK_NAME,
|
||||
.irq_config_func = spi_mcux_config_func_0,
|
||||
};
|
||||
|
||||
static struct spi_mcux_data spi_mcux_data_0 = {
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_0, ctx),
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_0, ctx),
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(spi_mcux_0, DT_NXP_IMX_LPSPI_SPI_0_LABEL, &spi_mcux_init,
|
||||
&spi_mcux_data_0, &spi_mcux_config_0,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&spi_mcux_driver_api);
|
||||
|
||||
static void spi_mcux_config_func_0(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_NXP_IMX_LPSPI_SPI_0_IRQ_0, DT_NXP_IMX_LPSPI_SPI_0_IRQ_0_PRIORITY,
|
||||
spi_mcux_isr, DEVICE_GET(spi_mcux_0), 0);
|
||||
|
||||
irq_enable(DT_NXP_IMX_LPSPI_SPI_0_IRQ_0);
|
||||
}
|
||||
#endif /* SPI_0 */
|
||||
|
||||
#ifdef CONFIG_SPI_1
|
||||
static void spi_mcux_config_func_1(struct device *dev);
|
||||
|
||||
static const struct spi_mcux_config spi_mcux_config_1 = {
|
||||
.base = (LPSPI_Type *) DT_NXP_IMX_LPSPI_SPI_1_BASE_ADDRESS,
|
||||
.clock_name = DT_NXP_IMX_LPSPI_SPI_1_CLOCK_CONTROLLER,
|
||||
.clock_subsys = (clock_control_subsys_t) DT_NXP_IMX_LPSPI_SPI_1_CLOCK_NAME,
|
||||
.irq_config_func = spi_mcux_config_func_1,
|
||||
};
|
||||
|
||||
static struct spi_mcux_data spi_mcux_data_1 = {
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_1, ctx),
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_1, ctx),
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(spi_mcux_1, DT_NXP_IMX_LPSPI_SPI_1_LABEL, &spi_mcux_init,
|
||||
&spi_mcux_data_1, &spi_mcux_config_1,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&spi_mcux_driver_api);
|
||||
|
||||
static void spi_mcux_config_func_1(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_NXP_IMX_LPSPI_SPI_1_IRQ_0, DT_NXP_IMX_LPSPI_SPI_1_IRQ_0_PRIORITY,
|
||||
spi_mcux_isr, DEVICE_GET(spi_mcux_1), 0);
|
||||
|
||||
irq_enable(DT_NXP_IMX_LPSPI_SPI_1_IRQ_0);
|
||||
}
|
||||
#endif /* SPI_1 */
|
||||
|
||||
#ifdef CONFIG_SPI_2
|
||||
static void spi_mcux_config_func_2(struct device *dev);
|
||||
|
||||
static const struct spi_mcux_config spi_mcux_config_2 = {
|
||||
.base = (LPSPI_Type *) DT_NXP_IMX_LPSPI_SPI_2_BASE_ADDRESS,
|
||||
.clock_name = DT_NXP_IMX_LPSPI_SPI_2_CLOCK_CONTROLLER,
|
||||
.clock_subsys = (clock_control_subsys_t) DT_NXP_IMX_LPSPI_SPI_2_CLOCK_NAME,
|
||||
.irq_config_func = spi_mcux_config_func_2,
|
||||
};
|
||||
|
||||
static struct spi_mcux_data spi_mcux_data_2 = {
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_2, ctx),
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_2, ctx),
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(spi_mcux_2, DT_NXP_IMX_LPSPI_SPI_2_LABEL, &spi_mcux_init,
|
||||
&spi_mcux_data_2, &spi_mcux_config_2,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&spi_mcux_driver_api);
|
||||
|
||||
static void spi_mcux_config_func_2(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_NXP_IMX_LPSPI_SPI_2_IRQ_0, DT_NXP_IMX_LPSPI_SPI_2_IRQ_0_PRIORITY,
|
||||
spi_mcux_isr, DEVICE_GET(spi_mcux_2), 0);
|
||||
|
||||
irq_enable(DT_NXP_IMX_LPSPI_SPI_2_IRQ_0);
|
||||
}
|
||||
#endif /* SPI_2 */
|
||||
|
||||
#ifdef CONFIG_SPI_3
|
||||
static void spi_mcux_config_func_3(struct device *dev);
|
||||
|
||||
static const struct spi_mcux_config spi_mcux_config_3 = {
|
||||
.base = (LPSPI_Type *) DT_NXP_IMX_LPSPI_SPI_3_BASE_ADDRESS,
|
||||
.clock_name = DT_NXP_IMX_LPSPI_SPI_3_CLOCK_CONTROLLER,
|
||||
.clock_subsys = (clock_control_subsys_t) DT_NXP_IMX_LPSPI_SPI_3_CLOCK_NAME,
|
||||
.irq_config_func = spi_mcux_config_func_3,
|
||||
};
|
||||
|
||||
static struct spi_mcux_data spi_mcux_data_3 = {
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_3, ctx),
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_3, ctx),
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(spi_mcux_3, DT_NXP_IMX_LPSPI_SPI_3_LABEL, &spi_mcux_init,
|
||||
&spi_mcux_data_3, &spi_mcux_config_3,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&spi_mcux_driver_api);
|
||||
|
||||
static void spi_mcux_config_func_3(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_NXP_IMX_LPSPI_SPI_3_IRQ_0, DT_NXP_IMX_LPSPI_SPI_3_IRQ_0_PRIORITY,
|
||||
spi_mcux_isr, DEVICE_GET(spi_mcux_3), 0);
|
||||
|
||||
irq_enable(DT_NXP_IMX_LPSPI_SPI_3_IRQ_0);
|
||||
}
|
||||
#endif /* CONFIG_SPI_3 */
|
||||
DT_INST_FOREACH(SPI_MCUX_LPSPI_INIT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue