Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3813792ybk; Tue, 19 May 2020 13:36:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynXPlHPWFYf+BeL0GH6lr1uMzTEsuinWA4yfo51sCPf+eafwGO4Esc0NJnMqnPMfVIVa2K X-Received: by 2002:aa7:d718:: with SMTP id t24mr601754edq.20.1589920614570; Tue, 19 May 2020 13:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589920614; cv=none; d=google.com; s=arc-20160816; b=Wus20B8VFHebpL2IZLLwQrue173+CCMW3S8JA6S9/FcS5he/8n1IH3oCFRc2zbLU6L rc/BFjJfi+dRTLt20W92hq+u3bLjwStlPr81C5iB1fi61EwtdLKacTwf/NTGq3Gdat8w nsQpe4AAhtHB32QoSOwhRE7bfNDT1uUB9qcrVorXtZI2zYy6P9pypNxedYnLYq7p2AsH z0LFas7mvAzv0HuSzTW5SzVbdQfV1e8J0xyXy1Qt5TBwNGvnSiBSChdWZP6g9zAqrTsk wHrNg85jBygQEx8rZsLFBB8uqXl9NazHNTuqUGZsx0tmm46N5i4+RHFtKEYnWGj+NA+A Rl2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=J281k52JLBet2aI7yPc79j0xBp0Ckelf4qDNoFJvJD8=; b=zblv6Oo2JA849t62/qVeMbP4Cxhwe//uB8LTUkhtPEmdv1xsmtowgXOA6GfAijIEzx MuztovXPqo8MxDAdLJmvdCQbH0cmz/bkggJwWlm2iOjpy8pg/FGompiH1U3j0YwYv961 jyrr6B92mo3/zC2X3YVuquyKEEv9/77x/phkXBR6TTuM2aBt+sb9IvlkRXmlexWPXECF AkelXKMTtr1Kmrh7gpd0sGrkpNhqfeT5cNNbg1G0aLTSLuyQitEllu8Lc6wzMp5miO83 C4caeltZF4jhxseIC43/ZKWxUWsxDz5NQ4Psg103fkwAxxYcNHp+ZyT2L7IdqTKv36lc FhSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="BU/nji5f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si581957ejv.608.2020.05.19.13.36.31; Tue, 19 May 2020 13:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="BU/nji5f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbgESUe4 (ORCPT + 99 others); Tue, 19 May 2020 16:34:56 -0400 Received: from rnd-relay.smtp.broadcom.com ([192.19.229.170]:35098 "EHLO rnd-relay.smtp.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgESUex (ORCPT ); Tue, 19 May 2020 16:34:53 -0400 Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 141FD30D648; Tue, 19 May 2020 13:33:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 141FD30D648 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1589920409; bh=UyoqqGo1D4jVTiHXaSkn4arGidmJGLFdMWKH3sQlBYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BU/nji5fXvfof8GIii3uZh/oVDoLJG1BaCMzzhtWfPNXWfGBVAO4J2MyH+pVqTySu mNyQmER8FETLGGJ5o/n8B7yvTAiKTndwD9wbsIdOdkNACdMJVFy9saT668JpnB3L0O o110i9gly2AuBQDpcePbdf+nSs+bA1ja7kmt6+pc= Received: from stbsrv-and-01.and.broadcom.net (stbsrv-and-01.and.broadcom.net [10.28.16.211]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 1E0F6140069; Tue, 19 May 2020 13:34:50 -0700 (PDT) From: Jim Quinlan To: james.quinlan@broadcom.com, Nicolas Saenz Julienne Cc: Jim Quinlan , Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE), linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-pci@vger.kernel.org (open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 05/15] PCI: brcmstb: Add suspend and resume pm_ops Date: Tue, 19 May 2020 16:34:03 -0400 Message-Id: <20200519203419.12369-6-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519203419.12369-1-james.quinlan@broadcom.com> References: <20200519203419.12369-1-james.quinlan@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Quinlan Broadcom Set-top (BrcmSTB) boards typically support S2, S3, and S5 suspend and resume. This commit enables the PCIe driver to do so. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c1cf4ea7d3d9..39993203b991 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -972,6 +972,49 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) brcm_pcie_bridge_sw_init_set(pcie, 1); } +static int brcm_pcie_suspend(struct device *dev) +{ + struct brcm_pcie *pcie = dev_get_drvdata(dev); + int ret = 0; + + brcm_pcie_turn_off(pcie); + clk_disable_unprepare(pcie->clk); + + return ret; +} + +static int brcm_pcie_resume(struct device *dev) +{ + struct brcm_pcie *pcie = dev_get_drvdata(dev); + void __iomem *base; + u32 tmp; + int ret; + + base = pcie->base; + clk_prepare_enable(pcie->clk); + + /* Take bridge out of reset so we can access the SERDES reg */ + brcm_pcie_bridge_sw_init_set(pcie, 0); + + /* SERDES_IDDQ = 0 */ + tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + u32p_replace_bits(&tmp, 0, + PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK); + writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + + /* wait for serdes to be stable */ + udelay(100); + + ret = brcm_pcie_setup(pcie); + if (ret) + return ret; + + if (pcie->msi) + brcm_msi_set_regs(pcie->msi); + + return 0; +} + static void __brcm_pcie_remove(struct brcm_pcie *pcie) { brcm_msi_remove(pcie); @@ -1090,12 +1133,18 @@ static int brcm_pcie_probe(struct platform_device *pdev) MODULE_DEVICE_TABLE(of, brcm_pcie_match); +static const struct dev_pm_ops brcm_pcie_pm_ops = { + .suspend_noirq = brcm_pcie_suspend, + .resume_noirq = brcm_pcie_resume, +}; + static struct platform_driver brcm_pcie_driver = { .probe = brcm_pcie_probe, .remove = brcm_pcie_remove, .driver = { .name = "brcm-pcie", .of_match_table = brcm_pcie_match, + .pm = &brcm_pcie_pm_ops, }, }; module_platform_driver(brcm_pcie_driver); -- 2.17.1