Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3524167imm; Sun, 14 Oct 2018 22:45:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV60HWpzdhQBLYtEpL/eGaSC3NXSrYbl+wufRidMOIlDEo61SH1bck3jKeiA2pIz2e+eFPsmm X-Received: by 2002:aa7:8305:: with SMTP id t5-v6mr16029674pfm.81.1539582345677; Sun, 14 Oct 2018 22:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539582345; cv=none; d=google.com; s=arc-20160816; b=qy96ji+XPycQtQMWp223A36k+Ly9jZhBcPldk5gSAQOuCqPX+nHGEK7Abf/jhVJYak foG84XMv1pnYEczshDtbQD912kqZ8iPDp4F+tF4flXA0GGwGI93dn8mGqfVVNqK3AApI Fn5jY8L6rHnqdznfuY5HLJ3QgIHHWG6g4Ym3hQ2o1PCwEZte2VBRZfdxN0oIWAXPh1TW Q6OKborWK7qWChWZKMMrGK66IhMninSOLuf30PThEL+9SInn9Xech7qOerMiSPMIEvaz GmE+MLiSQeMsFj1SLrPAOJ9iDzZYD8DU+2edlP7sJsfzUoUjrnchW57Hfc4DVzr9ekj8 hrQg== 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=Q3bcIzLUtK60yxsFoZnP4oocEw3su4r++a7uDa2GQB4=; b=wgguhwPZ/7pSa4o8czCrsBRJ5e/9LjJXHjaA3XlsF1OOGzvDc/GQ+9cOeganOy5VoD xYo7FyTydg42SIzFAWzh8/jHN32o4gkWCuDEFYeU8lEvPYnt0gjijqtiqB/jrJAC+Kpp VbZEx8w0RY6U62q663eSarlQf4n7JKbZhBPgghiLjnLD7d3RTKTpGH1M9xTVwpGrhZ1K IWbDFWBuGMJ4pERPFOWOcb8jzXufmzplO1ZuUg/09W+B9puh6sQ4jJxwdHIRpxucNTID cfxgxzhI27WX5Y7aTxmoJRnbCqZS03gkgHvo9oEiglebYjDS9EuS0KvZiyd1CzkvgAca lFsg== 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 t33-v6si9616421pgk.141.2018.10.14.22.45.30; Sun, 14 Oct 2018 22:45:45 -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 S1726642AbeJON2n (ORCPT + 99 others); Mon, 15 Oct 2018 09:28:43 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:38369 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726539AbeJON2n (ORCPT ); Mon, 15 Oct 2018 09:28:43 -0400 X-UUID: 7b48a999d39046b4939bdd77ec4cd215-20181015 X-UUID: 7b48a999d39046b4939bdd77ec4cd215-20181015 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1857975892; Mon, 15 Oct 2018 13:44:58 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 15 Oct 2018 13:44:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 15 Oct 2018 13:44:55 +0800 From: To: , , , , , , CC: , , , , , , , , , Subject: [PATCH v7 7/9] PCI: mediatek: Add system PM support for MT2712 and MT7622 Date: Mon, 15 Oct 2018 13:44:45 +0800 Message-ID: <1539582287-9171-8-git-send-email-honghui.zhang@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1539582287-9171-1-git-send-email-honghui.zhang@mediatek.com> References: <1539582287-9171-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 57D238B6B36C32FBB21E2365C21D2A27CAE1B1B2E22E99DC9C9AAC3B6F46C66E2000: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 --- 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 d3f4694..42cf2a4 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