From patchwork Fri Jul 3 11:03:44 2015 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: 6714171 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 60293C05AC for ; Fri, 3 Jul 2015 11:04:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83DAD207E7 for ; Fri, 3 Jul 2015 11:04:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3326D207E9 for ; Fri, 3 Jul 2015 11:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932123AbbGCLEg (ORCPT ); Fri, 3 Jul 2015 07:04:36 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:43008 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754708AbbGCLD7 (ORCPT ); Fri, 3 Jul 2015 07:03:59 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t63B3vCU018690; Fri, 3 Jul 2015 06:03:57 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t63B3vkx004726; Fri, 3 Jul 2015 06:03:57 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Fri, 3 Jul 2015 06:03:49 -0500 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 t63B3mgN009511; Fri, 3 Jul 2015 06:03:54 -0500 From: Kishon Vijay Abraham I To: , , , , , , CC: Subject: [PATCH 2/3] PCI: host: pcie-designware: add support for suspend and resume Date: Fri, 3 Jul 2015 16:33:44 +0530 Message-ID: <1435921425-15121-3-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1435921425-15121-1-git-send-email-kishon@ti.com> References: <1435921425-15121-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain platforms require MSE bit to be cleared to set the master in standby mode. (In DRA7xx TRM_vE, section 24.9.4.5.2.2.1 PCIe Controller Master Standby Behavior advises to use the clearing of the local MSE bit to set the master in standby. Without this some of the clocks do not idle). Cleared the MSE bit on suspend and enabled it back on resume. This is required to get suspend/resume working. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sekhar Nori --- drivers/pci/host/pcie-designware.c | 20 ++++++++++++++++++++ drivers/pci/host/pcie-designware.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index 69486be..cfb2bd6 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c @@ -811,6 +811,26 @@ void dw_pcie_setup_rc(struct pcie_port *pp) dw_pcie_writel_rc(pp, val, PCI_COMMAND); } +void dw_pcie_suspend_rc(struct pcie_port *pp) +{ + u32 val; + + /* clear MSE */ + dw_pcie_readl_rc(pp, PCI_COMMAND, &val); + val &= ~PCI_COMMAND_MEMORY; + dw_pcie_writel_rc(pp, val, PCI_COMMAND); +} + +void dw_pcie_resume_rc(struct pcie_port *pp) +{ + u32 val; + + /* set MSE */ + dw_pcie_readl_rc(pp, PCI_COMMAND, &val); + val |= PCI_COMMAND_MEMORY; + dw_pcie_writel_rc(pp, val, PCI_COMMAND); +} + MODULE_AUTHOR("Jingoo Han "); MODULE_DESCRIPTION("Designware PCIe host controller driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/pci/host/pcie-designware.h b/drivers/pci/host/pcie-designware.h index d0bbd27..0df2dfa 100644 --- a/drivers/pci/host/pcie-designware.h +++ b/drivers/pci/host/pcie-designware.h @@ -83,5 +83,7 @@ void dw_pcie_msi_init(struct pcie_port *pp); int dw_pcie_link_up(struct pcie_port *pp); void dw_pcie_setup_rc(struct pcie_port *pp); int dw_pcie_host_init(struct pcie_port *pp); +void dw_pcie_suspend_rc(struct pcie_port *pp); +void dw_pcie_resume_rc(struct pcie_port *pp); #endif /* _PCIE_DESIGNWARE_H */