Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5004477imm; Tue, 16 Oct 2018 03:46:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61gxFquGDnd3Kf2pqE++lV2vmnjsDkN1VHveNa1uqJUECUediamLlaJceRT6jye5THgYGog X-Received: by 2002:a63:7156:: with SMTP id b22-v6mr19497733pgn.342.1539686780165; Tue, 16 Oct 2018 03:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539686780; cv=none; d=google.com; s=arc-20160816; b=UZGzRS1THMIcfjclzDKfetJwOz8l9an0HinHVSyQWEcsjBly3UGgTh3yzGZ1uGahZt nCTYU7tqHXtmJZZHV8WVMYnfo4nJU3RCqiPVKGNf3FCrHx3Fki5LCGqZQXp6iNi1wORe 9LhVrMHxmF1TdzvUTZdnMwJzQSB1qYKCt+RJnHXXZh5rrrrcJqPRmTJUWtZ+w9W0XvRA EeEygDtvrYCjLNGnfZmX5KBWAzhuxEkJ7C2/QYvmEiKJyXFeroR6RhZDuNSdDpj5l4iQ Qlex3FwOtAaaF7FVqw7OTxu7JnNz0KbQ/bl4Q2X5JMZ7kT2s1Q1hjfOSY71Vuz9JtaUg oTXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=oMx9Ye9M1/xNuYaddgpKD6D2NRkBCtwIGIlfk9DGtsY=; b=wEHWqKbA1PK7D9hucRK3YItB4Hd6OaR0tkBjAvV1LAhVxdVq9HV9+X9AC08B4IrE7h G1FuSs9bD8pSVPXmTn7If3TfB+Ag81cOZw5XWPnpAxgpUyWhjUQ+WqONtAPFsa4isoRH RRjjrD06f5fqmoHYsvivi897opIF/yerWN7lHiQvvnGjGP80XLqLBGtdUlsjoq3pSeeM x8zxigcR2d9ZZtLCorQwu988V1IOBUeuzWY29HlQ9WxCuDWhBqisPJ5w3EBmjSIWbHJs HossnxEdE8641aZi36QWvA3E2Ksko4qegIqfFqixUKkCt/xi0c6bJvZLsjqtl3PeKYwN bOqw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13-v6si14111430pfc.257.2018.10.16.03.46.04; Tue, 16 Oct 2018 03:46:20 -0700 (PDT) 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 S1727210AbeJPSe7 (ORCPT + 99 others); Tue, 16 Oct 2018 14:34:59 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:3359 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726595AbeJPSe7 (ORCPT ); Tue, 16 Oct 2018 14:34:59 -0400 X-UUID: 4a0ebfe74a07434cbdb198172e1786f7-20181016 X-UUID: 4a0ebfe74a07434cbdb198172e1786f7-20181016 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 743982769; Tue, 16 Oct 2018 18:45:07 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 16 Oct 2018 18:45:05 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 16 Oct 2018 18:45:05 +0800 From: To: , , , , , , CC: , , , , , , , , , Subject: [PATCH v9 7/9] PCI: mediatek: Add system PM support for MT2712 and MT7622 Date: Tue, 16 Oct 2018 18:44:48 +0800 Message-ID: <1539686690-24068-8-git-send-email-honghui.zhang@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1539686690-24068-1-git-send-email-honghui.zhang@mediatek.com> References: <1539686690-24068-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: E9C3A0C36B9FC78C1DE3684B071B388B5CC6D940BC38888088C1B89EA22E76872000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Honghui Zhang In order to reduce the PCIe power consuming while system suspend, the physical layer should be gated. And the PCIe link should be re-established and the related control register values should be re-initialized after system resume. Register suspend_noirq & resume_noirq callback functions to allow PCIe to come up after resume from RAM. Signed-off-by: Honghui Zhang Acked-by: Ryder Lee --- drivers/pci/controller/pcie-mediatek.c | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 82d3d85..cf7e357 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -1168,6 +1168,55 @@ static int mtk_pcie_probe(struct platform_device *pdev) return err; } +static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) +{ + struct mtk_pcie *pcie = dev_get_drvdata(dev); + struct mtk_pcie_port *port; + + if (list_empty(&pcie->ports)) + return 0; + + list_for_each_entry(port, &pcie->ports, list) { + clk_disable_unprepare(port->pipe_ck); + clk_disable_unprepare(port->obff_ck); + clk_disable_unprepare(port->axi_ck); + clk_disable_unprepare(port->aux_ck); + clk_disable_unprepare(port->ahb_ck); + clk_disable_unprepare(port->sys_ck); + phy_power_off(port->phy); + phy_exit(port->phy); + } + + clk_disable_unprepare(pcie->free_ck); + + return 0; +} + +static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev) +{ + struct mtk_pcie *pcie = dev_get_drvdata(dev); + struct mtk_pcie_port *port, *tmp; + + if (list_empty(&pcie->ports)) + return 0; + + clk_prepare_enable(pcie->free_ck); + + list_for_each_entry_safe(port, tmp, &pcie->ports, list) + mtk_pcie_enable_port(port); + + /* In case of EP was removed while system suspend. */ + if (list_empty(&pcie->ports)) + clk_disable_unprepare(pcie->free_ck); + + return 0; +} + +static const struct dev_pm_ops mtk_pcie_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_pcie_suspend_noirq, + mtk_pcie_resume_noirq) +}; + static const struct mtk_pcie_soc mtk_pcie_soc_v1 = { .ops = &mtk_pcie_ops, .startup = mtk_pcie_startup_port, @@ -1200,6 +1249,7 @@ static struct platform_driver mtk_pcie_driver = { .name = "mtk-pcie", .of_match_table = mtk_pcie_ids, .suppress_bind_attrs = true, + .pm = &mtk_pcie_pm_ops, }, }; builtin_platform_driver(mtk_pcie_driver); -- 2.6.4