# \[PATCH\] video: da8xx-fb: reset LCDC only if functional clock changes with DVFS

- Subsystems: FRAMEBUFFER LAYER, THE REST
- Maintainers: Helge Deller, Linus Torvalds
- List: linux-fbdev
- 3 messages, 2 authors
- Page: https://ratatoskr.run/linux-fbdev/2011/12/13462373/t

## \[PATCH\] video: da8xx-fb: reset LCDC only if functional clock changes with DVFS

- From: Manjunathappa, Prakash \<hidden\>
- Date: 2011-12-21 07:39:40 
- Message: https://ratatoskr.run/linux-fbdev/2011/12/13462373.md

```text
LCDC functional clock may or may not be derived from CPU/MPU DPLL,
For example,
AM335x => Separate independent DPLL for LCDC
Davinci => Same DPLL as MPU

So, on platforms where LCDC functional clock is not derived from CPU/MPU
PLL it is not required to reset LCDC module, if CPU frequency does not
change with DVFS.

This patch adds check to do reset only if functional clock changes
between pre and post notifier callbacks with DVFS.

Signed-off-by: Manjunathappa, Prakash <redacted>
---
 drivers/video/da8xx-fb.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 29577bf..1334a68 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -161,6 +161,7 @@ struct da8xx_fb_par {
 	int			vsync_timeout;
 #ifdef CONFIG_CPU_FREQ
 	struct notifier_block	freq_transition;
+	unsigned int		lcd_fck_rate;
 #endif
 	void (*panel_power_ctrl)(int);
 };
@@ -840,11 +841,12 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
 	struct da8xx_fb_par *par;
 
 	par = container_of(nb, struct da8xx_fb_par, freq_transition);
-	if (val = CPUFREQ_PRECHANGE) {
-		lcd_disable_raster();
-	} else if (val = CPUFREQ_POSTCHANGE) {
-		lcd_calc_clk_divider(par);
-		lcd_enable_raster();
+	if (val = CPUFREQ_POSTCHANGE) {
+		if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) {
+			lcd_disable_raster();
+			lcd_calc_clk_divider(par);
+			lcd_enable_raster();
+		}
 	}
 
 	return 0;
@@ -1137,6 +1139,7 @@ static int __devinit fb_probe(struct platform_device *device)
 
 	par = da8xx_fb_info->par;
 	par->lcdc_clk = fb_clk;
+	par->lcd_fck_rate = clk_get_rate(fb_clk);
 	par->pxl_clk = lcdc_info->pxl_clk;
 	if (fb_pdata->panel_power_ctrl) {
 		par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
-- 
1.7.1

```

## Re: \[PATCH\] video: da8xx-fb: reset LCDC only if functional clock

- From: Madhvapathi Sriram \<hidden\>
- Date: 2011-12-21 10:59:01 
- Message: https://ratatoskr.run/linux-fbdev/2011/12/13462374.md

```text
Prakash,

On Wed, Dec 21, 2011 at 12:57 PM, Manjunathappa, Prakash
[ref] wrote:
>
> LCDC functional clock may or may not be derived from CPU/MPU DPLL,
> For example,
> AM335x => Separate independent DPLL for LCDC
> Davinci => Same DPLL as MPU
>
> So, on platforms where LCDC functional clock is not derived from CPU/MPU
> PLL it is not required to reset LCDC module, if CPU frequency does not
> change with DVFS.
Is it not the case that the CPU frequency always changes during DVFS?
This sentence does not strike me straight.
Did you mean that if the frequency of the PLL (from which LCDC
derives) does not change with DVFS, then LCDC module is not required
to be reset?
>
> This patch adds check to do reset only if functional clock changes
> between pre and post notifier callbacks with DVFS.
>
> Signed-off-by: Manjunathappa, Prakash <redacted>
> ---
>  drivers/video/da8xx-fb.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
> index 29577bf..1334a68 100644
> --- a/drivers/video/da8xx-fb.c
> +++ b/drivers/video/da8xx-fb.c
> @@ -161,6 +161,7 @@ struct da8xx_fb_par {
>        int                     vsync_timeout;
>  #ifdef CONFIG_CPU_FREQ
>        struct notifier_block   freq_transition;
> +       unsigned int            lcd_fck_rate;
>  #endif
>        void (*panel_power_ctrl)(int);
>  };
> @@ -840,11 +841,12 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
>        struct da8xx_fb_par *par;
>
>        par = container_of(nb, struct da8xx_fb_par, freq_transition);
> -       if (val = CPUFREQ_PRECHANGE) {
> -               lcd_disable_raster();
> -       } else if (val = CPUFREQ_POSTCHANGE) {
> -               lcd_calc_clk_divider(par);
> -               lcd_enable_raster();
> +       if (val = CPUFREQ_POSTCHANGE) {
> +               if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) {
> +                       lcd_disable_raster();
> +                       lcd_calc_clk_divider(par);
> +                       lcd_enable_raster();
> +               }
>        }
>
>        return 0;
> @@ -1137,6 +1139,7 @@ static int __devinit fb_probe(struct platform_device *device)
>
>        par = da8xx_fb_info->par;
>        par->lcdc_clk = fb_clk;
> +       par->lcd_fck_rate = clk_get_rate(fb_clk);
>        par->pxl_clk = lcdc_info->pxl_clk;
>        if (fb_pdata->panel_power_ctrl) {
>                par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
> --
> 1.7.1
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> Davinci-linux-open-source@linux.davincidsp.com
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
```

## RE: \[PATCH\] video: da8xx-fb: reset LCDC only if functional clock

- From: Manjunathappa, Prakash \<hidden\>
- Date: 2011-12-21 11:11:57 
- Message: https://ratatoskr.run/linux-fbdev/2011/12/13462375.md

```text
Hi Sriram,

On Wed, Dec 21, 2011 at 16:17:01, Madhvapathi Sriram wrote:
> Prakash,
> 
> On Wed, Dec 21, 2011 at 12:57 PM, Manjunathappa, Prakash
> [ref] wrote:
> >
> > LCDC functional clock may or may not be derived from CPU/MPU DPLL,
> > For example,
> > AM335x => Separate independent DPLL for LCDC
> > Davinci => Same DPLL as MPU
> >
> > So, on platforms where LCDC functional clock is not derived from CPU/MPU
> > PLL it is not required to reset LCDC module, if CPU frequency does not
> > change with DVFS.
> Is it not the case that the CPU frequency always changes during DVFS?
> This sentence does not strike me straight.
> Did you mean that if the frequency of the PLL (from which LCDC
> derives) does not change with DVFS, then LCDC module is not required
> to be reset?

Ok I will re-phrase it as below:
So, on platforms where LCDC functional clock is not derived from CPU/MPU
PLL it is not required to reset LCDC module as its functional clock does not change with DVFS.
 
> >
> > This patch adds check to do reset only if functional clock changes
> > between pre and post notifier callbacks with DVFS.
> >
> > Signed-off-by: Manjunathappa, Prakash <redacted>
> > ---
> >  drivers/video/da8xx-fb.c |   13 ++++++++-----
> >  1 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
> > index 29577bf..1334a68 100644
> > --- a/drivers/video/da8xx-fb.c
> > +++ b/drivers/video/da8xx-fb.c
> > @@ -161,6 +161,7 @@ struct da8xx_fb_par {
> >        int                     vsync_timeout;
> >  #ifdef CONFIG_CPU_FREQ
> >        struct notifier_block   freq_transition;
> > +       unsigned int            lcd_fck_rate;
> >  #endif
> >        void (*panel_power_ctrl)(int);
> >  };
> > @@ -840,11 +841,12 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
> >        struct da8xx_fb_par *par;
> >
> >        par = container_of(nb, struct da8xx_fb_par, freq_transition);
> > -       if (val = CPUFREQ_PRECHANGE) {
> > -               lcd_disable_raster();
> > -       } else if (val = CPUFREQ_POSTCHANGE) {
> > -               lcd_calc_clk_divider(par);
> > -               lcd_enable_raster();
> > +       if (val = CPUFREQ_POSTCHANGE) {
> > +               if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) {
> > +                       lcd_disable_raster();
> > +                       lcd_calc_clk_divider(par);
> > +                       lcd_enable_raster();
> > +               }
> >        }
> >
> >        return 0;
> > @@ -1137,6 +1139,7 @@ static int __devinit fb_probe(struct platform_device *device)
> >
> >        par = da8xx_fb_info->par;
> >        par->lcdc_clk = fb_clk;
> > +       par->lcd_fck_rate = clk_get_rate(fb_clk);
> >        par->pxl_clk = lcdc_info->pxl_clk;
> >        if (fb_pdata->panel_power_ctrl) {
> >                par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
> > --
> > 1.7.1
> >
> > _______________________________________________
> > Davinci-linux-open-source mailing list
> > Davinci-linux-open-source@linux.davincidsp.com
> > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
> 

```
