From 8f3a71ed80cc045909fd985b54b00b61349020f5 Mon Sep 17 00:00:00 2001 From: cym Date: Sat, 10 Aug 2013 15:55:01 +0800 Subject: [PATCH] RK3168/RK3188:add preread ddr_freq_t.screen_ft_us/t0 when define DDR_CHANGE_FREQ_IN_LCDC_VSYNC,and add test_count maximum limit --- arch/arm/mach-rk30/ddr.c | 11 ++++++++--- arch/arm/plat-rk/ddr_freq.c | 11 ++++++++--- drivers/video/rockchip/rk_fb.c | 2 +- include/linux/rk_fb.h | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-rk30/ddr.c b/arch/arm/mach-rk30/ddr.c index 89b2a3d05b0d..f327f0d1e517 100755 --- a/arch/arm/mach-rk30/ddr.c +++ b/arch/arm/mach-rk30/ddr.c @@ -3190,12 +3190,17 @@ uint32_t __sramfunc ddr_change_freq_sram(uint32_t nMHz , struct ddr_freq_t ddr_f dsb(); #if defined (DDR_CHANGE_FREQ_IN_LCDC_VSYNC) + n = ddr_freq_t.screen_ft_us; + n = ddr_freq_t.t0; + dsb(); + if(ddr_freq_t.screen_ft_us > 0) { ddr_freq_t.t1 = cpu_clock(0); - ddr_freq_t.t2 = (u32)(ddr_freq_t.t1 - ddr_freq_t.t0)/1000; + ddr_freq_t.t2 = (u32)(ddr_freq_t.t1 - ddr_freq_t.t0); //ns - if(ddr_freq_t.t2 > ddr_freq_t.screen_ft_us) + //if test_count exceed maximum test times,ddr_freq_t.screen_ft_us == 0xfefefefe by ddr_freq.c + if( (ddr_freq_t.t2 > ddr_freq_t.screen_ft_us*1000) && (ddr_freq_t.screen_ft_us != 0xfefefefe)) { DDR_RESTORE_SP(save_sp); local_fiq_enable(); @@ -3550,7 +3555,7 @@ int ddr_init(uint32_t dram_speed_bin, uint32_t freq) uint32_t die=1; uint32_t gsr,dqstr; - ddr_print("version 1.00 201300806 \n"); + ddr_print("version 1.00 201300810 \n"); mem_type = pPHY_Reg->DCR.b.DDRMD; ddr_speed_bin = dram_speed_bin; diff --git a/arch/arm/plat-rk/ddr_freq.c b/arch/arm/plat-rk/ddr_freq.c index a431d7563396..9de24f7b1228 100755 --- a/arch/arm/plat-rk/ddr_freq.c +++ b/arch/arm/plat-rk/ddr_freq.c @@ -194,7 +194,7 @@ static int _ddr_change_freq_(uint32_t nMHz,struct ddr_freq_t ddr_freq_t) u32 timeout = MAX_TIMEOUT; unsigned int cpu; unsigned int this_cpu = smp_processor_id(); - int ret; + int ret = 0; cpu_maps_update_begin(); @@ -242,7 +242,12 @@ static void _ddr_change_freq(uint32_t nMHz) ddr_freq_t.screen_ft_us = rk_fb_get_prmry_screen_ft(); test_count++; - //dprintk(DEBUG_VERBOSE,"test_count=%d\n",test_count); + if(test_count > 10) //test 10 times + { + ddr_freq_t.screen_ft_us = 0xfefefefe; + dprintk(DEBUG_DDR,"%s:test_count exceed maximum!\n",__func__); + } + dprintk(DEBUG_VERBOSE,"%s:test_count=%d\n",__func__,test_count); usleep_range(ddr_freq_t.screen_ft_us-test_count*1000,ddr_freq_t.screen_ft_us-test_count*1000); flush_cache_all(); @@ -628,7 +633,7 @@ static int ddrfreq_late_init(void) register_reboot_notifier(&ddrfreq_reboot_notifier); - pr_info("verion 3.1 20130805 1\n"); + pr_info("verion 3.1 20130810\n"); dprintk(DEBUG_DDR, "normal %luMHz video %luMHz video_low %luMHz dualview %luMHz idle %luMHz suspend %luMHz reboot %luMHz\n", ddr.normal_rate / MHZ, ddr.video_rate / MHZ, ddr.video_low_rate / MHZ, ddr.dualview_rate / MHZ, ddr.idle_rate / MHZ, ddr.suspend_rate / MHZ, ddr.reboot_rate / MHZ); diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 11e10afc7d27..5d509b100fb8 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -217,7 +217,7 @@ int rk_fb_poll_prmry_screen_vblank(void) bool rk_fb_poll_wait_frame_complete(void) { - uint32_t timeout = MAX_TIMEOUT; + uint32_t timeout = RK_LF_MAX_TIMEOUT; if(rk_fb_poll_prmry_screen_vblank() == RK_LF_STATUS_NC) return false; diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index 179e9c1cc84a..335e684f1d21 100755 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -66,7 +66,7 @@ #define RK_LF_STATUS_FC 0xef #define RK_LF_STATUS_FR 0xee #define RK_LF_STATUS_NC 0xfe -#define MAX_TIMEOUT (1600000UL << 6) //>0.64s +#define RK_LF_MAX_TIMEOUT (1600000UL << 6) //>0.64s extern int rk_fb_poll_prmry_screen_vblank(void); -- 2.34.1