All of lore.kernel.org
 help / color / mirror / Atom feed
From: tharvey@gateworks.com (Tim Harvey)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] PCI: imx6: ventana: fixup for IRQ mismapping
Date: Thu, 27 Feb 2014 17:19:54 -0800	[thread overview]
Message-ID: <1393550394-11071-4-git-send-email-tharvey@gateworks.com> (raw)
In-Reply-To: <1393550394-11071-1-git-send-email-tharvey@gateworks.com>

The TI XIO2001 PCIe-to-PCI bridge used on Ventana expansion boards
has its slot-to-bridge IRQ mapping reversed from the PCI specification:

  INTA->INTD
  INTB->INTC
  INTC->INTB
  INTD->INTA

Implement a custom swizzle function that does a fixup on the interrupt for
devices on the first TI XIO2001 bridge in the tree.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Jingoo Han <jg1.han@samsung.com>
---
 drivers/pci/host/pci-imx6.c | 36 ++++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h     |  1 +
 2 files changed, 37 insertions(+)

diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index aaa05c8..b171a21 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -493,6 +493,39 @@ static int imx6_add_pcie_port(struct pcie_port *pp,
 	return 0;
 }
 
+/* TI XIO2001 PCIe-to-PCI bridge on GW16082 exp card has IRQs reversed */
+u8 ventana_swizzle(struct pci_dev *dev, u8 *pin)
+{
+	u8 i = 0;
+	struct pci_dev *pdev = dev;
+
+	/* count number of TI XIO2001 bridges on bus */
+	while (!pci_is_root_bus(pdev->bus)) {
+		if (pdev->bus && pdev->bus->self &&
+		    (pdev->bus->self->vendor == PCI_VENDOR_ID_TI) &&
+		    (pdev->bus->self->device == PCI_DEVICE_ID_TI_XIO2001)) {
+			i++;
+		}
+		pdev = pdev->bus->self;
+	}
+	while (!pci_is_root_bus(dev->bus)) {
+		/* if we are directly downstream from 1st TI XIO2001 bridge */
+		if (dev->bus && dev->bus->self &&
+		    (dev->bus->self->vendor == PCI_VENDOR_ID_TI) &&
+		    (dev->bus->self->device == PCI_DEVICE_ID_TI_XIO2001)) {
+			if (--i == 0) {
+				/* swap IRQs and swizzle backwards */
+				*pin = (15 - PCI_SLOT(dev->devfn)) + 1;
+				dev = dev->bus->self;
+				continue;
+			}
+		}
+		*pin = pci_swizzle_interrupt_pin(dev, *pin);
+		dev = dev->bus->self;
+	}
+	return PCI_SLOT(dev->devfn);
+}
+
 static int __init imx6_pcie_probe(struct platform_device *pdev)
 {
 	struct imx6_pcie *imx6_pcie;
@@ -601,6 +634,9 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 		return PTR_ERR(imx6_pcie->iomuxc_gpr);
 	}
 
+	if (of_machine_is_compatible("gw,ventana"))
+		pp->swizzle = ventana_swizzle;
+
 	ret = imx6_add_pcie_port(pp, pdev);
 	if (ret < 0)
 		return ret;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 97fbecd..4ca334f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -822,6 +822,7 @@
 #define PCI_DEVICE_ID_TI_XX12		0x8039
 #define PCI_DEVICE_ID_TI_XX12_FM	0x803b
 #define PCI_DEVICE_ID_TI_XIO2000A	0x8231
+#define PCI_DEVICE_ID_TI_XIO2001	0x8240
 #define PCI_DEVICE_ID_TI_1130		0xac12
 #define PCI_DEVICE_ID_TI_1031		0xac13
 #define PCI_DEVICE_ID_TI_1131		0xac15
-- 
1.8.3.2

  parent reply	other threads:[~2014-02-28  1:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28  1:19 [RFC PATCH 0/3] PCI: imx6: fixup for add-in card IRQ mismapping Tim Harvey
2014-02-28  1:19 ` [PATCH 1/3] PCI: designware: add legacy PCI interrupt mapping Tim Harvey
2014-02-28  2:00   ` Jingoo Han
2014-02-28  4:24     ` Tim Harvey
2014-02-28  7:01       ` Jingoo Han
2014-02-28 10:12         ` Marek Vasut
2014-02-28 11:27         ` Lucas Stach
2014-02-28 11:37           ` Arnd Bergmann
2014-02-28 12:09             ` Lucas Stach
2014-02-28 12:27               ` Arnd Bergmann
2014-02-28 13:53                 ` Lucas Stach
2014-02-28  2:10   ` Shawn Guo
2014-02-28  1:19 ` [PATCH 2/3] PCI: designware: add ability for custom swizzle Tim Harvey
2014-02-28  1:19 ` Tim Harvey [this message]
2014-02-28  2:10   ` [PATCH 3/3] PCI: imx6: ventana: fixup for IRQ mismapping Jingoo Han
2014-02-28  9:27   ` Arnd Bergmann
2014-02-28 17:39     ` Jason Gunthorpe
2014-03-01  0:52       ` Tim Harvey
2014-03-01  1:22         ` Jason Gunthorpe
2014-03-03 19:59           ` Tim Harvey
2014-03-03 23:37             ` Jason Gunthorpe
2014-03-04  0:38               ` Tim Harvey
2014-03-04  1:01                 ` Jason Gunthorpe
2014-02-28  1:50 ` [RFC PATCH 0/3] PCI: imx6: fixup for add-in card " Jingoo Han
2014-02-28  4:16   ` Tim Harvey
2014-02-28  6:22     ` Jingoo Han
2014-02-28 10:15       ` Marek Vasut
2014-02-28 16:52       ` Tim Harvey
2014-02-28 16:55         ` Lucas Stach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393550394-11071-4-git-send-email-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.