Hi Marek,

Thanks for your patch

On 4/29/22 22:45, Marek Vasut wrote:
> Certain DSI bridge chips like TC358767/TC358867/TC9595 expect the DSI D0
> data lane to be in LP-11 state when released from reset. Currently the
> STM32MP157 DSI host wrapper glue logic keeps D0 data lane in LP-00 state
> until DSI init happens, which confuses the TC358767 into entering some
> sort of test mode and the chip cannot be brought out of this test mode
> in any way.
>
> Enable the wrapper glue logic regulator in probe callback already and
> disable it in remove callback to satisfy this requirement. The D0 data
> lane is in LP-11 mode when the TC358767 bridge chip is brought up and
> the chip is not confused anymore.
>
> Signed-off-by: Marek Vasut <[email protected]>
> Cc: Alexandre Torgue <[email protected]>
> Cc: Antonio Borneo <[email protected]>
> Cc: Philippe Cornu <[email protected]>
> Cc: Raphael Gallais-Pou <[email protected]>
> Cc: Robert Foss <[email protected]>
> Cc: Yannick Fertre <[email protected]>
> ---
>  drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 30 +++++++++++++++++++++++----
>  1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c 
> b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> index 89897d5f5c72..c403633ffeae 100644
> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> @@ -194,16 +194,29 @@ static int dsi_pll_get_params(struct dw_mipi_dsi_stm 
> *dsi,
>       return 0;
>  }
>  
> +static int dw_mipi_dsi_phy_regulator_on(struct dw_mipi_dsi_stm *dsi)
> +{
> +     u32 val;
> +
> +     /* Enable the regulator */
> +     dsi_set(dsi, DSI_WRPCR, WRPCR_REGEN | WRPCR_BGREN);
> +     return readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
> +                               SLEEP_US, TIMEOUT_US);
> +}
> +
> +static void dw_mipi_dsi_phy_regulator_off(struct dw_mipi_dsi_stm *dsi)
> +{
> +     /* Disable the regulator */
> +     dsi_clear(dsi, DSI_WRPCR, WRPCR_REGEN | WRPCR_BGREN);
> +}
> +
>  static int dw_mipi_dsi_phy_init(void *priv_data)
>  {
>       struct dw_mipi_dsi_stm *dsi = priv_data;
>       u32 val;
>       int ret;
>  
> -     /* Enable the regulator */
> -     dsi_set(dsi, DSI_WRPCR, WRPCR_REGEN | WRPCR_BGREN);
> -     ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS,
> -                              SLEEP_US, TIMEOUT_US);
> +     ret = dw_mipi_dsi_phy_regulator_on(dsi);
>       if (ret)
>               DRM_DEBUG_DRIVER("!TIMEOUT! waiting REGU, let's continue\n");
>  
> @@ -499,8 +512,16 @@ static int dw_mipi_dsi_stm_probe(struct platform_device 
> *pdev)
>       }
>  
>       dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
> +
> +     ret = dw_mipi_dsi_phy_regulator_on(dsi);
>       clk_disable_unprepare(pclk);
>  
> +     if (ret) {
> +             DRM_ERROR("%s: Failed to enable wrapper regulator, ret=%d\n",
> +                       __func__, ret);
> +             goto err_dsi_probe;
> +     }
> +

I have no problem until here. If I understand this correctly, it enables the 
regulator during all the life of the driver.

If you feel an urge to merge this patch into the Linux kernel, the st display 
team could gladly do it because it enables more hardware bridges. However 
another solution could be to rework a bit the regulator part of the driver so 
that you would have only device tree to change, introducing a 'reg-always-on' 
property.

This driver needs in fact a bit of a rework with the power management. A 
solution could be to move the regulator-related part in 
dw_mipi_dsi_stm_power_on/off() so that it is only activated when needed. Those 
functions would integrate the enabling of the regulator, the switch for the 
internal regulator, and eventually handle the PLL if it cannot lock when the 
regulator is off.

With the DT property, the power management would be only in the 
probe()/remove(). In that way the DSI bridges would have the logic they need to 
work.

Ultimately there is two possibilities :
 * You really need this patch to be merged asap
 * You are ok to wait until we send the solution described above

If you want to write those patches (each for DT and regulator), feel free to do 
it.

What do you think about it ?


Regards,

Raphaƫl G-P

>       if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
>               ret = -ENODEV;
>               DRM_ERROR("bad dsi hardware version\n");
> @@ -542,6 +563,7 @@ static int dw_mipi_dsi_stm_remove(struct platform_device 
> *pdev)
>       struct dw_mipi_dsi_stm *dsi = platform_get_drvdata(pdev);
>  
>       dw_mipi_dsi_remove(dsi->dsi);
> +     dw_mipi_dsi_phy_regulator_off(dsi);
>       clk_disable_unprepare(dsi->pllref_clk);
>       regulator_disable(dsi->vdd_supply);
>  

Reply via email to