aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-19 08:39:58 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-19 08:39:58 -0400
commit14b6848bc0134b8838d374c423df3edda9b1490e (patch)
tree724dc912efe84f432d33a798502811c5f5295774 /arch/arm/plat-omap
parent05d9881bc4c6f172997b7a59e4a1a95910c4ebd7 (diff)
parent4da3782151300237db3abe070f716922889252e0 (diff)
Merge branch 'omap-clks3' into devel
Conflicts: arch/arm/mach-omap2/clock.c
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/Kconfig3
-rw-r--r--arch/arm/plat-omap/clock.c198
-rw-r--r--arch/arm/plat-omap/common.c2
-rw-r--r--arch/arm/plat-omap/cpu-omap.c57
-rw-r--r--arch/arm/plat-omap/include/mach/clkdev.h13
-rw-r--r--arch/arm/plat-omap/include/mach/clock.h80
-rw-r--r--arch/arm/plat-omap/include/mach/clockdomain.h24
-rw-r--r--arch/arm/plat-omap/include/mach/common.h2
-rw-r--r--arch/arm/plat-omap/include/mach/cpu.h26
-rw-r--r--arch/arm/plat-omap/include/mach/gpmc.h2
-rw-r--r--arch/arm/plat-omap/include/mach/io.h4
-rw-r--r--arch/arm/plat-omap/include/mach/mcbsp.h6
-rw-r--r--arch/arm/plat-omap/include/mach/pm.h12
-rw-r--r--arch/arm/plat-omap/include/mach/powerdomain.h5
-rw-r--r--arch/arm/plat-omap/include/mach/prcm.h5
-rw-r--r--arch/arm/plat-omap/include/mach/sdrc.h64
-rw-r--r--arch/arm/plat-omap/include/mach/system.h4
-rw-r--r--arch/arm/plat-omap/mcbsp.c90
18 files changed, 326 insertions, 271 deletions
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 46d3b0b9ce69..e25e1ac64fc1 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,14 +11,17 @@ choice
11 11
12config ARCH_OMAP1 12config ARCH_OMAP1
13 bool "TI OMAP1" 13 bool "TI OMAP1"
14 select COMMON_CLKDEV
14 15
15config ARCH_OMAP2 16config ARCH_OMAP2
16 bool "TI OMAP2" 17 bool "TI OMAP2"
17 select CPU_V6 18 select CPU_V6
19 select COMMON_CLKDEV
18 20
19config ARCH_OMAP3 21config ARCH_OMAP3
20 bool "TI OMAP3" 22 bool "TI OMAP3"
21 select CPU_V7 23 select CPU_V7
24 select COMMON_CLKDEV
22 25
23endchoice 26endchoice
24 27
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index be6aab9c6834..2e0614552ac8 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -36,44 +36,6 @@ static struct clk_functions *arch_clock;
36 * Standard clock functions defined in include/linux/clk.h 36 * Standard clock functions defined in include/linux/clk.h
37 *-------------------------------------------------------------------------*/ 37 *-------------------------------------------------------------------------*/
38 38
39/*
40 * Returns a clock. Note that we first try to use device id on the bus
41 * and clock name. If this fails, we try to use clock name only.
42 */
43struct clk * clk_get(struct device *dev, const char *id)
44{
45 struct clk *p, *clk = ERR_PTR(-ENOENT);
46 int idno;
47
48 if (dev == NULL || dev->bus != &platform_bus_type)
49 idno = -1;
50 else
51 idno = to_platform_device(dev)->id;
52
53 mutex_lock(&clocks_mutex);
54
55 list_for_each_entry(p, &clocks, node) {
56 if (p->id == idno &&
57 strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
58 clk = p;
59 goto found;
60 }
61 }
62
63 list_for_each_entry(p, &clocks, node) {
64 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
65 clk = p;
66 break;
67 }
68 }
69
70found:
71 mutex_unlock(&clocks_mutex);
72
73 return clk;
74}
75EXPORT_SYMBOL(clk_get);
76
77int clk_enable(struct clk *clk) 39int clk_enable(struct clk *clk)
78{ 40{
79 unsigned long flags; 41 unsigned long flags;
@@ -114,22 +76,6 @@ out:
114} 76}
115EXPORT_SYMBOL(clk_disable); 77EXPORT_SYMBOL(clk_disable);
116 78
117int clk_get_usecount(struct clk *clk)
118{
119 unsigned long flags;
120 int ret = 0;
121
122 if (clk == NULL || IS_ERR(clk))
123 return 0;
124
125 spin_lock_irqsave(&clockfw_lock, flags);
126 ret = clk->usecount;
127 spin_unlock_irqrestore(&clockfw_lock, flags);
128
129 return ret;
130}
131EXPORT_SYMBOL(clk_get_usecount);
132
133unsigned long clk_get_rate(struct clk *clk) 79unsigned long clk_get_rate(struct clk *clk)
134{ 80{
135 unsigned long flags; 81 unsigned long flags;
@@ -146,13 +92,6 @@ unsigned long clk_get_rate(struct clk *clk)
146} 92}
147EXPORT_SYMBOL(clk_get_rate); 93EXPORT_SYMBOL(clk_get_rate);
148 94
149void clk_put(struct clk *clk)
150{
151 if (clk && !IS_ERR(clk))
152 module_put(clk->owner);
153}
154EXPORT_SYMBOL(clk_put);
155
156/*------------------------------------------------------------------------- 95/*-------------------------------------------------------------------------
157 * Optional clock functions defined in include/linux/clk.h 96 * Optional clock functions defined in include/linux/clk.h
158 *-------------------------------------------------------------------------*/ 97 *-------------------------------------------------------------------------*/
@@ -185,6 +124,11 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
185 spin_lock_irqsave(&clockfw_lock, flags); 124 spin_lock_irqsave(&clockfw_lock, flags);
186 if (arch_clock->clk_set_rate) 125 if (arch_clock->clk_set_rate)
187 ret = arch_clock->clk_set_rate(clk, rate); 126 ret = arch_clock->clk_set_rate(clk, rate);
127 if (ret == 0) {
128 if (clk->recalc)
129 clk->rate = clk->recalc(clk);
130 propagate_rate(clk);
131 }
188 spin_unlock_irqrestore(&clockfw_lock, flags); 132 spin_unlock_irqrestore(&clockfw_lock, flags);
189 133
190 return ret; 134 return ret;
@@ -200,8 +144,16 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
200 return ret; 144 return ret;
201 145
202 spin_lock_irqsave(&clockfw_lock, flags); 146 spin_lock_irqsave(&clockfw_lock, flags);
203 if (arch_clock->clk_set_parent) 147 if (clk->usecount == 0) {
204 ret = arch_clock->clk_set_parent(clk, parent); 148 if (arch_clock->clk_set_parent)
149 ret = arch_clock->clk_set_parent(clk, parent);
150 if (ret == 0) {
151 if (clk->recalc)
152 clk->rate = clk->recalc(clk);
153 propagate_rate(clk);
154 }
155 } else
156 ret = -EBUSY;
205 spin_unlock_irqrestore(&clockfw_lock, flags); 157 spin_unlock_irqrestore(&clockfw_lock, flags);
206 158
207 return ret; 159 return ret;
@@ -210,18 +162,7 @@ EXPORT_SYMBOL(clk_set_parent);
210 162
211struct clk *clk_get_parent(struct clk *clk) 163struct clk *clk_get_parent(struct clk *clk)
212{ 164{
213 unsigned long flags; 165 return clk->parent;
214 struct clk * ret = NULL;
215
216 if (clk == NULL || IS_ERR(clk))
217 return ret;
218
219 spin_lock_irqsave(&clockfw_lock, flags);
220 if (arch_clock->clk_get_parent)
221 ret = arch_clock->clk_get_parent(clk);
222 spin_unlock_irqrestore(&clockfw_lock, flags);
223
224 return ret;
225} 166}
226EXPORT_SYMBOL(clk_get_parent); 167EXPORT_SYMBOL(clk_get_parent);
227 168
@@ -250,14 +191,20 @@ static int __init omap_clk_setup(char *str)
250__setup("mpurate=", omap_clk_setup); 191__setup("mpurate=", omap_clk_setup);
251 192
252/* Used for clocks that always have same value as the parent clock */ 193/* Used for clocks that always have same value as the parent clock */
253void followparent_recalc(struct clk *clk) 194unsigned long followparent_recalc(struct clk *clk)
254{ 195{
255 if (clk == NULL || IS_ERR(clk)) 196 return clk->parent->rate;
256 return; 197}
257 198
258 clk->rate = clk->parent->rate; 199void clk_reparent(struct clk *child, struct clk *parent)
259 if (unlikely(clk->flags & RATE_PROPAGATES)) 200{
260 propagate_rate(clk); 201 list_del_init(&child->sibling);
202 if (parent)
203 list_add(&child->sibling, &parent->children);
204 child->parent = parent;
205
206 /* now do the debugfs renaming to reattach the child
207 to the proper parent */
261} 208}
262 209
263/* Propagate rate to children */ 210/* Propagate rate to children */
@@ -265,17 +212,15 @@ void propagate_rate(struct clk * tclk)
265{ 212{
266 struct clk *clkp; 213 struct clk *clkp;
267 214
268 if (tclk == NULL || IS_ERR(tclk)) 215 list_for_each_entry(clkp, &tclk->children, sibling) {
269 return; 216 if (clkp->recalc)
270 217 clkp->rate = clkp->recalc(clkp);
271 list_for_each_entry(clkp, &clocks, node) { 218 propagate_rate(clkp);
272 if (likely(clkp->parent != tclk))
273 continue;
274 if (likely((u32)clkp->recalc))
275 clkp->recalc(clkp);
276 } 219 }
277} 220}
278 221
222static LIST_HEAD(root_clks);
223
279/** 224/**
280 * recalculate_root_clocks - recalculate and propagate all root clocks 225 * recalculate_root_clocks - recalculate and propagate all root clocks
281 * 226 *
@@ -287,18 +232,35 @@ void recalculate_root_clocks(void)
287{ 232{
288 struct clk *clkp; 233 struct clk *clkp;
289 234
290 list_for_each_entry(clkp, &clocks, node) { 235 list_for_each_entry(clkp, &root_clks, sibling) {
291 if (unlikely(!clkp->parent) && likely((u32)clkp->recalc)) 236 if (clkp->recalc)
292 clkp->recalc(clkp); 237 clkp->rate = clkp->recalc(clkp);
238 propagate_rate(clkp);
293 } 239 }
294} 240}
295 241
242void clk_init_one(struct clk *clk)
243{
244 INIT_LIST_HEAD(&clk->children);
245}
246
296int clk_register(struct clk *clk) 247int clk_register(struct clk *clk)
297{ 248{
298 if (clk == NULL || IS_ERR(clk)) 249 if (clk == NULL || IS_ERR(clk))
299 return -EINVAL; 250 return -EINVAL;
300 251
252 /*
253 * trap out already registered clocks
254 */
255 if (clk->node.next || clk->node.prev)
256 return 0;
257
301 mutex_lock(&clocks_mutex); 258 mutex_lock(&clocks_mutex);
259 if (clk->parent)
260 list_add(&clk->sibling, &clk->parent->children);
261 else
262 list_add(&clk->sibling, &root_clks);
263
302 list_add(&clk->node, &clocks); 264 list_add(&clk->node, &clocks);
303 if (clk->init) 265 if (clk->init)
304 clk->init(clk); 266 clk->init(clk);
@@ -314,39 +276,12 @@ void clk_unregister(struct clk *clk)
314 return; 276 return;
315 277
316 mutex_lock(&clocks_mutex); 278 mutex_lock(&clocks_mutex);
279 list_del(&clk->sibling);
317 list_del(&clk->node); 280 list_del(&clk->node);
318 mutex_unlock(&clocks_mutex); 281 mutex_unlock(&clocks_mutex);
319} 282}
320EXPORT_SYMBOL(clk_unregister); 283EXPORT_SYMBOL(clk_unregister);
321 284
322void clk_deny_idle(struct clk *clk)
323{
324 unsigned long flags;
325
326 if (clk == NULL || IS_ERR(clk))
327 return;
328
329 spin_lock_irqsave(&clockfw_lock, flags);
330 if (arch_clock->clk_deny_idle)
331 arch_clock->clk_deny_idle(clk);
332 spin_unlock_irqrestore(&clockfw_lock, flags);
333}
334EXPORT_SYMBOL(clk_deny_idle);
335
336void clk_allow_idle(struct clk *clk)
337{
338 unsigned long flags;
339
340 if (clk == NULL || IS_ERR(clk))
341 return;
342
343 spin_lock_irqsave(&clockfw_lock, flags);
344 if (arch_clock->clk_allow_idle)
345 arch_clock->clk_allow_idle(clk);
346 spin_unlock_irqrestore(&clockfw_lock, flags);
347}
348EXPORT_SYMBOL(clk_allow_idle);
349
350void clk_enable_init_clocks(void) 285void clk_enable_init_clocks(void)
351{ 286{
352 struct clk *clkp; 287 struct clk *clkp;
@@ -358,6 +293,23 @@ void clk_enable_init_clocks(void)
358} 293}
359EXPORT_SYMBOL(clk_enable_init_clocks); 294EXPORT_SYMBOL(clk_enable_init_clocks);
360 295
296/*
297 * Low level helpers
298 */
299static int clkll_enable_null(struct clk *clk)
300{
301 return 0;
302}
303
304static void clkll_disable_null(struct clk *clk)
305{
306}
307
308const struct clkops clkops_null = {
309 .enable = clkll_enable_null,
310 .disable = clkll_disable_null,
311};
312
361#ifdef CONFIG_CPU_FREQ 313#ifdef CONFIG_CPU_FREQ
362void clk_init_cpufreq_table(struct cpufreq_frequency_table **table) 314void clk_init_cpufreq_table(struct cpufreq_frequency_table **table)
363{ 315{
@@ -383,8 +335,10 @@ static int __init clk_disable_unused(void)
383 unsigned long flags; 335 unsigned long flags;
384 336
385 list_for_each_entry(ck, &clocks, node) { 337 list_for_each_entry(ck, &clocks, node) {
386 if (ck->usecount > 0 || (ck->flags & ALWAYS_ENABLED) || 338 if (ck->ops == &clkops_null)
387 ck->enable_reg == 0) 339 continue;
340
341 if (ck->usecount > 0 || ck->enable_reg == 0)
388 continue; 342 continue;
389 343
390 spin_lock_irqsave(&clockfw_lock, flags); 344 spin_lock_irqsave(&clockfw_lock, flags);
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 0843b8882f93..187239c054c9 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -249,7 +249,7 @@ static struct omap_globals *omap2_globals;
249static void __init __omap2_set_globals(void) 249static void __init __omap2_set_globals(void)
250{ 250{
251 omap2_set_globals_tap(omap2_globals); 251 omap2_set_globals_tap(omap2_globals);
252 omap2_set_globals_memory(omap2_globals); 252 omap2_set_globals_sdrc(omap2_globals);
253 omap2_set_globals_control(omap2_globals); 253 omap2_set_globals_control(omap2_globals);
254 omap2_set_globals_prcm(omap2_globals); 254 omap2_set_globals_prcm(omap2_globals);
255} 255}
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index b2690242a390..843e8af64066 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -23,10 +23,13 @@
23#include <linux/io.h> 23#include <linux/io.h>
24 24
25#include <mach/hardware.h> 25#include <mach/hardware.h>
26#include <mach/clock.h>
26#include <asm/system.h> 27#include <asm/system.h>
27 28
28#define VERY_HI_RATE 900000000 29#define VERY_HI_RATE 900000000
29 30
31static struct cpufreq_frequency_table *freq_table;
32
30#ifdef CONFIG_ARCH_OMAP1 33#ifdef CONFIG_ARCH_OMAP1
31#define MPU_CLK "mpu" 34#define MPU_CLK "mpu"
32#else 35#else
@@ -39,6 +42,9 @@ static struct clk *mpu_clk;
39 42
40int omap_verify_speed(struct cpufreq_policy *policy) 43int omap_verify_speed(struct cpufreq_policy *policy)
41{ 44{
45 if (freq_table)
46 return cpufreq_frequency_table_verify(policy, freq_table);
47
42 if (policy->cpu) 48 if (policy->cpu)
43 return -EINVAL; 49 return -EINVAL;
44 50
@@ -70,12 +76,26 @@ static int omap_target(struct cpufreq_policy *policy,
70 struct cpufreq_freqs freqs; 76 struct cpufreq_freqs freqs;
71 int ret = 0; 77 int ret = 0;
72 78
79 /* Ensure desired rate is within allowed range. Some govenors
80 * (ondemand) will just pass target_freq=0 to get the minimum. */
81 if (target_freq < policy->cpuinfo.min_freq)
82 target_freq = policy->cpuinfo.min_freq;
83 if (target_freq > policy->cpuinfo.max_freq)
84 target_freq = policy->cpuinfo.max_freq;
85
73 freqs.old = omap_getspeed(0); 86 freqs.old = omap_getspeed(0);
74 freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; 87 freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;
75 freqs.cpu = 0; 88 freqs.cpu = 0;
76 89
90 if (freqs.old == freqs.new)
91 return ret;
92
77 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 93 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
78 ret = clk_set_rate(mpu_clk, target_freq * 1000); 94#ifdef CONFIG_CPU_FREQ_DEBUG
95 printk(KERN_DEBUG "cpufreq-omap: transition: %u --> %u\n",
96 freqs.old, freqs.new);
97#endif
98 ret = clk_set_rate(mpu_clk, freqs.new * 1000);
79 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 99 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
80 100
81 return ret; 101 return ret;
@@ -83,16 +103,31 @@ static int omap_target(struct cpufreq_policy *policy,
83 103
84static int __init omap_cpu_init(struct cpufreq_policy *policy) 104static int __init omap_cpu_init(struct cpufreq_policy *policy)
85{ 105{
106 int result = 0;
107
86 mpu_clk = clk_get(NULL, MPU_CLK); 108 mpu_clk = clk_get(NULL, MPU_CLK);
87 if (IS_ERR(mpu_clk)) 109 if (IS_ERR(mpu_clk))
88 return PTR_ERR(mpu_clk); 110 return PTR_ERR(mpu_clk);
89 111
90 if (policy->cpu != 0) 112 if (policy->cpu != 0)
91 return -EINVAL; 113 return -EINVAL;
114
92 policy->cur = policy->min = policy->max = omap_getspeed(0); 115 policy->cur = policy->min = policy->max = omap_getspeed(0);
93 policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000; 116
94 policy->cpuinfo.max_freq = clk_round_rate(mpu_clk, VERY_HI_RATE) / 1000; 117 clk_init_cpufreq_table(&freq_table);
95 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; 118 if (freq_table) {
119 result = cpufreq_frequency_table_cpuinfo(policy, freq_table);
120 if (!result)
121 cpufreq_frequency_table_get_attr(freq_table,
122 policy->cpu);
123 } else {
124 policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
125 policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
126 VERY_HI_RATE) / 1000;
127 }
128
129 /* FIXME: what's the actual transition time? */
130 policy->cpuinfo.transition_latency = 10 * 1000 * 1000;
96 131
97 return 0; 132 return 0;
98} 133}
@@ -103,6 +138,11 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
103 return 0; 138 return 0;
104} 139}
105 140
141static struct freq_attr *omap_cpufreq_attr[] = {
142 &cpufreq_freq_attr_scaling_available_freqs,
143 NULL,
144};
145
106static struct cpufreq_driver omap_driver = { 146static struct cpufreq_driver omap_driver = {
107 .flags = CPUFREQ_STICKY, 147 .flags = CPUFREQ_STICKY,
108 .verify = omap_verify_speed, 148 .verify = omap_verify_speed,
@@ -111,6 +151,7 @@ static struct cpufreq_driver omap_driver = {
111 .init = omap_cpu_init, 151 .init = omap_cpu_init,
112 .exit = omap_cpu_exit, 152 .exit = omap_cpu_exit,
113 .name = "omap", 153 .name = "omap",
154 .attr = omap_cpufreq_attr,
114}; 155};
115 156
116static int __init omap_cpufreq_init(void) 157static int __init omap_cpufreq_init(void)
@@ -119,3 +160,11 @@ static int __init omap_cpufreq_init(void)
119} 160}
120 161
121arch_initcall(omap_cpufreq_init); 162arch_initcall(omap_cpufreq_init);
163
164/*
165 * if ever we want to remove this, upon cleanup call:
166 *
167 * cpufreq_unregister_driver()
168 * cpufreq_frequency_table_put_attr()
169 */
170
diff --git a/arch/arm/plat-omap/include/mach/clkdev.h b/arch/arm/plat-omap/include/mach/clkdev.h
new file mode 100644
index 000000000000..730c49d1ebd8
--- /dev/null
+++ b/arch/arm/plat-omap/include/mach/clkdev.h
@@ -0,0 +1,13 @@
1#ifndef __MACH_CLKDEV_H
2#define __MACH_CLKDEV_H
3
4static inline int __clk_get(struct clk *clk)
5{
6 return 1;
7}
8
9static inline void __clk_put(struct clk *clk)
10{
11}
12
13#endif
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index 719298554ed7..073a2c5569f0 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -17,11 +17,16 @@ struct module;
17struct clk; 17struct clk;
18struct clockdomain; 18struct clockdomain;
19 19
20struct clkops {
21 int (*enable)(struct clk *);
22 void (*disable)(struct clk *);
23};
24
20#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 25#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
21 26
22struct clksel_rate { 27struct clksel_rate {
23 u8 div;
24 u32 val; 28 u32 val;
29 u8 div;
25 u8 flags; 30 u8 flags;
26}; 31};
27 32
@@ -34,24 +39,28 @@ struct dpll_data {
34 void __iomem *mult_div1_reg; 39 void __iomem *mult_div1_reg;
35 u32 mult_mask; 40 u32 mult_mask;
36 u32 div1_mask; 41 u32 div1_mask;
42 struct clk *clk_bypass;
43 struct clk *clk_ref;
44 void __iomem *control_reg;
45 u32 enable_mask;
46 unsigned int rate_tolerance;
47 unsigned long last_rounded_rate;
37 u16 last_rounded_m; 48 u16 last_rounded_m;
38 u8 last_rounded_n; 49 u8 last_rounded_n;
39 unsigned long last_rounded_rate; 50 u8 min_divider;
40 unsigned int rate_tolerance;
41 u16 max_multiplier;
42 u8 max_divider; 51 u8 max_divider;
43 u32 max_tolerance; 52 u32 max_tolerance;
53 u16 max_multiplier;
44# if defined(CONFIG_ARCH_OMAP3) 54# if defined(CONFIG_ARCH_OMAP3)
45 u8 modes; 55 u8 modes;
46 void __iomem *control_reg; 56 void __iomem *autoidle_reg;
47 u32 enable_mask; 57 void __iomem *idlest_reg;
58 u32 autoidle_mask;
59 u32 freqsel_mask;
60 u32 idlest_mask;
48 u8 auto_recal_bit; 61 u8 auto_recal_bit;
49 u8 recal_en_bit; 62 u8 recal_en_bit;
50 u8 recal_st_bit; 63 u8 recal_st_bit;
51 void __iomem *autoidle_reg;
52 u32 autoidle_mask;
53 void __iomem *idlest_reg;
54 u8 idlest_bit;
55# endif 64# endif
56}; 65};
57 66
@@ -59,21 +68,21 @@ struct dpll_data {
59 68
60struct clk { 69struct clk {
61 struct list_head node; 70 struct list_head node;
62 struct module *owner; 71 const struct clkops *ops;
63 const char *name; 72 const char *name;
64 int id; 73 int id;
65 struct clk *parent; 74 struct clk *parent;
75 struct list_head children;
76 struct list_head sibling; /* node for children */
66 unsigned long rate; 77 unsigned long rate;
67 __u32 flags; 78 __u32 flags;
68 void __iomem *enable_reg; 79 void __iomem *enable_reg;
69 __u8 enable_bit; 80 unsigned long (*recalc)(struct clk *);
70 __s8 usecount;
71 void (*recalc)(struct clk *);
72 int (*set_rate)(struct clk *, unsigned long); 81 int (*set_rate)(struct clk *, unsigned long);
73 long (*round_rate)(struct clk *, unsigned long); 82 long (*round_rate)(struct clk *, unsigned long);
74 void (*init)(struct clk *); 83 void (*init)(struct clk *);
75 int (*enable)(struct clk *); 84 __u8 enable_bit;
76 void (*disable)(struct clk *); 85 __s8 usecount;
77#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 86#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
78 u8 fixed_div; 87 u8 fixed_div;
79 void __iomem *clksel_reg; 88 void __iomem *clksel_reg;
@@ -99,7 +108,6 @@ struct clk_functions {
99 long (*clk_round_rate)(struct clk *clk, unsigned long rate); 108 long (*clk_round_rate)(struct clk *clk, unsigned long rate);
100 int (*clk_set_rate)(struct clk *clk, unsigned long rate); 109 int (*clk_set_rate)(struct clk *clk, unsigned long rate);
101 int (*clk_set_parent)(struct clk *clk, struct clk *parent); 110 int (*clk_set_parent)(struct clk *clk, struct clk *parent);
102 struct clk * (*clk_get_parent)(struct clk *clk);
103 void (*clk_allow_idle)(struct clk *clk); 111 void (*clk_allow_idle)(struct clk *clk);
104 void (*clk_deny_idle)(struct clk *clk); 112 void (*clk_deny_idle)(struct clk *clk);
105 void (*clk_disable_unused)(struct clk *clk); 113 void (*clk_disable_unused)(struct clk *clk);
@@ -110,42 +118,33 @@ struct clk_functions {
110 118
111extern unsigned int mpurate; 119extern unsigned int mpurate;
112 120
113extern int clk_init(struct clk_functions * custom_clocks); 121extern int clk_init(struct clk_functions *custom_clocks);
122extern void clk_init_one(struct clk *clk);
114extern int clk_register(struct clk *clk); 123extern int clk_register(struct clk *clk);
124extern void clk_reparent(struct clk *child, struct clk *parent);
115extern void clk_unregister(struct clk *clk); 125extern void clk_unregister(struct clk *clk);
116extern void propagate_rate(struct clk *clk); 126extern void propagate_rate(struct clk *clk);
117extern void recalculate_root_clocks(void); 127extern void recalculate_root_clocks(void);
118extern void followparent_recalc(struct clk * clk); 128extern unsigned long followparent_recalc(struct clk *clk);
119extern void clk_allow_idle(struct clk *clk);
120extern void clk_deny_idle(struct clk *clk);
121extern int clk_get_usecount(struct clk *clk);
122extern void clk_enable_init_clocks(void); 129extern void clk_enable_init_clocks(void);
130#ifdef CONFIG_CPU_FREQ
131extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);
132#endif
133
134extern const struct clkops clkops_null;
123 135
124/* Clock flags */ 136/* Clock flags */
125#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */ 137/* bit 0 is free */
126#define RATE_FIXED (1 << 1) /* Fixed clock rate */ 138#define RATE_FIXED (1 << 1) /* Fixed clock rate */
127#define RATE_PROPAGATES (1 << 2) /* Program children too */ 139/* bits 2-4 are free */
128#define VIRTUAL_CLOCK (1 << 3) /* Composite clock from table */
129#define ALWAYS_ENABLED (1 << 4) /* Clock cannot be disabled */
130#define ENABLE_REG_32BIT (1 << 5) /* Use 32-bit access */ 140#define ENABLE_REG_32BIT (1 << 5) /* Use 32-bit access */
131#define VIRTUAL_IO_ADDRESS (1 << 6) /* Clock in virtual address */
132#define CLOCK_IDLE_CONTROL (1 << 7) 141#define CLOCK_IDLE_CONTROL (1 << 7)
133#define CLOCK_NO_IDLE_PARENT (1 << 8) 142#define CLOCK_NO_IDLE_PARENT (1 << 8)
134#define DELAYED_APP (1 << 9) /* Delay application of clock */ 143#define DELAYED_APP (1 << 9) /* Delay application of clock */
135#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */ 144#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */
136#define ENABLE_ON_INIT (1 << 11) /* Enable upon framework init */ 145#define ENABLE_ON_INIT (1 << 11) /* Enable upon framework init */
137#define INVERT_ENABLE (1 << 12) /* 0 enables, 1 disables */ 146#define INVERT_ENABLE (1 << 12) /* 0 enables, 1 disables */
138/* bits 13-20 are currently free */ 147/* bits 13-31 are currently free */
139#define CLOCK_IN_OMAP310 (1 << 21)
140#define CLOCK_IN_OMAP730 (1 << 22)
141#define CLOCK_IN_OMAP1510 (1 << 23)
142#define CLOCK_IN_OMAP16XX (1 << 24)
143#define CLOCK_IN_OMAP242X (1 << 25)
144#define CLOCK_IN_OMAP243X (1 << 26)
145#define CLOCK_IN_OMAP343X (1 << 27) /* clocks common to all 343X */
146#define PARENT_CONTROLS_CLOCK (1 << 28)
147#define CLOCK_IN_OMAP3430ES1 (1 << 29) /* 3430ES1 clocks only */
148#define CLOCK_IN_OMAP3430ES2 (1 << 30) /* 3430ES2 clocks only */
149 148
150/* Clksel_rate flags */ 149/* Clksel_rate flags */
151#define DEFAULT_RATE (1 << 0) 150#define DEFAULT_RATE (1 << 0)
@@ -157,9 +156,4 @@ extern void clk_enable_init_clocks(void);
157#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) 156#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
158 157
159 158
160/* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */
161#define CORE_CLK_SRC_32K 0
162#define CORE_CLK_SRC_DPLL 1
163#define CORE_CLK_SRC_DPLL_X2 2
164
165#endif 159#endif
diff --git a/arch/arm/plat-omap/include/mach/clockdomain.h b/arch/arm/plat-omap/include/mach/clockdomain.h
index 1f51f0173784..b9d0dd2da89b 100644
--- a/arch/arm/plat-omap/include/mach/clockdomain.h
+++ b/arch/arm/plat-omap/include/mach/clockdomain.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-arm/arch-omap/clockdomain.h 2 * arch/arm/plat-omap/include/mach/clockdomain.h
3 * 3 *
4 * OMAP2/3 clockdomain framework functions 4 * OMAP2/3 clockdomain framework functions
5 * 5 *
@@ -48,11 +48,13 @@
48 */ 48 */
49struct clkdm_pwrdm_autodep { 49struct clkdm_pwrdm_autodep {
50 50
51 /* Name of the powerdomain to add a wkdep/sleepdep on */ 51 union {
52 const char *pwrdm_name; 52 /* Name of the powerdomain to add a wkdep/sleepdep on */
53 const char *name;
53 54
54 /* Powerdomain pointer (looked up at clkdm_init() time) */ 55 /* Powerdomain pointer (looked up at clkdm_init() time) */
55 struct powerdomain *pwrdm; 56 struct powerdomain *ptr;
57 } pwrdm;
56 58
57 /* OMAP chip types that this clockdomain dep is valid on */ 59 /* OMAP chip types that this clockdomain dep is valid on */
58 const struct omap_chip_id omap_chip; 60 const struct omap_chip_id omap_chip;
@@ -64,8 +66,13 @@ struct clockdomain {
64 /* Clockdomain name */ 66 /* Clockdomain name */
65 const char *name; 67 const char *name;
66 68
67 /* Powerdomain enclosing this clockdomain */ 69 union {
68 const char *pwrdm_name; 70 /* Powerdomain enclosing this clockdomain */
71 const char *name;
72
73 /* Powerdomain pointer assigned at clkdm_register() */
74 struct powerdomain *ptr;
75 } pwrdm;
69 76
70 /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */ 77 /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */
71 const u16 clktrctrl_mask; 78 const u16 clktrctrl_mask;
@@ -79,9 +86,6 @@ struct clockdomain {
79 /* Usecount tracking */ 86 /* Usecount tracking */
80 atomic_t usecount; 87 atomic_t usecount;
81 88
82 /* Powerdomain pointer assigned at clkdm_register() */
83 struct powerdomain *pwrdm;
84
85 struct list_head node; 89 struct list_head node;
86 90
87}; 91};
diff --git a/arch/arm/plat-omap/include/mach/common.h b/arch/arm/plat-omap/include/mach/common.h
index ef70e2b0f054..f3444a66a57e 100644
--- a/arch/arm/plat-omap/include/mach/common.h
+++ b/arch/arm/plat-omap/include/mach/common.h
@@ -65,7 +65,7 @@ void omap2_set_globals_343x(void);
65 65
66/* These get called from omap2_set_globals_xxxx(), do not call these */ 66/* These get called from omap2_set_globals_xxxx(), do not call these */
67void omap2_set_globals_tap(struct omap_globals *); 67void omap2_set_globals_tap(struct omap_globals *);
68void omap2_set_globals_memory(struct omap_globals *); 68void omap2_set_globals_sdrc(struct omap_globals *);
69void omap2_set_globals_control(struct omap_globals *); 69void omap2_set_globals_control(struct omap_globals *);
70void omap2_set_globals_prcm(struct omap_globals *); 70void omap2_set_globals_prcm(struct omap_globals *);
71 71
diff --git a/arch/arm/plat-omap/include/mach/cpu.h b/arch/arm/plat-omap/include/mach/cpu.h
index a8e1178a9468..4166a970daa4 100644
--- a/arch/arm/plat-omap/include/mach/cpu.h
+++ b/arch/arm/plat-omap/include/mach/cpu.h
@@ -355,13 +355,27 @@ IS_OMAP_TYPE(3430, 0x3430)
355 * use omap_chip_is(). 355 * use omap_chip_is().
356 * 356 *
357 */ 357 */
358#define CHIP_IS_OMAP2420 (1 << 0) 358#define CHIP_IS_OMAP2420 (1 << 0)
359#define CHIP_IS_OMAP2430 (1 << 1) 359#define CHIP_IS_OMAP2430 (1 << 1)
360#define CHIP_IS_OMAP3430 (1 << 2) 360#define CHIP_IS_OMAP3430 (1 << 2)
361#define CHIP_IS_OMAP3430ES1 (1 << 3) 361#define CHIP_IS_OMAP3430ES1 (1 << 3)
362#define CHIP_IS_OMAP3430ES2 (1 << 4) 362#define CHIP_IS_OMAP3430ES2 (1 << 4)
363#define CHIP_IS_OMAP3430ES3_0 (1 << 5)
364#define CHIP_IS_OMAP3430ES3_1 (1 << 6)
365
366#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
367
368/*
369 * "GE" here represents "greater than or equal to" in terms of ES
370 * levels. So CHIP_GE_OMAP3430ES2 is intended to match all OMAP3430
371 * chips at ES2 and beyond, but not, for example, any OMAP lines after
372 * OMAP3.
373 */
374#define CHIP_GE_OMAP3430ES2 (CHIP_IS_OMAP3430ES2 | \
375 CHIP_IS_OMAP3430ES3_0 | \
376 CHIP_IS_OMAP3430ES3_1)
377#define CHIP_GE_OMAP3430ES3_1 (CHIP_IS_OMAP3430ES3_1)
363 378
364#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
365 379
366int omap_chip_is(struct omap_chip_id oci); 380int omap_chip_is(struct omap_chip_id oci);
367int omap_type(void); 381int omap_type(void);
diff --git a/arch/arm/plat-omap/include/mach/gpmc.h b/arch/arm/plat-omap/include/mach/gpmc.h
index 45b678439bb7..921b16532ff5 100644
--- a/arch/arm/plat-omap/include/mach/gpmc.h
+++ b/arch/arm/plat-omap/include/mach/gpmc.h
@@ -103,6 +103,6 @@ extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
103extern void gpmc_cs_free(int cs); 103extern void gpmc_cs_free(int cs);
104extern int gpmc_cs_set_reserved(int cs, int reserved); 104extern int gpmc_cs_set_reserved(int cs, int reserved);
105extern int gpmc_cs_reserved(int cs); 105extern int gpmc_cs_reserved(int cs);
106extern void gpmc_init(void); 106extern void __init gpmc_init(void);
107 107
108#endif 108#endif
diff --git a/arch/arm/plat-omap/include/mach/io.h b/arch/arm/plat-omap/include/mach/io.h
index d92bf7964481..0610d7e2b3d7 100644
--- a/arch/arm/plat-omap/include/mach/io.h
+++ b/arch/arm/plat-omap/include/mach/io.h
@@ -185,11 +185,13 @@
185#define omap_writew(v,a) __raw_writew(v, IO_ADDRESS(a)) 185#define omap_writew(v,a) __raw_writew(v, IO_ADDRESS(a))
186#define omap_writel(v,a) __raw_writel(v, IO_ADDRESS(a)) 186#define omap_writel(v,a) __raw_writel(v, IO_ADDRESS(a))
187 187
188struct omap_sdrc_params;
189
188extern void omap1_map_common_io(void); 190extern void omap1_map_common_io(void);
189extern void omap1_init_common_hw(void); 191extern void omap1_init_common_hw(void);
190 192
191extern void omap2_map_common_io(void); 193extern void omap2_map_common_io(void);
192extern void omap2_init_common_hw(void); 194extern void omap2_init_common_hw(struct omap_sdrc_params *sp);
193 195
194#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t) 196#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t)
195#define __arch_iounmap(v) omap_iounmap(v) 197#define __arch_iounmap(v) omap_iounmap(v)
diff --git a/arch/arm/plat-omap/include/mach/mcbsp.h b/arch/arm/plat-omap/include/mach/mcbsp.h
index 113c2466c86a..bb154ea76769 100644
--- a/arch/arm/plat-omap/include/mach/mcbsp.h
+++ b/arch/arm/plat-omap/include/mach/mcbsp.h
@@ -344,8 +344,6 @@ struct omap_mcbsp_platform_data {
344 u8 dma_rx_sync, dma_tx_sync; 344 u8 dma_rx_sync, dma_tx_sync;
345 u16 rx_irq, tx_irq; 345 u16 rx_irq, tx_irq;
346 struct omap_mcbsp_ops *ops; 346 struct omap_mcbsp_ops *ops;
347 char const **clk_names;
348 int num_clks;
349}; 347};
350 348
351struct omap_mcbsp { 349struct omap_mcbsp {
@@ -377,8 +375,8 @@ struct omap_mcbsp {
377 /* Protect the field .free, while checking if the mcbsp is in use */ 375 /* Protect the field .free, while checking if the mcbsp is in use */
378 spinlock_t lock; 376 spinlock_t lock;
379 struct omap_mcbsp_platform_data *pdata; 377 struct omap_mcbsp_platform_data *pdata;
380 struct clk **clks; 378 struct clk *iclk;
381 int num_clks; 379 struct clk *fclk;
382}; 380};
383extern struct omap_mcbsp **mcbsp_ptr; 381extern struct omap_mcbsp **mcbsp_ptr;
384extern int omap_mcbsp_count; 382extern int omap_mcbsp_count;
diff --git a/arch/arm/plat-omap/include/mach/pm.h b/arch/arm/plat-omap/include/mach/pm.h
index 2a9c27ad4c37..ca81830b4f86 100644
--- a/arch/arm/plat-omap/include/mach/pm.h
+++ b/arch/arm/plat-omap/include/mach/pm.h
@@ -118,18 +118,6 @@
118extern void prevent_idle_sleep(void); 118extern void prevent_idle_sleep(void);
119extern void allow_idle_sleep(void); 119extern void allow_idle_sleep(void);
120 120
121/**
122 * clk_deny_idle - Prevents the clock from being idled during MPU idle
123 * @clk: clock signal handle
124 */
125void clk_deny_idle(struct clk *clk);
126
127/**
128 * clk_allow_idle - Counters previous clk_deny_idle
129 * @clk: clock signal handle
130 */
131void clk_allow_idle(struct clk *clk);
132
133extern void omap_pm_idle(void); 121extern void omap_pm_idle(void);
134extern void omap_pm_suspend(void); 122extern void omap_pm_suspend(void);
135extern void omap730_cpu_suspend(unsigned short, unsigned short); 123extern void omap730_cpu_suspend(unsigned short, unsigned short);
diff --git a/arch/arm/plat-omap/include/mach/powerdomain.h b/arch/arm/plat-omap/include/mach/powerdomain.h
index 2806a9c8e4d7..69c9e675d8ee 100644
--- a/arch/arm/plat-omap/include/mach/powerdomain.h
+++ b/arch/arm/plat-omap/include/mach/powerdomain.h
@@ -50,9 +50,9 @@
50 50
51/* 51/*
52 * Maximum number of clockdomains that can be associated with a powerdomain. 52 * Maximum number of clockdomains that can be associated with a powerdomain.
53 * CORE powerdomain is probably the worst case. 53 * CORE powerdomain on OMAP3 is the worst case
54 */ 54 */
55#define PWRDM_MAX_CLKDMS 3 55#define PWRDM_MAX_CLKDMS 4
56 56
57/* XXX A completely arbitrary number. What is reasonable here? */ 57/* XXX A completely arbitrary number. What is reasonable here? */
58#define PWRDM_TRANSITION_BAILOUT 100000 58#define PWRDM_TRANSITION_BAILOUT 100000
@@ -145,6 +145,7 @@ int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
145 145
146int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst); 146int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
147int pwrdm_read_next_pwrst(struct powerdomain *pwrdm); 147int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
148int pwrdm_read_pwrst(struct powerdomain *pwrdm);
148int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm); 149int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
149int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm); 150int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
150 151
diff --git a/arch/arm/plat-omap/include/mach/prcm.h b/arch/arm/plat-omap/include/mach/prcm.h
index 56eba0fd6f6a..24ac3c715912 100644
--- a/arch/arm/plat-omap/include/mach/prcm.h
+++ b/arch/arm/plat-omap/include/mach/prcm.h
@@ -20,10 +20,11 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22 22
23#ifndef __ASM_ARM_ARCH_DPM_PRCM_H 23#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H
24#define __ASM_ARM_ARCH_DPM_PRCM_H 24#define __ASM_ARM_ARCH_OMAP_PRCM_H
25 25
26u32 omap_prcm_get_reset_sources(void); 26u32 omap_prcm_get_reset_sources(void);
27void omap_prcm_arch_reset(char mode);
27 28
28#endif 29#endif
29 30
diff --git a/arch/arm/plat-omap/include/mach/sdrc.h b/arch/arm/plat-omap/include/mach/sdrc.h
index a98c6c3beb2c..adc73522491f 100644
--- a/arch/arm/plat-omap/include/mach/sdrc.h
+++ b/arch/arm/plat-omap/include/mach/sdrc.h
@@ -4,10 +4,12 @@
4/* 4/*
5 * OMAP2/3 SDRC/SMS register definitions 5 * OMAP2/3 SDRC/SMS register definitions
6 * 6 *
7 * Copyright (C) 2007 Texas Instruments, Inc. 7 * Copyright (C) 2007-2008 Texas Instruments, Inc.
8 * Copyright (C) 2007 Nokia Corporation 8 * Copyright (C) 2007-2008 Nokia Corporation
9 * 9 *
10 * Written by Paul Walmsley 10 * Tony Lindgren
11 * Paul Walmsley
12 * Richard Woodruff
11 * 13 *
12 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 15 * it under the terms of the GNU General Public License version 2 as
@@ -64,14 +66,62 @@
64 * SMS register access 66 * SMS register access
65 */ 67 */
66 68
67 69#define OMAP242X_SMS_REGADDR(reg) \
68#define OMAP242X_SMS_REGADDR(reg) IO_ADDRESS(OMAP2420_SMS_BASE + reg) 70 (void __iomem *)IO_ADDRESS(OMAP2420_SMS_BASE + reg)
69#define OMAP243X_SMS_REGADDR(reg) IO_ADDRESS(OMAP243X_SMS_BASE + reg) 71#define OMAP243X_SMS_REGADDR(reg) \
70#define OMAP343X_SMS_REGADDR(reg) IO_ADDRESS(OMAP343X_SMS_BASE + reg) 72 (void __iomem *)IO_ADDRESS(OMAP243X_SMS_BASE + reg)
73#define OMAP343X_SMS_REGADDR(reg) \
74 (void __iomem *)IO_ADDRESS(OMAP343X_SMS_BASE + reg)
71 75
72/* SMS register offsets - read/write with sms_{read,write}_reg() */ 76/* SMS register offsets - read/write with sms_{read,write}_reg() */
73 77
74#define SMS_SYSCONFIG 0x010 78#define SMS_SYSCONFIG 0x010
75/* REVISIT: fill in other SMS registers here */ 79/* REVISIT: fill in other SMS registers here */
76 80
81
82#ifndef __ASSEMBLER__
83
84/**
85 * struct omap_sdrc_params - SDRC parameters for a given SDRC clock rate
86 * @rate: SDRC clock rate (in Hz)
87 * @actim_ctrla: Value to program to SDRC_ACTIM_CTRLA for this rate
88 * @actim_ctrlb: Value to program to SDRC_ACTIM_CTRLB for this rate
89 * @rfr_ctrl: Value to program to SDRC_RFR_CTRL for this rate
90 * @mr: Value to program to SDRC_MR for this rate
91 *
92 * This structure holds a pre-computed set of register values for the
93 * SDRC for a given SDRC clock rate and SDRAM chip. These are
94 * intended to be pre-computed and specified in an array in the board-*.c
95 * files. The structure is keyed off the 'rate' field.
96 */
97struct omap_sdrc_params {
98 unsigned long rate;
99 u32 actim_ctrla;
100 u32 actim_ctrlb;
101 u32 rfr_ctrl;
102 u32 mr;
103};
104
105void __init omap2_sdrc_init(struct omap_sdrc_params *sp);
106struct omap_sdrc_params *omap2_sdrc_get_params(unsigned long r);
107
108#ifdef CONFIG_ARCH_OMAP2
109
110struct memory_timings {
111 u32 m_type; /* ddr = 1, sdr = 0 */
112 u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */
113 u32 slow_dll_ctrl; /* unlock mode, dll value for slow speed */
114 u32 fast_dll_ctrl; /* unlock mode, dll value for fast speed */
115 u32 base_cs; /* base chip select to use for calculations */
116};
117
118extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);
119
120u32 omap2xxx_sdrc_dll_is_unlocked(void);
121u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);
122
123#endif /* CONFIG_ARCH_OMAP2 */
124
125#endif /* __ASSEMBLER__ */
126
77#endif 127#endif
diff --git a/arch/arm/plat-omap/include/mach/system.h b/arch/arm/plat-omap/include/mach/system.h
index 06923f261545..e9b95637f7fc 100644
--- a/arch/arm/plat-omap/include/mach/system.h
+++ b/arch/arm/plat-omap/include/mach/system.h
@@ -9,12 +9,12 @@
9#include <asm/mach-types.h> 9#include <asm/mach-types.h>
10#include <mach/hardware.h> 10#include <mach/hardware.h>
11 11
12#include <mach/prcm.h>
13
12#ifndef CONFIG_MACH_VOICEBLUE 14#ifndef CONFIG_MACH_VOICEBLUE
13#define voiceblue_reset() do {} while (0) 15#define voiceblue_reset() do {} while (0)
14#endif 16#endif
15 17
16extern void omap_prcm_arch_reset(char mode);
17
18static inline void arch_idle(void) 18static inline void arch_idle(void)
19{ 19{
20 cpu_do_idle(); 20 cpu_do_idle();
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index e5842e30e534..28b0a824b8cf 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -214,7 +214,6 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type);
214int omap_mcbsp_request(unsigned int id) 214int omap_mcbsp_request(unsigned int id)
215{ 215{
216 struct omap_mcbsp *mcbsp; 216 struct omap_mcbsp *mcbsp;
217 int i;
218 int err; 217 int err;
219 218
220 if (!omap_mcbsp_check_valid_id(id)) { 219 if (!omap_mcbsp_check_valid_id(id)) {
@@ -223,23 +222,23 @@ int omap_mcbsp_request(unsigned int id)
223 } 222 }
224 mcbsp = id_to_mcbsp_ptr(id); 223 mcbsp = id_to_mcbsp_ptr(id);
225 224
226 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
227 mcbsp->pdata->ops->request(id);
228
229 for (i = 0; i < mcbsp->num_clks; i++)
230 clk_enable(mcbsp->clks[i]);
231
232 spin_lock(&mcbsp->lock); 225 spin_lock(&mcbsp->lock);
233 if (!mcbsp->free) { 226 if (!mcbsp->free) {
234 dev_err(mcbsp->dev, "McBSP%d is currently in use\n", 227 dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
235 mcbsp->id); 228 mcbsp->id);
236 spin_unlock(&mcbsp->lock); 229 spin_unlock(&mcbsp->lock);
237 return -1; 230 return -EBUSY;
238 } 231 }
239 232
240 mcbsp->free = 0; 233 mcbsp->free = 0;
241 spin_unlock(&mcbsp->lock); 234 spin_unlock(&mcbsp->lock);
242 235
236 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
237 mcbsp->pdata->ops->request(id);
238
239 clk_enable(mcbsp->iclk);
240 clk_enable(mcbsp->fclk);
241
243 /* 242 /*
244 * Make sure that transmitter, receiver and sample-rate generator are 243 * Make sure that transmitter, receiver and sample-rate generator are
245 * not running before activating IRQs. 244 * not running before activating IRQs.
@@ -278,7 +277,6 @@ EXPORT_SYMBOL(omap_mcbsp_request);
278void omap_mcbsp_free(unsigned int id) 277void omap_mcbsp_free(unsigned int id)
279{ 278{
280 struct omap_mcbsp *mcbsp; 279 struct omap_mcbsp *mcbsp;
281 int i;
282 280
283 if (!omap_mcbsp_check_valid_id(id)) { 281 if (!omap_mcbsp_check_valid_id(id)) {
284 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 282 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
@@ -289,8 +287,14 @@ void omap_mcbsp_free(unsigned int id)
289 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) 287 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
290 mcbsp->pdata->ops->free(id); 288 mcbsp->pdata->ops->free(id);
291 289
292 for (i = mcbsp->num_clks - 1; i >= 0; i--) 290 clk_disable(mcbsp->fclk);
293 clk_disable(mcbsp->clks[i]); 291 clk_disable(mcbsp->iclk);
292
293 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
294 /* Free IRQs */
295 free_irq(mcbsp->rx_irq, (void *)mcbsp);
296 free_irq(mcbsp->tx_irq, (void *)mcbsp);
297 }
294 298
295 spin_lock(&mcbsp->lock); 299 spin_lock(&mcbsp->lock);
296 if (mcbsp->free) { 300 if (mcbsp->free) {
@@ -302,12 +306,6 @@ void omap_mcbsp_free(unsigned int id)
302 306
303 mcbsp->free = 1; 307 mcbsp->free = 1;
304 spin_unlock(&mcbsp->lock); 308 spin_unlock(&mcbsp->lock);
305
306 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
307 /* Free IRQs */
308 free_irq(mcbsp->rx_irq, (void *)mcbsp);
309 free_irq(mcbsp->tx_irq, (void *)mcbsp);
310 }
311} 309}
312EXPORT_SYMBOL(omap_mcbsp_free); 310EXPORT_SYMBOL(omap_mcbsp_free);
313 311
@@ -876,7 +874,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
876 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; 874 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
877 struct omap_mcbsp *mcbsp; 875 struct omap_mcbsp *mcbsp;
878 int id = pdev->id - 1; 876 int id = pdev->id - 1;
879 int i;
880 int ret = 0; 877 int ret = 0;
881 878
882 if (!pdata) { 879 if (!pdata) {
@@ -899,7 +896,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
899 ret = -ENOMEM; 896 ret = -ENOMEM;
900 goto exit; 897 goto exit;
901 } 898 }
902 mcbsp_ptr[id] = mcbsp;
903 899
904 spin_lock_init(&mcbsp->lock); 900 spin_lock_init(&mcbsp->lock);
905 mcbsp->id = id + 1; 901 mcbsp->id = id + 1;
@@ -921,39 +917,32 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
921 mcbsp->dma_rx_sync = pdata->dma_rx_sync; 917 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
922 mcbsp->dma_tx_sync = pdata->dma_tx_sync; 918 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
923 919
924 if (pdata->num_clks) { 920 mcbsp->iclk = clk_get(&pdev->dev, "ick");
925 mcbsp->num_clks = pdata->num_clks; 921 if (IS_ERR(mcbsp->iclk)) {
926 mcbsp->clks = kzalloc(mcbsp->num_clks * sizeof(struct clk *), 922 ret = PTR_ERR(mcbsp->iclk);
927 GFP_KERNEL); 923 dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
928 if (!mcbsp->clks) { 924 goto err_iclk;
929 ret = -ENOMEM; 925 }
930 goto exit;
931 }
932 for (i = 0; i < mcbsp->num_clks; i++) {
933 mcbsp->clks[i] = clk_get(&pdev->dev, pdata->clk_names[i]);
934 if (IS_ERR(mcbsp->clks[i])) {
935 dev_err(&pdev->dev,
936 "Invalid %s configuration for McBSP%d.\n",
937 pdata->clk_names[i], mcbsp->id);
938 ret = PTR_ERR(mcbsp->clks[i]);
939 goto err_clk;
940 }
941 }
942 926
927 mcbsp->fclk = clk_get(&pdev->dev, "fck");
928 if (IS_ERR(mcbsp->fclk)) {
929 ret = PTR_ERR(mcbsp->fclk);
930 dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
931 goto err_fclk;
943 } 932 }
944 933
945 mcbsp->pdata = pdata; 934 mcbsp->pdata = pdata;
946 mcbsp->dev = &pdev->dev; 935 mcbsp->dev = &pdev->dev;
936 mcbsp_ptr[id] = mcbsp;
947 platform_set_drvdata(pdev, mcbsp); 937 platform_set_drvdata(pdev, mcbsp);
948 return 0; 938 return 0;
949 939
950err_clk: 940err_fclk:
951 while (i--) 941 clk_put(mcbsp->iclk);
952 clk_put(mcbsp->clks[i]); 942err_iclk:
953 kfree(mcbsp->clks);
954 iounmap(mcbsp->io_base); 943 iounmap(mcbsp->io_base);
955err_ioremap: 944err_ioremap:
956 mcbsp->free = 0; 945 kfree(mcbsp);
957exit: 946exit:
958 return ret; 947 return ret;
959} 948}
@@ -961,7 +950,6 @@ exit:
961static int __devexit omap_mcbsp_remove(struct platform_device *pdev) 950static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
962{ 951{
963 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); 952 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
964 int i;
965 953
966 platform_set_drvdata(pdev, NULL); 954 platform_set_drvdata(pdev, NULL);
967 if (mcbsp) { 955 if (mcbsp) {
@@ -970,18 +958,15 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
970 mcbsp->pdata->ops->free) 958 mcbsp->pdata->ops->free)
971 mcbsp->pdata->ops->free(mcbsp->id); 959 mcbsp->pdata->ops->free(mcbsp->id);
972 960
973 for (i = mcbsp->num_clks - 1; i >= 0; i--) { 961 clk_disable(mcbsp->fclk);
974 clk_disable(mcbsp->clks[i]); 962 clk_disable(mcbsp->iclk);
975 clk_put(mcbsp->clks[i]); 963 clk_put(mcbsp->fclk);
976 } 964 clk_put(mcbsp->iclk);
977 965
978 iounmap(mcbsp->io_base); 966 iounmap(mcbsp->io_base);
979 967
980 if (mcbsp->num_clks) { 968 mcbsp->fclk = NULL;
981 kfree(mcbsp->clks); 969 mcbsp->iclk = NULL;
982 mcbsp->clks = NULL;
983 mcbsp->num_clks = 0;
984 }
985 mcbsp->free = 0; 970 mcbsp->free = 0;
986 mcbsp->dev = NULL; 971 mcbsp->dev = NULL;
987 } 972 }
@@ -1002,4 +987,3 @@ int __init omap_mcbsp_init(void)
1002 /* Register the McBSP driver */ 987 /* Register the McBSP driver */
1003 return platform_driver_register(&omap_mcbsp_driver); 988 return platform_driver_register(&omap_mcbsp_driver);
1004} 989}
1005