diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/arm/mach-s3c2412 | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/arm/mach-s3c2412')
-rw-r--r-- | arch/arm/mach-s3c2412/clock.c | 756 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/dma.c | 195 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/irq.c | 212 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/mach-jive.c | 664 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/mach-smdk2413.c | 160 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/mach-vstms.c | 166 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/pm.c | 122 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/s3c2412.c | 254 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/sleep.S | 68 |
9 files changed, 2597 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c2412/clock.c new file mode 100644 index 00000000000..140711db6c8 --- /dev/null +++ b/arch/arm/mach-s3c2412/clock.c | |||
@@ -0,0 +1,756 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/clock.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2412,S3C2413 Clock control support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/err.h> | ||
29 | #include <linux/sysdev.h> | ||
30 | #include <linux/clk.h> | ||
31 | #include <linux/mutex.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/serial_core.h> | ||
34 | #include <linux/io.h> | ||
35 | |||
36 | #include <asm/mach/map.h> | ||
37 | |||
38 | #include <mach/hardware.h> | ||
39 | |||
40 | #include <plat/regs-serial.h> | ||
41 | #include <mach/regs-clock.h> | ||
42 | #include <mach/regs-gpio.h> | ||
43 | |||
44 | #include <plat/s3c2412.h> | ||
45 | #include <plat/clock.h> | ||
46 | #include <plat/cpu.h> | ||
47 | |||
48 | /* We currently have to assume that the system is running | ||
49 | * from the XTPll input, and that all ***REFCLKs are being | ||
50 | * fed from it, as we cannot read the state of OM[4] from | ||
51 | * software. | ||
52 | * | ||
53 | * It would be possible for each board initialisation to | ||
54 | * set the correct muxing at initialisation | ||
55 | */ | ||
56 | |||
57 | static int s3c2412_clkcon_enable(struct clk *clk, int enable) | ||
58 | { | ||
59 | unsigned int clocks = clk->ctrlbit; | ||
60 | unsigned long clkcon; | ||
61 | |||
62 | clkcon = __raw_readl(S3C2410_CLKCON); | ||
63 | |||
64 | if (enable) | ||
65 | clkcon |= clocks; | ||
66 | else | ||
67 | clkcon &= ~clocks; | ||
68 | |||
69 | __raw_writel(clkcon, S3C2410_CLKCON); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int s3c2412_upll_enable(struct clk *clk, int enable) | ||
75 | { | ||
76 | unsigned long upllcon = __raw_readl(S3C2410_UPLLCON); | ||
77 | unsigned long orig = upllcon; | ||
78 | |||
79 | if (!enable) | ||
80 | upllcon |= S3C2412_PLLCON_OFF; | ||
81 | else | ||
82 | upllcon &= ~S3C2412_PLLCON_OFF; | ||
83 | |||
84 | __raw_writel(upllcon, S3C2410_UPLLCON); | ||
85 | |||
86 | /* allow ~150uS for the PLL to settle and lock */ | ||
87 | |||
88 | if (enable && (orig & S3C2412_PLLCON_OFF)) | ||
89 | udelay(150); | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | /* clock selections */ | ||
95 | |||
96 | static struct clk clk_erefclk = { | ||
97 | .name = "erefclk", | ||
98 | }; | ||
99 | |||
100 | static struct clk clk_urefclk = { | ||
101 | .name = "urefclk", | ||
102 | }; | ||
103 | |||
104 | static int s3c2412_setparent_usysclk(struct clk *clk, struct clk *parent) | ||
105 | { | ||
106 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
107 | |||
108 | if (parent == &clk_urefclk) | ||
109 | clksrc &= ~S3C2412_CLKSRC_USYSCLK_UPLL; | ||
110 | else if (parent == &clk_upll) | ||
111 | clksrc |= S3C2412_CLKSRC_USYSCLK_UPLL; | ||
112 | else | ||
113 | return -EINVAL; | ||
114 | |||
115 | clk->parent = parent; | ||
116 | |||
117 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static struct clk clk_usysclk = { | ||
122 | .name = "usysclk", | ||
123 | .parent = &clk_xtal, | ||
124 | .ops = &(struct clk_ops) { | ||
125 | .set_parent = s3c2412_setparent_usysclk, | ||
126 | }, | ||
127 | }; | ||
128 | |||
129 | static struct clk clk_mrefclk = { | ||
130 | .name = "mrefclk", | ||
131 | .parent = &clk_xtal, | ||
132 | }; | ||
133 | |||
134 | static struct clk clk_mdivclk = { | ||
135 | .name = "mdivclk", | ||
136 | .parent = &clk_xtal, | ||
137 | }; | ||
138 | |||
139 | static int s3c2412_setparent_usbsrc(struct clk *clk, struct clk *parent) | ||
140 | { | ||
141 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
142 | |||
143 | if (parent == &clk_usysclk) | ||
144 | clksrc &= ~S3C2412_CLKSRC_USBCLK_HCLK; | ||
145 | else if (parent == &clk_h) | ||
146 | clksrc |= S3C2412_CLKSRC_USBCLK_HCLK; | ||
147 | else | ||
148 | return -EINVAL; | ||
149 | |||
150 | clk->parent = parent; | ||
151 | |||
152 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | static unsigned long s3c2412_roundrate_usbsrc(struct clk *clk, | ||
157 | unsigned long rate) | ||
158 | { | ||
159 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
160 | int div; | ||
161 | |||
162 | if (rate > parent_rate) | ||
163 | return parent_rate; | ||
164 | |||
165 | div = parent_rate / rate; | ||
166 | if (div > 2) | ||
167 | div = 2; | ||
168 | |||
169 | return parent_rate / div; | ||
170 | } | ||
171 | |||
172 | static unsigned long s3c2412_getrate_usbsrc(struct clk *clk) | ||
173 | { | ||
174 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
175 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
176 | |||
177 | return parent_rate / ((div & S3C2412_CLKDIVN_USB48DIV) ? 2 : 1); | ||
178 | } | ||
179 | |||
180 | static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate) | ||
181 | { | ||
182 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
183 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
184 | |||
185 | rate = s3c2412_roundrate_usbsrc(clk, rate); | ||
186 | |||
187 | if ((parent_rate / rate) == 2) | ||
188 | clkdivn |= S3C2412_CLKDIVN_USB48DIV; | ||
189 | else | ||
190 | clkdivn &= ~S3C2412_CLKDIVN_USB48DIV; | ||
191 | |||
192 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static struct clk clk_usbsrc = { | ||
197 | .name = "usbsrc", | ||
198 | .ops = &(struct clk_ops) { | ||
199 | .get_rate = s3c2412_getrate_usbsrc, | ||
200 | .set_rate = s3c2412_setrate_usbsrc, | ||
201 | .round_rate = s3c2412_roundrate_usbsrc, | ||
202 | .set_parent = s3c2412_setparent_usbsrc, | ||
203 | }, | ||
204 | }; | ||
205 | |||
206 | static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent) | ||
207 | { | ||
208 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
209 | |||
210 | if (parent == &clk_mdivclk) | ||
211 | clksrc &= ~S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
212 | else if (parent == &clk_mpll) | ||
213 | clksrc |= S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
214 | else | ||
215 | return -EINVAL; | ||
216 | |||
217 | clk->parent = parent; | ||
218 | |||
219 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | static struct clk clk_msysclk = { | ||
224 | .name = "msysclk", | ||
225 | .ops = &(struct clk_ops) { | ||
226 | .set_parent = s3c2412_setparent_msysclk, | ||
227 | }, | ||
228 | }; | ||
229 | |||
230 | static int s3c2412_setparent_armclk(struct clk *clk, struct clk *parent) | ||
231 | { | ||
232 | unsigned long flags; | ||
233 | unsigned long clkdiv; | ||
234 | unsigned long dvs; | ||
235 | |||
236 | /* Note, we current equate fclk andf msysclk for S3C2412 */ | ||
237 | |||
238 | if (parent == &clk_msysclk || parent == &clk_f) | ||
239 | dvs = 0; | ||
240 | else if (parent == &clk_h) | ||
241 | dvs = S3C2412_CLKDIVN_DVSEN; | ||
242 | else | ||
243 | return -EINVAL; | ||
244 | |||
245 | clk->parent = parent; | ||
246 | |||
247 | /* update this under irq lockdown, clkdivn is not protected | ||
248 | * by the clock system. */ | ||
249 | |||
250 | local_irq_save(flags); | ||
251 | |||
252 | clkdiv = __raw_readl(S3C2410_CLKDIVN); | ||
253 | clkdiv &= ~S3C2412_CLKDIVN_DVSEN; | ||
254 | clkdiv |= dvs; | ||
255 | __raw_writel(clkdiv, S3C2410_CLKDIVN); | ||
256 | |||
257 | local_irq_restore(flags); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static struct clk clk_armclk = { | ||
263 | .name = "armclk", | ||
264 | .parent = &clk_msysclk, | ||
265 | .ops = &(struct clk_ops) { | ||
266 | .set_parent = s3c2412_setparent_armclk, | ||
267 | }, | ||
268 | }; | ||
269 | |||
270 | /* these next clocks have an divider immediately after them, | ||
271 | * so we can register them with their divider and leave out the | ||
272 | * intermediate clock stage | ||
273 | */ | ||
274 | static unsigned long s3c2412_roundrate_clksrc(struct clk *clk, | ||
275 | unsigned long rate) | ||
276 | { | ||
277 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
278 | int div; | ||
279 | |||
280 | if (rate > parent_rate) | ||
281 | return parent_rate; | ||
282 | |||
283 | /* note, we remove the +/- 1 calculations as they cancel out */ | ||
284 | |||
285 | div = (rate / parent_rate); | ||
286 | |||
287 | if (div < 1) | ||
288 | div = 1; | ||
289 | else if (div > 16) | ||
290 | div = 16; | ||
291 | |||
292 | return parent_rate / div; | ||
293 | } | ||
294 | |||
295 | static int s3c2412_setparent_uart(struct clk *clk, struct clk *parent) | ||
296 | { | ||
297 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
298 | |||
299 | if (parent == &clk_erefclk) | ||
300 | clksrc &= ~S3C2412_CLKSRC_UARTCLK_MPLL; | ||
301 | else if (parent == &clk_mpll) | ||
302 | clksrc |= S3C2412_CLKSRC_UARTCLK_MPLL; | ||
303 | else | ||
304 | return -EINVAL; | ||
305 | |||
306 | clk->parent = parent; | ||
307 | |||
308 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static unsigned long s3c2412_getrate_uart(struct clk *clk) | ||
313 | { | ||
314 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
315 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
316 | |||
317 | div &= S3C2412_CLKDIVN_UARTDIV_MASK; | ||
318 | div >>= S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
319 | |||
320 | return parent_rate / (div + 1); | ||
321 | } | ||
322 | |||
323 | static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate) | ||
324 | { | ||
325 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
326 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
327 | |||
328 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
329 | |||
330 | clkdivn &= ~S3C2412_CLKDIVN_UARTDIV_MASK; | ||
331 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
332 | |||
333 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | static struct clk clk_uart = { | ||
338 | .name = "uartclk", | ||
339 | .ops = &(struct clk_ops) { | ||
340 | .get_rate = s3c2412_getrate_uart, | ||
341 | .set_rate = s3c2412_setrate_uart, | ||
342 | .set_parent = s3c2412_setparent_uart, | ||
343 | .round_rate = s3c2412_roundrate_clksrc, | ||
344 | }, | ||
345 | }; | ||
346 | |||
347 | static int s3c2412_setparent_i2s(struct clk *clk, struct clk *parent) | ||
348 | { | ||
349 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
350 | |||
351 | if (parent == &clk_erefclk) | ||
352 | clksrc &= ~S3C2412_CLKSRC_I2SCLK_MPLL; | ||
353 | else if (parent == &clk_mpll) | ||
354 | clksrc |= S3C2412_CLKSRC_I2SCLK_MPLL; | ||
355 | else | ||
356 | return -EINVAL; | ||
357 | |||
358 | clk->parent = parent; | ||
359 | |||
360 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static unsigned long s3c2412_getrate_i2s(struct clk *clk) | ||
365 | { | ||
366 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
367 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
368 | |||
369 | div &= S3C2412_CLKDIVN_I2SDIV_MASK; | ||
370 | div >>= S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
371 | |||
372 | return parent_rate / (div + 1); | ||
373 | } | ||
374 | |||
375 | static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate) | ||
376 | { | ||
377 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
378 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
379 | |||
380 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
381 | |||
382 | clkdivn &= ~S3C2412_CLKDIVN_I2SDIV_MASK; | ||
383 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
384 | |||
385 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static struct clk clk_i2s = { | ||
390 | .name = "i2sclk", | ||
391 | .ops = &(struct clk_ops) { | ||
392 | .get_rate = s3c2412_getrate_i2s, | ||
393 | .set_rate = s3c2412_setrate_i2s, | ||
394 | .set_parent = s3c2412_setparent_i2s, | ||
395 | .round_rate = s3c2412_roundrate_clksrc, | ||
396 | }, | ||
397 | }; | ||
398 | |||
399 | static int s3c2412_setparent_cam(struct clk *clk, struct clk *parent) | ||
400 | { | ||
401 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
402 | |||
403 | if (parent == &clk_usysclk) | ||
404 | clksrc &= ~S3C2412_CLKSRC_CAMCLK_HCLK; | ||
405 | else if (parent == &clk_h) | ||
406 | clksrc |= S3C2412_CLKSRC_CAMCLK_HCLK; | ||
407 | else | ||
408 | return -EINVAL; | ||
409 | |||
410 | clk->parent = parent; | ||
411 | |||
412 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
413 | return 0; | ||
414 | } | ||
415 | static unsigned long s3c2412_getrate_cam(struct clk *clk) | ||
416 | { | ||
417 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
418 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
419 | |||
420 | div &= S3C2412_CLKDIVN_CAMDIV_MASK; | ||
421 | div >>= S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
422 | |||
423 | return parent_rate / (div + 1); | ||
424 | } | ||
425 | |||
426 | static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate) | ||
427 | { | ||
428 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
429 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
430 | |||
431 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
432 | |||
433 | clkdivn &= ~S3C2412_CLKDIVN_CAMDIV_MASK; | ||
434 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
435 | |||
436 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
437 | return 0; | ||
438 | } | ||
439 | |||
440 | static struct clk clk_cam = { | ||
441 | .name = "camif-upll", /* same as 2440 name */ | ||
442 | .ops = &(struct clk_ops) { | ||
443 | .get_rate = s3c2412_getrate_cam, | ||
444 | .set_rate = s3c2412_setrate_cam, | ||
445 | .set_parent = s3c2412_setparent_cam, | ||
446 | .round_rate = s3c2412_roundrate_clksrc, | ||
447 | }, | ||
448 | }; | ||
449 | |||
450 | /* standard clock definitions */ | ||
451 | |||
452 | static struct clk init_clocks_disable[] = { | ||
453 | { | ||
454 | .name = "nand", | ||
455 | .parent = &clk_h, | ||
456 | .enable = s3c2412_clkcon_enable, | ||
457 | .ctrlbit = S3C2412_CLKCON_NAND, | ||
458 | }, { | ||
459 | .name = "sdi", | ||
460 | .parent = &clk_p, | ||
461 | .enable = s3c2412_clkcon_enable, | ||
462 | .ctrlbit = S3C2412_CLKCON_SDI, | ||
463 | }, { | ||
464 | .name = "adc", | ||
465 | .parent = &clk_p, | ||
466 | .enable = s3c2412_clkcon_enable, | ||
467 | .ctrlbit = S3C2412_CLKCON_ADC, | ||
468 | }, { | ||
469 | .name = "i2c", | ||
470 | .parent = &clk_p, | ||
471 | .enable = s3c2412_clkcon_enable, | ||
472 | .ctrlbit = S3C2412_CLKCON_IIC, | ||
473 | }, { | ||
474 | .name = "iis", | ||
475 | .parent = &clk_p, | ||
476 | .enable = s3c2412_clkcon_enable, | ||
477 | .ctrlbit = S3C2412_CLKCON_IIS, | ||
478 | }, { | ||
479 | .name = "spi", | ||
480 | .parent = &clk_p, | ||
481 | .enable = s3c2412_clkcon_enable, | ||
482 | .ctrlbit = S3C2412_CLKCON_SPI, | ||
483 | } | ||
484 | }; | ||
485 | |||
486 | static struct clk init_clocks[] = { | ||
487 | { | ||
488 | .name = "dma", | ||
489 | .parent = &clk_h, | ||
490 | .enable = s3c2412_clkcon_enable, | ||
491 | .ctrlbit = S3C2412_CLKCON_DMA0, | ||
492 | }, { | ||
493 | .name = "dma", | ||
494 | .parent = &clk_h, | ||
495 | .enable = s3c2412_clkcon_enable, | ||
496 | .ctrlbit = S3C2412_CLKCON_DMA1, | ||
497 | }, { | ||
498 | .name = "dma", | ||
499 | .parent = &clk_h, | ||
500 | .enable = s3c2412_clkcon_enable, | ||
501 | .ctrlbit = S3C2412_CLKCON_DMA2, | ||
502 | }, { | ||
503 | .name = "dma", | ||
504 | .parent = &clk_h, | ||
505 | .enable = s3c2412_clkcon_enable, | ||
506 | .ctrlbit = S3C2412_CLKCON_DMA3, | ||
507 | }, { | ||
508 | .name = "lcd", | ||
509 | .parent = &clk_h, | ||
510 | .enable = s3c2412_clkcon_enable, | ||
511 | .ctrlbit = S3C2412_CLKCON_LCDC, | ||
512 | }, { | ||
513 | .name = "gpio", | ||
514 | .parent = &clk_p, | ||
515 | .enable = s3c2412_clkcon_enable, | ||
516 | .ctrlbit = S3C2412_CLKCON_GPIO, | ||
517 | }, { | ||
518 | .name = "usb-host", | ||
519 | .parent = &clk_h, | ||
520 | .enable = s3c2412_clkcon_enable, | ||
521 | .ctrlbit = S3C2412_CLKCON_USBH, | ||
522 | }, { | ||
523 | .name = "usb-device", | ||
524 | .parent = &clk_h, | ||
525 | .enable = s3c2412_clkcon_enable, | ||
526 | .ctrlbit = S3C2412_CLKCON_USBD, | ||
527 | }, { | ||
528 | .name = "timers", | ||
529 | .parent = &clk_p, | ||
530 | .enable = s3c2412_clkcon_enable, | ||
531 | .ctrlbit = S3C2412_CLKCON_PWMT, | ||
532 | }, { | ||
533 | .name = "uart", | ||
534 | .devname = "s3c2412-uart.0", | ||
535 | .parent = &clk_p, | ||
536 | .enable = s3c2412_clkcon_enable, | ||
537 | .ctrlbit = S3C2412_CLKCON_UART0, | ||
538 | }, { | ||
539 | .name = "uart", | ||
540 | .devname = "s3c2412-uart.1", | ||
541 | .parent = &clk_p, | ||
542 | .enable = s3c2412_clkcon_enable, | ||
543 | .ctrlbit = S3C2412_CLKCON_UART1, | ||
544 | }, { | ||
545 | .name = "uart", | ||
546 | .devname = "s3c2412-uart.2", | ||
547 | .parent = &clk_p, | ||
548 | .enable = s3c2412_clkcon_enable, | ||
549 | .ctrlbit = S3C2412_CLKCON_UART2, | ||
550 | }, { | ||
551 | .name = "rtc", | ||
552 | .parent = &clk_p, | ||
553 | .enable = s3c2412_clkcon_enable, | ||
554 | .ctrlbit = S3C2412_CLKCON_RTC, | ||
555 | }, { | ||
556 | .name = "watchdog", | ||
557 | .parent = &clk_p, | ||
558 | .ctrlbit = 0, | ||
559 | }, { | ||
560 | .name = "usb-bus-gadget", | ||
561 | .parent = &clk_usb_bus, | ||
562 | .enable = s3c2412_clkcon_enable, | ||
563 | .ctrlbit = S3C2412_CLKCON_USB_DEV48, | ||
564 | }, { | ||
565 | .name = "usb-bus-host", | ||
566 | .parent = &clk_usb_bus, | ||
567 | .enable = s3c2412_clkcon_enable, | ||
568 | .ctrlbit = S3C2412_CLKCON_USB_HOST48, | ||
569 | } | ||
570 | }; | ||
571 | |||
572 | /* clocks to add where we need to check their parentage */ | ||
573 | |||
574 | struct clk_init { | ||
575 | struct clk *clk; | ||
576 | unsigned int bit; | ||
577 | struct clk *src_0; | ||
578 | struct clk *src_1; | ||
579 | }; | ||
580 | |||
581 | static struct clk_init clks_src[] __initdata = { | ||
582 | { | ||
583 | .clk = &clk_usysclk, | ||
584 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
585 | .src_0 = &clk_urefclk, | ||
586 | .src_1 = &clk_upll, | ||
587 | }, { | ||
588 | .clk = &clk_i2s, | ||
589 | .bit = S3C2412_CLKSRC_I2SCLK_MPLL, | ||
590 | .src_0 = &clk_erefclk, | ||
591 | .src_1 = &clk_mpll, | ||
592 | }, { | ||
593 | .clk = &clk_cam, | ||
594 | .bit = S3C2412_CLKSRC_CAMCLK_HCLK, | ||
595 | .src_0 = &clk_usysclk, | ||
596 | .src_1 = &clk_h, | ||
597 | }, { | ||
598 | .clk = &clk_msysclk, | ||
599 | .bit = S3C2412_CLKSRC_MSYSCLK_MPLL, | ||
600 | .src_0 = &clk_mdivclk, | ||
601 | .src_1 = &clk_mpll, | ||
602 | }, { | ||
603 | .clk = &clk_uart, | ||
604 | .bit = S3C2412_CLKSRC_UARTCLK_MPLL, | ||
605 | .src_0 = &clk_erefclk, | ||
606 | .src_1 = &clk_mpll, | ||
607 | }, { | ||
608 | .clk = &clk_usbsrc, | ||
609 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
610 | .src_0 = &clk_usysclk, | ||
611 | .src_1 = &clk_h, | ||
612 | /* here we assume OM[4] select xtal */ | ||
613 | }, { | ||
614 | .clk = &clk_erefclk, | ||
615 | .bit = S3C2412_CLKSRC_EREFCLK_EXTCLK, | ||
616 | .src_0 = &clk_xtal, | ||
617 | .src_1 = &clk_ext, | ||
618 | }, { | ||
619 | .clk = &clk_urefclk, | ||
620 | .bit = S3C2412_CLKSRC_UREFCLK_EXTCLK, | ||
621 | .src_0 = &clk_xtal, | ||
622 | .src_1 = &clk_ext, | ||
623 | }, | ||
624 | }; | ||
625 | |||
626 | /* s3c2412_clk_initparents | ||
627 | * | ||
628 | * Initialise the parents for the clocks that we get at start-time | ||
629 | */ | ||
630 | |||
631 | static void __init s3c2412_clk_initparents(void) | ||
632 | { | ||
633 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
634 | struct clk_init *cip = clks_src; | ||
635 | struct clk *src; | ||
636 | int ptr; | ||
637 | int ret; | ||
638 | |||
639 | for (ptr = 0; ptr < ARRAY_SIZE(clks_src); ptr++, cip++) { | ||
640 | ret = s3c24xx_register_clock(cip->clk); | ||
641 | if (ret < 0) { | ||
642 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
643 | cip->clk->name, ret); | ||
644 | } | ||
645 | |||
646 | src = (clksrc & cip->bit) ? cip->src_1 : cip->src_0; | ||
647 | |||
648 | printk(KERN_INFO "%s: parent %s\n", cip->clk->name, src->name); | ||
649 | clk_set_parent(cip->clk, src); | ||
650 | } | ||
651 | } | ||
652 | |||
653 | /* clocks to add straight away */ | ||
654 | |||
655 | static struct clk *clks[] __initdata = { | ||
656 | &clk_ext, | ||
657 | &clk_usb_bus, | ||
658 | &clk_mrefclk, | ||
659 | &clk_armclk, | ||
660 | }; | ||
661 | |||
662 | int __init s3c2412_baseclk_add(void) | ||
663 | { | ||
664 | unsigned long clkcon = __raw_readl(S3C2410_CLKCON); | ||
665 | unsigned int dvs; | ||
666 | struct clk *clkp; | ||
667 | int ret; | ||
668 | int ptr; | ||
669 | |||
670 | clk_upll.enable = s3c2412_upll_enable; | ||
671 | clk_usb_bus.parent = &clk_usbsrc; | ||
672 | clk_usb_bus.rate = 0x0; | ||
673 | |||
674 | clk_f.parent = &clk_msysclk; | ||
675 | |||
676 | s3c2412_clk_initparents(); | ||
677 | |||
678 | for (ptr = 0; ptr < ARRAY_SIZE(clks); ptr++) { | ||
679 | clkp = clks[ptr]; | ||
680 | |||
681 | ret = s3c24xx_register_clock(clkp); | ||
682 | if (ret < 0) { | ||
683 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
684 | clkp->name, ret); | ||
685 | } | ||
686 | } | ||
687 | |||
688 | /* set the dvs state according to what we got at boot time */ | ||
689 | |||
690 | dvs = __raw_readl(S3C2410_CLKDIVN) & S3C2412_CLKDIVN_DVSEN; | ||
691 | |||
692 | if (dvs) | ||
693 | clk_armclk.parent = &clk_h; | ||
694 | |||
695 | printk(KERN_INFO "S3C2412: DVS is %s\n", dvs ? "on" : "off"); | ||
696 | |||
697 | /* ensure usb bus clock is within correct rate of 48MHz */ | ||
698 | |||
699 | if (clk_get_rate(&clk_usb_bus) != (48 * 1000 * 1000)) { | ||
700 | printk(KERN_INFO "Warning: USB bus clock not at 48MHz\n"); | ||
701 | |||
702 | /* for the moment, let's use the UPLL, and see if we can | ||
703 | * get 48MHz */ | ||
704 | |||
705 | clk_set_parent(&clk_usysclk, &clk_upll); | ||
706 | clk_set_parent(&clk_usbsrc, &clk_usysclk); | ||
707 | clk_set_rate(&clk_usbsrc, 48*1000*1000); | ||
708 | } | ||
709 | |||
710 | printk("S3C2412: upll %s, %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", | ||
711 | (__raw_readl(S3C2410_UPLLCON) & S3C2412_PLLCON_OFF) ? "off":"on", | ||
712 | print_mhz(clk_get_rate(&clk_upll)), | ||
713 | print_mhz(clk_get_rate(&clk_usb_bus))); | ||
714 | |||
715 | /* register clocks from clock array */ | ||
716 | |||
717 | clkp = init_clocks; | ||
718 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { | ||
719 | /* ensure that we note the clock state */ | ||
720 | |||
721 | clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0; | ||
722 | |||
723 | ret = s3c24xx_register_clock(clkp); | ||
724 | if (ret < 0) { | ||
725 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
726 | clkp->name, ret); | ||
727 | } | ||
728 | } | ||
729 | |||
730 | /* We must be careful disabling the clocks we are not intending to | ||
731 | * be using at boot time, as subsystems such as the LCD which do | ||
732 | * their own DMA requests to the bus can cause the system to lockup | ||
733 | * if they where in the middle of requesting bus access. | ||
734 | * | ||
735 | * Disabling the LCD clock if the LCD is active is very dangerous, | ||
736 | * and therefore the bootloader should be careful to not enable | ||
737 | * the LCD clock if it is not needed. | ||
738 | */ | ||
739 | |||
740 | /* install (and disable) the clocks we do not need immediately */ | ||
741 | |||
742 | clkp = init_clocks_disable; | ||
743 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) { | ||
744 | |||
745 | ret = s3c24xx_register_clock(clkp); | ||
746 | if (ret < 0) { | ||
747 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
748 | clkp->name, ret); | ||
749 | } | ||
750 | |||
751 | s3c2412_clkcon_enable(clkp, 0); | ||
752 | } | ||
753 | |||
754 | s3c_pwmclk_init(); | ||
755 | return 0; | ||
756 | } | ||
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c2412/dma.c new file mode 100644 index 00000000000..7abecfca0b7 --- /dev/null +++ b/arch/arm/mach-s3c2412/dma.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/dma.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2412 DMA selection | ||
7 | * | ||
8 | * http://armlinux.simtec.co.uk/ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/sysdev.h> | ||
18 | #include <linux/serial_core.h> | ||
19 | #include <linux/io.h> | ||
20 | |||
21 | #include <mach/dma.h> | ||
22 | |||
23 | #include <plat/dma-s3c24xx.h> | ||
24 | #include <plat/cpu.h> | ||
25 | |||
26 | #include <plat/regs-serial.h> | ||
27 | #include <mach/regs-gpio.h> | ||
28 | #include <plat/regs-ac97.h> | ||
29 | #include <plat/regs-dma.h> | ||
30 | #include <mach/regs-mem.h> | ||
31 | #include <mach/regs-lcd.h> | ||
32 | #include <mach/regs-sdi.h> | ||
33 | #include <plat/regs-iis.h> | ||
34 | #include <plat/regs-spi.h> | ||
35 | |||
36 | #define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID } | ||
37 | |||
38 | static struct s3c24xx_dma_map __initdata s3c2412_dma_mappings[] = { | ||
39 | [DMACH_XD0] = { | ||
40 | .name = "xdreq0", | ||
41 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ0), | ||
42 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ0), | ||
43 | }, | ||
44 | [DMACH_XD1] = { | ||
45 | .name = "xdreq1", | ||
46 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ1), | ||
47 | .channels_rx = MAP(S3C2412_DMAREQSEL_XDREQ1), | ||
48 | }, | ||
49 | [DMACH_SDI] = { | ||
50 | .name = "sdi", | ||
51 | .channels = MAP(S3C2412_DMAREQSEL_SDI), | ||
52 | .channels_rx = MAP(S3C2412_DMAREQSEL_SDI), | ||
53 | .hw_addr.to = S3C2410_PA_SDI + S3C2410_SDIDATA, | ||
54 | .hw_addr.from = S3C2410_PA_SDI + S3C2410_SDIDATA, | ||
55 | }, | ||
56 | [DMACH_SPI0] = { | ||
57 | .name = "spi0", | ||
58 | .channels = MAP(S3C2412_DMAREQSEL_SPI0TX), | ||
59 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI0RX), | ||
60 | .hw_addr.to = S3C2410_PA_SPI + S3C2410_SPTDAT, | ||
61 | .hw_addr.from = S3C2410_PA_SPI + S3C2410_SPRDAT, | ||
62 | }, | ||
63 | [DMACH_SPI1] = { | ||
64 | .name = "spi1", | ||
65 | .channels = MAP(S3C2412_DMAREQSEL_SPI1TX), | ||
66 | .channels_rx = MAP(S3C2412_DMAREQSEL_SPI1RX), | ||
67 | .hw_addr.to = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPTDAT, | ||
68 | .hw_addr.from = S3C2410_PA_SPI + S3C2412_SPI1 + S3C2410_SPRDAT, | ||
69 | }, | ||
70 | [DMACH_UART0] = { | ||
71 | .name = "uart0", | ||
72 | .channels = MAP(S3C2412_DMAREQSEL_UART0_0), | ||
73 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_0), | ||
74 | .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH, | ||
75 | .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH, | ||
76 | }, | ||
77 | [DMACH_UART1] = { | ||
78 | .name = "uart1", | ||
79 | .channels = MAP(S3C2412_DMAREQSEL_UART1_0), | ||
80 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_0), | ||
81 | .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH, | ||
82 | .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH, | ||
83 | }, | ||
84 | [DMACH_UART2] = { | ||
85 | .name = "uart2", | ||
86 | .channels = MAP(S3C2412_DMAREQSEL_UART2_0), | ||
87 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_0), | ||
88 | .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH, | ||
89 | .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH, | ||
90 | }, | ||
91 | [DMACH_UART0_SRC2] = { | ||
92 | .name = "uart0", | ||
93 | .channels = MAP(S3C2412_DMAREQSEL_UART0_1), | ||
94 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART0_1), | ||
95 | .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH, | ||
96 | .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH, | ||
97 | }, | ||
98 | [DMACH_UART1_SRC2] = { | ||
99 | .name = "uart1", | ||
100 | .channels = MAP(S3C2412_DMAREQSEL_UART1_1), | ||
101 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART1_1), | ||
102 | .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH, | ||
103 | .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH, | ||
104 | }, | ||
105 | [DMACH_UART2_SRC2] = { | ||
106 | .name = "uart2", | ||
107 | .channels = MAP(S3C2412_DMAREQSEL_UART2_1), | ||
108 | .channels_rx = MAP(S3C2412_DMAREQSEL_UART2_1), | ||
109 | .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH, | ||
110 | .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH, | ||
111 | }, | ||
112 | [DMACH_TIMER] = { | ||
113 | .name = "timer", | ||
114 | .channels = MAP(S3C2412_DMAREQSEL_TIMER), | ||
115 | .channels_rx = MAP(S3C2412_DMAREQSEL_TIMER), | ||
116 | }, | ||
117 | [DMACH_I2S_IN] = { | ||
118 | .name = "i2s-sdi", | ||
119 | .channels = MAP(S3C2412_DMAREQSEL_I2SRX), | ||
120 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2SRX), | ||
121 | }, | ||
122 | [DMACH_I2S_OUT] = { | ||
123 | .name = "i2s-sdo", | ||
124 | .channels = MAP(S3C2412_DMAREQSEL_I2STX), | ||
125 | .channels_rx = MAP(S3C2412_DMAREQSEL_I2STX), | ||
126 | }, | ||
127 | [DMACH_USB_EP1] = { | ||
128 | .name = "usb-ep1", | ||
129 | .channels = MAP(S3C2412_DMAREQSEL_USBEP1), | ||
130 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP1), | ||
131 | }, | ||
132 | [DMACH_USB_EP2] = { | ||
133 | .name = "usb-ep2", | ||
134 | .channels = MAP(S3C2412_DMAREQSEL_USBEP2), | ||
135 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP2), | ||
136 | }, | ||
137 | [DMACH_USB_EP3] = { | ||
138 | .name = "usb-ep3", | ||
139 | .channels = MAP(S3C2412_DMAREQSEL_USBEP3), | ||
140 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP3), | ||
141 | }, | ||
142 | [DMACH_USB_EP4] = { | ||
143 | .name = "usb-ep4", | ||
144 | .channels = MAP(S3C2412_DMAREQSEL_USBEP4), | ||
145 | .channels_rx = MAP(S3C2412_DMAREQSEL_USBEP4), | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | static void s3c2412_dma_direction(struct s3c2410_dma_chan *chan, | ||
150 | struct s3c24xx_dma_map *map, | ||
151 | enum s3c2410_dmasrc dir) | ||
152 | { | ||
153 | unsigned long chsel; | ||
154 | |||
155 | if (dir == S3C2410_DMASRC_HW) | ||
156 | chsel = map->channels_rx[0]; | ||
157 | else | ||
158 | chsel = map->channels[0]; | ||
159 | |||
160 | chsel &= ~DMA_CH_VALID; | ||
161 | chsel |= S3C2412_DMAREQSEL_HW; | ||
162 | |||
163 | writel(chsel, chan->regs + S3C2412_DMA_DMAREQSEL); | ||
164 | } | ||
165 | |||
166 | static void s3c2412_dma_select(struct s3c2410_dma_chan *chan, | ||
167 | struct s3c24xx_dma_map *map) | ||
168 | { | ||
169 | s3c2412_dma_direction(chan, map, chan->source); | ||
170 | } | ||
171 | |||
172 | static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = { | ||
173 | .select = s3c2412_dma_select, | ||
174 | .direction = s3c2412_dma_direction, | ||
175 | .dcon_mask = 0, | ||
176 | .map = s3c2412_dma_mappings, | ||
177 | .map_size = ARRAY_SIZE(s3c2412_dma_mappings), | ||
178 | }; | ||
179 | |||
180 | static int __init s3c2412_dma_add(struct sys_device *sysdev) | ||
181 | { | ||
182 | s3c2410_dma_init(); | ||
183 | return s3c24xx_dma_init_map(&s3c2412_dma_sel); | ||
184 | } | ||
185 | |||
186 | static struct sysdev_driver s3c2412_dma_driver = { | ||
187 | .add = s3c2412_dma_add, | ||
188 | }; | ||
189 | |||
190 | static int __init s3c2412_dma_init(void) | ||
191 | { | ||
192 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver); | ||
193 | } | ||
194 | |||
195 | arch_initcall(s3c2412_dma_init); | ||
diff --git a/arch/arm/mach-s3c2412/irq.c b/arch/arm/mach-s3c2412/irq.c new file mode 100644 index 00000000000..1a1aa220972 --- /dev/null +++ b/arch/arm/mach-s3c2412/irq.c | |||
@@ -0,0 +1,212 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/irq.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/ioport.h> | ||
26 | #include <linux/sysdev.h> | ||
27 | #include <linux/io.h> | ||
28 | |||
29 | #include <mach/hardware.h> | ||
30 | #include <asm/irq.h> | ||
31 | |||
32 | #include <asm/mach/irq.h> | ||
33 | |||
34 | #include <mach/regs-irq.h> | ||
35 | #include <mach/regs-gpio.h> | ||
36 | #include <mach/regs-power.h> | ||
37 | |||
38 | #include <plat/cpu.h> | ||
39 | #include <plat/irq.h> | ||
40 | #include <plat/pm.h> | ||
41 | |||
42 | #define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1) | ||
43 | #define INTMSK_SUB(start, end) (INTMSK(start, end) << ((start - S3C2410_IRQSUB(0)))) | ||
44 | |||
45 | /* the s3c2412 changes the behaviour of IRQ_EINT0 through IRQ_EINT3 by | ||
46 | * having them turn up in both the INT* and the EINT* registers. Whilst | ||
47 | * both show the status, they both now need to be acked when the IRQs | ||
48 | * go off. | ||
49 | */ | ||
50 | |||
51 | static void | ||
52 | s3c2412_irq_mask(struct irq_data *data) | ||
53 | { | ||
54 | unsigned long bitval = 1UL << (data->irq - IRQ_EINT0); | ||
55 | unsigned long mask; | ||
56 | |||
57 | mask = __raw_readl(S3C2410_INTMSK); | ||
58 | __raw_writel(mask | bitval, S3C2410_INTMSK); | ||
59 | |||
60 | mask = __raw_readl(S3C2412_EINTMASK); | ||
61 | __raw_writel(mask | bitval, S3C2412_EINTMASK); | ||
62 | } | ||
63 | |||
64 | static inline void | ||
65 | s3c2412_irq_ack(struct irq_data *data) | ||
66 | { | ||
67 | unsigned long bitval = 1UL << (data->irq - IRQ_EINT0); | ||
68 | |||
69 | __raw_writel(bitval, S3C2412_EINTPEND); | ||
70 | __raw_writel(bitval, S3C2410_SRCPND); | ||
71 | __raw_writel(bitval, S3C2410_INTPND); | ||
72 | } | ||
73 | |||
74 | static inline void | ||
75 | s3c2412_irq_maskack(struct irq_data *data) | ||
76 | { | ||
77 | unsigned long bitval = 1UL << (data->irq - IRQ_EINT0); | ||
78 | unsigned long mask; | ||
79 | |||
80 | mask = __raw_readl(S3C2410_INTMSK); | ||
81 | __raw_writel(mask|bitval, S3C2410_INTMSK); | ||
82 | |||
83 | mask = __raw_readl(S3C2412_EINTMASK); | ||
84 | __raw_writel(mask | bitval, S3C2412_EINTMASK); | ||
85 | |||
86 | __raw_writel(bitval, S3C2412_EINTPEND); | ||
87 | __raw_writel(bitval, S3C2410_SRCPND); | ||
88 | __raw_writel(bitval, S3C2410_INTPND); | ||
89 | } | ||
90 | |||
91 | static void | ||
92 | s3c2412_irq_unmask(struct irq_data *data) | ||
93 | { | ||
94 | unsigned long bitval = 1UL << (data->irq - IRQ_EINT0); | ||
95 | unsigned long mask; | ||
96 | |||
97 | mask = __raw_readl(S3C2412_EINTMASK); | ||
98 | __raw_writel(mask & ~bitval, S3C2412_EINTMASK); | ||
99 | |||
100 | mask = __raw_readl(S3C2410_INTMSK); | ||
101 | __raw_writel(mask & ~bitval, S3C2410_INTMSK); | ||
102 | } | ||
103 | |||
104 | static struct irq_chip s3c2412_irq_eint0t4 = { | ||
105 | .irq_ack = s3c2412_irq_ack, | ||
106 | .irq_mask = s3c2412_irq_mask, | ||
107 | .irq_unmask = s3c2412_irq_unmask, | ||
108 | .irq_set_wake = s3c_irq_wake, | ||
109 | .irq_set_type = s3c_irqext_type, | ||
110 | }; | ||
111 | |||
112 | #define INTBIT(x) (1 << ((x) - S3C2410_IRQSUB(0))) | ||
113 | |||
114 | /* CF and SDI sub interrupts */ | ||
115 | |||
116 | static void s3c2412_irq_demux_cfsdi(unsigned int irq, struct irq_desc *desc) | ||
117 | { | ||
118 | unsigned int subsrc, submsk; | ||
119 | |||
120 | subsrc = __raw_readl(S3C2410_SUBSRCPND); | ||
121 | submsk = __raw_readl(S3C2410_INTSUBMSK); | ||
122 | |||
123 | subsrc &= ~submsk; | ||
124 | |||
125 | if (subsrc & INTBIT(IRQ_S3C2412_SDI)) | ||
126 | generic_handle_irq(IRQ_S3C2412_SDI); | ||
127 | |||
128 | if (subsrc & INTBIT(IRQ_S3C2412_CF)) | ||
129 | generic_handle_irq(IRQ_S3C2412_CF); | ||
130 | } | ||
131 | |||
132 | #define INTMSK_CFSDI (1UL << (IRQ_S3C2412_CFSDI - IRQ_EINT0)) | ||
133 | #define SUBMSK_CFSDI INTMSK_SUB(IRQ_S3C2412_SDI, IRQ_S3C2412_CF) | ||
134 | |||
135 | static void s3c2412_irq_cfsdi_mask(struct irq_data *data) | ||
136 | { | ||
137 | s3c_irqsub_mask(data->irq, INTMSK_CFSDI, SUBMSK_CFSDI); | ||
138 | } | ||
139 | |||
140 | static void s3c2412_irq_cfsdi_unmask(struct irq_data *data) | ||
141 | { | ||
142 | s3c_irqsub_unmask(data->irq, INTMSK_CFSDI); | ||
143 | } | ||
144 | |||
145 | static void s3c2412_irq_cfsdi_ack(struct irq_data *data) | ||
146 | { | ||
147 | s3c_irqsub_maskack(data->irq, INTMSK_CFSDI, SUBMSK_CFSDI); | ||
148 | } | ||
149 | |||
150 | static struct irq_chip s3c2412_irq_cfsdi = { | ||
151 | .name = "s3c2412-cfsdi", | ||
152 | .irq_ack = s3c2412_irq_cfsdi_ack, | ||
153 | .irq_mask = s3c2412_irq_cfsdi_mask, | ||
154 | .irq_unmask = s3c2412_irq_cfsdi_unmask, | ||
155 | }; | ||
156 | |||
157 | static int s3c2412_irq_rtc_wake(struct irq_data *data, unsigned int state) | ||
158 | { | ||
159 | unsigned long pwrcfg; | ||
160 | |||
161 | pwrcfg = __raw_readl(S3C2412_PWRCFG); | ||
162 | if (state) | ||
163 | pwrcfg &= ~S3C2412_PWRCFG_RTC_MASKIRQ; | ||
164 | else | ||
165 | pwrcfg |= S3C2412_PWRCFG_RTC_MASKIRQ; | ||
166 | __raw_writel(pwrcfg, S3C2412_PWRCFG); | ||
167 | |||
168 | return s3c_irq_chip.irq_set_wake(data, state); | ||
169 | } | ||
170 | |||
171 | static struct irq_chip s3c2412_irq_rtc_chip; | ||
172 | |||
173 | static int s3c2412_irq_add(struct sys_device *sysdev) | ||
174 | { | ||
175 | unsigned int irqno; | ||
176 | |||
177 | for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) { | ||
178 | irq_set_chip_and_handler(irqno, &s3c2412_irq_eint0t4, | ||
179 | handle_edge_irq); | ||
180 | set_irq_flags(irqno, IRQF_VALID); | ||
181 | } | ||
182 | |||
183 | /* add demux support for CF/SDI */ | ||
184 | |||
185 | irq_set_chained_handler(IRQ_S3C2412_CFSDI, s3c2412_irq_demux_cfsdi); | ||
186 | |||
187 | for (irqno = IRQ_S3C2412_SDI; irqno <= IRQ_S3C2412_CF; irqno++) { | ||
188 | irq_set_chip_and_handler(irqno, &s3c2412_irq_cfsdi, | ||
189 | handle_level_irq); | ||
190 | set_irq_flags(irqno, IRQF_VALID); | ||
191 | } | ||
192 | |||
193 | /* change RTC IRQ's set wake method */ | ||
194 | |||
195 | s3c2412_irq_rtc_chip = s3c_irq_chip; | ||
196 | s3c2412_irq_rtc_chip.irq_set_wake = s3c2412_irq_rtc_wake; | ||
197 | |||
198 | irq_set_chip(IRQ_RTC, &s3c2412_irq_rtc_chip); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static struct sysdev_driver s3c2412_irq_driver = { | ||
204 | .add = s3c2412_irq_add, | ||
205 | }; | ||
206 | |||
207 | static int s3c2412_irq_init(void) | ||
208 | { | ||
209 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_irq_driver); | ||
210 | } | ||
211 | |||
212 | arch_initcall(s3c2412_irq_init); | ||
diff --git a/arch/arm/mach-s3c2412/mach-jive.c b/arch/arm/mach-s3c2412/mach-jive.c new file mode 100644 index 00000000000..5eeb47580b0 --- /dev/null +++ b/arch/arm/mach-s3c2412/mach-jive.c | |||
@@ -0,0 +1,664 @@ | |||
1 | /* linux/arch/arm/mach-s3c2410/mach-jive.c | ||
2 | * | ||
3 | * Copyright 2007 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/timer.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/gpio.h> | ||
20 | #include <linux/syscore_ops.h> | ||
21 | #include <linux/serial_core.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/i2c.h> | ||
24 | |||
25 | #include <video/ili9320.h> | ||
26 | |||
27 | #include <linux/spi/spi.h> | ||
28 | #include <linux/spi/spi_gpio.h> | ||
29 | |||
30 | #include <asm/mach/arch.h> | ||
31 | #include <asm/mach/map.h> | ||
32 | #include <asm/mach/irq.h> | ||
33 | |||
34 | #include <plat/regs-serial.h> | ||
35 | #include <plat/nand.h> | ||
36 | #include <plat/iic.h> | ||
37 | |||
38 | #include <mach/regs-power.h> | ||
39 | #include <mach/regs-gpio.h> | ||
40 | #include <mach/regs-mem.h> | ||
41 | #include <mach/regs-lcd.h> | ||
42 | #include <mach/fb.h> | ||
43 | |||
44 | #include <asm/mach-types.h> | ||
45 | |||
46 | #include <linux/mtd/mtd.h> | ||
47 | #include <linux/mtd/nand.h> | ||
48 | #include <linux/mtd/nand_ecc.h> | ||
49 | #include <linux/mtd/partitions.h> | ||
50 | |||
51 | #include <plat/gpio-cfg.h> | ||
52 | #include <plat/clock.h> | ||
53 | #include <plat/devs.h> | ||
54 | #include <plat/cpu.h> | ||
55 | #include <plat/pm.h> | ||
56 | #include <plat/udc.h> | ||
57 | |||
58 | static struct map_desc jive_iodesc[] __initdata = { | ||
59 | }; | ||
60 | |||
61 | #define UCON S3C2410_UCON_DEFAULT | ||
62 | #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | ||
63 | #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE | ||
64 | |||
65 | static struct s3c2410_uartcfg jive_uartcfgs[] = { | ||
66 | [0] = { | ||
67 | .hwport = 0, | ||
68 | .flags = 0, | ||
69 | .ucon = UCON, | ||
70 | .ulcon = ULCON, | ||
71 | .ufcon = UFCON, | ||
72 | }, | ||
73 | [1] = { | ||
74 | .hwport = 1, | ||
75 | .flags = 0, | ||
76 | .ucon = UCON, | ||
77 | .ulcon = ULCON, | ||
78 | .ufcon = UFCON, | ||
79 | }, | ||
80 | [2] = { | ||
81 | .hwport = 2, | ||
82 | .flags = 0, | ||
83 | .ucon = UCON, | ||
84 | .ulcon = ULCON, | ||
85 | .ufcon = UFCON, | ||
86 | } | ||
87 | }; | ||
88 | |||
89 | /* Jive flash assignment | ||
90 | * | ||
91 | * 0x00000000-0x00028000 : uboot | ||
92 | * 0x00028000-0x0002c000 : uboot env | ||
93 | * 0x0002c000-0x00030000 : spare | ||
94 | * 0x00030000-0x00200000 : zimage A | ||
95 | * 0x00200000-0x01600000 : cramfs A | ||
96 | * 0x01600000-0x017d0000 : zimage B | ||
97 | * 0x017d0000-0x02bd0000 : cramfs B | ||
98 | * 0x02bd0000-0x03fd0000 : yaffs | ||
99 | */ | ||
100 | static struct mtd_partition __initdata jive_imageA_nand_part[] = { | ||
101 | |||
102 | #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER | ||
103 | /* Don't allow access to the bootloader from linux */ | ||
104 | { | ||
105 | .name = "uboot", | ||
106 | .offset = 0, | ||
107 | .size = (160 * SZ_1K), | ||
108 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
109 | }, | ||
110 | |||
111 | /* spare */ | ||
112 | { | ||
113 | .name = "spare", | ||
114 | .offset = (176 * SZ_1K), | ||
115 | .size = (16 * SZ_1K), | ||
116 | }, | ||
117 | #endif | ||
118 | |||
119 | /* booted images */ | ||
120 | { | ||
121 | .name = "kernel (ro)", | ||
122 | .offset = (192 * SZ_1K), | ||
123 | .size = (SZ_2M) - (192 * SZ_1K), | ||
124 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
125 | }, { | ||
126 | .name = "root (ro)", | ||
127 | .offset = (SZ_2M), | ||
128 | .size = (20 * SZ_1M), | ||
129 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
130 | }, | ||
131 | |||
132 | /* yaffs */ | ||
133 | { | ||
134 | .name = "yaffs", | ||
135 | .offset = (44 * SZ_1M), | ||
136 | .size = (20 * SZ_1M), | ||
137 | }, | ||
138 | |||
139 | /* bootloader environment */ | ||
140 | { | ||
141 | .name = "env", | ||
142 | .offset = (160 * SZ_1K), | ||
143 | .size = (16 * SZ_1K), | ||
144 | }, | ||
145 | |||
146 | /* upgrade images */ | ||
147 | { | ||
148 | .name = "zimage", | ||
149 | .offset = (22 * SZ_1M), | ||
150 | .size = (2 * SZ_1M) - (192 * SZ_1K), | ||
151 | }, { | ||
152 | .name = "cramfs", | ||
153 | .offset = (24 * SZ_1M) - (192*SZ_1K), | ||
154 | .size = (20 * SZ_1M), | ||
155 | }, | ||
156 | }; | ||
157 | |||
158 | static struct mtd_partition __initdata jive_imageB_nand_part[] = { | ||
159 | |||
160 | #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER | ||
161 | /* Don't allow access to the bootloader from linux */ | ||
162 | { | ||
163 | .name = "uboot", | ||
164 | .offset = 0, | ||
165 | .size = (160 * SZ_1K), | ||
166 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
167 | }, | ||
168 | |||
169 | /* spare */ | ||
170 | { | ||
171 | .name = "spare", | ||
172 | .offset = (176 * SZ_1K), | ||
173 | .size = (16 * SZ_1K), | ||
174 | }, | ||
175 | #endif | ||
176 | |||
177 | /* booted images */ | ||
178 | { | ||
179 | .name = "kernel (ro)", | ||
180 | .offset = (22 * SZ_1M), | ||
181 | .size = (2 * SZ_1M) - (192 * SZ_1K), | ||
182 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
183 | }, | ||
184 | { | ||
185 | .name = "root (ro)", | ||
186 | .offset = (24 * SZ_1M) - (192 * SZ_1K), | ||
187 | .size = (20 * SZ_1M), | ||
188 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
189 | }, | ||
190 | |||
191 | /* yaffs */ | ||
192 | { | ||
193 | .name = "yaffs", | ||
194 | .offset = (44 * SZ_1M), | ||
195 | .size = (20 * SZ_1M), | ||
196 | }, | ||
197 | |||
198 | /* bootloader environment */ | ||
199 | { | ||
200 | .name = "env", | ||
201 | .offset = (160 * SZ_1K), | ||
202 | .size = (16 * SZ_1K), | ||
203 | }, | ||
204 | |||
205 | /* upgrade images */ | ||
206 | { | ||
207 | .name = "zimage", | ||
208 | .offset = (192 * SZ_1K), | ||
209 | .size = (2 * SZ_1M) - (192 * SZ_1K), | ||
210 | }, { | ||
211 | .name = "cramfs", | ||
212 | .offset = (2 * SZ_1M), | ||
213 | .size = (20 * SZ_1M), | ||
214 | }, | ||
215 | }; | ||
216 | |||
217 | static struct s3c2410_nand_set __initdata jive_nand_sets[] = { | ||
218 | [0] = { | ||
219 | .name = "flash", | ||
220 | .nr_chips = 1, | ||
221 | .nr_partitions = ARRAY_SIZE(jive_imageA_nand_part), | ||
222 | .partitions = jive_imageA_nand_part, | ||
223 | }, | ||
224 | }; | ||
225 | |||
226 | static struct s3c2410_platform_nand __initdata jive_nand_info = { | ||
227 | /* set taken from osiris nand timings, possibly still conservative */ | ||
228 | .tacls = 30, | ||
229 | .twrph0 = 55, | ||
230 | .twrph1 = 40, | ||
231 | .sets = jive_nand_sets, | ||
232 | .nr_sets = ARRAY_SIZE(jive_nand_sets), | ||
233 | }; | ||
234 | |||
235 | static int __init jive_mtdset(char *options) | ||
236 | { | ||
237 | struct s3c2410_nand_set *nand = &jive_nand_sets[0]; | ||
238 | unsigned long set; | ||
239 | |||
240 | if (options == NULL || options[0] == '\0') | ||
241 | return 0; | ||
242 | |||
243 | if (strict_strtoul(options, 10, &set)) { | ||
244 | printk(KERN_ERR "failed to parse mtdset=%s\n", options); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | switch (set) { | ||
249 | case 1: | ||
250 | nand->nr_partitions = ARRAY_SIZE(jive_imageB_nand_part); | ||
251 | nand->partitions = jive_imageB_nand_part; | ||
252 | case 0: | ||
253 | /* this is already setup in the nand info */ | ||
254 | break; | ||
255 | default: | ||
256 | printk(KERN_ERR "Unknown mtd set %ld specified," | ||
257 | "using default.", set); | ||
258 | } | ||
259 | |||
260 | return 0; | ||
261 | } | ||
262 | |||
263 | /* parse the mtdset= option given to the kernel command line */ | ||
264 | __setup("mtdset=", jive_mtdset); | ||
265 | |||
266 | /* LCD timing and setup */ | ||
267 | |||
268 | #define LCD_XRES (240) | ||
269 | #define LCD_YRES (320) | ||
270 | #define LCD_LEFT_MARGIN (12) | ||
271 | #define LCD_RIGHT_MARGIN (12) | ||
272 | #define LCD_LOWER_MARGIN (12) | ||
273 | #define LCD_UPPER_MARGIN (12) | ||
274 | #define LCD_VSYNC (2) | ||
275 | #define LCD_HSYNC (2) | ||
276 | |||
277 | #define LCD_REFRESH (60) | ||
278 | |||
279 | #define LCD_HTOT (LCD_HSYNC + LCD_LEFT_MARGIN + LCD_XRES + LCD_RIGHT_MARGIN) | ||
280 | #define LCD_VTOT (LCD_VSYNC + LCD_LOWER_MARGIN + LCD_YRES + LCD_UPPER_MARGIN) | ||
281 | |||
282 | static struct s3c2410fb_display jive_vgg2432a4_display[] = { | ||
283 | [0] = { | ||
284 | .width = LCD_XRES, | ||
285 | .height = LCD_YRES, | ||
286 | .xres = LCD_XRES, | ||
287 | .yres = LCD_YRES, | ||
288 | .left_margin = LCD_LEFT_MARGIN, | ||
289 | .right_margin = LCD_RIGHT_MARGIN, | ||
290 | .upper_margin = LCD_UPPER_MARGIN, | ||
291 | .lower_margin = LCD_LOWER_MARGIN, | ||
292 | .hsync_len = LCD_HSYNC, | ||
293 | .vsync_len = LCD_VSYNC, | ||
294 | |||
295 | .pixclock = (1000000000000LL / | ||
296 | (LCD_REFRESH * LCD_HTOT * LCD_VTOT)), | ||
297 | |||
298 | .bpp = 16, | ||
299 | .type = (S3C2410_LCDCON1_TFT16BPP | | ||
300 | S3C2410_LCDCON1_TFT), | ||
301 | |||
302 | .lcdcon5 = (S3C2410_LCDCON5_FRM565 | | ||
303 | S3C2410_LCDCON5_INVVLINE | | ||
304 | S3C2410_LCDCON5_INVVFRAME | | ||
305 | S3C2410_LCDCON5_INVVDEN | | ||
306 | S3C2410_LCDCON5_PWREN), | ||
307 | }, | ||
308 | }; | ||
309 | |||
310 | /* todo - put into gpio header */ | ||
311 | |||
312 | #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2)) | ||
313 | #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2)) | ||
314 | |||
315 | static struct s3c2410fb_mach_info jive_lcd_config = { | ||
316 | .displays = jive_vgg2432a4_display, | ||
317 | .num_displays = ARRAY_SIZE(jive_vgg2432a4_display), | ||
318 | .default_display = 0, | ||
319 | |||
320 | /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN | ||
321 | * and disable the pull down resistors on pins we are using for LCD | ||
322 | * data. */ | ||
323 | |||
324 | .gpcup = (0xf << 1) | (0x3f << 10), | ||
325 | |||
326 | .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE | | ||
327 | S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM | | ||
328 | S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 | | ||
329 | S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 | | ||
330 | S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7), | ||
331 | |||
332 | .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) | | ||
333 | S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) | | ||
334 | S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) | | ||
335 | S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) | | ||
336 | S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)), | ||
337 | |||
338 | .gpdup = (0x3f << 2) | (0x3f << 10), | ||
339 | |||
340 | .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 | | ||
341 | S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 | | ||
342 | S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 | | ||
343 | S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 | | ||
344 | S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 | | ||
345 | S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23), | ||
346 | |||
347 | .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) | | ||
348 | S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) | | ||
349 | S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) | | ||
350 | S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)| | ||
351 | S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)| | ||
352 | S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)), | ||
353 | }; | ||
354 | |||
355 | /* ILI9320 support. */ | ||
356 | |||
357 | static void jive_lcm_reset(unsigned int set) | ||
358 | { | ||
359 | printk(KERN_DEBUG "%s(%d)\n", __func__, set); | ||
360 | |||
361 | gpio_set_value(S3C2410_GPG(13), set); | ||
362 | } | ||
363 | |||
364 | #undef LCD_UPPER_MARGIN | ||
365 | #define LCD_UPPER_MARGIN 2 | ||
366 | |||
367 | static struct ili9320_platdata jive_lcm_config = { | ||
368 | .hsize = LCD_XRES, | ||
369 | .vsize = LCD_YRES, | ||
370 | |||
371 | .reset = jive_lcm_reset, | ||
372 | .suspend = ILI9320_SUSPEND_DEEP, | ||
373 | |||
374 | .entry_mode = ILI9320_ENTRYMODE_ID(3) | ILI9320_ENTRYMODE_BGR, | ||
375 | .display2 = (ILI9320_DISPLAY2_FP(LCD_UPPER_MARGIN) | | ||
376 | ILI9320_DISPLAY2_BP(LCD_LOWER_MARGIN)), | ||
377 | .display3 = 0x0, | ||
378 | .display4 = 0x0, | ||
379 | .rgb_if1 = (ILI9320_RGBIF1_RIM_RGB18 | | ||
380 | ILI9320_RGBIF1_RM | ILI9320_RGBIF1_CLK_RGBIF), | ||
381 | .rgb_if2 = ILI9320_RGBIF2_DPL, | ||
382 | .interface2 = 0x0, | ||
383 | .interface3 = 0x3, | ||
384 | .interface4 = (ILI9320_INTERFACE4_RTNE(16) | | ||
385 | ILI9320_INTERFACE4_DIVE(1)), | ||
386 | .interface5 = 0x0, | ||
387 | .interface6 = 0x0, | ||
388 | }; | ||
389 | |||
390 | /* LCD SPI support */ | ||
391 | |||
392 | static struct spi_gpio_platform_data jive_lcd_spi = { | ||
393 | .sck = S3C2410_GPG(8), | ||
394 | .mosi = S3C2410_GPB(8), | ||
395 | .miso = SPI_GPIO_NO_MISO, | ||
396 | }; | ||
397 | |||
398 | static struct platform_device jive_device_lcdspi = { | ||
399 | .name = "spi-gpio", | ||
400 | .id = 1, | ||
401 | .dev.platform_data = &jive_lcd_spi, | ||
402 | }; | ||
403 | |||
404 | |||
405 | /* WM8750 audio code SPI definition */ | ||
406 | |||
407 | static struct spi_gpio_platform_data jive_wm8750_spi = { | ||
408 | .sck = S3C2410_GPB(4), | ||
409 | .mosi = S3C2410_GPB(9), | ||
410 | .miso = SPI_GPIO_NO_MISO, | ||
411 | }; | ||
412 | |||
413 | static struct platform_device jive_device_wm8750 = { | ||
414 | .name = "spi-gpio", | ||
415 | .id = 2, | ||
416 | .dev.platform_data = &jive_wm8750_spi, | ||
417 | }; | ||
418 | |||
419 | /* JIVE SPI devices. */ | ||
420 | |||
421 | static struct spi_board_info __initdata jive_spi_devs[] = { | ||
422 | [0] = { | ||
423 | .modalias = "VGG2432A4", | ||
424 | .bus_num = 1, | ||
425 | .chip_select = 0, | ||
426 | .mode = SPI_MODE_3, /* CPOL=1, CPHA=1 */ | ||
427 | .max_speed_hz = 100000, | ||
428 | .platform_data = &jive_lcm_config, | ||
429 | .controller_data = (void *)S3C2410_GPB(7), | ||
430 | }, { | ||
431 | .modalias = "WM8750", | ||
432 | .bus_num = 2, | ||
433 | .chip_select = 0, | ||
434 | .mode = SPI_MODE_0, /* CPOL=0, CPHA=0 */ | ||
435 | .max_speed_hz = 100000, | ||
436 | .controller_data = (void *)S3C2410_GPH(10), | ||
437 | }, | ||
438 | }; | ||
439 | |||
440 | /* I2C bus and device configuration. */ | ||
441 | |||
442 | static struct s3c2410_platform_i2c jive_i2c_cfg __initdata = { | ||
443 | .frequency = 80 * 1000, | ||
444 | .flags = S3C_IICFLG_FILTER, | ||
445 | .sda_delay = 2, | ||
446 | }; | ||
447 | |||
448 | static struct i2c_board_info jive_i2c_devs[] __initdata = { | ||
449 | [0] = { | ||
450 | I2C_BOARD_INFO("lis302dl", 0x1c), | ||
451 | .irq = IRQ_EINT14, | ||
452 | }, | ||
453 | }; | ||
454 | |||
455 | /* The platform devices being used. */ | ||
456 | |||
457 | static struct platform_device *jive_devices[] __initdata = { | ||
458 | &s3c_device_ohci, | ||
459 | &s3c_device_rtc, | ||
460 | &s3c_device_wdt, | ||
461 | &s3c_device_i2c0, | ||
462 | &s3c_device_lcd, | ||
463 | &jive_device_lcdspi, | ||
464 | &jive_device_wm8750, | ||
465 | &s3c_device_nand, | ||
466 | &s3c_device_usbgadget, | ||
467 | }; | ||
468 | |||
469 | static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = { | ||
470 | .vbus_pin = S3C2410_GPG(1), /* detect is on GPG1 */ | ||
471 | }; | ||
472 | |||
473 | /* Jive power management device */ | ||
474 | |||
475 | #ifdef CONFIG_PM | ||
476 | static int jive_pm_suspend(void) | ||
477 | { | ||
478 | /* Write the magic value u-boot uses to check for resume into | ||
479 | * the INFORM0 register, and ensure INFORM1 is set to the | ||
480 | * correct address to resume from. */ | ||
481 | |||
482 | __raw_writel(0x2BED, S3C2412_INFORM0); | ||
483 | __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1); | ||
484 | |||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static void jive_pm_resume(void) | ||
489 | { | ||
490 | __raw_writel(0x0, S3C2412_INFORM0); | ||
491 | } | ||
492 | |||
493 | #else | ||
494 | #define jive_pm_suspend NULL | ||
495 | #define jive_pm_resume NULL | ||
496 | #endif | ||
497 | |||
498 | static struct syscore_ops jive_pm_syscore_ops = { | ||
499 | .suspend = jive_pm_suspend, | ||
500 | .resume = jive_pm_resume, | ||
501 | }; | ||
502 | |||
503 | static void __init jive_map_io(void) | ||
504 | { | ||
505 | s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc)); | ||
506 | s3c24xx_init_clocks(12000000); | ||
507 | s3c24xx_init_uarts(jive_uartcfgs, ARRAY_SIZE(jive_uartcfgs)); | ||
508 | } | ||
509 | |||
510 | static void jive_power_off(void) | ||
511 | { | ||
512 | printk(KERN_INFO "powering system down...\n"); | ||
513 | |||
514 | s3c2410_gpio_setpin(S3C2410_GPC(5), 1); | ||
515 | s3c_gpio_cfgpin(S3C2410_GPC(5), S3C2410_GPIO_OUTPUT); | ||
516 | } | ||
517 | |||
518 | static void __init jive_machine_init(void) | ||
519 | { | ||
520 | /* register system core operations for managing low level suspend */ | ||
521 | |||
522 | register_syscore_ops(&jive_pm_syscore_ops); | ||
523 | |||
524 | /* write our sleep configurations for the IO. Pull down all unused | ||
525 | * IO, ensure that we have turned off all peripherals we do not | ||
526 | * need, and configure the ones we do need. */ | ||
527 | |||
528 | /* Port B sleep */ | ||
529 | |||
530 | __raw_writel(S3C2412_SLPCON_IN(0) | | ||
531 | S3C2412_SLPCON_PULL(1) | | ||
532 | S3C2412_SLPCON_HIGH(2) | | ||
533 | S3C2412_SLPCON_PULL(3) | | ||
534 | S3C2412_SLPCON_PULL(4) | | ||
535 | S3C2412_SLPCON_PULL(5) | | ||
536 | S3C2412_SLPCON_PULL(6) | | ||
537 | S3C2412_SLPCON_HIGH(7) | | ||
538 | S3C2412_SLPCON_PULL(8) | | ||
539 | S3C2412_SLPCON_PULL(9) | | ||
540 | S3C2412_SLPCON_PULL(10), S3C2412_GPBSLPCON); | ||
541 | |||
542 | /* Port C sleep */ | ||
543 | |||
544 | __raw_writel(S3C2412_SLPCON_PULL(0) | | ||
545 | S3C2412_SLPCON_PULL(1) | | ||
546 | S3C2412_SLPCON_PULL(2) | | ||
547 | S3C2412_SLPCON_PULL(3) | | ||
548 | S3C2412_SLPCON_PULL(4) | | ||
549 | S3C2412_SLPCON_PULL(5) | | ||
550 | S3C2412_SLPCON_LOW(6) | | ||
551 | S3C2412_SLPCON_PULL(6) | | ||
552 | S3C2412_SLPCON_PULL(7) | | ||
553 | S3C2412_SLPCON_PULL(8) | | ||
554 | S3C2412_SLPCON_PULL(9) | | ||
555 | S3C2412_SLPCON_PULL(10) | | ||
556 | S3C2412_SLPCON_PULL(11) | | ||
557 | S3C2412_SLPCON_PULL(12) | | ||
558 | S3C2412_SLPCON_PULL(13) | | ||
559 | S3C2412_SLPCON_PULL(14) | | ||
560 | S3C2412_SLPCON_PULL(15), S3C2412_GPCSLPCON); | ||
561 | |||
562 | /* Port D sleep */ | ||
563 | |||
564 | __raw_writel(S3C2412_SLPCON_ALL_PULL, S3C2412_GPDSLPCON); | ||
565 | |||
566 | /* Port F sleep */ | ||
567 | |||
568 | __raw_writel(S3C2412_SLPCON_LOW(0) | | ||
569 | S3C2412_SLPCON_LOW(1) | | ||
570 | S3C2412_SLPCON_LOW(2) | | ||
571 | S3C2412_SLPCON_EINT(3) | | ||
572 | S3C2412_SLPCON_EINT(4) | | ||
573 | S3C2412_SLPCON_EINT(5) | | ||
574 | S3C2412_SLPCON_EINT(6) | | ||
575 | S3C2412_SLPCON_EINT(7), S3C2412_GPFSLPCON); | ||
576 | |||
577 | /* Port G sleep */ | ||
578 | |||
579 | __raw_writel(S3C2412_SLPCON_IN(0) | | ||
580 | S3C2412_SLPCON_IN(1) | | ||
581 | S3C2412_SLPCON_IN(2) | | ||
582 | S3C2412_SLPCON_IN(3) | | ||
583 | S3C2412_SLPCON_IN(4) | | ||
584 | S3C2412_SLPCON_IN(5) | | ||
585 | S3C2412_SLPCON_IN(6) | | ||
586 | S3C2412_SLPCON_IN(7) | | ||
587 | S3C2412_SLPCON_PULL(8) | | ||
588 | S3C2412_SLPCON_PULL(9) | | ||
589 | S3C2412_SLPCON_IN(10) | | ||
590 | S3C2412_SLPCON_PULL(11) | | ||
591 | S3C2412_SLPCON_PULL(12) | | ||
592 | S3C2412_SLPCON_PULL(13) | | ||
593 | S3C2412_SLPCON_IN(14) | | ||
594 | S3C2412_SLPCON_PULL(15), S3C2412_GPGSLPCON); | ||
595 | |||
596 | /* Port H sleep */ | ||
597 | |||
598 | __raw_writel(S3C2412_SLPCON_PULL(0) | | ||
599 | S3C2412_SLPCON_PULL(1) | | ||
600 | S3C2412_SLPCON_PULL(2) | | ||
601 | S3C2412_SLPCON_PULL(3) | | ||
602 | S3C2412_SLPCON_PULL(4) | | ||
603 | S3C2412_SLPCON_PULL(5) | | ||
604 | S3C2412_SLPCON_PULL(6) | | ||
605 | S3C2412_SLPCON_IN(7) | | ||
606 | S3C2412_SLPCON_IN(8) | | ||
607 | S3C2412_SLPCON_PULL(9) | | ||
608 | S3C2412_SLPCON_IN(10), S3C2412_GPHSLPCON); | ||
609 | |||
610 | /* initialise the power management now we've setup everything. */ | ||
611 | |||
612 | s3c_pm_init(); | ||
613 | |||
614 | /** TODO - check that this is after the cmdline option! */ | ||
615 | s3c_nand_set_platdata(&jive_nand_info); | ||
616 | |||
617 | /* initialise the spi */ | ||
618 | |||
619 | gpio_request(S3C2410_GPG(13), "lcm reset"); | ||
620 | gpio_direction_output(S3C2410_GPG(13), 0); | ||
621 | |||
622 | gpio_request(S3C2410_GPB(7), "jive spi"); | ||
623 | gpio_direction_output(S3C2410_GPB(7), 1); | ||
624 | |||
625 | s3c2410_gpio_setpin(S3C2410_GPB(6), 0); | ||
626 | s3c_gpio_cfgpin(S3C2410_GPB(6), S3C2410_GPIO_OUTPUT); | ||
627 | |||
628 | s3c2410_gpio_setpin(S3C2410_GPG(8), 1); | ||
629 | s3c_gpio_cfgpin(S3C2410_GPG(8), S3C2410_GPIO_OUTPUT); | ||
630 | |||
631 | /* initialise the WM8750 spi */ | ||
632 | |||
633 | gpio_request(S3C2410_GPH(10), "jive wm8750 spi"); | ||
634 | gpio_direction_output(S3C2410_GPH(10), 1); | ||
635 | |||
636 | /* Turn off suspend on both USB ports, and switch the | ||
637 | * selectable USB port to USB device mode. */ | ||
638 | |||
639 | s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST | | ||
640 | S3C2410_MISCCR_USBSUSPND0 | | ||
641 | S3C2410_MISCCR_USBSUSPND1, 0x0); | ||
642 | |||
643 | s3c24xx_udc_set_platdata(&jive_udc_cfg); | ||
644 | s3c24xx_fb_set_platdata(&jive_lcd_config); | ||
645 | |||
646 | spi_register_board_info(jive_spi_devs, ARRAY_SIZE(jive_spi_devs)); | ||
647 | |||
648 | s3c_i2c0_set_platdata(&jive_i2c_cfg); | ||
649 | i2c_register_board_info(0, jive_i2c_devs, ARRAY_SIZE(jive_i2c_devs)); | ||
650 | |||
651 | pm_power_off = jive_power_off; | ||
652 | |||
653 | platform_add_devices(jive_devices, ARRAY_SIZE(jive_devices)); | ||
654 | } | ||
655 | |||
656 | MACHINE_START(JIVE, "JIVE") | ||
657 | /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ | ||
658 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
659 | |||
660 | .init_irq = s3c24xx_init_irq, | ||
661 | .map_io = jive_map_io, | ||
662 | .init_machine = jive_machine_init, | ||
663 | .timer = &s3c24xx_timer, | ||
664 | MACHINE_END | ||
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c new file mode 100644 index 00000000000..834cfb61bcf --- /dev/null +++ b/arch/arm/mach-s3c2412/mach-smdk2413.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/mach-smdk2413.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * Thanks to Dimity Andric (TomTom) and Steven Ryu (Samsung) for the | ||
7 | * loans of SMDK2413 to work with. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/list.h> | ||
18 | #include <linux/timer.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/gpio.h> | ||
21 | #include <linux/serial_core.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/io.h> | ||
24 | |||
25 | #include <asm/mach/arch.h> | ||
26 | #include <asm/mach/map.h> | ||
27 | #include <asm/mach/irq.h> | ||
28 | |||
29 | #include <mach/hardware.h> | ||
30 | #include <asm/hardware/iomd.h> | ||
31 | #include <asm/setup.h> | ||
32 | #include <asm/irq.h> | ||
33 | #include <asm/mach-types.h> | ||
34 | |||
35 | //#include <asm/debug-ll.h> | ||
36 | #include <plat/regs-serial.h> | ||
37 | #include <mach/regs-gpio.h> | ||
38 | #include <mach/regs-lcd.h> | ||
39 | |||
40 | #include <mach/idle.h> | ||
41 | #include <plat/udc.h> | ||
42 | #include <plat/iic.h> | ||
43 | #include <mach/fb.h> | ||
44 | |||
45 | #include <plat/s3c2410.h> | ||
46 | #include <plat/s3c2412.h> | ||
47 | #include <plat/clock.h> | ||
48 | #include <plat/devs.h> | ||
49 | #include <plat/cpu.h> | ||
50 | |||
51 | #include <plat/common-smdk.h> | ||
52 | |||
53 | static struct map_desc smdk2413_iodesc[] __initdata = { | ||
54 | }; | ||
55 | |||
56 | static struct s3c2410_uartcfg smdk2413_uartcfgs[] __initdata = { | ||
57 | [0] = { | ||
58 | .hwport = 0, | ||
59 | .flags = 0, | ||
60 | .ucon = 0x3c5, | ||
61 | .ulcon = 0x03, | ||
62 | .ufcon = 0x51, | ||
63 | }, | ||
64 | [1] = { | ||
65 | .hwport = 1, | ||
66 | .flags = 0, | ||
67 | .ucon = 0x3c5, | ||
68 | .ulcon = 0x03, | ||
69 | .ufcon = 0x51, | ||
70 | }, | ||
71 | /* IR port */ | ||
72 | [2] = { | ||
73 | .hwport = 2, | ||
74 | .flags = 0, | ||
75 | .ucon = 0x3c5, | ||
76 | .ulcon = 0x43, | ||
77 | .ufcon = 0x51, | ||
78 | } | ||
79 | }; | ||
80 | |||
81 | |||
82 | static struct s3c2410_udc_mach_info smdk2413_udc_cfg __initdata = { | ||
83 | .pullup_pin = S3C2410_GPF(2), | ||
84 | }; | ||
85 | |||
86 | |||
87 | static struct platform_device *smdk2413_devices[] __initdata = { | ||
88 | &s3c_device_ohci, | ||
89 | &s3c_device_wdt, | ||
90 | &s3c_device_i2c0, | ||
91 | &s3c_device_iis, | ||
92 | &s3c_device_usbgadget, | ||
93 | }; | ||
94 | |||
95 | static void __init smdk2413_fixup(struct machine_desc *desc, | ||
96 | struct tag *tags, char **cmdline, | ||
97 | struct meminfo *mi) | ||
98 | { | ||
99 | if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { | ||
100 | mi->nr_banks=1; | ||
101 | mi->bank[0].start = 0x30000000; | ||
102 | mi->bank[0].size = SZ_64M; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | static void __init smdk2413_map_io(void) | ||
107 | { | ||
108 | s3c24xx_init_io(smdk2413_iodesc, ARRAY_SIZE(smdk2413_iodesc)); | ||
109 | s3c24xx_init_clocks(12000000); | ||
110 | s3c24xx_init_uarts(smdk2413_uartcfgs, ARRAY_SIZE(smdk2413_uartcfgs)); | ||
111 | } | ||
112 | |||
113 | static void __init smdk2413_machine_init(void) | ||
114 | { /* Turn off suspend on both USB ports, and switch the | ||
115 | * selectable USB port to USB device mode. */ | ||
116 | |||
117 | s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST | | ||
118 | S3C2410_MISCCR_USBSUSPND0 | | ||
119 | S3C2410_MISCCR_USBSUSPND1, 0x0); | ||
120 | |||
121 | |||
122 | s3c24xx_udc_set_platdata(&smdk2413_udc_cfg); | ||
123 | s3c_i2c0_set_platdata(NULL); | ||
124 | |||
125 | platform_add_devices(smdk2413_devices, ARRAY_SIZE(smdk2413_devices)); | ||
126 | smdk_machine_init(); | ||
127 | } | ||
128 | |||
129 | MACHINE_START(S3C2413, "S3C2413") | ||
130 | /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ | ||
131 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
132 | |||
133 | .fixup = smdk2413_fixup, | ||
134 | .init_irq = s3c24xx_init_irq, | ||
135 | .map_io = smdk2413_map_io, | ||
136 | .init_machine = smdk2413_machine_init, | ||
137 | .timer = &s3c24xx_timer, | ||
138 | MACHINE_END | ||
139 | |||
140 | MACHINE_START(SMDK2412, "SMDK2412") | ||
141 | /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ | ||
142 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
143 | |||
144 | .fixup = smdk2413_fixup, | ||
145 | .init_irq = s3c24xx_init_irq, | ||
146 | .map_io = smdk2413_map_io, | ||
147 | .init_machine = smdk2413_machine_init, | ||
148 | .timer = &s3c24xx_timer, | ||
149 | MACHINE_END | ||
150 | |||
151 | MACHINE_START(SMDK2413, "SMDK2413") | ||
152 | /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ | ||
153 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
154 | |||
155 | .fixup = smdk2413_fixup, | ||
156 | .init_irq = s3c24xx_init_irq, | ||
157 | .map_io = smdk2413_map_io, | ||
158 | .init_machine = smdk2413_machine_init, | ||
159 | .timer = &s3c24xx_timer, | ||
160 | MACHINE_END | ||
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c2412/mach-vstms.c new file mode 100644 index 00000000000..83544ebe20a --- /dev/null +++ b/arch/arm/mach-s3c2412/mach-vstms.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/mach-vstms.c | ||
2 | * | ||
3 | * (C) 2006 Thomas Gleixner <tglx@linutronix.de> | ||
4 | * | ||
5 | * Derived from mach-smdk2413.c - (C) 2006 Simtec Electronics | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/list.h> | ||
16 | #include <linux/timer.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/serial_core.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/mtd/mtd.h> | ||
22 | #include <linux/mtd/nand.h> | ||
23 | #include <linux/mtd/nand_ecc.h> | ||
24 | #include <linux/mtd/partitions.h> | ||
25 | |||
26 | #include <asm/mach/arch.h> | ||
27 | #include <asm/mach/map.h> | ||
28 | #include <asm/mach/irq.h> | ||
29 | |||
30 | #include <mach/hardware.h> | ||
31 | #include <asm/setup.h> | ||
32 | #include <asm/irq.h> | ||
33 | #include <asm/mach-types.h> | ||
34 | |||
35 | #include <plat/regs-serial.h> | ||
36 | #include <mach/regs-gpio.h> | ||
37 | #include <mach/regs-lcd.h> | ||
38 | |||
39 | #include <mach/idle.h> | ||
40 | #include <mach/fb.h> | ||
41 | |||
42 | #include <plat/iic.h> | ||
43 | #include <plat/nand.h> | ||
44 | |||
45 | #include <plat/s3c2410.h> | ||
46 | #include <plat/s3c2412.h> | ||
47 | #include <plat/clock.h> | ||
48 | #include <plat/devs.h> | ||
49 | #include <plat/cpu.h> | ||
50 | |||
51 | |||
52 | static struct map_desc vstms_iodesc[] __initdata = { | ||
53 | }; | ||
54 | |||
55 | static struct s3c2410_uartcfg vstms_uartcfgs[] __initdata = { | ||
56 | [0] = { | ||
57 | .hwport = 0, | ||
58 | .flags = 0, | ||
59 | .ucon = 0x3c5, | ||
60 | .ulcon = 0x03, | ||
61 | .ufcon = 0x51, | ||
62 | }, | ||
63 | [1] = { | ||
64 | .hwport = 1, | ||
65 | .flags = 0, | ||
66 | .ucon = 0x3c5, | ||
67 | .ulcon = 0x03, | ||
68 | .ufcon = 0x51, | ||
69 | }, | ||
70 | [2] = { | ||
71 | .hwport = 2, | ||
72 | .flags = 0, | ||
73 | .ucon = 0x3c5, | ||
74 | .ulcon = 0x03, | ||
75 | .ufcon = 0x51, | ||
76 | } | ||
77 | }; | ||
78 | |||
79 | static struct mtd_partition __initdata vstms_nand_part[] = { | ||
80 | [0] = { | ||
81 | .name = "Boot Agent", | ||
82 | .size = 0x7C000, | ||
83 | .offset = 0, | ||
84 | }, | ||
85 | [1] = { | ||
86 | .name = "UBoot Config", | ||
87 | .offset = 0x7C000, | ||
88 | .size = 0x4000, | ||
89 | }, | ||
90 | [2] = { | ||
91 | .name = "Kernel", | ||
92 | .offset = 0x80000, | ||
93 | .size = 0x200000, | ||
94 | }, | ||
95 | [3] = { | ||
96 | .name = "RFS", | ||
97 | .offset = 0x280000, | ||
98 | .size = 0x3d80000, | ||
99 | }, | ||
100 | }; | ||
101 | |||
102 | static struct s3c2410_nand_set __initdata vstms_nand_sets[] = { | ||
103 | [0] = { | ||
104 | .name = "NAND", | ||
105 | .nr_chips = 1, | ||
106 | .nr_partitions = ARRAY_SIZE(vstms_nand_part), | ||
107 | .partitions = vstms_nand_part, | ||
108 | }, | ||
109 | }; | ||
110 | |||
111 | /* choose a set of timings which should suit most 512Mbit | ||
112 | * chips and beyond. | ||
113 | */ | ||
114 | |||
115 | static struct s3c2410_platform_nand __initdata vstms_nand_info = { | ||
116 | .tacls = 20, | ||
117 | .twrph0 = 60, | ||
118 | .twrph1 = 20, | ||
119 | .nr_sets = ARRAY_SIZE(vstms_nand_sets), | ||
120 | .sets = vstms_nand_sets, | ||
121 | }; | ||
122 | |||
123 | static struct platform_device *vstms_devices[] __initdata = { | ||
124 | &s3c_device_ohci, | ||
125 | &s3c_device_wdt, | ||
126 | &s3c_device_i2c0, | ||
127 | &s3c_device_iis, | ||
128 | &s3c_device_rtc, | ||
129 | &s3c_device_nand, | ||
130 | }; | ||
131 | |||
132 | static void __init vstms_fixup(struct machine_desc *desc, | ||
133 | struct tag *tags, char **cmdline, | ||
134 | struct meminfo *mi) | ||
135 | { | ||
136 | if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { | ||
137 | mi->nr_banks=1; | ||
138 | mi->bank[0].start = 0x30000000; | ||
139 | mi->bank[0].size = SZ_64M; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | static void __init vstms_map_io(void) | ||
144 | { | ||
145 | s3c24xx_init_io(vstms_iodesc, ARRAY_SIZE(vstms_iodesc)); | ||
146 | s3c24xx_init_clocks(12000000); | ||
147 | s3c24xx_init_uarts(vstms_uartcfgs, ARRAY_SIZE(vstms_uartcfgs)); | ||
148 | } | ||
149 | |||
150 | static void __init vstms_init(void) | ||
151 | { | ||
152 | s3c_i2c0_set_platdata(NULL); | ||
153 | s3c_nand_set_platdata(&vstms_nand_info); | ||
154 | |||
155 | platform_add_devices(vstms_devices, ARRAY_SIZE(vstms_devices)); | ||
156 | } | ||
157 | |||
158 | MACHINE_START(VSTMS, "VSTMS") | ||
159 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
160 | |||
161 | .fixup = vstms_fixup, | ||
162 | .init_irq = s3c24xx_init_irq, | ||
163 | .init_machine = vstms_init, | ||
164 | .map_io = vstms_map_io, | ||
165 | .timer = &s3c24xx_timer, | ||
166 | MACHINE_END | ||
diff --git a/arch/arm/mach-s3c2412/pm.c b/arch/arm/mach-s3c2412/pm.c new file mode 100644 index 00000000000..f4077efa51f --- /dev/null +++ b/arch/arm/mach-s3c2412/pm.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/pm.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * http://armlinux.simtec.co.uk/. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/timer.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/sysdev.h> | ||
20 | #include <linux/syscore_ops.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/io.h> | ||
23 | |||
24 | #include <mach/hardware.h> | ||
25 | #include <asm/cacheflush.h> | ||
26 | #include <asm/irq.h> | ||
27 | |||
28 | #include <mach/regs-power.h> | ||
29 | #include <mach/regs-gpioj.h> | ||
30 | #include <mach/regs-gpio.h> | ||
31 | #include <mach/regs-dsc.h> | ||
32 | |||
33 | #include <plat/cpu.h> | ||
34 | #include <plat/pm.h> | ||
35 | |||
36 | #include <plat/s3c2412.h> | ||
37 | |||
38 | extern void s3c2412_sleep_enter(void); | ||
39 | |||
40 | static int s3c2412_cpu_suspend(unsigned long arg) | ||
41 | { | ||
42 | unsigned long tmp; | ||
43 | |||
44 | /* set our standby method to sleep */ | ||
45 | |||
46 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
47 | tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP; | ||
48 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
49 | |||
50 | s3c2412_sleep_enter(); | ||
51 | |||
52 | panic("sleep resumed to originator?"); | ||
53 | } | ||
54 | |||
55 | static void s3c2412_pm_prepare(void) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | static int s3c2412_pm_add(struct sys_device *sysdev) | ||
60 | { | ||
61 | pm_cpu_prep = s3c2412_pm_prepare; | ||
62 | pm_cpu_sleep = s3c2412_cpu_suspend; | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static struct sleep_save s3c2412_sleep[] = { | ||
68 | SAVE_ITEM(S3C2412_DSC0), | ||
69 | SAVE_ITEM(S3C2412_DSC1), | ||
70 | SAVE_ITEM(S3C2413_GPJDAT), | ||
71 | SAVE_ITEM(S3C2413_GPJCON), | ||
72 | SAVE_ITEM(S3C2413_GPJUP), | ||
73 | |||
74 | /* save the PWRCFG to get back to original sleep method */ | ||
75 | |||
76 | SAVE_ITEM(S3C2412_PWRCFG), | ||
77 | |||
78 | /* save the sleep configuration anyway, just in case these | ||
79 | * get damaged during wakeup */ | ||
80 | |||
81 | SAVE_ITEM(S3C2412_GPBSLPCON), | ||
82 | SAVE_ITEM(S3C2412_GPCSLPCON), | ||
83 | SAVE_ITEM(S3C2412_GPDSLPCON), | ||
84 | SAVE_ITEM(S3C2412_GPFSLPCON), | ||
85 | SAVE_ITEM(S3C2412_GPGSLPCON), | ||
86 | SAVE_ITEM(S3C2412_GPHSLPCON), | ||
87 | SAVE_ITEM(S3C2413_GPJSLPCON), | ||
88 | }; | ||
89 | |||
90 | static struct sysdev_driver s3c2412_pm_driver = { | ||
91 | .add = s3c2412_pm_add, | ||
92 | }; | ||
93 | |||
94 | static __init int s3c2412_pm_init(void) | ||
95 | { | ||
96 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver); | ||
97 | } | ||
98 | |||
99 | arch_initcall(s3c2412_pm_init); | ||
100 | |||
101 | static int s3c2412_pm_suspend(void) | ||
102 | { | ||
103 | s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static void s3c2412_pm_resume(void) | ||
108 | { | ||
109 | unsigned long tmp; | ||
110 | |||
111 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
112 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; | ||
113 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; | ||
114 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
115 | |||
116 | s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
117 | } | ||
118 | |||
119 | struct syscore_ops s3c2412_pm_syscore_ops = { | ||
120 | .suspend = s3c2412_pm_suspend, | ||
121 | .resume = s3c2412_pm_resume, | ||
122 | }; | ||
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c new file mode 100644 index 00000000000..57a1e01e4e5 --- /dev/null +++ b/arch/arm/mach-s3c2412/s3c2412.c | |||
@@ -0,0 +1,254 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/s3c2412.c | ||
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * http://armlinux.simtec.co.uk/. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/timer.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/sysdev.h> | ||
22 | #include <linux/syscore_ops.h> | ||
23 | #include <linux/serial_core.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/io.h> | ||
26 | |||
27 | #include <asm/mach/arch.h> | ||
28 | #include <asm/mach/map.h> | ||
29 | #include <asm/mach/irq.h> | ||
30 | |||
31 | #include <mach/hardware.h> | ||
32 | #include <asm/proc-fns.h> | ||
33 | #include <asm/irq.h> | ||
34 | |||
35 | #include <mach/reset.h> | ||
36 | #include <mach/idle.h> | ||
37 | |||
38 | #include <plat/cpu-freq.h> | ||
39 | |||
40 | #include <mach/regs-clock.h> | ||
41 | #include <plat/regs-serial.h> | ||
42 | #include <mach/regs-power.h> | ||
43 | #include <mach/regs-gpio.h> | ||
44 | #include <mach/regs-gpioj.h> | ||
45 | #include <mach/regs-dsc.h> | ||
46 | #include <plat/regs-spi.h> | ||
47 | #include <mach/regs-s3c2412.h> | ||
48 | |||
49 | #include <plat/s3c2412.h> | ||
50 | #include <plat/cpu.h> | ||
51 | #include <plat/devs.h> | ||
52 | #include <plat/clock.h> | ||
53 | #include <plat/pm.h> | ||
54 | #include <plat/pll.h> | ||
55 | #include <plat/nand-core.h> | ||
56 | |||
57 | #ifndef CONFIG_CPU_S3C2412_ONLY | ||
58 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; | ||
59 | |||
60 | static inline void s3c2412_init_gpio2(void) | ||
61 | { | ||
62 | s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10; | ||
63 | } | ||
64 | #else | ||
65 | #define s3c2412_init_gpio2() do { } while(0) | ||
66 | #endif | ||
67 | |||
68 | /* Initial IO mappings */ | ||
69 | |||
70 | static struct map_desc s3c2412_iodesc[] __initdata = { | ||
71 | IODESC_ENT(CLKPWR), | ||
72 | IODESC_ENT(TIMER), | ||
73 | IODESC_ENT(WATCHDOG), | ||
74 | { | ||
75 | .virtual = (unsigned long)S3C2412_VA_SSMC, | ||
76 | .pfn = __phys_to_pfn(S3C2412_PA_SSMC), | ||
77 | .length = SZ_1M, | ||
78 | .type = MT_DEVICE, | ||
79 | }, | ||
80 | { | ||
81 | .virtual = (unsigned long)S3C2412_VA_EBI, | ||
82 | .pfn = __phys_to_pfn(S3C2412_PA_EBI), | ||
83 | .length = SZ_1M, | ||
84 | .type = MT_DEVICE, | ||
85 | }, | ||
86 | }; | ||
87 | |||
88 | /* uart registration process */ | ||
89 | |||
90 | void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no) | ||
91 | { | ||
92 | s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no); | ||
93 | |||
94 | /* rename devices that are s3c2412/s3c2413 specific */ | ||
95 | s3c_device_sdi.name = "s3c2412-sdi"; | ||
96 | s3c_device_lcd.name = "s3c2412-lcd"; | ||
97 | s3c_nand_setname("s3c2412-nand"); | ||
98 | |||
99 | /* alter IRQ of SDI controller */ | ||
100 | |||
101 | s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI; | ||
102 | s3c_device_sdi.resource[1].end = IRQ_S3C2412_SDI; | ||
103 | |||
104 | /* spi channel related changes, s3c2412/13 specific */ | ||
105 | s3c_device_spi0.name = "s3c2412-spi"; | ||
106 | s3c_device_spi0.resource[0].end = S3C24XX_PA_SPI + 0x24; | ||
107 | s3c_device_spi1.name = "s3c2412-spi"; | ||
108 | s3c_device_spi1.resource[0].start = S3C24XX_PA_SPI + S3C2412_SPI1; | ||
109 | s3c_device_spi1.resource[0].end = S3C24XX_PA_SPI + S3C2412_SPI1 + 0x24; | ||
110 | |||
111 | } | ||
112 | |||
113 | /* s3c2412_idle | ||
114 | * | ||
115 | * use the standard idle call by ensuring the idle mode | ||
116 | * in power config, then issuing the idle co-processor | ||
117 | * instruction | ||
118 | */ | ||
119 | |||
120 | static void s3c2412_idle(void) | ||
121 | { | ||
122 | unsigned long tmp; | ||
123 | |||
124 | /* ensure our idle mode is to go to idle */ | ||
125 | |||
126 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
127 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; | ||
128 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; | ||
129 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
130 | |||
131 | cpu_do_idle(); | ||
132 | } | ||
133 | |||
134 | static void s3c2412_hard_reset(void) | ||
135 | { | ||
136 | /* errata "Watch-dog/Software Reset Problem" specifies that | ||
137 | * this reset must be done with the SYSCLK sourced from | ||
138 | * EXTCLK instead of FOUT to avoid a glitch in the reset | ||
139 | * mechanism. | ||
140 | * | ||
141 | * See the watchdog section of the S3C2412 manual for more | ||
142 | * information on this fix. | ||
143 | */ | ||
144 | |||
145 | __raw_writel(0x00, S3C2412_CLKSRC); | ||
146 | __raw_writel(S3C2412_SWRST_RESET, S3C2412_SWRST); | ||
147 | |||
148 | mdelay(1); | ||
149 | } | ||
150 | |||
151 | /* s3c2412_map_io | ||
152 | * | ||
153 | * register the standard cpu IO areas, and any passed in from the | ||
154 | * machine specific initialisation. | ||
155 | */ | ||
156 | |||
157 | void __init s3c2412_map_io(void) | ||
158 | { | ||
159 | /* move base of IO */ | ||
160 | |||
161 | s3c2412_init_gpio2(); | ||
162 | |||
163 | /* set our idle function */ | ||
164 | |||
165 | s3c24xx_idle = s3c2412_idle; | ||
166 | |||
167 | /* set custom reset hook */ | ||
168 | |||
169 | s3c24xx_reset_hook = s3c2412_hard_reset; | ||
170 | |||
171 | /* register our io-tables */ | ||
172 | |||
173 | iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); | ||
174 | } | ||
175 | |||
176 | void __init_or_cpufreq s3c2412_setup_clocks(void) | ||
177 | { | ||
178 | struct clk *xtal_clk; | ||
179 | unsigned long tmp; | ||
180 | unsigned long xtal; | ||
181 | unsigned long fclk; | ||
182 | unsigned long hclk; | ||
183 | unsigned long pclk; | ||
184 | |||
185 | xtal_clk = clk_get(NULL, "xtal"); | ||
186 | xtal = clk_get_rate(xtal_clk); | ||
187 | clk_put(xtal_clk); | ||
188 | |||
189 | /* now we've got our machine bits initialised, work out what | ||
190 | * clocks we've got */ | ||
191 | |||
192 | fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal * 2); | ||
193 | |||
194 | clk_mpll.rate = fclk; | ||
195 | |||
196 | tmp = __raw_readl(S3C2410_CLKDIVN); | ||
197 | |||
198 | /* work out clock scalings */ | ||
199 | |||
200 | hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1); | ||
201 | hclk /= ((tmp & S3C2412_CLKDIVN_ARMDIVN) ? 2 : 1); | ||
202 | pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1); | ||
203 | |||
204 | /* print brieft summary of clocks, etc */ | ||
205 | |||
206 | printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n", | ||
207 | print_mhz(fclk), print_mhz(hclk), print_mhz(pclk)); | ||
208 | |||
209 | s3c24xx_setup_clocks(fclk, hclk, pclk); | ||
210 | } | ||
211 | |||
212 | void __init s3c2412_init_clocks(int xtal) | ||
213 | { | ||
214 | /* initialise the clocks here, to allow other things like the | ||
215 | * console to use them | ||
216 | */ | ||
217 | |||
218 | s3c24xx_register_baseclocks(xtal); | ||
219 | s3c2412_setup_clocks(); | ||
220 | s3c2412_baseclk_add(); | ||
221 | } | ||
222 | |||
223 | /* need to register class before we actually register the device, and | ||
224 | * we also need to ensure that it has been initialised before any of the | ||
225 | * drivers even try to use it (even if not on an s3c2412 based system) | ||
226 | * as a driver which may support both 2410 and 2440 may try and use it. | ||
227 | */ | ||
228 | |||
229 | struct sysdev_class s3c2412_sysclass = { | ||
230 | .name = "s3c2412-core", | ||
231 | }; | ||
232 | |||
233 | static int __init s3c2412_core_init(void) | ||
234 | { | ||
235 | return sysdev_class_register(&s3c2412_sysclass); | ||
236 | } | ||
237 | |||
238 | core_initcall(s3c2412_core_init); | ||
239 | |||
240 | static struct sys_device s3c2412_sysdev = { | ||
241 | .cls = &s3c2412_sysclass, | ||
242 | }; | ||
243 | |||
244 | int __init s3c2412_init(void) | ||
245 | { | ||
246 | printk("S3C2412: Initialising architecture\n"); | ||
247 | |||
248 | #ifdef CONFIG_PM | ||
249 | register_syscore_ops(&s3c2412_pm_syscore_ops); | ||
250 | #endif | ||
251 | register_syscore_ops(&s3c24xx_irq_syscore_ops); | ||
252 | |||
253 | return sysdev_register(&s3c2412_sysdev); | ||
254 | } | ||
diff --git a/arch/arm/mach-s3c2412/sleep.S b/arch/arm/mach-s3c2412/sleep.S new file mode 100644 index 00000000000..c82418ed714 --- /dev/null +++ b/arch/arm/mach-s3c2412/sleep.S | |||
@@ -0,0 +1,68 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/sleep.S | ||
2 | * | ||
3 | * Copyright (c) 2007 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2412 Power Manager low-level sleep support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/linkage.h> | ||
24 | #include <asm/assembler.h> | ||
25 | #include <mach/hardware.h> | ||
26 | #include <mach/map.h> | ||
27 | |||
28 | #include <mach/regs-irq.h> | ||
29 | |||
30 | .text | ||
31 | |||
32 | .global s3c2412_sleep_enter | ||
33 | |||
34 | s3c2412_sleep_enter: | ||
35 | mov r0, #0 /* argument for coprocessors */ | ||
36 | ldr r1, =S3C2410_INTPND | ||
37 | ldr r2, =S3C2410_SRCPND | ||
38 | ldr r3, =S3C2410_EINTPEND | ||
39 | |||
40 | teq r0, r0 | ||
41 | bl s3c2412_sleep_enter1 | ||
42 | teq pc, r0 | ||
43 | bl s3c2412_sleep_enter1 | ||
44 | |||
45 | .align 5 | ||
46 | |||
47 | /* this is called twice, first with the Z flag to ensure that the | ||
48 | * instructions have been loaded into the cache, and the second | ||
49 | * time to try and suspend the system. | ||
50 | */ | ||
51 | s3c2412_sleep_enter1: | ||
52 | mcr p15, 0, r0, c7, c10, 4 | ||
53 | mcrne p15, 0, r0, c7, c0, 4 | ||
54 | |||
55 | /* if we return from here, it is because an interrupt was | ||
56 | * active when we tried to shutdown. Try and ack the IRQ and | ||
57 | * retry, as simply returning causes the system to lock. | ||
58 | */ | ||
59 | |||
60 | ldrne r9, [ r1 ] | ||
61 | strne r9, [ r1 ] | ||
62 | ldrne r9, [ r2 ] | ||
63 | strne r9, [ r2 ] | ||
64 | ldrne r9, [ r3 ] | ||
65 | strne r9, [ r3 ] | ||
66 | bne s3c2412_sleep_enter1 | ||
67 | |||
68 | mov pc, r14 | ||