2 * TP-LINK TL-WR841N/ND v1 board support
4 * Copyright (C) 2009-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/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/platform_device.h>
15 #include <asm/mach-ath79/ath79.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
22 #include "machtypes.h"
25 #define TL_WR841ND_V1_GPIO_LED_SYSTEM 2
26 #define TL_WR841ND_V1_GPIO_LED_QSS_GREEN 4
27 #define TL_WR841ND_V1_GPIO_LED_QSS_RED 5
29 #define TL_WR841ND_V1_GPIO_BTN_RESET 3
30 #define TL_WR841ND_V1_GPIO_BTN_QSS 7
32 #define TL_WR841ND_V1_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL \
34 (3 * TL_WR841ND_V1_KEYS_POLL_INTERVAL)
36 static struct mtd_partition tl_wr841n_v1_partitions[] = {
41 .mask_flags = MTD_WRITEABLE,
54 .mask_flags = MTD_WRITEABLE,
62 static struct flash_platform_data tl_wr841n_v1_flash_data = {
63 .parts = tl_wr841n_v1_partitions,
64 .nr_parts = ARRAY_SIZE(tl_wr841n_v1_partitions),
67 static struct gpio_led tl_wr841n_v1_leds_gpio[] __initdata = {
69 .name = "tp-link:green:system",
70 .gpio = TL_WR841ND_V1_GPIO_LED_SYSTEM,
73 .name = "tp-link:red:qss",
74 .gpio = TL_WR841ND_V1_GPIO_LED_QSS_RED,
76 .name = "tp-link:green:qss",
77 .gpio = TL_WR841ND_V1_GPIO_LED_QSS_GREEN,
81 static struct gpio_keys_button tl_wr841n_v1_gpio_keys[] __initdata = {
86 .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
87 .gpio = TL_WR841ND_V1_GPIO_BTN_RESET,
92 .code = KEY_WPS_BUTTON,
93 .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
94 .gpio = TL_WR841ND_V1_GPIO_BTN_QSS,
99 static struct dsa_chip_data tl_wr841n_v1_dsa_chip = {
100 .port_names[0] = "wan",
101 .port_names[1] = "lan1",
102 .port_names[2] = "lan2",
103 .port_names[3] = "lan3",
104 .port_names[4] = "lan4",
105 .port_names[5] = "cpu",
108 static struct dsa_platform_data tl_wr841n_v1_dsa_data = {
110 .chip = &tl_wr841n_v1_dsa_chip,
113 static void __init tl_wr841n_v1_setup(void)
115 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
117 ath79_register_mdio(0, 0x0);
119 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
120 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
121 ath79_eth0_data.speed = SPEED_100;
122 ath79_eth0_data.duplex = DUPLEX_FULL;
124 ath79_register_eth(0);
125 ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
126 &tl_wr841n_v1_dsa_data);
128 ath79_register_m25p80(&tl_wr841n_v1_flash_data);
130 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v1_leds_gpio),
131 tl_wr841n_v1_leds_gpio);
133 ath79_register_gpio_keys_polled(-1, TL_WR841ND_V1_KEYS_POLL_INTERVAL,
134 ARRAY_SIZE(tl_wr841n_v1_gpio_keys),
135 tl_wr841n_v1_gpio_keys);
136 ath79_register_pci();
139 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V1, "TL-WR841N-v1.5", "TP-LINK TL-WR841N v1",