Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp525368rdb; Thu, 15 Feb 2024 07:22:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9kKIpjViUMpFE0oiCmeLtSyamUY+xmL6jZYzZlHfjzcKf80/NdNmGWQmkI10J09fi0Uw8TUh9KdT7By2khftBqtTAy0Nn0hgQTCrw3A== X-Google-Smtp-Source: AGHT+IHGfJD017EcF+UQkPnwTCQkq6ULXAArvSQHTP4ahP0P/RJXDC1xTemI/Lkxq9xxDJT7ff2C X-Received: by 2002:a05:620a:4009:b0:786:cb72:ac1 with SMTP id h9-20020a05620a400900b00786cb720ac1mr2629173qko.48.1708010565082; Thu, 15 Feb 2024 07:22:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708010565; cv=pass; d=google.com; s=arc-20160816; b=wiygmBOiMOq3a7S19u2LOxtTEIAjIqEpDyHMEazA+6f0L1Dk6uH547CnLfnv6mnHIz EJ+Zvs6mW79mpMwQtQEIhClprCLqCkdX9AhQ/oqRGRuiKU7hg0xZfJEarGotFRnbGxQ/ B5qorCHiDy5Zz28oofuyfd9UhE5++ay7ulWBPR4Kd6hVXhwOtXWEvAC+wImhcbYLfuqu e84EV8RA2A0/uXZLuOia3lYMjL4G1J+YdWXiX05OkFm9kiilNIZLUE7W8oKHJ+uPRWCY j1BRc4YwuPeVnqc2iL+IMkqSfFpMIXTOCFRbqeC19WaVgZACvTMGtEu/b7qMHAuheEbX VUbw== 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=o/n4B9LOnxLUUU5hzy10sFMmyfzqbPQwJ7bYymZxm6Y=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=K/No59NjUnVtMCwqxGM0boKTc70uU5l+lr/+5l7nWneYd2sPLasIDwm+xVx5TunZBk dROECCm9yjf7qCayS1vLSNi5QeETPU0OHeodyEcSrXjP7N+lD7QN5aeM83slyGuRp2bA RCtkS+0MAnYvd7m/uniUGtn+LYhMwi9qBd6evrWDcJ6xG40/c0sRMTPprBRq0WaOVtFv 67Vz0rSFD69nVQLch60vThN/ctRg/Z9ZhLb3yY8rXg6DX1OK3P+EiRGCmIYwkz2mWNWk WO3M3togXJJiXF2aeww+0oELhun38Wb7wqy9p0QqQBxvVEeJzCtOVyI6aXXgLOdKqOZE owMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=l3I5opKm; 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-67162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a12-20020a05620a124c00b00785cba0cd9csi1661768qkl.418.2024.02.15.07.22.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=l3I5opKm; 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-67162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67162-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D0F581C221C7 for ; Thu, 15 Feb 2024 15:22:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E858F1369AF; Thu, 15 Feb 2024 15:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="l3I5opKm" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 A56BB135A70; Thu, 15 Feb 2024 15:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708010299; cv=none; b=PthWYVaIUtMuwv7k1iXx3vdakYv7PIWebFHkACS9cXia6sXsY/mseDeM5lWoV5Y3yCWmTQeL2WoGgWKEr/xC2YgPauZDzLV/7QaX9j4aFSjbq9EnqdoUnP/Cuyflevn13ovar7sgEZaqw/CbUZwMAlaMYWFBgi9MR1qpoIXhULw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708010299; c=relaxed/simple; bh=57NrSEphSAhIcAkGiRglqT77eN7Fa3WCZ9Iq4SoEB6c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MdW0lBCBESYGqNRzwRlHJQbKK5qKm/moUbRlGFOnLHuHUXH+1LEW1rngcNKzAw2A/UHtfy8AKAlsFkZsiy8KiekeKOMwUSkPLa22hUmi2w/KH8jmAHn5quAJpuFfBiYAqsMt1WJfDjONlpC6+M+t6VfLxxj/0qWmavHHpUEs8iE= 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=l3I5opKm; arc=none smtp.client-ip=217.70.183.193 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 14ADC240010; Thu, 15 Feb 2024 15:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708010295; 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=o/n4B9LOnxLUUU5hzy10sFMmyfzqbPQwJ7bYymZxm6Y=; b=l3I5opKm97eEdSGimUZKWbPZ7j4nyfXC8xekOA6RNJorZoQZU1aNZ1i7LlRJODHPFcROAn RLVPqfOyjAybiSSn6fjgs1d3ooZn5lPeoOwBo8XThE93l2+ODfyeZnFwHLrkG8lp+cTdxL W9COtNdDor33jiWcSXCWVg3D3nvy8ixFe4kFgFYa1PvrHl+bOE4V6dvSmfAiwqoYW2EVCG nYIWXvrUfeZc+wtzJ0K78oF0NluedTd0yExPXEIn+ViF+pcSwGRQNbMZcMmI+oIidKy93i V+Sw1qcw3sSdBiUfd54tEfC9BuJKUbBBlux7vm3ccucA67rTy4tQ5KxIbmep5g== From: Thomas Richard Date: Thu, 15 Feb 2024 16:17:59 +0100 Subject: [PATCH v3 14/18] 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: <20240102-j7200-pcie-s2r-v3-14-5c2e4a3fac1f@bootlin.com> References: <20240102-j7200-pcie-s2r-v3-0-5c2e4a3fac1f@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v3-0-5c2e4a3fac1f@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@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. Based on the work of Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 52cadca4c07b..f8945a11e7ca 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -3005,6 +3005,59 @@ 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->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) + goto clk_cleanup; + + /* 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->clk); +clk_cleanup: + cdns_torrent_clk_cleanup(cdns_phy); + 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}, @@ -4576,6 +4629,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