Message ID | E1qfiqx-007TPm-QD@rmk-PC.armlinux.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: stmmac: add and use library for setting clock | expand |
On Mon, Sep 11, 2023 at 04:29:31PM +0100, Russell King (Oracle) wrote: > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> > --- > .../ethernet/stmicro/stmmac/dwmac-starfive.c | 29 +++++-------------- > 1 file changed, 8 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > index 9289bb87c3e3..3dc04017e3d3 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c > @@ -14,6 +14,7 @@ > #include <linux/regmap.h> > > #include "stmmac_platform.h" > +#include "stmmac_plat_lib.h" > > #define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 > #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 > @@ -27,29 +28,15 @@ struct starfive_dwmac { > static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) > { > struct starfive_dwmac *dwmac = priv; > - unsigned long rate; > int err; > > - rate = clk_get_rate(dwmac->clk_tx); > - > - switch (speed) { > - case SPEED_1000: > - rate = 125000000; > - break; > - case SPEED_100: > - rate = 25000000; > - break; > - case SPEED_10: > - rate = 2500000; > - break; > - default: > - dev_err(dwmac->dev, "invalid speed %u\n", speed); > - break; > - } > - > - err = clk_set_rate(dwmac->clk_tx, rate); > - if (err) > - dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); > + err = dwmac_set_tx_clk_gmii(dwmac->clk_tx, speed); > + if (err == -ENOTSUPP) > + dev_err(dwmac->dev, "invalid speed %dMbps\n", speed); %u? > + else if (err) > + dev_err(dwmac->dev, > + "failed to set tx rate for speed %dMbps: %pe\n", ditto -Serge(y) > + speed, ERR_PTR(err)); > } > > static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) > -- > 2.30.2 > >
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c index 9289bb87c3e3..3dc04017e3d3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c @@ -14,6 +14,7 @@ #include <linux/regmap.h> #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" #define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 @@ -27,29 +28,15 @@ struct starfive_dwmac { static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct starfive_dwmac *dwmac = priv; - unsigned long rate; int err; - rate = clk_get_rate(dwmac->clk_tx); - - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_10: - rate = 2500000; - break; - default: - dev_err(dwmac->dev, "invalid speed %u\n", speed); - break; - } - - err = clk_set_rate(dwmac->clk_tx, rate); - if (err) - dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); + err = dwmac_set_tx_clk_gmii(dwmac->clk_tx, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %dMbps\n", speed); + else if (err) + dev_err(dwmac->dev, + "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); } static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> --- .../ethernet/stmicro/stmmac/dwmac-starfive.c | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-)