2 * Buffalo WZR-450HP2 board support
4 * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
6 * Based on the Qualcomm Atheros AP135/AP136 reference board support code
7 * Copyright (c) 2012 Qualcomm Atheros
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <linux/phy.h>
24 #include <linux/gpio.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/partitions.h>
27 #include <linux/platform_device.h>
28 #include <linux/ar8216_platform.h>
30 #include <asm/mach-ath79/ar71xx_regs.h>
34 #include "dev-gpio-buttons.h"
35 #include "dev-leds-gpio.h"
36 #include "dev-m25p80.h"
40 #include "machtypes.h"
42 #define WZR_450HP2_KEYS_POLL_INTERVAL 20 /* msecs */
43 #define WZR_450HP2_KEYS_DEBOUNCE_INTERVAL (3 * WZR_450HP2_KEYS_POLL_INTERVAL)
45 #define WZR_450HP2_WMAC_CALDATA_OFFSET 0x1000
47 static struct mtd_partition wzrhpg450h_partitions
[] = {
52 .mask_flags
= MTD_WRITEABLE
,
61 .mask_flags
= MTD_WRITEABLE
,
67 .name
= "user_property",
73 static struct flash_platform_data wzr_450hp2_flash_data
= {
74 .parts
= wzrhpg450h_partitions
,
75 .nr_parts
= ARRAY_SIZE(wzrhpg450h_partitions
),
78 static struct gpio_led wzr_450hp2_leds_gpio
[] __initdata
= {
80 .name
= "buffalo:green:wps",
85 .name
= "buffalo:green:system",
90 .name
= "buffalo:green:wlan",
96 static struct gpio_keys_button wzr_450hp2_gpio_keys
[] __initdata
= {
98 .desc
= "Reset button",
101 .debounce_interval
= WZR_450HP2_KEYS_DEBOUNCE_INTERVAL
,
106 .desc
= "RFKILL button",
109 .debounce_interval
= WZR_450HP2_KEYS_DEBOUNCE_INTERVAL
,
115 static const struct ar8327_led_info wzr_450hp2_leds_ar8327
[] = {
116 AR8327_LED_INFO(PHY0_0
, HW
, "buffalo:green:lan1"),
117 AR8327_LED_INFO(PHY1_0
, HW
, "buffalo:green:lan2"),
118 AR8327_LED_INFO(PHY2_0
, HW
, "buffalo:green:lan3"),
119 AR8327_LED_INFO(PHY3_0
, HW
, "buffalo:green:lan4"),
120 AR8327_LED_INFO(PHY4_0
, HW
, "buffalo:green:wan"),
123 /* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
124 static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad0_cfg
= {
125 .mode
= AR8327_PAD_MAC_SGMII
,
126 .sgmii_delay_en
= true,
129 /* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
130 static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad6_cfg
= {
131 .mode
= AR8327_PAD_MAC_RGMII
,
132 .txclk_delay_en
= true,
133 .rxclk_delay_en
= true,
134 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL1
,
135 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
138 static struct ar8327_led_cfg wzr_450hp2_ar8327_led_cfg
= {
139 .led_ctrl0
= 0xcc35cc35,
140 .led_ctrl1
= 0xca35ca35,
141 .led_ctrl2
= 0xc935c935,
142 .led_ctrl3
= 0x03ffff00,
146 static struct ar8327_platform_data wzr_450hp2_ar8327_data
= {
147 .pad0_cfg
= &wzr_450hp2_ar8327_pad0_cfg
,
148 .pad6_cfg
= &wzr_450hp2_ar8327_pad6_cfg
,
151 .speed
= AR8327_PORT_SPEED_1000
,
158 .speed
= AR8327_PORT_SPEED_1000
,
163 .led_cfg
= &wzr_450hp2_ar8327_led_cfg
,
164 .num_leds
= ARRAY_SIZE(wzr_450hp2_leds_ar8327
),
165 .leds
= wzr_450hp2_leds_ar8327
,
168 static struct mdio_board_info wzr_450hp2_mdio0_info
[] = {
170 .bus_id
= "ag71xx-mdio.0",
172 .platform_data
= &wzr_450hp2_ar8327_data
,
176 static void __init
wzr_450hp2_setup(void)
178 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
180 u8
*mac_lan
= mac_wan
+ ETH_ALEN
;
182 ath79_register_m25p80(&wzr_450hp2_flash_data
);
184 ath79_register_leds_gpio(-1, ARRAY_SIZE(wzr_450hp2_leds_gpio
),
185 wzr_450hp2_leds_gpio
);
186 ath79_register_gpio_keys_polled(-1, WZR_450HP2_KEYS_POLL_INTERVAL
,
187 ARRAY_SIZE(wzr_450hp2_gpio_keys
),
188 wzr_450hp2_gpio_keys
);
190 ath79_register_wmac(art
+ WZR_450HP2_WMAC_CALDATA_OFFSET
, mac_lan
);
192 mdiobus_register_board_info(wzr_450hp2_mdio0_info
,
193 ARRAY_SIZE(wzr_450hp2_mdio0_info
));
194 ath79_register_mdio(0, 0x0);
196 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN
);
198 /* GMAC0 is connected to the RMGII interface */
199 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
200 ath79_eth0_data
.phy_mask
= BIT(0);
201 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
202 ath79_eth0_pll_data
.pll_1000
= 0x56000000;
204 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac_wan
, 0);
205 ath79_register_eth(0);
207 /* GMAC1 is connected to the SGMII interface */
208 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
209 ath79_eth1_data
.speed
= SPEED_1000
;
210 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
211 ath79_eth1_pll_data
.pll_1000
= 0x03000101;
213 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac_lan
, 0);
214 ath79_register_eth(1);
216 ath79_register_usb();
219 MIPS_MACHINE(ATH79_MACH_WZR_450HP2
, "WZR-450HP2",
220 "Buffalo WZR-450HP2", wzr_450hp2_setup
);