Re: [PATCH 19/21] drm/mediatek: dpi: add support for dpi clock
From: Chun-Kuang Hu
Date: Mon Mar 13 2023 - 11:21:28 EST
Hi, Alexandre:
Alexandre Mergnat <amergnat@xxxxxxxxxxxx> 於 2023年3月9日 週四 下午10:23寫道:
>
> From: Fabien Parent <fparent@xxxxxxxxxxxx>
>
> MT8365 requires an additional clock for DPI. Add support for that
> additional clock.
>
> Signed-off-by: Fabien Parent <fparent@xxxxxxxxxxxx>
> Signed-off-by: Alexandre Mergnat <amergnat@xxxxxxxxxxxx>
> ---
> drivers/gpu/drm/mediatek/mtk_dpi.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 4317595a15d1..474c6e5bbf04 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -68,6 +68,7 @@ struct mtk_dpi {
> struct device *dev;
> struct clk *engine_clk;
> struct clk *pixel_clk;
> + struct clk *dpi_clk;
> struct clk *tvd_clk;
> int irq;
> struct drm_display_mode mode;
> @@ -464,6 +465,7 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)
> mtk_dpi_disable(dpi);
> clk_disable_unprepare(dpi->pixel_clk);
> clk_disable_unprepare(dpi->engine_clk);
> + clk_disable_unprepare(dpi->dpi_clk);
> }
>
> static int mtk_dpi_power_on(struct mtk_dpi *dpi)
> @@ -473,10 +475,16 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
> if (++dpi->refcount != 1)
> return 0;
>
> + ret = clk_prepare_enable(dpi->dpi_clk);
> + if (ret) {
> + dev_err(dpi->dev, "failed to enable dpi clock: %d\n", ret);
> + goto err_refcount;
> + }
> +
> ret = clk_prepare_enable(dpi->engine_clk);
> if (ret) {
> dev_err(dpi->dev, "Failed to enable engine clock: %d\n", ret);
> - goto err_refcount;
> + goto err_engine;
> }
>
> ret = clk_prepare_enable(dpi->pixel_clk);
> @@ -489,6 +497,8 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
>
> err_pixel:
> clk_disable_unprepare(dpi->engine_clk);
> +err_engine:
> + clk_disable_unprepare(dpi->dpi_clk);
> err_refcount:
> dpi->refcount--;
> return ret;
> @@ -1044,6 +1054,12 @@ static int mtk_dpi_probe(struct platform_device *pdev)
> return ret;
> }
>
> + dpi->dpi_clk = devm_clk_get_optional(dev, "dpi");
For MT8365, DPI clock is not optional, so make sure that MT8365 DPI
should have this clock.
Regards,
Chun-Kuang.
> + if (IS_ERR(dpi->dpi_clk)) {
> + return dev_err_probe(dev, ret, "Failed to get dpi clock: %p\n",
> + dpi->dpi_clk);
> + }
> +
> dpi->irq = platform_get_irq(pdev, 0);
> if (dpi->irq <= 0)
> return -EINVAL;
>
> --
> b4 0.10.1