aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-06-06 17:24:09 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-06-06 17:24:09 +0000
commitdc9675282e17439ac7ffecc29f0a5e2ddd3b9264 (patch)
tree203339543515de0aaffda1a6c433180ebc20d448
parent072bed476076acec560557e985ca0ddcdd62be9a (diff)
downloadupstream-dc9675282e17439ac7ffecc29f0a5e2ddd3b9264.tar.gz
upstream-dc9675282e17439ac7ffecc29f0a5e2ddd3b9264.tar.bz2
upstream-dc9675282e17439ac7ffecc29f0a5e2ddd3b9264.zip
ar71xx: add a helper function for setting up PHY4 swapping on ar933x
SVN-Revision: 32092
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c18
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h2
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c16
3 files changed, 21 insertions, 15 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
index bc88a44aa7..45817e171a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
@@ -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)
{
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
index 4c010ef74e..d4f27d9cf2 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h
@@ -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 */
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
index 214429cd54..0d758913f3 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
@@ -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 |