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/module.h>
26 #include <asm/bootinfo.h>
27 #include <asm/setup.h>
30 #include <asm/machdep.h>
32 #include <asm/amigahw.h>
35 #include <asm/atarihw.h>
38 #ifdef CONFIG_BLK_DEV_INITRD
39 #include <linux/blk.h>
43 #define dbprintf printk
46 unsigned long m68k_machtype
;
47 unsigned long m68k_cputype
;
48 unsigned long m68k_fputype
;
49 unsigned long m68k_mmutype
;
51 unsigned long vme_brdtype
;
54 int m68k_is040or060
= 0;
57 extern unsigned long availmem
;
59 int m68k_num_memory
= 0;
60 int m68k_realnum_memory
= 0;
61 unsigned long m68k_memoffset
;
62 struct mem_info m68k_memory
[NUM_MEMINFO
];
64 static struct mem_info m68k_ramdisk
= { 0, 0 };
66 static char m68k_command_line
[CL_SIZE
];
67 char saved_command_line
[CL_SIZE
];
69 char m68k_debug_device
[6] = "";
71 void (*mach_sched_init
) (void (*handler
)(int, void *, struct pt_regs
*)) __initdata
= NULL
;
72 /* machine dependent keyboard functions */
73 int (*mach_keyb_init
) (void) __initdata
= NULL
;
74 int (*mach_kbdrate
) (struct kbd_repeat
*) = NULL
;
75 void (*mach_kbd_leds
) (unsigned int) = NULL
;
76 int (*mach_kbd_translate
)(unsigned char scancode
, unsigned char *keycode
, char raw_mode
) = NULL
;
77 unsigned int SYSRQ_KEY
;
78 /* machine dependent irq functions */
79 void (*mach_init_IRQ
) (void) __initdata
= NULL
;
80 void (*(*mach_default_handler
)[]) (int, void *, struct pt_regs
*) = NULL
;
81 void (*mach_get_model
) (char *model
) = NULL
;
82 int (*mach_get_hardware_list
) (char *buffer
) = NULL
;
83 int (*mach_get_irq_list
) (char *) = NULL
;
84 void (*mach_process_int
) (int, struct pt_regs
*) = NULL
;
85 /* machine dependent timer functions */
86 unsigned long (*mach_gettimeoffset
) (void);
87 void (*mach_gettod
) (int*, int*, int*, int*, int*, int*);
88 int (*mach_hwclk
) (int, struct hwclk_time
*) = NULL
;
89 int (*mach_set_clock_mmss
) (unsigned long) = NULL
;
90 void (*mach_reset
)( void );
91 void (*mach_halt
)( void ) = NULL
;
92 void (*mach_power_off
)( void ) = NULL
;
93 long mach_max_dma_address
= 0x00ffffff; /* default set to the lower 16MB */
94 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY) || defined(CONFIG_BLK_DEV_FD)
95 void (*mach_floppy_setup
) (char *, int *) __initdata
= NULL
;
96 void (*mach_floppy_eject
) (void) = NULL
;
100 long serial_rs_init(void);
101 int serial_register_serial(struct serial_struct
*);
102 void serial_unregister_serial(int);
103 long ser_console_init(long, long );
105 #if defined(CONFIG_USERIAL)||defined(CONFIG_HPDCA)||defined(CONFIG_WHIPPET_SERIAL)||defined(CONFIG_MULTIFACE_III_TTY)||defined(CONFIG_GVPIOEXT)||defined(CONFIG_AMIGA_BUILTIN_SERIAL)||defined(CONFIG_MAC_SCC)||defined(CONFIG_ATARI_MIDI)||defined(CONFIG_ATARI_SCC)||defined(CONFIG_ATARI_MFPSER)
109 long m68k_rs_init(void);
110 int m68k_register_serial(struct serial_struct
*);
111 void m68k_unregister_serial(int);
112 long m68k_serial_console_init(void);
114 #ifdef CONFIG_HEARTBEAT
115 void (*mach_heartbeat
) (int) = NULL
;
116 EXPORT_SYMBOL(mach_heartbeat
);
118 #ifdef CONFIG_M68K_L2_CACHE
119 void (*mach_l2_flush
) (int) = NULL
;
122 #ifdef CONFIG_MAGIC_SYSRQ
123 int mach_sysrq_key
= -1;
124 int mach_sysrq_shift_state
= 0;
125 int mach_sysrq_shift_mask
= 0;
126 char *mach_sysrq_xlate
= NULL
;
129 extern int amiga_parse_bootinfo(const struct bi_record
*);
130 extern int atari_parse_bootinfo(const struct bi_record
*);
131 extern int mac_parse_bootinfo(const struct bi_record
*);
132 extern int q40_parse_bootinfo(const struct bi_record
*);
133 extern int bvme6000_parse_bootinfo(const struct bi_record
*);
134 extern int mvme16x_parse_bootinfo(const struct bi_record
*);
135 extern int mvme147_parse_bootinfo(const struct bi_record
*);
137 extern void config_amiga(void);
138 extern void config_atari(void);
139 extern void config_mac(void);
140 extern void config_sun3(unsigned long *, unsigned long *);
141 extern void config_apollo(void);
142 extern void config_mvme147(void);
143 extern void config_mvme16x(void);
144 extern void config_bvme6000(void);
145 extern void config_hp300(void);
146 extern void config_q40(void);
147 extern void config_sun3x(void);
149 extern void mac_debugging_short (int, short);
150 extern void mac_debugging_long (int, long);
152 #define MASK_256K 0xfffc0000
154 static void __init
m68k_parse_bootinfo(const struct bi_record
*record
)
156 while (record
->tag
!= BI_LAST
) {
158 const u_long
*data
= record
->data
;
159 switch (record
->tag
) {
164 /* Already set up by head.S */
168 if (m68k_num_memory
< NUM_MEMINFO
) {
169 m68k_memory
[m68k_num_memory
].addr
= data
[0];
170 m68k_memory
[m68k_num_memory
].size
= data
[1];
173 printk("m68k_parse_bootinfo: too many memory chunks\n");
177 m68k_ramdisk
.addr
= data
[0];
178 m68k_ramdisk
.size
= data
[1];
181 case BI_COMMAND_LINE
:
182 strncpy(m68k_command_line
, (const char *)data
, CL_SIZE
);
183 m68k_command_line
[CL_SIZE
-1] = '\0';
188 unknown
= amiga_parse_bootinfo(record
);
189 else if (MACH_IS_ATARI
)
190 unknown
= atari_parse_bootinfo(record
);
191 else if (MACH_IS_MAC
)
192 unknown
= mac_parse_bootinfo(record
);
193 else if (MACH_IS_Q40
)
194 unknown
= q40_parse_bootinfo(record
);
195 else if (MACH_IS_BVME6000
)
196 unknown
= bvme6000_parse_bootinfo(record
);
197 else if (MACH_IS_MVME16x
)
198 unknown
= mvme16x_parse_bootinfo(record
);
199 else if (MACH_IS_MVME147
)
200 unknown
= mvme147_parse_bootinfo(record
);
205 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
207 record
= (struct bi_record
*)((u_long
)record
+record
->size
);
210 m68k_realnum_memory
= m68k_num_memory
;
211 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
212 if (m68k_num_memory
> 1) {
213 printk("Ignoring last %i chunks of physical memory\n",
214 (m68k_num_memory
- 1));
217 m68k_memoffset
= m68k_memory
[0].addr
-PAGE_OFFSET
;
221 void __init
setup_arch(char **cmdline_p
)
223 extern int _etext
, _edata
, _end
;
224 unsigned long endmem
, startmem
;
228 /* The bootinfo is located right after the kernel bss */
229 m68k_parse_bootinfo((const struct bi_record
*)&_end
);
236 /* FIXME: m68k_fputype is passed in by Penguin booter, which can
237 * be confused by software FPU emulation. BEWARE.
238 * We should really do our own FPU check at startup.
239 * [what do we do with buggy 68LC040s? if we have problems
240 * with them, we should add a test to check_bugs() below] */
241 #ifndef CONFIG_M68KFPU_EMU_ONLY
242 /* clear the fpu if we have one */
243 if (m68k_fputype
& (FPU_68881
|FPU_68882
|FPU_68040
|FPU_68060
)) {
244 volatile int zero
= 0;
245 asm __volatile__ ("frestore %0" : : "m" (zero
));
249 init_mm
.start_code
= PAGE_OFFSET
;
250 init_mm
.end_code
= (unsigned long) &_etext
;
251 init_mm
.end_data
= (unsigned long) &_edata
;
252 init_mm
.brk
= (unsigned long) &_end
;
254 *cmdline_p
= m68k_command_line
;
255 memcpy(saved_command_line
, *cmdline_p
, CL_SIZE
);
257 /* Parse the command line for arch-specific options.
258 * For the m68k, this is currently only "debug=xxx" to enable printing
259 * certain kernel messages to some machine-specific device.
261 for( p
= *cmdline_p
; p
&& *p
; ) {
263 if (!strncmp( p
, "debug=", 6 )) {
264 strncpy( m68k_debug_device
, p
+6, sizeof(m68k_debug_device
)-1 );
265 m68k_debug_device
[sizeof(m68k_debug_device
)-1] = 0;
266 if ((q
= strchr( m68k_debug_device
, ' ' ))) *q
= 0;
270 /* This option must be parsed very early */
271 if (!strncmp( p
, "switches=", 9 )) {
272 extern void atari_switches_setup( const char *, int );
273 atari_switches_setup( p
+9, (q
= strchr( p
+9, ' ' )) ?
274 (q
- (p
+9)) : strlen(p
+9) );
280 /* option processed, delete it */
281 if ((q
= strchr( p
, ' ' )))
286 if ((p
= strchr( p
, ' ' ))) ++p
;
290 switch (m68k_machtype
) {
308 config_sun3(memory_start_p
, memory_end_p
);
316 #ifdef CONFIG_MVME147
321 #ifdef CONFIG_MVME16x
326 #ifdef CONFIG_BVME6000
347 panic ("No configuration setup");
350 #ifdef CONFIG_BLK_DEV_INITRD
351 if (m68k_ramdisk
.size
) {
352 initrd_start
= (unsigned long)phys_to_virt(m68k_ramdisk
.addr
);
353 initrd_end
= initrd_start
+ m68k_ramdisk
.size
;
358 startmem
= m68k_memory
[0].addr
;
359 endmem
= startmem
+ m68k_memory
[0].size
;
360 high_memory
= PAGE_OFFSET
;
361 for (i
= 0; i
< m68k_num_memory
; i
++) {
362 m68k_memory
[i
].size
&= MASK_256K
;
363 if (m68k_memory
[i
].addr
< startmem
)
364 startmem
= m68k_memory
[i
].addr
;
365 if (m68k_memory
[i
].addr
+m68k_memory
[i
].size
> endmem
)
366 endmem
= m68k_memory
[i
].addr
+m68k_memory
[i
].size
;
367 high_memory
+= m68k_memory
[i
].size
;
370 availmem
+= init_bootmem_node(NODE_DATA(0), availmem
>> PAGE_SHIFT
,
371 startmem
>> PAGE_SHIFT
, endmem
>> PAGE_SHIFT
);
373 for (i
= 0; i
< m68k_num_memory
; i
++)
374 free_bootmem(m68k_memory
[0].addr
, m68k_memory
[0].size
);
376 reserve_bootmem(m68k_memory
[0].addr
, availmem
- m68k_memory
[0].addr
);
380 int get_cpuinfo(char * buffer
)
382 const char *cpu
, *mmu
, *fpu
;
383 u_long clockfreq
, clockfactor
;
385 #define LOOP_CYCLES_68020 (8)
386 #define LOOP_CYCLES_68030 (8)
387 #define LOOP_CYCLES_68040 (3)
388 #define LOOP_CYCLES_68060 (1)
392 clockfactor
= LOOP_CYCLES_68020
;
393 } else if (CPU_IS_030
) {
395 clockfactor
= LOOP_CYCLES_68030
;
396 } else if (CPU_IS_040
) {
398 clockfactor
= LOOP_CYCLES_68040
;
399 } else if (CPU_IS_060
) {
401 clockfactor
= LOOP_CYCLES_68060
;
407 #ifdef CONFIG_M68KFPU_EMU_ONLY
408 fpu
="none(soft float)";
410 if (m68k_fputype
& FPU_68881
)
412 else if (m68k_fputype
& FPU_68882
)
414 else if (m68k_fputype
& FPU_68040
)
416 else if (m68k_fputype
& FPU_68060
)
418 else if (m68k_fputype
& FPU_SUNFPA
)
424 if (m68k_mmutype
& MMU_68851
)
426 else if (m68k_mmutype
& MMU_68030
)
428 else if (m68k_mmutype
& MMU_68040
)
430 else if (m68k_mmutype
& MMU_68060
)
432 else if (m68k_mmutype
& MMU_SUN3
)
434 else if (m68k_mmutype
& MMU_APOLLO
)
439 clockfreq
= loops_per_sec
*clockfactor
;
441 return(sprintf(buffer
, "CPU:\t\t%s\n"
444 "Clocking:\t%lu.%1luMHz\n"
445 "BogoMips:\t%lu.%02lu\n"
446 "Calibration:\t%lu loops\n",
448 clockfreq
/1000000,(clockfreq
/100000)%10,
449 loops_per_sec
/500000,(loops_per_sec
/5000)%100,
454 int get_hardware_list(char *buffer
)
462 mach_get_model(model
);
464 strcpy(model
, "Unknown m68k");
466 len
+= sprintf(buffer
+len
, "Model:\t\t%s\n", model
);
467 len
+= get_cpuinfo(buffer
+len
);
468 for (mem
= 0, i
= 0; i
< m68k_num_memory
; i
++)
469 mem
+= m68k_memory
[i
].size
;
470 len
+= sprintf(buffer
+len
, "System Memory:\t%ldK\n", mem
>>10);
472 if (mach_get_hardware_list
)
473 len
+= mach_get_hardware_list(buffer
+len
);
478 #if defined(CONFIG_SERIAL) || defined(M68K_SERIAL)
483 return serial_rs_init();
486 return m68k_rs_init();
489 int register_serial(struct serial_struct
*p
)
493 return serial_register_serial(p
);
496 return m68k_register_serial(p
);
499 void unregister_serial(int i
)
503 serial_unregister_serial(i
);
506 m68k_unregister_serial(i
);
509 EXPORT_SYMBOL(register_serial
);
510 EXPORT_SYMBOL(unregister_serial
);
512 #ifdef CONFIG_SERIAL_CONSOLE
513 void serial_console_init(void)
515 #ifdef CONFIG_Q40_SERIAL
521 #if defined(M68K_SERIAL) && defined(CONFIG_SERIAL_CONSOLE)
522 m68k_serial_console_init();
528 #if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY) || defined(CONFIG_BLK_DEV_FD)
529 void __init
floppy_setup(char *str
, int *ints
)
531 if (mach_floppy_setup
)
532 mach_floppy_setup (str
, ints
);
535 void floppy_eject(void)
537 if (mach_floppy_eject
)
542 /* for "kbd-reset" cmdline param */
543 void __init
kbd_reset_setup(char *str
, int *ints
)
547 void arch_gettod(int *year
, int *mon
, int *day
, int *hour
,
551 mach_gettod(year
, mon
, day
, hour
, min
, sec
);
553 *year
= *mon
= *day
= *hour
= *min
= *sec
= 0;
556 void check_bugs(void)
558 #ifndef CONFIG_M68KFPU_EMU
559 if (m68k_fputype
== 0) {
560 printk( KERN_EMERG
"*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
561 "WHICH IS REQUIRED BY LINUX/M68K ***\n" );
562 printk( KERN_EMERG
"Upgrade your hardware or join the FPU "
563 "emulation project\n" );
564 printk( KERN_EMERG
"(see http://no-fpu.linux-m68k.org)\n" );