ar71xx: wpj588: add missing usb support
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tl-wa7210n-v2.c
1 /*
2  *  TP-LINK TL-WA7210N v2.1 board support
3  *
4  *  Copyright (C) 2011 dongyuqi <729650915@qq.com>
5  *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6  *  Copyright (C) 2014 Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
7  *  Copyright (C) 2014 Alexander List <alex@graz.funkfeuer.at>
8  *  Copyright (C) 2015 Hendrik Frenzel <hfrenzel@scunc.net>
9  *
10  *  rebased on TL-WA7510Nv1 support,
11  *    Copyright (C) 2012 Stefan Helmert <helst_listen@aol.de>
12  *
13  *  This program is free software; you can redistribute it and/or modify it
14  *  under the terms of the GNU General Public License version 2 as published
15  *  by the Free Software Foundation.
16  */
17
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/platform_device.h>
21 #include <linux/gpio.h>
22
23 #include <asm/mach-ath79/ar71xx_regs.h>
24 #include <asm/mach-ath79/ath79.h>
25
26 #include "dev-dsa.h"
27 #include "dev-eth.h"
28 #include "dev-gpio-buttons.h"
29 #include "dev-leds-gpio.h"
30 #include "dev-m25p80.h"
31 #include "dev-wmac.h"
32 #include "machtypes.h"
33 #include "pci.h"
34
35 #include "common.h"
36
37 #define TL_WA7210N_V2_GPIO_BTN_RESET    11
38 #define TL_WA7210N_V2_KEYS_POLL_INT     20
39 #define TL_WA7210N_V2_KEYS_DEBOUNCE_INT (3 * TL_WA7210N_V2_KEYS_POLL_INT)
40
41 #define TL_WA7210N_V2_GPIO_LED_LAN  17
42 #define TL_WA7210N_V2_GPIO_LED_SIG1 0
43 #define TL_WA7210N_V2_GPIO_LED_SIG2 1
44 #define TL_WA7210N_V2_GPIO_LED_SIG3 27
45 #define TL_WA7210N_V2_GPIO_LED_SIG4 26
46
47 #define  TL_WA7210N_V2_GPIO_LNA_EN 28
48
49 static const char *tl_wa7210n_v2_part_probes[] = {
50         "tp-link",
51         NULL,
52 };
53
54 static struct gpio_keys_button tl_wa7210n_v2_gpio_keys[] __initdata = {
55         {
56                 .desc              = "reset",
57                 .type              = EV_KEY,
58                 .code              = KEY_RESTART,
59                 .debounce_interval = TL_WA7210N_V2_KEYS_DEBOUNCE_INT,
60                 .gpio              = TL_WA7210N_V2_GPIO_BTN_RESET,
61                 .active_low        = 0,
62         },
63 };
64
65 static struct gpio_led tl_wa7210n_v2_leds_gpio[] __initdata = {
66         {
67                 .name       = "tp-link:green:lan",
68                 .gpio       = TL_WA7210N_V2_GPIO_LED_LAN,
69                 .active_low = 1,
70         }, {
71                 .name       = "tp-link:green:signal1",
72                 .gpio       = TL_WA7210N_V2_GPIO_LED_SIG1,
73                 .active_low = 0,
74         }, {
75                 .name       = "tp-link:green:signal2",
76                 .gpio       = TL_WA7210N_V2_GPIO_LED_SIG2,
77                 .active_low = 0,
78         }, {
79                 .name       = "tp-link:green:signal3",
80                 .gpio       = TL_WA7210N_V2_GPIO_LED_SIG3,
81                 .active_low = 1,
82         }, {
83                 .name       = "tp-link:green:signal4",
84                 .gpio       = TL_WA7210N_V2_GPIO_LED_SIG4,
85                 .active_low = 1,
86         },
87 };
88
89 static struct flash_platform_data tl_wa7210n_v2_flash_data = {
90         .part_probes    = tl_wa7210n_v2_part_probes,
91 };
92
93 static void __init tl_wa7210n_v2_setup(void)
94 {
95         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
96         u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
97
98         ath79_register_gpio_keys_polled(-1, TL_WA7210N_V2_KEYS_POLL_INT,
99                         ARRAY_SIZE(tl_wa7210n_v2_gpio_keys),
100                         tl_wa7210n_v2_gpio_keys);
101
102         ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa7210n_v2_leds_gpio),
103                         tl_wa7210n_v2_leds_gpio);
104
105         ath79_gpio_function_enable(TL_WA7210N_V2_GPIO_LNA_EN);
106
107         ath79_setup_ar933x_phy4_switch(false, false);
108
109         ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
110         ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
111
112         ath79_register_eth(0);
113         ath79_register_eth(1);
114
115         ath79_register_mdio(0, 0x0);
116
117         ath79_register_wmac(ee, mac);
118
119         ath79_register_m25p80(&tl_wa7210n_v2_flash_data);
120
121         ath79_register_pci();
122 }
123
124 MIPS_MACHINE(ATH79_MACH_TL_WA7210N_V2, "TL-WA7210N-v2", "TP-LINK TL-WA7210N v2",
125         tl_wa7210n_v2_setup);