Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp629133rdb; Mon, 15 Jan 2024 08:20:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk3WFQugC7zFayZuz0VOoiA3N1YoUTvey8tv/rDKM7x8a1olrrSYBFRIA7NvACox2HexNE X-Received: by 2002:a17:907:1992:b0:a29:fb9a:a3a0 with SMTP id li18-20020a170907199200b00a29fb9aa3a0mr7440264ejc.1.1705335605602; Mon, 15 Jan 2024 08:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705335605; cv=none; d=google.com; s=arc-20160816; b=l37Y8XRRS7TDa3FCgIneaSdO9YnN8SGlByn2SfX5KmO9MJdrPV+IXTw4cGyyxZgGTG QCw2RT2ywgZ5CxuNqjHx8jlyqG5gZTs8jkJOojT2YURWFp5flsHKSz61TaXeM9icmUsc iGPMAPrvYnI4zLA5NUzBeHbT6qum/kQthRWbsUkiEYger65I3Y5Q9+nYEJrLlZhig8m/ d5Qsr0hzKO31f19QTmlp4l+3S7bGzcCCJODWyGMPmtPMOwSyOZO1I1oA/Hl23GkBBRPf k4cGCqgKYhXo9twWHllYGbzd4CFCZmoh+CeQMds460hLxP1Y3YL8l4ylN5Jk2zVdq4zR azHQ== ARC-Message-Signature: i=1; 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=ZG2Pox00yczUKsAlTmAE1lwg+/Kk7l0gD46+mEZfvAE=; fh=ihwxVJW8DyodhmdJo1IfhLUDNDWeXh+49SpWXYbpL2Y=; b=Wt6KYD+JFbr0uy69JVuJtOX1lSCX9hXnd0+jgDRNJ0n6I6qPrcjlZtOcRcAA/UKCQk lbDhUOPdUfsq8MRfJyuT6qXAWVHHa1ON7fL8M9fOlV7/y8inPcz5AdIZlI0zZhMq7LWp tukA22aWIonapXeGzvEot5/wpu5Y/yv8DYz3K2/pYKnPYAtgdHb4sy5VGVvo7We+/lam PQCYiV/SvANSIZvxxd3JaUQEDe9eMHTs2omSkt0nNnsxSwX/d36vvpdwC3nYP/owlrjo NF9n3OHPh8S8gMKlKjFKbqiPNbvc3umZ649O3RePETi1Hgkjlenr9VeZGv8TvKagPuQ2 /FbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XGvUOA+e; spf=pass (google.com: domain of linux-kernel+bounces-26244-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26244-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 hg27-20020a170906f35b00b00a26a9373372si3909149ejb.115.2024.01.15.08.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 08:20:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26244-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=XGvUOA+e; spf=pass (google.com: domain of linux-kernel+bounces-26244-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26244-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 5645E1F227A0 for ; Mon, 15 Jan 2024 16:20:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9D8919BD0; Mon, 15 Jan 2024 16:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XGvUOA+e" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 C27B618E34; Mon, 15 Jan 2024 16:16:29 +0000 (UTC) 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 26252C0010; Mon, 15 Jan 2024 16:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705335388; 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=ZG2Pox00yczUKsAlTmAE1lwg+/Kk7l0gD46+mEZfvAE=; b=XGvUOA+e6WdCR5PyqrZfuF3SK/PbCfdr6CrX72v2I0IcCGz6htsbkE35DqpOh78dCB30vx VmFbjwqxVuXofkTBoLio5wn+Osd0rYWMUhLDcrcdGQWTYKBf40QT8yDgCq+tZlbEUziIDf cvIITxE0+8Q9SQNpINfr3+L7LLsYBXMBKsqbthuzb85zrjiN8Q8aZHbWrsh0gqE6C6vpfF /FbHjbC8TGebFkQyb7tSjXBBq5QRt6ttYsD0fuZcjzEAi6fJCkjskscR8YBQuhHD9VKnfR GdU01PLTUzSM0c/Bo6VKZRp5iyooUBB62UGPMuBLkxyop3kw1iTa7PznPYj/hQ== From: Thomas Richard Date: Mon, 15 Jan 2024 17:14:52 +0100 Subject: [PATCH 11/14] 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-v1-11-84e55da52400@bootlin.com> References: <20240102-j7200-pcie-s2r-v1-0-84e55da52400@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v1-0-84e55da52400@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 , Tom Joseph , 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 alread_configured flag is cleared during 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 | 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 70413fca5776..31b2594e5942 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -3006,6 +3006,62 @@ static void cdns_torrent_phy_remove(struct platform_device *pdev) cdns_torrent_clk_cleanup(cdns_phy); } +#ifdef CONFIG_PM +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) + clk_disable_unprepare(cdns_phy->clk); + else + cdns_phy->already_configured = 0; + + 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_put(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 const struct dev_pm_ops cdns_torrent_phy_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_torrent_phy_suspend_noirq, + cdns_torrent_phy_resume_noirq) +}; +#endif + /* USB and DP link configuration */ static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = { {0x0002, PHY_PLL_CFG}, @@ -4577,6 +4633,7 @@ static struct platform_driver cdns_torrent_phy_driver = { .driver = { .name = "cdns-torrent-phy", .of_match_table = cdns_torrent_phy_of_match, + .pm = pm_ptr(&cdns_torrent_phy_pm_ops), } }; module_platform_driver(cdns_torrent_phy_driver); -- 2.39.2