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);
49 void (*init_uarts)(struct s3c2410_uartcfg *cfg, int no);
50 void (*init_clocks)(int xtal);
55 /* table of supported CPUs */
57 static const char name_s3c2410[] = "S3C2410";
58 static const char name_s3c2440[] = "S3C2440";
59 static const char name_s3c2410a[] = "S3C2410A";
60 static const char name_s3c2440a[] = "S3C2440A";
62 static struct cpu_table cpu_ids[] __initdata = {
66 .map_io = s3c2410_map_io,
67 .init_clocks = s3c2410_init_clocks,
68 .init_uarts = s3c2410_init_uarts,
75 .map_io = s3c2410_map_io,
76 .init_clocks = s3c2410_init_clocks,
77 .init_uarts = s3c2410_init_uarts,
84 .map_io = s3c2440_map_io,
85 .init_clocks = s3c2440_init_clocks,
86 .init_uarts = s3c2440_init_uarts,
93 .map_io = s3c2440_map_io,
94 .init_clocks = s3c2440_init_clocks,
95 .init_uarts = s3c2440_init_uarts,
101 /* minimal IO mapping */
103 static struct map_desc s3c_iodesc[] __initdata = {
111 static struct cpu_table *
112 s3c_lookup_cpu(unsigned long idcode)
114 struct cpu_table *tab;
118 for (count = 0; count < ARRAY_SIZE(cpu_ids); count++, tab++) {
119 if ((idcode & tab->idmask) == tab->idcode)
126 /* board information */
128 static struct s3c24xx_board *board;
130 void s3c24xx_set_board(struct s3c24xx_board *b)
136 if (b->clocks_count != 0) {
137 struct clk **ptr = b->clocks;;
139 for (i = b->clocks_count; i > 0; i--, ptr++)
140 s3c24xx_register_clock(*ptr);
144 /* cpu information */
146 static struct cpu_table *cpu;
148 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
150 unsigned long idcode;
152 /* initialise the io descriptors we need for initialisation */
153 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
155 idcode = __raw_readl(S3C2410_GSTATUS1);
156 cpu = s3c_lookup_cpu(idcode);
159 printk(KERN_ERR "Unknown CPU type 0x%08lx\n", idcode);
160 panic("Unknown S3C24XX CPU");
163 if (cpu->map_io == NULL || cpu->init == NULL) {
164 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
165 panic("Unsupported S3C24XX CPU");
168 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
170 (cpu->map_io)(mach_desc, size);
173 /* s3c24xx_init_clocks
175 * Initialise the clock subsystem and associated information from the
176 * given master crystal value.
178 * xtal = 0 -> use default PLL crystal value (normally 12MHz)
179 * != 0 -> PLL crystal value in Hz
182 void __init s3c24xx_init_clocks(int xtal)
188 panic("s3c24xx_init_clocks: no cpu setup?\n");
190 if (cpu->init_clocks == NULL)
191 panic("s3c24xx_init_clocks: cpu has no clock init\n");
193 (cpu->init_clocks)(xtal);
196 void __init s3c24xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
201 if (cpu->init_uarts == NULL) {
202 printk(KERN_ERR "s3c24xx_init_uarts: cpu has no uart init\n");
204 (cpu->init_uarts)(cfg, no);
207 static int __init s3c_arch_init(void)
211 // do the correct init for cpu
214 panic("s3c_arch_init: NULL cpu\n");
221 struct platform_device **ptr = board->devices;
224 for (i = 0; i < board->devices_count; i++, ptr++) {
225 ret = platform_device_register(*ptr);
228 printk(KERN_ERR "s3c24xx: failed to add board device %s (%d) @%p\n", (*ptr)->name, ret, *ptr);
232 /* mask any error, we may not need all these board
240 arch_initcall(s3c_arch_init);