2 * Unbranded router from DX board support
3 * Also known as *WR512*-3GN by local vendors
4 * e.g. WS-WR512N1, Sin Hon SH-WR512NU, and etc
5 * (http://www.dealextreme.com/p/portable-wireless-n-3g-router-cdma2000-evdo-td-scdma-hspa-wcdma-45639)
6 * This router is also known to be rebranded and sold by a number of local
7 * vendors in several countries.
9 * Copyright (C) 2011 Andrew Andrianov <necromant@necromant.ath.cx>
10 * Based on MOFI3500-3N code by
11 * Copyright (C) 2011 Layne Edwards <ledwards76@gmail.com>
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation.
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/physmap.h>
25 #include <asm/mach-ralink/machine.h>
26 #include <asm/mach-ralink/dev-gpio-buttons.h>
27 #include <asm/mach-ralink/dev-gpio-leds.h>
28 #include <asm/mach-ralink/rt305x.h>
29 #include <asm/mach-ralink/rt305x_regs.h>
34 #define WR512_3GN_GPIO_LED_3G 9
35 #define WR512_3GN_GPIO_LED_GATEWAY 11
36 #define WR512_3GN_GPIO_LED_AP 12
37 #define WR512_3GN_GPIO_LED_STATION 13
38 #define WR512_3GN_GPIO_LED_WPS 14
40 #define WR512_3GN_GPIO_BUTTON_RESET 10
41 #define WR512_3GN_GPIO_BUTTON_CONNECT 7
42 #define WR512_3GN_GPIO_BUTTON_WPS 0
43 #define WR512_3GN_GPIO_BUTTON_WPS2 8
45 #define WR512_3GN_KEYS_POLL_INTERVAL 20
46 #define WR512_3GN_KEYS_DEBOUNCE_INTERVAL (3 * WR512_3GN_KEYS_POLL_INTERVAL)
48 static struct mtd_partition wr512_3gn_partitions[] = {
53 .mask_flags = MTD_WRITEABLE,
58 .mask_flags = MTD_WRITEABLE,
63 .mask_flags = MTD_WRITEABLE,
79 static struct physmap_flash_data wr512_3gn_flash_data = {
80 .nr_parts = ARRAY_SIZE(wr512_3gn_partitions),
81 .parts = wr512_3gn_partitions,
84 static struct gpio_led wr512_3gn_leds_gpio[] __initdata = {
86 .name = "wr512:green:3g",
87 .gpio = WR512_3GN_GPIO_LED_3G,
90 .name = "wr512:green:gateway",
91 .gpio = WR512_3GN_GPIO_LED_GATEWAY,
94 .name = "wr512:green:ap",
95 .gpio = WR512_3GN_GPIO_LED_AP,
98 .name = "wr512:green:wps",
99 .gpio = WR512_3GN_GPIO_LED_WPS,
102 .name = "wr512:green:station",
103 .gpio = WR512_3GN_GPIO_LED_STATION,
108 static struct gpio_keys_button wr512_3gn_gpio_buttons[] __initdata = {
113 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
114 .gpio = WR512_3GN_GPIO_BUTTON_RESET,
120 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
121 .gpio = WR512_3GN_GPIO_BUTTON_CONNECT,
126 #define WR512_3GN_GPIO_MODE \
127 ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
128 RT305X_GPIO_MODE_MDIO)
130 static void __init wr512_3gn_init(void)
132 rt305x_gpio_init(WR512_3GN_GPIO_MODE);
134 rt305x_register_flash(0, &wr512_3gn_flash_data);
135 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
136 rt305x_register_ethernet();
137 ramips_register_gpio_leds(-1, ARRAY_SIZE(wr512_3gn_leds_gpio),
138 wr512_3gn_leds_gpio);
139 ramips_register_gpio_buttons(-1, WR512_3GN_KEYS_POLL_INTERVAL,
140 ARRAY_SIZE(wr512_3gn_gpio_buttons),
141 wr512_3gn_gpio_buttons);
142 rt305x_register_wifi();
143 rt305x_register_wdt();
144 rt305x_register_usb();
147 MIPS_MACHINE(RAMIPS_MACH_WR512_3GN, "WR512-3GN", "WR512-3GN-like router",