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/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/delay.h>
15 #include <linux/interrupt.h>
17 #include <linux/console.h>
18 #include <linux/genhd.h>
19 #include <linux/errno.h>
20 #include <linux/string.h>
21 #include <linux/init.h>
22 #include <linux/bootmem.h>
23 #include <linux/seq_file.h>
24 #include <linux/module.h>
25 #include <linux/initrd.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>
43 unsigned long m68k_machtype;
44 unsigned long m68k_cputype;
45 unsigned long m68k_fputype;
46 unsigned long m68k_mmutype;
48 unsigned long vme_brdtype;
54 extern unsigned long availmem;
57 int m68k_realnum_memory;
58 unsigned long m68k_memoffset;
59 struct mem_info m68k_memory[NUM_MEMINFO];
61 static struct mem_info m68k_ramdisk;
63 static char m68k_command_line[CL_SIZE];
65 char m68k_debug_device[6] = "";
67 void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
68 /* machine dependent irq functions */
69 void (*mach_init_IRQ) (void) __initdata = NULL;
70 void (*mach_get_model) (char *model);
71 int (*mach_get_hardware_list) (char *buffer);
72 /* machine dependent timer functions */
73 unsigned long (*mach_gettimeoffset) (void);
74 int (*mach_hwclk) (int, struct rtc_time*);
75 int (*mach_set_clock_mmss) (unsigned long);
76 unsigned int (*mach_get_ss)(void);
77 int (*mach_get_rtc_pll)(struct rtc_pll_info *);
78 int (*mach_set_rtc_pll)(struct rtc_pll_info *);
79 void (*mach_reset)( void );
80 void (*mach_halt)( void );
81 void (*mach_power_off)( void );
82 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
83 #ifdef CONFIG_HEARTBEAT
84 void (*mach_heartbeat) (int);
85 EXPORT_SYMBOL(mach_heartbeat);
87 #ifdef CONFIG_M68K_L2_CACHE
88 void (*mach_l2_flush) (int);
90 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
91 void (*mach_beep)(unsigned int, unsigned int);
93 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
96 EXPORT_SYMBOL(isa_type);
97 EXPORT_SYMBOL(isa_sex);
100 extern int amiga_parse_bootinfo(const struct bi_record *);
101 extern int atari_parse_bootinfo(const struct bi_record *);
102 extern int mac_parse_bootinfo(const struct bi_record *);
103 extern int q40_parse_bootinfo(const struct bi_record *);
104 extern int bvme6000_parse_bootinfo(const struct bi_record *);
105 extern int mvme16x_parse_bootinfo(const struct bi_record *);
106 extern int mvme147_parse_bootinfo(const struct bi_record *);
107 extern int hp300_parse_bootinfo(const struct bi_record *);
109 extern void config_amiga(void);
110 extern void config_atari(void);
111 extern void config_mac(void);
112 extern void config_sun3(void);
113 extern void config_apollo(void);
114 extern void config_mvme147(void);
115 extern void config_mvme16x(void);
116 extern void config_bvme6000(void);
117 extern void config_hp300(void);
118 extern void config_q40(void);
119 extern void config_sun3x(void);
121 extern void mac_debugging_short (int, short);
122 extern void mac_debugging_long (int, long);
124 #define MASK_256K 0xfffc0000
126 extern void paging_init(void);
128 static void __init m68k_parse_bootinfo(const struct bi_record *record)
130 while (record->tag != BI_LAST) {
132 const unsigned long *data = record->data;
133 switch (record->tag) {
138 /* Already set up by head.S */
142 if (m68k_num_memory < NUM_MEMINFO) {
143 m68k_memory[m68k_num_memory].addr = data[0];
144 m68k_memory[m68k_num_memory].size = data[1];
147 printk("m68k_parse_bootinfo: too many memory chunks\n");
151 m68k_ramdisk.addr = data[0];
152 m68k_ramdisk.size = data[1];
155 case BI_COMMAND_LINE:
156 strlcpy(m68k_command_line, (const char *)data, sizeof(m68k_command_line));
161 unknown = amiga_parse_bootinfo(record);
162 else if (MACH_IS_ATARI)
163 unknown = atari_parse_bootinfo(record);
164 else if (MACH_IS_MAC)
165 unknown = mac_parse_bootinfo(record);
166 else if (MACH_IS_Q40)
167 unknown = q40_parse_bootinfo(record);
168 else if (MACH_IS_BVME6000)
169 unknown = bvme6000_parse_bootinfo(record);
170 else if (MACH_IS_MVME16x)
171 unknown = mvme16x_parse_bootinfo(record);
172 else if (MACH_IS_MVME147)
173 unknown = mvme147_parse_bootinfo(record);
174 else if (MACH_IS_HP300)
175 unknown = hp300_parse_bootinfo(record);
180 printk("m68k_parse_bootinfo: unknown tag 0x%04x ignored\n",
182 record = (struct bi_record *)((unsigned long)record+record->size);
185 m68k_realnum_memory = m68k_num_memory;
186 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
187 if (m68k_num_memory > 1) {
188 printk("Ignoring last %i chunks of physical memory\n",
189 (m68k_num_memory - 1));
192 m68k_memoffset = m68k_memory[0].addr-PAGE_OFFSET;
196 void __init setup_arch(char **cmdline_p)
198 extern int _etext, _edata, _end;
200 unsigned long endmem, startmem;
205 /* The bootinfo is located right after the kernel bss */
206 m68k_parse_bootinfo((const struct bi_record *)&_end);
213 /* FIXME: m68k_fputype is passed in by Penguin booter, which can
214 * be confused by software FPU emulation. BEWARE.
215 * We should really do our own FPU check at startup.
216 * [what do we do with buggy 68LC040s? if we have problems
217 * with them, we should add a test to check_bugs() below] */
218 #ifndef CONFIG_M68KFPU_EMU_ONLY
219 /* clear the fpu if we have one */
220 if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
221 volatile int zero = 0;
222 asm __volatile__ ("frestore %0" : : "m" (zero));
229 asm (".chip 68060; movec %%pcr,%0; .chip 68k"
231 if (((pcr >> 8) & 0xff) <= 5) {
232 printk("Enabling workaround for errata I14\n");
233 asm (".chip 68060; movec %0,%%pcr; .chip 68k"
234 : : "d" (pcr | 0x20));
238 init_mm.start_code = PAGE_OFFSET;
239 init_mm.end_code = (unsigned long) &_etext;
240 init_mm.end_data = (unsigned long) &_edata;
241 init_mm.brk = (unsigned long) &_end;
243 *cmdline_p = m68k_command_line;
244 memcpy(saved_command_line, *cmdline_p, CL_SIZE);
246 /* Parse the command line for arch-specific options.
247 * For the m68k, this is currently only "debug=xxx" to enable printing
248 * certain kernel messages to some machine-specific device.
250 for( p = *cmdline_p; p && *p; ) {
252 if (!strncmp( p, "debug=", 6 )) {
253 strlcpy( m68k_debug_device, p+6, sizeof(m68k_debug_device) );
254 if ((q = strchr( m68k_debug_device, ' ' ))) *q = 0;
258 /* This option must be parsed very early */
259 if (!strncmp( p, "switches=", 9 )) {
260 extern void atari_switches_setup( const char *, int );
261 atari_switches_setup( p+9, (q = strchr( p+9, ' ' )) ?
262 (q - (p+9)) : strlen(p+9) );
268 /* option processed, delete it */
269 if ((q = strchr( p, ' ' )))
274 if ((p = strchr( p, ' ' ))) ++p;
278 #ifdef CONFIG_DUMMY_CONSOLE
279 conswitchp = &dummy_con;
282 switch (m68k_machtype) {
308 #ifdef CONFIG_MVME147
313 #ifdef CONFIG_MVME16x
318 #ifdef CONFIG_BVME6000
339 panic ("No configuration setup");
343 startmem= m68k_memory[0].addr;
344 endmem = startmem + m68k_memory[0].size;
345 high_memory = (void *)PAGE_OFFSET;
346 for (i = 0; i < m68k_num_memory; i++) {
347 m68k_memory[i].size &= MASK_256K;
348 if (m68k_memory[i].addr < startmem)
349 startmem = m68k_memory[i].addr;
350 if (m68k_memory[i].addr+m68k_memory[i].size > endmem)
351 endmem = m68k_memory[i].addr+m68k_memory[i].size;
352 high_memory += m68k_memory[i].size;
355 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
356 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
358 for (i = 0; i < m68k_num_memory; i++)
359 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
361 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
363 #ifdef CONFIG_BLK_DEV_INITRD
364 if (m68k_ramdisk.size) {
365 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size);
366 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
367 initrd_end = initrd_start + m68k_ramdisk.size;
368 printk ("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
374 atari_stram_reserve_pages((void *)availmem);
382 #endif /* !CONFIG_SUN3 */
386 /* set ISA defs early as possible */
387 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
388 #if defined(CONFIG_Q40)
393 #elif defined(CONFIG_GG2)
394 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)){
398 #elif defined(CONFIG_AMIGA_PCMCIA)
399 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)){
407 static int show_cpuinfo(struct seq_file *m, void *v)
409 const char *cpu, *mmu, *fpu;
410 unsigned long clockfreq, clockfactor;
412 #define LOOP_CYCLES_68020 (8)
413 #define LOOP_CYCLES_68030 (8)
414 #define LOOP_CYCLES_68040 (3)
415 #define LOOP_CYCLES_68060 (1)
419 clockfactor = LOOP_CYCLES_68020;
420 } else if (CPU_IS_030) {
422 clockfactor = LOOP_CYCLES_68030;
423 } else if (CPU_IS_040) {
425 clockfactor = LOOP_CYCLES_68040;
426 } else if (CPU_IS_060) {
428 clockfactor = LOOP_CYCLES_68060;
434 #ifdef CONFIG_M68KFPU_EMU_ONLY
435 fpu="none(soft float)";
437 if (m68k_fputype & FPU_68881)
439 else if (m68k_fputype & FPU_68882)
441 else if (m68k_fputype & FPU_68040)
443 else if (m68k_fputype & FPU_68060)
445 else if (m68k_fputype & FPU_SUNFPA)
451 if (m68k_mmutype & MMU_68851)
453 else if (m68k_mmutype & MMU_68030)
455 else if (m68k_mmutype & MMU_68040)
457 else if (m68k_mmutype & MMU_68060)
459 else if (m68k_mmutype & MMU_SUN3)
461 else if (m68k_mmutype & MMU_APOLLO)
466 clockfreq = loops_per_jiffy*HZ*clockfactor;
468 seq_printf(m, "CPU:\t\t%s\n"
471 "Clocking:\t%lu.%1luMHz\n"
472 "BogoMips:\t%lu.%02lu\n"
473 "Calibration:\t%lu loops\n",
475 clockfreq/1000000,(clockfreq/100000)%10,
476 loops_per_jiffy/(500000/HZ),(loops_per_jiffy/(5000/HZ))%100,
481 static void *c_start(struct seq_file *m, loff_t *pos)
483 return *pos < 1 ? (void *)1 : NULL;
485 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
490 static void c_stop(struct seq_file *m, void *v)
493 struct seq_operations cpuinfo_op = {
497 .show = show_cpuinfo,
500 int get_hardware_list(char *buffer)
508 mach_get_model(model);
510 strcpy(model, "Unknown m68k");
512 len += sprintf(buffer+len, "Model:\t\t%s\n", model);
513 for (mem = 0, i = 0; i < m68k_num_memory; i++)
514 mem += m68k_memory[i].size;
515 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
517 if (mach_get_hardware_list)
518 len += mach_get_hardware_list(buffer+len);
523 void check_bugs(void)
525 #ifndef CONFIG_M68KFPU_EMU
526 if (m68k_fputype == 0) {
527 printk( KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
528 "WHICH IS REQUIRED BY LINUX/M68K ***\n" );
529 printk( KERN_EMERG "Upgrade your hardware or join the FPU "
530 "emulation project\n" );
533 #endif /* !CONFIG_M68KFPU_EMU */