5b496d4eac2a51c19edee628ba3605643ae97948
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-rt-n10-plus.c
1 /*
2  *  ASUS RT-N10+ board support
3  *
4  *  Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13
14 #include <asm/mach-ralink/machine.h>
15 #include <asm/mach-ralink/dev-gpio-buttons.h>
16 #include <asm/mach-ralink/dev-gpio-leds.h>
17 #include <asm/mach-ralink/rt305x.h>
18 #include <asm/mach-ralink/rt305x_regs.h>
19
20 #include "devices.h"
21
22 #define RT_N10_PLUS_GPIO_LED_WPS        14
23
24 #define RT_N10_PLUS_GPIO_BUTTON_WPS     0       /* active low */
25 #define RT_N10_PLUS_GPIO_BUTTON_RESET   10      /* active low */
26
27 #define RT_N10_PLUS_KEYS_POLL_INTERVAL  20
28 #define RT_N10_PLUS_KEYS_DEBOUNCE_INTERVAL  (3 * RT_N10_PLUS_KEYS_POLL_INTERVAL)
29
30 static struct gpio_led rt_n10_plus_leds_gpio[] __initdata = {
31         {
32                 .name           = "asus:green:wps",
33                 .gpio           = RT_N10_PLUS_GPIO_LED_WPS,
34                 .active_low     = 1,
35         }
36 };
37
38 static struct gpio_keys_button rt_n10_plus_gpio_buttons[] __initdata = {
39         {
40                 .desc           = "reset",
41                 .type           = EV_KEY,
42                 .code           = KEY_RESTART,
43                 .debounce_interval = RT_N10_PLUS_KEYS_DEBOUNCE_INTERVAL,
44                 .gpio           = RT_N10_PLUS_GPIO_BUTTON_RESET,
45                 .active_low     = 1,
46         }, {
47                 .desc           = "wps",
48                 .type           = EV_KEY,
49                 .code           = KEY_WPS_BUTTON,
50                 .debounce_interval = RT_N10_PLUS_KEYS_DEBOUNCE_INTERVAL,
51                 .gpio           = RT_N10_PLUS_GPIO_BUTTON_WPS,
52                 .active_low     = 1,
53         }
54 };
55
56 static void __init rt_n10_plus_init(void)
57 {
58         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
59
60         rt305x_register_flash(0);
61
62         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
63         rt305x_register_ethernet();
64         ramips_register_gpio_leds(-1, ARRAY_SIZE(rt_n10_plus_leds_gpio),
65                                   rt_n10_plus_leds_gpio);
66         ramips_register_gpio_buttons(-1, RT_N10_PLUS_KEYS_POLL_INTERVAL,
67                                      ARRAY_SIZE(rt_n10_plus_gpio_buttons),
68                                      rt_n10_plus_gpio_buttons);
69         rt305x_register_wifi();
70         rt305x_register_wdt();
71 }
72
73 MIPS_MACHINE(RAMIPS_MACH_RT_N10_PLUS, "RT-N10-PLUS", "Asus RT-N10+",
74         rt_n10_plus_init);