Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3630633imm; Mon, 15 Oct 2018 01:10:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sBspDjdOygajEKy2qpF7/UCp7yzedr81BdK4boOmbrjx5k5b4CjxuKE6Pt5aH0HsHwJPo X-Received: by 2002:a17:902:2867:: with SMTP id e94-v6mr2911581plb.317.1539591043057; Mon, 15 Oct 2018 01:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539591043; cv=none; d=google.com; s=arc-20160816; b=IsSFuP2AkRay3MWfy5lZpcYjNkcczAdxKuEwZuXfJmsDQjwz4ZaLGFDhQD2meCCoS3 06ItLa7aT8C/DpHGMbJBz9TDhTtbNTtyQ2k8rjajx77mwdJAHDpiyReEThKv7gQoDaV1 bnDRSAYmHPvlYZs5b7MavjG+6tYbgrdkZOMHwsKfajnKty4VwIqxFOKAkh9ANLpRXWKZ dr/er1Hwv9S1n9Hie7q5pDDhJcII+GOodIwTevmp3qkEvxuEYKEYetevNeVLCON1PAFO CNnd1E/rVL0S/uGwcYNcbOZemvl3cdkRn98JzfsLsSo0DCnflFMpxzC7Sra+cO2AC9Zw h3jw== 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=og6383Fe6Yui8edBZYEj9hAZL2csJKcFL/zb+F+t8pY=; b=05XFFx2Y18vEkipSb87gLkOwbCDx33iAEWl4vYU9/Zs5ytq1M25r7GVgVcnb1QFutw 37x3k5JhIGc10IF+90XlT3duSlvR9vGUxWc0JXwwJKVbPCqbCCqXkdj0Ad4/R6HqQlAS gqZacmXE8r1tjaLF5I9S8Fp1sQGSSECwLGZWmpsH14XuS3UkfL0b3iH9gSuFhuG5+Zsd Uaayc61KTO6hBQyFlJvkHOPCJP11eqeyMbYABl5llG5gpE+7u3riNreRByEVqODGtD4R UosYQyJcYx+EyrwjCLKUAm8Ee4yFHD9bOv4+h+d0ku8PAo3/oc6Wbf8HJqLNo7CDbamc lofQ== 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 a16-v6si9138932pgw.187.2018.10.15.01.10.28; Mon, 15 Oct 2018 01:10:43 -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 S1726986AbeJOPxy (ORCPT + 99 others); Mon, 15 Oct 2018 11:53:54 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:24511 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726560AbeJOPxa (ORCPT ); Mon, 15 Oct 2018 11:53:30 -0400 X-UUID: d8a6cf64fc534310a2ff412eaae91d36-20181015 X-UUID: d8a6cf64fc534310a2ff412eaae91d36-20181015 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1867447799; Mon, 15 Oct 2018 16:09:12 +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; Mon, 15 Oct 2018 16:09:10 +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; Mon, 15 Oct 2018 16:09:09 +0800 From: To: , , , , , , CC: , , , , , , , , , , Subject: [PATCH v8 7/9] PCI: mediatek: Add system PM support for MT2712 and MT7622 Date: Mon, 15 Oct 2018 16:08:58 +0800 Message-ID: <1539590940-13355-8-git-send-email-honghui.zhang@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1539590940-13355-1-git-send-email-honghui.zhang@mediatek.com> References: <1539590940-13355-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 6D30B7141603E15AE431EFA99E648A82D6A536764A2473C7B2713D9E70D80EEA2000: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 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