Author: nbd
Date: 2015-04-20 17:00:52 +0200 (Mon, 20 Apr 2015)
New Revision: 45523

Modified:
   trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
   trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
Log:
ar71xx: add a helper function to set RXDV/RXD of ETH_CFG on AR934x

The ETH_RXDV_DELAY (17:16) and ETH_RXD_DELAY (15:14) are currently not cleared
by the function ath79_setup_ar934x_eth_cfg. Clearing these in the
ath79_setup_ar934x_eth_cfg may cause problems on some hardware because they
rely on the preset value by the bootloader.

Instead another function is introduced which also works on ETH_CFG on AR934x.
It can be used to safely clear and set ETH_RXDV_DELAY and ETH_RXD_DELAY on
machines which require special settings.

Signed-off-by: Sven Eckelmann <[email protected]>

Modified: trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
===================================================================
--- trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c   2015-04-20 
15:00:41 UTC (rev 45522)
+++ trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c   2015-04-20 
15:00:52 UTC (rev 45523)
@@ -769,6 +769,32 @@
        iounmap(base);
 }
 
+void __init ath79_setup_ar934x_eth_rx_delay(unsigned int rxd,
+                                           unsigned int rxdv)
+{
+       void __iomem *base;
+       u32 t;
+
+       rxd &= AR934X_ETH_CFG_RXD_DELAY_MASK;
+       rxdv &= AR934X_ETH_CFG_RDV_DELAY_MASK;
+
+       base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
+
+       t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
+
+       t &= ~(AR934X_ETH_CFG_RXD_DELAY_MASK << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
+              AR934X_ETH_CFG_RDV_DELAY_MASK << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
+
+       t |= (rxd << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
+             rxdv << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
+
+       __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
+       /* flush write */
+       __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
+
+       iounmap(base);
+}
+
 void __init ath79_setup_qca955x_eth_cfg(u32 mask)
 {
        void __iomem *base;

Modified: trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
===================================================================
--- trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h   2015-04-20 
15:00:41 UTC (rev 45522)
+++ trunk/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h   2015-04-20 
15:00:52 UTC (rev 45523)
@@ -47,6 +47,7 @@
 
 void ath79_setup_ar933x_phy4_switch(bool mac, bool mdio);
 void ath79_setup_ar934x_eth_cfg(u32 mask);
+void ath79_setup_ar934x_eth_rx_delay(unsigned int rxd, unsigned int rxdv);
 void ath79_setup_qca955x_eth_cfg(u32 mask);
 
 #endif /* _ATH79_DEV_ETH_H */
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to