2 * TP-LINK RE355/RE450 board support
4 * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (c) 2016 Tal Keren <kooolk@gmail.com>
6 * Copyright (c) 2018 Henryk Heisig <hyniu@o2.pl>
8 * Based on the Qualcomm Atheros AP135/AP136 reference board support code
9 * Copyright (c) 2012 Qualcomm Atheros
11 * Permission to use, copy, modify, and/or distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 #include <linux/pci.h>
26 #include <linux/phy.h>
27 #include <linux/gpio.h>
28 #include <linux/platform_data/mdio-gpio.h>
29 #include <linux/platform_device.h>
30 #include <linux/ar8216_platform.h>
32 #include <asm/mach-ath79/ath79.h>
33 #include <asm/mach-ath79/ar71xx_regs.h>
36 #include "dev-ap9x-pci.h"
38 #include "dev-gpio-buttons.h"
39 #include "dev-leds-gpio.h"
40 #include "dev-m25p80.h"
42 #include "machtypes.h"
45 #define RE450_GPIO_LED_SYSTEM 12
46 #define RE450_GPIO_LED_WLAN2G 13
47 #define RE450_GPIO_LED_WLAN5G 14
48 #define RE450_GPIO_LED_LAN_DATA 17
49 #define RE450_GPIO_LED_JUMPSTART 21
50 #define RE450_GPIO_LED_JUMPSTART_RED 22
51 #define RE450_GPIO_LED_LAN_LINK 23
53 #define RE450_GPIO_BTN_RESET 18
54 #define RE450_GPIO_BTN_LED 19
55 #define RE450_GPIO_BTN_JUMPSTART 20
57 #define RE450_GPIO_SMI_MDIO 1
58 #define RE450_GPIO_SMI_MDC 3
60 #define RE450_LAN_PHYADDR 4
62 #define RE450_KEYS_POLL_INTERVAL 20 /* msecs */
63 #define RE450_KEYS_DEBOUNCE_INTERVAL (3 * RE450_KEYS_POLL_INTERVAL)
65 #define RE450_WMAC_CALDATA_OFFSET 0x1000
67 static const char *tl_re450_part_probes[] = {
72 static struct flash_platform_data tl_re450_flash_data = {
73 .part_probes = tl_re450_part_probes,
76 static struct gpio_led re355_leds_gpio[] __initdata = {
78 .name = "re355:blue:power",
79 .gpio = RE450_GPIO_LED_SYSTEM,
83 .name = "re355:blue:wlan2g",
84 .gpio = RE450_GPIO_LED_WLAN2G,
88 .name = "re355:blue:wlan5g",
89 .gpio = RE450_GPIO_LED_WLAN5G,
93 .name = "re355:blue:wps",
94 .gpio = RE450_GPIO_LED_JUMPSTART,
97 .name = "re355:red:wps",
98 .gpio = RE450_GPIO_LED_JUMPSTART_RED,
101 .name = "re355:green:lan_data",
102 .gpio = RE450_GPIO_LED_LAN_DATA,
106 .name = "re355:green:lan_link",
107 .gpio = RE450_GPIO_LED_LAN_LINK,
112 static struct gpio_led re450_leds_gpio[] __initdata = {
114 .name = "re450:blue:power",
115 .gpio = RE450_GPIO_LED_SYSTEM,
119 .name = "re450:blue:wlan2g",
120 .gpio = RE450_GPIO_LED_WLAN2G,
124 .name = "re450:blue:wlan5g",
125 .gpio = RE450_GPIO_LED_WLAN5G,
129 .name = "re450:blue:wps",
130 .gpio = RE450_GPIO_LED_JUMPSTART,
133 .name = "re450:red:wps",
134 .gpio = RE450_GPIO_LED_JUMPSTART_RED,
137 .name = "re450:green:lan_data",
138 .gpio = RE450_GPIO_LED_LAN_DATA,
142 .name = "re450:green:lan_link",
143 .gpio = RE450_GPIO_LED_LAN_LINK,
148 static struct gpio_keys_button re450_gpio_keys[] __initdata = {
150 .desc = "Reset button",
152 .code = KEY_WPS_BUTTON,
153 .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
154 .gpio = RE450_GPIO_BTN_RESET,
158 .desc = "WPS button",
161 .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
162 .gpio = RE450_GPIO_BTN_JUMPSTART,
166 .desc = "Control LED button",
169 .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
170 .gpio = RE450_GPIO_BTN_LED,
175 static struct mdio_gpio_platform_data re450_mdio = {
176 .mdc = RE450_GPIO_SMI_MDC,
177 .mdio = RE450_GPIO_SMI_MDIO,
178 .phy_mask = ~BIT(RE450_LAN_PHYADDR),
181 static struct platform_device re450_phy_device = {
185 .platform_data = &re450_mdio,
189 static void __init rex5x_setup(void)
191 u8 *mac = (u8 *) KSEG1ADDR(0x1f610008);
192 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
195 ath79_register_m25p80(&tl_re450_flash_data);
196 ath79_register_gpio_keys_polled(-1, RE450_KEYS_POLL_INTERVAL,
197 ARRAY_SIZE(re450_gpio_keys),
200 ath79_init_mac(tmpmac, mac, -1);
201 ath79_register_wmac(art + RE450_WMAC_CALDATA_OFFSET, tmpmac);
203 ath79_register_pci();
206 platform_device_register(&re450_phy_device);
208 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
210 /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
211 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
212 ath79_eth0_data.mii_bus_dev = &re450_phy_device.dev;
213 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
214 ath79_eth0_data.phy_mask = BIT(RE450_LAN_PHYADDR);
215 ath79_eth0_pll_data.pll_1000 = 0xa6000000;
216 ath79_eth0_pll_data.pll_100 = 0xa0000101;
217 ath79_eth0_pll_data.pll_10 = 0x80001313;
218 ath79_register_eth(0);
221 static void __init re355_setup(void)
224 ath79_register_leds_gpio(-1, ARRAY_SIZE(re355_leds_gpio),
228 MIPS_MACHINE(ATH79_MACH_RE355, "RE355", "TP-LINK RE355",
231 static void __init re450_setup(void)
234 ath79_register_leds_gpio(-1, ARRAY_SIZE(re450_leds_gpio),
238 MIPS_MACHINE(ATH79_MACH_RE450, "RE450", "TP-LINK RE450",