2 * linux/arch/m68k/kernel/setup.c
4 * Copyright (C) 1995 Hamish Macdonald
8 * This file handles the architecture-dependent parts of system setup
11 #include <linux/config.h>
12 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
16 #include <linux/interrupt.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>
27 #include <asm/bootinfo.h>
28 #include <asm/setup.h>
31 #include <asm/machdep.h>
33 #include <asm/amigahw.h>
36 #include <asm/atarihw.h>
37 #include <asm/atari_stram.h>
41 extern void sun_serial_setup(void);
44 #ifdef CONFIG_BLK_DEV_INITRD
45 #include <linux/blk.h>
48 unsigned long m68k_machtype;
49 unsigned long m68k_cputype;
50 unsigned long m68k_fputype;
51 unsigned long m68k_mmutype;
53 unsigned long vme_brdtype;
56 int m68k_is040or060 = 0;
59 extern unsigned long availmem;
61 int m68k_num_memory = 0;
62 int m68k_realnum_memory = 0;
63 unsigned long m68k_memoffset;
64 struct mem_info m68k_memory[NUM_MEMINFO];
66 static struct mem_info m68k_ramdisk = { 0, 0 };
68 static char m68k_command_line[CL_SIZE];
69 char saved_command_line[CL_SIZE];
71 char m68k_debug_device[6] = "";
73 void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
74 /* machine dependent keyboard functions */
76 int (*mach_keyb_init) (void) __initdata = NULL;
77 int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
78 void (*mach_kbd_leds) (unsigned int) = NULL;
79 int (*mach_kbd_translate)(unsigned char scancode, unsigned char *keycode, char raw_mode) = NULL;
81 /* machine dependent irq functions */
82 void (*mach_init_IRQ) (void) __initdata = NULL;
83 void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
84 void (*mach_get_model) (char *model) = NULL;
85 int (*mach_get_hardware_list) (char *buffer) = NULL;
86 int (*mach_get_irq_list) (char *) = NULL;
87 void (*mach_process_int) (int, struct pt_regs *) = NULL;
88 /* machine dependent timer functions */
89 unsigned long (*mach_gettimeoffset) (void);
90 void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
91 int (*mach_hwclk) (int, struct rtc_time*) = NULL;
92 int (*mach_set_clock_mmss) (unsigned long) = NULL;
93 unsigned int (*mach_get_ss)(void) = NULL;
94 int (*mach_get_rtc_pll)(struct rtc_pll_info *) = NULL;
95 int (*mach_set_rtc_pll)(struct rtc_pll_info *) = NULL;
96 void (*mach_reset)( void );
97 void (*mach_halt)( void ) = NULL;
98 void (*mach_power_off)( void ) = NULL;
99 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
100 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
101 void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
103 #ifdef CONFIG_HEARTBEAT
104 void (*mach_heartbeat) (int) = NULL;
105 EXPORT_SYMBOL(mach_heartbeat);
107 #ifdef CONFIG_M68K_L2_CACHE
108 void (*mach_l2_flush) (int) = NULL;
111 #ifdef CONFIG_MAGIC_SYSRQ
112 unsigned int SYSRQ_KEY;
113 int mach_sysrq_key = -1;
114 int mach_sysrq_shift_state = 0;
115 int mach_sysrq_shift_mask = 0;
116 char *mach_sysrq_xlate = NULL;
119 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
124 extern int amiga_parse_bootinfo(const struct bi_record *);
125 extern int atari_parse_bootinfo(const struct bi_record *);
126 extern int mac_parse_bootinfo(const struct bi_record *);
127 extern int q40_parse_bootinfo(const struct bi_record *);
128 extern int bvme6000_parse_bootinfo(const struct bi_record *);
129 extern int mvme16x_parse_bootinfo(const struct bi_record *);
130 extern int mvme147_parse_bootinfo(const struct bi_record *);
132 extern void config_amiga(void);
133 extern void config_atari(void);
134 extern void config_mac(void);
135 extern void config_sun3(void);
136 extern void config_apollo(void);
137 extern void config_mvme147(void);
138 extern void config_mvme16x(void);
139 extern void config_bvme6000(void);
140 extern void config_hp300(void);
141 extern void config_q40(void);
142 extern void config_sun3x(void);
144 extern void mac_debugging_short (int, short);
145 extern void mac_debugging_long (int, long);
147 #define MASK_256K 0xfffc0000
149 extern void paging_init(void);
151 static void __init m68k_parse_bootinfo(const struct bi_record *record)
153 while (record->tag != BI_LAST) {
155 const unsigned long *data = record->data;
156 switch (record->tag) {
161 /* Already set up by head.S */
165 if (m68k_num_memory < NUM_MEMINFO) {
166 m68k_memory[m68k_num_memory].addr = data[0];
167 m68k_memory[m68k_num_memory].size = data[1];
170 printk("m68k_parse_bootinfo: too many memory chunks\n");
174 m68k_ramdisk.addr = data[0];
175 m68k_ramdisk.size = data[1];
178 case BI_COMMAND_LINE:
179 strncpy(m68k_command_line, (const char *)data, CL_SIZE);
180 m68k_command_line[CL_SIZE-1] = '\0';
185 unknown = amiga_parse_bootinfo(record);
186 else if (MACH_IS_ATARI)
187 unknown = atari_parse_bootinfo(record);
188 else if (MACH_IS_MAC)
189 unknown = mac_parse_bootinfo(record);
190 else if (MACH_IS_Q40)
191 unknown = q40_parse_bootinfo(record);
192 else if (MACH_IS_BVME6000)
193 unknown = bvme6000_parse_bootinfo(record);
194 else if (MACH_IS_MVME16x)
195 unknown = mvme16x_parse_bootinfo(record);
196 else if (MACH_IS_MVME147)
197 unknown = mvme147_parse_bootinfo(record);
202 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
204 record = (struct bi_record *)((unsigned long)record+record->size);
207 m68k_realnum_memory = m68k_num_memory;
208 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
209 if (m68k_num_memory > 1) {
210 printk("Ignoring last %i chunks of physical memory\n",
211 (m68k_num_memory - 1));
214 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
218 void __init setup_arch(char **cmdline_p)
220 extern int _etext, _edata, _end;
222 unsigned long endmem, startmem;
227 if (!MACH_IS_HP300) {
228 /* The bootinfo is located right after the kernel bss */
229 m68k_parse_bootinfo((const struct bi_record *)&_end);
231 /* FIXME HP300 doesn't use bootinfo yet */
232 extern unsigned long hp300_phys_ram_base;
233 unsigned long hp300_mem_size = 0xffffffff-hp300_phys_ram_base;
234 m68k_cputype = CPU_68030;
235 m68k_fputype = FPU_68882;
236 m68k_memory[0].addr = hp300_phys_ram_base;
237 /* 0.5M fudge factor */
238 m68k_memory[0].size = hp300_mem_size-512*1024;
250 asm (".chip 68060; movec %%pcr,%0; .chip 68k"
252 if (((pcr >> 8) & 0xff) <= 5) {
253 printk("Enabling workaround for errata I14\n");
254 asm (".chip 68060; movec %0,%%pcr; .chip 68k"
255 : : "d" (pcr | 0x20));
259 /* FIXME: m68k_fputype is passed in by Penguin booter, which can
260 * be confused by software FPU emulation. BEWARE.
261 * We should really do our own FPU check at startup.
262 * [what do we do with buggy 68LC040s? if we have problems
263 * with them, we should add a test to check_bugs() below] */
264 #ifndef CONFIG_M68KFPU_EMU_ONLY
265 /* clear the fpu if we have one */
266 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
267 volatile int zero = 0;
268 asm __volatile__ ("frestore %0" : : "m" (zero));
272 init_mm.start_code = PAGE_OFFSET;
273 init_mm.end_code = (unsigned long) &_etext;
274 init_mm.end_data = (unsigned long) &_edata;
275 init_mm.brk = (unsigned long) &_end;
277 *cmdline_p = m68k_command_line;
278 memcpy(saved_command_line, *cmdline_p, CL_SIZE);
280 /* Parse the command line for arch-specific options.
281 * For the m68k, this is currently only "debug=xxx" to enable printing
282 * certain kernel messages to some machine-specific device.
284 for( p = *cmdline_p; p && *p; ) {
286 if (!strncmp( p, "debug=", 6 )) {
287 strncpy( m68k_debug_device, p+6, sizeof(m68k_debug_device)-1 );
288 m68k_debug_device[sizeof(m68k_debug_device)-1] = 0;
289 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
293 /* These options must be parsed very early */
294 if (!strncmp( p, "switches=", 9 )) {
295 extern void atari_switches_setup( const char *, int );
296 atari_switches_setup( p+9, (q = strchr( p+9, ' ' )) ?
297 (q - (p+9)) : strlen(p+9) );
300 #ifdef CONFIG_STRAM_SWAP
301 if (!strncmp( p, "stram_swap=", 11 )) {
302 extern void stram_swap_setup( char * );
303 stram_swap_setup( p+11 );
306 #endif /* CONFIG_STRAM_SWAP */
310 /* option processed, delete it */
311 if ((q = strchr( p, ' ' )))
316 if ((p = strchr( p, ' ' ))) ++p;
320 switch (m68k_machtype) {
346 #ifdef CONFIG_MVME147
351 #ifdef CONFIG_MVME16x
356 #ifdef CONFIG_BVME6000
377 panic ("No configuration setup");
381 startmem= m68k_memory[0].addr;
382 endmem = startmem + m68k_memory[0].size;
383 high_memory = PAGE_OFFSET;
384 for (i = 0; i < m68k_num_memory; i++) {
385 m68k_memory[i].size &= MASK_256K;
386 if (m68k_memory[i].addr < startmem)
387 startmem = m68k_memory[i].addr;
388 if (m68k_memory[i].addr+m68k_memory[i].size > endmem)
389 endmem = m68k_memory[i].addr+m68k_memory[i].size;
390 high_memory += m68k_memory[i].size;
393 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
394 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
396 for (i = 0; i < m68k_num_memory; i++)
397 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
399 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
401 #ifdef CONFIG_BLK_DEV_INITRD
402 if (m68k_ramdisk.size) {
403 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size);
404 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
405 initrd_end = initrd_start + m68k_ramdisk.size;
406 printk ("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
412 atari_stram_reserve_pages((void *)availmem);
417 #ifdef CONFIG_SUN3X_ZS
423 #endif /* !CONFIG_SUN3 */
427 /* set ISA defs early as possible */
428 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
429 #if defined(CONFIG_Q40)
434 #elif defined(CONFIG_GG2)
435 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
439 #elif defined(CONFIG_AMIGA_PCMCIA)
440 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
448 static int show_cpuinfo(struct seq_file *m, void *v)
450 const char *cpu, *mmu, *fpu;
451 unsigned long clockfreq, clockfactor;
453 #define LOOP_CYCLES_68020 (8)
454 #define LOOP_CYCLES_68030 (8)
455 #define LOOP_CYCLES_68040 (3)
456 #define LOOP_CYCLES_68060 (1)
460 clockfactor = LOOP_CYCLES_68020;
461 } else if (CPU_IS_030) {
463 clockfactor = LOOP_CYCLES_68030;
464 } else if (CPU_IS_040) {
466 clockfactor = LOOP_CYCLES_68040;
467 } else if (CPU_IS_060) {
469 clockfactor = LOOP_CYCLES_68060;
475 #ifdef CONFIG_M68KFPU_EMU_ONLY
476 fpu="none(soft float)";
478 if (m68k_fputype & FPU_68881)
480 else if (m68k_fputype & FPU_68882)
482 else if (m68k_fputype & FPU_68040)
484 else if (m68k_fputype & FPU_68060)
486 else if (m68k_fputype & FPU_SUNFPA)
492 if (m68k_mmutype & MMU_68851)
494 else if (m68k_mmutype & MMU_68030)
496 else if (m68k_mmutype & MMU_68040)
498 else if (m68k_mmutype & MMU_68060)
500 else if (m68k_mmutype & MMU_SUN3)
502 else if (m68k_mmutype & MMU_APOLLO)
507 clockfreq = loops_per_jiffy*HZ*clockfactor;
509 seq_printf(m, "CPU:\t\t%s\n"
512 "Clocking:\t%lu.%1luMHz\n"
513 "BogoMips:\t%lu.%02lu\n"
514 "Calibration:\t%lu loops\n",
516 clockfreq/1000000,(clockfreq/100000)%10,
517 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
522 static void *c_start(struct seq_file *m, loff_t *pos)
524 return *pos < 1 ? (void *)1 : NULL;
526 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
531 static void c_stop(struct seq_file *m, void *v)
534 struct seq_operations cpuinfo_op = {
541 int get_hardware_list(char *buffer)
549 mach_get_model(model);
551 strcpy(model, "Unknown m68k");
553 len += sprintf(buffer+len, "Model:\t\t%s\n", model);
554 //len += get_cpuinfo(buffer+len);
555 for (mem = 0, i = 0; i < m68k_num_memory; i++)
556 mem += m68k_memory[i].size;
557 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
559 if (mach_get_hardware_list)
560 len += mach_get_hardware_list(buffer+len);
566 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
567 void __init floppy_setup(char *str, int *ints)
569 if (mach_floppy_setup)
570 mach_floppy_setup (str, ints);
575 /* for "kbd-reset" cmdline param */
576 void __init kbd_reset_setup(char *str, int *ints)
580 void arch_gettod(int *year, int *mon, int *day, int *hour,
584 mach_gettod(year, mon, day, hour, min, sec);
586 *year = *mon = *day = *hour = *min = *sec = 0;
589 void check_bugs(void)
591 #ifndef CONFIG_M68KFPU_EMU
592 if (m68k_fputype == 0) {
593 printk( KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
594 "WHICH IS REQUIRED BY LINUX/M68K ***\n" );
595 printk( KERN_EMERG "Upgrade your hardware or join the FPU "
596 "emulation project\n" );
597 printk( KERN_EMERG "(see http://no-fpu.linux-m68k.org)\n" );
600 #endif /* !CONFIG_M68KFPU_EMU */