2 * ALFA Networks W502U board support
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
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/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.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 W502U_GPIO_LED_USB 13
26 #define W502U_GPIO_LED_WPS 14
28 #define W502U_GPIO_BUTTON_WPS 0
29 #define W502U_GPIO_BUTTON_RESET 10
31 #define W502U_BUTTONS_POLL_INTERVAL 20
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition w502u_partitions
[] = {
39 .mask_flags
= MTD_WRITEABLE
,
44 .mask_flags
= MTD_WRITEABLE
,
49 .mask_flags
= MTD_WRITEABLE
,
62 .mask_flags
= MTD_WRITEABLE
,
69 #endif /* CONFIG_MTD_PARTITIONS */
71 static struct physmap_flash_data w502u_flash_data
= {
72 #ifdef CONFIG_MTD_PARTITIONS
73 .nr_parts
= ARRAY_SIZE(w502u_partitions
),
74 .parts
= w502u_partitions
,
78 static struct gpio_led w502u_leds_gpio
[] __initdata
= {
80 .name
= "alfa:blue:usb",
81 .gpio
= W502U_GPIO_LED_USB
,
85 .name
= "alfa:blue:wps",
86 .gpio
= W502U_GPIO_LED_WPS
,
91 static struct gpio_button w502u_gpio_buttons
[] __initdata
= {
93 .desc
= "Reset button",
97 .gpio
= W502U_GPIO_BUTTON_RESET
,
101 .desc
= "WPS button",
103 .code
= KEY_WPS_BUTTON
,
105 .gpio
= W502U_GPIO_BUTTON_WPS
,
110 static void __init
w502u_init(void)
112 rt305x_gpio_init((RT305X_GPIO_MODE_GPIO
<<
113 RT305X_GPIO_MODE_UART0_SHIFT
));
115 rt305x_register_flash(0, &w502u_flash_data
);
116 rt305x_esw_data
.vlan_config
= RT305X_ESW_VLAN_CONFIG_LLLLW
;
117 rt305x_register_ethernet();
118 ramips_register_gpio_leds(-1, ARRAY_SIZE(w502u_leds_gpio
),
120 ramips_register_gpio_buttons(-1, W502U_BUTTONS_POLL_INTERVAL
,
121 ARRAY_SIZE(w502u_gpio_buttons
),
123 rt305x_register_wifi();
124 rt305x_register_wdt();
125 rt305x_register_usb();
128 MIPS_MACHINE(RAMIPS_MACH_W502U
, "W502U", "ALFA Networks W502U",