From 8f1ad5f7a217e1b995e759648e7fa3e6151ba0c0 Mon Sep 17 00:00:00 2001 From: Suraj Jaiswal Date: Wed, 17 Mar 2021 22:51:58 +0530 Subject: [PATCH 1/2] net: stmmac: disable & enable clock on suspend resume disable all eth clocks on suspend and enable them on resume. Change-Id: I65e80188e2cce0967b5bce8f0f5f55c842f40aa0 Acked-by: Nagarjuna Chaganti Signed-off-by: Suraj Jaiswal --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 3183782e2e74..f324ac0655ad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -899,6 +899,8 @@ static void ethqos_pps_irq_config(struct qcom_ethqos *ethqos) static void qcom_ethqos_phy_suspend_clks(struct qcom_ethqos *ethqos) { + struct stmmac_priv *priv = qcom_ethqos_get_priv(ethqos); + ETHQOSINFO("Enter\n"); if (phy_intr_en) @@ -908,6 +910,18 @@ static void qcom_ethqos_phy_suspend_clks(struct qcom_ethqos *ethqos) ethqos_update_rgmii_clk_and_bus_cfg(ethqos, 0); + if (priv->plat->stmmac_clk) + clk_disable_unprepare(priv->plat->stmmac_clk); + + if (priv->plat->pclk) + clk_disable_unprepare(priv->plat->pclk); + + if (priv->plat->clk_ptp_ref) + clk_disable_unprepare(priv->plat->clk_ptp_ref); + + if (ethqos->rgmii_clk) + clk_disable_unprepare(ethqos->rgmii_clk); + ETHQOSINFO("Exit\n"); } @@ -933,8 +947,22 @@ inline bool qcom_ethqos_is_phy_link_up(struct qcom_ethqos *ethqos) static void qcom_ethqos_phy_resume_clks(struct qcom_ethqos *ethqos) { + struct stmmac_priv *priv = qcom_ethqos_get_priv(ethqos); + ETHQOSINFO("Enter\n"); + if (priv->plat->stmmac_clk) + clk_prepare_enable(priv->plat->stmmac_clk); + + if (priv->plat->pclk) + clk_prepare_enable(priv->plat->pclk); + + if (priv->plat->clk_ptp_ref) + clk_prepare_enable(priv->plat->clk_ptp_ref); + + if (ethqos->rgmii_clk) + clk_prepare_enable(ethqos->rgmii_clk); + if (qcom_ethqos_is_phy_link_up(ethqos)) ethqos_update_rgmii_clk_and_bus_cfg(ethqos, ethqos->speed); else From b532c90034848062041ad5b68bf875b92c3206db Mon Sep 17 00:00:00 2001 From: Suraj Jaiswal Date: Fri, 14 Aug 2020 18:20:32 +0530 Subject: [PATCH 2/2] net: stmmac: LPM link detection fix Fix Link detection issue after suspend resume. Change-Id: If2bd3825225bb17689709cdc226eeea827ff4bf3 Acked-by: Nagarjuna Chaganti Signed-off-by: Suraj Jaiswal --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 2329f39cc3da..6bc3e941dd67 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4806,6 +4806,11 @@ int stmmac_suspend(struct device *dev) phylink_mac_change(priv->phylink, false); +#ifdef CONFIG_DWMAC_QCOM_ETHQOS + rtnl_lock(); + phylink_stop(priv->phylink); + rtnl_unlock(); +#endif mutex_lock(&priv->lock); netif_device_detach(ndev); @@ -4825,9 +4830,11 @@ int stmmac_suspend(struct device *dev) priv->irq_wake = 1; } else { mutex_unlock(&priv->lock); +#ifndef CONFIG_DWMAC_QCOM_ETHQOS rtnl_lock(); phylink_stop(priv->phylink); rtnl_unlock(); +#endif mutex_lock(&priv->lock); stmmac_mac_set(priv, priv->ioaddr, false); @@ -4925,13 +4932,18 @@ int stmmac_resume(struct device *dev) stmmac_start_all_queues(priv); mutex_unlock(&priv->lock); - +#ifndef CONFIG_DWMAC_QCOM_ETHQOS if (!device_may_wakeup(priv->device)) { rtnl_lock(); phylink_start(priv->phylink); rtnl_unlock(); } - +#endif +#ifdef CONFIG_DWMAC_QCOM_ETHQOS + rtnl_lock(); + phylink_start(priv->phylink); + rtnl_unlock(); +#endif phylink_mac_change(priv->phylink, true); return 0;