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