Skip to content

Commit 0dec3b4

Browse files
Bartosz Golaszewskikuba-moo
authored andcommitted
net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes phy
On sa8775p platforms, there's a SGMII SerDes PHY between the MAC and external PHY that we need to enable and configure. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f2b1758 commit 0dec3b4

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/of_device.h>
77
#include <linux/platform_device.h>
88
#include <linux/phy.h>
9+
#include <linux/phy/phy.h>
910
#include <linux/property.h>
1011

1112
#include "stmmac.h"
@@ -93,6 +94,7 @@ struct qcom_ethqos {
9394

9495
unsigned int rgmii_clk_rate;
9596
struct clk *rgmii_clk;
97+
struct phy *serdes_phy;
9698
unsigned int speed;
9799

98100
const struct ethqos_emac_por *por;
@@ -565,6 +567,30 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed)
565567
ethqos_configure(ethqos);
566568
}
567569

570+
static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)
571+
{
572+
struct qcom_ethqos *ethqos = priv;
573+
int ret;
574+
575+
ret = phy_init(ethqos->serdes_phy);
576+
if (ret)
577+
return ret;
578+
579+
ret = phy_power_on(ethqos->serdes_phy);
580+
if (ret)
581+
return ret;
582+
583+
return phy_set_speed(ethqos->serdes_phy, ethqos->speed);
584+
}
585+
586+
static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv)
587+
{
588+
struct qcom_ethqos *ethqos = priv;
589+
590+
phy_power_off(ethqos->serdes_phy);
591+
phy_exit(ethqos->serdes_phy);
592+
}
593+
568594
static int ethqos_clks_config(void *priv, bool enabled)
569595
{
570596
struct qcom_ethqos *ethqos = priv;
@@ -650,6 +676,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
650676
if (ret)
651677
goto out_config_dt;
652678

679+
ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
680+
if (IS_ERR(ethqos->serdes_phy)) {
681+
ret = PTR_ERR(ethqos->serdes_phy);
682+
goto out_config_dt;
683+
}
684+
653685
ethqos->speed = SPEED_1000;
654686
ethqos_update_rgmii_clk(ethqos, SPEED_1000);
655687
ethqos_set_func_clk_en(ethqos);
@@ -665,6 +697,11 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
665697
if (of_device_is_compatible(np, "qcom,qcs404-ethqos"))
666698
plat_dat->rx_clk_runs_in_lpi = 1;
667699

700+
if (ethqos->serdes_phy) {
701+
plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
702+
plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;
703+
}
704+
668705
ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
669706
if (ret)
670707
goto out_config_dt;

0 commit comments

Comments
 (0)