2 * TP-LINK TL-WR841N/ND v8 board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
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/platform_device.h>
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
22 #include "machtypes.h"
24 #define TL_WR841NV8_GPIO_LED_WLAN 13
25 #define TL_WR841NV8_GPIO_LED_QSS 15
26 #define TL_WR841NV8_GPIO_LED_WAN 18
27 #define TL_WR841NV8_GPIO_LED_LAN1 19
28 #define TL_WR841NV8_GPIO_LED_LAN2 20
29 #define TL_WR841NV8_GPIO_LED_LAN3 21
30 #define TL_WR841NV8_GPIO_LED_LAN4 12
31 #define TL_WR841NV8_GPIO_LED_SYSTEM 14
33 #define TL_WR841NV8_GPIO_BTN_RESET 17
34 #define TL_WR841NV8_GPIO_SW_RFKILL 16
36 #define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL)
39 static const char *tl_wr841n_v8_part_probes[] = {
44 static struct flash_platform_data tl_wr841n_v8_flash_data = {
45 .part_probes = tl_wr841n_v8_part_probes,
48 static struct gpio_led tl_wr841n_v8_leds_gpio[] __initdata = {
50 .name = "tp-link:green:lan1",
51 .gpio = TL_WR841NV8_GPIO_LED_LAN1,
54 .name = "tp-link:green:lan2",
55 .gpio = TL_WR841NV8_GPIO_LED_LAN2,
58 .name = "tp-link:green:lan3",
59 .gpio = TL_WR841NV8_GPIO_LED_LAN3,
62 .name = "tp-link:green:lan4",
63 .gpio = TL_WR841NV8_GPIO_LED_LAN4,
66 .name = "tp-link:green:qss",
67 .gpio = TL_WR841NV8_GPIO_LED_QSS,
70 .name = "tp-link:green:system",
71 .gpio = TL_WR841NV8_GPIO_LED_SYSTEM,
74 .name = "tp-link:green:wan",
75 .gpio = TL_WR841NV8_GPIO_LED_WAN,
78 .name = "tp-link:green:wlan",
79 .gpio = TL_WR841NV8_GPIO_LED_WLAN,
84 static struct gpio_keys_button tl_wr841n_v8_gpio_keys[] __initdata = {
86 .desc = "Reset button",
89 .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = TL_WR841NV8_GPIO_BTN_RESET,
93 .desc = "RFKILL switch",
96 .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
97 .gpio = TL_WR841NV8_GPIO_SW_RFKILL,
102 static void __init tl_wr841n_v8_setup(void)
104 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
105 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
107 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
108 tl_wr841n_v8_leds_gpio);
110 ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
111 ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
112 tl_wr841n_v8_gpio_keys);
114 ath79_register_m25p80(&tl_wr841n_v8_flash_data);
116 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
118 ath79_register_mdio(1, 0x0);
120 ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
121 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
123 /* GMAC0 is connected to the PHY0 of the internal switch */
124 ath79_switch_data.phy4_mii_en = 1;
125 ath79_switch_data.phy_poll_mask = BIT(0);
126 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
127 ath79_eth0_data.phy_mask = BIT(0);
128 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
129 ath79_register_eth(0);
131 /* GMAC1 is connected to the internal switch */
132 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
133 ath79_register_eth(1);
135 ath79_register_wmac(ee, mac);
138 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8",