2023-03-13 15:21:28

by Chun-Kuang Hu

[permalink] [raw]
Subject: Re: [PATCH 19/21] drm/mediatek: dpi: add support for dpi clock

Hi, Alexandre:

Alexandre Mergnat <[email protected]> 於 2023年3月9日 週四 下午10:23寫道:
>
> From: Fabien Parent <[email protected]>
>
> MT8365 requires an additional clock for DPI. Add support for that
> additional clock.
>
> Signed-off-by: Fabien Parent <[email protected]>
> Signed-off-by: Alexandre Mergnat <[email protected]>
> ---
> 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


2023-03-15 09:36:15

by Alexandre Mergnat

[permalink] [raw]
Subject: Re: [PATCH 19/21] drm/mediatek: dpi: add support for dpi clock

Le lun. 13 mars 2023 à 16:21, Chun-Kuang Hu <[email protected]> a écrit :
>
> >
> > + 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.

This should be check and notified at build time thanks to the
device-tree binding. Do you prefer this?:
#IF MT8365_SOC
dpi->dpi_clk = devm_clk_get(dev, "dpi");

Regards,
Alex

2023-03-15 14:17:55

by Chun-Kuang Hu

[permalink] [raw]
Subject: Re: [PATCH 19/21] drm/mediatek: dpi: add support for dpi clock

Hi, Alexandre:

Alexandre Mergnat <[email protected]> 於 2023年3月15日 週三 下午5:36寫道:
>
> Le lun. 13 mars 2023 à 16:21, Chun-Kuang Hu <[email protected]> a écrit :
> >
> > >
> > > + 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.
>
> This should be check and notified at build time thanks to the
> device-tree binding. Do you prefer this?:
> #IF MT8365_SOC
> dpi->dpi_clk = devm_clk_get(dev, "dpi");

Add one member in struct mtk_dpi_conf for dpi_clk. In
mtk_dpi_of_ids[], add one item for mt8365

{ .compatible = "mediatek,mt8365-dpi",
.data = &mt8365_conf,
},

Regards,
Chun-Kuang.

>
> Regards,
> Alex