[ATM]: Fix build after neigh->parms->neigh_destructor change.
[linux-2.6/verdex.git] / arch / m68k / kernel / setup.c
blob750d5b3c971fe001a2d86808a30b9cd237b0eebe
1 /*
2 * linux/arch/m68k/kernel/setup.c
4 * Copyright (C) 1995 Hamish Macdonald
5 */
7 /*
8 * This file handles the architecture-dependent parts of system setup
9 */
11 #include <linux/config.h>
12 #include <linux/kernel.h>
13 #include <linux/mm.h>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
16 #include <linux/interrupt.h>
17 #include <linux/fs.h>
18 #include <linux/console.h>
19 #include <linux/genhd.h>
20 #include <linux/errno.h>
21 #include <linux/string.h>
22 #include <linux/init.h>
23 #include <linux/bootmem.h>
24 #include <linux/seq_file.h>
25 #include <linux/module.h>
26 #include <linux/initrd.h>
28 #include <asm/bootinfo.h>
29 #include <asm/setup.h>
30 #include <asm/irq.h>
31 #include <asm/io.h>
32 #include <asm/machdep.h>
33 #ifdef CONFIG_AMIGA
34 #include <asm/amigahw.h>
35 #endif
36 #ifdef CONFIG_ATARI
37 #include <asm/atarihw.h>
38 #include <asm/atari_stram.h>
39 #endif
40 #ifdef CONFIG_SUN3X
41 #include <asm/dvma.h>
42 #endif
44 unsigned long m68k_machtype;
45 unsigned long m68k_cputype;
46 unsigned long m68k_fputype;
47 unsigned long m68k_mmutype;
48 #ifdef CONFIG_VME
49 unsigned long vme_brdtype;
50 #endif
52 int m68k_is040or060;
54 extern int end;
55 extern unsigned long availmem;
57 int m68k_num_memory;
58 int m68k_realnum_memory;
59 unsigned long m68k_memoffset;
60 struct mem_info m68k_memory[NUM_MEMINFO];
62 static struct mem_info m68k_ramdisk;
64 static char m68k_command_line[CL_SIZE];
66 char m68k_debug_device[6] = "";
68 void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
69 /* machine dependent irq functions */
70 void (*mach_init_IRQ) (void) __initdata = NULL;
71 irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *);
72 void (*mach_get_model) (char *model);
73 int (*mach_get_hardware_list) (char *buffer);
74 int (*mach_get_irq_list) (struct seq_file *, void *);
75 irqreturn_t (*mach_process_int) (int, struct pt_regs *);
76 /* machine dependent timer functions */
77 unsigned long (*mach_gettimeoffset) (void);
78 int (*mach_hwclk) (int, struct rtc_time*);
79 int (*mach_set_clock_mmss) (unsigned long);
80 unsigned int (*mach_get_ss)(void);
81 int (*mach_get_rtc_pll)(struct rtc_pll_info *);
82 int (*mach_set_rtc_pll)(struct rtc_pll_info *);
83 void (*mach_reset)( void );
84 void (*mach_halt)( void );
85 void (*mach_power_off)( void );
86 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
87 #ifdef CONFIG_HEARTBEAT
88 void (*mach_heartbeat) (int);
89 EXPORT_SYMBOL(mach_heartbeat);
90 #endif
91 #ifdef CONFIG_M68K_L2_CACHE
92 void (*mach_l2_flush) (int);
93 #endif
94 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
95 void (*mach_beep)(unsigned int, unsigned int);
96 #endif
97 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
98 int isa_type;
99 int isa_sex;
100 EXPORT_SYMBOL(isa_type);
101 EXPORT_SYMBOL(isa_sex);
102 #endif
104 extern int amiga_parse_bootinfo(const struct bi_record *);
105 extern int atari_parse_bootinfo(const struct bi_record *);
106 extern int mac_parse_bootinfo(const struct bi_record *);
107 extern int q40_parse_bootinfo(const struct bi_record *);
108 extern int bvme6000_parse_bootinfo(const struct bi_record *);
109 extern int mvme16x_parse_bootinfo(const struct bi_record *);
110 extern int mvme147_parse_bootinfo(const struct bi_record *);
111 extern int hp300_parse_bootinfo(const struct bi_record *);
113 extern void config_amiga(void);
114 extern void config_atari(void);
115 extern void config_mac(void);
116 extern void config_sun3(void);
117 extern void config_apollo(void);
118 extern void config_mvme147(void);
119 extern void config_mvme16x(void);
120 extern void config_bvme6000(void);
121 extern void config_hp300(void);
122 extern void config_q40(void);
123 extern void config_sun3x(void);
125 extern void mac_debugging_short (int, short);
126 extern void mac_debugging_long (int, long);
128 #define MASK_256K 0xfffc0000
130 extern void paging_init(void);
132 static void __init m68k_parse_bootinfo(const struct bi_record *record)
134 while (record->tag != BI_LAST) {
135 int unknown = 0;
136 const unsigned long *data = record->data;
137 switch (record->tag) {
138 case BI_MACHTYPE:
139 case BI_CPUTYPE:
140 case BI_FPUTYPE:
141 case BI_MMUTYPE:
142 /* Already set up by head.S */
143 break;
145 case BI_MEMCHUNK:
146 if (m68k_num_memory < NUM_MEMINFO) {
147 m68k_memory[m68k_num_memory].addr = data[0];
148 m68k_memory[m68k_num_memory].size = data[1];
149 m68k_num_memory++;
150 } else
151 printk("m68k_parse_bootinfo: too many memory chunks\n");
152 break;
154 case BI_RAMDISK:
155 m68k_ramdisk.addr = data[0];
156 m68k_ramdisk.size = data[1];
157 break;
159 case BI_COMMAND_LINE:
160 strlcpy(m68k_command_line, (const char *)data, sizeof(m68k_command_line));
161 break;
163 default:
164 if (MACH_IS_AMIGA)
165 unknown = amiga_parse_bootinfo(record);
166 else if (MACH_IS_ATARI)
167 unknown = atari_parse_bootinfo(record);
168 else if (MACH_IS_MAC)
169 unknown = mac_parse_bootinfo(record);
170 else if (MACH_IS_Q40)
171 unknown = q40_parse_bootinfo(record);
172 else if (MACH_IS_BVME6000)
173 unknown = bvme6000_parse_bootinfo(record);
174 else if (MACH_IS_MVME16x)
175 unknown = mvme16x_parse_bootinfo(record);
176 else if (MACH_IS_MVME147)
177 unknown = mvme147_parse_bootinfo(record);
178 else if (MACH_IS_HP300)
179 unknown = hp300_parse_bootinfo(record);
180 else
181 unknown = 1;
183 if (unknown)
184 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
185 record->tag);
186 record = (struct bi_record *)((unsigned long)record+record->size);
189 m68k_realnum_memory = m68k_num_memory;
190 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
191 if (m68k_num_memory > 1) {
192 printk("Ignoring last %i chunks of physical memory\n",
193 (m68k_num_memory - 1));
194 m68k_num_memory = 1;
196 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
197 #endif
200 void __init setup_arch(char **cmdline_p)
202 extern int _etext, _edata, _end;
203 #ifndef CONFIG_SUN3
204 unsigned long endmem, startmem;
205 #endif
206 int i;
207 char *p, *q;
209 /* The bootinfo is located right after the kernel bss */
210 m68k_parse_bootinfo((const struct bi_record *)&_end);
212 if (CPU_IS_040)
213 m68k_is040or060 = 4;
214 else if (CPU_IS_060)
215 m68k_is040or060 = 6;
217 /* FIXME: m68k_fputype is passed in by Penguin booter, which can
218 * be confused by software FPU emulation. BEWARE.
219 * We should really do our own FPU check at startup.
220 * [what do we do with buggy 68LC040s? if we have problems
221 * with them, we should add a test to check_bugs() below] */
222 #ifndef CONFIG_M68KFPU_EMU_ONLY
223 /* clear the fpu if we have one */
224 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
225 volatile int zero = 0;
226 asm __volatile__ ("frestore %0" : : "m" (zero));
228 #endif
230 if (CPU_IS_060) {
231 u32 pcr;
233 asm (".chip 68060; movec %%pcr,%0; .chip 68k"
234 : "=d" (pcr));
235 if (((pcr >> 8) & 0xff) <= 5) {
236 printk("Enabling workaround for errata I14\n");
237 asm (".chip 68060; movec %0,%%pcr; .chip 68k"
238 : : "d" (pcr | 0x20));
242 init_mm.start_code = PAGE_OFFSET;
243 init_mm.end_code = (unsigned long) &_etext;
244 init_mm.end_data = (unsigned long) &_edata;
245 init_mm.brk = (unsigned long) &_end;
247 *cmdline_p = m68k_command_line;
248 memcpy(saved_command_line, *cmdline_p, CL_SIZE);
250 /* Parse the command line for arch-specific options.
251 * For the m68k, this is currently only "debug=xxx" to enable printing
252 * certain kernel messages to some machine-specific device.
254 for( p = *cmdline_p; p && *p; ) {
255 i = 0;
256 if (!strncmp( p, "debug=", 6 )) {
257 strlcpy( m68k_debug_device, p+6, sizeof(m68k_debug_device) );
258 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
259 i = 1;
261 #ifdef CONFIG_ATARI
262 /* This option must be parsed very early */
263 if (!strncmp( p, "switches=", 9 )) {
264 extern void atari_switches_setup( const char *, int );
265 atari_switches_setup( p+9, (q = strchr( p+9, ' ' )) ?
266 (q - (p+9)) : strlen(p+9) );
267 i = 1;
269 #endif
271 if (i) {
272 /* option processed, delete it */
273 if ((q = strchr( p, ' ' )))
274 strcpy( p, q+1 );
275 else
276 *p = 0;
277 } else {
278 if ((p = strchr( p, ' ' ))) ++p;
282 #ifdef CONFIG_DUMMY_CONSOLE
283 conswitchp = &dummy_con;
284 #endif
286 switch (m68k_machtype) {
287 #ifdef CONFIG_AMIGA
288 case MACH_AMIGA:
289 config_amiga();
290 break;
291 #endif
292 #ifdef CONFIG_ATARI
293 case MACH_ATARI:
294 config_atari();
295 break;
296 #endif
297 #ifdef CONFIG_MAC
298 case MACH_MAC:
299 config_mac();
300 break;
301 #endif
302 #ifdef CONFIG_SUN3
303 case MACH_SUN3:
304 config_sun3();
305 break;
306 #endif
307 #ifdef CONFIG_APOLLO
308 case MACH_APOLLO:
309 config_apollo();
310 break;
311 #endif
312 #ifdef CONFIG_MVME147
313 case MACH_MVME147:
314 config_mvme147();
315 break;
316 #endif
317 #ifdef CONFIG_MVME16x
318 case MACH_MVME16x:
319 config_mvme16x();
320 break;
321 #endif
322 #ifdef CONFIG_BVME6000
323 case MACH_BVME6000:
324 config_bvme6000();
325 break;
326 #endif
327 #ifdef CONFIG_HP300
328 case MACH_HP300:
329 config_hp300();
330 break;
331 #endif
332 #ifdef CONFIG_Q40
333 case MACH_Q40:
334 config_q40();
335 break;
336 #endif
337 #ifdef CONFIG_SUN3X
338 case MACH_SUN3X:
339 config_sun3x();
340 break;
341 #endif
342 default:
343 panic ("No configuration setup");
346 #ifndef CONFIG_SUN3
347 startmem= m68k_memory[0].addr;
348 endmem = startmem + m68k_memory[0].size;
349 high_memory = (void *)PAGE_OFFSET;
350 for (i = 0; i < m68k_num_memory; i++) {
351 m68k_memory[i].size &= MASK_256K;
352 if (m68k_memory[i].addr < startmem)
353 startmem = m68k_memory[i].addr;
354 if (m68k_memory[i].addr+m68k_memory[i].size > endmem)
355 endmem = m68k_memory[i].addr+m68k_memory[i].size;
356 high_memory += m68k_memory[i].size;
359 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
360 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
362 for (i = 0; i < m68k_num_memory; i++)
363 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
365 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
367 #ifdef CONFIG_BLK_DEV_INITRD
368 if (m68k_ramdisk.size) {
369 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size);
370 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
371 initrd_end = initrd_start + m68k_ramdisk.size;
372 printk ("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
374 #endif
376 #ifdef CONFIG_ATARI
377 if (MACH_IS_ATARI)
378 atari_stram_reserve_pages((void *)availmem);
379 #endif
380 #ifdef CONFIG_SUN3X
381 if (MACH_IS_SUN3X) {
382 dvma_init();
384 #endif
386 #endif /* !CONFIG_SUN3 */
388 paging_init();
390 /* set ISA defs early as possible */
391 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
392 #if defined(CONFIG_Q40)
393 if (MACH_IS_Q40) {
394 isa_type = Q40_ISA;
395 isa_sex = 0;
397 #elif defined(CONFIG_GG2)
398 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
399 isa_type = GG2_ISA;
400 isa_sex = 0;
402 #elif defined(CONFIG_AMIGA_PCMCIA)
403 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
404 isa_type = AG_ISA;
405 isa_sex = 1;
407 #endif
408 #endif
411 static int show_cpuinfo(struct seq_file *m, void *v)
413 const char *cpu, *mmu, *fpu;
414 unsigned long clockfreq, clockfactor;
416 #define LOOP_CYCLES_68020 (8)
417 #define LOOP_CYCLES_68030 (8)
418 #define LOOP_CYCLES_68040 (3)
419 #define LOOP_CYCLES_68060 (1)
421 if (CPU_IS_020) {
422 cpu = "68020";
423 clockfactor = LOOP_CYCLES_68020;
424 } else if (CPU_IS_030) {
425 cpu = "68030";
426 clockfactor = LOOP_CYCLES_68030;
427 } else if (CPU_IS_040) {
428 cpu = "68040";
429 clockfactor = LOOP_CYCLES_68040;
430 } else if (CPU_IS_060) {
431 cpu = "68060";
432 clockfactor = LOOP_CYCLES_68060;
433 } else {
434 cpu = "680x0";
435 clockfactor = 0;
438 #ifdef CONFIG_M68KFPU_EMU_ONLY
439 fpu="none(soft float)";
440 #else
441 if (m68k_fputype & FPU_68881)
442 fpu = "68881";
443 else if (m68k_fputype & FPU_68882)
444 fpu = "68882";
445 else if (m68k_fputype & FPU_68040)
446 fpu = "68040";
447 else if (m68k_fputype & FPU_68060)
448 fpu = "68060";
449 else if (m68k_fputype & FPU_SUNFPA)
450 fpu = "Sun FPA";
451 else
452 fpu = "none";
453 #endif
455 if (m68k_mmutype & MMU_68851)
456 mmu = "68851";
457 else if (m68k_mmutype & MMU_68030)
458 mmu = "68030";
459 else if (m68k_mmutype & MMU_68040)
460 mmu = "68040";
461 else if (m68k_mmutype & MMU_68060)
462 mmu = "68060";
463 else if (m68k_mmutype & MMU_SUN3)
464 mmu = "Sun-3";
465 else if (m68k_mmutype & MMU_APOLLO)
466 mmu = "Apollo";
467 else
468 mmu = "unknown";
470 clockfreq = loops_per_jiffy*HZ*clockfactor;
472 seq_printf(m, "CPU:\t\t%s\n"
473 "MMU:\t\t%s\n"
474 "FPU:\t\t%s\n"
475 "Clocking:\t%lu.%1luMHz\n"
476 "BogoMips:\t%lu.%02lu\n"
477 "Calibration:\t%lu loops\n",
478 cpu, mmu, fpu,
479 clockfreq/1000000,(clockfreq/100000)%10,
480 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
481 loops_per_jiffy);
482 return 0;
485 static void *c_start(struct seq_file *m, loff_t *pos)
487 return *pos < 1 ? (void *)1 : NULL;
489 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
491 ++*pos;
492 return NULL;
494 static void c_stop(struct seq_file *m, void *v)
497 struct seq_operations cpuinfo_op = {
498 .start = c_start,
499 .next = c_next,
500 .stop = c_stop,
501 .show = show_cpuinfo,
504 int get_hardware_list(char *buffer)
506 int len = 0;
507 char model[80];
508 unsigned long mem;
509 int i;
511 if (mach_get_model)
512 mach_get_model(model);
513 else
514 strcpy(model, "Unknown m68k");
516 len += sprintf(buffer+len, "Model:\t\t%s\n", model);
517 for (mem = 0, i = 0; i < m68k_num_memory; i++)
518 mem += m68k_memory[i].size;
519 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
521 if (mach_get_hardware_list)
522 len += mach_get_hardware_list(buffer+len);
524 return(len);
527 void check_bugs(void)
529 #ifndef CONFIG_M68KFPU_EMU
530 if (m68k_fputype == 0) {
531 printk( KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
532 "WHICH IS REQUIRED BY LINUX/M68K ***\n" );
533 printk( KERN_EMERG "Upgrade your hardware or join the FPU "
534 "emulation project\n" );
535 panic( "no FPU" );
537 #endif /* !CONFIG_M68KFPU_EMU */