Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2037109lqp; Tue, 16 Apr 2024 05:54:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7K4LfsqsRXHewd1ELQG4IaCes9O/rmhE+ysLO/r2JAq0A4ZcCzzQUeg+RZHYBtQ6q0n7JMS8vDJU1muolOsXZ7LPhe2+8v1rcJ7ZbqQ== X-Google-Smtp-Source: AGHT+IEk0vrVg4ysD4yjoIrdKsgNOqE1oA5RtK5pOvNMm304b37HEDMhr/MRc7DjTgQ9IiobdQjX X-Received: by 2002:a17:906:c78d:b0:a51:ae39:d385 with SMTP id cw13-20020a170906c78d00b00a51ae39d385mr7658027ejb.1.1713272079792; Tue, 16 Apr 2024 05:54:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713272079; cv=pass; d=google.com; s=arc-20160816; b=OZRpWQJcPz57K5ILgPvu5yXRyB0m4rrgPXP+pSTPOQK1grCkyKVCKV+tEXJeaAVIBj xHgA792CWpp5mPiifTLqtPWJQ6BYonDkSxCauQ13nx96c+abYuDHV3mwz5GrrQK0S9on 6DtB7/l87ayLfhwJplBYinUVDbJ4EfYvVkbOvmS1/YipF2VP9YY95QuS5izDaoQzSp/1 IwhA/P3eElIDSrMBxtZRC7GHZzSe+b7eht31qW28Yr2oy88HuB3ssLAikk0SdU5DppIk 7pdw/jmD2ACji4fTjFR08L0Dqmm5qgFlsjI3Hk/d4Fw9g2Y45j5+hf4pdOjZBH7F5rsE gdfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=7ro+3bzijX1lOO7JWK3H90lUuZ5Kj2+U5keyLVtzdlk=; fh=GkNdvG04Lunqqv1Jt68/BI66vXiv28hSSvpkD3jAO7w=; b=FkL47Oxfjkb0kPF4bsivfJcEIHEi5DEybT+loQJJedEtdFKzAs68U7ARmDC/8acGui l/aOWyeekaCrAeJ/K3np1d92M8npVGp5hdBgNyAh+D3rf3mo/iFLDY5q1xfpi+xhW9w+ wuNu0gCqmmNqI08OE7eV1qV+QSCPZAvrDUQb7bhFWLF29QcSg5bQy0lSAhRyV2NTc8nq 6mu8v8D5p2zb3Bx6tRqwRz0l9JvjGEevSdvG/7ru7lVwWzlN1asilRt/QWny6cO9SAoH 0p7QeYa59IXpTGubbpV6zQXwLFS3vbeZ/Lh7thB/edFVuASfuLGdj6jkO/ML4DCT8Kre OJtw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pAuP0kbK; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-146830-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cw12-20020a170906478c00b00a52526f7848si3478818ejc.527.2024.04.16.05.54.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 05:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146830-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pAuP0kbK; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-146830-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 850351F22834 for ; Tue, 16 Apr 2024 12:54:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F357212DDBF; Tue, 16 Apr 2024 12:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pAuP0kbK" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65C1312D1FC for ; Tue, 16 Apr 2024 12:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271997; cv=none; b=RPznlvcC/YW/xYNFTE0HH7Tuha+dQvMpwX5aIxFQj7//kB6cDFBwcW+M+N+NEJWoWCAv1VjTEBdolWkjjCHAsQKeKebVgVpvPnqIaCrrQXCJ96VFrxMkGXg3oMXARkrMoGubVnFnp2wXzTFvkw8FTfzhla+qyXyyN0dzL5e7g3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271997; c=relaxed/simple; bh=gFjxgSayQ1SfbalF5DRlC1huW5MRdAZQxlVPqDd7Vgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pbQ+Q3TCPDK64H36uBmEslp2c8HCrOjzOyx3gfuAJJgdsYvM+wnJlRmcZ0PAsscjwxHl2/6rMfoVX8J5kU39CZELOpiCcj8ywPdAWjgEfKIdw8xRckwHiwKqDAluxjO7pw85S3WxMSEGGom8hpnvoKuFB4Wi5amNDpDoIremAk8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pAuP0kbK; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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); -- 2.39.2