From 09c054b13c94a18ca0fa476a8a2c9a46e296f38c Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 11 Feb 2021 19:23:55 -0600 Subject: [PATCH] drivers: serial: NXP: Convert clock control to use DEVICE_DT_GET Replace device_get_binding with DEVICE_DT_GET for getting access to the clock controller device. Signed-off-by: Kumar Gala --- drivers/serial/uart_mcux.c | 12 +++--------- drivers/serial/uart_mcux_flexcomm.c | 12 +++--------- drivers/serial/uart_mcux_iuart.c | 12 +++--------- drivers/serial/uart_mcux_lpsci.c | 12 +++--------- drivers/serial/uart_mcux_lpuart.c | 12 +++--------- 5 files changed, 15 insertions(+), 45 deletions(-) diff --git a/drivers/serial/uart_mcux.c b/drivers/serial/uart_mcux.c index 5bfba4ad3c4..e8f0391582e 100644 --- a/drivers/serial/uart_mcux.c +++ b/drivers/serial/uart_mcux.c @@ -16,7 +16,7 @@ struct uart_mcux_config { UART_Type *base; - char *clock_name; + const struct device *clock_dev; clock_control_subsys_t clock_subsys; #ifdef CONFIG_UART_INTERRUPT_DRIVEN void (*irq_config_func)(const struct device *dev); @@ -37,16 +37,10 @@ static int uart_mcux_configure(const struct device *dev, const struct uart_mcux_config *config = dev->config; struct uart_mcux_data *data = dev->data; uart_config_t uart_config; - const struct device *clock_dev; uint32_t clock_freq; status_t retval; - clock_dev = device_get_binding(config->clock_name); - if (clock_dev == NULL) { - return -EINVAL; - } - - if (clock_control_get_rate(clock_dev, config->clock_subsys, + if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { return -EINVAL; } @@ -363,7 +357,7 @@ static const struct uart_driver_api uart_mcux_driver_api = { #define UART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \ static const struct uart_mcux_config uart_mcux_##n##_config = { \ .base = (UART_Type *)DT_INST_REG_ADDR(n), \ - .clock_name = DT_INST_CLOCKS_LABEL(n), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ IRQ_FUNC_INIT \ } diff --git a/drivers/serial/uart_mcux_flexcomm.c b/drivers/serial/uart_mcux_flexcomm.c index dd34f2d783d..240d7cbf4b7 100644 --- a/drivers/serial/uart_mcux_flexcomm.c +++ b/drivers/serial/uart_mcux_flexcomm.c @@ -24,7 +24,7 @@ struct mcux_flexcomm_config { USART_Type *base; - char *clock_name; + const struct device *clock_dev; clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -248,15 +248,9 @@ static int mcux_flexcomm_init(const struct device *dev) const struct mcux_flexcomm_config *config = dev->config; usart_config_t usart_config; uint32_t clock_freq; - const struct device *clock_dev; /* Get the clock frequency */ - clock_dev = device_get_binding(config->clock_name); - if (clock_dev == NULL) { - return -EINVAL; - } - - if (clock_control_get_rate(clock_dev, config->clock_subsys, + if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { return -EINVAL; } @@ -323,7 +317,7 @@ static const struct uart_driver_api mcux_flexcomm_driver_api = { #define UART_MCUX_FLEXCOMM_DECLARE_CFG(n, IRQ_FUNC_INIT) \ static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \ .base = (USART_Type *)DT_INST_REG_ADDR(n), \ - .clock_name = DT_INST_CLOCKS_LABEL(n), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = \ (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ diff --git a/drivers/serial/uart_mcux_iuart.c b/drivers/serial/uart_mcux_iuart.c index 7cb783f311d..c3823da3e48 100644 --- a/drivers/serial/uart_mcux_iuart.c +++ b/drivers/serial/uart_mcux_iuart.c @@ -15,7 +15,7 @@ struct mcux_iuart_config { UART_Type *base; - const char *clock_name; + const struct device *clock_dev; clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -225,15 +225,9 @@ static int mcux_iuart_init(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uart_config_t uart_config; - const struct device *clock_dev; uint32_t clock_freq; - clock_dev = device_get_binding(config->clock_name); - if (clock_dev == NULL) { - return -EINVAL; - } - - if (clock_control_get_rate(clock_dev, config->clock_subsys, + if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { return -EINVAL; } @@ -305,7 +299,7 @@ static const struct uart_driver_api mcux_iuart_driver_api = { #define IUART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \ static const struct mcux_iuart_config mcux_iuart_##n##_config = { \ .base = (UART_Type *) DT_INST_REG_ADDR(n), \ - .clock_name = DT_INST_CLOCKS_LABEL(n), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ IRQ_FUNC_INIT \ diff --git a/drivers/serial/uart_mcux_lpsci.c b/drivers/serial/uart_mcux_lpsci.c index 177321bbde7..7e4f9c06f78 100644 --- a/drivers/serial/uart_mcux_lpsci.c +++ b/drivers/serial/uart_mcux_lpsci.c @@ -15,7 +15,7 @@ struct mcux_lpsci_config { UART0_Type *base; - char *clock_name; + const struct device *clock_dev; clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -236,15 +236,9 @@ static int mcux_lpsci_init(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; lpsci_config_t uart_config; - const struct device *clock_dev; uint32_t clock_freq; - clock_dev = device_get_binding(config->clock_name); - if (clock_dev == NULL) { - return -EINVAL; - } - - if (clock_control_get_rate(clock_dev, config->clock_subsys, + if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { return -EINVAL; } @@ -309,7 +303,7 @@ static const struct uart_driver_api mcux_lpsci_driver_api = { #define MCUX_LPSCI_DECLARE_CFG(n, IRQ_FUNC_INIT) \ static const struct mcux_lpsci_config mcux_lpsci_##n##_config = { \ .base = (UART0_Type *)DT_INST_REG_ADDR(n), \ - .clock_name = DT_INST_CLOCKS_LABEL(n), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ IRQ_FUNC_INIT \ diff --git a/drivers/serial/uart_mcux_lpuart.c b/drivers/serial/uart_mcux_lpuart.c index fc033be4c3c..09d584fe0c6 100644 --- a/drivers/serial/uart_mcux_lpuart.c +++ b/drivers/serial/uart_mcux_lpuart.c @@ -16,7 +16,7 @@ struct mcux_lpuart_config { LPUART_Type *base; - char *clock_name; + const struct device *clock_dev; clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -239,15 +239,9 @@ static int mcux_lpuart_configure_init(const struct device *dev, { const struct mcux_lpuart_config *config = dev->config; struct mcux_lpuart_data *data = dev->data; - const struct device *clock_dev; uint32_t clock_freq; - clock_dev = device_get_binding(config->clock_name); - if (clock_dev == NULL) { - return -EINVAL; - } - - if (clock_control_get_rate(clock_dev, config->clock_subsys, + if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { return -EINVAL; } @@ -429,7 +423,7 @@ static const struct uart_driver_api mcux_lpuart_driver_api = { #define LPUART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \ static const struct mcux_lpuart_config mcux_lpuart_##n##_config = { \ .base = (LPUART_Type *) DT_INST_REG_ADDR(n), \ - .clock_name = DT_INST_CLOCKS_LABEL(n), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ IRQ_FUNC_INIT \