Message ID | E1tkLZ6-004RZO-0H@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: stmmac: cleanup transmit clock setting | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/apply | fail | Patch does not apply to net-next-0 |
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
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>
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!
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;
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(-)