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/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
16 #include <asm/mips_machine.h>
17 #include <asm/mach-ar71xx/ar71xx.h>
18 #include <asm/mach-ar71xx/gpio.h>
22 #include "dev-ap91-pci.h"
23 #include "dev-gpio-buttons.h"
24 #include "dev-leds-gpio.h"
25 #include "dev-m25p80.h"
29 #define WZRHPG300NH2_MAC_OFFSET 0x20c
30 #define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition wzrhpg300nh2_flash_partitions
[] = {
39 .mask_flags
= MTD_WRITEABLE
,
44 .mask_flags
= MTD_WRITEABLE
,
49 .mask_flags
= MTD_WRITEABLE
,
59 .name
= "user_property",
62 .mask_flags
= MTD_WRITEABLE
,
70 #endif /* CONFIG_MTD_PARTITIONS */
74 static struct flash_platform_data wzrhpg300nh2_flash_data
= {
75 #ifdef CONFIG_MTD_PARTITIONS
76 .parts
= wzrhpg300nh2_flash_partitions
,
77 .nr_parts
= ARRAY_SIZE(wzrhpg300nh2_flash_partitions
),
82 static struct gpio_led wzrhpg300nh2_leds_gpio
[] __initdata
= {
84 .name
= "buffalo:red:diag",
90 static struct gpio_led wzrhpg300nh2_wmac_leds_gpio
[] = {
92 .name
= "buffalo:blue:usb",
97 .name
= "buffalo:green:wireless",
102 .name
= "buffalo:orange:security",
107 .name
= "buffalo:green:router",
112 .name
= "buffalo:blue:movie_engine_on",
117 .name
= "buffalo:blue:movie_engine_off",
123 /* The AOSS button is wmac gpio 12 */
124 static struct gpio_keys_button wzrhpg300nh2_gpio_keys
[] __initdata
= {
129 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
136 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
143 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
150 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
157 static void __init
wzrhpg300nh2_setup(void)
160 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1f051000);
161 u8
*mac0
= eeprom
+ WZRHPG300NH2_MAC_OFFSET
;
162 /* There is an eth1 but it is not connected to the switch */
164 ar71xx_add_device_m25p80_multi(&wzrhpg300nh2_flash_data
);
166 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac0
, 0);
167 ar71xx_add_device_mdio(0, ~(BIT(0)));
169 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac0
, 0);
170 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
171 ar71xx_eth0_data
.speed
= SPEED_1000
;
172 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
173 ar71xx_eth0_data
.phy_mask
= BIT(0);
175 ar71xx_add_device_eth(0);
176 ar71xx_add_device_usb();
177 /* gpio13 is usb power. Turn it on. */
178 gpio_request(13, "usb");
179 gpio_direction_output(13, 1);
181 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio
),
182 wzrhpg300nh2_leds_gpio
);
183 ar71xx_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL
,
184 ARRAY_SIZE(wzrhpg300nh2_gpio_keys
),
185 wzrhpg300nh2_gpio_keys
);
186 ap91_pci_setup_wmac_led_pin(22);
187 ap91_pci_setup_wmac_leds(wzrhpg300nh2_wmac_leds_gpio
,
188 ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio
));
190 ap91_pci_init(eeprom
, mac0
);
193 MIPS_MACHINE(AR71XX_MACH_WZR_HP_AG300H
, "WZR-HP-G300NH2",
194 "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup
);