OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * TP-LINK RE355/RE450 board support |
||
3 | * |
||
4 | * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * Copyright (c) 2016 Tal Keren <kooolk@gmail.com> |
||
6 | * Copyright (c) 2018 Henryk Heisig <hyniu@o2.pl> |
||
7 | * |
||
8 | * Based on the Qualcomm Atheros AP135/AP136 reference board support code |
||
9 | * Copyright (c) 2012 Qualcomm Atheros |
||
10 | * |
||
11 | * Permission to use, copy, modify, and/or distribute this software for any |
||
12 | * purpose with or without fee is hereby granted, provided that the above |
||
13 | * copyright notice and this permission notice appear in all copies. |
||
14 | * |
||
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
21 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
22 | * |
||
23 | */ |
||
24 | |||
25 | #include <linux/pci.h> |
||
26 | #include <linux/phy.h> |
||
27 | #include <linux/gpio.h> |
||
28 | #include <linux/platform_data/mdio-gpio.h> |
||
29 | #include <linux/platform_device.h> |
||
30 | #include <linux/ar8216_platform.h> |
||
31 | |||
32 | #include <asm/mach-ath79/ath79.h> |
||
33 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
34 | |||
35 | #include "common.h" |
||
36 | #include "dev-ap9x-pci.h" |
||
37 | #include "dev-eth.h" |
||
38 | #include "dev-gpio-buttons.h" |
||
39 | #include "dev-leds-gpio.h" |
||
40 | #include "dev-m25p80.h" |
||
41 | #include "dev-wmac.h" |
||
42 | #include "machtypes.h" |
||
43 | #include "pci.h" |
||
44 | |||
45 | #define RE450_GPIO_LED_SYSTEM 12 |
||
46 | #define RE450_GPIO_LED_WLAN2G 13 |
||
47 | #define RE450_GPIO_LED_WLAN5G 14 |
||
48 | #define RE450_GPIO_LED_LAN_DATA 17 |
||
49 | #define RE450_GPIO_LED_JUMPSTART 21 |
||
50 | #define RE450_GPIO_LED_JUMPSTART_RED 22 |
||
51 | #define RE450_GPIO_LED_LAN_LINK 23 |
||
52 | |||
53 | #define RE450_GPIO_BTN_RESET 18 |
||
54 | #define RE450_GPIO_BTN_LED 19 |
||
55 | #define RE450_GPIO_BTN_JUMPSTART 20 |
||
56 | |||
57 | #define RE450_GPIO_SMI_MDIO 1 |
||
58 | #define RE450_GPIO_SMI_MDC 3 |
||
59 | |||
60 | #define RE450_LAN_PHYADDR 4 |
||
61 | |||
62 | #define RE450_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
63 | #define RE450_KEYS_DEBOUNCE_INTERVAL (3 * RE450_KEYS_POLL_INTERVAL) |
||
64 | |||
65 | #define RE450_WMAC_CALDATA_OFFSET 0x1000 |
||
66 | |||
67 | static const char *tl_re450_part_probes[] = { |
||
68 | "cmdlinepart", |
||
69 | NULL, |
||
70 | }; |
||
71 | |||
72 | static struct flash_platform_data tl_re450_flash_data = { |
||
73 | .part_probes = tl_re450_part_probes, |
||
74 | }; |
||
75 | |||
76 | static struct gpio_led re355_leds_gpio[] __initdata = { |
||
77 | { |
||
78 | .name = "re355:blue:power", |
||
79 | .gpio = RE450_GPIO_LED_SYSTEM, |
||
80 | .active_low = 1, |
||
81 | }, |
||
82 | { |
||
83 | .name = "re355:blue:wlan2g", |
||
84 | .gpio = RE450_GPIO_LED_WLAN2G, |
||
85 | .active_low = 1, |
||
86 | }, |
||
87 | { |
||
88 | .name = "re355:blue:wlan5g", |
||
89 | .gpio = RE450_GPIO_LED_WLAN5G, |
||
90 | .active_low = 1, |
||
91 | }, |
||
92 | { |
||
93 | .name = "re355:blue:wps", |
||
94 | .gpio = RE450_GPIO_LED_JUMPSTART, |
||
95 | }, |
||
96 | { |
||
97 | .name = "re355:red:wps", |
||
98 | .gpio = RE450_GPIO_LED_JUMPSTART_RED, |
||
99 | }, |
||
100 | { |
||
101 | .name = "re355:green:lan_data", |
||
102 | .gpio = RE450_GPIO_LED_LAN_DATA, |
||
103 | .active_low = 1, |
||
104 | }, |
||
105 | { |
||
106 | .name = "re355:green:lan_link", |
||
107 | .gpio = RE450_GPIO_LED_LAN_LINK, |
||
108 | .active_low = 1, |
||
109 | }, |
||
110 | }; |
||
111 | |||
112 | static struct gpio_led re450_leds_gpio[] __initdata = { |
||
113 | { |
||
114 | .name = "re450:blue:power", |
||
115 | .gpio = RE450_GPIO_LED_SYSTEM, |
||
116 | .active_low = 1, |
||
117 | }, |
||
118 | { |
||
119 | .name = "re450:blue:wlan2g", |
||
120 | .gpio = RE450_GPIO_LED_WLAN2G, |
||
121 | .active_low = 1, |
||
122 | }, |
||
123 | { |
||
124 | .name = "re450:blue:wlan5g", |
||
125 | .gpio = RE450_GPIO_LED_WLAN5G, |
||
126 | .active_low = 1, |
||
127 | }, |
||
128 | { |
||
129 | .name = "re450:blue:wps", |
||
130 | .gpio = RE450_GPIO_LED_JUMPSTART, |
||
131 | }, |
||
132 | { |
||
133 | .name = "re450:red:wps", |
||
134 | .gpio = RE450_GPIO_LED_JUMPSTART_RED, |
||
135 | }, |
||
136 | { |
||
137 | .name = "re450:green:lan_data", |
||
138 | .gpio = RE450_GPIO_LED_LAN_DATA, |
||
139 | .active_low = 1, |
||
140 | }, |
||
141 | { |
||
142 | .name = "re450:green:lan_link", |
||
143 | .gpio = RE450_GPIO_LED_LAN_LINK, |
||
144 | .active_low = 1, |
||
145 | }, |
||
146 | }; |
||
147 | |||
148 | static struct gpio_keys_button re450_gpio_keys[] __initdata = { |
||
149 | { |
||
150 | .desc = "Reset button", |
||
151 | .type = EV_KEY, |
||
152 | .code = KEY_WPS_BUTTON, |
||
153 | .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL, |
||
154 | .gpio = RE450_GPIO_BTN_RESET, |
||
155 | .active_low = 1, |
||
156 | }, |
||
157 | { |
||
158 | .desc = "WPS button", |
||
159 | .type = EV_KEY, |
||
160 | .code = KEY_RESTART, |
||
161 | .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL, |
||
162 | .gpio = RE450_GPIO_BTN_JUMPSTART, |
||
163 | .active_low = 1, |
||
164 | }, |
||
165 | { |
||
166 | .desc = "Control LED button", |
||
167 | .type = EV_KEY, |
||
168 | .code = BTN_0, |
||
169 | .debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL, |
||
170 | .gpio = RE450_GPIO_BTN_LED, |
||
171 | .active_low = 1, |
||
172 | }, |
||
173 | }; |
||
174 | |||
175 | static struct mdio_gpio_platform_data re450_mdio = { |
||
176 | .mdc = RE450_GPIO_SMI_MDC, |
||
177 | .mdio = RE450_GPIO_SMI_MDIO, |
||
178 | .phy_mask = ~BIT(RE450_LAN_PHYADDR), |
||
179 | }; |
||
180 | |||
181 | static struct platform_device re450_phy_device = { |
||
182 | .name = "mdio-gpio", |
||
183 | .id = 0, |
||
184 | .dev = { |
||
185 | .platform_data = &re450_mdio, |
||
186 | }, |
||
187 | }; |
||
188 | |||
189 | static void __init rex5x_setup(void) |
||
190 | { |
||
191 | u8 *mac = (u8 *) KSEG1ADDR(0x1f610008); |
||
192 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
193 | u8 tmpmac[ETH_ALEN]; |
||
194 | |||
195 | ath79_register_m25p80(&tl_re450_flash_data); |
||
196 | ath79_register_gpio_keys_polled(-1, RE450_KEYS_POLL_INTERVAL, |
||
197 | ARRAY_SIZE(re450_gpio_keys), |
||
198 | re450_gpio_keys); |
||
199 | |||
200 | ath79_init_mac(tmpmac, mac, -1); |
||
201 | ath79_register_wmac(art + RE450_WMAC_CALDATA_OFFSET, tmpmac); |
||
202 | |||
203 | ath79_register_pci(); |
||
204 | |||
205 | /* MDIO Interface */ |
||
206 | platform_device_register(&re450_phy_device); |
||
207 | |||
208 | ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN); |
||
209 | |||
210 | /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */ |
||
211 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
||
212 | ath79_eth0_data.mii_bus_dev = &re450_phy_device.dev; |
||
213 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
214 | ath79_eth0_data.phy_mask = BIT(RE450_LAN_PHYADDR); |
||
215 | ath79_eth0_pll_data.pll_1000 = 0xa6000000; |
||
216 | ath79_eth0_pll_data.pll_100 = 0xa0000101; |
||
217 | ath79_eth0_pll_data.pll_10 = 0x80001313; |
||
218 | ath79_register_eth(0); |
||
219 | } |
||
220 | |||
221 | static void __init re355_setup(void) |
||
222 | { |
||
223 | rex5x_setup(); |
||
224 | ath79_register_leds_gpio(-1, ARRAY_SIZE(re355_leds_gpio), |
||
225 | re355_leds_gpio); |
||
226 | } |
||
227 | |||
228 | MIPS_MACHINE(ATH79_MACH_RE355, "RE355", "TP-LINK RE355", |
||
229 | re355_setup) |
||
230 | |||
231 | static void __init re450_setup(void) |
||
232 | { |
||
233 | rex5x_setup(); |
||
234 | ath79_register_leds_gpio(-1, ARRAY_SIZE(re450_leds_gpio), |
||
235 | re450_leds_gpio); |
||
236 | } |
||
237 | |||
238 | MIPS_MACHINE(ATH79_MACH_RE450, "RE450", "TP-LINK RE450", |
||
239 | re450_setup) |