pci.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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>
  26. #include <linux/interrupt.h>
  27. #include <linux/init.h>
  28. #include <asm/mach/pci.h>
  29. #include <asm/mach-types.h>
  30. #include <mach/irqs.h>
  31. /*
  32. * A small note about bridges and interrupts. The DECchip 21050 (and
  33. * later) adheres to the PCI-PCI bridge specification. This says that
  34. * the interrupts on the other side of a bridge are swizzled in the
  35. * following manner:
  36. *
  37. * Dev Interrupt Interrupt
  38. * Pin on Pin on
  39. * Device Connector
  40. *
  41. * 4 A A
  42. * B B
  43. * C C
  44. * D D
  45. *
  46. * 5 A B
  47. * B C
  48. * C D
  49. * D A
  50. *
  51. * 6 A C
  52. * B D
  53. * C A
  54. * D B
  55. *
  56. * 7 A D
  57. * B A
  58. * C B
  59. * D C
  60. *
  61. * Where A = pin 1, B = pin 2 and so on and pin=0 = default = A.
  62. * Thus, each swizzle is ((pin-1) + (device#-4)) % 4
  63. */
  64. /*
  65. * This routine handles multiple bridges.
  66. */
  67. static u8 __init integrator_swizzle(struct pci_dev *dev, u8 *pinp)
  68. {
  69. if (*pinp == 0)
  70. *pinp = 1;
  71. return pci_common_swizzle(dev, pinp);
  72. }
  73. static int irq_tab[4] __initdata = {
  74. IRQ_AP_PCIINT0, IRQ_AP_PCIINT1, IRQ_AP_PCIINT2, IRQ_AP_PCIINT3
  75. };
  76. /*
  77. * map the specified device/slot/pin to an IRQ. This works out such
  78. * that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1.
  79. */
  80. static int __init integrator_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  81. {
  82. int intnr = ((slot - 9) + (pin - 1)) & 3;
  83. return irq_tab[intnr];
  84. }
  85. extern void pci_v3_init(void *);
  86. static struct hw_pci integrator_pci __initdata = {
  87. .swizzle = integrator_swizzle,
  88. .map_irq = integrator_map_irq,
  89. .setup = pci_v3_setup,
  90. .nr_controllers = 1,
  91. .ops = &pci_v3_ops,
  92. .preinit = pci_v3_preinit,
  93. .postinit = pci_v3_postinit,
  94. };
  95. static int __init integrator_pci_init(void)
  96. {
  97. if (machine_is_integrator())
  98. pci_common_init(&integrator_pci);
  99. return 0;
  100. }
  101. subsys_initcall(integrator_pci_init);