Index: conf/options.mips =================================================================== --- conf/options.mips (revision 240075) +++ conf/options.mips (working copy) @@ -82,6 +82,7 @@ AR71XX_ENV_UBOOT opt_ar71xx.h AR71XX_ENV_REDBOOT opt_ar71xx.h AR71XX_ATH_EEPROM opt_ar71xx.h +AR71XX_ROUTERBOOT opt_ar71xx.h # # Options that control the Ralink RT305xF Etherenet MAC. Index: mips/atheros/ar71xx_machdep.c =================================================================== --- mips/atheros/ar71xx_machdep.c (revision 239916) +++ mips/atheros/ar71xx_machdep.c (working copy) @@ -140,6 +140,30 @@ } } +#ifdef AR71XX_ROUTERBOOT +/* + * Parse the available boad memory from command line arguments. + */ +static int +ar71xx_routerboot_get_mem(int argc, char **argv) +{ + int i, board_mem; + + /* + * Protect ourselves from garbage in registers + */ + if (MIPS_IS_VALID_PTR(argv)) { + for (i = 0; i < argc; i++) { + if (strncmp(argv[i], "mem=", 4) == 0) { + if (sscanf(argv[i] + 4, "%dM", &board_mem) == 1) + return (btoc(board_mem * 1024 * 1024)); + } + } + } + return (0); +} +#endif + void platform_start(__register_t a0 __unused, __register_t a1 __unused, __register_t a2 __unused, __register_t a3 __unused) @@ -183,7 +207,15 @@ } } +#ifdef AR71XX_ROUTERBOOT /* + * RouterBoot informs the board memory as a command line argument. + */ + if (realmem == 0) + realmem = ar71xx_routerboot_get_mem(argc, argv); +#endif + + /* * Just wild guess. RedBoot let us down and didn't reported * memory size */ Index: mips/atheros/if_arge.c =================================================================== --- mips/atheros/if_arge.c (revision 239916) +++ mips/atheros/if_arge.c (working copy) @@ -36,6 +36,7 @@ #endif #include "opt_arge.h" +#include "opt_ar71xx.h" #include #include @@ -371,6 +370,9 @@ uint32_t hint; long eeprom_mac_addr = 0; int miicfg = 0; +#ifdef AR71XX_ROUTERBOOT + char *board; +#endif sc = device_get_softc(dev); sc->arge_dev = dev; @@ -533,8 +535,21 @@ sc->arge_eaddr[4] = (rnd >> 16) & 0xff; sc->arge_eaddr[5] = (rnd >> 8) & 0xff; } - if (sc->arge_mac_unit != 0) - sc->arge_eaddr[5] += sc->arge_mac_unit; +#ifdef AR71XX_ROUTERBOOT + /* + * Some RouterBoards (RB433x, RB450x and RB493x) uses the unit 1 as + * main (WAN) port. Invert the mac address setup logic if needed. + */ + if ((board = getenv("board")) != NULL && + (strncmp(board, "433", 3) == 0 || + strncmp(board, "450", 3) == 0 || + strncmp(board, "493", 3) == 0)) { + if (sc->arge_mac_unit == 0) + sc->arge_eaddr[5] += 1; + } else +#endif + if (sc->arge_mac_unit != 0) + sc->arge_eaddr[5] += sc->arge_mac_unit; if (arge_dma_alloc(sc) != 0) { error = ENXIO;