From 62977660d8f0b0f77c7d6ad40f9496336a1a8e26 Mon Sep 17 00:00:00 2001 From: nbd Date: Wed, 6 Jun 2012 17:24:09 +0000 Subject: ar71xx: add a helper function for setting up PHY4 swapping on ar933x git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32092 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 18 ++++++++++++++++++ target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h | 2 ++ .../ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c | 16 +--------------- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'target/linux/ar71xx/files/arch/mips') 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 | -- cgit v1.2.3