This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / arm / mach-s3c2410 / cpu.c
1 /* linux/arch/arm/mach-s3c2410/cpu.c
2  *
3  * Copyright (c) 2004 Simtec Electronics
4  * Ben Dooks <ben@simtec.co.uk>
5  *
6  * S3C24XX CPU 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
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>
29
30 #include <asm/hardware.h>
31 #include <asm/irq.h>
32 #include <asm/io.h>
33 #include <asm/delay.h>
34
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37
38 #include <asm/arch/regs-gpio.h>
39
40 #include "cpu.h"
41 #include "s3c2410.h"
42 #include "s3c2440.h"
43
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;
50 };
51
52 /* table of supported CPUs */
53
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";
58
59 static struct cpu_table cpu_ids[] __initdata = {
60         {
61                 .idcode = 0x32410000,
62                 .idmask = 0xffffffff,
63                 .map_io = s3c2410_map_io,
64                 .init   = s3c2410_init,
65                 .name   = name_s3c2410
66         },
67         {
68                 .idcode = 0x3241002,
69                 .idmask = 0xffffffff,
70                 .map_io = s3c2410_map_io,
71                 .init   = s3c2410_init,
72                 .name   = name_s3c2410a
73         },
74         {
75                 .idcode = 0x32440000,
76                 .idmask = 0xffffffff,
77                 .map_io = s3c2440_map_io,
78                 .init   = s3c2440_init,
79                 .name   = name_s3c2440
80         },
81         {
82                 .idcode = 0x32440001,
83                 .idmask = 0xffffffff,
84                 .map_io = s3c2440_map_io,
85                 .init   = s3c2440_init,
86                 .name   = name_s3c2440a
87         }
88 };
89
90 /* minimal IO mapping */
91
92 static struct map_desc s3c_iodesc[] __initdata = {
93         IODESC_ENT(GPIO),
94         IODESC_ENT(IRQ),
95         IODESC_ENT(MEMCTRL),
96         IODESC_ENT(UART)
97 };
98
99
100 static struct cpu_table *
101 s3c_lookup_cpu(unsigned long idcode)
102 {
103         struct cpu_table *tab;
104         int count;
105
106         tab = cpu_ids;
107         for (count = 0; count < ARRAY_SIZE(cpu_ids); count++) {
108                 if ((idcode & tab->idmask) == tab->idcode)
109                         return tab;
110         }
111
112         return NULL;
113 }
114
115 static struct cpu_table *cpu;
116
117 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
118 {
119         unsigned long idcode;
120
121         /* initialise the io descriptors we need for initialisation */
122         iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
123
124         idcode = __raw_readl(S3C2410_GSTATUS1);
125         cpu = s3c_lookup_cpu(idcode);
126
127         if (cpu == NULL) {
128                 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
129                 panic("Unknown S3C24XX CPU");
130         }
131
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");
135         }
136
137         printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
138
139         (cpu->map_io)(mach_desc, size);
140 }
141
142 static int __init s3c_arch_init(void)
143 {
144         // do the correct init for cpu
145
146         if (cpu == NULL)
147                 panic("s3c_arch_init: NULL cpu\n");
148
149         return (cpu->init)();
150 }
151
152 arch_initcall(s3c_arch_init);