Skip to content

Commit feeb271

Browse files
Bartosz Golaszewskikuba-moo
authored andcommitted
net: stmmac: dwmac-qcom-ethqos: add support for the phyaux clock
On sa8775p, the EMAC revision is 4 and we use SGMII instead of RGMII. There's no "rgmii" clock but there's a fourth clock under a different name: "phyaux". Add a new field to the chip data struct that specifies the link clock name. Default to "rgmii" for backward compatibility. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 0dec3b4 commit feeb271

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,16 @@ struct ethqos_emac_driver_data {
8585
unsigned int num_por;
8686
bool rgmii_config_loopback_en;
8787
bool has_emac3;
88+
const char *link_clk_name;
8889
struct dwmac4_addrs dwmac4_addrs;
8990
};
9091

9192
struct qcom_ethqos {
9293
struct platform_device *pdev;
9394
void __iomem *rgmii_base;
9495

95-
unsigned int rgmii_clk_rate;
96-
struct clk *rgmii_clk;
96+
unsigned int link_clk_rate;
97+
struct clk *link_clk;
9798
struct phy *serdes_phy;
9899
unsigned int speed;
99100

@@ -156,23 +157,23 @@ static void rgmii_dump(void *priv)
156157
#define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ (5 * 1000 * 1000UL)
157158

158159
static void
159-
ethqos_update_rgmii_clk(struct qcom_ethqos *ethqos, unsigned int speed)
160+
ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed)
160161
{
161162
switch (speed) {
162163
case SPEED_1000:
163-
ethqos->rgmii_clk_rate = RGMII_1000_NOM_CLK_FREQ;
164+
ethqos->link_clk_rate = RGMII_1000_NOM_CLK_FREQ;
164165
break;
165166

166167
case SPEED_100:
167-
ethqos->rgmii_clk_rate = RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ;
168+
ethqos->link_clk_rate = RGMII_ID_MODE_100_LOW_SVS_CLK_FREQ;
168169
break;
169170

170171
case SPEED_10:
171-
ethqos->rgmii_clk_rate = RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ;
172+
ethqos->link_clk_rate = RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ;
172173
break;
173174
}
174175

175-
clk_set_rate(ethqos->rgmii_clk, ethqos->rgmii_clk_rate);
176+
clk_set_rate(ethqos->link_clk, ethqos->link_clk_rate);
176177
}
177178

178179
static void ethqos_set_func_clk_en(struct qcom_ethqos *ethqos)
@@ -563,7 +564,7 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)
563564
struct qcom_ethqos *ethqos = priv;
564565

565566
ethqos->speed = speed;
566-
ethqos_update_rgmii_clk(ethqos, speed);
567+
ethqos_update_link_clk(ethqos, speed);
567568
ethqos_configure(ethqos);
568569
}
569570

@@ -597,9 +598,9 @@ static int ethqos_clks_config(void *priv, bool enabled)
597598
int ret = 0;
598599

599600
if (enabled) {
600-
ret = clk_prepare_enable(ethqos->rgmii_clk);
601+
ret = clk_prepare_enable(ethqos->link_clk);
601602
if (ret) {
602-
dev_err(&ethqos->pdev->dev, "rgmii_clk enable failed\n");
603+
dev_err(&ethqos->pdev->dev, "link_clk enable failed\n");
603604
return ret;
604605
}
605606

@@ -610,7 +611,7 @@ static int ethqos_clks_config(void *priv, bool enabled)
610611
*/
611612
ethqos_set_func_clk_en(ethqos);
612613
} else {
613-
clk_disable_unprepare(ethqos->rgmii_clk);
614+
clk_disable_unprepare(ethqos->link_clk);
614615
}
615616

616617
return ret;
@@ -662,9 +663,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
662663
ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en;
663664
ethqos->has_emac3 = data->has_emac3;
664665

665-
ethqos->rgmii_clk = devm_clk_get(dev, "rgmii");
666-
if (IS_ERR(ethqos->rgmii_clk)) {
667-
ret = PTR_ERR(ethqos->rgmii_clk);
666+
ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
667+
if (IS_ERR(ethqos->link_clk)) {
668+
ret = PTR_ERR(ethqos->link_clk);
668669
goto out_config_dt;
669670
}
670671

@@ -683,7 +684,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
683684
}
684685

685686
ethqos->speed = SPEED_1000;
686-
ethqos_update_rgmii_clk(ethqos, SPEED_1000);
687+
ethqos_update_link_clk(ethqos, SPEED_1000);
687688
ethqos_set_func_clk_en(ethqos);
688689

689690
plat_dat->bsp_priv = ethqos;

0 commit comments

Comments
 (0)