linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support
@ 2010-12-22  9:52 Guennadi Liakhovetski
  2010-12-22 23:24 ` Paul Mundt
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Guennadi Liakhovetski @ 2010-12-22  9:52 UTC (permalink / raw)
  To: linux-fbdev

On SH-Mobile platforms using runtime PM with the MIPI DSI driver switches the
DSI Tx link clock on PM events.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/video/sh_mipi_dsi.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c
index 3f3d431..ef19cac 100644
--- a/drivers/video/sh_mipi_dsi.c
+++ b/drivers/video/sh_mipi_dsi.c
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
@@ -33,6 +34,7 @@ struct sh_mipi {
 	void __iomem	*base;
 	struct clk	*dsit_clk;
 	struct clk	*dsip_clk;
+	struct device	*dev;
 };
 
 static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
@@ -104,6 +106,7 @@ static void mipi_display_on(void *arg, struct fb_info *info)
 {
 	struct sh_mipi *mipi = arg;
 
+	pm_runtime_get_sync(mipi->dev);
 	sh_mipi_dsi_enable(mipi, true);
 }
 
@@ -112,6 +115,7 @@ static void mipi_display_off(void *arg)
 	struct sh_mipi *mipi = arg;
 
 	sh_mipi_dsi_enable(mipi, false);
+	pm_runtime_put(mipi->dev);
 }
 
 static int __init sh_mipi_setup(struct sh_mipi *mipi,
@@ -356,7 +360,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
 		goto emap;
 	}
 
-	mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
+	mipi->dev = &pdev->dev;
+
+	mipi->dsit_clk = clk_get(NULL, "dsit_clk");
 	if (IS_ERR(mipi->dsit_clk)) {
 		ret = PTR_ERR(mipi->dsit_clk);
 		goto eclktget;
@@ -405,6 +411,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
 
 	mipi_dsi[idx] = mipi;
 
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_resume(&pdev->dev);
+
 	ret = sh_mipi_setup(mipi, pdata);
 	if (ret < 0)
 		goto emipisetup;
@@ -416,11 +425,13 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
 	pdata->lcd_chan->board_cfg.board_data = mipi;
 	pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
 	pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
+	pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
 
 	return 0;
 
 emipisetup:
 	mipi_dsi[idx] = NULL;
+	pm_runtime_disable(&pdev->dev);
 	clk_disable(mipi->dsip_clk);
 eclkpon:
 	clk_disable(mipi->dsit_clk);
@@ -467,10 +478,12 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	pdata->lcd_chan->board_cfg.owner = NULL;
 	pdata->lcd_chan->board_cfg.display_on = NULL;
 	pdata->lcd_chan->board_cfg.display_off = NULL;
 	pdata->lcd_chan->board_cfg.board_data = NULL;
 
+	pm_runtime_disable(&pdev->dev);
 	clk_disable(mipi->dsip_clk);
 	clk_disable(mipi->dsit_clk);
 	clk_put(mipi->dsit_clk);
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support
  2010-12-22  9:52 [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Guennadi Liakhovetski
@ 2010-12-22 23:24 ` Paul Mundt
  2010-12-23  0:08 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2010-12-22 23:24 UTC (permalink / raw)
  To: linux-fbdev

On Wed, Dec 22, 2010 at 10:52:18AM +0100, Guennadi Liakhovetski wrote:
> @@ -356,7 +360,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
>  		goto emap;
>  	}
>  
> -	mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
> +	mipi->dev = &pdev->dev;
> +
> +	mipi->dsit_clk = clk_get(NULL, "dsit_clk");

Why did you drop &pdev->dev from clk_get()?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM
  2010-12-22  9:52 [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Guennadi Liakhovetski
  2010-12-22 23:24 ` Paul Mundt
@ 2010-12-23  0:08 ` Guennadi Liakhovetski
  2010-12-24  1:34 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Paul Mundt
  2010-12-24  8:28 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski
  3 siblings, 0 replies; 5+ messages in thread
From: Guennadi Liakhovetski @ 2010-12-23  0:08 UTC (permalink / raw)
  To: linux-fbdev

On Thu, 23 Dec 2010, Paul Mundt wrote:

> On Wed, Dec 22, 2010 at 10:52:18AM +0100, Guennadi Liakhovetski wrote:
> > @@ -356,7 +360,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
> >  		goto emap;
> >  	}
> >  
> > -	mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
> > +	mipi->dev = &pdev->dev;
> > +
> > +	mipi->dsit_clk = clk_get(NULL, "dsit_clk");
> 
> Why did you drop &pdev->dev from clk_get()?

Because that clock is not associated with that device, it sisn't work 
correctly until now. You also cannot associate it with that device 
exclusively, because it serves two devices...

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support
  2010-12-22  9:52 [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Guennadi Liakhovetski
  2010-12-22 23:24 ` Paul Mundt
  2010-12-23  0:08 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski
@ 2010-12-24  1:34 ` Paul Mundt
  2010-12-24  8:28 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2010-12-24  1:34 UTC (permalink / raw)
  To: linux-fbdev

On Thu, Dec 23, 2010 at 01:08:34AM +0100, Guennadi Liakhovetski wrote:
> On Thu, 23 Dec 2010, Paul Mundt wrote:
> 
> > On Wed, Dec 22, 2010 at 10:52:18AM +0100, Guennadi Liakhovetski wrote:
> > > @@ -356,7 +360,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
> > >  		goto emap;
> > >  	}
> > >  
> > > -	mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
> > > +	mipi->dev = &pdev->dev;
> > > +
> > > +	mipi->dsit_clk = clk_get(NULL, "dsit_clk");
> > 
> > Why did you drop &pdev->dev from clk_get()?
> 
> Because that clock is not associated with that device, it sisn't work 
> correctly until now. You also cannot associate it with that device 
> exclusively, because it serves two devices...
> 
I'm not sure I see what the problem is. If there is no special lookup
matching this clock to the device pointer then the lookup will resolve to
whatever generically provides that clock. There is also nothing that
stops someone from providing the same clock to multiple devices via the
same lookup string, this is largely what clock lookups are for in the
first place. Any move away from a device pointer to clk_get() is a step
in the wrong direction.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM
  2010-12-22  9:52 [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Guennadi Liakhovetski
                   ` (2 preceding siblings ...)
  2010-12-24  1:34 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Paul Mundt
@ 2010-12-24  8:28 ` Guennadi Liakhovetski
  3 siblings, 0 replies; 5+ messages in thread
From: Guennadi Liakhovetski @ 2010-12-24  8:28 UTC (permalink / raw)
  To: linux-fbdev

On Fri, 24 Dec 2010, Paul Mundt wrote:

> On Thu, Dec 23, 2010 at 01:08:34AM +0100, Guennadi Liakhovetski wrote:
> > On Thu, 23 Dec 2010, Paul Mundt wrote:
> > 
> > > On Wed, Dec 22, 2010 at 10:52:18AM +0100, Guennadi Liakhovetski wrote:
> > > > @@ -356,7 +360,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
> > > >  		goto emap;
> > > >  	}
> > > >  
> > > > -	mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
> > > > +	mipi->dev = &pdev->dev;
> > > > +
> > > > +	mipi->dsit_clk = clk_get(NULL, "dsit_clk");
> > > 
> > > Why did you drop &pdev->dev from clk_get()?
> > 
> > Because that clock is not associated with that device, it sisn't work 
> > correctly until now. You also cannot associate it with that device 
> > exclusively, because it serves two devices...
> > 
> I'm not sure I see what the problem is. If there is no special lookup
> matching this clock to the device pointer then the lookup will resolve to
> whatever generically provides that clock. There is also nothing that
> stops someone from providing the same clock to multiple devices via the
> same lookup string, this is largely what clock lookups are for in the
> first place. Any move away from a device pointer to clk_get() is a step
> in the wrong direction.

That device also has other clocks, so, previously, with the device pointer 
but with an unmatching device string I was getting a wrong clock - the one 
from the device... So, it is a step in the "right" direction in the sense, 
that I am now getting a correct clock. But yes, if I can associate one 
clock with several devices, that's even better! I'll try that.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-24  8:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-22  9:52 [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Guennadi Liakhovetski
2010-12-22 23:24 ` Paul Mundt
2010-12-23  0:08 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski
2010-12-24  1:34 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM support Paul Mundt
2010-12-24  8:28 ` [PATCH 1/2] fbdev: sh-mobile: implement MIPI DSI runtime PM Guennadi Liakhovetski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).