@@ -102,7 +102,6 @@ static int lpc11u6x_uart0_configure(const struct device *dev,
102
102
{
103
103
const struct lpc11u6x_uart0_config * dev_cfg = dev -> config ;
104
104
struct lpc11u6x_uart0_data * data = dev -> data ;
105
- const struct device * clk_dev ;
106
105
uint32_t flags = 0 ;
107
106
108
107
/* Check that the baudrate is a multiple of 9600 */
@@ -167,11 +166,7 @@ static int lpc11u6x_uart0_configure(const struct device *dev,
167
166
return - ENOTSUP ;
168
167
}
169
168
170
- clk_dev = device_get_binding (dev_cfg -> clock_drv_name );
171
- if (!clk_dev ) {
172
- return - EINVAL ;
173
- }
174
- lpc11u6x_uart0_config_baudrate (clk_dev , dev_cfg , cfg -> baudrate );
169
+ lpc11u6x_uart0_config_baudrate (dev_cfg -> clock_dev , dev_cfg , cfg -> baudrate );
175
170
dev_cfg -> uart0 -> lcr = flags ;
176
171
177
172
data -> baudrate = cfg -> baudrate ;
@@ -344,7 +339,6 @@ static int lpc11u6x_uart0_init(const struct device *dev)
344
339
{
345
340
const struct lpc11u6x_uart0_config * cfg = dev -> config ;
346
341
struct lpc11u6x_uart0_data * data = dev -> data ;
347
- const struct device * clk_drv ;
348
342
int err ;
349
343
350
344
/* Apply default pin control state to select RX and TX pins */
@@ -353,16 +347,10 @@ static int lpc11u6x_uart0_init(const struct device *dev)
353
347
return err ;
354
348
}
355
349
356
- /* Call clock driver to initialize uart0 clock */
357
- clk_drv = device_get_binding (cfg -> clock_drv_name );
358
- if (!clk_drv ) {
359
- return - EINVAL ;
360
- }
361
-
362
- clock_control_on (clk_drv , (clock_control_subsys_t ) cfg -> clkid );
350
+ clock_control_on (cfg -> clock_dev , (clock_control_subsys_t ) cfg -> clkid );
363
351
364
352
/* Configure baudrate, parity and stop bits */
365
- lpc11u6x_uart0_config_baudrate (clk_drv , cfg , cfg -> baudrate );
353
+ lpc11u6x_uart0_config_baudrate (cfg -> clock_dev , cfg , cfg -> baudrate );
366
354
367
355
cfg -> uart0 -> lcr |= LPC11U6X_UART0_LCR_WLS_8BITS ; /* 8N1 */
368
356
@@ -390,7 +378,7 @@ PINCTRL_DT_DEFINE(DT_NODELABEL(uart0));
390
378
static const struct lpc11u6x_uart0_config uart0_config = {
391
379
.uart0 = (struct lpc11u6x_uart0_regs * )
392
380
DT_REG_ADDR (DT_NODELABEL (uart0 )),
393
- .clock_drv_name = DT_LABEL ( DT_PHANDLE (DT_NODELABEL (uart0 ), clocks )),
381
+ .clock_dev = DEVICE_DT_GET ( DT_CLOCKS_CTLR (DT_NODELABEL (uart0 ))),
394
382
.pincfg = PINCTRL_DT_DEV_CONFIG_GET (DT_NODELABEL (uart0 )),
395
383
.clkid = DT_PHA_BY_IDX (DT_NODELABEL (uart0 ), clocks , 0 , clkid ),
396
384
.baudrate = DT_PROP (DT_NODELABEL (uart0 ), current_speed ),
@@ -491,11 +479,11 @@ static int lpc11u6x_uartx_err_check(const struct device *dev)
491
479
}
492
480
493
481
static void lpc11u6x_uartx_config_baud (const struct lpc11u6x_uartx_config * cfg ,
494
- const struct device * clk_drv ,
495
482
uint32_t baudrate )
496
483
{
497
484
uint32_t clk_rate ;
498
485
uint32_t div ;
486
+ const struct device * clk_drv = cfg -> clock_dev ;
499
487
500
488
clock_control_get_rate (clk_drv , (clock_control_subsys_t ) cfg -> clkid ,
501
489
& clk_rate );
@@ -511,9 +499,8 @@ static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg,
511
499
static int lpc11u6x_uartx_configure (const struct device * dev ,
512
500
const struct uart_config * cfg )
513
501
{
514
- const struct lpc11u6x_uartx_config * dev_cfg = dev -> config ;
502
+ const struct lpc11u6x_uartx_config * dev_cfg = dev -> config ;
515
503
struct lpc11u6x_uartx_data * data = dev -> data ;
516
- const struct device * clk_dev ;
517
504
uint32_t flags = 0 ;
518
505
519
506
/* We only support baudrates that are multiple of 9600 */
@@ -576,16 +563,11 @@ static int lpc11u6x_uartx_configure(const struct device *dev,
576
563
return - ENOTSUP ;
577
564
}
578
565
579
- clk_dev = device_get_binding (dev_cfg -> clock_drv_name );
580
- if (!clk_dev ) {
581
- return - EINVAL ;
582
- }
583
-
584
566
/* Disable UART */
585
567
dev_cfg -> base -> cfg = 0 ;
586
568
587
569
/* Update baudrate */
588
- lpc11u6x_uartx_config_baud (dev_cfg , clk_dev , cfg -> baudrate );
570
+ lpc11u6x_uartx_config_baud (dev_cfg , cfg -> baudrate );
589
571
590
572
/* Set parity, data bits, stop bits and re-enable UART interface */
591
573
dev_cfg -> base -> cfg = flags | LPC11U6X_UARTX_CFG_ENABLE ;
@@ -779,7 +761,6 @@ static int lpc11u6x_uartx_init(const struct device *dev)
779
761
{
780
762
const struct lpc11u6x_uartx_config * cfg = dev -> config ;
781
763
struct lpc11u6x_uartx_data * data = dev -> data ;
782
- const struct device * clk_drv ;
783
764
int err ;
784
765
785
766
/* Apply default pin control state to select RX and TX pins */
@@ -788,16 +769,10 @@ static int lpc11u6x_uartx_init(const struct device *dev)
788
769
return err ;
789
770
}
790
771
791
- /* Call clock driver to initialize uart0 clock */
792
- clk_drv = device_get_binding (cfg -> clock_drv_name );
793
- if (!clk_drv ) {
794
- return - EINVAL ;
795
- }
796
-
797
- clock_control_on (clk_drv , (clock_control_subsys_t ) cfg -> clkid );
772
+ clock_control_on (cfg -> clock_dev , (clock_control_subsys_t ) cfg -> clkid );
798
773
799
774
/* Configure baudrate, parity and stop bits */
800
- lpc11u6x_uartx_config_baud (cfg , clk_drv , cfg -> baudrate );
775
+ lpc11u6x_uartx_config_baud (cfg , cfg -> baudrate );
801
776
cfg -> base -> cfg = LPC11U6X_UARTX_CFG_DATALEN_8BIT ; /* 8N1 */
802
777
803
778
data -> baudrate = cfg -> baudrate ;
@@ -861,8 +836,7 @@ PINCTRL_DT_DEFINE(DT_NODELABEL(uart##idx)); \
861
836
static const struct lpc11u6x_uartx_config uart_cfg_##idx = { \
862
837
.base = (struct lpc11u6x_uartx_regs *) \
863
838
DT_REG_ADDR(DT_NODELABEL(uart##idx)), \
864
- .clock_drv_name = \
865
- DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart##idx), clocks)), \
839
+ .clock_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_NODELABEL(uart##idx))), \
866
840
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart##idx), clocks, 0, clkid), \
867
841
.pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart##idx)), \
868
842
.baudrate = DT_PROP(DT_NODELABEL(uart##idx), current_speed), \
0 commit comments