74dfaa30b06e3597802fc416638cf713ebc9f93c
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-broadway.c
1 /*
2  *  Hauppauge/PCTV Broadway Support
3  *
4  *  Copyright (C) 2012 Devin Heitmueller <dheitmueller@kernellabs.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 BROADWAY_GPIO_LED_DISKMOUNT     9
23 #define BROADWAY_GPIO_LED_WPS           14
24
25 #define BROADWAY_GPIO_BUTTON_WPS                0
26 #define BROADWAY_GPIO_BUTTON_FACTORYRESET       13
27
28 #define BROADWAY_KEYS_POLL_INTERVAL     20
29 #define BROADWAY_KEYS_DEBOUNCE_INTERVAL (3 * BROADWAY_KEYS_POLL_INTERVAL)
30
31 static struct gpio_led broadway_leds_gpio[] __initdata = {
32         {
33                 .name           = "red:diskmounted",
34                 .gpio           = BROADWAY_GPIO_LED_DISKMOUNT,
35                 .active_low     = 1,
36         },
37         {
38                 .name           = "red:wps_active",
39                 .gpio           = BROADWAY_GPIO_LED_WPS,
40                 .active_low     = 1,
41         },
42 };
43
44 static struct gpio_keys_button broadway_gpio_buttons[] __initdata = {
45         {
46                 .desc           = "Factory Reset button",
47                 .type           = EV_KEY,
48                 .code           = KEY_RESTART,
49                 .debounce_interval = BROADWAY_KEYS_DEBOUNCE_INTERVAL,
50                 .gpio           = BROADWAY_GPIO_BUTTON_FACTORYRESET,
51                 .active_low     = 1,
52         },
53 #ifdef DJH_WPS_BUTTON_NOT_WIRED_TO_GPIO
54         {
55                 .desc           = "WPS button",
56                 .type           = EV_KEY,
57                 .code           = KEY_WPS_BUTTON,
58                 .debounce_interval = BROADWAY_KEYS_DEBOUNCE_INTERVAL,
59                 .gpio           = BROADWAY_GPIO_BUTTON_WPS,
60                 .active_low     = 1,
61         },
62 #endif
63 };
64
65 static void __init broadway_init(void)
66 {
67         rt305x_gpio_init((RT305X_GPIO_MODE_GPIO <<
68                           RT305X_GPIO_MODE_UART0_SHIFT));
69
70         rt305x_register_flash(0);
71
72         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
73         rt305x_register_ethernet();
74
75         ramips_register_gpio_leds(-1, ARRAY_SIZE(broadway_leds_gpio),
76                                   broadway_leds_gpio);
77         ramips_register_gpio_buttons(-1, BROADWAY_KEYS_POLL_INTERVAL,
78                                      ARRAY_SIZE(broadway_gpio_buttons),
79                                      broadway_gpio_buttons);
80
81         rt305x_register_wifi();
82         rt305x_register_wdt();
83         rt305x_register_usb();
84 }
85
86 MIPS_MACHINE(RAMIPS_MACH_BROADWAY, "BROADWAY", "Hauppauge Broadway",
87               broadway_init);