ar71xx: move arch specific files to files-2.6.39
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files-2.6.39 / 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/platform_device.h>
12
13 #include <asm/mach-ar71xx/ar71xx.h>
14
15 #include "machtype.h"
16 #include "devices.h"
17 #include "dev-dsa.h"
18 #include "dev-m25p80.h"
19 #include "dev-ar9xxx-wmac.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22
23 #define TL_WR941ND_GPIO_LED_SYSTEM 2
24 #define TL_WR941ND_GPIO_LED_QSS_RED 4
25 #define TL_WR941ND_GPIO_LED_QSS_GREEN 5
26 #define TL_WR941ND_GPIO_LED_WLAN 9
27
28 #define TL_WR941ND_GPIO_BTN_RESET 3
29 #define TL_WR941ND_GPIO_BTN_QSS 7
30
31 #define TL_WR941ND_KEYS_POLL_INTERVAL 20 /* msecs */
32 #define TL_WR941ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_KEYS_POLL_INTERVAL)
33
34 static const char *tl_wr941nd_part_probes[] = {
35 "tp-link",
36 NULL,
37 };
38
39 static struct flash_platform_data tl_wr941nd_flash_data = {
40 .part_probes = tl_wr941nd_part_probes,
41 };
42
43 static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
44 {
45 .name = "tp-link:green:system",
46 .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
47 .active_low = 1,
48 }, {
49 .name = "tp-link:red:qss",
50 .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
51 }, {
52 .name = "tp-link:green:qss",
53 .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
54 }, {
55 .name = "tp-link:green:wlan",
56 .gpio = TL_WR941ND_GPIO_LED_WLAN,
57 .active_low = 1,
58 }
59 };
60
61 static struct gpio_keys_button tl_wr941nd_gpio_keys[] __initdata = {
62 {
63 .desc = "reset",
64 .type = EV_KEY,
65 .code = KEY_RESTART,
66 .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
67 .gpio = TL_WR941ND_GPIO_BTN_RESET,
68 .active_low = 1,
69 }, {
70 .desc = "qss",
71 .type = EV_KEY,
72 .code = KEY_WPS_BUTTON,
73 .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
74 .gpio = TL_WR941ND_GPIO_BTN_QSS,
75 .active_low = 1,
76 }
77 };
78
79 static struct dsa_chip_data tl_wr941nd_dsa_chip = {
80 .port_names[0] = "wan",
81 .port_names[1] = "lan1",
82 .port_names[2] = "lan2",
83 .port_names[3] = "lan3",
84 .port_names[4] = "lan4",
85 .port_names[5] = "cpu",
86 };
87
88 static struct dsa_platform_data tl_wr941nd_dsa_data = {
89 .nr_chips = 1,
90 .chip = &tl_wr941nd_dsa_chip,
91 };
92
93 static void __init tl_wr941nd_setup(void)
94 {
95 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
96 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
97
98 ar71xx_add_device_mdio(0, 0x0);
99
100 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
101 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
102 ar71xx_eth0_data.speed = SPEED_100;
103 ar71xx_eth0_data.duplex = DUPLEX_FULL;
104
105 ar71xx_add_device_eth(0);
106 ar71xx_add_device_dsa(&ar71xx_eth0_device.dev, &ar71xx_mdio0_device.dev,
107 &tl_wr941nd_dsa_data);
108
109 ar71xx_add_device_m25p80(&tl_wr941nd_flash_data);
110
111 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
112 tl_wr941nd_leds_gpio);
113
114 ar71xx_register_gpio_keys_polled(-1, TL_WR941ND_KEYS_POLL_INTERVAL,
115 ARRAY_SIZE(tl_wr941nd_gpio_keys),
116 tl_wr941nd_gpio_keys);
117 ar9xxx_add_device_wmac(eeprom, mac);
118 }
119
120 MIPS_MACHINE(AR71XX_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
121 tl_wr941nd_setup);