* [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting
@ 2025-02-18 11:14 Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook Russell King (Oracle)
` (7 more replies)
0 siblings, 8 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:14 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Hi,
A lot of stmmac platform code which sets the transmit clock is very
similar - they decode the speed to the clock rate (125, 25 or 2.5 MHz)
and then set a clock to that rate.
The DWMAC core appears to have a clock input for the transmit section
called clk_tx_i which requires this rate.
This series moves the code which sets this clock into the core stmmac
code.
Patch 1 adds a hook that platforms can use to configure the clock rate.
Patch 2 adds a generic implementation.
Patches 3 through 7 convert the easy-to-convert platforms to use this
new infrastructure.
.../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 +----
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 5 ++-
.../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 24 ++----------
drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 22 ++---------
.../net/ethernet/stmicro/stmmac/dwmac-starfive.c | 26 ++-----------
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 43 ++++++++++++++++++++++
include/linux/stmmac.h | 4 ++
8 files changed, 65 insertions(+), 71 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
@ 2025-02-18 11:14 ` Russell King (Oracle)
2025-02-25 20:33 ` Thierry Reding
2025-02-18 11:14 ` [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method Russell King (Oracle)
` (6 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:14 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Several stmmac sub-drivers which support RGMII follow the same pattern.
They calculate the transmit clock, and then call the clk API to set a
clock to that rate.
Analysis of documentation suggests that the platform is responsible for
providing the transmit clock to the DWMAC core (clk_tx_i). The expected
rates are:
10Mbps 100Mbps 1Gbps
MII 2.5MHz 25MHz
GMII 125MHz
RGMI 2.5MHz 25MHz 125MHz
RMII 2.5MHz 25MHz
It seems some platforms require this clock to be manually configured,
but there are outputs from the MAC core that indicate the speed, so a
platform may use these to automatically configure the clock. Thus, we
can't just provide one solution to configuring the clock.
Moreover, the clock may need to be derived from one of several sources
depending on the interface mode.
Provide a platform hook that is passed the interface mode, speed, and
transmit clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++
include/linux/stmmac.h | 4 ++++
2 files changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 4d542f482ecb..f7ff94a09da2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -928,6 +928,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
unsigned int flow_ctrl;
u32 old_ctrl, ctrl;
+ int ret;
if ((priv->plat->flags & STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP) &&
priv->plat->serdes_powerup)
@@ -1000,6 +1001,16 @@ static void stmmac_mac_link_up(struct phylink_config *config,
if (priv->plat->fix_mac_speed)
priv->plat->fix_mac_speed(priv->plat->bsp_priv, speed, mode);
+ if (priv->plat->set_clk_tx_rate) {
+ ret = priv->plat->set_clk_tx_rate(priv->plat->bsp_priv,
+ priv->plat->clk_tx_i,
+ interface, speed);
+ if (ret < 0)
+ netdev_err(priv->dev,
+ "failed to configure transmit clock for %dMbps: %pe\n",
+ speed, ERR_PTR(ret));
+ }
+
if (!duplex)
ctrl &= ~priv->hw->link.duplex;
else
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 6d2aa77ea963..cd0d1383df87 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -78,6 +78,7 @@
| DMA_AXI_BLEN_32 | DMA_AXI_BLEN_64 \
| DMA_AXI_BLEN_128 | DMA_AXI_BLEN_256)
+struct clk;
struct stmmac_priv;
/* Platfrom data for platform device structure's platform_data field */
@@ -231,6 +232,8 @@ struct plat_stmmacenet_data {
u8 tx_sched_algorithm;
struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
+ int (*set_clk_tx_rate)(void *priv, struct clk *clk_tx_i,
+ phy_interface_t interface, int speed);
void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
int (*serdes_powerup)(struct net_device *ndev, void *priv);
@@ -252,6 +255,7 @@ struct plat_stmmacenet_data {
struct clk *stmmac_clk;
struct clk *pclk;
struct clk *clk_ptp_ref;
+ struct clk *clk_tx_i; /* clk_tx_i to MAC core */
unsigned long clk_ptp_rate;
unsigned long clk_ref_rate;
struct clk_bulk_data *clks;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook Russell King (Oracle)
@ 2025-02-18 11:14 ` Russell King (Oracle)
2025-02-25 20:34 ` Thierry Reding
2025-02-18 11:14 ` [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
` (5 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:14 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Provide a generic implementation for the set_clk_tx_rate method
introduced by the previous patch, which is capable of configuring the
MAC transmit clock for 10M, 100M and 1000M speeds for at least MII,
GMII, RGMII and RMII interface modes.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 +++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 3395188c198a..0934b30e6c72 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -406,6 +406,8 @@ int stmmac_dvr_probe(struct device *device,
int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt);
int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size);
int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled);
+int stmmac_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+ phy_interface_t interface, int speed);
static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv)
{
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f7ff94a09da2..43ff26166e74 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -177,6 +177,38 @@ int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled)
}
EXPORT_SYMBOL_GPL(stmmac_bus_clks_config);
+/**
+ * stmmac_set_clk_tx_rate() - set the clock rate for the MAC transmit clock
+ * @bsp_priv: BSP private data structure (unused)
+ * @clk_tx_i: the transmit clock
+ * @interface: the selected interface mode
+ * @speed: the speed that the MAC will be operating at
+ *
+ * Set the transmit clock rate for the MAC, normally 2.5MHz for 10Mbps,
+ * 25MHz for 100Mbps and 125MHz for 1Gbps. This is suitable for at least
+ * MII, GMII, RGMII and RMII interface modes. Platforms can hook this into
+ * the plat_data->set_clk_tx_rate method directly, call it via their own
+ * implementation, or implement their own method should they have more
+ * complex requirements. It is intended to only be used in this method.
+ *
+ * plat_data->clk_tx_i must be filled in.
+ */
+int stmmac_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+ phy_interface_t interface, int speed)
+{
+ long rate = rgmii_clock(speed);
+
+ /* Silently ignore unsupported speeds as rgmii_clock() only
+ * supports 10, 100 and 1000Mbps. We do not want to spit
+ * errors for 2500 and higher speeds here.
+ */
+ if (rate < 0)
+ return 0;
+
+ return clk_set_rate(clk_tx_i, rate);
+}
+EXPORT_SYMBOL_GPL(stmmac_set_clk_tx_rate);
+
/**
* stmmac_verify_args - verify the driver parameters.
* Description: it checks the driver parameters and set a default in case of
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method Russell King (Oracle)
@ 2025-02-18 11:14 ` Russell King (Oracle)
2025-02-25 20:35 ` Thierry Reding
2025-02-18 11:14 ` [PATCH RFC net-next 4/7] net: stmmac: starfive: " Russell King (Oracle)
` (4 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:14 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 392574bdd4a4..581c0b40db57 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -30,7 +30,6 @@ struct tegra_eqos {
struct reset_control *rst;
struct clk *clk_slave;
- struct clk *clk_tx;
struct gpio_desc *reset;
};
@@ -145,7 +144,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
{
struct tegra_eqos *eqos = priv;
bool needs_calibration = false;
- long rate = 125000000;
u32 value;
int err;
@@ -156,7 +154,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
fallthrough;
case SPEED_10:
- rate = rgmii_clock(speed);
break;
default:
@@ -203,10 +200,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
value &= ~AUTO_CAL_CONFIG_ENABLE;
writel(value, eqos->regs + AUTO_CAL_CONFIG);
}
-
- err = clk_set_rate(eqos->clk_tx, rate);
- if (err < 0)
- dev_err(eqos->dev, "failed to set TX rate: %d\n", err);
}
static int tegra_eqos_init(struct platform_device *pdev, void *priv)
@@ -246,7 +239,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
eqos->clk_slave = data->clks[i].clk;
data->stmmac_clk = eqos->clk_slave;
} else if (strcmp(data->clks[i].id, "tx") == 0) {
- eqos->clk_tx = data->clks[i].clk;
+ data->clk_tx_i = data->clks[i].clk;
}
}
@@ -282,6 +275,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
bypass_clk_reset_gpio:
data->fix_mac_speed = tegra_eqos_fix_speed;
+ data->set_clk_tx_rate = stmmac_set_clk_tx_rate;
data->init = tegra_eqos_init;
data->bsp_priv = eqos;
data->flags |= STMMAC_FLAG_SPH_DISABLE;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 4/7] net: stmmac: starfive: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
` (2 preceding siblings ...)
2025-02-18 11:14 ` [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
@ 2025-02-18 11:14 ` Russell King (Oracle)
2025-02-25 20:36 ` Thierry Reding
2025-02-18 11:15 ` [PATCH RFC net-next 5/7] net: stmmac: s32: " Russell King (Oracle)
` (3 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:14 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../ethernet/stmicro/stmmac/dwmac-starfive.c | 26 +++----------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 282c846dad0b..5e31cb3bb4b8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -27,27 +27,9 @@ struct starfive_dwmac_data {
struct starfive_dwmac {
struct device *dev;
- struct clk *clk_tx;
const struct starfive_dwmac_data *data;
};
-static void starfive_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
-{
- struct starfive_dwmac *dwmac = priv;
- long rate;
- int err;
-
- rate = rgmii_clock(speed);
- if (rate < 0) {
- dev_err(dwmac->dev, "invalid speed %d\n", speed);
- return;
- }
-
- err = clk_set_rate(dwmac->clk_tx, rate);
- if (err)
- dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
-}
-
static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
{
struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
@@ -122,9 +104,9 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
dwmac->data = device_get_match_data(&pdev->dev);
- dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
- if (IS_ERR(dwmac->clk_tx))
- return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
+ plat_dat->clk_tx_i = devm_clk_get_enabled(&pdev->dev, "tx");
+ if (IS_ERR(plat_dat->clk_tx_i))
+ return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat->clk_tx_i),
"error getting tx clock\n");
clk_gtx = devm_clk_get_enabled(&pdev->dev, "gtx");
@@ -139,7 +121,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
* internally, because rgmii_rxin will be adaptively adjusted.
*/
if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
- plat_dat->fix_mac_speed = starfive_dwmac_fix_mac_speed;
+ plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
dwmac->dev = &pdev->dev;
plat_dat->bsp_priv = dwmac;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 5/7] net: stmmac: s32: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
` (3 preceding siblings ...)
2025-02-18 11:14 ` [PATCH RFC net-next 4/7] net: stmmac: starfive: " Russell King (Oracle)
@ 2025-02-18 11:15 ` Russell King (Oracle)
2025-02-25 20:31 ` Thierry Reding
2025-02-25 20:43 ` Thierry Reding
2025-02-18 11:15 ` [PATCH RFC net-next 6/7] net: stmmac: intel: " Russell King (Oracle)
` (2 subsequent siblings)
7 siblings, 2 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:15 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-s32.c | 22 +++----------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
index 6a498833b8ed..b76bfa41af82 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
@@ -100,24 +100,6 @@ static void s32_gmac_exit(struct platform_device *pdev, void *priv)
clk_disable_unprepare(gmac->rx_clk);
}
-static void s32_fix_mac_speed(void *priv, int speed, unsigned int mode)
-{
- struct s32_priv_data *gmac = priv;
- long tx_clk_rate;
- int ret;
-
- tx_clk_rate = rgmii_clock(speed);
- if (tx_clk_rate < 0) {
- dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
- return;
- }
-
- dev_dbg(gmac->dev, "Set tx clock to %ld Hz\n", tx_clk_rate);
- ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
- if (ret)
- dev_err(gmac->dev, "Can't set tx clock\n");
-}
-
static int s32_dwmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat;
@@ -172,7 +154,9 @@ static int s32_dwmac_probe(struct platform_device *pdev)
plat->init = s32_gmac_init;
plat->exit = s32_gmac_exit;
- plat->fix_mac_speed = s32_fix_mac_speed;
+
+ plat->clk_tx_i = dmac->tx_clk;
+ plat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
plat->bsp_priv = gmac;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 6/7] net: stmmac: intel: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
` (4 preceding siblings ...)
2025-02-18 11:15 ` [PATCH RFC net-next 5/7] net: stmmac: s32: " Russell King (Oracle)
@ 2025-02-18 11:15 ` Russell King (Oracle)
2025-02-25 20:46 ` Thierry Reding
2025-02-18 11:15 ` [PATCH RFC net-next 7/7] net: stmmac: imx: " Russell King (Oracle)
2025-02-25 20:30 ` [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Thierry Reding
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:15 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../stmicro/stmmac/dwmac-intel-plat.c | 24 +++----------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index 0591756a2100..e81d81e44127 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -22,31 +22,12 @@ struct intel_dwmac {
};
struct intel_dwmac_data {
- void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
unsigned long ptp_ref_clk_rate;
unsigned long tx_clk_rate;
bool tx_clk_en;
};
-static void kmb_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
-{
- struct intel_dwmac *dwmac = priv;
- long rate;
- int ret;
-
- rate = rgmii_clock(speed);
- if (rate < 0) {
- dev_err(dwmac->dev, "Invalid speed\n");
- return;
- }
-
- ret = clk_set_rate(dwmac->tx_clk, rate);
- if (ret)
- dev_err(dwmac->dev, "Failed to configure tx clock rate\n");
-}
-
static const struct intel_dwmac_data kmb_data = {
- .fix_mac_speed = kmb_eth_fix_mac_speed,
.ptp_ref_clk_rate = 200000000,
.tx_clk_rate = 125000000,
.tx_clk_en = true,
@@ -89,8 +70,6 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
* platform_match().
*/
dwmac->data = device_get_match_data(&pdev->dev);
- if (dwmac->data->fix_mac_speed)
- plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
/* Enable TX clock */
if (dwmac->data->tx_clk_en) {
@@ -130,6 +109,9 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
goto err_tx_clk_disable;
}
}
+
+ plat_dat->clk_tx_i = dwmac->tx_clk;
+ plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
}
plat_dat->bsp_priv = dwmac;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH RFC net-next 7/7] net: stmmac: imx: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
` (5 preceding siblings ...)
2025-02-18 11:15 ` [PATCH RFC net-next 6/7] net: stmmac: intel: " Russell King (Oracle)
@ 2025-02-18 11:15 ` Russell King (Oracle)
2025-02-18 11:41 ` Russell King (Oracle)
2025-02-25 20:30 ` [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Thierry Reding
7 siblings, 1 reply; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:15 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
Convert non-i.MX93 users to use the generic stmmac_set_clk_tx_rate() to
configure the MAC transmit clock rate.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 610204b51e3f..927ce8d97f78 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -358,7 +358,6 @@ static int imx_dwmac_probe(struct platform_device *pdev)
plat_dat->init = imx_dwmac_init;
plat_dat->exit = imx_dwmac_exit;
plat_dat->clks_config = imx_dwmac_clks_config;
- plat_dat->fix_mac_speed = imx_dwmac_fix_speed;
plat_dat->bsp_priv = dwmac;
dwmac->plat_dat = plat_dat;
dwmac->base_addr = stmmac_res.addr;
@@ -371,8 +370,12 @@ static int imx_dwmac_probe(struct platform_device *pdev)
if (ret)
goto err_dwmac_init;
+ plat_dat->clk_tx_i = dwmac->clk_tx;
if (dwmac->ops->fix_mac_speed)
plat_dat->fix_mac_speed = dwmac->ops->fix_mac_speed;
+ else
+ plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+
dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset;
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 7/7] net: stmmac: imx: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:15 ` [PATCH RFC net-next 7/7] net: stmmac: imx: " Russell King (Oracle)
@ 2025-02-18 11:41 ` Russell King (Oracle)
0 siblings, 0 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 11:41 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller,
Emil Renner Berthing, Eric Dumazet, Fabio Estevam, imx,
Inochi Amaoto, Jakub Kicinski, Jan Petrous, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, Minda Chen,
netdev, NXP S32 Linux Team, Paolo Abeni, Pengutronix Kernel Team,
Sascha Hauer, Shawn Guo, Thierry Reding
On Tue, Feb 18, 2025 at 11:15:10AM +0000, Russell King (Oracle) wrote:
> Convert non-i.MX93 users to use the generic stmmac_set_clk_tx_rate() to
> configure the MAC transmit clock rate.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Looking at this again, this patch is not correct - imx does a few
checks before changing the "tx" clock.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
` (6 preceding siblings ...)
2025-02-18 11:15 ` [PATCH RFC net-next 7/7] net: stmmac: imx: " Russell King (Oracle)
@ 2025-02-25 20:30 ` Thierry Reding
7 siblings, 0 replies; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:30 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 1414 bytes --]
On Tue, Feb 18, 2025 at 11:14:39AM +0000, Russell King (Oracle) wrote:
> Hi,
>
> A lot of stmmac platform code which sets the transmit clock is very
> similar - they decode the speed to the clock rate (125, 25 or 2.5 MHz)
> and then set a clock to that rate.
>
> The DWMAC core appears to have a clock input for the transmit section
> called clk_tx_i which requires this rate.
>
> This series moves the code which sets this clock into the core stmmac
> code.
>
> Patch 1 adds a hook that platforms can use to configure the clock rate.
> Patch 2 adds a generic implementation.
> Patches 3 through 7 convert the easy-to-convert platforms to use this
> new infrastructure.
>
> .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 +----
> drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 5 ++-
> .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 24 ++----------
> drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 22 ++---------
> .../net/ethernet/stmicro/stmmac/dwmac-starfive.c | 26 ++-----------
> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 43 ++++++++++++++++++++++
> include/linux/stmmac.h | 4 ++
> 8 files changed, 65 insertions(+), 71 deletions(-)
Seems to work fine on Jetson TX2, so patches 1-3 are:
Tested-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 5/7] net: stmmac: s32: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:15 ` [PATCH RFC net-next 5/7] net: stmmac: s32: " Russell King (Oracle)
@ 2025-02-25 20:31 ` Thierry Reding
2025-02-25 20:43 ` Thierry Reding
1 sibling, 0 replies; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:31 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]
On Tue, Feb 18, 2025 at 11:15:00AM +0000, Russell King (Oracle) wrote:
> Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-s32.c | 22 +++----------------
> 1 file changed, 3 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
> index 6a498833b8ed..b76bfa41af82 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
> @@ -100,24 +100,6 @@ static void s32_gmac_exit(struct platform_device *pdev, void *priv)
> clk_disable_unprepare(gmac->rx_clk);
> }
>
> -static void s32_fix_mac_speed(void *priv, int speed, unsigned int mode)
> -{
> - struct s32_priv_data *gmac = priv;
> - long tx_clk_rate;
> - int ret;
> -
> - tx_clk_rate = rgmii_clock(speed);
> - if (tx_clk_rate < 0) {
> - dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
> - return;
> - }
> -
> - dev_dbg(gmac->dev, "Set tx clock to %ld Hz\n", tx_clk_rate);
> - ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> - if (ret)
> - dev_err(gmac->dev, "Can't set tx clock\n");
> -}
> -
> static int s32_dwmac_probe(struct platform_device *pdev)
> {
> struct plat_stmmacenet_data *plat;
> @@ -172,7 +154,9 @@ static int s32_dwmac_probe(struct platform_device *pdev)
>
> plat->init = s32_gmac_init;
> plat->exit = s32_gmac_exit;
> - plat->fix_mac_speed = s32_fix_mac_speed;
> +
> + plat->clk_tx_i = dmac->tx_clk;
I noticed this while building, the "dmac" above should be "gmac".
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook
2025-02-18 11:14 ` [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook Russell King (Oracle)
@ 2025-02-25 20:33 ` Thierry Reding
0 siblings, 0 replies; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:33 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 1325 bytes --]
On Tue, Feb 18, 2025 at 11:14:39AM +0000, Russell King (Oracle) wrote:
> Several stmmac sub-drivers which support RGMII follow the same pattern.
> They calculate the transmit clock, and then call the clk API to set a
> clock to that rate.
>
> Analysis of documentation suggests that the platform is responsible for
> providing the transmit clock to the DWMAC core (clk_tx_i). The expected
> rates are:
>
> 10Mbps 100Mbps 1Gbps
> MII 2.5MHz 25MHz
> GMII 125MHz
> RGMI 2.5MHz 25MHz 125MHz
> RMII 2.5MHz 25MHz
>
> It seems some platforms require this clock to be manually configured,
> but there are outputs from the MAC core that indicate the speed, so a
> platform may use these to automatically configure the clock. Thus, we
> can't just provide one solution to configuring the clock.
>
> Moreover, the clock may need to be derived from one of several sources
> depending on the interface mode.
>
> Provide a platform hook that is passed the interface mode, speed, and
> transmit clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++
> include/linux/stmmac.h | 4 ++++
> 2 files changed, 15 insertions(+)
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method
2025-02-18 11:14 ` [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method Russell King (Oracle)
@ 2025-02-25 20:34 ` Thierry Reding
0 siblings, 0 replies; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:34 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 627 bytes --]
On Tue, Feb 18, 2025 at 11:14:44AM +0000, Russell King (Oracle) wrote:
> Provide a generic implementation for the set_clk_tx_rate method
> introduced by the previous patch, which is capable of configuring the
> MAC transmit clock for 10M, 100M and 1000M speeds for at least MII,
> GMII, RGMII and RMII interface modes.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++
> .../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 +++++++++++++++++++
> 2 files changed, 34 insertions(+)
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 ` [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
@ 2025-02-25 20:35 ` Thierry Reding
2025-02-26 12:19 ` Russell King (Oracle)
0 siblings, 1 reply; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:35 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 415 bytes --]
On Tue, Feb 18, 2025 at 11:14:49AM +0000, Russell King (Oracle) wrote:
> Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 4/7] net: stmmac: starfive: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:14 ` [PATCH RFC net-next 4/7] net: stmmac: starfive: " Russell King (Oracle)
@ 2025-02-25 20:36 ` Thierry Reding
0 siblings, 0 replies; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:36 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 416 bytes --]
On Tue, Feb 18, 2025 at 11:14:54AM +0000, Russell King (Oracle) wrote:
> Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../ethernet/stmicro/stmmac/dwmac-starfive.c | 26 +++----------------
> 1 file changed, 4 insertions(+), 22 deletions(-)
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 5/7] net: stmmac: s32: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:15 ` [PATCH RFC net-next 5/7] net: stmmac: s32: " Russell King (Oracle)
2025-02-25 20:31 ` Thierry Reding
@ 2025-02-25 20:43 ` Thierry Reding
2025-02-26 12:24 ` Russell King (Oracle)
1 sibling, 1 reply; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:43 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 692 bytes --]
On Tue, Feb 18, 2025 at 11:15:00AM +0000, Russell King (Oracle) wrote:
> Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
I wonder if the clk_set_rate() call for gmac->tx_clk could also be
removed from s32_gmac_init(). Comparing to the other drivers that
doesn't seem to be relevant since ->set_clk_tx_rate() will be called
anyway when the interface is brought up.
But it might be more difficult because somebody would actually have to
go and test this, whereas this patch here is the equivalent of the
previous code, so:
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 6/7] net: stmmac: intel: use generic stmmac_set_clk_tx_rate()
2025-02-18 11:15 ` [PATCH RFC net-next 6/7] net: stmmac: intel: " Russell King (Oracle)
@ 2025-02-25 20:46 ` Thierry Reding
2025-02-26 12:40 ` Russell King (Oracle)
0 siblings, 1 reply; 20+ messages in thread
From: Thierry Reding @ 2025-02-25 20:46 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
[-- Attachment #1: Type: text/plain, Size: 599 bytes --]
On Tue, Feb 18, 2025 at 11:15:05AM +0000, Russell King (Oracle) wrote:
> Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> clock.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../stmicro/stmmac/dwmac-intel-plat.c | 24 +++----------------
> 1 file changed, 3 insertions(+), 21 deletions(-)
This isn't quite the same code, but the result should be the same since
clk_set_rate() will be ignored if the clock is NULL, which would be the
case for !dwmac->data->tx_clk_en.
Reviewed-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate()
2025-02-25 20:35 ` Thierry Reding
@ 2025-02-26 12:19 ` Russell King (Oracle)
0 siblings, 0 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-26 12:19 UTC (permalink / raw)
To: Thierry Reding
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
On Tue, Feb 25, 2025 at 09:35:52PM +0100, Thierry Reding wrote:
> On Tue, Feb 18, 2025 at 11:14:49AM +0000, Russell King (Oracle) wrote:
> > Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> > clock.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> > .../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 ++--------
> > 1 file changed, 2 insertions(+), 8 deletions(-)
>
> Reviewed-by: Thierry Reding <treding@nvidia.com>
Hi Thierry,
Please note that things changed in this patch as a result of:
cff608268baf net: stmmac: dwc-qos: name struct plat_stmmacenet_data consistently
which has now been merged. Are you still happy for me to add your
r-b? The current patch is below.
8<===
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Subject: [PATCH net-next] net: stmmac: dwc-qos: use generic
stmmac_set_clk_tx_rate()
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 6cadf24a575c..3f0f4ea6cf2e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -30,7 +30,6 @@ struct tegra_eqos {
struct reset_control *rst;
struct clk *clk_slave;
- struct clk *clk_tx;
struct gpio_desc *reset;
};
@@ -150,7 +149,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
{
struct tegra_eqos *eqos = priv;
bool needs_calibration = false;
- long rate = 125000000;
u32 value;
int err;
@@ -161,7 +159,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
fallthrough;
case SPEED_10:
- rate = rgmii_clock(speed);
break;
default:
@@ -208,10 +205,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
value &= ~AUTO_CAL_CONFIG_ENABLE;
writel(value, eqos->regs + AUTO_CAL_CONFIG);
}
-
- err = clk_set_rate(eqos->clk_tx, rate);
- if (err < 0)
- dev_err(eqos->dev, "failed to set TX rate: %d\n", err);
}
static int tegra_eqos_init(struct platform_device *pdev, void *priv)
@@ -247,7 +240,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
if (!is_of_node(dev->fwnode))
goto bypass_clk_reset_gpio;
- eqos->clk_tx = dwc_eth_find_clk(plat_dat, "tx");
+ plat_dat->clk_tx_i = dwc_eth_find_clk(plat_dat, "tx");
eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
if (IS_ERR(eqos->reset)) {
@@ -281,6 +274,7 @@ static int tegra_eqos_probe(struct platform_device *pdev,
bypass_clk_reset_gpio:
plat_dat->fix_mac_speed = tegra_eqos_fix_speed;
+ plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
plat_dat->init = tegra_eqos_init;
plat_dat->bsp_priv = eqos;
plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
--
2.30.2
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 5/7] net: stmmac: s32: use generic stmmac_set_clk_tx_rate()
2025-02-25 20:43 ` Thierry Reding
@ 2025-02-26 12:24 ` Russell King (Oracle)
0 siblings, 0 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-26 12:24 UTC (permalink / raw)
To: Thierry Reding
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
On Tue, Feb 25, 2025 at 09:43:56PM +0100, Thierry Reding wrote:
> On Tue, Feb 18, 2025 at 11:15:00AM +0000, Russell King (Oracle) wrote:
> > Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> > clock.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>
> I wonder if the clk_set_rate() call for gmac->tx_clk could also be
> removed from s32_gmac_init(). Comparing to the other drivers that
> doesn't seem to be relevant since ->set_clk_tx_rate() will be called
> anyway when the interface is brought up.
>
> But it might be more difficult because somebody would actually have to
> go and test this, whereas this patch here is the equivalent of the
> previous code, so:
>
> Reviewed-by: Thierry Reding <treding@nvidia.com>
I'd prefer not to change the code behaviour in this patch series. It's
entirely possible that's somehow necessary to ensure a correct clock
is supplied before attempting to reset the MAC core on this hardware.
It could be something to be cleaned up in the future.
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH RFC net-next 6/7] net: stmmac: intel: use generic stmmac_set_clk_tx_rate()
2025-02-25 20:46 ` Thierry Reding
@ 2025-02-26 12:40 ` Russell King (Oracle)
0 siblings, 0 replies; 20+ messages in thread
From: Russell King (Oracle) @ 2025-02-26 12:40 UTC (permalink / raw)
To: Thierry Reding
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Emil Renner Berthing, Eric Dumazet,
Fabio Estevam, imx, Inochi Amaoto, Jakub Kicinski, Jan Petrous,
Jon Hunter, linux-arm-kernel, linux-stm32, Maxime Coquelin,
Minda Chen, netdev, NXP S32 Linux Team, Paolo Abeni,
Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Thierry Reding
On Tue, Feb 25, 2025 at 09:46:56PM +0100, Thierry Reding wrote:
> On Tue, Feb 18, 2025 at 11:15:05AM +0000, Russell King (Oracle) wrote:
> > Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
> > clock.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> > .../stmicro/stmmac/dwmac-intel-plat.c | 24 +++----------------
> > 1 file changed, 3 insertions(+), 21 deletions(-)
>
> This isn't quite the same code, but the result should be the same since
> clk_set_rate() will be ignored if the clock is NULL, which would be the
> case for !dwmac->data->tx_clk_en.
You're right, thanks for spotting! I'll move it out of the if()
statement so the code has the exact same behaviour. Replacement patch
below.
> Reviewed-by: Thierry Reding <treding@nvidia.com>
Thanks for the review.
8<====
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Subject: [PATCH net-next] net: stmmac: intel: use generic
stmmac_set_clk_tx_rate()
Use the generic stmmac_set_clk_tx_rate() to configure the MAC transmit
clock.
Note that given the current unpatched driver structure,
plat_dat->fix_mac_speed will always be populated with
kmb_eth_fix_mac_speed(), even when no clock is present. We preserve
this behaviour in this patch by always initialising plat_dat->clk_tx_i
and plat_dat->set_clk_tx_rate.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../stmicro/stmmac/dwmac-intel-plat.c | 24 +++----------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index 0591756a2100..599def7b3a64 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -22,31 +22,12 @@ struct intel_dwmac {
};
struct intel_dwmac_data {
- void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
unsigned long ptp_ref_clk_rate;
unsigned long tx_clk_rate;
bool tx_clk_en;
};
-static void kmb_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
-{
- struct intel_dwmac *dwmac = priv;
- long rate;
- int ret;
-
- rate = rgmii_clock(speed);
- if (rate < 0) {
- dev_err(dwmac->dev, "Invalid speed\n");
- return;
- }
-
- ret = clk_set_rate(dwmac->tx_clk, rate);
- if (ret)
- dev_err(dwmac->dev, "Failed to configure tx clock rate\n");
-}
-
static const struct intel_dwmac_data kmb_data = {
- .fix_mac_speed = kmb_eth_fix_mac_speed,
.ptp_ref_clk_rate = 200000000,
.tx_clk_rate = 125000000,
.tx_clk_en = true,
@@ -89,8 +70,6 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
* platform_match().
*/
dwmac->data = device_get_match_data(&pdev->dev);
- if (dwmac->data->fix_mac_speed)
- plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
/* Enable TX clock */
if (dwmac->data->tx_clk_en) {
@@ -132,6 +111,9 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
}
}
+ plat_dat->clk_tx_i = dwmac->tx_clk;
+ plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+
plat_dat->bsp_priv = dwmac;
plat_dat->eee_usecs_rate = plat_dat->clk_ptp_rate;
--
2.30.2
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-02-26 12:40 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18 11:14 [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 1/7] net: stmmac: provide generic transmit clock configuration hook Russell King (Oracle)
2025-02-25 20:33 ` Thierry Reding
2025-02-18 11:14 ` [PATCH RFC net-next 2/7] net: stmmac: provide generic implementation for set_clk_tx_rate method Russell King (Oracle)
2025-02-25 20:34 ` Thierry Reding
2025-02-18 11:14 ` [PATCH RFC net-next 3/7] net: stmmac: dwc-qos-eth: use generic stmmac_set_clk_tx_rate() Russell King (Oracle)
2025-02-25 20:35 ` Thierry Reding
2025-02-26 12:19 ` Russell King (Oracle)
2025-02-18 11:14 ` [PATCH RFC net-next 4/7] net: stmmac: starfive: " Russell King (Oracle)
2025-02-25 20:36 ` Thierry Reding
2025-02-18 11:15 ` [PATCH RFC net-next 5/7] net: stmmac: s32: " Russell King (Oracle)
2025-02-25 20:31 ` Thierry Reding
2025-02-25 20:43 ` Thierry Reding
2025-02-26 12:24 ` Russell King (Oracle)
2025-02-18 11:15 ` [PATCH RFC net-next 6/7] net: stmmac: intel: " Russell King (Oracle)
2025-02-25 20:46 ` Thierry Reding
2025-02-26 12:40 ` Russell King (Oracle)
2025-02-18 11:15 ` [PATCH RFC net-next 7/7] net: stmmac: imx: " Russell King (Oracle)
2025-02-18 11:41 ` Russell King (Oracle)
2025-02-25 20:30 ` [PATCH RFC net-next 0/7] net: stmmac: cleanup transmit clock setting Thierry Reding
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).