diff options
Diffstat (limited to 'arch/arm/plat-spear')
-rw-r--r-- | arch/arm/plat-spear/Kconfig | 31 | ||||
-rw-r--r-- | arch/arm/plat-spear/Makefile | 8 | ||||
-rw-r--r-- | arch/arm/plat-spear/clock.c | 435 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/clkdev.h | 20 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/clock.h | 126 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/debug-macro.S | 38 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/gpio.h | 24 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/io.h | 22 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/memory.h | 20 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/padmux.h | 92 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/shirq.h | 73 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/system.h | 41 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/timex.h | 19 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/uncompress.h | 43 | ||||
-rw-r--r-- | arch/arm/plat-spear/include/plat/vmalloc.h | 19 | ||||
-rw-r--r-- | arch/arm/plat-spear/padmux.c | 164 | ||||
-rw-r--r-- | arch/arm/plat-spear/shirq.c | 118 | ||||
-rw-r--r-- | arch/arm/plat-spear/time.c | 292 |
18 files changed, 1585 insertions, 0 deletions
diff --git a/arch/arm/plat-spear/Kconfig b/arch/arm/plat-spear/Kconfig new file mode 100644 index 000000000000..1bb3dbce8810 --- /dev/null +++ b/arch/arm/plat-spear/Kconfig | |||
@@ -0,0 +1,31 @@ | |||
1 | # | ||
2 | # SPEAr Platform configuration file | ||
3 | # | ||
4 | |||
5 | if PLAT_SPEAR | ||
6 | |||
7 | choice | ||
8 | prompt "ST SPEAr Family" | ||
9 | default ARCH_SPEAR3XX | ||
10 | |||
11 | config ARCH_SPEAR3XX | ||
12 | bool "SPEAr3XX" | ||
13 | select ARM_VIC | ||
14 | select CPU_ARM926T | ||
15 | help | ||
16 | Supports for ARM's SPEAR3XX family | ||
17 | |||
18 | config ARCH_SPEAR6XX | ||
19 | bool "SPEAr6XX" | ||
20 | select ARM_VIC | ||
21 | select CPU_ARM926T | ||
22 | help | ||
23 | Supports for ARM's SPEAR6XX family | ||
24 | |||
25 | endchoice | ||
26 | |||
27 | # Adding SPEAr machine specific configuration files | ||
28 | source "arch/arm/mach-spear3xx/Kconfig" | ||
29 | source "arch/arm/mach-spear6xx/Kconfig" | ||
30 | |||
31 | endif | ||
diff --git a/arch/arm/plat-spear/Makefile b/arch/arm/plat-spear/Makefile new file mode 100644 index 000000000000..eb89540aeda9 --- /dev/null +++ b/arch/arm/plat-spear/Makefile | |||
@@ -0,0 +1,8 @@ | |||
1 | # | ||
2 | # SPEAr Platform specific Makefile | ||
3 | # | ||
4 | |||
5 | # Common support | ||
6 | obj-y := clock.o padmux.o time.o | ||
7 | |||
8 | obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o | ||
diff --git a/arch/arm/plat-spear/clock.c b/arch/arm/plat-spear/clock.c new file mode 100644 index 000000000000..ee4f90e534d8 --- /dev/null +++ b/arch/arm/plat-spear/clock.c | |||
@@ -0,0 +1,435 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/clock.c | ||
3 | * | ||
4 | * Clock framework for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/bug.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/list.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <mach/misc_regs.h> | ||
21 | #include <plat/clock.h> | ||
22 | |||
23 | static DEFINE_SPINLOCK(clocks_lock); | ||
24 | static LIST_HEAD(root_clks); | ||
25 | |||
26 | static void propagate_rate(struct list_head *); | ||
27 | |||
28 | static int generic_clk_enable(struct clk *clk) | ||
29 | { | ||
30 | unsigned int val; | ||
31 | |||
32 | if (!clk->en_reg) | ||
33 | return -EFAULT; | ||
34 | |||
35 | val = readl(clk->en_reg); | ||
36 | if (unlikely(clk->flags & RESET_TO_ENABLE)) | ||
37 | val &= ~(1 << clk->en_reg_bit); | ||
38 | else | ||
39 | val |= 1 << clk->en_reg_bit; | ||
40 | |||
41 | writel(val, clk->en_reg); | ||
42 | |||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | static void generic_clk_disable(struct clk *clk) | ||
47 | { | ||
48 | unsigned int val; | ||
49 | |||
50 | if (!clk->en_reg) | ||
51 | return; | ||
52 | |||
53 | val = readl(clk->en_reg); | ||
54 | if (unlikely(clk->flags & RESET_TO_ENABLE)) | ||
55 | val |= 1 << clk->en_reg_bit; | ||
56 | else | ||
57 | val &= ~(1 << clk->en_reg_bit); | ||
58 | |||
59 | writel(val, clk->en_reg); | ||
60 | } | ||
61 | |||
62 | /* generic clk ops */ | ||
63 | static struct clkops generic_clkops = { | ||
64 | .enable = generic_clk_enable, | ||
65 | .disable = generic_clk_disable, | ||
66 | }; | ||
67 | |||
68 | /* | ||
69 | * clk_enable - inform the system when the clock source should be running. | ||
70 | * @clk: clock source | ||
71 | * | ||
72 | * If the clock can not be enabled/disabled, this should return success. | ||
73 | * | ||
74 | * Returns success (0) or negative errno. | ||
75 | */ | ||
76 | int clk_enable(struct clk *clk) | ||
77 | { | ||
78 | unsigned long flags; | ||
79 | int ret = 0; | ||
80 | |||
81 | if (!clk || IS_ERR(clk)) | ||
82 | return -EFAULT; | ||
83 | |||
84 | spin_lock_irqsave(&clocks_lock, flags); | ||
85 | if (clk->usage_count == 0) { | ||
86 | if (clk->ops && clk->ops->enable) | ||
87 | ret = clk->ops->enable(clk); | ||
88 | } | ||
89 | clk->usage_count++; | ||
90 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | EXPORT_SYMBOL(clk_enable); | ||
95 | |||
96 | /* | ||
97 | * clk_disable - inform the system when the clock source is no longer required. | ||
98 | * @clk: clock source | ||
99 | * | ||
100 | * Inform the system that a clock source is no longer required by | ||
101 | * a driver and may be shut down. | ||
102 | * | ||
103 | * Implementation detail: if the clock source is shared between | ||
104 | * multiple drivers, clk_enable() calls must be balanced by the | ||
105 | * same number of clk_disable() calls for the clock source to be | ||
106 | * disabled. | ||
107 | */ | ||
108 | void clk_disable(struct clk *clk) | ||
109 | { | ||
110 | unsigned long flags; | ||
111 | |||
112 | if (!clk || IS_ERR(clk)) | ||
113 | return; | ||
114 | |||
115 | WARN_ON(clk->usage_count == 0); | ||
116 | |||
117 | spin_lock_irqsave(&clocks_lock, flags); | ||
118 | clk->usage_count--; | ||
119 | if (clk->usage_count == 0) { | ||
120 | if (clk->ops && clk->ops->disable) | ||
121 | clk->ops->disable(clk); | ||
122 | } | ||
123 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
124 | } | ||
125 | EXPORT_SYMBOL(clk_disable); | ||
126 | |||
127 | /** | ||
128 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. | ||
129 | * This is only valid once the clock source has been enabled. | ||
130 | * @clk: clock source | ||
131 | */ | ||
132 | unsigned long clk_get_rate(struct clk *clk) | ||
133 | { | ||
134 | unsigned long flags, rate; | ||
135 | |||
136 | spin_lock_irqsave(&clocks_lock, flags); | ||
137 | rate = clk->rate; | ||
138 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
139 | |||
140 | return rate; | ||
141 | } | ||
142 | EXPORT_SYMBOL(clk_get_rate); | ||
143 | |||
144 | /** | ||
145 | * clk_set_parent - set the parent clock source for this clock | ||
146 | * @clk: clock source | ||
147 | * @parent: parent clock source | ||
148 | * | ||
149 | * Returns success (0) or negative errno. | ||
150 | */ | ||
151 | int clk_set_parent(struct clk *clk, struct clk *parent) | ||
152 | { | ||
153 | int i, found = 0, val = 0; | ||
154 | unsigned long flags; | ||
155 | |||
156 | if (!clk || IS_ERR(clk) || !parent || IS_ERR(parent)) | ||
157 | return -EFAULT; | ||
158 | if (clk->usage_count) | ||
159 | return -EBUSY; | ||
160 | if (!clk->pclk_sel) | ||
161 | return -EPERM; | ||
162 | if (clk->pclk == parent) | ||
163 | return 0; | ||
164 | |||
165 | for (i = 0; i < clk->pclk_sel->pclk_count; i++) { | ||
166 | if (clk->pclk_sel->pclk_info[i].pclk == parent) { | ||
167 | found = 1; | ||
168 | break; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | if (!found) | ||
173 | return -EINVAL; | ||
174 | |||
175 | spin_lock_irqsave(&clocks_lock, flags); | ||
176 | /* reflect parent change in hardware */ | ||
177 | val = readl(clk->pclk_sel->pclk_sel_reg); | ||
178 | val &= ~(clk->pclk_sel->pclk_sel_mask << clk->pclk_sel_shift); | ||
179 | val |= clk->pclk_sel->pclk_info[i].pclk_mask << clk->pclk_sel_shift; | ||
180 | writel(val, clk->pclk_sel->pclk_sel_reg); | ||
181 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
182 | |||
183 | /* reflect parent change in software */ | ||
184 | clk->recalc(clk); | ||
185 | propagate_rate(&clk->children); | ||
186 | return 0; | ||
187 | } | ||
188 | EXPORT_SYMBOL(clk_set_parent); | ||
189 | |||
190 | /* registers clock in platform clock framework */ | ||
191 | void clk_register(struct clk_lookup *cl) | ||
192 | { | ||
193 | struct clk *clk = cl->clk; | ||
194 | unsigned long flags; | ||
195 | |||
196 | if (!clk || IS_ERR(clk)) | ||
197 | return; | ||
198 | |||
199 | spin_lock_irqsave(&clocks_lock, flags); | ||
200 | |||
201 | INIT_LIST_HEAD(&clk->children); | ||
202 | if (clk->flags & ALWAYS_ENABLED) | ||
203 | clk->ops = NULL; | ||
204 | else if (!clk->ops) | ||
205 | clk->ops = &generic_clkops; | ||
206 | |||
207 | /* root clock don't have any parents */ | ||
208 | if (!clk->pclk && !clk->pclk_sel) { | ||
209 | list_add(&clk->sibling, &root_clks); | ||
210 | /* add clocks with only one parent to parent's children list */ | ||
211 | } else if (clk->pclk && !clk->pclk_sel) { | ||
212 | list_add(&clk->sibling, &clk->pclk->children); | ||
213 | } else { | ||
214 | /* add clocks with > 1 parent to 1st parent's children list */ | ||
215 | list_add(&clk->sibling, | ||
216 | &clk->pclk_sel->pclk_info[0].pclk->children); | ||
217 | } | ||
218 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
219 | |||
220 | /* add clock to arm clockdev framework */ | ||
221 | clkdev_add(cl); | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * propagate_rate - recalculate and propagate all clocks in list head | ||
226 | * | ||
227 | * Recalculates all root clocks in list head, which if the clock's .recalc is | ||
228 | * set correctly, should also propagate their rates. | ||
229 | */ | ||
230 | static void propagate_rate(struct list_head *lhead) | ||
231 | { | ||
232 | struct clk *clkp, *_temp; | ||
233 | |||
234 | list_for_each_entry_safe(clkp, _temp, lhead, sibling) { | ||
235 | if (clkp->recalc) | ||
236 | clkp->recalc(clkp); | ||
237 | propagate_rate(&clkp->children); | ||
238 | } | ||
239 | } | ||
240 | |||
241 | /* returns current programmed clocks clock info structure */ | ||
242 | static struct pclk_info *pclk_info_get(struct clk *clk) | ||
243 | { | ||
244 | unsigned int mask, i; | ||
245 | unsigned long flags; | ||
246 | struct pclk_info *info = NULL; | ||
247 | |||
248 | spin_lock_irqsave(&clocks_lock, flags); | ||
249 | mask = (readl(clk->pclk_sel->pclk_sel_reg) >> clk->pclk_sel_shift) | ||
250 | & clk->pclk_sel->pclk_sel_mask; | ||
251 | |||
252 | for (i = 0; i < clk->pclk_sel->pclk_count; i++) { | ||
253 | if (clk->pclk_sel->pclk_info[i].pclk_mask == mask) | ||
254 | info = &clk->pclk_sel->pclk_info[i]; | ||
255 | } | ||
256 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
257 | |||
258 | return info; | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * Set pclk as cclk's parent and add clock sibling node to current parents | ||
263 | * children list | ||
264 | */ | ||
265 | static void change_parent(struct clk *cclk, struct clk *pclk) | ||
266 | { | ||
267 | unsigned long flags; | ||
268 | |||
269 | spin_lock_irqsave(&clocks_lock, flags); | ||
270 | list_del(&cclk->sibling); | ||
271 | list_add(&cclk->sibling, &pclk->children); | ||
272 | |||
273 | cclk->pclk = pclk; | ||
274 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | * calculates current programmed rate of pll1 | ||
279 | * | ||
280 | * In normal mode | ||
281 | * rate = (2 * M[15:8] * Fin)/(N * 2^P) | ||
282 | * | ||
283 | * In Dithered mode | ||
284 | * rate = (2 * M[15:0] * Fin)/(256 * N * 2^P) | ||
285 | */ | ||
286 | void pll1_clk_recalc(struct clk *clk) | ||
287 | { | ||
288 | struct pll_clk_config *config = clk->private_data; | ||
289 | unsigned int num = 2, den = 0, val, mode = 0; | ||
290 | unsigned long flags; | ||
291 | |||
292 | spin_lock_irqsave(&clocks_lock, flags); | ||
293 | mode = (readl(config->mode_reg) >> PLL_MODE_SHIFT) & | ||
294 | PLL_MODE_MASK; | ||
295 | |||
296 | val = readl(config->cfg_reg); | ||
297 | /* calculate denominator */ | ||
298 | den = (val >> PLL_DIV_P_SHIFT) & PLL_DIV_P_MASK; | ||
299 | den = 1 << den; | ||
300 | den *= (val >> PLL_DIV_N_SHIFT) & PLL_DIV_N_MASK; | ||
301 | |||
302 | /* calculate numerator & denominator */ | ||
303 | if (!mode) { | ||
304 | /* Normal mode */ | ||
305 | num *= (val >> PLL_NORM_FDBK_M_SHIFT) & PLL_NORM_FDBK_M_MASK; | ||
306 | } else { | ||
307 | /* Dithered mode */ | ||
308 | num *= (val >> PLL_DITH_FDBK_M_SHIFT) & PLL_DITH_FDBK_M_MASK; | ||
309 | den *= 256; | ||
310 | } | ||
311 | |||
312 | clk->rate = (((clk->pclk->rate/10000) * num) / den) * 10000; | ||
313 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
314 | } | ||
315 | |||
316 | /* calculates current programmed rate of ahb or apb bus */ | ||
317 | void bus_clk_recalc(struct clk *clk) | ||
318 | { | ||
319 | struct bus_clk_config *config = clk->private_data; | ||
320 | unsigned int div; | ||
321 | unsigned long flags; | ||
322 | |||
323 | spin_lock_irqsave(&clocks_lock, flags); | ||
324 | div = ((readl(config->reg) >> config->shift) & config->mask) + 1; | ||
325 | clk->rate = (unsigned long)clk->pclk->rate / div; | ||
326 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
327 | } | ||
328 | |||
329 | /* | ||
330 | * calculates current programmed rate of auxiliary synthesizers | ||
331 | * used by: UART, FIRDA | ||
332 | * | ||
333 | * Fout from synthesizer can be given from two equations: | ||
334 | * Fout1 = (Fin * X/Y)/2 | ||
335 | * Fout2 = Fin * X/Y | ||
336 | * | ||
337 | * Selection of eqn 1 or 2 is programmed in register | ||
338 | */ | ||
339 | void aux_clk_recalc(struct clk *clk) | ||
340 | { | ||
341 | struct aux_clk_config *config = clk->private_data; | ||
342 | struct pclk_info *pclk_info = NULL; | ||
343 | unsigned int num = 1, den = 1, val, eqn; | ||
344 | unsigned long flags; | ||
345 | |||
346 | /* get current programmed parent */ | ||
347 | pclk_info = pclk_info_get(clk); | ||
348 | if (!pclk_info) { | ||
349 | spin_lock_irqsave(&clocks_lock, flags); | ||
350 | clk->pclk = NULL; | ||
351 | clk->rate = 0; | ||
352 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
353 | return; | ||
354 | } | ||
355 | |||
356 | change_parent(clk, pclk_info->pclk); | ||
357 | |||
358 | spin_lock_irqsave(&clocks_lock, flags); | ||
359 | if (pclk_info->scalable) { | ||
360 | val = readl(config->synth_reg); | ||
361 | |||
362 | eqn = (val >> AUX_EQ_SEL_SHIFT) & AUX_EQ_SEL_MASK; | ||
363 | if (eqn == AUX_EQ1_SEL) | ||
364 | den *= 2; | ||
365 | |||
366 | /* calculate numerator */ | ||
367 | num = (val >> AUX_XSCALE_SHIFT) & AUX_XSCALE_MASK; | ||
368 | |||
369 | /* calculate denominator */ | ||
370 | den *= (val >> AUX_YSCALE_SHIFT) & AUX_YSCALE_MASK; | ||
371 | val = (((clk->pclk->rate/10000) * num) / den) * 10000; | ||
372 | } else | ||
373 | val = clk->pclk->rate; | ||
374 | |||
375 | clk->rate = val; | ||
376 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
377 | } | ||
378 | |||
379 | /* | ||
380 | * calculates current programmed rate of gpt synthesizers | ||
381 | * Fout from synthesizer can be given from below equations: | ||
382 | * Fout= Fin/((2 ^ (N+1)) * (M+1)) | ||
383 | */ | ||
384 | void gpt_clk_recalc(struct clk *clk) | ||
385 | { | ||
386 | struct aux_clk_config *config = clk->private_data; | ||
387 | struct pclk_info *pclk_info = NULL; | ||
388 | unsigned int div = 1, val; | ||
389 | unsigned long flags; | ||
390 | |||
391 | pclk_info = pclk_info_get(clk); | ||
392 | if (!pclk_info) { | ||
393 | spin_lock_irqsave(&clocks_lock, flags); | ||
394 | clk->pclk = NULL; | ||
395 | clk->rate = 0; | ||
396 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
397 | return; | ||
398 | } | ||
399 | |||
400 | change_parent(clk, pclk_info->pclk); | ||
401 | |||
402 | spin_lock_irqsave(&clocks_lock, flags); | ||
403 | if (pclk_info->scalable) { | ||
404 | val = readl(config->synth_reg); | ||
405 | div += (val >> GPT_MSCALE_SHIFT) & GPT_MSCALE_MASK; | ||
406 | div *= 1 << (((val >> GPT_NSCALE_SHIFT) & GPT_NSCALE_MASK) + 1); | ||
407 | } | ||
408 | |||
409 | clk->rate = (unsigned long)clk->pclk->rate / div; | ||
410 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
411 | } | ||
412 | |||
413 | /* | ||
414 | * Used for clocks that always have same value as the parent clock divided by a | ||
415 | * fixed divisor | ||
416 | */ | ||
417 | void follow_parent(struct clk *clk) | ||
418 | { | ||
419 | unsigned long flags; | ||
420 | |||
421 | spin_lock_irqsave(&clocks_lock, flags); | ||
422 | clk->rate = clk->pclk->rate; | ||
423 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * recalc_root_clocks - recalculate and propagate all root clocks | ||
428 | * | ||
429 | * Recalculates all root clocks (clocks with no parent), which if the | ||
430 | * clock's .recalc is set correctly, should also propagate their rates. | ||
431 | */ | ||
432 | void recalc_root_clocks(void) | ||
433 | { | ||
434 | propagate_rate(&root_clks); | ||
435 | } | ||
diff --git a/arch/arm/plat-spear/include/plat/clkdev.h b/arch/arm/plat-spear/include/plat/clkdev.h new file mode 100644 index 000000000000..a2d0112fcaf7 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/clkdev.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/clkdev.h | ||
3 | * | ||
4 | * Clock Dev framework definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_CLKDEV_H | ||
15 | #define __PLAT_CLKDEV_H | ||
16 | |||
17 | #define __clk_get(clk) ({ 1; }) | ||
18 | #define __clk_put(clk) do { } while (0) | ||
19 | |||
20 | #endif /* __PLAT_CLKDEV_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h new file mode 100644 index 000000000000..298bafc0a52f --- /dev/null +++ b/arch/arm/plat-spear/include/plat/clock.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/clock.h | ||
3 | * | ||
4 | * Clock framework definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_CLOCK_H | ||
15 | #define __PLAT_CLOCK_H | ||
16 | |||
17 | #include <linux/list.h> | ||
18 | #include <asm/clkdev.h> | ||
19 | #include <linux/types.h> | ||
20 | |||
21 | /* clk structure flags */ | ||
22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ | ||
23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ | ||
24 | |||
25 | /** | ||
26 | * struct clkops - clock operations | ||
27 | * @enable: pointer to clock enable function | ||
28 | * @disable: pointer to clock disable function | ||
29 | */ | ||
30 | struct clkops { | ||
31 | int (*enable) (struct clk *); | ||
32 | void (*disable) (struct clk *); | ||
33 | }; | ||
34 | |||
35 | /** | ||
36 | * struct pclk_info - parents info | ||
37 | * @pclk: pointer to parent clk | ||
38 | * @pclk_mask: value to be written for selecting this parent | ||
39 | * @scalable: Is parent scalable (1 - YES, 0 - NO) | ||
40 | */ | ||
41 | struct pclk_info { | ||
42 | struct clk *pclk; | ||
43 | u8 pclk_mask; | ||
44 | u8 scalable; | ||
45 | }; | ||
46 | |||
47 | /** | ||
48 | * struct pclk_sel - parents selection configuration | ||
49 | * @pclk_info: pointer to array of parent clock info | ||
50 | * @pclk_count: number of parents | ||
51 | * @pclk_sel_reg: register for selecting a parent | ||
52 | * @pclk_sel_mask: mask for selecting parent (can be used to clear bits also) | ||
53 | */ | ||
54 | struct pclk_sel { | ||
55 | struct pclk_info *pclk_info; | ||
56 | u8 pclk_count; | ||
57 | unsigned int *pclk_sel_reg; | ||
58 | unsigned int pclk_sel_mask; | ||
59 | }; | ||
60 | |||
61 | /** | ||
62 | * struct clk - clock structure | ||
63 | * @usage_count: num of users who enabled this clock | ||
64 | * @flags: flags for clock properties | ||
65 | * @rate: programmed clock rate in Hz | ||
66 | * @en_reg: clk enable/disable reg | ||
67 | * @en_reg_bit: clk enable/disable bit | ||
68 | * @ops: clk enable/disable ops - generic_clkops selected if NULL | ||
69 | * @recalc: pointer to clock rate recalculate function | ||
70 | * @pclk: current parent clk | ||
71 | * @pclk_sel: pointer to parent selection structure | ||
72 | * @pclk_sel_shift: register shift for selecting parent of this clock | ||
73 | * @children: list for childrens or this clock | ||
74 | * @sibling: node for list of clocks having same parents | ||
75 | * @private_data: clock specific private data | ||
76 | */ | ||
77 | struct clk { | ||
78 | unsigned int usage_count; | ||
79 | unsigned int flags; | ||
80 | unsigned long rate; | ||
81 | unsigned int *en_reg; | ||
82 | u8 en_reg_bit; | ||
83 | const struct clkops *ops; | ||
84 | void (*recalc) (struct clk *); | ||
85 | |||
86 | struct clk *pclk; | ||
87 | struct pclk_sel *pclk_sel; | ||
88 | unsigned int pclk_sel_shift; | ||
89 | |||
90 | struct list_head children; | ||
91 | struct list_head sibling; | ||
92 | void *private_data; | ||
93 | }; | ||
94 | |||
95 | /* pll configuration structure */ | ||
96 | struct pll_clk_config { | ||
97 | unsigned int *mode_reg; | ||
98 | unsigned int *cfg_reg; | ||
99 | }; | ||
100 | |||
101 | /* ahb and apb bus configuration structure */ | ||
102 | struct bus_clk_config { | ||
103 | unsigned int *reg; | ||
104 | unsigned int mask; | ||
105 | unsigned int shift; | ||
106 | }; | ||
107 | |||
108 | /* | ||
109 | * Aux clk configuration structure: applicable to GPT, UART and FIRDA | ||
110 | */ | ||
111 | struct aux_clk_config { | ||
112 | unsigned int *synth_reg; | ||
113 | }; | ||
114 | |||
115 | /* platform specific clock functions */ | ||
116 | void clk_register(struct clk_lookup *cl); | ||
117 | void recalc_root_clocks(void); | ||
118 | |||
119 | /* clock recalc functions */ | ||
120 | void follow_parent(struct clk *clk); | ||
121 | void pll1_clk_recalc(struct clk *clk); | ||
122 | void bus_clk_recalc(struct clk *clk); | ||
123 | void gpt_clk_recalc(struct clk *clk); | ||
124 | void aux_clk_recalc(struct clk *clk); | ||
125 | |||
126 | #endif /* __PLAT_CLOCK_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/debug-macro.S b/arch/arm/plat-spear/include/plat/debug-macro.S new file mode 100644 index 000000000000..1670734b7e51 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/debug-macro.S | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/debug-macro.S | ||
3 | * | ||
4 | * Debugging macro include header for spear platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/amba/serial.h> | ||
15 | #include <mach/spear.h> | ||
16 | |||
17 | .macro addruart, rx | ||
18 | mrc p15, 0, \rx, c1, c0 | ||
19 | tst \rx, #1 @ MMU enabled? | ||
20 | moveq \rx, =SPEAR_DBG_UART_BASE @ Physical base | ||
21 | movne \rx, =VA_SPEAR_DBG_UART_BASE @ Virtual base | ||
22 | .endm | ||
23 | |||
24 | .macro senduart, rd, rx | ||
25 | strb \rd, [\rx, #UART01x_DR] @ ASC_TX_BUFFER | ||
26 | .endm | ||
27 | |||
28 | .macro waituart, rd, rx | ||
29 | 1001: ldr \rd, [\rx, #UART01x_FR] @ FLAG REGISTER | ||
30 | tst \rd, #UART01x_FR_TXFF @ TX_FULL | ||
31 | bne 1001b | ||
32 | .endm | ||
33 | |||
34 | .macro busyuart, rd, rx | ||
35 | 1002: ldr \rd, [\rx, #UART01x_FR] @ FLAG REGISTER | ||
36 | tst \rd, #UART011_FR_TXFE @ TX_EMPTY | ||
37 | beq 1002b | ||
38 | .endm | ||
diff --git a/arch/arm/plat-spear/include/plat/gpio.h b/arch/arm/plat-spear/include/plat/gpio.h new file mode 100644 index 000000000000..b857c91257dd --- /dev/null +++ b/arch/arm/plat-spear/include/plat/gpio.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/gpio.h | ||
3 | * | ||
4 | * GPIO macros for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_GPIO_H | ||
15 | #define __PLAT_GPIO_H | ||
16 | |||
17 | #include <asm-generic/gpio.h> | ||
18 | |||
19 | #define gpio_get_value __gpio_get_value | ||
20 | #define gpio_set_value __gpio_set_value | ||
21 | #define gpio_cansleep __gpio_cansleep | ||
22 | #define gpio_to_irq __gpio_to_irq | ||
23 | |||
24 | #endif /* __PLAT_GPIO_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/io.h b/arch/arm/plat-spear/include/plat/io.h new file mode 100644 index 000000000000..4d4ba822b3eb --- /dev/null +++ b/arch/arm/plat-spear/include/plat/io.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/io.h | ||
3 | * | ||
4 | * IO definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_IO_H | ||
15 | #define __PLAT_IO_H | ||
16 | |||
17 | #define IO_SPACE_LIMIT 0xFFFFFFFF | ||
18 | |||
19 | #define __io(a) __typesafe_io(a) | ||
20 | #define __mem_pci(a) (a) | ||
21 | |||
22 | #endif /* __PLAT_IO_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/memory.h b/arch/arm/plat-spear/include/plat/memory.h new file mode 100644 index 000000000000..27a4aba77343 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/memory.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/memory.h | ||
3 | * | ||
4 | * Memory map for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_MEMORY_H | ||
15 | #define __PLAT_MEMORY_H | ||
16 | |||
17 | /* Physical DRAM offset */ | ||
18 | #define PHYS_OFFSET UL(0x00000000) | ||
19 | |||
20 | #endif /* __PLAT_MEMORY_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/padmux.h b/arch/arm/plat-spear/include/plat/padmux.h new file mode 100644 index 000000000000..877f3adcf610 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/padmux.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/padmux.h | ||
3 | * | ||
4 | * SPEAr platform specific gpio pads muxing file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_PADMUX_H | ||
15 | #define __PLAT_PADMUX_H | ||
16 | |||
17 | #include <linux/types.h> | ||
18 | |||
19 | /* | ||
20 | * struct pmx_reg: configuration structure for mode reg and mux reg | ||
21 | * | ||
22 | * offset: offset of mode reg | ||
23 | * mask: mask of mode reg | ||
24 | */ | ||
25 | struct pmx_reg { | ||
26 | u32 offset; | ||
27 | u32 mask; | ||
28 | }; | ||
29 | |||
30 | /* | ||
31 | * struct pmx_dev_mode: configuration structure every group of modes of a device | ||
32 | * | ||
33 | * ids: all modes for this configuration | ||
34 | * mask: mask for supported mode | ||
35 | */ | ||
36 | struct pmx_dev_mode { | ||
37 | u32 ids; | ||
38 | u32 mask; | ||
39 | }; | ||
40 | |||
41 | /* | ||
42 | * struct pmx_mode: mode definition structure | ||
43 | * | ||
44 | * name: mode name | ||
45 | * mask: mode mask | ||
46 | */ | ||
47 | struct pmx_mode { | ||
48 | char *name; | ||
49 | u32 id; | ||
50 | u32 mask; | ||
51 | }; | ||
52 | |||
53 | /* | ||
54 | * struct pmx_dev: device definition structure | ||
55 | * | ||
56 | * name: device name | ||
57 | * modes: device configuration array for different modes supported | ||
58 | * mode_count: size of modes array | ||
59 | * is_active: is peripheral active/enabled | ||
60 | * enb_on_reset: if 1, mask bits to be cleared in reg otherwise to be set in reg | ||
61 | */ | ||
62 | struct pmx_dev { | ||
63 | char *name; | ||
64 | struct pmx_dev_mode *modes; | ||
65 | u8 mode_count; | ||
66 | bool is_active; | ||
67 | bool enb_on_reset; | ||
68 | }; | ||
69 | |||
70 | /* | ||
71 | * struct pmx_driver: driver definition structure | ||
72 | * | ||
73 | * mode: mode to be set | ||
74 | * devs: array of pointer to pmx devices | ||
75 | * devs_count: ARRAY_SIZE of devs | ||
76 | * base: base address of soc config registers | ||
77 | * mode_reg: structure of mode config register | ||
78 | * mux_reg: structure of device mux config register | ||
79 | */ | ||
80 | struct pmx_driver { | ||
81 | struct pmx_mode *mode; | ||
82 | struct pmx_dev **devs; | ||
83 | u8 devs_count; | ||
84 | u32 *base; | ||
85 | struct pmx_reg mode_reg; | ||
86 | struct pmx_reg mux_reg; | ||
87 | }; | ||
88 | |||
89 | /* pmx functions */ | ||
90 | int pmx_register(struct pmx_driver *driver); | ||
91 | |||
92 | #endif /* __PLAT_PADMUX_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/shirq.h b/arch/arm/plat-spear/include/plat/shirq.h new file mode 100644 index 000000000000..03ed8b585dcf --- /dev/null +++ b/arch/arm/plat-spear/include/plat/shirq.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/shirq.h | ||
3 | * | ||
4 | * SPEAr platform shared irq layer header file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_SHIRQ_H | ||
15 | #define __PLAT_SHIRQ_H | ||
16 | |||
17 | #include <linux/irq.h> | ||
18 | #include <linux/types.h> | ||
19 | |||
20 | /* | ||
21 | * struct shirq_dev_config: shared irq device configuration | ||
22 | * | ||
23 | * virq: virtual irq number of device | ||
24 | * enb_mask: enable mask of device | ||
25 | * status_mask: status mask of device | ||
26 | * clear_mask: clear mask of device | ||
27 | */ | ||
28 | struct shirq_dev_config { | ||
29 | u32 virq; | ||
30 | u32 enb_mask; | ||
31 | u32 status_mask; | ||
32 | u32 clear_mask; | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * struct shirq_regs: shared irq register configuration | ||
37 | * | ||
38 | * base: base address of shared irq register | ||
39 | * enb_reg: enable register offset | ||
40 | * reset_to_enb: val 1 indicates, we need to clear bit for enabling interrupt | ||
41 | * status_reg: status register offset | ||
42 | * status_reg_mask: status register valid mask | ||
43 | * clear_reg: clear register offset | ||
44 | * reset_to_clear: val 1 indicates, we need to clear bit for clearing interrupt | ||
45 | */ | ||
46 | struct shirq_regs { | ||
47 | void __iomem *base; | ||
48 | u32 enb_reg; | ||
49 | u32 reset_to_enb; | ||
50 | u32 status_reg; | ||
51 | u32 status_reg_mask; | ||
52 | u32 clear_reg; | ||
53 | u32 reset_to_clear; | ||
54 | }; | ||
55 | |||
56 | /* | ||
57 | * struct spear_shirq: shared irq structure | ||
58 | * | ||
59 | * irq: hardware irq number | ||
60 | * dev_config: array of device config structures which are using "irq" line | ||
61 | * dev_count: size of dev_config array | ||
62 | * regs: register configuration for shared irq block | ||
63 | */ | ||
64 | struct spear_shirq { | ||
65 | u32 irq; | ||
66 | struct shirq_dev_config *dev_config; | ||
67 | u32 dev_count; | ||
68 | struct shirq_regs regs; | ||
69 | }; | ||
70 | |||
71 | int spear_shirq_register(struct spear_shirq *shirq); | ||
72 | |||
73 | #endif /* __PLAT_SHIRQ_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/system.h b/arch/arm/plat-spear/include/plat/system.h new file mode 100644 index 000000000000..55a4e405d578 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/system.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/system.h | ||
3 | * | ||
4 | * SPEAr platform specific architecture functions | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_SYSTEM_H | ||
15 | #define __PLAT_SYSTEM_H | ||
16 | |||
17 | #include <asm/hardware/sp810.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <mach/spear.h> | ||
20 | |||
21 | static inline void arch_idle(void) | ||
22 | { | ||
23 | /* | ||
24 | * This should do all the clock switching | ||
25 | * and wait for interrupt tricks | ||
26 | */ | ||
27 | cpu_do_idle(); | ||
28 | } | ||
29 | |||
30 | static inline void arch_reset(char mode, const char *cmd) | ||
31 | { | ||
32 | if (mode == 's') { | ||
33 | /* software reset, Jump into ROM at address 0 */ | ||
34 | cpu_reset(0); | ||
35 | } else { | ||
36 | /* hardware reset, Use on-chip reset capability */ | ||
37 | sysctl_soft_reset((void __iomem *)VA_SPEAR_SYS_CTRL_BASE); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | #endif /* __PLAT_SYSTEM_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/timex.h b/arch/arm/plat-spear/include/plat/timex.h new file mode 100644 index 000000000000..914d09dd50fd --- /dev/null +++ b/arch/arm/plat-spear/include/plat/timex.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/timex.h | ||
3 | * | ||
4 | * SPEAr platform specific timex definitions | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_TIMEX_H | ||
15 | #define __PLAT_TIMEX_H | ||
16 | |||
17 | #define CLOCK_TICK_RATE 48000000 | ||
18 | |||
19 | #endif /* __PLAT_TIMEX_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/uncompress.h b/arch/arm/plat-spear/include/plat/uncompress.h new file mode 100644 index 000000000000..99ba6789cc97 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/uncompress.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/uncompress.h | ||
3 | * | ||
4 | * Serial port stubs for kernel decompress status messages | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/io.h> | ||
15 | #include <linux/amba/serial.h> | ||
16 | #include <mach/spear.h> | ||
17 | |||
18 | #ifndef __PLAT_UNCOMPRESS_H | ||
19 | #define __PLAT_UNCOMPRESS_H | ||
20 | /* | ||
21 | * This does not append a newline | ||
22 | */ | ||
23 | static inline void putc(int c) | ||
24 | { | ||
25 | void __iomem *base = (void __iomem *)SPEAR_DBG_UART_BASE; | ||
26 | |||
27 | while (readl(base + UART01x_FR) & UART01x_FR_TXFF) | ||
28 | barrier(); | ||
29 | |||
30 | writel(c, base + UART01x_DR); | ||
31 | } | ||
32 | |||
33 | static inline void flush(void) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * nothing to do | ||
39 | */ | ||
40 | #define arch_decomp_setup() | ||
41 | #define arch_decomp_wdog() | ||
42 | |||
43 | #endif /* __PLAT_UNCOMPRESS_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/vmalloc.h b/arch/arm/plat-spear/include/plat/vmalloc.h new file mode 100644 index 000000000000..09e9372aea21 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/vmalloc.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/vmalloc.h | ||
3 | * | ||
4 | * Defining Vmalloc area for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_VMALLOC_H | ||
15 | #define __PLAT_VMALLOC_H | ||
16 | |||
17 | #define VMALLOC_END 0xF0000000 | ||
18 | |||
19 | #endif /* __PLAT_VMALLOC_H */ | ||
diff --git a/arch/arm/plat-spear/padmux.c b/arch/arm/plat-spear/padmux.c new file mode 100644 index 000000000000..d2aab3adcdeb --- /dev/null +++ b/arch/arm/plat-spear/padmux.c | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/padmux.c | ||
3 | * | ||
4 | * SPEAr platform specific gpio pads muxing source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/err.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <plat/padmux.h> | ||
18 | |||
19 | /* | ||
20 | * struct pmx: pmx definition structure | ||
21 | * | ||
22 | * base: base address of configuration registers | ||
23 | * mode_reg: mode configurations | ||
24 | * mux_reg: muxing configurations | ||
25 | * active_mode: pointer to current active mode | ||
26 | */ | ||
27 | struct pmx { | ||
28 | u32 base; | ||
29 | struct pmx_reg mode_reg; | ||
30 | struct pmx_reg mux_reg; | ||
31 | struct pmx_mode *active_mode; | ||
32 | }; | ||
33 | |||
34 | static struct pmx *pmx; | ||
35 | |||
36 | /** | ||
37 | * pmx_mode_set - Enables an multiplexing mode | ||
38 | * @mode - pointer to pmx mode | ||
39 | * | ||
40 | * It will set mode of operation in hardware. | ||
41 | * Returns -ve on Err otherwise 0 | ||
42 | */ | ||
43 | static int pmx_mode_set(struct pmx_mode *mode) | ||
44 | { | ||
45 | u32 val; | ||
46 | |||
47 | if (!mode->name) | ||
48 | return -EFAULT; | ||
49 | |||
50 | pmx->active_mode = mode; | ||
51 | |||
52 | val = readl(pmx->base + pmx->mode_reg.offset); | ||
53 | val &= ~pmx->mode_reg.mask; | ||
54 | val |= mode->mask & pmx->mode_reg.mask; | ||
55 | writel(val, pmx->base + pmx->mode_reg.offset); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * pmx_devs_enable - Enables list of devices | ||
62 | * @devs - pointer to pmx device array | ||
63 | * @count - number of devices to enable | ||
64 | * | ||
65 | * It will enable pads for all required peripherals once and only once. | ||
66 | * If peripheral is not supported by current mode then request is rejected. | ||
67 | * Conflicts between peripherals are not handled and peripherals will be | ||
68 | * enabled in the order they are present in pmx_dev array. | ||
69 | * In case of conflicts last peripheral enalbed will be present. | ||
70 | * Returns -ve on Err otherwise 0 | ||
71 | */ | ||
72 | static int pmx_devs_enable(struct pmx_dev **devs, u8 count) | ||
73 | { | ||
74 | u32 val, i, mask; | ||
75 | |||
76 | if (!count) | ||
77 | return -EINVAL; | ||
78 | |||
79 | val = readl(pmx->base + pmx->mux_reg.offset); | ||
80 | for (i = 0; i < count; i++) { | ||
81 | u8 j = 0; | ||
82 | |||
83 | if (!devs[i]->name || !devs[i]->modes) { | ||
84 | printk(KERN_ERR "padmux: dev name or modes is null\n"); | ||
85 | continue; | ||
86 | } | ||
87 | /* check if peripheral exists in active mode */ | ||
88 | if (pmx->active_mode) { | ||
89 | bool found = false; | ||
90 | for (j = 0; j < devs[i]->mode_count; j++) { | ||
91 | if (devs[i]->modes[j].ids & | ||
92 | pmx->active_mode->id) { | ||
93 | found = true; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | if (found == false) { | ||
98 | printk(KERN_ERR "%s device not available in %s"\ | ||
99 | "mode\n", devs[i]->name, | ||
100 | pmx->active_mode->name); | ||
101 | continue; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /* enable peripheral */ | ||
106 | mask = devs[i]->modes[j].mask & pmx->mux_reg.mask; | ||
107 | if (devs[i]->enb_on_reset) | ||
108 | val &= ~mask; | ||
109 | else | ||
110 | val |= mask; | ||
111 | |||
112 | devs[i]->is_active = true; | ||
113 | } | ||
114 | writel(val, pmx->base + pmx->mux_reg.offset); | ||
115 | kfree(pmx); | ||
116 | |||
117 | /* this will ensure that multiplexing can't be changed now */ | ||
118 | pmx = (struct pmx *)-1; | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * pmx_register - registers a platform requesting pad mux feature | ||
125 | * @driver - pointer to driver structure containing driver specific parameters | ||
126 | * | ||
127 | * Also this must be called only once. This will allocate memory for pmx | ||
128 | * structure, will call pmx_mode_set, will call pmx_devs_enable. | ||
129 | * Returns -ve on Err otherwise 0 | ||
130 | */ | ||
131 | int pmx_register(struct pmx_driver *driver) | ||
132 | { | ||
133 | int ret = 0; | ||
134 | |||
135 | if (pmx) | ||
136 | return -EPERM; | ||
137 | if (!driver->base || !driver->devs) | ||
138 | return -EFAULT; | ||
139 | |||
140 | pmx = kzalloc(sizeof(*pmx), GFP_KERNEL); | ||
141 | if (!pmx) | ||
142 | return -ENOMEM; | ||
143 | |||
144 | pmx->base = (u32)driver->base; | ||
145 | pmx->mode_reg.offset = driver->mode_reg.offset; | ||
146 | pmx->mode_reg.mask = driver->mode_reg.mask; | ||
147 | pmx->mux_reg.offset = driver->mux_reg.offset; | ||
148 | pmx->mux_reg.mask = driver->mux_reg.mask; | ||
149 | |||
150 | /* choose mode to enable */ | ||
151 | if (driver->mode) { | ||
152 | ret = pmx_mode_set(driver->mode); | ||
153 | if (ret) | ||
154 | goto pmx_fail; | ||
155 | } | ||
156 | ret = pmx_devs_enable(driver->devs, driver->devs_count); | ||
157 | if (ret) | ||
158 | goto pmx_fail; | ||
159 | |||
160 | return 0; | ||
161 | |||
162 | pmx_fail: | ||
163 | return ret; | ||
164 | } | ||
diff --git a/arch/arm/plat-spear/shirq.c b/arch/arm/plat-spear/shirq.c new file mode 100644 index 000000000000..2172d6946aea --- /dev/null +++ b/arch/arm/plat-spear/shirq.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/shirq.c | ||
3 | * | ||
4 | * SPEAr platform shared irq layer source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/err.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/irq.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | #include <plat/shirq.h> | ||
19 | |||
20 | struct spear_shirq *shirq; | ||
21 | static DEFINE_SPINLOCK(lock); | ||
22 | |||
23 | static void shirq_irq_mask(unsigned irq) | ||
24 | { | ||
25 | struct spear_shirq *shirq = get_irq_chip_data(irq); | ||
26 | u32 val, id = irq - shirq->dev_config[0].virq; | ||
27 | unsigned long flags; | ||
28 | |||
29 | if ((shirq->regs.enb_reg == -1) || shirq->dev_config[id].enb_mask == -1) | ||
30 | return; | ||
31 | |||
32 | spin_lock_irqsave(&lock, flags); | ||
33 | val = readl(shirq->regs.base + shirq->regs.enb_reg); | ||
34 | if (shirq->regs.reset_to_enb) | ||
35 | val |= shirq->dev_config[id].enb_mask; | ||
36 | else | ||
37 | val &= ~(shirq->dev_config[id].enb_mask); | ||
38 | writel(val, shirq->regs.base + shirq->regs.enb_reg); | ||
39 | spin_unlock_irqrestore(&lock, flags); | ||
40 | } | ||
41 | |||
42 | static void shirq_irq_unmask(unsigned irq) | ||
43 | { | ||
44 | struct spear_shirq *shirq = get_irq_chip_data(irq); | ||
45 | u32 val, id = irq - shirq->dev_config[0].virq; | ||
46 | unsigned long flags; | ||
47 | |||
48 | if ((shirq->regs.enb_reg == -1) || shirq->dev_config[id].enb_mask == -1) | ||
49 | return; | ||
50 | |||
51 | spin_lock_irqsave(&lock, flags); | ||
52 | val = readl(shirq->regs.base + shirq->regs.enb_reg); | ||
53 | if (shirq->regs.reset_to_enb) | ||
54 | val &= ~(shirq->dev_config[id].enb_mask); | ||
55 | else | ||
56 | val |= shirq->dev_config[id].enb_mask; | ||
57 | writel(val, shirq->regs.base + shirq->regs.enb_reg); | ||
58 | spin_unlock_irqrestore(&lock, flags); | ||
59 | } | ||
60 | |||
61 | static struct irq_chip shirq_chip = { | ||
62 | .name = "spear_shirq", | ||
63 | .ack = shirq_irq_mask, | ||
64 | .mask = shirq_irq_mask, | ||
65 | .unmask = shirq_irq_unmask, | ||
66 | }; | ||
67 | |||
68 | static void shirq_handler(unsigned irq, struct irq_desc *desc) | ||
69 | { | ||
70 | u32 i, val, mask; | ||
71 | struct spear_shirq *shirq = get_irq_data(irq); | ||
72 | |||
73 | desc->chip->ack(irq); | ||
74 | while ((val = readl(shirq->regs.base + shirq->regs.status_reg) & | ||
75 | shirq->regs.status_reg_mask)) { | ||
76 | for (i = 0; (i < shirq->dev_count) && val; i++) { | ||
77 | if (!(shirq->dev_config[i].status_mask & val)) | ||
78 | continue; | ||
79 | |||
80 | generic_handle_irq(shirq->dev_config[i].virq); | ||
81 | |||
82 | /* clear interrupt */ | ||
83 | val &= ~shirq->dev_config[i].status_mask; | ||
84 | if ((shirq->regs.clear_reg == -1) || | ||
85 | shirq->dev_config[i].clear_mask == -1) | ||
86 | continue; | ||
87 | mask = readl(shirq->regs.base + shirq->regs.clear_reg); | ||
88 | if (shirq->regs.reset_to_clear) | ||
89 | mask &= ~shirq->dev_config[i].clear_mask; | ||
90 | else | ||
91 | mask |= shirq->dev_config[i].clear_mask; | ||
92 | writel(mask, shirq->regs.base + shirq->regs.clear_reg); | ||
93 | } | ||
94 | } | ||
95 | desc->chip->unmask(irq); | ||
96 | } | ||
97 | |||
98 | int spear_shirq_register(struct spear_shirq *shirq) | ||
99 | { | ||
100 | int i; | ||
101 | |||
102 | if (!shirq || !shirq->dev_config || !shirq->regs.base) | ||
103 | return -EFAULT; | ||
104 | |||
105 | if (!shirq->dev_count) | ||
106 | return -EINVAL; | ||
107 | |||
108 | set_irq_chained_handler(shirq->irq, shirq_handler); | ||
109 | for (i = 0; i < shirq->dev_count; i++) { | ||
110 | set_irq_chip(shirq->dev_config[i].virq, &shirq_chip); | ||
111 | set_irq_handler(shirq->dev_config[i].virq, handle_simple_irq); | ||
112 | set_irq_flags(shirq->dev_config[i].virq, IRQF_VALID); | ||
113 | set_irq_chip_data(shirq->dev_config[i].virq, shirq); | ||
114 | } | ||
115 | |||
116 | set_irq_data(shirq->irq, shirq); | ||
117 | return 0; | ||
118 | } | ||
diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c new file mode 100644 index 000000000000..a1025d38f383 --- /dev/null +++ b/arch/arm/plat-spear/time.c | |||
@@ -0,0 +1,292 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/time.c | ||
3 | * | ||
4 | * Copyright (C) 2009 ST Microelectronics | ||
5 | * Shiraz Hashim<shiraz.hashim@st.com> | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/clk.h> | ||
13 | #include <linux/clockchips.h> | ||
14 | #include <linux/clocksource.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/time.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <asm/mach/time.h> | ||
23 | #include <mach/irqs.h> | ||
24 | #include <mach/hardware.h> | ||
25 | #include <mach/spear.h> | ||
26 | #include <mach/generic.h> | ||
27 | |||
28 | /* | ||
29 | * We would use TIMER0 and TIMER1 as clockevent and clocksource. | ||
30 | * Timer0 and Timer1 both belong to same gpt block in cpu subbsystem. Further | ||
31 | * they share same functional clock. Any change in one's functional clock will | ||
32 | * also affect other timer. | ||
33 | */ | ||
34 | |||
35 | #define CLKEVT 0 /* gpt0, channel0 as clockevent */ | ||
36 | #define CLKSRC 1 /* gpt0, channel1 as clocksource */ | ||
37 | |||
38 | /* Register offsets, x is channel number */ | ||
39 | #define CR(x) ((x) * 0x80 + 0x80) | ||
40 | #define IR(x) ((x) * 0x80 + 0x84) | ||
41 | #define LOAD(x) ((x) * 0x80 + 0x88) | ||
42 | #define COUNT(x) ((x) * 0x80 + 0x8C) | ||
43 | |||
44 | /* Reg bit definitions */ | ||
45 | #define CTRL_INT_ENABLE 0x0100 | ||
46 | #define CTRL_ENABLE 0x0020 | ||
47 | #define CTRL_ONE_SHOT 0x0010 | ||
48 | |||
49 | #define CTRL_PRESCALER1 0x0 | ||
50 | #define CTRL_PRESCALER2 0x1 | ||
51 | #define CTRL_PRESCALER4 0x2 | ||
52 | #define CTRL_PRESCALER8 0x3 | ||
53 | #define CTRL_PRESCALER16 0x4 | ||
54 | #define CTRL_PRESCALER32 0x5 | ||
55 | #define CTRL_PRESCALER64 0x6 | ||
56 | #define CTRL_PRESCALER128 0x7 | ||
57 | #define CTRL_PRESCALER256 0x8 | ||
58 | |||
59 | #define INT_STATUS 0x1 | ||
60 | |||
61 | static __iomem void *gpt_base; | ||
62 | static struct clk *gpt_clk; | ||
63 | |||
64 | static void clockevent_set_mode(enum clock_event_mode mode, | ||
65 | struct clock_event_device *clk_event_dev); | ||
66 | static int clockevent_next_event(unsigned long evt, | ||
67 | struct clock_event_device *clk_event_dev); | ||
68 | |||
69 | /* | ||
70 | * Following clocksource_set_clock and clockevent_set_clock picked | ||
71 | * from arch/mips/kernel/time.c | ||
72 | */ | ||
73 | |||
74 | void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock) | ||
75 | { | ||
76 | u64 temp; | ||
77 | u32 shift; | ||
78 | |||
79 | /* Find a shift value */ | ||
80 | for (shift = 32; shift > 0; shift--) { | ||
81 | temp = (u64) NSEC_PER_SEC << shift; | ||
82 | do_div(temp, clock); | ||
83 | if ((temp >> 32) == 0) | ||
84 | break; | ||
85 | } | ||
86 | cs->shift = shift; | ||
87 | cs->mult = (u32) temp; | ||
88 | } | ||
89 | |||
90 | void __init clockevent_set_clock(struct clock_event_device *cd, | ||
91 | unsigned int clock) | ||
92 | { | ||
93 | u64 temp; | ||
94 | u32 shift; | ||
95 | |||
96 | /* Find a shift value */ | ||
97 | for (shift = 32; shift > 0; shift--) { | ||
98 | temp = (u64) clock << shift; | ||
99 | do_div(temp, NSEC_PER_SEC); | ||
100 | if ((temp >> 32) == 0) | ||
101 | break; | ||
102 | } | ||
103 | cd->shift = shift; | ||
104 | cd->mult = (u32) temp; | ||
105 | } | ||
106 | |||
107 | static cycle_t clocksource_read_cycles(struct clocksource *cs) | ||
108 | { | ||
109 | return (cycle_t) readw(gpt_base + COUNT(CLKSRC)); | ||
110 | } | ||
111 | |||
112 | static struct clocksource clksrc = { | ||
113 | .name = "tmr1", | ||
114 | .rating = 200, /* its a pretty decent clock */ | ||
115 | .read = clocksource_read_cycles, | ||
116 | .mask = 0xFFFF, /* 16 bits */ | ||
117 | .mult = 0, /* to be computed */ | ||
118 | .shift = 0, /* to be computed */ | ||
119 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
120 | }; | ||
121 | |||
122 | static void spear_clocksource_init(void) | ||
123 | { | ||
124 | u32 tick_rate; | ||
125 | u16 val; | ||
126 | |||
127 | /* program the prescaler (/256)*/ | ||
128 | writew(CTRL_PRESCALER256, gpt_base + CR(CLKSRC)); | ||
129 | |||
130 | /* find out actual clock driving Timer */ | ||
131 | tick_rate = clk_get_rate(gpt_clk); | ||
132 | tick_rate >>= CTRL_PRESCALER256; | ||
133 | |||
134 | writew(0xFFFF, gpt_base + LOAD(CLKSRC)); | ||
135 | |||
136 | val = readw(gpt_base + CR(CLKSRC)); | ||
137 | val &= ~CTRL_ONE_SHOT; /* autoreload mode */ | ||
138 | val |= CTRL_ENABLE ; | ||
139 | writew(val, gpt_base + CR(CLKSRC)); | ||
140 | |||
141 | clocksource_set_clock(&clksrc, tick_rate); | ||
142 | |||
143 | /* register the clocksource */ | ||
144 | clocksource_register(&clksrc); | ||
145 | } | ||
146 | |||
147 | static struct clock_event_device clkevt = { | ||
148 | .name = "tmr0", | ||
149 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | ||
150 | .set_mode = clockevent_set_mode, | ||
151 | .set_next_event = clockevent_next_event, | ||
152 | .shift = 0, /* to be computed */ | ||
153 | }; | ||
154 | |||
155 | static void clockevent_set_mode(enum clock_event_mode mode, | ||
156 | struct clock_event_device *clk_event_dev) | ||
157 | { | ||
158 | u32 period; | ||
159 | u16 val; | ||
160 | |||
161 | /* stop the timer */ | ||
162 | val = readw(gpt_base + CR(CLKEVT)); | ||
163 | val &= ~CTRL_ENABLE; | ||
164 | writew(val, gpt_base + CR(CLKEVT)); | ||
165 | |||
166 | switch (mode) { | ||
167 | case CLOCK_EVT_MODE_PERIODIC: | ||
168 | period = clk_get_rate(gpt_clk) / HZ; | ||
169 | period >>= CTRL_PRESCALER16; | ||
170 | writew(period, gpt_base + LOAD(CLKEVT)); | ||
171 | |||
172 | val = readw(gpt_base + CR(CLKEVT)); | ||
173 | val &= ~CTRL_ONE_SHOT; | ||
174 | val |= CTRL_ENABLE | CTRL_INT_ENABLE; | ||
175 | writew(val, gpt_base + CR(CLKEVT)); | ||
176 | |||
177 | break; | ||
178 | case CLOCK_EVT_MODE_ONESHOT: | ||
179 | val = readw(gpt_base + CR(CLKEVT)); | ||
180 | val |= CTRL_ONE_SHOT; | ||
181 | writew(val, gpt_base + CR(CLKEVT)); | ||
182 | |||
183 | break; | ||
184 | case CLOCK_EVT_MODE_UNUSED: | ||
185 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
186 | case CLOCK_EVT_MODE_RESUME: | ||
187 | |||
188 | break; | ||
189 | default: | ||
190 | pr_err("Invalid mode requested\n"); | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | static int clockevent_next_event(unsigned long cycles, | ||
196 | struct clock_event_device *clk_event_dev) | ||
197 | { | ||
198 | u16 val; | ||
199 | |||
200 | writew(cycles, gpt_base + LOAD(CLKEVT)); | ||
201 | |||
202 | val = readw(gpt_base + CR(CLKEVT)); | ||
203 | val |= CTRL_ENABLE | CTRL_INT_ENABLE; | ||
204 | writew(val, gpt_base + CR(CLKEVT)); | ||
205 | |||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static irqreturn_t spear_timer_interrupt(int irq, void *dev_id) | ||
210 | { | ||
211 | struct clock_event_device *evt = &clkevt; | ||
212 | |||
213 | writew(INT_STATUS, gpt_base + IR(CLKEVT)); | ||
214 | |||
215 | evt->event_handler(evt); | ||
216 | |||
217 | return IRQ_HANDLED; | ||
218 | } | ||
219 | |||
220 | static struct irqaction spear_timer_irq = { | ||
221 | .name = "timer", | ||
222 | .flags = IRQF_DISABLED | IRQF_TIMER, | ||
223 | .handler = spear_timer_interrupt | ||
224 | }; | ||
225 | |||
226 | static void __init spear_clockevent_init(void) | ||
227 | { | ||
228 | u32 tick_rate; | ||
229 | |||
230 | /* program the prescaler */ | ||
231 | writew(CTRL_PRESCALER16, gpt_base + CR(CLKEVT)); | ||
232 | |||
233 | tick_rate = clk_get_rate(gpt_clk); | ||
234 | tick_rate >>= CTRL_PRESCALER16; | ||
235 | |||
236 | clockevent_set_clock(&clkevt, tick_rate); | ||
237 | |||
238 | clkevt.max_delta_ns = clockevent_delta2ns(0xfff0, | ||
239 | &clkevt); | ||
240 | clkevt.min_delta_ns = clockevent_delta2ns(3, &clkevt); | ||
241 | |||
242 | clkevt.cpumask = cpumask_of(0); | ||
243 | |||
244 | clockevents_register_device(&clkevt); | ||
245 | |||
246 | setup_irq(SPEAR_GPT0_CHAN0_IRQ, &spear_timer_irq); | ||
247 | } | ||
248 | |||
249 | void __init spear_setup_timer(void) | ||
250 | { | ||
251 | struct clk *pll3_clk; | ||
252 | |||
253 | if (!request_mem_region(SPEAR_GPT0_BASE, SZ_1K, "gpt0")) { | ||
254 | pr_err("%s:cannot get IO addr\n", __func__); | ||
255 | return; | ||
256 | } | ||
257 | |||
258 | gpt_base = (void __iomem *)ioremap(SPEAR_GPT0_BASE, SZ_1K); | ||
259 | if (!gpt_base) { | ||
260 | pr_err("%s:ioremap failed for gpt\n", __func__); | ||
261 | goto err_mem; | ||
262 | } | ||
263 | |||
264 | gpt_clk = clk_get_sys("gpt0", NULL); | ||
265 | if (!gpt_clk) { | ||
266 | pr_err("%s:couldn't get clk for gpt\n", __func__); | ||
267 | goto err_iomap; | ||
268 | } | ||
269 | |||
270 | pll3_clk = clk_get(NULL, "pll3_48m_clk"); | ||
271 | if (!pll3_clk) { | ||
272 | pr_err("%s:couldn't get PLL3 as parent for gpt\n", __func__); | ||
273 | goto err_iomap; | ||
274 | } | ||
275 | |||
276 | clk_set_parent(gpt_clk, pll3_clk); | ||
277 | |||
278 | spear_clockevent_init(); | ||
279 | spear_clocksource_init(); | ||
280 | |||
281 | return; | ||
282 | |||
283 | err_iomap: | ||
284 | iounmap(gpt_base); | ||
285 | |||
286 | err_mem: | ||
287 | release_mem_region(SPEAR_GPT0_BASE, SZ_1K); | ||
288 | } | ||
289 | |||
290 | struct sys_timer spear_sys_timer = { | ||
291 | .init = spear_setup_timer, | ||
292 | }; | ||