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 * 2000 (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/kernel.h>
16 #include <linux/init.h>
17 #include <linux/pci.h>
18 #include <linux/slab.h>
19
20 #include <asm/byteorder.h>
21 #include <asm/io.h>
22 #include <asm/uaccess.h>
23 #include <asm/machdep.h>
24 #include <asm/pci-bridge.h>
25 #include <platforms/spruce.h>
26
27 #include "cpc700.h"
28
29 static inline int
spruce_map_irq(struct pci_dev * dev,unsigned char idsel,unsigned char pin)30 spruce_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
31 {
32 static char pci_irq_table[][4] =
33 /*
34 * PCI IDSEL/INTPIN->INTLINE
35 * A B C D
36 */
37 {
38 {23, 24, 25, 26}, /* IDSEL 1 - PCI slot 3 */
39 {24, 25, 26, 23}, /* IDSEL 2 - PCI slot 2 */
40 {25, 26, 23, 24}, /* IDSEL 3 - PCI slot 1 */
41 {26, 23, 24, 25}, /* IDSEL 4 - PCI slot 0 */
42 };
43
44 const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
45 return PCI_IRQ_TABLE_LOOKUP;
46 }
47
48 void __init
spruce_setup_hose(void)49 spruce_setup_hose(void)
50 {
51 struct pci_controller *hose;
52
53 /* Setup hose */
54 hose = pcibios_alloc_controller();
55 if (!hose)
56 return;
57
58 hose->first_busno = 0;
59 hose->last_busno = 0xff;
60
61 pci_init_resource(&hose->io_resource,
62 SPRUCE_PCI_LOWER_IO,
63 SPRUCE_PCI_UPPER_IO,
64 IORESOURCE_IO,
65 "PCI host bridge");
66
67 pci_init_resource(&hose->mem_resources[0],
68 SPRUCE_PCI_LOWER_MEM,
69 SPRUCE_PCI_UPPER_MEM,
70 IORESOURCE_MEM,
71 "PCI host bridge");
72
73 hose->io_space.start = SPRUCE_PCI_LOWER_IO;
74 hose->io_space.end = SPRUCE_PCI_UPPER_IO;
75 hose->mem_space.start = SPRUCE_PCI_LOWER_MEM;
76 hose->mem_space.end = SPRUCE_PCI_UPPER_MEM;
77 hose->io_base_virt = (void *)SPRUCE_ISA_IO_BASE;
78
79 setup_indirect_pci(hose,
80 SPRUCE_PCI_CONFIG_ADDR,
81 SPRUCE_PCI_CONFIG_DATA);
82
83 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
84
85 ppc_md.pci_swizzle = common_swizzle;
86 ppc_md.pci_map_irq = spruce_map_irq;
87 }
88