From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Date: Thu, 13 Feb 2020 12:06:40 +0800
Subject: PCI: mobiveil: Add Header Type field check
Git-commit: 11d22cc395ca1b9ff78255edaee3bf258515ad72
Patch-mainline: v5.7-rc1
References: fate#326572
Check the Header Type and exit from the host driver initialization if
it is not in host mode.
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
drivers/pci/host/mobiveil/pcie-mobiveil-host.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
--- a/drivers/pci/host/mobiveil/pcie-mobiveil-host.c
+++ b/drivers/pci/host/mobiveil/pcie-mobiveil-host.c
@@ -562,6 +562,16 @@ static int mobiveil_pcie_interrupt_init(
return mobiveil_pcie_integrated_interrupt_init(pcie);
}
+static bool mobiveil_pcie_is_bridge(struct mobiveil_pcie *pcie)
+{
+ u32 header_type;
+
+ header_type = mobiveil_csr_readb(pcie, PCI_HEADER_TYPE);
+ header_type &= 0x7f;
+
+ return header_type == PCI_HEADER_TYPE_BRIDGE;
+}
+
int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)
{
struct mobiveil_root_port *rp = &pcie->rp;
@@ -577,6 +587,9 @@ int mobiveil_pcie_host_probe(struct mobi
return ret;
}
+ if (!mobiveil_pcie_is_bridge(pcie))
+ return -ENODEV;
+
/* parse the host bridge base addresses from the device tree file */
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL);
if (ret) {