ethernet: add interface to delay rx/tx clk [1/1]
authorZhuo Wang <zhuo.wang@amlogic.com>
Wed, 12 Jun 2019 08:07:22 +0000 (16:07 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 07:27:55 +0000 (15:27 +0800)
PD#SWPL-9720

Problem:
difference window area between chips

Solution:
add interface to custom

Verify:
verify on g12a u200 board

Change-Id: I589c890e36961f533bffae557337b24a09f1bf41
Signed-off-by: Zhuo Wang <zhuo.wang@amlogic.com>
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
drivers/net/phy/realtek.c

index 1235225..3fe1544 100644 (file)
@@ -377,6 +377,10 @@ static void __iomem *g12a_network_interface_setup(struct platform_device *pdev)
 
        /*config extern phy*/
        if (internal_phy == 0) {
+               if (of_property_read_u32(np, "tx_delay", &external_tx_delay))
+                       pr_debug("set exphy tx delay\n");
+               if (of_property_read_u32(np, "rx_delay", &external_rx_delay))
+                       pr_debug("set exphy rx delay\n");
                /* only exphy support wol since g12a*/
                /*we enable/disable wol with item in dts with "wol=<1>"*/
                if (of_property_read_u32(np, "wol",
index a902bb6..5b44e9b 100644 (file)
@@ -33,6 +33,8 @@ int stmmac_pltfr_remove(struct platform_device *pdev);
 #ifdef CONFIG_AMLOGIC_ETH_PRIVE
 int stmmac_pltfr_suspend(struct device *dev);
 int stmmac_pltfr_resume(struct device *dev);
+extern unsigned int external_rx_delay;
+extern unsigned int external_tx_delay;
 #endif
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
@@ -43,5 +45,4 @@ static inline void *get_stmmac_bsp_priv(struct device *dev)
 
        return priv->plat->bsp_priv;
 }
-
 #endif /* __STMMAC_PLATFORM_H__ */
index 68c27b5..5adeeb8 100644 (file)
@@ -50,6 +50,8 @@ static int wol_enable = 0;
 
 #ifdef CONFIG_AMLOGIC_ETH_PRIVE
 unsigned int support_external_phy_wol;
+unsigned int external_rx_delay;
+unsigned int external_tx_delay;
 #endif
 
 static int __init init_wol_state(char *str)
@@ -190,6 +192,20 @@ static int rtl8211f_config_init(struct phy_device *phydev)
 
        phy_write(phydev, 0x11, reg);
 #ifdef CONFIG_AMLOGIC_ETH_PRIVE
+       if (external_rx_delay) {
+       /*add 2ns delay for rx*/
+               phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
+               reg = phy_read(phydev, 0x15);
+               reg = phy_write(phydev, 0x15, reg | 0x8);
+               phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
+       }
+       if (external_tx_delay) {
+       /*add 2ns delay for tx*/
+               phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
+               reg = phy_read(phydev, 0x11);
+               reg = phy_write(phydev, 0x11, reg | 0x100);
+               phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
+       }
        /*disable clk_out pin 35 set page 0x0a43 reg25.0 as 0*/
        phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0a43);
        reg = phy_read(phydev, 0x19);