drivers: serial: uart_imx: Convert driver to new DT_INST macros

Convert driver to use DT_INST macros and remove related board per
instance Kconfig symbol usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-01 14:50:40 -05:00 committed by Kumar Gala
commit 7056c2304c
9 changed files with 42 additions and 427 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT nxp_imx_uart
/**
* @brief Driver for UART on NXP IMX family processor.
@ -281,249 +282,48 @@ static const struct uart_driver_api uart_imx_driver_api = {
};
#ifdef CONFIG_UART_IMX_UART_1
#define UART_IMX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
static const struct imx_uart_config imx_uart_##n##_config = { \
.base = (UART_Type *) DT_INST_REG_ADDR(n), \
.baud_rate = DT_INST_PROP(n, current_speed), \
.modem_mode = DT_INST_PROP(n, modem_mode), \
IRQ_FUNC_INIT \
}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_1(struct device *port);
#define UART_IMX_CONFIG_FUNC(n) \
static void irq_config_func_##n(struct device *dev) \
{ \
IRQ_CONNECT(DT_INST_IRQN(n), \
DT_INST_IRQ(n, priority), \
uart_imx_isr, \
DEVICE_GET(uart_##n), 0); \
irq_enable(DT_INST_IRQN(n)); \
}
#define UART_IMX_IRQ_CFG_FUNC_INIT(n) \
.irq_config_func = irq_config_func_##n
#define UART_IMX_INIT_CFG(n) \
UART_IMX_DECLARE_CFG(n, UART_IMX_IRQ_CFG_FUNC_INIT(n))
#else
#define UART_IMX_CONFIG_FUNC(n)
#define UART_IMX_IRQ_CFG_FUNC_INIT
#define UART_IMX_INIT_CFG(n) \
UART_IMX_DECLARE_CFG(n, UART_IMX_IRQ_CFG_FUNC_INIT)
#endif
static const struct imx_uart_config imx_uart_1_config = {
.base = (UART_Type *) DT_UART_IMX_UART_1_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_1_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_1_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_1,
#endif
};
#define UART_IMX_INIT(n) \
static struct imx_uart_data imx_uart_##n##_data; \
\
static const struct imx_uart_config imx_uart_##n##_config; \
\
DEVICE_AND_API_INIT(uart_##n, DT_INST_LABEL(n), &uart_imx_init, \
&imx_uart_##n##_data, &imx_uart_##n##_config, \
PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
&uart_imx_driver_api); \
\
UART_IMX_CONFIG_FUNC(n) \
\
UART_IMX_INIT_CFG(n)
static struct imx_uart_data imx_uart_1_data;
DEVICE_AND_API_INIT(uart_1, DT_UART_IMX_UART_1_NAME, &uart_imx_init,
&imx_uart_1_data, &imx_uart_1_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_1(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_1_IRQ_NUM,
DT_UART_IMX_UART_1_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_1),
0);
irq_enable(DT_UART_IMX_UART_1_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_1 */
#ifdef CONFIG_UART_IMX_UART_2
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_2(struct device *port);
#endif
static const struct imx_uart_config imx_uart_2_config = {
.base = (UART_Type *) DT_UART_IMX_UART_2_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_2_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_2_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_2,
#endif
};
static struct imx_uart_data imx_uart_2_data;
DEVICE_AND_API_INIT(uart_2, DT_UART_IMX_UART_2_NAME, &uart_imx_init,
&imx_uart_2_data, &imx_uart_2_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_2(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_2_IRQ_NUM,
DT_UART_IMX_UART_2_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_2),
0);
irq_enable(DT_UART_IMX_UART_2_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_2 */
#ifdef CONFIG_UART_IMX_UART_3
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_3(struct device *port);
#endif
static const struct imx_uart_config imx_uart_3_config = {
.base = (UART_Type *) DT_UART_IMX_UART_3_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_3_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_3_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_3,
#endif
};
static struct imx_uart_data imx_uart_3_data;
DEVICE_AND_API_INIT(uart_3, DT_UART_IMX_UART_3_NAME, &uart_imx_init,
&imx_uart_3_data, &imx_uart_3_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_3(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_3_IRQ_NUM,
DT_UART_IMX_UART_3_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_3),
0);
irq_enable(DT_UART_IMX_UART_3_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_3 */
#ifdef CONFIG_UART_IMX_UART_4
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_4(struct device *port);
#endif
static const struct imx_uart_config imx_uart_4_config = {
.base = (UART_Type *) DT_UART_IMX_UART_4_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_4_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_4_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_4,
#endif
};
static struct imx_uart_data imx_uart_4_data;
DEVICE_AND_API_INIT(uart_4, DT_UART_IMX_UART_4_NAME, &uart_imx_init,
&imx_uart_4_data, &imx_uart_4_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_4(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_4_IRQ_NUM,
DT_UART_IMX_UART_4_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_4),
0);
irq_enable(DT_UART_IMX_UART_4_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_4 */
#ifdef CONFIG_UART_IMX_UART_5
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_5(struct device *port);
#endif
static const struct imx_uart_config imx_uart_5_config = {
.base = (UART_Type *) DT_UART_IMX_UART_5_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_5_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_5_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_5,
#endif
};
static struct imx_uart_data imx_uart_5_data;
DEVICE_AND_API_INIT(uart_5, DT_UART_IMX_UART_5_NAME, &uart_imx_init,
&imx_uart_5_data, &imx_uart_5_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_5(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_5_IRQ_NUM,
DT_UART_IMX_UART_5_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_5),
0);
irq_enable(DT_UART_IMX_UART_5_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_5 */
#ifdef CONFIG_UART_IMX_UART_6
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_6(struct device *port);
#endif
static const struct imx_uart_config imx_uart_6_config = {
.base = (UART_Type *) DT_UART_IMX_UART_6_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_6_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_6_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_6,
#endif
};
static struct imx_uart_data imx_uart_6_data;
DEVICE_AND_API_INIT(uart_6, DT_UART_IMX_UART_6_NAME, &uart_imx_init,
&imx_uart_6_data, &imx_uart_6_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_6(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_6_IRQ_NUM,
DT_UART_IMX_UART_6_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_6),
0);
irq_enable(DT_UART_IMX_UART_6_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_6 */
#ifdef CONFIG_UART_IMX_UART_7
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_7(struct device *port);
#endif
static const struct imx_uart_config imx_uart_7_config = {
.base = (UART_Type *) DT_UART_IMX_UART_7_BASE_ADDRESS,
.baud_rate = DT_UART_IMX_UART_7_BAUD_RATE,
.modem_mode = DT_UART_IMX_UART_7_MODEM_MODE,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = irq_config_func_7,
#endif
};
static struct imx_uart_data imx_uart_7_data;
DEVICE_AND_API_INIT(uart_7, DT_UART_IMX_UART_7_NAME, &uart_imx_init,
&imx_uart_7_data, &imx_uart_7_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&uart_imx_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void irq_config_func_7(struct device *dev)
{
IRQ_CONNECT(DT_UART_IMX_UART_7_IRQ_NUM,
DT_UART_IMX_UART_7_IRQ_PRI,
uart_imx_isr, DEVICE_GET(uart_7),
0);
irq_enable(DT_UART_IMX_UART_7_IRQ_NUM);
}
#endif
#endif /* CONFIG_UART_IMX_UART_7 */
DT_INST_FOREACH(UART_IMX_INIT)