ar71xx: rewrite WNDR3700/3800 handling
authorGabor Juhos <juhosg@openwrt.org>
Mon, 5 Dec 2011 13:03:54 +0000 (13:03 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 5 Dec 2011 13:03:54 +0000 (13:03 +0000)
SVN-Revision: 29434

target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network [deleted file]
target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network [deleted file]
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/etc/uci-defaults/leds
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c
target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h
target/linux/ar71xx/generic/profiles/netgear.mk
target/linux/ar71xx/image/Makefile

diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network b/target/linux/ar71xx/base-files/etc/defconfig/wndr3700v2/network
deleted file mode 100644 (file)
index 69d7dc7..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-config interface loopback
-       option ifname   lo
-       option proto    static
-       option ipaddr   127.0.0.1
-       option netmask  255.0.0.0
-
-config interface lan
-       option ifname   eth0.1
-       option type     bridge
-       option proto    static
-       option ipaddr   192.168.1.1
-       option netmask  255.255.255.0
-
-config interface wan
-       option ifname   eth1
-       option proto    dhcp
-
-config switch
-       option name     rtl8366s
-       option reset    1
-       option enable_vlan 1
-       # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
-       option blinkrate        2
-
-config switch_vlan
-       option device   rtl8366s
-       option vlan     1
-       option ports    "0 1 2 3 5t"
-
-config switch_port
-       # Port 1 controls the GREEN configuration of LEDs for
-       # the switch and the section does not correspond to a real
-       # switch port.
-       #
-       # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
-       # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
-       # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
-       # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
-       # 14: Link (master); 15: separate register
-
-       option device           rtl8366s
-       option port             1
-       option led              6
-
-config switch_port
-       # Port 2 controls the ORANGE configuration of LEDs for
-       # the switch and the section does not correspond to a real
-       # switch port.
-       #
-       # See the key above for switch port 1 for the meaning of the
-       # 'led' setting below.
-       
-       option device           rtl8366s
-       option port             2
-       option led              9
-
-config switch_port
-       # Port 5 controls the configuration of the WAN LED and the
-       # section does not correspond to a real switch port.
-       #
-       # To toggle the use of green or orange LEDs for the WAN port,
-       # see the LED setting for wndr3700:green:wan in /etc/config/system.
-       #
-       # See the key above for switch port 1 for the meaning of the
-       # 'led' setting below.
-
-       option device           rtl8366s
-       option port             5
-       option led              2
diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network b/target/linux/ar71xx/base-files/etc/defconfig/wndr3800/network
deleted file mode 100644 (file)
index 69d7dc7..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-config interface loopback
-       option ifname   lo
-       option proto    static
-       option ipaddr   127.0.0.1
-       option netmask  255.0.0.0
-
-config interface lan
-       option ifname   eth0.1
-       option type     bridge
-       option proto    static
-       option ipaddr   192.168.1.1
-       option netmask  255.255.255.0
-
-config interface wan
-       option ifname   eth1
-       option proto    dhcp
-
-config switch
-       option name     rtl8366s
-       option reset    1
-       option enable_vlan 1
-       # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
-       option blinkrate        2
-
-config switch_vlan
-       option device   rtl8366s
-       option vlan     1
-       option ports    "0 1 2 3 5t"
-
-config switch_port
-       # Port 1 controls the GREEN configuration of LEDs for
-       # the switch and the section does not correspond to a real
-       # switch port.
-       #
-       # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
-       # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
-       # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
-       # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
-       # 14: Link (master); 15: separate register
-
-       option device           rtl8366s
-       option port             1
-       option led              6
-
-config switch_port
-       # Port 2 controls the ORANGE configuration of LEDs for
-       # the switch and the section does not correspond to a real
-       # switch port.
-       #
-       # See the key above for switch port 1 for the meaning of the
-       # 'led' setting below.
-       
-       option device           rtl8366s
-       option port             2
-       option led              9
-
-config switch_port
-       # Port 5 controls the configuration of the WAN LED and the
-       # section does not correspond to a real switch port.
-       #
-       # To toggle the use of green or orange LEDs for the WAN port,
-       # see the LED setting for wndr3700:green:wan in /etc/config/system.
-       #
-       # See the key above for switch port 1 for the meaning of the
-       # 'led' setting below.
-
-       option device           rtl8366s
-       option port             5
-       option led              2
index cb3b85177c65e2345ceb8003e1bda8610e7eacbb..3af66b7e34597ed04a4519be7ee1f432c1cbdfa7 100755 (executable)
@@ -111,7 +111,7 @@ get_status_led() {
        wzr-hp-g300nh)
                status_led="buffalo:green:router"
                ;;
-       wndr3700 | wndr3700v2 | wndr3800)
+       wndr3700)
                status_led="wndr3700:green:power"
                ;;
        wnr2000)
index 0a724221cf8ecd59130c03b7d19148d3db741cd6..a0779effd8d76c364be9ec1b86dc65b099bc7fe8 100755 (executable)
@@ -123,9 +123,7 @@ wrt160nl)
        set_led_wlan "wlan" "WLAN" "wrt160nl:blue:wlan" "phy0tpt"
        ;;
 
-wndr3700 | \
-wndr3700v2 | \
-wndr3800)
+wndr3700)
        set_led_default "wan" "WAN LED (green)" "wndr3700:green:wan" "0"
        set_led_usbdev "usb" "USB" "wndr3700:green:usb" "1-1"
        ;;
index 02286e9aabe10ca08f43616cd1192f78c31c1bc0..22e951d1432b1bb74bc3f568eeb41a93a24c9bb5 100755 (executable)
@@ -6,6 +6,48 @@
 AR71XX_BOARD_NAME=
 AR71XX_MODEL=
 
+ar71xx_get_mem_total() {
+       $(awk '/MemTotal:/ {print($2)}' /proc/meminfo)
+}
+
+ar71xx_get_mtd_part_magic() {
+       local part="$1"
+       local mtd
+
+       mtd=$(find_mtd_part $part)
+       [ -z "$mtd" ] && return
+
+       dd if=$mtd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+wndr3700_board_detect() {
+       local machine="$1"
+       local magic
+       local name
+
+       name="wndr3700"
+
+       magic="$(ar71xx_get_mtd_part_magic firmware)"
+       case $magic in
+       "33373030")
+               machine="NETGEAR WNDR3700"
+               ;;
+       "33373031")
+               local mt
+
+               mt=$(ar71xx_get_mem_total)
+               if [ "$mt" -lt "65536" ]; then
+                       machine="NETGEAR WNDR3700v2"
+               else
+                       machine="NETGEAR WNDR3800"
+               fi
+               ;;
+       esac
+
+       AR71XX_BOARD_NAME="$name"
+       AR71XX_MODEL="$machine"
+}
+
 ar71xx_board_detect() {
        local machine
        local name
@@ -169,14 +211,8 @@ ar71xx_board_detect() {
        *WP543)
                name="wp543"
                ;;
-       *WNDR3700)
-               name="wndr3700"
-               ;;
-       *WNDR3700v2)
-               name="wndr3700v2"
-               ;;
-       *WNDR3800)
-               name="wndr3800"
+       *"WNDR3700/WNDR3800")
+               wndr3700_board_detect "$machine"
                ;;
        *WNR2000)
                name="wnr2000"
index cc327e6a1c7b168cee137360de9c295c8f9128b8..1de90771585d80c21f70b42c8fce0231489e3f85 100755 (executable)
@@ -127,15 +127,11 @@ platform_check_image() {
                return 0
                ;;
        wndr3700)
-               [ "$magic_long" != "33373030" ] && {
-                       echo "Invalid image type."
-                       return 1
-               }
-               return 0
-               ;;
-       wndr3700v2|wndr3800)
-               [ "$magic_long" != "33373031" ] && {
-                       echo "Invalid image type."
+               local hw_magic
+
+               hw_magic="$(ar71xx_get_mtd_part_magic firmware)"
+               [ "$magic_long" != "$hw_magic" ] && {
+                       echo "Invalid image, hardware ID mismatch, hw:$hw_magic image:$magic_long."
                        return 1
                }
                return 0
index 358f1a9f381521c9f195e54bd61c55812966528a..568dac917de395c0931b55ab31dbc7c9fa75005b 100644 (file)
 #define WNDR3700_CALDATA0_OFFSET       0x1000
 #define WNDR3700_CALDATA1_OFFSET       0x5000
 
-#ifdef CONFIG_MTD_PARTITIONS
-static struct mtd_partition wndr3700_partitions[] = {
-       {
-               .name           = "uboot",
-               .offset         = 0,
-               .size           = 0x050000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "env",
-               .offset         = 0x050000,
-               .size           = 0x020000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "rootfs",
-               .offset         = 0x070000,
-               .size           = 0x720000,
-       }, {
-               .name           = "config",
-               .offset         = 0x790000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "config_bak",
-               .offset         = 0x7a0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "pot",
-               .offset         = 0x7b0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "traffic_meter",
-               .offset         = 0x7c0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "language",
-               .offset         = 0x7d0000,
-               .size           = 0x020000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "caldata",
-               .offset         = 0x7f0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }
-};
-
-static struct mtd_partition wndr3700v2_partitions[] = {
-       {
-               .name           = "uboot",
-               .offset         = 0,
-               .size           = 0x050000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "env",
-               .offset         = 0x050000,
-               .size           = 0x020000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "rootfs",
-               .offset         = 0x070000,
-               .size           = 0xe40000,
-       }, {
-               .name           = "config",
-               .offset         = 0xeb0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "config_bak",
-               .offset         = 0xec0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "pot",
-               .offset         = 0xed0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "traffic_meter",
-               .offset         = 0xee0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "language",
-               .offset         = 0xef0000,
-               .size           = 0x100000,
-               .mask_flags     = MTD_WRITEABLE,
-       }, {
-               .name           = "caldata",
-               .offset         = 0xff0000,
-               .size           = 0x010000,
-               .mask_flags     = MTD_WRITEABLE,
-       }
-};
-#define wndr3700_num_partitions                ARRAY_SIZE(wndr3700_partitions)
-#define wndr3700v2_num_partitions      ARRAY_SIZE(wndr3700v2_partitions)
-#else
-#define wndr3700_partitions            NULL
-#define wndr3700_num_partitions                0
-#define wndr3700v2_partitions          NULL
-#define wndr3700v2_num_partitions      0
-#endif /* CONFIG_MTD_PARTITIONS */
-
-static struct flash_platform_data wndr3700_flash_data;
-
 static struct gpio_led wndr3700_leds_gpio[] __initdata = {
        {
                .name           = "wndr3700:green:power",
@@ -218,7 +111,7 @@ static struct platform_device wndr3700_rtl8366s_device = {
        }
 };
 
-static void __init wndr3700_common_setup(void)
+static void __init wndr3700_setup(void)
 {
        u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
 
@@ -242,7 +135,7 @@ static void __init wndr3700_common_setup(void)
 
        ar71xx_add_device_usb();
 
-       ar71xx_add_device_m25p80(&wndr3700_flash_data);
+       ar71xx_add_device_m25p80(NULL);
 
        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
                                        wndr3700_leds_gpio);
@@ -269,24 +162,5 @@ static void __init wndr3700_common_setup(void)
                      art + WNDR3700_WMAC1_MAC_OFFSET);
 }
 
-static void __init wndr3700_setup(void)
-{
-       wndr3700_flash_data.parts = wndr3700_partitions,
-       wndr3700_flash_data.nr_parts = wndr3700_num_partitions,
-       wndr3700_common_setup();
-}
-
-MIPS_MACHINE(AR71XX_MACH_WNDR3700, "WNDR3700", "NETGEAR WNDR3700",
+MIPS_MACHINE(AR71XX_MACH_WNDR3700, "WNDR3700", "NETGEAR WNDR3700/WNDR3800",
             wndr3700_setup);
-
-static void __init wndr3700v2_setup(void)
-{
-       wndr3700_flash_data.parts = wndr3700v2_partitions,
-       wndr3700_flash_data.nr_parts = wndr3700v2_num_partitions,
-       wndr3700_common_setup();
-}
-
-MIPS_MACHINE(AR71XX_MACH_WNDR3700V2, "WNDR3700v2", "NETGEAR WNDR3700v2",
-            wndr3700v2_setup);
-MIPS_MACHINE(AR71XX_MACH_WNDR3800, "WNDR3800", "NETGEAR WNDR3800",
-            wndr3700v2_setup);
index 6b2c160c96ab2de7a076ea807ad65bfb1f2ba1b7..d755a7ae5fe003f0d3680d9d31c571d1515f4397 100644 (file)
@@ -69,9 +69,7 @@ enum ar71xx_mach_type {
        AR71XX_MACH_WHR_G301N,  /* Buffalo WHR-G301N */
        AR71XX_MACH_WHR_HP_G300N, /* Buffalo WHR-HP-G300N */
        AR71XX_MACH_WHR_HP_GN,  /* Buffalo WHR-HP-GN */
-       AR71XX_MACH_WNDR3700,   /* NETGEAR WNDR3700 */
-       AR71XX_MACH_WNDR3700V2, /* NETGEAR WNDR3700v2 */
-       AR71XX_MACH_WNDR3800,   /* NETGEAR WNDR3800 */
+       AR71XX_MACH_WNDR3700,   /* NETGEAR WNDR3700/WNDR3800 */
        AR71XX_MACH_WNR2000,    /* NETGEAR WNR2000 */
        AR71XX_MACH_WP543,      /* Compex WP543 */
        AR71XX_MACH_WRT160NL,   /* Linksys WRT160NL */
index 438d03bba3c3bae2fd36ba30b00a79979ab297e9..78dba9762ab480c92d68af1676156c2baafb0cbd 100644 (file)
@@ -6,12 +6,12 @@
 #
 
 define Profile/WNDR3700
-       NAME:=NETGEAR WNDR3700
+       NAME:=NETGEAR WNDR3700/3800
        PACKAGES:=kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
 endef
 
 define Profile/WNDR3700/Description
-       Package set optimized for the NETGEAR WNDR3700
+       Package set optimized for the NETGEAR WNDR3700/3800
 endef
 
 $(eval $(call Profile,WNDR3700))
index 32c1b24c174974ef2f849b0d22eee536c2392c1e..2394e9938099dfe817340bacb876a04ea84e5a02 100644 (file)
@@ -759,13 +759,11 @@ endef
 
 wndr3700_cmdline=board=WNDR3700 console=ttyS0,115200
 wndr3700_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1024k(kernel),6656k(rootfs),64k(art)ro,7680k@0x70000(firmware)
-wndr3700v2_cmdline=board=WNDR3700v2 console=ttyS0,115200
 wndr3700v2_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1024k(kernel),14848k(rootfs),64k(art)ro,15872k@0x70000(firmware)
-wndr3800_cmdline=board=WNDR3800 console=ttyS0,115200
 define Image/Build/Profile/WNDR3700
        $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3700,$(wndr3700_cmdline),$(wndr3700_mtdlayout),3700,WNDR3700,"" NA,)
-       $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3700v2,$(wndr3700v2_cmdline),$(wndr3700v2_mtdlayout),3701,WNDR3700v2,"",-H 29763654+16+64)
-       $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3800,$(wndr3800_cmdline),$(wndr3700v2_mtdlayout),3701,WNDR3800,"",-H 29763654+16+128)
+       $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3700v2,$(wndr3700_cmdline),$(wndr3700v2_mtdlayout),3701,WNDR3700,"",-H 29763654+16+64)
+       $(call Image/Build/Template/$(fs_64k)/$(1),Netgear,wndr3800,$(wndr3700_cmdline),$(wndr3700v2_mtdlayout),3701,WNDR3700,"",-H 29763654+16+128)
 endef
 
 wr400n_cmdline=board=WRT400N console=ttyS0,115200