ramips: rt3883: add initial support for the TRENDnet TEW-691GR board
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt3883 / mach-tew-691gr.c
1 /*
2 * TRENDnet TEW-691GR board support
3 *
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
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 #include <linux/ethtool.h>
14 #include <linux/pci.h>
15 #include <linux/phy.h>
16 #include <linux/rt2x00_platform.h>
17 #include <linux/ar8216_platform.h>
18
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev-gpio-buttons.h>
21 #include <asm/mach-ralink/dev-gpio-leds.h>
22 #include <asm/mach-ralink/rt3883.h>
23 #include <asm/mach-ralink/rt3883_regs.h>
24 #include <asm/mach-ralink/ramips_eth_platform.h>
25
26 #include "devices.h"
27
28 #define TEW_691GR_GPIO_LED_WPS_GREEN 9
29
30 #define TEW_691GR_GPIO_BUTTON_RESET 10
31 #define TEW_691GR_GPIO_BUTTON_WPS 26
32
33 #define TEW_691GR_GPIO_SWITCH_RFKILL 0
34
35 #define TEW_691GR_KEYS_POLL_INTERVAL 20
36 #define TEW_691GR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_691GR_KEYS_POLL_INTERVAL)
37
38 static struct gpio_led tew_691gr_leds_gpio[] __initdata = {
39 {
40 .name = "trendnet:green:wps",
41 .gpio = TEW_691GR_GPIO_LED_WPS_GREEN,
42 .active_low = 1,
43 },
44 };
45
46 static struct gpio_keys_button tew_691gr_gpio_buttons[] __initdata = {
47 {
48 .desc = "Reset button",
49 .type = EV_KEY,
50 .code = KEY_RESTART,
51 .debounce_interval = TEW_691GR_KEYS_DEBOUNCE_INTERVAL,
52 .gpio = TEW_691GR_GPIO_BUTTON_RESET,
53 .active_low = 1,
54 },
55 {
56 .desc = "WPS button",
57 .type = EV_KEY,
58 .code = KEY_WPS_BUTTON,
59 .debounce_interval = TEW_691GR_KEYS_DEBOUNCE_INTERVAL,
60 .gpio = TEW_691GR_GPIO_BUTTON_WPS,
61 .active_low = 1,
62 },
63 {
64 .desc = "RFKILL switch",
65 .type = EV_SW,
66 .code = KEY_WPS_BUTTON,
67 .debounce_interval = TEW_691GR_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = TEW_691GR_GPIO_SWITCH_RFKILL,
69 .active_low = 1,
70 },
71 };
72
73 static void __init tew_691gr_init(void)
74 {
75 rt3883_gpio_init(RT3883_GPIO_MODE_I2C |
76 RT3883_GPIO_MODE_SPI |
77 RT3883_GPIO_MODE_UART0(RT3883_GPIO_MODE_GPIO) |
78 RT3883_GPIO_MODE_JTAG |
79 RT3883_GPIO_MODE_PCI(RT3883_GPIO_MODE_PCI_FNC));
80
81 rt3883_register_pflash(0);
82
83 ramips_register_gpio_leds(-1, ARRAY_SIZE(tew_691gr_leds_gpio),
84 tew_691gr_leds_gpio);
85
86 ramips_register_gpio_buttons(-1, TEW_691GR_KEYS_POLL_INTERVAL,
87 ARRAY_SIZE(tew_691gr_gpio_buttons),
88 tew_691gr_gpio_buttons);
89
90 rt3883_register_wlan();
91
92 rt3883_eth_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
93 rt3883_eth_data.phy_mask = BIT(0);
94 rt3883_eth_data.tx_fc = 1;
95 rt3883_eth_data.rx_fc = 1;
96 rt3883_register_ethernet();
97
98 rt3883_register_wdt(false);
99 }
100
101 MIPS_MACHINE(RAMIPS_MACH_TEW_691GR, "TEW-691GR", "TRENDnet TEW-691GR",
102 tew_691gr_init);