ramips: rt305x: add support for Edimax 3G-6200N
[openwrt/openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-3g-6200n.c
1 /*
2 * Edimax 3g-6200n board support
3 *
4 * Copyright (C) 2011 Andrzej Hajda <andrzej.hajda@wp.pl>
5 * Copyright (C) 2012 Lukasz Golebiowski <lgolebio@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15
16 #include <asm/mach-ralink/machine.h>
17 #include <asm/mach-ralink/dev-gpio-buttons.h>
18 #include <asm/mach-ralink/dev-gpio-leds.h>
19 #include <asm/mach-ralink/rt305x.h>
20 #include <asm/mach-ralink/rt305x_regs.h>
21
22 #include "devices.h"
23
24 #define EDIMAX_GPIO_BUTTON_WPS 12
25 #define EDIMAX_GPIO_BTN_0 13 /* Wifi on/off switch button */
26
27 #define EDIMAX_GPIO_LED_POWER 9
28 #define EDIMAX_GPIO_LED_WLAN 14
29 #define EDIMAX_GPIO_LED_3G 7
30
31 #define EDIMAX_KEYS_POLL_INTERVAL 20
32 #define EDIMAX_KEYS_DEBOUNCE_INTERVAL (3 * EDIMAX_KEYS_POLL_INTERVAL)
33
34 static struct gpio_led edimax_leds_gpio[] __initdata = {
35 {
36 .name = "edimax:green:power",
37 .gpio = EDIMAX_GPIO_LED_POWER,
38 .active_low = 1,
39 }, {
40 .name = "edimax:amber:wlan",
41 .gpio = EDIMAX_GPIO_LED_WLAN,
42 .active_low = 1,
43 }, {
44 .name = "edimax:blue:3g",
45 .gpio = EDIMAX_GPIO_LED_3G,
46 .active_low = 1,
47 }
48 };
49
50 static struct gpio_keys_button edimax_gpio_buttons[] __initdata = {
51 {
52 .desc = "wps",
53 .type = EV_KEY,
54 .code = KEY_WPS_BUTTON,
55 .debounce_interval = EDIMAX_KEYS_DEBOUNCE_INTERVAL,
56 .gpio = EDIMAX_GPIO_BUTTON_WPS,
57 .active_low = 1,
58 }, {
59 .desc = "wlanswitch",
60 .type = EV_KEY,
61 .code = BTN_0,
62 .debounce_interval = EDIMAX_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = EDIMAX_GPIO_BTN_0,
64 .active_low = 1,
65 }
66 };
67
68 static void __init edimax_init(void)
69 {
70 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
71
72 rt305x_register_flash(0);
73 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
74 rt305x_register_ethernet();
75 ramips_register_gpio_leds(-1, ARRAY_SIZE(edimax_leds_gpio),
76 edimax_leds_gpio);
77 ramips_register_gpio_buttons(-1, EDIMAX_KEYS_POLL_INTERVAL,
78 ARRAY_SIZE(edimax_gpio_buttons),
79 edimax_gpio_buttons);
80 rt305x_register_wifi();
81 rt305x_register_wdt();
82 rt305x_register_usb();
83 }
84
85 MIPS_MACHINE(RAMIPS_MACH_3G_6200N, "3G-6200N", "Edimax 3g-6200n",
86 edimax_init);