[ramips] move files to files-3.7
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-wr512-3gn.c
1 /*
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.
8  *
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>
12  *
13  *
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.
17  */
18
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21
22 #include <asm/mach-ralink/machine.h>
23 #include <asm/mach-ralink/dev-gpio-buttons.h>
24 #include <asm/mach-ralink/dev-gpio-leds.h>
25 #include <asm/mach-ralink/rt305x.h>
26 #include <asm/mach-ralink/rt305x_regs.h>
27
28 #include "devices.h"
29
30
31 #define WR512_3GN_GPIO_LED_3G           9
32 #define WR512_3GN_GPIO_LED_GATEWAY      11
33 #define WR512_3GN_GPIO_LED_AP           12
34 #define WR512_3GN_GPIO_LED_STATION      13
35 #define WR512_3GN_GPIO_LED_WPS          14
36
37 #define WR512_3GN_GPIO_BUTTON_RESET     10
38 #define WR512_3GN_GPIO_BUTTON_CONNECT   7
39 #define WR512_3GN_GPIO_BUTTON_WPS       0
40 #define WR512_3GN_GPIO_BUTTON_WPS2      8
41
42 #define WR512_3GN_KEYS_POLL_INTERVAL    20
43 #define WR512_3GN_KEYS_DEBOUNCE_INTERVAL (3 * WR512_3GN_KEYS_POLL_INTERVAL)
44
45 static struct gpio_led wr512_3gn_leds_gpio[] __initdata = {
46         {
47                 .name           = "wr512:green:3g",
48                 .gpio           = WR512_3GN_GPIO_LED_3G,
49                 .active_low     = 1,
50         }, {
51                 .name           = "wr512:green:gateway",
52                 .gpio           = WR512_3GN_GPIO_LED_GATEWAY,
53                 .active_low     = 1,
54         }, {
55                 .name           = "wr512:green:ap",
56                 .gpio           = WR512_3GN_GPIO_LED_AP,
57                 .active_low     = 1,
58         }, {
59                 .name           = "wr512:green:wps",
60                 .gpio           = WR512_3GN_GPIO_LED_WPS,
61                 .active_low     = 1,
62         }, {
63                 .name           = "wr512:green:station",
64                 .gpio           = WR512_3GN_GPIO_LED_STATION,
65                 .active_low     = 1,
66         }
67 };
68
69 static struct gpio_keys_button wr512_3gn_gpio_buttons[] __initdata = {
70         {
71                 .desc           = "reset_wps",
72                 .type           = EV_KEY,
73                 .code           = KEY_RESTART,
74                 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
75                 .gpio           = WR512_3GN_GPIO_BUTTON_RESET,
76                 .active_low     = 1,
77         }, {
78                 .desc           = "mode",
79                 .type           = EV_KEY,
80                 .code           = KEY_M,
81                 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
82                 .gpio           = WR512_3GN_GPIO_BUTTON_CONNECT,
83                 .active_low     = 1,
84         }
85 };
86
87 #define WR512_3GN_GPIO_MODE \
88         ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
89          RT305X_GPIO_MODE_MDIO)
90
91 static void __init wr512_3gn_init(void)
92 {
93         rt305x_gpio_init(WR512_3GN_GPIO_MODE);
94
95         rt305x_register_flash(0);
96
97         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
98         rt305x_register_ethernet();
99         ramips_register_gpio_leds(-1, ARRAY_SIZE(wr512_3gn_leds_gpio),
100                                   wr512_3gn_leds_gpio);
101         ramips_register_gpio_buttons(-1, WR512_3GN_KEYS_POLL_INTERVAL,
102                                      ARRAY_SIZE(wr512_3gn_gpio_buttons),
103                                      wr512_3gn_gpio_buttons);
104         rt305x_register_wifi();
105         rt305x_register_wdt();
106         rt305x_register_usb();
107 }
108
109 MIPS_MACHINE(RAMIPS_MACH_WR512_3GN, "WR512-3GN", "WR512-3GN-like router",
110               wr512_3gn_init);