ar71xx: merge dev-ar9{13,34}x-wmac into dev-ar9xxx-wmac
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-tl-wr941nd.c
1 /*
2 * TP-LINK TL-WR941ND board support
3 *
4 * Copyright (C) 2009-2010 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
14 #include <asm/mach-ar71xx/ar71xx.h>
15
16 #include "machtype.h"
17 #include "devices.h"
18 #include "dev-dsa.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
24 #define TL_WR941ND_GPIO_LED_SYSTEM 2
25 #define TL_WR941ND_GPIO_LED_QSS_RED 4
26 #define TL_WR941ND_GPIO_LED_QSS_GREEN 5
27 #define TL_WR941ND_GPIO_LED_WLAN 9
28
29 #define TL_WR941ND_GPIO_BTN_RESET 3
30 #define TL_WR941ND_GPIO_BTN_QSS 7
31
32 #define TL_WR941ND_BUTTONS_POLL_INTERVAL 20
33
34 #ifdef CONFIG_MTD_PARTITIONS
35 static struct mtd_partition tl_wr941nd_partitions[] = {
36 {
37 .name = "u-boot",
38 .offset = 0,
39 .size = 0x020000,
40 .mask_flags = MTD_WRITEABLE,
41 }, {
42 .name = "kernel",
43 .offset = 0x020000,
44 .size = 0x140000,
45 }, {
46 .name = "rootfs",
47 .offset = 0x160000,
48 .size = 0x290000,
49 }, {
50 .name = "art",
51 .offset = 0x3f0000,
52 .size = 0x010000,
53 .mask_flags = MTD_WRITEABLE,
54 }, {
55 .name = "firmware",
56 .offset = 0x020000,
57 .size = 0x3d0000,
58 }
59 };
60 #endif /* CONFIG_MTD_PARTITIONS */
61
62 static struct flash_platform_data tl_wr941nd_flash_data = {
63 #ifdef CONFIG_MTD_PARTITIONS
64 .parts = tl_wr941nd_partitions,
65 .nr_parts = ARRAY_SIZE(tl_wr941nd_partitions),
66 #endif
67 };
68
69 static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
70 {
71 .name = "tl-wr941nd:green:system",
72 .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
73 .active_low = 1,
74 }, {
75 .name = "tl-wr941nd:red:qss",
76 .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
77 }, {
78 .name = "tl-wr941nd:green:qss",
79 .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
80 }, {
81 .name = "tl-wr941nd:green:wlan",
82 .gpio = TL_WR941ND_GPIO_LED_WLAN,
83 .active_low = 1,
84 }
85 };
86
87 static struct gpio_button tl_wr941nd_gpio_buttons[] __initdata = {
88 {
89 .desc = "reset",
90 .type = EV_KEY,
91 .code = KEY_RESTART,
92 .threshold = 3,
93 .gpio = TL_WR941ND_GPIO_BTN_RESET,
94 .active_low = 1,
95 }, {
96 .desc = "qss",
97 .type = EV_KEY,
98 .code = KEY_WPS_BUTTON,
99 .threshold = 3,
100 .gpio = TL_WR941ND_GPIO_BTN_QSS,
101 .active_low = 1,
102 }
103 };
104
105 static struct dsa_chip_data tl_wr941nd_dsa_chip = {
106 .port_names[0] = "wan",
107 .port_names[1] = "lan1",
108 .port_names[2] = "lan2",
109 .port_names[3] = "lan3",
110 .port_names[4] = "lan4",
111 .port_names[5] = "cpu",
112 };
113
114 static struct dsa_platform_data tl_wr941nd_dsa_data = {
115 .nr_chips = 1,
116 .chip = &tl_wr941nd_dsa_chip,
117 };
118
119 static void __init tl_wr941nd_setup(void)
120 {
121 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
122 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
123
124 ar71xx_add_device_mdio(0x0);
125
126 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
127 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
128 ar71xx_eth0_data.speed = SPEED_100;
129 ar71xx_eth0_data.duplex = DUPLEX_FULL;
130
131 ar71xx_add_device_eth(0);
132 ar71xx_add_device_dsa(0, &tl_wr941nd_dsa_data);
133
134 ar71xx_add_device_m25p80(&tl_wr941nd_flash_data);
135
136 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
137 tl_wr941nd_leds_gpio);
138
139 ar71xx_add_device_gpio_buttons(-1, TL_WR941ND_BUTTONS_POLL_INTERVAL,
140 ARRAY_SIZE(tl_wr941nd_gpio_buttons),
141 tl_wr941nd_gpio_buttons);
142 ar9xxx_add_device_wmac(eeprom, mac);
143 }
144
145 MIPS_MACHINE(AR71XX_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
146 tl_wr941nd_setup);