1 #include <linux/kernel.h>
2 #include <linux/init.h>
4 #include <linux/types.h>
5 #include <asm/cpu/irq.h>
8 static inline u8 bridge_swizzle(u8 pin, u8 slot)
10 return (((pin - 1) + slot) % 4) + 1;
13 int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
17 /* The complication here is that the PCI IRQ lines from the Cayman's 2
18 5V slots get into the CPU via a different path from the IRQ lines
19 from the 3 3.3V slots. Thus, we have to detect whether the card's
20 interrupts go via the 5V or 3.3V path, i.e. the 'bridge swizzling'
21 at the point where we cross from 5V to 3.3V is not the normal case.
23 The added complication is that we don't know that the 5V slots are
24 always bus 2, because a card containing a PCI-PCI bridge may be
25 plugged into a 3.3V slot, and this changes the bus numbering.
27 Also, the Cayman has an intermediate PCI bus that goes a custom
28 expansion board header (and to the secondary bridge). This bus has
29 never been used in practice.
31 The 1ary onboard PCI-PCI bridge is device 3 on bus 0
32 The 2ary onboard PCI-PCI bridge is device 0 on the 2ary bus of
42 while (dev->bus->number > 0) {
44 slot = path[i].slot = PCI_SLOT(dev->devfn);
45 pin = path[i].pin = bridge_swizzle(pin, slot);
48 if (i > 3) panic("PCI path to root bus too long!\n");
51 slot = PCI_SLOT(dev->devfn);
52 /* This is the slot on bus 0 through which the device is eventually
55 /* Now work back up. */
56 if ((slot < 3) || (i == 0)) {
57 /* Bus 0 (incl. PCI-PCI bridge itself) : perform the final
59 result = IRQ_INTA + bridge_swizzle(pin, slot) - 1;
65 panic("PCI expansion bus device found - not handled!\n");
72 /* 'pin' was swizzled earlier wrt slot, don't do it again. */
73 result = IRQ_P2INTA + (pin - 1);
75 /* IRQ for 2ary PCI-PCI bridge : unused */
84 struct pci_channel board_pci_channels[] = {
85 { &sh5_pci_ops, NULL, NULL, 0, 0xff },
86 { NULL, NULL, NULL, 0, 0 },
88 EXPORT_SYMBOL(board_pci_channels);
90 int __init pcibios_init_platform(void)
92 return sh5pci_init(__pa(memory_start),
93 __pa(memory_end) - __pa(memory_start));