blob: 750d5b3c971fe001a2d86808a30b9cd237b0eebe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68k/kernel/setup.c
3 *
4 * Copyright (C) 1995 Hamish Macdonald
5 */
6
7/*
8 * This file handles the architecture-dependent parts of system setup
9 */
10
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>
27
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
43
44unsigned long m68k_machtype;
45unsigned long m68k_cputype;
46unsigned long m68k_fputype;
47unsigned long m68k_mmutype;
48#ifdef CONFIG_VME
49unsigned long vme_brdtype;
50#endif
51
52int m68k_is040or060;
53
54extern int end;
55extern unsigned long availmem;
56
57int m68k_num_memory;
58int m68k_realnum_memory;
59unsigned long m68k_memoffset;
60struct mem_info m68k_memory[NUM_MEMINFO];
61
62static struct mem_info m68k_ramdisk;
63
64static char m68k_command_line[CL_SIZE];
65
66char m68k_debug_device[6] = "";
67
68void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
69/* machine dependent irq functions */
70void (*mach_init_IRQ) (void) __initdata = NULL;
71irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *);
72void (*mach_get_model) (char *model);
73int (*mach_get_hardware_list) (char *buffer);
74int (*mach_get_irq_list) (struct seq_file *, void *);
75irqreturn_t (*mach_process_int) (int, struct pt_regs *);
76/* machine dependent timer functions */
77unsigned long (*mach_gettimeoffset) (void);
78int (*mach_hwclk) (int, struct rtc_time*);
79int (*mach_set_clock_mmss) (unsigned long);
80unsigned int (*mach_get_ss)(void);
81int (*mach_get_rtc_pll)(struct rtc_pll_info *);
82int (*mach_set_rtc_pll)(struct rtc_pll_info *);
83void (*mach_reset)( void );
84void (*mach_halt)( void );
85void (*mach_power_off)( void );
86long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#ifdef CONFIG_HEARTBEAT
88void (*mach_heartbeat) (int);
89EXPORT_SYMBOL(mach_heartbeat);
90#endif
91#ifdef CONFIG_M68K_L2_CACHE
92void (*mach_l2_flush) (int);
93#endif
94#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
95void (*mach_beep)(unsigned int, unsigned int);
96#endif
97#if defined(CONFIG_ISA) && defined(MULTI_ISA)
98int isa_type;
99int isa_sex;
Al Viroaa7e02f2006-01-12 01:06:15 -0800100EXPORT_SYMBOL(isa_type);
101EXPORT_SYMBOL(isa_sex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#endif
103
104extern int amiga_parse_bootinfo(const struct bi_record *);
105extern int atari_parse_bootinfo(const struct bi_record *);
106extern int mac_parse_bootinfo(const struct bi_record *);
107extern int q40_parse_bootinfo(const struct bi_record *);
108extern int bvme6000_parse_bootinfo(const struct bi_record *);
109extern int mvme16x_parse_bootinfo(const struct bi_record *);
110extern int mvme147_parse_bootinfo(const struct bi_record *);
111extern int hp300_parse_bootinfo(const struct bi_record *);
112
113extern void config_amiga(void);
114extern void config_atari(void);
115extern void config_mac(void);
116extern void config_sun3(void);
117extern void config_apollo(void);
118extern void config_mvme147(void);
119extern void config_mvme16x(void);
120extern void config_bvme6000(void);
121extern void config_hp300(void);
122extern void config_q40(void);
123extern void config_sun3x(void);
124
125extern void mac_debugging_short (int, short);
126extern void mac_debugging_long (int, long);
127
128#define MASK_256K 0xfffc0000
129
130extern void paging_init(void);
131
132static void __init m68k_parse_bootinfo(const struct bi_record *record)
133{
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;
144
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;
153
154 case BI_RAMDISK:
155 m68k_ramdisk.addr = data[0];
156 m68k_ramdisk.size = data[1];
157 break;
158
159 case BI_COMMAND_LINE:
160 strlcpy(m68k_command_line, (const char *)data, sizeof(m68k_command_line));
161 break;
162
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;
182 }
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);
187 }
188
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;
195 }
196 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
197#endif
198}
199
200void __init setup_arch(char **cmdline_p)
201{
202 extern int _etext, _edata, _end;
203#ifndef CONFIG_SUN3
204 unsigned long endmem, startmem;
205#endif
206 int i;
207 char *p, *q;
208
209 /* The bootinfo is located right after the kernel bss */
210 m68k_parse_bootinfo((const struct bi_record *)&_end);
211
212 if (CPU_IS_040)
213 m68k_is040or060 = 4;
214 else if (CPU_IS_060)
215 m68k_is040or060 = 6;
216
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));
227 }
228#endif
229
230 if (CPU_IS_060) {
231 u32 pcr;
232
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));
239 }
240 }
241
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;
246
247 *cmdline_p = m68k_command_line;
248 memcpy(saved_command_line, *cmdline_p, CL_SIZE);
249
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.
253 */
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;
260 }
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;
268 }
269#endif
270
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;
279 }
280 }
281
Al Viro0c793582006-01-12 01:06:35 -0800282#ifdef CONFIG_DUMMY_CONSOLE
283 conswitchp = &dummy_con;
284#endif
285
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 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");
344 }
345
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;
357 }
358
359 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
360 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
361
362 for (i = 0; i < m68k_num_memory; i++)
363 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
364
365 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
366
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);
373 }
374#endif
375
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();
383 }
384#endif
385
386#endif /* !CONFIG_SUN3 */
387
388 paging_init();
389
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;
396 }
397#elif defined(CONFIG_GG2)
398 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
399 isa_type = GG2_ISA;
400 isa_sex = 0;
401 }
402#elif defined(CONFIG_AMIGA_PCMCIA)
403 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
404 isa_type = AG_ISA;
405 isa_sex = 1;
406 }
407#endif
408#endif
409}
410
411static int show_cpuinfo(struct seq_file *m, void *v)
412{
413 const char *cpu, *mmu, *fpu;
414 unsigned long clockfreq, clockfactor;
415
416#define LOOP_CYCLES_68020 (8)
417#define LOOP_CYCLES_68030 (8)
418#define LOOP_CYCLES_68040 (3)
419#define LOOP_CYCLES_68060 (1)
420
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;
436 }
437
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
454
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";
469
470 clockfreq = loops_per_jiffy*HZ*clockfactor;
471
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;
483}
484
485static void *c_start(struct seq_file *m, loff_t *pos)
486{
487 return *pos < 1 ? (void *)1 : NULL;
488}
489static void *c_next(struct seq_file *m, void *v, loff_t *pos)
490{
491 ++*pos;
492 return NULL;
493}
494static void c_stop(struct seq_file *m, void *v)
495{
496}
497struct seq_operations cpuinfo_op = {
498 .start = c_start,
499 .next = c_next,
500 .stop = c_stop,
501 .show = show_cpuinfo,
502};
503
504int get_hardware_list(char *buffer)
505{
506 int len = 0;
507 char model[80];
508 unsigned long mem;
509 int i;
510
511 if (mach_get_model)
512 mach_get_model(model);
513 else
514 strcpy(model, "Unknown m68k");
515
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);
520
521 if (mach_get_hardware_list)
522 len += mach_get_hardware_list(buffer+len);
523
524 return(len);
525}
526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527void check_bugs(void)
528{
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" );
536 }
537#endif /* !CONFIG_M68KFPU_EMU */
538}