Feed the mess through indent.
[linux-2.6/linux-mips.git] / arch / mips / pci / pci-ddb5074.c
blob91e4792a6dc3c978e6e2c6e998b21ecc856ee2af
1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/types.h>
4 #include <linux/pci.h>
6 #include <asm/pci_channel.h>
7 #include <asm/debug.h>
9 #include <asm/ddb5xxx/ddb5xxx.h>
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
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
25 extern struct pci_ops ddb5476_ext_pci_ops;
27 struct pci_channel mips_pci_channels[] = {
28 {&ddb5476_ext_pci_ops, &extpci_io_resource, &extpci_mem_resource},
29 {NULL, NULL, NULL}
32 #define PCI_EXT_INTA 8
33 #define PCI_EXT_INTB 9
34 #define PCI_EXT_INTC 10
35 #define PCI_EXT_INTD 11
36 #define PCI_EXT_INTE 12
38 #define MAX_SLOT_NUM 14
40 static unsigned char irq_map[MAX_SLOT_NUM] = {
41 /* SLOT: 0 */ nile4_to_irq(PCI_EXT_INTE),
42 /* SLOT: 1 */ nile4_to_irq(PCI_EXT_INTA),
43 /* SLOT: 2 */ nile4_to_irq(PCI_EXT_INTA),
44 /* SLOT: 3 */ nile4_to_irq(PCI_EXT_INTB),
45 /* SLOT: 4 */ nile4_to_irq(PCI_EXT_INTC),
46 /* SLOT: 5 */ nile4_to_irq(NILE4_INT_UART),
47 /* SLOT: 6 */ 0xff,
48 /* SLOT: 7 */ 0xff,
49 /* SLOT: 8 */ 0xff,
50 /* SLOT: 9 */ 0xff,
51 /* SLOT: 10 */ nile4_to_irq(PCI_EXT_INTE),
52 /* SLOT: 11 */ 0xff,
53 /* SLOT: 12 */ 0xff,
54 /* SLOT: 13 */ nile4_to_irq(PCI_EXT_INTE),
57 void __init pcibios_fixup_irqs(void)
60 struct pci_dev *dev;
61 int slot_num;
63 pci_for_each_dev(dev) {
64 slot_num = PCI_SLOT(dev->devfn);
65 db_assert(slot_num < MAX_SLOT_NUM);
66 printk("irq_map[%d]: %02x\n", slot_num, irq_map[slot_num]);
67 db_assert(irq_map[slot_num] != 0xff);
69 pci_write_config_byte(dev,
70 PCI_INTERRUPT_LINE,
71 irq_map[slot_num]);
73 dev->irq = irq_map[slot_num];
77 void __init ddb_pci_reset_bus(void)
79 u32 temp;
82 * I am not sure about the "official" procedure, the following
83 * steps work as far as I know:
84 * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
85 * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
86 * The same is true for both PCI channels.
88 temp = ddb_in32(DDB_PCICTRL + 4);
89 temp |= 0x80000000;
90 ddb_out32(DDB_PCICTRL + 4, temp);
91 temp &= ~0xc0000000;
92 ddb_out32(DDB_PCICTRL + 4, temp);
96 unsigned __init int pcibios_assign_all_busses(void)
98 /* we hope pci_auto has assigned the bus numbers to all buses */
99 return 1;
102 void __init pcibios_fixup_resources(struct pci_dev *dev)
106 void __init pcibios_fixup(void)
108 struct pci_dev *dev;
110 pci_for_each_dev(dev) {
111 if (dev->vendor == PCI_VENDOR_ID_AL &&
112 dev->device == PCI_DEVICE_ID_AL_M7101) {
114 * It's nice to have the LEDs on the GPIO pins
115 * available for debugging
117 extern struct pci_dev *pci_pmu;
118 u8 t8;
120 pci_pmu = dev; /* for LEDs D2 and D3 */
121 /* Program the lines for LEDs D2 and D3 to output */
122 pci_read_config_byte(dev, 0x7d, &t8);
123 t8 |= 0xc0;
124 pci_write_config_byte(dev, 0x7d, t8);
125 /* Turn LEDs D2 and D3 off */
126 pci_read_config_byte(dev, 0x7e, &t8);
127 t8 |= 0xc0;
128 pci_write_config_byte(dev, 0x7e, t8);