2 * TP-LINK TL-WR1043N/ND 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/platform_device.h>
12 #include <linux/rtl8366.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-m25p80.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
23 #include "machtypes.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 static const char *tl_wr1043nd_part_probes
[] = {
44 static struct flash_platform_data tl_wr1043nd_flash_data
= {
45 .part_probes
= tl_wr1043nd_part_probes
,
48 static struct gpio_led tl_wr1043nd_leds_gpio
[] __initdata
= {
50 .name
= "tp-link:green:usb",
51 .gpio
= TL_WR1043ND_GPIO_LED_USB
,
54 .name
= "tp-link:green:system",
55 .gpio
= TL_WR1043ND_GPIO_LED_SYSTEM
,
58 .name
= "tp-link:green:qss",
59 .gpio
= TL_WR1043ND_GPIO_LED_QSS
,
62 .name
= "tp-link:green:wlan",
63 .gpio
= TL_WR1043ND_GPIO_LED_WLAN
,
68 static struct gpio_keys_button tl_wr1043nd_gpio_keys
[] __initdata
= {
73 .debounce_interval
= TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL
,
74 .gpio
= TL_WR1043ND_GPIO_BTN_RESET
,
79 .code
= KEY_WPS_BUTTON
,
80 .debounce_interval
= TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL
,
81 .gpio
= TL_WR1043ND_GPIO_BTN_QSS
,
86 static void tl_wr1043nd_rtl8366rb_hw_reset(bool active
)
89 ath79_device_reset_set(AR71XX_RESET_GE0_PHY
);
91 ath79_device_reset_clear(AR71XX_RESET_GE0_PHY
);
94 static struct rtl8366_platform_data tl_wr1043nd_rtl8366rb_data
= {
95 .gpio_sda
= TL_WR1043ND_GPIO_RTL8366_SDA
,
96 .gpio_sck
= TL_WR1043ND_GPIO_RTL8366_SCK
,
97 .hw_reset
= tl_wr1043nd_rtl8366rb_hw_reset
,
100 static struct platform_device tl_wr1043nd_rtl8366rb_device
= {
101 .name
= RTL8366RB_DRIVER_NAME
,
104 .platform_data
= &tl_wr1043nd_rtl8366rb_data
,
108 static void __init
tl_wr1043nd_setup(void)
110 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
111 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1fff1000);
113 tl_wr1043nd_rtl8366rb_hw_reset(true);
115 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
116 ath79_eth0_data
.mii_bus_dev
= &tl_wr1043nd_rtl8366rb_device
.dev
;
117 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
118 ath79_eth0_data
.speed
= SPEED_1000
;
119 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
120 ath79_eth0_pll_data
.pll_1000
= 0x1a000000;
122 ath79_register_eth(0);
124 ath79_register_usb();
126 ath79_register_m25p80(&tl_wr1043nd_flash_data
);
128 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio
),
129 tl_wr1043nd_leds_gpio
);
131 platform_device_register(&tl_wr1043nd_rtl8366rb_device
);
133 ath79_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL
,
134 ARRAY_SIZE(tl_wr1043nd_gpio_keys
),
135 tl_wr1043nd_gpio_keys
);
137 ath79_register_wmac(eeprom
, mac
);
140 MIPS_MACHINE(ATH79_MACH_TL_WR1043ND
, "TL-WR1043ND", "TP-LINK TL-WR1043ND",