From patchwork Thu Jan 14 14:11:12 2016 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: 59734 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp4030156lbb; Thu, 14 Jan 2016 06:12:09 -0800 (PST) X-Received: by 10.66.159.226 with SMTP id xf2mr6151250pab.23.1452780729815; Thu, 14 Jan 2016 06:12:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si9742208pft.41.2016.01.14.06.12.07; Thu, 14 Jan 2016 06:12:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754569AbcANOME (ORCPT + 29 others); Thu, 14 Jan 2016 09:12:04 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:51913 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754525AbcANOL7 (ORCPT ); Thu, 14 Jan 2016 09:11:59 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u0EEBT60012080; Thu, 14 Jan 2016 08:11:29 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u0EEBTbF029037; Thu, 14 Jan 2016 08:11:29 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Thu, 14 Jan 2016 08:11:28 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u0EEBF3h026141; Thu, 14 Jan 2016 08:11:26 -0600 From: Kishon Vijay Abraham I To: Tony Lindgren , Bjorn Helgaas , CC: Russell King , Suman Anna , , , , , Subject: [PATCH v3 3/3] pci: dra7xx: use pdata callbacks to perform reset Date: Thu, 14 Jan 2016 19:41:12 +0530 Message-ID: <1452780672-14339-4-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1452780672-14339-1-git-send-email-kishon@ti.com> References: <1452780672-14339-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use assert/deassert callbacks populated in the platform data to to perform reset of PCIe. Use these callbacks until a reset controller driver is is available in the kernel to reset PCIe. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sekhar Nori --- drivers/pci/host/pci-dra7xx.c | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) -- 1.7.9.5 diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c index 8c36880..f9a3240 100644 --- a/drivers/pci/host/pci-dra7xx.c +++ b/drivers/pci/host/pci-dra7xx.c @@ -25,6 +25,8 @@ #include #include +#include + #include "pcie-designware.h" /* PCIe controller wrapper DRA7XX configuration registers */ @@ -329,6 +331,61 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, return 0; } +static int dra7xx_pcie_assert_reset(struct platform_device *pdev) +{ + int ret; + struct device *dev = &pdev->dev; + struct pci_dra7xx_platform_data *pdata = pdev->dev.platform_data; + + if (!(pdata && pdata->assert_reset)) { + dev_err(dev, "platform data for assert reset not found!\n"); + return -EINVAL; + } + + ret = pdata->assert_reset(pdev, pdata->reset_name); + if (ret) { + dev_err(dev, "assert_reset failed: %d\n", ret); + return ret; + } + + return 0; +} + +static int dra7xx_pcie_deassert_reset(struct platform_device *pdev) +{ + int ret; + struct device *dev = &pdev->dev; + struct pci_dra7xx_platform_data *pdata = pdev->dev.platform_data; + + if (!(pdata && pdata->deassert_reset)) { + dev_err(dev, "platform data for deassert reset not found!\n"); + return -EINVAL; + } + + ret = pdata->deassert_reset(pdev, pdata->reset_name); + if (ret) { + dev_err(dev, "deassert_reset failed: %d\n", ret); + return ret; + } + + return 0; +} + +static int dra7xx_pcie_reset(struct platform_device *pdev) +{ + int ret; + + ret = dra7xx_pcie_assert_reset(pdev); + if (ret < 0) + return ret; + + ret = dra7xx_pcie_deassert_reset(pdev); + if (ret < 0) + return ret; + + return 0; +} + static int __init dra7xx_pcie_probe(struct platform_device *pdev) { u32 reg; @@ -347,6 +404,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) enum of_gpio_flags flags; unsigned long gpio_flags; + ret = dra7xx_pcie_reset(pdev); + if (ret) + return ret; + dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL); if (!dra7xx) return -ENOMEM; @@ -457,6 +518,7 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev) struct pcie_port *pp = &dra7xx->pp; struct device *dev = &pdev->dev; int count = dra7xx->phy_count; + int ret; if (pp->irq_domain) irq_domain_remove(pp->irq_domain); @@ -467,6 +529,10 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev) phy_exit(dra7xx->phy[count]); } + ret = dra7xx_pcie_assert_reset(pdev); + if (ret < 0) + return ret; + return 0; }