ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / pci / pci-ddb5074.c
1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/types.h>
4 #include <linux/pci.h>
5
6 #include <asm/pci_channel.h>
7 #include <asm/debug.h>
8
9 #include <asm/ddb5xxx/ddb5xxx.h>
10
11 static struct resource extpci_io_resource = {
12         "pci IO space",
13         0x1000,                 /* leave some room for ISA bus */
14         DDB_PCI_IO_SIZE - 1,
15         IORESOURCE_IO
16 };
17
18 static struct resource extpci_mem_resource = {
19         "pci memory space",
20         DDB_PCI_MEM_BASE + 0x00100000,  /* leave 1 MB for RTC */
21         DDB_PCI_MEM_BASE + DDB_PCI_MEM_SIZE - 1,
22         IORESOURCE_MEM
23 };
24
25 extern struct pci_ops ddb5476_ext_pci_ops;
26
27 struct pci_controller ddb5476_controller = {
28         .pci_ops        = &ddb5476_ext_pci_ops,
29         .io_resource    = &extpci_io_resource,
30         .mem_resource   = &extpci_mem_resource,
31 };
32
33 #define     PCI_EXT_INTA        8
34 #define     PCI_EXT_INTB        9
35 #define     PCI_EXT_INTC        10
36 #define     PCI_EXT_INTD        11
37 #define     PCI_EXT_INTE        12
38
39 #define     MAX_SLOT_NUM        14
40
41 static unsigned char irq_map[MAX_SLOT_NUM] = {
42   [ 0] = nile4_to_irq(PCI_EXT_INTE),
43   [ 1] = nile4_to_irq(PCI_EXT_INTA),
44   [ 2] = nile4_to_irq(PCI_EXT_INTA),
45   [ 3] = nile4_to_irq(PCI_EXT_INTB),
46   [ 4] = nile4_to_irq(PCI_EXT_INTC),
47   [ 5] = nile4_to_irq(NILE4_INT_UART),
48   [10] = nile4_to_irq(PCI_EXT_INTE),
49   [13] = nile4_to_irq(PCI_EXT_INTE),
50 };
51
52 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
53 {
54         return irq_map[slot];
55 }
56
57 void __init ddb_pci_reset_bus(void)
58 {
59         u32 temp;
60
61         /*
62          * I am not sure about the "official" procedure, the following
63          * steps work as far as I know:
64          * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
65          * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
66          * The same is true for both PCI channels.
67          */
68         temp = ddb_in32(DDB_PCICTRL + 4);
69         temp |= 0x80000000;
70         ddb_out32(DDB_PCICTRL + 4, temp);
71         temp &= ~0xc0000000;
72         ddb_out32(DDB_PCICTRL + 4, temp);
73
74 }