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)
committerTao Zeng <tao.zeng@amlogic.com>
Fri, 28 Jun 2019 04:27:57 +0000 (21:27 -0700)
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 9910115..178b934 100644 (file)
@@ -376,6 +376,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 31bc5a3..0f5615a 100644 (file)
@@ -45,6 +45,8 @@ MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_AMLOGIC_ETH_PRIVE
 unsigned int support_external_phy_wol;
+unsigned int external_rx_delay;
+unsigned int external_tx_delay;
 #endif
 static int rtl821x_ack_interrupt(struct phy_device *phydev)
 {
@@ -130,6 +132,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);