ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.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  * 2001-2002 (c) MontaVista, Software, Inc.  This file is licensed under
10  * the terms of the GNU General Public License version 2.  This program
11  * is licensed "as is" without any warranty of any kind, whether express
12  * or implied.
13  */
14
15 #include <linux/init.h>
16 #include <linux/pci.h>
17
18 #include <asm/machdep.h>
19 #include <asm/pci-bridge.h>
20 #include <asm/mpc10x.h>
21
22 static inline int __init
23 lopec_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
24 {
25         int irq;
26         static char pci_irq_table[][4] = {
27                 {16, 0, 0, 0}, /* ID 11 - Winbond */
28                 {22, 0, 0, 0}, /* ID 12 - SCSI */
29                 {0, 0, 0, 0}, /* ID 13 - nothing */
30                 {17, 0, 0, 0}, /* ID 14 - 82559 Ethernet */
31                 {27, 0, 0, 0}, /* ID 15 - USB */
32                 {23, 0, 0, 0}, /* ID 16 - PMC slot 1 */
33                 {24, 0, 0, 0}, /* ID 17 - PMC slot 2 */
34                 {25, 0, 0, 0}, /* ID 18 - PCI slot */
35                 {0, 0, 0, 0}, /* ID 19 - nothing */
36                 {0, 0, 0, 0}, /* ID 20 - nothing */
37                 {0, 0, 0, 0}, /* ID 21 - nothing */
38                 {0, 0, 0, 0}, /* ID 22 - nothing */
39                 {0, 0, 0, 0}, /* ID 23 - nothing */
40                 {0, 0, 0, 0}, /* ID 24 - PMC slot 1b */
41                 {0, 0, 0, 0}, /* ID 25 - nothing */
42                 {0, 0, 0, 0}  /* ID 26 - PMC Slot 2b */
43         };
44         const long min_idsel = 11, max_idsel = 26, irqs_per_slot = 4;
45
46         irq = PCI_IRQ_TABLE_LOOKUP;
47         if (!irq)
48                 return 0;
49
50         return irq;
51 }
52
53 void __init
54 lopec_setup_winbond_83553(struct pci_controller *hose)
55 {
56         int devfn;
57
58         devfn = PCI_DEVFN(11,0);
59
60         /* IDE interrupt routing (primary 14, secondary 15) */
61         early_write_config_byte(hose, 0, devfn, 0x43, 0xef);
62         /* PCI interrupt routing */
63         early_write_config_word(hose, 0, devfn, 0x44, 0x0000);
64
65         /* ISA-PCI address decoder */
66         early_write_config_byte(hose, 0, devfn, 0x48, 0xf0);
67
68         /* RTC, kb, not used in PPC */
69         early_write_config_byte(hose, 0, devfn, 0x4d, 0x00);
70         early_write_config_byte(hose, 0, devfn, 0x4e, 0x04);
71         devfn = PCI_DEVFN(11, 1);
72         early_write_config_byte(hose, 0, devfn, 0x09, 0x8f);
73         early_write_config_dword(hose, 0, devfn, 0x40, 0x00ff0011);
74 }
75
76 void __init
77 lopec_find_bridges(void)
78 {
79         struct pci_controller *hose;
80
81         hose = pcibios_alloc_controller();
82         if (!hose)
83                 return;
84
85         hose->first_busno = 0;
86         hose->last_busno = 0xff;
87
88         if (mpc10x_bridge_init(hose,
89                                MPC10X_MEM_MAP_B,
90                                MPC10X_MEM_MAP_B,
91                                MPC10X_MAPB_EUMB_BASE) == 0) {
92
93                 hose->mem_resources[0].end = 0xffffffff;
94                 lopec_setup_winbond_83553(hose);
95                 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
96                 ppc_md.pci_swizzle = common_swizzle;
97                 ppc_md.pci_map_irq = lopec_map_irq;
98         }
99 }