fixups-cayman.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/pci.h>
  4. #include <linux/types.h>
  5. #include <cpu/irq.h>
  6. #include "pci-sh5.h"
  7. int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  8. {
  9. int result = -1;
  10. /* The complication here is that the PCI IRQ lines from the Cayman's 2
  11. 5V slots get into the CPU via a different path from the IRQ lines
  12. from the 3 3.3V slots. Thus, we have to detect whether the card's
  13. interrupts go via the 5V or 3.3V path, i.e. the 'bridge swizzling'
  14. at the point where we cross from 5V to 3.3V is not the normal case.
  15. The added complication is that we don't know that the 5V slots are
  16. always bus 2, because a card containing a PCI-PCI bridge may be
  17. plugged into a 3.3V slot, and this changes the bus numbering.
  18. Also, the Cayman has an intermediate PCI bus that goes a custom
  19. expansion board header (and to the secondary bridge). This bus has
  20. never been used in practice.
  21. The 1ary onboard PCI-PCI bridge is device 3 on bus 0
  22. The 2ary onboard PCI-PCI bridge is device 0 on the 2ary bus of
  23. the 1ary bridge.
  24. */
  25. struct slot_pin {
  26. int slot;
  27. int pin;
  28. } path[4];
  29. int i=0;
  30. while (dev->bus->number > 0) {
  31. slot = path[i].slot = PCI_SLOT(dev->devfn);
  32. pin = path[i].pin = pci_swizzle_interrupt_pin(dev, pin);
  33. dev = dev->bus->self;
  34. i++;
  35. if (i > 3) panic("PCI path to root bus too long!\n");
  36. }
  37. slot = PCI_SLOT(dev->devfn);
  38. /* This is the slot on bus 0 through which the device is eventually
  39. reachable. */
  40. /* Now work back up. */
  41. if ((slot < 3) || (i == 0)) {
  42. /* Bus 0 (incl. PCI-PCI bridge itself) : perform the final
  43. swizzle now. */
  44. result = IRQ_INTA + pci_swizzle_interrupt_pin(dev, pin) - 1;
  45. } else {
  46. i--;
  47. slot = path[i].slot;
  48. pin = path[i].pin;
  49. if (slot > 0) {
  50. panic("PCI expansion bus device found - not handled!\n");
  51. } else {
  52. if (i > 0) {
  53. /* 5V slots */
  54. i--;
  55. slot = path[i].slot;
  56. pin = path[i].pin;
  57. /* 'pin' was swizzled earlier wrt slot, don't do it again. */
  58. result = IRQ_P2INTA + (pin - 1);
  59. } else {
  60. /* IRQ for 2ary PCI-PCI bridge : unused */
  61. result = -1;
  62. }
  63. }
  64. }
  65. return result;
  66. }