b274b917da5f718ace844474cdc9e3fdbacb37e0
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-hw550-3g.c
1 /*
2  *  Aztech HW550-3G board support
3  *
4  *  Copyright (C) 2011 Layne Edwards <ledwards76@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 HW550_3G_GPIO_LED_USB           8
23 #define HW550_3G_GPIO_LED_3G            11
24 #define HW550_3G_GPIO_LED_STATUS        12
25 #define HW550_3G_GPIO_LED_WPS           14
26
27 #define HW550_3G_GPIO_BUTTON_RESET      10
28 #define HW550_3G_GPIO_BUTTON_CONNECT    7
29 #define HW550_3G_GPIO_BUTTON_WPS        0
30
31 #define HW550_3G_KEYS_POLL_INTERVAL     20
32 #define HW550_3G_KEYS_DEBOUNCE_INTERVAL (3 * HW550_3G_KEYS_POLL_INTERVAL)
33
34 static struct gpio_led hw550_3g_leds_gpio[] __initdata = {
35         {
36                 .name           = "hw550-3g:green:usb",
37                 .gpio           = HW550_3G_GPIO_LED_USB,
38                 .active_low     = 1,
39         }, {
40                 .name           = "hw550-3g:green:3g",
41                 .gpio           = HW550_3G_GPIO_LED_3G,
42                 .active_low     = 1,
43         }, {
44                 .name           = "hw550-3g:green:status",
45                 .gpio           = HW550_3G_GPIO_LED_STATUS,
46                 .active_low     = 1,
47         }, {
48                 .name           = "hw550-3g:green:wps",
49                 .gpio           = HW550_3G_GPIO_LED_WPS,
50                 .active_low     = 1,
51         }
52 };
53
54 static struct gpio_keys_button hw550_3g_gpio_buttons[] __initdata = {
55         {
56                 .desc           = "reset",
57                 .type           = EV_KEY,
58                 .code           = KEY_RESTART,
59                 .debounce_interval = HW550_3G_KEYS_DEBOUNCE_INTERVAL,
60                 .gpio           = HW550_3G_GPIO_BUTTON_RESET,
61                 .active_low     = 1,
62         }, {
63                 .desc           = "connect",
64                 .type           = EV_KEY,
65                 .code           = KEY_CONNECT,
66                 .debounce_interval = HW550_3G_KEYS_DEBOUNCE_INTERVAL,
67                 .gpio           = HW550_3G_GPIO_BUTTON_CONNECT,
68                 .active_low     = 1,
69         }, {
70                 .desc           = "wps",
71                 .type           = EV_KEY,
72                 .code           = KEY_WPS_BUTTON,
73                 .debounce_interval = HW550_3G_KEYS_DEBOUNCE_INTERVAL,
74                 .gpio           = HW550_3G_GPIO_BUTTON_WPS,
75                 .active_low     = 1,
76         }
77 };
78
79 #define HW550_3G_GPIO_MODE \
80         ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
81          RT305X_GPIO_MODE_MDIO)
82
83 static void __init hw550_3g_init(void)
84 {
85         rt305x_gpio_init(HW550_3G_GPIO_MODE);
86
87         rt305x_register_flash(0);
88
89        rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
90         rt305x_register_ethernet();
91         ramips_register_gpio_leds(-1, ARRAY_SIZE(hw550_3g_leds_gpio),
92                                   hw550_3g_leds_gpio);
93         ramips_register_gpio_buttons(-1, HW550_3G_KEYS_POLL_INTERVAL,
94                                      ARRAY_SIZE(hw550_3g_gpio_buttons),
95                                      hw550_3g_gpio_buttons);
96         rt305x_register_wifi();
97         rt305x_register_wdt();
98         rt305x_register_usb();
99 }
100
101 MIPS_MACHINE(RAMIPS_MACH_HW550_3G, "HW550-3G", "Aztech HW550-3G",
102              hw550_3g_init);
103
104 MIPS_MACHINE(RAMIPS_MACH_ALL0239_3G, "ALL0239-3G", "Allnet ALL0239-3G",
105              hw550_3g_init);