From: Chi Zhang <zhangchi...@gmail.com>

This patch makes it possible for OpenWRT to run on a version of w150m that has 
4MB parallel flash.

Signed-off-by: Chi Zhang <zhangchi...@gmail.com>
---

In addtion I would like to point out that 3G300M, 3G150M, W300M, W150M and 
W150M+ 's board are the same, except that 3G models have USB sockets populated, 
and there are a few differences in LED labeling between 3G models and W models. 
xx300M uses RT3052F which has 2T2R MIMO while xx150M uses RT3050F.

Stock firmware indicates that all of the above models can have either SPI or 
parallel NOR flash. 3G models have 4MB flash and 16M x 16bit SDRAM, while most 
W models come with 2MB flash and 8M x 16bit SDRAM. But there are special cases 
that some W150M (at least those customized by Hewlett-Packard ) have 4MB flash, 
which is enough for OpenWRT.

It is still hard to squeeze OpenWRT into the common 2MB version of W150M, and 
the versions with SPI flash can use 3G300M profile instead, but with wrong LED 
definations.

I did not include rt305x_register_usb() call in my patch, though some people 
could get the USB socket on W150M populated or even upgrade the memories making 
it identical to 3G models.

Finally, what we need is actually 4 target profiles: 3G150M/3G300M, 3G150M 
SPI/3G300M SPI, W150M/W300M, W150M SPI/W300M SPI ( stock firmware adds "_SPI" 
after firmware version for SPI flash hardware version).

Internal photos and boot information for Hewlett-Packard customized version of 
W150M can be found on my site at http://blog.dword1511.info/?p=3781 ( in 
Chinese ).

diff --git a/target/linux/ramips/base-files/etc/diag.sh 
b/target/linux/ramips/base-files/etc/diag.sh
index 102ff27..cbae14a 100755
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -9,7 +9,7 @@ get_status_led() {
        3g-6200n)
                status_led="edimax:green:power"
                ;;
-       3g300m)
+       3g300m | w150m)
                status_led="tenda:blue:ap"
                ;;
        argus-atp52b)
diff --git 
a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom 
b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
index 43121e1..8fa1de9 100644
--- a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
+++ b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
@@ -83,6 +83,7 @@ case "$FIRMWARE" in
        v11st-fe | \
        v22rw-2x2 | \
        w306r-v20 | \
+       w150m | \
        w502u | \
        wcr-150gn | \
        whr-g300n | \
diff --git a/target/linux/ramips/base-files/etc/uci-defaults/02_network 
b/target/linux/ramips/base-files/etc/uci-defaults/02_network
index 5fb52bb..448a453 100755
--- a/target/linux/ramips/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ramips/base-files/etc/uci-defaults/02_network
@@ -38,6 +38,7 @@ ramips_setup_interfaces()
 
        case $board in
        3g300m | \
+       w150m | \
        all0256n | \
        all5002 | \
        broadway)
@@ -147,6 +148,7 @@ ramips_setup_macs()
                ;;
        3g-6200n | \
        3g300m | \
+       w150m | \
        air3gii | \
        argus-atp52b | \
        bc2 | \
diff --git a/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac 
b/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
index fcfb86b..30eaf28 100644
--- a/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
+++ b/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
@@ -11,6 +11,7 @@ preinit_set_mac_address() {
        case $(ramips_board_name) in
        3g-6200n |\
        3g300m | \
+       w150m | \
        mzk-w300nh2 |\
        wl-330n |\
        wl-330n3g)
diff --git a/target/linux/ramips/base-files/lib/ramips.sh 
b/target/linux/ramips/base-files/lib/ramips.sh
index 5d24abc..461b43d 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -157,6 +157,9 @@ ramips_board_name() {
        *"Tenda W306R V2.0")
                name="w306r-v20"
                ;;
+       *"Tenda W150M")
+               name="w150m"
+               ;;
        *"TEW-691GR")
                name="tew-691gr"
                ;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh 
b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 1b358c1..728cb8a 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -16,6 +16,7 @@ platform_check_image() {
        case "$board" in
        3g-6200n | \
        3g300m | \
+       w150m | \
        air3gii | \
        all0239-3g | \
        all0256n | \
diff --git 
a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h 
b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
index b3903fc..d503941 100644
--- a/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
+++ b/target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
@@ -68,6 +68,7 @@ enum ramips_mach_type {
        RAMIPS_MACH_MZKW300NH2,         /* Planex MZK-W300NH2 Router */
        RAMIPS_MACH_XDXRN502J,          /* unknown XDX-RN502J */
        RAMIPS_MACH_UR_336UN,           /* UPVEL ROUTER */
+       RAMIPS_MACH_W150M,              /* Tenda W150M */
 
        /* RT3352 based machines */
        RAMIPS_MACH_ALL5002,            /* Allnet ALL5002 */
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig 
b/target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
index c4653f5..cb05dd7 100644
--- a/target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
@@ -174,6 +174,11 @@ config RT305X_MACH_W306R_V20
        select RALINK_DEV_GPIO_BUTTONS
        select RALINK_DEV_GPIO_LEDS
 
+config RT305X_MACH_W150M
+       bool "Tenda W150M board support"
+       select RALINK_DEV_GPIO_BUTTONS
+       select RALINK_DEV_GPIO_LEDS
+
 config RT305X_MACH_WL341V3
        bool "Sitecom WL-341 v3 board support"
        select RALINK_DEV_GPIO_BUTTONS
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile 
b/target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
index 4e9f2f7..9dcf520 100644
--- a/target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_RT305X_MACH_RT_N10_PLUS) += mach-rt-n10-plus.o
 obj-$(CONFIG_RT305X_MACH_SL_R7205)     += mach-sl-r7205.o
 obj-$(CONFIG_RT305X_MACH_V22RW_2X2)    += mach-v22rw-2x2.o
 obj-$(CONFIG_RT305X_MACH_W306R_V20)    += mach-w306r-v20.o
+obj-$(CONFIG_RT305X_MACH_W150M)                += mach-w150m.o
 obj-$(CONFIG_RT305X_MACH_W502U)                += mach-w502u.o
 obj-$(CONFIG_RT305X_MACH_WCR150GN)     += mach-wcr150gn.o
 obj-$(CONFIG_RT305X_MACH_WHR_G300N)    += mach-whr-g300n.o
diff --git a/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-w150m.c 
b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-w150m.c
new file mode 100644
index 0000000..f990c34
--- /dev/null
+++ b/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-w150m.c
@@ -0,0 +1,103 @@
+/*
+ *  Tenda W150M board support
+ *
+ *
+ *  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/gpio.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 TENDA_W150M_GPIO_BUTTON_RESET          0
+#define TENDA_W150M_GPIO_BUTTON_MODE           10
+
+#define TENDA_W150M_GPIO_LED_AP                        11
+#define TENDA_W150M_GPIO_LED_CLIENTAP          12
+#define TENDA_W150M_GPIO_LED_WDSROUTER         9
+#define TENDA_W150M_GPIO_LED_WIRELESSROUTER    13
+#define TENDA_W150M_GPIO_LED_WISPROUTER                7
+#define TENDA_W150M_GPIO_LED_WPSRESET          14
+
+#define TENDA_W150M_KEYS_POLL_INTERVAL         20
+#define TENDA_W150M_KEYS_DEBOUNCE_INTERVAL     (3 * 
TENDA_W150M_KEYS_POLL_INTERVAL)
+
+static struct gpio_led tenda_w150m_leds_gpio[] __initdata = {
+       {
+               .name           = "tenda:blue:ap",
+               .gpio           = TENDA_W150M_GPIO_LED_AP,
+               .active_low     = 1,
+       },{
+               .name           = "tenda:blue:clientap",
+               .gpio           = TENDA_W150M_GPIO_LED_CLIENTAP,
+               .active_low     = 1,
+       },{
+               .name           = "tenda:blue:wdsrouter",
+               .gpio           = TENDA_W150M_GPIO_LED_WDSROUTER,
+               .active_low     = 1,
+       },{
+               .name           = "tenda:blue:wirelessrouter",
+               .gpio           = TENDA_W150M_GPIO_LED_WIRELESSROUTER,
+               .active_low     = 1,
+       },{
+               .name           = "tenda:blue:wisprouter",
+               .gpio           = TENDA_W150M_GPIO_LED_WISPROUTER,
+               .active_low     = 1,
+       },{
+               .name           = "tenda:blue:wpsreset",
+               .gpio           = TENDA_W150M_GPIO_LED_WPSRESET,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_keys_button tenda_w150m_gpio_buttons[] __initdata = {
+       {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = TENDA_W150M_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = TENDA_W150M_GPIO_BUTTON_RESET,
+               .active_low     = 1,
+       },{
+               .desc           = "mode",
+               .type           = EV_KEY,
+               .code           = BTN_0,
+               .debounce_interval = TENDA_W150M_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = TENDA_W150M_GPIO_BUTTON_MODE,
+               .active_low     = 1,
+       }
+};
+
+static void __init tenda_w150m_init(void)
+{
+       rt305x_register_flash(0);
+
+       rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
+
+       ramips_register_gpio_leds(-1, ARRAY_SIZE(tenda_w150m_leds_gpio),
+                       tenda_w150m_leds_gpio);
+
+       ramips_register_gpio_buttons(-1, TENDA_W150M_KEYS_POLL_INTERVAL,
+                       ARRAY_SIZE(tenda_w150m_gpio_buttons),
+                       tenda_w150m_gpio_buttons);
+
+       rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
+       rt305x_register_ethernet();
+
+       rt305x_register_wifi();
+
+       rt305x_register_wdt();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_W150M, "W150M", "Tenda W150M",
+               tenda_w150m_init);
diff --git a/target/linux/ramips/image/Makefile 
b/target/linux/ramips/image/Makefile
index d88bc95..1e1b2d6 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -478,6 +478,11 @@ define Image/Build/Profile/3G300M
        $(call 
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,3g300m,3G300M,ttyS1,57600,spi)
 endef
 
+define Image/Build/Profile/W150M
+       $(call 
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,w150m,W150M,ttyS1,57600,phys,W150M
 Kernel Image,factory.bin)
+       $(call 
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,w150m,W150M,ttyS1,57600,phys)
+endef
+
 define Image/Build/Profile/AIR3GII
        $(call 
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,air3gii,AIR3GII,ttyS1,57600,spi)
 endef
@@ -650,6 +655,7 @@ ifeq ($(CONFIG_RALINK_RT305X),y)
 define Image/Build/Profile/Default
        $(call Image/Build/Profile/3G6200N,$(1))
        $(call Image/Build/Profile/3G300M,$(1))
+       $(call Image/Build/Profile/W150M,$(1))
        $(call Image/Build/Profile/AIR3GII,$(1))
        $(call Image/Build/Profile/ALL02393G,$(1))
        $(call Image/Build/Profile/ALL0256N,$(1))
diff --git a/target/linux/ramips/rt305x/config-3.7 
b/target/linux/ramips/rt305x/config-3.7
index 831219c..abe18f5 100644
--- a/target/linux/ramips/rt305x/config-3.7
+++ b/target/linux/ramips/rt305x/config-3.7
@@ -134,6 +134,7 @@ CONFIG_RT305X_MACH_SL_R7205=y
 CONFIG_RT305X_MACH_UR_336UN=y
 CONFIG_RT305X_MACH_V22RW_2X2=y
 CONFIG_RT305X_MACH_W306R_V20=y
+CONFIG_RT305X_MACH_W150M=y
 CONFIG_RT305X_MACH_W502U=y
 CONFIG_RT305X_MACH_WCR150GN=y
 CONFIG_RT305X_MACH_WHR_G300N=y
diff --git a/target/linux/ramips/rt305x/profiles/tenda.mk 
b/target/linux/ramips/rt305x/profiles/tenda.mk
index 10a4cb3..a0ef08d 100644
--- a/target/linux/ramips/rt305x/profiles/tenda.mk
+++ b/target/linux/ramips/rt305x/profiles/tenda.mk
@@ -18,6 +18,17 @@ endef
 
 $(eval $(call Profile,3G300M))
 
+define Profile/W150M
+       NAME:=Tenda W150M
+       PACKAGES:=
+endef
+
+define Profile/W150M/Description
+       Package set for Tenda W150M board with parallel NOR flash
+endef
+
+$(eval $(call Profile,W150M))
+
 define Profile/W306R_V20
        NAME:=Tenda W306R V2.0
        PACKAGES:=
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to