From: Gabor Juhos Date: Wed, 18 Aug 2010 16:00:28 +0000 (+0000) Subject: ar71xx: change mac address initialization X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7bc5a672c10e3409fb64b7ea37b4ab1307b448f5;p=openwrt%2Fstaging%2Fansuel.git ar71xx: change mac address initialization SVN-Revision: 22700 --- diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.c b/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.c index e45092c46c..fbb813603f 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.c @@ -34,11 +34,8 @@ static void ap91_eth_set_port_name(unsigned port, const char *name) ap91_dsa_chip.port_names[port] = (char *) name; } -void __init ap91_eth_init(u8 *mac_addr, const char *port_names[]) +void __init ap91_eth_init(const char *port_names[]) { - if (mac_addr) - ar71xx_set_mac_base(mac_addr); - if (port_names) { int i; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.h b/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.h index d9cd2141ad..08b1dde6bb 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.h @@ -14,9 +14,9 @@ #define AP91_ETH_NUM_PORT_NAMES 4 #if defined(CONFIG_AR71XX_DEV_AP91_ETH) -void ap91_eth_init(u8 *mac_addr, const char *port_names[]) __init; +void ap91_eth_init(const char *port_names[]) __init; #else -static inline void ap91_eth_init(u8 *mac_addr) { } +static inline void ap91_eth_init(const char *port_names[]) { } #endif #endif /* _AR71XX_DEV_AP91_ETH_H */ diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c index 6f1d2619ef..8879448ac1 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c @@ -22,7 +22,7 @@ #include "devices.h" -static u8 ar71xx_mac_base[ETH_ALEN] __initdata; +unsigned char ar71xx_mac_base[ETH_ALEN] __initdata; static struct resource ar71xx_uart_resources[] = { { @@ -490,10 +490,7 @@ void __init ar71xx_add_device_eth(unsigned int id) break; } - if (is_valid_ether_addr(ar71xx_mac_base)) { - memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN); - pdata->mac_addr[5] += ar71xx_eth_instance; - } else { + if (!is_valid_ether_addr(pdata->mac_addr)) { random_ether_addr(pdata->mac_addr); printk(KERN_DEBUG "ar71xx: using random MAC address for eth%d\n", @@ -580,3 +577,24 @@ static int __init ar71xx_kmac_setup(char *str) return 1; } __setup("kmac=", ar71xx_kmac_setup); + +void __init ar71xx_init_mac(unsigned char *dst, const unsigned char *src, + unsigned offset) +{ + u32 t; + + if (!is_valid_ether_addr(src)) { + memset(dst, '\0', ETH_ALEN); + return; + } + + t = (((u32) src[3]) << 16) + (((u32) src[4]) << 8) + ((u32) src[5]); + t += offset; + + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = (t >> 16) & 0xff; + dst[4] = (t >> 8) & 0xff; + dst[5] = t & 0xff; +} diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h index 957675b0e1..0a3255ff89 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h @@ -20,8 +20,10 @@ void ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata, struct spi_board_info const *info, unsigned n) __init; -void ar71xx_set_mac_base(unsigned char *mac) __init; +extern unsigned char ar71xx_mac_base[] __initdata; void ar71xx_parse_mac_addr(char *mac_str) __init; +void ar71xx_init_mac(unsigned char *dst, const unsigned char *src, + unsigned offset) __init; struct ar71xx_eth_pll_data { u32 pll_10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap81.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap81.c index cd865b001e..5e06c6c1e3 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap81.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap81.c @@ -109,14 +109,15 @@ static void __init ap81_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; ar71xx_eth0_data.has_ar8216 = 1; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = 0x10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap83.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap83.c index acb9f5a1c2..8417b75396 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap83.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap83.c @@ -196,15 +196,15 @@ static void __init ap83_generic_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); - ar71xx_add_device_mdio(0xfffffffe); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.phy_mask = 0x1; ar71xx_add_device_eth(0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.speed = SPEED_1000; ar71xx_eth1_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-600-a1.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-600-a1.c index d0a4490fc5..438d19468d 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-600-a1.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-600-a1.c @@ -118,8 +118,11 @@ static void __init dir_600_a1_setup(void) u8 *mac = NULL; if (nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE, - "lan_mac=", mac_buff) == 0) + "lan_mac=", mac_buff) == 0) { + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); mac = mac_buff; + } ar71xx_add_device_m25p80(&dir_600_a1_flash_data); @@ -130,7 +133,7 @@ static void __init dir_600_a1_setup(void) ARRAY_SIZE(dir_600_a1_gpio_buttons), dir_600_a1_gpio_buttons); - ap91_eth_init(mac, NULL); + ap91_eth_init(NULL); ap91_pci_init(ee, mac); } diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-615-c1.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-615-c1.c index 9c302f79fc..260397bf2c 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-615-c1.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-615-c1.c @@ -142,7 +142,8 @@ static void __init dir_615c1_setup(void) if (nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE, "lan_mac=", mac) == 0) { - ar71xx_set_mac_base(mac); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); wlan_mac = mac; } diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-825-b1.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-825-b1.c index f009bfb7ae..e886f5b217 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-825-b1.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-825-b1.c @@ -145,22 +145,18 @@ static struct platform_device dir825b1_rtl8366s_device = { static void __init dir825b1_setup(void) { - u8 mac[6], i; - - memcpy(mac, (u8*)KSEG1ADDR(DIR825B1_MAC_LOCATION_1), 6); - for(i = 5; i >= 3; i--) - if(++mac[i] != 0x00) break; - - ar71xx_set_mac_base(mac); + u8 *mac = (u8 *) KSEG1ADDR(DIR825B1_MAC_LOCATION_1); ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 1); ar71xx_eth0_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev; ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; ar71xx_eth0_pll_data.pll_1000 = 0x11110000; + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 2); ar71xx_eth1_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev; ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.phy_mask = 0x10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c index 6da318e2d1..3006698f94 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c @@ -145,8 +145,11 @@ static struct gpio_button eap7660d_gpio_buttons[] __initdata = { static void __init eap7660d_setup(void) { u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG); - ar71xx_set_mac_base(boardconfig + EAP7660D_GBIC_MAC_OFFSET); + ar71xx_add_device_mdio(~EAP7660D_PHYMASK); + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, + boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.phy_mask = EAP7660D_PHYMASK; ar71xx_add_device_eth(0); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w04nu.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w04nu.c index df68b282fc..48e080fe2c 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w04nu.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w04nu.c @@ -133,15 +133,15 @@ static void __init mzk_w04nu_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); - ar71xx_add_device_mdio(MZK_W04NU_MDIO_MASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; ar71xx_eth0_data.has_ar8216 = 1; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w300nh.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w300nh.c index 28a79eac6b..4d5df02cfc 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w300nh.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w300nh.c @@ -128,15 +128,15 @@ static void __init mzk_w300nh_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); - ar71xx_add_device_mdio(MZK_W300NH_MDIO_MASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; ar71xx_eth0_data.has_ar8216 = 1; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-nbg460n.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-nbg460n.c index 602a9f022d..3ef8afa1e2 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-nbg460n.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-nbg460n.c @@ -184,15 +184,15 @@ static void __init nbg460n_setup(void) /* last sector contains wlan calib data */ u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(mac); - /* LAN Port */ + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev; ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; /* WAN Port */ + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); ar71xx_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev; ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.phy_mask = 0x10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb42.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb42.c index 576da4ba7a..d14cc9b954 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb42.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb42.c @@ -51,9 +51,11 @@ static void __init pb42_init(void) ar71xx_add_device_mdio(~PB42_MDIO_PHYMASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = PB42_WAN_PHYMASK; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.speed = SPEED_100; ar71xx_eth1_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb44.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb44.c index e514635d16..51951614e9 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb44.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb44.c @@ -173,11 +173,13 @@ static void __init pb44_init(void) { ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.phy_mask = PB44_WAN_PHYMASK; ar71xx_add_device_eth(0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.speed = SPEED_1000; ar71xx_eth1_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb92.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb92.c index de6b86d16d..0419e9b721 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb92.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb92.c @@ -84,14 +84,15 @@ static void __init pb92_init(void) { u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000); - ar71xx_set_mac_base(mac); ar71xx_add_device_m25p80(&pb92_flash_data); ar71xx_add_device_mdio(~0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.speed = SPEED_1000; ar71xx_eth1_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb4xx.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb4xx.c index dc3c2005df..a477cd3ade 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb4xx.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb4xx.c @@ -179,6 +179,7 @@ static void __init rb411_setup(void) ar71xx_add_device_mdio(0xfffffffc); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = 0x00000003; @@ -210,9 +211,11 @@ static void __init rb433_setup(void) ar71xx_add_device_mdio(~RB433_MDIO_PHYMASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = RB433_LAN_PHYMASK; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = RB433_WAN_PHYMASK; @@ -245,9 +248,11 @@ static void __init rb450_generic_setup(int gige) ar71xx_add_device_mdio(~RB450_MDIO_PHYMASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth0_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = RB450_LAN_PHYMASK; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth1_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = RB450_WAN_PHYMASK; @@ -278,10 +283,12 @@ static void __init rb493_setup(void) ar71xx_add_device_mdio(0x3fffff00); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = 0x00000001; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c index 3972f57ac7..9c8386b7ba 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb750.c @@ -13,6 +13,7 @@ #include #include "machtype.h" +#include "devices.h" #include "dev-ap91-eth.h" static struct rb750_led_data rb750_leds[] = { @@ -124,7 +125,10 @@ static void __init rb750_setup(void) AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN | AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN); - ap91_eth_init(NULL, rb750_port_names); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); + ap91_eth_init(rb750_port_names); + platform_device_register(&rb750_leds_device); platform_device_register(&rb750_nand_device); } diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tew-632brp.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tew-632brp.c index 4581fa0b57..3ace1dd544 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tew-632brp.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tew-632brp.c @@ -118,7 +118,8 @@ static void __init tew_632brp_setup(void) if (nvram_parse_mac_addr(config, TEW_632BRP_CONFIG_SIZE, "lan_mac=", mac) == 0) { - ar71xx_set_mac_base(mac); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); wlan_mac = mac; } diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wa901nd.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wa901nd.c index c7779bf50c..ea4135a3d0 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wa901nd.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wa901nd.c @@ -110,13 +110,12 @@ static void __init tl_wa901nd_setup(void) u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(mac); - /* * ar71xx_eth0 would be the WAN port, but is not connected on * the TL-WA901ND. ar71xx_eth1 connects to the internal switch chip, * however we have a single LAN port only. */ + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 0); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.speed = SPEED_1000; ar71xx_eth1_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c index b1e203859c..99cb7d843a 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c @@ -126,8 +126,7 @@ static void __init tl_wr1043nd_setup(void) u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(mac); - + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev; ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd.c index ed217f9e23..834b462de4 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd.c @@ -109,7 +109,8 @@ static void __init tl_wr741nd_setup(void) tl_wr741nd_gpio_buttons); ar71xx_eth1_data.has_ar7240_switch = 1; - ar71xx_set_mac_base(mac); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); /* WAN port */ ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr841n.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr841n.c index fd832d6d97..74f5c2c16d 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr841n.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr841n.c @@ -115,10 +115,9 @@ static void __init tl_wr841n_v1_setup(void) { u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); - ar71xx_set_mac_base(mac); - ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr941nd.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr941nd.c index 2471d48d2e..85289bdf59 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr941nd.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr941nd.c @@ -116,10 +116,9 @@ static void __init tl_wr941nd_setup(void) u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(mac); - ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ubnt.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ubnt.c index 130d9e421d..5af18a7e05 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ubnt.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ubnt.c @@ -142,9 +142,11 @@ static void __init ubnt_rs_setup(void) ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK)); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.speed = SPEED_100; ar71xx_eth1_data.duplex = DUPLEX_FULL; @@ -170,9 +172,11 @@ static void __init ubnt_rspro_setup(void) ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK | UBNT_RSPRO_LAN_PHYMASK)); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, ar71xx_mac_base, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK; ar71xx_eth1_data.speed = SPEED_1000; @@ -205,6 +209,7 @@ static void __init ubnt_lssr71_setup(void) ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK; @@ -222,12 +227,12 @@ static void __init ubnt_m_setup(void) u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000); u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(mac); - ar71xx_add_device_m25p80(NULL); ar71xx_add_device_mdio(~0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c index 51e2ce53fc..0d3e374fe2 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c @@ -168,14 +168,14 @@ static void __init wndr3700_setup(void) { u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); - ar71xx_set_mac_base(art); - + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art, 0); ar71xx_eth0_pll_data.pll_1000 = 0x11110000; ar71xx_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev; ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art, 1); ar71xx_eth1_pll_data.pll_1000 = 0x11110000; ar71xx_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev; ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wnr2000.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wnr2000.c index b0c547065f..002c8ab9f2 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wnr2000.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wnr2000.c @@ -118,14 +118,15 @@ static void __init wnr2000_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); - ar71xx_set_mac_base(eeprom); ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, eeprom, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; ar71xx_eth0_data.has_ar8216 = 1; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, eeprom, 1); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = 0x10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c index 22585842e2..20e0324411 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c @@ -78,6 +78,7 @@ static void __init wp543_setup(void) ar71xx_add_device_mdio(0xfffffff7); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, ar71xx_mac_base, 0); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; ar71xx_eth0_data.phy_mask = 0x08; ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC | diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c index 74d30573cf..acb7e0d1bb 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c @@ -121,8 +121,10 @@ static void __init wrt160nl_setup(void) u8 mac[6]; if (nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE, - "lan_hwaddr=", mac) == 0) - ar71xx_set_mac_base(mac); + "lan_hwaddr=", mac) == 0) { + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); + } ar71xx_add_device_mdio(0x0); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt400n.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt400n.c index d28193850e..5e5536a9f8 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt400n.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt400n.c @@ -131,21 +131,16 @@ static struct gpio_button wrt400n_gpio_buttons[] __initdata = { static void __init wrt400n_setup(void) { u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); - u8 mac[6]; - int i; - - memcpy(mac, art + WRT400N_MAC_ADDR_OFFSET, 6); - for (i = 5; i >= 3; i--) - if (++mac[i] != 0x00) break; - - ar71xx_set_mac_base(mac); + u8 *mac = art + WRT400N_MAC_ADDR_OFFSET; ar71xx_add_device_mdio(0x0); + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 1); ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth0_data.speed = SPEED_100; ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 2); ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; ar71xx_eth1_data.phy_mask = 0x10; diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c index c12b0a0415..83935377a6 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c @@ -228,15 +228,16 @@ static struct platform_device wzrhpg300nh_rtl8366s_device = { static void __init wzrhpg300nh_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); + u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET; - ar71xx_set_mac_base(eeprom + WZRHPG300NH_MAC_OFFSET); - + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_eth0_pll_data.pll_1000 = 0x1e000100; ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); ar71xx_eth1_pll_data.pll_1000 = 0x1e000100; ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;