ar71xx: add a helper function for setting up PHY4 swapping on ar933x
authorFelix Fietkau <nbd@openwrt.org>
Wed, 6 Jun 2012 17:24:09 +0000 (17:24 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 6 Jun 2012 17:24:09 +0000 (17:24 +0000)
SVN-Revision: 32092

target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c

index bc88a44aa761958e201ceeba398f4bf27a3957fb..45817e171ac02b0b50f1ed8ab0dba528b59448d1 100644 (file)
@@ -634,6 +634,24 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
        return 0;
 }
 
+void __init ath79_setup_ar933x_phy4_switch(bool mac, bool mdio)
+{
+       void __iomem *base;
+       u32 t;
+
+       base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
+
+       t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
+       t &= ~(AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
+       if (mac)
+               t |= AR933X_ETH_CFG_SW_PHY_SWAP;
+       if (mdio)
+               t |= AR933X_ETH_CFG_SW_PHY_ADDR_SWAP;
+       __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
+
+       iounmap(base);
+}
+
 static int ath79_eth_instance __initdata;
 void __init ath79_register_eth(unsigned int id)
 {
index 4c010ef74ee40ab56713b2eb2ccc580d1c8e72b5..d4f27d9cf21780368838816162ed0d97badf6724 100644 (file)
@@ -43,4 +43,6 @@ extern struct platform_device ath79_mdio0_device;
 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);
+
 #endif /* _ATH79_DEV_ETH_H */
index 214429cd54b3a515873a0e3355aca80e4f8e3b4a..0d758913f315217a87d11d197e946ef264f8a7ff 100644 (file)
@@ -100,26 +100,12 @@ static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
        }
 };
 
-static void __init tl_wr741ndv4_gmac_setup(void)
-{
-       void __iomem *base;
-       u32 t;
-
-       base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
-
-       t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
-       t |= (AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
-       __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
-
-       iounmap(base);
-}
-
 static void __init tl_wr741ndv4_setup(void)
 {
        u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
        u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
 
-       tl_wr741ndv4_gmac_setup();
+       ath79_setup_ar933x_phy4_switch(true, true);
 
        ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
                                    AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |