ar71xx: add a helper function for setting up PHY4 swapping on ar933x

SVN-Revision: 32092
This commit is contained in:
Felix Fietkau 2012-06-06 17:24:09 +00:00
parent 072bed4760
commit dc9675282e
3 changed files with 21 additions and 15 deletions

View file

@ -634,6 +634,24 @@ static int __init ath79_setup_phy_if_mode(unsigned int id,
return 0; 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; static int ath79_eth_instance __initdata;
void __init ath79_register_eth(unsigned int id) void __init ath79_register_eth(unsigned int id)
{ {

View file

@ -43,4 +43,6 @@ extern struct platform_device ath79_mdio0_device;
extern struct platform_device ath79_mdio1_device; extern struct platform_device ath79_mdio1_device;
void ath79_register_mdio(unsigned int id, u32 phy_mask); 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 */ #endif /* _ATH79_DEV_ETH_H */

View 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) static void __init tl_wr741ndv4_setup(void)
{ {
u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); 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 | ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN | AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |