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-wr741nd.c
1 /*
2 * TP-LINK TL-WR741ND 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 <asm/mach-ar71xx/ar71xx.h>
12
13 #include "machtype.h"
14 #include "devices.h"
15 #include "dev-m25p80.h"
16 #include "dev-ap91-pci.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19
20 #define TL_WR741ND_GPIO_LED_QSS 0
21 #define TL_WR741ND_GPIO_LED_SYSTEM 1
22 #define TL_WR741ND_GPIO_LED_LAN1 13
23 #define TL_WR741ND_GPIO_LED_LAN2 14
24 #define TL_WR741ND_GPIO_LED_LAN3 15
25 #define TL_WR741ND_GPIO_LED_LAN4 16
26 #define TL_WR741ND_GPIO_LED_WAN 17
27
28 #define TL_WR741ND_GPIO_BTN_RESET 11
29 #define TL_WR741ND_GPIO_BTN_QSS 12
30
31 #define TL_WR741ND_KEYS_POLL_INTERVAL 20 /* msecs */
32 #define TL_WR741ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741ND_KEYS_POLL_INTERVAL)
33
34 static const char *tl_wr741nd_part_probes[] = {
35 "tp-link",
36 NULL,
37 };
38
39 static struct flash_platform_data tl_wr741nd_flash_data = {
40 .part_probes = tl_wr741nd_part_probes,
41 };
42
43 static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
44 {
45 .name = "tp-link:green:lan1",
46 .gpio = TL_WR741ND_GPIO_LED_LAN1,
47 .active_low = 1,
48 }, {
49 .name = "tp-link:green:lan2",
50 .gpio = TL_WR741ND_GPIO_LED_LAN2,
51 .active_low = 1,
52 }, {
53 .name = "tp-link:green:lan3",
54 .gpio = TL_WR741ND_GPIO_LED_LAN3,
55 .active_low = 1,
56 }, {
57 .name = "tp-link:green:lan4",
58 .gpio = TL_WR741ND_GPIO_LED_LAN4,
59 .active_low = 1,
60 }, {
61 .name = "tp-link:green:qss",
62 .gpio = TL_WR741ND_GPIO_LED_QSS,
63 .active_low = 1,
64 }, {
65 .name = "tp-link:green:system",
66 .gpio = TL_WR741ND_GPIO_LED_SYSTEM,
67 .active_low = 1,
68 }, {
69 .name = "tp-link:green:wan",
70 .gpio = TL_WR741ND_GPIO_LED_WAN,
71 .active_low = 1,
72 },
73 };
74
75 static struct gpio_keys_button tl_wr741nd_gpio_keys[] __initdata = {
76 {
77 .desc = "reset",
78 .type = EV_KEY,
79 .code = KEY_RESTART,
80 .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
81 .gpio = TL_WR741ND_GPIO_BTN_RESET,
82 .active_low = 1,
83 }, {
84 .desc = "qss",
85 .type = EV_KEY,
86 .code = KEY_WPS_BUTTON,
87 .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
88 .gpio = TL_WR741ND_GPIO_BTN_QSS,
89 .active_low = 1,
90 }
91 };
92
93 static void __init tl_wr741nd_setup(void)
94 {
95 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
96 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
97
98 ar71xx_add_device_m25p80(&tl_wr741nd_flash_data);
99
100 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
101 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
102 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
103 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
104 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
105
106 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
107 tl_wr741nd_leds_gpio);
108
109 ar71xx_register_gpio_keys_polled(-1, TL_WR741ND_KEYS_POLL_INTERVAL,
110 ARRAY_SIZE(tl_wr741nd_gpio_keys),
111 tl_wr741nd_gpio_keys);
112
113 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 1);
114 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, -1);
115
116 ar71xx_add_device_mdio(0, 0x0);
117
118 /* LAN ports */
119 ar71xx_add_device_eth(1);
120
121 /* WAN port */
122 ar71xx_add_device_eth(0);
123
124 ap91_pci_setup_wmac_led_pin(1);
125
126 ap91_pci_init(ee, mac);
127 }
128 MIPS_MACHINE(AR71XX_MACH_TL_WR741ND, "TL-WR741ND", "TP-LINK TL-WR741ND",
129 tl_wr741nd_setup);