aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2014-12-03 12:35:29 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-12-05 11:30:23 -0500
commit4faee128843c7c1c9a8af83ea300cc3f1cc83da0 (patch)
tree2da73c62aa58af31c8b972444deffbab003b68db
parentab71f99fd70b3ff6f74928612778f553836fb1c0 (diff)
ARM: 8242/1: sa1100: add cpu clock
Both SA1100 framebuffer and PCMCIA drivers require knowledge of cpu frequency to correctly program timings. Currently they receive timing information by calling cpufreq_get(0). However if cpu frequency driver is not enabled (e.g. due to unsupported DRAM chip/board on sa1110) cpufreq_get(0) returns 0, causing incorrect timings to be programmed. Add cpu clock returning cpu frequency, to be used by sa11x0 fb and pcmcia drivers. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-sa1100/clock.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
index 9fa6a990cf03..53f750d8b940 100644
--- a/arch/arm/mach-sa1100/clock.c
+++ b/arch/arm/mach-sa1100/clock.c
@@ -15,10 +15,12 @@
15#include <linux/clkdev.h> 15#include <linux/clkdev.h>
16 16
17#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <mach/generic.h>
18 19
19struct clkops { 20struct clkops {
20 void (*enable)(struct clk *); 21 void (*enable)(struct clk *);
21 void (*disable)(struct clk *); 22 void (*disable)(struct clk *);
23 unsigned long (*get_rate)(struct clk *);
22}; 24};
23 25
24struct clk { 26struct clk {
@@ -33,13 +35,6 @@ struct clk clk_##_name = { \
33 35
34static DEFINE_SPINLOCK(clocks_lock); 36static DEFINE_SPINLOCK(clocks_lock);
35 37
36/* Dummy clk routine to build generic kernel parts that may be using them */
37unsigned long clk_get_rate(struct clk *clk)
38{
39 return 0;
40}
41EXPORT_SYMBOL(clk_get_rate);
42
43static void clk_gpio27_enable(struct clk *clk) 38static void clk_gpio27_enable(struct clk *clk)
44{ 39{
45 /* 40 /*
@@ -58,6 +53,19 @@ static void clk_gpio27_disable(struct clk *clk)
58 GAFR &= ~GPIO_32_768kHz; 53 GAFR &= ~GPIO_32_768kHz;
59} 54}
60 55
56static void clk_cpu_enable(struct clk *clk)
57{
58}
59
60static void clk_cpu_disable(struct clk *clk)
61{
62}
63
64static unsigned long clk_cpu_get_rate(struct clk *clk)
65{
66 return sa11x0_getspeed(0) * 1000;
67}
68
61int clk_enable(struct clk *clk) 69int clk_enable(struct clk *clk)
62{ 70{
63 unsigned long flags; 71 unsigned long flags;
@@ -87,16 +95,35 @@ void clk_disable(struct clk *clk)
87} 95}
88EXPORT_SYMBOL(clk_disable); 96EXPORT_SYMBOL(clk_disable);
89 97
98unsigned long clk_get_rate(struct clk *clk)
99{
100 if (clk && clk->ops && clk->ops->get_rate)
101 return clk->ops->get_rate(clk);
102
103 return 0;
104}
105EXPORT_SYMBOL(clk_get_rate);
106
90const struct clkops clk_gpio27_ops = { 107const struct clkops clk_gpio27_ops = {
91 .enable = clk_gpio27_enable, 108 .enable = clk_gpio27_enable,
92 .disable = clk_gpio27_disable, 109 .disable = clk_gpio27_disable,
93}; 110};
94 111
112const struct clkops clk_cpu_ops = {
113 .enable = clk_cpu_enable,
114 .disable = clk_cpu_disable,
115 .get_rate = clk_cpu_get_rate,
116};
117
95static DEFINE_CLK(gpio27, &clk_gpio27_ops); 118static DEFINE_CLK(gpio27, &clk_gpio27_ops);
96 119
120static DEFINE_CLK(cpu, &clk_cpu_ops);
121
97static struct clk_lookup sa11xx_clkregs[] = { 122static struct clk_lookup sa11xx_clkregs[] = {
98 CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27), 123 CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27),
99 CLKDEV_INIT("sa1100-rtc", NULL, NULL), 124 CLKDEV_INIT("sa1100-rtc", NULL, NULL),
125 CLKDEV_INIT("sa11x0-fb", NULL, &clk_cpu),
126 CLKDEV_INIT("sa11x0-pcmcia", NULL, &clk_cpu),
100}; 127};
101 128
102static int __init sa11xx_clk_init(void) 129static int __init sa11xx_clk_init(void)