ar71xx: add support for TP-Link TL-MR11U
[openwrt.git] / target / linux / ar71xx / files-2.6.39 / arch / mips / ar71xx / mach-wzr-hp-g450h.c
1 /*
2  *  Buffalo WZR-HP-G450G board support
3  *
4  *  Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
5  *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
6  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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 #include <asm/mach-ar71xx/ar71xx.h>
16 #include <asm/mach-ar71xx/gpio.h>
17
18 #include "machtype.h"
19 #include "devices.h"
20 #include "dev-m25p80.h"
21 #include "dev-ap91-pci.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-usb.h"
25
26 #define WZRHPG450H_KEYS_POLL_INTERVAL     20      /* msecs */
27 #define WZRHPG450H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG450H_KEYS_POLL_INTERVAL)
28
29 #ifdef CONFIG_MTD_PARTITIONS
30 static struct mtd_partition wzrhpg450h_partitions[] = {
31         {
32                 .name           = "u-boot",
33                 .offset         = 0,
34                 .size           = 0x0040000,
35                 .mask_flags     = MTD_WRITEABLE,
36         }, {
37                 .name           = "u-boot-env",
38                 .offset         = 0x0040000,
39                 .size           = 0x0010000,
40         }, {
41                 .name           = "ART",
42                 .offset         = 0x0050000,
43                 .size           = 0x0010000,
44                 .mask_flags     = MTD_WRITEABLE,
45         }, {
46                 .name           = "uImage",
47                 .offset         = 0x0060000,
48                 .size           = 0x0100000,
49         }, {
50                 .name           = "rootfs",
51                 .offset         = 0x0160000,
52                 .size           = 0x1e80000,
53         }, {
54                 .name           = "user_property",
55                 .offset         = 0x1fe0000,
56                 .size           = 0x0020000,
57         }, {
58                 .name           = "firmware",
59                 .offset         = 0x0060000,
60                 .size           = 0x1f80000,
61         }
62 };
63 #endif /* CONFIG_MTD_PARTITIONS */
64
65 static struct flash_platform_data wzrhpg450h_flash_data = {
66 #ifdef CONFIG_MTD_PARTITIONS
67         .parts          = wzrhpg450h_partitions,
68         .nr_parts       = ARRAY_SIZE(wzrhpg450h_partitions),
69 #endif
70 };
71
72 static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
73         {
74                 .name           = "buffalo:red:diag",
75                 .gpio           = 14,
76                 .active_low     = 1,
77         },
78         {
79                 .name           = "buffalo:orange:security",
80                 .gpio           = 13,
81                 .active_low     = 1,
82         },
83 };
84
85
86 static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
87         {
88                 .name           = "buffalo:blue:movie_engine",
89                 .gpio           = 13,
90                 .active_low     = 1,
91         },
92         {
93                 .name           = "buffalo:green:router",
94                 .gpio           = 14,
95                 .active_low     = 1,
96         },
97 };
98
99 static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
100         {
101                 .desc           = "reset",
102                 .type           = EV_KEY,
103                 .code           = KEY_RESTART,
104                 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
105                 .gpio           = 6,
106                 .active_low     = 1,
107         }, {
108                 .desc           = "usb",
109                 .type           = EV_KEY,
110                 .code           = BTN_2,
111                 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
112                 .gpio           = 1,
113                 .active_low     = 1,
114         }, {
115                 .desc           = "aoss",
116                 .type           = EV_KEY,
117                 .code           = KEY_WPS_BUTTON,
118                 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
119                 .gpio           = 8,
120                 .active_low     = 1,
121         }, {
122                 .desc           = "movie_engine",
123                 .type           = EV_KEY,
124                 .code           = BTN_6,
125                 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
126                 .gpio           = 7,
127                 .active_low     = 0,
128         }, {
129                 .desc           = "router_off",
130                 .type           = EV_KEY,
131                 .code           = BTN_5,
132                 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
133                 .gpio           = 12,
134                 .active_low     = 0,
135         }
136 };
137
138
139 static void __init wzrhpg450h_init(void)
140 {
141         u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
142         u8 *mac = (u8 *) ee + 2;
143
144         ar71xx_add_device_m25p80_multi(&wzrhpg450h_flash_data);
145
146         ar71xx_add_device_mdio(0, ~BIT(0));
147         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
148         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
149         ar71xx_eth0_data.speed = SPEED_1000;
150         ar71xx_eth0_data.duplex = DUPLEX_FULL;
151         ar71xx_eth0_data.phy_mask = BIT(0);
152
153         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
154                                     wzrhpg450h_leds_gpio);
155
156         ar71xx_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
157                                          ARRAY_SIZE(wzrhpg450h_gpio_keys),
158                                          wzrhpg450h_gpio_keys);
159
160         ar71xx_add_device_eth(0);
161
162         ar71xx_add_device_usb();
163         gpio_request(16, "usb");
164         gpio_direction_output(16, 1);
165
166         ap91_pci_init(ee, NULL);
167         ap91_pci_setup_wmac_led_pin(15);
168         ap91_pci_setup_wmac_leds(wzrhpg450h_wmac_leds_gpio,
169                                  ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
170 }
171
172 MIPS_MACHINE(AR71XX_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
173              wzrhpg450h_init);