Skip to content

Commit 873bba0

Browse files
hfruchet-stkartben
authored andcommitted
drivers: display: stm32_ltdc: add support of clock_configure
Add support of clock_configure() for clock source selection through devicetree. Signed-off-by: Hugues Fruchet <[email protected]>
1 parent 0da7671 commit 873bba0

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

drivers/display/display_stm32_ltdc.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ struct display_stm32_ltdc_config {
7676
uint32_t height;
7777
struct gpio_dt_spec disp_on_gpio;
7878
struct gpio_dt_spec bl_ctrl_gpio;
79-
struct stm32_pclken pclken;
79+
const struct stm32_pclken *pclken;
80+
size_t pclk_len;
8081
const struct reset_dt_spec reset;
8182
const struct pinctrl_dev_config *pctrl;
8283
void (*irq_config_func)(const struct device *dev);
@@ -297,6 +298,14 @@ static int stm32_ltdc_display_blanking_on(const struct device *dev)
297298
return display_blanking_on(display_dev);
298299
}
299300

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+
300309
static int stm32_ltdc_init(const struct device *dev)
301310
{
302311
int err;
@@ -337,12 +346,23 @@ static int stm32_ltdc_init(const struct device *dev)
337346

338347
/* Turn on LTDC peripheral clock */
339348
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]);
341350
if (err < 0) {
342351
LOG_ERR("Could not enable LTDC peripheral clock");
343352
return err;
344353
}
345354

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+
346366
#if defined(CONFIG_SOC_SERIES_STM32F4X)
347367
LL_RCC_PLLSAI_Disable();
348368
LL_RCC_PLLSAI_ConfigDomain_LTDC(LL_RCC_PLLSOURCE_HSE,
@@ -455,7 +475,7 @@ static int stm32_ltdc_suspend(const struct device *dev)
455475

456476
/* Turn off LTDC peripheral clock */
457477
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]);
459479

460480
return err;
461481
}
@@ -634,6 +654,9 @@ static DEVICE_API(display, stm32_ltdc_display_api) = {
634654
}, \
635655
}, \
636656
}; \
657+
static const struct stm32_pclken pclken_##inst[] = \
658+
STM32_DT_INST_CLOCKS(inst); \
659+
\
637660
static const struct display_stm32_ltdc_config stm32_ltdc_config_##inst = { \
638661
.width = DT_INST_PROP(inst, width), \
639662
.height = DT_INST_PROP(inst, height), \
@@ -642,10 +665,8 @@ static DEVICE_API(display, stm32_ltdc_display_api) = {
642665
.bl_ctrl_gpio = COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, bl_ctrl_gpios), \
643666
(GPIO_DT_SPEC_INST_GET(inst, bl_ctrl_gpios)), ({ 0 })), \
644667
.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), \
649670
.pctrl = STM32_LTDC_DEVICE_PINCTRL_GET(inst), \
650671
.irq_config_func = stm32_ltdc_irq_config_func_##inst, \
651672
.display_controller = DEVICE_DT_GET_OR_NULL( \

0 commit comments

Comments
 (0)