[ramips] move files to files-3.7
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-ur-326n4g.c
1 /*
2  *  UR-326N4G board support
3  *
4  *  Copyright (C) 2013 Dmitry Lebedev <Lebedev@upvel.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
23 #define UR_326N4G_GPIO_LED_3G           9
24 #define UR_326N4G_GPIO_LED_GATEWAY      11
25 #define UR_326N4G_GPIO_LED_AP           12
26 #define UR_326N4G_GPIO_LED_STATION      13
27 #define UR_326N4G_GPIO_LED_WPS          14
28
29 #define UR_326N4G_GPIO_BUTTON_RESET     10
30 #define UR_326N4G_GPIO_BUTTON_CONNECT   7
31 #define UR_326N4G_GPIO_BUTTON_WPS       0
32 #define UR_326N4G_GPIO_BUTTON_WPS2      8
33
34 #define UR_326N4G_KEYS_POLL_INTERVAL    20
35 #define UR_326N4G_KEYS_DEBOUNCE_INTERVAL (3 * UR_326N4G_KEYS_POLL_INTERVAL)
36
37 static struct gpio_led UR_326N4G_leds_gpio[] __initdata = {
38         {
39                 .name           = "ur326:green:3g",
40                 .gpio           = UR_326N4G_GPIO_LED_3G,
41                 .active_low     = 1,
42         }, {
43                 .name           = "ur326:green:gateway",
44                 .gpio           = UR_326N4G_GPIO_LED_GATEWAY,
45                 .active_low     = 1,
46         }, {
47                 .name           = "ur326:green:ap",
48                 .gpio           = UR_326N4G_GPIO_LED_AP,
49                 .active_low     = 1,
50         }, {
51                 .name           = "ur326:green:wps",
52                 .gpio           = UR_326N4G_GPIO_LED_WPS,
53                 .active_low     = 1,
54         }, {
55                 .name           = "ur326:green:station",
56                 .gpio           = UR_326N4G_GPIO_LED_STATION,
57                 .active_low     = 1,
58         }
59 };
60
61 static struct gpio_keys_button UR_326N4G_gpio_buttons[] __initdata = {
62         {
63                 .desc           = "reset_wps",
64                 .type           = EV_KEY,
65                 .code           = KEY_RESTART,
66                 .debounce_interval = UR_326N4G_KEYS_DEBOUNCE_INTERVAL,
67                 .gpio           = UR_326N4G_GPIO_BUTTON_RESET,
68                 .active_low     = 1,
69         }, {
70                 .desc           = "mode",
71                 .type           = EV_KEY,
72                 .code           = KEY_M,
73                 .debounce_interval = UR_326N4G_KEYS_DEBOUNCE_INTERVAL,
74                 .gpio           = UR_326N4G_GPIO_BUTTON_CONNECT,
75                 .active_low     = 1,
76         }
77 };
78
79 #define UR_326N4G_GPIO_MODE \
80         ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
81          RT305X_GPIO_MODE_MDIO)
82
83 static void __init UR_326N4G_init(void)
84 {
85         rt305x_gpio_init(UR_326N4G_GPIO_MODE);
86
87         rt305x_register_flash(0);
88
89         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
90         rt305x_register_ethernet();
91         ramips_register_gpio_leds(-1, ARRAY_SIZE(UR_326N4G_leds_gpio),
92                                   UR_326N4G_leds_gpio);
93         ramips_register_gpio_buttons(-1, UR_326N4G_KEYS_POLL_INTERVAL,
94                                      ARRAY_SIZE(UR_326N4G_gpio_buttons),
95                                      UR_326N4G_gpio_buttons);
96         rt305x_register_wifi();
97         rt305x_register_wdt();
98         rt305x_register_usb();
99 }
100
101 MIPS_MACHINE(RAMIPS_MACH_UR_326N4G, "UR-326N4G", "UR-326N4G Wireless N router",
102               UR_326N4G_init);