From: Ray Jui <rjui@broadcom.com> To: Bjorn Helgaas <bhelgaas@google.com> Cc: Hauke Mehrtens <hauke@hauke-m.de>, <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <bcm-kernel-feedback-list@broadcom.com>, Ray Jui <rjui@broadcom.com> Subject: [PATCH 5/8] PCI: iproc: Improve link detection logic Date: Tue, 15 Sep 2015 17:39:19 -0700 [thread overview] Message-ID: <1442363962-29805-6-git-send-email-rjui@broadcom.com> (raw) In-Reply-To: <1442363962-29805-1-git-send-email-rjui@broadcom.com> This patch further improves the iProc PCIe link detection logic by explicitly querying the link status register to ensure link is active It also forces class to PCI_CLASS_BRIDGE_PCI (0x0604) through the host configuration space register Signed-off-by: Ray Jui <rjui@broadcom.com> Reviewed-by: Anup Patel <anup.patel@broadcom.com> Reviewed-by: Scott Branden <sbranden@broadcom.com> --- drivers/pci/host/pcie-iproc.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 80e0541..62e8085 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -60,6 +60,12 @@ #define SYS_RC_INTX_EN 0x330 #define SYS_RC_INTX_MASK 0xf +#define PCIE_LINK_STATUS_OFFSET 0xf0c +#define PCIE_PHYLINKUP_SHIFT 3 +#define PCIE_PHYLINKUP BIT(PCIE_PHYLINKUP_SHIFT) +#define PCIE_DL_ACTIVE_SHIFT 2 +#define PCIE_DL_ACTIVE BIT(PCIE_DL_ACTIVE_SHIFT) + static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) { struct iproc_pcie *pcie; @@ -138,9 +144,15 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie) static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) { u8 hdr_type; - u32 link_ctrl; + u32 link_ctrl, class, val; u16 pos, link_status; - int link_is_active = 0; + bool link_is_active = false; + + val = readl(pcie->base + PCIE_LINK_STATUS_OFFSET); + if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) { + dev_err(pcie->dev, "PHY or data link is INACTIVE!\n"); + return -ENODEV; + } /* make sure we are not in EP mode */ pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type); @@ -150,14 +162,19 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) } /* force class to PCI_CLASS_BRIDGE_PCI (0x0604) */ - pci_bus_write_config_word(bus, 0, PCI_CLASS_DEVICE, - PCI_CLASS_BRIDGE_PCI); +#define PCI_BRIDGE_CTRL_REG_OFFSET 0x43c +#define PCI_CLASS_BRIDGE_MASK 0xffff00 +#define PCI_CLASS_BRIDGE_SHIFT 8 + pci_bus_read_config_dword(bus, 0, PCI_BRIDGE_CTRL_REG_OFFSET, &class); + class &= ~PCI_CLASS_BRIDGE_MASK; + class |= (PCI_CLASS_BRIDGE_PCI << PCI_CLASS_BRIDGE_SHIFT); + pci_bus_write_config_dword(bus, 0, PCI_BRIDGE_CTRL_REG_OFFSET, class); /* check link status to see if link is active */ pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); if (link_status & PCI_EXP_LNKSTA_NLW) - link_is_active = 1; + link_is_active = true; if (!link_is_active) { /* try GEN 1 link speed */ @@ -181,7 +198,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); if (link_status & PCI_EXP_LNKSTA_NLW) - link_is_active = 1; + link_is_active = true; } } -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: rjui@broadcom.com (Ray Jui) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/8] PCI: iproc: Improve link detection logic Date: Tue, 15 Sep 2015 17:39:19 -0700 [thread overview] Message-ID: <1442363962-29805-6-git-send-email-rjui@broadcom.com> (raw) In-Reply-To: <1442363962-29805-1-git-send-email-rjui@broadcom.com> This patch further improves the iProc PCIe link detection logic by explicitly querying the link status register to ensure link is active It also forces class to PCI_CLASS_BRIDGE_PCI (0x0604) through the host configuration space register Signed-off-by: Ray Jui <rjui@broadcom.com> Reviewed-by: Anup Patel <anup.patel@broadcom.com> Reviewed-by: Scott Branden <sbranden@broadcom.com> --- drivers/pci/host/pcie-iproc.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 80e0541..62e8085 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -60,6 +60,12 @@ #define SYS_RC_INTX_EN 0x330 #define SYS_RC_INTX_MASK 0xf +#define PCIE_LINK_STATUS_OFFSET 0xf0c +#define PCIE_PHYLINKUP_SHIFT 3 +#define PCIE_PHYLINKUP BIT(PCIE_PHYLINKUP_SHIFT) +#define PCIE_DL_ACTIVE_SHIFT 2 +#define PCIE_DL_ACTIVE BIT(PCIE_DL_ACTIVE_SHIFT) + static inline struct iproc_pcie *iproc_data(struct pci_bus *bus) { struct iproc_pcie *pcie; @@ -138,9 +144,15 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie) static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) { u8 hdr_type; - u32 link_ctrl; + u32 link_ctrl, class, val; u16 pos, link_status; - int link_is_active = 0; + bool link_is_active = false; + + val = readl(pcie->base + PCIE_LINK_STATUS_OFFSET); + if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) { + dev_err(pcie->dev, "PHY or data link is INACTIVE!\n"); + return -ENODEV; + } /* make sure we are not in EP mode */ pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type); @@ -150,14 +162,19 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) } /* force class to PCI_CLASS_BRIDGE_PCI (0x0604) */ - pci_bus_write_config_word(bus, 0, PCI_CLASS_DEVICE, - PCI_CLASS_BRIDGE_PCI); +#define PCI_BRIDGE_CTRL_REG_OFFSET 0x43c +#define PCI_CLASS_BRIDGE_MASK 0xffff00 +#define PCI_CLASS_BRIDGE_SHIFT 8 + pci_bus_read_config_dword(bus, 0, PCI_BRIDGE_CTRL_REG_OFFSET, &class); + class &= ~PCI_CLASS_BRIDGE_MASK; + class |= (PCI_CLASS_BRIDGE_PCI << PCI_CLASS_BRIDGE_SHIFT); + pci_bus_write_config_dword(bus, 0, PCI_BRIDGE_CTRL_REG_OFFSET, class); /* check link status to see if link is active */ pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); if (link_status & PCI_EXP_LNKSTA_NLW) - link_is_active = 1; + link_is_active = true; if (!link_is_active) { /* try GEN 1 link speed */ @@ -181,7 +198,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); if (link_status & PCI_EXP_LNKSTA_NLW) - link_is_active = 1; + link_is_active = true; } } -- 1.9.1
next prev parent reply other threads:[~2015-09-16 0:39 UTC|newest] Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-09-16 0:39 [PATCH 0/8] Broadcom iProc PCIe fixes and outbound mapping support Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` [PATCH 1/8] PCI: iproc: Fix code comment Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` [PATCH 2/8] PCI: iproc: Remove unused code Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` [PATCH 3/8] PCI: iproc: Remove ARCH specific flag Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` [PATCH 4/8] PCI: iproc: Fix PCIe reset logic Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` Ray Jui [this message] 2015-09-16 0:39 ` [PATCH 5/8] PCI: iproc: Improve link detection logic Ray Jui 2015-09-16 0:39 ` [PATCH 6/8] PCI: iproc: Update iProc PCIe device tree bindings Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-16 0:39 ` [PATCH 7/8] PCI: iproc: Add outbound mapping support Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-10-13 17:58 ` Kevin Hilman 2015-10-13 17:58 ` Kevin Hilman 2015-10-13 17:58 ` Kevin Hilman 2015-10-13 20:02 ` [PATCH] PCI: iproc: fix 32-bit build error Arnd Bergmann 2015-10-13 20:02 ` Arnd Bergmann 2015-10-13 20:06 ` Hauke Mehrtens 2015-10-13 20:06 ` Hauke Mehrtens 2015-10-13 20:11 ` Ray Jui 2015-10-13 20:11 ` Ray Jui 2015-10-13 21:00 ` Arnd Bergmann 2015-10-13 21:00 ` Arnd Bergmann 2015-10-15 16:00 ` Bjorn Helgaas 2015-10-15 16:00 ` Bjorn Helgaas 2015-10-15 16:19 ` Ray Jui 2015-10-15 16:19 ` Ray Jui 2015-10-15 19:40 ` [PATCH v2] " Arnd Bergmann 2015-10-15 19:40 ` Arnd Bergmann 2015-10-15 20:57 ` Hauke Mehrtens 2015-10-15 20:57 ` Hauke Mehrtens 2015-10-15 21:01 ` Bjorn Helgaas 2015-10-15 21:01 ` Bjorn Helgaas 2015-10-16 9:47 ` Arnd Bergmann 2015-10-16 9:47 ` Arnd Bergmann 2015-10-16 13:23 ` Bjorn Helgaas 2015-10-16 13:23 ` Bjorn Helgaas 2015-10-13 21:21 ` [PATCH] " Kevin Hilman 2015-10-13 21:21 ` Kevin Hilman 2015-09-16 0:39 ` [PATCH 8/8] PCI: iproc: Fix compile warnings Ray Jui 2015-09-16 0:39 ` Ray Jui 2015-09-25 23:21 ` [PATCH 0/8] Broadcom iProc PCIe fixes and outbound mapping support Bjorn Helgaas 2015-09-25 23:21 ` Bjorn Helgaas
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=1442363962-29805-6-git-send-email-rjui@broadcom.com \ --to=rjui@broadcom.com \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=bhelgaas@google.com \ --cc=hauke@hauke-m.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pci@vger.kernel.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: linkBe 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.