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

net: stmmac: qcom-ethqos: use rgmii_clock() to set the link clock

The link clock operates at twice the RGMII clock rate. Therefore, we
can use the rgmii_clock() helper to set this clock rate.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1tlRMK-004Vsx-Ss@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
98f99288 e13b6da7

+5 -18
+5 -18
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 169 169 rgmii_readl(ethqos, EMAC_SYSTEM_LOW_POWER_DEBUG)); 170 170 } 171 171 172 - /* Clock rates */ 173 - #define RGMII_1000_NOM_CLK_FREQ (250 * 1000 * 1000UL) 174 - #define RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ (50 * 1000 * 1000UL) 175 - #define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ (5 * 1000 * 1000UL) 176 - 177 172 static void 178 173 ethqos_update_link_clk(struct qcom_ethqos *ethqos, int speed) 179 174 { 175 + long rate; 176 + 180 177 if (!phy_interface_mode_is_rgmii(ethqos->phy_mode)) 181 178 return; 182 179 183 - switch (speed) { 184 - case SPEED_1000: 185 - ethqos->link_clk_rate = RGMII_1000_NOM_CLK_FREQ; 186 - break; 187 - 188 - case SPEED_100: 189 - ethqos->link_clk_rate = RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ; 190 - break; 191 - 192 - case SPEED_10: 193 - ethqos->link_clk_rate = RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ; 194 - break; 195 - } 180 + rate = rgmii_clock(speed); 181 + if (rate > 0) 182 + ethqos->link_clk_rate = rate * 2; 196 183 197 184 clk_set_rate(ethqos->link_clk, ethqos->link_clk_rate); 198 185 }