ar71xx: wpa8630: change board name to tl-wpa8630
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tl-wpa8630.c
1 /*
2 * TP-Link TL-WPA8630 board support
3 *
4 * Copyright (C) 2016 Henryk Heisig <hyniu@o2.pl>
5 *
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.
9 */
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>
14
15 #include "common.h"
16 #include "dev-m25p80.h"
17 #include "machtypes.h"
18 #include "pci.h"
19 #include "dev-ap9x-pci.h"
20 #include "dev-eth.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-spi.h"
24 #include "dev-wmac.h"
25
26 #define TL_WPA8630_KEYS_POLL_INTERVAL 20
27 #define TL_WPA8630_KEYS_DEBOUNCE_INTERVAL (3 * TL_WPA8630_KEYS_POLL_INTERVAL)
28
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
33
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
38
39 #define TL_WPA8630_MAC0_OFFSET 0x0000
40 #define TL_WPA8630_WMAC_CALDATA_OFFSET 0x1000
41 #define TL_WPA8630_PCI_CALDATA_OFFSET 0x5000
42
43 static struct flash_platform_data tl_wpa8630_flash_data = {
44 .type = "s25fl064k",
45 };
46
47 static struct gpio_led tl_wpa8630_leds_gpio[] __initdata = {
48 {
49 .name = "tl-wpa8630:green:power",
50 .gpio = TL_WPA8630_GPIO_LED_POWER,
51 .active_low = 1,
52 },
53 {
54 .name = "tl-wpa8630:green:lan",
55 .gpio = TL_WPA8630_GPIO_LED_LAN,
56 .active_low = 1,
57 },
58 {
59 .name = "tl-wpa8630:green:wlan",
60 .gpio = TL_WPA8630_GPIO_LED_WLAN,
61 .active_low = 1,
62 },
63 {
64 .name = "tl-wpa8630:green:wlan5",
65 .gpio = TL_WPA8630_GPIO_LED_WLAN5,
66 .active_low = 1,
67 },
68 };
69
70 static struct gpio_keys_button tl_wpa8630_gpio_keys[] __initdata = {
71 {
72 .desc = "Reset button",
73 .type = EV_KEY,
74 .code = KEY_RESTART,
75 .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = TL_WPA8630_GPIO_BTN_RESET,
77 .active_low = 1,
78 },
79 {
80 .desc = "RFKILL button",
81 .type = EV_KEY,
82 .code = KEY_RFKILL,
83 .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
84 .gpio = TL_WPA8630_GPIO_BTN_RFKILL,
85 .active_low = 1,
86 },
87 {
88 .desc = "LED",
89 .type = EV_KEY,
90 .code = BTN_0,
91 .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
92 .gpio = TL_WPA8630_GPIO_BTN_LED,
93 .active_low = 1,
94 },
95 {
96 .desc = "Pair",
97 .type = EV_KEY,
98 .code = BTN_1,
99 .debounce_interval = TL_WPA8630_KEYS_DEBOUNCE_INTERVAL,
100 .gpio = TL_WPA8630_GPIO_BTN_PAIR,
101 .active_low = 1,
102 },
103 };
104
105 /* GMAC0 of the QCA8337 switch is connected to the QCA9563 SoC via SGMII */
106 static struct ar8327_pad_cfg tl_wpa8630_qca8337_pad0_cfg = {
107 .mode = AR8327_PAD_MAC_SGMII,
108 .sgmii_delay_en = true,
109 };
110
111 static struct ar8327_platform_data tl_wpa8630_qca8337_data = {
112 .pad0_cfg = &tl_wpa8630_qca8337_pad0_cfg,
113 .port0_cfg = {
114 .force_link = 1,
115 .speed = AR8327_PORT_SPEED_1000,
116 .duplex = 1,
117 .txpause = 1,
118 .rxpause = 1,
119 },
120 };
121
122 static struct mdio_board_info tl_wpa8630_mdio0_info[] = {
123 {
124 .bus_id = "ag71xx-mdio.0",
125 .phy_addr = 0,
126 .platform_data = &tl_wpa8630_qca8337_data,
127 },
128 };
129
130 static void __init tl_wpa8630_setup(void)
131 {
132 u8 *mac = (u8 *) KSEG1ADDR(0x1f00fc00);
133 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
134
135 ath79_register_m25p80(&tl_wpa8630_flash_data);
136
137 ath79_init_mac(ath79_eth0_data.mac_addr,
138 art + TL_WPA8630_MAC0_OFFSET, 0);
139
140 platform_device_register(&ath79_mdio0_device);
141
142 mdiobus_register_board_info(tl_wpa8630_mdio0_info,
143 ARRAY_SIZE(tl_wpa8630_mdio0_info));
144
145 /* GMAC0 is connected to an AR8337 switch */
146 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
147 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
148 ath79_eth0_data.phy_mask = ~BIT(4);
149 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
150
151 ath79_register_eth(0);
152
153 ath79_register_wmac(art + TL_WPA8630_WMAC_CALDATA_OFFSET, mac);
154
155 ap91_pci_init(art + TL_WPA8630_PCI_CALDATA_OFFSET, NULL);
156
157 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wpa8630_leds_gpio),
158 tl_wpa8630_leds_gpio);
159
160 ath79_register_gpio_keys_polled(-1, TL_WPA8630_KEYS_POLL_INTERVAL,
161 ARRAY_SIZE(tl_wpa8630_gpio_keys),
162 tl_wpa8630_gpio_keys);
163 }
164
165 MIPS_MACHINE(ATH79_MACH_TL_WPA8630, "TL-WPA8630", "TP-Link TL-WPA8630",
166 tl_wpa8630_setup);