Support for Planex MZK-W300NH2.

Thunderbird issue, sorry for spamming.

 base-files/etc/diag.sh                             |    3
 base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom |    1
 base-files/etc/uci-defaults/leds                   |    3
 base-files/etc/uci-defaults/network                |    8 +
 base-files/lib/preinit/06_set_iface_mac            |    1
 base-files/lib/ramips.sh                           |    3
 base-files/lib/upgrade/platform.sh                 |    1
 files/arch/mips/include/asm/mach-ralink/machine.h  |    1
 files/arch/mips/ralink/rt305x/Kconfig              |    5 +
 files/arch/mips/ralink/rt305x/Makefile             |    1
 files/arch/mips/ralink/rt305x/mach-mzk-w300nh2.c   |   94 +++++++++++++++++++++
 image/Makefile                                     |   20 ++++
 rt305x/config-3.6                                  |    1
 13 files changed, 142 insertions(+)

This is a Japanese market router, for details check
http://www.planex.co.jp/product/router/mzk-w300nh2/. It has only 16MB
RAM, but base OpenWRT install worked fine for days without issues.
Even an image with built-in Luci worked, but don't expect smooth
experience, due to the lack of RAM. Wifi was not extensively tested,
but seems it is working. GPIO LEDs & buttons, factory flash image and
switch config are confirmed working. Tested against revision 34882 +
this patch.

Signed-off-by: Samir Ibradžić <sibrad...@gmail.com>
---
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/mach-mzk-w300nh2.c
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/mach-mzk-w300nh2.c        
(revision 0)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/mach-mzk-w300nh2.c        
(working copy)
@@ -0,0 +1,94 @@
+/*
+ *  Planex MZK-W300NH2 board support
+ *
+ *  Copyright (C) 2012 Samir Ibradžić sibrad...@gmail.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/init.h>
+#include <linux/platform_device.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 MZKW300NH2_GPIO_BUTTON_RESET     0     /* active low */
+#define MZKW300NH2_GPIO_BUTTON_WPS      12     /* active low */
+#define MZKW300NH2_GPIO_SWITCH_MODE_RT 13      /* active low */
+
+#define MZKW300NH2_GPIO_LED_POWER        9
+#define MZKW300NH2_GPIO_LED_WLAN        14
+#define MZKW300NH2_GPIO_LED_WPS         11
+
+#define MZKW300NH2_KEYS_POLL_INTERVAL   20
+#define MZKW300NH2_KEYS_DEBOUNCE_INTERVAL (3 * MZKW300NH2_KEYS_POLL_INTERVAL)
+
+static struct gpio_led mzkw300nh2_leds_gpio[] __initdata = {
+       {
+               .name           = "mzkw300nh2:green:power",
+               .gpio           = MZKW300NH2_GPIO_LED_POWER,
+               .active_low     = 1,
+       }, {
+               .name           = "mzkw300nh2:amber:wlan",
+               .gpio           = MZKW300NH2_GPIO_LED_WLAN,
+               .active_low     = 1,
+       }, {
+               .name           = "mzkw300nh2:amber:wps",
+               .gpio           = MZKW300NH2_GPIO_LED_WPS,
+               .active_low     = 1,
+       }
+};
+
+static struct gpio_keys_button mzkw300nh2_gpio_buttons[] __initdata = {
+       {
+               .desc           = "wps",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = MZKW300NH2_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = MZKW300NH2_GPIO_BUTTON_WPS,
+               .active_low     = 1,
+       }, {
+               .desc           = "reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = MZKW300NH2_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = MZKW300NH2_GPIO_BUTTON_RESET,
+               .active_low     = 1,
+       }, {
+               .desc           = "rt",
+               .type           = EV_KEY,
+               .code           = BTN_0,
+               .debounce_interval = MZKW300NH2_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = MZKW300NH2_GPIO_SWITCH_MODE_RT,
+               .active_low     = 1,
+       }
+};
+
+static void __init mzkw300nh2_init(void)
+{
+       rt305x_gpio_init(RT305X_GPIO_MODE_UART0(RT305X_GPIO_MODE_GPIO) |
+                        RT305X_GPIO_MODE_I2C |
+                        RT305X_GPIO_MODE_SPI |
+                        RT305X_GPIO_MODE_JTAG);
+
+       rt305x_register_flash(0);
+       rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
+       rt305x_register_ethernet();
+       ramips_register_gpio_leds(-1, ARRAY_SIZE(mzkw300nh2_leds_gpio),
+                                 mzkw300nh2_leds_gpio);
+       ramips_register_gpio_buttons(-1, MZKW300NH2_KEYS_POLL_INTERVAL,
+                                    ARRAY_SIZE(mzkw300nh2_gpio_buttons),
+                                    mzkw300nh2_gpio_buttons);
+       rt305x_register_wifi();
+       rt305x_register_wdt();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_MZKW300NH2, "MZK-W300NH2", "Planex MZK-W300NH2",
+             mzkw300nh2_init);
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig   (revision 34882)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/Kconfig   (working copy)
@@ -184,6 +184,11 @@
        select RALINK_DEV_GPIO_BUTTONS
        select RALINK_DEV_GPIO_LEDS

+config RT305X_MACH_MZKW300NH2
+       bool "Planex MZK-W300NH2 Router support"
+       select RALINK_DEV_GPIO_BUTTONS
+       select RALINK_DEV_GPIO_LEDS
+
 config RT305X_MACH_XDX_RN502J
        bool "Unknown board XDX-RN502J"
        select RALINK_DEV_GPIO_BUTTONS
Index: target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile  (revision 34882)
+++ target/linux/ramips/files/arch/mips/ralink/rt305x/Makefile  (working copy)
@@ -48,4 +48,5 @@
 obj-$(CONFIG_RT305X_MACH_WL341V3)      += mach-wl341v3.o
 obj-$(CONFIG_RT305X_MACH_WL351)                += mach-wl351.o
 obj-$(CONFIG_RT305X_MACH_WR6202)       += mach-wr6202.o
+obj-$(CONFIG_RT305X_MACH_MZKW300NH2)   += mach-mzk-w300nh2.o
 obj-$(CONFIG_RT305X_MACH_XDX_RN502J)    += mach-xdx-rn502j.o
Index: target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
===================================================================
--- target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h       
(revision 34882)
+++ target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h       
(working copy)
@@ -62,6 +62,7 @@
        RAMIPS_MACH_WL351,              /* Sitecom WL-351 v1 002 */
        RAMIPS_MACH_WR512_3GN,          /* SH-WR512NU/WS-WR512N1-like 3GN*/
        RAMIPS_MACH_WR6202,             /* Accton WR6202 */
+       RAMIPS_MACH_MZKW300NH2,         /* Planex MZK-W300NH2 Router */
        RAMIPS_MACH_XDXRN502J,          /* unknown XDX-RN502J */
        RAMIPS_MACH_UR_336UN,           /* UPVEL ROUTER */

Index: target/linux/ramips/rt305x/config-3.6
===================================================================
--- target/linux/ramips/rt305x/config-3.6       (revision 34882)
+++ target/linux/ramips/rt305x/config-3.6       (working copy)
@@ -129,6 +129,7 @@
 CONFIG_RT305X_MACH_WL_330N3G=y
 CONFIG_RT305X_MACH_WR512_3GN=y
 CONFIG_RT305X_MACH_WR6202=y
+CONFIG_RT305X_MACH_MZKW300NH2=y
 CONFIG_RT305X_MACH_XDX_RN502J=y
 # CONFIG_SCSI_DMA is not set
 CONFIG_SERIAL_8250_NR_UARTS=4
Index: target/linux/ramips/base-files/lib/upgrade/platform.sh
===================================================================
--- target/linux/ramips/base-files/lib/upgrade/platform.sh      (revision 34882)
+++ target/linux/ramips/base-files/lib/upgrade/platform.sh      (working copy)
@@ -34,6 +34,7 @@
        freestation5 | \
        hw550-3g | \
        mofi3500-3gn | \
+       mzk-w300nh2 | \
        nbg-419n | \
        nw718 | \
        omni-emb | \
Index: target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
===================================================================
--- target/linux/ramips/base-files/lib/preinit/06_set_iface_mac (revision 34882)
+++ target/linux/ramips/base-files/lib/preinit/06_set_iface_mac (working copy)
@@ -9,6 +9,7 @@

        case $(ramips_board_name) in
        3g-6200n |\
+       mzk-w300nh2 |\
        wl-330n |\
        wl-330n3g)
                mac=$(ramips_get_mac_binary factory 4)
Index: target/linux/ramips/base-files/lib/ramips.sh
===================================================================
--- target/linux/ramips/base-files/lib/ramips.sh        (revision 34882)
+++ target/linux/ramips/base-files/lib/ramips.sh        (working copy)
@@ -137,6 +137,9 @@
        *"Petatel PSR-680W"*)
                name="psr-680w"
                ;;
+       *"Planex MZK-W300NH2"*)
+               name="mzk-w300nh2"
+               ;;
        *"PWH2004")
                name="pwh2004"
                ;;
Index: target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
===================================================================
--- target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom      
(revision 34882)
+++ target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom      
(working copy)
@@ -87,6 +87,7 @@
        wli-tx4-ag300n | \
        wr512-3gn | \
        wr6202 | \
+       mzk-w300nh2 | \
        ur-336un | \
        xdxrn502j)
                rt2x00_eeprom_extract "factory" 0 272
Index: target/linux/ramips/base-files/etc/uci-defaults/leds
===================================================================
--- target/linux/ramips/base-files/etc/uci-defaults/leds        (revision 34882)
+++ target/linux/ramips/base-files/etc/uci-defaults/leds        (working copy)
@@ -65,6 +65,9 @@
        mofi3500-3gn)
                set_usb_led "mofi3500-3gn:green:usb"
                ;;
+       mzk-w300nh2)
+               set_wifi_led "mzkw300nh2:amber:wlan"
+               ;;
        nw718)
                set_usb_led "nw718:amber:usb"
                ;;
Index: target/linux/ramips/base-files/etc/uci-defaults/network
===================================================================
--- target/linux/ramips/base-files/etc/uci-defaults/network     (revision 34882)
+++ target/linux/ramips/base-files/etc/uci-defaults/network     (working copy)
@@ -71,6 +71,13 @@
                ucidef_add_switch_vlan "switch0" "2" "0 6t"
                ;;

+       mzk-w300nh2)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+               ucidef_add_switch "switch0" "1" "1"
+               ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
+               ucidef_add_switch_vlan "switch0" "2" "4 6t"
+               ;;
+
        f5d8235-v1 | \
        f5d8235-v2 | \
        ur-336un)
@@ -144,6 +151,7 @@
        bc2 | \
        broadway | \
        f5d8235-v1 | \
+       mzk-w300nh2 | \
        nw718 | \
        psr-680w | \
        rt-n15 | \
Index: target/linux/ramips/base-files/etc/diag.sh
===================================================================
--- target/linux/ramips/base-files/etc/diag.sh  (revision 34882)
+++ target/linux/ramips/base-files/etc/diag.sh  (working copy)
@@ -122,6 +122,9 @@
        wr512-3gn)
                status_led="wr512:green:wps"
                ;;
+       mzk-w300nh2)
+               status_led="mzkw300nh2:green:power"
+               ;;
        ur-336un)
                status_led="ur336:green:wps"
                ;;
Index: target/linux/ramips/image/Makefile
===================================================================
--- target/linux/ramips/image/Makefile  (revision 34882)
+++ target/linux/ramips/image/Makefile  (working copy)
@@ -410,6 +410,21 @@
        $(call BuildFirmware/Buffalo2,$(1),wli-tx4-ag300n,WLI-TX4-AG300N,$(call 
mkmtd/phys,$(mtdlayout_wlitx4ag300n)),917504,2883584)
 endef

+mtdlayout_mzkw300nh2=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,832k(kernel),2816k(rootfs),128k@0x3e0000(cimage)ro,3648k@0x50000(firmware)
+kernel_size_mzkw300nh2=851968
+rootfs_size_mzkw300nh2=2883584
+define BuildFirmware/MZKW300NH2
+       $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) 
$(call 
mkmtd/$(6),$(mtdlayout_mzkw300nh2)),$(kernel_size_mzkw300nh2),$(rootfs_size_mzkw300nh2))
+       $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,`expr 
$(kernel_size_mzkw300nh2) - 
20`,$(KDIR)/root.$(1),$(rootfs_size_mzkw300nh2),$(call 
imgname,$(1),$(2))-factory.bin)
+       mkedimaximg -i $(call imgname,$(1),$(2))-factory.bin \
+               -o $(call imgname,$(1),$(2))-factory.bin \
+               -s CSYS -m RN52 -f 0x50000 -S 0xc0000;
+endef
+
+define BuildFirmware/MZKW300NH2/initramfs
+       $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call 
mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_mzkw300nh2)))
+endef
+
 #
 # Templates
 #
@@ -533,6 +548,10 @@
        $(call 
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,nbg-419n,NBG-419N,ttyS1,57600,phys)
 endef

+define Image/Build/Profile/MZKW3000NH2
+       $(call 
Image/Build/Template/$(fs_squash)/$(1),MZKW300NH2,mzk-w300nh2,MZK-W300NH2,ttyS1,57600,phys)
+endef
+
 define Image/Build/Profile/NW718
        $(call Image/Build/Template/$(fs_squash)/$(1),NW718,nw718)
 endef
@@ -637,6 +656,7 @@
        $(call Image/Build/Profile/FREESTATION5,$(1))
        $(call Image/Build/Profile/HW5503G,$(1))
        $(call Image/Build/Profile/MOFI35003GN,$(1))
+       $(call Image/Build/Profile/MZKW3000NH2,$(1))
        $(call Image/Build/Profile/NBG419N,$(1))
        $(call Image/Build/Profile/NW718,$(1))
        $(call Image/Build/Profile/OMNIEMB,$(1))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to