2 * TP-Link WPA8630 board support
4 * Copyright (C) 2016 Henryk Heisig <hyniu@o2.pl>
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.
10 #include <linux/platform_device.h>
11 #include <linux/ath9k_platform.h>
12 #include <linux/ar8216_platform.h>
13 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include "dev-m25p80.h"
17 #include "machtypes.h"
19 #include "dev-ap9x-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
26 #define WPA8630_KEYS_POLL_INTERVAL 20
27 #define WPA8630_KEYS_DEBOUNCE_INTERVAL (3 * WPA8630_KEYS_POLL_INTERVAL)
29 #define WPA8630_GPIO_LED_POWER 1
30 #define WPA8630_GPIO_LED_LAN 5
31 #define WPA8630_GPIO_LED_WLAN 19
32 #define WPA8630_GPIO_LED_WLAN5 21
34 #define WPA8630_GPIO_BTN_RESET 2
35 #define WPA8630_GPIO_BTN_RFKILL 8
36 #define WPA8630_GPIO_BTN_0 6
37 #define WPA8630_GPIO_BTN_1 7
39 #define WPA8630_MAC0_OFFSET 0x0000
40 #define WPA8630_WMAC_CALDATA_OFFSET 0x1000
41 #define WPA8630_PCI_CALDATA_OFFSET 0x5000
43 static struct flash_platform_data wpa8630_flash_data
= {
47 static struct gpio_led wpa8630_leds_gpio
[] __initdata
= {
49 .name
= "wpa8630:green:power",
50 .gpio
= WPA8630_GPIO_LED_POWER
,
54 .name
= "wpa8630:green:lan",
55 .gpio
= WPA8630_GPIO_LED_LAN
,
59 .name
= "wpa8630:green:wlan",
60 .gpio
= WPA8630_GPIO_LED_WLAN
,
64 .name
= "wpa8630:green:wlan5",
65 .gpio
= WPA8630_GPIO_LED_WLAN5
,
70 static struct gpio_keys_button wpa8630_gpio_keys
[] __initdata
= {
72 .desc
= "Reset button",
75 .debounce_interval
= WPA8630_KEYS_DEBOUNCE_INTERVAL
,
76 .gpio
= WPA8630_GPIO_BTN_RESET
,
80 .desc
= "RFKILL button",
83 .debounce_interval
= WPA8630_KEYS_DEBOUNCE_INTERVAL
,
84 .gpio
= WPA8630_GPIO_BTN_RFKILL
,
90 .debounce_interval
= WPA8630_KEYS_DEBOUNCE_INTERVAL
,
91 .gpio
= WPA8630_GPIO_BTN_0
,
97 .debounce_interval
= WPA8630_KEYS_DEBOUNCE_INTERVAL
,
98 .gpio
= WPA8630_GPIO_BTN_1
,
103 /* GMAC0 of the QCA8337 switch is connected to the QCA9563 SoC via SGMII */
104 static struct ar8327_pad_cfg wpa8630_qca8337_pad0_cfg
= {
105 .mode
= AR8327_PAD_MAC_SGMII
,
106 .sgmii_delay_en
= true,
109 static struct ar8327_platform_data wpa8630_qca8337_data
= {
110 .pad0_cfg
= &wpa8630_qca8337_pad0_cfg
,
113 .speed
= AR8327_PORT_SPEED_1000
,
120 static struct mdio_board_info wpa8630_mdio0_info
[] = {
122 .bus_id
= "ag71xx-mdio.0",
124 .platform_data
= &wpa8630_qca8337_data
,
128 static void __init
wpa8630_setup(void)
130 u8
*mac
= (u8
*) KSEG1ADDR(0x1f00fc00);
131 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
133 ath79_register_m25p80(&wpa8630_flash_data
);
135 ath79_init_mac(ath79_eth0_data
.mac_addr
,
136 art
+ WPA8630_MAC0_OFFSET
, 0);
138 platform_device_register(&ath79_mdio0_device
);
140 mdiobus_register_board_info(wpa8630_mdio0_info
,
141 ARRAY_SIZE(wpa8630_mdio0_info
));
143 /* GMAC0 is connected to an AR8337 switch */
144 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
145 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
146 ath79_eth0_data
.phy_mask
= ~BIT(4);
147 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
149 ath79_register_eth(0);
151 ath79_register_wmac(art
+ WPA8630_WMAC_CALDATA_OFFSET
, mac
);
153 ap91_pci_init(art
+ WPA8630_PCI_CALDATA_OFFSET
, NULL
);
155 ath79_register_leds_gpio(-1, ARRAY_SIZE(wpa8630_leds_gpio
),
158 ath79_register_gpio_keys_polled(-1, WPA8630_KEYS_POLL_INTERVAL
,
159 ARRAY_SIZE(wpa8630_gpio_keys
),
163 MIPS_MACHINE(ATH79_MACH_WPA8630
, "WPA8630", "TP-Link WPA8630",