ETH: do eth reset bit when resume. [1/1]
authorqi duan <qi.duan@amlogic.com>
Thu, 15 Aug 2019 07:58:34 +0000 (03:58 -0400)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 28 Aug 2019 04:11:32 +0000 (21:11 -0700)
PD#SWPL-12780

Problem:
internal phy can not connect network probably
after long stress suspend test

Solution:
In suspend/resume sequeue, add eth reset

Verify:
verify on TL1 and G12b

Change-Id: Id8f6767686f4e4d52774d9ac28dac46549a52d4c
Signed-off-by: qi duan <qi.duan@amlogic.com>
13 files changed:
arch/arm/boot/dts/amlogic/mesong12a.dtsi
arch/arm/boot/dts/amlogic/mesong12b.dtsi
arch/arm/boot/dts/amlogic/mesong12b_a.dtsi
arch/arm/boot/dts/amlogic/mesonsm1.dtsi
arch/arm/boot/dts/amlogic/mesontl1.dtsi
arch/arm/boot/dts/amlogic/mesontm2.dtsi
arch/arm64/boot/dts/amlogic/mesong12a.dtsi
arch/arm64/boot/dts/amlogic/mesong12b.dtsi
arch/arm64/boot/dts/amlogic/mesong12b_a.dtsi
arch/arm64/boot/dts/amlogic/mesonsm1.dtsi
arch/arm64/boot/dts/amlogic/mesontl1.dtsi
arch/arm64/boot/dts/amlogic/mesontm2.dtsi
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c

index df38838..47b5d2f 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 7b23315..f98a97f 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 59b639c..76dd3cd 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index f7f509c..16ba4a2 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 5a398a4..87efd0a 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 62618ee..b8bc9e2 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0xff3f0000 0x10000
                        0xff634540 0x8
-                       0xff64c000 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0xff64c000 0xa0
+                       0xffd01008 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index c315acf..0bf23d3 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index add712c..78cfb28 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 7740701..e9276e2 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index 8c72445..ac87f8a 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index da702c7..2d02cdd 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index a81a8ee..30a7eab 100644 (file)
                compatible = "amlogic, g12a-eth-dwmac","snps,dwmac";
                reg = <0x0 0xff3f0000 0x0 0x10000
                        0x0 0xff634540 0x0 0x8
-                       0x0 0xff64c000 0x0 0xa0>;
-               reg-names = "eth_base", "eth_cfg", "eth_pll";
+                       0x0 0xff64c000 0x0 0xa0
+                       0x0 0xffd01008 0x0 0x4>;
+               reg-names = "eth_base", "eth_cfg", "eth_pll", "eth_reset";
                interrupts = <0 8 1>;
                interrupt-names = "macirq";
                status = "disabled";
index ed459b9..a4cdb8e 100644 (file)
@@ -55,6 +55,9 @@ static unsigned int is_internal_phy;
 struct meson_dwmac_data {
        bool g12a_phy;
 };
+
+void __iomem *ee_reset_base;
+struct platform_device *ppdev;
 #endif
 
 struct meson_dwmac {
@@ -313,6 +316,7 @@ static void __iomem *g12a_network_interface_setup(struct platform_device *pdev)
        int auto_cali_idx = -1;
        is_internal_phy = 0;
 
+       ppdev = pdev;
        pr_debug("g12a_network_interface_setup\n");
        /*map PRG_ETH_REG */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eth_cfg");
@@ -330,6 +334,21 @@ static void __iomem *g12a_network_interface_setup(struct platform_device *pdev)
        REG_ETH_reg0_addr = addr;
        pr_info(" REG0:Addr = %p\n", REG_ETH_reg0_addr);
 
+       /*map ETH_RESET address*/
+       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eth_reset");
+       if (!res) {
+               dev_err(&pdev->dev, "Unable to get resource(%d)\n", __LINE__);
+               ee_reset_base = NULL;
+       } else {
+               addr = devm_ioremap_resource(dev, res);
+               if (IS_ERR(addr)) {
+                       dev_err(&pdev->dev, "Unable to map reset base\n");
+                       return NULL;
+               }
+               ee_reset_base = addr;
+               pr_info(" ee eth reset:Addr = %p\n", ee_reset_base);
+       }
+
        /*map ETH_PLL address*/
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "eth_pll");
        if (!res) {
@@ -494,6 +513,10 @@ static int meson6_dwmac_resume(struct device *dev)
        struct pinctrl_state *turnon_tes = NULL;
        pr_info("resuem inter = %d\n", is_internal_phy);
        if ((is_internal_phy) && (support_mac_wol == 0)) {
+               if (ee_reset_base)
+                       writel((1 << 11), (void __iomem *)
+                               (unsigned long)ee_reset_base);
+
                pin_ctrl = devm_pinctrl_get(dev);
                if (IS_ERR_OR_NULL(pin_ctrl)) {
                        pr_info("pinctrl is null\n");
@@ -504,7 +527,13 @@ static int meson6_dwmac_resume(struct device *dev)
                        devm_pinctrl_put(pin_ctrl);
                        pin_ctrl = NULL;
                }
-               dwmac_meson_recover_analog(dev);
+               if (!ee_reset_base) {
+                       dwmac_meson_recover_analog(dev);
+               } else {
+                       dwmac_meson_cfg_pll(phy_analog_config_addr, ppdev);
+                       dwmac_meson_cfg_analog(phy_analog_config_addr, ppdev);
+                       dwmac_meson_cfg_ctrl(phy_analog_config_addr, ppdev);
+               }
        }
        ret = stmmac_pltfr_resume(dev);
        return ret;