ethernet: turn off led and phy power
authorZhuo Wang <zhuo.wang@amlogic.com>
Thu, 14 Jun 2018 06:01:11 +0000 (14:01 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Thu, 14 Jun 2018 09:02:12 +0000 (02:02 -0700)
PD#164611: u211 optimize power for phy

Change-Id: Ic5eb4684b221f84abc581520fe89cde4d271d1cf
Signed-off-by: Zhuo Wang <zhuo.wang@amlogic.com>
arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts
arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts
arch/arm64/boot/dts/amlogic/mesong12a.dtsi
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c

index f0e08f4817ee4bd6fca501f3502318f8461e66e5..5846d602995793fcfc2827aad226cf06295d1c7e 100644 (file)
 };
 &ethmac {
        status = "okay";
-       pinctrl-names = "internal_eth_pins";
+       pinctrl-names = "internal_eth_pins", "internal_gpio_pins";
        pinctrl-0 = <&internal_eth_pins>;
+       pinctrl-1 = <&internal_gpio_pins>;
        mc_val = <0x4be04>;
 
        internal_phy=<1>;
index c489d226073ea980567fbdb8d1e75e5677d25cab..184a70ca37cd6508083a1ebef08f3b746daecf35 100644 (file)
 };
 &ethmac {
        status = "okay";
-       pinctrl-names = "internal_eth_pins";
+       pinctrl-names = "internal_eth_pins", "internal_gpio_pins";
        pinctrl-0 = <&internal_eth_pins>;
+       pinctrl-1 = <&internal_gpio_pins>;
        mc_val = <0x4be04>;
 
        internal_phy=<1>;
index 2a83e09ea2bc3a0f33ec61c1589c897eddd72631..4674abf344309061ece50ea5931fde4176c653e0 100644 (file)
 };
 &ethmac {
        status = "disabled";
-       pinctrl-names = "internal_eth_pins";
+       pinctrl-names = "internal_eth_pins", "internal_gpio_pins";
        pinctrl-0 = <&internal_eth_pins>;
+       pinctrl-1 = <&internal_gpio_pins>;
        mc_val = <0x4be04>;
 
        internal_phy=<1>;
index d4b487e306321f8df215157defc9d47fc48973ac..b3ee0a0cba907500859087a2b644bafd2799ba70 100644 (file)
                };
        };
 
+       internal_gpio_pins: internal_gpio_pins {
+               mux {
+                       groups = "GPIOZ_14",
+                               "GPIOZ_15";
+                       function = "gpio_periphs";
+                       bias-disable;
+                       input-enable;
+               };
+       };
+
        external_eth_pins: external_eth_pins {
                mux {
                        groups = "eth_mdio",
index f6af2573f100abd831bad889a6a5851997e20de9..a854e6c65b60d6878c407509c1cf8e51ad8b245a 100644 (file)
@@ -236,10 +236,10 @@ static int dwmac_meson_cfg_ctrl(void __iomem *base_addr)
 
        /*use_phy_smi | use_phy_ip | co_clkin from eth_phy_top*/
        writel(0x260, ETH_PHY_config_addr + ETH_PHY_CNTL2);
-
-       writel(0x54147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
-       writel(0x14147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
-       writel(0x54147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
+       /*led signal is inverted*/
+       writel(0x41054147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
+       writel(0x41014147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
+       writel(0x41054147, ETH_PHY_config_addr + ETH_PHY_CNTL1);
        /*wait phy to reset cause Power Up Reset need 5.2~2.6 ms*/
        mdelay(10);
        return 0;
@@ -418,11 +418,21 @@ static int dwmac_meson_recover_analog(struct device *dev)
 static int meson6_dwmac_suspend(struct device *dev)
 {
        int ret;
+       struct pinctrl *pin_ctrl;
+       struct pinctrl_state *turnoff_tes = NULL;
 
        /*shudown internal phy analog*/
        pr_info("suspend inter = %d\n", is_internal_phy);
-       if (is_internal_phy)
+       if (is_internal_phy) {
+               /*turn off led*/
+               pin_ctrl = devm_pinctrl_get(dev);
+               turnoff_tes = pinctrl_lookup_state
+                                       (pin_ctrl, "internal_gpio_pins");
+               pinctrl_select_state(pin_ctrl, turnoff_tes);
+               devm_pinctrl_put(pin_ctrl);
+               pin_ctrl = NULL;
                dwmac_meson_disable_analog(dev);
+       }
        ret = stmmac_pltfr_suspend(dev);
 
        return ret;
@@ -431,16 +441,50 @@ static int meson6_dwmac_suspend(struct device *dev)
 static int meson6_dwmac_resume(struct device *dev)
 {
        int ret;
+       struct pinctrl *pin_ctrl;
+       struct pinctrl_state *turnon_tes = NULL;
 
        pr_info("resuem inter = %d\n", is_internal_phy);
-       if (is_internal_phy)
+       if (is_internal_phy) {
+               pin_ctrl = devm_pinctrl_get(dev);
+               turnon_tes = pinctrl_lookup_state
+                                       (pin_ctrl, "internal_eth_pins");
+               pinctrl_select_state(pin_ctrl, turnon_tes);
+               devm_pinctrl_put(pin_ctrl);
+               pin_ctrl = NULL;
                dwmac_meson_recover_analog(dev);
+       }
        ret = stmmac_pltfr_resume(dev);
 
        return ret;
 }
 EXPORT_SYMBOL_GPL(meson6_dwmac_resume);
 
+void meson6_dwmac_shutdown(struct platform_device *pdev)
+{
+       struct net_device *ndev = platform_get_drvdata(pdev);
+       struct stmmac_priv *priv = netdev_priv(ndev);
+       struct pinctrl *pin_ctrl;
+       struct pinctrl_state *turnoff_tes = NULL;
+
+       /*shudown internal phy analog*/
+       if (is_internal_phy) {
+               pin_ctrl = devm_pinctrl_get(&pdev->dev);
+               turnoff_tes = pinctrl_lookup_state
+                                       (pin_ctrl, "internal_gpio_pins");
+               pinctrl_select_state(pin_ctrl, turnoff_tes);
+               devm_pinctrl_put(pin_ctrl);
+               pin_ctrl = NULL;
+               dwmac_meson_disable_analog(&pdev->dev);
+       }
+       //stmmac_release(ndev);
+       stmmac_pltfr_suspend(&pdev->dev);
+       if (priv->phydev)
+               genphy_suspend(ndev->phydev);
+       if (priv->plat->exit)
+               priv->plat->exit(pdev, priv->plat->bsp_priv);
+}
+
 #endif
 static int meson6_dwmac_probe(struct platform_device *pdev)
 {
@@ -539,6 +583,9 @@ SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, meson6_dwmac_suspend,
 static struct platform_driver meson6_dwmac_driver = {
        .probe  = meson6_dwmac_probe,
        .remove = stmmac_pltfr_remove,
+#ifdef CONFIG_AMLOGIC_ETH_PRIVE
+       .shutdown = meson6_dwmac_shutdown,
+#endif
        .driver = {
                .name           = "meson6-dwmac",
                .pm             = &stmmac_pltfr_pm_ops,