initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / m68k / kernel / setup.c
blob1d2563e115e4e3e216c358c7810f1d911f338611
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 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
88 void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
89 #endif
90 #ifdef CONFIG_HEARTBEAT
91 void (*mach_heartbeat) (int);
92 EXPORT_SYMBOL(mach_heartbeat);
93 #endif
94 #ifdef CONFIG_M68K_L2_CACHE
95 void (*mach_l2_flush) (int);
96 #endif
97 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
98 void (*mach_beep)(unsigned int, unsigned int);
99 #endif
100 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
101 int isa_type;
102 int isa_sex;
103 #endif
105 extern int amiga_parse_bootinfo(const struct bi_record *);
106 extern int atari_parse_bootinfo(const struct bi_record *);
107 extern int mac_parse_bootinfo(const struct bi_record *);
108 extern int q40_parse_bootinfo(const struct bi_record *);
109 extern int bvme6000_parse_bootinfo(const struct bi_record *);
110 extern int mvme16x_parse_bootinfo(const struct bi_record *);
111 extern int mvme147_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
179 unknown = 1;
181 if (unknown)
182 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
183 record->tag);
184 record = (struct bi_record *)((unsigned long)record+record->size);
187 m68k_realnum_memory = m68k_num_memory;
188 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
189 if (m68k_num_memory > 1) {
190 printk("Ignoring last %i chunks of physical memory\n",
191 (m68k_num_memory - 1));
192 m68k_num_memory = 1;
194 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
195 #endif
198 void __init setup_arch(char **cmdline_p)
200 extern int _etext, _edata, _end;
201 #ifndef CONFIG_SUN3
202 unsigned long endmem, startmem;
203 #endif
204 int i;
205 char *p, *q;
207 if (!MACH_IS_HP300) {
208 /* The bootinfo is located right after the kernel bss */
209 m68k_parse_bootinfo((const struct bi_record *)&_end);
210 } else {
211 /* FIXME HP300 doesn't use bootinfo yet */
212 extern unsigned long hp300_phys_ram_base;
213 unsigned long hp300_mem_size = 0xffffffff-hp300_phys_ram_base;
214 m68k_cputype = CPU_68030;
215 m68k_fputype = FPU_68882;
216 m68k_memory[0].addr = hp300_phys_ram_base;
217 /* 0.5M fudge factor */
218 m68k_memory[0].size = hp300_mem_size-512*1024;
219 m68k_num_memory++;
222 if (CPU_IS_040)
223 m68k_is040or060 = 4;
224 else if (CPU_IS_060)
225 m68k_is040or060 = 6;
227 /* FIXME: m68k_fputype is passed in by Penguin booter, which can
228 * be confused by software FPU emulation. BEWARE.
229 * We should really do our own FPU check at startup.
230 * [what do we do with buggy 68LC040s? if we have problems
231 * with them, we should add a test to check_bugs() below] */
232 #ifndef CONFIG_M68KFPU_EMU_ONLY
233 /* clear the fpu if we have one */
234 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
235 volatile int zero = 0;
236 asm __volatile__ ("frestore %0" : : "m" (zero));
238 #endif
240 if (CPU_IS_060) {
241 u32 pcr;
243 asm (".chip 68060; movec %%pcr,%0; .chip 68k"
244 : "=d" (pcr));
245 if (((pcr >> 8) & 0xff) <= 5) {
246 printk("Enabling workaround for errata I14\n");
247 asm (".chip 68060; movec %0,%%pcr; .chip 68k"
248 : : "d" (pcr | 0x20));
252 init_mm.start_code = PAGE_OFFSET;
253 init_mm.end_code = (unsigned long) &_etext;
254 init_mm.end_data = (unsigned long) &_edata;
255 init_mm.brk = (unsigned long) &_end;
257 *cmdline_p = m68k_command_line;
258 memcpy(saved_command_line, *cmdline_p, CL_SIZE);
260 /* Parse the command line for arch-specific options.
261 * For the m68k, this is currently only "debug=xxx" to enable printing
262 * certain kernel messages to some machine-specific device.
264 for( p = *cmdline_p; p && *p; ) {
265 i = 0;
266 if (!strncmp( p, "debug=", 6 )) {
267 strlcpy( m68k_debug_device, p+6, sizeof(m68k_debug_device) );
268 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
269 i = 1;
271 #ifdef CONFIG_ATARI
272 /* This option must be parsed very early */
273 if (!strncmp( p, "switches=", 9 )) {
274 extern void atari_switches_setup( const char *, int );
275 atari_switches_setup( p+9, (q = strchr( p+9, ' ' )) ?
276 (q - (p+9)) : strlen(p+9) );
277 i = 1;
279 #endif
281 if (i) {
282 /* option processed, delete it */
283 if ((q = strchr( p, ' ' )))
284 strcpy( p, q+1 );
285 else
286 *p = 0;
287 } else {
288 if ((p = strchr( p, ' ' ))) ++p;
292 switch (m68k_machtype) {
293 #ifdef CONFIG_AMIGA
294 case MACH_AMIGA:
295 config_amiga();
296 break;
297 #endif
298 #ifdef CONFIG_ATARI
299 case MACH_ATARI:
300 config_atari();
301 break;
302 #endif
303 #ifdef CONFIG_MAC
304 case MACH_MAC:
305 config_mac();
306 break;
307 #endif
308 #ifdef CONFIG_SUN3
309 case MACH_SUN3:
310 config_sun3();
311 break;
312 #endif
313 #ifdef CONFIG_APOLLO
314 case MACH_APOLLO:
315 config_apollo();
316 break;
317 #endif
318 #ifdef CONFIG_MVME147
319 case MACH_MVME147:
320 config_mvme147();
321 break;
322 #endif
323 #ifdef CONFIG_MVME16x
324 case MACH_MVME16x:
325 config_mvme16x();
326 break;
327 #endif
328 #ifdef CONFIG_BVME6000
329 case MACH_BVME6000:
330 config_bvme6000();
331 break;
332 #endif
333 #ifdef CONFIG_HP300
334 case MACH_HP300:
335 config_hp300();
336 break;
337 #endif
338 #ifdef CONFIG_Q40
339 case MACH_Q40:
340 config_q40();
341 break;
342 #endif
343 #ifdef CONFIG_SUN3X
344 case MACH_SUN3X:
345 config_sun3x();
346 break;
347 #endif
348 default:
349 panic ("No configuration setup");
352 #ifndef CONFIG_SUN3
353 startmem= m68k_memory[0].addr;
354 endmem = startmem + m68k_memory[0].size;
355 high_memory = PAGE_OFFSET;
356 for (i = 0; i < m68k_num_memory; i++) {
357 m68k_memory[i].size &= MASK_256K;
358 if (m68k_memory[i].addr < startmem)
359 startmem = m68k_memory[i].addr;
360 if (m68k_memory[i].addr+m68k_memory[i].size > endmem)
361 endmem = m68k_memory[i].addr+m68k_memory[i].size;
362 high_memory += m68k_memory[i].size;
365 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
366 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
368 for (i = 0; i < m68k_num_memory; i++)
369 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
371 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
373 #ifdef CONFIG_BLK_DEV_INITRD
374 if (m68k_ramdisk.size) {
375 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size);
376 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
377 initrd_end = initrd_start + m68k_ramdisk.size;
378 printk ("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
380 #endif
382 #ifdef CONFIG_ATARI
383 if (MACH_IS_ATARI)
384 atari_stram_reserve_pages((void *)availmem);
385 #endif
386 #ifdef CONFIG_SUN3X
387 if (MACH_IS_SUN3X) {
388 dvma_init();
390 #endif
392 #endif /* !CONFIG_SUN3 */
394 paging_init();
396 /* set ISA defs early as possible */
397 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
398 #if defined(CONFIG_Q40)
399 if (MACH_IS_Q40) {
400 isa_type = Q40_ISA;
401 isa_sex = 0;
403 #elif defined(CONFIG_GG2)
404 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
405 isa_type = GG2_ISA;
406 isa_sex = 0;
408 #elif defined(CONFIG_AMIGA_PCMCIA)
409 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
410 isa_type = AG_ISA;
411 isa_sex = 1;
413 #endif
414 #endif
417 static int show_cpuinfo(struct seq_file *m, void *v)
419 const char *cpu, *mmu, *fpu;
420 unsigned long clockfreq, clockfactor;
422 #define LOOP_CYCLES_68020 (8)
423 #define LOOP_CYCLES_68030 (8)
424 #define LOOP_CYCLES_68040 (3)
425 #define LOOP_CYCLES_68060 (1)
427 if (CPU_IS_020) {
428 cpu = "68020";
429 clockfactor = LOOP_CYCLES_68020;
430 } else if (CPU_IS_030) {
431 cpu = "68030";
432 clockfactor = LOOP_CYCLES_68030;
433 } else if (CPU_IS_040) {
434 cpu = "68040";
435 clockfactor = LOOP_CYCLES_68040;
436 } else if (CPU_IS_060) {
437 cpu = "68060";
438 clockfactor = LOOP_CYCLES_68060;
439 } else {
440 cpu = "680x0";
441 clockfactor = 0;
444 #ifdef CONFIG_M68KFPU_EMU_ONLY
445 fpu="none(soft float)";
446 #else
447 if (m68k_fputype & FPU_68881)
448 fpu = "68881";
449 else if (m68k_fputype & FPU_68882)
450 fpu = "68882";
451 else if (m68k_fputype & FPU_68040)
452 fpu = "68040";
453 else if (m68k_fputype & FPU_68060)
454 fpu = "68060";
455 else if (m68k_fputype & FPU_SUNFPA)
456 fpu = "Sun FPA";
457 else
458 fpu = "none";
459 #endif
461 if (m68k_mmutype & MMU_68851)
462 mmu = "68851";
463 else if (m68k_mmutype & MMU_68030)
464 mmu = "68030";
465 else if (m68k_mmutype & MMU_68040)
466 mmu = "68040";
467 else if (m68k_mmutype & MMU_68060)
468 mmu = "68060";
469 else if (m68k_mmutype & MMU_SUN3)
470 mmu = "Sun-3";
471 else if (m68k_mmutype & MMU_APOLLO)
472 mmu = "Apollo";
473 else
474 mmu = "unknown";
476 clockfreq = loops_per_jiffy*HZ*clockfactor;
478 seq_printf(m, "CPU:\t\t%s\n"
479 "MMU:\t\t%s\n"
480 "FPU:\t\t%s\n"
481 "Clocking:\t%lu.%1luMHz\n"
482 "BogoMips:\t%lu.%02lu\n"
483 "Calibration:\t%lu loops\n",
484 cpu, mmu, fpu,
485 clockfreq/1000000,(clockfreq/100000)%10,
486 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
487 loops_per_jiffy);
488 return 0;
491 static void *c_start(struct seq_file *m, loff_t *pos)
493 return *pos < 1 ? (void *)1 : NULL;
495 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
497 ++*pos;
498 return NULL;
500 static void c_stop(struct seq_file *m, void *v)
503 struct seq_operations cpuinfo_op = {
504 .start = c_start,
505 .next = c_next,
506 .stop = c_stop,
507 .show = show_cpuinfo,
510 int get_hardware_list(char *buffer)
512 int len = 0;
513 char model[80];
514 unsigned long mem;
515 int i;
517 if (mach_get_model)
518 mach_get_model(model);
519 else
520 strcpy(model, "Unknown m68k");
522 len += sprintf(buffer+len, "Model:\t\t%s\n", model);
523 for (mem = 0, i = 0; i < m68k_num_memory; i++)
524 mem += m68k_memory[i].size;
525 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
527 if (mach_get_hardware_list)
528 len += mach_get_hardware_list(buffer+len);
530 return(len);
534 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
535 void __init floppy_setup(char *str, int *ints)
537 if (mach_floppy_setup)
538 mach_floppy_setup (str, ints);
541 #endif
543 void check_bugs(void)
545 #ifndef CONFIG_M68KFPU_EMU
546 if (m68k_fputype == 0) {
547 printk( KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
548 "WHICH IS REQUIRED BY LINUX/M68K ***\n" );
549 printk( KERN_EMERG "Upgrade your hardware or join the FPU "
550 "emulation project\n" );
551 panic( "no FPU" );
554 #endif /* CONFIG_SUN3 */