[ramips] D-Link DAP-1350 initial support
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-dap-1350.c
1 /*
2 * D-Link DAP-1350 board support
3 */
4
5 #include <linux/init.h>
6 #include <linux/platform_device.h>
7
8 #include <asm/mach-ralink/machine.h>
9 #include <asm/mach-ralink/dev-gpio-buttons.h>
10 #include <asm/mach-ralink/dev-gpio-leds.h>
11 #include <asm/mach-ralink/rt305x.h>
12 #include <asm/mach-ralink/rt305x_regs.h>
13
14 #include "devices.h"
15
16 #define DAP_1350_GPIO_LED_POWER_BLUE 8
17 #define DAP_1350_GPIO_LED_POWER_RED 9
18 #define DAP_1350_GPIO_LED_WPS 14
19
20 #define DAP_1350_GPIO_BUTTON_WPS 0 /* active low */
21 #define DAP_1350_GPIO_BUTTON_RESET 10 /* active low */
22 #define DAP_1350_GPIO_SWITCH_MODE_AP 7 /* active low */
23 #define DAP_1350_GPIO_SWITCH_MODE_RT 11 /* active low */
24
25 #define DAP_1350_KEYS_POLL_INTERVAL 20
26 #define DAP_1350_KEYS_DEBOUNCE_INTERVAL (3 * DAP_1350_KEYS_POLL_INTERVAL)
27
28 static struct gpio_led dap_1350_leds_gpio[] __initdata = {
29 {
30 .name = "d-link:blue:power",
31 .gpio = DAP_1350_GPIO_LED_POWER_BLUE,
32 .active_low = 1,
33 }, {
34 .name = "d-link:red:power",
35 .gpio = DAP_1350_GPIO_LED_POWER_RED,
36 .active_low = 1,
37 }, {
38 .name = "d-link:blue:wps",
39 .gpio = DAP_1350_GPIO_LED_WPS,
40 .active_low = 1,
41 }
42 };
43
44 static struct gpio_keys_button dap_1350_gpio_buttons[] __initdata = {
45 {
46 .desc = "reset",
47 .type = EV_KEY,
48 .code = KEY_RESTART,
49 .debounce_interval = DAP_1350_KEYS_DEBOUNCE_INTERVAL,
50 .gpio = DAP_1350_GPIO_BUTTON_RESET,
51 .active_low = 1,
52 }, {
53 .desc = "wps",
54 .type = EV_KEY,
55 .code = KEY_WPS_BUTTON,
56 .debounce_interval = DAP_1350_KEYS_DEBOUNCE_INTERVAL,
57 .gpio = DAP_1350_GPIO_BUTTON_WPS,
58 .active_low = 1,
59 }, {
60 .desc = "rt",
61 .type = EV_KEY,
62 .code = BTN_0,
63 .debounce_interval = DAP_1350_KEYS_DEBOUNCE_INTERVAL,
64 .gpio = DAP_1350_GPIO_SWITCH_MODE_RT,
65 .active_low = 1,
66 }, {
67 .desc = "ap",
68 .type = EV_KEY,
69 .code = BTN_1,
70 .debounce_interval = DAP_1350_KEYS_DEBOUNCE_INTERVAL,
71 .gpio = DAP_1350_GPIO_SWITCH_MODE_AP,
72 .active_low = 1,
73 }
74 };
75
76 static void __init dap_1350_init(void)
77 {
78 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
79
80 rt305x_register_flash(0);
81
82 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
83 rt305x_register_ethernet();
84 ramips_register_gpio_leds(-1, ARRAY_SIZE(dap_1350_leds_gpio),
85 dap_1350_leds_gpio);
86 ramips_register_gpio_buttons(-1, DAP_1350_KEYS_POLL_INTERVAL,
87 ARRAY_SIZE(dap_1350_gpio_buttons),
88 dap_1350_gpio_buttons);
89 rt305x_register_wifi();
90 rt305x_register_wdt();
91 }
92
93 MIPS_MACHINE(RAMIPS_MACH_DAP_1350, "DAP-1350", "D-Link DAP-1350",
94 dap_1350_init);