1 /* linux/arch/arm/mach-s3c2410/cpu.c
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
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>
33 #include <asm/delay.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <asm/arch/regs-gpio.h>
48 void (*map_io)(struct map_desc *mach_desc, int size);
53 /* table of supported CPUs */
55 static const char name_s3c2410[] = "S3C2410";
56 static const char name_s3c2440[] = "S3C2440";
57 static const char name_s3c2410a[] = "S3C2410A";
58 static const char name_s3c2440a[] = "S3C2440A";
60 static struct cpu_table cpu_ids[] __initdata = {
64 .map_io = s3c2410_map_io,
71 .map_io = s3c2410_map_io,
78 .map_io = s3c2440_map_io,
85 .map_io = s3c2440_map_io,
91 /* minimal IO mapping */
93 static struct map_desc s3c_iodesc[] __initdata = {
101 static struct cpu_table *
102 s3c_lookup_cpu(unsigned long idcode)
104 struct cpu_table *tab;
108 for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
109 if ((idcode & tab->idmask) == tab->idcode)
116 /* board information */
118 static struct s3c24xx_board *board;
120 void s3c24xx_set_board(struct s3c24xx_board *b)
126 if (b->clocks_count != 0) {
127 struct clk **ptr = b->clocks;;
129 for (i = b->clocks_count; i > 0; i--, ptr++)
130 s3c2410_register_clock(*ptr);
134 /* cpu information */
136 static struct cpu_table *cpu;
138 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
140 unsigned long idcode;
142 /* initialise the io descriptors we need for initialisation */
143 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
145 idcode = __raw_readl(S3C2410_GSTATUS1);
146 cpu = s3c_lookup_cpu(idcode);
149 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
150 panic("Unknown S3C24XX CPU");
153 if (cpu->map_io == NULL || cpu->init == NULL) {
154 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
155 panic("Unsupported S3C24XX CPU");
158 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
160 (cpu->map_io)(mach_desc, size);
163 static int __init s3c_arch_init(void)
167 // do the correct init for cpu
170 panic("s3c_arch_init: NULL cpu\n");
177 struct platform_device **ptr = board->devices;
180 for (i = 0; i < board->devices_count; i++, ptr++) {
181 ret = platform_device_register(*ptr);
184 printk(KERN_ERR "s3c24xx: failed to add board device %s (%d) @%p\n", (*ptr)->name, ret, *ptr);
188 /* mask any error, we may not need all these board
196 arch_initcall(s3c_arch_init);