From patchwork Fri Sep 8 05:14:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 9943167 X-Patchwork-Delegate: bhelgaas@google.com 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 E83DD600CB for ; Fri, 8 Sep 2017 05:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB09528438 for ; Fri, 8 Sep 2017 05:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF53A28462; Fri, 8 Sep 2017 05:16:02 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 7200528438 for ; Fri, 8 Sep 2017 05:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754462AbdIHFPG (ORCPT ); Fri, 8 Sep 2017 01:15:06 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:61053 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754185AbdIHFPE (ORCPT ); Fri, 8 Sep 2017 01:15:04 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v885F3J9016101; Fri, 8 Sep 2017 00:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1504847703; bh=hxEtuklD3ov1IWOKXn1pMAAF3eN9fmlJGG/qyNbM1P0=; h=From:To:CC:Subject:Date; b=lK1PKG8qmCN3jo+fYFsZCEE1UrawsD/j1Ktu049rZUl9Z7bhFciCAZ2SidEYwZiQD Tz70iMNPADZgsKCq3wOKobjAjVIaBgjdPdWeklntEvVgCuV6dtZdO3PonxRw/DjG+d 5gt7zGpesYVwUnF1yLUMW80IkKJBATNYtRKpAJeY= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v885F3Yk017685; Fri, 8 Sep 2017 00:15:03 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 8 Sep 2017 00:15:02 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 8 Sep 2017 00:15:03 -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 v885ExFg019896; Fri, 8 Sep 2017 00:15:00 -0500 From: Keerthy To: , CC: , , , , Subject: [PATCH v3] pci: dwc: dra7xx: Add shutdown handler to cleanly turn off clocks Date: Fri, 8 Sep 2017 10:44:54 +0530 Message-ID: <1504847694-23701-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-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add shutdown handler to cleanly turn off clocks. This will help in cases of kexec where in a new kernel can boot abruptly. Signed-off-by: Keerthy Acked-by: Kishon Vijay Abraham I --- Changes in v3: * Pushed the function outside #ifdef CONFIG_PM_SLEEP. * Added more details to commit log. 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index 0f9adf2..ec8f842 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c @@ -794,6 +794,19 @@ static int dra7xx_pcie_resume_noirq(struct device *dev) } #endif +void dra7xx_pcie_shutdown(struct platform_device *pdev) +{ + struct dra7xx_pcie *dra7xx = dev_get_drvdata(&pdev->dev); + int ret; + + ret = pm_runtime_put_sync(&pdev->dev); + if (ret < 0) + dev_dbg(&pdev->dev, "pm_runtime_put_sync failed\n"); + + pm_runtime_disable(&pdev->dev); + dra7xx_pcie_disable_phy(dra7xx); +} + static const struct dev_pm_ops dra7xx_pcie_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend, dra7xx_pcie_resume) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend_noirq, @@ -807,5 +820,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);