From patchwork Sun Feb 20 19:33:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12752861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB013C433EF for ; Sun, 20 Feb 2022 19:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0dt8uARFRH0mX1/POkYqLTRmPakbeRW+db1Y4z6G+/Q=; b=llb0faeULWY0TQ H9bXtRj5t3ESfkpEC1zcyVMl1YiVM2frrcegpO/eDD/3WA1KxMV/L3npZvw3gRxQsgdbM5bIialjw OwhegIHdWD+vGO9Bnx+CCHvg9HzddB7Ue0ys2l5kj/vfVknyRQv47ioRnH+J+F/HV+ritF1QEUrbE pmj9gL5ZS74FTwxJGmfDOhY2KpAtRWz4rDY97P5cGBRo6b+PFIDiJfopLC5MUTfE87D9s8HvDMxge BjEv0gecSkDuGwbNc9dt2zm2G3MTILDK2LUSUSX/L0rq50vAkiLqj1my+1m+8E8Z15Uu4K8KSjUFX 3xuXaHyoAZMYuNc6ayBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLs4u-002EY5-4O; Sun, 20 Feb 2022 19:41:04 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLryZ-002BN6-Sm for linux-arm-kernel@lists.infradead.org; Sun, 20 Feb 2022 19:34:33 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 874B4B80DC0; Sun, 20 Feb 2022 19:34:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 459FFC340F0; Sun, 20 Feb 2022 19:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645385669; bh=7qdI8wPDTMSC9v1RpxsrNJM7/qlF5QfCj6/iWHqorwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkBuEFBjeMzxUUsJZegCsoC4wdoVsaslLn4Bkoao3kyhPb2BlVXp0jInqsPn+DI2a 5q0Go1TZW91qS6bQwpw+9okyDs/ONLzoRTFyLQVrAzYU7kuxu3kT33Fkaey29cfxn7 JeJS8M5/4MjqpmPiHBgbrqvi4BepFme1B0jFdOwV20Xx2UgfSW/JofCC8INynl3CD7 NURjcuA5E0JNYK6wr19laWrZAvRzDL/nUgqcvntNbjWj9mUBl3hNT1QHFUElV7hEV7 noALdsNigN7KpoblX5u99paX93PWZsiCbGBAbQignA4GXmuoy1916tmwqMBDr0GuTJ q/AcJ2fJdqgww== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi , Bjorn Helgaas Cc: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Marc Zyngier , pali@kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Gregory CLEMENT , Miquel Raynal , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH 16/18] PCI: aardvark: Add suspend to RAM support Date: Sun, 20 Feb 2022 20:33:44 +0100 Message-Id: <20220220193346.23789-17-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220193346.23789-1-kabel@kernel.org> References: <20220220193346.23789-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220220_113432_139358_4523DCA9 X-CRM114-Status: GOOD ( 16.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Miquel Raynal Add suspend and resume callbacks. The priority of these are "_noirq()", to workaround early access to the registers done by the PCI core through the ->read()/->write() callbacks at resume time. Signed-off-by: Miquel Raynal Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 3b51f47abd72..8c9ac7766ac7 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1896,6 +1896,44 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) return ret; } +static int __maybe_unused advk_pcie_suspend(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + + advk_pcie_disable_phy(pcie); + + clk_disable_unprepare(pcie->clk); + + return 0; +} + +static int __maybe_unused advk_pcie_resume(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(pcie->clk); + if (ret) + return ret; + + ret = advk_pcie_enable_phy(pcie); + if (ret) + return ret; + + advk_pcie_setup_hw(pcie); + + return 0; +} + +/* + * The PCI core will try to reconfigure the bus quite early in the resume path. + * We must use the _noirq() alternatives to ensure the controller is ready when + * the core uses the ->read()/->write() callbacks. + */ +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume) +}; + static int advk_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2171,6 +2209,7 @@ static struct platform_driver advk_pcie_driver = { .driver = { .name = "advk-pcie", .of_match_table = advk_pcie_of_match_table, + .pm = &advk_pcie_dev_pm_ops, }, .probe = advk_pcie_probe, .remove = advk_pcie_remove,