ar71xx: use the tp-link parser on the tp-link boards
[openwrt/openwrt.git] / target / linux / ar71xx / files / 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
23 #define TL_WR741ND_GPIO_BTN_RESET 11
24 #define TL_WR741ND_GPIO_BTN_QSS 12
25
26 #define TL_WR741ND_KEYS_POLL_INTERVAL 20 /* msecs */
27 #define TL_WR741ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741ND_KEYS_POLL_INTERVAL)
28
29 static const char *tl_wr741nd_part_probes[] = {
30 "tp-link",
31 NULL,
32 };
33
34 static struct flash_platform_data tl_wr741nd_flash_data = {
35 .part_probes = tl_wr741nd_part_probes,
36 };
37
38 static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
39 {
40 .name = "tp-link:green:system",
41 .gpio = TL_WR741ND_GPIO_LED_SYSTEM,
42 .active_low = 1,
43 }, {
44 .name = "tp-link:green:qss",
45 .gpio = TL_WR741ND_GPIO_LED_QSS,
46 .active_low = 1,
47 }
48 };
49
50 static struct gpio_keys_button tl_wr741nd_gpio_keys[] __initdata = {
51 {
52 .desc = "reset",
53 .type = EV_KEY,
54 .code = KEY_RESTART,
55 .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
56 .gpio = TL_WR741ND_GPIO_BTN_RESET,
57 .active_low = 1,
58 }, {
59 .desc = "qss",
60 .type = EV_KEY,
61 .code = KEY_WPS_BUTTON,
62 .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = TL_WR741ND_GPIO_BTN_QSS,
64 .active_low = 1,
65 }
66 };
67
68 static void __init tl_wr741nd_setup(void)
69 {
70 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
71 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
72
73 ar71xx_add_device_m25p80(&tl_wr741nd_flash_data);
74
75 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
76 tl_wr741nd_leds_gpio);
77
78 ar71xx_register_gpio_keys_polled(-1, TL_WR741ND_KEYS_POLL_INTERVAL,
79 ARRAY_SIZE(tl_wr741nd_gpio_keys),
80 tl_wr741nd_gpio_keys);
81
82 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
83 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
84
85 ar71xx_add_device_mdio(0, 0x0);
86
87 /* LAN ports */
88 ar71xx_add_device_eth(1);
89
90 /* WAN port */
91 ar71xx_add_device_eth(0);
92
93 ap91_pci_setup_wmac_led_pin(1);
94
95 ap91_pci_init(ee, mac);
96 }
97 MIPS_MACHINE(AR71XX_MACH_TL_WR741ND, "TL-WR741ND", "TP-LINK TL-WR741ND",
98 tl_wr741nd_setup);