From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Vinod Koul <vkoul@kernel.org>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Jose Abreu <joabreu@synopsys.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Matthew Gerlach <matthew.gerlach@altera.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Keguang Zhang <keguang.zhang@gmail.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Jan Petrous <jan.petrous@oss.nxp.com>,
s32@nxp.com, Romain Gantois <romain.gantois@bootlin.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
Heiko Stuebner <heiko@sntech.de>,
Chen Wang <unicorn_wang@outlook.com>,
Inochi Amaoto <inochiama@gmail.com>,
Emil Renner Berthing <kernel@esmil.dk>,
Minda Chen <minda.chen@starfivetech.com>,
Drew Fustini <fustini@kernel.org>, Guo Ren <guoren@kernel.org>,
Fu Wei <wefu@redhat.com>,
Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Maxime Ripard <mripard@kernel.org>,
Shuang Liang <liangshuang@eswincomputing.com>,
Zhi Li <lizhi2@eswincomputing.com>,
Shangjuan Wei <weishangjuan@eswincomputing.com>,
"G. Jaya Kumaran" <vineetha.g.jaya.kumaran@intel.com>,
Clark Wang <xiaoning.wang@nxp.com>,
Linux Team <linux-imx@nxp.com>, Frank Li <Frank.Li@nxp.com>,
David Wu <david.wu@rock-chips.com>,
Samin Guo <samin.guo@starfivetech.com>,
Christophe Roullier <christophe.roullier@foss.st.com>,
Swathi K S <swathi.ks@samsung.com>
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
Drew Fustini <dfustini@tenstorrent.com>,
linux-sunxi@lists.linux.dev, linux-amlogic@lists.infradead.org,
linux-mips@vger.kernel.org, imx@lists.linux.dev,
linux-renesas-soc@vger.kernel.org,
linux-rockchip@lists.infradead.org, sophgo@lists.linux.dev,
linux-riscv@lists.infradead.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH v5 8/8] net: stmmac: qcom-ethqos: add support for sa8255p
Date: Fri, 07 Nov 2025 11:29:58 +0100 [thread overview]
Message-ID: <20251107-qcom-sa8255p-emac-v5-8-01d3e3aaf388@linaro.org> (raw)
In-Reply-To: <20251107-qcom-sa8255p-emac-v5-0-01d3e3aaf388@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Extend the driver to support a new model - sa8255p. Unlike the
previously supported variants, this one's power management is done in
the firmware using SCMI. This is modeled in linux using power domains so
add support for them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 230 ++++++++++++++++++---
1 file changed, 201 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 446f06b591a0b70992c7a431b56cf88c1b6718fd..d2922b4fb4bad1bb8dd77f1feaa7a260b97f0ae8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -7,6 +7,8 @@
#include <linux/platform_device.h>
#include <linux/phy.h>
#include <linux/phy/phy.h>
+#include <linux/pm_opp.h>
+#include <linux/pm_domain.h>
#include "stmmac.h"
#include "stmmac_platform.h"
@@ -81,6 +83,13 @@
#define SGMII_10M_RX_CLK_DVDR 0x31
+enum ethqos_pd_selector {
+ ETHQOS_PD_CORE = 0,
+ ETHQOS_PD_MDIO,
+ ETHQOS_PD_SERDES,
+ ETHQOS_NUM_PDS,
+};
+
struct ethqos_emac_por {
unsigned int offset;
unsigned int value;
@@ -98,6 +107,9 @@ struct ethqos_emac_driver_data {
struct ethqos_emac_pm_data {
const char *link_clk_name;
+ bool use_domains;
+ struct dev_pm_domain_attach_data pd;
+ unsigned int clk_ptp_rate;
};
struct ethqos_emac_match_data {
@@ -111,13 +123,20 @@ struct ethqos_emac_pm_ctx {
struct phy *serdes_phy;
};
+struct ethqos_emac_pd_ctx {
+ struct dev_pm_domain_list *pd_list;
+};
+
struct qcom_ethqos {
struct platform_device *pdev;
void __iomem *rgmii_base;
void __iomem *mac_base;
int (*configure_func)(struct qcom_ethqos *ethqos, int speed);
- struct ethqos_emac_pm_ctx pm;
+ union {
+ struct ethqos_emac_pm_ctx pm;
+ struct ethqos_emac_pd_ctx pd;
+ };
phy_interface_t phy_mode;
int serdes_speed;
int (*set_serdes_speed)(struct qcom_ethqos *ethqos);
@@ -330,6 +349,25 @@ static const struct ethqos_emac_match_data emac_sa8775p_data = {
.pm_data = &emac_sa8775p_pm_data,
};
+static const char * const emac_sa8255p_pd_names[] = {
+ "core", "mdio", "serdes"
+};
+
+static const struct ethqos_emac_pm_data emac_sa8255p_pm_data = {
+ .pd = {
+ .pd_flags = PD_FLAG_NO_DEV_LINK,
+ .pd_names = emac_sa8255p_pd_names,
+ .num_pd_names = ETHQOS_NUM_PDS,
+ },
+ .use_domains = true,
+ .clk_ptp_rate = 230400000,
+};
+
+static const struct ethqos_emac_match_data emac_sa8255p_data = {
+ .drv_data = &emac_v4_0_0_data,
+ .pm_data = &emac_sa8255p_pm_data,
+};
+
static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
{
struct device *dev = ðqos->pdev->dev;
@@ -411,6 +449,28 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
return 0;
}
+static int qcom_ethqos_domain_on(struct qcom_ethqos *ethqos,
+ enum ethqos_pd_selector sel)
+{
+ struct device *dev = ethqos->pd.pd_list->pd_devs[sel];
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ dev_err(ðqos->pdev->dev,
+ "Failed to enable the power domain for %s\n",
+ dev_name(dev));
+ return ret;
+}
+
+static void qcom_ethqos_domain_off(struct qcom_ethqos *ethqos,
+ enum ethqos_pd_selector sel)
+{
+ struct device *dev = ethqos->pd.pd_list->pd_devs[sel];
+
+ pm_runtime_put_sync(dev);
+}
+
static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed)
{
struct device *dev = ðqos->pdev->dev;
@@ -646,6 +706,13 @@ static int ethqos_set_serdes_speed_phy(struct qcom_ethqos *ethqos)
return phy_set_speed(ethqos->pm.serdes_phy, ethqos->serdes_speed);
}
+static int ethqos_set_serdes_speed_pd(struct qcom_ethqos *ethqos)
+{
+ struct device *dev = ethqos->pd.pd_list->pd_devs[ETHQOS_PD_SERDES];
+
+ return dev_pm_opp_set_level(dev, ethqos->serdes_speed);
+}
+
static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed)
{
if (ethqos->serdes_speed != speed) {
@@ -737,6 +804,27 @@ static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv)
phy_exit(ethqos->pm.serdes_phy);
}
+static int qcom_ethqos_pd_serdes_powerup(struct net_device *ndev, void *priv)
+{
+ struct qcom_ethqos *ethqos = priv;
+ struct device *dev = ethqos->pd.pd_list->pd_devs[ETHQOS_PD_SERDES];
+ int ret;
+
+ ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_SERDES);
+ if (ret < 0)
+ return ret;
+
+ return dev_pm_opp_set_level(dev, ethqos->serdes_speed);
+}
+
+static void qcom_ethqos_pd_serdes_powerdown(struct net_device *ndev, void *priv)
+{
+ struct qcom_ethqos *ethqos = priv;
+
+ /* TODO set level */
+ qcom_ethqos_domain_off(ethqos, ETHQOS_PD_SERDES);
+}
+
static int ethqos_clks_config(void *priv, bool enabled)
{
struct qcom_ethqos *ethqos = priv;
@@ -769,6 +857,61 @@ static void ethqos_clks_disable(void *data)
ethqos_clks_config(ethqos, false);
}
+static int ethqos_pd_clks_config(void *priv, bool enabled)
+{
+ struct qcom_ethqos *ethqos = priv;
+ int ret = 0;
+
+ if (enabled) {
+ ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_MDIO);
+ if (ret < 0) {
+ dev_err(ðqos->pdev->dev,
+ "Failed to enable the MDIO power domain\n");
+ return ret;
+ }
+
+ ethqos_set_func_clk_en(ethqos);
+ } else {
+ qcom_ethqos_domain_off(ethqos, ETHQOS_PD_MDIO);
+ }
+
+ return ret;
+}
+
+static int qcom_ethqos_pd_init(struct platform_device *pdev, void *priv)
+{
+ struct qcom_ethqos *ethqos = priv;
+ int ret;
+
+ /*
+ * Enable functional clock to prevent DMA reset after timeout due
+ * to no PHY clock being enabled after the hardware block has been
+ * power cycled. The actual configuration will be adjusted once
+ * ethqos_fix_mac_speed() is called.
+ */
+ ethqos_set_func_clk_en(ethqos);
+
+ ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_CORE);
+ if (ret)
+ return ret;
+
+ ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_MDIO);
+ if (ret) {
+ qcom_ethqos_domain_off(ethqos, ETHQOS_PD_CORE);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void qcom_ethqos_pd_exit(struct platform_device *pdev, void *data)
+{
+ struct qcom_ethqos *ethqos = data;
+
+ qcom_ethqos_domain_off(ethqos, ETHQOS_PD_MDIO);
+ qcom_ethqos_domain_off(ethqos, ETHQOS_PD_CORE);
+}
+
static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv)
{
struct plat_stmmacenet_data *plat_dat = priv->plat;
@@ -809,8 +952,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
"dt configuration failed\n");
}
- plat_dat->clks_config = ethqos_clks_config;
-
ethqos = devm_kzalloc(dev, sizeof(*ethqos), GFP_KERNEL);
if (!ethqos)
return -ENOMEM;
@@ -852,28 +993,63 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos->rgmii_config_loopback_en = drv_data->rgmii_config_loopback_en;
ethqos->has_emac_ge_3 = drv_data->has_emac_ge_3;
ethqos->needs_sgmii_loopback = drv_data->needs_sgmii_loopback;
-
- ethqos->pm.link_clk = devm_clk_get(dev, clk_name);
- if (IS_ERR(ethqos->pm.link_clk))
- return dev_err_probe(dev, PTR_ERR(ethqos->pm.link_clk),
- "Failed to get link_clk\n");
-
- ret = ethqos_clks_config(ethqos, true);
- if (ret)
- return ret;
-
- ret = devm_add_action_or_reset(dev, ethqos_clks_disable, ethqos);
- if (ret)
- return ret;
-
- ethqos->pm.serdes_phy = devm_phy_optional_get(dev, "serdes");
- if (IS_ERR(ethqos->pm.serdes_phy))
- return dev_err_probe(dev, PTR_ERR(ethqos->pm.serdes_phy),
- "Failed to get serdes phy\n");
-
- ethqos->set_serdes_speed = ethqos_set_serdes_speed_phy;
ethqos->serdes_speed = SPEED_1000;
- ethqos_update_link_clk(ethqos, SPEED_1000);
+
+ if (pm_data && pm_data->use_domains) {
+ ethqos->set_serdes_speed = ethqos_set_serdes_speed_pd;
+
+ ret = devm_pm_domain_attach_list(dev, &pm_data->pd,
+ ðqos->pd.pd_list);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to attach power domains\n");
+
+ plat_dat->clks_config = ethqos_pd_clks_config;
+ plat_dat->serdes_powerup = qcom_ethqos_pd_serdes_powerup;
+ plat_dat->serdes_powerdown = qcom_ethqos_pd_serdes_powerdown;
+ plat_dat->exit = qcom_ethqos_pd_exit;
+ plat_dat->init = qcom_ethqos_pd_init;
+ plat_dat->clk_ptp_rate = pm_data->clk_ptp_rate;
+
+ ret = qcom_ethqos_pd_init(pdev, ethqos);
+ if (ret)
+ return ret;
+
+ ret = qcom_ethqos_domain_on(ethqos, ETHQOS_PD_SERDES);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to enable the serdes power domain\n");
+ } else {
+ ethqos->set_serdes_speed = ethqos_set_serdes_speed_phy;
+
+ ethqos->pm.link_clk = devm_clk_get(dev, clk_name);
+ if (IS_ERR(ethqos->pm.link_clk))
+ return dev_err_probe(dev, PTR_ERR(ethqos->pm.link_clk),
+ "Failed to get link_clk\n");
+
+ ret = ethqos_clks_config(ethqos, true);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(dev, ethqos_clks_disable, ethqos);
+ if (ret)
+ return ret;
+
+ ethqos->pm.serdes_phy = devm_phy_optional_get(dev, "serdes");
+ if (IS_ERR(ethqos->pm.serdes_phy))
+ return dev_err_probe(dev, PTR_ERR(ethqos->pm.serdes_phy),
+ "Failed to get serdes phy\n");
+
+ ethqos_update_link_clk(ethqos, SPEED_1000);
+
+ plat_dat->clks_config = ethqos_clks_config;
+ plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config;
+
+ if (ethqos->pm.serdes_phy) {
+ plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
+ plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
+ }
+ }
+
ethqos_set_func_clk_en(ethqos);
plat_dat->bsp_priv = ethqos;
@@ -891,11 +1067,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
if (drv_data->dma_addr_width)
plat_dat->host_dma_width = drv_data->dma_addr_width;
- if (ethqos->pm.serdes_phy) {
- plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
- plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
- }
-
/* Enable TSO on queue0 and enable TBS on rest of the queues */
for (i = 1; i < plat_dat->tx_queues_to_use; i++)
plat_dat->tx_queues_cfg[i].tbs_en = 1;
@@ -905,6 +1076,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
static const struct of_device_id qcom_ethqos_match[] = {
{ .compatible = "qcom,qcs404-ethqos", .data = &emac_qcs404_data},
+ { .compatible = "qcom,sa8255p-ethqos", .data = &emac_sa8255p_data},
{ .compatible = "qcom,sa8775p-ethqos", .data = &emac_sa8775p_data},
{ .compatible = "qcom,sc8280xp-ethqos", .data = &emac_sc8280xp_data},
{ .compatible = "qcom,sm8150-ethqos", .data = &emac_sm8150_data},
--
2.51.0
next prev parent reply other threads:[~2025-11-07 10:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 10:29 [PATCH v5 0/8] net: stmmac: qcom-ethqos: add support for SCMI power domains Bartosz Golaszewski
2025-11-07 10:29 ` [PATCH v5 1/8] dt-bindings: net: qcom: document the ethqos device for SCMI-based systems Bartosz Golaszewski
2025-11-07 11:22 ` Rob Herring (Arm)
2025-11-07 10:29 ` [PATCH v5 2/8] net: stmmac: qcom-ethqos: use generic device properties Bartosz Golaszewski
2025-11-07 10:49 ` Konrad Dybcio
2025-11-07 10:29 ` [PATCH v5 3/8] net: stmmac: qcom-ethqos: improve typing in devres callback Bartosz Golaszewski
2025-11-07 10:50 ` Konrad Dybcio
2025-11-07 10:29 ` [PATCH v5 4/8] net: stmmac: qcom-ethqos: wrap emac driver data in additional structure Bartosz Golaszewski
2025-11-07 10:54 ` Konrad Dybcio
2025-11-07 10:29 ` [PATCH v5 5/8] net: stmmac: qcom-ethqos: split power management fields into a separate structure Bartosz Golaszewski
2025-11-07 10:29 ` [PATCH v5 6/8] net: stmmac: qcom-ethqos: split power management context into a separate struct Bartosz Golaszewski
2025-11-07 11:00 ` Konrad Dybcio
2025-11-07 10:29 ` [PATCH v5 7/8] net: stmmac: qcom-ethqos: define a callback for setting the serdes speed Bartosz Golaszewski
2025-11-07 10:29 ` Bartosz Golaszewski [this message]
2025-11-07 11:10 ` [PATCH v5 8/8] net: stmmac: qcom-ethqos: add support for sa8255p Konrad Dybcio
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=20251107-qcom-sa8255p-emac-v5-8-01d3e3aaf388@linaro.org \
--to=brgl@bgdev.pl \
--cc=Frank.Li@nxp.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bartosz.golaszewski@linaro.org \
--cc=christophe.roullier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=david.wu@rock-chips.com \
--cc=devicetree@vger.kernel.org \
--cc=dfustini@tenstorrent.com \
--cc=edumazet@google.com \
--cc=festevam@gmail.com \
--cc=fustini@kernel.org \
--cc=geert+renesas@glider.be \
--cc=guoren@kernel.org \
--cc=heiko@sntech.de \
--cc=imx@lists.linux.dev \
--cc=inochiama@gmail.com \
--cc=jan.petrous@oss.nxp.com \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@gmail.com \
--cc=joabreu@synopsys.com \
--cc=keguang.zhang@gmail.com \
--cc=kernel@esmil.dk \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=liangshuang@eswincomputing.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=lizhi2@eswincomputing.com \
--cc=magnus.damm@gmail.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=matthew.gerlach@altera.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=minda.chen@starfivetech.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=nobuhiro.iwamatsu.x90@mail.toshiba \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=romain.gantois@bootlin.com \
--cc=s.hauer@pengutronix.de \
--cc=s32@nxp.com \
--cc=samin.guo@starfivetech.com \
--cc=samuel@sholland.org \
--cc=shawnguo@kernel.org \
--cc=sophgo@lists.linux.dev \
--cc=swathi.ks@samsung.com \
--cc=unicorn_wang@outlook.com \
--cc=vineetha.g.jaya.kumaran@intel.com \
--cc=vkoul@kernel.org \
--cc=wefu@redhat.com \
--cc=weishangjuan@eswincomputing.com \
--cc=wens@kernel.org \
--cc=xiaoning.wang@nxp.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).