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/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
15 #include <asm/mips_machine.h>
16 #include <asm/mach-ar71xx/ar71xx.h>
17 #include <asm/mach-ar71xx/gpio.h>
21 #include "dev-ap94-pci.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-m25p80.h"
27 #define WZRHPAG300H_MAC_OFFSET 0x20c
28 #define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */
29 #define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL)
31 #ifdef CONFIG_MTD_PARTITIONS
32 static struct mtd_partition wzrhpag300h_flash_partitions[] = {
37 .mask_flags = MTD_WRITEABLE,
42 .mask_flags = MTD_WRITEABLE,
47 .mask_flags = MTD_WRITEABLE,
57 .name = "user_property",
60 .mask_flags = MTD_WRITEABLE,
68 #endif /* CONFIG_MTD_PARTITIONS */
70 static struct flash_platform_data wzrhpag300h_flash_data = {
71 #ifdef CONFIG_MTD_PARTITIONS
72 .parts = wzrhpag300h_flash_partitions,
73 .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions),
77 static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
79 .name = "buffalo:red:diag",
86 static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = {
91 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
98 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
104 .code = KEY_WPS_BUTTON,
105 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
109 .desc = "router_auto",
112 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
116 .desc = "router_off",
119 .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
125 static void __init wzrhpag300h_setup(void)
127 u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000);
128 u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000);
129 u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET;
130 u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET;
132 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac1, 0);
133 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac2, 1);
135 ar71xx_add_device_mdio(0, ~(BIT(0) | BIT(4)));
137 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
138 ar71xx_eth0_data.speed = SPEED_1000;
139 ar71xx_eth0_data.duplex = DUPLEX_FULL;
140 ar71xx_eth0_data.phy_mask = BIT(0);
142 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
143 ar71xx_eth1_data.phy_mask = BIT(4);
145 ar71xx_add_device_eth(0);
146 ar71xx_add_device_eth(1);
148 ar71xx_add_device_usb();
149 gpio_request(2, "usb");
150 gpio_direction_output(2, 1);
152 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
153 wzrhpag300h_leds_gpio);
155 ar71xx_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL,
156 ARRAY_SIZE(wzrhpag300h_gpio_keys),
157 wzrhpag300h_gpio_keys);
159 ar71xx_add_device_m25p80_multi(&wzrhpag300h_flash_data);
161 ap94_pci_init(eeprom1, mac1, eeprom2, mac2);
164 MIPS_MACHINE(AR71XX_MACH_WZR_HP_AG300H, "WZR-HP-AG300H",
165 "Buffalo WZR-HP-AG300H", wzrhpag300h_setup);