From: Thomas Richard <thomas.richard@bootlin.com>
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 <thomas.richard@bootlin.com>
Subject: [PATCH] net: ethernet: ti: am65-cpsw: improve suspend/resume support for J7200
Date: Tue, 28 Nov 2023 14:19:36 +0100 [thread overview]
Message-ID: <20231128131936.600233-1-thomas.richard@bootlin.com> (raw)
From: Gregory CLEMENT <gregory.clement@bootlin.com>
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 <gregory.clement@bootlin.com>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
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
next reply other threads:[~2023-11-28 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 13:19 Thomas Richard [this message]
2023-11-29 12:38 ` [PATCH] net: ethernet: ti: am65-cpsw: improve suspend/resume support for J7200 Roger Quadros
2023-11-29 13:14 ` Dan Carpenter
2023-11-29 13:17 ` Gregory CLEMENT
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231128131936.600233-1-thomas.richard@bootlin.com \
--to=thomas.richard@bootlin.com \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=grygorii.strashko@ti.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rogerq@kernel.org \
--cc=s-vadapalli@ti.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=u-kumar1@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).