From nobody Mon Feb 9 11:36:51 2026 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 629B112BE8C for ; Tue, 16 Apr 2024 12:53:00 +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=1713271982; cv=none; b=Co52uTyk8UxL1qKow1D3aUdK4Lr9A5btxRyhu0kbBPxrPF+oY7FTyeGGzMBS6lKOggBzkV4j1gXPZYs61ZL7e2G02vLB8pCsUCfbE+TpR6g0sDgs+M+ul1T29Up2hVPlNh9dL0sv9eI3/Ykv2cORw10dUFLfWkbKPHllM68ckW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271982; c=relaxed/simple; bh=gDGwcPUlhrJ58tTxtAf4S10aFgybKlZmlLgO5JE33HE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AIkvclCzGHMjmte9LdYr32EZknBD8sn4kgsz5pWVSCKaywPb+vZylHkYzq8OQdonCTPQJMU6NBxwVfOGjxW1H7ZGPGFlnHHHNsqUNxABBBnambw+VgC6v5UtQwN6y2pNpM0k5rRIb0TSfHvHmLhZfFkjjt9cSS06AjCH67I5Koc= 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=WLbBzn5g; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WLbBzn5g" Received: by mail.gandi.net (Postfix) with ESMTPSA id 26AC020009; Tue, 16 Apr 2024 12:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271973; 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=9MU9XELe1rM5Qiqxbtkg8dW/yfnlPXWOR1yK6MM7gxg=; b=WLbBzn5gy3ph07VsIR980IaL+R79W7fITyjAVQdORLdCv59T3lKm2bJ//bK+PZLVmHSuU4 3bybP5lxjM52va46BJHwEI1GW8jaxeKX7+5fY/2XQgS/3qN8TbJlNfy3K43HM4q0t3/fzk EVZn9UMeKFnxAk/NjWQ9IgDvT0ppobvVOQIa23gLu08aW2nyoeR0zqOFtNAxPaIhxtGvWy IVAu6QhHDfpQF2qQq6w4FeCL8W/mpvBJbRiIiLtylHfxj10FcEcNQ9BK2UvPT7QqHXt95r kVIeex45iiRJd6lL43bwUUyGbZnbAATIq4BwWmNM41qlrjQTukj2O2mag8Z9CA== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:30 +0200 Subject: [PATCH 1/8] phy: ti: phy-j721e-wiz: use dev_err_probe() instead of dev_err() 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-1-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 Use dev_err_probe() instead of dev_err() in wiz_clock_init() to simplify the code and standardize the error output. Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 46 +++++++++++++++++++-------------------= ---- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 00d7e6a6de03..5fea4df9404e 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1088,11 +1088,10 @@ static int wiz_clock_init(struct wiz *wiz, struct d= evice_node *node) int i; =20 clk =3D devm_clk_get(dev, "core_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref_clk clock not found\n"); - ret =3D PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref_clk clock not found\n"); + wiz->input_clks[WIZ_CORE_REFCLK] =3D clk; =20 rate =3D clk_get_rate(clk); @@ -1122,11 +1121,10 @@ static int wiz_clock_init(struct wiz *wiz, struct d= evice_node *node) =20 if (wiz->data->pma_cmn_refclk1_int_mode) { clk =3D devm_clk_get(dev, "core_ref1_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref1_clk clock not found\n"); - ret =3D PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref1_clk clock not found\n"); + wiz->input_clks[WIZ_CORE_REFCLK1] =3D clk; =20 rate =3D clk_get_rate(clk); @@ -1137,11 +1135,10 @@ static int wiz_clock_init(struct wiz *wiz, struct d= evice_node *node) } =20 clk =3D devm_clk_get(dev, "ext_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "ext_ref_clk clock not found\n"); - ret =3D PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "ext_ref_clk clock not found\n"); + wiz->input_clks[WIZ_EXT_REFCLK] =3D clk; =20 rate =3D clk_get_rate(clk); @@ -1157,8 +1154,9 @@ static int wiz_clock_init(struct wiz *wiz, struct dev= ice_node *node) case J721S2_WIZ_10G: ret =3D wiz_clock_register(wiz); if (ret) - dev_err(dev, "Failed to register wiz clocks\n"); - return ret; + return dev_err_probe(dev, ret, "Failed to register wiz clocks\n"); + + return 0; default: break; } @@ -1167,16 +1165,15 @@ static int wiz_clock_init(struct wiz *wiz, struct d= evice_node *node) node_name =3D clk_mux_sel[i].node_name; clk_node =3D of_get_child_by_name(node, node_name); if (!clk_node) { - dev_err(dev, "Unable to get %s node\n", node_name); - ret =3D -EINVAL; + ret =3D dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_nam= e); goto err; } =20 ret =3D wiz_mux_of_clk_register(wiz, clk_node, wiz->mux_sel_field[i], clk_mux_sel[i].table); if (ret) { - dev_err(dev, "Failed to register %s clock\n", - node_name); + dev_err_probe(dev, ret, "Failed to register %s clock\n", + node_name); of_node_put(clk_node); goto err; } @@ -1188,16 +1185,15 @@ static int wiz_clock_init(struct wiz *wiz, struct d= evice_node *node) node_name =3D clk_div_sel[i].node_name; clk_node =3D of_get_child_by_name(node, node_name); if (!clk_node) { - dev_err(dev, "Unable to get %s node\n", node_name); - ret =3D -EINVAL; + ret =3D dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_nam= e); goto err; } =20 ret =3D wiz_div_clk_register(wiz, clk_node, wiz->div_sel_field[i], clk_div_sel[i].table); if (ret) { - dev_err(dev, "Failed to register %s clock\n", - node_name); + dev_err_probe(dev, ret, "Failed to register %s clock\n", + node_name); of_node_put(clk_node); goto err; } --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 9679912BEA9 for ; Tue, 16 Apr 2024 12:53:00 +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=1713271982; cv=none; b=g4nBvSs996pAgUHjlBSoYIaOuGamTjnWITBaBlRtfX1ULUe5NT00H2aX9L/cz+Mcfq+OuISg7QCGwkne/IYw+9eYWxM/olBM5NQfq4idWVKQoNGw1GP8TCC6jrqygLFZHy25/2E963THDZTHRlTCZG8BkLur8T2fAggyV+VJXfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271982; c=relaxed/simple; bh=fVFt3TspoIf3x4uHfvW0rMMbgwzq4+eKFDrqeSJaUQo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xm4MrJp0s7BcGnOQTvx3kxqFElrHrllUUmrQ3onaN5Q7ugeCmxvDRSEqskFpzXJ3FknF7059TOFVQHJFWz7pOV2A6Xfup0U9azgghIulWxvizYG4oRqZUnNm/gn1xMt1+IVqBnQ/u1349+dZ8dAZyW7ZRwN5kqPiWmQlpIN2R3E= 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=Q5ai+EHa; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Q5ai+EHa" Received: by mail.gandi.net (Postfix) with ESMTPSA id E46DF20010; Tue, 16 Apr 2024 12:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271979; 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=DkjYb/heaYMzCjQ4QnbfLecl4jtQfd543suxAgCkx34=; b=Q5ai+EHaCMUt1LHzoBzp0RKUivr1riPA7SfjAObRdy9sv11F78Z2/Z2uVARG4ibWFm6KJQ 7T5qEbMlrPGdB72T8U8EXbDN5udTOluG2lVK4Ktfe19oq7QXEy5h4owMDTuh4+VYhBJYra PIjpAltwcL7hCxDyMCFp8w4v+2f6SWckxX6Cju1FAx4TXg7b5CLTkDeWFp4f/YdmPgpKW7 xpNBzNNwi6/YTERptsBBLBsRXcSVL2s/P1wIcGWxIv9dLPR8fZqKRwS5TXE8SAJSNzV2A0 EzicZT71cPUzCyffhAgC9oH6el92omZVuB9HCFgZt8MVsFN6V7SrQ4gbGHL0AQ== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:31 +0200 Subject: [PATCH 2/8] phy: ti: phy-j721e-wiz: split wiz_clock_init() function 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-2-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 The wiz_clock_init() function mixes probe and hardware configuration. Rename the wiz_clock_init() to wiz_clock_probe() and move the hardware configuration part in a new function named wiz_clock_init(). This hardware configuration sequence must be called during the resume stage of the driver. Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 66 +++++++++++++++++++++++---------------= ---- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 5fea4df9404e..ba670109e7ad 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1076,26 +1076,12 @@ static int wiz_clock_register(struct wiz *wiz) return ret; } =20 -static int wiz_clock_init(struct wiz *wiz, struct device_node *node) +static void wiz_clock_init(struct wiz *wiz) { - const struct wiz_clk_mux_sel *clk_mux_sel =3D wiz->clk_mux_sel; - struct device *dev =3D wiz->dev; - struct device_node *clk_node; - const char *node_name; unsigned long rate; - struct clk *clk; - int ret; - int i; - - clk =3D devm_clk_get(dev, "core_ref_clk"); - if (IS_ERR(clk)) - return dev_err_probe(dev, PTR_ERR(clk), - "core_ref_clk clock not found\n"); =20 - wiz->input_clks[WIZ_CORE_REFCLK] =3D clk; - - rate =3D clk_get_rate(clk); - if (rate >=3D 100000000) + rate =3D clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK]); + if (rate >=3D REF_CLK_100MHZ) regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x1); else regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x3); @@ -1119,6 +1105,38 @@ static int wiz_clock_init(struct wiz *wiz, struct de= vice_node *node) break; } =20 + if (wiz->input_clks[WIZ_CORE_REFCLK1]) { + rate =3D clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK1]); + if (rate >=3D REF_CLK_100MHZ) + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); + else + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); + } + + rate =3D clk_get_rate(wiz->input_clks[WIZ_EXT_REFCLK]); + if (rate >=3D REF_CLK_100MHZ) + regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); + else + regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); +} + +static int wiz_clock_probe(struct wiz *wiz, struct device_node *node) +{ + const struct wiz_clk_mux_sel *clk_mux_sel =3D wiz->clk_mux_sel; + struct device *dev =3D wiz->dev; + struct device_node *clk_node; + const char *node_name; + struct clk *clk; + int ret; + int i; + + clk =3D devm_clk_get(dev, "core_ref_clk"); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref_clk clock not found\n"); + + wiz->input_clks[WIZ_CORE_REFCLK] =3D clk; + if (wiz->data->pma_cmn_refclk1_int_mode) { clk =3D devm_clk_get(dev, "core_ref1_clk"); if (IS_ERR(clk)) @@ -1126,12 +1144,6 @@ static int wiz_clock_init(struct wiz *wiz, struct de= vice_node *node) "core_ref1_clk clock not found\n"); =20 wiz->input_clks[WIZ_CORE_REFCLK1] =3D clk; - - rate =3D clk_get_rate(clk); - if (rate >=3D 100000000) - regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); - else - regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); } =20 clk =3D devm_clk_get(dev, "ext_ref_clk"); @@ -1141,11 +1153,7 @@ static int wiz_clock_init(struct wiz *wiz, struct de= vice_node *node) =20 wiz->input_clks[WIZ_EXT_REFCLK] =3D clk; =20 - rate =3D clk_get_rate(clk); - if (rate >=3D 100000000) - regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); - else - regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); + wiz_clock_init(wiz); =20 switch (wiz->type) { case AM64_WIZ_10G: @@ -1589,7 +1597,7 @@ static int wiz_probe(struct platform_device *pdev) goto err_get_sync; } =20 - ret =3D wiz_clock_init(wiz, node); + ret =3D wiz_clock_probe(wiz, node); if (ret < 0) { dev_warn(dev, "Failed to initialize clocks\n"); goto err_get_sync; --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 3CA7D12C531 for ; Tue, 16 Apr 2024 12:53:05 +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=1713271987; cv=none; b=jj8un3O8YsQQMpTID0Bz1ZOM7YlpyqKTZEQEYYfmQpdFQ1aS1pna/Y31BeM10ZTD2MROJVauIxiFp5J6NLSEWJ0Chu5Sy0H6HHx4ku4/P/1XEHjENJNC6ypDGy78JnKQFY/I5QRM8Fxx8shck3ru8WR16iUId8SAzBR8DHkVnb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271987; c=relaxed/simple; bh=sl5SRuv0DrtHW5bkZkmZdN6IxP9VaaJTX0VeczM4sbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uMg7HFM2qNJU20THc2Md0VmX9b1hKheOkPlZlL9T2nMeE9l598GY/waC3w9zEvB4HQH69IW8gOTeuzblysinmP7GqYg4KtwDhAYBAUvolpT3MgsdIllKPuFxXWIufu+oWNepiGoNCAWhxzsrA4cvqqjm4MMLLJ/axg3xC9pJ01k= 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=PnuH0l0l; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="PnuH0l0l" Received: by mail.gandi.net (Postfix) with ESMTPSA id D802D20007; Tue, 16 Apr 2024 12:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271984; 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=eSCKVt3PzenyfZAdSt+Uuc2sxOPAq2JS3OulPvLdYig=; b=PnuH0l0lvmrlNI/TjKBPEceAakQIcg0D6nTXGLXNxcGQuomiZOgahc2w4WGZgh9cmqZe+p 5x4UiNap8ydEjSPxH9upz/z131/oOvV0EACCmwXeS5EV8CeYFtpHXI4tFYOD+SalMWYnIo hbO4BoowDHIYbb0DNNX3Pt0WvuySI5NdsOT6xABNYzj4+OEDLUiQLJbMvJE3liEcC40thk F8/z9UxoaKHCjs6PGx5FR3k6D4sWFdtP9urojSMl+Hc9dOQYRcF/1uai3BNEbKLpuwdHk1 gIb5Ovj4fEx1Iaj25SJW9774f8ewuEoCGtDk0vX3w6TUIaSdqvKrSGjUHUSgPQ== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:32 +0200 Subject: [PATCH 3/8] phy: ti: phy-j721e-wiz: add 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-3-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 resume support. It has been tested on J7200 SR1.0 and SR2.0. Co-developed-by: Th=C3=A9o Lebrun Signed-off-by: Th=C3=A9o Lebrun Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index ba670109e7ad..7f626c597025 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1659,12 +1659,41 @@ static void wiz_remove(struct platform_device *pdev) pm_runtime_disable(dev); } =20 +static int wiz_resume_noirq(struct device *dev) +{ + struct device_node *node =3D dev->of_node; + struct wiz *wiz =3D dev_get_drvdata(dev); + int ret; + + /* Enable supplemental Control override if available */ + if (wiz->sup_legacy_clk_override) + regmap_field_write(wiz->sup_legacy_clk_override, 1); + + wiz_clock_init(wiz); + + ret =3D wiz_init(wiz); + if (ret) { + dev_err(dev, "WIZ initialization failed\n"); + goto err_wiz_init; + } + + return 0; + +err_wiz_init: + wiz_clock_cleanup(wiz, node); + + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq); + static struct platform_driver wiz_driver =3D { .probe =3D wiz_probe, .remove_new =3D wiz_remove, .driver =3D { .name =3D "wiz", .of_match_table =3D wiz_id_table, + .pm =3D pm_sleep_ptr(&wiz_pm_ops), }, }; module_platform_driver(wiz_driver); --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 DDDF512C7FA for ; Tue, 16 Apr 2024 12:53:10 +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=1713271992; cv=none; b=KSs1OU9IiN5p/Vuq9WN5tUHcSYsyt98p4+RS6+JsbR/7Bfbe2498wVpjkkqvrQ+AdeRh/+bkExNsrARbRmO1HR/kQJONnR/JEWgc0fbDf/SeEOFW6CU3VK2/OHLDgmLrqGHT8N8V23ZLThYgUOaRIHp4h+TKTGjL6QjgMbDKWSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271992; c=relaxed/simple; bh=HVzH+f/4Onq+eKPSjAJZZx+AmOCCQWtHzdUdxMuI95s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FggAvpjlRFTRrXAHmWCiowIiSjtvm9Biavd0bKc3bKtQRU114dwo1pmQFa5bjCwr0z2pV4y0P7scz15h/rFRkVp6LboqGtJc7r399pMJnwpES26Si4y9BFldcKbCP8QvTPyE3UoXXRRsI13LkMunqxlPFuXihmQrU72d4UN8kcU= 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=dY64t8KV; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dY64t8KV" Received: by mail.gandi.net (Postfix) with ESMTPSA id 77E912000C; Tue, 16 Apr 2024 12:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271989; 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=07LG+D8zx6QxscnqktDKHECH7SKyoDjzNohjqBXAyyE=; b=dY64t8KVvXqYXN0OQsRmz2nexv5PBGQTQNhgas/mAxHCuvLMHxg/zS9km5wdJ3FQ/Ky+XI 2VZ/7jHGdikgZvm3pQEbAzrIaU1JcEbilQ4ZSPp5OwSjbJolI1VVjLxaVzpzBHZPuOuXp8 ZKe67o3PVt4301atrthiuuXC7vXufdw+l+SN2x8zNOJCm9IMwzPEOpcZ27mePnQJcVelu0 ZORaXfpg3fH4kwKC8tlCiTv+5e4tRu0OOJRU0dmZAWOOLpdiwW7HGLVX57RRwvYrJjG+3o tIurJI4oiZNyyeU3kWByLoOErzBB6s8EtE/c2kls80p9wCyALeluq8H54LnBiA== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:33 +0200 Subject: [PATCH 4/8] phy: cadence-torrent: extract calls to clk_get from cdns_torrent_clk 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-4-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 Extract calls to clk_get from cdns_torrent_clk into a separate function. It needs to call cdns_torrent_clk at resume without looking up the clock. Co-developed-by: Th=C3=A9o Lebrun Signed-off-by: Th=C3=A9o Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 37 ++++++++++++++++++---------= ---- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadenc= e/phy-cadence-torrent.c index 95924a09960c..e64625859a07 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2699,20 +2699,29 @@ static int cdns_torrent_reset(struct cdns_torrent_p= hy *cdns_phy) return 0; } =20 +static int cdns_torrent_of_get_clk(struct cdns_torrent_phy *cdns_phy) +{ + /* refclk: Input reference clock for PLL0 */ + cdns_phy->clk =3D devm_clk_get(cdns_phy->dev, "refclk"); + if (IS_ERR(cdns_phy->clk)) + return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk), + "phy ref clock not found\n"); + + /* refclk1: Input reference clock for PLL1 */ + cdns_phy->clk1 =3D devm_clk_get_optional(cdns_phy->dev, "pll1_refclk"); + if (IS_ERR(cdns_phy->clk1)) + return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk1), + "phy PLL1 ref clock not found\n"); + + return 0; +} + static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) { - struct device *dev =3D cdns_phy->dev; unsigned long ref_clk1_rate; unsigned long ref_clk_rate; int ret; =20 - /* refclk: Input reference clock for PLL0 */ - cdns_phy->clk =3D devm_clk_get(dev, "refclk"); - if (IS_ERR(cdns_phy->clk)) { - dev_err(dev, "phy ref clock not found\n"); - return PTR_ERR(cdns_phy->clk); - } - ret =3D clk_prepare_enable(cdns_phy->clk); if (ret) { dev_err(cdns_phy->dev, "Failed to prepare ref clock: %d\n", ret); @@ -2745,14 +2754,6 @@ static int cdns_torrent_clk(struct cdns_torrent_phy = *cdns_phy) goto disable_clk; } =20 - /* refclk1: Input reference clock for PLL1 */ - cdns_phy->clk1 =3D devm_clk_get_optional(dev, "pll1_refclk"); - if (IS_ERR(cdns_phy->clk1)) { - dev_err(dev, "phy PLL1 ref clock not found\n"); - ret =3D PTR_ERR(cdns_phy->clk1); - goto disable_clk; - } - if (cdns_phy->clk1) { ret =3D clk_prepare_enable(cdns_phy->clk1); if (ret) { @@ -2846,6 +2847,10 @@ static int cdns_torrent_phy_probe(struct platform_de= vice *pdev) if (ret) return ret; =20 + ret =3D cdns_torrent_of_get_clk(cdns_phy); + if (ret) + goto clk_cleanup; + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); =20 if (!already_configured) { --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 9693112BF38 for ; Tue, 16 Apr 2024 12:53:12 +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=1713271994; cv=none; b=PpWjIpFaNW1rSFyB7T8ZOiIma9zbe4247tFhFUNyPIHcCEs9q7fAoSOZG9hyheJOd1tP8RPh6q6My3W9RVfRu8rLBS2o0VQ6v4gIFPV9BxxYb8GEaa1+Qp4ud/RLkgnVnUcdn9makuR4FYWHUusQB33euMiZAyAtD4TJsqqUO5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271994; c=relaxed/simple; bh=+rOSG0/7rUaquvxvPvPzJ2V5TIecUPb6fosGPKU86g0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hay/xjuzsIbBS13DC2kg7c7pRtdBZ//FW30wfmcmbRKtjjMfaMwTOUrhvurj5KeTjiT8kW0HzmgMu/sLaBR2n/PAZsENn3RYvaO9X6JVNaSzd0C6rdweG3T4hHC3sVA5JD7oY7CXNhLfePV7dqh5ALGn5jykYvfi2v3nvUJYw4Y= 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=Yo5yI32Z; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Yo5yI32Z" Received: by mail.gandi.net (Postfix) with ESMTPSA id 283072000F; Tue, 16 Apr 2024 12:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271991; 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=GeCvzxoz401XbYRIrAa+sB5K03ywKvZQVjVxSvr6zHY=; b=Yo5yI32Z1dWrtaDWz9EEueR7iCWMdQUFDQHa5+JZ4T4Sk5wnnd4YnxA9rq3MDH2DJ1S4nQ J8TtlgobqD31mj5UjvnaPKhYWnvU06AGk6L6vISVHXDcuyeymFbJjyPPuUdh1yu149mFeY qi+3O2Rf98JGdQi/CbJvhw0XATlG5cPkirtOZ5HRCon5qN9jPgHMc5GTGSa+12nOMvg9YJ vbT6A2kN4xtqglid9D0Eix8MuSd4MKqc00OwBZQAMvmhvN6SamCbs0q9vE14MZ6xPztWHY n6nAaWNysX56DPUDEgExe90h2a8luhPxkXiWUdFM0Kn5qFu+aFCF2JSjf1BYYQ== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:34 +0200 Subject: [PATCH 5/8] phy: cadence-torrent: register resets even if the phy is already configured 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-5-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 Resets are needed during suspend and resume stages. So they shall be registered during the probe even the phy is already initialized. The function cdns_torrent_reset is renamed cdns_torrent_of_get_reset() to make it clear. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadenc= e/phy-cadence-torrent.c index e64625859a07..7b3a409da185 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2678,7 +2678,7 @@ static int cdns_torrent_clk_register(struct cdns_torr= ent_phy *cdns_phy) return 0; } =20 -static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) +static int cdns_torrent_of_get_reset(struct cdns_torrent_phy *cdns_phy) { struct device *dev =3D cdns_phy->dev; =20 @@ -2847,6 +2847,10 @@ static int cdns_torrent_phy_probe(struct platform_de= vice *pdev) if (ret) return ret; =20 + ret =3D cdns_torrent_of_get_reset(cdns_phy); + if (ret) + goto clk_cleanup; + ret =3D cdns_torrent_of_get_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2854,10 +2858,6 @@ static int cdns_torrent_phy_probe(struct platform_de= vice *pdev) regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); =20 if (!already_configured) { - ret =3D cdns_torrent_reset(cdns_phy); - if (ret) - goto clk_cleanup; - ret =3D cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 A525512CD91 for ; Tue, 16 Apr 2024 12:53:13 +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=1713271995; cv=none; b=BQ99Qfox3LFVOhbx07A/BeVtSDQV6u6MMS6DDHGj5cx4L6nGa84OJLg7NpmeDgg3LfLBt22VMmlm5yWKjTv+vCAM/F/KAHD9DOXv2/V8RiiHOjljX4+SO5GOvC/jHlTy0+edwuuyw+e+SOod7NQ4VXpp+LKv7IQSNcYju7ak07E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271995; c=relaxed/simple; bh=f8C3Okw/s+xXWVTB5tLnmefazjTi4G3oMjAuSheWM1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mlaNftUmfJ4BoZ1DmZKc/S9RX+6CqjxuW3WPvMYyHpiLc2Zj2TEjlU1CY0ZEnRLGxZa8GE7rAuqAiKxmmwoHU/qYZb0s/eXF1vNJgsOK/OC4EyKjIzJ3B6PGTJVRr0+CgxUSjxJycyq11r3c+Oj2VjarkOvQDELqyilTTq8MEC4= 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=A1/F4t/v; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="A1/F4t/v" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5C59C2000B; Tue, 16 Apr 2024 12:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713271992; 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=Hw3jxUBFhu/KlEI+Ltv83Drt/dGgFaXZtN+apO8lfUc=; b=A1/F4t/v+kIbUoQdQJLmH3nvceEu5KWt9WdIGP2GzFrh+IyaqG+jBU6tA7T8bsoD+AHdUX oZUIUi5ggWNXCzhA6/tMjFcdru55BfK/+HgB1X/9WVykhP9umurMGF4T18TJNxcHrJLr/t JtM2AryoV+qEzjgRoHXbD5sYzZNVIHGwfamE2z366wNF1y+UZWYUFeem4UZrozzPz0RTlz aMfgmjnZhJYfFgxY1qUxVkfRG6S/xWRv4z4fMwPLqFlmYcUOnn22gZB4ncQRnRdnr1IUt1 t/RZuRK8X7xBI/jVZLjFeoYIsJyphsCKwsxF30hkBj0vR6hXsnOAY9h1/NG8LQ== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:35 +0200 Subject: [PATCH 6/8] phy: cadence-torrent: add already_configured to struct cdns_torrent_phy 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-6-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 already_configured to struct cdns_torrent_phy, so it can be used at differents stages. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadenc= e/phy-cadence-torrent.c index 7b3a409da185..0636d5d04817 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -360,6 +360,7 @@ struct cdns_torrent_phy { enum cdns_torrent_ref_clk ref_clk1_rate; struct cdns_torrent_inst phys[MAX_NUM_LANES]; int nsubnodes; + int already_configured; const struct cdns_torrent_data *init_data; struct regmap *regmap_common_cdb; struct regmap *regmap_phy_pcs_common_cdb; @@ -2808,7 +2809,6 @@ static int cdns_torrent_phy_probe(struct platform_dev= ice *pdev) struct device_node *child; int ret, subnodes, node =3D 0, i; u32 total_num_lanes =3D 0; - int already_configured; u8 init_dp_regmap =3D 0; u32 phy_type; =20 @@ -2855,9 +2855,9 @@ static int cdns_torrent_phy_probe(struct platform_dev= ice *pdev) if (ret) goto clk_cleanup; =20 - regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &cdns_phy->already_config= ured); =20 - if (!already_configured) { + if (!cdns_phy->already_configured) { ret =3D cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2937,7 +2937,7 @@ static int cdns_torrent_phy_probe(struct platform_dev= ice *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); =20 - if (!already_configured) + if (!cdns_phy->already_configured) gphy =3D devm_phy_create(dev, child, &cdns_torrent_phy_ops); else gphy =3D devm_phy_create(dev, child, &noop_ops); @@ -3023,7 +3023,7 @@ static int cdns_torrent_phy_probe(struct platform_dev= ice *pdev) goto put_lnk_rst; } =20 - if (cdns_phy->nsubnodes > 1 && !already_configured) { + if (cdns_phy->nsubnodes > 1 && !cdns_phy->already_configured) { ret =3D cdns_torrent_phy_configure_multilink(cdns_phy); if (ret) goto put_lnk_rst; --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 2E8BB12CD9B for ; Tue, 16 Apr 2024 12:53:14 +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=1713271995; cv=none; b=iomYqPywMiMGHme5rzvyJi0HYbbcsmVUmA5R9XLMe3XydO/LHH1TFtzRoloVe0kRbdz+Fotw/dFB1wywenfmvPog1hwYXzvHzk/JVfbK/xlJUMoqi7uVbTO1JBz6WCzkcZpm7kgcMeIgWiqDW5uFKTX0hpqtbH/IhBD1rSbX0II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713271995; c=relaxed/simple; bh=Ea8yruTncvXm5sRFL3kWVhDS9eIu8eUYRpop2ZECQjI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H+UiD7VQu13y5H/mBtM0Udkd9FAt7MCtUm+m15Ch/TUlMm8+AiSHzzVLPPKGvTSVsymJ93lKx5Ro+6tycliLyx+M3xYAhLXKZJrLf9khXCjrF7SI+iU6vhvXo7qIfzGURD+SiJC47LOsys/HlTDyuVMnPwDI75OF4ydhqPVjmjQ= 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=po115KdO; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="po115KdO" Received: by mail.gandi.net (Postfix) with ESMTPSA id 361F020010; 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=1713271992; 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=VPItTV/Mp42ilTj6tN8/dzU8kHkSA8+8bFCV4f5utvE=; b=po115KdOsG3t/mmyxxa9RY7XLvDp2aOIX3CTMiymKr+XSQXWVQ2i1h8s76kSAveyvXVMvt z7BFVWLI//KU1SXeA/E+P32LMXKZIpd2fnorFRgLc5VLQTcEo8P/PxryAGcp+GgvSsn4YT csvwnDjZSekOw+PLiuThbADaGQd9ory3lGJNUvBGSTUzybBsfNsN5vr/70Dx3yNZRkV9an rqBHflsM1PNBXTWp7Lg3qG33dra+zG/ENGYr9bFhMrNJaqWpsEmv8oNT+Dii1BddBKqtyd dw/+H1fkxg6vFSBnxL49k4REYVO/r/lCq6b5Mfs0yvFStVsU8uRTt42Rc3HCSQ== From: Thomas Richard Date: Tue, 16 Apr 2024 14:52:36 +0200 Subject: [PATCH 7/8] phy: cadence-torrent: remove noop_ops phy operations 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: quoted-printable Message-Id: <20240412-j7200-phy-s2r-v1-7-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 Even if a PHY is already configured, the PHY operations are needed during resume stage, as the PHY is in reset state. The noop_ops PHY operations is removed to always have PHY operations. The already_configured flag is checked at the begening of init, configure and poweron operations to keep the already_configured behaviour. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 30 +++++++++++++--------------= --- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadenc= e/phy-cadence-torrent.c index 0636d5d04817..0e3c755e6089 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -1595,6 +1595,9 @@ static int cdns_torrent_dp_configure(struct phy *phy, struct cdns_torrent_phy *cdns_phy =3D dev_get_drvdata(phy->dev.parent); int ret; =20 + if (cdns_phy->already_configured) + return 0; + ret =3D cdns_torrent_dp_verify_config(inst, &opts->dp); if (ret) { dev_err(&phy->dev, "invalid params for phy configure\n"); @@ -1630,6 +1633,12 @@ static int cdns_torrent_phy_on(struct phy *phy) u32 read_val; int ret; =20 + if (cdns_phy->already_configured) { + /* Give 5ms to 10ms delay for the PIPE clock to be stable */ + usleep_range(5000, 10000); + return 0; + } + if (cdns_phy->nsubnodes =3D=3D 1) { /* Take the PHY lane group out of reset */ reset_control_deassert(inst->lnk_rst); @@ -2308,6 +2317,9 @@ static int cdns_torrent_phy_init(struct phy *phy) u32 num_regs; int i, j; =20 + if (cdns_phy->already_configured) + return 0; + if (cdns_phy->nsubnodes > 1) { if (phy_type =3D=3D TYPE_DP) return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy); @@ -2445,19 +2457,6 @@ static const struct phy_ops cdns_torrent_phy_ops =3D= { .owner =3D THIS_MODULE, }; =20 -static int cdns_torrent_noop_phy_on(struct phy *phy) -{ - /* Give 5ms to 10ms delay for the PIPE clock to be stable */ - usleep_range(5000, 10000); - - return 0; -} - -static const struct phy_ops noop_ops =3D { - .power_on =3D cdns_torrent_noop_phy_on, - .owner =3D THIS_MODULE, -}; - static int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) { @@ -2937,10 +2936,7 @@ static int cdns_torrent_phy_probe(struct platform_de= vice *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); =20 - if (!cdns_phy->already_configured) - gphy =3D devm_phy_create(dev, child, &cdns_torrent_phy_ops); - else - gphy =3D devm_phy_create(dev, child, &noop_ops); + gphy =3D devm_phy_create(dev, child, &cdns_torrent_phy_ops); if (IS_ERR(gphy)) { ret =3D PTR_ERR(gphy); goto put_child; --=20 2.39.2 From nobody Mon Feb 9 11:36:51 2026 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pAuP0kbK" 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: quoted-printable 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=C3=A9o Lebrun Signed-off-by: Th=C3=A9o 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/cadenc= e/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); } =20 +static int cdns_torrent_phy_suspend_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy =3D dev_get_drvdata(dev); + int i; + + reset_control_assert(cdns_phy->phy_rst); + reset_control_assert(cdns_phy->apb_rst); + for (i =3D 0; i < cdns_phy->nsubnodes; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + + if (cdns_phy->already_configured) + cdns_phy->already_configured =3D 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 =3D dev_get_drvdata(dev); + int node =3D cdns_phy->nsubnodes; + int ret, i; + + ret =3D cdns_torrent_clk(cdns_phy); + if (ret) + return ret; + + /* Enable APB */ + reset_control_deassert(cdns_phy->apb_rst); + + if (cdns_phy->nsubnodes > 1) { + ret =3D cdns_torrent_phy_configure_multilink(cdns_phy); + if (ret) + goto put_lnk_rst; + } + + return 0; + +put_lnk_rst: + for (i =3D 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[] =3D { {0x0002, PHY_PLL_CFG}, @@ -5276,6 +5332,7 @@ static struct platform_driver cdns_torrent_phy_driver= =3D { .driver =3D { .name =3D "cdns-torrent-phy", .of_match_table =3D cdns_torrent_phy_of_match, + .pm =3D pm_sleep_ptr(&cdns_torrent_phy_pm_ops), } }; module_platform_driver(cdns_torrent_phy_driver); --=20 2.39.2