From patchwork Wed Sep 6 13:56:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 9940819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9763460350 for ; Wed, 6 Sep 2017 13:56:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BBEA28C0A for ; Wed, 6 Sep 2017 13:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7091B28C0E; Wed, 6 Sep 2017 13:56:40 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 108DE28C12 for ; Wed, 6 Sep 2017 13:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932386AbdIFN4W (ORCPT ); Wed, 6 Sep 2017 09:56:22 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:40224 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932239AbdIFN4U (ORCPT ); Wed, 6 Sep 2017 09:56:20 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v86DuJtd005894; Wed, 6 Sep 2017 08:56:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1504706179; bh=prsGGH09f4fZC1edYAqkVLcLDY3xFIr9sZNeFgGpenQ=; h=From:To:CC:Subject:Date; b=UprHZrCtzDJoBG+fIVeQZhhbqEKb4KMhTplvTdZ0nHIBjRqRpWqHjR4MWLq8GqeAf JPOoLfma+uOHu5JI4QZKKv18tVSmjT3XSUpOkSJ/eguMSRqB5cPEup3X+YFRCzyNC+ bW4OsFrbD0TvsJirok0EJozWfSxFVt/YTrQAle6E= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v86DuJWH010933; Wed, 6 Sep 2017 08:56:19 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 6 Sep 2017 08:56:19 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 6 Sep 2017 08:56:19 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v86DuGZX011055; Wed, 6 Sep 2017 08:56:17 -0500 From: Keerthy To: , CC: , , , , Subject: [PATCH v2] pci: dwc: dra7xx: Add shutdown handler to cleanly turn off clocks Date: Wed, 6 Sep 2017 19:26:06 +0530 Message-ID: <1504706166-2854-1-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add shutdown handler to cleanly turn off clocks. Signed-off-by: Keerthy Acked-by: Kishon Vijay Abraham I --- Changes in v2: * used a local dev pointer instead of dereferencing dev at multiple places. * dra7xx_pcie_stop_link before disabling clks in the shutdown path. drivers/pci/dwc/pci-dra7xx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index 0f9adf2..0d8307a 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c @@ -779,6 +779,22 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev) return 0; } +void dra7xx_pcie_shutdown(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); + int ret; + + dra7xx_pcie_stop_link(dra7xx->pci); + + ret = pm_runtime_put_sync(dev); + if (ret < 0) + dev_dbg(dev, "pm_runtime_put_sync failed\n"); + + pm_runtime_disable(dev); + dra7xx_pcie_disable_phy(dra7xx); +} + static int dra7xx_pcie_resume_noirq(struct device *dev) { struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); @@ -807,5 +823,6 @@ static int dra7xx_pcie_resume_noirq(struct device *dev) .suppress_bind_attrs = true, .pm = &dra7xx_pcie_pm_ops, }, + .shutdown = dra7xx_pcie_shutdown, }; builtin_platform_driver_probe(dra7xx_pcie_driver, dra7xx_pcie_probe);