diff mbox series

[19/21] drm/mediatek: dpi: add support for dpi clock

Message ID 20230220-display-v1-19-45cbc68e188b@baylibre.com (mailing list archive)
State New, archived
Headers show
Series Add display support for the MT8365-EVK board. | expand

Commit Message

Alexandre Mergnat March 9, 2023, 2:23 p.m. UTC
From: Fabien Parent <fparent@baylibre.com>

MT8365 requires an additional clock for DPI. Add support for that
additional clock.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Chun-Kuang Hu March 13, 2023, 3:21 p.m. UTC | #1
Hi, Alexandre:

Alexandre Mergnat <amergnat@baylibre.com> 於 2023年3月9日 週四 下午10:23寫道:
>
> From: Fabien Parent <fparent@baylibre.com>
>
> MT8365 requires an additional clock for DPI. Add support for that
> additional clock.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
> ---
>  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
Alexandre Mergnat March 15, 2023, 9:35 a.m. UTC | #2
Le lun. 13 mars 2023 à 16:21, Chun-Kuang Hu <chunkuang.hu@kernel.org> 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
Chun-Kuang Hu March 15, 2023, 2:17 p.m. UTC | #3
Hi, Alexandre:

Alexandre Mergnat <amergnat@baylibre.com> 於 2023年3月15日 週三 下午5:36寫道:
>
> Le lun. 13 mars 2023 à 16:21, Chun-Kuang Hu <chunkuang.hu@kernel.org> 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
diff mbox series

Patch

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");
+	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;