Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-integrator/pci-integrator.c |
| 3 | * |
| 4 | * Copyright (C) 1999 ARM Limited |
| 5 | * Copyright (C) 2000 Deep Blue Solutions Ltd |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * |
| 21 | * |
| 22 | * PCI functions for Integrator |
| 23 | */ |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/init.h> |
| 28 | |
| 29 | #include <asm/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/mach/pci.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | |
| 33 | /* |
| 34 | * A small note about bridges and interrupts. The DECchip 21050 (and |
| 35 | * later) adheres to the PCI-PCI bridge specification. This says that |
| 36 | * the interrupts on the other side of a bridge are swizzled in the |
| 37 | * following manner: |
| 38 | * |
| 39 | * Dev Interrupt Interrupt |
| 40 | * Pin on Pin on |
| 41 | * Device Connector |
| 42 | * |
| 43 | * 4 A A |
| 44 | * B B |
| 45 | * C C |
| 46 | * D D |
| 47 | * |
| 48 | * 5 A B |
| 49 | * B C |
| 50 | * C D |
| 51 | * D A |
| 52 | * |
| 53 | * 6 A C |
| 54 | * B D |
| 55 | * C A |
| 56 | * D B |
| 57 | * |
| 58 | * 7 A D |
| 59 | * B A |
| 60 | * C B |
| 61 | * D C |
| 62 | * |
| 63 | * Where A = pin 1, B = pin 2 and so on and pin=0 = default = A. |
| 64 | * Thus, each swizzle is ((pin-1) + (device#-4)) % 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * This routine handles multiple bridges. |
| 69 | */ |
| 70 | static u8 __init integrator_swizzle(struct pci_dev *dev, u8 *pinp) |
| 71 | { |
| 72 | int pin = *pinp; |
| 73 | |
| 74 | if (pin == 0) |
| 75 | pin = 1; |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | while (dev->bus->self) { |
Bjorn Helgaas | f14d766 | 2008-12-09 16:12:12 -0700 | [diff] [blame] | 78 | pin = pci_swizzle_interrupt_pin(dev, pin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | /* |
| 80 | * move up the chain of bridges, swizzling as we go. |
| 81 | */ |
| 82 | dev = dev->bus->self; |
| 83 | } |
Bjorn Helgaas | f14d766 | 2008-12-09 16:12:12 -0700 | [diff] [blame] | 84 | *pinp = pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | return PCI_SLOT(dev->devfn); |
| 87 | } |
| 88 | |
| 89 | static int irq_tab[4] __initdata = { |
| 90 | IRQ_AP_PCIINT0, IRQ_AP_PCIINT1, IRQ_AP_PCIINT2, IRQ_AP_PCIINT3 |
| 91 | }; |
| 92 | |
| 93 | /* |
| 94 | * map the specified device/slot/pin to an IRQ. This works out such |
| 95 | * that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1. |
| 96 | */ |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 97 | static int __init integrator_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
| 99 | int intnr = ((slot - 9) + (pin - 1)) & 3; |
| 100 | |
| 101 | return irq_tab[intnr]; |
| 102 | } |
| 103 | |
| 104 | extern void pci_v3_init(void *); |
| 105 | |
| 106 | static struct hw_pci integrator_pci __initdata = { |
| 107 | .swizzle = integrator_swizzle, |
| 108 | .map_irq = integrator_map_irq, |
| 109 | .setup = pci_v3_setup, |
| 110 | .nr_controllers = 1, |
| 111 | .scan = pci_v3_scan_bus, |
| 112 | .preinit = pci_v3_preinit, |
| 113 | .postinit = pci_v3_postinit, |
| 114 | }; |
| 115 | |
| 116 | static int __init integrator_pci_init(void) |
| 117 | { |
| 118 | if (machine_is_integrator()) |
| 119 | pci_common_init(&integrator_pci); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | subsys_initcall(integrator_pci_init); |