aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-s3c2410/s3c2410.c5
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c3
-rw-r--r--arch/arm/mach-s3c2443/s3c2443.c3
-rw-r--r--arch/arm/plat-s3c/Makefile15
-rw-r--r--arch/arm/plat-s3c/init.c161
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c141
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/cpu.h15
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2400.h2
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2410.h2
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2412.h2
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c2443.h2
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.c3
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.h2
13 files changed, 201 insertions, 155 deletions
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index ac79b536c4c3..1db39c609d78 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -59,12 +59,9 @@ void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
59 * machine specific initialisation. 59 * machine specific initialisation.
60*/ 60*/
61 61
62void __init s3c2410_map_io(struct map_desc *mach_desc, int mach_size) 62void __init s3c2410_map_io(void)
63{ 63{
64 /* register our io-tables */
65
66 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc)); 64 iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
67 iotable_init(mach_desc, mach_size);
68} 65}
69 66
70void __init s3c2410_init_clocks(int xtal) 67void __init s3c2410_init_clocks(int xtal)
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index a086818e117e..22d22a035782 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -136,7 +136,7 @@ static void s3c2412_hard_reset(void)
136 * machine specific initialisation. 136 * machine specific initialisation.
137*/ 137*/
138 138
139void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size) 139void __init s3c2412_map_io(void)
140{ 140{
141 /* move base of IO */ 141 /* move base of IO */
142 142
@@ -153,7 +153,6 @@ void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
153 /* register our io-tables */ 153 /* register our io-tables */
154 154
155 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); 155 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
156 iotable_init(mach_desc, mach_size);
157} 156}
158 157
159void __init s3c2412_init_clocks(int xtal) 158void __init s3c2412_init_clocks(int xtal)
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c2443/s3c2443.c
index bbeddf9ddcb1..ce2ec3298930 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c2443/s3c2443.c
@@ -81,10 +81,9 @@ void __init s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no)
81 * machine specific initialisation. 81 * machine specific initialisation.
82 */ 82 */
83 83
84void __init s3c2443_map_io(struct map_desc *mach_desc, int mach_size) 84void __init s3c2443_map_io(void)
85{ 85{
86 iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc)); 86 iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc));
87 iotable_init(mach_desc, mach_size);
88} 87}
89 88
90/* need to register class before we actually register the device, and 89/* need to register class before we actually register the device, and
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile
index f03d7b35ba37..f7c8824ef805 100644
--- a/arch/arm/plat-s3c/Makefile
+++ b/arch/arm/plat-s3c/Makefile
@@ -1,3 +1,14 @@
1# dummy makefile, currently just including asm/arm/plat-s3c/include/plat 1# arch/arm/plat-s3c/Makefile
2#
3# Copyright 2008 Simtec Electronics
4#
5# Licensed under GPLv2
2 6
3obj-n := dummy.o 7obj-y :=
8obj-m :=
9obj-n :=
10obj- :=
11
12# Core support for all Samsung SoCs
13
14obj-y += init.o
diff --git a/arch/arm/plat-s3c/init.c b/arch/arm/plat-s3c/init.c
new file mode 100644
index 000000000000..85f086ee930a
--- /dev/null
+++ b/arch/arm/plat-s3c/init.c
@@ -0,0 +1,161 @@
1/* linux/arch/arm/plat-s3c/init.c
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * http://armlinux.simtec.co.uk/
6 *
7 * S3C series CPU initialisation
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/init.h>
15#include <linux/module.h>
16#include <linux/interrupt.h>
17#include <linux/ioport.h>
18#include <linux/serial_core.h>
19#include <linux/platform_device.h>
20#include <linux/delay.h>
21
22#include <mach/hardware.h>
23
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26
27#include <plat/cpu.h>
28#include <plat/devs.h>
29#include <plat/clock.h>
30
31#include <plat/regs-serial.h>
32
33static struct cpu_table *cpu;
34
35static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode,
36 struct cpu_table *tab,
37 unsigned int count)
38{
39 for (; count != 0; count--, tab++) {
40 if ((idcode & tab->idmask) == tab->idcode)
41 return tab;
42 }
43
44 return NULL;
45}
46
47void __init s3c_init_cpu(unsigned long idcode,
48 struct cpu_table *cputab, unsigned int cputab_size)
49{
50 cpu = s3c_lookup_cpu(idcode, cputab, cputab_size);
51
52 if (cpu == NULL) {
53 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
54 panic("Unknown S3C24XX CPU");
55 }
56
57 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
58
59 if (cpu->map_io == NULL || cpu->init == NULL) {
60 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
61 panic("Unsupported Samsung CPU");
62 }
63
64 cpu->map_io();
65}
66
67/* s3c24xx_init_clocks
68 *
69 * Initialise the clock subsystem and associated information from the
70 * given master crystal value.
71 *
72 * xtal = 0 -> use default PLL crystal value (normally 12MHz)
73 * != 0 -> PLL crystal value in Hz
74*/
75
76void __init s3c24xx_init_clocks(int xtal)
77{
78 if (xtal == 0)
79 xtal = 12*1000*1000;
80
81 if (cpu == NULL)
82 panic("s3c24xx_init_clocks: no cpu setup?\n");
83
84 if (cpu->init_clocks == NULL)
85 panic("s3c24xx_init_clocks: cpu has no clock init\n");
86 else
87 (cpu->init_clocks)(xtal);
88}
89
90/* uart management */
91
92static int nr_uarts __initdata = 0;
93
94static struct s3c2410_uartcfg uart_cfgs[3];
95
96/* s3c24xx_init_uartdevs
97 *
98 * copy the specified platform data and configuration into our central
99 * set of devices, before the data is thrown away after the init process.
100 *
101 * This also fills in the array passed to the serial driver for the
102 * early initialisation of the console.
103*/
104
105void __init s3c24xx_init_uartdevs(char *name,
106 struct s3c24xx_uart_resources *res,
107 struct s3c2410_uartcfg *cfg, int no)
108{
109 struct platform_device *platdev;
110 struct s3c2410_uartcfg *cfgptr = uart_cfgs;
111 struct s3c24xx_uart_resources *resp;
112 int uart;
113
114 memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
115
116 for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
117 platdev = s3c24xx_uart_src[cfgptr->hwport];
118
119 resp = res + cfgptr->hwport;
120
121 s3c24xx_uart_devs[uart] = platdev;
122
123 platdev->name = name;
124 platdev->resource = resp->resources;
125 platdev->num_resources = resp->nr_resources;
126
127 platdev->dev.platform_data = cfgptr;
128 }
129
130 nr_uarts = no;
131}
132
133void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
134{
135 if (cpu == NULL)
136 return;
137
138 if (cpu->init_uarts == NULL) {
139 printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
140 } else
141 (cpu->init_uarts)(cfg, no);
142}
143
144static int __init s3c_arch_init(void)
145{
146 int ret;
147
148 // do the correct init for cpu
149
150 if (cpu == NULL)
151 panic("s3c_arch_init: NULL cpu\n");
152
153 ret = (cpu->init)();
154 if (ret != 0)
155 return ret;
156
157 ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
158 return ret;
159}
160
161arch_initcall(s3c_arch_init);
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index 22a329513c0f..7a0f494c93b6 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -55,16 +55,6 @@
55#include <plat/s3c2442.h> 55#include <plat/s3c2442.h>
56#include <plat/s3c2443.h> 56#include <plat/s3c2443.h>
57 57
58struct cpu_table {
59 unsigned long idcode;
60 unsigned long idmask;
61 void (*map_io)(struct map_desc *mach_desc, int size);
62 void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
63 void (*init_clocks)(int xtal);
64 int (*init)(void);
65 const char *name;
66};
67
68/* table of supported CPUs */ 58/* table of supported CPUs */
69 59
70static const char name_s3c2400[] = "S3C2400"; 60static const char name_s3c2400[] = "S3C2400";
@@ -169,23 +159,7 @@ static struct map_desc s3c_iodesc[] __initdata = {
169 IODESC_ENT(UART) 159 IODESC_ENT(UART)
170}; 160};
171 161
172static struct cpu_table * __init s3c_lookup_cpu(unsigned long idcode) 162/* read cpu identificaiton code */
173{
174 struct cpu_table *tab;
175 int count;
176
177 tab = cpu_ids;
178 for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
179 if ((idcode & tab->idmask) == tab->idcode)
180 return tab;
181 }
182
183 return NULL;
184}
185
186/* cpu information */
187
188static struct cpu_table *cpu;
189 163
190static unsigned long s3c24xx_read_idcode_v5(void) 164static unsigned long s3c24xx_read_idcode_v5(void)
191{ 165{
@@ -231,6 +205,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
231 unsigned long idcode = 0x0; 205 unsigned long idcode = 0x0;
232 206
233 /* initialise the io descriptors we need for initialisation */ 207 /* initialise the io descriptors we need for initialisation */
208 iotable_init(mach_desc, size);
234 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); 209 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
235 210
236 if (cpu_architecture() >= CPU_ARCH_ARMv5) { 211 if (cpu_architecture() >= CPU_ARCH_ARMv5) {
@@ -239,117 +214,7 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
239 idcode = s3c24xx_read_idcode_v4(); 214 idcode = s3c24xx_read_idcode_v4();
240 } 215 }
241 216
242 cpu = s3c_lookup_cpu(idcode);
243
244 if (cpu == NULL) {
245 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
246 panic("Unknown S3C24XX CPU");
247 }
248
249 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
250
251 if (cpu->map_io == NULL || cpu->init == NULL) {
252 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
253 panic("Unsupported S3C24XX CPU");
254 }
255
256 arm_pm_restart = s3c24xx_pm_restart; 217 arm_pm_restart = s3c24xx_pm_restart;
257 218
258 (cpu->map_io)(mach_desc, size); 219 s3c_init_cpu(idcode, cpu_ids, ARRAY_SIZE(cpu_ids));
259}
260
261/* s3c24xx_init_clocks
262 *
263 * Initialise the clock subsystem and associated information from the
264 * given master crystal value.
265 *
266 * xtal = 0 -> use default PLL crystal value (normally 12MHz)
267 * != 0 -> PLL crystal value in Hz
268*/
269
270void __init s3c24xx_init_clocks(int xtal)
271{
272 if (xtal == 0)
273 xtal = 12*1000*1000;
274
275 if (cpu == NULL)
276 panic("s3c24xx_init_clocks: no cpu setup?\n");
277
278 if (cpu->init_clocks == NULL)
279 panic("s3c24xx_init_clocks: cpu has no clock init\n");
280 else
281 (cpu->init_clocks)(xtal);
282}
283
284/* uart management */
285
286static int nr_uarts __initdata = 0;
287
288static struct s3c2410_uartcfg uart_cfgs[3];
289
290/* s3c24xx_init_uartdevs
291 *
292 * copy the specified platform data and configuration into our central
293 * set of devices, before the data is thrown away after the init process.
294 *
295 * This also fills in the array passed to the serial driver for the
296 * early initialisation of the console.
297*/
298
299void __init s3c24xx_init_uartdevs(char *name,
300 struct s3c24xx_uart_resources *res,
301 struct s3c2410_uartcfg *cfg, int no)
302{
303 struct platform_device *platdev;
304 struct s3c2410_uartcfg *cfgptr = uart_cfgs;
305 struct s3c24xx_uart_resources *resp;
306 int uart;
307
308 memcpy(cfgptr, cfg, sizeof(struct s3c2410_uartcfg) * no);
309
310 for (uart = 0; uart < no; uart++, cfg++, cfgptr++) {
311 platdev = s3c24xx_uart_src[cfgptr->hwport];
312
313 resp = res + cfgptr->hwport;
314
315 s3c24xx_uart_devs[uart] = platdev;
316
317 platdev->name = name;
318 platdev->resource = resp->resources;
319 platdev->num_resources = resp->nr_resources;
320
321 platdev->dev.platform_data = cfgptr;
322 }
323
324 nr_uarts = no;
325} 220}
326
327void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
328{
329 if (cpu == NULL)
330 return;
331
332 if (cpu->init_uarts == NULL) {
333 printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
334 } else
335 (cpu->init_uarts)(cfg, no);
336}
337
338static int __init s3c_arch_init(void)
339{
340 int ret;
341
342 // do the correct init for cpu
343
344 if (cpu == NULL)
345 panic("s3c_arch_init: NULL cpu\n");
346
347 ret = (cpu->init)();
348 if (ret != 0)
349 return ret;
350
351 ret = platform_add_devices(s3c24xx_uart_devs, nr_uarts);
352 return ret;
353}
354
355arch_initcall(s3c_arch_init);
diff --git a/arch/arm/plat-s3c24xx/include/plat/cpu.h b/arch/arm/plat-s3c24xx/include/plat/cpu.h
index 23e420e8bd5b..bd0a02963b46 100644
--- a/arch/arm/plat-s3c24xx/include/plat/cpu.h
+++ b/arch/arm/plat-s3c24xx/include/plat/cpu.h
@@ -26,6 +26,21 @@ struct platform_device;
26struct s3c2410_uartcfg; 26struct s3c2410_uartcfg;
27struct map_desc; 27struct map_desc;
28 28
29/* per-cpu initialisation function table. */
30
31struct cpu_table {
32 unsigned long idcode;
33 unsigned long idmask;
34 void (*map_io)(void);
35 void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
36 void (*init_clocks)(int xtal);
37 int (*init)(void);
38 const char *name;
39};
40
41extern void s3c_init_cpu(unsigned long idcode,
42 struct cpu_table *cpus, unsigned int cputab_size);
43
29/* core initialisation functions */ 44/* core initialisation functions */
30 45
31extern void s3c24xx_init_irq(void); 46extern void s3c24xx_init_irq(void);
diff --git a/arch/arm/plat-s3c24xx/include/plat/s3c2400.h b/arch/arm/plat-s3c24xx/include/plat/s3c2400.h
index 3a5a16821af8..b3feaea5c70b 100644
--- a/arch/arm/plat-s3c24xx/include/plat/s3c2400.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2400.h
@@ -17,7 +17,7 @@
17 17
18extern int s3c2400_init(void); 18extern int s3c2400_init(void);
19 19
20extern void s3c2400_map_io(struct map_desc *mach_desc, int size); 20extern void s3c2400_map_io(void);
21 21
22extern void s3c2400_init_uarts(struct s3c2410_uartcfg *cfg, int no); 22extern void s3c2400_init_uarts(struct s3c2410_uartcfg *cfg, int no);
23 23
diff --git a/arch/arm/plat-s3c24xx/include/plat/s3c2410.h b/arch/arm/plat-s3c24xx/include/plat/s3c2410.h
index 3cd1ec677b3f..a9ac9e29759e 100644
--- a/arch/arm/plat-s3c24xx/include/plat/s3c2410.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2410.h
@@ -15,7 +15,7 @@
15 15
16extern int s3c2410_init(void); 16extern int s3c2410_init(void);
17 17
18extern void s3c2410_map_io(struct map_desc *mach_desc, int size); 18extern void s3c2410_map_io(void);
19 19
20extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no); 20extern void s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no);
21 21
diff --git a/arch/arm/plat-s3c24xx/include/plat/s3c2412.h b/arch/arm/plat-s3c24xx/include/plat/s3c2412.h
index 3ec97685e781..bb15d3b68be5 100644
--- a/arch/arm/plat-s3c24xx/include/plat/s3c2412.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2412.h
@@ -14,7 +14,7 @@
14 14
15extern int s3c2412_init(void); 15extern int s3c2412_init(void);
16 16
17extern void s3c2412_map_io(struct map_desc *mach_desc, int size); 17extern void s3c2412_map_io(void);
18 18
19extern void s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no); 19extern void s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no);
20 20
diff --git a/arch/arm/plat-s3c24xx/include/plat/s3c2443.h b/arch/arm/plat-s3c24xx/include/plat/s3c2443.h
index 11d83b5c84e6..815b107ed890 100644
--- a/arch/arm/plat-s3c24xx/include/plat/s3c2443.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c2443.h
@@ -16,7 +16,7 @@ struct s3c2410_uartcfg;
16 16
17extern int s3c2443_init(void); 17extern int s3c2443_init(void);
18 18
19extern void s3c2443_map_io(struct map_desc *mach_desc, int size); 19extern void s3c2443_map_io(void);
20 20
21extern void s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no); 21extern void s3c2443_init_uarts(struct s3c2410_uartcfg *cfg, int no);
22 22
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c
index c0344fac4a94..d1152d1f9ba0 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.c
+++ b/arch/arm/plat-s3c24xx/s3c244x.c
@@ -56,12 +56,11 @@ void __init s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no)
56 s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no); 56 s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no);
57} 57}
58 58
59void __init s3c244x_map_io(struct map_desc *mach_desc, int size) 59void __init s3c244x_map_io(void)
60{ 60{
61 /* register our io-tables */ 61 /* register our io-tables */
62 62
63 iotable_init(s3c244x_iodesc, ARRAY_SIZE(s3c244x_iodesc)); 63 iotable_init(s3c244x_iodesc, ARRAY_SIZE(s3c244x_iodesc));
64 iotable_init(mach_desc, size);
65 64
66 /* rename any peripherals used differing from the s3c2410 */ 65 /* rename any peripherals used differing from the s3c2410 */
67 66
diff --git a/arch/arm/plat-s3c24xx/s3c244x.h b/arch/arm/plat-s3c24xx/s3c244x.h
index f8ed17676a35..6aab5eaae2b4 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.h
+++ b/arch/arm/plat-s3c24xx/s3c244x.h
@@ -12,7 +12,7 @@
12 12
13#if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442) 13#if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442)
14 14
15extern void s3c244x_map_io(struct map_desc *mach_desc, int size); 15extern void s3c244x_map_io(void);
16 16
17extern void s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no); 17extern void s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no);
18 18