move files to files-3.7
[openwrt/openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-3g300m.c
1 /*
2 * Tenda 3G300M board support
3 *
4 * Copyright (C) 2013 Cezary Jackiewicz <cezary.jackiewicz@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 #include <linux/spi/spi.h>
14 #include <linux/spi/flash.h>
15 #include <linux/gpio.h>
16
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define TENDA_3G300M_GPIO_BUTTON_RESET 0
26 #define TENDA_3G300M_GPIO_BUTTON_MODE 10
27
28 #define TENDA_3G300M_GPIO_LED_3GROUTER 11
29 #define TENDA_3G300M_GPIO_LED_AP 12
30 #define TENDA_3G300M_GPIO_LED_WISPROUTER 9
31 #define TENDA_3G300M_GPIO_LED_WIRELESSROUTER 13
32 #define TENDA_3G300M_GPIO_LED_3G 7
33 #define TENDA_3G300M_GPIO_LED_WPSRESET 14
34
35 #define TENDA_3G300M_KEYS_POLL_INTERVAL 20
36 #define TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL (3 * TENDA_3G300M_KEYS_POLL_INTERVAL)
37
38 const struct flash_platform_data tenda_3g300m_flash = {
39 .type = "mx25l3205d",
40 };
41
42 struct spi_board_info tenda_3g300m_spi_slave_info[] __initdata = {
43 {
44 .modalias = "m25p80",
45 .platform_data = &tenda_3g300m_flash,
46 .irq = -1,
47 .max_speed_hz = 10000000,
48 .bus_num = 0,
49 .chip_select = 0,
50 }
51 };
52
53 static struct gpio_led tenda_3g300m_leds_gpio[] __initdata = {
54 {
55 .name = "tenda:blue:3grouter",
56 .gpio = TENDA_3G300M_GPIO_LED_3GROUTER,
57 .active_low = 1,
58 },{
59 .name = "tenda:blue:ap",
60 .gpio = TENDA_3G300M_GPIO_LED_AP,
61 .active_low = 1,
62 },{
63 .name = "tenda:blue:wisprouter",
64 .gpio = TENDA_3G300M_GPIO_LED_WISPROUTER,
65 .active_low = 1,
66 },{
67 .name = "tenda:blue:wirelessrouter",
68 .gpio = TENDA_3G300M_GPIO_LED_WIRELESSROUTER,
69 .active_low = 1,
70 },{
71 .name = "tenda:blue:3g",
72 .gpio = TENDA_3G300M_GPIO_LED_3G,
73 .active_low = 1,
74 },{
75 .name = "tenda:blue:wpsreset",
76 .gpio = TENDA_3G300M_GPIO_LED_WPSRESET,
77 .active_low = 1,
78 }
79 };
80
81 static struct gpio_keys_button tenda_3g300m_gpio_buttons[] __initdata = {
82 {
83 .desc = "reset",
84 .type = EV_KEY,
85 .code = KEY_RESTART,
86 .debounce_interval = TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL,
87 .gpio = TENDA_3G300M_GPIO_BUTTON_RESET,
88 .active_low = 1,
89 },{
90 .desc = "mode",
91 .type = EV_KEY,
92 .code = BTN_0,
93 .debounce_interval = TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL,
94 .gpio = TENDA_3G300M_GPIO_BUTTON_MODE,
95 .active_low = 1,
96 }
97 };
98
99 static void __init tenda_3g300m_init(void)
100 {
101 rt305x_gpio_init((RT305X_GPIO_MODE_GPIO <<
102 RT305X_GPIO_MODE_UART0_SHIFT) |
103 RT305X_GPIO_MODE_JTAG);
104
105 rt305x_register_spi(tenda_3g300m_spi_slave_info,
106 ARRAY_SIZE(tenda_3g300m_spi_slave_info));
107
108 ramips_register_gpio_leds(-1, ARRAY_SIZE(tenda_3g300m_leds_gpio),
109 tenda_3g300m_leds_gpio);
110
111 ramips_register_gpio_buttons(-1, TENDA_3G300M_KEYS_POLL_INTERVAL,
112 ARRAY_SIZE(tenda_3g300m_gpio_buttons),
113 tenda_3g300m_gpio_buttons);
114
115 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
116 rt305x_register_ethernet();
117
118 rt305x_register_wifi();
119
120 rt305x_register_wdt();
121
122 rt305x_register_usb();
123 }
124
125 MIPS_MACHINE(RAMIPS_MACH_3G300M, "3G300M", "Tenda 3G300M",
126 tenda_3g300m_init);