ar71xx: add a helper function for setting up ETH_CFG register on AR934x
authorGabor Juhos <juhosg@openwrt.org>
Wed, 17 Oct 2012 18:27:45 +0000 (18:27 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Wed, 17 Oct 2012 18:27:45 +0000 (18:27 +0000)
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 33817

target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h

index 4487958bc78cd7cd82e801d55ee633fa34df2988..5a0b950c1bf907f837503f8c58df9de5c85a2366 100644 (file)
@@ -691,6 +691,30 @@ void __init ath79_setup_ar933x_phy4_switch(bool mac, bool mdio)
        iounmap(base);
 }
 
+void __init ath79_setup_ar934x_eth_cfg(u32 mask)
+{
+       void __iomem *base;
+       u32 t;
+
+       base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
+
+       t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
+
+       t &= ~(AR934X_ETH_CFG_RGMII_GMAC0 |
+              AR934X_ETH_CFG_MII_GMAC0 |
+              AR934X_ETH_CFG_GMII_GMAC0 |
+              AR934X_ETH_CFG_SW_ONLY_MODE |
+              AR934X_ETH_CFG_SW_PHY_SWAP);
+
+       t |= mask;
+
+       __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
+       /* flush write */
+       __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
+
+       iounmap(base);
+}
+
 static int ath79_eth_instance __initdata;
 void __init ath79_register_eth(unsigned int id)
 {
index d4f27d9cf21780368838816162ed0d97badf6724..561bf3ff861836d7714c2a770eeeaf19730ce2e1 100644 (file)
@@ -44,5 +44,6 @@ extern struct platform_device ath79_mdio1_device;
 void ath79_register_mdio(unsigned int id, u32 phy_mask);
 
 void ath79_setup_ar933x_phy4_switch(bool mac, bool mdio);
+void ath79_setup_ar934x_eth_cfg(u32 mask);
 
 #endif /* _ATH79_DEV_ETH_H */