Merge git://oss.sgi.com:8090/oss/git/xfs-2.6
[sfrench/cifs-2.6.git] / arch / ppc / platforms / apus_setup.c
1 /*
2  *  Copyright (C) 1998, 1999  Jesper Skov
3  *
4  *  Basically what is needed to replace functionality found in
5  *  arch/m68k allowing Amiga drivers to work under APUS.
6  *  Bits of code and/or ideas from arch/m68k and arch/ppc files.
7  *
8  * TODO:
9  *  This file needs a *really* good cleanup. Restructure and optimize.
10  *  Make sure it can be compiled for non-APUS configs. Begin to move
11  *  Amiga specific stuff into mach/amiga.
12  */
13
14 #include <linux/config.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/init.h>
18 #include <linux/initrd.h>
19 #include <linux/seq_file.h>
20
21 /* Needs INITSERIAL call in head.S! */
22 #undef APUS_DEBUG
23
24 #include <asm/bootinfo.h>
25 #include <asm/setup.h>
26 #include <asm/amigahw.h>
27 #include <asm/amigaints.h>
28 #include <asm/amigappc.h>
29 #include <asm/pgtable.h>
30 #include <asm/dma.h>
31 #include <asm/machdep.h>
32 #include <asm/time.h>
33
34 unsigned long m68k_machtype;
35 char debug_device[6] = "";
36
37 extern void amiga_init_IRQ(void);
38
39 extern void apus_setup_pci_ptrs(void);
40
41 void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) __initdata = NULL;
42 /* machine dependent irq functions */
43 void (*mach_init_IRQ) (void) __initdata = NULL;
44 void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
45 void (*mach_get_model) (char *model) = NULL;
46 int (*mach_get_hardware_list) (char *buffer) = NULL;
47 int (*mach_get_irq_list) (struct seq_file *, void *) = NULL;
48 void (*mach_process_int) (int, struct pt_regs *) = NULL;
49 /* machine dependent timer functions */
50 unsigned long (*mach_gettimeoffset) (void);
51 void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
52 int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
53 int (*mach_set_clock_mmss) (unsigned long) = NULL;
54 void (*mach_reset)( void );
55 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
56 #ifdef CONFIG_HEARTBEAT
57 void (*mach_heartbeat) (int) = NULL;
58 extern void apus_heartbeat (void);
59 #endif
60
61 extern unsigned long amiga_model;
62 extern unsigned decrementer_count;/* count value for 1e6/HZ microseconds */
63 extern unsigned count_period_num; /* 1 decrementer count equals */
64 extern unsigned count_period_den; /* count_period_num / count_period_den us */
65
66 int num_memory = 0;
67 struct mem_info memory[NUM_MEMINFO];/* memory description */
68 /* FIXME: Duplicate memory data to avoid conflicts with m68k shared code. */
69 int m68k_realnum_memory = 0;
70 struct mem_info m68k_memory[NUM_MEMINFO];/* memory description */
71
72 struct mem_info ramdisk;
73
74 extern void config_amiga(void);
75
76 static int __60nsram = 0;
77
78 /* for cpuinfo */
79 static int __bus_speed = 0;
80 static int __speed_test_failed = 0;
81
82 /********************************************** COMPILE PROTECTION */
83 /* Provide some stubs that links to Amiga specific functions.
84  * This allows CONFIG_APUS to be removed from generic PPC files while
85  * preventing link errors for other PPC targets.
86  */
87 unsigned long apus_get_rtc_time(void)
88 {
89 #ifdef CONFIG_APUS
90         extern unsigned long m68k_get_rtc_time(void);
91
92         return m68k_get_rtc_time ();
93 #else
94         return 0;
95 #endif
96 }
97
98 int apus_set_rtc_time(unsigned long nowtime)
99 {
100 #ifdef CONFIG_APUS
101         extern int m68k_set_rtc_time(unsigned long nowtime);
102
103         return m68k_set_rtc_time (nowtime);
104 #else
105         return 0;
106 #endif
107 }
108
109 /*********************************************************** SETUP */
110 /* From arch/m68k/kernel/setup.c. */
111 void __init apus_setup_arch(void)
112 {
113 #ifdef CONFIG_APUS
114         extern char cmd_line[];
115         int i;
116         char *p, *q;
117
118         /* Let m68k-shared code know it should do the Amiga thing. */
119         m68k_machtype = MACH_AMIGA;
120
121         /* Parse the command line for arch-specific options.
122          * For the m68k, this is currently only "debug=xxx" to enable printing
123          * certain kernel messages to some machine-specific device.  */
124         for( p = cmd_line; p && *p; ) {
125             i = 0;
126             if (!strncmp( p, "debug=", 6 )) {
127                     strlcpy( debug_device, p+6, sizeof(debug_device) );
128                     if ((q = strchr( debug_device, ' ' ))) *q = 0;
129                     i = 1;
130             } else if (!strncmp( p, "60nsram", 7 )) {
131                     APUS_WRITE (APUS_REG_WAITSTATE,
132                                 REGWAITSTATE_SETRESET
133                                 |REGWAITSTATE_PPCR
134                                 |REGWAITSTATE_PPCW);
135                     __60nsram = 1;
136                     i = 1;
137             }
138
139             if (i) {
140                 /* option processed, delete it */
141                 if ((q = strchr( p, ' ' )))
142                     strcpy( p, q+1 );
143                 else
144                     *p = 0;
145             } else {
146                 if ((p = strchr( p, ' ' ))) ++p;
147             }
148         }
149
150         config_amiga();
151
152 #if 0 /* Enable for logging - also include logging.o in Makefile rule */
153         {
154 #define LOG_SIZE 4096
155                 void* base;
156
157                 /* Throw away some memory - the P5 firmare stomps on top
158                  * of CHIP memory during bootup.
159                  */
160                 amiga_chip_alloc(0x1000);
161
162                 base = amiga_chip_alloc(LOG_SIZE+sizeof(klog_data_t));
163                 LOG_INIT(base, base+sizeof(klog_data_t), LOG_SIZE);
164         }
165 #endif
166 #endif
167 }
168
169 int
170 apus_show_cpuinfo(struct seq_file *m)
171 {
172         extern int __map_without_bats;
173         extern unsigned long powerup_PCI_present;
174
175         seq_printf(m, "machine\t\t: Amiga\n");
176         seq_printf(m, "bus speed\t: %d%s", __bus_speed,
177                    (__speed_test_failed) ? " [failed]\n" : "\n");
178         seq_printf(m, "using BATs\t: %s\n",
179                    (__map_without_bats) ? "No" : "Yes");
180         seq_printf(m, "ram speed\t: %dns\n", (__60nsram) ? 60 : 70);
181         seq_printf(m, "PCI bridge\t: %s\n",
182                    (powerup_PCI_present) ? "Yes" : "No");
183         return 0;
184 }
185
186 static void get_current_tb(unsigned long long *time)
187 {
188         __asm __volatile ("1:mftbu 4      \n\t"
189                           "  mftb  5      \n\t"
190                           "  mftbu 6      \n\t"
191                           "  cmpw  4,6    \n\t"
192                           "  bne   1b     \n\t"
193                           "  stw   4,0(%0)\n\t"
194                           "  stw   5,4(%0)\n\t"
195                           :
196                           : "r" (time)
197                           : "r4", "r5", "r6");
198 }
199
200
201 void apus_calibrate_decr(void)
202 {
203 #ifdef CONFIG_APUS
204         unsigned long freq;
205
206         /* This algorithm for determining the bus speed was
207            contributed by Ralph Schmidt. */
208         unsigned long long start, stop;
209         int bus_speed;
210         int speed_test_failed = 0;
211
212         {
213                 unsigned long loop = amiga_eclock / 10;
214
215                 get_current_tb (&start);
216                 while (loop--) {
217                         unsigned char tmp;
218
219                         tmp = ciaa.pra;
220                 }
221                 get_current_tb (&stop);
222         }
223
224         bus_speed = (((unsigned long)(stop-start))*10*4) / 1000000;
225         if (AMI_1200 == amiga_model)
226                 bus_speed /= 2;
227
228         if ((bus_speed >= 47) && (bus_speed < 53)) {
229                 bus_speed = 50;
230                 freq = 12500000;
231         } else if ((bus_speed >= 57) && (bus_speed < 63)) {
232                 bus_speed = 60;
233                 freq = 15000000;
234         } else if ((bus_speed >= 63) && (bus_speed < 69)) {
235                 bus_speed = 67;
236                 freq = 16666667;
237         } else {
238                 printk ("APUS: Unable to determine bus speed (%d). "
239                         "Defaulting to 50MHz", bus_speed);
240                 bus_speed = 50;
241                 freq = 12500000;
242                 speed_test_failed = 1;
243         }
244
245         /* Ease diagnostics... */
246         {
247                 extern int __map_without_bats;
248                 extern unsigned long powerup_PCI_present;
249
250                 printk ("APUS: BATs=%d, BUS=%dMHz",
251                         (__map_without_bats) ? 0 : 1,
252                         bus_speed);
253                 if (speed_test_failed)
254                         printk ("[FAILED - please report]");
255
256                 printk (", RAM=%dns, PCI bridge=%d\n",
257                         (__60nsram) ? 60 : 70,
258                         (powerup_PCI_present) ? 1 : 0);
259
260                 /* print a bit more if asked politely... */
261                 if (!(ciaa.pra & 0x40)){
262                         extern unsigned int bat_addrs[4][3];
263                         int b;
264                         for (b = 0; b < 4; ++b) {
265                                 printk ("APUS: BAT%d ", b);
266                                 printk ("%08x-%08x -> %08x\n",
267                                         bat_addrs[b][0],
268                                         bat_addrs[b][1],
269                                         bat_addrs[b][2]);
270                         }
271                 }
272
273         }
274
275         printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
276                freq/1000000, freq%1000000);
277         tb_ticks_per_jiffy = freq / HZ;
278         tb_to_us = mulhwu_scale_factor(freq, 1000000);
279
280         __bus_speed = bus_speed;
281         __speed_test_failed = speed_test_failed;
282 #endif
283 }
284
285 void arch_gettod(int *year, int *mon, int *day, int *hour,
286                  int *min, int *sec)
287 {
288 #ifdef CONFIG_APUS
289         if (mach_gettod)
290                 mach_gettod(year, mon, day, hour, min, sec);
291         else
292                 *year = *mon = *day = *hour = *min = *sec = 0;
293 #endif
294 }
295
296 /* for "kbd-reset" cmdline param */
297 __init
298 void kbd_reset_setup(char *str, int *ints)
299 {
300 }
301
302 /*********************************************************** MEMORY */
303 #define KMAP_MAX 32
304 unsigned long kmap_chunks[KMAP_MAX*3];
305 int kmap_chunk_count = 0;
306
307 /* From pgtable.h */
308 static __inline__ pte_t *my_find_pte(struct mm_struct *mm,unsigned long va)
309 {
310         pgd_t *dir = 0;
311         pmd_t *pmd = 0;
312         pte_t *pte = 0;
313
314         va &= PAGE_MASK;
315
316         dir = pgd_offset( mm, va );
317         if (dir)
318         {
319                 pmd = pmd_offset(dir, va & PAGE_MASK);
320                 if (pmd && pmd_present(*pmd))
321                 {
322                         pte = pte_offset(pmd, va);
323                 }
324         }
325         return pte;
326 }
327
328
329 /* Again simulating an m68k/mm/kmap.c function. */
330 void kernel_set_cachemode( unsigned long address, unsigned long size,
331                            unsigned int cmode )
332 {
333         unsigned long mask, flags;
334
335         switch (cmode)
336         {
337         case IOMAP_FULL_CACHING:
338                 mask = ~(_PAGE_NO_CACHE | _PAGE_GUARDED);
339                 flags = 0;
340                 break;
341         case IOMAP_NOCACHE_SER:
342                 mask = ~0;
343                 flags = (_PAGE_NO_CACHE | _PAGE_GUARDED);
344                 break;
345         default:
346                 panic ("kernel_set_cachemode() doesn't support mode %d\n",
347                        cmode);
348                 break;
349         }
350
351         size /= PAGE_SIZE;
352         address &= PAGE_MASK;
353         while (size--)
354         {
355                 pte_t *pte;
356
357                 pte = my_find_pte(&init_mm, address);
358                 if ( !pte )
359                 {
360                         printk("pte NULL in kernel_set_cachemode()\n");
361                         return;
362                 }
363
364                 pte_val (*pte) &= mask;
365                 pte_val (*pte) |= flags;
366                 flush_tlb_page(find_vma(&init_mm,address),address);
367
368                 address += PAGE_SIZE;
369         }
370 }
371
372 unsigned long mm_ptov (unsigned long paddr)
373 {
374         unsigned long ret;
375         if (paddr < 16*1024*1024)
376                 ret = ZTWO_VADDR(paddr);
377         else {
378                 int i;
379
380                 for (i = 0; i < kmap_chunk_count;){
381                         unsigned long phys = kmap_chunks[i++];
382                         unsigned long size = kmap_chunks[i++];
383                         unsigned long virt = kmap_chunks[i++];
384                         if (paddr >= phys
385                             && paddr < (phys + size)){
386                                 ret = virt + paddr - phys;
387                                 goto exit;
388                         }
389                 }
390
391                 ret = (unsigned long) __va(paddr);
392         }
393 exit:
394 #ifdef DEBUGPV
395         printk ("PTOV(%lx)=%lx\n", paddr, ret);
396 #endif
397         return ret;
398 }
399
400 int mm_end_of_chunk (unsigned long addr, int len)
401 {
402         if (memory[0].addr + memory[0].size == addr + len)
403                 return 1;
404         return 0;
405 }
406
407 /*********************************************************** CACHE */
408
409 #define L1_CACHE_BYTES 32
410 #define MAX_CACHE_SIZE 8192
411 void cache_push(__u32 addr, int length)
412 {
413         addr = mm_ptov(addr);
414
415         if (MAX_CACHE_SIZE < length)
416                 length = MAX_CACHE_SIZE;
417
418         while(length > 0){
419                 __asm ("dcbf 0,%0\n\t"
420                        : : "r" (addr));
421                 addr += L1_CACHE_BYTES;
422                 length -= L1_CACHE_BYTES;
423         }
424         /* Also flush trailing block */
425         __asm ("dcbf 0,%0\n\t"
426                "sync \n\t"
427                : : "r" (addr));
428 }
429
430 void cache_clear(__u32 addr, int length)
431 {
432         if (MAX_CACHE_SIZE < length)
433                 length = MAX_CACHE_SIZE;
434
435         addr = mm_ptov(addr);
436
437         __asm ("dcbf 0,%0\n\t"
438                "sync \n\t"
439                "icbi 0,%0 \n\t"
440                "isync \n\t"
441                : : "r" (addr));
442
443         addr += L1_CACHE_BYTES;
444         length -= L1_CACHE_BYTES;
445
446         while(length > 0){
447                 __asm ("dcbf 0,%0\n\t"
448                        "sync \n\t"
449                        "icbi 0,%0 \n\t"
450                        "isync \n\t"
451                        : : "r" (addr));
452                 addr += L1_CACHE_BYTES;
453                 length -= L1_CACHE_BYTES;
454         }
455
456         __asm ("dcbf 0,%0\n\t"
457                "sync \n\t"
458                "icbi 0,%0 \n\t"
459                "isync \n\t"
460                : : "r" (addr));
461 }
462
463 /****************************************************** from setup.c */
464 void
465 apus_restart(char *cmd)
466 {
467         local_irq_disable();
468
469         APUS_WRITE(APUS_REG_LOCK,
470                    REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2);
471         APUS_WRITE(APUS_REG_LOCK,
472                    REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK3);
473         APUS_WRITE(APUS_REG_LOCK,
474                    REGLOCK_BLACKMAGICK2|REGLOCK_BLACKMAGICK3);
475         APUS_WRITE(APUS_REG_SHADOW, REGSHADOW_SELFRESET);
476         APUS_WRITE(APUS_REG_RESET, REGRESET_AMIGARESET);
477         for(;;);
478 }
479
480 void
481 apus_power_off(void)
482 {
483         for (;;);
484 }
485
486 void
487 apus_halt(void)
488 {
489    apus_restart(NULL);
490 }
491
492 /****************************************************** IRQ stuff */
493
494 static unsigned char last_ipl[8];
495
496 int apus_get_irq(struct pt_regs* regs)
497 {
498         unsigned char ipl_emu, mask;
499         unsigned int level;
500
501         APUS_READ(APUS_IPL_EMU, ipl_emu);
502         level = (ipl_emu >> 3) & IPLEMU_IPLMASK;
503         mask = IPLEMU_SETRESET|IPLEMU_DISABLEINT|level;
504         level ^= 7;
505
506         /* Save previous IPL value */
507         if (last_ipl[level])
508                 return -2;
509         last_ipl[level] = ipl_emu;
510
511         /* Set to current IPL value */
512         APUS_WRITE(APUS_IPL_EMU, mask);
513         APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT|level);
514
515
516 #ifdef __INTERRUPT_DEBUG
517         printk("<%d:%d>", level, ~ipl_emu & IPLEMU_IPLMASK);
518 #endif
519         return level + IRQ_AMIGA_AUTO;
520 }
521
522 void apus_end_irq(unsigned int irq)
523 {
524         unsigned char ipl_emu;
525         unsigned int level = irq - IRQ_AMIGA_AUTO;
526 #ifdef __INTERRUPT_DEBUG
527         printk("{%d}", ~last_ipl[level] & IPLEMU_IPLMASK);
528 #endif
529         /* Restore IPL to the previous value */
530         ipl_emu = last_ipl[level] & IPLEMU_IPLMASK;
531         APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET|IPLEMU_DISABLEINT|ipl_emu);
532         last_ipl[level] = 0;
533         ipl_emu ^= 7;
534         APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT|ipl_emu);
535 }
536
537 /****************************************************** debugging */
538
539 /* some serial hardware definitions */
540 #define SDR_OVRUN   (1<<15)
541 #define SDR_RBF     (1<<14)
542 #define SDR_TBE     (1<<13)
543 #define SDR_TSRE    (1<<12)
544
545 #define AC_SETCLR   (1<<15)
546 #define AC_UARTBRK  (1<<11)
547
548 #define SER_DTR     (1<<7)
549 #define SER_RTS     (1<<6)
550 #define SER_DCD     (1<<5)
551 #define SER_CTS     (1<<4)
552 #define SER_DSR     (1<<3)
553
554 static __inline__ void ser_RTSon(void)
555 {
556     ciab.pra &= ~SER_RTS; /* active low */
557 }
558
559 int __debug_ser_out( unsigned char c )
560 {
561         amiga_custom.serdat = c | 0x100;
562         mb();
563         while (!(amiga_custom.serdatr & 0x2000))
564                 barrier();
565         return 1;
566 }
567
568 unsigned char __debug_ser_in( void )
569 {
570         unsigned char c;
571
572         /* XXX: is that ok?? derived from amiga_ser.c... */
573         while( !(amiga_custom.intreqr & IF_RBF) )
574                 barrier();
575         c = amiga_custom.serdatr;
576         /* clear the interrupt, so that another character can be read */
577         amiga_custom.intreq = IF_RBF;
578         return c;
579 }
580
581 int __debug_serinit( void )
582 {
583         unsigned long flags;
584
585         local_irq_save(flags);
586
587         /* turn off Rx and Tx interrupts */
588         amiga_custom.intena = IF_RBF | IF_TBE;
589
590         /* clear any pending interrupt */
591         amiga_custom.intreq = IF_RBF | IF_TBE;
592
593         local_irq_restore(flags);
594
595         /*
596          * set the appropriate directions for the modem control flags,
597          * and clear RTS and DTR
598          */
599         ciab.ddra |= (SER_DTR | SER_RTS);   /* outputs */
600         ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR);  /* inputs */
601
602 #ifdef CONFIG_KGDB
603         /* turn Rx interrupts on for GDB */
604         amiga_custom.intena = IF_SETCLR | IF_RBF;
605         ser_RTSon();
606 #endif
607
608         return 0;
609 }
610
611 void __debug_print_hex(unsigned long x)
612 {
613         int i;
614         char hexchars[] = "0123456789ABCDEF";
615
616         for (i = 0; i < 8; i++) {
617                 __debug_ser_out(hexchars[(x >> 28) & 15]);
618                 x <<= 4;
619         }
620         __debug_ser_out('\n');
621         __debug_ser_out('\r');
622 }
623
624 void __debug_print_string(char* s)
625 {
626         unsigned char c;
627         while((c = *s++))
628                 __debug_ser_out(c);
629         __debug_ser_out('\n');
630         __debug_ser_out('\r');
631 }
632
633 static void apus_progress(char *s, unsigned short value)
634 {
635         __debug_print_string(s);
636 }
637
638 /****************************************************** init */
639
640 /* The number of spurious interrupts */
641 volatile unsigned int num_spurious;
642
643 extern struct irqaction amiga_sys_irqaction[AUTO_IRQS];
644
645
646 extern void amiga_enable_irq(unsigned int irq);
647 extern void amiga_disable_irq(unsigned int irq);
648
649 struct hw_interrupt_type amiga_sys_irqctrl = {
650         .typename = "Amiga IPL",
651         .end = apus_end_irq,
652 };
653
654 struct hw_interrupt_type amiga_irqctrl = {
655         .typename = "Amiga    ",
656         .enable = amiga_enable_irq,
657         .disable = amiga_disable_irq,
658 };
659
660 #define HARDWARE_MAPPED_SIZE (512*1024)
661 unsigned long __init apus_find_end_of_memory(void)
662 {
663         int shadow = 0;
664         unsigned long total;
665
666         /* The memory size reported by ADOS excludes the 512KB
667            reserved for PPC exception registers and possibly 512KB
668            containing a shadow of the ADOS ROM. */
669         {
670                 unsigned long size = memory[0].size;
671
672                 /* If 2MB aligned, size was probably user
673                    specified. We can't tell anything about shadowing
674                    in this case so skip shadow assignment. */
675                 if (0 != (size & 0x1fffff)){
676                         /* Align to 512KB to ensure correct handling
677                            of both memfile and system specified
678                            sizes. */
679                         size = ((size+0x0007ffff) & 0xfff80000);
680                         /* If memory is 1MB aligned, assume
681                            shadowing. */
682                         shadow = !(size & 0x80000);
683                 }
684
685                 /* Add the chunk that ADOS does not see. by aligning
686                    the size to the nearest 2MB limit upwards.  */
687                 memory[0].size = ((size+0x001fffff) & 0xffe00000);
688         }
689
690         ppc_memstart = memory[0].addr;
691         ppc_memoffset = PAGE_OFFSET - PPC_MEMSTART;
692         total = memory[0].size;
693
694         /* Remove the memory chunks that are controlled by special
695            Phase5 hardware. */
696
697         /* Remove the upper 512KB if it contains a shadow of
698            the ADOS ROM. FIXME: It might be possible to
699            disable this shadow HW. Check the booter
700            (ppc_boot.c) */
701         if (shadow)
702                 total -= HARDWARE_MAPPED_SIZE;
703
704         /* Remove the upper 512KB where the PPC exception
705            vectors are mapped. */
706         total -= HARDWARE_MAPPED_SIZE;
707
708         /* Linux/APUS only handles one block of memory -- the one on
709            the PowerUP board. Other system memory is horrible slow in
710            comparison. The user can use other memory for swapping
711            using the z2ram device. */
712         return total;
713 }
714
715 static void __init
716 apus_map_io(void)
717 {
718         /* Map PPC exception vectors. */
719         io_block_mapping(0xfff00000, 0xfff00000, 0x00020000, _PAGE_KERNEL);
720         /* Map chip and ZorroII memory */
721         io_block_mapping(zTwoBase,   0x00000000, 0x01000000, _PAGE_IO);
722 }
723
724 __init
725 void apus_init_IRQ(void)
726 {
727         struct irqaction *action;
728         int i;
729
730 #ifdef CONFIG_PCI
731         apus_setup_pci_ptrs();
732 #endif
733
734         for ( i = 0 ; i < AMI_IRQS; i++ ) {
735                 irq_desc[i].status = IRQ_LEVEL;
736                 if (i < IRQ_AMIGA_AUTO) {
737                         irq_desc[i].handler = &amiga_irqctrl;
738                 } else {
739                         irq_desc[i].handler = &amiga_sys_irqctrl;
740                         action = &amiga_sys_irqaction[i-IRQ_AMIGA_AUTO];
741                         if (action->name)
742                                 setup_irq(i, action);
743                 }
744         }
745
746         amiga_init_IRQ();
747
748 }
749
750 __init
751 void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
752                    unsigned long r6, unsigned long r7)
753 {
754         extern int parse_bootinfo(const struct bi_record *);
755         extern char _end[];
756
757         /* Parse bootinfo. The bootinfo is located right after
758            the kernel bss */
759         parse_bootinfo((const struct bi_record *)&_end);
760 #ifdef CONFIG_BLK_DEV_INITRD
761         /* Take care of initrd if we have one. Use data from
762            bootinfo to avoid the need to initialize PPC
763            registers when kernel is booted via a PPC reset. */
764         if ( ramdisk.addr ) {
765                 initrd_start = (unsigned long) __va(ramdisk.addr);
766                 initrd_end = (unsigned long)
767                         __va(ramdisk.size + ramdisk.addr);
768         }
769 #endif /* CONFIG_BLK_DEV_INITRD */
770
771         ISA_DMA_THRESHOLD = 0x00ffffff;
772
773         ppc_md.setup_arch     = apus_setup_arch;
774         ppc_md.show_cpuinfo   = apus_show_cpuinfo;
775         ppc_md.init_IRQ       = apus_init_IRQ;
776         ppc_md.get_irq        = apus_get_irq;
777
778 #ifdef CONFIG_HEARTBEAT
779         ppc_md.heartbeat      = apus_heartbeat;
780         ppc_md.heartbeat_count = 1;
781 #endif
782 #ifdef APUS_DEBUG
783         __debug_serinit();
784         ppc_md.progress       = apus_progress;
785 #endif
786         ppc_md.init           = NULL;
787
788         ppc_md.restart        = apus_restart;
789         ppc_md.power_off      = apus_power_off;
790         ppc_md.halt           = apus_halt;
791
792         ppc_md.time_init      = NULL;
793         ppc_md.set_rtc_time   = apus_set_rtc_time;
794         ppc_md.get_rtc_time   = apus_get_rtc_time;
795         ppc_md.calibrate_decr = apus_calibrate_decr;
796
797         ppc_md.find_end_of_memory = apus_find_end_of_memory;
798         ppc_md.setup_io_mappings = apus_map_io;
799 }