MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / arch / arm / mach-s3c2410 / cpu.c
blob42eec7912858757a7618003e3f5df801a13f37de
1 /* linux/arch/arm/mach-s3c2410/cpu.c
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * S3C24XX CPU Support
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.
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.
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
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/interrupt.h>
27 #include <linux/ioport.h>
28 #include <linux/device.h>
30 #include <asm/hardware.h>
31 #include <asm/irq.h>
32 #include <asm/io.h>
33 #include <asm/delay.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <asm/arch/regs-gpio.h>
40 #include "cpu.h"
41 #include "s3c2410.h"
42 #include "s3c2440.h"
44 struct cpu_table {
45 unsigned long idcode;
46 unsigned long idmask;
47 void (*map_io)(struct map_desc *mach_desc, int size);
48 int (*init)(void);
49 const char *name;
52 /* table of supported CPUs */
54 static const char name_s3c2410[] = "S3C2410";
55 static const char name_s3c2440[] = "S3C2440";
56 static const char name_s3c2410a[] = "S3C2410A";
57 static const char name_s3c2440a[] = "S3C2440A";
59 static struct cpu_table cpu_ids[] __initdata = {
61 .idcode = 0x32410000,
62 .idmask = 0xffffffff,
63 .map_io = s3c2410_map_io,
64 .init = s3c2410_init,
65 .name = name_s3c2410
68 .idcode = 0x3241002,
69 .idmask = 0xffffffff,
70 .map_io = s3c2410_map_io,
71 .init = s3c2410_init,
72 .name = name_s3c2410a
75 .idcode = 0x32440000,
76 .idmask = 0xffffffff,
77 .map_io = s3c2440_map_io,
78 .init = s3c2440_init,
79 .name = name_s3c2440
82 .idcode = 0x32440001,
83 .idmask = 0xffffffff,
84 .map_io = s3c2440_map_io,
85 .init = s3c2440_init,
86 .name = name_s3c2440a
90 /* minimal IO mapping */
92 static struct map_desc s3c_iodesc[] __initdata = {
93 IODESC_ENT(GPIO),
94 IODESC_ENT(IRQ),
95 IODESC_ENT(MEMCTRL),
96 IODESC_ENT(UART)
100 static struct cpu_table *
101 s3c_lookup_cpu(unsigned long idcode)
103 struct cpu_table *tab;
104 int count;
106 tab = cpu_ids;
107 for (count = 0; count < ARRAY_SIZE(cpu_ids); count++) {
108 if ((idcode & tab->idmask) == tab->idcode)
109 return tab;
112 return NULL;
115 static struct cpu_table *cpu;
117 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
119 unsigned long idcode;
121 /* initialise the io descriptors we need for initialisation */
122 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
124 idcode = __raw_readl(S3C2410_GSTATUS1);
125 cpu = s3c_lookup_cpu(idcode);
127 if (cpu == NULL) {
128 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
129 panic("Unknown S3C24XX CPU");
132 if (cpu->map_io == NULL || cpu->init == NULL) {
133 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
134 panic("Unsupported S3C24XX CPU");
137 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
139 (cpu->map_io)(mach_desc, size);
142 static int __init s3c_arch_init(void)
144 // do the correct init for cpu
146 if (cpu == NULL)
147 panic("s3c_arch_init: NULL cpu\n");
149 return (cpu->init)();
152 arch_initcall(s3c_arch_init);