Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp556330imm; Fri, 28 Sep 2018 03:05:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV61tD2V9LWgigeWcLSRPOP+eFRtyrzcltqM3kecbk0NtwJw+jAVzdn/W16yQkfsjcY5rcvjT X-Received: by 2002:a62:ac15:: with SMTP id v21-v6mr16136777pfe.126.1538129154555; Fri, 28 Sep 2018 03:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538129154; cv=none; d=google.com; s=arc-20160816; b=n4xdbTi02WbRcsmHMmWDyAfuL1ceKF9douNCQGPMzV0oohwpoCyXdsytTyeBC+/p7v nM5u2QNfvHrsYlpKT8Z/HTipQOrhsgLT0dWB88D9xjXfK/t0n67tiqTv/3PtB19q8IvW bX2rlDC078hHxxR7BWryBPhkPMWCHupFLTOYbrsXdijsj1W6n1rTMLyArCvSxFrZa60E 4mFK/w/BMw+lWWyji+Me+UJueOO2RXwv05DQ2yoma1z2IkvN5FMlipK8u+CsRgs/Gw0S u0/OEJQK21YE7CkSLHAEqyxMCwipI7mbPJgmEiW5rX5h2qIu7B+FLMragHYl9ou5idJb NPmg== 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=uUweN50s4oU5VuPVrBGRnFiuPMGhdLuPi/lzLSA76YM=; b=EOAVSA80+MXfDhkFdAt8Z7fzyFFeAgRWAxRF6nYDTBwEliB3sxBRaoqevCAlQuGvN3 JMylrYw4lymTjfddmlMoVkyurxjwGv89dZmIF7+Fy+470WOKb6DWhVCmo8MCgps0Di5A hYcJCGnhfDcJU1k+yiZQ4q8OKUrcJX5NVC1trFHrWjy9QPw2YVPShglPqI8SadsfGPQ+ hMZxK/utpkgp2Y38HAkXCd8Bj0TN0YA1dg20iJaNpowJZL7UMvUg9QHKJ4kcy8t/GtrZ p3J4NyVAqu+NqFQXROVz3zCF88tHtNGpvGuZ0jQkrauYmdXYr+qkRQF9RYR+ixNzpyQT BY0w== 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 59-v6si4365849plp.87.2018.09.28.03.05.38; Fri, 28 Sep 2018 03:05:54 -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 S1729438AbeI1Q2P (ORCPT + 99 others); Fri, 28 Sep 2018 12:28:15 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:34120 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729093AbeI1Q14 (ORCPT ); Fri, 28 Sep 2018 12:27:56 -0400 X-UUID: ad15c5d6b8df463ba1ad7713e0defb71-20180928 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 339698027; Fri, 28 Sep 2018 18:04:50 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 28 Sep 2018 18:04:49 +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; Fri, 28 Sep 2018 18:04:48 +0800 From: To: , , , , , , CC: , , , , , , , , , Subject: [PATCH v5 7/9] PCI: mediatek: Add system pm support for MT2712 and MT7622 Date: Fri, 28 Sep 2018 18:04:38 +0800 Message-ID: <1538129080-8206-8-git-send-email-honghui.zhang@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1538129080-8206-1-git-send-email-honghui.zhang@mediatek.com> References: <1538129080-8206-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain 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 be38b38..bd1bde3 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -1172,6 +1172,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, @@ -1204,6 +1253,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