diff mbox series

[04/12] drm/sun4i: sun6i_mipi_dsi: Enable missing DSI bus clock

Message ID 20180927114850.24565-5-jagan@amarulasolutions.com
State Superseded, archived
Headers show
Series drm/sun4i: Allwinner A64 MIPI-DSI support | expand

Commit Message

Jagan Teki Sept. 27, 2018, 11:48 a.m. UTC
DSI bus_clk is already available in sun6i_dsi but missed to
get the clk and process for enable/disable.

This patch add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Chen-Yu Tsai Sept. 27, 2018, 12:42 p.m. UTC | #1
Hi,

On Thu, Sep 27, 2018 at 7:49 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> DSI bus_clk is already available in sun6i_dsi but missed to
> get the clk and process for enable/disable.
>
> This patch add support for it.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> index 8e9c76febca2..156b371243c6 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> @@ -1004,6 +1004,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
>                 return PTR_ERR(dsi->reset);
>         }
>
> +       dsi->bus_clk = devm_clk_get(dev, "bus");
> +       if (IS_ERR(dsi->bus_clk)) {
> +               dev_err(dev, "Couldn't get the DSI bus clock\n");
> +               return PTR_ERR(dsi->bus_clk);
> +       }
> +

The DSI driver uses devm_regmap_init_mmio_clk, which enables the
clock behind the scenes when regmap access needs it enabled.

Did you have any issues without this patch?

ChenYu

>         if (dsi->variant->has_mod_clk) {
>                 dsi->mod_clk = devm_clk_get(dev, "mod");
>                 if (IS_ERR(dsi->mod_clk)) {
> @@ -1012,6 +1018,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
>                 }
>         }
>
> +       clk_prepare_enable(dsi->bus_clk);
>         /*
>          * In order to operate properly, that clock seems to be always
>          * set to 297MHz.
> @@ -1065,6 +1072,7 @@ static int sun6i_dsi_remove(struct platform_device *pdev)
>         sun6i_dphy_remove(dsi);
>         if (dsi->variant->has_mod_clk)
>                 clk_rate_exclusive_put(dsi->mod_clk);
> +       clk_disable_unprepare(dsi->bus_clk);
>
>         return 0;
>  }
> --
> 2.18.0.321.gffc6fa0e3
>
Jagan Teki Sept. 27, 2018, 1:44 p.m. UTC | #2
On Thu, Sep 27, 2018 at 6:13 PM Chen-Yu Tsai <wens@csie.org> wrote:
>
> Hi,
>
> On Thu, Sep 27, 2018 at 7:49 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> >
> > DSI bus_clk is already available in sun6i_dsi but missed to
> > get the clk and process for enable/disable.
> >
> > This patch add support for it.
> >
> > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > ---
> >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > index 8e9c76febca2..156b371243c6 100644
> > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > @@ -1004,6 +1004,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
> >                 return PTR_ERR(dsi->reset);
> >         }
> >
> > +       dsi->bus_clk = devm_clk_get(dev, "bus");
> > +       if (IS_ERR(dsi->bus_clk)) {
> > +               dev_err(dev, "Couldn't get the DSI bus clock\n");
> > +               return PTR_ERR(dsi->bus_clk);
> > +       }
> > +
>
> The DSI driver uses devm_regmap_init_mmio_clk, which enables the
> clock behind the scenes when regmap access needs it enabled.
>
> Did you have any issues without this patch?

I'm unable to read register values via devmem, I see all 0's for all
dsi reg space.
Chen-Yu Tsai Sept. 27, 2018, 2:16 p.m. UTC | #3
On Thu, Sep 27, 2018 at 9:44 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> On Thu, Sep 27, 2018 at 6:13 PM Chen-Yu Tsai <wens@csie.org> wrote:
> >
> > Hi,
> >
> > On Thu, Sep 27, 2018 at 7:49 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> > >
> > > DSI bus_clk is already available in sun6i_dsi but missed to
> > > get the clk and process for enable/disable.
> > >
> > > This patch add support for it.
> > >
> > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > > ---
> > >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > index 8e9c76febca2..156b371243c6 100644
> > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > @@ -1004,6 +1004,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
> > >                 return PTR_ERR(dsi->reset);
> > >         }
> > >
> > > +       dsi->bus_clk = devm_clk_get(dev, "bus");
> > > +       if (IS_ERR(dsi->bus_clk)) {
> > > +               dev_err(dev, "Couldn't get the DSI bus clock\n");
> > > +               return PTR_ERR(dsi->bus_clk);
> > > +       }
> > > +
> >
> > The DSI driver uses devm_regmap_init_mmio_clk, which enables the
> > clock behind the scenes when regmap access needs it enabled.
> >
> > Did you have any issues without this patch?
>
> I'm unable to read register values via devmem, I see all 0's for all
> dsi reg space.

Well that is to be expected given how mmio with clk regmap works.
Did you encounter any other problems besides this?

FYI you can dump regmap contents using /sys/kernel/debug/regmap/*/registers

ChenYu
Jagan Teki Sept. 27, 2018, 4:26 p.m. UTC | #4
On Thu, Sep 27, 2018 at 7:47 PM Chen-Yu Tsai <wens@csie.org> wrote:
>
> On Thu, Sep 27, 2018 at 9:44 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> >
> > On Thu, Sep 27, 2018 at 6:13 PM Chen-Yu Tsai <wens@csie.org> wrote:
> > >
> > > Hi,
> > >
> > > On Thu, Sep 27, 2018 at 7:49 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> > > >
> > > > DSI bus_clk is already available in sun6i_dsi but missed to
> > > > get the clk and process for enable/disable.
> > > >
> > > > This patch add support for it.
> > > >
> > > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > > > ---
> > > >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > index 8e9c76febca2..156b371243c6 100644
> > > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > @@ -1004,6 +1004,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
> > > >                 return PTR_ERR(dsi->reset);
> > > >         }
> > > >
> > > > +       dsi->bus_clk = devm_clk_get(dev, "bus");
> > > > +       if (IS_ERR(dsi->bus_clk)) {
> > > > +               dev_err(dev, "Couldn't get the DSI bus clock\n");
> > > > +               return PTR_ERR(dsi->bus_clk);
> > > > +       }
> > > > +
> > >
> > > The DSI driver uses devm_regmap_init_mmio_clk, which enables the
> > > clock behind the scenes when regmap access needs it enabled.
> > >
> > > Did you have any issues without this patch?
> >
> > I'm unable to read register values via devmem, I see all 0's for all
> > dsi reg space.
>
> Well that is to be expected given how mmio with clk regmap works.
> Did you encounter any other problems besides this?

no

>
> FYI you can dump regmap contents using /sys/kernel/debug/regmap/*/registers

Thanks, but ccu not using regmap I believe so can't see bus enabled
bit set via devmap
# devmem 0x01C20060
0x33800000
Chen-Yu Tsai Sept. 27, 2018, 4:33 p.m. UTC | #5
On Fri, Sep 28, 2018 at 12:26 AM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> On Thu, Sep 27, 2018 at 7:47 PM Chen-Yu Tsai <wens@csie.org> wrote:
> >
> > On Thu, Sep 27, 2018 at 9:44 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> > >
> > > On Thu, Sep 27, 2018 at 6:13 PM Chen-Yu Tsai <wens@csie.org> wrote:
> > > >
> > > > Hi,
> > > >
> > > > On Thu, Sep 27, 2018 at 7:49 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> > > > >
> > > > > DSI bus_clk is already available in sun6i_dsi but missed to
> > > > > get the clk and process for enable/disable.
> > > > >
> > > > > This patch add support for it.
> > > > >
> > > > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > > > > ---
> > > > >  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 8 ++++++++
> > > > >  1 file changed, 8 insertions(+)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > > index 8e9c76febca2..156b371243c6 100644
> > > > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> > > > > @@ -1004,6 +1004,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev)
> > > > >                 return PTR_ERR(dsi->reset);
> > > > >         }
> > > > >
> > > > > +       dsi->bus_clk = devm_clk_get(dev, "bus");
> > > > > +       if (IS_ERR(dsi->bus_clk)) {
> > > > > +               dev_err(dev, "Couldn't get the DSI bus clock\n");
> > > > > +               return PTR_ERR(dsi->bus_clk);
> > > > > +       }
> > > > > +
> > > >
> > > > The DSI driver uses devm_regmap_init_mmio_clk, which enables the
> > > > clock behind the scenes when regmap access needs it enabled.
> > > >
> > > > Did you have any issues without this patch?
> > >
> > > I'm unable to read register values via devmem, I see all 0's for all
> > > dsi reg space.
> >
> > Well that is to be expected given how mmio with clk regmap works.
> > Did you encounter any other problems besides this?
>
> no
>
> >
> > FYI you can dump regmap contents using /sys/kernel/debug/regmap/*/registers
>
> Thanks, but ccu not using regmap I believe so can't see bus enabled
> bit set via devmap
> # devmem 0x01C20060
> 0x33800000

That is perfectly normal. It is only enabled when there are accesses to the
DSI regmap.

ChenYu
diff mbox series

Patch

diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index 8e9c76febca2..156b371243c6 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -1004,6 +1004,12 @@  static int sun6i_dsi_probe(struct platform_device *pdev)
 		return PTR_ERR(dsi->reset);
 	}
 
+	dsi->bus_clk = devm_clk_get(dev, "bus");
+	if (IS_ERR(dsi->bus_clk)) {
+		dev_err(dev, "Couldn't get the DSI bus clock\n");
+		return PTR_ERR(dsi->bus_clk);
+	}
+
 	if (dsi->variant->has_mod_clk) {
 		dsi->mod_clk = devm_clk_get(dev, "mod");
 		if (IS_ERR(dsi->mod_clk)) {
@@ -1012,6 +1018,7 @@  static int sun6i_dsi_probe(struct platform_device *pdev)
 		}
 	}
 
+	clk_prepare_enable(dsi->bus_clk);
 	/*
 	 * In order to operate properly, that clock seems to be always
 	 * set to 297MHz.
@@ -1065,6 +1072,7 @@  static int sun6i_dsi_remove(struct platform_device *pdev)
 	sun6i_dphy_remove(dsi);
 	if (dsi->variant->has_mod_clk)
 		clk_rate_exclusive_put(dsi->mod_clk);
+	clk_disable_unprepare(dsi->bus_clk);
 
 	return 0;
 }