2 * Buffalo WZR-HP-AG300H board support
4 * Copyright (C) 2011 Felix Fietkau <nbd@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/gpio.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
15 #include <asm/mach-ath79/ath79.h>
18 #include "dev-ap9x-pci.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define WZRHPAG300H_MAC_OFFSET 0x20c
26 #define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */
27 #define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL)
29 static struct mtd_partition wzrhpag300h_flash_partitions[] = {
34 .mask_flags = MTD_WRITEABLE,
43 .mask_flags = MTD_WRITEABLE,
53 .name = "user_property",
56 .mask_flags = MTD_WRITEABLE,
64 static struct flash_platform_data wzrhpag300h_flash_data = {
65 .parts = wzrhpag300h_flash_partitions,
66 .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions),
69 static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
71 .name = "buffalo:red:diag",
77 static struct gpio_led wzrhpag300h_wmac0_leds_gpio[] = {
79 .name = "buffalo:amber:band2g",
84 .name = "buffalo:green:usb",
89 .name = "buffalo:green:band2g",
95 static struct gpio_led wzrhpag300h_wmac1_leds_gpio[] = {
97 .name = "buffalo:green:band5g",
102 .name = "buffalo:green:router",
107 .name = "buffalo:blue:movie_engine",
112 .name = "buffalo:amber:band5g",
118 static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = {
123 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
130 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
136 .code = KEY_WPS_BUTTON,
137 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
141 .desc = "router_auto",
144 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
148 .desc = "router_off",
151 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
155 .desc = "movie_engine",
158 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
164 static void __init wzrhpag300h_setup(void)
166 u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000);
167 u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000);
168 u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET;
169 u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET;
171 ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
172 ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1);
174 ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
176 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
177 ath79_eth0_data.speed = SPEED_1000;
178 ath79_eth0_data.duplex = DUPLEX_FULL;
179 ath79_eth0_data.phy_mask = BIT(0);
181 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
182 ath79_eth1_data.phy_mask = BIT(4);
184 ath79_register_eth(0);
185 ath79_register_eth(1);
187 gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
189 ath79_register_usb();
191 ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
192 wzrhpag300h_leds_gpio);
194 ath79_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL,
195 ARRAY_SIZE(wzrhpag300h_gpio_keys),
196 wzrhpag300h_gpio_keys);
198 ath79_register_m25p80_multi(&wzrhpag300h_flash_data);
200 ap94_pci_init(eeprom1, mac1, eeprom2, mac2);
202 ap9x_pci_setup_wmac_led_pin(0, 1);
203 ap9x_pci_setup_wmac_led_pin(1, 5);
205 ap9x_pci_setup_wmac_leds(0, wzrhpag300h_wmac0_leds_gpio,
206 ARRAY_SIZE(wzrhpag300h_wmac0_leds_gpio));
207 ap9x_pci_setup_wmac_leds(1, wzrhpag300h_wmac1_leds_gpio,
208 ARRAY_SIZE(wzrhpag300h_wmac1_leds_gpio));
211 MIPS_MACHINE(ATH79_MACH_WZR_HP_AG300H, "WZR-HP-AG300H",
212 "Buffalo WZR-HP-AG300H", wzrhpag300h_setup);
214 MIPS_MACHINE(ATH79_MACH_WZR_600DHP, "WZR-600DHP",
215 "Buffalo WZR-600DHP", wzrhpag300h_setup);