ar71xx: Add support for the OMYlink OMY-X1
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-tl-mr3x20.c
1 /*
2 * TP-LINK TL-MR3220/3420 board support
3 *
4 * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/gpio.h>
12
13 #include <asm/mach-ath79/ath79.h>
14
15 #include "dev-eth.h"
16 #include "dev-ap9x-pci.h"
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
20 #include "dev-usb.h"
21 #include "machtypes.h"
22
23 #define TL_MR3X20_GPIO_LED_QSS 0
24 #define TL_MR3X20_GPIO_LED_SYSTEM 1
25 #define TL_MR3X20_GPIO_LED_3G 8
26
27 #define TL_MR3X20_GPIO_BTN_RESET 11
28 #define TL_MR3X20_GPIO_BTN_QSS 12
29
30 #define TL_MR3X20_GPIO_USB_POWER 6
31
32 #define TL_MR3X20_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
34
35 static const char *tl_mr3x20_part_probes[] = {
36 "tp-link",
37 NULL,
38 };
39
40 static struct flash_platform_data tl_mr3x20_flash_data = {
41 .part_probes = tl_mr3x20_part_probes,
42 };
43
44 static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
45 {
46 .name = "tp-link:green:system",
47 .gpio = TL_MR3X20_GPIO_LED_SYSTEM,
48 .active_low = 1,
49 }, {
50 .name = "tp-link:green:qss",
51 .gpio = TL_MR3X20_GPIO_LED_QSS,
52 .active_low = 1,
53 }, {
54 .name = "tp-link:green:3g",
55 .gpio = TL_MR3X20_GPIO_LED_3G,
56 .active_low = 1,
57 }
58 };
59
60 static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
61 {
62 .desc = "reset",
63 .type = EV_KEY,
64 .code = KEY_RESTART,
65 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
66 .gpio = TL_MR3X20_GPIO_BTN_RESET,
67 .active_low = 1,
68 }, {
69 .desc = "qss",
70 .type = EV_KEY,
71 .code = KEY_WPS_BUTTON,
72 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
73 .gpio = TL_MR3X20_GPIO_BTN_QSS,
74 .active_low = 1,
75 }
76 };
77
78 static void __init tl_ap99_setup(void)
79 {
80 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
81 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
82
83 ath79_register_m25p80(&tl_mr3x20_flash_data);
84
85 ath79_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
86 ARRAY_SIZE(tl_mr3x20_gpio_keys),
87 tl_mr3x20_gpio_keys);
88
89 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
90 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
91
92 ath79_register_mdio(0, 0x0);
93
94 /* LAN ports */
95 ath79_register_eth(1);
96 /* WAN port */
97 ath79_register_eth(0);
98
99 ap91_pci_init(ee, mac);
100 }
101
102 static void __init tl_mr3x20_usb_setup(void)
103 {
104 /* enable power for the USB port */
105 gpio_request_one(TL_MR3X20_GPIO_USB_POWER,
106 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
107 "USB power");
108 ath79_register_usb();
109 }
110
111 static void __init tl_mr3220_setup(void)
112 {
113 tl_ap99_setup();
114
115 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
116 tl_mr3x20_leds_gpio);
117 ap9x_pci_setup_wmac_led_pin(0, 1);
118 tl_mr3x20_usb_setup();
119 }
120
121 MIPS_MACHINE(ATH79_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
122 tl_mr3220_setup);
123
124 static void __init tl_mr3420_setup(void)
125 {
126 tl_ap99_setup();
127
128 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
129 tl_mr3x20_leds_gpio);
130 ap9x_pci_setup_wmac_led_pin(0, 0);
131 tl_mr3x20_usb_setup();
132 }
133
134 MIPS_MACHINE(ATH79_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",
135 tl_mr3420_setup);
136
137 static void __init tl_wr841n_v7_setup(void)
138 {
139 tl_ap99_setup();
140
141 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio) - 1,
142 tl_mr3x20_leds_gpio);
143 ap9x_pci_setup_wmac_led_pin(0, 0);
144 }
145
146 MIPS_MACHINE(ATH79_MACH_TL_WR841N_V7, "TL-WR841N-v7",
147 "TP-LINK TL-WR841N/ND v7", tl_wr841n_v7_setup);