2 * TP-LINK TL-WR841N/ND v9
4 * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.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"
25 #define TL_WR841NV9_GPIO_LED_WLAN 13
26 #define TL_WR841NV9_GPIO_LED_QSS 3
27 #define TL_WR841NV9_GPIO_LED_WAN 4
28 #define TL_WR841NV9_GPIO_LED_LAN1 16
29 #define TL_WR841NV9_GPIO_LED_LAN2 15
30 #define TL_WR841NV9_GPIO_LED_LAN3 14
31 #define TL_WR841NV9_GPIO_LED_LAN4 11
33 #define TL_WR841NV9_GPIO_BTN_RESET 12
34 #define TL_WR841NV9_GPIO_BTN_WIFI 17
36 #define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
39 static const char *tl_wr841n_v9_part_probes[] = {
44 static struct flash_platform_data tl_wr841n_v9_flash_data = {
45 .part_probes = tl_wr841n_v9_part_probes,
48 static struct gpio_led tl_wr841n_v9_leds_gpio[] __initdata = {
50 .name = "tp-link:green:lan1",
51 .gpio = TL_WR841NV9_GPIO_LED_LAN1,
54 .name = "tp-link:green:lan2",
55 .gpio = TL_WR841NV9_GPIO_LED_LAN2,
58 .name = "tp-link:green:lan3",
59 .gpio = TL_WR841NV9_GPIO_LED_LAN3,
62 .name = "tp-link:green:lan4",
63 .gpio = TL_WR841NV9_GPIO_LED_LAN4,
66 .name = "tp-link:green:qss",
67 .gpio = TL_WR841NV9_GPIO_LED_QSS,
70 .name = "tp-link:green:wan",
71 .gpio = TL_WR841NV9_GPIO_LED_WAN,
74 .name = "tp-link:green:wlan",
75 .gpio = TL_WR841NV9_GPIO_LED_WLAN,
80 static struct gpio_keys_button tl_wr841n_v9_gpio_keys[] __initdata = {
82 .desc = "Reset button",
85 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
86 .gpio = TL_WR841NV9_GPIO_BTN_RESET,
89 .desc = "WIFI button",
92 .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
93 .gpio = TL_WR841NV9_GPIO_BTN_WIFI,
99 static void __init tl_ap143_setup(void)
101 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
102 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
105 ath79_register_m25p80(&tl_wr841n_v9_flash_data);
107 ath79_setup_ar933x_phy4_switch(false, false);
109 ath79_register_mdio(0, 0x0);
112 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
113 ath79_eth1_data.duplex = DUPLEX_FULL;
114 ath79_switch_data.phy_poll_mask |= BIT(4);
115 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
116 ath79_register_eth(1);
119 ath79_switch_data.phy4_mii_en = 1;
120 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
121 ath79_eth0_data.duplex = DUPLEX_FULL;
122 ath79_eth0_data.speed = SPEED_100;
123 ath79_eth0_data.phy_mask = BIT(4);
124 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
125 ath79_register_eth(0);
127 ath79_init_mac(tmpmac, mac, 0);
128 ath79_register_wmac(ee, tmpmac);
131 static void __init tl_wr841n_v9_setup(void)
135 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v9_leds_gpio),
136 tl_wr841n_v9_leds_gpio);
138 ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
139 ARRAY_SIZE(tl_wr841n_v9_gpio_keys),
140 tl_wr841n_v9_gpio_keys);
143 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V9, "TL-WR841N-v9", "TP-LINK TL-WR841N/ND v9",