linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138
@ 2018-03-14 22:58 David Lechner
  2018-03-19  9:05 ` Jyri Sarha
  0 siblings, 1 reply; 4+ messages in thread
From: David Lechner @ 2018-03-14 22:58 UTC (permalink / raw)
  To: dri-devel
  Cc: David Lechner, Jyri Sarha, Tomi Valkeinen, Bartosz Golaszewski,
	Sekhar Nori, linux-kernel

This fixes setting the clock divider on the TI OMAP-L138 LCDK board.

The clock drivers for OMAP-L138 are being covernted to the common clock
framework. When this happens, clk_set_rate() will no longer return an
error. However, on this SoC, the clock rate cannot actually be changed
because the clock has to maintain a fixed ratio to the ARM clock. So
after attempting to set the clock rate, we need to check to see if the
new rate is actually close enough. If not, then follow the previous
error path to adjust the divider in LCDC IP block to compensate for not
being able to change the parent clock rate.

Tested working on a TI OMAP-L138 LCDK board.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 8bf6bb9..6931777 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -224,7 +224,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
 
 	ret = clk_set_rate(priv->clk, req_rate * clkdiv);
 	clk_rate = clk_get_rate(priv->clk);
-	if (ret < 0) {
+	if (ret < 0 || tilcdc_pclk_diff(req_rate, clk_rate) > 5) {
 		/*
 		 * If we fail to set the clock rate (some architectures don't
 		 * use the common clock framework yet and may not implement
-- 
2.7.4

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

* Re: [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138
  2018-03-14 22:58 [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138 David Lechner
@ 2018-03-19  9:05 ` Jyri Sarha
  2018-05-09 16:22   ` David Lechner
  0 siblings, 1 reply; 4+ messages in thread
From: Jyri Sarha @ 2018-03-19  9:05 UTC (permalink / raw)
  To: David Lechner, dri-devel
  Cc: Tomi Valkeinen, Bartosz Golaszewski, Sekhar Nori, linux-kernel

Thanks,
I'll pick this for v4.18.

Best regards,
Jyri

On 15/03/18 00:58, David Lechner wrote:
> This fixes setting the clock divider on the TI OMAP-L138 LCDK board.
> 
> The clock drivers for OMAP-L138 are being covernted to the common clock
> framework. When this happens, clk_set_rate() will no longer return an
> error. However, on this SoC, the clock rate cannot actually be changed
> because the clock has to maintain a fixed ratio to the ARM clock. So
> after attempting to set the clock rate, we need to check to see if the
> new rate is actually close enough. If not, then follow the previous
> error path to adjust the divider in LCDC IP block to compensate for not
> being able to change the parent clock rate.
> 
> Tested working on a TI OMAP-L138 LCDK board.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 8bf6bb9..6931777 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -224,7 +224,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
>  
>  	ret = clk_set_rate(priv->clk, req_rate * clkdiv);
>  	clk_rate = clk_get_rate(priv->clk);
> -	if (ret < 0) {
> +	if (ret < 0 || tilcdc_pclk_diff(req_rate, clk_rate) > 5) {
>  		/*
>  		 * If we fail to set the clock rate (some architectures don't
>  		 * use the common clock framework yet and may not implement
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138
  2018-03-19  9:05 ` Jyri Sarha
@ 2018-05-09 16:22   ` David Lechner
  2018-05-09 17:42     ` Jyri Sarha
  0 siblings, 1 reply; 4+ messages in thread
From: David Lechner @ 2018-05-09 16:22 UTC (permalink / raw)
  To: Jyri Sarha, dri-devel
  Cc: Tomi Valkeinen, Bartosz Golaszewski, Sekhar Nori, linux-kernel

On 03/19/2018 04:05 AM, Jyri Sarha wrote:
> Thanks,
> I'll pick this for v4.18.

Ping. I don't see this in drm-misc-next yet.

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

* Re: [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138
  2018-05-09 16:22   ` David Lechner
@ 2018-05-09 17:42     ` Jyri Sarha
  0 siblings, 0 replies; 4+ messages in thread
From: Jyri Sarha @ 2018-05-09 17:42 UTC (permalink / raw)
  To: David Lechner, dri-devel
  Cc: Tomi Valkeinen, Bartosz Golaszewski, Sekhar Nori, linux-kernel

On 05/09/18 19:22, David Lechner wrote:
> On 03/19/2018 04:05 AM, Jyri Sarha wrote:
>> Thanks,
>> I'll pick this for v4.18.
> 
> Ping. I don't see this in drm-misc-next yet.
> 

Thanks for the ping. I thought I would have time to do something more
for tilcdc in v4.18, but it seems I have not. After testing I just sent
a tilcdc pull request with just this patch.

Best regards,
Jyri


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

end of thread, other threads:[~2018-05-09 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 22:58 [PATCH] drm/tilcdc: Fix setting clock divider for omap-l138 David Lechner
2018-03-19  9:05 ` Jyri Sarha
2018-05-09 16:22   ` David Lechner
2018-05-09 17:42     ` Jyri Sarha

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).