77262d73945a13b2d84586d8e0978495b200d776
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-tl-wr1043nd.c
1 /*
2 * TP-LINK TL-WR1043ND board support
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
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>
16
17 #include "machtype.h"
18 #include "devices.h"
19 #include "dev-m25p80.h"
20 #include "dev-ar9xxx-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-usb.h"
24
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
29
30 #define TL_WR1043ND_GPIO_BTN_RESET 3
31 #define TL_WR1043ND_GPIO_BTN_QSS 7
32
33 #define TL_WR1043ND_GPIO_RTL8366_SDA 18
34 #define TL_WR1043ND_GPIO_RTL8366_SCK 19
35
36 #define TL_WR1043ND_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043ND_KEYS_POLL_INTERVAL)
38
39 #ifdef CONFIG_MTD_PARTITIONS
40 static struct mtd_partition tl_wr1043nd_partitions[] = {
41 {
42 .name = "u-boot",
43 .offset = 0,
44 .size = 0x020000,
45 .mask_flags = MTD_WRITEABLE,
46 }, {
47 .name = "kernel",
48 .offset = 0x020000,
49 .size = 0x140000,
50 }, {
51 .name = "rootfs",
52 .offset = 0x160000,
53 .size = 0x690000,
54 }, {
55 .name = "art",
56 .offset = 0x7f0000,
57 .size = 0x010000,
58 .mask_flags = MTD_WRITEABLE,
59 }, {
60 .name = "firmware",
61 .offset = 0x020000,
62 .size = 0x7d0000,
63 }
64 };
65 #endif /* CONFIG_MTD_PARTITIONS */
66
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),
71 #endif
72 };
73
74 static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
75 {
76 .name = "tl-wr1043nd:green:usb",
77 .gpio = TL_WR1043ND_GPIO_LED_USB,
78 .active_low = 1,
79 }, {
80 .name = "tl-wr1043nd:green:system",
81 .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
82 .active_low = 1,
83 }, {
84 .name = "tl-wr1043nd:green:qss",
85 .gpio = TL_WR1043ND_GPIO_LED_QSS,
86 .active_low = 0,
87 }, {
88 .name = "tl-wr1043nd:green:wlan",
89 .gpio = TL_WR1043ND_GPIO_LED_WLAN,
90 .active_low = 1,
91 }
92 };
93
94 static struct gpio_keys_button tl_wr1043nd_gpio_keys[] __initdata = {
95 {
96 .desc = "reset",
97 .type = EV_KEY,
98 .code = KEY_RESTART,
99 .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
100 .gpio = TL_WR1043ND_GPIO_BTN_RESET,
101 .active_low = 1,
102 }, {
103 .desc = "qss",
104 .type = EV_KEY,
105 .code = KEY_WPS_BUTTON,
106 .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
107 .gpio = TL_WR1043ND_GPIO_BTN_QSS,
108 .active_low = 1,
109 }
110 };
111
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,
115 };
116
117 static struct platform_device tl_wr1043nd_rtl8366rb_device = {
118 .name = RTL8366RB_DRIVER_NAME,
119 .id = -1,
120 .dev = {
121 .platform_data = &tl_wr1043nd_rtl8366rb_data,
122 }
123 };
124
125 static void __init tl_wr1043nd_setup(void)
126 {
127 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
128 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
129
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;
136
137 ar71xx_add_device_eth(0);
138
139 ar71xx_add_device_usb();
140
141 ar71xx_add_device_m25p80(&tl_wr1043nd_flash_data);
142
143 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
144 tl_wr1043nd_leds_gpio);
145
146 platform_device_register(&tl_wr1043nd_rtl8366rb_device);
147
148 ar71xx_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL,
149 ARRAY_SIZE(tl_wr1043nd_gpio_keys),
150 tl_wr1043nd_gpio_keys);
151
152 ar9xxx_add_device_wmac(eeprom, mac);
153 }
154
155 MIPS_MACHINE(AR71XX_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
156 tl_wr1043nd_setup);