ar71xx: add support for the TP-Link TL-WA901ND v2 board
[oweals/openwrt.git] / 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-ar913x-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_BUTTONS_POLL_INTERVAL     20
34
35 #ifdef CONFIG_MTD_PARTITIONS
36 static struct mtd_partition tl_wa901nd_v2_partitions[] = {
37         {
38                 .name           = "u-boot",
39                 .offset         = 0,
40                 .size           = 0x020000,
41                 .mask_flags     = MTD_WRITEABLE,
42         }, {
43                 .name           = "kernel",
44                 .offset         = 0x020000,
45                 .size           = 0x140000,
46         }, {
47                 .name           = "rootfs",
48                 .offset         = 0x160000,
49                 .size           = 0x290000,
50         }, {
51                 .name           = "art",
52                 .offset         = 0x3f0000,
53                 .size           = 0x010000,
54                 .mask_flags     = MTD_WRITEABLE,
55         }, {
56                 .name           = "firmware",
57                 .offset         = 0x020000,
58                 .size           = 0x3d0000,
59         }
60 };
61 #endif /* CONFIG_MTD_PARTITIONS */
62
63 static struct flash_platform_data tl_wa901nd_v2_flash_data = {
64 #ifdef CONFIG_MTD_PARTITIONS
65         .parts          = tl_wa901nd_v2_partitions,
66         .nr_parts       = ARRAY_SIZE(tl_wa901nd_v2_partitions),
67 #endif
68 };
69
70 static struct gpio_led tl_wa901nd_v2_leds_gpio[] __initdata = {
71         {
72                 .name           = "tl-wa901nd-v2:green:system",
73                 .gpio           = TL_WA901ND_V2_GPIO_LED_SYSTEM,
74                 .active_low     = 1,
75         }, {
76                 .name           = "tl-wa901nd-v2:green:qss",
77                 .gpio           = TL_WA901ND_V2_GPIO_LED_QSS,
78         }, {
79                 .name           = "tl-wa901nd-v2:green:wlan",
80                 .gpio           = TL_WA901ND_V2_GPIO_LED_WLAN,
81                 .active_low     = 1,
82         }
83 };
84
85 static struct gpio_button tl_wa901nd_v2_gpio_buttons[] __initdata = {
86         {
87                 .desc           = "reset",
88                 .type           = EV_KEY,
89                 .code           = KEY_RESTART,
90                 .threshold      = 3,
91                 .gpio           = TL_WA901ND_V2_GPIO_BTN_RESET,
92                 .active_low     = 1,
93         }, {
94                 .desc           = "qss",
95                 .type           = EV_KEY,
96                 .code           = KEY_WPS_BUTTON,
97                 .threshold      = 3,
98                 .gpio           = TL_WA901ND_V2_GPIO_BTN_QSS,
99                 .active_low     = 1,
100         }
101 };
102
103 static void __init tl_wa901nd_v2_setup(void)
104 {
105         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
106         u8 *eeprom  = (u8 *) KSEG1ADDR(0x1fff1000);
107
108         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
109
110         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
111         ar71xx_eth0_data.phy_mask = 0x00001000;
112         ar71xx_add_device_mdio(0x0);
113
114         ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC |
115                                      RESET_MODULE_GE0_PHY;
116         ar71xx_add_device_eth(0);
117
118         ar71xx_add_device_m25p80(&tl_wa901nd_v2_flash_data);
119
120         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_v2_leds_gpio),
121                                         tl_wa901nd_v2_leds_gpio);
122
123         ar71xx_add_device_gpio_buttons(-1, TL_WA901ND_V2_BUTTONS_POLL_INTERVAL,
124                                         ARRAY_SIZE(tl_wa901nd_v2_gpio_buttons),
125                                         tl_wa901nd_v2_gpio_buttons);
126
127         ar913x_add_device_wmac(eeprom, mac);
128 }
129
130 MIPS_MACHINE(AR71XX_MACH_TL_WA901ND_V2, "TL-WA901ND-v2",
131              "TP-LINK TL-WA901ND v2", tl_wa901nd_v2_setup);