From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn1on0119.outbound.protection.outlook.com ([157.56.110.119]:60413 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752370AbbJPHSl (ORCPT ); Fri, 16 Oct 2015 03:18:41 -0400 From: Minghuan Lian To: CC: , Zang Roy-R61911 , Hu Mingkai-B21284 , "Yoder Stuart-B08248" , Li Yang , Arnd Bergmann , Bjorn Helgaas , "Jingoo Han" , Zhou Wang , "Minghuan Lian" Subject: [PATCH v4 2/6] PCI: layerscape: check PCIe controller work mode Date: Fri, 16 Oct 2015 15:19:16 +0800 Message-ID: <1444979960-24100-2-git-send-email-Minghuan.Lian@freescale.com> In-Reply-To: <1444979960-24100-1-git-send-email-Minghuan.Lian@freescale.com> References: <1444979960-24100-1-git-send-email-Minghuan.Lian@freescale.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-pci-owner@vger.kernel.org List-ID: Layerscape PCIe controller supports root complex (RC) and endpoint (EP) mode. The mode can be set by RCW. The patch will check it. If not in RC mode, the driver directly returns -ENODEV. Signed-off-by: Minghuan Lian --- Change log v4: split from [PATCH v3] PCI: layerscape: Add PCIe support for LS1043a and LS2080a drivers/pci/host/pci-layerscape.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c index 6dd44a0..5eabe92 100644 --- a/drivers/pci/host/pci-layerscape.c +++ b/drivers/pci/host/pci-layerscape.c @@ -47,6 +47,16 @@ struct ls_pcie { #define to_ls_pcie(x) container_of(x, struct ls_pcie, pp) +static bool ls_pcie_is_bridge(struct ls_pcie *pcie) +{ + u32 header_type; + + header_type = ioread8(pcie->dbi + PCI_HEADER_TYPE); + header_type &= 0x7f; + + return header_type == PCI_HEADER_TYPE_BRIDGE; +} + static int ls_pcie_link_up(struct pcie_port *pp) { u32 state; @@ -135,6 +145,9 @@ static int __init ls_pcie_probe(struct platform_device *pdev) return ret; pcie->index = index[1]; + if (!ls_pcie_is_bridge(pcie)) + return -ENODEV; + ret = ls_add_pcie_port(pcie); if (ret < 0) return ret; -- 1.9.1