2 * devolo dLAN pro 500 Wireless+ support
4 * Copyright (c) 2013-2015 devolo AG
5 * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <linux/pci.h>
22 #include <linux/phy.h>
23 #include <linux/platform_device.h>
24 #include <linux/ath9k_platform.h>
25 #include <linux/ar8216_platform.h>
26 #include <linux/gpio.h>
28 #include <asm/mach-ath79/ar71xx_regs.h>
31 #include "dev-ap9x-pci.h"
33 #include "dev-gpio-buttons.h"
34 #include "dev-leds-gpio.h"
35 #include "dev-m25p80.h"
38 #include "machtypes.h"
40 #define DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE 13
41 #define DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE 17
42 #define DLAN_PRO_500_WP_GPIO_LED_WLAN_5G 11
43 #define DLAN_PRO_500_WP_GPIO_LED_WLAN_2G 12
44 #define DLAN_PRO_500_WP_GPIO_LED_STATUS 16
45 #define DLAN_PRO_500_WP_GPIO_LED_ETH 14
47 #define DLAN_PRO_500_WP_GPIO_BTN_WPS 20
48 #define DLAN_PRO_500_WP_GPIO_BTN_WLAN 22
49 #define DLAN_PRO_500_WP_GPIO_BTN_DLAN 21
50 #define DLAN_PRO_500_WP_GPIO_BTN_RESET 4
52 #define DLAN_PRO_500_WP_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_500_WP_KEYS_POLL_INTERVAL)
55 #define DLAN_PRO_500_WP_ART_ADDRESS 0x1fff0000
56 #define DLAN_PRO_500_WP_CALDATA_OFFSET 0x1000
57 #define DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET 0x1002
58 #define DLAN_PRO_500_WP_PCIE_CALDATA_OFFSET 0x5000
60 static struct gpio_led dlan_pro_500_wp_leds_gpio
[] __initdata
= {
62 .name
= "devolo:green:status",
63 .gpio
= DLAN_PRO_500_WP_GPIO_LED_STATUS
,
67 .name
= "devolo:green:eth",
68 .gpio
= DLAN_PRO_500_WP_GPIO_LED_ETH
,
72 .name
= "devolo:blue:wlan-5g",
73 .gpio
= DLAN_PRO_500_WP_GPIO_LED_WLAN_5G
,
77 .name
= "devolo:green:wlan-2g",
78 .gpio
= DLAN_PRO_500_WP_GPIO_LED_WLAN_2G
,
83 static struct gpio_keys_button dlan_pro_500_wp_gpio_keys
[] __initdata
= {
85 .desc
= "dLAN button",
88 .debounce_interval
= DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL
,
89 .gpio
= DLAN_PRO_500_WP_GPIO_BTN_DLAN
,
95 .code
= KEY_WPS_BUTTON
,
96 .debounce_interval
= DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL
,
97 .gpio
= DLAN_PRO_500_WP_GPIO_BTN_WPS
,
101 .desc
= "WLAN button",
104 .debounce_interval
= DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL
,
105 .gpio
= DLAN_PRO_500_WP_GPIO_BTN_WLAN
,
109 .desc
= "Reset button",
112 .debounce_interval
= DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL
,
113 .gpio
= DLAN_PRO_500_WP_GPIO_BTN_RESET
,
118 static struct ar8327_pad_cfg dlan_pro_500_wp_ar8327_pad0_cfg
= {
119 .mode
= AR8327_PAD_PHY_RGMII
,
120 .txclk_delay_en
= false,
121 .rxclk_delay_en
= false,
122 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL0
,
123 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL0
,
126 static struct ar8327_led_cfg dlan_pro_500_wp_ar8327_led_cfg
= {
127 .led_ctrl0
= 0x00000000,
128 .led_ctrl1
= 0xc737c737,
129 .led_ctrl2
= 0x00000000,
130 .led_ctrl3
= 0x00c30c00,
134 static struct ar8327_platform_data dlan_pro_500_wp_ar8327_data
= {
135 .pad0_cfg
= &dlan_pro_500_wp_ar8327_pad0_cfg
,
138 .speed
= AR8327_PORT_SPEED_1000
,
143 .led_cfg
= &dlan_pro_500_wp_ar8327_led_cfg
,
146 static struct mdio_board_info dlan_pro_500_wp_mdio0_info
[] = {
148 .bus_id
= "ag71xx-mdio.0",
150 .platform_data
= &dlan_pro_500_wp_ar8327_data
,
154 static void __init
dlan_pro_500_wp_setup(void)
156 u8
*art
= (u8
*) KSEG1ADDR(DLAN_PRO_500_WP_ART_ADDRESS
);
157 u8
*cal
= art
+ DLAN_PRO_500_WP_CALDATA_OFFSET
;
158 u8
*wifi_mac
= art
+ DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET
;
160 ath79_register_m25p80(NULL
);
162 ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_500_wp_leds_gpio
),
163 dlan_pro_500_wp_leds_gpio
);
165 ath79_register_gpio_keys_polled(-1, DLAN_PRO_500_WP_KEYS_POLL_INTERVAL
,
166 ARRAY_SIZE(dlan_pro_500_wp_gpio_keys
),
167 dlan_pro_500_wp_gpio_keys
);
169 gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE
,
170 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
172 gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE
,
173 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
176 ath79_register_wmac(cal
, wifi_mac
);
178 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0
);
180 ath79_register_mdio(1, 0x0);
181 ath79_register_mdio(0, 0x0);
183 mdiobus_register_board_info(dlan_pro_500_wp_mdio0_info
,
184 ARRAY_SIZE(dlan_pro_500_wp_mdio0_info
));
186 /* GMAC0 is connected to a AR7400 PLC in PHY mode */
187 ath79_init_mac(ath79_eth0_data
.mac_addr
, wifi_mac
, 2);
188 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
189 ath79_eth0_pll_data
.pll_1000
= 0x0e000000;
190 ath79_eth0_data
.speed
= SPEED_1000
;
191 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
192 ath79_register_eth(0);
194 /* GMAC1 is connected to the internal switch */
195 ath79_init_mac(ath79_eth1_data
.mac_addr
, wifi_mac
, 1);
196 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
197 ath79_eth1_data
.speed
= SPEED_1000
;
198 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
199 ath79_register_eth(1);
202 MIPS_MACHINE(ATH79_MACH_DLAN_PRO_500_WP
, "dLAN-pro-500-wp", "devolo dLAN pro 500 Wireless+",
203 dlan_pro_500_wp_setup
);