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 <kumar.gala@linaro.org>
This commit is contained in:
parent
7b26544547
commit
09c054b13c
5 changed files with 15 additions and 45 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
struct uart_mcux_config {
|
struct uart_mcux_config {
|
||||||
UART_Type *base;
|
UART_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
void (*irq_config_func)(const struct device *dev);
|
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;
|
const struct uart_mcux_config *config = dev->config;
|
||||||
struct uart_mcux_data *data = dev->data;
|
struct uart_mcux_data *data = dev->data;
|
||||||
uart_config_t uart_config;
|
uart_config_t uart_config;
|
||||||
const struct device *clock_dev;
|
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
status_t retval;
|
status_t retval;
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&clock_freq)) {
|
&clock_freq)) {
|
||||||
return -EINVAL;
|
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) \
|
#define UART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct uart_mcux_config uart_mcux_##n##_config = { \
|
static const struct uart_mcux_config uart_mcux_##n##_config = { \
|
||||||
.base = (UART_Type *)DT_INST_REG_ADDR(n), \
|
.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),\
|
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
struct mcux_flexcomm_config {
|
struct mcux_flexcomm_config {
|
||||||
USART_Type *base;
|
USART_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#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;
|
const struct mcux_flexcomm_config *config = dev->config;
|
||||||
usart_config_t usart_config;
|
usart_config_t usart_config;
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
const struct device *clock_dev;
|
|
||||||
|
|
||||||
/* Get the clock frequency */
|
/* Get the clock frequency */
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&clock_freq)) {
|
&clock_freq)) {
|
||||||
return -EINVAL;
|
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) \
|
#define UART_MCUX_FLEXCOMM_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \
|
static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \
|
||||||
.base = (USART_Type *)DT_INST_REG_ADDR(n), \
|
.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_subsys = \
|
||||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
struct mcux_iuart_config {
|
struct mcux_iuart_config {
|
||||||
UART_Type *base;
|
UART_Type *base;
|
||||||
const char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#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);
|
const struct mcux_iuart_config *config = DEV_CFG(dev);
|
||||||
uart_config_t uart_config;
|
uart_config_t uart_config;
|
||||||
const struct device *clock_dev;
|
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&clock_freq)) {
|
&clock_freq)) {
|
||||||
return -EINVAL;
|
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) \
|
#define IUART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct mcux_iuart_config mcux_iuart_##n##_config = { \
|
static const struct mcux_iuart_config mcux_iuart_##n##_config = { \
|
||||||
.base = (UART_Type *) DT_INST_REG_ADDR(n), \
|
.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),\
|
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
struct mcux_lpsci_config {
|
struct mcux_lpsci_config {
|
||||||
UART0_Type *base;
|
UART0_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#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;
|
const struct mcux_lpsci_config *config = dev->config;
|
||||||
lpsci_config_t uart_config;
|
lpsci_config_t uart_config;
|
||||||
const struct device *clock_dev;
|
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&clock_freq)) {
|
&clock_freq)) {
|
||||||
return -EINVAL;
|
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) \
|
#define MCUX_LPSCI_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct mcux_lpsci_config mcux_lpsci_##n##_config = { \
|
static const struct mcux_lpsci_config mcux_lpsci_##n##_config = { \
|
||||||
.base = (UART0_Type *)DT_INST_REG_ADDR(n), \
|
.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),\
|
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
struct mcux_lpuart_config {
|
struct mcux_lpuart_config {
|
||||||
LPUART_Type *base;
|
LPUART_Type *base;
|
||||||
char *clock_name;
|
const struct device *clock_dev;
|
||||||
clock_control_subsys_t clock_subsys;
|
clock_control_subsys_t clock_subsys;
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#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;
|
const struct mcux_lpuart_config *config = dev->config;
|
||||||
struct mcux_lpuart_data *data = dev->data;
|
struct mcux_lpuart_data *data = dev->data;
|
||||||
const struct device *clock_dev;
|
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
|
|
||||||
clock_dev = device_get_binding(config->clock_name);
|
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||||
if (clock_dev == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clock_control_get_rate(clock_dev, config->clock_subsys,
|
|
||||||
&clock_freq)) {
|
&clock_freq)) {
|
||||||
return -EINVAL;
|
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) \
|
#define LPUART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct mcux_lpuart_config mcux_lpuart_##n##_config = { \
|
static const struct mcux_lpuart_config mcux_lpuart_##n##_config = { \
|
||||||
.base = (LPUART_Type *) DT_INST_REG_ADDR(n), \
|
.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),\
|
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue