2 * TP-Link TL-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 TL_WPA8630_KEYS_POLL_INTERVAL 20
27 #define TL_WPA8630_KEYS_DEBOUNCE_INTERVAL (3 * TL_WPA8630_KEYS_POLL_INTERVAL)
29 #define TL_WPA8630_GPIO_LED_POWER 1
30 #define TL_WPA8630_GPIO_LED_LAN 5
31 #define TL_WPA8630_GPIO_LED_WLAN 19
32 #define TL_WPA8630_GPIO_LED_WLAN5 21
34 #define TL_WPA8630_GPIO_BTN_RESET 2
35 #define TL_WPA8630_GPIO_BTN_RFKILL 8
36 #define TL_WPA8630_GPIO_BTN_LED 6
37 #define TL_WPA8630_GPIO_BTN_PAIR 7
39 #define TL_WPA8630_MAC0_OFFSET 0x0000
40 #define TL_WPA8630_WMAC_CALDATA_OFFSET 0x1000
41 #define TL_WPA8630_PCI_CALDATA_OFFSET 0x5000
43 static const char *tl_wpa8630_part_probes
[] = {
48 static struct flash_platform_data tl_wpa8630_flash_data
= {
49 .part_probes
= tl_wpa8630_part_probes
,
53 static struct gpio_led tl_wpa8630_leds_gpio
[] __initdata
= {
55 .name
= "tl-wpa8630:green:power",
56 .gpio
= TL_WPA8630_GPIO_LED_POWER
,
60 .name
= "tl-wpa8630:green:lan",
61 .gpio
= TL_WPA8630_GPIO_LED_LAN
,
65 .name
= "tl-wpa8630:green:wlan",
66 .gpio
= TL_WPA8630_GPIO_LED_WLAN
,
70 .name
= "tl-wpa8630:green:wlan5",
71 .gpio
= TL_WPA8630_GPIO_LED_WLAN5
,
76 static struct gpio_keys_button tl_wpa8630_gpio_keys
[] __initdata
= {
78 .desc
= "Reset button",
81 .debounce_interval
= TL_WPA8630_KEYS_DEBOUNCE_INTERVAL
,
82 .gpio
= TL_WPA8630_GPIO_BTN_RESET
,
86 .desc
= "RFKILL button",
89 .debounce_interval
= TL_WPA8630_KEYS_DEBOUNCE_INTERVAL
,
90 .gpio
= TL_WPA8630_GPIO_BTN_RFKILL
,
97 .debounce_interval
= TL_WPA8630_KEYS_DEBOUNCE_INTERVAL
,
98 .gpio
= TL_WPA8630_GPIO_BTN_LED
,
105 .debounce_interval
= TL_WPA8630_KEYS_DEBOUNCE_INTERVAL
,
106 .gpio
= TL_WPA8630_GPIO_BTN_PAIR
,
111 /* GMAC0 of the QCA8337 switch is connected to the QCA9563 SoC via SGMII */
112 static struct ar8327_pad_cfg tl_wpa8630_qca8337_pad0_cfg
= {
113 .mode
= AR8327_PAD_MAC_SGMII
,
114 .sgmii_delay_en
= true,
117 static struct ar8327_platform_data tl_wpa8630_qca8337_data
= {
118 .pad0_cfg
= &tl_wpa8630_qca8337_pad0_cfg
,
121 .speed
= AR8327_PORT_SPEED_1000
,
128 static struct mdio_board_info tl_wpa8630_mdio0_info
[] = {
130 .bus_id
= "ag71xx-mdio.0",
132 .platform_data
= &tl_wpa8630_qca8337_data
,
136 static void __init
tl_wpa8630_setup(void)
138 u8
*mac
= (u8
*) KSEG1ADDR(0x1f00fc00);
139 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
141 ath79_register_m25p80(&tl_wpa8630_flash_data
);
143 ath79_init_mac(ath79_eth0_data
.mac_addr
,
144 art
+ TL_WPA8630_MAC0_OFFSET
, 0);
146 platform_device_register(&ath79_mdio0_device
);
148 mdiobus_register_board_info(tl_wpa8630_mdio0_info
,
149 ARRAY_SIZE(tl_wpa8630_mdio0_info
));
151 /* GMAC0 is connected to an AR8337 switch */
152 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
153 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
154 ath79_eth0_data
.phy_mask
= ~BIT(4);
155 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
157 ath79_register_eth(0);
159 ath79_register_wmac(art
+ TL_WPA8630_WMAC_CALDATA_OFFSET
, mac
);
161 ap91_pci_init(art
+ TL_WPA8630_PCI_CALDATA_OFFSET
, NULL
);
163 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wpa8630_leds_gpio
),
164 tl_wpa8630_leds_gpio
);
166 ath79_register_gpio_keys_polled(-1, TL_WPA8630_KEYS_POLL_INTERVAL
,
167 ARRAY_SIZE(tl_wpa8630_gpio_keys
),
168 tl_wpa8630_gpio_keys
);
171 MIPS_MACHINE(ATH79_MACH_TL_WPA8630
, "TL-WPA8630", "TP-Link TL-WPA8630",