Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3836871rdh; Tue, 28 Nov 2023 05:21:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4NzTL2fk4oyB9ATJYhaJuPLs72F2JsNXWn8kksxpTE3J6hPbLkIWpdSHxU+8uR/zlmiSC X-Received: by 2002:a05:6808:1488:b0:3b8:402d:578b with SMTP id e8-20020a056808148800b003b8402d578bmr22508157oiw.25.1701177684211; Tue, 28 Nov 2023 05:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701177684; cv=none; d=google.com; s=arc-20160816; b=u0IDnqtvb+/DD65jLUVZH02JrQ15nykCxDn6Kvi9lnjdifjqGFcH5lJo1N2q/SpIv5 bWCiqolilYtDinDkVS0+j9y4+5v5vlNb/1QNOBfVqGoX8GJgVSP07+qLVO6QjO/9T5df BFmYg3bresF8+kZ6lndQiDKlo2trogbGpswdq0XGQlig9J4nTB/7k8GS36rnPAHR0OQ1 o52hR1/YRSoBu5U/UDbK0PXvl9SuEGunITaWHt2xSX/rYezVkDACKetWv1hh1/XeoV2z e6O6TeAUID91Q61RkarY+e6fk71BeNzFGFmKrbirB0dAtx6DUzwUTpI3GQ8TVncO8MLN X0Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uG7hIl7at36uWKJHQ21nTIZih0E8GqWucxRcdCXoYHQ=; fh=UleJvHjLFnpnLoHUHmgjtb8EhjQMaItcjjOf8E357Q8=; b=FQnzzbqjrLxIObQPIAlOjOAhBdEBvjAGcVOlNxtZRXa50e1nUmiRmFV7zntKeZ23pS XZR1ZS+cKFOOQJjEalN1OitJ9rsuex+4LkhhX/xipfyRFOMOagcMKJHH9VnYZ2MrmHpS KC2IzimwOaMglrQupozuPvy+a+Tu4kw9mvB2j+xXLRFn291pLyBQXASLgpMHl+GecC8g T4ZiXvFdXRsWmjIdK5/fBSp2Pcz0B+IPd2g7Vg2g3cDRPBUYh+WKKCc3rqPngylB7Ka1 o4GKqzSAspzjkqyS0eYsmFEntXrkAT2HmxwRE2f+Y5kiFtb3100sY8q7za3wPTk5bKka FUQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="OL2Gbi/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a20-20020a63e854000000b005bd85b2f231si11683876pgk.298.2023.11.28.05.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 05:21:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="OL2Gbi/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C65DE8097E64; Tue, 28 Nov 2023 05:21:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344876AbjK1NU6 (ORCPT + 99 others); Tue, 28 Nov 2023 08:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343821AbjK1NU5 (ORCPT ); Tue, 28 Nov 2023 08:20:57 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2813D62; Tue, 28 Nov 2023 05:21:01 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 39C60C000C; Tue, 28 Nov 2023 13:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701177660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=uG7hIl7at36uWKJHQ21nTIZih0E8GqWucxRcdCXoYHQ=; b=OL2Gbi/I03qzlLOdV3y8RDkLDr2fYDmcARSVxreMVGFgfnRLhaHz4RuRSWXvKPfJSYFFvG KPrfiTjtSTHyf/JVyg+I9TZ1LT8u17m+OhCOkzC2SGmc0B3qpxN9VkyxqzMUXyVVyCCwDO J/4CcWDr0p2HU958mwSRHlcWWDAH3rr+W/5RJ38FBZCNH1+KWcO882LqRlFfkyfhEKRxkL c25599glt9Nit566C56v3UM9e/V8NYIT/uFmp8zvtb3rF4VVRTuMz37+RbXYLB7LMEHkxz Aj8vNYR7yBj9DMgyaTh+WngIkTSasROcHKGwJKsa339hipUODpV9XpjfaZ29jA== From: Thomas Richard To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, s-vadapalli@ti.com, rogerq@kernel.org, grygorii.strashko@ti.com, dan.carpenter@linaro.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard Subject: [PATCH] net: ethernet: ti: am65-cpsw: improve suspend/resume support for J7200 Date: Tue, 28 Nov 2023 14:19:36 +0100 Message-Id: <20231128131936.600233-1-thomas.richard@bootlin.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 28 Nov 2023 05:21:17 -0800 (PST) From: Gregory CLEMENT On J7200 the SoC is off during suspend, so the clocks have to be completely power down, and phy_set_mode_ext must be called again. Signed-off-by: Gregory CLEMENT Signed-off-by: Thomas Richard --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 25 ++++++++++++++++++++++++ drivers/net/ethernet/ti/am65-cpts.c | 11 +++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index ece9f8df98ae..e95ef30bd67f 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2115,6 +2115,27 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common) return ret; } +static int am65_cpsw_nuss_resume_slave_ports(struct am65_cpsw_common *common) +{ + struct device *dev = common->dev; + int i; + + for (i = 1; i <= common->port_num; i++) { + struct am65_cpsw_port *port; + int ret; + + port = am65_common_get_port(common, i); + + ret = phy_set_mode_ext(port->slave.ifphy, PHY_MODE_ETHERNET, port->slave.phy_if); + if (ret) { + dev_err(dev, "port %d error setting phy mode %d\n", i, ret); + return ret; + } + } + + return 0; +} + static void am65_cpsw_pcpu_stats_free(void *data) { struct am65_cpsw_ndev_stats __percpu *stats = data; @@ -3087,6 +3108,10 @@ static int am65_cpsw_nuss_resume(struct device *dev) if (common->rx_irq_disabled) disable_irq(common->rx_chns.irq); + ret = am65_cpsw_nuss_resume_slave_ports(common); + if (ret) + dev_err(dev, "failed to resume slave ports: %d", ret); + am65_cpts_resume(common->cpts); for (i = 0; i < common->port_num; i++) { diff --git a/drivers/net/ethernet/ti/am65-cpts.c b/drivers/net/ethernet/ti/am65-cpts.c index c66618d91c28..e6db5b61409a 100644 --- a/drivers/net/ethernet/ti/am65-cpts.c +++ b/drivers/net/ethernet/ti/am65-cpts.c @@ -1189,7 +1189,11 @@ void am65_cpts_suspend(struct am65_cpts *cpts) cpts->sr_cpts_ns = am65_cpts_gettime(cpts, NULL); cpts->sr_ktime_ns = ktime_to_ns(ktime_get_real()); am65_cpts_disable(cpts); - clk_disable(cpts->refclk); + + /* During suspend the SoC can be power off, so let's not only + * disable but also unprepare the clock + */ + clk_disable_unprepare(cpts->refclk); /* Save GENF state */ memcpy_fromio(&cpts->sr_genf, &cpts->reg->genf, sizeof(cpts->sr_genf)); @@ -1204,8 +1208,11 @@ void am65_cpts_resume(struct am65_cpts *cpts) int i; s64 ktime_ns; + /* During suspend the SoC can be power off, so let's not only + * enable but also prepare the clock + */ + clk_prepare_enable(cpts->refclk); /* restore state and enable CPTS */ - clk_enable(cpts->refclk); am65_cpts_write32(cpts, cpts->sr_rftclk_sel, rftclk_sel); am65_cpts_set_add_val(cpts); am65_cpts_write32(cpts, cpts->sr_control, control); -- 2.39.2