1f81e4338c343ec7bfd8fb57bfd189386b4e38f8
[openwrt/openwrt.git] / target / linux / imx6 / patches-3.10 / 0034-PCI-imx6-add-support-for-legacy-irqs.patch
1 From: Tim Harvey <tharvey@gateworks.com>
2 Subject: [PATCH] PCI: imx6: add support for legacy irqs
3
4 The i.MX6 supports legacy IRQ's via 155,154,153,152. When devices
5 are behind a PCIe-to-PCIe switch (at least for the TI XIO2001) the
6 mapping is reversed from when they are behind a PCIe switch.
7
8 This patch still needs some review and clarification before going
9 upstream.
10 ---
11 drivers/pci/host/pcie-designware.c | 21 ++++++++++++++++++++-
12 1 file changed, 20 insertions(+), 1 deletion(-)
13
14 --- a/drivers/pci/host/pcie-designware.c
15 +++ b/drivers/pci/host/pcie-designware.c
16 @@ -447,7 +447,26 @@ int dw_pcie_map_irq(const struct pci_dev
17 {
18 struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata);
19
20 - return pp->irq;
21 + /* TI XIO2001 PCIe-to-PCI bridge IRQs are flipped it seems */
22 + if ( dev->bus && dev->bus->self
23 + && (dev->bus->self->vendor == 0x104c)
24 + && (dev->bus->self->device == 0x8240)) {
25 + switch (pin) {
26 + case 1: return pp->irq - 3;
27 + case 2: return pp->irq - 2;
28 + case 3: return pp->irq - 1;
29 + case 4: return pp->irq;
30 + default: return -1;
31 + }
32 + } else {
33 + switch (pin) {
34 + case 1: return pp->irq;
35 + case 2: return pp->irq - 1;
36 + case 3: return pp->irq - 2;
37 + case 4: return pp->irq - 3;
38 + default: return -1;
39 + }
40 + }
41 }
42
43 static struct hw_pci dw_pci = {