cleanup
[linux-2.4.git] / arch / ppc / platforms / lopec_pci.c
1 /*
2  * arch/ppc/platforms/lopec_pci.c
3  *
4  * PCI setup routines for the Motorola LoPEC.
5  *
6  * Author: Dan Cox
7  *         danc@mvista.com (or, alternately, source@mvista.com)
8  *
9  * Copyright 2001 MontaVista Software Inc.
10  *
11  * This program is free software; you can redistribute  it and/or modify it
12  * under  the terms of  the GNU General Public License as published by the
13  * Free Software Foundation;  either version 2 of the  License, or (at your
14  * option) any later version.
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/pci.h>
20 #include <linux/slab.h>
21
22 #include <asm/machdep.h>
23 #include <asm/byteorder.h>
24 #include <asm/io.h>
25 #include <asm/irq.h>
26 #include <asm/uaccess.h>
27 #include <asm/pci-bridge.h>
28 #include <asm/open_pic.h>
29 #include <asm/mpc10x.h>
30
31 static inline int __init
32 lopec_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
33 {
34         int irq;
35         static char pci_irq_table[][4] = {
36                 {16, 0, 0, 0}, /* ID 11 - Winbond */
37                 {22, 0, 0, 0}, /* ID 12 - SCSI */
38                 {0, 0, 0, 0}, /* ID 13 - nothing */
39                 {17, 0, 0, 0}, /* ID 14 - 82559 Ethernet */
40                 {27, 0, 0, 0}, /* ID 15 - USB */
41                 {23, 0, 0, 0}, /* ID 16 - PMC slot 1 */
42                 {24, 0, 0, 0}, /* ID 17 - PMC slot 2 */
43                 {25, 0, 0, 0}, /* ID 18 - PCI slot */
44                 {0, 0, 0, 0}, /* ID 19 - nothing */
45                 {0, 0, 0, 0}, /* ID 20 - nothing */
46                 {0, 0, 0, 0}, /* ID 21 - nothing */
47                 {0, 0, 0, 0}, /* ID 22 - nothing */
48                 {0, 0, 0, 0}, /* ID 23 - nothing */
49                 {0, 0, 0, 0}, /* ID 24 - PMC slot 1b */
50                 {0, 0, 0, 0}, /* ID 25 - nothing */
51                 {0, 0, 0, 0}  /* ID 26 - PMC Slot 2b */
52         };
53         const long min_idsel = 11, max_idsel = 26, irqs_per_slot = 4;
54
55         irq = PCI_IRQ_TABLE_LOOKUP;
56         if (!irq)
57                 return 0;
58
59         return irq;
60 }
61
62 void __init
63 lopec_setup_winbond_83553(struct pci_controller *hose)
64 {
65         int devfn;
66
67         devfn = PCI_DEVFN(11,0);
68
69         /* IDE interrupt routing (primary 14, secondary 15) */
70         early_write_config_byte(hose, 0, devfn, 0x43, 0xef);
71         /* PCI interrupt routing */
72         early_write_config_word(hose, 0, devfn, 0x44, 0x0000);
73
74         /* ISA-PCI address decoder */
75         early_write_config_byte(hose, 0, devfn, 0x48, 0xf0);
76
77         /* RTC, kb, not used in PPC */
78         early_write_config_byte(hose, 0, devfn, 0x4d, 0x00);
79         early_write_config_byte(hose, 0, devfn, 0x4e, 0x04);
80         devfn = PCI_DEVFN(11, 1);
81         early_write_config_byte(hose, 0, devfn, 0x09, 0x8f);
82         early_write_config_dword(hose, 0, devfn, 0x40, 0x00ff0011);
83 }
84
85 void __init
86 lopec_find_bridges(void)
87 {
88         struct pci_controller *hose;
89
90         hose = pcibios_alloc_controller();
91         if (!hose)
92                 return;
93
94         hose->first_busno = 0;
95         hose->last_busno = 0xff;
96
97         if (mpc10x_bridge_init(hose,
98                                MPC10X_MEM_MAP_B,
99                                MPC10X_MEM_MAP_B,
100                                MPC10X_MAPB_EUMB_BASE) == 0) {
101
102                 hose->mem_resources[0].end = 0xffffffff;
103                 lopec_setup_winbond_83553(hose);
104                 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
105                 ppc_md.pci_swizzle = common_swizzle;
106                 ppc_md.pci_map_irq = lopec_map_irq;
107         }
108 }