ramips: rt305x: add support for the Netcore NW718 board
authorGabor Juhos <juhosg@openwrt.org>
Thu, 28 Jul 2011 10:56:32 +0000 (10:56 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Thu, 28 Jul 2011 10:56:32 +0000 (10:56 +0000)
SVN-Revision: 27813

target/linux/ramips/base-files/etc/diag.sh
target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
target/linux/ramips/base-files/lib/ramips.sh
target/linux/ramips/base-files/lib/upgrade/platform.sh
target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
target/linux/ramips/files/arch/mips/ralink/rt305x/mach-nw718.c [new file with mode: 0644]
target/linux/ramips/image/Makefile
target/linux/ramips/rt305x/config-2.6.39

index c41105397a131a25d2fd4ec4ede52dc7a4f68c58..1a5747f2f6361cbc6db4b6b3c27c59592bf48865 100755 (executable)
@@ -42,6 +42,9 @@ get_status_led() {
        mofi3500-3gn)
                status_led="mofi3500-3gn:green:status"
                ;;
+       nw718)
+               status_led="nw718:amber:cpu"
+               ;;
        pwh2004)
                status_led="pwh2004:green:power"
                ;;
index ee20b54ef2e7b5d3295d6e58c2185fd62fe442b2..405e7c42ef66097bb99f310c7f0affd3e920a1b4 100644 (file)
@@ -46,6 +46,7 @@ case "$FIRMWARE" in
        hw550-3g | \
        mofi3500-3gn | \
        pwh2004 | \
+       nw718 | \
        rt-n15 | \
        v22rw-2x2 | \
        wcr150gn | \
index d081b8be67ec6968a169a3efc3155d3f6120c4f3..33ce13cb5551b42ce0b395d008675549c02cab4b 100755 (executable)
@@ -31,6 +31,9 @@ ramips_board_name() {
        *"MoFi Network MOFI3500-3GN")
                name="mofi3500-3gn"
                ;;
+       *"NW718")
+               name="nw718"
+               ;;
        *"PWH2004")
                name="pwh2004"
                ;;
index e7511e849b38ae3e5209a9c6ed6e46204cf368dc..dda4a67577e8de9d12bbaa1d404850b1dccfada5 100755 (executable)
@@ -14,7 +14,7 @@ platform_check_image() {
        [ "$ARGC" -gt 1 ] && return 1
 
        case "$board" in
-       dir-300-b1 | dir-600-b1 | dir-600-b2 | fonera20n | rt-g32-b1 | v22rw-2x2 | whr-g300n | hw550-3g | mofi3500-3gn)
+       dir-300-b1 | dir-600-b1 | dir-600-b2 | fonera20n | nw718 | rt-g32-b1 | v22rw-2x2 | whr-g300n | hw550-3g | mofi3500-3gn)
                [ "$magic" != "2705" ] && {
                        echo "Invalid image type."
                        return 1
index 3f410716d561db0efd2fc4213737d568b10ccd3e..8571f7a28acf2a5a5c942ca4235bd1de37f881ae 100644 (file)
@@ -22,6 +22,7 @@ enum ramips_mach_type {
        RAMIPS_MACH_DIR_600_B1,         /* D-Link DIR-600 B1 */
        RAMIPS_MACH_DIR_600_B2,         /* D-Link DIR-600 B2 */
        RAMIPS_MACH_RT_G32_B1,          /* Asus RT-G32 B1 */
+       RAMIPS_MACH_NW718,              /* Netcore NW718 */
 
        /* RT3052 based machines */
        RAMIPS_MACH_F5D8235_V2,         /* Belkin F5D8235 v2 */
index a12693ce11f557c3100d611657503c011ba6aee7..c24670e033a5797d19911a4fe0ac152277d0939d 100644 (file)
@@ -43,6 +43,12 @@ config RT305X_MACH_MOFI3500_3GN
        select RALINK_DEV_GPIO_BUTTONS
        select RALINK_DEV_GPIO_LEDS
 
+config RT305X_MACH_NW718
+       bool "Netcore NW718"
+       default y
+       select RALINK_DEV_GPIO_BUTTONS
+       select RALINK_DEV_GPIO_LEDS
+
 config RT305X_MACH_PWH2004
        bool "Prolink PWH2004 / Abocom WR5205 support (32M RAM, 8M flash)"
        default y
index 5460a148ba84bb7cdfef1d1d81cbdb5e46ea0904..2b1c59ea21cc743eb565c353902cbe6acd8973bc 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_RT305X_MACH_F5D8235_V2)    += mach-f5d8235-v2.o
 obj-$(CONFIG_RT305X_MACH_FONERA20N)    += mach-fonera20n.o
 obj-$(CONFIG_RT305X_MACH_HW550_3G)     += mach-hw550-3g.o
 obj-$(CONFIG_RT305X_MACH_MOFI3500_3GN) += mach-mofi3500-3gn.o
+obj-$(CONFIG_RT305X_MACH_NW718)                += mach-nw718.o
 obj-$(CONFIG_RT305X_MACH_PWH2004)      += mach-pwh2004.o
 obj-$(CONFIG_RT305X_MACH_RT_G32_REVB)  += mach-rt-g32-revb.o
 obj-$(CONFIG_RT305X_MACH_V22RW_2X2)    += mach-v22rw-2x2.o
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-nw718.c b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-nw718.c
new file mode 100644 (file)
index 0000000..09f6dc4
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ *  Netcore NW718 board support
+ *
+ *  Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  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/init.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+
+#include <asm/mach-ralink/machine.h>
+#include <asm/mach-ralink/dev-gpio-buttons.h>
+#include <asm/mach-ralink/dev-gpio-leds.h>
+#include <asm/mach-ralink/rt305x.h>
+#include <asm/mach-ralink/rt305x_regs.h>
+
+#include "devices.h"
+
+#define NW718_GPIO_LED_USB             8
+#define NW718_GPIO_LED_CPU             13
+#define NW718_GPIO_LED_WPS             14
+
+#define NW718_GPIO_BUTTON_WPS          0
+#define NW718_GPIO_BUTTON_RESET                10
+
+#define NW718_GPIO_SPI_CS0             3
+#define NW718_GPIO_SPI_SCK             4
+#define NW718_GPIO_SPI_MOSI            5
+#define NW718_GPIO_SPI_MISO            6
+
+#define NW718_BUTTONS_POLL_INTERVAL    20
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition nw718_partitions[] = {
+       {
+               .name   = "u-boot",
+               .offset = 0,
+               .size   = 0x030000,
+               .mask_flags = MTD_WRITEABLE,
+       }, {
+               .name   = "config",
+               .offset = 0x030000,
+               .size   = 0x020000,
+               .mask_flags = MTD_WRITEABLE,
+       }, {
+               .name   = "factory",
+               .offset = 0x050000,
+               .size   = 0x010000,
+               .mask_flags = MTD_WRITEABLE,
+       }, {
+               .name   = "kernel",
+               .offset = 0x060000,
+               .size   = 0x090000,
+       }, {
+               .name   = "rootfs",
+               .offset = 0x150000,
+               .size   = 0x2b0000,
+       }, {
+               .name   = "firmware",
+               .offset = 0x060000,
+               .size   = 0x3a0000,
+       }
+};
+#define nw718_nr_parts         ARRAY_SIZE(nw718_partitions)
+#else
+#define nw718_nr_parts         0
+#define nw718_partitions       NULL
+#endif /* CONFIG_MTD_PARTITIONS */
+
+static struct flash_platform_data nw718_flash_data = {
+       .nr_parts       = nw718_nr_parts,
+       .parts          = nw718_partitions,
+};
+
+static struct gpio_led nw718_leds_gpio[] __initdata = {
+       {
+               .name           = "nw718:amber:cpu",
+               .gpio           = NW718_GPIO_LED_CPU,
+               .active_low     = 1,
+       }, {
+               .name           = "nw718:amber:usb",
+               .gpio           = NW718_GPIO_LED_USB,
+               .active_low     = 1,
+       }, {
+               .name           = "nw718:amber:wps",
+               .gpio           = NW718_GPIO_LED_WPS,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_button nw718_gpio_buttons[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .threshold      = 3,
+               .gpio           = NW718_GPIO_BUTTON_RESET,
+               .active_low     = 1,
+       }, {
+               .desc           = "wps",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .threshold      = 3,
+               .gpio           = NW718_GPIO_BUTTON_WPS,
+               .active_low     = 1,
+       }
+};
+
+static struct spi_board_info nw718_spi_info[] = {
+       {
+               .bus_num        = 0,
+               .chip_select    = 0,
+               .max_speed_hz   = 25000000,
+               .modalias       = "m25p80",
+               .platform_data  = &nw718_flash_data,
+               .controller_data = (void *) NW718_GPIO_SPI_CS0,
+       }
+};
+
+static void __init nw718_init(void)
+{
+       rt305x_gpio_init(RT305X_GPIO_MODE_I2C |
+                        RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
+
+       rt305x_register_ethernet();
+       ramips_register_gpio_leds(-1, ARRAY_SIZE(nw718_leds_gpio),
+                                 nw718_leds_gpio);
+       ramips_register_gpio_buttons(-1, NW718_BUTTONS_POLL_INTERVAL,
+                                    ARRAY_SIZE(nw718_gpio_buttons),
+                                    nw718_gpio_buttons);
+       rt305x_register_wifi();
+       rt305x_register_wdt();
+       rt305x_register_spi(nw718_spi_info, ARRAY_SIZE(nw718_spi_info));
+}
+
+MIPS_MACHINE(RAMIPS_MACH_WHR_G300N, "NW718", "Netcore NW718", nw718_init);
index 22eaaa088284d758f2748e917d02ab8d660ebb93..69543990f88153383f82157a7e0738a182630c8f 100644 (file)
@@ -89,6 +89,24 @@ define BuildFirmware/Buffalo
        fi; fi
 endef
 
+define BuildFirmware/NW718
+       $(call PatchKernelLzma,$(2),$(3) $($(4)))
+       mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry) \
+               -n "ARA1B4NCRNW718;1" \
+               -d "$(KDIR)/vmlinux-$(2).bin.lzma" \
+               "$(KDIR)/vmlinux-$(2).uImage"
+       if [ `stat -c%s "$(KDIR)/vmlinux-$(2).uImage"` -gt $(5) ]; then \
+               echo "Warning: $(KDIR)/vmlinux-$(2).uImage is too big"; \
+       else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(6) ]; then \
+               echo "Warning: $(KDIR)/root.$(1) is too big"; \
+       else \
+               ( \
+                       dd if=$(KDIR)/vmlinux-$(2).uImage bs=$(5) conv=sync; \
+                       dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
+               ) > $(call imgname,$(1),$(2))-factory.bin; \
+       fi; fi
+endef
+
 mtdlayout_4M=mtdparts=physmap-flash.0:192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,832k(kernel),2944k(rootfs),3776k@0x50000(firmware)
 define Image/Build/Template/GENERIC_4M
        $(call BuildFirmware/Generic,$(1),$(2),board=$(3),mtdlayout_4M,851968,3014656)
@@ -109,6 +127,12 @@ define Image/Build/Template/DIR300B1
                -o $(call imgname,$(1),$(2))-factory.bin
 endef
 
+mtdlayout_nw718=mtdparts=spi0.0:192k(u-boot)ro,128k(config)ro,64k(factory)ro,832k(kernel),2880k(rootfs),3712k@0x60000(firmware)
+define Image/Build/Template/NW718
+       $(call BuildFirmware/Generic,$(1),$(2),board=$(3),mtdlayout_nw718,851968,2949120)
+       $(call BuildFirmware/NW718,$(1),$(2),board=$(3),mtdlayout_nw718,851968,2949120)
+endef
+
 define Image/Build/Profile/DIR300B1
        $(call Image/Build/Template/DIR300B1,$(1),dir-300-b1,DIR-300-B1,wrgn23_dlwbr_dir300b)
        $(call Image/Build/Template/DIR300B1,$(1),dir-600-b1,DIR-600-B1,wrgn23_dlwbr_dir600b)
@@ -130,6 +154,10 @@ define Image/Build/Profile/FONERA20N
        $(call Image/Build/Template/GENERIC_8M,$(1),fonera20n,FONERA20N)
 endef
 
+define Image/Build/Profile/NW718
+       $(call Image/Build/Template/NW718,$(1),nw718,NW718)
+endef
+
 define Image/Build/Profile/PWH2004
        $(call Image/Build/Template/GENERIC_8M,$(1),pwh2004,PWH2004)
 endef
@@ -189,6 +217,7 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/RTG32B1,$(1))
        $(call Image/Build/Profile/FONERA20N,$(1))
        $(call Image/Build/Profile/V22RW2X2,$(1))
+       $(call Image/Build/Profile/NW718,$(1))
        $(call Image/Build/Profile/PWH2004,$(1))
        $(call Image/Build/Profile/WHRG300N,$(1))
        $(call Image/Build/Profile/WCR150GN,$(1))
index 562b8f1536ddba6449281fe00e61778c820db7c0..bd8887bfa66545f7632a3b43c15b4de1ea5564f6 100644 (file)
@@ -96,6 +96,7 @@ CONFIG_RT305X_MACH_F5D8235_V2=y
 CONFIG_RT305X_MACH_FONERA20N=y
 CONFIG_RT305X_MACH_HW550_3G=y
 CONFIG_RT305X_MACH_MOFI3500_3GN=y
+CONFIG_RT305X_MACH_NW718=y
 CONFIG_RT305X_MACH_PWH2004=y
 CONFIG_RT305X_MACH_RT_G32_REVB=y
 CONFIG_RT305X_MACH_V22RW_2X2=y