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