[PATCH net-next v8 5/6] net: stmmac: qcom-ethqos: split power management context into a separate struct
Bartosz Golaszewski
bartosz.golaszewski at oss.qualcomm.com
Wed Mar 11 10:03:40 PDT 2026
From: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
With match data split into general and power-management sections, let's
now do the same with runtime device data.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski at oss.qualcomm.com>
---
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 40 ++++++++++++----------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 2166084aac999a38367af4294129f925391179de..7e3dc1df093a20eb766ebcb29738d9f4261145eb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -105,14 +105,18 @@ struct ethqos_emac_match_data {
const struct ethqos_emac_pm_data *pm_data;
};
+struct ethqos_emac_pm_ctx {
+ struct clk *link_clk;
+ struct phy *serdes_phy;
+};
+
struct qcom_ethqos {
struct platform_device *pdev;
void __iomem *rgmii_base;
void (*configure_func)(struct qcom_ethqos *ethqos,
phy_interface_t interface, int speed);
- struct clk *link_clk;
- struct phy *serdes_phy;
+ struct ethqos_emac_pm_ctx pm;
phy_interface_t phy_mode;
const struct ethqos_emac_por *rgmii_por;
@@ -194,7 +198,7 @@ static int ethqos_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
if (rate < 0)
return rate;
- return clk_set_rate(ethqos->link_clk, rate * 2);
+ return clk_set_rate(ethqos->pm.link_clk, rate * 2);
}
static void
@@ -670,13 +674,13 @@ static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)
struct qcom_ethqos *ethqos = priv;
int ret;
- ret = phy_init(ethqos->serdes_phy);
+ ret = phy_init(ethqos->pm.serdes_phy);
if (ret)
return ret;
- ret = phy_power_on(ethqos->serdes_phy);
+ ret = phy_power_on(ethqos->pm.serdes_phy);
if (ret)
- phy_exit(ethqos->serdes_phy);
+ phy_exit(ethqos->pm.serdes_phy);
return ret;
}
@@ -685,8 +689,8 @@ static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv)
{
struct qcom_ethqos *ethqos = priv;
- phy_power_off(ethqos->serdes_phy);
- phy_exit(ethqos->serdes_phy);
+ phy_power_off(ethqos->pm.serdes_phy);
+ phy_exit(ethqos->pm.serdes_phy);
}
static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,
@@ -700,7 +704,7 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,
if (interface == PHY_INTERFACE_MODE_SGMII ||
interface == PHY_INTERFACE_MODE_2500BASEX)
- ret = phy_set_mode_ext(ethqos->serdes_phy, PHY_MODE_ETHERNET,
+ ret = phy_set_mode_ext(ethqos->pm.serdes_phy, PHY_MODE_ETHERNET,
interface);
return ret;
@@ -712,7 +716,7 @@ static int ethqos_clks_config(void *priv, bool enabled)
int ret = 0;
if (enabled) {
- ret = clk_prepare_enable(ethqos->link_clk);
+ ret = clk_prepare_enable(ethqos->pm.link_clk);
if (ret) {
dev_err(ðqos->pdev->dev, "link_clk enable failed\n");
return ret;
@@ -726,7 +730,7 @@ static int ethqos_clks_config(void *priv, bool enabled)
qcom_ethqos_set_sgmii_loopback(ethqos, true);
ethqos_set_func_clk_en(ethqos);
} else {
- clk_disable_unprepare(ethqos->link_clk);
+ clk_disable_unprepare(ethqos->pm.link_clk);
}
return ret;
@@ -819,9 +823,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos->has_emac_ge_3 = drv_data->has_emac_ge_3;
ethqos->needs_sgmii_loopback = drv_data->needs_sgmii_loopback;
- ethqos->link_clk = devm_clk_get(dev, clk_name);
- if (IS_ERR(ethqos->link_clk))
- return dev_err_probe(dev, PTR_ERR(ethqos->link_clk),
+ 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);
@@ -832,9 +836,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
if (ret)
return ret;
- ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
- if (IS_ERR(ethqos->serdes_phy))
- return dev_err_probe(dev, PTR_ERR(ethqos->serdes_phy),
+ 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_clk_tx_rate(ethqos, NULL, plat_dat->phy_interface,
@@ -859,7 +863,7 @@ 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->serdes_phy) {
+ if (ethqos->pm.serdes_phy) {
plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
}
--
2.47.3
More information about the Linux-rockchip
mailing list