diff --git a/drivers/display/display_stm32_ltdc.c b/drivers/display/display_stm32_ltdc.c index 68e9d972179..7a4b2d0196d 100644 --- a/drivers/display/display_stm32_ltdc.c +++ b/drivers/display/display_stm32_ltdc.c @@ -76,7 +76,8 @@ struct display_stm32_ltdc_config { uint32_t height; struct gpio_dt_spec disp_on_gpio; struct gpio_dt_spec bl_ctrl_gpio; - struct stm32_pclken pclken; + const struct stm32_pclken *pclken; + size_t pclk_len; const struct reset_dt_spec reset; const struct pinctrl_dev_config *pctrl; void (*irq_config_func)(const struct device *dev); @@ -297,6 +298,14 @@ static int stm32_ltdc_display_blanking_on(const struct device *dev) return display_blanking_on(display_dev); } +/* This symbol takes the value 1 if one of the device instances */ +/* is configured in dts with a domain clock */ +#if STM32_DT_INST_DEV_DOMAIN_CLOCK_SUPPORT +#define STM32_LTDC_DOMAIN_CLOCK_SUPPORT 1 +#else +#define STM32_LTDC_DOMAIN_CLOCK_SUPPORT 0 +#endif + static int stm32_ltdc_init(const struct device *dev) { int err; @@ -337,12 +346,23 @@ static int stm32_ltdc_init(const struct device *dev) /* Turn on LTDC peripheral clock */ err = clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE), - (clock_control_subsys_t) &config->pclken); + (clock_control_subsys_t) &config->pclken[0]); if (err < 0) { LOG_ERR("Could not enable LTDC peripheral clock"); return err; } + if (IS_ENABLED(STM32_LTDC_DOMAIN_CLOCK_SUPPORT) && (config->pclk_len > 1)) { + /* Enable LTDC clock source */ + err = clock_control_configure(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE), + (clock_control_subsys_t) &config->pclken[1], + NULL); + if (err < 0) { + LOG_ERR("Could not configure LTDC peripheral clock"); + return err; + } + } + #if defined(CONFIG_SOC_SERIES_STM32F4X) LL_RCC_PLLSAI_Disable(); LL_RCC_PLLSAI_ConfigDomain_LTDC(LL_RCC_PLLSOURCE_HSE, @@ -455,7 +475,7 @@ static int stm32_ltdc_suspend(const struct device *dev) /* Turn off LTDC peripheral clock */ err = clock_control_off(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE), - (clock_control_subsys_t) &config->pclken); + (clock_control_subsys_t) &config->pclken[0]); return err; } @@ -634,6 +654,9 @@ static DEVICE_API(display, stm32_ltdc_display_api) = { }, \ }, \ }; \ + static const struct stm32_pclken pclken_##inst[] = \ + STM32_DT_INST_CLOCKS(inst); \ + \ static const struct display_stm32_ltdc_config stm32_ltdc_config_##inst = { \ .width = DT_INST_PROP(inst, width), \ .height = DT_INST_PROP(inst, height), \ @@ -642,10 +665,8 @@ static DEVICE_API(display, stm32_ltdc_display_api) = { .bl_ctrl_gpio = COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, bl_ctrl_gpios), \ (GPIO_DT_SPEC_INST_GET(inst, bl_ctrl_gpios)), ({ 0 })), \ .reset = RESET_DT_SPEC_INST_GET(0), \ - .pclken = { \ - .enr = DT_INST_CLOCKS_CELL(inst, bits), \ - .bus = DT_INST_CLOCKS_CELL(inst, bus) \ - }, \ + .pclken = pclken_##inst, \ + .pclk_len = DT_INST_NUM_CLOCKS(inst), \ .pctrl = STM32_LTDC_DEVICE_PINCTRL_GET(inst), \ .irq_config_func = stm32_ltdc_irq_config_func_##inst, \ .display_controller = DEVICE_DT_GET_OR_NULL( \