2 * Tenda 3G300M board support
4 * Copyright (C) 2013 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
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.
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>
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>
25 #define TENDA_3G300M_GPIO_BUTTON_RESET 0
26 #define TENDA_3G300M_GPIO_BUTTON_MODE 10
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
35 #define TENDA_3G300M_KEYS_POLL_INTERVAL 20
36 #define TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL (3 * TENDA_3G300M_KEYS_POLL_INTERVAL)
38 const struct flash_platform_data tenda_3g300m_flash
= {
42 struct spi_board_info tenda_3g300m_spi_slave_info
[] __initdata
= {
45 .platform_data
= &tenda_3g300m_flash
,
47 .max_speed_hz
= 10000000,
53 static struct gpio_led tenda_3g300m_leds_gpio
[] __initdata
= {
55 .name
= "tenda:blue:3grouter",
56 .gpio
= TENDA_3G300M_GPIO_LED_3GROUTER
,
59 .name
= "tenda:blue:ap",
60 .gpio
= TENDA_3G300M_GPIO_LED_AP
,
63 .name
= "tenda:blue:wisprouter",
64 .gpio
= TENDA_3G300M_GPIO_LED_WISPROUTER
,
67 .name
= "tenda:blue:wirelessrouter",
68 .gpio
= TENDA_3G300M_GPIO_LED_WIRELESSROUTER
,
71 .name
= "tenda:blue:3g",
72 .gpio
= TENDA_3G300M_GPIO_LED_3G
,
75 .name
= "tenda:blue:wpsreset",
76 .gpio
= TENDA_3G300M_GPIO_LED_WPSRESET
,
81 static struct gpio_keys_button tenda_3g300m_gpio_buttons
[] __initdata
= {
86 .debounce_interval
= TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL
,
87 .gpio
= TENDA_3G300M_GPIO_BUTTON_RESET
,
93 .debounce_interval
= TENDA_3G300M_KEYS_DEBOUNCE_INTERVAL
,
94 .gpio
= TENDA_3G300M_GPIO_BUTTON_MODE
,
99 static void __init
tenda_3g300m_init(void)
101 rt305x_gpio_init((RT305X_GPIO_MODE_GPIO
<<
102 RT305X_GPIO_MODE_UART0_SHIFT
) |
103 RT305X_GPIO_MODE_JTAG
);
105 rt305x_register_spi(tenda_3g300m_spi_slave_info
,
106 ARRAY_SIZE(tenda_3g300m_spi_slave_info
));
108 ramips_register_gpio_leds(-1, ARRAY_SIZE(tenda_3g300m_leds_gpio
),
109 tenda_3g300m_leds_gpio
);
111 ramips_register_gpio_buttons(-1, TENDA_3G300M_KEYS_POLL_INTERVAL
,
112 ARRAY_SIZE(tenda_3g300m_gpio_buttons
),
113 tenda_3g300m_gpio_buttons
);
115 rt305x_esw_data
.vlan_config
= RT305X_ESW_VLAN_CONFIG_LLLLW
;
116 rt305x_register_ethernet();
118 rt305x_register_wifi();
120 rt305x_register_wdt();
122 rt305x_register_usb();
125 MIPS_MACHINE(RAMIPS_MACH_3G300M
, "3G300M", "Tenda 3G300M",