[PATCH] ppc32: Add VIA IDE support to MPC8555 CDS platform
[safe/jmp/linux-2.6] / arch / ppc / platforms / 85xx / mpc85xx_cds_common.c
1 /*
2  * arch/ppc/platform/85xx/mpc85xx_cds_common.c
3  *
4  * MPC85xx CDS board specific routines
5  *
6  * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7  *
8  * Copyright 2004 Freescale Semiconductor, Inc
9  *
10  * This program is free software; you can redistribute  it and/or modify it
11  * under  the terms of  the GNU General  Public License as published by the
12  * Free Software Foundation;  either version 2 of the  License, or (at your
13  * option) any later version.
14  */
15
16 #include <linux/config.h>
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/errno.h>
21 #include <linux/reboot.h>
22 #include <linux/pci.h>
23 #include <linux/kdev_t.h>
24 #include <linux/major.h>
25 #include <linux/console.h>
26 #include <linux/delay.h>
27 #include <linux/irq.h>
28 #include <linux/seq_file.h>
29 #include <linux/serial.h>
30 #include <linux/module.h>
31 #include <linux/root_dev.h>
32 #include <linux/initrd.h>
33 #include <linux/tty.h>
34 #include <linux/serial_core.h>
35 #include <linux/fsl_devices.h>
36
37 #include <asm/system.h>
38 #include <asm/pgtable.h>
39 #include <asm/page.h>
40 #include <asm/atomic.h>
41 #include <asm/time.h>
42 #include <asm/todc.h>
43 #include <asm/io.h>
44 #include <asm/machdep.h>
45 #include <asm/prom.h>
46 #include <asm/open_pic.h>
47 #include <asm/i8259.h>
48 #include <asm/bootinfo.h>
49 #include <asm/pci-bridge.h>
50 #include <asm/mpc85xx.h>
51 #include <asm/irq.h>
52 #include <asm/immap_85xx.h>
53 #include <asm/immap_cpm2.h>
54 #include <asm/ppc_sys.h>
55 #include <asm/kgdb.h>
56
57 #include <mm/mmu_decl.h>
58 #include <syslib/cpm2_pic.h>
59 #include <syslib/ppc85xx_common.h>
60 #include <syslib/ppc85xx_setup.h>
61
62
63 #ifndef CONFIG_PCI
64 unsigned long isa_io_base = 0;
65 unsigned long isa_mem_base = 0;
66 #endif
67
68 extern unsigned long total_memory;      /* in mm/init */
69
70 unsigned char __res[sizeof (bd_t)];
71
72 static int cds_pci_slot = 2;
73 static volatile u8 * cadmus;
74
75 /* Internal interrupts are all Level Sensitive, and Positive Polarity */
76
77 static u_char mpc85xx_cds_openpic_initsenses[] __initdata = {
78         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  0: L2 Cache */
79         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  1: ECM */
80         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  2: DDR DRAM */
81         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  3: LBIU */
82         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  4: DMA 0 */
83         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  5: DMA 1 */
84         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  6: DMA 2 */
85         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  7: DMA 3 */
86         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  8: PCI/PCI-X */
87         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal  9: RIO Inbound Port Write Error */
88         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 10: RIO Doorbell Inbound */
89         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 11: RIO Outbound Message */
90         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 12: RIO Inbound Message */
91         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 13: TSEC 0 Transmit */
92         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 14: TSEC 0 Receive */
93         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 15: Unused */
94         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 16: Unused */
95         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 17: Unused */
96         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 18: TSEC 0 Receive/Transmit Error */
97         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 19: TSEC 1 Transmit */
98         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 20: TSEC 1 Receive */
99         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 21: Unused */
100         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 22: Unused */
101         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 23: Unused */
102         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 24: TSEC 1 Receive/Transmit Error */
103         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 25: Fast Ethernet */
104         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 26: DUART */
105         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 27: I2C */
106         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 28: Performance Monitor */
107         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 29: Unused */
108         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 30: CPM */
109         (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* Internal 31: Unused */
110 #if defined(CONFIG_PCI)
111         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 0: PCI1 slot */
112         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 1: PCI1 slot */
113         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 2: PCI1 slot */
114         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 3: PCI1 slot */
115 #else
116         0x0,                                            /* External  0: */
117         0x0,                                            /* External  1: */
118         0x0,                                            /* External  2: */
119         0x0,                                            /* External  3: */
120 #endif
121         0x0,                                            /* External  4: */
122         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External  5: PHY */
123         0x0,                                            /* External  6: */
124         0x0,                                            /* External  7: */
125         0x0,                                            /* External  8: */
126         0x0,                                            /* External  9: */
127         0x0,                                            /* External 10: */
128 #if defined(CONFIG_85xx_PCI2) && defined(CONFIG_PCI)
129         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 11: PCI2 slot 0 */
130 #else
131         0x0,                                            /* External 11: */
132 #endif
133 };
134
135 /* ************************************************************************ */
136 int
137 mpc85xx_cds_show_cpuinfo(struct seq_file *m)
138 {
139         uint pvid, svid, phid1;
140         uint memsize = total_memory;
141         bd_t *binfo = (bd_t *) __res;
142         unsigned int freq;
143
144         /* get the core frequency */
145         freq = binfo->bi_intfreq;
146
147         pvid = mfspr(SPRN_PVR);
148         svid = mfspr(SPRN_SVR);
149
150         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
151         seq_printf(m, "Machine\t\t: CDS - MPC%s (%x)\n", cur_ppc_sys_spec->ppc_sys_name, cadmus[CM_VER]);
152         seq_printf(m, "clock\t\t: %dMHz\n", freq / 1000000);
153         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
154         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
155
156         /* Display cpu Pll setting */
157         phid1 = mfspr(SPRN_HID1);
158         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
159
160         /* Display the amount of memory */
161         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
162
163         return 0;
164 }
165
166 #ifdef CONFIG_CPM2
167 static void cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
168 {
169         while((irq = cpm2_get_irq(regs)) >= 0)
170                 __do_IRQ(irq, regs);
171 }
172
173 static struct irqaction cpm2_irqaction = {
174         .handler = cpm2_cascade,
175         .flags = SA_INTERRUPT,
176         .mask = CPU_MASK_NONE,
177         .name = "cpm2_cascade",
178 };
179 #endif /* CONFIG_CPM2 */
180
181 void __init
182 mpc85xx_cds_init_IRQ(void)
183 {
184         bd_t *binfo = (bd_t *) __res;
185         int i;
186
187         /* Determine the Physical Address of the OpenPIC regs */
188         phys_addr_t OpenPIC_PAddr = binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET;
189         OpenPIC_Addr = ioremap(OpenPIC_PAddr, MPC85xx_OPENPIC_SIZE);
190         OpenPIC_InitSenses = mpc85xx_cds_openpic_initsenses;
191         OpenPIC_NumInitSenses = sizeof (mpc85xx_cds_openpic_initsenses);
192
193         /* Skip reserved space and internal sources */
194         openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
195         /* Map PIC IRQs 0-11 */
196         openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000);
197
198         /* we let openpic interrupts starting from an offset, to
199          * leave space for cascading interrupts underneath.
200          */
201         openpic_init(MPC85xx_OPENPIC_IRQ_OFFSET);
202
203         openpic_hookup_cascade(PIRQ0A, "82c59 cascade", i8259_irq);
204
205         for (i = 0; i < NUM_8259_INTERRUPTS; i++)
206                 irq_desc[i].handler = &i8259_pic;
207
208         i8259_init(0);
209
210 #ifdef CONFIG_CPM2
211         /* Setup CPM2 PIC */
212         cpm2_init_IRQ();
213
214         setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
215 #endif
216
217         return;
218 }
219
220 #ifdef CONFIG_PCI
221 /*
222  * interrupt routing
223  */
224 int
225 mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
226 {
227         struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
228
229         if (!hose->index)
230         {
231                 /* Handle PCI1 interrupts */
232                 char pci_irq_table[][4] =
233                         /*
234                          *      PCI IDSEL/INTPIN->INTLINE
235                          *        A      B      C      D
236                          */
237
238                         /* Note IRQ assignment for slots is based on which slot the elysium is
239                          * in -- in this setup elysium is in slot #2 (this PIRQA as first
240                          * interrupt on slot */
241                 {
242                         { 0, 1, 2, 3 }, /* 16 - PMC */
243                         { 0, 1, 2, 3 }, /* 17 P2P (Tsi320) */
244                         { 0, 1, 2, 3 }, /* 18 - Slot 1 */
245                         { 1, 2, 3, 0 }, /* 19 - Slot 2 */
246                         { 2, 3, 0, 1 }, /* 20 - Slot 3 */
247                         { 3, 0, 1, 2 }, /* 21 - Slot 4 */
248                 };
249
250                 const long min_idsel = 16, max_idsel = 21, irqs_per_slot = 4;
251                 int i, j;
252
253                 for (i = 0; i < 6; i++)
254                         for (j = 0; j < 4; j++)
255                                 pci_irq_table[i][j] =
256                                         ((pci_irq_table[i][j] + 5 -
257                                           cds_pci_slot) & 0x3) + PIRQ0A;
258
259                 return PCI_IRQ_TABLE_LOOKUP;
260         } else {
261                 /* Handle PCI2 interrupts (if we have one) */
262                 char pci_irq_table[][4] =
263                 {
264                         /*
265                          * We only have one slot and one interrupt
266                          * going to PIRQA - PIRQD */
267                         { PIRQ1A, PIRQ1A, PIRQ1A, PIRQ1A }, /* 21 - slot 0 */
268                 };
269
270                 const long min_idsel = 21, max_idsel = 21, irqs_per_slot = 4;
271
272                 return PCI_IRQ_TABLE_LOOKUP;
273         }
274 }
275
276 #define ARCADIA_HOST_BRIDGE_IDSEL       17
277 #define ARCADIA_2ND_BRIDGE_IDSEL        3
278
279 extern int mpc85xx_pci1_last_busno;
280
281 int
282 mpc85xx_exclude_device(u_char bus, u_char devfn)
283 {
284         if (bus == 0 && PCI_SLOT(devfn) == 0)
285                 return PCIBIOS_DEVICE_NOT_FOUND;
286 #ifdef CONFIG_85xx_PCI2
287         if (mpc85xx_pci1_last_busno)
288                 if (bus == (mpc85xx_pci1_last_busno + 1) && PCI_SLOT(devfn) == 0)
289                         return PCIBIOS_DEVICE_NOT_FOUND;
290 #endif
291         /* We explicitly do not go past the Tundra 320 Bridge */
292         if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
293                 return PCIBIOS_DEVICE_NOT_FOUND;
294         if ((bus == 0) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
295                 return PCIBIOS_DEVICE_NOT_FOUND;
296         else
297                 return PCIBIOS_SUCCESSFUL;
298 }
299
300 void __init
301 mpc85xx_cds_enable_via(struct pci_controller *hose)
302 {
303         u32 pci_class;
304         u16 vid, did;
305
306         early_read_config_dword(hose, 0, 0x88, PCI_CLASS_REVISION, &pci_class);
307         if ((pci_class >> 16) != PCI_CLASS_BRIDGE_PCI)
308                 return;
309
310         /* Configure P2P so that we can reach bus 1 */
311         early_write_config_byte(hose, 0, 0x88, PCI_PRIMARY_BUS, 0);
312         early_write_config_byte(hose, 0, 0x88, PCI_SECONDARY_BUS, 1);
313         early_write_config_byte(hose, 0, 0x88, PCI_SUBORDINATE_BUS, 0xff);
314
315         early_read_config_word(hose, 1, 0x10, PCI_VENDOR_ID, &vid);
316         early_read_config_word(hose, 1, 0x10, PCI_DEVICE_ID, &did);
317
318         if ((vid != PCI_VENDOR_ID_VIA) ||
319                         (did != PCI_DEVICE_ID_VIA_82C686))
320                 return;
321
322         /* Enable USB and IDE functions */
323         early_write_config_byte(hose, 1, 0x10, 0x48, 0x08);
324 }
325
326 void __init
327 mpc85xx_cds_fixup_via(struct pci_controller *hose)
328 {
329         u32 pci_class;
330         u16 vid, did;
331
332         early_read_config_dword(hose, 0, 0x88, PCI_CLASS_REVISION, &pci_class);
333         if ((pci_class >> 16) != PCI_CLASS_BRIDGE_PCI)
334                 return;
335
336         /*
337          * Force the backplane P2P bridge to have a window
338          * open from 0x00000000-0x00001fff in PCI I/O space.
339          * This allows legacy I/O (i8259, etc) on the VIA
340          * southbridge to be accessed.
341          */
342         early_write_config_byte(hose, 0, 0x88, PCI_IO_BASE, 0x00);
343         early_write_config_word(hose, 0, 0x88, PCI_IO_BASE_UPPER16, 0x0000);
344         early_write_config_byte(hose, 0, 0x88, PCI_IO_LIMIT, 0x10);
345         early_write_config_word(hose, 0, 0x88, PCI_IO_LIMIT_UPPER16, 0x0000);
346
347         early_read_config_word(hose, 1, 0x10, PCI_VENDOR_ID, &vid);
348         early_read_config_word(hose, 1, 0x10, PCI_DEVICE_ID, &did);
349         if ((vid != PCI_VENDOR_ID_VIA) ||
350                         (did != PCI_DEVICE_ID_VIA_82C686))
351                 return;
352
353         /*
354          * Since the P2P window was forced to cover the fixed
355          * legacy I/O addresses, it is necessary to manually
356          * place the base addresses for the IDE and USB functions
357          * within this window.
358          */
359         /* Function 1, IDE */
360         early_write_config_dword(hose, 1, 0x11, PCI_BASE_ADDRESS_0, 0x1ff8);
361         early_write_config_dword(hose, 1, 0x11, PCI_BASE_ADDRESS_1, 0x1ff4);
362         early_write_config_dword(hose, 1, 0x11, PCI_BASE_ADDRESS_2, 0x1fe8);
363         early_write_config_dword(hose, 1, 0x11, PCI_BASE_ADDRESS_3, 0x1fe4);
364         early_write_config_dword(hose, 1, 0x11, PCI_BASE_ADDRESS_4, 0x1fd0);
365
366         /* Function 2, USB ports 0-1 */
367         early_write_config_dword(hose, 1, 0x12, PCI_BASE_ADDRESS_4, 0x1fa0);
368
369         /* Function 3, USB ports 2-3 */
370         early_write_config_dword(hose, 1, 0x13, PCI_BASE_ADDRESS_4, 0x1f80);
371
372         /* Function 5, Power Management */
373         early_write_config_dword(hose, 1, 0x15, PCI_BASE_ADDRESS_0, 0x1e00);
374         early_write_config_dword(hose, 1, 0x15, PCI_BASE_ADDRESS_1, 0x1dfc);
375         early_write_config_dword(hose, 1, 0x15, PCI_BASE_ADDRESS_2, 0x1df8);
376
377         /* Function 6, AC97 Interface */
378         early_write_config_dword(hose, 1, 0x16, PCI_BASE_ADDRESS_0, 0x1c00);
379 }
380
381 void __init
382 mpc85xx_cds_pcibios_fixup(void)
383 {
384         struct pci_dev *dev = NULL;
385         u_char          c;
386
387         if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
388                                         PCI_DEVICE_ID_VIA_82C586_1, NULL))) {
389                 /*
390                  * U-Boot does not set the enable bits
391                  * for the IDE device. Force them on here.
392                  */
393                 pci_read_config_byte(dev, 0x40, &c);
394                 c |= 0x03; /* IDE: Chip Enable Bits */
395                 pci_write_config_byte(dev, 0x40, c);
396
397                 /*
398                  * Since only primary interface works, force the
399                  * IDE function to standard primary IDE interrupt
400                  * w/ 8259 offset
401                  */
402                 dev->irq = 14;
403                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
404         }
405
406         /*
407          * Force legacy USB interrupt routing
408          */
409         if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
410                                         PCI_DEVICE_ID_VIA_82C586_2, NULL))) {
411                 dev->irq = 10;
412                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10);
413         }
414
415         if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
416                                         PCI_DEVICE_ID_VIA_82C586_2, dev))) {
417                 dev->irq = 11;
418                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
419         }
420 }
421 #endif /* CONFIG_PCI */
422
423 TODC_ALLOC();
424
425 /* ************************************************************************
426  *
427  * Setup the architecture
428  *
429  */
430 static void __init
431 mpc85xx_cds_setup_arch(void)
432 {
433         bd_t *binfo = (bd_t *) __res;
434         unsigned int freq;
435         struct gianfar_platform_data *pdata;
436
437         /* get the core frequency */
438         freq = binfo->bi_intfreq;
439
440         printk("mpc85xx_cds_setup_arch\n");
441
442         /* VIA IDE configuration */
443         ppc_md.pcibios_fixup = mpc85xx_cds_pcibios_fixup;
444
445 #ifdef CONFIG_CPM2
446         cpm2_reset();
447 #endif
448
449         cadmus = ioremap(CADMUS_BASE, CADMUS_SIZE);
450         cds_pci_slot = ((cadmus[CM_CSR] >> 6) & 0x3) + 1;
451         printk("CDS Version = %x in PCI slot %d\n", cadmus[CM_VER], cds_pci_slot);
452
453         /* Setup TODC access */
454         TODC_INIT(TODC_TYPE_DS1743,
455                         0,
456                         0,
457                         ioremap(CDS_RTC_ADDR, CDS_RTC_SIZE),
458                         8);
459
460         /* Set loops_per_jiffy to a half-way reasonable value,
461            for use until calibrate_delay gets called. */
462         loops_per_jiffy = freq / HZ;
463
464 #ifdef CONFIG_PCI
465         /* setup PCI host bridges */
466         mpc85xx_setup_hose();
467 #endif
468
469 #ifdef CONFIG_SERIAL_8250
470         mpc85xx_early_serial_map();
471 #endif
472
473 #ifdef CONFIG_SERIAL_TEXT_DEBUG
474         /* Invalidate the entry we stole earlier the serial ports
475          * should be properly mapped */
476         invalidate_tlbcam_entry(NUM_TLBCAMS - 1);
477 #endif
478
479         /* setup the board related information for the enet controllers */
480         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
481         pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
482         pdata->interruptPHY = MPC85xx_IRQ_EXT5;
483         pdata->phyid = 0;
484         /* fixup phy address */
485         pdata->phy_reg_addr += binfo->bi_immr_base;
486         memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
487
488         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
489         pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
490         pdata->interruptPHY = MPC85xx_IRQ_EXT5;
491         pdata->phyid = 1;
492         /* fixup phy address */
493         pdata->phy_reg_addr += binfo->bi_immr_base;
494         memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
495
496
497 #ifdef CONFIG_BLK_DEV_INITRD
498         if (initrd_start)
499                 ROOT_DEV = Root_RAM0;
500         else
501 #endif
502 #ifdef  CONFIG_ROOT_NFS
503                 ROOT_DEV = Root_NFS;
504 #else
505         ROOT_DEV = Root_HDA1;
506 #endif
507 }
508
509 /* ************************************************************************ */
510 void __init
511 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
512               unsigned long r6, unsigned long r7)
513 {
514         /* parse_bootinfo must always be called first */
515         parse_bootinfo(find_bootinfo());
516
517         /*
518          * If we were passed in a board information, copy it into the
519          * residual data area.
520          */
521         if (r3) {
522                 memcpy((void *) __res, (void *) (r3 + KERNELBASE),
523                                 sizeof (bd_t));
524
525         }
526 #ifdef CONFIG_SERIAL_TEXT_DEBUG
527         {
528                 bd_t *binfo = (bd_t *) __res;
529                 struct uart_port p;
530
531                 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
532                 settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base,
533                                 binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
534
535                 memset(&p, 0, sizeof (p));
536                 p.iotype = SERIAL_IO_MEM;
537                 p.membase = (void *) binfo->bi_immr_base + MPC85xx_UART0_OFFSET;
538                 p.uartclk = binfo->bi_busfreq;
539
540                 gen550_init(0, &p);
541
542                 memset(&p, 0, sizeof (p));
543                 p.iotype = SERIAL_IO_MEM;
544                 p.membase = (void *) binfo->bi_immr_base + MPC85xx_UART1_OFFSET;
545                 p.uartclk = binfo->bi_busfreq;
546
547                 gen550_init(1, &p);
548         }
549 #endif
550
551 #if defined(CONFIG_BLK_DEV_INITRD)
552         /*
553          * If the init RAM disk has been configured in, and there's a valid
554          * starting address for it, set it up.
555          */
556         if (r4) {
557                 initrd_start = r4 + KERNELBASE;
558                 initrd_end = r5 + KERNELBASE;
559         }
560 #endif /* CONFIG_BLK_DEV_INITRD */
561
562         /* Copy the kernel command line arguments to a safe place. */
563
564         if (r6) {
565                 *(char *) (r7 + KERNELBASE) = 0;
566                 strcpy(cmd_line, (char *) (r6 + KERNELBASE));
567         }
568
569         identify_ppc_sys_by_id(mfspr(SPRN_SVR));
570
571         /* setup the PowerPC module struct */
572         ppc_md.setup_arch = mpc85xx_cds_setup_arch;
573         ppc_md.show_cpuinfo = mpc85xx_cds_show_cpuinfo;
574
575         ppc_md.init_IRQ = mpc85xx_cds_init_IRQ;
576         ppc_md.get_irq = openpic_get_irq;
577
578         ppc_md.restart = mpc85xx_restart;
579         ppc_md.power_off = mpc85xx_power_off;
580         ppc_md.halt = mpc85xx_halt;
581
582         ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
583
584         ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
585
586         ppc_md.time_init = todc_time_init;
587         ppc_md.set_rtc_time = todc_set_rtc_time;
588         ppc_md.get_rtc_time = todc_get_rtc_time;
589
590         ppc_md.nvram_read_val = todc_direct_read_val;
591         ppc_md.nvram_write_val = todc_direct_write_val;
592
593 #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
594         ppc_md.progress = gen550_progress;
595 #endif /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
596 #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_KGDB)
597         ppc_md.early_serial_map = mpc85xx_early_serial_map;
598 #endif  /* CONFIG_SERIAL_8250 && CONFIG_KGDB */
599
600         if (ppc_md.progress)
601                 ppc_md.progress("mpc85xx_cds_init(): exit", 0);
602
603         return;
604 }