From patchwork Tue Jun 4 13:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 10975075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A15C2D49 for ; Tue, 4 Jun 2019 13:19:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76AF0285FD for ; Tue, 4 Jun 2019 13:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AC4728857; Tue, 4 Jun 2019 13:19:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0368828867 for ; Tue, 4 Jun 2019 13:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DBEh4FrwGLxvSdRGnK22B5sNDQ7mrDzOF9moUpmxNp0=; b=PGKHTRYvzVqaHu za7DT1UEjG2H1gdEQIFJnBcpwIfWEPUtOZo5PpJoRTiyZ8u0cLNcWgydS5+Mg+47FzTwJuZecmJN8 wCCq0gdN9u3WlroskPDHyasrqkYq+Y9/hNsp8ZUsP7lq1lpqnv9A2banGcmuPst/4UgoBm8mm+blk yNUdvbx5R66n3uUurZgG7stG2lj5XnhqLFyLxgHlUmosT+WU9cqp2gyZZYgAKOhpVLTM8bEvrb8y8 goTfk2iYwm814/Qn5uT9E+mm7QkKlHhtU1SgynJwN3mGCUlY+Ec+evtc/H+xd4Ws7QDsCjKbxxngy pS0mvCeOSnC8qOmUtm4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY9L9-0004vG-Nf; Tue, 04 Jun 2019 13:18:59 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY9K2-0003RN-Pr; Tue, 04 Jun 2019 13:18:39 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x54DHf13028057; Tue, 4 Jun 2019 08:17:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1559654261; bh=RElHPxtACkCdk4rLufC/bmJZmseWFYOIIvYrh7aFO/8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ctcAw7L7QUByHCOouvIbfAiWv5Zee8mbXY3jZXhr2OTNddfQLtmVD7zJnqx/VdTyr lC1MgB43JIWeJjcT739mZpUBUOpgDiQwkfxViuPTLl3GsgePCdIvDMwpmCh+CjaqWG lqtruagGs6y45G+xx4UhzoFRKD5nWMZRXj0nSwfY= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x54DHeFX052834 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 4 Jun 2019 08:17:40 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 4 Jun 2019 08:17:40 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 4 Jun 2019 08:17:40 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x54DGdGQ098972; Tue, 4 Jun 2019 08:17:35 -0500 From: Kishon Vijay Abraham I To: Tom Joseph , Bjorn Helgaas , Rob Herring , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Gustavo Pimentel Subject: [RFC PATCH 10/30] PCI: cadence: Use *_start_link() and *_wait_for_link() to establish link Date: Tue, 4 Jun 2019 18:44:56 +0530 Message-ID: <20190604131516.13596-11-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604131516.13596-1-kishon@ti.com> References: <20190604131516.13596-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_061751_546394_4A389F0E X-CRM114-Status: GOOD ( 17.66 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Jingoo Han , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , linux-rockchip@lists.infradead.org, Greg Kroah-Hartman , linux-omap@vger.kernel.org, Frank Rowand , linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use cdns_pcie_start_link() to start link training and cdns_pcie_wait_for_link() in order to wait to establish the link. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/pcie-cadence-ep.c | 11 ++++++++++- drivers/pci/controller/pcie-cadence-host.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-cadence-ep.c b/drivers/pci/controller/pcie-cadence-ep.c index b044167071e6..825a515821c3 100644 --- a/drivers/pci/controller/pcie-cadence-ep.c +++ b/drivers/pci/controller/pcie-cadence-ep.c @@ -21,6 +21,7 @@ /** * struct cdns_pcie_ep - private data for this PCIe endpoint controller driver * @pcie: Cadence PCIe controller + * @dev: pointer to PCIe EP device * @max_regions: maximum number of regions supported by hardware * @ob_region_map: bitmask of mapped outbound regions * @ob_addr: base addresses in the AXI bus where the outbound regions start @@ -37,6 +38,7 @@ */ struct cdns_pcie_ep { struct cdns_pcie pcie; + struct device *dev; u32 max_regions; unsigned long ob_region_map; phys_addr_t *ob_addr; @@ -386,6 +388,7 @@ static int cdns_pcie_ep_start(struct pci_epc *epc) struct cdns_pcie_ep *ep = epc_get_drvdata(epc); struct cdns_pcie *pcie = &ep->pcie; struct pci_epf *epf; + int ret = 0; u32 cfg; /* @@ -397,7 +400,11 @@ static int cdns_pcie_ep_start(struct pci_epc *epc) cfg |= BIT(epf->func_no); cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, cfg); - return 0; + ret = cdns_pcie_start_link(pcie, true); + if (ret) + dev_err(ep->dev, "Failed to start link\n"); + + return ret; } static const struct pci_epc_features cdns_pcie_epc_features = { @@ -460,6 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev) if (!ep) return -ENOMEM; + ep->dev = dev; + pcie = &ep->pcie; pcie->is_rc = false; pcie->plat_data = pdev->dev.platform_data; diff --git a/drivers/pci/controller/pcie-cadence-host.c b/drivers/pci/controller/pcie-cadence-host.c index 2363f05e7c58..4ad8f2ece6e2 100644 --- a/drivers/pci/controller/pcie-cadence-host.c +++ b/drivers/pci/controller/pcie-cadence-host.c @@ -365,6 +365,14 @@ static int cdns_pcie_host_probe(struct platform_device *pdev) goto err_get_sync; } + ret = cdns_pcie_start_link(pcie, true); + if (ret) { + dev_err(dev, "Failed to start link\n"); + goto err_start_link; + } + + cdns_pcie_wait_for_link(dev, pcie); + ret = cdns_pcie_host_init(dev, &resources, rc); if (ret) goto err_init; @@ -386,6 +394,9 @@ static int cdns_pcie_host_probe(struct platform_device *pdev) pci_free_resource_list(&resources); err_init: + cdns_pcie_start_link(pcie, false); + + err_start_link: pm_runtime_put_sync(dev); err_get_sync: