This patch adds OpenWRT support for the Netgear WNR2200 (N300)
wireless router with USB.

Technical details of this router can be found at
http://www.netgear.com/home/products/wirelessrouters/work-and-play/WNR2200.aspx
and http://wikidevi.com/wiki/Netgear_WNR2200

The patch includes a new ar71xx/files/arch/mips/ath79/mach-wnr2200.c
file and corresponding updates to the base-files/etc/diag.sh,
base-files/etc/uci-defaults/02_network,
ar71xx/base-files/lib/ar71xx.sh, ar71xx/config-3.10,
ar71xx/generic/profiles/netgear.mk and ar71xx/image/Makefile files


Signed-off-by: Aidan Kissane <aidankiss...@googlemail.com>


diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
new file mode 100644
index 0000000..b407af3
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c
@@ -0,0 +1,182 @@
+/*
+ *  NETGEAR WNR2200 board support
+ *
+ *  Copyright (C) 2013 Aidan Kissane <aidankiss...@googlemail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/mach-ath79/ath79.h>
+
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-usb.h"
+##include "machtypes.h"
+
+//#define WNR2200_GPIO_LED_LAN1_AMBER     ??
+#define WNR2200_GPIO_LED_LAN2_AMBER     0
+#define WNR2200_GPIO_LED_LAN4_AMBER     1
+#define WNR2200_GPIO_LED_WPS            5
+#define WNR2200_GPIO_LED_WAN_GREEN      7
+#define WNR2200_GPIO_LED_USB            8
+#define WNR2200_GPIO_LED_LAN3_AMBER     11
+#define WNR2200_GPIO_LED_WAN_AMBER      12
+#define WNR2200_GPIO_LED_LAN1_GREEN     13
+#define WNR2200_GPIO_LED_LAN2_GREEN     14
+#define WNR2200_GPIO_LED_LAN3_GREEN     15
+#define WNR2200_GPIO_LED_LAN4_GREEN     16
+#define WNR2200_GPIO_LED_PWR_AMBER      21
+#define WNR2200_GPIO_LED_PWR_GREEN      22
+
+#define WNR220_GPIO_USB_POWER           24
+
+//#define WNR2200_GPIO_BTN_RESET         ??
+//#define WNR2200_GPIO_BTN_WIRELESS      ??
+//#define WNR2200_GPIO_BTN_WPS           ??
+
+#define WNR2200_KEYS_POLL_INTERVAL     20      /* msecs */
+#define WNR2200_KEYS_DEBOUNCE_INTERVAL (3 * WNR2200_KEYS_POLL_INTERVAL)
+
+#define WNR2200_MAC0_OFFSET            0
+#define WNR2200_MAC1_OFFSET            6
+#define WNR2200_PCIE_CALDATA_OFFSET    0x1000
+
+static struct gpio_led wnr2200_leds_gpio[] __initdata = {
+        {
+                .name           = "wnr2200:amber:lan2",
+                .gpio           = WNR2200_GPIO_LED_LAN2_AMBER,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:amber:lan4",
+                .gpio           = WNR2200_GPIO_LED_LAN4_AMBER,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:green:wps",
+                .gpio           = WNR2200_GPIO_LED_WPS,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:green:wan",
+                .gpio           = WNR2200_GPIO_LED_WAN_GREEN,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:green:usb",
+                .gpio           = WNR2200_GPIO_LED_USB,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:amber:lan3",
+                .gpio           = WNR2200_GPIO_LED_LAN3_AMBER,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:amber:wan",
+                .gpio           = WNR2200_GPIO_LED_WAN_AMBER,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:amber:wan",
+                .gpio           = WNR2200_GPIO_LED_WAN_AMBER,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:green:lan1",
+                .gpio           = WNR2200_GPIO_LED_LAN1_GREEN,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:green:lan2",
+                .gpio           = WNR2200_GPIO_LED_LAN2_GREEN,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:green:lan3",
+                .gpio           = WNR2200_GPIO_LED_LAN3_GREEN,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:green:lan4",
+                .gpio           = WNR2200_GPIO_LED_LAN4_GREEN,
+                .active_low     = 1,
+        }, {
+        {
+                .name           = "wnr2200:anber:power",
+                .gpio           = WNR2200_GPIO_LED_PWR_AMBER,
+                .active_low     = 1,
+        }, {
+                .name           = "wnr2200:green:power",
+                .gpio           = WNR2200_GPIO_LED_PWR_GREEN,
+                .active_low     = 1,
+        }
+};
+
+/*
+static struct gpio_keys_button wnr2200_gpio_keys[] __initdata = {
+        {
+                .desc           = "Reset button",
+                .type           = EV_KEY,
+                .code           = KEY_RESTART,
+                .debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
+                .gpio           = WNR2200_GPIO_BTN_RESET,
+        },
+        {
+                .desc           = "WPS button",
+                .type           = EV_KEY,
+                .code           = KEY_WPS_BUTTON,
+                .debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
+                .gpio           = WNR2200_GPIO_BTN_WPS,
+        },
+        {
+                .desc           = "Wireless button",
+                .type           = EV_KEY,
+                .code           = BTN_0,
+                .debounce_interval = WNR2200_KEYS_DEBOUNCE_INTERVAL,
+                .gpio           = WNR2200_GPIO_BTN_WIRELESS,
+        },
+};
+*/
+
+static void __init wnr2200_setup(void)
+{
+        u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+        ath79_register_mdio(0, 0x0);
+
+        ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2200_MAC0_OFFSET, 0);
+        ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+        ath79_eth0_data.speed = SPEED_100;
+        ath79_eth0_data.duplex = DUPLEX_FULL;
+
+        ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2200_MAC1_OFFSET, 0);
+        ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
+        ath79_eth1_data.phy_mask = 0x10;
+
+        ath79_register_eth(0);
+        ath79_register_eth(1);
+
+       ath79_register_m25p80(NULL);
+        ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET, NULL);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
+                                wnr2200_leds_gpio);
+
+/*     ath79_register_gpio_keys_polled(-1, WNR2200_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(wnr2200_gpio_keys),
+                                       wnr2200_gpio_keys);
+*/
+
+        /* enable power for the USB port */
+        gpio_request_one(WNR220_GPIO_USB_POWER,
+                         GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+                         "USB power");
+
+        ath79_register_usb();
+
+}
+
+MIPS_MACHINE(ATH79_MACH_WNR2200, "WNR2200", "NETGEAR WNR2200", wnr2200_setup);
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh
b/target/linux/ar71xx/base-files/etc/diag.sh
index 7b790e2..49803ca 100755
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -175,7 +175,10 @@ get_status_led() {
        wnr2000)
                status_led="wnr2000:green:power"
                ;;
-       wnr612-v2)
+       wnr2200)
+                status_led="wnr2200:amber:power"
+                ;;
+        wnr612-v2)
                status_led="wnr612v2:green:power"
                ;;
        wp543)
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index 176c485..cf56e46 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -169,6 +169,7 @@ tl-wr941nd)
 tl-mr3420-v2 |\
 tl-wr841n-v8 |\
 wnr2000-v3 |\
+wnr2200 |\
 wnr612-v2)
        ucidef_set_interfaces_lan_wan "eth1" "eth0"
        ucidef_add_switch "switch0" "1" "1"
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index e7fbfbe..352582f 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -516,7 +516,10 @@ ar71xx_board_detect() {
        *WNR2000)
                name="wnr2000"
                ;;
-       *"WNR612 V2")
+       *WNR2200)
+                name="wnr2200"
+                ;;
+        *"WNR612 V2")
                name="wnr612-v2"
                ;;
        *WRT160NL)
diff --git a/target/linux/ar71xx/config-3.10 b/target/linux/ar71xx/config-3.10
index 6c75f14..ae1a481 100644
--- a/target/linux/ar71xx/config-3.10
+++ b/target/linux/ar71xx/config-3.10
@@ -90,6 +90,7 @@ CONFIG_ATH79_MACH_WNDR3700=y
 CONFIG_ATH79_MACH_WNDR4300=y
 CONFIG_ATH79_MACH_WNR2000=y
 CONFIG_ATH79_MACH_WNR2000_V3=y
+CONFIG_ATH79_MACH_WNR2200=y
 CONFIG_ATH79_MACH_WP543=y
 CONFIG_ATH79_MACH_WPE72=y
 CONFIG_ATH79_MACH_WRT160NL=y
diff --git a/target/linux/ar71xx/generic/profiles/netgear.mk
b/target/linux/ar71xx/generic/profiles/netgear.mk
index 99425ec..7e32977 100644
--- a/target/linux/ar71xx/generic/profiles/netgear.mk
+++ b/target/linux/ar71xx/generic/profiles/netgear.mk
@@ -60,3 +60,14 @@ define Profile/WNR612V2/Description
 endef

 $(eval $(call Profile,WNR612V2))
+
+
+define Profile/WNR2200
+        NAME:=NETGEAR WNR2200
+endef
+
+define Profile/WNR2200/Description
+        Package set optimized for the NETGEAR WNR2200
+endef
+
+$(eval $(call Profile,WNR2200))
diff --git a/target/linux/ar71xx/image/Makefile
b/target/linux/ar71xx/image/Makefile
index f5650c9..5d5d5d1 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -182,6 +182,7 @@
ubdev_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware)
 
whrhpg300n_mtdlayout=mtdparts=spi0.0:248k(u-boot)ro,8k(u-boot-env)ro,3712k(firmware),64k(art)ro
 
wndap360_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1728k(kernel),6016k(rootfs),64k(nvram)ro,64k(art)ro,7744k@0x50000(firmware)
 
wnr2000v3_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1024k(kernel),2688k(rootfs),64k(art)ro,3712k@0x50000(firmware)
+wnr2200_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1024k(kernel),6784k(rootfs),64k(art)ro,7808k@0x50000(firmware)
 
wndr3700_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1152k(kernel),6528k(rootfs),64k(art)ro,7680k@0x70000(firmware)
 
wndr3700v2_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1152k(kernel),14720k(rootfs),64k(art)ro,15872k@0x70000(firmware)
 
wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata),512k(pot),2048k(language),512k(config),3072k(traffic_meter),1152k(kernel),24448k
@@ -935,6 +936,7 @@ $(eval $(call
SingleProfile,MyLoader,$(fs_64k),WPE72_16M,wpe72,,ttyS0,115200,0x1
 $(eval $(call 
SingleProfile,AthGzip,$(fs_64k),WNDAP360,wndap360,WNDAP360,ttyS0,9600,$$(wndap360_mtdlayout),1769472,6160384,KRuImage))
 $(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNR2000V3,wnr2000v3,WNR2000V3,ttyS0,115200,$$(wnr2000v3_mtdlayout),2003,WNR2000V3,""
NA,))
 $(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNR612V2,wnr612v2,WNR612V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),2061,WNR612V2,"",))
+$(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNR2200,wnr2200,WNR2200,ttyS0,115200,$$(wnr2200_mtdlayout),2200,WNR2200,""
NA,))
 $(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNDR3700V1,wndr3700,WNDR3700,ttyS0,115200,$$(wndr3700_mtdlayout),3700,WNDR3700,""
NA,))
 $(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNDR3700V2,wndr3700v2,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),3701,WNDR3700v2,"",-H
29763654+16+64))
 $(eval $(call 
SingleProfile,Netgear,$(fs_64k),WNDR3800,wndr3800,WNDR3700,ttyS0,115200,$$(wndr3700v2_mtdlayout),3701,WNDR3800,"",-H
29763654+16+128))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to