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:orange:security",
102 .name
= "buffalo:green:router",
107 .name
= "buffalo:blue:movie_engine_on",
112 .name
= "buffalo:blue:movie_engine_off",
118 /* The AOSS button is wmac gpio 12 */
119 static struct gpio_keys_button wzrhpg300nh2_gpio_keys
[] __initdata
= {
124 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
131 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
138 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
145 .debounce_interval
= WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL
,
152 static void __init
wzrhpg300nh2_setup(void)
155 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1f051000);
156 u8
*mac0
= eeprom
+ WZRHPG300NH2_MAC_OFFSET
;
157 /* There is an eth1 but it is not connected to the switch */
159 ar71xx_add_device_m25p80_multi(&wzrhpg300nh2_flash_data
);
161 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac0
, 0);
162 ar71xx_add_device_mdio(0, ~(BIT(0)));
164 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac0
, 0);
165 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
166 ar71xx_eth0_data
.speed
= SPEED_1000
;
167 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
168 ar71xx_eth0_data
.phy_mask
= BIT(0);
170 ar71xx_add_device_eth(0);
171 ar71xx_add_device_usb();
172 /* gpio13 is usb power. Turn it on. */
173 gpio_request(13, "usb");
174 gpio_direction_output(13, 1);
176 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio
),
177 wzrhpg300nh2_leds_gpio
);
178 ar71xx_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL
,
179 ARRAY_SIZE(wzrhpg300nh2_gpio_keys
),
180 wzrhpg300nh2_gpio_keys
);
181 ap91_pci_setup_wmac_led_pin(5);
182 ap91_pci_setup_wmac_leds(wzrhpg300nh2_wmac_leds_gpio
,
183 ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio
));
185 ap91_pci_init(eeprom
, mac0
);
188 MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH2
, "WZR-HP-G300NH2",
189 "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup
);