Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dwmac-sti: Use helper rgmii_clock

Utilize a new helper function rgmii_clock().

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
Link: https://patch.msgid.link/20241205-upstream_s32cc_gmac-v8-12-ec1d180df815@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jan Petrous (OSS) and committed by
Jakub Kicinski
1ead5777 fd59bca4

+5 -13
+5 -13
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 21 21 22 22 #include "stmmac_platform.h" 23 23 24 - #define DWMAC_125MHZ 125000000 25 24 #define DWMAC_50MHZ 50000000 26 - #define DWMAC_25MHZ 25000000 27 - #define DWMAC_2_5MHZ 2500000 28 25 29 26 #define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \ 30 27 iface == PHY_INTERFACE_MODE_RGMII_ID || \ ··· 137 140 struct sti_dwmac *dwmac = priv; 138 141 u32 src = dwmac->tx_retime_src; 139 142 u32 reg = dwmac->ctrl_reg; 140 - u32 freq = 0; 143 + long freq = 0; 141 144 142 145 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { 143 146 src = TX_RETIME_SRC_TXCLK; ··· 150 153 } 151 154 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { 152 155 /* On GiGa clk source can be either ext or from clkgen */ 153 - if (spd == SPEED_1000) { 154 - freq = DWMAC_125MHZ; 155 - } else { 156 + freq = rgmii_clock(spd); 157 + 158 + if (spd != SPEED_1000 && freq > 0) 156 159 /* Switch to clkgen for these speeds */ 157 160 src = TX_RETIME_SRC_CLKGEN; 158 - if (spd == SPEED_100) 159 - freq = DWMAC_25MHZ; 160 - else if (spd == SPEED_10) 161 - freq = DWMAC_2_5MHZ; 162 - } 163 161 } 164 162 165 - if (src == TX_RETIME_SRC_CLKGEN && freq) 163 + if (src == TX_RETIME_SRC_CLKGEN && freq > 0) 166 164 clk_set_rate(dwmac->clk, freq); 167 165 168 166 regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK,