ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / momentum / ocelot_c / pci-irq.c
1 /*
2  * Copyright 2002 Momentum Computer Inc.
3  * Author: Matthew Dharm <mdharm@momenco.com> 
4  *
5  * Based on work for the Linux port to the Ocelot board, which is
6  * Copyright 2001 MontaVista Software Inc.
7  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
8  *
9  * arch/mips/momentum/ocelot_g/pci.c
10  *     Board-specific PCI routines for mv64340 controller.
11  *
12  * This program is free software; you can redistribute  it and/or modify it
13  * under  the terms of  the GNU General  Public License as published by the
14  * Free Software Foundation;  either version 2 of the  License, or (at your
15  * option) any later version.
16  */
17 #include <linux/types.h>
18 #include <linux/pci.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <asm/pci.h>
22
23
24 void __init mv64340_board_pcibios_fixup_bus(struct pci_bus *bus)
25 {
26         struct pci_bus *current_bus = bus;
27         struct pci_dev *devices;
28         struct list_head *devices_link;
29         u16 cmd;
30
31         /* loop over all known devices on this bus */
32         list_for_each(devices_link, &(current_bus->devices)) {
33
34                 devices = pci_dev_b(devices_link);
35                 if (devices == NULL)
36                         continue;
37
38                 if ((current_bus->number == 0) &&
39                         (PCI_SLOT(devices->devfn) == 1) &&
40                         (PCI_FUNC(devices->devfn) == 0)) {
41                         /* LSI 53C10101R SCSI (A) */
42                         devices->irq = 2;
43                 } else if ((current_bus->number == 0) &&
44                         (PCI_SLOT(devices->devfn) == 1) &&
45                         (PCI_FUNC(devices->devfn) == 1)) {
46                         /* LSI 53C10101R SCSI (B) */
47                         devices->irq = 2;
48                 } else if ((current_bus->number == 1) &&
49                         (PCI_SLOT(devices->devfn) == 1)) {
50                         /* Intel 21555 bridge */
51                         devices->irq = 12;
52                 } else if ((current_bus->number == 1) &&
53                         (PCI_SLOT(devices->devfn) == 2)) {
54                         /* PMC Slot */
55                         devices->irq = 4;
56                 } else {
57                         /* We don't have assign interrupts for other devices. */
58                         devices->irq = 0xff;
59                 }
60
61                 /* Assign an interrupt number for the device */
62                 bus->ops->write_byte(devices, PCI_INTERRUPT_LINE, devices->irq);
63
64                 /* enable master for everything but the MV-64340 */
65                 if (((current_bus->number != 0) && (current_bus->number != 1))
66                                 || (PCI_SLOT(devices->devfn) != 0)) {
67                         bus->ops->read_word(devices, PCI_COMMAND, &cmd);
68                         cmd |= PCI_COMMAND_MASTER;
69                         bus->ops->write_word(devices, PCI_COMMAND, cmd);
70                 }
71         }
72 }