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/jaguar/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/version.h>
21 #include <linux/init.h>
22 #include <asm/pci.h>
23
24
mv64340_board_pcibios_fixup_bus(struct pci_bus * bus)25 void __init mv64340_board_pcibios_fixup_bus(struct pci_bus *bus)
26 {
27 struct pci_bus *current_bus = bus;
28 struct pci_dev *devices;
29 struct list_head *devices_link;
30 u16 cmd;
31
32 /* loop over all known devices on this bus */
33 list_for_each(devices_link, &(current_bus->devices)) {
34
35 devices = pci_dev_b(devices_link);
36 if (devices == NULL)
37 continue;
38
39 if ((current_bus->number == 0) &&
40 (PCI_SLOT(devices->devfn) == 1)) {
41 /* PCI-X A */
42 devices->irq = 3;
43 } else if ((current_bus->number == 0) &&
44 (PCI_SLOT(devices->devfn) == 2)) {
45 /* PCI-X B */
46 devices->irq = 4;
47 } else if ((current_bus->number == 1) &&
48 (PCI_SLOT(devices->devfn) == 1)) {
49 /* PCI A */
50 devices->irq = 5;
51 } else if ((current_bus->number == 1) &&
52 (PCI_SLOT(devices->devfn) == 2)) {
53 /* PCI B */
54 devices->irq = 6;
55 } else {
56 /* We don't have assign interrupts for other devices. */
57 devices->irq = 0xff;
58 }
59
60 /* Assign an interrupt number for the device */
61 bus->ops->write_byte(devices, PCI_INTERRUPT_LINE, devices->irq);
62
63 /* enable master for everything but the MV-64340 */
64 if (((current_bus->number != 0) && (current_bus->number != 1))
65 || (PCI_SLOT(devices->devfn) != 0)) {
66 bus->ops->read_word(devices, PCI_COMMAND, &cmd);
67 cmd |= PCI_COMMAND_MASTER;
68 bus->ops->write_word(devices, PCI_COMMAND, cmd);
69 }
70 }
71 }
72