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 <marex@xxxxxxx> Cc: Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx> Cc: Antonio Borneo <antonio.borneo@xxxxxxxxxxx> Cc: Philippe Cornu <philippe.cornu@xxxxxxxxxxx> Cc: Raphael Gallais-Pou <raphael.gallais-pou@xxxxxxxxxxx> Cc: Robert Foss <robert.foss@xxxxxxxxxx> Cc: Yannick Fertre <yannick.fertre@xxxxxxxxxxx> --- 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; + } + 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); -- 2.35.1