diff options
author | Ranjani Vaidyanathan-RA5478 <Ranjani.Vaidyanathan@freescale.com> | 2009-12-10 14:43:56 -0600 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-02-12 17:19:45 +0100 |
commit | 9ba449e22ef33129d1d2e82c30cfcccb922ffc96 (patch) | |
tree | 5771734209da6c8a9297feb24804f2fce7342183 /drivers/mxc/ipu3 | |
parent | 6bf49f588ac3cfd943bd4bf305bc4949240dfb98 (diff) |
ENGR00119202: Fix DVFS-PER related bugs.
DVFS-PER needs to make sure that the pixel clock divider is an
even integer.
Added support for pixel clock being sourced from an external clock (PLL3)
Signed-off-by: Ranjani Vaidyanathan-RA5478 <Ranjani.Vaidyanathan@freescale.com>
Diffstat (limited to 'drivers/mxc/ipu3')
-rw-r--r-- | drivers/mxc/ipu3/ipu_common.c | 39 | ||||
-rw-r--r-- | drivers/mxc/ipu3/ipu_disp.c | 49 |
2 files changed, 56 insertions, 32 deletions
diff --git a/drivers/mxc/ipu3/ipu_common.c b/drivers/mxc/ipu3/ipu_common.c index c0bf870ca0a9..5d90d47e34b9 100644 --- a/drivers/mxc/ipu3/ipu_common.c +++ b/drivers/mxc/ipu3/ipu_common.c @@ -151,27 +151,27 @@ static void _ipu_pixel_clk_recalc(struct clk *clk) static unsigned long _ipu_pixel_clk_round_rate(struct clk *clk, unsigned long rate) { - u32 div; - int ipu_freq_scaling_enabled = dvfs_per_pixel_clk_limit(rate); - + u32 div, div1; + u32 tmp; /* * Calculate divider * Fractional part is 4 bits, * so simply multiply by 2^4 to get fractional part. */ - div = (clk->parent->rate * 16) / rate; + tmp = (clk->parent->rate * 16); + div = tmp / rate; + if (div < 0x10) /* Min DI disp clock divider is 1 */ div = 0x10; - /* Need an even integer divder for DVFS-PER to work */ - if (ipu_freq_scaling_enabled) { - if (div & 0x10) - div += 0x10; - /* Fractional part is rounded off to 0. */ - div &= 0xFF0; - } else - /* Only MSB fractional bit is supported. */ + if (div & ~0xFEF) div &= 0xFF8; - + else { + div1 = div & 0xFE0; + if ((tmp/div1 - tmp/div) < rate / 4) + div = div1; + else + div &= 0xFF8; + } return (clk->parent->rate * 16) / div; } @@ -196,6 +196,8 @@ static int _ipu_pixel_clk_enable(struct clk *clk) disp_gen |= clk->id ? DI1_COUNTER_RELEASE : DI0_COUNTER_RELEASE; __raw_writel(disp_gen, IPU_DISP_GEN); + start_dvfs_per(); + return 0; } @@ -204,11 +206,13 @@ static void _ipu_pixel_clk_disable(struct clk *clk) u32 disp_gen = __raw_readl(IPU_DISP_GEN); disp_gen &= clk->id ? ~DI1_COUNTER_RELEASE : ~DI0_COUNTER_RELEASE; __raw_writel(disp_gen, IPU_DISP_GEN); + + start_dvfs_per(); } static int _ipu_pixel_clk_set_parent(struct clk *clk, struct clk *parent) { - u32 di_gen = __raw_readl(DI_GENERAL(clk->id)); + u32 di_gen = 0;/*__raw_readl(DI_GENERAL(clk->id));*/ if (parent == g_ipu_clk) di_gen &= ~DI_GEN_DI_CLK_EXT; @@ -383,12 +387,6 @@ static int ipu_probe(struct platform_device *pdev) /* Set MCU_T to divide MCU access window into 2 */ __raw_writel(0x00400000L | (IPU_MCU_T_DEFAULT << 18), IPU_DISP_GEN); - /* Enable for a divide by 2 clock change. */ - reg = __raw_readl(IPU_PM); - reg &= ~(0x7f << 7); - reg |= 0x20 << 7; - __raw_writel(reg, IPU_PM); - clk_disable(g_ipu_clk); register_ipu_device(); @@ -491,6 +489,7 @@ int32_t ipu_init_channel(ipu_channel_t channel, ipu_channel_params_t *params) __raw_writel(0xFFFFFFFF, IPU_INT_CTRL(10)); if (g_ipu_clk_enabled == false) { + stop_dvfs_per(); g_ipu_clk_enabled = true; clk_enable(g_ipu_clk); } diff --git a/drivers/mxc/ipu3/ipu_disp.c b/drivers/mxc/ipu3/ipu_disp.c index 14e014edc916..1135fcbaf3c2 100644 --- a/drivers/mxc/ipu3/ipu_disp.c +++ b/drivers/mxc/ipu3/ipu_disp.c @@ -24,8 +24,10 @@ #include <linux/spinlock.h> #include <linux/io.h> #include <linux/ipu.h> +#include <linux/clk.h> #include <asm/atomic.h> #include <mach/mxc_dvfs.h> +#include <mach/clock.h> #include "ipu_prv.h" #include "ipu_regs.h" #include "ipu_param_mem.h" @@ -845,7 +847,8 @@ int32_t ipu_init_sync_panel(int disp, uint32_t pixel_clk, uint32_t div, rounded_pixel_clk; uint32_t h_total, v_total; int map; - int ipu_freq_scaling_enabled; + int ipu_freq_scaling_enabled = 0; + struct clk *di_parent; dev_dbg(g_ipu_dev, "panel size = %d x %d\n", width, height); @@ -858,21 +861,45 @@ int32_t ipu_init_sync_panel(int disp, uint32_t pixel_clk, /* Init clocking */ dev_dbg(g_ipu_dev, "pixel clk = %d\n", pixel_clk); - if (sig.ext_clk) + if (sig.ext_clk) { + /* Set the PLL to be an even multiple of the pixel clock. */ + if ((clk_get_usecount(g_pixel_clk[0]) == 0) && + (clk_get_usecount(g_pixel_clk[1]) == 0)) { + di_parent = clk_get_parent(g_di_clk[disp]); + rounded_pixel_clk = + clk_round_rate(g_pixel_clk[disp], pixel_clk); + div = clk_get_rate(di_parent) / rounded_pixel_clk; + if (div % 2) + div++; + + if (clk_get_rate(di_parent) != div * rounded_pixel_clk) + clk_set_rate(di_parent, div * rounded_pixel_clk); + msleep(10); + clk_set_rate(g_di_clk[disp], 2 * rounded_pixel_clk); + msleep(10); + } clk_set_parent(g_pixel_clk[disp], g_di_clk[disp]); - else - clk_set_parent(g_pixel_clk[disp], g_ipu_clk); - - stop_dvfs_per(); - + } else { + if (clk_get_usecount(g_pixel_clk[disp]) != 0) + clk_set_parent(g_pixel_clk[disp], g_ipu_clk); + } rounded_pixel_clk = clk_round_rate(g_pixel_clk[disp], pixel_clk); clk_set_rate(g_pixel_clk[disp], rounded_pixel_clk); - - ipu_freq_scaling_enabled = dvfs_per_pixel_clk_limit(rounded_pixel_clk); - + msleep(5); /* Get integer portion of divider */ div = clk_get_rate(clk_get_parent(g_pixel_clk[disp])) / rounded_pixel_clk; + ipu_freq_scaling_enabled = dvfs_per_pixel_clk_limit(); + + if (ipu_freq_scaling_enabled) { + /* Enable for a divide by 2 clock change. */ + reg = __raw_readl(IPU_PM); + reg &= ~(0x7f << 7); + reg |= 0x20 << 7; + reg &= ~(0x7f << 23); + reg |= 0x20 << 23; + __raw_writel(reg, IPU_PM); + } spin_lock_irqsave(&ipu_lock, lock_flags); _ipu_di_data_wave_config(disp, SYNC_WAVE, div - 1, div - 1); @@ -1236,8 +1263,6 @@ int32_t ipu_init_sync_panel(int disp, uint32_t pixel_clk, spin_unlock_irqrestore(&ipu_lock, lock_flags); - start_dvfs_per(); - return 0; } EXPORT_SYMBOL(ipu_init_sync_panel); |