Root/target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wa901nd-v2.c

1/*
2 * TP-LINK TL-WA901ND v2 board support
3 *
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
6 * Copyright (C) 2011 Jonathan Bennett <jbscience87@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h>
15
16#include <asm/mach-ar71xx/ar71xx.h>
17
18#include "machtype.h"
19#include "devices.h"
20#include "dev-m25p80.h"
21#include "dev-gpio-buttons.h"
22#include "dev-leds-gpio.h"
23#include "dev-ar9xxx-wmac.h"
24
25#define TL_WA901ND_V2_GPIO_LED_QSS 4
26#define TL_WA901ND_V2_GPIO_LED_SYSTEM 2
27#define TL_WA901ND_V2_GPIO_LED_WLAN 9
28
29
30#define TL_WA901ND_V2_GPIO_BTN_RESET 3
31#define TL_WA901ND_V2_GPIO_BTN_QSS 7
32
33#define TL_WA901ND_V2_KEYS_POLL_INTERVAL 20 /* msecs */
34#define TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL \
35                    (3 * TL_WA901ND_V2_KEYS_POLL_INTERVAL)
36#ifdef CONFIG_MTD_PARTITIONS
37static struct mtd_partition tl_wa901nd_v2_partitions[] = {
38    {
39        .name = "u-boot",
40        .offset = 0,
41        .size = 0x020000,
42        .mask_flags = MTD_WRITEABLE,
43    }, {
44        .name = "kernel",
45        .offset = 0x020000,
46        .size = 0x140000,
47    }, {
48        .name = "rootfs",
49        .offset = 0x160000,
50        .size = 0x290000,
51    }, {
52        .name = "art",
53        .offset = 0x3f0000,
54        .size = 0x010000,
55        .mask_flags = MTD_WRITEABLE,
56    }, {
57        .name = "firmware",
58        .offset = 0x020000,
59        .size = 0x3d0000,
60    }
61};
62#endif /* CONFIG_MTD_PARTITIONS */
63
64static struct flash_platform_data tl_wa901nd_v2_flash_data = {
65#ifdef CONFIG_MTD_PARTITIONS
66    .parts = tl_wa901nd_v2_partitions,
67    .nr_parts = ARRAY_SIZE(tl_wa901nd_v2_partitions),
68#endif
69};
70
71static struct gpio_led tl_wa901nd_v2_leds_gpio[] __initdata = {
72    {
73        .name = "tl-wa901nd-v2:green:system",
74        .gpio = TL_WA901ND_V2_GPIO_LED_SYSTEM,
75        .active_low = 1,
76    }, {
77        .name = "tl-wa901nd-v2:green:qss",
78        .gpio = TL_WA901ND_V2_GPIO_LED_QSS,
79    }, {
80        .name = "tl-wa901nd-v2:green:wlan",
81        .gpio = TL_WA901ND_V2_GPIO_LED_WLAN,
82        .active_low = 1,
83    }
84};
85
86static struct gpio_keys_button tl_wa901nd_v2_gpio_keys[] __initdata = {
87    {
88        .desc = "reset",
89        .type = EV_KEY,
90        .code = KEY_RESTART,
91        .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
92        .gpio = TL_WA901ND_V2_GPIO_BTN_RESET,
93        .active_low = 1,
94    }, {
95        .desc = "qss",
96        .type = EV_KEY,
97        .code = KEY_WPS_BUTTON,
98        .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
99        .gpio = TL_WA901ND_V2_GPIO_BTN_QSS,
100        .active_low = 1,
101    }
102};
103
104static void __init tl_wa901nd_v2_setup(void)
105{
106    u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
107    u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
108
109    ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
110
111    ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
112    ar71xx_eth0_data.phy_mask = 0x00001000;
113    ar71xx_add_device_mdio(0x0);
114
115    ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC |
116                     RESET_MODULE_GE0_PHY;
117    ar71xx_add_device_eth(0);
118
119    ar71xx_add_device_m25p80(&tl_wa901nd_v2_flash_data);
120
121    ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_v2_leds_gpio),
122                    tl_wa901nd_v2_leds_gpio);
123
124    ar71xx_register_gpio_keys_polled(-1, TL_WA901ND_V2_KEYS_POLL_INTERVAL,
125                     ARRAY_SIZE(tl_wa901nd_v2_gpio_keys),
126                     tl_wa901nd_v2_gpio_keys);
127
128        ar9xxx_add_device_wmac(eeprom, mac);
129}
130
131MIPS_MACHINE(AR71XX_MACH_TL_WA901ND_V2, "TL-WA901ND-v2",
132         "TP-LINK TL-WA901ND v2", tl_wa901nd_v2_setup);
133

Archive Download this file



interactive