drivers: serial: uart_sifive: convert to new DT API

Use the new devicetree.h API instead of the legacy macros.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-03-10 17:24:43 -05:00 committed by Kumar Gala
commit 8f84520130

View file

@ -8,6 +8,8 @@
* @brief UART driver for the SiFive Freedom Processor
*/
#define DT_DRV_COMPAT sifive_uart0
#include <kernel.h>
#include <arch/cpu.h>
#include <drivers/uart.h>
@ -381,9 +383,9 @@ static void uart_sifive_irq_cfg_func_0(void);
#endif
static const struct uart_sifive_device_config uart_sifive_dev_cfg_0 = {
.port = DT_INST_0_SIFIVE_UART0_BASE_ADDRESS,
.sys_clk_freq = DT_INST_0_SIFIVE_UART0_CLOCK_FREQUENCY,
.baud_rate = DT_INST_0_SIFIVE_UART0_CURRENT_SPEED,
.port = DT_INST_REG_ADDR(0),
.sys_clk_freq = DT_INST_PROP(0, clock_frequency),
.baud_rate = DT_INST_PROP(0, current_speed),
.rxcnt_irq = CONFIG_UART_SIFIVE_PORT_0_RXCNT_IRQ,
.txcnt_irq = CONFIG_UART_SIFIVE_PORT_0_TXCNT_IRQ,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@ -391,7 +393,7 @@ static const struct uart_sifive_device_config uart_sifive_dev_cfg_0 = {
#endif
};
DEVICE_AND_API_INIT(uart_sifive_0, DT_INST_0_SIFIVE_UART0_LABEL,
DEVICE_AND_API_INIT(uart_sifive_0, DT_INST_PROP(0, label),
uart_sifive_init,
&uart_sifive_data_0, &uart_sifive_dev_cfg_0,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
@ -400,12 +402,12 @@ DEVICE_AND_API_INIT(uart_sifive_0, DT_INST_0_SIFIVE_UART0_LABEL,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void uart_sifive_irq_cfg_func_0(void)
{
IRQ_CONNECT(DT_INST_0_SIFIVE_UART0_IRQ_0,
IRQ_CONNECT(DT_INST_IRQN(0),
CONFIG_UART_SIFIVE_PORT_0_IRQ_PRIORITY,
uart_sifive_irq_handler, DEVICE_GET(uart_sifive_0),
0);
irq_enable(DT_INST_0_SIFIVE_UART0_IRQ_0);
irq_enable(DT_INST_IRQN(0));
}
#endif
@ -420,9 +422,9 @@ static void uart_sifive_irq_cfg_func_1(void);
#endif
static const struct uart_sifive_device_config uart_sifive_dev_cfg_1 = {
.port = DT_INST_1_SIFIVE_UART0_BASE_ADDRESS,
.sys_clk_freq = DT_INST_1_SIFIVE_UART0_CLOCK_FREQUENCY,
.baud_rate = DT_INST_1_SIFIVE_UART0_CURRENT_SPEED,
.port = DT_INST_REG_ADDR(1),
.sys_clk_freq = DT_INST_PROP(1, clock_frequency),
.baud_rate = DT_INST_PROP(1, current_speed),
.rxcnt_irq = CONFIG_UART_SIFIVE_PORT_1_RXCNT_IRQ,
.txcnt_irq = CONFIG_UART_SIFIVE_PORT_1_TXCNT_IRQ,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@ -430,7 +432,7 @@ static const struct uart_sifive_device_config uart_sifive_dev_cfg_1 = {
#endif
};
DEVICE_AND_API_INIT(uart_sifive_1, DT_INST_1_SIFIVE_UART0_LABEL,
DEVICE_AND_API_INIT(uart_sifive_1, DT_INST_PROP(1, label),
uart_sifive_init,
&uart_sifive_data_1, &uart_sifive_dev_cfg_1,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
@ -439,12 +441,12 @@ DEVICE_AND_API_INIT(uart_sifive_1, DT_INST_1_SIFIVE_UART0_LABEL,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void uart_sifive_irq_cfg_func_1(void)
{
IRQ_CONNECT(DT_INST_1_SIFIVE_UART0_IRQ_0,
IRQ_CONNECT(DT_INST_IRQN(1),
CONFIG_UART_SIFIVE_PORT_1_IRQ_PRIORITY,
uart_sifive_irq_handler, DEVICE_GET(uart_sifive_1),
0);
irq_enable(DT_INST_1_SIFIVE_UART0_IRQ_0);
irq_enable(DT_INST_IRQN(1));
}
#endif