2f4e0c047dfd74d049be728d871a04ddc993eec4
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tl-wa901nd.c
1 /*
2 * TP-LINK TL-WA901N/ND v1 board support
3 *
4 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <asm/mach-ath79/ar71xx_regs.h>
13 #include <asm/mach-ath79/ath79.h>
14
15 #include "common.h"
16 #include "dev-ap9x-pci.h"
17 #include "dev-eth.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "machtypes.h"
22
23 #define TL_WA901ND_GPIO_LED_QSS 0
24 #define TL_WA901ND_GPIO_LED_SYSTEM 1
25 #define TL_WA901ND_GPIO_LED_LAN 13
26
27 #define TL_WA901ND_GPIO_BTN_RESET 11
28 #define TL_WA901ND_GPIO_BTN_QSS 12
29
30 #define TL_WA901ND_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define TL_WA901ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA901ND_KEYS_POLL_INTERVAL)
32
33 static const char *tl_wa901nd_part_probes[] = {
34 "tp-link",
35 NULL,
36 };
37
38 static struct flash_platform_data tl_wa901nd_flash_data = {
39 .part_probes = tl_wa901nd_part_probes,
40 };
41
42 static struct gpio_led tl_wa901nd_leds_gpio[] __initdata = {
43 {
44 .name = "tp-link:green:lan",
45 .gpio = TL_WA901ND_GPIO_LED_LAN,
46 .active_low = 1,
47 }, {
48 .name = "tp-link:green:system",
49 .gpio = TL_WA901ND_GPIO_LED_SYSTEM,
50 .active_low = 1,
51 }, {
52 .name = "tp-link:green:qss",
53 .gpio = TL_WA901ND_GPIO_LED_QSS,
54 .active_low = 1,
55 }
56 };
57
58 static struct gpio_keys_button tl_wa901nd_gpio_keys[] __initdata = {
59 {
60 .desc = "reset",
61 .type = EV_KEY,
62 .code = BTN_0,
63 .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
64 .gpio = TL_WA901ND_GPIO_BTN_RESET,
65 .active_low = 1,
66 }, {
67 .desc = "qss",
68 .type = EV_KEY,
69 .code = BTN_1,
70 .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
71 .gpio = TL_WA901ND_GPIO_BTN_QSS,
72 .active_low = 1,
73 }
74 };
75
76 static void __init tl_wa901nd_setup(void)
77 {
78 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
79 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
80
81 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
82 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
83 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
84 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
85 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
86
87 /*
88 * ath79_eth0 would be the WAN port, but is not connected on
89 * the TL-WA901ND. ath79_eth1 connects to the internal switch chip,
90 * however we have a single LAN port only.
91 */
92 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
93 ath79_register_mdio(0, 0x0);
94 ath79_register_eth(1);
95
96 ath79_register_m25p80(&tl_wa901nd_flash_data);
97
98 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_leds_gpio),
99 tl_wa901nd_leds_gpio);
100
101 ath79_register_gpio_keys_polled(-1, TL_WA901ND_KEYS_POLL_INTERVAL,
102 ARRAY_SIZE(tl_wa901nd_gpio_keys),
103 tl_wa901nd_gpio_keys);
104
105 ap91_pci_init(ee, mac);
106 }
107
108 MIPS_MACHINE(ATH79_MACH_TL_WA901ND, "TL-WA901ND", "TP-LINK TL-WA901ND",
109 tl_wa901nd_setup);