From patchwork Tue Apr 16 12:52:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13631792 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 3174AC04FFF for ; Tue, 16 Apr 2024 12:53:29 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4mRXwcj0IR6wEt9aaoNfJeyaJVFQKMDCaIXBStsfKsM=; b=Ab5KYHD/aHNWDD 59Qqn5E8KLMhkZdoeVjgJ3brkb1BjSoJChzQ00bNm7JD0MAXH7AIdRHOsyE1Yep6NmCKFW5iaoJqh WsSNFHB4LAaovhuWEu0y7hTy/azurowv54k9sAkUa+yBGadaf/oArgPBPEJYHp0pIaq4dSSIeWdIw okev7dj0xyG3FTiBTilGp61IX8SxHm+QVOBJZyZl9YC/afEqQNpoLwq2q0vXHLlZEzqxICM8XJ3c0 xOUd0upn7ak+WiLijCUTRy7ny9GEYtMnzXqv6vQHvwJhoBCotX1EePcwXwGEHnGohWJynqPRFnWLu yTu42DCQ6cOgW7MgPIUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwiJU-0000000CCFn-3fZD; Tue, 16 Apr 2024 12:53:28 +0000 Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwiJH-0000000CC91-1OQx for linux-phy@lists.infradead.org; Tue, 16 Apr 2024 12:53:19 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0715520007; Tue, 16 Apr 2024 12:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ro+3bzijX1lOO7JWK3H90lUuZ5Kj2+U5keyLVtzdlk=; b=pAuP0kbKH2mNvyLRFchYB99mZx1lASw7r5vAd3qlB+PghI3w/X5BQ9o5f6Z1QrOjk8xrbh ViEcxldjzJYec6GZcX7cdivXfv56ixaS9unm0Tt3JrxR/hM+Fsf71mu3U+bNdSRqd0Bs6a Y10DCgt93L3AdSepW61zVNZmV5428qZuhXQDJjjm3eBMZi9ReR9PaCPgmifVzTIEEglb4t 49CikAL7I/pEUPKKf4ivgiAub3Iv85cspsyxBRaGXY59ZJ5LjHWLZvuQL/529U/wpPJyyL +45DixWXo9ijBxRUEWXs/ssOC8U69ofkMYkZgV5+QV/L1uthKfYlz2LAVcxh0g== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:37 +0200 Subject: [PATCH 8/8] phy: cadence-torrent: add suspend and resume support MIME-Version: 1.0 Message-Id: <20240412-j7200-phy-s2r-v1-8-f15815833974@bootlin.com> References: <20240412-j7200-phy-s2r-v1-0-f15815833974@bootlin.com> In-Reply-To: <20240412-j7200-phy-s2r-v1-0-f15815833974@bootlin.com> To: Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_055315_793186_A78E15CB X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Add suspend and resume support. The already_configured flag is cleared during the suspend stage to force the PHY initialization during the resume stage. Co-developed-by: Théo Lebrun Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 0e3c755e6089..7e488788a367 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -3075,6 +3075,62 @@ static void cdns_torrent_phy_remove(struct platform_device *pdev) cdns_torrent_clk_cleanup(cdns_phy); } +static int cdns_torrent_phy_suspend_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int i; + + reset_control_assert(cdns_phy->phy_rst); + reset_control_assert(cdns_phy->apb_rst); + for (i = 0; i < cdns_phy->nsubnodes; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + + if (cdns_phy->already_configured) + cdns_phy->already_configured = 0; + else { + clk_disable_unprepare(cdns_phy->clk1); + clk_disable_unprepare(cdns_phy->clk); + } + + return 0; +} + +static int cdns_torrent_phy_resume_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int node = cdns_phy->nsubnodes; + int ret, i; + + ret = cdns_torrent_clk(cdns_phy); + if (ret) + return ret; + + /* Enable APB */ + reset_control_deassert(cdns_phy->apb_rst); + + if (cdns_phy->nsubnodes > 1) { + ret = cdns_torrent_phy_configure_multilink(cdns_phy); + if (ret) + goto put_lnk_rst; + } + + return 0; + +put_lnk_rst: + for (i = 0; i < node; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + reset_control_assert(cdns_phy->apb_rst); + + clk_disable_unprepare(cdns_phy->clk1); + clk_disable_unprepare(cdns_phy->clk); + + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(cdns_torrent_phy_pm_ops, + cdns_torrent_phy_suspend_noirq, + cdns_torrent_phy_resume_noirq); + /* USB and DP link configuration */ static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = { {0x0002, PHY_PLL_CFG}, @@ -5276,6 +5332,7 @@ static struct platform_driver cdns_torrent_phy_driver = { .driver = { .name = "cdns-torrent-phy", .of_match_table = cdns_torrent_phy_of_match, + .pm = pm_sleep_ptr(&cdns_torrent_phy_pm_ops), } }; module_platform_driver(cdns_torrent_phy_driver);