2 * Buffalo WZR-HP-G300NH2 board support
4 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2011 Mark Deneen <mdeneen@gmail.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <linux/gpio.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
16 #include <asm/mach-ath79/ath79.h>
18 #include "dev-ap9x-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define WZRHPG300NH2_MAC_OFFSET 0x20c
27 #define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
28 #define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
30 static struct mtd_partition wzrhpg300nh2_flash_partitions[] = {
35 .mask_flags = MTD_WRITEABLE,
40 .mask_flags = MTD_WRITEABLE,
45 .mask_flags = MTD_WRITEABLE,
51 .name = "user_property",
54 .mask_flags = MTD_WRITEABLE,
58 static struct flash_platform_data wzrhpg300nh2_flash_data = {
59 .parts = wzrhpg300nh2_flash_partitions,
60 .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions),
63 static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = {
65 .name = "buffalo:red:diag",
71 static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = {
73 .name = "buffalo:blue:usb",
78 .name = "buffalo:orange:security",
83 .name = "buffalo:green:router",
88 .name = "buffalo:blue:movie_engine_on",
93 .name = "buffalo:blue:movie_engine_off",
99 /* The AOSS button is wmac gpio 12 */
100 static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = {
105 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
112 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
119 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
126 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
132 static void __init wzrhpg300nh2_setup(void)
135 u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000);
136 u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET;
137 /* There is an eth1 but it is not connected to the switch */
139 ath79_register_m25p80_multi(&wzrhpg300nh2_flash_data);
141 ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
142 ath79_register_mdio(0, ~(BIT(0)));
144 ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
145 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
146 ath79_eth0_data.speed = SPEED_1000;
147 ath79_eth0_data.duplex = DUPLEX_FULL;
148 ath79_eth0_data.phy_mask = BIT(0);
150 ath79_register_eth(0);
152 /* gpio13 is usb power. Turn it on. */
153 gpio_request_one(13, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
155 ath79_register_usb();
157 ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
158 wzrhpg300nh2_leds_gpio);
159 ath79_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL,
160 ARRAY_SIZE(wzrhpg300nh2_gpio_keys),
161 wzrhpg300nh2_gpio_keys);
162 ap9x_pci_setup_wmac_led_pin(0, 5);
163 ap9x_pci_setup_wmac_leds(0, wzrhpg300nh2_wmac_leds_gpio,
164 ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio));
166 ap91_pci_init(eeprom, mac0);
169 MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH2, "WZR-HP-G300NH2",
170 "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup);