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>
26 #include <linux/initrd.h>
28 #include <asm/bootinfo.h>
29 #include <asm/setup.h>
32 #include <asm/machdep.h>
34 #include <asm/amigahw.h>
37 #include <asm/atarihw.h>
38 #include <asm/atari_stram.h>
44 unsigned long m68k_machtype;
45 unsigned long m68k_cputype;
46 unsigned long m68k_fputype;
47 unsigned long m68k_mmutype;
49 unsigned long vme_brdtype;
55 extern unsigned long availmem;
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);
91 #ifdef CONFIG_M68K_L2_CACHE
92 void (*mach_l2_flush) (int);
94 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
95 void (*mach_beep)(unsigned int, unsigned int);
97 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
100 EXPORT_SYMBOL(isa_type);
101 EXPORT_SYMBOL(isa_sex);
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) {
136 const unsigned long *data = record->data;
137 switch (record->tag) {
142 /* Already set up by head.S */
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];
151 printk("m68k_parse_bootinfo: too many memory chunks\n");
155 m68k_ramdisk.addr = data[0];
156 m68k_ramdisk.size = data[1];
159 case BI_COMMAND_LINE:
160 strlcpy(m68k_command_line, (const char *)data, sizeof(m68k_command_line));
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);
184 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
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));
196 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
200 void __init setup_arch(char **cmdline_p)
202 extern int _etext, _edata, _end;
204 unsigned long endmem, startmem;
209 /* The bootinfo is located right after the kernel bss */
210 m68k_parse_bootinfo((const struct bi_record *)&_end);
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));
233 asm (".chip 68060; movec %%pcr,%0; .chip 68k"
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; ) {
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;
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) );
272 /* option processed, delete it */
273 if ((q = strchr( p, ' ' )))
278 if ((p = strchr( p, ' ' ))) ++p;
282 #ifdef CONFIG_DUMMY_CONSOLE
283 conswitchp = &dummy_con;
286 switch (m68k_machtype) {
312 #ifdef CONFIG_MVME147
317 #ifdef CONFIG_MVME16x
322 #ifdef CONFIG_BVME6000
343 panic ("No configuration setup");
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);
378 atari_stram_reserve_pages((void *)availmem);
386 #endif /* !CONFIG_SUN3 */
390 /* set ISA defs early as possible */
391 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
392 #if defined(CONFIG_Q40)
397 #elif defined(CONFIG_GG2)
398 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
402 #elif defined(CONFIG_AMIGA_PCMCIA)
403 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
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)
423 clockfactor = LOOP_CYCLES_68020;
424 } else if (CPU_IS_030) {
426 clockfactor = LOOP_CYCLES_68030;
427 } else if (CPU_IS_040) {
429 clockfactor = LOOP_CYCLES_68040;
430 } else if (CPU_IS_060) {
432 clockfactor = LOOP_CYCLES_68060;
438 #ifdef CONFIG_M68KFPU_EMU_ONLY
439 fpu="none(soft float)";
441 if (m68k_fputype & FPU_68881)
443 else if (m68k_fputype & FPU_68882)
445 else if (m68k_fputype & FPU_68040)
447 else if (m68k_fputype & FPU_68060)
449 else if (m68k_fputype & FPU_SUNFPA)
455 if (m68k_mmutype & MMU_68851)
457 else if (m68k_mmutype & MMU_68030)
459 else if (m68k_mmutype & MMU_68040)
461 else if (m68k_mmutype & MMU_68060)
463 else if (m68k_mmutype & MMU_SUN3)
465 else if (m68k_mmutype & MMU_APOLLO)
470 clockfreq = loops_per_jiffy*HZ*clockfactor;
472 seq_printf(m, "CPU:\t\t%s\n"
475 "Clocking:\t%lu.%1luMHz\n"
476 "BogoMips:\t%lu.%02lu\n"
477 "Calibration:\t%lu loops\n",
479 clockfreq/1000000,(clockfreq/100000)%10,
480 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
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)
494 static void c_stop(struct seq_file *m, void *v)
497 struct seq_operations cpuinfo_op = {
501 .show = show_cpuinfo,
504 int get_hardware_list(char *buffer)
512 mach_get_model(model);
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);
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" );
537 #endif /* !CONFIG_M68KFPU_EMU */