2 * TP-LINK TL-WR1043ND board support
4 * Copyright (C) 2009 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>
14 #include <linux/rtl8366.h>
15 #include <asm/mach-ar71xx/ar71xx.h>
19 #include "dev-m25p80.h"
20 #include "dev-ar9xxx-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
25 #define TL_WR1043ND_GPIO_LED_USB 1
26 #define TL_WR1043ND_GPIO_LED_SYSTEM 2
27 #define TL_WR1043ND_GPIO_LED_QSS 5
28 #define TL_WR1043ND_GPIO_LED_WLAN 9
30 #define TL_WR1043ND_GPIO_BTN_RESET 3
31 #define TL_WR1043ND_GPIO_BTN_QSS 7
33 #define TL_WR1043ND_GPIO_RTL8366_SDA 18
34 #define TL_WR1043ND_GPIO_RTL8366_SCK 19
36 #define TL_WR1043ND_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043ND_KEYS_POLL_INTERVAL)
39 #ifdef CONFIG_MTD_PARTITIONS
40 static struct mtd_partition tl_wr1043nd_partitions[] = {
45 .mask_flags = MTD_WRITEABLE,
58 .mask_flags = MTD_WRITEABLE,
65 #endif /* CONFIG_MTD_PARTITIONS */
67 static struct flash_platform_data tl_wr1043nd_flash_data = {
68 #ifdef CONFIG_MTD_PARTITIONS
69 .parts = tl_wr1043nd_partitions,
70 .nr_parts = ARRAY_SIZE(tl_wr1043nd_partitions),
74 static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
76 .name = "tp-link:green:usb",
77 .gpio = TL_WR1043ND_GPIO_LED_USB,
80 .name = "tp-link:green:system",
81 .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
84 .name = "tp-link:green:qss",
85 .gpio = TL_WR1043ND_GPIO_LED_QSS,
88 .name = "tp-link:green:wlan",
89 .gpio = TL_WR1043ND_GPIO_LED_WLAN,
94 static struct gpio_keys_button tl_wr1043nd_gpio_keys[] __initdata = {
99 .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
100 .gpio = TL_WR1043ND_GPIO_BTN_RESET,
105 .code = KEY_WPS_BUTTON,
106 .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
107 .gpio = TL_WR1043ND_GPIO_BTN_QSS,
112 static struct rtl8366_platform_data tl_wr1043nd_rtl8366rb_data = {
113 .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
114 .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
117 static struct platform_device tl_wr1043nd_rtl8366rb_device = {
118 .name = RTL8366RB_DRIVER_NAME,
121 .platform_data = &tl_wr1043nd_rtl8366rb_data,
125 static void __init tl_wr1043nd_setup(void)
127 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
128 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
130 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
131 ar71xx_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
132 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
133 ar71xx_eth0_data.speed = SPEED_1000;
134 ar71xx_eth0_data.duplex = DUPLEX_FULL;
135 ar71xx_eth0_pll_data.pll_1000 = 0x1a000000;
137 ar71xx_add_device_eth(0);
139 ar71xx_add_device_usb();
141 ar71xx_add_device_m25p80(&tl_wr1043nd_flash_data);
143 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
144 tl_wr1043nd_leds_gpio);
146 platform_device_register(&tl_wr1043nd_rtl8366rb_device);
148 ar71xx_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL,
149 ARRAY_SIZE(tl_wr1043nd_gpio_keys),
150 tl_wr1043nd_gpio_keys);
152 ar9xxx_add_device_wmac(eeprom, mac);
155 MIPS_MACHINE(AR71XX_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",