2 * Buffalo WLI-TX4-AG300N 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/ethtool.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/dev-gpio-leds.h>
21 #include <asm/mach-ralink/rt288x.h>
22 #include <asm/mach-ralink/rt288x_regs.h>
23 #include <asm/mach-ralink/ramips_eth_platform.h>
27 #define WLI_TX4_AG300N_GPIO_LED_DIAG 10
28 #define WLI_TX4_AG300N_GPIO_LED_POWER 12
29 #define WLI_TX4_AG300N_GPIO_LED_SECURITY 13
31 #define WLI_TX4_AG300N_GPIO_BUTTON_AOSS 0
32 #define WLI_TX4_AG300N_GPIO_BUTTON_BW_SWITCH 8
33 #define WLI_TX4_AG300N_GPIO_BUTTON_RESET 9
35 #define WLI_TX4_AG300N_KEYS_POLL_INTERVAL 20
36 #define WLI_TX4_AG300N_KEYS_DEBOUNCE_INTERVAL (3 * WLI_TX4_AG300N_KEYS_POLL_INTERVAL)
38 static struct mtd_partition wli_tx4_ag300n_partitions[] = {
43 .mask_flags = MTD_WRITEABLE,
49 .mask_flags = MTD_WRITEABLE,
55 .mask_flags = MTD_WRITEABLE,
79 static struct gpio_led wli_tx4_ag300n_leds_gpio[] __initdata = {
81 .name = "buffalo:blue:power",
82 .gpio = WLI_TX4_AG300N_GPIO_LED_POWER,
86 .name = "buffalo:red:diag",
87 .gpio = WLI_TX4_AG300N_GPIO_LED_DIAG,
91 .name = "buffalo:blue:security",
92 .gpio = WLI_TX4_AG300N_GPIO_LED_SECURITY,
97 static struct gpio_keys_button wli_tx4_ag300n_gpio_buttons[] __initdata = {
99 .desc = "Reset button",
102 .debounce_interval = WLI_TX4_AG300N_KEYS_DEBOUNCE_INTERVAL,
103 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_RESET,
107 .desc = "AOSS button",
109 .code = KEY_WPS_BUTTON,
110 .debounce_interval = WLI_TX4_AG300N_KEYS_DEBOUNCE_INTERVAL,
111 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_AOSS,
115 .desc = "Bandwidth switch",
118 .debounce_interval = WLI_TX4_AG300N_KEYS_DEBOUNCE_INTERVAL,
119 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_BW_SWITCH,
124 static void __init wli_tx4_ag300n_init(void)
126 rt288x_gpio_init(RT2880_GPIO_MODE_UART0);
128 ramips_register_gpio_leds(-1, ARRAY_SIZE(wli_tx4_ag300n_leds_gpio),
129 wli_tx4_ag300n_leds_gpio);
130 ramips_register_gpio_buttons(-1, WLI_TX4_AG300N_KEYS_POLL_INTERVAL,
131 ARRAY_SIZE(wli_tx4_ag300n_gpio_buttons),
132 wli_tx4_ag300n_gpio_buttons);
134 rt288x_flash0_data.nr_parts = ARRAY_SIZE(wli_tx4_ag300n_partitions);
135 rt288x_flash0_data.parts = wli_tx4_ag300n_partitions;
136 rt288x_register_flash(0);
138 rt288x_register_wifi();
139 rt288x_register_wdt();
141 rt288x_eth_data.speed = SPEED_100;
142 rt288x_eth_data.duplex = DUPLEX_FULL;
143 rt288x_eth_data.tx_fc = 1;
144 rt288x_eth_data.rx_fc = 1;
145 rt288x_register_ethernet();
148 MIPS_MACHINE(RAMIPS_MACH_WLI_TX4_AG300N, "WLI-TX4-AG300N",
149 "Buffalo WLI-TX4-AG300N", wli_tx4_ag300n_init);