stm32h7 MIPI DSI with LTDC


Rico Ganahl
 

Hi all

I'm currently developing an stm32h7 mipi dsi driver and have the following problem:
It only works if i add the following code to the LTDC driver:

diff --git a/drivers/display/display_stm32_ltdc.c b/drivers/display/display_stm32_ltdc.c
index 840c276e28..04d387cf37 100644
--- a/drivers/display/display_stm32_ltdc.c
+++ b/drivers/display/display_stm32_ltdc.c
@@ -280,7 +280,18 @@ static int stm32_ltdc_init(const struct device *dev)
                LOG_ERR("clock control device not ready");
                return -ENODEV;
        }
-
+#if 1
+       RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;
+
+       PeriphClkInitStruct.PeriphClockSelection   = RCC_PERIPHCLK_LTDC;
+       PeriphClkInitStruct.PLL3.PLL3M      = DT_PROP(DT_NODELABEL(pll3), div_m);
+       PeriphClkInitStruct.PLL3.PLL3N      = DT_PROP(DT_NODELABEL(pll3), mul_n);
+       PeriphClkInitStruct.PLL3.PLL3P      = DT_PROP_OR(DT_NODELABEL(pll3), div_p, 1);
+       PeriphClkInitStruct.PLL3.PLL3Q      = DT_PROP_OR(DT_NODELABEL(pll3), div_q, 1);
+       PeriphClkInitStruct.PLL3.PLL3R      = DT_PROP_OR(DT_NODELABEL(pll3), div_r, 1);
+       PeriphClkInitStruct.PLL3.PLL3FRACN  = 0U;
+       HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+#endif
        /* Turn on LTDC peripheral clock */
        err = clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
                                (clock_control_subsys_t) &config->pclken);

I do not like to screw up the beautiful work of https://github.com/tmilkovic51

Where is the correct place for the PLL3 setup?
It looks like that the current implementation https://github.com/zephyrproject-rtos/zephyr/blob/bbf03fd9910f4debc991a659d1073abb57e1c843/drivers/clock_control/clock_stm32_ll_h7.c#L741 does not work properly.

Did I miss something?

Thanks
Rico


Erwan Gouriou
 

Hi Rico

Since injecting device tee configuration directly in RCC HAL works,
this likely means there's something wrong in PLL3 configuration performed in H7 clock_control driver.
Would you be able to check registers and see where zephyr driver is failing ?

In any case, please raise an issue in github with maximum information on how to reproduce the failure you're seeing.

Thanks
Erwan


On Fri, 2 Dec 2022 at 15:02, Rico Ganahl <rico.ganahl@...> wrote:
Hi all

I'm currently developing an stm32h7 mipi dsi driver and have the
following problem:
It only works if i add the following code to the LTDC driver:

diff --git a/drivers/display/display_stm32_ltdc.c
b/drivers/display/display_stm32_ltdc.c
index 840c276e28..04d387cf37 100644
--- a/drivers/display/display_stm32_ltdc.c
+++ b/drivers/display/display_stm32_ltdc.c
@@ -280,7 +280,18 @@ static int stm32_ltdc_init(const struct device *dev)
                 LOG_ERR("clock control device not ready");
                 return -ENODEV;
         }
-
+#if 1
+       RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;
+
+       PeriphClkInitStruct.PeriphClockSelection   = RCC_PERIPHCLK_LTDC;
+       PeriphClkInitStruct.PLL3.PLL3M      =
DT_PROP(DT_NODELABEL(pll3), div_m);
+       PeriphClkInitStruct.PLL3.PLL3N      =
DT_PROP(DT_NODELABEL(pll3), mul_n);
+       PeriphClkInitStruct.PLL3.PLL3P      =
DT_PROP_OR(DT_NODELABEL(pll3), div_p, 1);
+       PeriphClkInitStruct.PLL3.PLL3Q      =
DT_PROP_OR(DT_NODELABEL(pll3), div_q, 1);
+       PeriphClkInitStruct.PLL3.PLL3R      =
DT_PROP_OR(DT_NODELABEL(pll3), div_r, 1);
+       PeriphClkInitStruct.PLL3.PLL3FRACN  = 0U;
+       HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+#endif
         /* Turn on LTDC peripheral clock */
         err = clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
                                 (clock_control_subsys_t) &config->pclken);

I do not like to screw up the beautiful work of
https://github.com/tmilkovic51

Where is the correct place for the PLL3 setup?
It looks like that the current implementation
https://github.com/zephyrproject-rtos/zephyr/blob/bbf03fd9910f4debc991a659d1073abb57e1c843/drivers/clock_control/clock_stm32_ll_h7.c#L741
does not work properly.

Did I miss something?

Thanks
Rico