aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2014-12-03 12:36:53 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-12-05 11:30:25 -0500
commit23834a4116cd468d62e1092234e46ec1919a9e86 (patch)
tree63657bb4d48931f4d665323e19edfbe0e558cc80 /drivers/video
parent7faf6d1ab0f99c6ee2a8acb5c5ec71ffcb8a264a (diff)
ARM: 8244/1: fbdev: sa1100fb: make use of device clock
Use per-device clock (instead of calling cpufreq_get(0), which can return 0 if no cpu frequency driver is selected) to program timings. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/sa1100fb.c30
-rw-r--r--drivers/video/fbdev/sa1100fb.h1
2 files changed, 24 insertions, 7 deletions
diff --git a/drivers/video/fbdev/sa1100fb.c b/drivers/video/fbdev/sa1100fb.c
index 9690216d38ff..c0abe276ee55 100644
--- a/drivers/video/fbdev/sa1100fb.c
+++ b/drivers/video/fbdev/sa1100fb.c
@@ -178,6 +178,7 @@
178#include <linux/dma-mapping.h> 178#include <linux/dma-mapping.h>
179#include <linux/mutex.h> 179#include <linux/mutex.h>
180#include <linux/io.h> 180#include <linux/io.h>
181#include <linux/clk.h>
181 182
182#include <video/sa1100fb.h> 183#include <video/sa1100fb.h>
183 184
@@ -416,9 +417,9 @@ sa1100fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
416 var->transp.offset); 417 var->transp.offset);
417 418
418#ifdef CONFIG_CPU_FREQ 419#ifdef CONFIG_CPU_FREQ
419 dev_dbg(fbi->dev, "dma period = %d ps, clock = %d kHz\n", 420 dev_dbg(fbi->dev, "dma period = %d ps, clock = %ld kHz\n",
420 sa1100fb_display_dma_period(var), 421 sa1100fb_display_dma_period(var),
421 cpufreq_get(smp_processor_id())); 422 clk_get_rate(fbi->clk) / 1000);
422#endif 423#endif
423 424
424 return 0; 425 return 0;
@@ -592,9 +593,10 @@ static struct fb_ops sa1100fb_ops = {
592 * Calculate the PCD value from the clock rate (in picoseconds). 593 * Calculate the PCD value from the clock rate (in picoseconds).
593 * We take account of the PPCR clock setting. 594 * We take account of the PPCR clock setting.
594 */ 595 */
595static inline unsigned int get_pcd(unsigned int pixclock, unsigned int cpuclock) 596static inline unsigned int get_pcd(struct sa1100fb_info *fbi,
597 unsigned int pixclock)
596{ 598{
597 unsigned int pcd = cpuclock / 100; 599 unsigned int pcd = clk_get_rate(fbi->clk) / 100 / 1000;
598 600
599 pcd *= pixclock; 601 pcd *= pixclock;
600 pcd /= 10000000; 602 pcd /= 10000000;
@@ -673,7 +675,7 @@ static int sa1100fb_activate_var(struct fb_var_screeninfo *var, struct sa1100fb_
673 LCCR2_BegFrmDel(var->upper_margin) + 675 LCCR2_BegFrmDel(var->upper_margin) +
674 LCCR2_EndFrmDel(var->lower_margin); 676 LCCR2_EndFrmDel(var->lower_margin);
675 677
676 pcd = get_pcd(var->pixclock, cpufreq_get(0)); 678 pcd = get_pcd(fbi, var->pixclock);
677 new_regs.lccr3 = LCCR3_PixClkDiv(pcd) | fbi->inf->lccr3 | 679 new_regs.lccr3 = LCCR3_PixClkDiv(pcd) | fbi->inf->lccr3 |
678 (var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) | 680 (var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) |
679 (var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL); 681 (var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL);
@@ -787,6 +789,9 @@ static void sa1100fb_enable_controller(struct sa1100fb_info *fbi)
787 fbi->palette_cpu[0] &= 0xcfff; 789 fbi->palette_cpu[0] &= 0xcfff;
788 fbi->palette_cpu[0] |= palette_pbs(&fbi->fb.var); 790 fbi->palette_cpu[0] |= palette_pbs(&fbi->fb.var);
789 791
792 /* enable LCD controller clock */
793 clk_prepare_enable(fbi->clk);
794
790 /* Sequence from 11.7.10 */ 795 /* Sequence from 11.7.10 */
791 writel_relaxed(fbi->reg_lccr3, fbi->base + LCCR3); 796 writel_relaxed(fbi->reg_lccr3, fbi->base + LCCR3);
792 writel_relaxed(fbi->reg_lccr2, fbi->base + LCCR2); 797 writel_relaxed(fbi->reg_lccr2, fbi->base + LCCR2);
@@ -831,6 +836,9 @@ static void sa1100fb_disable_controller(struct sa1100fb_info *fbi)
831 836
832 schedule_timeout(20 * HZ / 1000); 837 schedule_timeout(20 * HZ / 1000);
833 remove_wait_queue(&fbi->ctrlr_wait, &wait); 838 remove_wait_queue(&fbi->ctrlr_wait, &wait);
839
840 /* disable LCD controller clock */
841 clk_disable_unprepare(fbi->clk);
834} 842}
835 843
836/* 844/*
@@ -1009,7 +1017,6 @@ sa1100fb_freq_transition(struct notifier_block *nb, unsigned long val,
1009 void *data) 1017 void *data)
1010{ 1018{
1011 struct sa1100fb_info *fbi = TO_INF(nb, freq_transition); 1019 struct sa1100fb_info *fbi = TO_INF(nb, freq_transition);
1012 struct cpufreq_freqs *f = data;
1013 u_int pcd; 1020 u_int pcd;
1014 1021
1015 switch (val) { 1022 switch (val) {
@@ -1018,7 +1025,7 @@ sa1100fb_freq_transition(struct notifier_block *nb, unsigned long val,
1018 break; 1025 break;
1019 1026
1020 case CPUFREQ_POSTCHANGE: 1027 case CPUFREQ_POSTCHANGE:
1021 pcd = get_pcd(fbi->fb.var.pixclock, f->new); 1028 pcd = get_pcd(fbi, fbi->fb.var.pixclock);
1022 fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd); 1029 fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd);
1023 set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE); 1030 set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE);
1024 break; 1031 break;
@@ -1225,6 +1232,13 @@ static int sa1100fb_probe(struct platform_device *pdev)
1225 if (!fbi) 1232 if (!fbi)
1226 goto failed; 1233 goto failed;
1227 1234
1235 fbi->clk = clk_get(&pdev->dev, NULL);
1236 if (IS_ERR(fbi->clk)) {
1237 ret = PTR_ERR(fbi->clk);
1238 fbi->clk = NULL;
1239 goto failed;
1240 }
1241
1228 fbi->base = ioremap(res->start, resource_size(res)); 1242 fbi->base = ioremap(res->start, resource_size(res));
1229 if (!fbi->base) 1243 if (!fbi->base)
1230 goto failed; 1244 goto failed;
@@ -1277,6 +1291,8 @@ static int sa1100fb_probe(struct platform_device *pdev)
1277 failed: 1291 failed:
1278 if (fbi) 1292 if (fbi)
1279 iounmap(fbi->base); 1293 iounmap(fbi->base);
1294 if (fbi->clk)
1295 clk_put(fbi->clk);
1280 kfree(fbi); 1296 kfree(fbi);
1281 release_mem_region(res->start, resource_size(res)); 1297 release_mem_region(res->start, resource_size(res));
1282 return ret; 1298 return ret;
diff --git a/drivers/video/fbdev/sa1100fb.h b/drivers/video/fbdev/sa1100fb.h
index fc5d4292fad6..0139d13377a5 100644
--- a/drivers/video/fbdev/sa1100fb.h
+++ b/drivers/video/fbdev/sa1100fb.h
@@ -68,6 +68,7 @@ struct sa1100fb_info {
68#endif 68#endif
69 69
70 const struct sa1100fb_mach_info *inf; 70 const struct sa1100fb_mach_info *inf;
71 struct clk *clk;
71}; 72};
72 73
73#define TO_INF(ptr,member) container_of(ptr,struct sa1100fb_info,member) 74#define TO_INF(ptr,member) container_of(ptr,struct sa1100fb_info,member)