@@ -76,7 +76,8 @@ struct display_stm32_ltdc_config {
76
76
uint32_t height ;
77
77
struct gpio_dt_spec disp_on_gpio ;
78
78
struct gpio_dt_spec bl_ctrl_gpio ;
79
- struct stm32_pclken pclken ;
79
+ const struct stm32_pclken * pclken ;
80
+ size_t pclk_len ;
80
81
const struct reset_dt_spec reset ;
81
82
const struct pinctrl_dev_config * pctrl ;
82
83
void (* irq_config_func )(const struct device * dev );
@@ -297,6 +298,14 @@ static int stm32_ltdc_display_blanking_on(const struct device *dev)
297
298
return display_blanking_on (display_dev );
298
299
}
299
300
301
+ /* This symbol takes the value 1 if one of the device instances */
302
+ /* is configured in dts with a domain clock */
303
+ #if STM32_DT_INST_DEV_DOMAIN_CLOCK_SUPPORT
304
+ #define STM32_LTDC_DOMAIN_CLOCK_SUPPORT 1
305
+ #else
306
+ #define STM32_LTDC_DOMAIN_CLOCK_SUPPORT 0
307
+ #endif
308
+
300
309
static int stm32_ltdc_init (const struct device * dev )
301
310
{
302
311
int err ;
@@ -337,12 +346,23 @@ static int stm32_ltdc_init(const struct device *dev)
337
346
338
347
/* Turn on LTDC peripheral clock */
339
348
err = clock_control_on (DEVICE_DT_GET (STM32_CLOCK_CONTROL_NODE ),
340
- (clock_control_subsys_t ) & config -> pclken );
349
+ (clock_control_subsys_t ) & config -> pclken [ 0 ] );
341
350
if (err < 0 ) {
342
351
LOG_ERR ("Could not enable LTDC peripheral clock" );
343
352
return err ;
344
353
}
345
354
355
+ if (IS_ENABLED (STM32_LTDC_DOMAIN_CLOCK_SUPPORT ) && (config -> pclk_len > 1 )) {
356
+ /* Enable LTDC clock source */
357
+ err = clock_control_configure (DEVICE_DT_GET (STM32_CLOCK_CONTROL_NODE ),
358
+ (clock_control_subsys_t ) & config -> pclken [1 ],
359
+ NULL );
360
+ if (err < 0 ) {
361
+ LOG_ERR ("Could not configure LTDC peripheral clock" );
362
+ return err ;
363
+ }
364
+ }
365
+
346
366
#if defined(CONFIG_SOC_SERIES_STM32F4X )
347
367
LL_RCC_PLLSAI_Disable ();
348
368
LL_RCC_PLLSAI_ConfigDomain_LTDC (LL_RCC_PLLSOURCE_HSE ,
@@ -455,7 +475,7 @@ static int stm32_ltdc_suspend(const struct device *dev)
455
475
456
476
/* Turn off LTDC peripheral clock */
457
477
err = clock_control_off (DEVICE_DT_GET (STM32_CLOCK_CONTROL_NODE ),
458
- (clock_control_subsys_t ) & config -> pclken );
478
+ (clock_control_subsys_t ) & config -> pclken [ 0 ] );
459
479
460
480
return err ;
461
481
}
@@ -634,6 +654,9 @@ static DEVICE_API(display, stm32_ltdc_display_api) = {
634
654
}, \
635
655
}, \
636
656
}; \
657
+ static const struct stm32_pclken pclken_##inst[] = \
658
+ STM32_DT_INST_CLOCKS(inst); \
659
+ \
637
660
static const struct display_stm32_ltdc_config stm32_ltdc_config_##inst = { \
638
661
.width = DT_INST_PROP(inst, width), \
639
662
.height = DT_INST_PROP(inst, height), \
@@ -642,10 +665,8 @@ static DEVICE_API(display, stm32_ltdc_display_api) = {
642
665
.bl_ctrl_gpio = COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, bl_ctrl_gpios), \
643
666
(GPIO_DT_SPEC_INST_GET(inst, bl_ctrl_gpios)), ({ 0 })), \
644
667
.reset = RESET_DT_SPEC_INST_GET(0), \
645
- .pclken = { \
646
- .enr = DT_INST_CLOCKS_CELL(inst, bits), \
647
- .bus = DT_INST_CLOCKS_CELL(inst, bus) \
648
- }, \
668
+ .pclken = pclken_##inst, \
669
+ .pclk_len = DT_INST_NUM_CLOCKS(inst), \
649
670
.pctrl = STM32_LTDC_DEVICE_PINCTRL_GET(inst), \
650
671
.irq_config_func = stm32_ltdc_irq_config_func_##inst, \
651
672
.display_controller = DEVICE_DT_GET_OR_NULL( \
0 commit comments