[ramips] add feature gpio
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-rt-n13u.c
1 /*
2  *  ASUS RT-N13U board support
3  *
4  *  Copyright (C) 2012 lintel<lintel.huang@gmail.com>
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_N13U_GPIO_BUTTON_RESET       10
23 #define RT_N13U_GPIO_BUTTON_WPS         0
24
25 #define RT_N13U_GPIO_LED_POWER          7
26 #define RT_N13U_GPIO_LED_WIFI           8
27
28
29 #define RT_N13U_BUTTONS_POLL_INTERVAL   10
30 #define RT_N13U_BUTTONS_DEBOUNCE_INTERVAL  (3 * RT_N13U_BUTTONS_POLL_INTERVAL)
31
32 static struct gpio_led rt_n13u_leds_gpio[] __initdata = {
33         {
34                 .name           = "rt-n13u:power",
35                 .gpio           = RT_N13U_GPIO_LED_POWER,
36                 .active_low     = 1,
37         }, {
38                 .name           = "rt-n13u:wifi",
39                 .gpio           = RT_N13U_GPIO_LED_WIFI,
40                 .active_low     = 1,
41         }
42 };
43
44 static struct gpio_keys_button rt_n13u_gpio_buttons[] __initdata = {
45         {
46                 .desc           = "reset",
47                 .type           = EV_KEY,
48                 .code           = KEY_RESTART,
49                 .debounce_interval      = RT_N13U_BUTTONS_DEBOUNCE_INTERVAL,
50                 .gpio           = RT_N13U_GPIO_BUTTON_RESET,
51                 .active_low     = 1,
52         }, {
53                 .desc           = "wps",
54                 .type           = EV_KEY,
55                 .code           = KEY_WPS_BUTTON,
56                 .debounce_interval      = RT_N13U_BUTTONS_DEBOUNCE_INTERVAL,
57                 .gpio           = RT_N13U_GPIO_BUTTON_WPS,
58                 .active_low     = 1,
59         },
60 };
61
62 static void __init rt_n13u_init(void)
63 {
64         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
65
66         rt305x_register_flash(0);
67
68         ramips_register_gpio_leds(-1, ARRAY_SIZE(rt_n13u_leds_gpio),
69                                   rt_n13u_leds_gpio);
70
71         ramips_register_gpio_buttons(-1, RT_N13U_BUTTONS_POLL_INTERVAL,
72                                      ARRAY_SIZE(rt_n13u_gpio_buttons),
73                                      rt_n13u_gpio_buttons);
74
75         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
76         rt305x_register_ethernet();
77         rt305x_register_wifi();
78         rt305x_register_wdt();
79         rt305x_register_usb();
80 }
81
82 MIPS_MACHINE(RAMIPS_MACH_RT_N13U, "RT-N13U", "Asus RT-N13U",
83              rt_n13u_init);