2 * TP-LINK TL-WR940N v4 and v6 board support
4 * Copyright (C) 2016 David Lutz <kpanic@ff3l.net>
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.
11 #include <linux/gpio.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
23 #include "machtypes.h"
26 #define TL_WR940N_V4_GPIO_LED_QSS 3
27 #define TL_WR940N_V4_GPIO_LED_WAN 14
28 #define TL_WR940N_V4_GPIO_LED_WAN_RED 15
29 #define TL_WR940N_V4_GPIO_LED_LAN4 4
30 #define TL_WR940N_V4_GPIO_LED_LAN3 18
31 #define TL_WR940N_V4_GPIO_LED_LAN2 6
32 #define TL_WR940N_V4_GPIO_LED_LAN1 8
33 #define TL_WR940N_V4_GPIO_LED_WLAN 7
34 #define TL_WR940N_V4_GPIO_LED_SYSTEM 5
35 /* WR940N v6 specific GPIO*/
36 #define TL_WR940N_V6_GPIO_LED_DIAG_ORANGE 15
37 #define TL_WR940N_V6_GPIO_LED_WAN_BLUE 14
39 #define TL_WR940N_V4_GPIO_BTN_RESET 1
40 #define TL_WR940N_V4_GPIO_BTN_RFKILL 2
42 #define TL_WR940N_KEYS_POLL_INTERVAL 20
43 #define TL_WR940N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR940N_KEYS_POLL_INTERVAL)
46 static struct gpio_led tl_wr940n_v4_leds_gpio
[] __initdata
= {
48 .name
= "tp-link:blue:qss",
49 .gpio
= TL_WR940N_V4_GPIO_LED_QSS
,
53 .name
= "tp-link:blue:wan",
54 .gpio
= TL_WR940N_V4_GPIO_LED_WAN
,
58 .name
= "tp-link:red:wan",
59 .gpio
= TL_WR940N_V4_GPIO_LED_WAN_RED
,
63 .name
= "tp-link:blue:lan1",
64 .gpio
= TL_WR940N_V4_GPIO_LED_LAN1
,
68 .name
= "tp-link:blue:lan2",
69 .gpio
= TL_WR940N_V4_GPIO_LED_LAN2
,
73 .name
= "tp-link:blue:lan3",
74 .gpio
= TL_WR940N_V4_GPIO_LED_LAN3
,
78 .name
= "tp-link:blue:lan4",
79 .gpio
= TL_WR940N_V4_GPIO_LED_LAN4
,
83 .name
= "tp-link:blue:wlan",
84 .gpio
= TL_WR940N_V4_GPIO_LED_WLAN
,
88 .name
= "tp-link:blue:system",
89 .gpio
= TL_WR940N_V4_GPIO_LED_SYSTEM
,
94 static struct gpio_keys_button tl_wr940n_v4_gpio_keys
[] __initdata
= {
96 .desc
= "Reset button",
99 .debounce_interval
= TL_WR940N_KEYS_DEBOUNCE_INTERVAL
,
100 .gpio
= TL_WR940N_V4_GPIO_BTN_RESET
,
103 .desc
= "RFKILL button",
106 .debounce_interval
= TL_WR940N_KEYS_DEBOUNCE_INTERVAL
,
107 .gpio
= TL_WR940N_V4_GPIO_BTN_RFKILL
,
112 static struct gpio_led tl_wr940n_v6_leds_gpio
[] __initdata
= {
114 .name
= "tp-link:blue:wan",
115 .gpio
= TL_WR940N_V6_GPIO_LED_WAN_BLUE
,
119 .name
= "tp-link:orange:diag",
120 .gpio
= TL_WR940N_V6_GPIO_LED_DIAG_ORANGE
,
126 static const char *tl_wr940n_part_probes
[] = {
131 static struct flash_platform_data tl_wr940n_flash_data
= {
132 .part_probes
= tl_wr940n_part_probes
,
136 static void __init
tl_wr940n_setup(void)
138 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
139 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
141 ath79_register_m25p80(&tl_wr940n_flash_data
);
143 ath79_register_mdio(0, 0x0);
145 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
146 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
148 ath79_switch_data
.phy4_mii_en
= 1;
150 ath79_register_eth(0);
151 ath79_register_eth(1);
153 ath79_register_wmac(ee
, mac
);
157 static void __init
tl_wr940n_v4_setup(void)
161 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr940n_v4_leds_gpio
),
162 tl_wr940n_v4_leds_gpio
);
164 ath79_register_gpio_keys_polled(-1, TL_WR940N_KEYS_POLL_INTERVAL
,
165 ARRAY_SIZE(tl_wr940n_v4_gpio_keys
),
166 tl_wr940n_v4_gpio_keys
);
169 static void __init
tl_wr940n_v6_setup(void)
173 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr940n_v6_leds_gpio
),
174 tl_wr940n_v6_leds_gpio
);
176 ath79_register_gpio_keys_polled(-1, TL_WR940N_KEYS_POLL_INTERVAL
,
177 ARRAY_SIZE(tl_wr940n_v4_gpio_keys
),
178 tl_wr940n_v4_gpio_keys
);
181 MIPS_MACHINE(ATH79_MACH_TL_WR940N_V4
, "TL-WR940N-v4", "TP-LINK TL-WR940N v4",
183 MIPS_MACHINE(ATH79_MACH_TL_WR940N_V6
, "TL-WR940N-v6", "TP-LINK TL-WR940N v6",