ar71xx: add Netgear WNR2000v5 support
authorJo-Philipp Wich <jo@mein.io>
Thu, 19 Apr 2018 06:39:05 +0000 (08:39 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 14 Aug 2019 06:09:27 +0000 (08:09 +0200)
Specifications :
- Chispet : Qualcomm Atheros QCA953x
- 32 MB of RAM
- 4 MB of FLASH
- 1x 10/100Mbps Ethernet
- 1x switch with 4x 10/100Mbps port
- 2.4GHz wifi
- 2 Antennas on PCB
- UART pads on JP2 header, default comm parameters : 115200 baud 8N1

Flash instructions:

The dni image can be flashed over tftp using uboot firmware recovery
mode via UART or Ethernet.
Via UART, interupt the boot sequence by pressing any key, then use
the 'fw_recovery' command to start the tftp server.
Via ethernet, turn off the router, then power it on while pressing
the reset button. When the status led starts blinking the tftp server
has started. Maintain the reset button pressed until the flash has
started.
The recovery tftp server listens on 192.168.1.1, port 69.

Alternatively you can boot the initramfs without flashing the device
via the UART interface.
Start a tftp server listening on 192.168.1.10.
Use the 'tftpboot <img name>' command to load the initramfs uImage.
Then use the 'bootm' command to start it.

Signed-off-by: Raphael Catolino <raphael.catolino@gmail.com>
[squashed name matching fixes, separated kmod-gpio-nxp-74hc164 changes,
 move image build definition after the wndr* family, disable mach code
 for nand and mikrotik subtargets]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/board.d/02_network
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/config-4.14
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/Makefile
target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v5.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/image/generic.mk
target/linux/ar71xx/tiny/config-default

index 8e49cb9fe253081c944499b207c6d9494fae7381..867847b97bf49e1ea3078ac58658ff1275cfd63c 100755 (executable)
@@ -1055,6 +1055,12 @@ wnr2000-v4)
        ucidef_set_led_switch "lan4" "LAN4" "netgear:amber:lan4" "switch0" "0x10"
        ucidef_set_led_usbport "usb" "USB" "netgear:amber:status" "usb1-port1"
        ;;
+wnr2000-v5)
+       ucidef_set_led_default "power" "System Power" "netgear:green:status" "1"
+       ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" "eth0" "rx tx"
+       ucidef_set_led_netdev "wan-green" "WAN (green)" "netgear:green:wan" "eth0" "link"
+       ucidef_set_led_netdev "wlan" "WLAN" "netgear:green:wlan" "wlan0"
+       ;;
 wnr2200)
        ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" "eth0"
        ucidef_set_led_default "wan-green" "WAN (green)" "netgear:green:wan" "0"
index 1fcfa43c4b5aaba2cc5c41652797f711c45b5248..1d889a13896eb05856bb1996ff531c2ab9f122b2 100755 (executable)
@@ -365,6 +365,7 @@ ar71xx_setup_interfaces()
        tl-wr941nd-v6|\
        wnr1000-v2|\
        wnr2000-v4|\
+       wnr2000-v5|\
        wnr2200|\
        wnr612-v2|\
        wpn824n)
index 894835b14d79e8f47a6ddf013980d11278d07e78..94484119daf76736232fd266f90d7c07107352c7 100755 (executable)
@@ -1503,6 +1503,9 @@ ar71xx_board_detect() {
        *"WNR2000 V4")
                name="wnr2000-v4"
                ;;
+       *"WNR2000 V5")
+               name="wnr2000-v5"
+               ;;
        *"WNR2200")
                name="wnr2200"
                ;;
index 9a524fae4316caa10431bd6b3b4dadbe8660f14c..48f654e393e8bac4d7a03e215ed518dea8d351ba 100644 (file)
@@ -259,6 +259,7 @@ CONFIG_ATH79=y
 # CONFIG_ATH79_MACH_WNR2000 is not set
 # CONFIG_ATH79_MACH_WNR2000_V3 is not set
 # CONFIG_ATH79_MACH_WNR2000_V4 is not set
+# CONFIG_ATH79_MACH_WNR2000_V5 is not set
 # CONFIG_ATH79_MACH_WNR2200 is not set
 # CONFIG_ATH79_MACH_WP543 is not set
 # CONFIG_ATH79_MACH_WPE72 is not set
index 6fd78c46a09c40d82822c62b521486a22c5f27a6..80a26b12fb82cd8de13097bed2772ce066b3fbf3 100644 (file)
@@ -1297,6 +1297,14 @@ config ATH79_MACH_WNR2000_V4
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_WNR2000_V5
+       bool "NETGEAR WNR2000 V5 board support"
+       select SOC_QCA953X
+       select ATH79_DEV_ETH
+       select ATH79_DEV_GPIO_BUTTONS
+       select ATH79_DEV_LEDS_GPIO
+       select ATH79_DEV_M25P80
+
 config ATH79_MACH_OM2P
        bool "OpenMesh OM2P board support"
        select SOC_AR724X
index 0265b3d818135b3917f221173c59a85cc8d6cdb7..7da354f98d0864f1818dfea7b921f7ad6ee5389f 100644 (file)
@@ -268,6 +268,7 @@ obj-$(CONFIG_ATH79_MACH_WNDR4300)           += mach-wndr4300.o
 obj-$(CONFIG_ATH79_MACH_WNR2000)               += mach-wnr2000.o
 obj-$(CONFIG_ATH79_MACH_WNR2000_V3)            += mach-wnr2000-v3.o
 obj-$(CONFIG_ATH79_MACH_WNR2000_V4)            += mach-wnr2000-v4.o
+obj-$(CONFIG_ATH79_MACH_WNR2000_V5)            += mach-wnr2000-v5.o
 obj-$(CONFIG_ATH79_MACH_WNR2200)               += mach-wnr2200.o
 obj-$(CONFIG_ATH79_MACH_WP543)                 += mach-wp543.o
 obj-$(CONFIG_ATH79_MACH_WPE72)                 += mach-wpe72.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v5.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v5.c
new file mode 100644 (file)
index 0000000..c3014a4
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ *  NETGEAR WNR2000v5 board support
+ *
+ * Copyright (c) 2017 Raphael Catolino <raphael.catolino@gmail.com>
+ * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/spi/74x164.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_gpio.h>
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ath79_spi_platform.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define WNR2000V5_GPIO_LED_STATUS_GREEN 21
+#define WNR2000V5_GPIO_LED_STATUS_AMBER 20
+#define WNR2000V5_GPIO_LED_DATA_GREEN   25
+#define WNR2000V5_GPIO_LED_DATA_AMBER   19
+#define WNR2000V5_GPIO_LED_WLAN         18
+
+#define WNR2000V5_GPIO_BTN_RFKILL 0
+#define WNR2000V5_GPIO_BTN_RESET  1
+#define WNR2000V5_GPIO_BTN_WPS    2
+
+#define WNR2000V5_KEYS_POLL_INTERVAL   20      /* msecs */
+#define WNR2000V5_KEYS_DEBOUNCE_INTERVAL       (4 * WNR2000V5_KEYS_POLL_INTERVAL)
+
+#define WNR2000V5_SPI_GPIO_RESET 14
+#define WNR2000V5_SPI_GPIO_MOSI 15
+#define WNR2000V5_SPI_GPIO_CLK 16
+/* The QCA953X platform has QCA953X_GPIO_COUNT GPIOs, the 74x164 muxer adds 8
+ * additional GPIOs on this board. */
+#define WNR2000V5_74X164_GPIO_BASE QCA953X_GPIO_COUNT
+
+
+static struct gpio_led wnr2000v5_leds_gpio[] __initdata = {
+       {
+               .name           = "netgear:green:status",
+               .gpio           = WNR2000V5_GPIO_LED_STATUS_GREEN,
+               .active_low     = 1,
+               .default_trigger = "default-on",
+       },
+       {
+               .name           = "netgear:amber:status",
+               .gpio           = WNR2000V5_GPIO_LED_STATUS_AMBER,
+               .active_low     = 1,
+       },
+       {
+               .name           = "netgear:green:wlan",
+               .gpio           = WNR2000V5_GPIO_LED_WLAN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "netgear:green:wan",
+               .gpio           = WNR2000V5_GPIO_LED_DATA_GREEN,
+               .active_low     = 1,
+       },
+       {
+               .name           = "netgear:amber:wan",
+               .gpio           = WNR2000V5_GPIO_LED_DATA_AMBER,
+               .active_low     = 1,
+       },
+};
+
+static struct gpio_keys_button wnr2000v5_gpio_keys[] __initdata = {
+       {
+               .desc           = "WPS button",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = WNR2000V5_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = WNR2000V5_GPIO_BTN_WPS,
+               .active_low     = 1,
+       },
+       {
+               .desc           = "rfkill",
+               .type           = EV_KEY,
+               .code           = KEY_RFKILL,
+               .debounce_interval = WNR2000V5_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = WNR2000V5_GPIO_BTN_RFKILL,
+               .active_low     = 1,
+       },
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = WNR2000V5_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = WNR2000V5_GPIO_BTN_RESET,
+               .active_low     = 1,
+       },
+};
+
+static void __init wnr2000v5_gpio_led_setup(void)
+{
+       ath79_gpio_direction_select(WNR2000V5_GPIO_LED_STATUS_GREEN, true);
+       ath79_gpio_direction_select(WNR2000V5_GPIO_LED_STATUS_AMBER, true);
+       ath79_gpio_direction_select(WNR2000V5_GPIO_LED_WLAN, true);
+       ath79_gpio_direction_select(WNR2000V5_GPIO_LED_DATA_GREEN, true);
+       ath79_gpio_direction_select(WNR2000V5_GPIO_LED_DATA_AMBER, true);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v5_leds_gpio),
+                       wnr2000v5_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, WNR2000V5_KEYS_POLL_INTERVAL,
+                       ARRAY_SIZE(wnr2000v5_gpio_keys),
+                       wnr2000v5_gpio_keys);
+}
+
+static u8 wnr2000v5_ssr_initdata[] __initdata = {
+       BIT(7) | BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0),
+};
+
+static struct spi_gpio_platform_data wnr2000v5_spi_gpio_data = {
+       .sck            = WNR2000V5_SPI_GPIO_CLK,
+       .mosi           = WNR2000V5_SPI_GPIO_MOSI,
+       .miso           = SPI_GPIO_NO_MISO,
+       .num_chipselect = 1,
+};
+
+static struct platform_device wnr2000v5_spi_gpio_device = {
+       .name           = "spi_gpio",
+       .id             = 1,
+       .dev = {
+               .platform_data = &wnr2000v5_spi_gpio_data,
+       },
+};
+
+static struct gen_74x164_chip_platform_data wnr2000v5_ssr_data = {
+       .base = WNR2000V5_74X164_GPIO_BASE,
+       .num_registers = ARRAY_SIZE(wnr2000v5_ssr_initdata),
+       .init_data = wnr2000v5_ssr_initdata,
+};
+
+static struct spi_board_info wnr2000v5_spi_gpio_info[] = {
+       {
+               .bus_num        = 1,
+               .chip_select    = 0,
+               .max_speed_hz   = 400000,
+               .modalias       = "74x164",
+               .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT,
+               .platform_data = &wnr2000v5_ssr_data,
+       },
+};
+
+static void __init WNR2000V5_setup(void)
+{
+       u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+       /* SPI NOR initialization */
+       ath79_register_m25p80(NULL);
+
+       /* GPIOS and LEDS */
+       spi_register_board_info(wnr2000v5_spi_gpio_info, ARRAY_SIZE(wnr2000v5_spi_gpio_info));
+       platform_device_register(&wnr2000v5_spi_gpio_device);
+       wnr2000v5_gpio_led_setup();
+       ath79_register_wmac(art + 0x1000, NULL);
+       ath79_register_mdio(0, 0x0);
+
+       /* Ethernet and switch */
+       ath79_init_mac(ath79_eth0_data.mac_addr, art + 0, 0);
+       ath79_init_mac(ath79_eth1_data.mac_addr, art + 6, 0);
+
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+       ath79_eth0_data.speed = SPEED_100;
+       ath79_eth0_data.duplex = DUPLEX_FULL;
+       ath79_eth0_data.phy_mask = BIT(4);
+       ath79_register_eth(0);
+
+       ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+       ath79_eth1_data.speed = SPEED_1000;
+       ath79_eth1_data.duplex = DUPLEX_FULL;
+       ath79_switch_data.phy_poll_mask |= BIT(4);
+       ath79_switch_data.phy4_mii_en = 1;
+       ath79_register_eth(1);
+}
+
+MIPS_MACHINE(ATH79_MACH_WNR2000_V5, "WNR2000V5", "Netgear WNR2000 V5", WNR2000V5_setup);
index 9722744a37d04dec6fe233d7f7faceb3947fa893..7488c3fabba340b49b8e81a730f82117e36152b7 100644 (file)
@@ -358,6 +358,7 @@ enum ath79_mach_type {
        ATH79_MACH_WNR2000,                     /* NETGEAR WNR2000 */
        ATH79_MACH_WNR2000_V3,                  /* NETGEAR WNR2000 v3 */
        ATH79_MACH_WNR2000_V4,                  /* NETGEAR WNR2000 v4 */
+       ATH79_MACH_WNR2000_V5,                  /* NETGEAR WNR2000 v5 */
        ATH79_MACH_WNR2200,                     /* NETGEAR WNR2200 */
        ATH79_MACH_WNR612_V2,                   /* NETGEAR WNR612 v2 */
        ATH79_MACH_WP543,                       /* Compex WP543 */
index 30a8b3448342c917f7c60bf6b9a50dca3d2c6ff1..9f42ebf65ccc13c1182c73c04970d9ef0273c4b8 100644 (file)
@@ -631,6 +631,20 @@ define Device/wndr3700
 endef
 TARGET_DEVICES += wndr3700
 
+define Build/netgear-pad
+  dd if=/dev/zero bs=128 count=1 >> $@
+  dd if=$@ of=$@.new bs=$(1) conv=sync
+  head -c -128 $@.new > $@
+endef
+
+define Build/fake-uimage-footer
+  echo -n -e "\x27\x05\x19\x56" >> $@
+  echo -n -e "\x26\x02\x6c\xff" >> $@
+  dd if=/dev/zero bs=20 count=1 >> $@
+  echo -n -e "\x05\x05\x07\x00" >> $@
+  dd if=/dev/zero bs=32 count=1 >> $@
+endef
+
 define Device/wndr3700v2
   $(Device/wndr3700)
   DEVICE_TITLE := NETGEAR WNDR3700 v2
@@ -672,6 +686,24 @@ define Device/wndrmacv2
 endef
 TARGET_DEVICES += wndrmacv2
 
+define Device/wnr2000v5
+  DEVICE_TITLE := NETGEAR WNR2000V5
+  DEVICE_PACKAGES := kmod-block2mtd kmod-gpio-nxp-74hc164
+  BOARDNAME = WNR2000V5
+  NETGEAR_KERNEL_MAGIC = 0x32303030
+  NETGEAR_HW_ID = 29764648+4+0+32+2x2+0
+  NETGEAR_BOARD_ID = WNR2000v5
+  IMAGE_SIZE := 3904k
+  MTDPARTS = spi0.0:128k(u-boot)ro,3904k(firmware),64k(art)ro
+  IMAGES := kernel.uImage dni.img
+  KERNEL := kernel-bin | patch-cmdline | lzma -d20
+  KERNEL_INITRAMFS := $$(KERNEL) | netgear-pad $$(BLOCKSIZE) | uImage lzma | fake-uimage-footer
+  KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX).uImage
+  IMAGE/kernel.uImage = append-kernel | netgear-pad $$$$(BLOCKSIZE) | uImage lzma | fake-uimage-footer
+  IMAGE/dni.img = $$(IMAGE/kernel.uImage) | append-rootfs | pad-rootfs | netgear-dni | check-size $$$$(IMAGE_SIZE)
+endef
+TARGET_DEVICES += wnr2000v5
+
 define Device/cap324
   DEVICE_TITLE := PowerCloud Systems CAP324
   BOARDNAME := CAP324
index 1148d8c451dee890c785ffb78ff0bb9de2454326..48199457a394e7a1db951ecd7bc257d9994e9ad3 100644 (file)
@@ -52,6 +52,7 @@ CONFIG_ATH79_MACH_WLAE_AG300N=y
 CONFIG_ATH79_MACH_WNR2000=y
 CONFIG_ATH79_MACH_WNR2000_V3=y
 CONFIG_ATH79_MACH_WNR2000_V4=y
+CONFIG_ATH79_MACH_WNR2000_V5=y
 CONFIG_ATH79_MACH_WP543=y
 CONFIG_ATH79_MACH_WPE72=y
 CONFIG_ATH79_MACH_ZBT_WE1526=y