diff options
author | Ben Dooks <ben-linux@fluff.org> | 2007-02-11 12:31:01 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-02-11 12:36:09 -0500 |
commit | a21765a70ec06be175d3997320a83fa66fcc8955 (patch) | |
tree | 24bdbf437a9bd5b7c1af05898f5aa25dccf67fe9 /arch/arm/mach-s3c2412 | |
parent | d19494b187b20e363f9b434b9ceab4159ac88324 (diff) |
[ARM] 4157/2: S3C24XX: move arch/arch/mach-s3c2410 into cpu components
The following patch and script moves the arch/arm/mach-s3c2410
directory into arch/arm/plat-s3c24xx for the generic core code
and inti arch/arm/mach-s3c{cpu} for the cpu/machine support files
Include directory include/asm-arm/plat-s3c24xx is added for the
core include files.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-s3c2412')
-rw-r--r-- | arch/arm/mach-s3c2412/Kconfig | 58 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/Makefile | 21 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/clock.c | 716 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/dma.c | 161 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/irq.c | 133 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/mach-smdk2413.c | 140 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/mach-vstms.c | 169 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/pm.c | 128 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/s3c2412.c | 181 |
9 files changed, 1707 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2412/Kconfig b/arch/arm/mach-s3c2412/Kconfig new file mode 100644 index 000000000000..6d629de84cdb --- /dev/null +++ b/arch/arm/mach-s3c2412/Kconfig | |||
@@ -0,0 +1,58 @@ | |||
1 | # arch/arm/mach-s3c2412/Kconfig | ||
2 | # | ||
3 | # Copyright 2007 Simtec Electronics | ||
4 | # | ||
5 | # Licensed under GPLv2 | ||
6 | |||
7 | config CPU_S3C2412 | ||
8 | bool | ||
9 | depends on ARCH_S3C2410 | ||
10 | select S3C2412_PM if PM | ||
11 | select S3C2412_DMA if S3C2410_DMA | ||
12 | help | ||
13 | Support for the S3C2412 and S3C2413 SoCs from the S3C24XX line | ||
14 | |||
15 | config CPU_S3C2412_ONLY | ||
16 | bool | ||
17 | depends on ARCH_S3C2410 && !CPU_S3C2400 && !CPU_S3C2410 && \ | ||
18 | !CPU_S3C2440 && !CPU_S3C2442 && CPU_S3C2412 | ||
19 | default y if CPU_S3C2412 | ||
20 | |||
21 | config S3C2412_DMA | ||
22 | bool | ||
23 | depends on CPU_S3C2412 | ||
24 | help | ||
25 | Internal config node for S3C2412 DMA support | ||
26 | |||
27 | config S3C2412_PM | ||
28 | bool | ||
29 | help | ||
30 | Internal config node to apply S3C2412 power management | ||
31 | |||
32 | |||
33 | menu "S3C2412 Machines" | ||
34 | |||
35 | config MACH_SMDK2413 | ||
36 | bool "SMDK2413" | ||
37 | select CPU_S3C2412 | ||
38 | select MACH_S3C2413 | ||
39 | select MACH_SMDK | ||
40 | help | ||
41 | Say Y here if you are using an SMDK2413 | ||
42 | |||
43 | config MACH_S3C2413 | ||
44 | bool | ||
45 | help | ||
46 | Internal node for S3C2413 version of SMDK2413, so that | ||
47 | machine_is_s3c2413() will work when MACH_SMDK2413 is | ||
48 | selected | ||
49 | |||
50 | config MACH_VSTMS | ||
51 | bool "VMSTMS" | ||
52 | select CPU_S3C2412 | ||
53 | help | ||
54 | Say Y here if you are using an VSTMS board | ||
55 | |||
56 | |||
57 | endmenu | ||
58 | |||
diff --git a/arch/arm/mach-s3c2412/Makefile b/arch/arm/mach-s3c2412/Makefile new file mode 100644 index 000000000000..f8e011691b31 --- /dev/null +++ b/arch/arm/mach-s3c2412/Makefile | |||
@@ -0,0 +1,21 @@ | |||
1 | # arch/arm/mach-s3c2412/Makefile | ||
2 | # | ||
3 | # Copyright 2007 Simtec Electronics | ||
4 | # | ||
5 | # Licensed under GPLv2 | ||
6 | |||
7 | obj-y := | ||
8 | obj-m := | ||
9 | obj-n := | ||
10 | obj- := | ||
11 | |||
12 | obj-$(CONFIG_CPU_S3C2412) += s3c2412.o | ||
13 | obj-$(CONFIG_CPU_S3C2412) += irq.o | ||
14 | obj-$(CONFIG_CPU_S3C2412) += clock.o | ||
15 | obj-$(CONFIG_S3C2412_DMA) += dma.o | ||
16 | obj-$(CONFIG_S3C2412_PM) += pm.o | ||
17 | |||
18 | # Machine support | ||
19 | |||
20 | obj-$(CONFIG_MACH_SMDK2413) += mach-smdk2413.o | ||
21 | obj-$(CONFIG_MACH_VSTMS) += mach-vstms.o | ||
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c2412/clock.c new file mode 100644 index 000000000000..6a8e4448770b --- /dev/null +++ b/arch/arm/mach-s3c2412/clock.c | |||
@@ -0,0 +1,716 @@ | |||
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 | |||
35 | #include <asm/mach/map.h> | ||
36 | |||
37 | #include <asm/hardware.h> | ||
38 | #include <asm/io.h> | ||
39 | |||
40 | #include <asm/arch/regs-serial.h> | ||
41 | #include <asm/arch/regs-clock.h> | ||
42 | #include <asm/arch/regs-gpio.h> | ||
43 | |||
44 | #include <asm/plat-s3c24xx/s3c2412.h> | ||
45 | #include <asm/plat-s3c24xx/clock.h> | ||
46 | #include <asm/plat-s3c24xx/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 | /* CPU EXTCLK input */ | ||
97 | static struct clk clk_ext = { | ||
98 | .name = "extclk", | ||
99 | .id = -1, | ||
100 | }; | ||
101 | |||
102 | static struct clk clk_erefclk = { | ||
103 | .name = "erefclk", | ||
104 | .id = -1, | ||
105 | }; | ||
106 | |||
107 | static struct clk clk_urefclk = { | ||
108 | .name = "urefclk", | ||
109 | .id = -1, | ||
110 | }; | ||
111 | |||
112 | static int s3c2412_setparent_usysclk(struct clk *clk, struct clk *parent) | ||
113 | { | ||
114 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
115 | |||
116 | if (parent == &clk_urefclk) | ||
117 | clksrc &= ~S3C2412_CLKSRC_USYSCLK_UPLL; | ||
118 | else if (parent == &clk_upll) | ||
119 | clksrc |= S3C2412_CLKSRC_USYSCLK_UPLL; | ||
120 | else | ||
121 | return -EINVAL; | ||
122 | |||
123 | clk->parent = parent; | ||
124 | |||
125 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static struct clk clk_usysclk = { | ||
130 | .name = "usysclk", | ||
131 | .id = -1, | ||
132 | .parent = &clk_xtal, | ||
133 | .set_parent = s3c2412_setparent_usysclk, | ||
134 | }; | ||
135 | |||
136 | static struct clk clk_mrefclk = { | ||
137 | .name = "mrefclk", | ||
138 | .parent = &clk_xtal, | ||
139 | .id = -1, | ||
140 | }; | ||
141 | |||
142 | static struct clk clk_mdivclk = { | ||
143 | .name = "mdivclk", | ||
144 | .parent = &clk_xtal, | ||
145 | .id = -1, | ||
146 | }; | ||
147 | |||
148 | static int s3c2412_setparent_usbsrc(struct clk *clk, struct clk *parent) | ||
149 | { | ||
150 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
151 | |||
152 | if (parent == &clk_usysclk) | ||
153 | clksrc &= ~S3C2412_CLKSRC_USBCLK_HCLK; | ||
154 | else if (parent == &clk_h) | ||
155 | clksrc |= S3C2412_CLKSRC_USBCLK_HCLK; | ||
156 | else | ||
157 | return -EINVAL; | ||
158 | |||
159 | clk->parent = parent; | ||
160 | |||
161 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | static unsigned long s3c2412_roundrate_usbsrc(struct clk *clk, | ||
166 | unsigned long rate) | ||
167 | { | ||
168 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
169 | int div; | ||
170 | |||
171 | if (rate > parent_rate) | ||
172 | return parent_rate; | ||
173 | |||
174 | div = parent_rate / rate; | ||
175 | if (div > 2) | ||
176 | div = 2; | ||
177 | |||
178 | return parent_rate / div; | ||
179 | } | ||
180 | |||
181 | static unsigned long s3c2412_getrate_usbsrc(struct clk *clk) | ||
182 | { | ||
183 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
184 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
185 | |||
186 | return parent_rate / ((div & S3C2412_CLKDIVN_USB48DIV) ? 2 : 1); | ||
187 | } | ||
188 | |||
189 | static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate) | ||
190 | { | ||
191 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
192 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
193 | |||
194 | rate = s3c2412_roundrate_usbsrc(clk, rate); | ||
195 | |||
196 | if ((parent_rate / rate) == 2) | ||
197 | clkdivn |= S3C2412_CLKDIVN_USB48DIV; | ||
198 | else | ||
199 | clkdivn &= ~S3C2412_CLKDIVN_USB48DIV; | ||
200 | |||
201 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static struct clk clk_usbsrc = { | ||
206 | .name = "usbsrc", | ||
207 | .id = -1, | ||
208 | .get_rate = s3c2412_getrate_usbsrc, | ||
209 | .set_rate = s3c2412_setrate_usbsrc, | ||
210 | .round_rate = s3c2412_roundrate_usbsrc, | ||
211 | .set_parent = s3c2412_setparent_usbsrc, | ||
212 | }; | ||
213 | |||
214 | static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent) | ||
215 | { | ||
216 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
217 | |||
218 | if (parent == &clk_mdivclk) | ||
219 | clksrc &= ~S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
220 | else if (parent == &clk_upll) | ||
221 | clksrc |= S3C2412_CLKSRC_MSYSCLK_MPLL; | ||
222 | else | ||
223 | return -EINVAL; | ||
224 | |||
225 | clk->parent = parent; | ||
226 | |||
227 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static struct clk clk_msysclk = { | ||
232 | .name = "msysclk", | ||
233 | .id = -1, | ||
234 | .set_parent = s3c2412_setparent_msysclk, | ||
235 | }; | ||
236 | |||
237 | /* these next clocks have an divider immediately after them, | ||
238 | * so we can register them with their divider and leave out the | ||
239 | * intermediate clock stage | ||
240 | */ | ||
241 | static unsigned long s3c2412_roundrate_clksrc(struct clk *clk, | ||
242 | unsigned long rate) | ||
243 | { | ||
244 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
245 | int div; | ||
246 | |||
247 | if (rate > parent_rate) | ||
248 | return parent_rate; | ||
249 | |||
250 | /* note, we remove the +/- 1 calculations as they cancel out */ | ||
251 | |||
252 | div = (rate / parent_rate); | ||
253 | |||
254 | if (div < 1) | ||
255 | div = 1; | ||
256 | else if (div > 16) | ||
257 | div = 16; | ||
258 | |||
259 | return parent_rate / div; | ||
260 | } | ||
261 | |||
262 | static int s3c2412_setparent_uart(struct clk *clk, struct clk *parent) | ||
263 | { | ||
264 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
265 | |||
266 | if (parent == &clk_erefclk) | ||
267 | clksrc &= ~S3C2412_CLKSRC_UARTCLK_MPLL; | ||
268 | else if (parent == &clk_mpll) | ||
269 | clksrc |= S3C2412_CLKSRC_UARTCLK_MPLL; | ||
270 | else | ||
271 | return -EINVAL; | ||
272 | |||
273 | clk->parent = parent; | ||
274 | |||
275 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | static unsigned long s3c2412_getrate_uart(struct clk *clk) | ||
280 | { | ||
281 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
282 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
283 | |||
284 | div &= S3C2412_CLKDIVN_UARTDIV_MASK; | ||
285 | div >>= S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
286 | |||
287 | return parent_rate / (div + 1); | ||
288 | } | ||
289 | |||
290 | static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate) | ||
291 | { | ||
292 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
293 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
294 | |||
295 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
296 | |||
297 | clkdivn &= ~S3C2412_CLKDIVN_UARTDIV_MASK; | ||
298 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_UARTDIV_SHIFT; | ||
299 | |||
300 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | static struct clk clk_uart = { | ||
305 | .name = "uartclk", | ||
306 | .id = -1, | ||
307 | .get_rate = s3c2412_getrate_uart, | ||
308 | .set_rate = s3c2412_setrate_uart, | ||
309 | .set_parent = s3c2412_setparent_uart, | ||
310 | .round_rate = s3c2412_roundrate_clksrc, | ||
311 | }; | ||
312 | |||
313 | static int s3c2412_setparent_i2s(struct clk *clk, struct clk *parent) | ||
314 | { | ||
315 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
316 | |||
317 | if (parent == &clk_erefclk) | ||
318 | clksrc &= ~S3C2412_CLKSRC_I2SCLK_MPLL; | ||
319 | else if (parent == &clk_mpll) | ||
320 | clksrc |= S3C2412_CLKSRC_I2SCLK_MPLL; | ||
321 | else | ||
322 | return -EINVAL; | ||
323 | |||
324 | clk->parent = parent; | ||
325 | |||
326 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static unsigned long s3c2412_getrate_i2s(struct clk *clk) | ||
331 | { | ||
332 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
333 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
334 | |||
335 | div &= S3C2412_CLKDIVN_I2SDIV_MASK; | ||
336 | div >>= S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
337 | |||
338 | return parent_rate / (div + 1); | ||
339 | } | ||
340 | |||
341 | static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate) | ||
342 | { | ||
343 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
344 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
345 | |||
346 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
347 | |||
348 | clkdivn &= ~S3C2412_CLKDIVN_I2SDIV_MASK; | ||
349 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_I2SDIV_SHIFT; | ||
350 | |||
351 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | static struct clk clk_i2s = { | ||
356 | .name = "i2sclk", | ||
357 | .id = -1, | ||
358 | .get_rate = s3c2412_getrate_i2s, | ||
359 | .set_rate = s3c2412_setrate_i2s, | ||
360 | .set_parent = s3c2412_setparent_i2s, | ||
361 | .round_rate = s3c2412_roundrate_clksrc, | ||
362 | }; | ||
363 | |||
364 | static int s3c2412_setparent_cam(struct clk *clk, struct clk *parent) | ||
365 | { | ||
366 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
367 | |||
368 | if (parent == &clk_usysclk) | ||
369 | clksrc &= ~S3C2412_CLKSRC_CAMCLK_HCLK; | ||
370 | else if (parent == &clk_h) | ||
371 | clksrc |= S3C2412_CLKSRC_CAMCLK_HCLK; | ||
372 | else | ||
373 | return -EINVAL; | ||
374 | |||
375 | clk->parent = parent; | ||
376 | |||
377 | __raw_writel(clksrc, S3C2412_CLKSRC); | ||
378 | return 0; | ||
379 | } | ||
380 | static unsigned long s3c2412_getrate_cam(struct clk *clk) | ||
381 | { | ||
382 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
383 | unsigned long div = __raw_readl(S3C2410_CLKDIVN); | ||
384 | |||
385 | div &= S3C2412_CLKDIVN_CAMDIV_MASK; | ||
386 | div >>= S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
387 | |||
388 | return parent_rate / (div + 1); | ||
389 | } | ||
390 | |||
391 | static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate) | ||
392 | { | ||
393 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
394 | unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); | ||
395 | |||
396 | rate = s3c2412_roundrate_clksrc(clk, rate); | ||
397 | |||
398 | clkdivn &= ~S3C2412_CLKDIVN_CAMDIV_MASK; | ||
399 | clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_CAMDIV_SHIFT; | ||
400 | |||
401 | __raw_writel(clkdivn, S3C2410_CLKDIVN); | ||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | static struct clk clk_cam = { | ||
406 | .name = "camif-upll", /* same as 2440 name */ | ||
407 | .id = -1, | ||
408 | .get_rate = s3c2412_getrate_cam, | ||
409 | .set_rate = s3c2412_setrate_cam, | ||
410 | .set_parent = s3c2412_setparent_cam, | ||
411 | .round_rate = s3c2412_roundrate_clksrc, | ||
412 | }; | ||
413 | |||
414 | /* standard clock definitions */ | ||
415 | |||
416 | static struct clk init_clocks_disable[] = { | ||
417 | { | ||
418 | .name = "nand", | ||
419 | .id = -1, | ||
420 | .parent = &clk_h, | ||
421 | .enable = s3c2412_clkcon_enable, | ||
422 | .ctrlbit = S3C2412_CLKCON_NAND, | ||
423 | }, { | ||
424 | .name = "sdi", | ||
425 | .id = -1, | ||
426 | .parent = &clk_p, | ||
427 | .enable = s3c2412_clkcon_enable, | ||
428 | .ctrlbit = S3C2412_CLKCON_SDI, | ||
429 | }, { | ||
430 | .name = "adc", | ||
431 | .id = -1, | ||
432 | .parent = &clk_p, | ||
433 | .enable = s3c2412_clkcon_enable, | ||
434 | .ctrlbit = S3C2412_CLKCON_ADC, | ||
435 | }, { | ||
436 | .name = "i2c", | ||
437 | .id = -1, | ||
438 | .parent = &clk_p, | ||
439 | .enable = s3c2412_clkcon_enable, | ||
440 | .ctrlbit = S3C2412_CLKCON_IIC, | ||
441 | }, { | ||
442 | .name = "iis", | ||
443 | .id = -1, | ||
444 | .parent = &clk_p, | ||
445 | .enable = s3c2412_clkcon_enable, | ||
446 | .ctrlbit = S3C2412_CLKCON_IIS, | ||
447 | }, { | ||
448 | .name = "spi", | ||
449 | .id = -1, | ||
450 | .parent = &clk_p, | ||
451 | .enable = s3c2412_clkcon_enable, | ||
452 | .ctrlbit = S3C2412_CLKCON_SPI, | ||
453 | } | ||
454 | }; | ||
455 | |||
456 | static struct clk init_clocks[] = { | ||
457 | { | ||
458 | .name = "dma", | ||
459 | .id = 0, | ||
460 | .parent = &clk_h, | ||
461 | .enable = s3c2412_clkcon_enable, | ||
462 | .ctrlbit = S3C2412_CLKCON_DMA0, | ||
463 | }, { | ||
464 | .name = "dma", | ||
465 | .id = 1, | ||
466 | .parent = &clk_h, | ||
467 | .enable = s3c2412_clkcon_enable, | ||
468 | .ctrlbit = S3C2412_CLKCON_DMA1, | ||
469 | }, { | ||
470 | .name = "dma", | ||
471 | .id = 2, | ||
472 | .parent = &clk_h, | ||
473 | .enable = s3c2412_clkcon_enable, | ||
474 | .ctrlbit = S3C2412_CLKCON_DMA2, | ||
475 | }, { | ||
476 | .name = "dma", | ||
477 | .id = 3, | ||
478 | .parent = &clk_h, | ||
479 | .enable = s3c2412_clkcon_enable, | ||
480 | .ctrlbit = S3C2412_CLKCON_DMA3, | ||
481 | }, { | ||
482 | .name = "lcd", | ||
483 | .id = -1, | ||
484 | .parent = &clk_h, | ||
485 | .enable = s3c2412_clkcon_enable, | ||
486 | .ctrlbit = S3C2412_CLKCON_LCDC, | ||
487 | }, { | ||
488 | .name = "gpio", | ||
489 | .id = -1, | ||
490 | .parent = &clk_p, | ||
491 | .enable = s3c2412_clkcon_enable, | ||
492 | .ctrlbit = S3C2412_CLKCON_GPIO, | ||
493 | }, { | ||
494 | .name = "usb-host", | ||
495 | .id = -1, | ||
496 | .parent = &clk_h, | ||
497 | .enable = s3c2412_clkcon_enable, | ||
498 | .ctrlbit = S3C2412_CLKCON_USBH, | ||
499 | }, { | ||
500 | .name = "usb-device", | ||
501 | .id = -1, | ||
502 | .parent = &clk_h, | ||
503 | .enable = s3c2412_clkcon_enable, | ||
504 | .ctrlbit = S3C2412_CLKCON_USBD, | ||
505 | }, { | ||
506 | .name = "timers", | ||
507 | .id = -1, | ||
508 | .parent = &clk_p, | ||
509 | .enable = s3c2412_clkcon_enable, | ||
510 | .ctrlbit = S3C2412_CLKCON_PWMT, | ||
511 | }, { | ||
512 | .name = "uart", | ||
513 | .id = 0, | ||
514 | .parent = &clk_p, | ||
515 | .enable = s3c2412_clkcon_enable, | ||
516 | .ctrlbit = S3C2412_CLKCON_UART0, | ||
517 | }, { | ||
518 | .name = "uart", | ||
519 | .id = 1, | ||
520 | .parent = &clk_p, | ||
521 | .enable = s3c2412_clkcon_enable, | ||
522 | .ctrlbit = S3C2412_CLKCON_UART1, | ||
523 | }, { | ||
524 | .name = "uart", | ||
525 | .id = 2, | ||
526 | .parent = &clk_p, | ||
527 | .enable = s3c2412_clkcon_enable, | ||
528 | .ctrlbit = S3C2412_CLKCON_UART2, | ||
529 | }, { | ||
530 | .name = "rtc", | ||
531 | .id = -1, | ||
532 | .parent = &clk_p, | ||
533 | .enable = s3c2412_clkcon_enable, | ||
534 | .ctrlbit = S3C2412_CLKCON_RTC, | ||
535 | }, { | ||
536 | .name = "watchdog", | ||
537 | .id = -1, | ||
538 | .parent = &clk_p, | ||
539 | .ctrlbit = 0, | ||
540 | }, { | ||
541 | .name = "usb-bus-gadget", | ||
542 | .id = -1, | ||
543 | .parent = &clk_usb_bus, | ||
544 | .enable = s3c2412_clkcon_enable, | ||
545 | .ctrlbit = S3C2412_CLKCON_USB_DEV48, | ||
546 | }, { | ||
547 | .name = "usb-bus-host", | ||
548 | .id = -1, | ||
549 | .parent = &clk_usb_bus, | ||
550 | .enable = s3c2412_clkcon_enable, | ||
551 | .ctrlbit = S3C2412_CLKCON_USB_HOST48, | ||
552 | } | ||
553 | }; | ||
554 | |||
555 | /* clocks to add where we need to check their parentage */ | ||
556 | |||
557 | struct clk_init { | ||
558 | struct clk *clk; | ||
559 | unsigned int bit; | ||
560 | struct clk *src_0; | ||
561 | struct clk *src_1; | ||
562 | }; | ||
563 | |||
564 | static struct clk_init clks_src[] __initdata = { | ||
565 | { | ||
566 | .clk = &clk_usysclk, | ||
567 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
568 | .src_0 = &clk_urefclk, | ||
569 | .src_1 = &clk_upll, | ||
570 | }, { | ||
571 | .clk = &clk_i2s, | ||
572 | .bit = S3C2412_CLKSRC_I2SCLK_MPLL, | ||
573 | .src_0 = &clk_erefclk, | ||
574 | .src_1 = &clk_mpll, | ||
575 | }, { | ||
576 | .clk = &clk_cam, | ||
577 | .bit = S3C2412_CLKSRC_CAMCLK_HCLK, | ||
578 | .src_0 = &clk_usysclk, | ||
579 | .src_1 = &clk_h, | ||
580 | }, { | ||
581 | .clk = &clk_msysclk, | ||
582 | .bit = S3C2412_CLKSRC_MSYSCLK_MPLL, | ||
583 | .src_0 = &clk_mdivclk, | ||
584 | .src_1 = &clk_mpll, | ||
585 | }, { | ||
586 | .clk = &clk_uart, | ||
587 | .bit = S3C2412_CLKSRC_UARTCLK_MPLL, | ||
588 | .src_0 = &clk_erefclk, | ||
589 | .src_1 = &clk_mpll, | ||
590 | }, { | ||
591 | .clk = &clk_usbsrc, | ||
592 | .bit = S3C2412_CLKSRC_USBCLK_HCLK, | ||
593 | .src_0 = &clk_usysclk, | ||
594 | .src_1 = &clk_h, | ||
595 | }, | ||
596 | }; | ||
597 | |||
598 | /* s3c2412_clk_initparents | ||
599 | * | ||
600 | * Initialise the parents for the clocks that we get at start-time | ||
601 | */ | ||
602 | |||
603 | static void __init s3c2412_clk_initparents(void) | ||
604 | { | ||
605 | unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); | ||
606 | struct clk_init *cip = clks_src; | ||
607 | struct clk *src; | ||
608 | int ptr; | ||
609 | int ret; | ||
610 | |||
611 | for (ptr = 0; ptr < ARRAY_SIZE(clks_src); ptr++, cip++) { | ||
612 | ret = s3c24xx_register_clock(cip->clk); | ||
613 | if (ret < 0) { | ||
614 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
615 | cip->clk->name, ret); | ||
616 | } | ||
617 | |||
618 | src = (clksrc & cip->bit) ? cip->src_1 : cip->src_0; | ||
619 | |||
620 | printk(KERN_INFO "%s: parent %s\n", cip->clk->name, src->name); | ||
621 | clk_set_parent(cip->clk, src); | ||
622 | } | ||
623 | } | ||
624 | |||
625 | /* clocks to add straight away */ | ||
626 | |||
627 | static struct clk *clks[] __initdata = { | ||
628 | &clk_ext, | ||
629 | &clk_usb_bus, | ||
630 | &clk_erefclk, | ||
631 | &clk_urefclk, | ||
632 | &clk_mrefclk, | ||
633 | }; | ||
634 | |||
635 | int __init s3c2412_baseclk_add(void) | ||
636 | { | ||
637 | unsigned long clkcon = __raw_readl(S3C2410_CLKCON); | ||
638 | struct clk *clkp; | ||
639 | int ret; | ||
640 | int ptr; | ||
641 | |||
642 | clk_upll.enable = s3c2412_upll_enable; | ||
643 | clk_usb_bus.parent = &clk_usbsrc; | ||
644 | clk_usb_bus.rate = 0x0; | ||
645 | |||
646 | s3c2412_clk_initparents(); | ||
647 | |||
648 | for (ptr = 0; ptr < ARRAY_SIZE(clks); ptr++) { | ||
649 | clkp = clks[ptr]; | ||
650 | |||
651 | ret = s3c24xx_register_clock(clkp); | ||
652 | if (ret < 0) { | ||
653 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
654 | clkp->name, ret); | ||
655 | } | ||
656 | } | ||
657 | |||
658 | /* ensure usb bus clock is within correct rate of 48MHz */ | ||
659 | |||
660 | if (clk_get_rate(&clk_usb_bus) != (48 * 1000 * 1000)) { | ||
661 | printk(KERN_INFO "Warning: USB bus clock not at 48MHz\n"); | ||
662 | |||
663 | /* for the moment, let's use the UPLL, and see if we can | ||
664 | * get 48MHz */ | ||
665 | |||
666 | clk_set_parent(&clk_usysclk, &clk_upll); | ||
667 | clk_set_parent(&clk_usbsrc, &clk_usysclk); | ||
668 | clk_set_rate(&clk_usbsrc, 48*1000*1000); | ||
669 | } | ||
670 | |||
671 | printk("S3C2412: upll %s, %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", | ||
672 | (__raw_readl(S3C2410_UPLLCON) & S3C2412_PLLCON_OFF) ? "off":"on", | ||
673 | print_mhz(clk_get_rate(&clk_upll)), | ||
674 | print_mhz(clk_get_rate(&clk_usb_bus))); | ||
675 | |||
676 | /* register clocks from clock array */ | ||
677 | |||
678 | clkp = init_clocks; | ||
679 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { | ||
680 | /* ensure that we note the clock state */ | ||
681 | |||
682 | clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0; | ||
683 | |||
684 | ret = s3c24xx_register_clock(clkp); | ||
685 | if (ret < 0) { | ||
686 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
687 | clkp->name, ret); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | /* We must be careful disabling the clocks we are not intending to | ||
692 | * be using at boot time, as subsytems such as the LCD which do | ||
693 | * their own DMA requests to the bus can cause the system to lockup | ||
694 | * if they where in the middle of requesting bus access. | ||
695 | * | ||
696 | * Disabling the LCD clock if the LCD is active is very dangerous, | ||
697 | * and therefore the bootloader should be careful to not enable | ||
698 | * the LCD clock if it is not needed. | ||
699 | */ | ||
700 | |||
701 | /* install (and disable) the clocks we do not need immediately */ | ||
702 | |||
703 | clkp = init_clocks_disable; | ||
704 | for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) { | ||
705 | |||
706 | ret = s3c24xx_register_clock(clkp); | ||
707 | if (ret < 0) { | ||
708 | printk(KERN_ERR "Failed to register clock %s (%d)\n", | ||
709 | clkp->name, ret); | ||
710 | } | ||
711 | |||
712 | s3c2412_clkcon_enable(clkp, 0); | ||
713 | } | ||
714 | |||
715 | return 0; | ||
716 | } | ||
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c2412/dma.c new file mode 100644 index 000000000000..28b598287fae --- /dev/null +++ b/arch/arm/mach-s3c2412/dma.c | |||
@@ -0,0 +1,161 @@ | |||
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 | |||
20 | #include <asm/dma.h> | ||
21 | #include <asm/arch/dma.h> | ||
22 | #include <asm/io.h> | ||
23 | |||
24 | #include <asm/plat-s3c24xx/dma.h> | ||
25 | #include <asm/plat-s3c24xx/cpu.h> | ||
26 | |||
27 | #include <asm/arch/regs-serial.h> | ||
28 | #include <asm/arch/regs-gpio.h> | ||
29 | #include <asm/arch/regs-ac97.h> | ||
30 | #include <asm/arch/regs-mem.h> | ||
31 | #include <asm/arch/regs-lcd.h> | ||
32 | #include <asm/arch/regs-sdi.h> | ||
33 | #include <asm/arch/regs-iis.h> | ||
34 | #include <asm/arch/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 | }, | ||
43 | [DMACH_XD1] = { | ||
44 | .name = "xdreq1", | ||
45 | .channels = MAP(S3C2412_DMAREQSEL_XDREQ1), | ||
46 | }, | ||
47 | [DMACH_SDI] = { | ||
48 | .name = "sdi", | ||
49 | .channels = MAP(S3C2412_DMAREQSEL_SDI), | ||
50 | .hw_addr.to = S3C2410_PA_IIS + S3C2410_IISFIFO, | ||
51 | .hw_addr.from = S3C2410_PA_IIS + S3C2410_IISFIFO, | ||
52 | }, | ||
53 | [DMACH_SPI0] = { | ||
54 | .name = "spi0", | ||
55 | .channels = MAP(S3C2412_DMAREQSEL_SPI0TX), | ||
56 | .hw_addr.to = S3C2410_PA_SPI + S3C2410_SPTDAT, | ||
57 | .hw_addr.from = S3C2410_PA_SPI + S3C2410_SPRDAT, | ||
58 | }, | ||
59 | [DMACH_SPI1] = { | ||
60 | .name = "spi1", | ||
61 | .channels = MAP(S3C2412_DMAREQSEL_SPI1TX), | ||
62 | .hw_addr.to = S3C2410_PA_SPI + 0x20 + S3C2410_SPTDAT, | ||
63 | .hw_addr.from = S3C2410_PA_SPI + 0x20 + S3C2410_SPRDAT, | ||
64 | }, | ||
65 | [DMACH_UART0] = { | ||
66 | .name = "uart0", | ||
67 | .channels = MAP(S3C2412_DMAREQSEL_UART0_0), | ||
68 | .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH, | ||
69 | .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH, | ||
70 | }, | ||
71 | [DMACH_UART1] = { | ||
72 | .name = "uart1", | ||
73 | .channels = MAP(S3C2412_DMAREQSEL_UART1_0), | ||
74 | .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH, | ||
75 | .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH, | ||
76 | }, | ||
77 | [DMACH_UART2] = { | ||
78 | .name = "uart2", | ||
79 | .channels = MAP(S3C2412_DMAREQSEL_UART2_0), | ||
80 | .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH, | ||
81 | .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH, | ||
82 | }, | ||
83 | [DMACH_UART0_SRC2] = { | ||
84 | .name = "uart0", | ||
85 | .channels = MAP(S3C2412_DMAREQSEL_UART0_1), | ||
86 | .hw_addr.to = S3C2410_PA_UART0 + S3C2410_UTXH, | ||
87 | .hw_addr.from = S3C2410_PA_UART0 + S3C2410_URXH, | ||
88 | }, | ||
89 | [DMACH_UART1_SRC2] = { | ||
90 | .name = "uart1", | ||
91 | .channels = MAP(S3C2412_DMAREQSEL_UART1_1), | ||
92 | .hw_addr.to = S3C2410_PA_UART1 + S3C2410_UTXH, | ||
93 | .hw_addr.from = S3C2410_PA_UART1 + S3C2410_URXH, | ||
94 | }, | ||
95 | [DMACH_UART2_SRC2] = { | ||
96 | .name = "uart2", | ||
97 | .channels = MAP(S3C2412_DMAREQSEL_UART2_1), | ||
98 | .hw_addr.to = S3C2410_PA_UART2 + S3C2410_UTXH, | ||
99 | .hw_addr.from = S3C2410_PA_UART2 + S3C2410_URXH, | ||
100 | }, | ||
101 | [DMACH_TIMER] = { | ||
102 | .name = "timer", | ||
103 | .channels = MAP(S3C2412_DMAREQSEL_TIMER), | ||
104 | }, | ||
105 | [DMACH_I2S_IN] = { | ||
106 | .name = "i2s-sdi", | ||
107 | .channels = MAP(S3C2412_DMAREQSEL_I2SRX), | ||
108 | .hw_addr.from = S3C2410_PA_IIS + S3C2410_IISFIFO, | ||
109 | }, | ||
110 | [DMACH_I2S_OUT] = { | ||
111 | .name = "i2s-sdo", | ||
112 | .channels = MAP(S3C2412_DMAREQSEL_I2STX), | ||
113 | .hw_addr.to = S3C2410_PA_IIS + S3C2410_IISFIFO, | ||
114 | }, | ||
115 | [DMACH_USB_EP1] = { | ||
116 | .name = "usb-ep1", | ||
117 | .channels = MAP(S3C2412_DMAREQSEL_USBEP1), | ||
118 | }, | ||
119 | [DMACH_USB_EP2] = { | ||
120 | .name = "usb-ep2", | ||
121 | .channels = MAP(S3C2412_DMAREQSEL_USBEP2), | ||
122 | }, | ||
123 | [DMACH_USB_EP3] = { | ||
124 | .name = "usb-ep3", | ||
125 | .channels = MAP(S3C2412_DMAREQSEL_USBEP3), | ||
126 | }, | ||
127 | [DMACH_USB_EP4] = { | ||
128 | .name = "usb-ep4", | ||
129 | .channels = MAP(S3C2412_DMAREQSEL_USBEP4), | ||
130 | }, | ||
131 | }; | ||
132 | |||
133 | static void s3c2412_dma_select(struct s3c2410_dma_chan *chan, | ||
134 | struct s3c24xx_dma_map *map) | ||
135 | { | ||
136 | writel(map->channels[0] | S3C2412_DMAREQSEL_HW, | ||
137 | chan->regs + S3C2412_DMA_DMAREQSEL); | ||
138 | } | ||
139 | |||
140 | static struct s3c24xx_dma_selection __initdata s3c2412_dma_sel = { | ||
141 | .select = s3c2412_dma_select, | ||
142 | .dcon_mask = 0, | ||
143 | .map = s3c2412_dma_mappings, | ||
144 | .map_size = ARRAY_SIZE(s3c2412_dma_mappings), | ||
145 | }; | ||
146 | |||
147 | static int s3c2412_dma_add(struct sys_device *sysdev) | ||
148 | { | ||
149 | return s3c24xx_dma_init_map(&s3c2412_dma_sel); | ||
150 | } | ||
151 | |||
152 | static struct sysdev_driver s3c2412_dma_driver = { | ||
153 | .add = s3c2412_dma_add, | ||
154 | }; | ||
155 | |||
156 | static int __init s3c2412_dma_init(void) | ||
157 | { | ||
158 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_dma_driver); | ||
159 | } | ||
160 | |||
161 | 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 000000000000..e89dbdcb1b7b --- /dev/null +++ b/arch/arm/mach-s3c2412/irq.c | |||
@@ -0,0 +1,133 @@ | |||
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/ptrace.h> | ||
27 | #include <linux/sysdev.h> | ||
28 | |||
29 | #include <asm/hardware.h> | ||
30 | #include <asm/irq.h> | ||
31 | #include <asm/io.h> | ||
32 | |||
33 | #include <asm/mach/irq.h> | ||
34 | |||
35 | #include <asm/arch/regs-irq.h> | ||
36 | #include <asm/arch/regs-gpio.h> | ||
37 | |||
38 | #include <asm/plat-s3c24xx/cpu.h> | ||
39 | #include <asm/plat-s3c24xx/irq.h> | ||
40 | #include <asm/plat-s3c24xx/pm.h> | ||
41 | |||
42 | /* the s3c2412 changes the behaviour of IRQ_EINT0 through IRQ_EINT3 by | ||
43 | * having them turn up in both the INT* and the EINT* registers. Whilst | ||
44 | * both show the status, they both now need to be acked when the IRQs | ||
45 | * go off. | ||
46 | */ | ||
47 | |||
48 | static void | ||
49 | s3c2412_irq_mask(unsigned int irqno) | ||
50 | { | ||
51 | unsigned long bitval = 1UL << (irqno - IRQ_EINT0); | ||
52 | unsigned long mask; | ||
53 | |||
54 | mask = __raw_readl(S3C2410_INTMSK); | ||
55 | __raw_writel(mask | bitval, S3C2410_INTMSK); | ||
56 | |||
57 | mask = __raw_readl(S3C2412_EINTMASK); | ||
58 | __raw_writel(mask | bitval, S3C2412_EINTMASK); | ||
59 | } | ||
60 | |||
61 | static inline void | ||
62 | s3c2412_irq_ack(unsigned int irqno) | ||
63 | { | ||
64 | unsigned long bitval = 1UL << (irqno - IRQ_EINT0); | ||
65 | |||
66 | __raw_writel(bitval, S3C2412_EINTPEND); | ||
67 | __raw_writel(bitval, S3C2410_SRCPND); | ||
68 | __raw_writel(bitval, S3C2410_INTPND); | ||
69 | } | ||
70 | |||
71 | static inline void | ||
72 | s3c2412_irq_maskack(unsigned int irqno) | ||
73 | { | ||
74 | unsigned long bitval = 1UL << (irqno - IRQ_EINT0); | ||
75 | unsigned long mask; | ||
76 | |||
77 | mask = __raw_readl(S3C2410_INTMSK); | ||
78 | __raw_writel(mask|bitval, S3C2410_INTMSK); | ||
79 | |||
80 | mask = __raw_readl(S3C2412_EINTMASK); | ||
81 | __raw_writel(mask | bitval, S3C2412_EINTMASK); | ||
82 | |||
83 | __raw_writel(bitval, S3C2412_EINTPEND); | ||
84 | __raw_writel(bitval, S3C2410_SRCPND); | ||
85 | __raw_writel(bitval, S3C2410_INTPND); | ||
86 | } | ||
87 | |||
88 | static void | ||
89 | s3c2412_irq_unmask(unsigned int irqno) | ||
90 | { | ||
91 | unsigned long bitval = 1UL << (irqno - IRQ_EINT0); | ||
92 | unsigned long mask; | ||
93 | |||
94 | mask = __raw_readl(S3C2412_EINTMASK); | ||
95 | __raw_writel(mask & ~bitval, S3C2412_EINTMASK); | ||
96 | |||
97 | mask = __raw_readl(S3C2410_INTMSK); | ||
98 | __raw_writel(mask & ~bitval, S3C2410_INTMSK); | ||
99 | } | ||
100 | |||
101 | static struct irq_chip s3c2412_irq_eint0t4 = { | ||
102 | .ack = s3c2412_irq_ack, | ||
103 | .mask = s3c2412_irq_mask, | ||
104 | .unmask = s3c2412_irq_unmask, | ||
105 | .set_wake = s3c_irq_wake, | ||
106 | .set_type = s3c_irqext_type, | ||
107 | }; | ||
108 | |||
109 | static int s3c2412_irq_add(struct sys_device *sysdev) | ||
110 | { | ||
111 | unsigned int irqno; | ||
112 | |||
113 | for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) { | ||
114 | set_irq_chip(irqno, &s3c2412_irq_eint0t4); | ||
115 | set_irq_handler(irqno, handle_edge_irq); | ||
116 | set_irq_flags(irqno, IRQF_VALID); | ||
117 | } | ||
118 | |||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static struct sysdev_driver s3c2412_irq_driver = { | ||
123 | .add = s3c2412_irq_add, | ||
124 | .suspend = s3c24xx_irq_suspend, | ||
125 | .resume = s3c24xx_irq_resume, | ||
126 | }; | ||
127 | |||
128 | static int s3c2412_irq_init(void) | ||
129 | { | ||
130 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_irq_driver); | ||
131 | } | ||
132 | |||
133 | arch_initcall(s3c2412_irq_init); | ||
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c new file mode 100644 index 000000000000..32b15617ef2a --- /dev/null +++ b/arch/arm/mach-s3c2412/mach-smdk2413.c | |||
@@ -0,0 +1,140 @@ | |||
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/serial_core.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | |||
23 | #include <asm/mach/arch.h> | ||
24 | #include <asm/mach/map.h> | ||
25 | #include <asm/mach/irq.h> | ||
26 | |||
27 | #include <asm/hardware.h> | ||
28 | #include <asm/hardware/iomd.h> | ||
29 | #include <asm/setup.h> | ||
30 | #include <asm/io.h> | ||
31 | #include <asm/irq.h> | ||
32 | #include <asm/mach-types.h> | ||
33 | |||
34 | //#include <asm/debug-ll.h> | ||
35 | #include <asm/arch/regs-serial.h> | ||
36 | #include <asm/arch/regs-gpio.h> | ||
37 | #include <asm/arch/regs-lcd.h> | ||
38 | |||
39 | #include <asm/arch/idle.h> | ||
40 | #include <asm/arch/fb.h> | ||
41 | |||
42 | #include <asm/plat-s3c24xx/s3c2410.h> | ||
43 | #include <asm/plat-s3c24xx/s3c2412.h> | ||
44 | #include <asm/plat-s3c24xx/clock.h> | ||
45 | #include <asm/plat-s3c24xx/devs.h> | ||
46 | #include <asm/plat-s3c24xx/cpu.h> | ||
47 | |||
48 | #include <asm/plat-s3c24xx/common-smdk.h> | ||
49 | |||
50 | static struct map_desc smdk2413_iodesc[] __initdata = { | ||
51 | }; | ||
52 | |||
53 | static struct s3c2410_uartcfg smdk2413_uartcfgs[] __initdata = { | ||
54 | [0] = { | ||
55 | .hwport = 0, | ||
56 | .flags = 0, | ||
57 | .ucon = 0x3c5, | ||
58 | .ulcon = 0x03, | ||
59 | .ufcon = 0x51, | ||
60 | }, | ||
61 | [1] = { | ||
62 | .hwport = 1, | ||
63 | .flags = 0, | ||
64 | .ucon = 0x3c5, | ||
65 | .ulcon = 0x03, | ||
66 | .ufcon = 0x51, | ||
67 | }, | ||
68 | /* IR port */ | ||
69 | [2] = { | ||
70 | .hwport = 2, | ||
71 | .flags = 0, | ||
72 | .ucon = 0x3c5, | ||
73 | .ulcon = 0x43, | ||
74 | .ufcon = 0x51, | ||
75 | } | ||
76 | }; | ||
77 | |||
78 | static struct platform_device *smdk2413_devices[] __initdata = { | ||
79 | &s3c_device_usb, | ||
80 | //&s3c_device_lcd, | ||
81 | &s3c_device_wdt, | ||
82 | &s3c_device_i2c, | ||
83 | &s3c_device_iis, | ||
84 | }; | ||
85 | |||
86 | static struct s3c24xx_board smdk2413_board __initdata = { | ||
87 | .devices = smdk2413_devices, | ||
88 | .devices_count = ARRAY_SIZE(smdk2413_devices) | ||
89 | }; | ||
90 | |||
91 | static void __init smdk2413_fixup(struct machine_desc *desc, | ||
92 | struct tag *tags, char **cmdline, | ||
93 | struct meminfo *mi) | ||
94 | { | ||
95 | if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { | ||
96 | mi->nr_banks=1; | ||
97 | mi->bank[0].start = 0x30000000; | ||
98 | mi->bank[0].size = SZ_64M; | ||
99 | mi->bank[0].node = 0; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | static void __init smdk2413_map_io(void) | ||
104 | { | ||
105 | s3c24xx_init_io(smdk2413_iodesc, ARRAY_SIZE(smdk2413_iodesc)); | ||
106 | s3c24xx_init_clocks(12000000); | ||
107 | s3c24xx_init_uarts(smdk2413_uartcfgs, ARRAY_SIZE(smdk2413_uartcfgs)); | ||
108 | s3c24xx_set_board(&smdk2413_board); | ||
109 | } | ||
110 | |||
111 | static void __init smdk2413_machine_init(void) | ||
112 | { | ||
113 | smdk_machine_init(); | ||
114 | } | ||
115 | |||
116 | MACHINE_START(S3C2413, "S3C2413") | ||
117 | /* Maintainer: Ben Dooks <ben@fluff.org> */ | ||
118 | .phys_io = S3C2410_PA_UART, | ||
119 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | ||
120 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
121 | |||
122 | .fixup = smdk2413_fixup, | ||
123 | .init_irq = s3c24xx_init_irq, | ||
124 | .map_io = smdk2413_map_io, | ||
125 | .init_machine = smdk2413_machine_init, | ||
126 | .timer = &s3c24xx_timer, | ||
127 | MACHINE_END | ||
128 | |||
129 | MACHINE_START(SMDK2413, "SMDK2413") | ||
130 | /* Maintainer: Ben Dooks <ben@fluff.org> */ | ||
131 | .phys_io = S3C2410_PA_UART, | ||
132 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | ||
133 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
134 | |||
135 | .fixup = smdk2413_fixup, | ||
136 | .init_irq = s3c24xx_init_irq, | ||
137 | .map_io = smdk2413_map_io, | ||
138 | .init_machine = smdk2413_machine_init, | ||
139 | .timer = &s3c24xx_timer, | ||
140 | 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 000000000000..f1afb707ff16 --- /dev/null +++ b/arch/arm/mach-s3c2412/mach-vstms.c | |||
@@ -0,0 +1,169 @@ | |||
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 | |||
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 <asm/hardware.h> | ||
31 | #include <asm/hardware/iomd.h> | ||
32 | #include <asm/setup.h> | ||
33 | #include <asm/io.h> | ||
34 | #include <asm/irq.h> | ||
35 | #include <asm/mach-types.h> | ||
36 | |||
37 | #include <asm/arch/regs-serial.h> | ||
38 | #include <asm/arch/regs-gpio.h> | ||
39 | #include <asm/arch/regs-lcd.h> | ||
40 | |||
41 | #include <asm/arch/idle.h> | ||
42 | #include <asm/arch/fb.h> | ||
43 | |||
44 | #include <asm/arch/nand.h> | ||
45 | |||
46 | #include <asm/plat-s3c24xx/s3c2410.h> | ||
47 | #include <asm/plat-s3c24xx/s3c2412.h> | ||
48 | #include <asm/plat-s3c24xx/clock.h> | ||
49 | #include <asm/plat-s3c24xx/devs.h> | ||
50 | #include <asm/plat-s3c24xx/cpu.h> | ||
51 | |||
52 | |||
53 | static struct map_desc vstms_iodesc[] __initdata = { | ||
54 | }; | ||
55 | |||
56 | static struct s3c2410_uartcfg vstms_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 | [2] = { | ||
72 | .hwport = 2, | ||
73 | .flags = 0, | ||
74 | .ucon = 0x3c5, | ||
75 | .ulcon = 0x03, | ||
76 | .ufcon = 0x51, | ||
77 | } | ||
78 | }; | ||
79 | |||
80 | static struct mtd_partition vstms_nand_part[] = { | ||
81 | [0] = { | ||
82 | .name = "Boot Agent", | ||
83 | .size = 0x7C000, | ||
84 | .offset = 0, | ||
85 | }, | ||
86 | [1] = { | ||
87 | .name = "UBoot Config", | ||
88 | .offset = 0x7C000, | ||
89 | .size = 0x4000, | ||
90 | }, | ||
91 | [2] = { | ||
92 | .name = "Kernel", | ||
93 | .offset = 0x80000, | ||
94 | .size = 0x200000, | ||
95 | }, | ||
96 | [3] = { | ||
97 | .name = "RFS", | ||
98 | .offset = 0x280000, | ||
99 | .size = 0x3d80000, | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | static struct s3c2410_nand_set vstms_nand_sets[] = { | ||
104 | [0] = { | ||
105 | .name = "NAND", | ||
106 | .nr_chips = 1, | ||
107 | .nr_partitions = ARRAY_SIZE(vstms_nand_part), | ||
108 | .partitions = vstms_nand_part, | ||
109 | }, | ||
110 | }; | ||
111 | |||
112 | /* choose a set of timings which should suit most 512Mbit | ||
113 | * chips and beyond. | ||
114 | */ | ||
115 | |||
116 | static struct s3c2410_platform_nand vstms_nand_info = { | ||
117 | .tacls = 20, | ||
118 | .twrph0 = 60, | ||
119 | .twrph1 = 20, | ||
120 | .nr_sets = ARRAY_SIZE(vstms_nand_sets), | ||
121 | .sets = vstms_nand_sets, | ||
122 | }; | ||
123 | |||
124 | static struct platform_device *vstms_devices[] __initdata = { | ||
125 | &s3c_device_usb, | ||
126 | &s3c_device_wdt, | ||
127 | &s3c_device_i2c, | ||
128 | &s3c_device_iis, | ||
129 | &s3c_device_rtc, | ||
130 | &s3c_device_nand, | ||
131 | }; | ||
132 | |||
133 | static struct s3c24xx_board vstms_board __initdata = { | ||
134 | .devices = vstms_devices, | ||
135 | .devices_count = ARRAY_SIZE(vstms_devices) | ||
136 | }; | ||
137 | |||
138 | static void __init vstms_fixup(struct machine_desc *desc, | ||
139 | struct tag *tags, char **cmdline, | ||
140 | struct meminfo *mi) | ||
141 | { | ||
142 | if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { | ||
143 | mi->nr_banks=1; | ||
144 | mi->bank[0].start = 0x30000000; | ||
145 | mi->bank[0].size = SZ_64M; | ||
146 | mi->bank[0].node = 0; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | static void __init vstms_map_io(void) | ||
151 | { | ||
152 | s3c_device_nand.dev.platform_data = &vstms_nand_info; | ||
153 | |||
154 | s3c24xx_init_io(vstms_iodesc, ARRAY_SIZE(vstms_iodesc)); | ||
155 | s3c24xx_init_clocks(12000000); | ||
156 | s3c24xx_init_uarts(vstms_uartcfgs, ARRAY_SIZE(vstms_uartcfgs)); | ||
157 | s3c24xx_set_board(&vstms_board); | ||
158 | } | ||
159 | |||
160 | MACHINE_START(VSTMS, "VSTMS") | ||
161 | .phys_io = S3C2410_PA_UART, | ||
162 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | ||
163 | .boot_params = S3C2410_SDRAM_PA + 0x100, | ||
164 | |||
165 | .fixup = vstms_fixup, | ||
166 | .init_irq = s3c24xx_init_irq, | ||
167 | .map_io = vstms_map_io, | ||
168 | .timer = &s3c24xx_timer, | ||
169 | MACHINE_END | ||
diff --git a/arch/arm/mach-s3c2412/pm.c b/arch/arm/mach-s3c2412/pm.c new file mode 100644 index 000000000000..8988dac388a9 --- /dev/null +++ b/arch/arm/mach-s3c2412/pm.c | |||
@@ -0,0 +1,128 @@ | |||
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/platform_device.h> | ||
21 | |||
22 | #include <asm/hardware.h> | ||
23 | #include <asm/io.h> | ||
24 | #include <asm/irq.h> | ||
25 | |||
26 | #include <asm/arch/regs-power.h> | ||
27 | #include <asm/arch/regs-gpioj.h> | ||
28 | #include <asm/arch/regs-gpio.h> | ||
29 | #include <asm/arch/regs-dsc.h> | ||
30 | |||
31 | #include <asm/plat-s3c24xx/cpu.h> | ||
32 | #include <asm/plat-s3c24xx/pm.h> | ||
33 | |||
34 | #include <asm/plat-s3c24xx/s3c2412.h> | ||
35 | |||
36 | static void s3c2412_cpu_suspend(void) | ||
37 | { | ||
38 | unsigned long tmp; | ||
39 | |||
40 | /* set our standby method to sleep */ | ||
41 | |||
42 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
43 | tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP; | ||
44 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
45 | |||
46 | /* issue the standby signal into the pm unit. Note, we | ||
47 | * issue a write-buffer drain just in case */ | ||
48 | |||
49 | tmp = 0; | ||
50 | |||
51 | asm("b 1f\n\t" | ||
52 | ".align 5\n\t" | ||
53 | "1:\n\t" | ||
54 | "mcr p15, 0, %0, c7, c10, 4\n\t" | ||
55 | "mcr p15, 0, %0, c7, c0, 4" :: "r" (tmp)); | ||
56 | |||
57 | /* we should never get past here */ | ||
58 | |||
59 | panic("sleep resumed to originator?"); | ||
60 | } | ||
61 | |||
62 | static void s3c2412_pm_prepare(void) | ||
63 | { | ||
64 | } | ||
65 | |||
66 | static int s3c2412_pm_add(struct sys_device *sysdev) | ||
67 | { | ||
68 | pm_cpu_prep = s3c2412_pm_prepare; | ||
69 | pm_cpu_sleep = s3c2412_cpu_suspend; | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static struct sleep_save s3c2412_sleep[] = { | ||
75 | SAVE_ITEM(S3C2412_DSC0), | ||
76 | SAVE_ITEM(S3C2412_DSC1), | ||
77 | SAVE_ITEM(S3C2413_GPJDAT), | ||
78 | SAVE_ITEM(S3C2413_GPJCON), | ||
79 | SAVE_ITEM(S3C2413_GPJUP), | ||
80 | |||
81 | /* save the PWRCFG to get back to original sleep method */ | ||
82 | |||
83 | SAVE_ITEM(S3C2412_PWRCFG), | ||
84 | |||
85 | /* save the sleep configuration anyway, just in case these | ||
86 | * get damaged during wakeup */ | ||
87 | |||
88 | SAVE_ITEM(S3C2412_GPBSLPCON), | ||
89 | SAVE_ITEM(S3C2412_GPCSLPCON), | ||
90 | SAVE_ITEM(S3C2412_GPDSLPCON), | ||
91 | SAVE_ITEM(S3C2412_GPESLPCON), | ||
92 | SAVE_ITEM(S3C2412_GPFSLPCON), | ||
93 | SAVE_ITEM(S3C2412_GPGSLPCON), | ||
94 | SAVE_ITEM(S3C2412_GPHSLPCON), | ||
95 | SAVE_ITEM(S3C2413_GPJSLPCON), | ||
96 | }; | ||
97 | |||
98 | static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state) | ||
99 | { | ||
100 | s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static int s3c2412_pm_resume(struct sys_device *dev) | ||
105 | { | ||
106 | unsigned long tmp; | ||
107 | |||
108 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
109 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; | ||
110 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; | ||
111 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
112 | |||
113 | s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static struct sysdev_driver s3c2412_pm_driver = { | ||
118 | .add = s3c2412_pm_add, | ||
119 | .suspend = s3c2412_pm_suspend, | ||
120 | .resume = s3c2412_pm_resume, | ||
121 | }; | ||
122 | |||
123 | static __init int s3c2412_pm_init(void) | ||
124 | { | ||
125 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver); | ||
126 | } | ||
127 | |||
128 | arch_initcall(s3c2412_pm_init); | ||
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c new file mode 100644 index 000000000000..aafe0bc593f1 --- /dev/null +++ b/arch/arm/mach-s3c2412/s3c2412.c | |||
@@ -0,0 +1,181 @@ | |||
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/sysdev.h> | ||
20 | #include <linux/serial_core.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | |||
23 | #include <asm/mach/arch.h> | ||
24 | #include <asm/mach/map.h> | ||
25 | #include <asm/mach/irq.h> | ||
26 | |||
27 | #include <asm/hardware.h> | ||
28 | #include <asm/proc-fns.h> | ||
29 | #include <asm/io.h> | ||
30 | #include <asm/irq.h> | ||
31 | |||
32 | #include <asm/arch/idle.h> | ||
33 | |||
34 | #include <asm/arch/regs-clock.h> | ||
35 | #include <asm/arch/regs-serial.h> | ||
36 | #include <asm/arch/regs-power.h> | ||
37 | #include <asm/arch/regs-gpio.h> | ||
38 | #include <asm/arch/regs-gpioj.h> | ||
39 | #include <asm/arch/regs-dsc.h> | ||
40 | |||
41 | #include <asm/plat-s3c24xx/s3c2412.h> | ||
42 | #include <asm/plat-s3c24xx/cpu.h> | ||
43 | #include <asm/plat-s3c24xx/devs.h> | ||
44 | #include <asm/plat-s3c24xx/clock.h> | ||
45 | #include <asm/plat-s3c24xx/pm.h> | ||
46 | |||
47 | #ifndef CONFIG_CPU_S3C2412_ONLY | ||
48 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; | ||
49 | |||
50 | static inline void s3c2412_init_gpio2(void) | ||
51 | { | ||
52 | s3c24xx_va_gpio2 = S3C24XX_VA_GPIO + 0x10; | ||
53 | } | ||
54 | #else | ||
55 | #define s3c2412_init_gpio2() do { } while(0) | ||
56 | #endif | ||
57 | |||
58 | /* Initial IO mappings */ | ||
59 | |||
60 | static struct map_desc s3c2412_iodesc[] __initdata = { | ||
61 | IODESC_ENT(CLKPWR), | ||
62 | IODESC_ENT(LCD), | ||
63 | IODESC_ENT(TIMER), | ||
64 | IODESC_ENT(WATCHDOG), | ||
65 | }; | ||
66 | |||
67 | /* uart registration process */ | ||
68 | |||
69 | void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no) | ||
70 | { | ||
71 | s3c24xx_init_uartdevs("s3c2412-uart", s3c2410_uart_resources, cfg, no); | ||
72 | |||
73 | /* rename devices that are s3c2412/s3c2413 specific */ | ||
74 | s3c_device_sdi.name = "s3c2412-sdi"; | ||
75 | s3c_device_lcd.name = "s3c2412-lcd"; | ||
76 | s3c_device_nand.name = "s3c2412-nand"; | ||
77 | } | ||
78 | |||
79 | /* s3c2412_idle | ||
80 | * | ||
81 | * use the standard idle call by ensuring the idle mode | ||
82 | * in power config, then issuing the idle co-processor | ||
83 | * instruction | ||
84 | */ | ||
85 | |||
86 | static void s3c2412_idle(void) | ||
87 | { | ||
88 | unsigned long tmp; | ||
89 | |||
90 | /* ensure our idle mode is to go to idle */ | ||
91 | |||
92 | tmp = __raw_readl(S3C2412_PWRCFG); | ||
93 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; | ||
94 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; | ||
95 | __raw_writel(tmp, S3C2412_PWRCFG); | ||
96 | |||
97 | cpu_do_idle(); | ||
98 | } | ||
99 | |||
100 | /* s3c2412_map_io | ||
101 | * | ||
102 | * register the standard cpu IO areas, and any passed in from the | ||
103 | * machine specific initialisation. | ||
104 | */ | ||
105 | |||
106 | void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size) | ||
107 | { | ||
108 | /* move base of IO */ | ||
109 | |||
110 | s3c2412_init_gpio2(); | ||
111 | |||
112 | /* set our idle function */ | ||
113 | |||
114 | s3c24xx_idle = s3c2412_idle; | ||
115 | |||
116 | /* register our io-tables */ | ||
117 | |||
118 | iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); | ||
119 | iotable_init(mach_desc, mach_size); | ||
120 | } | ||
121 | |||
122 | void __init s3c2412_init_clocks(int xtal) | ||
123 | { | ||
124 | unsigned long tmp; | ||
125 | unsigned long fclk; | ||
126 | unsigned long hclk; | ||
127 | unsigned long pclk; | ||
128 | |||
129 | /* now we've got our machine bits initialised, work out what | ||
130 | * clocks we've got */ | ||
131 | |||
132 | fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal*2); | ||
133 | |||
134 | tmp = __raw_readl(S3C2410_CLKDIVN); | ||
135 | |||
136 | /* work out clock scalings */ | ||
137 | |||
138 | hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1); | ||
139 | hclk /= ((tmp & S3C2421_CLKDIVN_ARMDIVN) ? 2 : 1); | ||
140 | pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1); | ||
141 | |||
142 | /* print brieft summary of clocks, etc */ | ||
143 | |||
144 | printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n", | ||
145 | print_mhz(fclk), print_mhz(hclk), print_mhz(pclk)); | ||
146 | |||
147 | /* initialise the clocks here, to allow other things like the | ||
148 | * console to use them | ||
149 | */ | ||
150 | |||
151 | s3c24xx_setup_clocks(xtal, fclk, hclk, pclk); | ||
152 | s3c2412_baseclk_add(); | ||
153 | } | ||
154 | |||
155 | /* need to register class before we actually register the device, and | ||
156 | * we also need to ensure that it has been initialised before any of the | ||
157 | * drivers even try to use it (even if not on an s3c2412 based system) | ||
158 | * as a driver which may support both 2410 and 2440 may try and use it. | ||
159 | */ | ||
160 | |||
161 | struct sysdev_class s3c2412_sysclass = { | ||
162 | set_kset_name("s3c2412-core"), | ||
163 | }; | ||
164 | |||
165 | static int __init s3c2412_core_init(void) | ||
166 | { | ||
167 | return sysdev_class_register(&s3c2412_sysclass); | ||
168 | } | ||
169 | |||
170 | core_initcall(s3c2412_core_init); | ||
171 | |||
172 | static struct sys_device s3c2412_sysdev = { | ||
173 | .cls = &s3c2412_sysclass, | ||
174 | }; | ||
175 | |||
176 | int __init s3c2412_init(void) | ||
177 | { | ||
178 | printk("S3C2412: Initialising architecture\n"); | ||
179 | |||
180 | return sysdev_register(&s3c2412_sysdev); | ||
181 | } | ||