fix to allow usb modules to compile
[linux-2.4.21-pre4.git] / arch / ppc / platforms / spruce_pci.c
1 /*
2  * arch/ppc/platforms/spruce_pci.c
3  * 
4  * PCI support for IBM Spruce
5  *
6  * Author: Johnnie Peters
7  *         jpeters@mvista.com
8  *
9  * Copyright 2000 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  * THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
17  * WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
19  * NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
22  * USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  * ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * You should have received a copy of the  GNU General Public License along
28  * with this program; if not, write  to the Free Software Foundation, Inc.,
29  * 675 Mass Ave, Cambridge, MA 02139, USA.
30  */
31
32 #include <linux/kernel.h>
33 #include <linux/init.h>
34 #include <linux/pci.h>
35 #include <linux/slab.h>
36
37 #include <asm/byteorder.h>
38 #include <asm/io.h>
39 #include <asm/uaccess.h>
40 #include <asm/machdep.h>
41 #include <asm/pci-bridge.h>
42 #include <platforms/spruce.h>
43
44 #include "cpc700.h"
45
46 static inline int
47 spruce_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
48 {
49         static char pci_irq_table[][4] =
50                 /*
51                  *      PCI IDSEL/INTPIN->INTLINE 
52                  *      A       B       C       D
53                  */
54         {
55                 {23, 24, 25, 26},       /* IDSEL 1 - PCI slot 3 */
56                 {24, 25, 26, 23},       /* IDSEL 2 - PCI slot 2 */
57                 {25, 26, 23, 24},       /* IDSEL 3 - PCI slot 1 */
58                 {26, 23, 24, 25},       /* IDSEL 4 - PCI slot 0 */
59         };
60
61         const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
62         return PCI_IRQ_TABLE_LOOKUP;
63 }
64
65 void __init
66 spruce_setup_hose(void)
67 {
68         struct pci_controller *hose;
69
70         /* Setup hose */
71         hose = pcibios_alloc_controller();
72         if (!hose) 
73                 return;
74
75         hose->first_busno = 0;
76         hose->last_busno = 0xff;
77
78         pci_init_resource(&hose->io_resource,
79                         SPRUCE_PCI_LOWER_IO,
80                         SPRUCE_PCI_UPPER_IO,
81                         IORESOURCE_IO,
82                         "PCI host bridge");
83
84         pci_init_resource(&hose->mem_resources[0],
85                         SPRUCE_PCI_LOWER_MEM,
86                         SPRUCE_PCI_UPPER_MEM,
87                         IORESOURCE_MEM,
88                         "PCI host bridge");
89
90         hose->io_space.start = SPRUCE_PCI_LOWER_IO;
91         hose->io_space.end = SPRUCE_PCI_UPPER_IO;
92         hose->mem_space.start = SPRUCE_PCI_LOWER_MEM;
93         hose->mem_space.end = SPRUCE_PCI_UPPER_MEM;
94         hose->io_base_virt = (void *)SPRUCE_ISA_IO_BASE;
95
96         setup_indirect_pci(hose,
97                         SPRUCE_PCI_CONFIG_ADDR,
98                         SPRUCE_PCI_CONFIG_DATA);
99
100         hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
101
102         ppc_md.pci_swizzle = common_swizzle;
103         ppc_md.pci_map_irq = spruce_map_irq;
104 }