imgtec-ci20: genimage config/ u-boot env
[openadk.git] / target / mips / ath79 / patches / 4.1.43 / 0001-openwrt-ath79.patch
blobf3964a4641496cbf87cff648b2a0415349f53b58
1 diff -Nur linux-4.1.43.orig/arch/mips/Kconfig linux-4.1.43/arch/mips/Kconfig
2 --- linux-4.1.43.orig/arch/mips/Kconfig 2017-08-06 01:56:14.000000000 +0200
3 +++ linux-4.1.43/arch/mips/Kconfig 2017-08-06 20:02:15.000000000 +0200
4 @@ -1071,6 +1071,9 @@
5 config MIPS_NILE4
6 bool
8 +config MYLOADER
9 + bool
11 config SYNC_R4K
12 bool
14 diff -Nur linux-4.1.43.orig/arch/mips/Makefile linux-4.1.43/arch/mips/Makefile
15 --- linux-4.1.43.orig/arch/mips/Makefile 2017-08-06 01:56:14.000000000 +0200
16 +++ linux-4.1.43/arch/mips/Makefile 2017-08-06 20:02:15.000000000 +0200
17 @@ -216,6 +216,7 @@
19 libs-$(CONFIG_FW_ARC) += arch/mips/fw/arc/
20 libs-$(CONFIG_FW_CFE) += arch/mips/fw/cfe/
21 +libs-$(CONFIG_MYLOADER) += arch/mips/fw/myloader/
22 libs-$(CONFIG_FW_SNIPROM) += arch/mips/fw/sni/
23 libs-y += arch/mips/fw/lib/
25 diff -Nur linux-4.1.43.orig/arch/mips/ath79/Kconfig linux-4.1.43/arch/mips/ath79/Kconfig
26 --- linux-4.1.43.orig/arch/mips/ath79/Kconfig 2017-08-06 01:56:14.000000000 +0200
27 +++ linux-4.1.43/arch/mips/ath79/Kconfig 2017-08-06 20:02:15.000000000 +0200
28 @@ -2,75 +2,1466 @@
30 menu "Atheros AR71XX/AR724X/AR913X machine selection"
32 +config ATH79_MACH_ALFA_AP96
33 + bool "ALFA Network AP96 board support"
34 + select SOC_AR71XX
35 + select ATH79_DEV_ETH
36 + select ATH79_DEV_GPIO_BUTTONS
37 + select ATH79_DEV_M25P80
38 + select ATH79_DEV_USB
40 +config ATH79_MACH_HORNET_UB
41 + bool "ALFA Network Hornet-UB board support"
42 + select SOC_AR933X
43 + select ATH79_DEV_ETH
44 + select ATH79_DEV_GPIO_BUTTONS
45 + select ATH79_DEV_LEDS_GPIO
46 + select ATH79_DEV_M25P80
47 + select ATH79_DEV_USB
48 + select ATH79_DEV_WMAC
50 +config ATH79_MACH_ALFA_NX
51 + bool "ALFA Network N2/N5 board support"
52 + select SOC_AR724X
53 + select ATH79_DEV_AP9X_PCI if PCI
54 + select ATH79_DEV_ETH
55 + select ATH79_DEV_GPIO_BUTTONS
56 + select ATH79_DEV_LEDS_GPIO
57 + select ATH79_DEV_M25P80
59 +config ATH79_MACH_TUBE2H
60 + bool "ALFA Network Tube2H board support"
61 + select SOC_AR933X
62 + select ATH79_DEV_ETH
63 + select ATH79_DEV_GPIO_BUTTONS
64 + select ATH79_DEV_LEDS_GPIO
65 + select ATH79_DEV_M25P80
66 + select ATH79_DEV_WMAC
68 +config ATH79_MACH_ALL0258N
69 + bool "Allnet ALL0258N support"
70 + select SOC_AR724X
71 + select ATH79_DEV_AP9X_PCI if PCI
72 + select ATH79_DEV_ETH
73 + select ATH79_DEV_GPIO_BUTTONS
74 + select ATH79_DEV_LEDS_GPIO
75 + select ATH79_DEV_M25P80
77 +config ATH79_MACH_ALL0315N
78 + bool "Allnet ALL0315N support"
79 + select SOC_AR724X
80 + select ATH79_DEV_AP9X_PCI if PCI
81 + select ATH79_DEV_ETH
82 + select ATH79_DEV_GPIO_BUTTONS
83 + select ATH79_DEV_LEDS_GPIO
84 + select ATH79_DEV_M25P80
86 +config ATH79_MACH_ANTMINER_S1
87 + bool "Bitmain Antminer S1 support"
88 + select SOC_AR933X
89 + select ATH79_DEV_ETH
90 + select ATH79_DEV_GPIO_BUTTONS
91 + select ATH79_DEV_LEDS_GPIO
92 + select ATH79_DEV_M25P80
93 + select ATH79_DEV_USB
94 + select ATH79_DEV_WMAC
96 +config ATH79_MACH_ANTMINER_S3
97 + bool "Bitmain Antminer S3 support"
98 + select SOC_AR933X
99 + select ATH79_DEV_ETH
100 + select ATH79_DEV_GPIO_BUTTONS
101 + select ATH79_DEV_LEDS_GPIO
102 + select ATH79_DEV_M25P80
103 + select ATH79_DEV_USB
104 + select ATH79_DEV_WMAC
106 +config ATH79_MACH_ARDUINO_YUN
107 + bool "Arduino Yun"
108 + select SOC_AR933X
109 + select ATH79_DEV_ETH
110 + select ATH79_DEV_GPIO_BUTTONS
111 + select ATH79_DEV_LEDS_GPIO
112 + select ATH79_DEV_M25P80
113 + select ATH79_DEV_USB
114 + select ATH79_DEV_WMAC
115 + help
116 + Say 'Y' here if you want your kernel to support the
117 + Arduino Yun.
119 +config ATH79_MACH_AP113
120 + bool "Atheros AP113 board support"
121 + select SOC_AR724X
122 + select ATH79_DEV_M25P80
123 + select ATH79_DEV_PB9X_PCI if PCI
124 + select ATH79_DEV_GPIO_BUTTONS
125 + select ATH79_DEV_LEDS_GPIO
126 + select ATH79_DEV_USB
127 + select ATH79_DEV_ETH
129 config ATH79_MACH_AP121
130 bool "Atheros AP121 reference board"
131 select SOC_AR933X
132 + select ATH79_DEV_ETH
133 + select ATH79_DEV_GPIO_BUTTONS
134 + select ATH79_DEV_LEDS_GPIO
135 + select ATH79_DEV_M25P80
136 + select ATH79_DEV_USB
137 + select ATH79_DEV_WMAC
138 + help
139 + Say 'Y' here if you want your kernel to support the
140 + Atheros AP121 reference board.
142 +config ATH79_MACH_AP132
143 + bool "Atheros AP132 reference board"
144 + select SOC_QCA955X
145 + select ATH79_DEV_GPIO_BUTTONS
146 + select ATH79_DEV_LEDS_GPIO
147 + select ATH79_DEV_M25P80
148 + select ATH79_DEV_USB
149 + select ATH79_DEV_WMAC
150 + help
151 + Say 'Y' here if you want your kernel to support the
152 + Atheros AP132 reference boards.
154 +config ATH79_MACH_AP136
155 + bool "Atheros AP136/AP135 reference board"
156 + select SOC_QCA955X
157 + select ATH79_DEV_GPIO_BUTTONS
158 + select ATH79_DEV_LEDS_GPIO
159 + select ATH79_DEV_NFC
160 + select ATH79_DEV_M25P80
161 + select ATH79_DEV_USB
162 + select ATH79_DEV_WMAC
163 + help
164 + Say 'Y' here if you want your kernel to support the
165 + Atheros AP136 or AP135 reference boards.
167 +config ATH79_MACH_AP143
168 + bool "Atheros AP143 reference board"
169 + select SOC_QCA953X
170 + select ATH79_DEV_GPIO_BUTTONS
171 + select ATH79_DEV_LEDS_GPIO
172 + select ATH79_DEV_SPI
173 + select ATH79_DEV_USB
174 + select ATH79_DEV_WMAC
175 + select ATH79_DEV_ETH
176 + select ATH79_DEV_M25P80
177 + help
178 + Say 'Y' here if you want your kernel to support the
179 + Atheros AP143 reference board.
181 +config ATH79_MACH_AP147
182 + bool "Atheros AP147 reference board"
183 + select SOC_QCA953X
184 + select ATH79_DEV_GPIO_BUTTONS
185 + select ATH79_DEV_LEDS_GPIO
186 + select ATH79_DEV_M25P80
187 + select ATH79_DEV_USB
188 + select ATH79_DEV_WMAC
189 + select ATH79_DEV_AP9X_PCI if PCI
190 + help
191 + Say 'Y' here if you want your kernel to support the
192 + QCA AP147 reference boards.
194 +config ATH79_MACH_AP152
195 + bool "Atheros AP152 reference board"
196 + select SOC_QCA956X
197 + select ATH79_DEV_GPIO_BUTTONS
198 + select ATH79_DEV_LEDS_GPIO
199 + select ATH79_DEV_M25P80
200 + select ATH79_DEV_USB
201 + select ATH79_DEV_WMAC
202 + select ATH79_DEV_AP9X_PCI if PCI
203 + help
204 + Say 'Y' here if you want your kernel to support the
205 + QCA AP152 reference boards.
208 +config ATH79_MACH_AP81
209 + bool "Atheros AP81 reference board"
210 + select SOC_AR913X
211 + select ATH79_DEV_ETH
212 + select ATH79_DEV_GPIO_BUTTONS
213 + select ATH79_DEV_LEDS_GPIO
214 + select ATH79_DEV_M25P80
215 + select ATH79_DEV_USB
216 + select ATH79_DEV_WMAC
217 + help
218 + Say 'Y' here if you want your kernel to support the
219 + Atheros AP81 reference board.
221 +config ATH79_MACH_AP83
222 + bool "Atheros AP83 board support"
223 + select SOC_AR913X
224 + select ATH79_DEV_GPIO_BUTTONS
225 + select ATH79_DEV_LEDS_GPIO
226 + select ATH79_DEV_USB
227 + select ATH79_DEV_WMAC
229 +config ATH79_MACH_AP96
230 + bool "Atheros AP96 board support"
231 + select SOC_AR71XX
232 + select ATH79_DEV_AP9X_PCI if PCI
233 + select ATH79_DEV_ETH
234 + select ATH79_DEV_GPIO_BUTTONS
235 + select ATH79_DEV_LEDS_GPIO
236 + select ATH79_DEV_M25P80
237 + select ATH79_DEV_USB
239 +config ATH79_MACH_DB120
240 + bool "Atheros DB120 reference board"
241 + select SOC_AR934X
242 + select ATH79_DEV_AP9X_PCI if PCI
243 + select ATH79_DEV_ETH
244 + select ATH79_DEV_GPIO_BUTTONS
245 + select ATH79_DEV_LEDS_GPIO
246 + select ATH79_DEV_M25P80
247 + select ATH79_DEV_NFC
248 + select ATH79_DEV_USB
249 + select ATH79_DEV_WMAC
250 + help
251 + Say 'Y' here if you want your kernel to support the
252 + Atheros DB120 reference board.
254 +config ATH79_MACH_PB42
255 + bool "Atheros PB42 board support"
256 + select SOC_AR71XX
257 + select ATH79_DEV_ETH
258 + select ATH79_DEV_GPIO_BUTTONS
259 + select ATH79_DEV_M25P80
261 +config ATH79_MACH_PB44
262 + bool "Atheros PB44 reference board"
263 + select SOC_AR71XX
264 + select ATH79_DEV_ETH
265 + select ATH79_DEV_GPIO_BUTTONS
266 + select ATH79_DEV_LEDS_GPIO
267 + select ATH79_DEV_SPI
268 + select ATH79_DEV_USB
269 + help
270 + Say 'Y' here if you want your kernel to support the
271 + Atheros PB44 reference board.
273 +config ATH79_MACH_PB92
274 + bool "Atheros PB92 board support"
275 + select SOC_AR724X
276 + select ATH79_DEV_ETH
277 + select ATH79_DEV_GPIO_BUTTONS
278 + select ATH79_DEV_LEDS_GPIO
279 + select ATH79_DEV_PB9X_PCI if PCI
280 + select ATH79_DEV_USB
282 +config ATH79_MACH_AW_NR580
283 + bool "AzureWave AW-NR580 board support"
284 + select SOC_AR71XX
285 + select ATH79_DEV_ETH
286 + select ATH79_DEV_GPIO_BUTTONS
287 + select ATH79_DEV_LEDS_GPIO
288 + select ATH79_DEV_M25P80
290 +config ATH79_MACH_F9K1115V2
291 + bool "Belkin AC1750DB board support"
292 + select SOC_QCA955X
293 + select ATH79_DEV_ETH
294 + select ATH79_DEV_GPIO_BUTTONS
295 + select ATH79_DEV_LEDS_GPIO
296 + select ATH79_DEV_M25P80
297 + select ATH79_DEV_USB
298 + select ATH79_DEV_WMAC
300 +config ATH79_MACH_EPG5000
301 + bool "EnGenius EPG5000 board support"
302 + select SOC_QCA955X
303 + select ATH79_DEV_ETH
304 + select ATH79_DEV_GPIO_BUTTONS
305 + select ATH79_DEV_LEDS_GPIO
306 + select ATH79_DEV_M25P80
307 + select ATH79_DEV_USB
308 + select ATH79_DEV_WMAC
309 + select ATH79_NVRAM
311 +config ATH79_MACH_ESR1750
312 + bool "EnGenius ESR1750 board support"
313 + select SOC_QCA955X
314 + select ATH79_DEV_ETH
315 + select ATH79_DEV_GPIO_BUTTONS
316 + select ATH79_DEV_LEDS_GPIO
317 + select ATH79_DEV_M25P80
318 + select ATH79_DEV_USB
319 + select ATH79_DEV_WMAC
321 +config ATH79_MACH_WHR_HP_G300N
322 + bool "Buffalo WHR-HP-G300N board support"
323 + select SOC_AR724X
324 + select ATH79_DEV_AP9X_PCI if PCI
325 + select ATH79_DEV_ETH
326 + select ATH79_DEV_GPIO_BUTTONS
327 + select ATH79_DEV_LEDS_GPIO
328 + select ATH79_DEV_M25P80
330 +config ATH79_MACH_WLAE_AG300N
331 + bool "Buffalo WLAE-AG300N board support"
332 + select SOC_AR71XX
333 + select ATH79_DEV_ETH
334 + select ATH79_DEV_GPIO_BUTTONS
335 + select ATH79_DEV_LEDS_GPIO
336 + select ATH79_DEV_M25P80
338 +config ATH79_MACH_WLR8100
339 + bool "Sitecom WLR-8100 board support"
340 + select SOC_QCA955X
341 + select ATH79_DEV_ETH
342 + select ATH79_DEV_GPIO_BUTTONS
343 + select ATH79_DEV_LEDS_GPIO
344 + select ATH79_DEV_M25P80
345 + select ATH79_DEV_USB
346 + select ATH79_DEV_WMAC
348 +config ATH79_MACH_WZR_HP_AG300H
349 + bool "Buffalo WZR-HP-AG300H board support"
350 + select SOC_AR71XX
351 + select ATH79_DEV_AP9X_PCI if PCI
352 + select ATH79_DEV_ETH
353 + select ATH79_DEV_GPIO_BUTTONS
354 + select ATH79_DEV_LEDS_GPIO
355 + select ATH79_DEV_M25P80
356 + select ATH79_DEV_USB
358 +config ATH79_MACH_WZR_HP_G300NH
359 + bool "Buffalo WZR-HP-G300NH board support"
360 + select SOC_AR913X
361 + select ATH79_DEV_ETH
362 + select ATH79_DEV_GPIO_BUTTONS
363 + select ATH79_DEV_LEDS_GPIO
364 + select ATH79_DEV_USB
365 + select ATH79_DEV_WMAC
366 + select RTL8366_SMI
368 +config ATH79_MACH_WZR_HP_G300NH2
369 + bool "Buffalo WZR-HP-G300NH2 board support"
370 + select SOC_AR724X
371 + select ATH79_DEV_AP9X_PCI if PCI
372 + select ATH79_DEV_ETH
373 + select ATH79_DEV_GPIO_BUTTONS
374 + select ATH79_DEV_LEDS_GPIO
375 + select ATH79_DEV_M25P80
376 + select ATH79_DEV_USB
378 +config ATH79_MACH_WZR_HP_G450H
379 + bool "Buffalo WZR-HP-G450H board support"
380 + select SOC_AR724X
381 + select ATH79_DEV_ETH
382 + select ATH79_DEV_AP9X_PCI if PCI
383 + select ATH79_DEV_GPIO_BUTTONS
384 + select ATH79_DEV_LEDS_GPIO
385 + select ATH79_DEV_M25P80
386 + select ATH79_DEV_USB
388 +config ATH79_MACH_WZR_450HP2
389 + bool "Buffalo WZR-450HP2 board support"
390 + select SOC_QCA955X
391 + select ATH79_DEV_ETH
392 + select ATH79_DEV_GPIO_BUTTONS
393 + select ATH79_DEV_LEDS_GPIO
394 + select ATH79_DEV_M25P80
395 + select ATH79_DEV_USB
396 + select ATH79_DEV_WMAC
398 +config ATH79_MACH_WP543
399 + bool "Compex WP543/WPJ543 board support"
400 + select SOC_AR71XX
401 + select ATH79_DEV_ETH
402 + select ATH79_DEV_GPIO_BUTTONS
403 + select ATH79_DEV_LEDS_GPIO
404 + select ATH79_DEV_M25P80
405 + select ATH79_DEV_USB
406 + select MYLOADER
408 +config ATH79_MACH_WPE72
409 + bool "Compex WPE72/WPE72NX board support"
410 + select SOC_AR724X
411 + select ATH79_DEV_ETH
412 + select ATH79_DEV_GPIO_BUTTONS
413 + select ATH79_DEV_LEDS_GPIO
414 + select ATH79_DEV_M25P80
415 + select ATH79_DEV_USB
416 + select MYLOADER
418 +config ATH79_MACH_WPJ344
419 + bool "Compex WPJ344 board support"
420 + select SOC_AS934X
421 + select ATH79_DEV_ETH
422 + select ATH79_DEV_GPIO_BUTTONS
423 + select ATH79_DEV_LEDS_GPIO
424 + select ATH79_DEV_M25P80
425 + select ATH79_DEV_USB
426 + select ATH79_DEV_WMAC
428 +config ATH79_MACH_WPJ531
429 + bool "Compex WPJ531 board support"
430 + select SOC_QCA953X
431 + select ATH79_DEV_ETH
432 + select ATH79_DEV_GPIO_BUTTONS
433 + select ATH79_DEV_LEDS_GPIO
434 + select ATH79_DEV_M25P80
435 + select ATH79_DEV_USB
436 + select ATH79_DEV_WMAC
438 +config ATH79_MACH_WPJ558
439 + bool "Compex WPJ558 board support"
440 + select SOC_QCA955X
441 + select ATH79_DEV_ETH
442 + select ATH79_DEV_GPIO_BUTTONS
443 + select ATH79_DEV_LEDS_GPIO
444 + select ATH79_DEV_M25P80
445 + select ATH79_DEV_USB
446 + select ATH79_DEV_WMAC
448 +config ATH79_MACH_DGL_5500_A1
449 + bool "D-Link DGL-5500 A1 support"
450 + select SOC_QCA955X
451 + select ATH79_DEV_ETH
452 + select ATH79_DEV_GPIO_BUTTONS
453 + select ATH79_DEV_LEDS_GPIO
454 + select ATH79_DEV_M25P80
455 + select ATH79_DEV_WMAC
456 + select ATH79_DEV_USB
458 +config ATH79_MACH_DHP_1565_A1
459 + bool "D-Link DHP-1565 rev. A1 board support"
460 + select SOC_AR934X
461 + select ATH79_DEV_AP9X_PCI if PCI
462 + select ATH79_DEV_ETH
463 + select ATH79_DEV_GPIO_BUTTONS
464 + select ATH79_DEV_LEDS_GPIO
465 + select ATH79_DEV_M25P80
466 + select ATH79_DEV_USB
467 + select ATH79_DEV_WMAC
469 +config ATH79_MACH_DIR_505_A1
470 + bool "D-Link DIR-505-A1 support"
471 + select SOC_AR933X
472 + select ATH79_DEV_ETH
473 + select ATH79_DEV_GPIO_BUTTONS
474 + select ATH79_DEV_LEDS_GPIO
475 + select ATH79_DEV_M25P80
476 + select ATH79_DEV_WMAC
477 + select ATH79_NVRAM
479 +config ATH79_MACH_DIR_600_A1
480 + bool "D-Link DIR-600 A1/DIR-615 E1/DIR-615 E4 support"
481 + select SOC_AR724X
482 + select ATH79_DEV_AP9X_PCI if PCI
483 + select ATH79_DEV_ETH
484 + select ATH79_DEV_GPIO_BUTTONS
485 + select ATH79_DEV_LEDS_GPIO
486 + select ATH79_DEV_M25P80
487 + select ATH79_NVRAM
489 +config ATH79_MACH_DIR_615_C1
490 + bool "D-Link DIR-615 rev. C1 support"
491 + select SOC_AR913X
492 + select ATH79_DEV_ETH
493 + select ATH79_DEV_GPIO_BUTTONS
494 + select ATH79_DEV_LEDS_GPIO
495 + select ATH79_DEV_M25P80
496 + select ATH79_DEV_WMAC
497 + select ATH79_NVRAM
499 +config ATH79_MACH_DIR_615_I1
500 + bool "D-Link DIR-615 rev. I1 support"
501 + select SOC_AR934X
502 + select ATH79_DEV_AP9X_PCI if PCI
503 + select ATH79_DEV_ETH
504 + select ATH79_DEV_GPIO_BUTTONS
505 + select ATH79_DEV_LEDS_GPIO
506 + select ATH79_DEV_M25P80
507 + select ATH79_DEV_WMAC
508 + select ATH79_NVRAM
510 +config ATH79_MACH_DIR_825_B1
511 + bool "D-Link DIR-825 rev. B1 board support"
512 + select SOC_AR71XX
513 + select ATH79_DEV_AP9X_PCI if PCI
514 + select ATH79_DEV_ETH
515 + select ATH79_DEV_GPIO_BUTTONS
516 + select ATH79_DEV_LEDS_GPIO
517 + select ATH79_DEV_M25P80
518 + select ATH79_DEV_USB
520 +config ATH79_MACH_DIR_825_C1
521 + bool "D-Link DIR-825 rev. C1/DIR-835 rev. A1 board support"
522 + select SOC_AR934X
523 + select ATH79_DEV_AP9X_PCI if PCI
524 + select ATH79_DEV_ETH
525 + select ATH79_DEV_GPIO_BUTTONS
526 + select ATH79_DEV_LEDS_GPIO
527 + select ATH79_DEV_M25P80
528 + select ATH79_DEV_USB
529 + select ATH79_DEV_WMAC
531 +config ATH79_MACH_DLAN_HOTSPOT
532 + bool "devolo dLAN Hotspot support"
533 + select SOC_AR933X
534 + select ATH79_DEV_ETH
535 + select ATH79_DEV_GPIO_BUTTONS
536 + select ATH79_DEV_LEDS_GPIO
537 + select ATH79_DEV_M25P80
538 + select ATH79_DEV_WMAC
540 +config ATH79_MACH_DLAN_PRO_500_WP
541 + bool "devolo dLAN pro 500 Wireless+ support"
542 + select SOC_AR934X
543 + select ATH79_DEV_ETH
544 + select ATH79_DEV_GPIO_BUTTONS
545 + select ATH79_DEV_LEDS_GPIO
546 + select ATH79_DEV_SPI
547 + select ATH79_DEV_M25P80
548 + select ATH79_DEV_WMAC
549 + select ATH79_DEV_USB
551 +config ATH79_MACH_DLAN_PRO_1200_AC
552 + bool "devolo dLAN pro 1200+ WiFi ac support"
553 + select SOC_AR934X
554 + select ATH79_DEV_AP9X_PCI if PCI
555 + select ATH79_DEV_ETH
556 + select ATH79_DEV_GPIO_BUTTONS
557 + select ATH79_DEV_LEDS_GPIO
558 + select ATH79_DEV_SPI
559 + select ATH79_DEV_M25P80
560 + select ATH79_DEV_WMAC
561 + select ATH79_DEV_NFC
562 + select ATH79_DEV_USB
564 +config ATH79_MACH_DRAGINO2
565 + bool "DRAGINO V2 support"
566 + select SOC_AR933X
567 + select ATH79_DEV_M25P80
568 + select ATH79_DEV_GPIO_BUTTONS
569 + select ATH79_DEV_LEDS_GPIO
570 + select ATH79_DEV_WMAC
571 + select ATH79_DEV_ETH
572 + select ATH79_DEV_USB
574 +config ATH79_MACH_ESR900
575 + bool "EnGenius ESR900 board support"
576 + select SOC_QCA955X
577 + select ATH79_DEV_ETH
578 + select ATH79_DEV_GPIO_BUTTONS
579 + select ATH79_DEV_LEDS_GPIO
580 + select ATH79_DEV_M25P80
581 + select ATH79_DEV_USB
582 + select ATH79_DEV_WMAC
584 +config ATH79_MACH_EW_DORIN
585 + bool "embedded wireless Dorin Platform support"
586 + select SOC_AR933X
587 + select ATH79_DEV_M25P80
588 + select ATH79_DEV_GPIO_BUTTONS
589 + select ATH79_DEV_LEDS_GPIO
590 + select ATH79_DEV_WMAC
591 + select ATH79_DEV_ETH
592 + help
593 + Say 'Y' here if you want your kernel to support the
594 + Dorin Platform from www.80211.de .
596 +config ATH79_MACH_EL_M150
597 + bool "EasyLink EL-M150 support"
598 + select SOC_AR933X
599 + select ATH79_DEV_ETH
600 + select ATH79_DEV_GPIO_BUTTONS
601 + select ATH79_DEV_LEDS_GPIO
602 + select ATH79_DEV_M25P80
603 + select ATH79_DEV_USB
604 + select ATH79_DEV_WMAC
606 +config ATH79_MACH_EL_MINI
607 + bool "EasyLink EL-MINI support"
608 + select SOC_AR933X
609 + select ATH79_DEV_ETH
610 + select ATH79_DEV_GPIO_BUTTONS
611 + select ATH79_DEV_LEDS_GPIO
612 + select ATH79_DEV_M25P80
613 + select ATH79_DEV_USB
614 + select ATH79_DEV_WMAC
616 +config ATH79_MACH_GL_AR150
617 + bool "GL AR150 support"
618 + select SOC_AR933X
619 + select ATH79_DEV_ETH
620 + select ATH79_DEV_GPIO_BUTTONS
621 + select ATH79_DEV_LEDS_GPIO
622 + select ATH79_DEV_M25P80
623 + select ATH79_DEV_USB
624 + select ATH79_DEV_WMAC
626 +config ATH79_MACH_GL_AR300
627 + bool "GL_AR300 support"
628 + select SOC_AR934X
629 + select ATH79_DEV_ETH
630 + select ATH79_DEV_GPIO_BUTTONS
631 + select ATH79_DEV_LEDS_GPIO
632 + select ATH79_DEV_M25P80
633 + select ATH79_DEV_USB
634 + select ATH79_DEV_WMAC
636 +config ATH79_MACH_GL_DOMINO
637 + bool "DOMINO support"
638 + select SOC_AR933X
639 + select ATH79_DEV_ETH
640 + select ATH79_DEV_GPIO_BUTTONS
641 + select ATH79_DEV_LEDS_GPIO
642 + select ATH79_DEV_M25P80
643 + select ATH79_DEV_USB
644 + select ATH79_DEV_WMAC
646 +config ATH79_MACH_GL_INET
647 + bool "GL-INET support"
648 + select SOC_AR933X
649 + select ATH79_DEV_ETH
650 + select ATH79_DEV_GPIO_BUTTONS
651 + select ATH79_DEV_LEDS_GPIO
652 + select ATH79_DEV_M25P80
653 + select ATH79_DEV_USB
654 + select ATH79_DEV_WMAC
656 +config ATH79_MACH_EAP300V2
657 + bool "EnGenius EAP300 v2 support"
658 + select SOC_AR934X
659 + select ATH79_DEV_ETH
660 + select ATH79_DEV_GPIO_BUTTONS
661 + select ATH79_DEV_LEDS_GPIO
662 + select ATH79_DEV_M25P80
663 + select ATH79_DEV_WMAC
665 +config ATH79_MACH_GS_MINIBOX_V1
666 + bool "Gainstrong MiniBox V1.0 support"
667 + select SOC_AR933X
668 + select ARH79_DEV_ETH
669 + select ARH79_DEV_GPIO_BUTTONS
670 + select ATH79_DEV_LEDS_GPIO
671 + select ATH79_DEV_M25P80
672 + select ATH79_DEV_USB
673 + select ATH79_DEV_WMAC
675 +config ATH79_MACH_GS_OOLITE
676 + bool "GS Oolite V1 support"
677 + select SOC_AR933X
678 + select ARH79_DEV_ETH
679 + select ARH79_DEV_GPIO_BUTTONS
680 + select ATH79_DEV_LEDS_GPIO
681 + select ATH79_DEV_M25P80
682 + select ATH79_DEV_USB
683 + select ATH79_DEV_WMAC
685 +config ATH79_MACH_HIWIFI_HC6361
686 + bool "HiWiFi HC6361 board support"
687 + select SOC_AR933X
688 + select ATH79_DEV_ETH
689 + select ATH79_DEV_GPIO_BUTTONS
690 + select ATH79_DEV_LEDS_GPIO
691 + select ATH79_DEV_M25P80
692 + select ATH79_DEV_USB
693 + select ATH79_DEV_WMAC
695 +config ATH79_MACH_JA76PF
696 + bool "jjPlus JA76PF board support"
697 + select SOC_AR71XX
698 + select ATH79_DEV_ETH
699 + select ATH79_DEV_GPIO_BUTTONS
700 + select ATH79_DEV_LEDS_GPIO
701 + select ATH79_DEV_M25P80
702 + select ATH79_DEV_USB
704 +config ATH79_MACH_JWAP003
705 + bool "jjPlus JWAP003 board support"
706 + select SOC_AR71XX
707 + select ATH79_DEV_ETH
708 + select ATH79_DEV_GPIO_BUTTONS
709 + select ATH79_DEV_M25P80
710 + select ATH79_DEV_USB
712 +config ATH79_MACH_WRT160NL
713 + bool "Linksys WRT160NL board support"
714 + select SOC_AR913X
715 + select ATH79_DEV_ETH
716 + select ATH79_DEV_GPIO_BUTTONS
717 + select ATH79_DEV_LEDS_GPIO
718 + select ATH79_DEV_M25P80
719 + select ATH79_DEV_USB
720 + select ATH79_DEV_WMAC
721 + select ATH79_NVRAM
723 +config ATH79_MACH_WRT400N
724 + bool "Linksys WRT400N board support"
725 + select SOC_AR71XX
726 + select ATH79_DEV_AP9X_PCI if PCI
727 + select ATH79_DEV_ETH
728 + select ATH79_DEV_GPIO_BUTTONS
729 + select ATH79_DEV_LEDS_GPIO
730 + select ATH79_DEV_M25P80
732 +config ATH79_MACH_R6100
733 + bool "NETGEAR R6100 board support"
734 + select SOC_AR934X
735 + select ATH79_DEV_AP9X_PCI if PCI
736 + select ATH79_DEV_ETH
737 + select ATH79_DEV_GPIO_BUTTONS
738 + select ATH79_DEV_LEDS_GPIO
739 + select ATH79_DEV_NFC
740 + select ATH79_DEV_USB
741 + select ATH79_DEV_WMAC
743 +config ATH79_MACH_MC_MAC1200R
744 + bool "MERCURY MAC1200R board support"
745 + select SOC_AR934X
746 + select ATH79_DEV_AP9X_PCI if PCI
747 + select ATH79_DEV_ETH
748 + select ATH79_DEV_GPIO_BUTTONS
749 + select ATH79_DEV_LEDS_GPIO
750 + select ATH79_DEV_M25P80
751 + select ATH79_DEV_WMAC
753 +config ATH79_MACH_RB4XX
754 + bool "MikroTik RouterBOARD 4xx series support"
755 + select SOC_AR71XX
756 + select ATH79_DEV_ETH
757 + select ATH79_DEV_GPIO_BUTTONS
758 + select ATH79_DEV_LEDS_GPIO
759 + select ATH79_DEV_USB
761 +config ATH79_MACH_RB750
762 + bool "MikroTik RouterBOARD 750 support"
763 + select SOC_AR724X
764 + select ATH79_DEV_AP9X_PCI if PCI
765 + select ATH79_DEV_ETH
766 + select ATH79_DEV_USB
767 + select ATH79_ROUTERBOOT
769 +config ATH79_MACH_RB91X
770 + bool "MikroTik RouterBOARD 91X support"
771 + select SOC_AR934X
772 + select ATH79_DEV_ETH
773 + select ATH79_DEV_SPI
774 + select ATH79_DEV_WMAC
775 + select ATH79_DEV_USB
776 + select ATH79_ROUTERBOOT
778 +config ATH79_MACH_RB922
779 + bool "MikroTik RouterBOARD 922 support"
780 + select SOC_QCA955X
781 + select ATH79_DEV_ETH
782 + select ATH79_DEV_M25P80
783 + select ATH79_DEV_NFC
784 + select ATH79_DEV_USB
785 + select ATH79_ROUTERBOOT
786 + select RLE_DECOMPRESS
788 +config ATH79_MACH_RB95X
789 + bool "MikroTik RouterBOARD 95X support"
790 + select SOC_AR934X
791 + select ATH79_DEV_ETH
792 + select ATH79_DEV_NFC
793 + select ATH79_DEV_WMAC
794 + select ATH79_DEV_USB
795 + select ATH79_ROUTERBOOT
797 +config ATH79_MACH_RB2011
798 + bool "MikroTik RouterBOARD 2011 support"
799 + select SOC_AR934X
800 + select ATH79_DEV_ETH
801 + select ATH79_DEV_M25P80
802 + select ATH79_DEV_NFC
803 + select ATH79_DEV_USB
804 + select ATH79_DEV_WMAC
805 + select ATH79_ROUTERBOOT
807 +config ATH79_MACH_RBSXTLITE
808 + bool "MikroTik RouterBOARD SXT Lite"
809 + select SOC_AR934X
810 + select ATH79_DEV_ETH
811 + select ATH79_DEV_NFC
812 + select ATH79_DEV_WMAC
813 + select ATH79_ROUTERBOOT
815 +config ATH79_MACH_SMART_300
816 + bool "NC-LINK SMART-300 board support"
817 + select SOC_AR934X
818 + select ATH79_DEV_ETH
819 + select ATH79_DEV_GPIO_BUTTONS
820 + select ATH79_DEV_LEDS_GPIO
821 + select ATH79_DEV_M25P80
822 + select ATH79_DEV_WMAC
824 +config ATH79_MACH_WNDAP360
825 + bool "NETGEAR WNDAP360 board support"
826 + select SOC_AR71XX
827 + select ATH79_DEV_AP9X_PCI if PCI
828 + select ATH79_DEV_ETH
829 + select ATH79_DEV_GPIO_BUTTONS
830 + select ATH79_DEV_LEDS_GPIO
831 + select ATH79_DEV_M25P80
833 +config ATH79_MACH_WNDR3700
834 + bool "NETGEAR WNDR3700 board support"
835 + select SOC_AR71XX
836 + select ATH79_DEV_AP9X_PCI if PCI
837 + select ATH79_DEV_ETH
838 + select ATH79_DEV_GPIO_BUTTONS
839 + select ATH79_DEV_LEDS_GPIO
840 + select ATH79_DEV_M25P80
841 + select ATH79_DEV_USB
843 +config ATH79_MACH_WNDR4300
844 + bool "NETGEAR WNDR3700v4/WNDR4300 board support"
845 + select SOC_AR934X
846 + select ATH79_DEV_AP9X_PCI if PCI
847 + select ATH79_DEV_ETH
848 + select ATH79_DEV_GPIO_BUTTONS
849 + select ATH79_DEV_LEDS_GPIO
850 + select ATH79_DEV_NFC
851 + select ATH79_DEV_USB
852 + select ATH79_DEV_WMAC
854 +config ATH79_MACH_WNR2000
855 + bool "NETGEAR WNR2000 board support"
856 + select SOC_AR913X
857 + select ATH79_DEV_ETH
858 + select ATH79_DEV_GPIO_BUTTONS
859 + select ATH79_DEV_LEDS_GPIO
860 + select ATH79_DEV_M25P80
861 + select ATH79_DEV_WMAC
863 +config ATH79_MACH_WNR2000_V3
864 + bool "NETGEAR WNR2000 V3/WNR612 v2/WNR1000 v2 board support"
865 + select SOC_AR724X
866 + select ATH79_DEV_AP9X_PCI if PCI
867 + select ATH79_DEV_ETH
868 + select ATH79_DEV_GPIO_BUTTONS
869 + select ATH79_DEV_LEDS_GPIO
870 + select ATH79_DEV_M25P80
872 + config ATH79_MACH_WNR2200
873 + bool "NETGEAR WNR2200 board support"
874 + select SOC_AR724X
875 + select ATH79_DEV_AP9X_PCI if PCI
876 + select ATH79_DEV_ETH
877 + select ATH79_DEV_GPIO_BUTTONS
878 + select ATH79_DEV_LEDS_GPIO
879 + select ATH79_DEV_M25P80
880 + select ATH79_DEV_USB
882 +config ATH79_MACH_WNR2000_V4
883 + bool "NETGEAR WNR2000 V4"
884 + select SOC_AR934X
885 + select ATH79_DEV_ETH
886 + select ATH79_DEV_GPIO_BUTTONS
887 + select ATH79_DEV_LEDS_GPIO
888 + select ATH79_DEV_M25P80
889 + select ATH79_DEV_USB
890 + select ATH79_DEV_WMAC
892 +config ATH79_MACH_OM2P
893 + bool "OpenMesh OM2P board support"
894 + select SOC_AR724X
895 + select SOC_AR933X
896 + select ATH79_DEV_AP9X_PCI if PCI
897 + select ATH79_DEV_ETH
898 + select ATH79_DEV_GPIO_BUTTONS
899 + select ATH79_DEV_LEDS_GPIO
900 + select ATH79_DEV_M25P80
901 + select ATH79_DEV_WMAC
903 +config ATH79_MACH_OM5P
904 + bool "OpenMesh OM5P board support"
905 + select SOC_AR934X
906 + select ATH79_DEV_AP9X_PCI if PCI
907 + select ATH79_DEV_ETH
908 + select ATH79_DEV_GPIO_BUTTONS
909 + select ATH79_DEV_LEDS_GPIO
910 + select ATH79_DEV_M25P80
911 + select ATH79_DEV_WMAC
913 +config ATH79_MACH_ONION_OMEGA
914 + bool "ONION OMEGA support"
915 + select SOC_AR933X
916 + select ATH79_DEV_ETH
917 + select ATH79_DEV_GPIO_BUTTONS
918 + select ATH79_DEV_LEDS_GPIO
919 + select ATH79_DEV_M25P80
920 + select ATH79_DEV_USB
921 + select ATH79_DEV_WMAC
923 +config ATH79_MACH_MR12
924 + bool "Meraki MR12 board support"
925 + select SOC_AR724X
926 + select ATH79_DEV_AP9X_PCI if PCI
927 + select ATH79_DEV_ETH
928 + select ATH79_DEV_GPIO_BUTTONS
929 + select ATH79_DEV_LEDS_GPIO
930 + select ATH79_DEV_M25P80
931 + select ATH79_DEV_WMAC
933 +config ATH79_MACH_MR16
934 + bool "Meraki MR16 board support"
935 + select SOC_AR71XX
936 + select ATH79_DEV_AP9X_PCI if PCI
937 + select ATH79_DEV_ETH
938 + select ATH79_DEV_GPIO_BUTTONS
939 + select ATH79_DEV_LEDS_GPIO
940 + select ATH79_DEV_M25P80
941 + select ATH79_DEV_WMAC
943 +config ATH79_MACH_MR600
944 + bool "OpenMesh MR600 board support"
945 + select SOC_AR934X
946 + select ATH79_DEV_AP9X_PCI if PCI
947 + select ATH79_DEV_ETH
948 + select ATH79_DEV_GPIO_BUTTONS
949 + select ATH79_DEV_LEDS_GPIO
950 + select ATH79_DEV_M25P80
951 + select ATH79_DEV_WMAC
953 +config ATH79_MACH_MZK_W04NU
954 + bool "Planex MZK-W04NU board support"
955 + select SOC_AR913X
956 + select ATH79_DEV_ETH
957 + select ATH79_DEV_GPIO_BUTTONS
958 + select ATH79_DEV_LEDS_GPIO
959 + select ATH79_DEV_M25P80
960 + select ATH79_DEV_USB
961 + select ATH79_DEV_WMAC
963 +config ATH79_MACH_MZK_W300NH
964 + bool "Planex MZK-W300NH board support"
965 + select SOC_AR913X
966 + select ATH79_DEV_ETH
967 + select ATH79_DEV_GPIO_BUTTONS
968 + select ATH79_DEV_LEDS_GPIO
969 + select ATH79_DEV_M25P80
970 + select ATH79_DEV_WMAC
972 +config ATH79_MACH_RW2458N
973 + bool "Redwave RW2458N board support"
974 + select SOC_AR724X
975 + select ATH79_DEV_AP9X_PCI if PCI
976 + select ATH79_DEV_ETH
977 + select ATH79_DEV_GPIO_BUTTONS
978 + select ATH79_DEV_LEDS_GPIO
979 + select ATH79_DEV_M25P80
980 + select ATH79_DEV_USB
982 +config ATH79_MACH_CAP4200AG
983 + bool "Senao CAP4200AG support"
984 + select SOC_AR934X
985 + select ATH79_DEV_AP9X_PCI if PCI
986 + select ATH79_DEV_ETH
987 + select ATH79_DEV_GPIO_BUTTONS
988 + select ATH79_DEV_LEDS_GPIO
989 + select ATH79_DEV_M25P80
990 + select ATH79_DEV_WMAC
992 +config ATH79_MACH_MR1750
993 + bool "OpenMesh MR1750 board support"
994 + select SOC_QCA955X
995 + select ATH79_DEV_AP9X_PCI if PCI
996 + select ATH79_DEV_ETH
997 + select ATH79_DEV_GPIO_BUTTONS
998 + select ATH79_DEV_LEDS_GPIO
999 + select ATH79_DEV_M25P80
1000 + select ATH79_DEV_WMAC
1002 +config ATH79_MACH_MR900
1003 + bool "OpenMesh MR900 board support"
1004 + select SOC_QCA955X
1005 + select ATH79_DEV_AP9X_PCI if PCI
1006 + select ATH79_DEV_ETH
1007 + select ATH79_DEV_GPIO_BUTTONS
1008 + select ATH79_DEV_LEDS_GPIO
1009 + select ATH79_DEV_M25P80
1010 + select ATH79_DEV_WMAC
1012 +config ATH79_MACH_EAP7660D
1013 + bool "Senao EAP7660D support"
1014 + select SOC_AR71XX
1015 + select ATH79_DEV_ETH
1016 + select ATH79_DEV_GPIO_BUTTONS
1017 + select ATH79_DEV_LEDS_GPIO
1018 + select ATH79_DEV_M25P80
1020 +config ATH79_MACH_BSB
1021 + bool "Smart Electronics Black Swift board"
1022 + select SOC_AR933X
1023 + select ATH79_DEV_ETH
1024 + select ATH79_DEV_GPIO_BUTTONS
1025 + select ATH79_DEV_LEDS_GPIO
1026 + select ATH79_DEV_M25P80
1027 + select ATH79_DEV_USB
1028 + select ATH79_DEV_WMAC
1030 +config ATH79_MACH_ARCHER_C7
1031 + bool "TP-LINK Archer C5/C7/TL-WDR4900 v2 board support"
1032 + select SOC_QCA955X
1033 + select ATH79_DEV_AP9X_PCI if PCI
1034 + select ATH79_DEV_ETH
1035 + select ATH79_DEV_GPIO_BUTTONS
1036 + select ATH79_DEV_LEDS_GPIO
1037 + select ATH79_DEV_M25P80
1038 + select ATH79_DEV_USB
1039 + select ATH79_DEV_WMAC
1041 +config ATH79_MACH_CPE510
1042 + bool "TP-LINK CPE510 support"
1043 + select SOC_AR934X
1044 + select ATH79_DEV_ETH
1045 + select ATH79_DEV_GPIO_BUTTONS
1046 + select ATH79_DEV_LEDS_GPIO
1047 + select ATH79_DEV_M25P80
1048 + select ATH79_DEV_WMAC
1050 +config ATH79_MACH_TL_MR11U
1051 + bool "TP-LINK TL-MR11U/TL-MR3040 support"
1052 + select SOC_AR933X
1053 + select ATH79_DEV_ETH
1054 select ATH79_DEV_GPIO_BUTTONS
1055 select ATH79_DEV_LEDS_GPIO
1056 - select ATH79_DEV_SPI
1057 + select ATH79_DEV_M25P80
1058 select ATH79_DEV_USB
1059 select ATH79_DEV_WMAC
1060 - help
1061 - Say 'Y' here if you want your kernel to support the
1062 - Atheros AP121 reference board.
1064 -config ATH79_MACH_AP136
1065 - bool "Atheros AP136 reference board"
1066 - select SOC_QCA955X
1067 +config ATH79_MACH_TL_MR13U
1068 + bool "TP-LINK TL-MR13U support"
1069 + select SOC_AR933X
1070 + select ATH79_DEV_ETH
1071 select ATH79_DEV_GPIO_BUTTONS
1072 select ATH79_DEV_LEDS_GPIO
1073 - select ATH79_DEV_SPI
1074 + select ATH79_DEV_M25P80
1075 select ATH79_DEV_USB
1076 select ATH79_DEV_WMAC
1077 - help
1078 - Say 'Y' here if you want your kernel to support the
1079 - Atheros AP136 reference board.
1081 -config ATH79_MACH_AP81
1082 - bool "Atheros AP81 reference board"
1083 +config ATH79_MACH_TL_MR3020
1084 + bool "TP-LINK TL-MR3020 support"
1085 + select SOC_AR933X
1086 + select ATH79_DEV_ETH
1087 + select ATH79_DEV_GPIO_BUTTONS
1088 + select ATH79_DEV_LEDS_GPIO
1089 + select ATH79_DEV_M25P80
1090 + select ATH79_DEV_USB
1091 + select ATH79_DEV_WMAC
1093 +config ATH79_MACH_TL_MR3X20
1094 + bool "TP-LINK TL-MR3220/3420 support"
1095 + select SOC_AR724X
1096 + select ATH79_DEV_AP9X_PCI if PCI
1097 + select ATH79_DEV_ETH
1098 + select ATH79_DEV_GPIO_BUTTONS
1099 + select ATH79_DEV_LEDS_GPIO
1100 + select ATH79_DEV_M25P80
1101 + select ATH79_DEV_USB
1103 +config ATH79_MACH_TL_WAX50RE
1104 + bool "TP-LINK TL-WA750/850RE support"
1105 + select SOC_AR934X
1106 + select ATH79_DEV_ETH
1107 + select ATH79_DEV_GPIO_BUTTONS
1108 + select ATH79_DEV_LEDS_GPIO
1109 + select ATH79_DEV_M25P80
1110 + select ATH79_DEV_WMAC
1112 +config ATH79_MACH_TL_WA701ND_V2
1113 + bool "TP-LINK TL-WA701ND v2 support"
1114 + select SOC_AR933X
1115 + select ATH79_DEV_ETH
1116 + select ATH79_DEV_GPIO_BUTTONS
1117 + select ATH79_DEV_LEDS_GPIO
1118 + select ATH79_DEV_M25P80
1119 + select ATH79_DEV_USB
1120 + select ATH79_DEV_WMAC
1122 +config ATH79_MACH_TL_WA7210N_V2
1123 + bool "TP-LINK TL-WA7210N v2 support"
1124 + select SOC_AR724X
1125 + select ATH79_DEV_AP9X_PCI if PCI
1126 + select ATH79_DEV_ETH
1127 + select ATH79_DEV_LEDS_GPIO
1128 + select ATH79_DEV_GPIO_BUTTONS
1129 + select ATH79_DEV_M25P80
1130 + select ATH79_DEV_WMAC
1132 +config ATH79_MACH_TL_WA830RE_V2
1133 + bool "TP-LINK TL-WA830RE v2 support"
1134 + select SOC_AR934X
1135 + select ATH79_DEV_ETH
1136 + select ATH79_DEV_GPIO_BUTTONS
1137 + select ATH79_DEV_LEDS_GPIO
1138 + select ATH79_DEV_M25P80
1139 + select ATH79_DEV_USB
1140 + select ATH79_DEV_WMAC
1142 +config ATH79_MACH_TL_WA901ND
1143 + bool "TP-LINK TL-WA901ND/TL-WA7510N support"
1144 + select SOC_AR724X
1145 + select ATH79_DEV_AP9X_PCI if PCI
1146 + select ATH79_DEV_ETH
1147 + select ATH79_DEV_GPIO_BUTTONS
1148 + select ATH79_DEV_LEDS_GPIO
1149 + select ATH79_DEV_M25P80
1151 +config ATH79_MACH_TL_WA901ND_V2
1152 + bool "TP-LINK TL-WA901ND v2 support"
1153 select SOC_AR913X
1154 + select ATH79_DEV_ETH
1155 select ATH79_DEV_GPIO_BUTTONS
1156 select ATH79_DEV_LEDS_GPIO
1157 - select ATH79_DEV_SPI
1158 + select ATH79_DEV_M25P80
1159 + select ATH79_DEV_WMAC
1161 +config ATH79_MACH_TL_WDR3320_V2
1162 + bool "TP-LINK TL-WDR3320 v2 board support"
1163 + select SOC_AR934X
1164 + select ATH79_DEV_AP9X_PCI if PCI
1165 + select ATH79_DEV_ETH
1166 + select ATH79_DEV_GPIO_BUTTONS
1167 + select ATH79_DEV_LEDS_GPIO
1168 + select ATH79_DEV_M25P80
1169 select ATH79_DEV_USB
1170 select ATH79_DEV_WMAC
1171 - help
1172 - Say 'Y' here if you want your kernel to support the
1173 - Atheros AP81 reference board.
1175 -config ATH79_MACH_DB120
1176 - bool "Atheros DB120 reference board"
1177 +config ATH79_MACH_TL_WDR3500
1178 + bool "TP-LINK TL-WDR3500 board support"
1179 select SOC_AR934X
1180 + select ATH79_DEV_AP9X_PCI if PCI
1181 + select ATH79_DEV_ETH
1182 select ATH79_DEV_GPIO_BUTTONS
1183 select ATH79_DEV_LEDS_GPIO
1184 - select ATH79_DEV_SPI
1185 + select ATH79_DEV_M25P80
1186 select ATH79_DEV_USB
1187 select ATH79_DEV_WMAC
1188 - help
1189 - Say 'Y' here if you want your kernel to support the
1190 - Atheros DB120 reference board.
1192 -config ATH79_MACH_PB44
1193 - bool "Atheros PB44 reference board"
1194 +config ATH79_MACH_TL_WDR4300
1195 + bool "TP-LINK TL-WDR3600/4300/4310 board support"
1196 + select SOC_AR934X
1197 + select ATH79_DEV_AP9X_PCI if PCI
1198 + select ATH79_DEV_ETH
1199 + select ATH79_DEV_GPIO_BUTTONS
1200 + select ATH79_DEV_LEDS_GPIO
1201 + select ATH79_DEV_M25P80
1202 + select ATH79_DEV_USB
1203 + select ATH79_DEV_WMAC
1205 +config ATH79_MACH_TL_WDR6500_V2
1206 + bool "TP-LINK TL-WDR6500 v2 board support"
1207 + select SOC_QCA956X
1208 + select ATH79_DEV_AP9X_PCI if PCI
1209 + select ATH79_DEV_ETH
1210 + select ATH79_DEV_GPIO_BUTTONS
1211 + select ATH79_DEV_LEDS_GPIO
1212 + select ATH79_DEV_M25P80
1213 + select ATH79_DEV_USB
1214 + select ATH79_DEV_WMAC
1216 +config ATH79_MACH_TL_WR703N
1217 + bool "TP-LINK TL-WR703N/TL-WR710N/TL-MR10U support"
1218 + select SOC_AR933X
1219 + select ATH79_DEV_ETH
1220 + select ATH79_DEV_GPIO_BUTTONS
1221 + select ATH79_DEV_LEDS_GPIO
1222 + select ATH79_DEV_M25P80
1223 + select ATH79_DEV_USB
1224 + select ATH79_DEV_WMAC
1226 +config ATH79_MACH_TL_WR720N_V3
1227 + bool "TP-LINK TL-WR720N v3/v4 support"
1228 + select SOC_AR933X
1229 + select ATH79_DEV_ETH
1230 + select ATH79_DEV_GPIO_BUTTONS
1231 + select ATH79_DEV_LEDS_GPIO
1232 + select ATH79_DEV_M25P80
1233 + select ATH79_DEV_USB
1234 + select ATH79_DEV_WMAC
1236 +config ATH79_MACH_TL_WR741ND
1237 + bool "TP-LINK TL-WR741ND support"
1238 + select SOC_AR724X
1239 + select ATH79_DEV_AP9X_PCI if PCI
1240 + select ATH79_DEV_ETH
1241 + select ATH79_DEV_GPIO_BUTTONS
1242 + select ATH79_DEV_LEDS_GPIO
1243 + select ATH79_DEV_M25P80
1245 +config ATH79_MACH_TL_WR741ND_V4
1246 + bool "TP-LINK TL-WR741ND v4/TL-MR3220 v2 support"
1247 + select SOC_AR933X
1248 + select ATH79_DEV_ETH
1249 + select ATH79_DEV_GPIO_BUTTONS
1250 + select ATH79_DEV_LEDS_GPIO
1251 + select ATH79_DEV_M25P80
1252 + select ATH79_DEV_USB
1253 + select ATH79_DEV_WMAC
1255 +config ATH79_MACH_TL_WR841N_V1
1256 + bool "TP-LINK TL-WR841N v1 support"
1257 select SOC_AR71XX
1258 + select ATH79_DEV_DSA
1259 + select ATH79_DEV_ETH
1260 select ATH79_DEV_GPIO_BUTTONS
1261 select ATH79_DEV_LEDS_GPIO
1262 - select ATH79_DEV_SPI
1263 + select ATH79_DEV_M25P80
1265 +config ATH79_MACH_TL_WR841N_V8
1266 + bool "TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 support"
1267 + select SOC_AR934X
1268 + select ATH79_DEV_ETH
1269 + select ATH79_DEV_GPIO_BUTTONS
1270 + select ATH79_DEV_LEDS_GPIO
1271 + select ATH79_DEV_M25P80
1272 + select ATH79_DEV_USB
1273 + select ATH79_DEV_WMAC
1275 +config ATH79_MACH_TL_WR841N_V9
1276 + bool "TP-LINK TL-WR841N/ND v9 support"
1277 + select SOC_QCA953X
1278 + select ATH79_DEV_ETH
1279 + select ATH79_DEV_GPIO_BUTTONS
1280 + select ATH79_DEV_LEDS_GPIO
1281 + select ATH79_DEV_M25P80
1282 + select ATH79_DEV_WMAC
1284 +config ATH79_MACH_TL_WR941ND
1285 + bool "TP-LINK TL-WR941ND support"
1286 + select SOC_AR913X
1287 + select ATH79_DEV_DSA
1288 + select ATH79_DEV_ETH
1289 + select ATH79_DEV_GPIO_BUTTONS
1290 + select ATH79_DEV_LEDS_GPIO
1291 + select ATH79_DEV_M25P80
1292 + select ATH79_DEV_WMAC
1294 +config ATH79_MACH_TL_WR941ND_V6
1295 + bool "TP-LINK TL-WR941ND v6 support"
1296 + select SOC_QCA956X
1297 + select ATH79_DEV_ETH
1298 + select ATH79_DEV_GPIO_BUTTONS
1299 + select ATH79_DEV_LEDS_GPIO
1300 + select ATH79_DEV_M25P80
1301 + select ATH79_DEV_WMAC
1303 +config ATH79_MACH_TL_WR1041N_V2
1304 + bool "TP-LINK TL-WR1041N v2 support"
1305 + select SOC_AR934X
1306 + select ATH79_DEV_AP9X_PCI if PCI
1307 + select ATH79_DEV_ETH
1308 + select ATH79_DEV_GPIO_BUTTONS
1309 + select ATH79_DEV_LEDS_GPIO
1310 + select ATH79_DEV_M25P80
1311 + select ATH79_DEV_USB
1312 + select ATH79_DEV_WMAC
1314 +config ATH79_MACH_TL_WR1043ND
1315 + bool "TP-LINK TL-WR1043ND support"
1316 + select SOC_AR913X
1317 + select ATH79_DEV_ETH
1318 + select ATH79_DEV_GPIO_BUTTONS
1319 + select ATH79_DEV_LEDS_GPIO
1320 + select ATH79_DEV_M25P80
1321 + select ATH79_DEV_USB
1322 + select ATH79_DEV_WMAC
1324 +config ATH79_MACH_TL_WR1043ND_V2
1325 + bool "TP-LINK TL-WR1043ND v2 support"
1326 + select SOC_QCA955X
1327 + select ATH79_DEV_ETH
1328 + select ATH79_DEV_GPIO_BUTTONS
1329 + select ATH79_DEV_LEDS_GPIO
1330 + select ATH79_DEV_M25P80
1331 + select ATH79_DEV_USB
1332 + select ATH79_DEV_WMAC
1334 +config ATH79_MACH_TL_WR2543N
1335 + bool "TP-LINK TL-WR2543N/ND support"
1336 + select SOC_AR724X
1337 + select ATH79_DEV_AP9X_PCI if PCI
1338 + select ATH79_DEV_ETH
1339 + select ATH79_DEV_GPIO_BUTTONS
1340 + select ATH79_DEV_LEDS_GPIO
1341 + select ATH79_DEV_M25P80
1342 + select ATH79_DEV_USB
1344 +config ATH79_MACH_TEW_632BRP
1345 + bool "TRENDnet TEW-632BRP support"
1346 + select SOC_AR913X
1347 + select ATH79_DEV_ETH
1348 + select ATH79_DEV_GPIO_BUTTONS
1349 + select ATH79_DEV_LEDS_GPIO
1350 + select ATH79_DEV_M25P80
1351 + select ATH79_DEV_WMAC
1352 + select ATH79_NVRAM
1354 +config ATH79_MACH_TEW_673GRU
1355 + bool "TRENDnet TEW-673GRU support"
1356 + select SOC_AR71XX
1357 + select ATH79_DEV_AP9X_PCI if PCI
1358 + select ATH79_DEV_ETH
1359 + select ATH79_DEV_GPIO_BUTTONS
1360 + select ATH79_DEV_LEDS_GPIO
1361 + select ATH79_DEV_M25P80
1362 + select ATH79_DEV_USB
1363 + select ATH79_NVRAM
1365 +config ATH79_MACH_TEW_712BR
1366 + bool "TRENDnet TEW-712BR support"
1367 + select SOC_AR933X
1368 + select ATH79_DEV_ETH
1369 + select ATH79_DEV_GPIO_BUTTONS
1370 + select ATH79_DEV_LEDS_GPIO
1371 + select ATH79_DEV_M25P80
1372 + select ATH79_DEV_WMAC
1373 + select ATH79_NVRAM
1375 +config ATH79_MACH_TEW_732BR
1376 + bool "TRENDnet TEW-732BR support"
1377 + select SOC_AR934X
1378 + select ATH79_DEV_ETH
1379 + select ATH79_DEV_GPIO_BUTTONS
1380 + select ATH79_DEV_LEDS_GPIO
1381 + select ATH79_DEV_M25P80
1382 + select ATH79_DEV_WMAC
1384 +config ATH79_MACH_UBNT
1385 + bool "Ubiquiti AR71xx based boards support"
1386 + select SOC_AR71XX
1387 + select ATH79_DEV_ETH
1388 + select ATH79_DEV_GPIO_BUTTONS
1389 + select ATH79_DEV_LEDS_GPIO
1390 + select ATH79_DEV_M25P80
1391 select ATH79_DEV_USB
1392 - help
1393 - Say 'Y' here if you want your kernel to support the
1394 - Atheros PB44 reference board.
1396 config ATH79_MACH_UBNT_XM
1397 - bool "Ubiquiti Networks XM (rev 1.0) board"
1398 + bool "Ubiquiti Networks XM/UniFi boards"
1399 select SOC_AR724X
1400 + select SOC_AR934X
1401 + select ATH79_DEV_AP9X_PCI if PCI
1402 + select ATH79_DEV_ETH
1403 select ATH79_DEV_GPIO_BUTTONS
1404 select ATH79_DEV_LEDS_GPIO
1405 - select ATH79_DEV_SPI
1406 + select ATH79_DEV_M25P80
1407 + select ATH79_DEV_USB
1408 + select ATH79_DEV_WMAC
1409 help
1410 Say 'Y' here if you want your kernel to support the
1411 Ubiquiti Networks XM (rev 1.0) board.
1413 +config ATH79_MACH_WEIO
1414 + bool "WeIO board"
1415 + select SOC_AR933X
1416 + select ATH79_DEV_GPIO_BUTTONS
1417 + select ATH79_DEV_LEDS_GPIO
1418 + select ATH79_DEV_M25P80
1419 + select ATH79_DEV_USB
1420 + select ATH79_DEV_WMAC
1422 +config ATH79_MACH_MYNET_N600
1423 + bool "WD My Net N600 board support"
1424 + select SOC_AR934X
1425 + select ATH79_DEV_ETH
1426 + select ATH79_DEV_GPIO_BUTTONS
1427 + select ATH79_DEV_LEDS_GPIO
1428 + select ATH79_DEV_M25P80
1429 + select ATH79_DEV_WMAC
1430 + select ATH79_NVRAM
1432 +config ATH79_MACH_MYNET_N750
1433 + bool "WD My Net N750 board support"
1434 + select SOC_AR934X
1435 + select ATH79_DEV_ETH
1436 + select ATH79_DEV_GPIO_BUTTONS
1437 + select ATH79_DEV_LEDS_GPIO
1438 + select ATH79_DEV_M25P80
1439 + select ATH79_DEV_WMAC
1440 + select ATH79_NVRAM
1442 +config ATH79_MACH_MYNET_REXT
1443 + bool "WD My Net Wi-Fi Range Extender board support"
1444 + select SOC_AR934X
1445 + select ATH79_DEV_AP9X_PCI if PCI
1446 + select ATH79_DEV_ETH
1447 + select ATH79_DEV_GPIO_BUTTONS
1448 + select ATH79_DEV_LEDS_GPIO
1449 + select ATH79_DEV_M25P80
1450 + select ATH79_DEV_WMAC
1451 + select ATH79_NVRAM
1453 +config ATH79_MACH_ZCN_1523H
1454 + bool "Zcomax ZCN-1523H support"
1455 + select SOC_AR724X
1456 + select ATH79_DEV_AP9X_PCI if PCI
1457 + select ATH79_DEV_ETH
1458 + select ATH79_DEV_GPIO_BUTTONS
1459 + select ATH79_DEV_LEDS_GPIO
1460 + select ATH79_DEV_M25P80
1462 +config ATH79_MACH_NBG460N
1463 + bool "Zyxel NBG460N/550N/550NH board support"
1464 + select SOC_AR913X
1465 + select ATH79_DEV_ETH
1466 + select ATH79_DEV_GPIO_BUTTONS
1467 + select ATH79_DEV_LEDS_GPIO
1468 + select ATH79_DEV_M25P80
1469 + select ATH79_DEV_WMAC
1471 +config ATH79_MACH_NBG6716
1472 + bool "Zyxel NBG6616/NBG6716 board support"
1473 + select SOC_QCA955X
1474 + select ATH79_DEV_ETH
1475 + select ATH79_DEV_GPIO_BUTTONS
1476 + select ATH79_DEV_LEDS_GPIO
1477 + select ATH79_DEV_M25P80
1478 + select ATH79_DEV_NFC
1479 + select ATH79_DEV_USB
1480 + select ATH79_DEV_WMAC
1482 +config ATH79_MACH_CARAMBOLA2
1483 + bool "8devices Carambola2 board"
1484 + select SOC_AR933X
1485 + select ATH79_DEV_ETH
1486 + select ATH79_DEV_GPIO_BUTTONS
1487 + select ATH79_DEV_LEDS_GPIO
1488 + select ATH79_DEV_M25P80
1489 + select ATH79_DEV_USB
1490 + select ATH79_DEV_WMAC
1492 +config ATH79_MACH_CF_E316N_V2
1493 + bool "COMFAST CF-E316N v2 board"
1494 + select SOC_AR934X
1495 + select ATH79_DEV_ETH
1496 + select ATH79_DEV_GPIO_BUTTONS
1497 + select ATH79_DEV_LEDS_GPIO
1498 + select ATH79_DEV_M25P80
1499 + select ATH79_DEV_USB
1500 + select ATH79_DEV_WMAC
1502 +config ATH79_MACH_BHU_BXU2000N2_A
1503 + bool "BHU BXU2000n-2 rev. A support"
1504 + select SOC_AR934X
1505 + select ATH79_DEV_ETH
1506 + select ATH79_DEV_GPIO_BUTTONS
1507 + select ATH79_DEV_LEDS_GPIO
1508 + select ATH79_DEV_M25P80
1509 + select ATH79_DEV_USB
1510 + select ATH79_DEV_WMAC
1512 +config ATH79_MACH_QIHOO_C301
1513 + bool "Qihoo 360 C301 board support"
1514 + select SOC_AR934X
1515 + select ATH79_DEV_ETH
1516 + select ATH79_DEV_GPIO_BUTTONS
1517 + select ATH79_DEV_LEDS_GPIO
1518 + select ATH79_DEV_M25P80
1519 + select ATH79_DEV_WMAC
1520 + select ATH79_DEV_USB
1521 + select ATH79_NVRAM
1523 endmenu
1525 config SOC_AR71XX
1526 @@ -93,12 +1484,39 @@
1527 select PCI_AR724X if PCI
1528 def_bool n
1530 +config SOC_QCA953X
1531 + select USB_ARCH_HAS_EHCI
1532 + def_bool n
1534 config SOC_QCA955X
1535 select HW_HAS_PCI
1536 select PCI_AR724X if PCI
1537 def_bool n
1539 -config PCI_AR724X
1540 +config SOC_QCA956X
1541 + select USB_ARCH_HAS_EHCI
1542 + select HW_HAS_PCI
1543 + select PCI_AR724X if PCI
1544 + def_bool n
1546 +config ATH79_DEV_M25P80
1547 + select ATH79_DEV_SPI
1548 + def_bool n
1550 +config ATH79_DEV_AP9X_PCI
1551 + select ATH79_PCI_ATH9K_FIXUP
1552 + def_bool n
1554 +config ATH79_DEV_DSA
1555 + def_bool n
1557 +config ATH79_DEV_ETH
1558 + def_bool n
1560 +config ATH79_DEV_DSA
1561 + def_bool n
1563 +config ATH79_DEV_ETH
1564 def_bool n
1566 config ATH79_DEV_GPIO_BUTTONS
1567 @@ -107,6 +1525,10 @@
1568 config ATH79_DEV_LEDS_GPIO
1569 def_bool n
1571 +config ATH79_DEV_NFC
1572 + depends on (SOC_AR934X || SOC_QCA955X)
1573 + def_bool n
1575 config ATH79_DEV_SPI
1576 def_bool n
1578 @@ -114,7 +1536,21 @@
1579 def_bool n
1581 config ATH79_DEV_WMAC
1582 - depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
1583 + depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA953X || SOC_QCA955X || SOC_QCA956X)
1584 + def_bool n
1586 +config ATH79_NVRAM
1587 + def_bool n
1589 +config ATH79_PCI_ATH9K_FIXUP
1590 + def_bool n
1592 +config ATH79_ROUTERBOOT
1593 + select RLE_DECOMPRESS
1594 + select LZO_DECOMPRESS
1595 + def_bool n
1597 +config PCI_AR724X
1598 def_bool n
1600 endif
1601 diff -Nur linux-4.1.43.orig/arch/mips/ath79/Makefile linux-4.1.43/arch/mips/ath79/Makefile
1602 --- linux-4.1.43.orig/arch/mips/ath79/Makefile 2017-08-06 01:56:14.000000000 +0200
1603 +++ linux-4.1.43/arch/mips/ath79/Makefile 2017-08-06 20:02:15.000000000 +0200
1604 @@ -17,18 +17,169 @@
1605 # Devices
1607 obj-y += dev-common.o
1608 +obj-$(CONFIG_ATH79_DEV_AP9X_PCI) += dev-ap9x-pci.o
1609 +obj-$(CONFIG_ATH79_DEV_DSA) += dev-dsa.o
1610 +obj-$(CONFIG_ATH79_DEV_ETH) += dev-eth.o
1611 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
1612 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO) += dev-leds-gpio.o
1613 +obj-$(CONFIG_ATH79_DEV_M25P80) += dev-m25p80.o
1614 +obj-$(CONFIG_ATH79_DEV_NFC) += dev-nfc.o
1615 obj-$(CONFIG_ATH79_DEV_SPI) += dev-spi.o
1616 obj-$(CONFIG_ATH79_DEV_USB) += dev-usb.o
1617 obj-$(CONFIG_ATH79_DEV_WMAC) += dev-wmac.o
1620 +# Miscellaneous objects
1622 +obj-$(CONFIG_ATH79_NVRAM) += nvram.o
1623 +obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP) += pci-ath9k-fixup.o
1624 +obj-$(CONFIG_ATH79_ROUTERBOOT) += routerboot.o
1627 # Machines
1629 +obj-$(CONFIG_ATH79_MACH_ALFA_AP96) += mach-alfa-ap96.o
1630 +obj-$(CONFIG_ATH79_MACH_ALFA_NX) += mach-alfa-nx.o
1631 +obj-$(CONFIG_ATH79_MACH_ALL0258N) += mach-all0258n.o
1632 +obj-$(CONFIG_ATH79_MACH_ALL0315N) += mach-all0315n.o
1633 +obj-$(CONFIG_ATH79_MACH_ANTMINER_S1)+= mach-antminer-s1.o
1634 +obj-$(CONFIG_ATH79_MACH_ANTMINER_S3)+= mach-antminer-s3.o
1635 +obj-$(CONFIG_ATH79_MACH_ARDUINO_YUN) += mach-arduino-yun.o
1636 +obj-$(CONFIG_ATH79_MACH_AP113) += mach-ap113.o
1637 obj-$(CONFIG_ATH79_MACH_AP121) += mach-ap121.o
1638 +obj-$(CONFIG_ATH79_MACH_AP132) += mach-ap132.o
1639 obj-$(CONFIG_ATH79_MACH_AP136) += mach-ap136.o
1640 +obj-$(CONFIG_ATH79_MACH_AP143) += mach-ap143.o
1641 +obj-$(CONFIG_ATH79_MACH_AP147) += mach-ap147.o
1642 +obj-$(CONFIG_ATH79_MACH_AP152) += mach-ap152.o
1643 obj-$(CONFIG_ATH79_MACH_AP81) += mach-ap81.o
1644 +obj-$(CONFIG_ATH79_MACH_AP83) += mach-ap83.o
1645 +obj-$(CONFIG_ATH79_MACH_AP96) += mach-ap96.o
1646 +obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7.o
1647 +obj-$(CONFIG_ATH79_MACH_AW_NR580) += mach-aw-nr580.o
1648 +obj-$(CONFIG_ATH79_MACH_BHU_BXU2000N2_A)+= mach-bhu-bxu2000n2-a.o
1649 +obj-$(CONFIG_ATH79_MACH_BSB) += mach-bsb.o
1650 +obj-$(CONFIG_ATH79_MACH_CAP4200AG) += mach-cap4200ag.o
1651 +obj-$(CONFIG_ATH79_MACH_CF_E316N_V2) += mach-cf-e316n-v2.o
1652 +obj-$(CONFIG_ATH79_MACH_CPE510) += mach-cpe510.o
1653 obj-$(CONFIG_ATH79_MACH_DB120) += mach-db120.o
1654 +obj-$(CONFIG_ATH79_MACH_DLAN_HOTSPOT) += mach-dlan-hotspot.o
1655 +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_500_WP) += mach-dlan-pro-500-wp.o
1656 +obj-$(CONFIG_ATH79_MACH_DLAN_PRO_1200_AC) += mach-dlan-pro-1200-ac.o
1657 +obj-$(CONFIG_ATH79_MACH_DGL_5500_A1) += mach-dgl-5500-a1.o
1658 +obj-$(CONFIG_ATH79_MACH_DHP_1565_A1) += mach-dhp-1565-a1.o
1659 +obj-$(CONFIG_ATH79_MACH_DIR_505_A1) += mach-dir-505-a1.o
1660 +obj-$(CONFIG_ATH79_MACH_DIR_600_A1) += mach-dir-600-a1.o
1661 +obj-$(CONFIG_ATH79_MACH_DIR_615_C1) += mach-dir-615-c1.o
1662 +obj-$(CONFIG_ATH79_MACH_DIR_615_I1) += mach-dir-615-i1.o
1663 +obj-$(CONFIG_ATH79_MACH_DIR_825_B1) += mach-dir-825-b1.o
1664 +obj-$(CONFIG_ATH79_MACH_DIR_825_C1) += mach-dir-825-c1.o
1665 +obj-$(CONFIG_ATH79_MACH_DRAGINO2) += mach-dragino2.o
1666 +obj-$(CONFIG_ATH79_MACH_ESR900) += mach-esr900.o
1667 +obj-$(CONFIG_ATH79_MACH_EW_DORIN) += mach-ew-dorin.o
1668 +obj-$(CONFIG_ATH79_MACH_EAP300V2) += mach-eap300v2.o
1669 +obj-$(CONFIG_ATH79_MACH_EAP7660D) += mach-eap7660d.o
1670 +obj-$(CONFIG_ATH79_MACH_EL_M150) += mach-el-m150.o
1671 +obj-$(CONFIG_ATH79_MACH_EL_MINI) += mach-el-mini.o
1672 +obj-$(CONFIG_ATH79_MACH_EPG5000) += mach-epg5000.o
1673 +obj-$(CONFIG_ATH79_MACH_ESR1750) += mach-esr1750.o
1674 +obj-$(CONFIG_ATH79_MACH_F9K1115V2) += mach-f9k1115v2.o
1675 +obj-$(CONFIG_ATH79_MACH_GL_AR150) += mach-gl-ar150.o
1676 +obj-$(CONFIG_ATH79_MACH_GL_AR300) += mach-gl-ar300.o
1677 +obj-$(CONFIG_ATH79_MACH_GL_DOMINO) += mach-gl-domino.o
1678 +obj-$(CONFIG_ATH79_MACH_GL_INET) += mach-gl-inet.o
1679 +obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1) += mach-gs-minibox-v1.o
1680 +obj-$(CONFIG_ATH79_MACH_GS_OOLITE) += mach-gs-oolite.o
1681 +obj-$(CONFIG_ATH79_MACH_HIWIFI_HC6361) += mach-hiwifi-hc6361.o
1682 +obj-$(CONFIG_ATH79_MACH_JA76PF) += mach-ja76pf.o
1683 +obj-$(CONFIG_ATH79_MACH_JWAP003) += mach-jwap003.o
1684 +obj-$(CONFIG_ATH79_MACH_HORNET_UB) += mach-hornet-ub.o
1685 +obj-$(CONFIG_ATH79_MACH_MC_MAC1200R) += mach-mc-mac1200r.o
1686 +obj-$(CONFIG_ATH79_MACH_MR12) += mach-mr12.o
1687 +obj-$(CONFIG_ATH79_MACH_MR16) += mach-mr16.o
1688 +obj-$(CONFIG_ATH79_MACH_MR1750) += mach-mr1750.o
1689 +obj-$(CONFIG_ATH79_MACH_MR600) += mach-mr600.o
1690 +obj-$(CONFIG_ATH79_MACH_MR900) += mach-mr900.o
1691 +obj-$(CONFIG_ATH79_MACH_MYNET_N600) += mach-mynet-n600.o
1692 +obj-$(CONFIG_ATH79_MACH_MYNET_N750) += mach-mynet-n750.o
1693 +obj-$(CONFIG_ATH79_MACH_MYNET_REXT) += mach-mynet-rext.o
1694 +obj-$(CONFIG_ATH79_MACH_MZK_W04NU) += mach-mzk-w04nu.o
1695 +obj-$(CONFIG_ATH79_MACH_MZK_W300NH) += mach-mzk-w300nh.o
1696 +obj-$(CONFIG_ATH79_MACH_NBG460N) += mach-nbg460n.o
1697 +obj-$(CONFIG_ATH79_MACH_OM2P) += mach-om2p.o
1698 +obj-$(CONFIG_ATH79_MACH_OM5P) += mach-om5p.o
1699 +obj-$(CONFIG_ATH79_MACH_ONION_OMEGA) += mach-onion-omega.o
1700 +obj-$(CONFIG_ATH79_MACH_PB42) += mach-pb42.o
1701 obj-$(CONFIG_ATH79_MACH_PB44) += mach-pb44.o
1702 +obj-$(CONFIG_ATH79_MACH_PB92) += mach-pb92.o
1703 +obj-$(CONFIG_ATH79_MACH_QIHOO_C301) += mach-qihoo-c301.o
1704 +obj-$(CONFIG_ATH79_MACH_R6100) += mach-r6100.o
1705 +obj-$(CONFIG_ATH79_MACH_RB4XX) += mach-rb4xx.o
1706 +obj-$(CONFIG_ATH79_MACH_RB750) += mach-rb750.o
1707 +obj-$(CONFIG_ATH79_MACH_RB91X) += mach-rb91x.o
1708 +obj-$(CONFIG_ATH79_MACH_RB922) += mach-rb922.o
1709 +obj-$(CONFIG_ATH79_MACH_RB95X) += mach-rb95x.o
1710 +obj-$(CONFIG_ATH79_MACH_RB2011) += mach-rb2011.o
1711 +obj-$(CONFIG_ATH79_MACH_RBSXTLITE) += mach-rbsxtlite.o
1712 +obj-$(CONFIG_ATH79_MACH_RW2458N) += mach-rw2458n.o
1713 +obj-$(CONFIG_ATH79_MACH_SMART_300) += mach-smart-300.o
1714 +obj-$(CONFIG_ATH79_MACH_TEW_632BRP) += mach-tew-632brp.o
1715 +obj-$(CONFIG_ATH79_MACH_TEW_673GRU) += mach-tew-673gru.o
1716 +obj-$(CONFIG_ATH79_MACH_TEW_712BR) += mach-tew-712br.o
1717 +obj-$(CONFIG_ATH79_MACH_TEW_732BR) += mach-tew-732br.o
1718 +obj-$(CONFIG_ATH79_MACH_TL_MR11U) += mach-tl-mr11u.o
1719 +obj-$(CONFIG_ATH79_MACH_TL_MR13U) += mach-tl-mr13u.o
1720 +obj-$(CONFIG_ATH79_MACH_TL_MR3020) += mach-tl-mr3020.o
1721 +obj-$(CONFIG_ATH79_MACH_TL_MR3X20) += mach-tl-mr3x20.o
1722 +obj-$(CONFIG_ATH79_MACH_TL_WAX50RE) += mach-tl-wax50re.o
1723 +obj-$(CONFIG_ATH79_MACH_TL_WA701ND_V2) += mach-tl-wa701nd-v2.o
1724 +obj-$(CONFIG_ATH79_MACH_TL_WA7210N_V2) += mach-tl-wa7210n-v2.o
1725 +obj-$(CONFIG_ATH79_MACH_TL_WA830RE_V2) += mach-tl-wa830re-v2.o
1726 +obj-$(CONFIG_ATH79_MACH_TL_WA901ND) += mach-tl-wa901nd.o
1727 +obj-$(CONFIG_ATH79_MACH_TL_WA901ND_V2) += mach-tl-wa901nd-v2.o
1728 +obj-$(CONFIG_ATH79_MACH_TL_WDR3320_V2) += mach-tl-wdr3320-v2.o
1729 +obj-$(CONFIG_ATH79_MACH_TL_WDR3500) += mach-tl-wdr3500.o
1730 +obj-$(CONFIG_ATH79_MACH_TL_WDR4300) += mach-tl-wdr4300.o
1731 +obj-$(CONFIG_ATH79_MACH_TL_WDR6500_V2) += mach-tl-wdr6500-v2.o
1732 +obj-$(CONFIG_ATH79_MACH_TL_WR741ND) += mach-tl-wr741nd.o
1733 +obj-$(CONFIG_ATH79_MACH_TL_WR741ND_V4) += mach-tl-wr741nd-v4.o
1734 +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V1) += mach-tl-wr841n.o
1735 +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V8) += mach-tl-wr841n-v8.o
1736 +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V9) += mach-tl-wr841n-v9.o
1737 +obj-$(CONFIG_ATH79_MACH_TL_WR941ND) += mach-tl-wr941nd.o
1738 +obj-$(CONFIG_ATH79_MACH_TL_WR941ND_V6) += mach-tl-wr941nd-v6.o
1739 +obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
1740 +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
1741 +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND_V2) += mach-tl-wr1043nd-v2.o
1742 +obj-$(CONFIG_ATH79_MACH_TL_WR2543N) += mach-tl-wr2543n.o
1743 +obj-$(CONFIG_ATH79_MACH_TL_WR703N) += mach-tl-wr703n.o
1744 +obj-$(CONFIG_ATH79_MACH_TL_WR720N_V3) += mach-tl-wr720n-v3.o
1745 +obj-$(CONFIG_ATH79_MACH_TUBE2H) += mach-tube2h.o
1746 +obj-$(CONFIG_ATH79_MACH_UBNT) += mach-ubnt.o
1747 obj-$(CONFIG_ATH79_MACH_UBNT_XM) += mach-ubnt-xm.o
1748 +obj-$(CONFIG_ATH79_MACH_WEIO) += mach-weio.o
1749 +obj-$(CONFIG_ATH79_MACH_WHR_HP_G300N) += mach-whr-hp-g300n.o
1750 +obj-$(CONFIG_ATH79_MACH_WLAE_AG300N) += mach-wlae-ag300n.o
1751 +obj-$(CONFIG_ATH79_MACH_WLR8100) += mach-wlr8100.o
1752 +obj-$(CONFIG_ATH79_MACH_WNDAP360) += mach-wndap360.o
1753 +obj-$(CONFIG_ATH79_MACH_WNDR3700) += mach-wndr3700.o
1754 +obj-$(CONFIG_ATH79_MACH_WNDR4300) += mach-wndr4300.o
1755 +obj-$(CONFIG_ATH79_MACH_WNR2000) += mach-wnr2000.o
1756 +obj-$(CONFIG_ATH79_MACH_WNR2000_V3) += mach-wnr2000-v3.o
1757 +obj-$(CONFIG_ATH79_MACH_WNR2000_V4) += mach-wnr2000-v4.o
1758 +obj-$(CONFIG_ATH79_MACH_WNR2200) += mach-wnr2200.o
1759 +obj-$(CONFIG_ATH79_MACH_WP543) += mach-wp543.o
1760 +obj-$(CONFIG_ATH79_MACH_WPE72) += mach-wpe72.o
1761 +obj-$(CONFIG_ATH79_MACH_WPJ344) += mach-wpj344.o
1762 +obj-$(CONFIG_ATH79_MACH_WPJ531) += mach-wpj531.o
1763 +obj-$(CONFIG_ATH79_MACH_WPJ558) += mach-wpj558.o
1764 +obj-$(CONFIG_ATH79_MACH_WRT160NL) += mach-wrt160nl.o
1765 +obj-$(CONFIG_ATH79_MACH_WRT400N) += mach-wrt400n.o
1766 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH) += mach-wzr-hp-g300nh.o
1767 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G300NH2) += mach-wzr-hp-g300nh2.o
1768 +obj-$(CONFIG_ATH79_MACH_WZR_HP_AG300H) += mach-wzr-hp-ag300h.o
1769 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H) += mach-wzr-hp-g450h.o
1770 +obj-$(CONFIG_ATH79_MACH_WZR_450HP2) += mach-wzr-450hp2.o
1771 +obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o
1772 +obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o
1773 +obj-$(CONFIG_ATH79_MACH_NBG6716) += mach-nbg6716.o
1774 diff -Nur linux-4.1.43.orig/arch/mips/ath79/clock.c linux-4.1.43/arch/mips/ath79/clock.c
1775 --- linux-4.1.43.orig/arch/mips/ath79/clock.c 2017-08-06 01:56:14.000000000 +0200
1776 +++ linux-4.1.43/arch/mips/ath79/clock.c 2017-08-06 20:02:15.000000000 +0200
1777 @@ -25,7 +25,7 @@
1778 #include "common.h"
1780 #define AR71XX_BASE_FREQ 40000000
1781 -#define AR724X_BASE_FREQ 5000000
1782 +#define AR724X_BASE_FREQ 40000000
1783 #define AR913X_BASE_FREQ 5000000
1785 struct clk {
1786 @@ -99,8 +99,8 @@
1787 div = ((pll >> AR724X_PLL_DIV_SHIFT) & AR724X_PLL_DIV_MASK);
1788 freq = div * ref_rate;
1790 - div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK);
1791 - freq *= div;
1792 + div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK) * 2;
1793 + freq /= div;
1795 cpu_rate = freq;
1797 @@ -350,6 +350,91 @@
1798 iounmap(dpll_base);
1801 +static void __init qca953x_clocks_init(void)
1803 + unsigned long ref_rate;
1804 + unsigned long cpu_rate;
1805 + unsigned long ddr_rate;
1806 + unsigned long ahb_rate;
1807 + u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
1808 + u32 cpu_pll, ddr_pll;
1809 + u32 bootstrap;
1811 + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
1812 + if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
1813 + ref_rate = 40 * 1000 * 1000;
1814 + else
1815 + ref_rate = 25 * 1000 * 1000;
1817 + pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
1818 + out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
1819 + QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
1820 + ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
1821 + QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
1822 + nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
1823 + QCA953X_PLL_CPU_CONFIG_NINT_MASK;
1824 + frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
1825 + QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
1827 + cpu_pll = nint * ref_rate / ref_div;
1828 + cpu_pll += frac * (ref_rate >> 6) / ref_div;
1829 + cpu_pll /= (1 << out_div);
1831 + pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
1832 + out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
1833 + QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
1834 + ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
1835 + QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
1836 + nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
1837 + QCA953X_PLL_DDR_CONFIG_NINT_MASK;
1838 + frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
1839 + QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
1841 + ddr_pll = nint * ref_rate / ref_div;
1842 + ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
1843 + ddr_pll /= (1 << out_div);
1845 + clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
1847 + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
1848 + QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
1850 + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
1851 + cpu_rate = ref_rate;
1852 + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
1853 + cpu_rate = cpu_pll / (postdiv + 1);
1854 + else
1855 + cpu_rate = ddr_pll / (postdiv + 1);
1857 + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
1858 + QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
1860 + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
1861 + ddr_rate = ref_rate;
1862 + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
1863 + ddr_rate = ddr_pll / (postdiv + 1);
1864 + else
1865 + ddr_rate = cpu_pll / (postdiv + 1);
1867 + postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
1868 + QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
1870 + if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
1871 + ahb_rate = ref_rate;
1872 + else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
1873 + ahb_rate = ddr_pll / (postdiv + 1);
1874 + else
1875 + ahb_rate = cpu_pll / (postdiv + 1);
1877 + ath79_add_sys_clkdev("ref", ref_rate);
1878 + ath79_add_sys_clkdev("cpu", cpu_rate);
1879 + ath79_add_sys_clkdev("ddr", ddr_rate);
1880 + ath79_add_sys_clkdev("ahb", ahb_rate);
1882 + clk_add_alias("wdt", NULL, "ref", NULL);
1883 + clk_add_alias("uart", NULL, "ref", NULL);
1886 static void __init qca955x_clocks_init(void)
1888 unsigned long ref_rate;
1889 @@ -435,6 +520,100 @@
1890 clk_add_alias("uart", NULL, "ref", NULL);
1893 +static void __init qca956x_clocks_init(void)
1895 + unsigned long ref_rate;
1896 + unsigned long cpu_rate;
1897 + unsigned long ddr_rate;
1898 + unsigned long ahb_rate;
1899 + u32 pll, out_div, ref_div, nint, hfrac, lfrac, clk_ctrl, postdiv;
1900 + u32 cpu_pll, ddr_pll;
1901 + u32 bootstrap;
1903 + bootstrap = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
1904 + if (bootstrap & QCA956X_BOOTSTRAP_REF_CLK_40)
1905 + ref_rate = 40 * 1000 * 1000;
1906 + else
1907 + ref_rate = 25 * 1000 * 1000;
1909 + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG_REG);
1910 + out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
1911 + QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
1912 + ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
1913 + QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
1915 + pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG1_REG);
1916 + nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
1917 + QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
1918 + hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
1919 + QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK;
1920 + lfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT) &
1921 + QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK;
1923 + cpu_pll = nint * ref_rate / ref_div;
1924 + cpu_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
1925 + cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
1926 + cpu_pll /= (1 << out_div);
1928 + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG_REG);
1929 + out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
1930 + QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
1931 + ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
1932 + QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
1933 + pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG1_REG);
1934 + nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
1935 + QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
1936 + hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
1937 + QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK;
1938 + lfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT) &
1939 + QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK;
1941 + ddr_pll = nint * ref_rate / ref_div;
1942 + ddr_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
1943 + ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
1944 + ddr_pll /= (1 << out_div);
1946 + clk_ctrl = ath79_pll_rr(QCA956X_PLL_CLK_CTRL_REG);
1948 + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
1949 + QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
1951 + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
1952 + cpu_rate = ref_rate;
1953 + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL)
1954 + cpu_rate = ddr_pll / (postdiv + 1);
1955 + else
1956 + cpu_rate = cpu_pll / (postdiv + 1);
1958 + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
1959 + QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
1961 + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
1962 + ddr_rate = ref_rate;
1963 + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL)
1964 + ddr_rate = cpu_pll / (postdiv + 1);
1965 + else
1966 + ddr_rate = ddr_pll / (postdiv + 1);
1968 + postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
1969 + QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
1971 + if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
1972 + ahb_rate = ref_rate;
1973 + else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
1974 + ahb_rate = ddr_pll / (postdiv + 1);
1975 + else
1976 + ahb_rate = cpu_pll / (postdiv + 1);
1978 + ath79_add_sys_clkdev("ref", ref_rate);
1979 + ath79_add_sys_clkdev("cpu", cpu_rate);
1980 + ath79_add_sys_clkdev("ddr", ddr_rate);
1981 + ath79_add_sys_clkdev("ahb", ahb_rate);
1983 + clk_add_alias("wdt", NULL, "ref", NULL);
1984 + clk_add_alias("uart", NULL, "ref", NULL);
1987 void __init ath79_clocks_init(void)
1989 if (soc_is_ar71xx())
1990 @@ -447,8 +626,12 @@
1991 ar933x_clocks_init();
1992 else if (soc_is_ar934x())
1993 ar934x_clocks_init();
1994 + else if (soc_is_qca953x())
1995 + qca953x_clocks_init();
1996 else if (soc_is_qca955x())
1997 qca955x_clocks_init();
1998 + else if (soc_is_qca956x())
1999 + qca956x_clocks_init();
2000 else
2001 BUG();
2003 @@ -488,3 +671,15 @@
2004 return clk->rate;
2006 EXPORT_SYMBOL(clk_get_rate);
2008 +int clk_set_rate(struct clk *clk, unsigned long rate)
2010 + return 0;
2012 +EXPORT_SYMBOL_GPL(clk_set_rate);
2014 +long clk_round_rate(struct clk *clk, unsigned long rate)
2016 + return 0;
2018 +EXPORT_SYMBOL_GPL(clk_round_rate);
2019 diff -Nur linux-4.1.43.orig/arch/mips/ath79/common.c linux-4.1.43/arch/mips/ath79/common.c
2020 --- linux-4.1.43.orig/arch/mips/ath79/common.c 2017-08-06 01:56:14.000000000 +0200
2021 +++ linux-4.1.43/arch/mips/ath79/common.c 2017-08-06 20:02:15.000000000 +0200
2022 @@ -22,6 +22,7 @@
2023 #include "common.h"
2025 static DEFINE_SPINLOCK(ath79_device_reset_lock);
2026 +static DEFINE_MUTEX(ath79_flash_mutex);
2028 u32 ath79_cpu_freq;
2029 EXPORT_SYMBOL_GPL(ath79_cpu_freq);
2030 @@ -72,10 +73,14 @@
2031 reg = AR933X_RESET_REG_RESET_MODULE;
2032 else if (soc_is_ar934x())
2033 reg = AR934X_RESET_REG_RESET_MODULE;
2034 + else if (soc_is_qca953x())
2035 + reg = QCA953X_RESET_REG_RESET_MODULE;
2036 else if (soc_is_qca955x())
2037 reg = QCA955X_RESET_REG_RESET_MODULE;
2038 + else if (soc_is_qca956x())
2039 + reg = QCA956X_RESET_REG_RESET_MODULE;
2040 else
2041 - BUG();
2042 + panic("Reset register not defined for this SOC");
2044 spin_lock_irqsave(&ath79_device_reset_lock, flags);
2045 t = ath79_reset_rr(reg);
2046 @@ -100,10 +105,14 @@
2047 reg = AR933X_RESET_REG_RESET_MODULE;
2048 else if (soc_is_ar934x())
2049 reg = AR934X_RESET_REG_RESET_MODULE;
2050 + else if (soc_is_qca953x())
2051 + reg = QCA953X_RESET_REG_RESET_MODULE;
2052 else if (soc_is_qca955x())
2053 reg = QCA955X_RESET_REG_RESET_MODULE;
2054 + else if (soc_is_qca956x())
2055 + reg = QCA956X_RESET_REG_RESET_MODULE;
2056 else
2057 - BUG();
2058 + panic("Reset register not defined for this SOC");
2060 spin_lock_irqsave(&ath79_device_reset_lock, flags);
2061 t = ath79_reset_rr(reg);
2062 @@ -111,3 +120,42 @@
2063 spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
2065 EXPORT_SYMBOL_GPL(ath79_device_reset_clear);
2067 +u32 ath79_device_reset_get(u32 mask)
2069 + unsigned long flags;
2070 + u32 reg;
2071 + u32 ret;
2073 + if (soc_is_ar71xx())
2074 + reg = AR71XX_RESET_REG_RESET_MODULE;
2075 + else if (soc_is_ar724x())
2076 + reg = AR724X_RESET_REG_RESET_MODULE;
2077 + else if (soc_is_ar913x())
2078 + reg = AR913X_RESET_REG_RESET_MODULE;
2079 + else if (soc_is_ar933x())
2080 + reg = AR933X_RESET_REG_RESET_MODULE;
2081 + else if (soc_is_ar934x())
2082 + reg = AR934X_RESET_REG_RESET_MODULE;
2083 + else
2084 + BUG();
2086 + spin_lock_irqsave(&ath79_device_reset_lock, flags);
2087 + ret = ath79_reset_rr(reg);
2088 + spin_unlock_irqrestore(&ath79_device_reset_lock, flags);
2089 + return ret;
2091 +EXPORT_SYMBOL_GPL(ath79_device_reset_get);
2093 +void ath79_flash_acquire(void)
2095 + mutex_lock(&ath79_flash_mutex);
2097 +EXPORT_SYMBOL_GPL(ath79_flash_acquire);
2099 +void ath79_flash_release(void)
2101 + mutex_unlock(&ath79_flash_mutex);
2103 +EXPORT_SYMBOL_GPL(ath79_flash_release);
2105 diff -Nur linux-4.1.43.orig/arch/mips/ath79/common.h linux-4.1.43/arch/mips/ath79/common.h
2106 --- linux-4.1.43.orig/arch/mips/ath79/common.h 2017-08-06 01:56:14.000000000 +0200
2107 +++ linux-4.1.43/arch/mips/ath79/common.h 2017-08-06 20:02:15.000000000 +0200
2108 @@ -27,6 +27,9 @@
2109 void ath79_gpio_function_enable(u32 mask);
2110 void ath79_gpio_function_disable(u32 mask);
2111 void ath79_gpio_function_setup(u32 set, u32 clear);
2112 +void ath79_gpio_function2_setup(u32 set, u32 clear);
2113 +void ath79_gpio_output_select(unsigned gpio, u8 val);
2114 +int ath79_gpio_direction_select(unsigned gpio, bool oe);
2115 void ath79_gpio_init(void);
2117 #endif /* __ATH79_COMMON_H */
2118 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-ap9x-pci.c linux-4.1.43/arch/mips/ath79/dev-ap9x-pci.c
2119 --- linux-4.1.43.orig/arch/mips/ath79/dev-ap9x-pci.c 1970-01-01 01:00:00.000000000 +0100
2120 +++ linux-4.1.43/arch/mips/ath79/dev-ap9x-pci.c 2017-08-06 20:02:15.000000000 +0200
2121 @@ -0,0 +1,159 @@
2123 + * Atheros AP9X reference board PCI initialization
2125 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
2127 + * This program is free software; you can redistribute it and/or modify it
2128 + * under the terms of the GNU General Public License version 2 as published
2129 + * by the Free Software Foundation.
2130 + */
2132 +#include <linux/pci.h>
2133 +#include <linux/ath9k_platform.h>
2134 +#include <linux/delay.h>
2136 +#include <asm/mach-ath79/ath79.h>
2138 +#include "dev-ap9x-pci.h"
2139 +#include "pci-ath9k-fixup.h"
2140 +#include "pci.h"
2142 +static struct ath9k_platform_data ap9x_wmac0_data = {
2143 + .led_pin = -1,
2145 +static struct ath9k_platform_data ap9x_wmac1_data = {
2146 + .led_pin = -1,
2148 +static char ap9x_wmac0_mac[6];
2149 +static char ap9x_wmac1_mac[6];
2151 +__init void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin)
2153 + switch (wmac) {
2154 + case 0:
2155 + ap9x_wmac0_data.led_pin = pin;
2156 + break;
2157 + case 1:
2158 + ap9x_wmac1_data.led_pin = pin;
2159 + break;
2163 +__init struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
2165 + switch (wmac) {
2166 + case 0:
2167 + return &ap9x_wmac0_data;
2169 + case 1:
2170 + return &ap9x_wmac1_data;
2173 + return NULL;
2176 +__init void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val)
2178 + switch (wmac) {
2179 + case 0:
2180 + ap9x_wmac0_data.gpio_mask = mask;
2181 + ap9x_wmac0_data.gpio_val = val;
2182 + break;
2183 + case 1:
2184 + ap9x_wmac1_data.gpio_mask = mask;
2185 + ap9x_wmac1_data.gpio_val = val;
2186 + break;
2190 +__init void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
2191 + int num_leds)
2193 + switch (wmac) {
2194 + case 0:
2195 + ap9x_wmac0_data.leds = leds;
2196 + ap9x_wmac0_data.num_leds = num_leds;
2197 + break;
2198 + case 1:
2199 + ap9x_wmac1_data.leds = leds;
2200 + ap9x_wmac1_data.num_leds = num_leds;
2201 + break;
2205 +static int ap91_pci_plat_dev_init(struct pci_dev *dev)
2207 + switch (PCI_SLOT(dev->devfn)) {
2208 + case 0:
2209 + dev->dev.platform_data = &ap9x_wmac0_data;
2210 + break;
2213 + return 0;
2216 +__init void ap91_pci_init(u8 *cal_data, u8 *mac_addr)
2218 + if (cal_data)
2219 + memcpy(ap9x_wmac0_data.eeprom_data, cal_data,
2220 + sizeof(ap9x_wmac0_data.eeprom_data));
2222 + if (mac_addr) {
2223 + memcpy(ap9x_wmac0_mac, mac_addr, sizeof(ap9x_wmac0_mac));
2224 + ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
2227 + ath79_pci_set_plat_dev_init(ap91_pci_plat_dev_init);
2228 + ath79_register_pci();
2230 + pci_enable_ath9k_fixup(0, ap9x_wmac0_data.eeprom_data);
2233 +__init void ap91_pci_init_simple(void)
2235 + ap91_pci_init(NULL, NULL);
2236 + ap9x_wmac0_data.eeprom_name = "pci_wmac0.eeprom";
2239 +static int ap94_pci_plat_dev_init(struct pci_dev *dev)
2241 + switch (PCI_SLOT(dev->devfn)) {
2242 + case 17:
2243 + dev->dev.platform_data = &ap9x_wmac0_data;
2244 + break;
2246 + case 18:
2247 + dev->dev.platform_data = &ap9x_wmac1_data;
2248 + break;
2251 + return 0;
2254 +__init void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
2255 + u8 *cal_data1, u8 *mac_addr1)
2257 + if (cal_data0)
2258 + memcpy(ap9x_wmac0_data.eeprom_data, cal_data0,
2259 + sizeof(ap9x_wmac0_data.eeprom_data));
2261 + if (cal_data1)
2262 + memcpy(ap9x_wmac1_data.eeprom_data, cal_data1,
2263 + sizeof(ap9x_wmac1_data.eeprom_data));
2265 + if (mac_addr0) {
2266 + memcpy(ap9x_wmac0_mac, mac_addr0, sizeof(ap9x_wmac0_mac));
2267 + ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
2270 + if (mac_addr1) {
2271 + memcpy(ap9x_wmac1_mac, mac_addr1, sizeof(ap9x_wmac1_mac));
2272 + ap9x_wmac1_data.macaddr = ap9x_wmac1_mac;
2275 + ath79_pci_set_plat_dev_init(ap94_pci_plat_dev_init);
2276 + ath79_register_pci();
2278 + pci_enable_ath9k_fixup(17, ap9x_wmac0_data.eeprom_data);
2279 + pci_enable_ath9k_fixup(18, ap9x_wmac1_data.eeprom_data);
2281 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-ap9x-pci.h linux-4.1.43/arch/mips/ath79/dev-ap9x-pci.h
2282 --- linux-4.1.43.orig/arch/mips/ath79/dev-ap9x-pci.h 1970-01-01 01:00:00.000000000 +0100
2283 +++ linux-4.1.43/arch/mips/ath79/dev-ap9x-pci.h 2017-08-06 20:02:15.000000000 +0200
2284 @@ -0,0 +1,48 @@
2286 + * Atheros AP9X reference board PCI initialization
2288 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
2290 + * This program is free software; you can redistribute it and/or modify it
2291 + * under the terms of the GNU General Public License version 2 as published
2292 + * by the Free Software Foundation.
2293 + */
2295 +#ifndef _ATH79_DEV_AP9X_PCI_H
2296 +#define _ATH79_DEV_AP9X_PCI_H
2298 +struct gpio_led;
2299 +struct ath9k_platform_data;
2301 +#if defined(CONFIG_ATH79_DEV_AP9X_PCI)
2302 +void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin);
2303 +void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val);
2304 +void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
2305 + int num_leds);
2306 +struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac);
2308 +void ap91_pci_init(u8 *cal_data, u8 *mac_addr);
2309 +void ap91_pci_init_simple(void);
2310 +void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
2311 + u8 *cal_data1, u8 *mac_addr1);
2313 +#else
2314 +static inline void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin) {}
2315 +static inline void ap9x_pci_setup_wmac_gpio(unsigned wmac,
2316 + u32 mask, u32 val) {}
2317 +static inline void ap9x_pci_setup_wmac_leds(unsigned wmac,
2318 + struct gpio_led *leds,
2319 + int num_leds) {}
2320 +static inline struct ath9k_platform_data *ap9x_pci_get_wmac_data(unsigned wmac)
2322 + return NULL;
2325 +static inline void ap91_pci_init(u8 *cal_data, u8 *mac_addr) {}
2326 +static inline void ap91_pci_init_simple(void) {}
2327 +static inline void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
2328 + u8 *cal_data1, u8 *mac_addr1) {}
2329 +#endif
2331 +#endif /* _ATH79_DEV_AP9X_PCI_H */
2333 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-common.c linux-4.1.43/arch/mips/ath79/dev-common.c
2334 --- linux-4.1.43.orig/arch/mips/ath79/dev-common.c 2017-08-06 01:56:14.000000000 +0200
2335 +++ linux-4.1.43/arch/mips/ath79/dev-common.c 2017-08-06 20:02:15.000000000 +0200
2336 @@ -80,11 +80,22 @@
2338 uart_clk_rate = ath79_get_sys_clk_rate("uart");
2340 + if (soc_is_ar71xx())
2341 + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_UART_EN);
2342 + else if (soc_is_ar724x())
2343 + ath79_gpio_function_enable(AR724X_GPIO_FUNC_UART_EN);
2344 + else if (soc_is_ar913x())
2345 + ath79_gpio_function_enable(AR913X_GPIO_FUNC_UART_EN);
2346 + else if (soc_is_ar933x())
2347 + ath79_gpio_function_enable(AR933X_GPIO_FUNC_UART_EN);
2349 if (soc_is_ar71xx() ||
2350 soc_is_ar724x() ||
2351 soc_is_ar913x() ||
2352 soc_is_ar934x() ||
2353 - soc_is_qca955x()) {
2354 + soc_is_qca953x() ||
2355 + soc_is_qca955x() ||
2356 + soc_is_qca956x()) {
2357 ath79_uart_data[0].uartclk = uart_clk_rate;
2358 platform_device_register(&ath79_uart_device);
2359 } else if (soc_is_ar933x()) {
2360 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-dsa.c linux-4.1.43/arch/mips/ath79/dev-dsa.c
2361 --- linux-4.1.43.orig/arch/mips/ath79/dev-dsa.c 1970-01-01 01:00:00.000000000 +0100
2362 +++ linux-4.1.43/arch/mips/ath79/dev-dsa.c 2017-08-06 20:02:15.000000000 +0200
2363 @@ -0,0 +1,41 @@
2365 + * Atheros AR71xx DSA switch device support
2367 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
2368 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
2370 + * This program is free software; you can redistribute it and/or modify it
2371 + * under the terms of the GNU General Public License version 2 as published
2372 + * by the Free Software Foundation.
2373 + */
2375 +#include <linux/init.h>
2376 +#include <linux/version.h>
2377 +#include <linux/platform_device.h>
2379 +#include <asm/mach-ath79/ath79.h>
2381 +#include "dev-dsa.h"
2383 +static struct platform_device ar71xx_dsa_switch_device = {
2384 + .name = "dsa",
2385 + .id = 0,
2388 +void __init ath79_register_dsa(struct device *netdev,
2389 + struct device *miidev,
2390 + struct dsa_platform_data *d)
2392 + int i;
2394 + d->netdev = netdev;
2395 + for (i = 0; i < d->nr_chips; i++)
2396 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
2397 + d->chip[i].mii_bus = miidev;
2398 +#else
2399 + d->chip[i].host_dev = miidev;
2400 +#endif
2402 + ar71xx_dsa_switch_device.dev.platform_data = d;
2403 + platform_device_register(&ar71xx_dsa_switch_device);
2405 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-dsa.h linux-4.1.43/arch/mips/ath79/dev-dsa.h
2406 --- linux-4.1.43.orig/arch/mips/ath79/dev-dsa.h 1970-01-01 01:00:00.000000000 +0100
2407 +++ linux-4.1.43/arch/mips/ath79/dev-dsa.h 2017-08-06 20:02:15.000000000 +0200
2408 @@ -0,0 +1,21 @@
2410 + * Atheros AR71xx DSA switch device support
2412 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
2413 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
2415 + * This program is free software; you can redistribute it and/or modify it
2416 + * under the terms of the GNU General Public License version 2 as published
2417 + * by the Free Software Foundation.
2418 + */
2420 +#ifndef _ATH79_DEV_DSA_H
2421 +#define _ATH79_DEV_DSA_H
2423 +#include <net/dsa.h>
2425 +void ath79_register_dsa(struct device *netdev,
2426 + struct device *miidev,
2427 + struct dsa_platform_data *d);
2429 +#endif /* _ATH79_DEV_DSA_H */
2430 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-eth.c linux-4.1.43/arch/mips/ath79/dev-eth.c
2431 --- linux-4.1.43.orig/arch/mips/ath79/dev-eth.c 1970-01-01 01:00:00.000000000 +0100
2432 +++ linux-4.1.43/arch/mips/ath79/dev-eth.c 2017-08-06 20:02:15.000000000 +0200
2433 @@ -0,0 +1,1254 @@
2435 + * Atheros AR71xx SoC platform devices
2437 + * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
2438 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
2439 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
2441 + * Parts of this file are based on Atheros 2.6.15 BSP
2442 + * Parts of this file are based on Atheros 2.6.31 BSP
2444 + * This program is free software; you can redistribute it and/or modify it
2445 + * under the terms of the GNU General Public License version 2 as published
2446 + * by the Free Software Foundation.
2447 + */
2449 +#include <linux/kernel.h>
2450 +#include <linux/init.h>
2451 +#include <linux/delay.h>
2452 +#include <linux/etherdevice.h>
2453 +#include <linux/platform_device.h>
2454 +#include <linux/serial_8250.h>
2455 +#include <linux/clk.h>
2456 +#include <linux/sizes.h>
2458 +#include <asm/mach-ath79/ath79.h>
2459 +#include <asm/mach-ath79/ar71xx_regs.h>
2460 +#include <asm/mach-ath79/irq.h>
2462 +#include "common.h"
2463 +#include "dev-eth.h"
2465 +unsigned char ath79_mac_base[ETH_ALEN] __initdata;
2467 +static struct resource ath79_mdio0_resources[] = {
2469 + .name = "mdio_base",
2470 + .flags = IORESOURCE_MEM,
2471 + .start = AR71XX_GE0_BASE,
2472 + .end = AR71XX_GE0_BASE + 0x200 - 1,
2476 +struct ag71xx_mdio_platform_data ath79_mdio0_data;
2478 +struct platform_device ath79_mdio0_device = {
2479 + .name = "ag71xx-mdio",
2480 + .id = 0,
2481 + .resource = ath79_mdio0_resources,
2482 + .num_resources = ARRAY_SIZE(ath79_mdio0_resources),
2483 + .dev = {
2484 + .platform_data = &ath79_mdio0_data,
2485 + },
2488 +static struct resource ath79_mdio1_resources[] = {
2490 + .name = "mdio_base",
2491 + .flags = IORESOURCE_MEM,
2492 + .start = AR71XX_GE1_BASE,
2493 + .end = AR71XX_GE1_BASE + 0x200 - 1,
2497 +struct ag71xx_mdio_platform_data ath79_mdio1_data;
2499 +struct platform_device ath79_mdio1_device = {
2500 + .name = "ag71xx-mdio",
2501 + .id = 1,
2502 + .resource = ath79_mdio1_resources,
2503 + .num_resources = ARRAY_SIZE(ath79_mdio1_resources),
2504 + .dev = {
2505 + .platform_data = &ath79_mdio1_data,
2506 + },
2509 +static void ath79_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
2511 + void __iomem *base;
2512 + u32 t;
2514 + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2516 + t = __raw_readl(base + cfg_reg);
2517 + t &= ~(3 << shift);
2518 + t |= (2 << shift);
2519 + __raw_writel(t, base + cfg_reg);
2520 + udelay(100);
2522 + __raw_writel(pll_val, base + pll_reg);
2524 + t |= (3 << shift);
2525 + __raw_writel(t, base + cfg_reg);
2526 + udelay(100);
2528 + t &= ~(3 << shift);
2529 + __raw_writel(t, base + cfg_reg);
2530 + udelay(100);
2532 + printk(KERN_DEBUG "ar71xx: pll_reg %#x: %#x\n",
2533 + (unsigned int)(base + pll_reg), __raw_readl(base + pll_reg));
2535 + iounmap(base);
2538 +static void __init ath79_mii_ctrl_set_if(unsigned int reg,
2539 + unsigned int mii_if)
2541 + void __iomem *base;
2542 + u32 t;
2544 + base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
2546 + t = __raw_readl(base + reg);
2547 + t &= ~(AR71XX_MII_CTRL_IF_MASK);
2548 + t |= (mii_if & AR71XX_MII_CTRL_IF_MASK);
2549 + __raw_writel(t, base + reg);
2551 + iounmap(base);
2554 +static void ath79_mii_ctrl_set_speed(unsigned int reg, unsigned int speed)
2556 + void __iomem *base;
2557 + unsigned int mii_speed;
2558 + u32 t;
2560 + switch (speed) {
2561 + case SPEED_10:
2562 + mii_speed = AR71XX_MII_CTRL_SPEED_10;
2563 + break;
2564 + case SPEED_100:
2565 + mii_speed = AR71XX_MII_CTRL_SPEED_100;
2566 + break;
2567 + case SPEED_1000:
2568 + mii_speed = AR71XX_MII_CTRL_SPEED_1000;
2569 + break;
2570 + default:
2571 + BUG();
2574 + base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
2576 + t = __raw_readl(base + reg);
2577 + t &= ~(AR71XX_MII_CTRL_SPEED_MASK << AR71XX_MII_CTRL_SPEED_SHIFT);
2578 + t |= mii_speed << AR71XX_MII_CTRL_SPEED_SHIFT;
2579 + __raw_writel(t, base + reg);
2581 + iounmap(base);
2584 +static unsigned long ar934x_get_mdio_ref_clock(void)
2586 + void __iomem *base;
2587 + unsigned long ret;
2588 + u32 t;
2590 + base = ioremap(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2592 + ret = 0;
2593 + t = __raw_readl(base + AR934X_PLL_SWITCH_CLOCK_CONTROL_REG);
2594 + if (t & AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL) {
2595 + ret = 100 * 1000 * 1000;
2596 + } else {
2597 + struct clk *clk;
2599 + clk = clk_get(NULL, "ref");
2600 + if (!IS_ERR(clk))
2601 + ret = clk_get_rate(clk);
2604 + iounmap(base);
2606 + return ret;
2609 +void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
2611 + struct platform_device *mdio_dev;
2612 + struct ag71xx_mdio_platform_data *mdio_data;
2613 + unsigned int max_id;
2615 + if (ath79_soc == ATH79_SOC_AR9341 ||
2616 + ath79_soc == ATH79_SOC_AR9342 ||
2617 + ath79_soc == ATH79_SOC_AR9344 ||
2618 + ath79_soc == ATH79_SOC_QCA9556 ||
2619 + ath79_soc == ATH79_SOC_QCA9558)
2620 + max_id = 1;
2621 + else
2622 + max_id = 0;
2624 + if (id > max_id) {
2625 + printk(KERN_ERR "ar71xx: invalid MDIO id %u\n", id);
2626 + return;
2629 + switch (ath79_soc) {
2630 + case ATH79_SOC_AR7241:
2631 + case ATH79_SOC_AR9330:
2632 + case ATH79_SOC_AR9331:
2633 + case ATH79_SOC_QCA9533:
2634 + case ATH79_SOC_QCA9561:
2635 + case ATH79_SOC_TP9343:
2636 + mdio_dev = &ath79_mdio1_device;
2637 + mdio_data = &ath79_mdio1_data;
2638 + break;
2640 + case ATH79_SOC_AR9341:
2641 + case ATH79_SOC_AR9342:
2642 + case ATH79_SOC_AR9344:
2643 + case ATH79_SOC_QCA9556:
2644 + case ATH79_SOC_QCA9558:
2645 + if (id == 0) {
2646 + mdio_dev = &ath79_mdio0_device;
2647 + mdio_data = &ath79_mdio0_data;
2648 + } else {
2649 + mdio_dev = &ath79_mdio1_device;
2650 + mdio_data = &ath79_mdio1_data;
2652 + break;
2654 + case ATH79_SOC_AR7242:
2655 + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG,
2656 + AR7242_PLL_REG_ETH0_INT_CLOCK, 0x62000000,
2657 + AR71XX_ETH0_PLL_SHIFT);
2658 + /* fall through */
2659 + default:
2660 + mdio_dev = &ath79_mdio0_device;
2661 + mdio_data = &ath79_mdio0_data;
2662 + break;
2665 + mdio_data->phy_mask = phy_mask;
2667 + switch (ath79_soc) {
2668 + case ATH79_SOC_AR7240:
2669 + mdio_data->is_ar7240 = 1;
2670 + /* fall through */
2671 + case ATH79_SOC_AR7241:
2672 + mdio_data->builtin_switch = 1;
2673 + break;
2675 + case ATH79_SOC_AR9330:
2676 + mdio_data->is_ar9330 = 1;
2677 + /* fall through */
2678 + case ATH79_SOC_AR9331:
2679 + mdio_data->builtin_switch = 1;
2680 + break;
2682 + case ATH79_SOC_AR9341:
2683 + case ATH79_SOC_AR9342:
2684 + case ATH79_SOC_AR9344:
2685 + if (id == 1) {
2686 + mdio_data->builtin_switch = 1;
2687 + mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
2688 + mdio_data->mdio_clock = 6250000;
2690 + mdio_data->is_ar934x = 1;
2691 + break;
2693 + case ATH79_SOC_QCA9533:
2694 + case ATH79_SOC_QCA9561:
2695 + case ATH79_SOC_TP9343:
2696 + mdio_data->builtin_switch = 1;
2697 + break;
2699 + case ATH79_SOC_QCA9556:
2700 + case ATH79_SOC_QCA9558:
2701 + mdio_data->is_ar934x = 1;
2702 + break;
2704 + default:
2705 + break;
2708 + platform_device_register(mdio_dev);
2711 +struct ath79_eth_pll_data ath79_eth0_pll_data;
2712 +struct ath79_eth_pll_data ath79_eth1_pll_data;
2714 +static u32 ath79_get_eth_pll(unsigned int mac, int speed)
2716 + struct ath79_eth_pll_data *pll_data;
2717 + u32 pll_val;
2719 + switch (mac) {
2720 + case 0:
2721 + pll_data = &ath79_eth0_pll_data;
2722 + break;
2723 + case 1:
2724 + pll_data = &ath79_eth1_pll_data;
2725 + break;
2726 + default:
2727 + BUG();
2730 + switch (speed) {
2731 + case SPEED_10:
2732 + pll_val = pll_data->pll_10;
2733 + break;
2734 + case SPEED_100:
2735 + pll_val = pll_data->pll_100;
2736 + break;
2737 + case SPEED_1000:
2738 + pll_val = pll_data->pll_1000;
2739 + break;
2740 + default:
2741 + BUG();
2744 + return pll_val;
2747 +static void ath79_set_speed_ge0(int speed)
2749 + u32 val = ath79_get_eth_pll(0, speed);
2751 + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH0_INT_CLOCK,
2752 + val, AR71XX_ETH0_PLL_SHIFT);
2753 + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
2756 +static void ath79_set_speed_ge1(int speed)
2758 + u32 val = ath79_get_eth_pll(1, speed);
2760 + ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH1_INT_CLOCK,
2761 + val, AR71XX_ETH1_PLL_SHIFT);
2762 + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
2765 +static void ar7242_set_speed_ge0(int speed)
2767 + u32 val = ath79_get_eth_pll(0, speed);
2768 + void __iomem *base;
2770 + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2771 + __raw_writel(val, base + AR7242_PLL_REG_ETH0_INT_CLOCK);
2772 + iounmap(base);
2775 +static void ar91xx_set_speed_ge0(int speed)
2777 + u32 val = ath79_get_eth_pll(0, speed);
2779 + ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH0_INT_CLOCK,
2780 + val, AR913X_ETH0_PLL_SHIFT);
2781 + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
2784 +static void ar91xx_set_speed_ge1(int speed)
2786 + u32 val = ath79_get_eth_pll(1, speed);
2788 + ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH1_INT_CLOCK,
2789 + val, AR913X_ETH1_PLL_SHIFT);
2790 + ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
2793 +static void ar934x_set_speed_ge0(int speed)
2795 + void __iomem *base;
2796 + u32 val = ath79_get_eth_pll(0, speed);
2798 + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2799 + __raw_writel(val, base + AR934X_PLL_ETH_XMII_CONTROL_REG);
2800 + iounmap(base);
2803 +static void qca955x_set_speed_xmii(int speed)
2805 + void __iomem *base;
2806 + u32 val = ath79_get_eth_pll(0, speed);
2808 + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2809 + __raw_writel(val, base + QCA955X_PLL_ETH_XMII_CONTROL_REG);
2810 + iounmap(base);
2813 +static void qca955x_set_speed_sgmii(int speed)
2815 + void __iomem *base;
2816 + u32 val = ath79_get_eth_pll(1, speed);
2818 + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
2819 + __raw_writel(val, base + QCA955X_PLL_ETH_SGMII_CONTROL_REG);
2820 + iounmap(base);
2823 +static void ath79_set_speed_dummy(int speed)
2827 +static void ath79_ddr_no_flush(void)
2831 +static void ath79_ddr_flush_ge0(void)
2833 + ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_GE0);
2836 +static void ath79_ddr_flush_ge1(void)
2838 + ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_GE1);
2841 +static void ar724x_ddr_flush_ge0(void)
2843 + ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_GE0);
2846 +static void ar724x_ddr_flush_ge1(void)
2848 + ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_GE1);
2851 +static void ar91xx_ddr_flush_ge0(void)
2853 + ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_GE0);
2856 +static void ar91xx_ddr_flush_ge1(void)
2858 + ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_GE1);
2861 +static void ar933x_ddr_flush_ge0(void)
2863 + ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_GE0);
2866 +static void ar933x_ddr_flush_ge1(void)
2868 + ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_GE1);
2871 +static struct resource ath79_eth0_resources[] = {
2873 + .name = "mac_base",
2874 + .flags = IORESOURCE_MEM,
2875 + .start = AR71XX_GE0_BASE,
2876 + .end = AR71XX_GE0_BASE + 0x200 - 1,
2877 + }, {
2878 + .name = "mac_irq",
2879 + .flags = IORESOURCE_IRQ,
2880 + .start = ATH79_CPU_IRQ(4),
2881 + .end = ATH79_CPU_IRQ(4),
2882 + },
2885 +struct ag71xx_platform_data ath79_eth0_data = {
2886 + .reset_bit = AR71XX_RESET_GE0_MAC,
2889 +struct platform_device ath79_eth0_device = {
2890 + .name = "ag71xx",
2891 + .id = 0,
2892 + .resource = ath79_eth0_resources,
2893 + .num_resources = ARRAY_SIZE(ath79_eth0_resources),
2894 + .dev = {
2895 + .platform_data = &ath79_eth0_data,
2896 + },
2899 +static struct resource ath79_eth1_resources[] = {
2901 + .name = "mac_base",
2902 + .flags = IORESOURCE_MEM,
2903 + .start = AR71XX_GE1_BASE,
2904 + .end = AR71XX_GE1_BASE + 0x200 - 1,
2905 + }, {
2906 + .name = "mac_irq",
2907 + .flags = IORESOURCE_IRQ,
2908 + .start = ATH79_CPU_IRQ(5),
2909 + .end = ATH79_CPU_IRQ(5),
2910 + },
2913 +struct ag71xx_platform_data ath79_eth1_data = {
2914 + .reset_bit = AR71XX_RESET_GE1_MAC,
2917 +struct platform_device ath79_eth1_device = {
2918 + .name = "ag71xx",
2919 + .id = 1,
2920 + .resource = ath79_eth1_resources,
2921 + .num_resources = ARRAY_SIZE(ath79_eth1_resources),
2922 + .dev = {
2923 + .platform_data = &ath79_eth1_data,
2924 + },
2927 +struct ag71xx_switch_platform_data ath79_switch_data;
2929 +#define AR71XX_PLL_VAL_1000 0x00110000
2930 +#define AR71XX_PLL_VAL_100 0x00001099
2931 +#define AR71XX_PLL_VAL_10 0x00991099
2933 +#define AR724X_PLL_VAL_1000 0x00110000
2934 +#define AR724X_PLL_VAL_100 0x00001099
2935 +#define AR724X_PLL_VAL_10 0x00991099
2937 +#define AR7242_PLL_VAL_1000 0x16000000
2938 +#define AR7242_PLL_VAL_100 0x00000101
2939 +#define AR7242_PLL_VAL_10 0x00001616
2941 +#define AR913X_PLL_VAL_1000 0x1a000000
2942 +#define AR913X_PLL_VAL_100 0x13000a44
2943 +#define AR913X_PLL_VAL_10 0x00441099
2945 +#define AR933X_PLL_VAL_1000 0x00110000
2946 +#define AR933X_PLL_VAL_100 0x00001099
2947 +#define AR933X_PLL_VAL_10 0x00991099
2949 +#define AR934X_PLL_VAL_1000 0x16000000
2950 +#define AR934X_PLL_VAL_100 0x00000101
2951 +#define AR934X_PLL_VAL_10 0x00001616
2953 +static void __init ath79_init_eth_pll_data(unsigned int id)
2955 + struct ath79_eth_pll_data *pll_data;
2956 + u32 pll_10, pll_100, pll_1000;
2958 + switch (id) {
2959 + case 0:
2960 + pll_data = &ath79_eth0_pll_data;
2961 + break;
2962 + case 1:
2963 + pll_data = &ath79_eth1_pll_data;
2964 + break;
2965 + default:
2966 + BUG();
2969 + switch (ath79_soc) {
2970 + case ATH79_SOC_AR7130:
2971 + case ATH79_SOC_AR7141:
2972 + case ATH79_SOC_AR7161:
2973 + pll_10 = AR71XX_PLL_VAL_10;
2974 + pll_100 = AR71XX_PLL_VAL_100;
2975 + pll_1000 = AR71XX_PLL_VAL_1000;
2976 + break;
2978 + case ATH79_SOC_AR7240:
2979 + case ATH79_SOC_AR7241:
2980 + pll_10 = AR724X_PLL_VAL_10;
2981 + pll_100 = AR724X_PLL_VAL_100;
2982 + pll_1000 = AR724X_PLL_VAL_1000;
2983 + break;
2985 + case ATH79_SOC_AR7242:
2986 + pll_10 = AR7242_PLL_VAL_10;
2987 + pll_100 = AR7242_PLL_VAL_100;
2988 + pll_1000 = AR7242_PLL_VAL_1000;
2989 + break;
2991 + case ATH79_SOC_AR9130:
2992 + case ATH79_SOC_AR9132:
2993 + pll_10 = AR913X_PLL_VAL_10;
2994 + pll_100 = AR913X_PLL_VAL_100;
2995 + pll_1000 = AR913X_PLL_VAL_1000;
2996 + break;
2998 + case ATH79_SOC_AR9330:
2999 + case ATH79_SOC_AR9331:
3000 + pll_10 = AR933X_PLL_VAL_10;
3001 + pll_100 = AR933X_PLL_VAL_100;
3002 + pll_1000 = AR933X_PLL_VAL_1000;
3003 + break;
3005 + case ATH79_SOC_AR9341:
3006 + case ATH79_SOC_AR9342:
3007 + case ATH79_SOC_AR9344:
3008 + case ATH79_SOC_QCA9533:
3009 + case ATH79_SOC_QCA9556:
3010 + case ATH79_SOC_QCA9558:
3011 + case ATH79_SOC_QCA9561:
3012 + case ATH79_SOC_TP9343:
3013 + pll_10 = AR934X_PLL_VAL_10;
3014 + pll_100 = AR934X_PLL_VAL_100;
3015 + pll_1000 = AR934X_PLL_VAL_1000;
3016 + break;
3018 + default:
3019 + BUG();
3022 + if (!pll_data->pll_10)
3023 + pll_data->pll_10 = pll_10;
3025 + if (!pll_data->pll_100)
3026 + pll_data->pll_100 = pll_100;
3028 + if (!pll_data->pll_1000)
3029 + pll_data->pll_1000 = pll_1000;
3032 +static int __init ath79_setup_phy_if_mode(unsigned int id,
3033 + struct ag71xx_platform_data *pdata)
3035 + unsigned int mii_if;
3037 + switch (id) {
3038 + case 0:
3039 + switch (ath79_soc) {
3040 + case ATH79_SOC_AR7130:
3041 + case ATH79_SOC_AR7141:
3042 + case ATH79_SOC_AR7161:
3043 + case ATH79_SOC_AR9130:
3044 + case ATH79_SOC_AR9132:
3045 + switch (pdata->phy_if_mode) {
3046 + case PHY_INTERFACE_MODE_MII:
3047 + mii_if = AR71XX_MII0_CTRL_IF_MII;
3048 + break;
3049 + case PHY_INTERFACE_MODE_GMII:
3050 + mii_if = AR71XX_MII0_CTRL_IF_GMII;
3051 + break;
3052 + case PHY_INTERFACE_MODE_RGMII:
3053 + mii_if = AR71XX_MII0_CTRL_IF_RGMII;
3054 + break;
3055 + case PHY_INTERFACE_MODE_RMII:
3056 + mii_if = AR71XX_MII0_CTRL_IF_RMII;
3057 + break;
3058 + default:
3059 + return -EINVAL;
3061 + ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII0_CTRL, mii_if);
3062 + break;
3064 + case ATH79_SOC_AR7240:
3065 + case ATH79_SOC_AR7241:
3066 + case ATH79_SOC_AR9330:
3067 + case ATH79_SOC_AR9331:
3068 + case ATH79_SOC_QCA9533:
3069 + case ATH79_SOC_TP9343:
3070 + pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
3071 + break;
3073 + case ATH79_SOC_AR7242:
3074 + /* FIXME */
3076 + case ATH79_SOC_AR9341:
3077 + case ATH79_SOC_AR9342:
3078 + case ATH79_SOC_AR9344:
3079 + switch (pdata->phy_if_mode) {
3080 + case PHY_INTERFACE_MODE_MII:
3081 + case PHY_INTERFACE_MODE_GMII:
3082 + case PHY_INTERFACE_MODE_RGMII:
3083 + case PHY_INTERFACE_MODE_RMII:
3084 + break;
3085 + default:
3086 + return -EINVAL;
3088 + break;
3090 + case ATH79_SOC_QCA9556:
3091 + case ATH79_SOC_QCA9558:
3092 + switch (pdata->phy_if_mode) {
3093 + case PHY_INTERFACE_MODE_MII:
3094 + case PHY_INTERFACE_MODE_RGMII:
3095 + case PHY_INTERFACE_MODE_SGMII:
3096 + break;
3097 + default:
3098 + return -EINVAL;
3100 + break;
3102 + case ATH79_SOC_QCA9561:
3103 + if (!pdata->phy_if_mode)
3104 + pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
3105 + break;
3107 + default:
3108 + BUG();
3110 + break;
3111 + case 1:
3112 + switch (ath79_soc) {
3113 + case ATH79_SOC_AR7130:
3114 + case ATH79_SOC_AR7141:
3115 + case ATH79_SOC_AR7161:
3116 + case ATH79_SOC_AR9130:
3117 + case ATH79_SOC_AR9132:
3118 + switch (pdata->phy_if_mode) {
3119 + case PHY_INTERFACE_MODE_RMII:
3120 + mii_if = AR71XX_MII1_CTRL_IF_RMII;
3121 + break;
3122 + case PHY_INTERFACE_MODE_RGMII:
3123 + mii_if = AR71XX_MII1_CTRL_IF_RGMII;
3124 + break;
3125 + default:
3126 + return -EINVAL;
3128 + ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII1_CTRL, mii_if);
3129 + break;
3131 + case ATH79_SOC_AR7240:
3132 + case ATH79_SOC_AR7241:
3133 + case ATH79_SOC_AR9330:
3134 + case ATH79_SOC_AR9331:
3135 + case ATH79_SOC_QCA9561:
3136 + case ATH79_SOC_TP9343:
3137 + pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
3138 + break;
3140 + case ATH79_SOC_AR7242:
3141 + /* FIXME */
3143 + case ATH79_SOC_AR9341:
3144 + case ATH79_SOC_AR9342:
3145 + case ATH79_SOC_AR9344:
3146 + case ATH79_SOC_QCA9533:
3147 + switch (pdata->phy_if_mode) {
3148 + case PHY_INTERFACE_MODE_MII:
3149 + case PHY_INTERFACE_MODE_GMII:
3150 + break;
3151 + default:
3152 + return -EINVAL;
3154 + break;
3156 + case ATH79_SOC_QCA9556:
3157 + case ATH79_SOC_QCA9558:
3158 + switch (pdata->phy_if_mode) {
3159 + case PHY_INTERFACE_MODE_MII:
3160 + case PHY_INTERFACE_MODE_RGMII:
3161 + case PHY_INTERFACE_MODE_SGMII:
3162 + break;
3163 + default:
3164 + return -EINVAL;
3166 + break;
3168 + default:
3169 + BUG();
3171 + break;
3174 + return 0;
3177 +void __init ath79_setup_ar933x_phy4_switch(bool mac, bool mdio)
3179 + void __iomem *base;
3180 + u32 t;
3182 + base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
3184 + t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
3185 + t &= ~(AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
3186 + if (mac)
3187 + t |= AR933X_ETH_CFG_SW_PHY_SWAP;
3188 + if (mdio)
3189 + t |= AR933X_ETH_CFG_SW_PHY_ADDR_SWAP;
3190 + __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
3192 + iounmap(base);
3195 +void __init ath79_setup_ar934x_eth_cfg(u32 mask)
3197 + void __iomem *base;
3198 + u32 t;
3200 + base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
3202 + t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
3204 + t &= ~(AR934X_ETH_CFG_RGMII_GMAC0 |
3205 + AR934X_ETH_CFG_MII_GMAC0 |
3206 + AR934X_ETH_CFG_GMII_GMAC0 |
3207 + AR934X_ETH_CFG_SW_ONLY_MODE |
3208 + AR934X_ETH_CFG_SW_PHY_SWAP);
3210 + t |= mask;
3212 + __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
3213 + /* flush write */
3214 + __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
3216 + iounmap(base);
3219 +void __init ath79_setup_ar934x_eth_rx_delay(unsigned int rxd,
3220 + unsigned int rxdv)
3222 + void __iomem *base;
3223 + u32 t;
3225 + rxd &= AR934X_ETH_CFG_RXD_DELAY_MASK;
3226 + rxdv &= AR934X_ETH_CFG_RDV_DELAY_MASK;
3228 + base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
3230 + t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
3232 + t &= ~(AR934X_ETH_CFG_RXD_DELAY_MASK << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
3233 + AR934X_ETH_CFG_RDV_DELAY_MASK << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
3235 + t |= (rxd << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
3236 + rxdv << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
3238 + __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
3239 + /* flush write */
3240 + __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
3242 + iounmap(base);
3245 +void __init ath79_setup_qca955x_eth_cfg(u32 mask)
3247 + void __iomem *base;
3248 + u32 t;
3250 + base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
3252 + t = __raw_readl(base + QCA955X_GMAC_REG_ETH_CFG);
3254 + t &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
3256 + t |= mask;
3258 + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
3260 + iounmap(base);
3263 +static int ath79_eth_instance __initdata;
3264 +void __init ath79_register_eth(unsigned int id)
3266 + struct platform_device *pdev;
3267 + struct ag71xx_platform_data *pdata;
3268 + int err;
3270 + if (id > 1) {
3271 + printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
3272 + return;
3275 + ath79_init_eth_pll_data(id);
3277 + if (id == 0)
3278 + pdev = &ath79_eth0_device;
3279 + else
3280 + pdev = &ath79_eth1_device;
3282 + pdata = pdev->dev.platform_data;
3284 + pdata->max_frame_len = 1540;
3285 + pdata->desc_pktlen_mask = 0xfff;
3287 + err = ath79_setup_phy_if_mode(id, pdata);
3288 + if (err) {
3289 + printk(KERN_ERR
3290 + "ar71xx: invalid PHY interface mode for GE%u\n", id);
3291 + return;
3294 + switch (ath79_soc) {
3295 + case ATH79_SOC_AR7130:
3296 + if (id == 0) {
3297 + pdata->ddr_flush = ath79_ddr_flush_ge0;
3298 + pdata->set_speed = ath79_set_speed_ge0;
3299 + } else {
3300 + pdata->ddr_flush = ath79_ddr_flush_ge1;
3301 + pdata->set_speed = ath79_set_speed_ge1;
3303 + break;
3305 + case ATH79_SOC_AR7141:
3306 + case ATH79_SOC_AR7161:
3307 + if (id == 0) {
3308 + pdata->ddr_flush = ath79_ddr_flush_ge0;
3309 + pdata->set_speed = ath79_set_speed_ge0;
3310 + } else {
3311 + pdata->ddr_flush = ath79_ddr_flush_ge1;
3312 + pdata->set_speed = ath79_set_speed_ge1;
3314 + pdata->has_gbit = 1;
3315 + break;
3317 + case ATH79_SOC_AR7242:
3318 + if (id == 0) {
3319 + pdata->reset_bit |= AR724X_RESET_GE0_MDIO |
3320 + AR71XX_RESET_GE0_PHY;
3321 + pdata->ddr_flush = ar724x_ddr_flush_ge0;
3322 + pdata->set_speed = ar7242_set_speed_ge0;
3323 + } else {
3324 + pdata->reset_bit |= AR724X_RESET_GE1_MDIO |
3325 + AR71XX_RESET_GE1_PHY;
3326 + pdata->ddr_flush = ar724x_ddr_flush_ge1;
3327 + pdata->set_speed = ath79_set_speed_dummy;
3329 + pdata->has_gbit = 1;
3330 + pdata->is_ar724x = 1;
3332 + if (!pdata->fifo_cfg1)
3333 + pdata->fifo_cfg1 = 0x0010ffff;
3334 + if (!pdata->fifo_cfg2)
3335 + pdata->fifo_cfg2 = 0x015500aa;
3336 + if (!pdata->fifo_cfg3)
3337 + pdata->fifo_cfg3 = 0x01f00140;
3338 + break;
3340 + case ATH79_SOC_AR7241:
3341 + if (id == 0)
3342 + pdata->reset_bit |= AR724X_RESET_GE0_MDIO;
3343 + else
3344 + pdata->reset_bit |= AR724X_RESET_GE1_MDIO;
3345 + /* fall through */
3346 + case ATH79_SOC_AR7240:
3347 + if (id == 0) {
3348 + pdata->reset_bit |= AR71XX_RESET_GE0_PHY;
3349 + pdata->ddr_flush = ar724x_ddr_flush_ge0;
3350 + pdata->set_speed = ath79_set_speed_dummy;
3352 + pdata->phy_mask = BIT(4);
3353 + } else {
3354 + pdata->reset_bit |= AR71XX_RESET_GE1_PHY;
3355 + pdata->ddr_flush = ar724x_ddr_flush_ge1;
3356 + pdata->set_speed = ath79_set_speed_dummy;
3358 + pdata->speed = SPEED_1000;
3359 + pdata->duplex = DUPLEX_FULL;
3360 + pdata->switch_data = &ath79_switch_data;
3362 + ath79_switch_data.phy_poll_mask |= BIT(4);
3364 + pdata->has_gbit = 1;
3365 + pdata->is_ar724x = 1;
3366 + if (ath79_soc == ATH79_SOC_AR7240)
3367 + pdata->is_ar7240 = 1;
3369 + if (!pdata->fifo_cfg1)
3370 + pdata->fifo_cfg1 = 0x0010ffff;
3371 + if (!pdata->fifo_cfg2)
3372 + pdata->fifo_cfg2 = 0x015500aa;
3373 + if (!pdata->fifo_cfg3)
3374 + pdata->fifo_cfg3 = 0x01f00140;
3375 + break;
3377 + case ATH79_SOC_AR9130:
3378 + if (id == 0) {
3379 + pdata->ddr_flush = ar91xx_ddr_flush_ge0;
3380 + pdata->set_speed = ar91xx_set_speed_ge0;
3381 + } else {
3382 + pdata->ddr_flush = ar91xx_ddr_flush_ge1;
3383 + pdata->set_speed = ar91xx_set_speed_ge1;
3385 + pdata->is_ar91xx = 1;
3386 + break;
3388 + case ATH79_SOC_AR9132:
3389 + if (id == 0) {
3390 + pdata->ddr_flush = ar91xx_ddr_flush_ge0;
3391 + pdata->set_speed = ar91xx_set_speed_ge0;
3392 + } else {
3393 + pdata->ddr_flush = ar91xx_ddr_flush_ge1;
3394 + pdata->set_speed = ar91xx_set_speed_ge1;
3396 + pdata->is_ar91xx = 1;
3397 + pdata->has_gbit = 1;
3398 + break;
3400 + case ATH79_SOC_AR9330:
3401 + case ATH79_SOC_AR9331:
3402 + if (id == 0) {
3403 + pdata->reset_bit = AR933X_RESET_GE0_MAC |
3404 + AR933X_RESET_GE0_MDIO;
3405 + pdata->ddr_flush = ar933x_ddr_flush_ge0;
3406 + pdata->set_speed = ath79_set_speed_dummy;
3408 + pdata->phy_mask = BIT(4);
3409 + } else {
3410 + pdata->reset_bit = AR933X_RESET_GE1_MAC |
3411 + AR933X_RESET_GE1_MDIO;
3412 + pdata->ddr_flush = ar933x_ddr_flush_ge1;
3413 + pdata->set_speed = ath79_set_speed_dummy;
3415 + pdata->speed = SPEED_1000;
3416 + pdata->has_gbit = 1;
3417 + pdata->duplex = DUPLEX_FULL;
3418 + pdata->switch_data = &ath79_switch_data;
3420 + ath79_switch_data.phy_poll_mask |= BIT(4);
3423 + pdata->is_ar724x = 1;
3425 + if (!pdata->fifo_cfg1)
3426 + pdata->fifo_cfg1 = 0x0010ffff;
3427 + if (!pdata->fifo_cfg2)
3428 + pdata->fifo_cfg2 = 0x015500aa;
3429 + if (!pdata->fifo_cfg3)
3430 + pdata->fifo_cfg3 = 0x01f00140;
3431 + break;
3433 + case ATH79_SOC_AR9341:
3434 + case ATH79_SOC_AR9342:
3435 + case ATH79_SOC_AR9344:
3436 + case ATH79_SOC_QCA9533:
3437 + if (id == 0) {
3438 + pdata->reset_bit = AR934X_RESET_GE0_MAC |
3439 + AR934X_RESET_GE0_MDIO;
3440 + pdata->set_speed = ar934x_set_speed_ge0;
3441 + } else {
3442 + pdata->reset_bit = AR934X_RESET_GE1_MAC |
3443 + AR934X_RESET_GE1_MDIO;
3444 + pdata->set_speed = ath79_set_speed_dummy;
3446 + pdata->switch_data = &ath79_switch_data;
3448 + /* reset the built-in switch */
3449 + ath79_device_reset_set(AR934X_RESET_ETH_SWITCH);
3450 + ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH);
3453 + pdata->ddr_flush = ath79_ddr_no_flush;
3454 + pdata->has_gbit = 1;
3455 + pdata->is_ar724x = 1;
3457 + pdata->max_frame_len = SZ_16K - 1;
3458 + pdata->desc_pktlen_mask = SZ_16K - 1;
3460 + if (!pdata->fifo_cfg1)
3461 + pdata->fifo_cfg1 = 0x0010ffff;
3462 + if (!pdata->fifo_cfg2)
3463 + pdata->fifo_cfg2 = 0x015500aa;
3464 + if (!pdata->fifo_cfg3)
3465 + pdata->fifo_cfg3 = 0x01f00140;
3466 + break;
3468 + case ATH79_SOC_QCA9561:
3469 + case ATH79_SOC_TP9343:
3470 + if (id == 0) {
3471 + pdata->reset_bit = AR933X_RESET_GE0_MAC |
3472 + AR933X_RESET_GE0_MDIO;
3473 + pdata->set_speed = ath79_set_speed_dummy;
3475 + if (!pdata->phy_mask)
3476 + pdata->phy_mask = BIT(4);
3477 + } else {
3478 + pdata->reset_bit = AR933X_RESET_GE1_MAC |
3479 + AR933X_RESET_GE1_MDIO;
3480 + pdata->set_speed = ath79_set_speed_dummy;
3482 + pdata->speed = SPEED_1000;
3483 + pdata->duplex = DUPLEX_FULL;
3484 + pdata->switch_data = &ath79_switch_data;
3486 + ath79_switch_data.phy_poll_mask |= BIT(4);
3489 + pdata->ddr_flush = ath79_ddr_no_flush;
3490 + pdata->has_gbit = 1;
3491 + pdata->is_ar724x = 1;
3493 + if (!pdata->fifo_cfg1)
3494 + pdata->fifo_cfg1 = 0x0010ffff;
3495 + if (!pdata->fifo_cfg2)
3496 + pdata->fifo_cfg2 = 0x015500aa;
3497 + if (!pdata->fifo_cfg3)
3498 + pdata->fifo_cfg3 = 0x01f00140;
3499 + break;
3501 + case ATH79_SOC_QCA9556:
3502 + case ATH79_SOC_QCA9558:
3503 + if (id == 0) {
3504 + pdata->reset_bit = QCA955X_RESET_GE0_MAC |
3505 + QCA955X_RESET_GE0_MDIO;
3506 + pdata->set_speed = qca955x_set_speed_xmii;
3507 + } else {
3508 + pdata->reset_bit = QCA955X_RESET_GE1_MAC |
3509 + QCA955X_RESET_GE1_MDIO;
3510 + pdata->set_speed = qca955x_set_speed_sgmii;
3513 + pdata->ddr_flush = ath79_ddr_no_flush;
3514 + pdata->has_gbit = 1;
3515 + pdata->is_ar724x = 1;
3517 + /*
3518 + * Limit the maximum frame length to 4095 bytes.
3519 + * Although the documentation says that the hardware
3520 + * limit is 16383 bytes but that does not work in
3521 + * practice. It seems that the hardware only updates
3522 + * the lowest 12 bits of the packet length field
3523 + * in the RX descriptor.
3524 + */
3525 + pdata->max_frame_len = SZ_4K - 1;
3526 + pdata->desc_pktlen_mask = SZ_16K - 1;
3528 + if (!pdata->fifo_cfg1)
3529 + pdata->fifo_cfg1 = 0x0010ffff;
3530 + if (!pdata->fifo_cfg2)
3531 + pdata->fifo_cfg2 = 0x015500aa;
3532 + if (!pdata->fifo_cfg3)
3533 + pdata->fifo_cfg3 = 0x01f00140;
3534 + break;
3536 + default:
3537 + BUG();
3540 + switch (pdata->phy_if_mode) {
3541 + case PHY_INTERFACE_MODE_GMII:
3542 + case PHY_INTERFACE_MODE_RGMII:
3543 + case PHY_INTERFACE_MODE_SGMII:
3544 + if (!pdata->has_gbit) {
3545 + printk(KERN_ERR "ar71xx: no gbit available on eth%d\n",
3546 + id);
3547 + return;
3549 + /* fallthrough */
3550 + default:
3551 + break;
3554 + if (!is_valid_ether_addr(pdata->mac_addr)) {
3555 + random_ether_addr(pdata->mac_addr);
3556 + printk(KERN_DEBUG
3557 + "ar71xx: using random MAC address for eth%d\n",
3558 + ath79_eth_instance);
3561 + if (pdata->mii_bus_dev == NULL) {
3562 + switch (ath79_soc) {
3563 + case ATH79_SOC_AR9341:
3564 + case ATH79_SOC_AR9342:
3565 + case ATH79_SOC_AR9344:
3566 + if (id == 0)
3567 + pdata->mii_bus_dev = &ath79_mdio0_device.dev;
3568 + else
3569 + pdata->mii_bus_dev = &ath79_mdio1_device.dev;
3570 + break;
3572 + case ATH79_SOC_AR7241:
3573 + case ATH79_SOC_AR9330:
3574 + case ATH79_SOC_AR9331:
3575 + case ATH79_SOC_QCA9533:
3576 + case ATH79_SOC_QCA9561:
3577 + case ATH79_SOC_TP9343:
3578 + pdata->mii_bus_dev = &ath79_mdio1_device.dev;
3579 + break;
3581 + case ATH79_SOC_QCA9556:
3582 + case ATH79_SOC_QCA9558:
3583 + /* don't assign any MDIO device by default */
3584 + break;
3586 + default:
3587 + pdata->mii_bus_dev = &ath79_mdio0_device.dev;
3588 + break;
3592 + /* Reset the device */
3593 + ath79_device_reset_set(pdata->reset_bit);
3594 + msleep(100);
3596 + ath79_device_reset_clear(pdata->reset_bit);
3597 + msleep(100);
3599 + platform_device_register(pdev);
3600 + ath79_eth_instance++;
3603 +void __init ath79_set_mac_base(unsigned char *mac)
3605 + memcpy(ath79_mac_base, mac, ETH_ALEN);
3608 +void __init ath79_parse_ascii_mac(char *mac_str, u8 *mac)
3610 + int t;
3612 + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
3613 + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
3615 + if (t != ETH_ALEN)
3616 + t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
3617 + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
3619 + if (t != ETH_ALEN || !is_valid_ether_addr(mac)) {
3620 + memset(mac, 0, ETH_ALEN);
3621 + printk(KERN_DEBUG "ar71xx: invalid mac address \"%s\"\n",
3622 + mac_str);
3626 +static void __init ath79_set_mac_base_ascii(char *str)
3628 + u8 mac[ETH_ALEN];
3630 + ath79_parse_ascii_mac(str, mac);
3631 + ath79_set_mac_base(mac);
3634 +static int __init ath79_ethaddr_setup(char *str)
3636 + ath79_set_mac_base_ascii(str);
3637 + return 1;
3639 +__setup("ethaddr=", ath79_ethaddr_setup);
3641 +static int __init ath79_kmac_setup(char *str)
3643 + ath79_set_mac_base_ascii(str);
3644 + return 1;
3646 +__setup("kmac=", ath79_kmac_setup);
3648 +void __init ath79_init_mac(unsigned char *dst, const unsigned char *src,
3649 + int offset)
3651 + int t;
3653 + if (!dst)
3654 + return;
3656 + if (!src || !is_valid_ether_addr(src)) {
3657 + memset(dst, '\0', ETH_ALEN);
3658 + return;
3661 + t = (((u32) src[3]) << 16) + (((u32) src[4]) << 8) + ((u32) src[5]);
3662 + t += offset;
3664 + dst[0] = src[0];
3665 + dst[1] = src[1];
3666 + dst[2] = src[2];
3667 + dst[3] = (t >> 16) & 0xff;
3668 + dst[4] = (t >> 8) & 0xff;
3669 + dst[5] = t & 0xff;
3672 +void __init ath79_init_local_mac(unsigned char *dst, const unsigned char *src)
3674 + int i;
3676 + if (!dst)
3677 + return;
3679 + if (!src || !is_valid_ether_addr(src)) {
3680 + memset(dst, '\0', ETH_ALEN);
3681 + return;
3684 + for (i = 0; i < ETH_ALEN; i++)
3685 + dst[i] = src[i];
3686 + dst[0] |= 0x02;
3688 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-eth.h linux-4.1.43/arch/mips/ath79/dev-eth.h
3689 --- linux-4.1.43.orig/arch/mips/ath79/dev-eth.h 1970-01-01 01:00:00.000000000 +0100
3690 +++ linux-4.1.43/arch/mips/ath79/dev-eth.h 2017-08-06 20:02:15.000000000 +0200
3691 @@ -0,0 +1,53 @@
3693 + * Atheros AR71xx SoC device definitions
3695 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
3696 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
3698 + * This program is free software; you can redistribute it and/or modify it
3699 + * under the terms of the GNU General Public License version 2 as published
3700 + * by the Free Software Foundation.
3701 + */
3703 +#ifndef _ATH79_DEV_ETH_H
3704 +#define _ATH79_DEV_ETH_H
3706 +#include <asm/mach-ath79/ag71xx_platform.h>
3708 +struct platform_device;
3710 +extern unsigned char ath79_mac_base[] __initdata;
3711 +void ath79_parse_ascii_mac(char *mac_str, u8 *mac);
3712 +void ath79_init_mac(unsigned char *dst, const unsigned char *src,
3713 + int offset);
3714 +void ath79_init_local_mac(unsigned char *dst, const unsigned char *src);
3716 +struct ath79_eth_pll_data {
3717 + u32 pll_10;
3718 + u32 pll_100;
3719 + u32 pll_1000;
3722 +extern struct ath79_eth_pll_data ath79_eth0_pll_data;
3723 +extern struct ath79_eth_pll_data ath79_eth1_pll_data;
3725 +extern struct ag71xx_platform_data ath79_eth0_data;
3726 +extern struct ag71xx_platform_data ath79_eth1_data;
3727 +extern struct platform_device ath79_eth0_device;
3728 +extern struct platform_device ath79_eth1_device;
3729 +void ath79_register_eth(unsigned int id);
3731 +extern struct ag71xx_switch_platform_data ath79_switch_data;
3733 +extern struct ag71xx_mdio_platform_data ath79_mdio0_data;
3734 +extern struct ag71xx_mdio_platform_data ath79_mdio1_data;
3735 +extern struct platform_device ath79_mdio0_device;
3736 +extern struct platform_device ath79_mdio1_device;
3737 +void ath79_register_mdio(unsigned int id, u32 phy_mask);
3739 +void ath79_setup_ar933x_phy4_switch(bool mac, bool mdio);
3740 +void ath79_setup_ar934x_eth_cfg(u32 mask);
3741 +void ath79_setup_ar934x_eth_rx_delay(unsigned int rxd, unsigned int rxdv);
3742 +void ath79_setup_qca955x_eth_cfg(u32 mask);
3744 +#endif /* _ATH79_DEV_ETH_H */
3745 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-m25p80.c linux-4.1.43/arch/mips/ath79/dev-m25p80.c
3746 --- linux-4.1.43.orig/arch/mips/ath79/dev-m25p80.c 1970-01-01 01:00:00.000000000 +0100
3747 +++ linux-4.1.43/arch/mips/ath79/dev-m25p80.c 2017-08-06 20:02:15.000000000 +0200
3748 @@ -0,0 +1,118 @@
3750 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
3752 + * This program is free software; you can redistribute it and/or modify it
3753 + * under the terms of the GNU General Public License version 2 as published
3754 + * by the Free Software Foundation.
3755 + */
3757 +#include <linux/init.h>
3758 +#include <linux/spi/spi.h>
3759 +#include <linux/spi/flash.h>
3760 +#include <linux/mtd/mtd.h>
3761 +#include <linux/mtd/partitions.h>
3762 +#include <linux/mtd/concat.h>
3764 +#include "dev-spi.h"
3765 +#include "dev-m25p80.h"
3767 +static struct ath79_spi_controller_data ath79_spi0_cdata =
3769 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
3770 + .cs_line = 0,
3773 +static struct ath79_spi_controller_data ath79_spi1_cdata =
3775 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
3776 + .cs_line = 1,
3779 +static struct spi_board_info ath79_spi_info[] = {
3781 + .bus_num = 0,
3782 + .chip_select = 0,
3783 + .max_speed_hz = 25000000,
3784 + .modalias = "m25p80",
3785 + .controller_data = &ath79_spi0_cdata,
3786 + },
3788 + .bus_num = 0,
3789 + .chip_select = 1,
3790 + .max_speed_hz = 25000000,
3791 + .modalias = "m25p80",
3792 + .controller_data = &ath79_spi1_cdata,
3796 +static struct ath79_spi_platform_data ath79_spi_data;
3798 +void __init ath79_register_m25p80(struct flash_platform_data *pdata)
3800 + ath79_spi_data.bus_num = 0;
3801 + ath79_spi_data.num_chipselect = 1;
3802 + ath79_spi0_cdata.is_flash = true;
3803 + ath79_spi_info[0].platform_data = pdata;
3804 + ath79_register_spi(&ath79_spi_data, ath79_spi_info, 1);
3807 +static struct flash_platform_data *multi_pdata;
3809 +static struct mtd_info *concat_devs[2] = { NULL, NULL };
3810 +static struct work_struct mtd_concat_work;
3812 +static void mtd_concat_add_work(struct work_struct *work)
3814 + struct mtd_info *mtd;
3816 + mtd = mtd_concat_create(concat_devs, ARRAY_SIZE(concat_devs), "flash");
3818 + mtd_device_register(mtd, multi_pdata->parts, multi_pdata->nr_parts);
3821 +static void mtd_concat_add(struct mtd_info *mtd)
3823 + static bool registered = false;
3825 + if (registered)
3826 + return;
3828 + if (!strcmp(mtd->name, "spi0.0"))
3829 + concat_devs[0] = mtd;
3830 + else if (!strcmp(mtd->name, "spi0.1"))
3831 + concat_devs[1] = mtd;
3832 + else
3833 + return;
3835 + if (!concat_devs[0] || !concat_devs[1])
3836 + return;
3838 + registered = true;
3839 + INIT_WORK(&mtd_concat_work, mtd_concat_add_work);
3840 + schedule_work(&mtd_concat_work);
3843 +static void mtd_concat_remove(struct mtd_info *mtd)
3847 +static void add_mtd_concat_notifier(void)
3849 + static struct mtd_notifier not = {
3850 + .add = mtd_concat_add,
3851 + .remove = mtd_concat_remove,
3852 + };
3854 + register_mtd_user(&not);
3858 +void __init ath79_register_m25p80_multi(struct flash_platform_data *pdata)
3860 + multi_pdata = pdata;
3861 + add_mtd_concat_notifier();
3862 + ath79_spi_data.bus_num = 0;
3863 + ath79_spi_data.num_chipselect = 2;
3864 + ath79_spi0_cdata.is_flash = true;
3865 + ath79_register_spi(&ath79_spi_data, ath79_spi_info, 2);
3867 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-m25p80.h linux-4.1.43/arch/mips/ath79/dev-m25p80.h
3868 --- linux-4.1.43.orig/arch/mips/ath79/dev-m25p80.h 1970-01-01 01:00:00.000000000 +0100
3869 +++ linux-4.1.43/arch/mips/ath79/dev-m25p80.h 2017-08-06 20:02:15.000000000 +0200
3870 @@ -0,0 +1,17 @@
3872 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
3874 + * This program is free software; you can redistribute it and/or modify it
3875 + * under the terms of the GNU General Public License version 2 as published
3876 + * by the Free Software Foundation.
3877 + */
3879 +#ifndef _ATH79_DEV_M25P80_H
3880 +#define _ATH79_DEV_M25P80_H
3882 +#include <linux/spi/flash.h>
3884 +void ath79_register_m25p80(struct flash_platform_data *pdata) __init;
3885 +void ath79_register_m25p80_multi(struct flash_platform_data *pdata) __init;
3887 +#endif /* _ATH79_DEV_M25P80_H */
3888 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-nfc.c linux-4.1.43/arch/mips/ath79/dev-nfc.c
3889 --- linux-4.1.43.orig/arch/mips/ath79/dev-nfc.c 1970-01-01 01:00:00.000000000 +0100
3890 +++ linux-4.1.43/arch/mips/ath79/dev-nfc.c 2017-08-06 20:02:15.000000000 +0200
3891 @@ -0,0 +1,141 @@
3893 + * Atheros AR934X SoCs built-in NAND flash controller support
3895 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
3897 + * This program is free software; you can redistribute it and/or modify it
3898 + * under the terms of the GNU General Public License version 2 as published
3899 + * by the Free Software Foundation.
3900 + */
3902 +#include <linux/kernel.h>
3903 +#include <linux/delay.h>
3904 +#include <linux/init.h>
3905 +#include <linux/irq.h>
3906 +#include <linux/dma-mapping.h>
3907 +#include <linux/etherdevice.h>
3908 +#include <linux/platform_device.h>
3909 +#include <linux/platform/ar934x_nfc.h>
3911 +#include <asm/mach-ath79/ath79.h>
3912 +#include <asm/mach-ath79/ar71xx_regs.h>
3914 +#include "dev-nfc.h"
3916 +static struct resource ath79_nfc_resources[2];
3917 +static u64 ar934x_nfc_dmamask = DMA_BIT_MASK(32);
3918 +static struct ar934x_nfc_platform_data ath79_nfc_data;
3920 +static struct platform_device ath79_nfc_device = {
3921 + .name = AR934X_NFC_DRIVER_NAME,
3922 + .id = -1,
3923 + .resource = ath79_nfc_resources,
3924 + .num_resources = ARRAY_SIZE(ath79_nfc_resources),
3925 + .dev = {
3926 + .dma_mask = &ar934x_nfc_dmamask,
3927 + .coherent_dma_mask = DMA_BIT_MASK(32),
3928 + .platform_data = &ath79_nfc_data,
3929 + },
3932 +static void __init ath79_nfc_init_resource(struct resource res[2],
3933 + unsigned long base,
3934 + unsigned long size,
3935 + int irq)
3937 + memset(res, 0, sizeof(struct resource) * 2);
3939 + res[0].flags = IORESOURCE_MEM;
3940 + res[0].start = base;
3941 + res[0].end = base + size - 1;
3943 + res[1].flags = IORESOURCE_IRQ;
3944 + res[1].start = irq;
3945 + res[1].end = irq;
3948 +static void ar934x_nfc_hw_reset(bool active)
3950 + if (active) {
3951 + ath79_device_reset_set(AR934X_RESET_NANDF);
3952 + udelay(100);
3954 + ath79_device_reset_set(AR934X_RESET_ETH_SWITCH_ANALOG);
3955 + udelay(250);
3956 + } else {
3957 + ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH_ANALOG);
3958 + udelay(250);
3960 + ath79_device_reset_clear(AR934X_RESET_NANDF);
3961 + udelay(100);
3965 +static void ar934x_nfc_setup(void)
3967 + ath79_nfc_data.hw_reset = ar934x_nfc_hw_reset;
3969 + ath79_nfc_init_resource(ath79_nfc_resources,
3970 + AR934X_NFC_BASE, AR934X_NFC_SIZE,
3971 + ATH79_MISC_IRQ(21));
3973 + platform_device_register(&ath79_nfc_device);
3976 +static void qca955x_nfc_hw_reset(bool active)
3978 + if (active) {
3979 + ath79_device_reset_set(QCA955X_RESET_NANDF);
3980 + udelay(250);
3981 + } else {
3982 + ath79_device_reset_clear(QCA955X_RESET_NANDF);
3983 + udelay(100);
3987 +static void qca955x_nfc_setup(void)
3989 + ath79_nfc_data.hw_reset = qca955x_nfc_hw_reset;
3991 + ath79_nfc_init_resource(ath79_nfc_resources,
3992 + QCA955X_NFC_BASE, QCA955X_NFC_SIZE,
3993 + ATH79_MISC_IRQ(21));
3995 + platform_device_register(&ath79_nfc_device);
3998 +void __init ath79_nfc_set_select_chip(void (*f)(int chip_no))
4000 + ath79_nfc_data.select_chip = f;
4003 +void __init ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd))
4005 + ath79_nfc_data.scan_fixup = f;
4008 +void __init ath79_nfc_set_swap_dma(bool enable)
4010 + ath79_nfc_data.swap_dma = enable;
4013 +void __init ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode)
4015 + ath79_nfc_data.ecc_mode = mode;
4018 +void __init ath79_nfc_set_parts(struct mtd_partition *parts, int nr_parts)
4020 + ath79_nfc_data.parts = parts;
4021 + ath79_nfc_data.nr_parts = nr_parts;
4024 +void __init ath79_register_nfc(void)
4026 + if (soc_is_ar934x())
4027 + ar934x_nfc_setup();
4028 + else if (soc_is_qca955x())
4029 + qca955x_nfc_setup();
4030 + else
4031 + BUG();
4033 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-nfc.h linux-4.1.43/arch/mips/ath79/dev-nfc.h
4034 --- linux-4.1.43.orig/arch/mips/ath79/dev-nfc.h 1970-01-01 01:00:00.000000000 +0100
4035 +++ linux-4.1.43/arch/mips/ath79/dev-nfc.h 2017-08-06 20:02:15.000000000 +0200
4036 @@ -0,0 +1,34 @@
4038 + * Atheros AR934X SoCs built-in NAND Flash Controller support
4040 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
4042 + * This program is free software; you can redistribute it and/or modify it
4043 + * under the terms of the GNU General Public License version 2 as published
4044 + * by the Free Software Foundation.
4045 + */
4047 +#ifndef _ATH79_DEV_NFC_H
4048 +#define _ATH79_DEV_NFC_H
4050 +struct mtd_partition;
4051 +enum ar934x_nfc_ecc_mode;
4053 +#ifdef CONFIG_ATH79_DEV_NFC
4054 +void ath79_nfc_set_parts(struct mtd_partition *parts, int nr_parts);
4055 +void ath79_nfc_set_select_chip(void (*f)(int chip_no));
4056 +void ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd));
4057 +void ath79_nfc_set_swap_dma(bool enable);
4058 +void ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode);
4059 +void ath79_register_nfc(void);
4060 +#else
4061 +static inline void ath79_nfc_set_parts(struct mtd_partition *parts,
4062 + int nr_parts) {}
4063 +static inline void ath79_nfc_set_select_chip(void (*f)(int chip_no)) {}
4064 +static inline void ath79_nfc_set_scan_fixup(int (*f)(struct mtd_info *mtd)) {}
4065 +static inline void ath79_nfc_set_swap_dma(bool enable) {}
4066 +static inline void ath79_nfc_set_ecc_mode(enum ar934x_nfc_ecc_mode mode) {}
4067 +static inline void ath79_register_nfc(void) {}
4068 +#endif
4070 +#endif /* _ATH79_DEV_NFC_H */
4071 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-usb.c linux-4.1.43/arch/mips/ath79/dev-usb.c
4072 --- linux-4.1.43.orig/arch/mips/ath79/dev-usb.c 2017-08-06 01:56:14.000000000 +0200
4073 +++ linux-4.1.43/arch/mips/ath79/dev-usb.c 2017-08-06 20:02:15.000000000 +0200
4074 @@ -37,6 +37,8 @@
4075 static struct usb_ehci_pdata ath79_ehci_pdata_v2 = {
4076 .caps_offset = 0x100,
4077 .has_tt = 1,
4078 + .qca_force_host_mode = 1,
4079 + .qca_force_16bit_ptw = 1,
4082 static void __init ath79_usb_register(const char *name, int id,
4083 @@ -159,6 +161,9 @@
4084 ath79_device_reset_clear(AR913X_RESET_USB_PHY);
4085 mdelay(10);
4087 + ath79_ehci_pdata_v2.qca_force_host_mode = 0;
4088 + ath79_ehci_pdata_v2.qca_force_16bit_ptw = 0;
4090 ath79_usb_register("ehci-platform", -1,
4091 AR913X_EHCI_BASE, AR913X_EHCI_SIZE,
4092 ATH79_CPU_IRQ(3),
4093 @@ -182,14 +187,34 @@
4094 &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4097 -static void __init ar934x_usb_setup(void)
4098 +static void enable_tx_tx_idp_violation_fix(unsigned base)
4100 - u32 bootstrap;
4101 + void __iomem *phy_reg;
4102 + u32 t;
4104 - bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
4105 - if (bootstrap & AR934X_BOOTSTRAP_USB_MODE_DEVICE)
4106 + phy_reg = ioremap(base, 4);
4107 + if (!phy_reg)
4108 return;
4110 + t = ioread32(phy_reg);
4111 + t &= ~0xff;
4112 + t |= 0x58;
4113 + iowrite32(t, phy_reg);
4115 + iounmap(phy_reg);
4118 +static void ar934x_usb_reset_notifier(struct platform_device *pdev)
4120 + if (pdev->id != -1)
4121 + return;
4123 + enable_tx_tx_idp_violation_fix(0x18116c94);
4124 + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
4127 +static void __init ar934x_usb_setup(void)
4129 ath79_device_reset_set(AR934X_RESET_USBSUS_OVERRIDE);
4130 udelay(1000);
4132 @@ -202,14 +227,64 @@
4133 ath79_device_reset_clear(AR934X_RESET_USB_HOST);
4134 udelay(1000);
4136 + if (ath79_soc_rev >= 3)
4137 + ath79_ehci_pdata_v2.reset_notifier = ar934x_usb_reset_notifier;
4139 ath79_usb_register("ehci-platform", -1,
4140 AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
4141 ATH79_CPU_IRQ(3),
4142 &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4145 +static void __init qca953x_usb_setup(void)
4147 + u32 bootstrap;
4149 + bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
4151 + ath79_device_reset_set(QCA953X_RESET_USBSUS_OVERRIDE);
4152 + udelay(1000);
4154 + ath79_device_reset_clear(QCA953X_RESET_USB_PHY);
4155 + udelay(1000);
4157 + ath79_device_reset_clear(QCA953X_RESET_USB_PHY_ANALOG);
4158 + udelay(1000);
4160 + ath79_device_reset_clear(QCA953X_RESET_USB_HOST);
4161 + udelay(1000);
4163 + ath79_usb_register("ehci-platform", -1,
4164 + QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,
4165 + ATH79_CPU_IRQ(3),
4166 + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4169 +static void qca955x_usb_reset_notifier(struct platform_device *pdev)
4171 + u32 base;
4173 + switch (pdev->id) {
4174 + case 0:
4175 + base = 0x18116c94;
4176 + break;
4178 + case 1:
4179 + base = 0x18116e54;
4180 + break;
4182 + default:
4183 + return;
4186 + enable_tx_tx_idp_violation_fix(base);
4187 + dev_info(&pdev->dev, "TX-TX IDP fix enabled\n");
4190 static void __init qca955x_usb_setup(void)
4192 + ath79_ehci_pdata_v2.reset_notifier = qca955x_usb_reset_notifier;
4194 ath79_usb_register("ehci-platform", 0,
4195 QCA955X_EHCI0_BASE, QCA955X_EHCI_SIZE,
4196 ATH79_IP3_IRQ(0),
4197 @@ -221,6 +296,19 @@
4198 &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4201 +static void __init qca956x_usb_setup(void)
4203 + ath79_usb_register("ehci-platform", 0,
4204 + QCA956X_EHCI0_BASE, QCA956X_EHCI_SIZE,
4205 + ATH79_IP3_IRQ(0),
4206 + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4208 + ath79_usb_register("ehci-platform", 1,
4209 + QCA956X_EHCI1_BASE, QCA956X_EHCI_SIZE,
4210 + ATH79_IP3_IRQ(1),
4211 + &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
4214 void __init ath79_register_usb(void)
4216 if (soc_is_ar71xx())
4217 @@ -235,8 +323,12 @@
4218 ar933x_usb_setup();
4219 else if (soc_is_ar934x())
4220 ar934x_usb_setup();
4221 + else if (soc_is_qca953x())
4222 + qca953x_usb_setup();
4223 else if (soc_is_qca955x())
4224 qca955x_usb_setup();
4225 + else if (soc_is_qca9561())
4226 + qca956x_usb_setup();
4227 else
4228 BUG();
4230 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-wmac.c linux-4.1.43/arch/mips/ath79/dev-wmac.c
4231 --- linux-4.1.43.orig/arch/mips/ath79/dev-wmac.c 2017-08-06 01:56:14.000000000 +0200
4232 +++ linux-4.1.43/arch/mips/ath79/dev-wmac.c 2017-08-06 20:02:15.000000000 +0200
4233 @@ -15,14 +15,21 @@
4234 #include <linux/init.h>
4235 #include <linux/delay.h>
4236 #include <linux/irq.h>
4237 +#include <linux/etherdevice.h>
4238 #include <linux/platform_device.h>
4239 #include <linux/ath9k_platform.h>
4240 +#include <linux/gpio.h>
4242 #include <asm/mach-ath79/ath79.h>
4243 #include <asm/mach-ath79/ar71xx_regs.h>
4244 +#include "common.h"
4245 #include "dev-wmac.h"
4247 -static struct ath9k_platform_data ath79_wmac_data;
4248 +static u8 ath79_wmac_mac[ETH_ALEN];
4250 +static struct ath9k_platform_data ath79_wmac_data = {
4251 + .led_pin = -1,
4254 static struct resource ath79_wmac_resources[] = {
4256 @@ -44,7 +51,7 @@
4260 -static void __init ar913x_wmac_setup(void)
4261 +static int ar913x_wmac_reset(void)
4263 /* reset the WMAC */
4264 ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
4265 @@ -53,22 +60,48 @@
4266 ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
4267 mdelay(10);
4269 + return 0;
4272 +static void __init ar913x_wmac_setup(void)
4274 + ar913x_wmac_reset();
4276 ath79_wmac_resources[0].start = AR913X_WMAC_BASE;
4277 ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1;
4278 ath79_wmac_resources[1].start = ATH79_CPU_IRQ(2);
4279 ath79_wmac_resources[1].end = ATH79_CPU_IRQ(2);
4281 + ath79_wmac_data.external_reset = ar913x_wmac_reset;
4285 static int ar933x_wmac_reset(void)
4287 + int retries = 20;
4289 ath79_device_reset_set(AR933X_RESET_WMAC);
4290 ath79_device_reset_clear(AR933X_RESET_WMAC);
4292 - return 0;
4293 + while (1) {
4294 + u32 bootstrap;
4296 + bootstrap = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
4297 + if ((bootstrap & AR933X_BOOTSTRAP_EEPBUSY) == 0)
4298 + return 0;
4300 + if (retries-- == 0)
4301 + break;
4303 + udelay(10000);
4304 + retries++;
4307 + pr_err("ar933x: WMAC reset timed out");
4308 + return -ETIMEDOUT;
4311 -static int ar933x_r1_get_wmac_revision(void)
4312 +static int ar93xx_get_soc_revision(void)
4314 return ath79_soc_rev;
4316 @@ -93,7 +126,7 @@
4317 ath79_wmac_data.is_clk_25mhz = true;
4319 if (ath79_soc_rev == 1)
4320 - ath79_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision;
4321 + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
4323 ath79_wmac_data.external_reset = ar933x_wmac_reset;
4325 @@ -114,6 +147,28 @@
4326 ath79_wmac_data.is_clk_25mhz = false;
4327 else
4328 ath79_wmac_data.is_clk_25mhz = true;
4330 + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
4333 +static void qca953x_wmac_setup(void)
4335 + u32 t;
4337 + ath79_wmac_device.name = "qca953x_wmac";
4339 + ath79_wmac_resources[0].start = QCA953X_WMAC_BASE;
4340 + ath79_wmac_resources[0].end = QCA953X_WMAC_BASE + QCA953X_WMAC_SIZE - 1;
4341 + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
4342 + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
4344 + t = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
4345 + if (t & QCA953X_BOOTSTRAP_REF_CLK_40)
4346 + ath79_wmac_data.is_clk_25mhz = false;
4347 + else
4348 + ath79_wmac_data.is_clk_25mhz = true;
4350 + ath79_wmac_data.get_mac_revision = ar93xx_get_soc_revision;
4353 static void qca955x_wmac_setup(void)
4354 @@ -134,7 +189,221 @@
4355 ath79_wmac_data.is_clk_25mhz = true;
4358 -void __init ath79_register_wmac(u8 *cal_data)
4359 +static void qca956x_wmac_setup(void)
4361 + u32 t;
4363 + ath79_wmac_device.name = "qca956x_wmac";
4365 + ath79_wmac_resources[0].start = QCA956X_WMAC_BASE;
4366 + ath79_wmac_resources[0].end = QCA956X_WMAC_BASE + QCA956X_WMAC_SIZE - 1;
4367 + ath79_wmac_resources[1].start = ATH79_IP2_IRQ(1);
4368 + ath79_wmac_resources[1].end = ATH79_IP2_IRQ(1);
4370 + t = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
4371 + if (t & QCA956X_BOOTSTRAP_REF_CLK_40)
4372 + ath79_wmac_data.is_clk_25mhz = false;
4373 + else
4374 + ath79_wmac_data.is_clk_25mhz = true;
4377 +static bool __init
4378 +ar93xx_wmac_otp_read_word(void __iomem *base, int addr, u32 *data)
4380 + int timeout = 1000;
4381 + u32 val;
4383 + __raw_readl(base + AR9300_OTP_BASE + (4 * addr));
4384 + while (timeout--) {
4385 + val = __raw_readl(base + AR9300_OTP_STATUS);
4386 + if ((val & AR9300_OTP_STATUS_TYPE) == AR9300_OTP_STATUS_VALID)
4387 + break;
4389 + udelay(10);
4392 + if (!timeout)
4393 + return false;
4395 + *data = __raw_readl(base + AR9300_OTP_READ_DATA);
4396 + return true;
4399 +static bool __init
4400 +ar93xx_wmac_otp_read(void __iomem *base, int addr, u8 *dest, int len)
4402 + u32 data;
4403 + int i;
4405 + for (i = 0; i < len; i++) {
4406 + int offset = 8 * ((addr - i) % 4);
4408 + if (!ar93xx_wmac_otp_read_word(base, (addr - i) / 4, &data))
4409 + return false;
4411 + dest[i] = (data >> offset) & 0xff;
4414 + return true;
4417 +static bool __init
4418 +ar93xx_wmac_otp_uncompress(void __iomem *base, int addr, int len, u8 *dest,
4419 + int dest_start, int dest_len)
4421 + int dest_bytes = 0;
4422 + int offset = 0;
4423 + int end = addr - len;
4424 + u8 hdr[2];
4426 + while (addr > end) {
4427 + if (!ar93xx_wmac_otp_read(base, addr, hdr, 2))
4428 + return false;
4430 + addr -= 2;
4431 + offset += hdr[0];
4433 + if (offset <= dest_start + dest_len &&
4434 + offset + len >= dest_start) {
4435 + int data_offset = 0;
4436 + int dest_offset = 0;
4437 + int copy_len;
4439 + if (offset < dest_start)
4440 + data_offset = dest_start - offset;
4441 + else
4442 + dest_offset = offset - dest_start;
4444 + copy_len = len - data_offset;
4445 + if (copy_len > dest_len - dest_offset)
4446 + copy_len = dest_len - dest_offset;
4448 + ar93xx_wmac_otp_read(base, addr - data_offset,
4449 + dest + dest_offset,
4450 + copy_len);
4452 + dest_bytes += copy_len;
4454 + addr -= hdr[1];
4456 + return !!dest_bytes;
4459 +bool __init ar93xx_wmac_read_mac_address(u8 *dest)
4461 + void __iomem *base;
4462 + bool ret = false;
4463 + int addr = 0x1ff;
4464 + unsigned int len;
4465 + u32 hdr_u32;
4466 + u8 *hdr = (u8 *) &hdr_u32;
4467 + u8 mac[6] = { 0x00, 0x02, 0x03, 0x04, 0x05, 0x06 };
4468 + int mac_start = 2, mac_end = 8;
4470 + BUG_ON(!soc_is_ar933x() && !soc_is_ar934x());
4471 + base = ioremap_nocache(AR933X_WMAC_BASE, AR933X_WMAC_SIZE);
4472 + while (addr > sizeof(hdr)) {
4473 + if (!ar93xx_wmac_otp_read(base, addr, hdr, sizeof(hdr)))
4474 + break;
4476 + if (hdr_u32 == 0 || hdr_u32 == ~0)
4477 + break;
4479 + len = (hdr[1] << 4) | (hdr[2] >> 4);
4480 + addr -= 4;
4482 + switch (hdr[0] >> 5) {
4483 + case 0:
4484 + if (len < mac_end)
4485 + break;
4487 + ar93xx_wmac_otp_read(base, addr - mac_start, mac, 6);
4488 + ret = true;
4489 + break;
4490 + case 3:
4491 + ret |= ar93xx_wmac_otp_uncompress(base, addr, len, mac,
4492 + mac_start, 6);
4493 + break;
4494 + default:
4495 + break;
4498 + addr -= len + 2;
4501 + iounmap(base);
4502 + if (ret)
4503 + memcpy(dest, mac, 6);
4505 + return ret;
4508 +void __init ath79_wmac_disable_2ghz(void)
4510 + ath79_wmac_data.disable_2ghz = true;
4513 +void __init ath79_wmac_disable_5ghz(void)
4515 + ath79_wmac_data.disable_5ghz = true;
4518 +void __init ath79_wmac_set_tx_gain_buffalo(void)
4520 + ath79_wmac_data.tx_gain_buffalo = true;
4523 +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
4525 + char buf[32];
4526 + char *label;
4527 + int err;
4529 + scnprintf(buf, sizeof(buf), "external LNA%u", chain);
4530 + label = kstrdup(buf, GFP_KERNEL);
4532 + err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
4533 + if (err) {
4534 + pr_err("unable to request GPIO%d for external LNA%u\n",
4535 + gpio, chain);
4536 + kfree(label);
4539 + return err;
4542 +static void ar934x_set_ext_lna_gpio(unsigned chain, int gpio)
4544 + unsigned int sel;
4545 + int err;
4547 + if (WARN_ON(chain > 1))
4548 + return;
4550 + err = ath79_request_ext_lna_gpio(chain, gpio);
4551 + if (err)
4552 + return;
4554 + if (chain == 0)
4555 + sel = AR934X_GPIO_OUT_EXT_LNA0;
4556 + else
4557 + sel = AR934X_GPIO_OUT_EXT_LNA1;
4559 + ath79_gpio_output_select(gpio, sel);
4562 +void __init ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio)
4564 + if (soc_is_ar934x())
4565 + ar934x_set_ext_lna_gpio(chain, gpio);
4568 +void __init ath79_wmac_set_led_pin(int gpio)
4570 + ath79_wmac_data.led_pin = gpio;
4573 +void __init ath79_register_wmac(u8 *cal_data, u8 *mac_addr)
4575 if (soc_is_ar913x())
4576 ar913x_wmac_setup();
4577 @@ -142,8 +411,12 @@
4578 ar933x_wmac_setup();
4579 else if (soc_is_ar934x())
4580 ar934x_wmac_setup();
4581 + else if (soc_is_qca953x())
4582 + qca953x_wmac_setup();
4583 else if (soc_is_qca955x())
4584 qca955x_wmac_setup();
4585 + else if (soc_is_qca956x())
4586 + qca956x_wmac_setup();
4587 else
4588 BUG();
4590 @@ -151,5 +424,16 @@
4591 memcpy(ath79_wmac_data.eeprom_data, cal_data,
4592 sizeof(ath79_wmac_data.eeprom_data));
4594 + if (mac_addr) {
4595 + memcpy(ath79_wmac_mac, mac_addr, sizeof(ath79_wmac_mac));
4596 + ath79_wmac_data.macaddr = ath79_wmac_mac;
4599 platform_device_register(&ath79_wmac_device);
4602 +void __init ath79_register_wmac_simple(void)
4604 + ath79_register_wmac(NULL, NULL);
4605 + ath79_wmac_data.eeprom_name = "soc_wmac.eeprom";
4607 diff -Nur linux-4.1.43.orig/arch/mips/ath79/dev-wmac.h linux-4.1.43/arch/mips/ath79/dev-wmac.h
4608 --- linux-4.1.43.orig/arch/mips/ath79/dev-wmac.h 2017-08-06 01:56:14.000000000 +0200
4609 +++ linux-4.1.43/arch/mips/ath79/dev-wmac.h 2017-08-06 20:02:15.000000000 +0200
4610 @@ -12,6 +12,14 @@
4611 #ifndef _ATH79_DEV_WMAC_H
4612 #define _ATH79_DEV_WMAC_H
4614 -void ath79_register_wmac(u8 *cal_data);
4615 +void ath79_register_wmac(u8 *cal_data, u8 *mac_addr);
4616 +void ath79_register_wmac_simple(void);
4617 +void ath79_wmac_disable_2ghz(void);
4618 +void ath79_wmac_disable_5ghz(void);
4619 +void ath79_wmac_set_tx_gain_buffalo(void);
4620 +void ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio);
4621 +void ath79_wmac_set_led_pin(int gpio);
4623 +bool ar93xx_wmac_read_mac_address(u8 *dest);
4625 #endif /* _ATH79_DEV_WMAC_H */
4626 diff -Nur linux-4.1.43.orig/arch/mips/ath79/early_printk.c linux-4.1.43/arch/mips/ath79/early_printk.c
4627 --- linux-4.1.43.orig/arch/mips/ath79/early_printk.c 2017-08-06 01:56:14.000000000 +0200
4628 +++ linux-4.1.43/arch/mips/ath79/early_printk.c 2017-08-06 20:02:15.000000000 +0200
4629 @@ -58,6 +58,46 @@
4630 /* nothing to do */
4633 +static void prom_enable_uart(u32 id)
4635 + void __iomem *gpio_base;
4636 + u32 uart_en;
4637 + u32 t;
4639 + switch (id) {
4640 + case REV_ID_MAJOR_AR71XX:
4641 + uart_en = AR71XX_GPIO_FUNC_UART_EN;
4642 + break;
4644 + case REV_ID_MAJOR_AR7240:
4645 + case REV_ID_MAJOR_AR7241:
4646 + case REV_ID_MAJOR_AR7242:
4647 + uart_en = AR724X_GPIO_FUNC_UART_EN;
4648 + break;
4650 + case REV_ID_MAJOR_AR913X:
4651 + uart_en = AR913X_GPIO_FUNC_UART_EN;
4652 + break;
4654 + case REV_ID_MAJOR_AR9330:
4655 + case REV_ID_MAJOR_AR9331:
4656 + uart_en = AR933X_GPIO_FUNC_UART_EN;
4657 + break;
4659 + case REV_ID_MAJOR_AR9341:
4660 + case REV_ID_MAJOR_AR9342:
4661 + case REV_ID_MAJOR_AR9344:
4662 + /* TODO */
4663 + default:
4664 + return;
4667 + gpio_base = (void __iomem *)(KSEG1ADDR(AR71XX_GPIO_BASE));
4668 + t = __raw_readl(gpio_base + AR71XX_GPIO_REG_FUNC);
4669 + t |= uart_en;
4670 + __raw_writel(t, gpio_base + AR71XX_GPIO_REG_FUNC);
4673 static void prom_putchar_init(void)
4675 void __iomem *base;
4676 @@ -76,8 +116,12 @@
4677 case REV_ID_MAJOR_AR9341:
4678 case REV_ID_MAJOR_AR9342:
4679 case REV_ID_MAJOR_AR9344:
4680 + case REV_ID_MAJOR_QCA9533:
4681 + case REV_ID_MAJOR_QCA9533_V2:
4682 case REV_ID_MAJOR_QCA9556:
4683 case REV_ID_MAJOR_QCA9558:
4684 + case REV_ID_MAJOR_TP9343:
4685 + case REV_ID_MAJOR_QCA9561:
4686 _prom_putchar = prom_putchar_ar71xx;
4687 break;
4689 @@ -88,8 +132,10 @@
4691 default:
4692 _prom_putchar = prom_putchar_dummy;
4693 - break;
4694 + return;
4697 + prom_enable_uart(id);
4700 void prom_putchar(unsigned char ch)
4701 diff -Nur linux-4.1.43.orig/arch/mips/ath79/gpio.c linux-4.1.43/arch/mips/ath79/gpio.c
4702 --- linux-4.1.43.orig/arch/mips/ath79/gpio.c 2017-08-06 01:56:14.000000000 +0200
4703 +++ linux-4.1.43/arch/mips/ath79/gpio.c 2017-08-06 20:02:15.000000000 +0200
4704 @@ -20,15 +20,29 @@
4705 #include <linux/io.h>
4706 #include <linux/ioport.h>
4707 #include <linux/gpio.h>
4708 +#include <linux/irq.h>
4709 +#include <linux/interrupt.h>
4711 +#include <linux/of.h>
4713 #include <asm/mach-ath79/ar71xx_regs.h>
4714 #include <asm/mach-ath79/ath79.h>
4715 +#include <asm/mach-ath79/irq.h>
4716 #include "common.h"
4718 -static void __iomem *ath79_gpio_base;
4719 +void __iomem *ath79_gpio_base;
4720 +EXPORT_SYMBOL_GPL(ath79_gpio_base);
4722 static unsigned long ath79_gpio_count;
4723 static DEFINE_SPINLOCK(ath79_gpio_lock);
4726 + * gpio_both_edge is a bitmask of which gpio pins need to have
4727 + * the detect priority flipped from the interrupt handler to
4728 + * emulate IRQ_TYPE_EDGE_BOTH.
4729 + */
4730 +static unsigned long gpio_both_edge = 0;
4732 static void __ath79_gpio_set_value(unsigned gpio, int value)
4734 void __iomem *base = ath79_gpio_base;
4735 @@ -128,6 +142,30 @@
4736 return 0;
4739 +int ath79_gpio_direction_select(unsigned gpio, bool oe)
4741 + void __iomem *base = ath79_gpio_base;
4742 + unsigned long flags;
4743 + bool ieq_1 = (soc_is_ar934x() ||
4744 + soc_is_qca953x());
4746 + if (gpio >= ath79_gpio_count)
4747 + return -1;
4749 + spin_lock_irqsave(&ath79_gpio_lock, flags);
4751 + if ((ieq_1 && oe) || (!ieq_1 && !oe))
4752 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << gpio),
4753 + base + AR71XX_GPIO_REG_OE);
4754 + else
4755 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) | (1 << gpio),
4756 + base + AR71XX_GPIO_REG_OE);
4758 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
4760 + return 0;
4763 static struct gpio_chip ath79_gpio_chip = {
4764 .label = "ath79",
4765 .get = ath79_gpio_get_value,
4766 @@ -146,7 +184,8 @@
4767 soc_is_ar913x() ||
4768 soc_is_ar933x())
4769 reg = AR71XX_GPIO_REG_FUNC;
4770 - else if (soc_is_ar934x())
4771 + else if (soc_is_ar934x() ||
4772 + soc_is_qca953x() || soc_is_qca956x())
4773 reg = AR934X_GPIO_REG_FUNC;
4774 else
4775 BUG();
4776 @@ -154,6 +193,36 @@
4777 return ath79_gpio_base + reg;
4780 +static void __iomem *ath79_gpio_get_function2_reg(void)
4782 + u32 reg = 0;
4784 + if (soc_is_ar71xx() ||
4785 + soc_is_ar724x() ||
4786 + soc_is_ar913x() ||
4787 + soc_is_ar933x())
4788 + reg = AR71XX_GPIO_REG_FUNC_2;
4789 + else
4790 + BUG();
4792 + return ath79_gpio_base + reg;
4796 +void ath79_gpio_function2_setup(u32 set, u32 clear)
4798 + void __iomem *reg = ath79_gpio_get_function2_reg();
4799 + unsigned long flags;
4801 + spin_lock_irqsave(&ath79_gpio_lock, flags);
4803 + __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
4804 + /* flush write */
4805 + __raw_readl(reg);
4807 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
4810 void ath79_gpio_function_setup(u32 set, u32 clear)
4812 void __iomem *reg = ath79_gpio_get_function_reg();
4813 @@ -178,6 +247,172 @@
4814 ath79_gpio_function_setup(0, mask);
4817 +void __init ath79_gpio_output_select(unsigned gpio, u8 val)
4819 + void __iomem *base = ath79_gpio_base;
4820 + unsigned long flags;
4821 + unsigned int reg, reg_base;
4822 + unsigned long gpio_count;
4823 + u32 t, s;
4825 + if (soc_is_ar934x()) {
4826 + gpio_count = AR934X_GPIO_COUNT;
4827 + reg_base = AR934X_GPIO_REG_OUT_FUNC0;
4828 + } else if (soc_is_qca953x()) {
4829 + gpio_count = QCA953X_GPIO_COUNT;
4830 + reg_base = QCA953X_GPIO_REG_OUT_FUNC0;
4831 + } else if (soc_is_qca955x()) {
4832 + gpio_count = QCA955X_GPIO_COUNT;
4833 + reg_base = QCA955X_GPIO_REG_OUT_FUNC0;
4834 + } else {
4835 + BUG();
4838 + if (gpio >= gpio_count)
4839 + return;
4841 + reg = reg_base + 4 * (gpio / 4);
4842 + s = 8 * (gpio % 4);
4844 + spin_lock_irqsave(&ath79_gpio_lock, flags);
4846 + t = __raw_readl(base + reg);
4847 + t &= ~(0xff << s);
4848 + t |= val << s;
4849 + __raw_writel(t, base + reg);
4851 + /* flush write */
4852 + (void) __raw_readl(base + reg);
4854 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
4857 +static int ath79_gpio_irq_type(struct irq_data *d, unsigned type)
4859 + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
4860 + void __iomem *base = ath79_gpio_base;
4861 + unsigned long flags;
4862 + unsigned long int_type;
4863 + unsigned long int_polarity;
4864 + unsigned long bit = (1 << offset);
4866 + spin_lock_irqsave(&ath79_gpio_lock, flags);
4868 + int_type = __raw_readl(base + AR71XX_GPIO_REG_INT_TYPE);
4869 + int_polarity = __raw_readl(base + AR71XX_GPIO_REG_INT_POLARITY);
4871 + gpio_both_edge &= ~bit;
4873 + switch (type) {
4874 + case IRQ_TYPE_EDGE_RISING:
4875 + int_type &= ~bit;
4876 + int_polarity |= bit;
4877 + break;
4879 + case IRQ_TYPE_EDGE_FALLING:
4880 + int_type &= ~bit;
4881 + int_polarity &= ~bit;
4882 + break;
4884 + case IRQ_TYPE_LEVEL_HIGH:
4885 + int_type |= bit;
4886 + int_polarity |= bit;
4887 + break;
4889 + case IRQ_TYPE_LEVEL_LOW:
4890 + int_type |= bit;
4891 + int_polarity &= ~bit;
4892 + break;
4894 + case IRQ_TYPE_EDGE_BOTH:
4895 + int_type |= bit;
4896 + /* set polarity based on current value */
4897 + if (gpio_get_value(offset)) {
4898 + int_polarity &= ~bit;
4899 + } else {
4900 + int_polarity |= bit;
4902 + /* flip this gpio in the interrupt handler */
4903 + gpio_both_edge |= bit;
4904 + break;
4906 + default:
4907 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
4908 + return -EINVAL;
4911 + __raw_writel(int_type, base + AR71XX_GPIO_REG_INT_TYPE);
4912 + __raw_writel(int_polarity, base + AR71XX_GPIO_REG_INT_POLARITY);
4914 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_MODE) | (1 << offset),
4915 + base + AR71XX_GPIO_REG_INT_MODE);
4917 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) & ~(1 << offset),
4918 + base + AR71XX_GPIO_REG_INT_ENABLE);
4920 + spin_unlock_irqrestore(&ath79_gpio_lock, flags);
4921 + return 0;
4924 +static void ath79_gpio_irq_enable(struct irq_data *d)
4926 + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
4927 + void __iomem *base = ath79_gpio_base;
4929 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) | (1 << offset),
4930 + base + AR71XX_GPIO_REG_INT_ENABLE);
4933 +static void ath79_gpio_irq_disable(struct irq_data *d)
4935 + int offset = d->irq - ATH79_GPIO_IRQ_BASE;
4936 + void __iomem *base = ath79_gpio_base;
4938 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_ENABLE) & ~(1 << offset),
4939 + base + AR71XX_GPIO_REG_INT_ENABLE);
4942 +static struct irq_chip ath79_gpio_irqchip = {
4943 + .name = "GPIO",
4944 + .irq_enable = ath79_gpio_irq_enable,
4945 + .irq_disable = ath79_gpio_irq_disable,
4946 + .irq_set_type = ath79_gpio_irq_type,
4949 +static irqreturn_t ath79_gpio_irq(int irq, void *dev)
4951 + void __iomem *base = ath79_gpio_base;
4952 + unsigned long stat = __raw_readl(base + AR71XX_GPIO_REG_INT_PENDING);
4953 + int bit_num;
4955 + for_each_set_bit(bit_num, &stat, sizeof(stat) * BITS_PER_BYTE) {
4956 + unsigned long bit = BIT(bit_num);
4958 + if (bit & gpio_both_edge) {
4959 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_INT_POLARITY) ^ bit,
4960 + base + AR71XX_GPIO_REG_INT_POLARITY);
4963 + generic_handle_irq(ATH79_GPIO_IRQ(bit_num));
4966 + return IRQ_HANDLED;
4969 +static int __init ath79_gpio_irq_init(struct gpio_chip *chip)
4971 + int irq;
4972 + int irq_base = ATH79_GPIO_IRQ_BASE;
4974 + for (irq = irq_base; irq < irq_base + chip->ngpio; irq++) {
4975 + irq_set_chip_data(irq, chip);
4976 + irq_set_chip_and_handler(irq, &ath79_gpio_irqchip, handle_simple_irq);
4977 + irq_set_noprobe(irq);
4980 + return 0;
4983 void __init ath79_gpio_init(void)
4985 int err;
4986 @@ -194,14 +429,19 @@
4987 ath79_gpio_count = AR933X_GPIO_COUNT;
4988 else if (soc_is_ar934x())
4989 ath79_gpio_count = AR934X_GPIO_COUNT;
4990 + else if (soc_is_qca953x())
4991 + ath79_gpio_count = QCA953X_GPIO_COUNT;
4992 else if (soc_is_qca955x())
4993 ath79_gpio_count = QCA955X_GPIO_COUNT;
4994 + else if (soc_is_qca956x())
4995 + ath79_gpio_count = QCA956X_GPIO_COUNT;
4996 else
4997 BUG();
4999 ath79_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
5000 ath79_gpio_chip.ngpio = ath79_gpio_count;
5001 - if (soc_is_ar934x() || soc_is_qca955x()) {
5002 + if (soc_is_ar934x() || soc_is_qca953x() || soc_is_qca955x() ||
5003 + soc_is_qca956x()) {
5004 ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
5005 ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
5007 @@ -209,6 +449,10 @@
5008 err = gpiochip_add(&ath79_gpio_chip);
5009 if (err)
5010 panic("cannot add AR71xx GPIO chip, error=%d", err);
5012 + ath79_gpio_irq_init(&ath79_gpio_chip);
5014 + request_irq(ATH79_MISC_IRQ(2), ath79_gpio_irq, 0, "ath79-gpio", NULL);
5017 int gpio_get_value(unsigned gpio)
5018 @@ -231,14 +475,22 @@
5020 int gpio_to_irq(unsigned gpio)
5022 - /* FIXME */
5023 - return -EINVAL;
5024 + if (gpio > ath79_gpio_count) {
5025 + return -EINVAL;
5028 + return ATH79_GPIO_IRQ_BASE + gpio;
5030 EXPORT_SYMBOL(gpio_to_irq);
5032 int irq_to_gpio(unsigned irq)
5034 - /* FIXME */
5035 - return -EINVAL;
5036 + unsigned gpio = irq - ATH79_GPIO_IRQ_BASE;
5038 + if (gpio > ath79_gpio_count) {
5039 + return -EINVAL;
5042 + return gpio;
5044 EXPORT_SYMBOL(irq_to_gpio);
5045 diff -Nur linux-4.1.43.orig/arch/mips/ath79/irq.c linux-4.1.43/arch/mips/ath79/irq.c
5046 --- linux-4.1.43.orig/arch/mips/ath79/irq.c 2017-08-06 01:56:14.000000000 +0200
5047 +++ linux-4.1.43/arch/mips/ath79/irq.c 2017-08-06 20:02:15.000000000 +0200
5048 @@ -26,6 +26,8 @@
5050 static void (*ath79_ip2_handler)(void);
5051 static void (*ath79_ip3_handler)(void);
5052 +static struct irq_chip ip2_chip;
5053 +static struct irq_chip ip3_chip;
5055 static void ath79_misc_irq_handler(unsigned int irq, struct irq_desc *desc)
5057 @@ -106,7 +108,9 @@
5058 else if (soc_is_ar724x() ||
5059 soc_is_ar933x() ||
5060 soc_is_ar934x() ||
5061 - soc_is_qca955x())
5062 + soc_is_qca953x() ||
5063 + soc_is_qca955x() ||
5064 + soc_is_qca956x())
5065 ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
5066 else
5067 BUG();
5068 @@ -147,12 +151,43 @@
5070 for (i = ATH79_IP2_IRQ_BASE;
5071 i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
5072 - irq_set_chip_and_handler(i, &dummy_irq_chip,
5073 - handle_level_irq);
5074 + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
5076 irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
5079 +static void qca953x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
5081 + u32 status;
5083 + disable_irq_nosync(irq);
5085 + status = ath79_reset_rr(QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS);
5087 + if (status & QCA953X_PCIE_WMAC_INT_PCIE_ALL) {
5088 + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_PCIE);
5089 + generic_handle_irq(ATH79_IP2_IRQ(0));
5090 + } else if (status & QCA953X_PCIE_WMAC_INT_WMAC_ALL) {
5091 + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_WMAC);
5092 + generic_handle_irq(ATH79_IP2_IRQ(1));
5093 + } else {
5094 + spurious_interrupt();
5097 + enable_irq(irq);
5100 +static void qca953x_irq_init(void)
5102 + int i;
5104 + for (i = ATH79_IP2_IRQ_BASE;
5105 + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
5106 + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
5108 + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca953x_ip2_irq_dispatch);
5111 static void qca955x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
5113 u32 status;
5114 @@ -222,19 +257,108 @@
5116 for (i = ATH79_IP2_IRQ_BASE;
5117 i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
5118 - irq_set_chip_and_handler(i, &dummy_irq_chip,
5119 - handle_level_irq);
5120 + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
5122 irq_set_chained_handler(ATH79_CPU_IRQ(2), qca955x_ip2_irq_dispatch);
5124 for (i = ATH79_IP3_IRQ_BASE;
5125 i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
5126 - irq_set_chip_and_handler(i, &dummy_irq_chip,
5127 - handle_level_irq);
5128 + irq_set_chip_and_handler(i, &ip3_chip, handle_level_irq);
5130 irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
5133 +static void qca956x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
5135 + u32 status;
5137 + disable_irq_nosync(irq);
5139 + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
5140 + status &= QCA956X_EXT_INT_PCIE_RC1_ALL | QCA956X_EXT_INT_WMAC_ALL;
5142 + if (status == 0) {
5143 + spurious_interrupt();
5144 + goto enable;
5147 + if (status & QCA956X_EXT_INT_PCIE_RC1_ALL) {
5148 + /* TODO: flush DDR? */
5149 + generic_handle_irq(ATH79_IP2_IRQ(0));
5152 + if (status & QCA956X_EXT_INT_WMAC_ALL) {
5153 + /* TODO: flsuh DDR? */
5154 + generic_handle_irq(ATH79_IP2_IRQ(1));
5157 +enable:
5158 + enable_irq(irq);
5161 +static void qca956x_ip3_irq_dispatch(unsigned int irq, struct irq_desc *desc)
5163 + u32 status;
5165 + disable_irq_nosync(irq);
5167 + status = ath79_reset_rr(QCA956X_RESET_REG_EXT_INT_STATUS);
5168 + status &= QCA956X_EXT_INT_PCIE_RC2_ALL |
5169 + QCA956X_EXT_INT_USB1 | QCA956X_EXT_INT_USB2;
5171 + if (status == 0) {
5172 + spurious_interrupt();
5173 + goto enable;
5176 + if (status & QCA956X_EXT_INT_USB1) {
5177 + /* TODO: flush DDR? */
5178 + generic_handle_irq(ATH79_IP3_IRQ(0));
5181 + if (status & QCA956X_EXT_INT_USB2) {
5182 + /* TODO: flush DDR? */
5183 + generic_handle_irq(ATH79_IP3_IRQ(1));
5186 + if (status & QCA956X_EXT_INT_PCIE_RC2_ALL) {
5187 + /* TODO: flush DDR? */
5188 + generic_handle_irq(ATH79_IP3_IRQ(2));
5191 +enable:
5192 + enable_irq(irq);
5195 +static void qca956x_enable_timer_cb(void) {
5196 + u32 misc;
5198 + misc = ath79_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
5199 + misc |= MISC_INT_MIPS_SI_TIMERINT_MASK;
5200 + ath79_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, misc);
5203 +static void qca956x_irq_init(void)
5205 + int i;
5207 + for (i = ATH79_IP2_IRQ_BASE;
5208 + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
5209 + irq_set_chip_and_handler(i, &ip2_chip, handle_level_irq);
5211 + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca956x_ip2_irq_dispatch);
5213 + for (i = ATH79_IP3_IRQ_BASE;
5214 + i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
5215 + irq_set_chip_and_handler(i, &ip3_chip, handle_level_irq);
5217 + irq_set_chained_handler(ATH79_CPU_IRQ(3), qca956x_ip3_irq_dispatch);
5219 + /* QCA956x timer init workaround has to be applied right before setting
5220 + * up the clock. Else, there will be no jiffies */
5221 + late_time_init = &qca956x_enable_timer_cb;
5224 asmlinkage void plat_irq_dispatch(void)
5226 unsigned long pending;
5227 @@ -335,8 +459,41 @@
5228 do_IRQ(ATH79_CPU_IRQ(3));
5231 +static void qca953x_ip3_handler(void)
5233 + ath79_ddr_wb_flush(QCA953X_DDR_REG_FLUSH_USB);
5234 + do_IRQ(ATH79_CPU_IRQ(3));
5237 +static void ath79_ip2_disable(struct irq_data *data)
5239 + disable_irq(ATH79_CPU_IRQ(2));
5242 +static void ath79_ip2_enable(struct irq_data *data)
5244 + enable_irq(ATH79_CPU_IRQ(2));
5247 +static void ath79_ip3_disable(struct irq_data *data)
5249 + disable_irq(ATH79_CPU_IRQ(3));
5252 +static void ath79_ip3_enable(struct irq_data *data)
5254 + enable_irq(ATH79_CPU_IRQ(3));
5257 void __init arch_init_irq(void)
5259 + ip2_chip = dummy_irq_chip;
5260 + ip3_chip = dummy_irq_chip;
5261 + ip2_chip.irq_disable = ath79_ip2_disable;
5262 + ip2_chip.irq_enable = ath79_ip2_enable;
5263 + ip3_chip.irq_disable = ath79_ip3_disable;
5264 + ip3_chip.irq_enable = ath79_ip3_enable;
5266 if (soc_is_ar71xx()) {
5267 ath79_ip2_handler = ar71xx_ip2_handler;
5268 ath79_ip3_handler = ar71xx_ip3_handler;
5269 @@ -352,9 +509,15 @@
5270 } else if (soc_is_ar934x()) {
5271 ath79_ip2_handler = ath79_default_ip2_handler;
5272 ath79_ip3_handler = ar934x_ip3_handler;
5273 + } else if (soc_is_qca953x()) {
5274 + ath79_ip2_handler = ath79_default_ip2_handler;
5275 + ath79_ip3_handler = qca953x_ip3_handler;
5276 } else if (soc_is_qca955x()) {
5277 ath79_ip2_handler = ath79_default_ip2_handler;
5278 ath79_ip3_handler = ath79_default_ip3_handler;
5279 + } else if (soc_is_qca956x()) {
5280 + ath79_ip2_handler = ath79_default_ip2_handler;
5281 + ath79_ip3_handler = ath79_default_ip3_handler;
5282 } else {
5283 BUG();
5285 @@ -364,6 +527,10 @@
5287 if (soc_is_ar934x())
5288 ar934x_ip2_irq_init();
5289 + else if (soc_is_qca953x())
5290 + qca953x_irq_init();
5291 else if (soc_is_qca955x())
5292 qca955x_irq_init();
5293 + else if (soc_is_qca956x())
5294 + qca956x_irq_init();
5296 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-alfa-ap96.c linux-4.1.43/arch/mips/ath79/mach-alfa-ap96.c
5297 --- linux-4.1.43.orig/arch/mips/ath79/mach-alfa-ap96.c 1970-01-01 01:00:00.000000000 +0100
5298 +++ linux-4.1.43/arch/mips/ath79/mach-alfa-ap96.c 2017-08-06 20:02:15.000000000 +0200
5299 @@ -0,0 +1,151 @@
5301 + * ALFA Network AP96 board support
5303 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5305 + * This program is free software; you can redistribute it and/or modify it
5306 + * under the terms of the GNU General Public License version 2 as published
5307 + * by the Free Software Foundation.
5308 + */
5310 +#include <linux/init.h>
5311 +#include <linux/bitops.h>
5312 +#include <linux/gpio.h>
5313 +#include <linux/platform_device.h>
5314 +#include <linux/mmc/host.h>
5315 +#include <linux/spi/spi.h>
5316 +#include <linux/spi/mmc_spi.h>
5318 +#include <asm/mach-ath79/ath79.h>
5319 +#include <asm/mach-ath79/ar71xx_regs.h>
5321 +#include "common.h"
5322 +#include "dev-eth.h"
5323 +#include "dev-gpio-buttons.h"
5324 +#include "dev-spi.h"
5325 +#include "dev-usb.h"
5326 +#include "machtypes.h"
5327 +#include "pci.h"
5329 +#define ALFA_AP96_GPIO_PCIE_RESET 2
5330 +#define ALFA_AP96_GPIO_SIM_DETECT 3
5331 +#define ALFA_AP96_GPIO_MICROSD_CD 4
5332 +#define ALFA_AP96_GPIO_PCIE_W_DISABLE 5
5334 +#define ALFA_AP96_GPIO_BUTTON_RESET 11
5336 +#define ALFA_AP96_KEYS_POLL_INTERVAL 20 /* msecs */
5337 +#define ALFA_AP96_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_AP96_KEYS_POLL_INTERVAL)
5339 +static struct gpio_keys_button alfa_ap96_gpio_keys[] __initdata = {
5341 + .desc = "Reset button",
5342 + .type = EV_KEY,
5343 + .code = KEY_RESTART,
5344 + .debounce_interval = ALFA_AP96_KEYS_DEBOUNCE_INTERVAL,
5345 + .gpio = ALFA_AP96_GPIO_BUTTON_RESET,
5346 + .active_low = 1,
5350 +static struct mmc_spi_platform_data alfa_ap96_mmc_data = {
5351 + .flags = MMC_SPI_USE_CD_GPIO,
5352 + .cd_gpio = ALFA_AP96_GPIO_MICROSD_CD,
5353 + .cd_debounce = 1,
5354 + .caps = MMC_CAP_NEEDS_POLL,
5355 + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
5358 +static struct ath79_spi_controller_data ap96_spi0_cdata = {
5359 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
5360 + .cs_line = 0,
5361 + .is_flash = true,
5364 +static struct ath79_spi_controller_data ap96_spi1_cdata = {
5365 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
5366 + .cs_line = 1,
5369 +static struct ath79_spi_controller_data ap96_spi2_cdata = {
5370 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
5371 + .cs_line = 2,
5374 +static struct spi_board_info alfa_ap96_spi_info[] = {
5376 + .bus_num = 0,
5377 + .chip_select = 0,
5378 + .max_speed_hz = 25000000,
5379 + .modalias = "m25p80",
5380 + .controller_data = &ap96_spi0_cdata
5381 + }, {
5382 + .bus_num = 0,
5383 + .chip_select = 1,
5384 + .max_speed_hz = 25000000,
5385 + .modalias = "mmc_spi",
5386 + .platform_data = &alfa_ap96_mmc_data,
5387 + .controller_data = &ap96_spi1_cdata
5388 + }, {
5389 + .bus_num = 0,
5390 + .chip_select = 2,
5391 + .max_speed_hz = 6250000,
5392 + .modalias = "rtc-pcf2123",
5393 + .controller_data = &ap96_spi2_cdata
5394 + },
5397 +static struct ath79_spi_platform_data alfa_ap96_spi_data = {
5398 + .bus_num = 0,
5399 + .num_chipselect = 3,
5402 +static void __init alfa_ap96_gpio_setup(void)
5404 + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
5405 + AR71XX_GPIO_FUNC_SPI_CS2_EN);
5407 + gpio_request(ALFA_AP96_GPIO_MICROSD_CD, "microSD CD");
5408 + gpio_direction_input(ALFA_AP96_GPIO_MICROSD_CD);
5409 + gpio_request(ALFA_AP96_GPIO_PCIE_RESET, "PCIe reset");
5410 + gpio_direction_output(ALFA_AP96_GPIO_PCIE_RESET, 1);
5411 + gpio_request(ALFA_AP96_GPIO_PCIE_W_DISABLE, "PCIe write disable");
5412 + gpio_direction_output(ALFA_AP96_GPIO_PCIE_W_DISABLE, 1);
5415 +#define ALFA_AP96_WAN_PHYMASK BIT(4)
5416 +#define ALFA_AP96_LAN_PHYMASK BIT(5)
5417 +#define ALFA_AP96_MDIO_PHYMASK (ALFA_AP96_LAN_PHYMASK | ALFA_AP96_WAN_PHYMASK)
5419 +static void __init alfa_ap96_init(void)
5421 + alfa_ap96_gpio_setup();
5423 + ath79_register_mdio(0, ~ALFA_AP96_MDIO_PHYMASK);
5425 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
5426 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
5427 + ath79_eth0_data.phy_mask = ALFA_AP96_WAN_PHYMASK;
5428 + ath79_eth1_pll_data.pll_1000 = 0x110000;
5430 + ath79_register_eth(0);
5432 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
5433 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
5434 + ath79_eth1_data.phy_mask = ALFA_AP96_LAN_PHYMASK;
5435 + ath79_eth1_pll_data.pll_1000 = 0x110000;
5437 + ath79_register_eth(1);
5439 + ath79_register_pci();
5440 + ath79_register_spi(&alfa_ap96_spi_data, alfa_ap96_spi_info,
5441 + ARRAY_SIZE(alfa_ap96_spi_info));
5443 + ath79_register_gpio_keys_polled(-1, ALFA_AP96_KEYS_POLL_INTERVAL,
5444 + ARRAY_SIZE(alfa_ap96_gpio_keys),
5445 + alfa_ap96_gpio_keys);
5446 + ath79_register_usb();
5449 +MIPS_MACHINE(ATH79_MACH_ALFA_AP96, "ALFA-AP96", "ALFA Network AP96",
5450 + alfa_ap96_init);
5451 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-alfa-nx.c linux-4.1.43/arch/mips/ath79/mach-alfa-nx.c
5452 --- linux-4.1.43.orig/arch/mips/ath79/mach-alfa-nx.c 1970-01-01 01:00:00.000000000 +0100
5453 +++ linux-4.1.43/arch/mips/ath79/mach-alfa-nx.c 2017-08-06 20:02:15.000000000 +0200
5454 @@ -0,0 +1,113 @@
5456 + * ALFA Network N2/N5 board support
5458 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
5460 + * This program is free software; you can redistribute it and/or modify it
5461 + * under the terms of the GNU General Public License version 2 as published
5462 + * by the Free Software Foundation.
5463 + */
5465 +#include <asm/mach-ath79/ar71xx_regs.h>
5466 +#include <asm/mach-ath79/ath79.h>
5468 +#include "common.h"
5469 +#include "dev-eth.h"
5470 +#include "dev-ap9x-pci.h"
5471 +#include "dev-gpio-buttons.h"
5472 +#include "dev-leds-gpio.h"
5473 +#include "dev-m25p80.h"
5474 +#include "machtypes.h"
5476 +#define ALFA_NX_GPIO_LED_2 17
5477 +#define ALFA_NX_GPIO_LED_3 16
5478 +#define ALFA_NX_GPIO_LED_5 12
5479 +#define ALFA_NX_GPIO_LED_6 8
5480 +#define ALFA_NX_GPIO_LED_7 6
5481 +#define ALFA_NX_GPIO_LED_8 7
5483 +#define ALFA_NX_GPIO_BTN_RESET 11
5485 +#define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */
5486 +#define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
5488 +#define ALFA_NX_MAC0_OFFSET 0
5489 +#define ALFA_NX_MAC1_OFFSET 6
5490 +#define ALFA_NX_CALDATA_OFFSET 0x1000
5492 +static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = {
5494 + .desc = "Reset button",
5495 + .type = EV_KEY,
5496 + .code = KEY_RESTART,
5497 + .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL,
5498 + .gpio = ALFA_NX_GPIO_BTN_RESET,
5499 + .active_low = 1,
5503 +static struct gpio_led alfa_nx_leds_gpio[] __initdata = {
5505 + .name = "alfa:green:led_2",
5506 + .gpio = ALFA_NX_GPIO_LED_2,
5507 + .active_low = 1,
5508 + }, {
5509 + .name = "alfa:green:led_3",
5510 + .gpio = ALFA_NX_GPIO_LED_3,
5511 + .active_low = 1,
5512 + }, {
5513 + .name = "alfa:red:led_5",
5514 + .gpio = ALFA_NX_GPIO_LED_5,
5515 + .active_low = 1,
5516 + }, {
5517 + .name = "alfa:amber:led_6",
5518 + .gpio = ALFA_NX_GPIO_LED_6,
5519 + .active_low = 1,
5520 + }, {
5521 + .name = "alfa:green:led_7",
5522 + .gpio = ALFA_NX_GPIO_LED_7,
5523 + .active_low = 1,
5524 + }, {
5525 + .name = "alfa:green:led_8",
5526 + .gpio = ALFA_NX_GPIO_LED_8,
5527 + .active_low = 1,
5531 +static void __init alfa_nx_setup(void)
5533 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
5535 + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
5536 + AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
5537 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
5538 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
5539 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
5540 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
5542 + ath79_register_m25p80(NULL);
5544 + ath79_register_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio),
5545 + alfa_nx_leds_gpio);
5547 + ath79_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL,
5548 + ARRAY_SIZE(alfa_nx_gpio_keys),
5549 + alfa_nx_gpio_keys);
5551 + ath79_register_mdio(0, 0x0);
5553 + ath79_init_mac(ath79_eth0_data.mac_addr,
5554 + art + ALFA_NX_MAC0_OFFSET, 0);
5555 + ath79_init_mac(ath79_eth1_data.mac_addr,
5556 + art + ALFA_NX_MAC1_OFFSET, 0);
5558 + /* WAN port */
5559 + ath79_register_eth(0);
5560 + /* LAN port */
5561 + ath79_register_eth(1);
5563 + ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL);
5566 +MIPS_MACHINE(ATH79_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5",
5567 + alfa_nx_setup);
5568 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-all0258n.c linux-4.1.43/arch/mips/ath79/mach-all0258n.c
5569 --- linux-4.1.43.orig/arch/mips/ath79/mach-all0258n.c 1970-01-01 01:00:00.000000000 +0100
5570 +++ linux-4.1.43/arch/mips/ath79/mach-all0258n.c 2017-08-06 20:02:15.000000000 +0200
5571 @@ -0,0 +1,88 @@
5573 + * Allnet ALL0258N support
5575 + * Copyright (C) 2011 Daniel Golle <dgolle@allnet.de>
5577 + * This program is free software; you can redistribute it and/or modify it
5578 + * under the terms of the GNU General Public License version 2 as published
5579 + * by the Free Software Foundation.
5580 + */
5582 +#include <asm/mach-ath79/ath79.h>
5584 +#include "dev-eth.h"
5585 +#include "dev-ap9x-pci.h"
5586 +#include "dev-gpio-buttons.h"
5587 +#include "dev-leds-gpio.h"
5588 +#include "dev-m25p80.h"
5589 +#include "machtypes.h"
5591 +/* found via /sys/gpio/... try and error */
5592 +#define ALL0258N_GPIO_BTN_RESET 1
5593 +#define ALL0258N_GPIO_LED_RSSIHIGH 13
5594 +#define ALL0258N_GPIO_LED_RSSIMEDIUM 15
5595 +#define ALL0258N_GPIO_LED_RSSILOW 14
5597 +/* defaults taken from others machs */
5598 +#define ALL0258N_KEYS_POLL_INTERVAL 20 /* msecs */
5599 +#define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL)
5601 +/* showed up in the original firmware's bootlog */
5602 +#define ALL0258N_SEC_PHYMASK BIT(3)
5604 +static struct gpio_led all0258n_leds_gpio[] __initdata = {
5606 + .name = "all0258n:green:rssihigh",
5607 + .gpio = ALL0258N_GPIO_LED_RSSIHIGH,
5608 + .active_low = 1,
5609 + }, {
5610 + .name = "all0258n:yellow:rssimedium",
5611 + .gpio = ALL0258N_GPIO_LED_RSSIMEDIUM,
5612 + .active_low = 1,
5613 + }, {
5614 + .name = "all0258n:red:rssilow",
5615 + .gpio = ALL0258N_GPIO_LED_RSSILOW,
5616 + .active_low = 1,
5620 +static struct gpio_keys_button all0258n_gpio_keys[] __initdata = {
5622 + .desc = "reset",
5623 + .type = EV_KEY,
5624 + .code = KEY_RESTART,
5625 + .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL,
5626 + .gpio = ALL0258N_GPIO_BTN_RESET,
5627 + .active_low = 1,
5631 +static void __init all0258n_setup(void)
5633 + u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000);
5634 + u8 *ee = (u8 *) KSEG1ADDR(0x1f7f1000);
5636 + ath79_register_m25p80(NULL);
5638 + ath79_register_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio),
5639 + all0258n_leds_gpio);
5641 + ath79_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL,
5642 + ARRAY_SIZE(all0258n_gpio_keys),
5643 + all0258n_gpio_keys);
5645 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
5646 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
5648 + ath79_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK;
5650 + ath79_register_mdio(0, 0x0);
5652 + ath79_register_eth(0);
5653 + ath79_register_eth(1);
5655 + ap91_pci_init(ee, mac);
5658 +MIPS_MACHINE(ATH79_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N",
5659 + all0258n_setup);
5660 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-all0315n.c linux-4.1.43/arch/mips/ath79/mach-all0315n.c
5661 --- linux-4.1.43.orig/arch/mips/ath79/mach-all0315n.c 1970-01-01 01:00:00.000000000 +0100
5662 +++ linux-4.1.43/arch/mips/ath79/mach-all0315n.c 2017-08-06 20:02:15.000000000 +0200
5663 @@ -0,0 +1,85 @@
5665 + * Allnet ALL0315N support
5667 + * Copyright (C) 2012 Daniel Golle <dgolle@allnet.de>
5670 + * This program is free software; you can redistribute it and/or modify it
5671 + * under the terms of the GNU General Public License version 2 as published
5672 + * by the Free Software Foundation.
5673 + */
5675 +#include <asm/mach-ath79/ath79.h>
5676 +#include <asm/mach-ath79/ar71xx_regs.h>
5678 +#include "common.h"
5679 +#include "dev-eth.h"
5680 +#include "dev-ap9x-pci.h"
5681 +#include "dev-gpio-buttons.h"
5682 +#include "dev-m25p80.h"
5683 +#include "dev-leds-gpio.h"
5684 +#include "machtypes.h"
5685 +#include "pci.h"
5687 +#define ALL0315N_GPIO_BTN_RESET 0
5688 +#define ALL0315N_GPIO_LED_RSSIHIGH 14
5689 +#define ALL0315N_GPIO_LED_RSSIMEDIUM 15
5690 +#define ALL0315N_GPIO_LED_RSSILOW 16
5692 +#define ALL0315N_KEYS_POLL_INTERVAL 20 /* msecs */
5693 +#define ALL0315N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0315N_KEYS_POLL_INTERVAL)
5695 +static struct gpio_led all0315n_leds_gpio[] __initdata = {
5697 + .name = "all0315n:green:rssihigh",
5698 + .gpio = ALL0315N_GPIO_LED_RSSIHIGH,
5699 + .active_low = 1,
5700 + }, {
5701 + .name = "all0315n:yellow:rssimedium",
5702 + .gpio = ALL0315N_GPIO_LED_RSSIMEDIUM,
5703 + .active_low = 1,
5704 + }, {
5705 + .name = "all0315n:red:rssilow",
5706 + .gpio = ALL0315N_GPIO_LED_RSSILOW,
5707 + .active_low = 1,
5711 +static struct gpio_keys_button all0315n_gpio_keys[] __initdata = {
5713 + .desc = "reset",
5714 + .type = EV_KEY,
5715 + .code = KEY_RESTART,
5716 + .debounce_interval = ALL0315N_KEYS_DEBOUNCE_INTERVAL,
5717 + .gpio = ALL0315N_GPIO_BTN_RESET,
5718 + .active_low = 1,
5722 +static void __init all0315n_setup(void)
5724 + u8 *mac = (u8 *) KSEG1ADDR(0x1ffc0000);
5725 + u8 *ee = (u8 *) KSEG1ADDR(0x1ffc1000);
5727 + ath79_register_m25p80(NULL);
5729 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
5730 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
5731 + ath79_eth0_data.phy_mask = BIT(0);
5733 + ath79_register_mdio(0, 0x0);
5734 + ath79_register_eth(0);
5736 + ath79_register_leds_gpio(-1, ARRAY_SIZE(all0315n_leds_gpio),
5737 + all0315n_leds_gpio);
5739 + ath79_register_gpio_keys_polled(-1, ALL0315N_KEYS_POLL_INTERVAL,
5740 + ARRAY_SIZE(all0315n_gpio_keys),
5741 + all0315n_gpio_keys);
5743 + ap9x_pci_setup_wmac_led_pin(0, 1);
5744 + ap91_pci_init(ee, NULL);
5747 +MIPS_MACHINE(ATH79_MACH_ALL0315N, "ALL0315N", "Allnet ALL0315N",
5748 + all0315n_setup);
5749 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-antminer-s1.c linux-4.1.43/arch/mips/ath79/mach-antminer-s1.c
5750 --- linux-4.1.43.orig/arch/mips/ath79/mach-antminer-s1.c 1970-01-01 01:00:00.000000000 +0100
5751 +++ linux-4.1.43/arch/mips/ath79/mach-antminer-s1.c 2017-08-06 20:02:15.000000000 +0200
5752 @@ -0,0 +1,98 @@
5754 + * Bitmain Antminer S1 board support
5756 + * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com>
5758 + * This program is free software; you can redistribute it and/or modify it
5759 + * under the terms of the GNU General Public License version 2 as published
5760 + * by the Free Software Foundation.
5761 + */
5763 +#include <linux/gpio.h>
5765 +#include <asm/mach-ath79/ath79.h>
5766 +#include <asm/mach-ath79/ar71xx_regs.h>
5768 +#include "common.h"
5769 +#include "dev-eth.h"
5770 +#include "dev-gpio-buttons.h"
5771 +#include "dev-leds-gpio.h"
5772 +#include "dev-m25p80.h"
5773 +#include "dev-wmac.h"
5774 +#include "machtypes.h"
5775 +#include "dev-usb.h"
5777 +#define ANTMINER_S1_GPIO_BTN_RESET 11
5779 +#define ANTMINER_S1_GPIO_LED_SYSTEM 23
5780 +#define ANTMINER_S1_GPIO_LED_WLAN 0
5781 +#define ANTMINER_S1_GPIO_USB_POWER 26
5783 +#define ANTMINER_S1_KEYSPOLL_INTERVAL 20 /* msecs */
5784 +#define ANTMINER_S1_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S1_KEYSPOLL_INTERVAL)
5786 +static const char *ANTMINER_S1_part_probes[] = {
5787 + "tp-link",
5788 + NULL,
5791 +static struct flash_platform_data ANTMINER_S1_flash_data = {
5792 + .part_probes = ANTMINER_S1_part_probes,
5795 +static struct gpio_led ANTMINER_S1_leds_gpio[] __initdata = {
5797 + .name = "antminer-s1:green:system",
5798 + .gpio = ANTMINER_S1_GPIO_LED_SYSTEM,
5799 + .active_low = 0,
5800 + },{
5801 + .name = "antminer-s1:green:wlan",
5802 + .gpio = ANTMINER_S1_GPIO_LED_WLAN,
5803 + .active_low = 0,
5804 + },
5807 +static struct gpio_keys_button ANTMINER_S1_GPIO_keys[] __initdata = {
5809 + .desc = "reset",
5810 + .type = EV_KEY,
5811 + .code = KEY_RESTART,
5812 + .debounce_interval = ANTMINER_S1_KEYSDEBOUNCE_INTERVAL,
5813 + .gpio = ANTMINER_S1_GPIO_BTN_RESET,
5814 + .active_low = 0,
5815 + },
5818 +static void __init antminer_s1_setup(void)
5820 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
5821 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
5823 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
5824 + ath79_setup_ar933x_phy4_switch(false, false);
5826 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S1_leds_gpio),
5827 + ANTMINER_S1_leds_gpio);
5829 + ath79_register_gpio_keys_polled(-1, ANTMINER_S1_KEYSPOLL_INTERVAL,
5830 + ARRAY_SIZE(ANTMINER_S1_GPIO_keys),
5831 + ANTMINER_S1_GPIO_keys);
5833 + gpio_request_one(ANTMINER_S1_GPIO_USB_POWER,
5834 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
5835 + "USB power");
5836 + ath79_register_usb();
5838 + ath79_register_m25p80(&ANTMINER_S1_flash_data);
5839 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
5840 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
5842 + ath79_register_mdio(0, 0x0);
5843 + ath79_register_eth(0);
5844 + ath79_register_eth(1);
5846 + ath79_register_wmac(ee, mac);
5849 +MIPS_MACHINE(ATH79_MACH_ANTMINER_S1, "ANTMINER-S1",
5850 + "Antminer-S1", antminer_s1_setup);
5851 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-antminer-s3.c linux-4.1.43/arch/mips/ath79/mach-antminer-s3.c
5852 --- linux-4.1.43.orig/arch/mips/ath79/mach-antminer-s3.c 1970-01-01 01:00:00.000000000 +0100
5853 +++ linux-4.1.43/arch/mips/ath79/mach-antminer-s3.c 2017-08-06 20:02:15.000000000 +0200
5854 @@ -0,0 +1,103 @@
5856 + * Bitmain Antminer S3 board support
5858 + * Copyright (C) 2015 L. D. Pinney <ldpinney@gmail.com>
5860 + * This program is free software; you can redistribute it and/or modify it
5861 + * under the terms of the GNU General Public License version 2 as published
5862 + * by the Free Software Foundation.
5863 + */
5865 +#include <linux/gpio.h>
5867 +#include <asm/mach-ath79/ath79.h>
5868 +#include <asm/mach-ath79/ar71xx_regs.h>
5870 +#include "common.h"
5871 +#include "dev-eth.h"
5872 +#include "dev-gpio-buttons.h"
5873 +#include "dev-leds-gpio.h"
5874 +#include "dev-m25p80.h"
5875 +#include "dev-wmac.h"
5876 +#include "machtypes.h"
5877 +#include "dev-usb.h"
5879 +#define ANTMINER_S3_GPIO_LED_WLAN 0
5880 +#define ANTMINER_S3_GPIO_LED_SYSTEM 17
5881 +#define ANTMINER_S3_GPIO_LED_LAN 22
5882 +#define ANTMINER_S3_GPIO_USB_POWER 26
5884 +#define ANTMINER_S3_GPIO_BTN_RESET 11
5886 +#define ANTMINER_S3_KEYSPOLL_INTERVAL 88 /* msecs */
5887 +#define ANTMINER_S3_KEYSDEBOUNCE_INTERVAL (3 * ANTMINER_S3_KEYSPOLL_INTERVAL)
5889 +static const char *ANTMINER_S3_part_probes[] = {
5890 + "tp-link",
5891 + NULL,
5894 +static struct flash_platform_data ANTMINER_S3_flash_data = {
5895 + .part_probes = ANTMINER_S3_part_probes,
5898 +static struct gpio_led ANTMINER_S3_leds_gpio[] __initdata = {
5900 + .name = "antminer-s3:green:wlan",
5901 + .gpio = ANTMINER_S3_GPIO_LED_WLAN,
5902 + .active_low = 0,
5903 + },{
5904 + .name = "antminer-s3:green:system",
5905 + .gpio = ANTMINER_S3_GPIO_LED_SYSTEM,
5906 + .active_low = 0,
5907 + },{
5908 + .name = "antminer-s3:yellow:lan",
5909 + .gpio = ANTMINER_S3_GPIO_LED_LAN,
5910 + .active_low = 0,
5911 + },
5914 +static struct gpio_keys_button ANTMINER_S3_GPIO_keys[] __initdata = {
5916 + .desc = "reset",
5917 + .type = EV_KEY,
5918 + .code = KEY_RESTART,
5919 + .debounce_interval = ANTMINER_S3_KEYSDEBOUNCE_INTERVAL,
5920 + .gpio = ANTMINER_S3_GPIO_BTN_RESET,
5921 + .active_low = 0,
5922 + },
5925 +static void __init antminer_s3_setup(void)
5927 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
5928 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
5930 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
5931 + ath79_setup_ar933x_phy4_switch(false, false);
5933 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTMINER_S3_leds_gpio),
5934 + ANTMINER_S3_leds_gpio);
5936 + ath79_register_gpio_keys_polled(-1, ANTMINER_S3_KEYSPOLL_INTERVAL,
5937 + ARRAY_SIZE(ANTMINER_S3_GPIO_keys),
5938 + ANTMINER_S3_GPIO_keys);
5940 + gpio_request_one(ANTMINER_S3_GPIO_USB_POWER,
5941 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
5942 + "USB power");
5943 + ath79_register_usb();
5945 + ath79_register_m25p80(&ANTMINER_S3_flash_data);
5946 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
5947 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
5949 + ath79_register_mdio(0, 0x0);
5950 + ath79_register_eth(0);
5951 + ath79_register_eth(1);
5953 + ath79_register_wmac(ee, mac);
5956 +MIPS_MACHINE(ATH79_MACH_ANTMINER_S3, "ANTMINER-S3",
5957 + "Antminer-S3", antminer_s3_setup);
5958 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap113.c linux-4.1.43/arch/mips/ath79/mach-ap113.c
5959 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap113.c 1970-01-01 01:00:00.000000000 +0100
5960 +++ linux-4.1.43/arch/mips/ath79/mach-ap113.c 2017-08-06 20:02:15.000000000 +0200
5961 @@ -0,0 +1,84 @@
5963 + * Atheros AP113 board support
5965 + * Copyright (C) 2011 Florian Fainelli <florian@openwrt.org>
5967 + * This program is free software; you can redistribute it and/or modify it
5968 + * under the terms of the GNU General Public License version 2 as published
5969 + * by the Free Software Foundation.
5970 + */
5972 +#include "dev-eth.h"
5973 +#include "dev-gpio-buttons.h"
5974 +#include "dev-leds-gpio.h"
5975 +#include "dev-m25p80.h"
5976 +#include "pci.h"
5977 +#include "dev-usb.h"
5978 +#include "machtypes.h"
5980 +#define AP113_GPIO_LED_USB 0
5981 +#define AP113_GPIO_LED_STATUS 1
5982 +#define AP113_GPIO_LED_ST 11
5984 +#define AP113_GPIO_BTN_JUMPSTART 12
5986 +#define AP113_KEYS_POLL_INTERVAL 20 /* msecs */
5987 +#define AP113_KEYS_DEBOUNCE_INTERVAL (3 * AP113_KEYS_POLL_INTERVAL)
5989 +static struct gpio_led ap113_leds_gpio[] __initdata = {
5991 + .name = "ap113:green:usb",
5992 + .gpio = AP113_GPIO_LED_USB,
5993 + .active_low = 1,
5994 + },
5996 + .name = "ap113:green:status",
5997 + .gpio = AP113_GPIO_LED_STATUS,
5998 + .active_low = 1,
5999 + },
6001 + .name = "ap113:green:st",
6002 + .gpio = AP113_GPIO_LED_ST,
6003 + .active_low = 1,
6007 +static struct gpio_keys_button ap113_gpio_keys[] __initdata = {
6009 + .desc = "jumpstart button",
6010 + .type = EV_KEY,
6011 + .code = KEY_WPS_BUTTON,
6012 + .debounce_interval = AP113_KEYS_DEBOUNCE_INTERVAL,
6013 + .gpio = AP113_GPIO_BTN_JUMPSTART,
6014 + .active_low = 1,
6015 + },
6018 +static void __init ap113_setup(void)
6020 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
6022 + ath79_register_m25p80(NULL);
6024 + ath79_register_mdio(0, ~BIT(0));
6025 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
6026 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
6027 + ath79_eth0_data.speed = SPEED_1000;
6028 + ath79_eth0_data.duplex = DUPLEX_FULL;
6029 + ath79_eth0_data.phy_mask = BIT(0);
6031 + ath79_register_eth(0);
6033 + ath79_register_gpio_keys_polled(-1, AP113_KEYS_POLL_INTERVAL,
6034 + ARRAY_SIZE(ap113_gpio_keys),
6035 + ap113_gpio_keys);
6036 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap113_leds_gpio),
6037 + ap113_leds_gpio);
6039 + ath79_register_pci();
6041 + ath79_register_usb();
6044 +MIPS_MACHINE(ATH79_MACH_AP113, "AP113", "Atheros AP113",
6045 + ap113_setup);
6046 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap121.c linux-4.1.43/arch/mips/ath79/mach-ap121.c
6047 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap121.c 2017-08-06 01:56:14.000000000 +0200
6048 +++ linux-4.1.43/arch/mips/ath79/mach-ap121.c 2017-08-06 20:02:15.000000000 +0200
6049 @@ -1,19 +1,21 @@
6051 * Atheros AP121 board support
6053 - * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
6054 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6056 * This program is free software; you can redistribute it and/or modify it
6057 * under the terms of the GNU General Public License version 2 as published
6058 * by the Free Software Foundation.
6061 -#include "machtypes.h"
6062 +#include "dev-eth.h"
6063 #include "dev-gpio-buttons.h"
6064 #include "dev-leds-gpio.h"
6065 +#include "dev-m25p80.h"
6066 #include "dev-spi.h"
6067 #include "dev-usb.h"
6068 #include "dev-wmac.h"
6069 +#include "machtypes.h"
6071 #define AP121_GPIO_LED_WLAN 0
6072 #define AP121_GPIO_LED_USB 1
6073 @@ -24,7 +26,14 @@
6074 #define AP121_KEYS_POLL_INTERVAL 20 /* msecs */
6075 #define AP121_KEYS_DEBOUNCE_INTERVAL (3 * AP121_KEYS_POLL_INTERVAL)
6077 -#define AP121_CAL_DATA_ADDR 0x1fff1000
6078 +#define AP121_MAC0_OFFSET 0x0000
6079 +#define AP121_MAC1_OFFSET 0x0006
6080 +#define AP121_CALDATA_OFFSET 0x1000
6081 +#define AP121_WMAC_MAC_OFFSET 0x1002
6083 +#define AP121_MINI_GPIO_LED_WLAN 0
6084 +#define AP121_MINI_GPIO_BTN_JUMPSTART 12
6085 +#define AP121_MINI_GPIO_BTN_RESET 11
6087 static struct gpio_led ap121_leds_gpio[] __initdata = {
6089 @@ -58,35 +67,78 @@
6093 -static struct spi_board_info ap121_spi_info[] = {
6094 +static struct gpio_led ap121_mini_leds_gpio[] __initdata = {
6096 - .bus_num = 0,
6097 - .chip_select = 0,
6098 - .max_speed_hz = 25000000,
6099 - .modalias = "mx25l1606e",
6101 + .name = "ap121:green:wlan",
6102 + .gpio = AP121_MINI_GPIO_LED_WLAN,
6103 + .active_low = 0,
6104 + },
6107 -static struct ath79_spi_platform_data ap121_spi_data = {
6108 - .bus_num = 0,
6109 - .num_chipselect = 1,
6110 +static struct gpio_keys_button ap121_mini_gpio_keys[] __initdata = {
6112 + .desc = "jumpstart button",
6113 + .type = EV_KEY,
6114 + .code = KEY_WPS_BUTTON,
6115 + .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
6116 + .gpio = AP121_MINI_GPIO_BTN_JUMPSTART,
6117 + .active_low = 1,
6118 + },
6120 + .desc = "reset button",
6121 + .type = EV_KEY,
6122 + .code = KEY_RESTART,
6123 + .debounce_interval = AP121_KEYS_DEBOUNCE_INTERVAL,
6124 + .gpio = AP121_MINI_GPIO_BTN_RESET,
6125 + .active_low = 1,
6129 +static void __init ap121_common_setup(void)
6131 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6133 + ath79_register_m25p80(NULL);
6134 + ath79_register_wmac(art + AP121_CALDATA_OFFSET,
6135 + art + AP121_WMAC_MAC_OFFSET);
6137 + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP121_MAC0_OFFSET, 0);
6138 + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP121_MAC1_OFFSET, 0);
6140 + ath79_register_mdio(0, 0x0);
6142 + /* LAN ports */
6143 + ath79_register_eth(1);
6145 + /* WAN port */
6146 + ath79_register_eth(0);
6149 static void __init ap121_setup(void)
6151 - u8 *cal_data = (u8 *) KSEG1ADDR(AP121_CAL_DATA_ADDR);
6152 + ap121_common_setup();
6154 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121_leds_gpio),
6155 ap121_leds_gpio);
6156 ath79_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
6157 ARRAY_SIZE(ap121_gpio_keys),
6158 ap121_gpio_keys);
6160 - ath79_register_spi(&ap121_spi_data, ap121_spi_info,
6161 - ARRAY_SIZE(ap121_spi_info));
6162 ath79_register_usb();
6163 - ath79_register_wmac(cal_data);
6166 MIPS_MACHINE(ATH79_MACH_AP121, "AP121", "Atheros AP121 reference board",
6167 ap121_setup);
6169 +static void __init ap121_mini_setup(void)
6171 + ap121_common_setup();
6173 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121_mini_leds_gpio),
6174 + ap121_mini_leds_gpio);
6175 + ath79_register_gpio_keys_polled(-1, AP121_KEYS_POLL_INTERVAL,
6176 + ARRAY_SIZE(ap121_mini_gpio_keys),
6177 + ap121_mini_gpio_keys);
6180 +MIPS_MACHINE(ATH79_MACH_AP121_MINI, "AP121-MINI", "Atheros AP121-MINI",
6181 + ap121_mini_setup);
6182 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap132.c linux-4.1.43/arch/mips/ath79/mach-ap132.c
6183 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap132.c 1970-01-01 01:00:00.000000000 +0100
6184 +++ linux-4.1.43/arch/mips/ath79/mach-ap132.c 2017-08-06 20:02:15.000000000 +0200
6185 @@ -0,0 +1,189 @@
6187 + * Atheros AP132 reference board support
6189 + * Copyright (c) 2012 Qualcomm Atheros
6190 + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6191 + * Copyright (c) 2013 Embedded Wireless GmbH <info@embeddedwireless.de>
6193 + * Permission to use, copy, modify, and/or distribute this software for any
6194 + * purpose with or without fee is hereby granted, provided that the above
6195 + * copyright notice and this permission notice appear in all copies.
6197 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6198 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
6199 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
6200 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
6201 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
6202 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
6203 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6205 + */
6207 +#include <linux/platform_device.h>
6208 +#include <linux/ar8216_platform.h>
6210 +#include <asm/mach-ath79/ar71xx_regs.h>
6212 +#include "common.h"
6213 +#include "dev-ap9x-pci.h"
6214 +#include "dev-gpio-buttons.h"
6215 +#include "dev-eth.h"
6216 +#include "dev-leds-gpio.h"
6217 +#include "dev-m25p80.h"
6218 +#include "dev-usb.h"
6219 +#include "dev-wmac.h"
6220 +#include "machtypes.h"
6222 +#define AP132_GPIO_LED_USB 4
6223 +#define AP132_GPIO_LED_WLAN_5G 12
6224 +#define AP132_GPIO_LED_WLAN_2G 13
6225 +#define AP132_GPIO_LED_STATUS_RED 14
6226 +#define AP132_GPIO_LED_WPS_RED 15
6228 +#define AP132_GPIO_BTN_WPS 16
6230 +#define AP132_KEYS_POLL_INTERVAL 20 /* msecs */
6231 +#define AP132_KEYS_DEBOUNCE_INTERVAL (3 * AP132_KEYS_POLL_INTERVAL)
6233 +#define AP132_MAC0_OFFSET 0
6234 +#define AP132_WMAC_CALDATA_OFFSET 0x1000
6236 +static struct gpio_led ap132_leds_gpio[] __initdata = {
6238 + .name = "ap132:red:status",
6239 + .gpio = AP132_GPIO_LED_STATUS_RED,
6240 + .active_low = 1,
6241 + },
6243 + .name = "ap132:red:wps",
6244 + .gpio = AP132_GPIO_LED_WPS_RED,
6245 + .active_low = 1,
6246 + },
6248 + .name = "ap132:red:wlan-2g",
6249 + .gpio = AP132_GPIO_LED_WLAN_2G,
6250 + .active_low = 1,
6251 + },
6253 + .name = "ap132:red:usb",
6254 + .gpio = AP132_GPIO_LED_USB,
6255 + .active_low = 1,
6259 +static struct gpio_keys_button ap132_gpio_keys[] __initdata = {
6261 + .desc = "WPS button",
6262 + .type = EV_KEY,
6263 + .code = KEY_WPS_BUTTON,
6264 + .debounce_interval = AP132_KEYS_DEBOUNCE_INTERVAL,
6265 + .gpio = AP132_GPIO_BTN_WPS,
6266 + .active_low = 1,
6267 + },
6270 +static struct ar8327_pad_cfg ap132_ar8327_pad0_cfg;
6272 +static struct ar8327_platform_data ap132_ar8327_data = {
6273 + .pad0_cfg = &ap132_ar8327_pad0_cfg,
6274 + .port0_cfg = {
6275 + .force_link = 1,
6276 + .speed = AR8327_PORT_SPEED_1000,
6277 + .duplex = 1,
6278 + .txpause = 1,
6279 + .rxpause = 1,
6280 + },
6283 +static struct mdio_board_info ap132_mdio1_info[] = {
6285 + .bus_id = "ag71xx-mdio.1",
6286 + .phy_addr = 0,
6287 + .platform_data = &ap132_ar8327_data,
6288 + },
6291 +static void __init ap132_mdio_setup(void)
6293 + void __iomem *base;
6294 + u32 t;
6296 +#define GPIO_IN_ENABLE3_ADDRESS 0x0050
6297 +#define GPIO_IN_ENABLE3_MII_GE1_MDI_MASK 0x00ff0000
6298 +#define GPIO_IN_ENABLE3_MII_GE1_MDI_LSB 16
6299 +#define GPIO_IN_ENABLE3_MII_GE1_MDI_SET(x) (((x) << GPIO_IN_ENABLE3_MII_GE1_MDI_LSB) & GPIO_IN_ENABLE3_MII_GE1_MDI_MASK)
6300 +#define GPIO_OUT_FUNCTION4_ADDRESS 0x003c
6301 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK 0xff000000
6302 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_LSB 24
6303 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_SET(x) (((x) << GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_LSB) & GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK)
6304 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK 0x0000ff00
6305 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_LSB 8
6306 +#define GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_SET(x) (((x) << GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_LSB) & GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK)
6308 + base = ioremap(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
6310 + t = __raw_readl(base + GPIO_IN_ENABLE3_ADDRESS);
6311 + t &= ~GPIO_IN_ENABLE3_MII_GE1_MDI_MASK;
6312 + t |= GPIO_IN_ENABLE3_MII_GE1_MDI_SET(19);
6313 + __raw_writel(t, base + GPIO_IN_ENABLE3_ADDRESS);
6316 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << 19), base + AR71XX_GPIO_REG_OE);
6318 + __raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << 17), base + AR71XX_GPIO_REG_OE);
6321 + t = __raw_readl(base + GPIO_OUT_FUNCTION4_ADDRESS);
6322 + t &= ~(GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_MASK | GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_MASK);
6323 + t |= GPIO_OUT_FUNCTION4_ENABLE_GPIO_19_SET(0x20) | GPIO_OUT_FUNCTION4_ENABLE_GPIO_17_SET(0x21);
6324 + __raw_writel(t, base + GPIO_OUT_FUNCTION4_ADDRESS);
6326 + iounmap(base);
6330 +static void __init ap132_setup(void)
6332 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6334 + ath79_register_m25p80(NULL);
6336 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap132_leds_gpio),
6337 + ap132_leds_gpio);
6338 + ath79_register_gpio_keys_polled(-1, AP132_KEYS_POLL_INTERVAL,
6339 + ARRAY_SIZE(ap132_gpio_keys),
6340 + ap132_gpio_keys);
6342 + ath79_register_usb();
6344 + ath79_register_wmac(art + AP132_WMAC_CALDATA_OFFSET, NULL);
6346 + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */
6347 + ap132_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII;
6348 + ap132_ar8327_pad0_cfg.sgmii_delay_en = true;
6350 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
6352 + ap132_mdio_setup();
6354 + ath79_register_mdio(1, 0x0);
6356 + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP132_MAC0_OFFSET, 0);
6358 + mdiobus_register_board_info(ap132_mdio1_info,
6359 + ARRAY_SIZE(ap132_mdio1_info));
6361 + /* GMAC1 is connected to the SGMII interface */
6362 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
6363 + ath79_eth1_data.speed = SPEED_1000;
6364 + ath79_eth1_data.duplex = DUPLEX_FULL;
6365 + ath79_eth1_data.phy_mask = BIT(0);
6366 + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
6368 + ath79_register_eth(1);
6371 +MIPS_MACHINE(ATH79_MACH_AP132, "AP132",
6372 + "Atheros AP132 reference board",
6373 + ap132_setup);
6375 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap136.c linux-4.1.43/arch/mips/ath79/mach-ap136.c
6376 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap136.c 2017-08-06 01:56:14.000000000 +0200
6377 +++ linux-4.1.43/arch/mips/ath79/mach-ap136.c 2017-08-06 20:02:15.000000000 +0200
6378 @@ -18,23 +18,29 @@
6382 -#include <linux/pci.h>
6383 -#include <linux/ath9k_platform.h>
6384 +#include <linux/platform_device.h>
6385 +#include <linux/ar8216_platform.h>
6387 -#include "machtypes.h"
6388 +#include <asm/mach-ath79/ar71xx_regs.h>
6390 +#include "common.h"
6391 +#include "pci.h"
6392 +#include "dev-ap9x-pci.h"
6393 #include "dev-gpio-buttons.h"
6394 +#include "dev-eth.h"
6395 #include "dev-leds-gpio.h"
6396 -#include "dev-spi.h"
6397 +#include "dev-m25p80.h"
6398 +#include "dev-nfc.h"
6399 #include "dev-usb.h"
6400 #include "dev-wmac.h"
6401 -#include "pci.h"
6402 +#include "machtypes.h"
6404 -#define AP136_GPIO_LED_STATUS_RED 14
6405 -#define AP136_GPIO_LED_STATUS_GREEN 19
6406 #define AP136_GPIO_LED_USB 4
6407 -#define AP136_GPIO_LED_WLAN_2G 13
6408 #define AP136_GPIO_LED_WLAN_5G 12
6409 +#define AP136_GPIO_LED_WLAN_2G 13
6410 +#define AP136_GPIO_LED_STATUS_RED 14
6411 #define AP136_GPIO_LED_WPS_RED 15
6412 +#define AP136_GPIO_LED_STATUS_GREEN 19
6413 #define AP136_GPIO_LED_WPS_GREEN 20
6415 #define AP136_GPIO_BTN_WPS 16
6416 @@ -43,37 +49,39 @@
6417 #define AP136_KEYS_POLL_INTERVAL 20 /* msecs */
6418 #define AP136_KEYS_DEBOUNCE_INTERVAL (3 * AP136_KEYS_POLL_INTERVAL)
6420 -#define AP136_WMAC_CALDATA_OFFSET 0x1000
6421 -#define AP136_PCIE_CALDATA_OFFSET 0x5000
6422 +#define AP136_MAC0_OFFSET 0
6423 +#define AP136_MAC1_OFFSET 6
6424 +#define AP136_WMAC_CALDATA_OFFSET 0x1000
6425 +#define AP136_PCIE_CALDATA_OFFSET 0x5000
6427 static struct gpio_led ap136_leds_gpio[] __initdata = {
6429 - .name = "qca:green:status",
6430 + .name = "ap136:green:status",
6431 .gpio = AP136_GPIO_LED_STATUS_GREEN,
6432 .active_low = 1,
6435 - .name = "qca:red:status",
6436 + .name = "ap136:red:status",
6437 .gpio = AP136_GPIO_LED_STATUS_RED,
6438 .active_low = 1,
6441 - .name = "qca:green:wps",
6442 + .name = "ap136:green:wps",
6443 .gpio = AP136_GPIO_LED_WPS_GREEN,
6444 .active_low = 1,
6447 - .name = "qca:red:wps",
6448 + .name = "ap136:red:wps",
6449 .gpio = AP136_GPIO_LED_WPS_RED,
6450 .active_low = 1,
6453 - .name = "qca:red:wlan-2g",
6454 + .name = "ap136:red:wlan-2g",
6455 .gpio = AP136_GPIO_LED_WLAN_2G,
6456 .active_low = 1,
6459 - .name = "qca:red:usb",
6460 + .name = "ap136:red:usb",
6461 .gpio = AP136_GPIO_LED_USB,
6462 .active_low = 1,
6464 @@ -98,59 +106,151 @@
6468 -static struct spi_board_info ap136_spi_info[] = {
6470 - .bus_num = 0,
6471 - .chip_select = 0,
6472 - .max_speed_hz = 25000000,
6473 - .modalias = "mx25l6405d",
6475 +static struct ar8327_pad_cfg ap136_ar8327_pad0_cfg;
6476 +static struct ar8327_pad_cfg ap136_ar8327_pad6_cfg;
6478 +static struct ar8327_platform_data ap136_ar8327_data = {
6479 + .pad0_cfg = &ap136_ar8327_pad0_cfg,
6480 + .pad6_cfg = &ap136_ar8327_pad6_cfg,
6481 + .port0_cfg = {
6482 + .force_link = 1,
6483 + .speed = AR8327_PORT_SPEED_1000,
6484 + .duplex = 1,
6485 + .txpause = 1,
6486 + .rxpause = 1,
6487 + },
6488 + .port6_cfg = {
6489 + .force_link = 1,
6490 + .speed = AR8327_PORT_SPEED_1000,
6491 + .duplex = 1,
6492 + .txpause = 1,
6493 + .rxpause = 1,
6494 + },
6497 -static struct ath79_spi_platform_data ap136_spi_data = {
6498 - .bus_num = 0,
6499 - .num_chipselect = 1,
6500 +static struct mdio_board_info ap136_mdio0_info[] = {
6502 + .bus_id = "ag71xx-mdio.0",
6503 + .phy_addr = 0,
6504 + .platform_data = &ap136_ar8327_data,
6505 + },
6508 -#ifdef CONFIG_PCI
6509 -static struct ath9k_platform_data ap136_ath9k_data;
6510 +static void __init ap136_common_setup(void)
6512 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6514 + ath79_register_m25p80(NULL);
6516 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
6517 + ap136_leds_gpio);
6518 + ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
6519 + ARRAY_SIZE(ap136_gpio_keys),
6520 + ap136_gpio_keys);
6522 + ath79_register_usb();
6523 + ath79_register_nfc();
6525 + ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET, NULL);
6527 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
6529 -static int ap136_pci_plat_dev_init(struct pci_dev *dev)
6530 + ath79_register_mdio(0, 0x0);
6531 + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP136_MAC0_OFFSET, 0);
6533 + mdiobus_register_board_info(ap136_mdio0_info,
6534 + ARRAY_SIZE(ap136_mdio0_info));
6536 + /* GMAC0 is connected to the RMGII interface */
6537 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
6538 + ath79_eth0_data.phy_mask = BIT(0);
6539 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
6541 + ath79_register_eth(0);
6543 + /* GMAC1 is connected tot eh SGMII interface */
6544 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
6545 + ath79_eth1_data.speed = SPEED_1000;
6546 + ath79_eth1_data.duplex = DUPLEX_FULL;
6548 + ath79_register_eth(1);
6551 +static void __init ap136_010_setup(void)
6553 - if (dev->bus->number == 1 && (PCI_SLOT(dev->devfn)) == 0)
6554 - dev->dev.platform_data = &ap136_ath9k_data;
6555 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6557 - return 0;
6558 + /* GMAC0 of the AR8327 switch is connected to GMAC0 via RGMII */
6559 + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
6560 + ap136_ar8327_pad0_cfg.txclk_delay_en = true;
6561 + ap136_ar8327_pad0_cfg.rxclk_delay_en = true;
6562 + ap136_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
6563 + ap136_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
6565 + /* GMAC6 of the AR8327 switch is connected to GMAC1 via SGMII */
6566 + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
6567 + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
6568 + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
6570 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
6571 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
6573 + ap136_common_setup();
6574 + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
6577 -static void __init ap136_pci_init(u8 *eeprom)
6578 +MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
6579 + "Atheros AP136-010 reference board",
6580 + ap136_010_setup);
6582 +static void __init ap136_020_common_setup(void)
6584 - memcpy(ap136_ath9k_data.eeprom_data, eeprom,
6585 - sizeof(ap136_ath9k_data.eeprom_data));
6586 + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */
6587 + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII;
6588 + ap136_ar8327_pad0_cfg.sgmii_delay_en = true;
6590 + /* GMAC6 of the AR8327 switch is connected to GMAC0 via RGMII */
6591 + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_RGMII;
6592 + ap136_ar8327_pad6_cfg.txclk_delay_en = true;
6593 + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
6594 + ap136_ar8327_pad6_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
6595 + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
6597 - ath79_pci_set_plat_dev_init(ap136_pci_plat_dev_init);
6598 - ath79_register_pci();
6599 + ath79_eth0_pll_data.pll_1000 = 0x56000000;
6600 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
6602 + ap136_common_setup();
6604 -#else
6605 -static inline void ap136_pci_init(u8 *eeprom) {}
6606 -#endif /* CONFIG_PCI */
6608 -static void __init ap136_setup(void)
6609 +static void __init ap136_020_setup(void)
6611 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6613 - ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
6614 - ap136_leds_gpio);
6615 - ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
6616 - ARRAY_SIZE(ap136_gpio_keys),
6617 - ap136_gpio_keys);
6618 - ath79_register_spi(&ap136_spi_data, ap136_spi_info,
6619 - ARRAY_SIZE(ap136_spi_info));
6620 - ath79_register_usb();
6621 - ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET);
6622 - ap136_pci_init(art + AP136_PCIE_CALDATA_OFFSET);
6623 + ap136_020_common_setup();
6624 + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
6627 -MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
6628 - "Atheros AP136-010 reference board",
6629 - ap136_setup);
6630 +MIPS_MACHINE(ATH79_MACH_AP136_020, "AP136-020",
6631 + "Atheros AP136-020 reference board",
6632 + ap136_020_setup);
6635 + * AP135-020 is similar to AP136-020, any future AP135 specific init
6636 + * code can be added here.
6637 + */
6638 +static void __init ap135_020_setup(void)
6640 + ap136_leds_gpio[0].name = "ap135:green:status";
6641 + ap136_leds_gpio[1].name = "ap135:red:status";
6642 + ap136_leds_gpio[2].name = "ap135:green:wps";
6643 + ap136_leds_gpio[3].name = "ap135:red:wps";
6644 + ap136_leds_gpio[4].name = "ap135:red:wlan-2g";
6645 + ap136_leds_gpio[5].name = "ap135:red:usb";
6647 + ap136_020_common_setup();
6648 + ath79_register_pci();
6651 +MIPS_MACHINE(ATH79_MACH_AP135_020, "AP135-020",
6652 + "Atheros AP135-020 reference board",
6653 + ap135_020_setup);
6654 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap143.c linux-4.1.43/arch/mips/ath79/mach-ap143.c
6655 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap143.c 1970-01-01 01:00:00.000000000 +0100
6656 +++ linux-4.1.43/arch/mips/ath79/mach-ap143.c 2017-08-06 20:02:15.000000000 +0200
6657 @@ -0,0 +1,142 @@
6659 + * Atheros AP143 reference board support
6661 + * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
6662 + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6664 + * Permission to use, copy, modify, and/or distribute this software for any
6665 + * purpose with or without fee is hereby granted, provided that the above
6666 + * copyright notice and this permission notice appear in all copies.
6668 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6669 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
6670 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
6671 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
6672 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
6673 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
6674 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6676 + */
6678 +#include <linux/platform_device.h>
6679 +#include <linux/ath9k_platform.h>
6680 +#include <linux/ar8216_platform.h>
6682 +#include <asm/mach-ath79/ar71xx_regs.h>
6684 +#include "common.h"
6685 +#include "dev-eth.h"
6686 +#include "dev-gpio-buttons.h"
6687 +#include "dev-leds-gpio.h"
6688 +#include "dev-m25p80.h"
6689 +#include "dev-spi.h"
6690 +#include "dev-usb.h"
6691 +#include "dev-wmac.h"
6692 +#include "machtypes.h"
6694 +#define AP143_GPIO_LED_WLAN 12
6695 +#define AP143_GPIO_LED_WPS 13
6696 +#define AP143_GPIO_LED_STATUS 13
6698 +#define AP143_GPIO_LED_WAN 4
6699 +#define AP143_GPIO_LED_LAN1 16
6700 +#define AP143_GPIO_LED_LAN2 15
6701 +#define AP143_GPIO_LED_LAN3 14
6702 +#define AP143_GPIO_LED_LAN4 11
6704 +#define AP143_GPIO_BTN_WPS 17
6706 +#define AP143_KEYS_POLL_INTERVAL 20 /* msecs */
6707 +#define AP143_KEYS_DEBOUNCE_INTERVAL (3 * AP143_KEYS_POLL_INTERVAL)
6709 +#define AP143_MAC0_OFFSET 0
6710 +#define AP143_MAC1_OFFSET 6
6711 +#define AP143_WMAC_CALDATA_OFFSET 0x1000
6713 +static struct gpio_led ap143_leds_gpio[] __initdata = {
6715 + .name = "ap143:green:status",
6716 + .gpio = AP143_GPIO_LED_STATUS,
6717 + .active_low = 1,
6718 + },
6720 + .name = "ap143:green:wlan",
6721 + .gpio = AP143_GPIO_LED_WLAN,
6722 + .active_low = 1,
6726 +static struct gpio_keys_button ap143_gpio_keys[] __initdata = {
6728 + .desc = "WPS button",
6729 + .type = EV_KEY,
6730 + .code = KEY_WPS_BUTTON,
6731 + .debounce_interval = AP143_KEYS_DEBOUNCE_INTERVAL,
6732 + .gpio = AP143_GPIO_BTN_WPS,
6733 + .active_low = 1,
6734 + },
6737 +static void __init ap143_gpio_led_setup(void)
6739 + ath79_gpio_direction_select(AP143_GPIO_LED_WAN, true);
6740 + ath79_gpio_direction_select(AP143_GPIO_LED_LAN1, true);
6741 + ath79_gpio_direction_select(AP143_GPIO_LED_LAN2, true);
6742 + ath79_gpio_direction_select(AP143_GPIO_LED_LAN3, true);
6743 + ath79_gpio_direction_select(AP143_GPIO_LED_LAN4, true);
6745 + ath79_gpio_output_select(AP143_GPIO_LED_WAN,
6746 + QCA953X_GPIO_OUT_MUX_LED_LINK5);
6747 + ath79_gpio_output_select(AP143_GPIO_LED_LAN1,
6748 + QCA953X_GPIO_OUT_MUX_LED_LINK1);
6749 + ath79_gpio_output_select(AP143_GPIO_LED_LAN2,
6750 + QCA953X_GPIO_OUT_MUX_LED_LINK2);
6751 + ath79_gpio_output_select(AP143_GPIO_LED_LAN3,
6752 + QCA953X_GPIO_OUT_MUX_LED_LINK3);
6753 + ath79_gpio_output_select(AP143_GPIO_LED_LAN4,
6754 + QCA953X_GPIO_OUT_MUX_LED_LINK4);
6756 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap143_leds_gpio),
6757 + ap143_leds_gpio);
6758 + ath79_register_gpio_keys_polled(-1, AP143_KEYS_POLL_INTERVAL,
6759 + ARRAY_SIZE(ap143_gpio_keys),
6760 + ap143_gpio_keys);
6763 +static void __init ap143_setup(void)
6765 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
6767 + ath79_register_m25p80(NULL);
6769 + ap143_gpio_led_setup();
6771 + ath79_register_usb();
6773 + ath79_wmac_set_led_pin(AP143_GPIO_LED_WLAN);
6774 + ath79_register_wmac(art + AP143_WMAC_CALDATA_OFFSET, NULL);
6776 + ath79_register_mdio(0, 0x0);
6777 + ath79_register_mdio(1, 0x0);
6779 + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP143_MAC0_OFFSET, 0);
6780 + ath79_init_mac(ath79_eth1_data.mac_addr, art + AP143_MAC1_OFFSET, 0);
6782 + /* WAN port */
6783 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
6784 + ath79_eth0_data.speed = SPEED_100;
6785 + ath79_eth0_data.duplex = DUPLEX_FULL;
6786 + ath79_eth0_data.phy_mask = BIT(4);
6787 + ath79_register_eth(0);
6789 + /* LAN ports */
6790 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
6791 + ath79_eth1_data.speed = SPEED_1000;
6792 + ath79_eth1_data.duplex = DUPLEX_FULL;
6793 + ath79_switch_data.phy_poll_mask |= BIT(4);
6794 + ath79_switch_data.phy4_mii_en = 1;
6795 + ath79_register_eth(1);
6798 +MIPS_MACHINE(ATH79_MACH_AP143, "AP143", "Qualcomm Atheros AP143 reference board",
6799 + ap143_setup);
6800 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap147.c linux-4.1.43/arch/mips/ath79/mach-ap147.c
6801 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap147.c 1970-01-01 01:00:00.000000000 +0100
6802 +++ linux-4.1.43/arch/mips/ath79/mach-ap147.c 2017-08-06 20:02:15.000000000 +0200
6803 @@ -0,0 +1,125 @@
6805 + * Atheros AP147 reference board support
6807 + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
6808 + * Copyright (C) 2015 Sven Eckelmann <sven@open-mesh.com>
6810 + * This program is free software; you can redistribute it and/or modify it
6811 + * under the terms of the GNU General Public License version 2 as published
6812 + * by the Free Software Foundation.
6813 + */
6815 +#include <linux/platform_device.h>
6816 +#include <linux/ar8216_platform.h>
6818 +#include <asm/mach-ath79/ar71xx_regs.h>
6819 +#include <asm/mach-ath79/ath79.h>
6821 +#include "common.h"
6822 +#include "dev-ap9x-pci.h"
6823 +#include "dev-eth.h"
6824 +#include "dev-gpio-buttons.h"
6825 +#include "dev-leds-gpio.h"
6826 +#include "dev-m25p80.h"
6827 +#include "dev-usb.h"
6828 +#include "dev-wmac.h"
6829 +#include "machtypes.h"
6830 +#include "pci.h"
6832 +#define AP147_GPIO_LED_WAN 4
6833 +#define AP147_GPIO_LED_LAN1 16
6834 +#define AP147_GPIO_LED_LAN2 15
6835 +#define AP147_GPIO_LED_LAN3 14
6836 +#define AP147_GPIO_LED_LAN4 11
6837 +#define AP147_GPIO_LED_STATUS 13
6838 +#define AP147_GPIO_LED_WLAN_2G 12
6840 +#define AP147_GPIO_BTN_WPS 17
6842 +#define AP147_KEYS_POLL_INTERVAL 20 /* msecs */
6843 +#define AP147_KEYS_DEBOUNCE_INTERVAL (3 * AP147_KEYS_POLL_INTERVAL)
6845 +#define AP147_MAC0_OFFSET 0x1000
6847 +static struct gpio_led ap147_leds_gpio[] __initdata = {
6849 + .name = "ap147:green:status",
6850 + .gpio = AP147_GPIO_LED_STATUS,
6851 + .active_low = 1,
6852 + }, {
6853 + .name = "ap147:green:wlan-2g",
6854 + .gpio = AP147_GPIO_LED_WLAN_2G,
6855 + .active_low = 1,
6856 + }, {
6857 + .name = "ap147:green:lan1",
6858 + .gpio = AP147_GPIO_LED_LAN1,
6859 + .active_low = 1,
6860 + }, {
6861 + .name = "ap147:green:lan2",
6862 + .gpio = AP147_GPIO_LED_LAN2,
6863 + .active_low = 1,
6864 + }, {
6865 + .name = "ap147:green:lan3",
6866 + .gpio = AP147_GPIO_LED_LAN3,
6867 + .active_low = 1,
6868 + }, {
6869 + .name = "ap147:green:lan4",
6870 + .gpio = AP147_GPIO_LED_LAN4,
6871 + .active_low = 1,
6872 + }, {
6873 + .name = "ap147:green:wan",
6874 + .gpio = AP147_GPIO_LED_WAN,
6875 + .active_low = 1,
6876 + },
6879 +static struct gpio_keys_button ap147_gpio_keys[] __initdata = {
6881 + .desc = "wps button",
6882 + .type = EV_KEY,
6883 + .code = KEY_WPS_BUTTON,
6884 + .debounce_interval = AP147_KEYS_DEBOUNCE_INTERVAL,
6885 + .gpio = AP147_GPIO_BTN_WPS,
6886 + .active_low = 1,
6890 +static void __init ap147_setup(void)
6892 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
6894 + ath79_register_m25p80(NULL);
6895 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap147_leds_gpio),
6896 + ap147_leds_gpio);
6897 + ath79_register_gpio_keys_polled(-1, AP147_KEYS_POLL_INTERVAL,
6898 + ARRAY_SIZE(ap147_gpio_keys),
6899 + ap147_gpio_keys);
6901 + ath79_register_usb();
6903 + ath79_register_pci();
6905 + ath79_register_wmac(art + AP147_MAC0_OFFSET, NULL);
6907 + ath79_setup_ar933x_phy4_switch(false, false);
6909 + ath79_register_mdio(0, 0x0);
6911 + /* LAN */
6912 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
6913 + ath79_eth1_data.duplex = DUPLEX_FULL;
6914 + ath79_switch_data.phy_poll_mask |= BIT(4);
6915 + ath79_init_mac(ath79_eth1_data.mac_addr, art, 0);
6916 + ath79_register_eth(1);
6918 + /* WAN */
6919 + ath79_switch_data.phy4_mii_en = 1;
6920 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
6921 + ath79_eth0_data.duplex = DUPLEX_FULL;
6922 + ath79_eth0_data.speed = SPEED_100;
6923 + ath79_eth0_data.phy_mask = BIT(4);
6924 + ath79_init_mac(ath79_eth0_data.mac_addr, art, 1);
6925 + ath79_register_eth(0);
6928 +MIPS_MACHINE(ATH79_MACH_AP147_010, "AP147-010", "Atheros AP147-010 reference board", ap147_setup);
6929 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap152.c linux-4.1.43/arch/mips/ath79/mach-ap152.c
6930 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap152.c 1970-01-01 01:00:00.000000000 +0100
6931 +++ linux-4.1.43/arch/mips/ath79/mach-ap152.c 2017-08-06 20:02:15.000000000 +0200
6932 @@ -0,0 +1,141 @@
6935 + * Qualcomm Atheros AP152 reference board support
6937 + * Copyright (c) 2015 Qualcomm Atheros
6938 + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6940 + * Permission to use, copy, modify, and/or distribute this software for any
6941 + * purpose with or without fee is hereby granted, provided that the above
6942 + * copyright notice and this permission notice appear in all copies.
6944 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6945 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
6946 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
6947 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
6948 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
6949 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
6950 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6952 + */
6954 +#include <linux/platform_device.h>
6955 +#include <linux/ath9k_platform.h>
6956 +#include <linux/ar8216_platform.h>
6957 +#include <asm/mach-ath79/ar71xx_regs.h>
6959 +#include "common.h"
6960 +#include "dev-m25p80.h"
6961 +#include "machtypes.h"
6962 +#include "pci.h"
6963 +#include "dev-eth.h"
6964 +#include "dev-gpio-buttons.h"
6965 +#include "dev-leds-gpio.h"
6966 +#include "dev-spi.h"
6967 +#include "dev-usb.h"
6968 +#include "dev-wmac.h"
6970 +#define AP152_GPIO_LED_USB0 7
6971 +#define AP152_GPIO_LED_USB1 8
6973 +#define AP152_GPIO_BTN_RESET 2
6974 +#define AP152_GPIO_BTN_WPS 1
6975 +#define AP152_KEYS_POLL_INTERVAL 20 /* msecs */
6976 +#define AP152_KEYS_DEBOUNCE_INTERVAL (3 * AP152_KEYS_POLL_INTERVAL)
6978 +#define AP152_MAC0_OFFSET 0
6979 +#define AP152_WMAC_CALDATA_OFFSET 0x1000
6981 +static struct gpio_led ap152_leds_gpio[] __initdata = {
6983 + .name = "ap152:green:usb0",
6984 + .gpio = AP152_GPIO_LED_USB0,
6985 + .active_low = 1,
6986 + },
6988 + .name = "ap152:green:usb1",
6989 + .gpio = AP152_GPIO_LED_USB1,
6990 + .active_low = 1,
6991 + },
6994 +static struct gpio_keys_button ap152_gpio_keys[] __initdata = {
6996 + .desc = "WPS button",
6997 + .type = EV_KEY,
6998 + .code = KEY_WPS_BUTTON,
6999 + .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
7000 + .gpio = AP152_GPIO_BTN_WPS,
7001 + .active_low = 1,
7002 + },
7004 + .desc = "Reset button",
7005 + .type = EV_KEY,
7006 + .code = KEY_RESTART,
7007 + .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
7008 + .gpio = AP152_GPIO_BTN_RESET,
7009 + .active_low = 1,
7010 + },
7013 +static struct ar8327_pad_cfg ap152_ar8337_pad0_cfg = {
7014 + .mode = AR8327_PAD_MAC_SGMII,
7015 + .sgmii_delay_en = true,
7018 +static struct ar8327_platform_data ap152_ar8337_data = {
7019 + .pad0_cfg = &ap152_ar8337_pad0_cfg,
7020 + .port0_cfg = {
7021 + .force_link = 1,
7022 + .speed = AR8327_PORT_SPEED_1000,
7023 + .duplex = 1,
7024 + .txpause = 1,
7025 + .rxpause = 1,
7026 + },
7029 +static struct mdio_board_info ap152_mdio0_info[] = {
7031 + .bus_id = "ag71xx-mdio.0",
7032 + .phy_addr = 0,
7033 + .platform_data = &ap152_ar8337_data,
7034 + },
7037 +static void __init ap152_setup(void)
7039 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
7041 + ath79_register_m25p80(NULL);
7043 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap152_leds_gpio),
7044 + ap152_leds_gpio);
7045 + ath79_register_gpio_keys_polled(-1, AP152_KEYS_POLL_INTERVAL,
7046 + ARRAY_SIZE(ap152_gpio_keys),
7047 + ap152_gpio_keys);
7049 + ath79_register_usb();
7051 + platform_device_register(&ath79_mdio0_device);
7053 + mdiobus_register_board_info(ap152_mdio0_info,
7054 + ARRAY_SIZE(ap152_mdio0_info));
7056 + ath79_register_wmac(art + AP152_WMAC_CALDATA_OFFSET, NULL);
7057 + ath79_register_pci();
7059 + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP152_MAC0_OFFSET, 0);
7061 + /* GMAC0 is connected to an AR8337 switch */
7062 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
7063 + ath79_eth0_data.speed = SPEED_1000;
7064 + ath79_eth0_data.duplex = DUPLEX_FULL;
7065 + ath79_eth0_data.phy_mask = BIT(0);
7066 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
7067 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
7069 + ath79_register_eth(0);
7072 +MIPS_MACHINE(ATH79_MACH_AP152, "AP152", "Qualcomm Atheros AP152 reference board",
7073 + ap152_setup);
7074 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap81.c linux-4.1.43/arch/mips/ath79/mach-ap81.c
7075 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap81.c 2017-08-06 01:56:14.000000000 +0200
7076 +++ linux-4.1.43/arch/mips/ath79/mach-ap81.c 2017-08-06 20:02:15.000000000 +0200
7077 @@ -9,12 +9,16 @@
7078 * by the Free Software Foundation.
7081 -#include "machtypes.h"
7082 -#include "dev-wmac.h"
7083 +#include <linux/mtd/mtd.h>
7084 +#include <linux/mtd/partitions.h>
7086 +#include "dev-eth.h"
7087 #include "dev-gpio-buttons.h"
7088 #include "dev-leds-gpio.h"
7089 -#include "dev-spi.h"
7090 +#include "dev-m25p80.h"
7091 #include "dev-usb.h"
7092 +#include "dev-wmac.h"
7093 +#include "machtypes.h"
7095 #define AP81_GPIO_LED_STATUS 1
7096 #define AP81_GPIO_LED_AOSS 3
7097 @@ -67,20 +71,6 @@
7101 -static struct spi_board_info ap81_spi_info[] = {
7103 - .bus_num = 0,
7104 - .chip_select = 0,
7105 - .max_speed_hz = 25000000,
7106 - .modalias = "m25p64",
7110 -static struct ath79_spi_platform_data ap81_spi_data = {
7111 - .bus_num = 0,
7112 - .num_chipselect = 1,
7115 static void __init ap81_setup(void)
7117 u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
7118 @@ -90,10 +80,24 @@
7119 ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL,
7120 ARRAY_SIZE(ap81_gpio_keys),
7121 ap81_gpio_keys);
7122 - ath79_register_spi(&ap81_spi_data, ap81_spi_info,
7123 - ARRAY_SIZE(ap81_spi_info));
7124 - ath79_register_wmac(cal_data);
7125 + ath79_register_m25p80(NULL);
7126 + ath79_register_wmac(cal_data, NULL);
7127 ath79_register_usb();
7129 + ath79_register_mdio(0, 0x0);
7131 + ath79_init_mac(ath79_eth0_data.mac_addr, cal_data, 0);
7132 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
7133 + ath79_eth0_data.speed = SPEED_100;
7134 + ath79_eth0_data.duplex = DUPLEX_FULL;
7135 + ath79_eth0_data.has_ar8216 = 1;
7137 + ath79_init_mac(ath79_eth1_data.mac_addr, cal_data, 1);
7138 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
7139 + ath79_eth1_data.phy_mask = 0x10;
7141 + ath79_register_eth(0);
7142 + ath79_register_eth(1);
7145 MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
7146 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap83.c linux-4.1.43/arch/mips/ath79/mach-ap83.c
7147 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap83.c 1970-01-01 01:00:00.000000000 +0100
7148 +++ linux-4.1.43/arch/mips/ath79/mach-ap83.c 2017-08-06 20:02:15.000000000 +0200
7149 @@ -0,0 +1,242 @@
7151 + * Atheros AP83 board support
7153 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
7154 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7156 + * This program is free software; you can redistribute it and/or modify it
7157 + * under the terms of the GNU General Public License version 2 as published
7158 + * by the Free Software Foundation.
7159 + */
7161 +#include <linux/delay.h>
7162 +#include <linux/platform_device.h>
7163 +#include <linux/mtd/mtd.h>
7164 +#include <linux/mtd/partitions.h>
7165 +#include <linux/mtd/physmap.h>
7166 +#include <linux/spi/spi.h>
7167 +#include <linux/spi/spi_gpio.h>
7168 +#include <linux/spi/vsc7385.h>
7170 +#include <asm/mach-ath79/ar71xx_regs.h>
7171 +#include <asm/mach-ath79/ath79.h>
7173 +#include "dev-eth.h"
7174 +#include "dev-gpio-buttons.h"
7175 +#include "dev-leds-gpio.h"
7176 +#include "dev-usb.h"
7177 +#include "dev-wmac.h"
7178 +#include "machtypes.h"
7180 +#define AP83_GPIO_LED_WLAN 6
7181 +#define AP83_GPIO_LED_POWER 14
7182 +#define AP83_GPIO_LED_JUMPSTART 15
7183 +#define AP83_GPIO_BTN_JUMPSTART 12
7184 +#define AP83_GPIO_BTN_RESET 21
7186 +#define AP83_050_GPIO_VSC7385_CS 1
7187 +#define AP83_050_GPIO_VSC7385_MISO 3
7188 +#define AP83_050_GPIO_VSC7385_MOSI 16
7189 +#define AP83_050_GPIO_VSC7385_SCK 17
7191 +#define AP83_KEYS_POLL_INTERVAL 20 /* msecs */
7192 +#define AP83_KEYS_DEBOUNCE_INTERVAL (3 * AP83_KEYS_POLL_INTERVAL)
7194 +static struct physmap_flash_data ap83_flash_data = {
7195 + .width = 2,
7198 +static struct resource ap83_flash_resources[] = {
7199 + [0] = {
7200 + .start = AR71XX_SPI_BASE,
7201 + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
7202 + .flags = IORESOURCE_MEM,
7203 + },
7206 +static struct platform_device ap83_flash_device = {
7207 + .name = "ar91xx-flash",
7208 + .id = -1,
7209 + .resource = ap83_flash_resources,
7210 + .num_resources = ARRAY_SIZE(ap83_flash_resources),
7211 + .dev = {
7212 + .platform_data = &ap83_flash_data,
7216 +static struct gpio_led ap83_leds_gpio[] __initdata = {
7218 + .name = "ap83:green:jumpstart",
7219 + .gpio = AP83_GPIO_LED_JUMPSTART,
7220 + .active_low = 0,
7221 + }, {
7222 + .name = "ap83:green:power",
7223 + .gpio = AP83_GPIO_LED_POWER,
7224 + .active_low = 0,
7225 + }, {
7226 + .name = "ap83:green:wlan",
7227 + .gpio = AP83_GPIO_LED_WLAN,
7228 + .active_low = 0,
7229 + },
7232 +static struct gpio_keys_button ap83_gpio_keys[] __initdata = {
7234 + .desc = "soft_reset",
7235 + .type = EV_KEY,
7236 + .code = KEY_RESTART,
7237 + .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
7238 + .gpio = AP83_GPIO_BTN_RESET,
7239 + .active_low = 1,
7240 + }, {
7241 + .desc = "jumpstart",
7242 + .type = EV_KEY,
7243 + .code = KEY_WPS_BUTTON,
7244 + .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
7245 + .gpio = AP83_GPIO_BTN_JUMPSTART,
7246 + .active_low = 1,
7250 +static struct resource ap83_040_spi_resources[] = {
7251 + [0] = {
7252 + .start = AR71XX_SPI_BASE,
7253 + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
7254 + .flags = IORESOURCE_MEM,
7255 + },
7258 +static struct platform_device ap83_040_spi_device = {
7259 + .name = "ap83-spi",
7260 + .id = 0,
7261 + .resource = ap83_040_spi_resources,
7262 + .num_resources = ARRAY_SIZE(ap83_040_spi_resources),
7265 +static struct spi_gpio_platform_data ap83_050_spi_data = {
7266 + .miso = AP83_050_GPIO_VSC7385_MISO,
7267 + .mosi = AP83_050_GPIO_VSC7385_MOSI,
7268 + .sck = AP83_050_GPIO_VSC7385_SCK,
7269 + .num_chipselect = 1,
7272 +static struct platform_device ap83_050_spi_device = {
7273 + .name = "spi_gpio",
7274 + .id = 0,
7275 + .dev = {
7276 + .platform_data = &ap83_050_spi_data,
7280 +static void ap83_vsc7385_reset(void)
7282 + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
7283 + udelay(10);
7284 + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
7285 + mdelay(50);
7288 +static struct vsc7385_platform_data ap83_vsc7385_data = {
7289 + .reset = ap83_vsc7385_reset,
7290 + .ucode_name = "vsc7385_ucode_ap83.bin",
7291 + .mac_cfg = {
7292 + .tx_ipg = 6,
7293 + .bit2 = 0,
7294 + .clk_sel = 3,
7295 + },
7298 +static struct spi_board_info ap83_spi_info[] = {
7300 + .bus_num = 0,
7301 + .chip_select = 0,
7302 + .max_speed_hz = 25000000,
7303 + .modalias = "spi-vsc7385",
7304 + .platform_data = &ap83_vsc7385_data,
7305 + .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
7309 +static void __init ap83_generic_setup(void)
7311 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
7313 + ath79_register_mdio(0, 0xfffffffe);
7315 + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
7316 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
7317 + ath79_eth0_data.phy_mask = 0x1;
7319 + ath79_register_eth(0);
7321 + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
7322 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
7323 + ath79_eth1_data.speed = SPEED_1000;
7324 + ath79_eth1_data.duplex = DUPLEX_FULL;
7326 + ath79_eth1_pll_data.pll_1000 = 0x1f000000;
7328 + ath79_register_eth(1);
7330 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
7331 + ap83_leds_gpio);
7333 + ath79_register_gpio_keys_polled(-1, AP83_KEYS_POLL_INTERVAL,
7334 + ARRAY_SIZE(ap83_gpio_keys),
7335 + ap83_gpio_keys);
7337 + ath79_register_usb();
7339 + ath79_register_wmac(eeprom, NULL);
7341 + platform_device_register(&ap83_flash_device);
7343 + spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
7346 +static void ap83_040_flash_lock(struct platform_device *pdev)
7348 + ath79_flash_acquire();
7351 +static void ap83_040_flash_unlock(struct platform_device *pdev)
7353 + ath79_flash_release();
7356 +static void __init ap83_040_setup(void)
7358 + ap83_flash_data.lock = ap83_040_flash_lock;
7359 + ap83_flash_data.unlock = ap83_040_flash_unlock;
7360 + ap83_generic_setup();
7361 + platform_device_register(&ap83_040_spi_device);
7364 +static void __init ap83_050_setup(void)
7366 + ap83_generic_setup();
7367 + platform_device_register(&ap83_050_spi_device);
7370 +static void __init ap83_setup(void)
7372 + u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
7373 + unsigned int board_version;
7375 + board_version = (unsigned int)(board_id[0] - '0');
7376 + board_version += ((unsigned int)(board_id[1] - '0')) * 10;
7378 + switch (board_version) {
7379 + case 40:
7380 + ap83_040_setup();
7381 + break;
7382 + case 50:
7383 + ap83_050_setup();
7384 + break;
7385 + default:
7386 + printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
7387 + board_version);
7391 +MIPS_MACHINE(ATH79_MACH_AP83, "AP83", "Atheros AP83", ap83_setup);
7392 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ap96.c linux-4.1.43/arch/mips/ath79/mach-ap96.c
7393 --- linux-4.1.43.orig/arch/mips/ath79/mach-ap96.c 1970-01-01 01:00:00.000000000 +0100
7394 +++ linux-4.1.43/arch/mips/ath79/mach-ap96.c 2017-08-06 20:02:15.000000000 +0200
7395 @@ -0,0 +1,142 @@
7397 + * Atheros AP96 board support
7399 + * Copyright (C) 2009 Marco Porsch
7400 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
7401 + * Copyright (C) 2010 Atheros Communications
7403 + * This program is free software; you can redistribute it and/or modify it
7404 + * under the terms of the GNU General Public License version 2 as published
7405 + * by the Free Software Foundation.
7406 + */
7408 +#include <linux/platform_device.h>
7409 +#include <linux/delay.h>
7411 +#include <asm/mach-ath79/ath79.h>
7413 +#include "dev-ap9x-pci.h"
7414 +#include "dev-eth.h"
7415 +#include "dev-gpio-buttons.h"
7416 +#include "dev-leds-gpio.h"
7417 +#include "dev-m25p80.h"
7418 +#include "dev-usb.h"
7419 +#include "machtypes.h"
7421 +#define AP96_GPIO_LED_12_GREEN 0
7422 +#define AP96_GPIO_LED_3_GREEN 1
7423 +#define AP96_GPIO_LED_2_GREEN 2
7424 +#define AP96_GPIO_LED_WPS_GREEN 4
7425 +#define AP96_GPIO_LED_5_GREEN 5
7426 +#define AP96_GPIO_LED_4_ORANGE 6
7428 +/* Reset button - next to the power connector */
7429 +#define AP96_GPIO_BTN_RESET 3
7430 +/* WPS button - next to a led on right */
7431 +#define AP96_GPIO_BTN_WPS 8
7433 +#define AP96_KEYS_POLL_INTERVAL 20 /* msecs */
7434 +#define AP96_KEYS_DEBOUNCE_INTERVAL (3 * AP96_KEYS_POLL_INTERVAL)
7436 +#define AP96_WMAC0_MAC_OFFSET 0x120c
7437 +#define AP96_WMAC1_MAC_OFFSET 0x520c
7438 +#define AP96_CALDATA0_OFFSET 0x1000
7439 +#define AP96_CALDATA1_OFFSET 0x5000
7442 + * AP96 has 12 unlabeled leds in the front; these are numbered from 1 to 12
7443 + * below (from left to right on the board). Led 1 seems to be on whenever the
7444 + * board is powered. Led 11 shows LAN link activity actity. Led 3 is orange;
7445 + * others are green.
7447 + * In addition, there is one led next to a button on the right side for WPS.
7448 + */
7449 +static struct gpio_led ap96_leds_gpio[] __initdata = {
7451 + .name = "ap96:green:led2",
7452 + .gpio = AP96_GPIO_LED_2_GREEN,
7453 + .active_low = 1,
7454 + }, {
7455 + .name = "ap96:green:led3",
7456 + .gpio = AP96_GPIO_LED_3_GREEN,
7457 + .active_low = 1,
7458 + }, {
7459 + .name = "ap96:orange:led4",
7460 + .gpio = AP96_GPIO_LED_4_ORANGE,
7461 + .active_low = 1,
7462 + }, {
7463 + .name = "ap96:green:led5",
7464 + .gpio = AP96_GPIO_LED_5_GREEN,
7465 + .active_low = 1,
7466 + }, {
7467 + .name = "ap96:green:led12",
7468 + .gpio = AP96_GPIO_LED_12_GREEN,
7469 + .active_low = 1,
7470 + }, { /* next to a button on right */
7471 + .name = "ap96:green:wps",
7472 + .gpio = AP96_GPIO_LED_WPS_GREEN,
7473 + .active_low = 1,
7477 +static struct gpio_keys_button ap96_gpio_keys[] __initdata = {
7479 + .desc = "reset",
7480 + .type = EV_KEY,
7481 + .code = KEY_RESTART,
7482 + .debounce_interval = AP96_KEYS_DEBOUNCE_INTERVAL,
7483 + .gpio = AP96_GPIO_BTN_RESET,
7484 + .active_low = 1,
7485 + }, {
7486 + .desc = "wps",
7487 + .type = EV_KEY,
7488 + .code = KEY_WPS_BUTTON,
7489 + .debounce_interval = AP96_KEYS_DEBOUNCE_INTERVAL,
7490 + .gpio = AP96_GPIO_BTN_WPS,
7491 + .active_low = 1,
7495 +#define AP96_WAN_PHYMASK 0x10
7496 +#define AP96_LAN_PHYMASK 0x0f
7498 +static void __init ap96_setup(void)
7500 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
7502 + ath79_register_mdio(0, ~(AP96_WAN_PHYMASK | AP96_LAN_PHYMASK));
7504 + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
7505 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
7506 + ath79_eth0_data.phy_mask = AP96_LAN_PHYMASK;
7507 + ath79_eth0_data.speed = SPEED_1000;
7508 + ath79_eth0_data.duplex = DUPLEX_FULL;
7510 + ath79_register_eth(0);
7512 + ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
7513 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
7514 + ath79_eth1_data.phy_mask = AP96_WAN_PHYMASK;
7516 + ath79_eth1_pll_data.pll_1000 = 0x1f000000;
7518 + ath79_register_eth(1);
7520 + ath79_register_usb();
7522 + ath79_register_m25p80(NULL);
7524 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap96_leds_gpio),
7525 + ap96_leds_gpio);
7527 + ath79_register_gpio_keys_polled(-1, AP96_KEYS_POLL_INTERVAL,
7528 + ARRAY_SIZE(ap96_gpio_keys),
7529 + ap96_gpio_keys);
7531 + ap94_pci_init(art + AP96_CALDATA0_OFFSET,
7532 + art + AP96_WMAC0_MAC_OFFSET,
7533 + art + AP96_CALDATA1_OFFSET,
7534 + art + AP96_WMAC1_MAC_OFFSET);
7537 +MIPS_MACHINE(ATH79_MACH_AP96, "AP96", "Atheros AP96", ap96_setup);
7538 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-archer-c7.c linux-4.1.43/arch/mips/ath79/mach-archer-c7.c
7539 --- linux-4.1.43.orig/arch/mips/ath79/mach-archer-c7.c 1970-01-01 01:00:00.000000000 +0100
7540 +++ linux-4.1.43/arch/mips/ath79/mach-archer-c7.c 2017-08-06 20:02:15.000000000 +0200
7541 @@ -0,0 +1,266 @@
7543 + * TP-LINK Archer C5/C7/TL-WDR4900 v2 board support
7545 + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
7546 + * Copyright (c) 2014 施康成 <tenninjas@tenninjas.ca>
7547 + * Copyright (c) 2014 Imre Kaloz <kaloz@openwrt.org>
7549 + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
7550 + * Copyright (c) 2012 Qualcomm Atheros
7552 + * Permission to use, copy, modify, and/or distribute this software for any
7553 + * purpose with or without fee is hereby granted, provided that the above
7554 + * copyright notice and this permission notice appear in all copies.
7556 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7557 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
7558 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
7559 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
7560 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
7561 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
7562 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7564 + */
7566 +#include <linux/pci.h>
7567 +#include <linux/phy.h>
7568 +#include <linux/gpio.h>
7569 +#include <linux/platform_device.h>
7570 +#include <linux/ath9k_platform.h>
7571 +#include <linux/ar8216_platform.h>
7573 +#include <asm/mach-ath79/ar71xx_regs.h>
7575 +#include "common.h"
7576 +#include "dev-ap9x-pci.h"
7577 +#include "dev-eth.h"
7578 +#include "dev-gpio-buttons.h"
7579 +#include "dev-leds-gpio.h"
7580 +#include "dev-m25p80.h"
7581 +#include "dev-spi.h"
7582 +#include "dev-usb.h"
7583 +#include "dev-wmac.h"
7584 +#include "machtypes.h"
7585 +#include "pci.h"
7587 +#define ARCHER_C7_GPIO_LED_WLAN2G 12
7588 +#define ARCHER_C7_GPIO_LED_SYSTEM 14
7589 +#define ARCHER_C7_GPIO_LED_QSS 15
7590 +#define ARCHER_C7_GPIO_LED_WLAN5G 17
7591 +#define ARCHER_C7_GPIO_LED_USB1 18
7592 +#define ARCHER_C7_GPIO_LED_USB2 19
7594 +#define ARCHER_C7_GPIO_BTN_RFKILL 13
7595 +#define ARCHER_C7_GPIO_BTN_RESET 16
7597 +#define ARCHER_C7_GPIO_USB1_POWER 22
7598 +#define ARCHER_C7_GPIO_USB2_POWER 21
7600 +#define ARCHER_C7_KEYS_POLL_INTERVAL 20 /* msecs */
7601 +#define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL)
7603 +#define ARCHER_C7_WMAC_CALDATA_OFFSET 0x1000
7604 +#define ARCHER_C7_PCIE_CALDATA_OFFSET 0x5000
7606 +static const char *archer_c7_part_probes[] = {
7607 + "tp-link",
7608 + NULL,
7611 +static struct flash_platform_data archer_c7_flash_data = {
7612 + .part_probes = archer_c7_part_probes,
7615 +static struct gpio_led archer_c7_leds_gpio[] __initdata = {
7617 + .name = "tp-link:blue:qss",
7618 + .gpio = ARCHER_C7_GPIO_LED_QSS,
7619 + .active_low = 1,
7620 + },
7622 + .name = "tp-link:blue:system",
7623 + .gpio = ARCHER_C7_GPIO_LED_SYSTEM,
7624 + .active_low = 1,
7625 + },
7627 + .name = "tp-link:blue:wlan2g",
7628 + .gpio = ARCHER_C7_GPIO_LED_WLAN2G,
7629 + .active_low = 1,
7630 + },
7632 + .name = "tp-link:blue:wlan5g",
7633 + .gpio = ARCHER_C7_GPIO_LED_WLAN5G,
7634 + .active_low = 1,
7635 + },
7637 + .name = "tp-link:green:usb1",
7638 + .gpio = ARCHER_C7_GPIO_LED_USB1,
7639 + .active_low = 1,
7640 + },
7642 + .name = "tp-link:green:usb2",
7643 + .gpio = ARCHER_C7_GPIO_LED_USB2,
7644 + .active_low = 1,
7645 + },
7648 +static struct gpio_keys_button archer_c7_gpio_keys[] __initdata = {
7650 + .desc = "Reset button",
7651 + .type = EV_KEY,
7652 + .code = KEY_WPS_BUTTON,
7653 + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
7654 + .gpio = ARCHER_C7_GPIO_BTN_RESET,
7655 + .active_low = 1,
7656 + },
7658 + .desc = "RFKILL switch",
7659 + .type = EV_SW,
7660 + .code = KEY_RFKILL,
7661 + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
7662 + .gpio = ARCHER_C7_GPIO_BTN_RFKILL,
7663 + },
7666 +static const struct ar8327_led_info archer_c7_leds_ar8327[] __initconst = {
7667 + AR8327_LED_INFO(PHY0_0, HW, "tp-link:blue:wan"),
7668 + AR8327_LED_INFO(PHY1_0, HW, "tp-link:blue:lan1"),
7669 + AR8327_LED_INFO(PHY2_0, HW, "tp-link:blue:lan2"),
7670 + AR8327_LED_INFO(PHY3_0, HW, "tp-link:blue:lan3"),
7671 + AR8327_LED_INFO(PHY4_0, HW, "tp-link:blue:lan4"),
7674 +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
7675 +static struct ar8327_pad_cfg archer_c7_ar8327_pad0_cfg = {
7676 + .mode = AR8327_PAD_MAC_SGMII,
7677 + .sgmii_delay_en = true,
7680 +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
7681 +static struct ar8327_pad_cfg archer_c7_ar8327_pad6_cfg = {
7682 + .mode = AR8327_PAD_MAC_RGMII,
7683 + .txclk_delay_en = true,
7684 + .rxclk_delay_en = true,
7685 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
7686 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
7689 +static struct ar8327_led_cfg archer_c7_ar8327_led_cfg = {
7690 + .led_ctrl0 = 0xc737c737,
7691 + .led_ctrl1 = 0x00000000,
7692 + .led_ctrl2 = 0x00000000,
7693 + .led_ctrl3 = 0x0030c300,
7694 + .open_drain = false,
7697 +static struct ar8327_platform_data archer_c7_ar8327_data = {
7698 + .pad0_cfg = &archer_c7_ar8327_pad0_cfg,
7699 + .pad6_cfg = &archer_c7_ar8327_pad6_cfg,
7700 + .port0_cfg = {
7701 + .force_link = 1,
7702 + .speed = AR8327_PORT_SPEED_1000,
7703 + .duplex = 1,
7704 + .txpause = 1,
7705 + .rxpause = 1,
7706 + },
7707 + .port6_cfg = {
7708 + .force_link = 1,
7709 + .speed = AR8327_PORT_SPEED_1000,
7710 + .duplex = 1,
7711 + .txpause = 1,
7712 + .rxpause = 1,
7713 + },
7714 + .led_cfg = &archer_c7_ar8327_led_cfg,
7715 + .num_leds = ARRAY_SIZE(archer_c7_leds_ar8327),
7716 + .leds = archer_c7_leds_ar8327,
7719 +static struct mdio_board_info archer_c7_mdio0_info[] = {
7721 + .bus_id = "ag71xx-mdio.0",
7722 + .phy_addr = 0,
7723 + .platform_data = &archer_c7_ar8327_data,
7724 + },
7727 +static void __init common_setup(bool pcie_slot)
7729 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
7730 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
7731 + u8 tmpmac[ETH_ALEN];
7733 + ath79_register_m25p80(&archer_c7_flash_data);
7734 + ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_leds_gpio),
7735 + archer_c7_leds_gpio);
7736 + ath79_register_gpio_keys_polled(-1, ARCHER_C7_KEYS_POLL_INTERVAL,
7737 + ARRAY_SIZE(archer_c7_gpio_keys),
7738 + archer_c7_gpio_keys);
7740 + ath79_init_mac(tmpmac, mac, -1);
7741 + ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, tmpmac);
7743 + if (pcie_slot) {
7744 + ath79_register_pci();
7745 + } else {
7746 + ath79_init_mac(tmpmac, mac, -1);
7747 + ap9x_pci_setup_wmac_led_pin(0, 0);
7748 + ap91_pci_init(art + ARCHER_C7_PCIE_CALDATA_OFFSET, tmpmac);
7751 + mdiobus_register_board_info(archer_c7_mdio0_info,
7752 + ARRAY_SIZE(archer_c7_mdio0_info));
7753 + ath79_register_mdio(0, 0x0);
7755 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
7757 + /* GMAC0 is connected to the RMGII interface */
7758 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
7759 + ath79_eth0_data.phy_mask = BIT(0);
7760 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
7761 + ath79_eth0_pll_data.pll_1000 = 0x56000000;
7763 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
7764 + ath79_register_eth(0);
7766 + /* GMAC1 is connected to the SGMII interface */
7767 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
7768 + ath79_eth1_data.speed = SPEED_1000;
7769 + ath79_eth1_data.duplex = DUPLEX_FULL;
7770 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
7772 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
7773 + ath79_register_eth(1);
7775 + gpio_request_one(ARCHER_C7_GPIO_USB1_POWER,
7776 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
7777 + "USB1 power");
7778 + gpio_request_one(ARCHER_C7_GPIO_USB2_POWER,
7779 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
7780 + "USB2 power");
7781 + ath79_register_usb();
7784 +static void __init archer_c5_setup(void)
7786 + common_setup(true);
7789 +MIPS_MACHINE(ATH79_MACH_ARCHER_C5, "ARCHER-C5", "TP-LINK Archer C5",
7790 + archer_c5_setup);
7792 +static void __init archer_c7_setup(void)
7794 + common_setup(true);
7797 +MIPS_MACHINE(ATH79_MACH_ARCHER_C7, "ARCHER-C7", "TP-LINK Archer C7",
7798 + archer_c7_setup);
7800 +static void __init tl_wdr4900_v2_setup(void)
7802 + common_setup(false);
7805 +MIPS_MACHINE(ATH79_MACH_TL_WDR4900_V2, "TL-WDR4900-v2", "TP-LINK TL-WDR4900 v2",
7806 + tl_wdr4900_v2_setup)
7808 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-arduino-yun.c linux-4.1.43/arch/mips/ath79/mach-arduino-yun.c
7809 --- linux-4.1.43.orig/arch/mips/ath79/mach-arduino-yun.c 1970-01-01 01:00:00.000000000 +0100
7810 +++ linux-4.1.43/arch/mips/ath79/mach-arduino-yun.c 2017-08-06 20:02:15.000000000 +0200
7811 @@ -0,0 +1,137 @@
7813 + * Arduino Yun support
7815 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
7816 + * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
7818 + * This program is free software; you can redistribute it and/or modify it
7819 + * under the terms of the GNU General Public License version 2 as published
7820 + * by the Free Software Foundation.
7821 + */
7823 +#include "dev-eth.h"
7824 +#include "dev-gpio-buttons.h"
7825 +#include "dev-leds-gpio.h"
7826 +#include "dev-m25p80.h"
7827 +#include "dev-spi.h"
7828 +#include "dev-usb.h"
7829 +#include "dev-wmac.h"
7830 +#include "machtypes.h"
7831 +#include <asm/mach-ath79/ar71xx_regs.h>
7832 +#include <asm/mach-ath79/ath79.h>
7833 +#include "common.h"
7834 +#include "gpio.h"
7835 +#include "linux/gpio.h"
7837 +// Uncomment to have reset on gpio18 instead of gipo7
7838 +#define DS2_B
7840 +#define DS_GPIO_LED_WLAN 0
7841 +#define DS_GPIO_LED_USB 1
7843 +#define DS_GPIO_OE 21
7844 +#define DS_GPIO_AVR_RESET 18
7846 +// Maintained to have the console in the previous version of DS2 working
7847 +#define DS_GPIO_AVR_RESET_DS2 7
7849 +#define DS_GPIO_OE2 22
7850 +#define DS_GPIO_UART_ENA 23
7851 +#define DS_GPIO_CONF_BTN 20
7853 +#define DS_KEYS_POLL_INTERVAL 20 /* msecs */
7854 +#define DS_KEYS_DEBOUNCE_INTERVAL (3 * DS_KEYS_POLL_INTERVAL)
7856 +#define DS_MAC0_OFFSET 0x0000
7857 +#define DS_MAC1_OFFSET 0x0006
7858 +#define DS_CALDATA_OFFSET 0x1000
7859 +#define DS_WMAC_MAC_OFFSET 0x1002
7862 +static struct gpio_led ds_leds_gpio[] __initdata = {
7864 + .name = "arduino:white:usb",
7865 + .gpio = DS_GPIO_LED_USB,
7866 + .active_low = 0,
7867 + },
7869 + .name = "arduino:blue:wlan",
7870 + .gpio = DS_GPIO_LED_WLAN,
7871 + .active_low = 0,
7872 + },
7875 +static void __init ds_common_setup(void)
7877 + static u8 mac[6];
7879 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
7880 + ath79_register_m25p80(NULL);
7882 + if (ar93xx_wmac_read_mac_address(mac)) {
7883 + ath79_register_wmac(NULL, NULL);
7884 + } else {
7885 + ath79_register_wmac(art + DS_CALDATA_OFFSET,
7886 + art + DS_WMAC_MAC_OFFSET);
7887 + memcpy(mac, art + DS_WMAC_MAC_OFFSET, sizeof(mac));
7890 + mac[3] |= 0x08;
7891 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
7893 + mac[3] &= 0xF7;
7894 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
7895 + ath79_register_mdio(0, 0x0);
7897 + /* LAN ports */
7898 + ath79_register_eth(1);
7900 + /* WAN port */
7901 + ath79_register_eth(0);
7904 +static void __init ds_setup(void)
7906 + u32 t;
7908 + ds_common_setup();
7910 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio),
7911 + ds_leds_gpio);
7912 + ath79_register_usb();
7914 + //Disable the Function for some pins to have GPIO functionality active
7915 + // GPIO6-7-8 and GPIO11
7916 + ath79_gpio_function_setup(AR933X_GPIO_FUNC_JTAG_DISABLE | AR933X_GPIO_FUNC_I2S_MCK_EN, 0);
7918 + ath79_gpio_function2_setup(AR933X_GPIO_FUNC2_JUMPSTART_DISABLE, 0);
7920 + printk("Setting DogStick2 GPIO\n");
7922 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
7923 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
7924 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
7926 + // Put the avr reset to high
7927 + if (gpio_request_one(DS_GPIO_AVR_RESET_DS2,
7928 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
7929 + printk("Error setting GPIO OE\n");
7930 + gpio_unexport(DS_GPIO_AVR_RESET_DS2);
7931 + gpio_free(DS_GPIO_AVR_RESET_DS2);
7933 + // enable OE of level shifter
7934 + if (gpio_request_one(DS_GPIO_OE,
7935 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
7936 + printk("Error setting GPIO OE\n");
7938 + if (gpio_request_one(DS_GPIO_UART_ENA,
7939 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "UART-ENA") != 0)
7940 + printk("Error setting GPIO Uart Enable\n");
7942 + // enable OE of level shifter
7943 + if (gpio_request_one(DS_GPIO_OE2,
7944 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-2") != 0)
7945 + printk("Error setting GPIO OE2\n");
7948 +MIPS_MACHINE(ATH79_MACH_ARDUINO_YUN, "Yun", "Arduino Yun", ds_setup);
7949 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-aw-nr580.c linux-4.1.43/arch/mips/ath79/mach-aw-nr580.c
7950 --- linux-4.1.43.orig/arch/mips/ath79/mach-aw-nr580.c 1970-01-01 01:00:00.000000000 +0100
7951 +++ linux-4.1.43/arch/mips/ath79/mach-aw-nr580.c 2017-08-06 20:02:15.000000000 +0200
7952 @@ -0,0 +1,107 @@
7954 + * AzureWave AW-NR580 board support
7956 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
7957 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7959 + * This program is free software; you can redistribute it and/or modify it
7960 + * under the terms of the GNU General Public License version 2 as published
7961 + * by the Free Software Foundation.
7962 + */
7964 +#include <asm/mach-ath79/ath79.h>
7966 +#include "dev-eth.h"
7967 +#include "dev-m25p80.h"
7968 +#include "dev-gpio-buttons.h"
7969 +#include "dev-leds-gpio.h"
7970 +#include "machtypes.h"
7971 +#include "pci.h"
7973 +#define AW_NR580_GPIO_LED_READY_RED 0
7974 +#define AW_NR580_GPIO_LED_WLAN 1
7975 +#define AW_NR580_GPIO_LED_READY_GREEN 2
7976 +#define AW_NR580_GPIO_LED_WPS_GREEN 4
7977 +#define AW_NR580_GPIO_LED_WPS_AMBER 5
7979 +#define AW_NR580_GPIO_BTN_WPS 3
7980 +#define AW_NR580_GPIO_BTN_RESET 11
7982 +#define AW_NR580_KEYS_POLL_INTERVAL 20 /* msecs */
7983 +#define AW_NR580_KEYS_DEBOUNCE_INTERVAL (3 * AW_NR580_KEYS_POLL_INTERVAL)
7985 +static struct gpio_led aw_nr580_leds_gpio[] __initdata = {
7987 + .name = "aw-nr580:red:ready",
7988 + .gpio = AW_NR580_GPIO_LED_READY_RED,
7989 + .active_low = 0,
7990 + }, {
7991 + .name = "aw-nr580:green:ready",
7992 + .gpio = AW_NR580_GPIO_LED_READY_GREEN,
7993 + .active_low = 0,
7994 + }, {
7995 + .name = "aw-nr580:green:wps",
7996 + .gpio = AW_NR580_GPIO_LED_WPS_GREEN,
7997 + .active_low = 0,
7998 + }, {
7999 + .name = "aw-nr580:amber:wps",
8000 + .gpio = AW_NR580_GPIO_LED_WPS_AMBER,
8001 + .active_low = 0,
8002 + }, {
8003 + .name = "aw-nr580:green:wlan",
8004 + .gpio = AW_NR580_GPIO_LED_WLAN,
8005 + .active_low = 0,
8009 +static struct gpio_keys_button aw_nr580_gpio_keys[] __initdata = {
8011 + .desc = "reset",
8012 + .type = EV_KEY,
8013 + .code = KEY_RESTART,
8014 + .debounce_interval = AW_NR580_KEYS_DEBOUNCE_INTERVAL,
8015 + .gpio = AW_NR580_GPIO_BTN_RESET,
8016 + .active_low = 1,
8017 + }, {
8018 + .desc = "wps",
8019 + .type = EV_KEY,
8020 + .code = KEY_WPS_BUTTON,
8021 + .debounce_interval = AW_NR580_KEYS_DEBOUNCE_INTERVAL,
8022 + .gpio = AW_NR580_GPIO_BTN_WPS,
8023 + .active_low = 1,
8027 +static const char *aw_nr580_part_probes[] = {
8028 + "RedBoot",
8029 + NULL,
8032 +static struct flash_platform_data aw_nr580_flash_data = {
8033 + .part_probes = aw_nr580_part_probes,
8036 +static void __init aw_nr580_setup(void)
8038 + ath79_register_mdio(0, 0x0);
8040 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
8041 + ath79_eth0_data.speed = SPEED_100;
8042 + ath79_eth0_data.duplex = DUPLEX_FULL;
8044 + ath79_register_eth(0);
8046 + ath79_register_pci();
8048 + ath79_register_m25p80(&aw_nr580_flash_data);
8050 + ath79_register_leds_gpio(-1, ARRAY_SIZE(aw_nr580_leds_gpio),
8051 + aw_nr580_leds_gpio);
8053 + ath79_register_gpio_keys_polled(-1, AW_NR580_KEYS_POLL_INTERVAL,
8054 + ARRAY_SIZE(aw_nr580_gpio_keys),
8055 + aw_nr580_gpio_keys);
8058 +MIPS_MACHINE(ATH79_MACH_AW_NR580, "AW-NR580", "AzureWave AW-NR580",
8059 + aw_nr580_setup);
8060 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-bhu-bxu2000n2-a.c linux-4.1.43/arch/mips/ath79/mach-bhu-bxu2000n2-a.c
8061 --- linux-4.1.43.orig/arch/mips/ath79/mach-bhu-bxu2000n2-a.c 1970-01-01 01:00:00.000000000 +0100
8062 +++ linux-4.1.43/arch/mips/ath79/mach-bhu-bxu2000n2-a.c 2017-08-06 20:02:15.000000000 +0200
8063 @@ -0,0 +1,120 @@
8065 + * BHU BXU2000n-2 A1 board support
8067 + * Copyright (C) 2013 Terry Yang <yangbo@bhunetworks.com>
8069 + * This program is free software; you can redistribute it and/or modify it
8070 + * under the terms of the GNU General Public License version 2 as published
8071 + * by the Free Software Foundation.
8072 + */
8074 +#include <linux/gpio.h>
8075 +#include <linux/platform_device.h>
8077 +#include <asm/mach-ath79/ath79.h>
8078 +#include <asm/mach-ath79/ar71xx_regs.h>
8080 +#include "common.h"
8081 +#include "dev-eth.h"
8082 +#include "dev-gpio-buttons.h"
8083 +#include "dev-leds-gpio.h"
8084 +#include "dev-m25p80.h"
8085 +#include "dev-usb.h"
8086 +#include "dev-wmac.h"
8087 +#include "machtypes.h"
8089 +#define BHU_BXU2000N2_A1_GPIO_LED_WLAN 13
8090 +#define BHU_BXU2000N2_A1_GPIO_LED_WAN 19
8091 +#define BHU_BXU2000N2_A1_GPIO_LED_LAN 21
8092 +#define BHU_BXU2000N2_A1_GPIO_LED_SYSTEM 14
8094 +#define BHU_BXU2000N2_A1_GPIO_BTN_RESET 17
8096 +#define BHU_BXU2000N2_KEYS_POLL_INTERVAL 20 /* msecs */
8097 +#define BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL \
8098 + (3 * BHU_BXU2000N2_KEYS_POLL_INTERVAL)
8100 +static const char *bhu_bxu2000n2_part_probes[] = {
8101 + "cmdlinepart",
8102 + NULL,
8105 +static struct flash_platform_data bhu_bxu2000n2_flash_data = {
8106 + .part_probes = bhu_bxu2000n2_part_probes,
8109 +static struct gpio_led bhu_bxu2000n2_a1_leds_gpio[] __initdata = {
8111 + .name = "bhu:green:status",
8112 + .gpio = BHU_BXU2000N2_A1_GPIO_LED_SYSTEM,
8113 + .active_low = 1,
8114 + }, {
8115 + .name = "bhu:green:lan",
8116 + .gpio = BHU_BXU2000N2_A1_GPIO_LED_LAN,
8117 + .active_low = 1,
8118 + }, {
8119 + .name = "bhu:green:wan",
8120 + .gpio = BHU_BXU2000N2_A1_GPIO_LED_WAN,
8121 + .active_low = 1,
8122 + }, {
8123 + .name = "bhu:green:wlan",
8124 + .gpio = BHU_BXU2000N2_A1_GPIO_LED_WLAN,
8125 + .active_low = 1,
8126 + },
8129 +static struct gpio_keys_button bhu_bxu2000n2_a1_gpio_keys[] __initdata = {
8131 + .desc = "Reset button",
8132 + .type = EV_KEY,
8133 + .code = KEY_RESTART,
8134 + .debounce_interval = BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL,
8135 + .gpio = BHU_BXU2000N2_A1_GPIO_BTN_RESET,
8136 + .active_low = 1,
8140 +static void __init bhu_ap123_setup(void)
8142 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
8143 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
8145 + ath79_register_m25p80(&bhu_bxu2000n2_flash_data);
8147 + ath79_register_mdio(1, 0x0);
8149 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
8150 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
8152 + /* GMAC0 is connected to the PHY4 of the internal switch */
8153 + ath79_switch_data.phy4_mii_en = 1;
8154 + ath79_switch_data.phy_poll_mask = BIT(4);
8155 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
8156 + ath79_eth0_data.phy_mask = BIT(4);
8157 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
8158 + ath79_register_eth(0);
8160 + /* GMAC1 is connected to the internal switch. Only use PHY3 */
8161 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
8162 + ath79_eth1_data.phy_mask = BIT(3);
8163 + ath79_register_eth(1);
8165 + ath79_register_wmac(ee, ee+2);
8168 +static void __init bhu_bxu2000n2_a1_setup(void)
8170 + bhu_ap123_setup();
8172 + ath79_register_leds_gpio(-1, ARRAY_SIZE(bhu_bxu2000n2_a1_leds_gpio),
8173 + bhu_bxu2000n2_a1_leds_gpio);
8175 + ath79_register_gpio_keys_polled(1, BHU_BXU2000N2_KEYS_POLL_INTERVAL,
8176 + ARRAY_SIZE(bhu_bxu2000n2_a1_gpio_keys),
8177 + bhu_bxu2000n2_a1_gpio_keys);
8180 +MIPS_MACHINE(ATH79_MACH_BHU_BXU2000N2_A1, "BXU2000n-2-A1",
8181 + "BHU BXU2000n-2 rev. A1",
8182 + bhu_bxu2000n2_a1_setup);
8184 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-bsb.c linux-4.1.43/arch/mips/ath79/mach-bsb.c
8185 --- linux-4.1.43.orig/arch/mips/ath79/mach-bsb.c 1970-01-01 01:00:00.000000000 +0100
8186 +++ linux-4.1.43/arch/mips/ath79/mach-bsb.c 2017-08-06 20:02:15.000000000 +0200
8187 @@ -0,0 +1,83 @@
8189 + * Smart Electronics Black Swift board support
8191 + * Copyright (C) 2014 Dmitriy Zherebkov dzh@black-swift.com
8193 + * This program is free software; you can redistribute it and/or modify it
8194 + * under the terms of the GNU General Public License version 2 as published
8195 + * by the Free Software Foundation.
8196 + */
8198 +#include <asm/mach-ath79/ath79.h>
8199 +#include <asm/mach-ath79/ar71xx_regs.h>
8200 +#include "common.h"
8201 +#include "dev-eth.h"
8202 +#include "dev-gpio-buttons.h"
8203 +#include "dev-leds-gpio.h"
8204 +#include "dev-m25p80.h"
8205 +#include "dev-spi.h"
8206 +#include "dev-usb.h"
8207 +#include "dev-wmac.h"
8208 +#include "machtypes.h"
8210 +#define BSB_GPIO_LED_SYS 27
8212 +#define BSB_GPIO_BTN_RESET 11
8214 +#define BSB_KEYS_POLL_INTERVAL 20 /* msecs */
8215 +#define BSB_KEYS_DEBOUNCE_INTERVAL (3 * BSB_KEYS_POLL_INTERVAL)
8217 +#define BSB_MAC_OFFSET 0x0000
8218 +#define BSB_CALDATA_OFFSET 0x1000
8220 +static struct gpio_led bsb_leds_gpio[] __initdata = {
8222 + .name = "bsb:red:sys",
8223 + .gpio = BSB_GPIO_LED_SYS,
8224 + .active_low = 1,
8228 +static struct gpio_keys_button bsb_gpio_keys[] __initdata = {
8230 + .desc = "reset button",
8231 + .type = EV_KEY,
8232 + .code = KEY_RESTART,
8233 + .debounce_interval = BSB_KEYS_DEBOUNCE_INTERVAL,
8234 + .gpio = BSB_GPIO_BTN_RESET,
8235 + .active_low = 1,
8236 + },
8239 +static void __init bsb_setup(void)
8241 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
8243 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
8244 + ath79_setup_ar933x_phy4_switch(false,false);
8246 + ath79_register_leds_gpio(-1, ARRAY_SIZE(bsb_leds_gpio),
8247 + bsb_leds_gpio);
8248 + ath79_register_gpio_keys_polled(-1, BSB_KEYS_POLL_INTERVAL,
8249 + ARRAY_SIZE(bsb_gpio_keys),
8250 + bsb_gpio_keys);
8252 + ath79_register_usb();
8254 + ath79_register_m25p80(NULL);
8256 + ath79_init_mac(ath79_eth0_data.mac_addr, art + BSB_MAC_OFFSET, 1);
8257 + ath79_init_mac(ath79_eth1_data.mac_addr, art + BSB_MAC_OFFSET, 2);
8259 + ath79_register_mdio(0, 0x0);
8261 + ath79_register_eth(0);
8262 + ath79_register_eth(1);
8264 + ath79_register_wmac(art + BSB_CALDATA_OFFSET,
8265 + art + BSB_MAC_OFFSET);
8268 +MIPS_MACHINE(ATH79_MACH_BSB, "BSB", "Smart Electronics Black Swift board",
8269 + bsb_setup);
8271 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-cap4200ag.c linux-4.1.43/arch/mips/ath79/mach-cap4200ag.c
8272 --- linux-4.1.43.orig/arch/mips/ath79/mach-cap4200ag.c 1970-01-01 01:00:00.000000000 +0100
8273 +++ linux-4.1.43/arch/mips/ath79/mach-cap4200ag.c 2017-08-06 20:02:15.000000000 +0200
8274 @@ -0,0 +1,131 @@
8276 + * Senao CAP4200AG board support
8278 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
8280 + * This program is free software; you can redistribute it and/or modify it
8281 + * under the terms of the GNU General Public License version 2 as published
8282 + * by the Free Software Foundation.
8283 + */
8285 +#include <linux/pci.h>
8286 +#include <linux/phy.h>
8287 +#include <linux/platform_device.h>
8288 +#include <linux/ath9k_platform.h>
8290 +#include <asm/mach-ath79/ar71xx_regs.h>
8292 +#include "common.h"
8293 +#include "dev-ap9x-pci.h"
8294 +#include "dev-eth.h"
8295 +#include "dev-gpio-buttons.h"
8296 +#include "dev-leds-gpio.h"
8297 +#include "dev-m25p80.h"
8298 +#include "dev-spi.h"
8299 +#include "dev-usb.h"
8300 +#include "dev-wmac.h"
8301 +#include "machtypes.h"
8303 +#define CAP4200AG_GPIO_LED_PWR_GREEN 12
8304 +#define CAP4200AG_GPIO_LED_PWR_AMBER 13
8305 +#define CAP4200AG_GPIO_LED_LAN_GREEN 14
8306 +#define CAP4200AG_GPIO_LED_LAN_AMBER 15
8307 +#define CAP4200AG_GPIO_LED_WLAN_GREEN 18
8308 +#define CAP4200AG_GPIO_LED_WLAN_AMBER 19
8310 +#define CAP4200AG_GPIO_BTN_RESET 17
8312 +#define CAP4200AG_KEYS_POLL_INTERVAL 20 /* msecs */
8313 +#define CAP4200AG_KEYS_DEBOUNCE_INTERVAL (3 * CAP4200AG_KEYS_POLL_INTERVAL)
8315 +#define CAP4200AG_MAC_OFFSET 0
8316 +#define CAP4200AG_WMAC_CALDATA_OFFSET 0x1000
8317 +#define CAP4200AG_PCIE_CALDATA_OFFSET 0x5000
8319 +static struct gpio_led cap4200ag_leds_gpio[] __initdata = {
8321 + .name = "senao:green:pwr",
8322 + .gpio = CAP4200AG_GPIO_LED_PWR_GREEN,
8323 + .active_low = 1,
8324 + },
8326 + .name = "senao:amber:pwr",
8327 + .gpio = CAP4200AG_GPIO_LED_PWR_AMBER,
8328 + .active_low = 1,
8329 + },
8331 + .name = "senao:green:lan",
8332 + .gpio = CAP4200AG_GPIO_LED_LAN_GREEN,
8333 + .active_low = 1,
8334 + },
8336 + .name = "senao:amber:lan",
8337 + .gpio = CAP4200AG_GPIO_LED_LAN_AMBER,
8338 + .active_low = 1,
8339 + },
8341 + .name = "senao:green:wlan",
8342 + .gpio = CAP4200AG_GPIO_LED_WLAN_GREEN,
8343 + .active_low = 1,
8344 + },
8346 + .name = "senao:amber:wlan",
8347 + .gpio = CAP4200AG_GPIO_LED_WLAN_AMBER,
8348 + .active_low = 1,
8349 + },
8352 +static struct gpio_keys_button cap4200ag_gpio_keys[] __initdata = {
8354 + .desc = "Reset button",
8355 + .type = EV_KEY,
8356 + .code = KEY_RESTART,
8357 + .debounce_interval = CAP4200AG_KEYS_DEBOUNCE_INTERVAL,
8358 + .gpio = CAP4200AG_GPIO_BTN_RESET,
8359 + .active_low = 1,
8360 + },
8363 +static void __init cap4200ag_setup(void)
8365 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
8366 + u8 mac[6];
8368 + ath79_gpio_output_select(CAP4200AG_GPIO_LED_LAN_GREEN,
8369 + AR934X_GPIO_OUT_GPIO);
8370 + ath79_gpio_output_select(CAP4200AG_GPIO_LED_LAN_AMBER,
8371 + AR934X_GPIO_OUT_GPIO);
8373 + ath79_register_m25p80(NULL);
8375 + ath79_register_leds_gpio(-1, ARRAY_SIZE(cap4200ag_leds_gpio),
8376 + cap4200ag_leds_gpio);
8377 + ath79_register_gpio_keys_polled(-1, CAP4200AG_KEYS_POLL_INTERVAL,
8378 + ARRAY_SIZE(cap4200ag_gpio_keys),
8379 + cap4200ag_gpio_keys);
8381 + ath79_init_mac(mac, art + CAP4200AG_MAC_OFFSET, -1);
8382 + ath79_wmac_disable_2ghz();
8383 + ath79_register_wmac(art + CAP4200AG_WMAC_CALDATA_OFFSET, mac);
8385 + ath79_init_mac(mac, art + CAP4200AG_MAC_OFFSET, -2);
8386 + ap91_pci_init(art + CAP4200AG_PCIE_CALDATA_OFFSET, mac);
8388 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
8389 + AR934X_ETH_CFG_SW_ONLY_MODE);
8391 + ath79_register_mdio(0, 0x0);
8393 + ath79_init_mac(ath79_eth0_data.mac_addr,
8394 + art + CAP4200AG_MAC_OFFSET, -2);
8396 + /* GMAC0 is connected to an external PHY */
8397 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
8398 + ath79_eth0_data.phy_mask = BIT(0);
8399 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
8400 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
8401 + ath79_register_eth(0);
8404 +MIPS_MACHINE(ATH79_MACH_CAP4200AG, "CAP4200AG", "Senao CAP4200AG",
8405 + cap4200ag_setup);
8406 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-carambola2.c linux-4.1.43/arch/mips/ath79/mach-carambola2.c
8407 --- linux-4.1.43.orig/arch/mips/ath79/mach-carambola2.c 1970-01-01 01:00:00.000000000 +0100
8408 +++ linux-4.1.43/arch/mips/ath79/mach-carambola2.c 2017-08-06 20:02:15.000000000 +0200
8409 @@ -0,0 +1,105 @@
8411 + * 8devices Carambola2 board support
8413 + * Copyright (C) 2013 Darius Augulis <darius@8devices.com>
8415 + * This program is free software; you can redistribute it and/or modify it
8416 + * under the terms of the GNU General Public License version 2 as published
8417 + * by the Free Software Foundation.
8418 + */
8420 +#include <asm/mach-ath79/ath79.h>
8421 +#include <asm/mach-ath79/ar71xx_regs.h>
8422 +#include "common.h"
8423 +#include "dev-eth.h"
8424 +#include "dev-gpio-buttons.h"
8425 +#include "dev-leds-gpio.h"
8426 +#include "dev-m25p80.h"
8427 +#include "dev-spi.h"
8428 +#include "dev-usb.h"
8429 +#include "dev-wmac.h"
8430 +#include "machtypes.h"
8432 +#define CARAMBOLA2_GPIO_LED_WLAN 0
8433 +#define CARAMBOLA2_GPIO_LED_ETH0 14
8434 +#define CARAMBOLA2_GPIO_LED_ETH1 13
8436 +#define CARAMBOLA2_GPIO_BTN_JUMPSTART 11
8438 +#define CARAMBOLA2_KEYS_POLL_INTERVAL 20 /* msecs */
8439 +#define CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL (3 * CARAMBOLA2_KEYS_POLL_INTERVAL)
8441 +#define CARAMBOLA2_MAC0_OFFSET 0x0000
8442 +#define CARAMBOLA2_MAC1_OFFSET 0x0006
8443 +#define CARAMBOLA2_CALDATA_OFFSET 0x1000
8444 +#define CARAMBOLA2_WMAC_MAC_OFFSET 0x1002
8446 +static struct gpio_led carambola2_leds_gpio[] __initdata = {
8448 + .name = "carambola2:green:wlan",
8449 + .gpio = CARAMBOLA2_GPIO_LED_WLAN,
8450 + .active_low = 1,
8451 + }, {
8452 + .name = "carambola2:orange:eth0",
8453 + .gpio = CARAMBOLA2_GPIO_LED_ETH0,
8454 + .active_low = 0,
8455 + }, {
8456 + .name = "carambola2:orange:eth1",
8457 + .gpio = CARAMBOLA2_GPIO_LED_ETH1,
8458 + .active_low = 0,
8462 +static struct gpio_keys_button carambola2_gpio_keys[] __initdata = {
8464 + .desc = "jumpstart button",
8465 + .type = EV_KEY,
8466 + .code = KEY_WPS_BUTTON,
8467 + .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
8468 + .gpio = CARAMBOLA2_GPIO_BTN_JUMPSTART,
8469 + .active_low = 1,
8470 + },
8473 +static void __init carambola2_common_setup(void)
8475 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
8477 + ath79_register_m25p80(NULL);
8478 + ath79_register_wmac(art + CARAMBOLA2_CALDATA_OFFSET,
8479 + art + CARAMBOLA2_WMAC_MAC_OFFSET);
8481 + ath79_setup_ar933x_phy4_switch(true, true);
8483 + ath79_init_mac(ath79_eth0_data.mac_addr, art + CARAMBOLA2_MAC0_OFFSET, 0);
8484 + ath79_init_mac(ath79_eth1_data.mac_addr, art + CARAMBOLA2_MAC1_OFFSET, 0);
8486 + ath79_register_mdio(0, 0x0);
8488 + /* LAN ports */
8489 + ath79_register_eth(1);
8491 + /* WAN port */
8492 + ath79_register_eth(0);
8495 +static void __init carambola2_setup(void)
8497 + carambola2_common_setup();
8499 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
8500 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
8501 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
8502 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
8503 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
8505 + ath79_register_leds_gpio(-1, ARRAY_SIZE(carambola2_leds_gpio),
8506 + carambola2_leds_gpio);
8507 + ath79_register_gpio_keys_polled(-1, CARAMBOLA2_KEYS_POLL_INTERVAL,
8508 + ARRAY_SIZE(carambola2_gpio_keys),
8509 + carambola2_gpio_keys);
8510 + ath79_register_usb();
8513 +MIPS_MACHINE(ATH79_MACH_CARAMBOLA2, "CARAMBOLA2", "8devices Carambola2 board",
8514 + carambola2_setup);
8515 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-cf-e316n-v2.c linux-4.1.43/arch/mips/ath79/mach-cf-e316n-v2.c
8516 --- linux-4.1.43.orig/arch/mips/ath79/mach-cf-e316n-v2.c 1970-01-01 01:00:00.000000000 +0100
8517 +++ linux-4.1.43/arch/mips/ath79/mach-cf-e316n-v2.c 2017-08-06 20:02:15.000000000 +0200
8518 @@ -0,0 +1,132 @@
8520 + * COMFAST CF-E316N v2
8521 + * by Shenzhen Four Seas Global Link Network Technology Co., Ltd
8523 + * aka CF-E316V2, CF-E316N-V2 and CF-E316Nv2.0 (no FCC ID)
8525 + * Copyright (C) 2015 Paul Fertser <fercerpav@gmail.com>
8527 + * This program is free software; you can redistribute it and/or modify it
8528 + * under the terms of the GNU General Public License version 2 as published
8529 + * by the Free Software Foundation.
8530 + */
8532 +#include <linux/gpio.h>
8533 +#include <linux/platform_device.h>
8534 +#include <linux/timer.h>
8536 +#include <asm/mach-ath79/ath79.h>
8537 +#include <asm/mach-ath79/ar71xx_regs.h>
8539 +#include "common.h"
8540 +#include "dev-eth.h"
8541 +#include "dev-gpio-buttons.h"
8542 +#include "dev-leds-gpio.h"
8543 +#include "dev-m25p80.h"
8544 +#include "dev-wmac.h"
8545 +#include "dev-usb.h"
8546 +#include "machtypes.h"
8548 +static struct gpio_led cf_e316n_v2_leds_gpio[] __initdata = {
8550 + .name = "cf-e316n-v2:blue:diag",
8551 + .gpio = 0,
8552 + .active_low = 0,
8553 + }, {
8554 + .name = "cf-e316n-v2:red:diag",
8555 + .gpio = 2,
8556 + .active_low = 0,
8557 + }, {
8558 + .name = "cf-e316n-v2:green:diag",
8559 + .gpio = 3,
8560 + .active_low = 0,
8561 + }, {
8562 + .name = "cf-e316n-v2:blue:wlan",
8563 + .gpio = 12,
8564 + .active_low = 1,
8565 + }, {
8566 + .name = "cf-e316n-v2:blue:wan",
8567 + .gpio = 17,
8568 + .active_low = 1,
8569 + }, {
8570 + .name = "cf-e316n-v2:blue:lan",
8571 + .gpio = 19,
8572 + .active_low = 1,
8573 + },
8576 +static struct gpio_keys_button cf_e316n_v2_gpio_keys[] __initdata = {
8578 + .desc = "Reset button",
8579 + .type = EV_KEY,
8580 + .code = KEY_RESTART,
8581 + .debounce_interval = 60,
8582 + .gpio = 20,
8583 + .active_low = 1,
8584 + },
8587 +/* There's a Pericon Technology PT7A7514 connected to GPIO 16 */
8588 +#define EXT_WATCHDOG_GPIO 16
8589 +static struct timer_list gpio_wdt_timer;
8591 +static void gpio_wdt_toggle(unsigned long period)
8593 + static int state;
8594 + state = !state;
8595 + gpio_set_value(EXT_WATCHDOG_GPIO, state);
8596 + mod_timer(&gpio_wdt_timer, jiffies + period);
8599 +static void __init cf_e316n_v2_setup(void)
8601 + u8 *maclan = (u8 *) KSEG1ADDR(0x1f010000);
8602 + u8 *macwlan = (u8 *) KSEG1ADDR(0x1f011002);
8603 + u8 *ee = (u8 *) KSEG1ADDR(0x1f011000);
8604 + u8 tmpmac[ETH_ALEN];
8606 + gpio_request(EXT_WATCHDOG_GPIO, "PT7A7514 watchdog");
8607 + gpio_direction_output(EXT_WATCHDOG_GPIO, 0);
8608 + setup_timer(&gpio_wdt_timer, gpio_wdt_toggle, msecs_to_jiffies(500));
8609 + gpio_wdt_toggle(msecs_to_jiffies(1));
8611 + ath79_register_m25p80(NULL);
8613 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
8614 + ath79_register_mdio(1, 0x0);
8616 + /* GMAC0 is connected to the PHY0 of the internal switch */
8617 + ath79_switch_data.phy4_mii_en = 1;
8618 + ath79_switch_data.phy_poll_mask = BIT(0);
8619 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
8620 + ath79_eth0_data.phy_mask = BIT(0);
8621 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
8622 + ath79_init_mac(ath79_eth0_data.mac_addr, maclan, 0);
8623 + ath79_register_eth(0);
8625 + /* GMAC1 is connected to the internal switch */
8626 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
8627 + ath79_init_mac(ath79_eth1_data.mac_addr, maclan, 2);
8628 + ath79_register_eth(1);
8630 + /* Enable 2x Skyworks SE2576L WLAN power amplifiers */
8631 + gpio_request(13, "RF Amp 1");
8632 + gpio_direction_output(13, 1);
8633 + gpio_request(14, "RF Amp 2");
8634 + gpio_direction_output(14, 1);
8635 + ath79_init_mac(tmpmac, macwlan, 0);
8636 + ath79_register_wmac(ee, tmpmac);
8638 + ath79_register_leds_gpio(-1, ARRAY_SIZE(cf_e316n_v2_leds_gpio),
8639 + cf_e316n_v2_leds_gpio);
8641 + ath79_register_gpio_keys_polled(1, 20,
8642 + ARRAY_SIZE(cf_e316n_v2_gpio_keys),
8643 + cf_e316n_v2_gpio_keys);
8645 + /* J1 is a High-Speed USB port, pin 1 is Vcc */
8646 + ath79_register_usb();
8649 +MIPS_MACHINE(ATH79_MACH_CF_E316N_V2, "CF-E316N-V2", "COMFAST CF-E316N v2",
8650 + cf_e316n_v2_setup);
8651 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-cpe510.c linux-4.1.43/arch/mips/ath79/mach-cpe510.c
8652 --- linux-4.1.43.orig/arch/mips/ath79/mach-cpe510.c 1970-01-01 01:00:00.000000000 +0100
8653 +++ linux-4.1.43/arch/mips/ath79/mach-cpe510.c 2017-08-06 20:02:15.000000000 +0200
8654 @@ -0,0 +1,107 @@
8656 + * TP-LINK CPE210/220/510/520 board support
8658 + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
8660 + * This program is free software; you can redistribute it and/or modify it
8661 + * under the terms of the GNU General Public License version 2 as published
8662 + * by the Free Software Foundation.
8663 + */
8665 +#include <linux/gpio.h>
8666 +#include <linux/platform_device.h>
8668 +#include <asm/mach-ath79/ath79.h>
8669 +#include <asm/mach-ath79/ar71xx_regs.h>
8671 +#include "common.h"
8672 +#include "dev-eth.h"
8673 +#include "dev-gpio-buttons.h"
8674 +#include "dev-leds-gpio.h"
8675 +#include "dev-m25p80.h"
8676 +#include "dev-wmac.h"
8677 +#include "machtypes.h"
8680 +#define CPE510_GPIO_LED_LAN0 11
8681 +#define CPE510_GPIO_LED_LAN1 12
8682 +#define CPE510_GPIO_LED_L1 13
8683 +#define CPE510_GPIO_LED_L2 14
8684 +#define CPE510_GPIO_LED_L3 15
8685 +#define CPE510_GPIO_LED_L4 16
8687 +#define CPE510_GPIO_BTN_RESET 4
8689 +#define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
8690 +#define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
8693 +static struct gpio_led cpe510_leds_gpio[] __initdata = {
8695 + .name = "tp-link:green:lan0",
8696 + .gpio = CPE510_GPIO_LED_LAN0,
8697 + .active_low = 1,
8698 + }, {
8699 + .name = "tp-link:green:lan1",
8700 + .gpio = CPE510_GPIO_LED_LAN1,
8701 + .active_low = 1,
8702 + }, {
8703 + .name = "tp-link:green:link1",
8704 + .gpio = CPE510_GPIO_LED_L1,
8705 + .active_low = 1,
8706 + }, {
8707 + .name = "tp-link:green:link2",
8708 + .gpio = CPE510_GPIO_LED_L2,
8709 + .active_low = 1,
8710 + }, {
8711 + .name = "tp-link:green:link3",
8712 + .gpio = CPE510_GPIO_LED_L3,
8713 + .active_low = 1,
8714 + }, {
8715 + .name = "tp-link:green:link4",
8716 + .gpio = CPE510_GPIO_LED_L4,
8717 + .active_low = 1,
8718 + },
8721 +static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
8723 + .desc = "Reset button",
8724 + .type = EV_KEY,
8725 + .code = KEY_RESTART,
8726 + .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
8727 + .gpio = CPE510_GPIO_BTN_RESET,
8728 + .active_low = 1,
8733 +static void __init cpe510_setup(void)
8735 + u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
8736 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
8738 + /* Disable JTAG, enabling GPIOs 0-3 */
8739 + /* Configure OBS4 line, for GPIO 4*/
8740 + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
8741 + AR934X_GPIO_FUNC_CLK_OBS4_EN);
8743 + ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio),
8744 + cpe510_leds_gpio);
8746 + ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL,
8747 + ARRAY_SIZE(cpe510_gpio_keys),
8748 + cpe510_gpio_keys);
8750 + ath79_register_m25p80(NULL);
8752 + ath79_register_mdio(1, 0);
8753 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
8754 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
8755 + ath79_register_eth(1);
8757 + ath79_register_wmac(ee, mac);
8760 +MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",
8761 + cpe510_setup);
8762 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-db120.c linux-4.1.43/arch/mips/ath79/mach-db120.c
8763 --- linux-4.1.43.orig/arch/mips/ath79/mach-db120.c 2017-08-06 01:56:14.000000000 +0200
8764 +++ linux-4.1.43/arch/mips/ath79/mach-db120.c 2017-08-06 20:02:15.000000000 +0200
8765 @@ -2,7 +2,7 @@
8766 * Atheros DB120 reference board support
8768 * Copyright (c) 2011 Qualcomm Atheros
8769 - * Copyright (c) 2011 Gabor Juhos <juhosg@openwrt.org>
8770 + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
8772 * Permission to use, copy, modify, and/or distribute this software for any
8773 * purpose with or without fee is hereby granted, provided that the above
8774 @@ -19,16 +19,26 @@
8777 #include <linux/pci.h>
8778 +#include <linux/phy.h>
8779 +#include <linux/platform_device.h>
8780 #include <linux/ath9k_platform.h>
8781 +#include <linux/ar8216_platform.h>
8783 -#include "machtypes.h"
8784 +#include <asm/mach-ath79/ar71xx_regs.h>
8786 +#include "common.h"
8787 +#include "dev-ap9x-pci.h"
8788 +#include "dev-eth.h"
8789 #include "dev-gpio-buttons.h"
8790 #include "dev-leds-gpio.h"
8791 +#include "dev-m25p80.h"
8792 +#include "dev-nfc.h"
8793 #include "dev-spi.h"
8794 #include "dev-usb.h"
8795 #include "dev-wmac.h"
8796 -#include "pci.h"
8797 +#include "machtypes.h"
8799 +#define DB120_GPIO_LED_USB 11
8800 #define DB120_GPIO_LED_WLAN_5G 12
8801 #define DB120_GPIO_LED_WLAN_2G 13
8802 #define DB120_GPIO_LED_STATUS 14
8803 @@ -39,8 +49,10 @@
8804 #define DB120_KEYS_POLL_INTERVAL 20 /* msecs */
8805 #define DB120_KEYS_DEBOUNCE_INTERVAL (3 * DB120_KEYS_POLL_INTERVAL)
8807 -#define DB120_WMAC_CALDATA_OFFSET 0x1000
8808 -#define DB120_PCIE_CALDATA_OFFSET 0x5000
8809 +#define DB120_MAC0_OFFSET 0
8810 +#define DB120_MAC1_OFFSET 6
8811 +#define DB120_WMAC_CALDATA_OFFSET 0x1000
8812 +#define DB120_PCIE_CALDATA_OFFSET 0x5000
8814 static struct gpio_led db120_leds_gpio[] __initdata = {
8816 @@ -63,6 +75,11 @@
8817 .gpio = DB120_GPIO_LED_WLAN_2G,
8818 .active_low = 1,
8821 + .name = "db120:green:usb",
8822 + .gpio = DB120_GPIO_LED_USB,
8823 + .active_low = 1,
8827 static struct gpio_keys_button db120_gpio_keys[] __initdata = {
8828 @@ -76,60 +93,85 @@
8832 -static struct spi_board_info db120_spi_info[] = {
8834 - .bus_num = 0,
8835 - .chip_select = 0,
8836 - .max_speed_hz = 25000000,
8837 - .modalias = "s25sl064a",
8839 +static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = {
8840 + .mode = AR8327_PAD_MAC_RGMII,
8841 + .txclk_delay_en = true,
8842 + .rxclk_delay_en = true,
8843 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
8844 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
8847 -static struct ath79_spi_platform_data db120_spi_data = {
8848 - .bus_num = 0,
8849 - .num_chipselect = 1,
8850 +static struct ar8327_led_cfg db120_ar8327_led_cfg = {
8851 + .led_ctrl0 = 0x00000000,
8852 + .led_ctrl1 = 0xc737c737,
8853 + .led_ctrl2 = 0x00000000,
8854 + .led_ctrl3 = 0x00c30c00,
8855 + .open_drain = true,
8858 -#ifdef CONFIG_PCI
8859 -static struct ath9k_platform_data db120_ath9k_data;
8861 -static int db120_pci_plat_dev_init(struct pci_dev *dev)
8863 - switch (PCI_SLOT(dev->devfn)) {
8864 - case 0:
8865 - dev->dev.platform_data = &db120_ath9k_data;
8866 - break;
8869 - return 0;
8872 -static void __init db120_pci_init(u8 *eeprom)
8874 - memcpy(db120_ath9k_data.eeprom_data, eeprom,
8875 - sizeof(db120_ath9k_data.eeprom_data));
8876 +static struct ar8327_platform_data db120_ar8327_data = {
8877 + .pad0_cfg = &db120_ar8327_pad0_cfg,
8878 + .port0_cfg = {
8879 + .force_link = 1,
8880 + .speed = AR8327_PORT_SPEED_1000,
8881 + .duplex = 1,
8882 + .txpause = 1,
8883 + .rxpause = 1,
8884 + },
8885 + .led_cfg = &db120_ar8327_led_cfg,
8888 - ath79_pci_set_plat_dev_init(db120_pci_plat_dev_init);
8889 - ath79_register_pci();
8891 -#else
8892 -static inline void db120_pci_init(u8 *eeprom) {}
8893 -#endif /* CONFIG_PCI */
8894 +static struct mdio_board_info db120_mdio0_info[] = {
8896 + .bus_id = "ag71xx-mdio.0",
8897 + .phy_addr = 0,
8898 + .platform_data = &db120_ar8327_data,
8899 + },
8902 static void __init db120_setup(void)
8904 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
8906 + ath79_gpio_output_select(DB120_GPIO_LED_USB, AR934X_GPIO_OUT_GPIO);
8907 + ath79_register_m25p80(NULL);
8909 ath79_register_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
8910 db120_leds_gpio);
8911 ath79_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
8912 ARRAY_SIZE(db120_gpio_keys),
8913 db120_gpio_keys);
8914 - ath79_register_spi(&db120_spi_data, db120_spi_info,
8915 - ARRAY_SIZE(db120_spi_info));
8916 ath79_register_usb();
8917 - ath79_register_wmac(art + DB120_WMAC_CALDATA_OFFSET);
8918 - db120_pci_init(art + DB120_PCIE_CALDATA_OFFSET);
8919 + ath79_register_wmac(art + DB120_WMAC_CALDATA_OFFSET, NULL);
8920 + ap91_pci_init(art + DB120_PCIE_CALDATA_OFFSET, NULL);
8922 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
8923 + AR934X_ETH_CFG_SW_ONLY_MODE);
8925 + ath79_register_mdio(1, 0x0);
8926 + ath79_register_mdio(0, 0x0);
8928 + ath79_init_mac(ath79_eth0_data.mac_addr, art + DB120_MAC0_OFFSET, 0);
8930 + mdiobus_register_board_info(db120_mdio0_info,
8931 + ARRAY_SIZE(db120_mdio0_info));
8933 + /* GMAC0 is connected to an AR8327 switch */
8934 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
8935 + ath79_eth0_data.phy_mask = BIT(0);
8936 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
8937 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
8938 + ath79_register_eth(0);
8940 + /* GMAC1 is connected to the internal switch */
8941 + ath79_init_mac(ath79_eth1_data.mac_addr, art + DB120_MAC1_OFFSET, 0);
8942 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
8943 + ath79_eth1_data.speed = SPEED_1000;
8944 + ath79_eth1_data.duplex = DUPLEX_FULL;
8946 + ath79_register_eth(1);
8948 + ath79_register_nfc();
8951 MIPS_MACHINE(ATH79_MACH_DB120, "DB120", "Atheros DB120 reference board",
8952 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dgl-5500-a1.c linux-4.1.43/arch/mips/ath79/mach-dgl-5500-a1.c
8953 --- linux-4.1.43.orig/arch/mips/ath79/mach-dgl-5500-a1.c 1970-01-01 01:00:00.000000000 +0100
8954 +++ linux-4.1.43/arch/mips/ath79/mach-dgl-5500-a1.c 2017-08-06 20:02:15.000000000 +0200
8955 @@ -0,0 +1,150 @@
8957 + * D-Link DGL-5500 board support
8959 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
8960 + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
8962 + * This program is free software; you can redistribute it and/or modify it
8963 + * under the terms of the GNU General Public License version 2 as published
8964 + * by the Free Software Foundation.
8965 + */
8967 +#include <linux/gpio.h>
8968 +#include <linux/platform_device.h>
8969 +#include <linux/ar8216_platform.h>
8971 +#include <asm/mach-ath79/ar71xx_regs.h>
8973 +#include "common.h"
8974 +#include "pci.h"
8975 +#include "dev-gpio-buttons.h"
8976 +#include "dev-eth.h"
8977 +#include "dev-leds-gpio.h"
8978 +#include "dev-m25p80.h"
8979 +#include "dev-usb.h"
8980 +#include "dev-wmac.h"
8981 +#include "machtypes.h"
8983 +#define DGL_5500_A1_GPIO_LED_POWER_ORANGE 14
8984 +#define DGL_5500_A1_GPIO_LED_POWER_GREEN 19
8985 +#define DGL_5500_A1_GPIO_LED_PLANET_GREEN 22
8986 +#define DGL_5500_A1_GPIO_LED_PLANET_ORANGE 23
8988 +#define DGL_5500_A1_GPIO_BTN_WPS 16
8989 +#define DGL_5500_A1_GPIO_BTN_RESET 17
8991 +#define DGL_5500_A1_KEYS_POLL_INTERVAL 20 /* msecs */
8992 +#define DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL \
8993 + (3 * DGL_5500_A1_KEYS_POLL_INTERVAL)
8995 +#define DGL_5500_A1_WMAC_CALDATA_OFFSET 0x1000
8997 +#define DGL_5500_A1_LAN_MAC_OFFSET 0x04
8998 +#define DGL_5500_A1_WAN_MAC_OFFSET 0x16
9000 +static struct gpio_led dgl_5500_a1_leds_gpio[] __initdata = {
9002 + .name = "d-link:green:power",
9003 + .gpio = DGL_5500_A1_GPIO_LED_POWER_GREEN,
9004 + .active_low = 1,
9005 + },
9007 + .name = "d-link:orange:power",
9008 + .gpio = DGL_5500_A1_GPIO_LED_POWER_ORANGE,
9009 + .active_low = 1,
9010 + },
9012 + .name = "d-link:green:planet",
9013 + .gpio = DGL_5500_A1_GPIO_LED_PLANET_GREEN,
9014 + .active_low = 1,
9015 + },
9017 + .name = "d-link:orange:planet",
9018 + .gpio = DGL_5500_A1_GPIO_LED_PLANET_ORANGE,
9019 + .active_low = 1,
9020 + },
9023 +static struct gpio_keys_button dgl_5500_a1_gpio_keys[] __initdata = {
9025 + .desc = "Reset button",
9026 + .type = EV_KEY,
9027 + .code = KEY_RESTART,
9028 + .debounce_interval = DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL,
9029 + .gpio = DGL_5500_A1_GPIO_BTN_RESET,
9030 + .active_low = 1,
9031 + },
9033 + .desc = "WPS button",
9034 + .type = EV_KEY,
9035 + .code = KEY_WPS_BUTTON,
9036 + .debounce_interval = DGL_5500_A1_KEYS_DEBOUNCE_INTERVAL,
9037 + .gpio = DGL_5500_A1_GPIO_BTN_WPS,
9038 + .active_low = 1,
9039 + },
9042 +static struct ar8327_pad_cfg dgl_5500_a1_ar8327_pad0_cfg = {
9043 + /* Use the SGMII interface for the GMAC0 of the AR8327 switch */
9044 + .mode = AR8327_PAD_MAC_SGMII,
9045 + .sgmii_delay_en = true,
9048 +static struct ar8327_platform_data dgl_5500_a1_ar8327_data = {
9049 + .pad0_cfg = &dgl_5500_a1_ar8327_pad0_cfg,
9050 + .port0_cfg = {
9051 + .force_link = 1,
9052 + .speed = AR8327_PORT_SPEED_1000,
9053 + .duplex = 1,
9054 + .txpause = 1,
9055 + .rxpause = 1,
9056 + },
9059 +static struct mdio_board_info dgl_5500_a1_mdio0_info[] = {
9061 + .bus_id = "ag71xx-mdio.0",
9062 + .phy_addr = 0,
9063 + .platform_data = &dgl_5500_a1_ar8327_data,
9064 + },
9067 +static void __init dgl_5500_a1_setup(void)
9069 + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
9070 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
9071 + u8 lan_mac[ETH_ALEN];
9073 + ath79_parse_ascii_mac(mac + DGL_5500_A1_LAN_MAC_OFFSET, lan_mac);
9075 + ath79_register_m25p80(NULL);
9077 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dgl_5500_a1_leds_gpio),
9078 + dgl_5500_a1_leds_gpio);
9079 + ath79_register_gpio_keys_polled(-1, DGL_5500_A1_KEYS_POLL_INTERVAL,
9080 + ARRAY_SIZE(dgl_5500_a1_gpio_keys),
9081 + dgl_5500_a1_gpio_keys);
9083 + ath79_register_wmac(art + DGL_5500_A1_WMAC_CALDATA_OFFSET, lan_mac);
9085 + ath79_register_mdio(0, 0x0);
9086 + mdiobus_register_board_info(dgl_5500_a1_mdio0_info,
9087 + ARRAY_SIZE(dgl_5500_a1_mdio0_info));
9089 + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
9091 + /* GMAC1 is connected to an AR8327N switch via the SMGII interface */
9092 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
9093 + ath79_eth1_data.phy_mask = BIT(0);
9094 + ath79_eth1_data.mii_bus_dev = &ath79_mdio0_device.dev;
9096 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
9098 + ath79_register_eth(1);
9100 + ath79_register_usb();
9101 + ath79_register_pci();
9104 +MIPS_MACHINE(ATH79_MACH_DGL_5500_A1, "DGL-5500-A1", "D-Link DGL-5500 rev. A1",
9105 + dgl_5500_a1_setup);
9106 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dhp-1565-a1.c linux-4.1.43/arch/mips/ath79/mach-dhp-1565-a1.c
9107 --- linux-4.1.43.orig/arch/mips/ath79/mach-dhp-1565-a1.c 1970-01-01 01:00:00.000000000 +0100
9108 +++ linux-4.1.43/arch/mips/ath79/mach-dhp-1565-a1.c 2017-08-06 20:02:15.000000000 +0200
9109 @@ -0,0 +1,170 @@
9111 + * D-Link DHP-1565 rev. A1 board support
9113 + * Copyright (C) 2014 Jacek Kikiewicz
9115 + * This program is free software; you can redistribute it and/or modify it
9116 + * under the terms of the GNU General Public License version 2 as published
9117 + * by the Free Software Foundation.
9118 + */
9120 +#include <linux/pci.h>
9121 +#include <linux/phy.h>
9122 +#include <linux/gpio.h>
9123 +#include <linux/platform_device.h>
9124 +#include <linux/ath9k_platform.h>
9125 +#include <linux/ar8216_platform.h>
9127 +#include <asm/mach-ath79/ar71xx_regs.h>
9129 +#include "common.h"
9130 +#include "dev-ap9x-pci.h"
9131 +#include "dev-eth.h"
9132 +#include "dev-gpio-buttons.h"
9133 +#include "dev-leds-gpio.h"
9134 +#include "dev-m25p80.h"
9135 +#include "dev-spi.h"
9136 +#include "dev-usb.h"
9137 +#include "dev-wmac.h"
9138 +#include "machtypes.h"
9140 +#define DHP1565A1_GPIO_LED_BLUE_USB 11
9141 +#define DHP1565A1_GPIO_LED_AMBER_POWER 14
9142 +#define DHP1565A1_GPIO_LED_BLUE_POWER 22
9143 +#define DHP1565A1_GPIO_LED_BLUE_WPS 15
9144 +#define DHP1565A1_GPIO_LED_AMBER_PLANET 19
9145 +#define DHP1565A1_GPIO_LED_BLUE_PLANET 18
9146 +#define DHP1565A1_GPIO_LED_WLAN_2G 13
9148 +#define DHP1565A1_GPIO_WAN_LED_ENABLE 20
9150 +#define DHP1565A1_GPIO_BTN_RESET 17
9151 +#define DHP1565A1_GPIO_BTN_WPS 16
9153 +#define DHP1565A1_KEYS_POLL_INTERVAL 20 /* msecs */
9154 +#define DHP1565A1_KEYS_DEBOUNCE_INTERVAL (3 * DHP1565A1_KEYS_POLL_INTERVAL)
9156 +#define DHP1565A1_MAC0_OFFSET 0xFFA0
9157 +#define DHP1565A1_MAC1_OFFSET 0xFFB4
9158 +#define DHP1565A1_WMAC0_OFFSET 0x5
9159 +#define DHP1565A1_WMAC_CALDATA_OFFSET 0x1000
9160 +#define DHP1565A1_PCIE_CALDATA_OFFSET 0x5000
9162 +static struct gpio_led dhp1565a1_leds_gpio[] __initdata = {
9164 + .name = "d-link:amber:power",
9165 + .gpio = DHP1565A1_GPIO_LED_AMBER_POWER,
9166 + .active_low = 1,
9167 + },
9169 + .name = "d-link:green:power",
9170 + .gpio = DHP1565A1_GPIO_LED_BLUE_POWER,
9171 + .active_low = 1,
9172 + },
9174 + .name = "d-link:amber:planet",
9175 + .gpio = DHP1565A1_GPIO_LED_AMBER_PLANET,
9176 + .active_low = 1,
9177 + },
9179 + .name = "d-link:green:planet",
9180 + .gpio = DHP1565A1_GPIO_LED_BLUE_PLANET,
9181 + .active_low = 1,
9182 + },
9185 +static struct gpio_keys_button dhp1565a1_gpio_keys[] __initdata = {
9187 + .desc = "Soft reset",
9188 + .type = EV_KEY,
9189 + .code = KEY_RESTART,
9190 + .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
9191 + .gpio = DHP1565A1_GPIO_BTN_RESET,
9192 + .active_low = 1,
9193 + },
9195 + .desc = "WPS button",
9196 + .type = EV_KEY,
9197 + .code = KEY_WPS_BUTTON,
9198 + .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
9199 + .gpio = DHP1565A1_GPIO_BTN_WPS,
9200 + .active_low = 1,
9201 + },
9204 +static struct ar8327_pad_cfg dhp1565a1_ar8327_pad0_cfg = {
9205 + .mode = AR8327_PAD_MAC_RGMII,
9206 + .txclk_delay_en = true,
9207 + .rxclk_delay_en = true,
9208 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
9209 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
9212 +static struct ar8327_platform_data dhp1565a1_ar8327_data = {
9213 + .pad0_cfg = &dhp1565a1_ar8327_pad0_cfg,
9214 + .port0_cfg = {
9215 + .force_link = 1,
9216 + .speed = AR8327_PORT_SPEED_1000,
9217 + .duplex = 1,
9218 + .txpause = 1,
9219 + .rxpause = 1,
9220 + },
9223 +static struct mdio_board_info dhp1565a1_mdio0_info[] = {
9225 + .bus_id = "ag71xx-mdio.0",
9226 + .phy_addr = 0,
9227 + .platform_data = &dhp1565a1_ar8327_data,
9228 + },
9231 +static void __init dhp1565a1_generic_setup(void)
9233 + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
9234 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
9235 + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
9236 + u8 wmac0[ETH_ALEN];
9238 + ath79_parse_ascii_mac(mac + DHP1565A1_MAC0_OFFSET, mac0);
9239 + ath79_parse_ascii_mac(mac + DHP1565A1_MAC1_OFFSET, mac1);
9241 + ath79_register_m25p80(NULL);
9243 + ath79_register_gpio_keys_polled(-1, DHP1565A1_KEYS_POLL_INTERVAL,
9244 + ARRAY_SIZE(dhp1565a1_gpio_keys),
9245 + dhp1565a1_gpio_keys);
9247 + ath79_init_mac(wmac0, mac0, 0);
9248 + ath79_register_wmac(art + DHP1565A1_WMAC_CALDATA_OFFSET, wmac0);
9250 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
9252 + mdiobus_register_board_info(dhp1565a1_mdio0_info,
9253 + ARRAY_SIZE(dhp1565a1_mdio0_info));
9255 + ath79_register_mdio(0, 0x0);
9257 + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 1);
9259 + /* GMAC0 is connected to an AR8327N switch */
9260 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
9261 + ath79_eth0_data.phy_mask = BIT(0);
9262 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
9263 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
9264 + ath79_register_eth(0);
9266 + ath79_register_usb();
9269 +static void __init dhp1565a1_setup(void)
9271 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dhp1565a1_leds_gpio),
9272 + dhp1565a1_leds_gpio);
9274 + dhp1565a1_generic_setup();
9277 +MIPS_MACHINE(ATH79_MACH_DHP_1565_A1, "DHP-1565-A1",
9278 + "D-Link DHP-1565 rev. A1",
9279 + dhp1565a1_setup);
9280 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-505-a1.c linux-4.1.43/arch/mips/ath79/mach-dir-505-a1.c
9281 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-505-a1.c 1970-01-01 01:00:00.000000000 +0100
9282 +++ linux-4.1.43/arch/mips/ath79/mach-dir-505-a1.c 2017-08-06 20:02:15.000000000 +0200
9283 @@ -0,0 +1,116 @@
9285 + * DLink DIR-505 A1 board support
9287 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
9289 + * This program is free software; you can redistribute it and/or modify it
9290 + * under the terms of the GNU General Public License version 2 as published
9291 + * by the Free Software Foundation.
9292 + */
9294 +#include <linux/gpio.h>
9296 +#include <asm/mach-ath79/ath79.h>
9297 +#include <asm/mach-ath79/ar71xx_regs.h>
9299 +#include "common.h"
9300 +#include "dev-eth.h"
9301 +#include "dev-gpio-buttons.h"
9302 +#include "dev-leds-gpio.h"
9303 +#include "dev-m25p80.h"
9304 +#include "dev-wmac.h"
9305 +#include "dev-usb.h"
9306 +#include "machtypes.h"
9308 +#define DIR_505A1_GPIO_BTN_WPS 11 /* verify */
9309 +#define DIR_505A1_GPIO_BTN_RESET 12 /* verify */
9311 +#define DIR_505A1_GPIO_LED_RED 26 /* unused, fyi */
9312 +#define DIR_505A1_GPIO_LED_GREEN 27
9314 +#define DIR_505A1_GPIO_WAN_LED_ENABLE 1
9316 +#define DIR_505A1_KEYS_POLL_INTERVAL 20 /* msecs */
9317 +#define DIR_505A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_505A1_KEYS_POLL_INTERVAL)
9319 +#define DIR_505A1_ART_ADDRESS 0x1f010000
9320 +#define DIR_505A1_CALDATA_OFFSET 0x1000
9322 +#define DIR_505A1_MAC_PART_ADDRESS 0x1f020000
9323 +#define DIR_505A1_LAN_MAC_OFFSET 0x04
9324 +#define DIR_505A1_WAN_MAC_OFFSET 0x16
9326 +static struct gpio_led dir_505_a1_leds_gpio[] __initdata = {
9328 + .name = "d-link:green:power",
9329 + .gpio = DIR_505A1_GPIO_LED_GREEN,
9330 + .active_low = 1,
9331 + }, {
9332 + .name = "d-link:red:status",
9333 + .gpio = DIR_505A1_GPIO_LED_RED,
9334 + .active_low = 1,
9335 + },
9338 +static struct gpio_keys_button dir_505_a1_gpio_keys[] __initdata = {
9340 + .desc = "Reset button",
9341 + .type = EV_KEY,
9342 + .code = KEY_RESTART,
9343 + .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
9344 + .gpio = DIR_505A1_GPIO_BTN_RESET,
9345 + .active_low = 0,
9346 + }, {
9347 + .desc = "WPS button",
9348 + .type = EV_KEY,
9349 + .code = KEY_WPS_BUTTON,
9350 + .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
9351 + .gpio = DIR_505A1_GPIO_BTN_WPS,
9352 + .active_low = 1,
9356 +static void __init dir_505_a1_setup(void)
9358 + u8 *art = (u8 *) KSEG1ADDR(DIR_505A1_ART_ADDRESS);
9359 + u8 *mac = (u8 *) KSEG1ADDR(DIR_505A1_MAC_PART_ADDRESS);
9360 + u8 lan_mac[ETH_ALEN];
9361 + u8 wan_mac[ETH_ALEN];
9363 + ath79_setup_ar933x_phy4_switch(false, false);
9365 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
9366 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
9367 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
9368 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
9369 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
9371 + gpio_request_one(DIR_505A1_GPIO_WAN_LED_ENABLE,
9372 + GPIOF_OUT_INIT_LOW, "WAN LED enable");
9374 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_505_a1_leds_gpio),
9375 + dir_505_a1_leds_gpio);
9377 + ath79_register_gpio_keys_polled(1, DIR_505A1_KEYS_POLL_INTERVAL,
9378 + ARRAY_SIZE(dir_505_a1_gpio_keys),
9379 + dir_505_a1_gpio_keys);
9381 + ath79_register_m25p80(NULL);
9383 + ath79_register_usb();
9385 + ath79_parse_ascii_mac(mac + DIR_505A1_LAN_MAC_OFFSET, lan_mac);
9386 + ath79_parse_ascii_mac(mac + DIR_505A1_WAN_MAC_OFFSET, wan_mac);
9388 + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
9389 + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
9391 + ath79_register_mdio(0, 0x0);
9392 + ath79_register_eth(1);
9393 + ath79_register_eth(0);
9395 + ath79_register_wmac(art + DIR_505A1_CALDATA_OFFSET, lan_mac);
9398 +MIPS_MACHINE(ATH79_MACH_DIR_505_A1, "DIR-505-A1",
9399 + "D-Link DIR-505 rev. A1", dir_505_a1_setup);
9400 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-600-a1.c linux-4.1.43/arch/mips/ath79/mach-dir-600-a1.c
9401 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-600-a1.c 1970-01-01 01:00:00.000000000 +0100
9402 +++ linux-4.1.43/arch/mips/ath79/mach-dir-600-a1.c 2017-08-06 20:02:15.000000000 +0200
9403 @@ -0,0 +1,159 @@
9405 + * D-Link DIR-600 rev. A1 board support
9407 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
9408 + * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
9410 + * This program is free software; you can redistribute it and/or modify it
9411 + * under the terms of the GNU General Public License version 2 as published
9412 + * by the Free Software Foundation.
9413 + */
9415 +#include <asm/mach-ath79/ath79.h>
9416 +#include <asm/mach-ath79/ar71xx_regs.h>
9418 +#include "common.h"
9419 +#include "dev-ap9x-pci.h"
9420 +#include "dev-eth.h"
9421 +#include "dev-gpio-buttons.h"
9422 +#include "dev-leds-gpio.h"
9423 +#include "dev-m25p80.h"
9424 +#include "machtypes.h"
9425 +#include "nvram.h"
9427 +#define DIR_600_A1_GPIO_LED_WPS 0
9428 +#define DIR_600_A1_GPIO_LED_POWER_AMBER 1
9429 +#define DIR_600_A1_GPIO_LED_POWER_GREEN 6
9430 +#define DIR_600_A1_GPIO_LED_LAN1 13
9431 +#define DIR_600_A1_GPIO_LED_LAN2 14
9432 +#define DIR_600_A1_GPIO_LED_LAN3 15
9433 +#define DIR_600_A1_GPIO_LED_LAN4 16
9434 +#define DIR_600_A1_GPIO_LED_WAN_AMBER 7
9435 +#define DIR_600_A1_GPIO_LED_WAN_GREEN 17
9437 +#define DIR_600_A1_GPIO_BTN_RESET 8
9438 +#define DIR_600_A1_GPIO_BTN_WPS 12
9440 +#define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
9441 +#define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
9443 +#define DIR_600_A1_NVRAM_ADDR 0x1f030000
9444 +#define DIR_600_A1_NVRAM_SIZE 0x10000
9446 +static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
9448 + .name = "d-link:green:power",
9449 + .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
9450 + }, {
9451 + .name = "d-link:amber:power",
9452 + .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
9453 + }, {
9454 + .name = "d-link:amber:wan",
9455 + .gpio = DIR_600_A1_GPIO_LED_WAN_AMBER,
9456 + }, {
9457 + .name = "d-link:green:wan",
9458 + .gpio = DIR_600_A1_GPIO_LED_WAN_GREEN,
9459 + .active_low = 1,
9460 + }, {
9461 + .name = "d-link:green:lan1",
9462 + .gpio = DIR_600_A1_GPIO_LED_LAN1,
9463 + .active_low = 1,
9464 + }, {
9465 + .name = "d-link:green:lan2",
9466 + .gpio = DIR_600_A1_GPIO_LED_LAN2,
9467 + .active_low = 1,
9468 + }, {
9469 + .name = "d-link:green:lan3",
9470 + .gpio = DIR_600_A1_GPIO_LED_LAN3,
9471 + .active_low = 1,
9472 + }, {
9473 + .name = "d-link:green:lan4",
9474 + .gpio = DIR_600_A1_GPIO_LED_LAN4,
9475 + .active_low = 1,
9476 + }, {
9477 + .name = "d-link:blue:wps",
9478 + .gpio = DIR_600_A1_GPIO_LED_WPS,
9479 + .active_low = 1,
9483 +static struct gpio_keys_button dir_600_a1_gpio_keys[] __initdata = {
9485 + .desc = "reset",
9486 + .type = EV_KEY,
9487 + .code = KEY_RESTART,
9488 + .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
9489 + .gpio = DIR_600_A1_GPIO_BTN_RESET,
9490 + .active_low = 1,
9491 + }, {
9492 + .desc = "wps",
9493 + .type = EV_KEY,
9494 + .code = KEY_WPS_BUTTON,
9495 + .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
9496 + .gpio = DIR_600_A1_GPIO_BTN_WPS,
9497 + .active_low = 1,
9501 +static void __init dir_600_a1_setup(void)
9503 + const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
9504 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
9505 + u8 mac_buff[6];
9506 + u8 *mac = NULL;
9508 + if (ath79_nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
9509 + "lan_mac=", mac_buff) == 0) {
9510 + ath79_init_mac(ath79_eth0_data.mac_addr, mac_buff, 0);
9511 + ath79_init_mac(ath79_eth1_data.mac_addr, mac_buff, 1);
9512 + mac = mac_buff;
9515 + ath79_register_m25p80(NULL);
9517 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
9518 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
9519 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
9520 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
9521 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
9523 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
9524 + dir_600_a1_leds_gpio);
9526 + ath79_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL,
9527 + ARRAY_SIZE(dir_600_a1_gpio_keys),
9528 + dir_600_a1_gpio_keys);
9530 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
9531 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
9533 + ath79_register_mdio(0, 0x0);
9535 + /* LAN ports */
9536 + ath79_register_eth(1);
9538 + /* WAN port */
9539 + ath79_register_eth(0);
9541 + ap91_pci_init(ee, mac);
9544 +MIPS_MACHINE(ATH79_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
9545 + dir_600_a1_setup);
9547 +static void __init dir_615_e1_setup(void)
9549 + dir_600_a1_setup();
9552 +MIPS_MACHINE(ATH79_MACH_DIR_615_E1, "DIR-615-E1", "D-Link DIR-615 rev. E1",
9553 + dir_615_e1_setup);
9555 +static void __init dir_615_e4_setup(void)
9557 + dir_600_a1_setup();
9558 + ap9x_pci_setup_wmac_led_pin(0, 1);
9561 +MIPS_MACHINE(ATH79_MACH_DIR_615_E4, "DIR-615-E4", "D-Link DIR-615 rev. E4",
9562 + dir_615_e4_setup);
9563 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-615-c1.c linux-4.1.43/arch/mips/ath79/mach-dir-615-c1.c
9564 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-615-c1.c 1970-01-01 01:00:00.000000000 +0100
9565 +++ linux-4.1.43/arch/mips/ath79/mach-dir-615-c1.c 2017-08-06 20:02:15.000000000 +0200
9566 @@ -0,0 +1,135 @@
9568 + * D-Link DIR-615 rev C1 board support
9570 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
9571 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
9573 + * This program is free software; you can redistribute it and/or modify it
9574 + * under the terms of the GNU General Public License version 2 as published
9575 + * by the Free Software Foundation.
9576 + */
9578 +#include <asm/mach-ath79/ath79.h>
9580 +#include "dev-eth.h"
9581 +#include "dev-gpio-buttons.h"
9582 +#include "dev-leds-gpio.h"
9583 +#include "dev-m25p80.h"
9584 +#include "dev-wmac.h"
9585 +#include "machtypes.h"
9586 +#include "nvram.h"
9588 +#define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
9589 +#define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
9590 +#define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
9591 +#define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
9592 +#define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
9593 +#define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
9594 +#define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
9596 +/* buttons may need refinement */
9598 +#define DIR_615C1_GPIO_BTN_WPS 12
9599 +#define DIR_615C1_GPIO_BTN_RESET 21
9601 +#define DIR_615C1_KEYS_POLL_INTERVAL 20 /* msecs */
9602 +#define DIR_615C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615C1_KEYS_POLL_INTERVAL)
9604 +#define DIR_615C1_CONFIG_ADDR 0x1f020000
9605 +#define DIR_615C1_CONFIG_SIZE 0x10000
9607 +#define DIR_615C1_WLAN_MAC_ADDR 0x1f3fffb4
9609 +static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
9611 + .name = "d-link:orange:status",
9612 + .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
9613 + .active_low = 1,
9614 + }, {
9615 + .name = "d-link:blue:wps",
9616 + .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
9617 + .active_low = 1,
9618 + }, {
9619 + .name = "d-link:green:wan",
9620 + .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
9621 + .active_low = 1,
9622 + }, {
9623 + .name = "d-link:green:wancpu",
9624 + .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
9625 + .active_low = 1,
9626 + }, {
9627 + .name = "d-link:green:wlan",
9628 + .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
9629 + .active_low = 1,
9630 + }, {
9631 + .name = "d-link:green:status",
9632 + .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
9633 + .active_low = 1,
9634 + }, {
9635 + .name = "d-link:orange:wan",
9636 + .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
9637 + .active_low = 1,
9642 +static struct gpio_keys_button dir_615c1_gpio_keys[] __initdata = {
9644 + .desc = "reset",
9645 + .type = EV_KEY,
9646 + .code = KEY_RESTART,
9647 + .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
9648 + .gpio = DIR_615C1_GPIO_BTN_RESET,
9649 + }, {
9650 + .desc = "wps",
9651 + .type = EV_KEY,
9652 + .code = KEY_WPS_BUTTON,
9653 + .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
9654 + .gpio = DIR_615C1_GPIO_BTN_WPS,
9658 +#define DIR_615C1_LAN_PHYMASK BIT(0)
9659 +#define DIR_615C1_WAN_PHYMASK BIT(4)
9660 +#define DIR_615C1_MDIO_MASK (~(DIR_615C1_LAN_PHYMASK | \
9661 + DIR_615C1_WAN_PHYMASK))
9663 +static void __init dir_615c1_setup(void)
9665 + const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
9666 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
9667 + u8 mac[ETH_ALEN], wlan_mac[ETH_ALEN];
9669 + if (ath79_nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
9670 + "lan_mac=", mac) == 0) {
9671 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
9672 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
9675 + ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615C1_WLAN_MAC_ADDR), wlan_mac);
9677 + ath79_register_mdio(0, DIR_615C1_MDIO_MASK);
9679 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
9680 + ath79_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
9682 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
9683 + ath79_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
9685 + ath79_register_eth(0);
9686 + ath79_register_eth(1);
9688 + ath79_register_m25p80(NULL);
9690 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
9691 + dir_615c1_leds_gpio);
9693 + ath79_register_gpio_keys_polled(-1, DIR_615C1_KEYS_POLL_INTERVAL,
9694 + ARRAY_SIZE(dir_615c1_gpio_keys),
9695 + dir_615c1_gpio_keys);
9697 + ath79_register_wmac(eeprom, wlan_mac);
9700 +MIPS_MACHINE(ATH79_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
9701 + dir_615c1_setup);
9702 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-615-i1.c linux-4.1.43/arch/mips/ath79/mach-dir-615-i1.c
9703 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-615-i1.c 1970-01-01 01:00:00.000000000 +0100
9704 +++ linux-4.1.43/arch/mips/ath79/mach-dir-615-i1.c 2017-08-06 20:02:15.000000000 +0200
9705 @@ -0,0 +1,133 @@
9707 + * D-Link DIR-615 rev. I1 board support
9708 + * Copyright (C) 2013-2015 Jaehoon You <teslamint@gmail.com>
9710 + * based on the DIR-600 rev. A1 board support code
9711 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
9712 + * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
9714 + * based on the TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support code
9715 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
9717 + * This program is free software; you can redistribute it and/or modify it
9718 + * under the terms of the GNU General Public License version 2 as published
9719 + * by the Free Software Foundation.
9720 + */
9722 +#include <linux/platform_device.h>
9724 +#include <asm/mach-ath79/ath79.h>
9725 +#include <asm/mach-ath79/ar71xx_regs.h>
9727 +#include "common.h"
9728 +#include "dev-eth.h"
9729 +#include "dev-gpio-buttons.h"
9730 +#include "dev-leds-gpio.h"
9731 +#include "dev-m25p80.h"
9732 +#include "dev-wmac.h"
9733 +#include "machtypes.h"
9735 +#define DIR_615_I1_GPIO_LED_WPS 15
9736 +#define DIR_615_I1_GPIO_LED_POWER_AMBER 14
9737 +#define DIR_615_I1_GPIO_LED_POWER_GREEN 4
9738 +#define DIR_615_I1_GPIO_LED_WAN_AMBER 22
9739 +#define DIR_615_I1_GPIO_LED_WAN_GREEN 12
9740 +#define DIR_615_I1_GPIO_LED_WLAN_GREEN 13
9742 +#define DIR_615_I1_GPIO_BTN_WPS 16
9743 +#define DIR_615_I1_GPIO_BTN_RESET 17
9745 +#define DIR_615_I1_KEYS_POLL_INTERVAL 20 /* msecs */
9746 +#define DIR_615_I1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_I1_KEYS_POLL_INTERVAL)
9748 +#define DIR_615_I1_LAN_PHYMASK BIT(0)
9749 +#define DIR_615_I1_WAN_PHYMASK BIT(4)
9750 +#define DIR_615_I1_WLAN_MAC_ADDR 0x1fffffb4
9752 +static struct gpio_led dir_615_i1_leds_gpio[] __initdata = {
9754 + .name = "d-link:green:power",
9755 + .gpio = DIR_615_I1_GPIO_LED_POWER_GREEN,
9756 + }, {
9757 + .name = "d-link:amber:power",
9758 + .gpio = DIR_615_I1_GPIO_LED_POWER_AMBER,
9759 + }, {
9760 + .name = "d-link:amber:wan",
9761 + .gpio = DIR_615_I1_GPIO_LED_WAN_AMBER,
9762 + }, {
9763 + .name = "d-link:green:wan",
9764 + .gpio = DIR_615_I1_GPIO_LED_WAN_GREEN,
9765 + .active_low = 1,
9766 + }, {
9767 + .name = "d-link:green:wlan",
9768 + .gpio = DIR_615_I1_GPIO_LED_WLAN_GREEN,
9769 + .active_low = 1,
9770 + }, {
9771 + .name = "d-link:blue:wps",
9772 + .gpio = DIR_615_I1_GPIO_LED_WPS,
9773 + .active_low = 1,
9777 +static struct gpio_keys_button dir_615_i1_gpio_keys[] __initdata = {
9779 + .desc = "reset",
9780 + .type = EV_KEY,
9781 + .code = KEY_RESTART,
9782 + .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
9783 + .gpio = DIR_615_I1_GPIO_BTN_RESET,
9784 + .active_low = 1,
9785 + }, {
9786 + .desc = "wps",
9787 + .type = EV_KEY,
9788 + .code = KEY_WPS_BUTTON,
9789 + .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
9790 + .gpio = DIR_615_I1_GPIO_BTN_WPS,
9791 + .active_low = 1,
9795 +static void __init dir_615_i1_setup(void)
9797 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
9798 + u8 mac[ETH_ALEN];
9800 + ath79_register_mdio(0, 0x0);
9801 + ath79_register_mdio(1, ~(DIR_615_I1_WAN_PHYMASK));
9803 + ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615_I1_WLAN_MAC_ADDR), mac);
9804 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
9805 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
9807 + /* GMAC0 is connected to the PHY0 of the internal switch */
9808 + ath79_switch_data.phy4_mii_en = 1;
9809 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
9810 + ath79_eth0_data.phy_mask = DIR_615_I1_WAN_PHYMASK;
9811 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
9813 + /* GMAC1 is connected to the internal switch */
9814 + ath79_eth1_data.phy_mask = DIR_615_I1_LAN_PHYMASK;
9815 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
9817 + ath79_register_eth(0);
9818 + ath79_register_eth(1);
9820 + ath79_register_m25p80(NULL);
9822 + /* Disable JTAG, enabling GPIOs 0-3 */
9823 + /* Configure OBS4 line, for GPIO 4*/
9824 + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
9825 + AR934X_GPIO_FUNC_CLK_OBS4_EN);
9827 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615_i1_leds_gpio),
9828 + dir_615_i1_leds_gpio);
9830 + ath79_register_gpio_keys_polled(-1, DIR_615_I1_KEYS_POLL_INTERVAL,
9831 + ARRAY_SIZE(dir_615_i1_gpio_keys),
9832 + dir_615_i1_gpio_keys);
9834 + ath79_register_wmac(eeprom, mac);
9837 +MIPS_MACHINE(ATH79_MACH_DIR_615_I1, "DIR-615-I1", "D-Link DIR-615 rev. I1",
9838 + dir_615_i1_setup);
9839 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-825-b1.c linux-4.1.43/arch/mips/ath79/mach-dir-825-b1.c
9840 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-825-b1.c 1970-01-01 01:00:00.000000000 +0100
9841 +++ linux-4.1.43/arch/mips/ath79/mach-dir-825-b1.c 2017-08-06 20:02:15.000000000 +0200
9842 @@ -0,0 +1,191 @@
9844 + * D-Link DIR-825 rev. B1 board support
9846 + * Copyright (C) 2009-2011 Lukas Kuna, Evkanet, s.r.o.
9848 + * based on mach-wndr3700.c
9850 + * This program is free software; you can redistribute it and/or modify it
9851 + * under the terms of the GNU General Public License version 2 as published
9852 + * by the Free Software Foundation.
9853 + */
9855 +#include <linux/platform_device.h>
9856 +#include <linux/delay.h>
9857 +#include <linux/rtl8366.h>
9859 +#include <asm/mach-ath79/ath79.h>
9861 +#include "dev-eth.h"
9862 +#include "dev-ap9x-pci.h"
9863 +#include "dev-gpio-buttons.h"
9864 +#include "dev-leds-gpio.h"
9865 +#include "dev-m25p80.h"
9866 +#include "dev-usb.h"
9867 +#include "machtypes.h"
9869 +#define DIR825B1_GPIO_LED_BLUE_USB 0
9870 +#define DIR825B1_GPIO_LED_ORANGE_POWER 1
9871 +#define DIR825B1_GPIO_LED_BLUE_POWER 2
9872 +#define DIR825B1_GPIO_LED_BLUE_WPS 4
9873 +#define DIR825B1_GPIO_LED_ORANGE_PLANET 6
9874 +#define DIR825B1_GPIO_LED_BLUE_PLANET 11
9876 +#define DIR825B1_GPIO_BTN_RESET 3
9877 +#define DIR825B1_GPIO_BTN_WPS 8
9879 +#define DIR825B1_GPIO_RTL8366_SDA 5
9880 +#define DIR825B1_GPIO_RTL8366_SCK 7
9882 +#define DIR825B1_KEYS_POLL_INTERVAL 20 /* msecs */
9883 +#define DIR825B1_KEYS_DEBOUNCE_INTERVAL (3 * DIR825B1_KEYS_POLL_INTERVAL)
9885 +#define DIR825B1_CAL0_OFFSET 0x1000
9886 +#define DIR825B1_CAL1_OFFSET 0x5000
9887 +#define DIR825B1_MAC0_OFFSET 0xffa0
9888 +#define DIR825B1_MAC1_OFFSET 0xffb4
9890 +#define DIR825B1_CAL_LOCATION_0 0x1f660000
9891 +#define DIR825B1_CAL_LOCATION_1 0x1f7f0000
9893 +static struct gpio_led dir825b1_leds_gpio[] __initdata = {
9895 + .name = "d-link:blue:usb",
9896 + .gpio = DIR825B1_GPIO_LED_BLUE_USB,
9897 + .active_low = 1,
9898 + }, {
9899 + .name = "d-link:orange:power",
9900 + .gpio = DIR825B1_GPIO_LED_ORANGE_POWER,
9901 + .active_low = 1,
9902 + }, {
9903 + .name = "d-link:blue:power",
9904 + .gpio = DIR825B1_GPIO_LED_BLUE_POWER,
9905 + .active_low = 1,
9906 + }, {
9907 + .name = "d-link:blue:wps",
9908 + .gpio = DIR825B1_GPIO_LED_BLUE_WPS,
9909 + .active_low = 1,
9910 + }, {
9911 + .name = "d-link:orange:planet",
9912 + .gpio = DIR825B1_GPIO_LED_ORANGE_PLANET,
9913 + .active_low = 1,
9914 + }, {
9915 + .name = "d-link:blue:planet",
9916 + .gpio = DIR825B1_GPIO_LED_BLUE_PLANET,
9917 + .active_low = 1,
9921 +static struct gpio_keys_button dir825b1_gpio_keys[] __initdata = {
9923 + .desc = "reset",
9924 + .type = EV_KEY,
9925 + .code = KEY_RESTART,
9926 + .debounce_interval = DIR825B1_KEYS_DEBOUNCE_INTERVAL,
9927 + .gpio = DIR825B1_GPIO_BTN_RESET,
9928 + .active_low = 1,
9929 + }, {
9930 + .desc = "wps",
9931 + .type = EV_KEY,
9932 + .code = KEY_WPS_BUTTON,
9933 + .debounce_interval = DIR825B1_KEYS_DEBOUNCE_INTERVAL,
9934 + .gpio = DIR825B1_GPIO_BTN_WPS,
9935 + .active_low = 1,
9939 +static struct rtl8366_initval dir825b1_rtl8366s_initvals[] = {
9940 + { .reg = 0x06, .val = 0x0108 },
9943 +static struct rtl8366_platform_data dir825b1_rtl8366s_data = {
9944 + .gpio_sda = DIR825B1_GPIO_RTL8366_SDA,
9945 + .gpio_sck = DIR825B1_GPIO_RTL8366_SCK,
9946 + .num_initvals = ARRAY_SIZE(dir825b1_rtl8366s_initvals),
9947 + .initvals = dir825b1_rtl8366s_initvals,
9950 +static struct platform_device dir825b1_rtl8366s_device = {
9951 + .name = RTL8366S_DRIVER_NAME,
9952 + .id = -1,
9953 + .dev = {
9954 + .platform_data = &dir825b1_rtl8366s_data,
9958 +static bool __init dir825b1_is_caldata_valid(u8 *p)
9960 + u16 *magic0, *magic1;
9962 + magic0 = (u16 *)(p + DIR825B1_CAL0_OFFSET);
9963 + magic1 = (u16 *)(p + DIR825B1_CAL1_OFFSET);
9965 + return (*magic0 == 0xa55a && *magic1 == 0xa55a);
9968 +static void __init dir825b1_wlan_init(void)
9970 + u8 *caldata;
9971 + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
9972 + u8 wmac0[ETH_ALEN], wmac1[ETH_ALEN];
9974 + caldata = (u8 *) KSEG1ADDR(DIR825B1_CAL_LOCATION_0);
9975 + if (!dir825b1_is_caldata_valid(caldata)) {
9976 + caldata = (u8 *)KSEG1ADDR(DIR825B1_CAL_LOCATION_1);
9977 + if (!dir825b1_is_caldata_valid(caldata)) {
9978 + pr_err("no calibration data found\n");
9979 + return;
9983 + ath79_parse_ascii_mac(caldata + DIR825B1_MAC0_OFFSET, mac0);
9984 + ath79_parse_ascii_mac(caldata + DIR825B1_MAC1_OFFSET, mac1);
9986 + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
9987 + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 0);
9988 + ath79_init_mac(wmac0, mac0, 0);
9989 + ath79_init_mac(wmac1, mac1, 1);
9991 + ap9x_pci_setup_wmac_led_pin(0, 5);
9992 + ap9x_pci_setup_wmac_led_pin(1, 5);
9994 + ap94_pci_init(caldata + DIR825B1_CAL0_OFFSET, wmac0,
9995 + caldata + DIR825B1_CAL1_OFFSET, wmac1);
9998 +static void __init dir825b1_setup(void)
10000 + dir825b1_wlan_init();
10002 + ath79_register_mdio(0, 0x0);
10004 + ath79_eth0_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
10005 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
10006 + ath79_eth0_data.speed = SPEED_1000;
10007 + ath79_eth0_data.duplex = DUPLEX_FULL;
10008 + ath79_eth0_pll_data.pll_1000 = 0x11110000;
10010 + ath79_eth1_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
10011 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
10012 + ath79_eth1_data.phy_mask = 0x10;
10013 + ath79_eth1_pll_data.pll_1000 = 0x11110000;
10015 + ath79_register_eth(0);
10016 + ath79_register_eth(1);
10018 + ath79_register_m25p80(NULL);
10020 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir825b1_leds_gpio),
10021 + dir825b1_leds_gpio);
10023 + ath79_register_gpio_keys_polled(-1, DIR825B1_KEYS_POLL_INTERVAL,
10024 + ARRAY_SIZE(dir825b1_gpio_keys),
10025 + dir825b1_gpio_keys);
10027 + ath79_register_usb();
10029 + platform_device_register(&dir825b1_rtl8366s_device);
10032 +MIPS_MACHINE(ATH79_MACH_DIR_825_B1, "DIR-825-B1", "D-Link DIR-825 rev. B1",
10033 + dir825b1_setup);
10034 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dir-825-c1.c linux-4.1.43/arch/mips/ath79/mach-dir-825-c1.c
10035 --- linux-4.1.43.orig/arch/mips/ath79/mach-dir-825-c1.c 1970-01-01 01:00:00.000000000 +0100
10036 +++ linux-4.1.43/arch/mips/ath79/mach-dir-825-c1.c 2017-08-06 20:02:15.000000000 +0200
10037 @@ -0,0 +1,241 @@
10039 + * D-Link DIR-825 rev. C1 board support
10041 + * Copyright (C) 2013 Alexander Stadler
10043 + * This program is free software; you can redistribute it and/or modify it
10044 + * under the terms of the GNU General Public License version 2 as published
10045 + * by the Free Software Foundation.
10046 + */
10048 +#include <linux/pci.h>
10049 +#include <linux/phy.h>
10050 +#include <linux/gpio.h>
10051 +#include <linux/platform_device.h>
10052 +#include <linux/ath9k_platform.h>
10053 +#include <linux/ar8216_platform.h>
10055 +#include <asm/mach-ath79/ar71xx_regs.h>
10057 +#include "common.h"
10058 +#include "dev-ap9x-pci.h"
10059 +#include "dev-eth.h"
10060 +#include "dev-gpio-buttons.h"
10061 +#include "dev-leds-gpio.h"
10062 +#include "dev-m25p80.h"
10063 +#include "dev-spi.h"
10064 +#include "dev-usb.h"
10065 +#include "dev-wmac.h"
10066 +#include "machtypes.h"
10068 +#define DIR825C1_GPIO_LED_BLUE_USB 11
10069 +#define DIR825C1_GPIO_LED_AMBER_POWER 14
10070 +#define DIR825C1_GPIO_LED_BLUE_POWER 22
10071 +#define DIR825C1_GPIO_LED_BLUE_WPS 15
10072 +#define DIR825C1_GPIO_LED_AMBER_PLANET 19
10073 +#define DIR825C1_GPIO_LED_BLUE_PLANET 18
10074 +#define DIR825C1_GPIO_LED_WLAN_2G 13
10076 +#define DIR825C1_GPIO_WAN_LED_ENABLE 20
10078 +#define DIR825C1_GPIO_BTN_RESET 17
10079 +#define DIR825C1_GPIO_BTN_WPS 16
10081 +#define DIR825C1_KEYS_POLL_INTERVAL 20 /* msecs */
10082 +#define DIR825C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR825C1_KEYS_POLL_INTERVAL)
10084 +#define DIR825C1_MAC0_OFFSET 0x4
10085 +#define DIR825C1_MAC1_OFFSET 0x18
10086 +#define DIR825C1_WMAC_CALDATA_OFFSET 0x1000
10087 +#define DIR825C1_PCIE_CALDATA_OFFSET 0x5000
10089 +static struct gpio_led dir825c1_leds_gpio[] __initdata = {
10091 + .name = "d-link:blue:usb",
10092 + .gpio = DIR825C1_GPIO_LED_BLUE_USB,
10093 + .active_low = 1,
10094 + },
10096 + .name = "d-link:amber:power",
10097 + .gpio = DIR825C1_GPIO_LED_AMBER_POWER,
10098 + .active_low = 1,
10099 + },
10101 + .name = "d-link:blue:power",
10102 + .gpio = DIR825C1_GPIO_LED_BLUE_POWER,
10103 + .active_low = 1,
10104 + },
10106 + .name = "d-link:blue:wps",
10107 + .gpio = DIR825C1_GPIO_LED_BLUE_WPS,
10108 + .active_low = 1,
10109 + },
10111 + .name = "d-link:amber:planet",
10112 + .gpio = DIR825C1_GPIO_LED_AMBER_PLANET,
10113 + .active_low = 1,
10114 + },
10116 + .name = "d-link:blue:wlan2g",
10117 + .gpio = DIR825C1_GPIO_LED_WLAN_2G,
10118 + .active_low = 1,
10119 + },
10122 +static struct gpio_led dir835a1_leds_gpio[] __initdata = {
10124 + .name = "d-link:amber:power",
10125 + .gpio = DIR825C1_GPIO_LED_AMBER_POWER,
10126 + .active_low = 1,
10127 + },
10129 + .name = "d-link:green:power",
10130 + .gpio = DIR825C1_GPIO_LED_BLUE_POWER,
10131 + .active_low = 1,
10132 + },
10134 + .name = "d-link:blue:wps",
10135 + .gpio = DIR825C1_GPIO_LED_BLUE_WPS,
10136 + .active_low = 1,
10137 + },
10139 + .name = "d-link:amber:planet",
10140 + .gpio = DIR825C1_GPIO_LED_AMBER_PLANET,
10141 + .active_low = 1,
10142 + },
10144 + .name = "d-link:green:planet",
10145 + .gpio = DIR825C1_GPIO_LED_BLUE_PLANET,
10146 + .active_low = 1,
10147 + },
10150 +static struct gpio_keys_button dir825c1_gpio_keys[] __initdata = {
10152 + .desc = "Soft reset",
10153 + .type = EV_KEY,
10154 + .code = KEY_RESTART,
10155 + .debounce_interval = DIR825C1_KEYS_DEBOUNCE_INTERVAL,
10156 + .gpio = DIR825C1_GPIO_BTN_RESET,
10157 + .active_low = 1,
10158 + },
10160 + .desc = "WPS button",
10161 + .type = EV_KEY,
10162 + .code = KEY_WPS_BUTTON,
10163 + .debounce_interval = DIR825C1_KEYS_DEBOUNCE_INTERVAL,
10164 + .gpio = DIR825C1_GPIO_BTN_WPS,
10165 + .active_low = 1,
10166 + },
10169 +static struct ar8327_pad_cfg dir825c1_ar8327_pad0_cfg = {
10170 + .mode = AR8327_PAD_MAC_RGMII,
10171 + .txclk_delay_en = true,
10172 + .rxclk_delay_en = true,
10173 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
10174 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
10177 +static struct ar8327_led_cfg dir825c1_ar8327_led_cfg = {
10178 + .led_ctrl0 = 0x00000000,
10179 + .led_ctrl1 = 0xc737c737,
10180 + .led_ctrl2 = 0x00000000,
10181 + .led_ctrl3 = 0x00c30c00,
10182 + .open_drain = true,
10185 +static struct ar8327_platform_data dir825c1_ar8327_data = {
10186 + .pad0_cfg = &dir825c1_ar8327_pad0_cfg,
10187 + .port0_cfg = {
10188 + .force_link = 1,
10189 + .speed = AR8327_PORT_SPEED_1000,
10190 + .duplex = 1,
10191 + .txpause = 1,
10192 + .rxpause = 1,
10193 + },
10194 + .led_cfg = &dir825c1_ar8327_led_cfg,
10197 +static struct mdio_board_info dir825c1_mdio0_info[] = {
10199 + .bus_id = "ag71xx-mdio.0",
10200 + .phy_addr = 0,
10201 + .platform_data = &dir825c1_ar8327_data,
10202 + },
10205 +static void __init dir825c1_generic_setup(void)
10207 + u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
10208 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
10209 + u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
10210 + u8 wmac0[ETH_ALEN], wmac1[ETH_ALEN];
10212 + ath79_parse_ascii_mac(mac + DIR825C1_MAC0_OFFSET, mac0);
10213 + ath79_parse_ascii_mac(mac + DIR825C1_MAC1_OFFSET, mac1);
10215 + ath79_register_m25p80(NULL);
10217 + ath79_register_gpio_keys_polled(-1, DIR825C1_KEYS_POLL_INTERVAL,
10218 + ARRAY_SIZE(dir825c1_gpio_keys),
10219 + dir825c1_gpio_keys);
10221 + ath79_init_mac(wmac0, mac0, 0);
10222 + ath79_register_wmac(art + DIR825C1_WMAC_CALDATA_OFFSET, wmac0);
10224 + ath79_init_mac(wmac1, mac1, 1);
10225 + ap91_pci_init(art + DIR825C1_PCIE_CALDATA_OFFSET, wmac1);
10227 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
10229 + mdiobus_register_board_info(dir825c1_mdio0_info,
10230 + ARRAY_SIZE(dir825c1_mdio0_info));
10232 + ath79_register_mdio(0, 0x0);
10234 + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
10236 + /* GMAC0 is connected to an AR8327N switch */
10237 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
10238 + ath79_eth0_data.phy_mask = BIT(0);
10239 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
10240 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
10241 + ath79_register_eth(0);
10243 + ath79_register_usb();
10246 +static void __init dir825c1_setup(void)
10248 + ath79_gpio_output_select(DIR825C1_GPIO_LED_BLUE_USB,
10249 + AR934X_GPIO_OUT_GPIO);
10251 + gpio_request_one(DIR825C1_GPIO_WAN_LED_ENABLE,
10252 + GPIOF_OUT_INIT_LOW, "WAN LED enable");
10254 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir825c1_leds_gpio),
10255 + dir825c1_leds_gpio);
10257 + ap9x_pci_setup_wmac_led_pin(0, 0);
10259 + dir825c1_generic_setup();
10262 +static void __init dir835a1_setup(void)
10264 + dir825c1_ar8327_data.led_cfg = NULL;
10266 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dir835a1_leds_gpio),
10267 + dir835a1_leds_gpio);
10269 + dir825c1_generic_setup();
10272 +MIPS_MACHINE(ATH79_MACH_DIR_825_C1, "DIR-825-C1",
10273 + "D-Link DIR-825 rev. C1",
10274 + dir825c1_setup);
10276 +MIPS_MACHINE(ATH79_MACH_DIR_835_A1, "DIR-835-A1",
10277 + "D-Link DIR-835 rev. A1",
10278 + dir835a1_setup);
10279 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dlan-hotspot.c linux-4.1.43/arch/mips/ath79/mach-dlan-hotspot.c
10280 --- linux-4.1.43.orig/arch/mips/ath79/mach-dlan-hotspot.c 1970-01-01 01:00:00.000000000 +0100
10281 +++ linux-4.1.43/arch/mips/ath79/mach-dlan-hotspot.c 2017-08-06 20:02:15.000000000 +0200
10282 @@ -0,0 +1,117 @@
10284 + * devolo dLAN Hotspot board support
10286 + * Copyright (C) 2015 Torsten Schnuis <torsten.schnuis@gik.de>
10287 + * Copyright (C) 2015 devolo AG
10289 + * This program is free software; you can redistribute it and/or modify it
10290 + * under the terms of the GNU General Public License version 2 as published
10291 + * by the Free Software Foundation.
10292 + */
10294 +#include <linux/gpio.h>
10296 +#include <asm/mach-ath79/ath79.h>
10298 +#include "dev-eth.h"
10299 +#include "dev-gpio-buttons.h"
10300 +#include "dev-leds-gpio.h"
10301 +#include "dev-m25p80.h"
10302 +#include "dev-usb.h"
10303 +#include "dev-wmac.h"
10304 +#include "machtypes.h"
10306 +#define DLAN_HOTSPOT_GPIO_LED_WIFI 0
10308 +#define DLAN_HOTSPOT_GPIO_BTN_RESET 11
10309 +#define DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING 12
10310 +#define DLAN_HOTSPOT_GPIO_BTN_WIFI 21
10312 +#define DLAN_HOTSPOT_GPIO_PLC_POWER 22
10313 +#define DLAN_HOTSPOT_GPIO_PLC_RESET 20
10314 +#define DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS 18
10316 +#define DLAN_HOTSPOT_KEYS_POLL_INTERVAL 20 /* msecs */
10317 +#define DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_HOTSPOT_KEYS_POLL_INTERVAL)
10319 +#define DLAN_HOTSPOT_ART_ADDRESS 0x1fff0000
10320 +#define DLAN_HOTSPOT_CALDATA_OFFSET 0x00001000
10321 +#define DLAN_HOTSPOT_MAC_ADDRESS_OFFSET 0x00001002
10323 +static struct gpio_led dlan_hotspot_leds_gpio[] __initdata = {
10325 + .name = "devolo:green:wifi",
10326 + .gpio = DLAN_HOTSPOT_GPIO_LED_WIFI,
10327 + .active_low = 0,
10331 +static struct gpio_keys_button dlan_hotspot_gpio_keys[] __initdata = {
10333 + .desc = "Reset button",
10334 + .type = EV_KEY,
10335 + .code = KEY_RESTART,
10336 + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
10337 + .gpio = DLAN_HOTSPOT_GPIO_BTN_RESET,
10338 + .active_low = 0,
10339 + },
10341 + .desc = "Pairing button",
10342 + .type = EV_KEY,
10343 + .code = BTN_0,
10344 + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
10345 + .gpio = DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING,
10346 + .active_low = 0,
10347 + },
10349 + .desc = "WLAN button",
10350 + .type = EV_KEY,
10351 + .code = KEY_WPS_BUTTON,
10352 + .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
10353 + .gpio = DLAN_HOTSPOT_GPIO_BTN_WIFI,
10354 + .active_low = 0,
10358 +static void __init dlan_hotspot_setup(void)
10360 + u8 *art = (u8 *) KSEG1ADDR(DLAN_HOTSPOT_ART_ADDRESS);
10361 + u8 *cal = art + DLAN_HOTSPOT_CALDATA_OFFSET;
10362 + u8 *wifi_mac = art + DLAN_HOTSPOT_MAC_ADDRESS_OFFSET;
10364 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
10365 + ath79_setup_ar933x_phy4_switch(false, false);
10367 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_hotspot_leds_gpio),
10368 + dlan_hotspot_leds_gpio);
10370 + ath79_register_gpio_keys_polled(-1, DLAN_HOTSPOT_KEYS_POLL_INTERVAL,
10371 + ARRAY_SIZE(dlan_hotspot_gpio_keys),
10372 + dlan_hotspot_gpio_keys);
10374 + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_POWER,
10375 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
10376 + "PLC power");
10377 + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_RESET,
10378 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
10379 + "PLC reset");
10380 + gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS,
10381 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
10382 + "PLC LEDs");
10384 + ath79_register_usb();
10386 + ath79_register_m25p80(NULL);
10388 + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 1);
10389 + ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 2);
10391 + ath79_register_mdio(0, 0x0);
10392 + ath79_register_eth(0);
10393 + ath79_register_eth(1);
10395 + ath79_register_wmac(cal, wifi_mac);
10398 +MIPS_MACHINE(ATH79_MACH_DLAN_HOTSPOT, "dLAN-Hotspot",
10399 + "dLAN Hotspot", dlan_hotspot_setup);
10400 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dlan-pro-1200-ac.c linux-4.1.43/arch/mips/ath79/mach-dlan-pro-1200-ac.c
10401 --- linux-4.1.43.orig/arch/mips/ath79/mach-dlan-pro-1200-ac.c 1970-01-01 01:00:00.000000000 +0100
10402 +++ linux-4.1.43/arch/mips/ath79/mach-dlan-pro-1200-ac.c 2017-08-06 20:02:15.000000000 +0200
10403 @@ -0,0 +1,189 @@
10405 + * devolo dLAN pro 500 Wireless+ support
10407 + * Copyright (c) 2013-2015 devolo AG
10408 + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
10410 + * Permission to use, copy, modify, and/or distribute this software for any
10411 + * purpose with or without fee is hereby granted, provided that the above
10412 + * copyright notice and this permission notice appear in all copies.
10414 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10415 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10416 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10417 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10418 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
10419 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
10420 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
10422 + */
10424 +#include <linux/pci.h>
10425 +#include <linux/phy.h>
10426 +#include <linux/platform_device.h>
10427 +#include <linux/ath9k_platform.h>
10428 +#include <linux/ar8216_platform.h>
10429 +#include <linux/gpio.h>
10431 +#include <asm/mach-ath79/ar71xx_regs.h>
10433 +#include "common.h"
10434 +#include "dev-ap9x-pci.h"
10435 +#include "dev-eth.h"
10436 +#include "dev-gpio-buttons.h"
10437 +#include "dev-leds-gpio.h"
10438 +#include "dev-m25p80.h"
10439 +#include "dev-nfc.h"
10440 +#include "dev-spi.h"
10441 +#include "dev-wmac.h"
10442 +#include "machtypes.h"
10444 +#define DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE 13
10445 +#define DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE 21
10446 +#define DLAN_PRO_1200_AC_GPIO_LED_WLAN 12
10447 +#define DLAN_PRO_1200_AC_GPIO_LED_DLAN 14
10448 +#define DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR 15
10450 +#define DLAN_PRO_1200_AC_GPIO_BTN_WLAN 20
10451 +#define DLAN_PRO_1200_AC_GPIO_BTN_DLAN 22
10452 +#define DLAN_PRO_1200_AC_GPIO_BTN_RESET 4
10453 +#define DLAN_PRO_1200_AC_GPIO_DLAN_IND 17
10454 +#define DLAN_PRO_1200_AC_GPIO_DLAN_ERR_IND 16
10456 +#define DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL 20 /* msecs */
10457 +#define DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL)
10459 +#define DLAN_PRO_1200_AC_ART_ADDRESS 0x1fff0000
10460 +#define DLAN_PRO_1200_AC_CALDATA_OFFSET 0x1000
10461 +#define DLAN_PRO_1200_AC_WIFIMAC_OFFSET 0x1002
10462 +#define DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET 0x5000
10464 +static struct gpio_led dlan_pro_1200_ac_leds_gpio[] __initdata = {
10466 + .name = "devolo:status:wlan",
10467 + .gpio = DLAN_PRO_1200_AC_GPIO_LED_WLAN,
10468 + .active_low = 1,
10469 + },
10471 + .name = "devolo:status:dlan",
10472 + .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN,
10473 + .active_low = 1,
10474 + },
10476 + .name = "devolo:error:dlan",
10477 + .gpio = DLAN_PRO_1200_AC_GPIO_LED_DLAN_ERR,
10478 + .active_low = 0,
10482 +static struct gpio_keys_button dlan_pro_1200_ac_gpio_keys[] __initdata = {
10484 + .desc = "dLAN button",
10485 + .type = EV_KEY,
10486 + .code = BTN_0,
10487 + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
10488 + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_DLAN,
10489 + .active_low = 1,
10490 + },
10492 + .desc = "WLAN button",
10493 + .type = EV_KEY,
10494 + .code = KEY_WPS_BUTTON,
10495 + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
10496 + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_WLAN,
10497 + .active_low = 0,
10498 + },
10500 + .desc = "Reset button",
10501 + .type = EV_KEY,
10502 + .code = KEY_RESTART,
10503 + .debounce_interval = DLAN_PRO_1200_AC_KEYS_DEBOUNCE_INTERVAL,
10504 + .gpio = DLAN_PRO_1200_AC_GPIO_BTN_RESET,
10505 + .active_low = 1,
10509 +static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad0_cfg = {
10510 + .mode = AR8327_PAD_MAC_RGMII,
10511 + .txclk_delay_en = true,
10512 + .rxclk_delay_en = false,
10513 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
10514 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
10517 +static struct ar8327_pad_cfg dlan_pro_1200_ac_ar8327_pad5_cfg = {
10518 + .mode = 0,
10519 + .txclk_delay_en = 0,
10520 + .rxclk_delay_en = 0,
10521 + .txclk_delay_sel = 0,
10522 + .rxclk_delay_sel = 0,
10525 +static struct ar8327_platform_data dlan_pro_1200_ac_ar8327_data = {
10526 + .pad0_cfg = &dlan_pro_1200_ac_ar8327_pad0_cfg,
10527 + .pad5_cfg = &dlan_pro_1200_ac_ar8327_pad5_cfg,
10528 + .port0_cfg = {
10529 + .force_link = 1,
10530 + .speed = AR8327_PORT_SPEED_1000,
10531 + .duplex = 1,
10532 + .txpause = 1,
10533 + .rxpause = 1,
10534 + },
10537 +static struct mdio_board_info dlan_pro_1200_ac_mdio0_info[] = {
10539 + .bus_id = "ag71xx-mdio.0",
10540 + .phy_addr = 0,
10541 + .platform_data = &dlan_pro_1200_ac_ar8327_data,
10542 + },
10545 +static void __init dlan_pro_1200_ac_setup(void)
10547 + u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_1200_AC_ART_ADDRESS);
10548 + u8 *cal = art + DLAN_PRO_1200_AC_CALDATA_OFFSET;
10549 + u8 *wifi_mac = art + DLAN_PRO_1200_AC_WIFIMAC_OFFSET;
10551 + ath79_register_m25p80(NULL);
10553 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_1200_ac_leds_gpio),
10554 + dlan_pro_1200_ac_leds_gpio);
10556 + ath79_register_gpio_keys_polled(-1, DLAN_PRO_1200_AC_KEYS_POLL_INTERVAL,
10557 + ARRAY_SIZE(dlan_pro_1200_ac_gpio_keys),
10558 + dlan_pro_1200_ac_gpio_keys);
10560 + /* dLAN power must be enabled from user-space as soon as the boot-from-host daemon is running */
10561 + gpio_request_one(DLAN_PRO_1200_AC_GPIO_DLAN_POWER_ENABLE,
10562 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
10563 + "dLAN power");
10565 + /* WLAN power is turned on initially to allow the PCI bus scan to succeed */
10566 + gpio_request_one(DLAN_PRO_1200_AC_GPIO_WLAN_POWER_ENABLE,
10567 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
10568 + "WLAN power");
10570 + ath79_register_wmac(cal, wifi_mac);
10571 + ap91_pci_init(art + DLAN_PRO_1200_AC_PCIE_CALDATA_OFFSET, NULL);
10573 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | AR934X_ETH_CFG_SW_ONLY_MODE);
10575 + ath79_register_mdio(1, 0x0);
10576 + ath79_register_mdio(0, 0x0);
10578 + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
10580 + mdiobus_register_board_info(dlan_pro_1200_ac_mdio0_info,
10581 + ARRAY_SIZE(dlan_pro_1200_ac_mdio0_info));
10583 + /* GMAC0 is connected to an AR8337 */
10584 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
10585 + ath79_eth0_data.phy_mask = BIT(0);
10586 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
10587 + ath79_eth0_pll_data.pll_1000 = 0x02000000;
10588 + ath79_register_eth(0);
10591 +MIPS_MACHINE(ATH79_MACH_DLAN_PRO_1200_AC, "dLAN-pro-1200-ac", "devolo dLAN pro 1200+ WiFi ac",
10592 + dlan_pro_1200_ac_setup);
10593 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dlan-pro-500-wp.c linux-4.1.43/arch/mips/ath79/mach-dlan-pro-500-wp.c
10594 --- linux-4.1.43.orig/arch/mips/ath79/mach-dlan-pro-500-wp.c 1970-01-01 01:00:00.000000000 +0100
10595 +++ linux-4.1.43/arch/mips/ath79/mach-dlan-pro-500-wp.c 2017-08-06 20:02:15.000000000 +0200
10596 @@ -0,0 +1,203 @@
10598 + * devolo dLAN pro 500 Wireless+ support
10600 + * Copyright (c) 2013-2015 devolo AG
10601 + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
10603 + * Permission to use, copy, modify, and/or distribute this software for any
10604 + * purpose with or without fee is hereby granted, provided that the above
10605 + * copyright notice and this permission notice appear in all copies.
10607 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10608 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10609 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10610 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10611 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
10612 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
10613 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
10615 + */
10617 +#include <linux/pci.h>
10618 +#include <linux/phy.h>
10619 +#include <linux/platform_device.h>
10620 +#include <linux/ath9k_platform.h>
10621 +#include <linux/ar8216_platform.h>
10622 +#include <linux/gpio.h>
10624 +#include <asm/mach-ath79/ar71xx_regs.h>
10626 +#include "common.h"
10627 +#include "dev-ap9x-pci.h"
10628 +#include "dev-eth.h"
10629 +#include "dev-gpio-buttons.h"
10630 +#include "dev-leds-gpio.h"
10631 +#include "dev-m25p80.h"
10632 +#include "dev-spi.h"
10633 +#include "dev-wmac.h"
10634 +#include "machtypes.h"
10636 +#define DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE 13
10637 +#define DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE 17
10638 +#define DLAN_PRO_500_WP_GPIO_LED_WLAN_5G 11
10639 +#define DLAN_PRO_500_WP_GPIO_LED_WLAN_2G 12
10640 +#define DLAN_PRO_500_WP_GPIO_LED_STATUS 16
10641 +#define DLAN_PRO_500_WP_GPIO_LED_ETH 14
10643 +#define DLAN_PRO_500_WP_GPIO_BTN_WPS 20
10644 +#define DLAN_PRO_500_WP_GPIO_BTN_WLAN 22
10645 +#define DLAN_PRO_500_WP_GPIO_BTN_DLAN 21
10646 +#define DLAN_PRO_500_WP_GPIO_BTN_RESET 4
10648 +#define DLAN_PRO_500_WP_KEYS_POLL_INTERVAL 20 /* msecs */
10649 +#define DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_PRO_500_WP_KEYS_POLL_INTERVAL)
10651 +#define DLAN_PRO_500_WP_ART_ADDRESS 0x1fff0000
10652 +#define DLAN_PRO_500_WP_CALDATA_OFFSET 0x1000
10653 +#define DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET 0x1002
10654 +#define DLAN_PRO_500_WP_PCIE_CALDATA_OFFSET 0x5000
10656 +static struct gpio_led dlan_pro_500_wp_leds_gpio[] __initdata = {
10658 + .name = "devolo:green:status",
10659 + .gpio = DLAN_PRO_500_WP_GPIO_LED_STATUS,
10660 + .active_low = 1,
10661 + },
10663 + .name = "devolo:green:eth",
10664 + .gpio = DLAN_PRO_500_WP_GPIO_LED_ETH,
10665 + .active_low = 1,
10666 + },
10668 + .name = "devolo:blue:wlan-5g",
10669 + .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_5G,
10670 + .active_low = 1,
10671 + },
10673 + .name = "devolo:green:wlan-2g",
10674 + .gpio = DLAN_PRO_500_WP_GPIO_LED_WLAN_2G,
10675 + .active_low = 1,
10679 +static struct gpio_keys_button dlan_pro_500_wp_gpio_keys[] __initdata = {
10681 + .desc = "dLAN button",
10682 + .type = EV_KEY,
10683 + .code = BTN_0,
10684 + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
10685 + .gpio = DLAN_PRO_500_WP_GPIO_BTN_DLAN,
10686 + .active_low = 0,
10687 + },
10689 + .desc = "WPS button",
10690 + .type = EV_KEY,
10691 + .code = KEY_WPS_BUTTON,
10692 + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
10693 + .gpio = DLAN_PRO_500_WP_GPIO_BTN_WPS,
10694 + .active_low = 0,
10695 + },
10697 + .desc = "WLAN button",
10698 + .type = EV_KEY,
10699 + .code = BTN_2,
10700 + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
10701 + .gpio = DLAN_PRO_500_WP_GPIO_BTN_WLAN,
10702 + .active_low = 1,
10703 + },
10705 + .desc = "Reset button",
10706 + .type = EV_KEY,
10707 + .code = KEY_RESTART,
10708 + .debounce_interval = DLAN_PRO_500_WP_KEYS_DEBOUNCE_INTERVAL,
10709 + .gpio = DLAN_PRO_500_WP_GPIO_BTN_RESET,
10710 + .active_low = 1,
10714 +static struct ar8327_pad_cfg dlan_pro_500_wp_ar8327_pad0_cfg = {
10715 + .mode = AR8327_PAD_PHY_RGMII,
10716 + .txclk_delay_en = false,
10717 + .rxclk_delay_en = false,
10718 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL0,
10719 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
10722 +static struct ar8327_led_cfg dlan_pro_500_wp_ar8327_led_cfg = {
10723 + .led_ctrl0 = 0x00000000,
10724 + .led_ctrl1 = 0xc737c737,
10725 + .led_ctrl2 = 0x00000000,
10726 + .led_ctrl3 = 0x00c30c00,
10727 + .open_drain = true,
10730 +static struct ar8327_platform_data dlan_pro_500_wp_ar8327_data = {
10731 + .pad0_cfg = &dlan_pro_500_wp_ar8327_pad0_cfg,
10732 + .port0_cfg = {
10733 + .force_link = 1,
10734 + .speed = AR8327_PORT_SPEED_1000,
10735 + .duplex = 1,
10736 + .txpause = 0,
10737 + .rxpause = 0,
10738 + },
10739 + .led_cfg = &dlan_pro_500_wp_ar8327_led_cfg,
10742 +static struct mdio_board_info dlan_pro_500_wp_mdio0_info[] = {
10744 + .bus_id = "ag71xx-mdio.0",
10745 + .phy_addr = 0,
10746 + .platform_data = &dlan_pro_500_wp_ar8327_data,
10747 + },
10750 +static void __init dlan_pro_500_wp_setup(void)
10752 + u8 *art = (u8 *) KSEG1ADDR(DLAN_PRO_500_WP_ART_ADDRESS);
10753 + u8 *cal = art + DLAN_PRO_500_WP_CALDATA_OFFSET;
10754 + u8 *wifi_mac = art + DLAN_PRO_500_WP_MAC_ADDRESS_OFFSET;
10756 + ath79_register_m25p80(NULL);
10758 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_pro_500_wp_leds_gpio),
10759 + dlan_pro_500_wp_leds_gpio);
10761 + ath79_register_gpio_keys_polled(-1, DLAN_PRO_500_WP_KEYS_POLL_INTERVAL,
10762 + ARRAY_SIZE(dlan_pro_500_wp_gpio_keys),
10763 + dlan_pro_500_wp_gpio_keys);
10765 + gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_POWER_ENABLE,
10766 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
10767 + "PLC power");
10768 + gpio_request_one(DLAN_PRO_500_WP_GPIO_DLAN_LED_ENABLE,
10769 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
10770 + "PLC LEDs");
10772 + ath79_register_wmac(cal, wifi_mac);
10774 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
10776 + ath79_register_mdio(1, 0x0);
10777 + ath79_register_mdio(0, 0x0);
10779 + mdiobus_register_board_info(dlan_pro_500_wp_mdio0_info,
10780 + ARRAY_SIZE(dlan_pro_500_wp_mdio0_info));
10782 + /* GMAC0 is connected to a AR7400 PLC in PHY mode */
10783 + ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 2);
10784 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
10785 + ath79_eth0_pll_data.pll_1000 = 0x0e000000;
10786 + ath79_eth0_data.speed = SPEED_1000;
10787 + ath79_eth0_data.duplex = DUPLEX_FULL;
10788 + ath79_register_eth(0);
10790 + /* GMAC1 is connected to the internal switch */
10791 + ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 1);
10792 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
10793 + ath79_eth1_data.speed = SPEED_1000;
10794 + ath79_eth1_data.duplex = DUPLEX_FULL;
10795 + ath79_register_eth(1);
10798 +MIPS_MACHINE(ATH79_MACH_DLAN_PRO_500_WP, "dLAN-pro-500-wp", "devolo dLAN pro 500 Wireless+",
10799 + dlan_pro_500_wp_setup);
10800 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-dragino2.c linux-4.1.43/arch/mips/ath79/mach-dragino2.c
10801 --- linux-4.1.43.orig/arch/mips/ath79/mach-dragino2.c 1970-01-01 01:00:00.000000000 +0100
10802 +++ linux-4.1.43/arch/mips/ath79/mach-dragino2.c 2017-08-06 20:02:15.000000000 +0200
10803 @@ -0,0 +1,136 @@
10805 + * DRAGINO V2 board support, based on Atheros AP121 board support
10807 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
10808 + * Copyright (C) 2012 Elektra Wagenrad <elektra@villagetelco.org>
10809 + * Copyright (C) 2014 Vittorio Gambaletta <openwrt@vittgam.net>
10811 + * This program is free software; you can redistribute it and/or modify it
10812 + * under the terms of the GNU General Public License version 2 as published
10813 + * by the Free Software Foundation.
10814 + */
10816 +#include <linux/gpio.h>
10817 +#include <asm/mach-ath79/ath79.h>
10818 +#include <asm/mach-ath79/ar71xx_regs.h>
10819 +#include "common.h"
10820 +#include "dev-eth.h"
10821 +#include "dev-gpio-buttons.h"
10822 +#include "dev-leds-gpio.h"
10823 +#include "dev-m25p80.h"
10824 +#include "dev-spi.h"
10825 +#include "dev-usb.h"
10826 +#include "dev-wmac.h"
10827 +#include "machtypes.h"
10829 +#define DRAGINO2_GPIO_LED_WLAN 0
10830 +#define DRAGINO2_GPIO_LED_LAN 13
10831 +#define DRAGINO2_GPIO_LED_WAN 17
10834 + * The following GPIO is named "SYS" on newer revisions of the the board.
10835 + * It was previously used to indicate USB activity, even though it was
10836 + * named "Router".
10837 + */
10839 +#define DRAGINO2_GPIO_LED_SYS 28
10840 +#define DRAGINO2_GPIO_BTN_JUMPSTART 11
10841 +#define DRAGINO2_GPIO_BTN_RESET 12
10843 +#define DRAGINO2_KEYS_POLL_INTERVAL 20 /* msecs */
10844 +#define DRAGINO2_KEYS_DEBOUNCE_INTERVAL (3 * DRAGINO2_KEYS_POLL_INTERVAL)
10846 +#define DRAGINO2_MAC0_OFFSET 0x0000
10847 +#define DRAGINO2_MAC1_OFFSET 0x0006
10848 +#define DRAGINO2_CALDATA_OFFSET 0x1000
10849 +#define DRAGINO2_WMAC_MAC_OFFSET 0x1002
10851 +static struct gpio_led dragino2_leds_gpio[] __initdata = {
10853 + .name = "dragino2:red:wlan",
10854 + .gpio = DRAGINO2_GPIO_LED_WLAN,
10855 + .active_low = 0,
10856 + },
10858 + .name = "dragino2:red:wan",
10859 + .gpio = DRAGINO2_GPIO_LED_WAN,
10860 + .active_low = 1,
10861 + },
10863 + .name = "dragino2:red:lan",
10864 + .gpio = DRAGINO2_GPIO_LED_LAN,
10865 + .active_low = 1,
10866 + },
10868 + .name = "dragino2:red:system",
10869 + .gpio = DRAGINO2_GPIO_LED_SYS,
10870 + .active_low = 0,
10871 + },
10874 +static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
10876 + .desc = "jumpstart button",
10877 + .type = EV_KEY,
10878 + .code = KEY_WPS_BUTTON,
10879 + .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
10880 + .gpio = DRAGINO2_GPIO_BTN_JUMPSTART,
10881 + .active_low = 1,
10882 + },
10884 + .desc = "reset button",
10885 + .type = EV_KEY,
10886 + .code = KEY_RESTART,
10887 + .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
10888 + .gpio = DRAGINO2_GPIO_BTN_RESET,
10889 + .active_low = 1,
10893 +static void __init dragino2_common_setup(void)
10895 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
10897 + ath79_register_m25p80(NULL);
10898 + ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
10899 + art + DRAGINO2_WMAC_MAC_OFFSET);
10901 + ath79_init_mac(ath79_eth0_data.mac_addr, art + DRAGINO2_MAC0_OFFSET, 0);
10902 + ath79_init_mac(ath79_eth1_data.mac_addr, art + DRAGINO2_MAC1_OFFSET, 0);
10904 + ath79_register_mdio(0, 0x0);
10906 + /* Enable GPIO13, GPIO14, GPIO15, GPIO16 and GPIO17 */
10907 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
10908 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
10909 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
10910 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
10911 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
10913 + /* LAN port */
10914 + ath79_register_eth(1);
10916 + /* WAN port */
10917 + ath79_register_eth(0);
10919 + /* Enable GPIO26 and GPIO27 */
10920 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP,
10921 + ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP) |
10922 + AR933X_BOOTSTRAP_MDIO_GPIO_EN);
10925 +static void __init dragino2_setup(void)
10927 + dragino2_common_setup();
10929 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dragino2_leds_gpio),
10930 + dragino2_leds_gpio);
10931 + ath79_register_gpio_keys_polled(-1, DRAGINO2_KEYS_POLL_INTERVAL,
10932 + ARRAY_SIZE(dragino2_gpio_keys),
10933 + dragino2_gpio_keys);
10934 + ath79_register_usb();
10937 +MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",
10938 + dragino2_setup);
10940 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-eap300v2.c linux-4.1.43/arch/mips/ath79/mach-eap300v2.c
10941 --- linux-4.1.43.orig/arch/mips/ath79/mach-eap300v2.c 1970-01-01 01:00:00.000000000 +0100
10942 +++ linux-4.1.43/arch/mips/ath79/mach-eap300v2.c 2017-08-06 20:02:15.000000000 +0200
10943 @@ -0,0 +1,101 @@
10945 + * EnGenius EAP300 v2 board support
10947 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
10949 + * This program is free software; you can redistribute it and/or modify it
10950 + * under the terms of the GNU General Public License version 2 as published
10951 + * by the Free Software Foundation.
10952 + */
10954 +#include <linux/gpio.h>
10955 +#include <linux/mtd/mtd.h>
10956 +#include <linux/mtd/partitions.h>
10957 +#include <linux/platform_device.h>
10959 +#include <asm/mach-ath79/ar71xx_regs.h>
10960 +#include <asm/mach-ath79/ath79.h>
10962 +#include "common.h"
10963 +#include "dev-eth.h"
10964 +#include "dev-gpio-buttons.h"
10965 +#include "dev-leds-gpio.h"
10966 +#include "dev-m25p80.h"
10967 +#include "dev-wmac.h"
10968 +#include "machtypes.h"
10970 +#define EAP300V2_GPIO_LED_POWER 0
10971 +#define EAP300V2_GPIO_LED_LAN 16
10972 +#define EAP300V2_GPIO_LED_WLAN 17
10974 +#define EAP300V2_GPIO_BTN_RESET 1
10976 +#define EAP300V2_KEYS_POLL_INTERVAL 20 /* msecs */
10977 +#define EAP300V2_KEYS_DEBOUNCE_INTERVAL (3 * EAP300V2_KEYS_POLL_INTERVAL)
10979 +static struct gpio_led eap300v2_leds_gpio[] __initdata = {
10981 + .name = "engenius:blue:power",
10982 + .gpio = EAP300V2_GPIO_LED_POWER,
10983 + .active_low = 1,
10984 + }, {
10985 + .name = "engenius:blue:lan",
10986 + .gpio = EAP300V2_GPIO_LED_LAN,
10987 + .active_low = 1,
10988 + }, {
10989 + .name = "engenius:blue:wlan",
10990 + .gpio = EAP300V2_GPIO_LED_WLAN,
10991 + .active_low = 1,
10995 +static struct gpio_keys_button eap300v2_gpio_keys[] __initdata = {
10997 + .desc = "reset",
10998 + .type = EV_KEY,
10999 + .code = KEY_RESTART,
11000 + .debounce_interval = EAP300V2_KEYS_DEBOUNCE_INTERVAL,
11001 + .gpio = EAP300V2_GPIO_BTN_RESET,
11002 + .active_low = 1,
11006 +#define EAP300V2_ART_MAC_OFFSET 2
11008 +#define EAP300V2_LAN_PHYMASK BIT(0)
11010 +static void __init eap300v2_setup(void)
11012 + u8 *art = (u8 *)KSEG1ADDR(0x1fff1000);
11014 + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
11016 + ath79_gpio_output_select(EAP300V2_GPIO_LED_POWER, AR934X_GPIO_OUT_GPIO);
11017 + ath79_gpio_output_select(EAP300V2_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
11018 + ath79_gpio_output_select(EAP300V2_GPIO_LED_WLAN, AR934X_GPIO_OUT_GPIO);
11020 + ath79_register_leds_gpio(-1, ARRAY_SIZE(eap300v2_leds_gpio),
11021 + eap300v2_leds_gpio);
11022 + ath79_register_gpio_keys_polled(-1, EAP300V2_KEYS_POLL_INTERVAL,
11023 + ARRAY_SIZE(eap300v2_gpio_keys),
11024 + eap300v2_gpio_keys);
11026 + ath79_register_m25p80(NULL);
11027 + ath79_register_wmac(art, NULL);
11028 + ath79_register_mdio(1, 0x0);
11030 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
11032 + ath79_init_mac(ath79_eth0_data.mac_addr,
11033 + art + EAP300V2_ART_MAC_OFFSET, 0);
11035 + ath79_switch_data.phy4_mii_en = 1;
11036 + ath79_switch_data.phy_poll_mask = EAP300V2_LAN_PHYMASK;
11037 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
11038 + ath79_eth0_data.phy_mask = EAP300V2_LAN_PHYMASK;
11039 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
11040 + ath79_register_eth(0);
11043 +MIPS_MACHINE(ATH79_MACH_EAP300V2, "EAP300V2", "EnGenius EAP300 v2",
11044 + eap300v2_setup);
11045 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-eap7660d.c linux-4.1.43/arch/mips/ath79/mach-eap7660d.c
11046 --- linux-4.1.43.orig/arch/mips/ath79/mach-eap7660d.c 1970-01-01 01:00:00.000000000 +0100
11047 +++ linux-4.1.43/arch/mips/ath79/mach-eap7660d.c 2017-08-06 20:02:15.000000000 +0200
11048 @@ -0,0 +1,181 @@
11050 + * Senao EAP7660D board support
11052 + * Copyright (C) 2010 Daniel Golle <daniel.golle@gmail.com>
11053 + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
11054 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
11056 + * This program is free software; you can redistribute it and/or modify it
11057 + * under the terms of the GNU General Public License version 2 as published
11058 + * by the Free Software Foundation.
11059 + */
11061 +#include <linux/pci.h>
11062 +#include <linux/ath5k_platform.h>
11063 +#include <linux/delay.h>
11065 +#include <asm/mach-ath79/ath79.h>
11067 +#include "dev-eth.h"
11068 +#include "dev-gpio-buttons.h"
11069 +#include "dev-leds-gpio.h"
11070 +#include "dev-m25p80.h"
11071 +#include "machtypes.h"
11072 +#include "pci.h"
11074 +#define EAP7660D_KEYS_POLL_INTERVAL 20 /* msecs */
11075 +#define EAP7660D_KEYS_DEBOUNCE_INTERVAL (3 * EAP7660D_KEYS_POLL_INTERVAL)
11077 +#define EAP7660D_GPIO_DS4 7
11078 +#define EAP7660D_GPIO_DS5 2
11079 +#define EAP7660D_GPIO_DS7 0
11080 +#define EAP7660D_GPIO_DS8 4
11081 +#define EAP7660D_GPIO_SW1 3
11082 +#define EAP7660D_GPIO_SW3 8
11083 +#define EAP7660D_PHYMASK BIT(20)
11084 +#define EAP7660D_BOARDCONFIG 0x1F7F0000
11085 +#define EAP7660D_GBIC_MAC_OFFSET 0x1000
11086 +#define EAP7660D_WMAC0_MAC_OFFSET 0x1010
11087 +#define EAP7660D_WMAC1_MAC_OFFSET 0x1016
11088 +#define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
11089 +#define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
11091 +#ifdef CONFIG_PCI
11092 +static struct ath5k_platform_data eap7660d_wmac0_data;
11093 +static struct ath5k_platform_data eap7660d_wmac1_data;
11094 +static char eap7660d_wmac0_mac[6];
11095 +static char eap7660d_wmac1_mac[6];
11096 +static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
11097 +static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
11099 +static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
11101 + switch (PCI_SLOT(dev->devfn)) {
11102 + case 17:
11103 + dev->dev.platform_data = &eap7660d_wmac0_data;
11104 + break;
11106 + case 18:
11107 + dev->dev.platform_data = &eap7660d_wmac1_data;
11108 + break;
11111 + return 0;
11114 +void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
11115 + u8 *cal_data1, u8 *mac_addr1)
11117 + if (cal_data0 && *cal_data0 == 0xa55a) {
11118 + memcpy(eap7660d_wmac0_eeprom, cal_data0,
11119 + ATH5K_PLAT_EEP_MAX_WORDS);
11120 + eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
11123 + if (cal_data1 && *cal_data1 == 0xa55a) {
11124 + memcpy(eap7660d_wmac1_eeprom, cal_data1,
11125 + ATH5K_PLAT_EEP_MAX_WORDS);
11126 + eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
11129 + if (mac_addr0) {
11130 + memcpy(eap7660d_wmac0_mac, mac_addr0,
11131 + sizeof(eap7660d_wmac0_mac));
11132 + eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
11135 + if (mac_addr1) {
11136 + memcpy(eap7660d_wmac1_mac, mac_addr1,
11137 + sizeof(eap7660d_wmac1_mac));
11138 + eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
11141 + ath79_pci_set_plat_dev_init(eap7660d_pci_plat_dev_init);
11142 + ath79_register_pci();
11144 +#else
11145 +static inline void eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
11146 + u8 *cal_data1, u8 *mac_addr1)
11149 +#endif /* CONFIG_PCI */
11151 +static struct gpio_led eap7660d_leds_gpio[] __initdata = {
11153 + .name = "eap7660d:green:ds8",
11154 + .gpio = EAP7660D_GPIO_DS8,
11155 + .active_low = 0,
11156 + },
11158 + .name = "eap7660d:green:ds5",
11159 + .gpio = EAP7660D_GPIO_DS5,
11160 + .active_low = 0,
11161 + },
11163 + .name = "eap7660d:green:ds7",
11164 + .gpio = EAP7660D_GPIO_DS7,
11165 + .active_low = 0,
11166 + },
11168 + .name = "eap7660d:green:ds4",
11169 + .gpio = EAP7660D_GPIO_DS4,
11170 + .active_low = 0,
11174 +static struct gpio_keys_button eap7660d_gpio_keys[] __initdata = {
11176 + .desc = "reset",
11177 + .type = EV_KEY,
11178 + .code = KEY_RESTART,
11179 + .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
11180 + .gpio = EAP7660D_GPIO_SW1,
11181 + .active_low = 1,
11182 + },
11184 + .desc = "wps",
11185 + .type = EV_KEY,
11186 + .code = KEY_WPS_BUTTON,
11187 + .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
11188 + .gpio = EAP7660D_GPIO_SW3,
11189 + .active_low = 1,
11193 +static const char *eap7660d_part_probes[] = {
11194 + "RedBoot",
11195 + NULL,
11198 +static struct flash_platform_data eap7660d_flash_data = {
11199 + .part_probes = eap7660d_part_probes,
11202 +static void __init eap7660d_setup(void)
11204 + u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
11206 + ath79_register_mdio(0, ~EAP7660D_PHYMASK);
11208 + ath79_init_mac(ath79_eth0_data.mac_addr,
11209 + boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
11210 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
11211 + ath79_eth0_data.phy_mask = EAP7660D_PHYMASK;
11212 + ath79_register_eth(0);
11213 + ath79_register_m25p80(&eap7660d_flash_data);
11214 + ath79_register_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
11215 + eap7660d_leds_gpio);
11216 + ath79_register_gpio_keys_polled(-1, EAP7660D_KEYS_POLL_INTERVAL,
11217 + ARRAY_SIZE(eap7660d_gpio_keys),
11218 + eap7660d_gpio_keys);
11219 + eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
11220 + boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
11221 + boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
11222 + boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
11225 +MIPS_MACHINE(ATH79_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",
11226 + eap7660d_setup);
11228 +MIPS_MACHINE(ATH79_MACH_ALL0305, "ALL0305", "Allnet ALL0305",
11229 + eap7660d_setup);
11230 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-el-m150.c linux-4.1.43/arch/mips/ath79/mach-el-m150.c
11231 --- linux-4.1.43.orig/arch/mips/ath79/mach-el-m150.c 1970-01-01 01:00:00.000000000 +0100
11232 +++ linux-4.1.43/arch/mips/ath79/mach-el-m150.c 2017-08-06 20:02:15.000000000 +0200
11233 @@ -0,0 +1,112 @@
11235 + * Easy-Link EL-M150 board support
11237 + * Copyright (C) 2012 huangfc <huangfangcheng@163.com>
11238 + * Copyright (C) 2012 HYS <550663898@qq.com>
11240 + * This program is free software; you can redistribute it and/or modify it
11241 + * under the terms of the GNU General Public License version 2 as published
11242 + * by the Free Software Foundation.
11243 + */
11245 +#include <linux/gpio.h>
11247 +#include <asm/mach-ath79/ath79.h>
11248 +#include <asm/mach-ath79/ar71xx_regs.h>
11250 +#include "common.h"
11251 +#include "dev-eth.h"
11252 +#include "dev-gpio-buttons.h"
11253 +#include "dev-leds-gpio.h"
11254 +#include "dev-m25p80.h"
11255 +#include "dev-wmac.h"
11256 +#include "machtypes.h"
11257 +#include "dev-usb.h"
11259 +#define EL_M150_GPIO_BTN6 6
11260 +#define EL_M150_GPIO_BTN7 7
11261 +#define EL_M150_GPIO_BTN_RESET 11
11263 +#define EL_M150_GPIO_LED_SYSTEM 27
11264 +#define EL_M150_GPIO_USB_POWER 8
11266 +#define EL_M150_KEYS_POLL_INTERVAL 20 /* msecs */
11267 +#define EL_M150_KEYS_DEBOUNCE_INTERVAL (3 * EL_M150_KEYS_POLL_INTERVAL)
11269 +static const char *EL_M150_part_probes[] = {
11270 + "tp-link",
11271 + NULL,
11274 +static struct flash_platform_data EL_M150_flash_data = {
11275 + .part_probes = EL_M150_part_probes,
11278 +static struct gpio_led EL_M150_leds_gpio[] __initdata = {
11280 + .name = "easylink:green:system",
11281 + .gpio = EL_M150_GPIO_LED_SYSTEM,
11282 + .active_low = 1,
11283 + },
11286 +static struct gpio_keys_button EL_M150_gpio_keys[] __initdata = {
11288 + .desc = "reset",
11289 + .type = EV_KEY,
11290 + .code = KEY_RESTART,
11291 + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
11292 + .gpio = EL_M150_GPIO_BTN_RESET,
11293 + .active_low = 0,
11294 + },
11296 + .desc = "BTN_6",
11297 + .type = EV_KEY,
11298 + .code = BTN_6,
11299 + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
11300 + .gpio = EL_M150_GPIO_BTN6,
11301 + .active_low = 1,
11302 + },
11304 + .desc = "BTN_7",
11305 + .type = EV_KEY,
11306 + .code = BTN_7,
11307 + .debounce_interval = EL_M150_KEYS_DEBOUNCE_INTERVAL,
11308 + .gpio = EL_M150_GPIO_BTN7,
11309 + .active_low = 1,
11310 + },
11313 +static void __init el_m150_setup(void)
11315 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
11316 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
11318 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
11319 + ath79_setup_ar933x_phy4_switch(false, false);
11321 + ath79_register_leds_gpio(-1, ARRAY_SIZE(EL_M150_leds_gpio),
11322 + EL_M150_leds_gpio);
11324 + ath79_register_gpio_keys_polled(-1, EL_M150_KEYS_POLL_INTERVAL,
11325 + ARRAY_SIZE(EL_M150_gpio_keys),
11326 + EL_M150_gpio_keys);
11328 + gpio_request_one(EL_M150_GPIO_USB_POWER,
11329 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
11330 + "USB power");
11331 + ath79_register_usb();
11333 + ath79_register_m25p80(&EL_M150_flash_data);
11334 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
11335 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
11337 + ath79_register_mdio(0, 0x0);
11338 + ath79_register_eth(0);
11339 + ath79_register_eth(1);
11341 + ath79_register_wmac(ee, mac);
11344 +MIPS_MACHINE(ATH79_MACH_EL_M150, "EL-M150",
11345 + "EasyLink EL-M150", el_m150_setup);
11346 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-el-mini.c linux-4.1.43/arch/mips/ath79/mach-el-mini.c
11347 --- linux-4.1.43.orig/arch/mips/ath79/mach-el-mini.c 1970-01-01 01:00:00.000000000 +0100
11348 +++ linux-4.1.43/arch/mips/ath79/mach-el-mini.c 2017-08-06 20:02:15.000000000 +0200
11349 @@ -0,0 +1,86 @@
11351 + * Easy-Link EL-MINI board support
11353 + * Copyright (C) 2012 huangfc <huangfangcheng@163.com>
11354 + * Copyright (C) 2011 hys <550663898@qq.com>
11356 + * This program is free software; you can redistribute it and/or modify it
11357 + * under the terms of the GNU General Public License version 2 as published
11358 + * by the Free Software Foundation.
11359 + */
11361 +#include <linux/gpio.h>
11363 +#include <asm/mach-ath79/ath79.h>
11365 +#include "dev-eth.h"
11366 +#include "dev-gpio-buttons.h"
11367 +#include "dev-leds-gpio.h"
11368 +#include "dev-m25p80.h"
11369 +#include "dev-usb.h"
11370 +#include "dev-wmac.h"
11371 +#include "machtypes.h"
11373 +#define MINI_GPIO_LED_SYSTEM 27
11374 +#define MINI_GPIO_BTN_RESET 11
11376 +#define MINI_GPIO_USB_POWER 8
11378 +#define MINI_KEYS_POLL_INTERVAL 20 /* msecs */
11379 +#define MINI_KEYS_DEBOUNCE_INTERVAL (3 * MINI_KEYS_POLL_INTERVAL)
11381 +static const char *mini_part_probes[] = {
11382 + "tp-link",
11383 + NULL,
11386 +static struct flash_platform_data mini_flash_data = {
11387 + .part_probes = mini_part_probes,
11390 +static struct gpio_led mini_leds_gpio[] __initdata = {
11392 + .name = "easylink:green:system",
11393 + .gpio = MINI_GPIO_LED_SYSTEM,
11394 + .active_low = 1,
11395 + },
11398 +static struct gpio_keys_button mini_gpio_keys[] __initdata = {
11400 + .desc = "reset",
11401 + .type = EV_KEY,
11402 + .code = KEY_RESTART,
11403 + .debounce_interval = MINI_KEYS_DEBOUNCE_INTERVAL,
11404 + .gpio = MINI_GPIO_BTN_RESET,
11405 + .active_low = 0,
11409 +static void __init el_mini_setup(void)
11411 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
11412 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
11414 + ath79_register_m25p80(&mini_flash_data);
11415 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mini_leds_gpio),
11416 + mini_leds_gpio);
11417 + ath79_register_gpio_keys_polled(-1, MINI_KEYS_POLL_INTERVAL,
11418 + ARRAY_SIZE(mini_gpio_keys),
11419 + mini_gpio_keys);
11421 + gpio_request_one(MINI_GPIO_USB_POWER,
11422 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
11423 + "USB power");
11424 + ath79_register_usb();
11426 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
11428 + ath79_register_mdio(0, 0x0);
11429 + ath79_register_eth(0);
11431 + ath79_register_wmac(ee, mac);
11434 +MIPS_MACHINE(ATH79_MACH_EL_MINI, "EL-MINI", "EasyLink EL-MINI",
11435 + el_mini_setup);
11436 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-epg5000.c linux-4.1.43/arch/mips/ath79/mach-epg5000.c
11437 --- linux-4.1.43.orig/arch/mips/ath79/mach-epg5000.c 1970-01-01 01:00:00.000000000 +0100
11438 +++ linux-4.1.43/arch/mips/ath79/mach-epg5000.c 2017-08-06 20:02:15.000000000 +0200
11439 @@ -0,0 +1,178 @@
11441 + * EnGenius EPG5000 board support
11443 + * Copyright (c) 2014 Jon Suphammer <jon@suphammer.net>
11444 + * Copyright (c) 2015 Christian Beier <cb@shoutrlabs.com>
11446 + * This program is free software; you can redistribute it and/or modify it
11447 + * under the terms of the GNU General Public License version 2 as published
11448 + * by the Free Software Foundation.
11449 + */
11451 +#include <linux/platform_device.h>
11452 +#include <linux/ar8216_platform.h>
11454 +#include <asm/mach-ath79/ar71xx_regs.h>
11456 +#include "common.h"
11457 +#include "pci.h"
11458 +#include "dev-ap9x-pci.h"
11459 +#include "dev-gpio-buttons.h"
11460 +#include "dev-eth.h"
11461 +#include "dev-leds-gpio.h"
11462 +#include "dev-m25p80.h"
11463 +#include "dev-usb.h"
11464 +#include "dev-wmac.h"
11465 +#include "machtypes.h"
11466 +#include "nvram.h"
11468 +#define EPG5000_GPIO_LED_WLAN_5G 23
11469 +#define EPG5000_GPIO_LED_WLAN_2G 13
11470 +#define EPG5000_GPIO_LED_POWER_AMBER 2
11471 +#define EPG5000_GPIO_LED_WPS_AMBER 22
11472 +#define EPG5000_GPIO_LED_WPS_BLUE 19
11474 +#define EPG5000_GPIO_BTN_WPS 16
11475 +#define EPG5000_GPIO_BTN_RESET 17
11477 +#define EPG5000_KEYS_POLL_INTERVAL 20 /* msecs */
11478 +#define EPG5000_KEYS_DEBOUNCE_INTERVAL (3 * EPG5000_KEYS_POLL_INTERVAL)
11480 +#define EPG5000_CALDATA_ADDR 0x1fff0000
11481 +#define EPG5000_WMAC_CALDATA_OFFSET 0x1000
11482 +#define EPG5000_PCIE_CALDATA_OFFSET 0x5000
11484 +#define EPG5000_NVRAM_ADDR 0x1f030000
11485 +#define EPG5000_NVRAM_SIZE 0x10000
11487 +static struct gpio_led epg5000_leds_gpio[] __initdata = {
11489 + .name = "epg5000:amber:power",
11490 + .gpio = EPG5000_GPIO_LED_POWER_AMBER,
11491 + .active_low = 1,
11492 + },
11494 + .name = "epg5000:blue:wps",
11495 + .gpio = EPG5000_GPIO_LED_WPS_BLUE,
11496 + .active_low = 1,
11497 + },
11499 + .name = "epg5000:amber:wps",
11500 + .gpio = EPG5000_GPIO_LED_WPS_AMBER,
11501 + .active_low = 1,
11502 + },
11504 + .name = "epg5000:blue:wlan-2g",
11505 + .gpio = EPG5000_GPIO_LED_WLAN_2G,
11506 + .active_low = 1,
11507 + },
11509 + .name = "epg5000:blue:wlan-5g",
11510 + .gpio = EPG5000_GPIO_LED_WLAN_5G,
11511 + .active_low = 1,
11515 +static struct gpio_keys_button epg5000_gpio_keys[] __initdata = {
11517 + .desc = "WPS button",
11518 + .type = EV_KEY,
11519 + .code = KEY_WPS_BUTTON,
11520 + .debounce_interval = EPG5000_KEYS_DEBOUNCE_INTERVAL,
11521 + .gpio = EPG5000_GPIO_BTN_WPS,
11522 + .active_low = 1,
11523 + },
11525 + .desc = "Reset button",
11526 + .type = EV_KEY,
11527 + .code = KEY_RESTART,
11528 + .debounce_interval = EPG5000_KEYS_DEBOUNCE_INTERVAL,
11529 + .gpio = EPG5000_GPIO_BTN_RESET,
11530 + .active_low = 1,
11531 + },
11534 +static struct ar8327_pad_cfg epg5000_ar8327_pad0_cfg = {
11535 + .mode = AR8327_PAD_MAC_RGMII,
11536 + .txclk_delay_en = true,
11537 + .rxclk_delay_en = true,
11538 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL2,
11539 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
11540 + .mac06_exchange_en = true,
11543 +static struct ar8327_platform_data epg5000_ar8327_data = {
11544 + .pad0_cfg = &epg5000_ar8327_pad0_cfg,
11545 + .port0_cfg = {
11546 + .force_link = 1,
11547 + .speed = AR8327_PORT_SPEED_1000,
11548 + .duplex = 1,
11549 + .txpause = 1,
11550 + .rxpause = 1,
11551 + },
11554 +static struct mdio_board_info epg5000_mdio0_info[] = {
11556 + .bus_id = "ag71xx-mdio.0",
11557 + .phy_addr = 0,
11558 + .platform_data = &epg5000_ar8327_data,
11559 + },
11562 +static int epg5000_get_mac(const char *name, char *mac)
11564 + u8 *nvram = (u8 *) KSEG1ADDR(EPG5000_NVRAM_ADDR);
11565 + int err;
11567 + err = ath79_nvram_parse_mac_addr(nvram, EPG5000_NVRAM_SIZE,
11568 + name, mac);
11569 + if (err) {
11570 + pr_err("no MAC address found for %s\n", name);
11571 + return false;
11574 + return true;
11577 +static void __init epg5000_setup(void)
11579 + u8 *caldata = (u8 *) KSEG1ADDR(EPG5000_CALDATA_ADDR);
11580 + u8 mac1[ETH_ALEN];
11582 + ath79_register_m25p80(NULL);
11584 + ath79_register_leds_gpio(-1, ARRAY_SIZE(epg5000_leds_gpio),
11585 + epg5000_leds_gpio);
11586 + ath79_register_gpio_keys_polled(-1, EPG5000_KEYS_POLL_INTERVAL,
11587 + ARRAY_SIZE(epg5000_gpio_keys),
11588 + epg5000_gpio_keys);
11590 + ath79_register_usb();
11592 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
11594 + ath79_register_mdio(0, 0x0);
11596 + mdiobus_register_board_info(epg5000_mdio0_info,
11597 + ARRAY_SIZE(epg5000_mdio0_info));
11599 + /* GMAC0 is connected to an QCA8327N switch */
11600 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
11601 + ath79_eth0_data.phy_mask = BIT(0);
11602 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
11604 + if (epg5000_get_mac("ethaddr=", mac1))
11605 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
11607 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
11608 + ath79_register_eth(0);
11610 + ath79_register_wmac(caldata + EPG5000_WMAC_CALDATA_OFFSET, mac1);
11612 + ath79_register_pci();
11615 +MIPS_MACHINE(ATH79_MACH_EPG5000, "EPG5000",
11616 + "EnGenius EPG5000",
11617 + epg5000_setup);
11618 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-esr1750.c linux-4.1.43/arch/mips/ath79/mach-esr1750.c
11619 --- linux-4.1.43.orig/arch/mips/ath79/mach-esr1750.c 1970-01-01 01:00:00.000000000 +0100
11620 +++ linux-4.1.43/arch/mips/ath79/mach-esr1750.c 2017-08-06 20:02:15.000000000 +0200
11621 @@ -0,0 +1,177 @@
11623 + * EnGenius ESR1750 board support
11625 + * Copyright (c) 2014 Jon Suphammer <jon@suphammer.net>
11627 + * This program is free software; you can redistribute it and/or modify it
11628 + * under the terms of the GNU General Public License version 2 as published
11629 + * by the Free Software Foundation.
11630 + */
11632 +#include <linux/platform_device.h>
11633 +#include <linux/ar8216_platform.h>
11635 +#include <asm/mach-ath79/ar71xx_regs.h>
11637 +#include "common.h"
11638 +#include "pci.h"
11639 +#include "dev-ap9x-pci.h"
11640 +#include "dev-gpio-buttons.h"
11641 +#include "dev-eth.h"
11642 +#include "dev-leds-gpio.h"
11643 +#include "dev-m25p80.h"
11644 +#include "dev-usb.h"
11645 +#include "dev-wmac.h"
11646 +#include "machtypes.h"
11647 +#include "nvram.h"
11649 +#define ESR1750_GPIO_LED_WLAN_5G 23
11650 +#define ESR1750_GPIO_LED_WLAN_2G 13
11651 +#define ESR1750_GPIO_LED_POWER_AMBER 2
11652 +#define ESR1750_GPIO_LED_WPS_AMBER 22
11653 +#define ESR1750_GPIO_LED_WPS_BLUE 19
11655 +#define ESR1750_GPIO_BTN_WPS 16
11656 +#define ESR1750_GPIO_BTN_RESET 17
11658 +#define ESR1750_KEYS_POLL_INTERVAL 20 /* msecs */
11659 +#define ESR1750_KEYS_DEBOUNCE_INTERVAL (3 * ESR1750_KEYS_POLL_INTERVAL)
11661 +#define ESR1750_CALDATA_ADDR 0x1fff0000
11662 +#define ESR1750_WMAC_CALDATA_OFFSET 0x1000
11663 +#define ESR1750_PCIE_CALDATA_OFFSET 0x5000
11665 +#define ESR1750_NVRAM_ADDR 0x1f030000
11666 +#define ESR1750_NVRAM_SIZE 0x10000
11668 +static struct gpio_led esr1750_leds_gpio[] __initdata = {
11670 + .name = "esr1750:amber:power",
11671 + .gpio = ESR1750_GPIO_LED_POWER_AMBER,
11672 + .active_low = 1,
11673 + },
11675 + .name = "esr1750:blue:wps",
11676 + .gpio = ESR1750_GPIO_LED_WPS_BLUE,
11677 + .active_low = 1,
11678 + },
11680 + .name = "esr1750:amber:wps",
11681 + .gpio = ESR1750_GPIO_LED_WPS_AMBER,
11682 + .active_low = 1,
11683 + },
11685 + .name = "esr1750:blue:wlan-2g",
11686 + .gpio = ESR1750_GPIO_LED_WLAN_2G,
11687 + .active_low = 1,
11688 + },
11690 + .name = "esr1750:blue:wlan-5g",
11691 + .gpio = ESR1750_GPIO_LED_WLAN_5G,
11692 + .active_low = 1,
11696 +static struct gpio_keys_button esr1750_gpio_keys[] __initdata = {
11698 + .desc = "WPS button",
11699 + .type = EV_KEY,
11700 + .code = KEY_WPS_BUTTON,
11701 + .debounce_interval = ESR1750_KEYS_DEBOUNCE_INTERVAL,
11702 + .gpio = ESR1750_GPIO_BTN_WPS,
11703 + .active_low = 1,
11704 + },
11706 + .desc = "Reset button",
11707 + .type = EV_KEY,
11708 + .code = KEY_RESTART,
11709 + .debounce_interval = ESR1750_KEYS_DEBOUNCE_INTERVAL,
11710 + .gpio = ESR1750_GPIO_BTN_RESET,
11711 + .active_low = 1,
11712 + },
11715 +static struct ar8327_pad_cfg esr1750_ar8327_pad0_cfg = {
11716 + .mode = AR8327_PAD_MAC_RGMII,
11717 + .txclk_delay_en = true,
11718 + .rxclk_delay_en = true,
11719 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL2,
11720 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
11721 + .mac06_exchange_en = true,
11724 +static struct ar8327_platform_data esr1750_ar8327_data = {
11725 + .pad0_cfg = &esr1750_ar8327_pad0_cfg,
11726 + .port0_cfg = {
11727 + .force_link = 1,
11728 + .speed = AR8327_PORT_SPEED_1000,
11729 + .duplex = 1,
11730 + .txpause = 1,
11731 + .rxpause = 1,
11732 + },
11735 +static struct mdio_board_info esr1750_mdio0_info[] = {
11737 + .bus_id = "ag71xx-mdio.0",
11738 + .phy_addr = 0,
11739 + .platform_data = &esr1750_ar8327_data,
11740 + },
11743 +static int esr1750_get_mac(const char *name, char *mac)
11745 + u8 *nvram = (u8 *) KSEG1ADDR(ESR1750_NVRAM_ADDR);
11746 + int err;
11748 + err = ath79_nvram_parse_mac_addr(nvram, ESR1750_NVRAM_SIZE,
11749 + name, mac);
11750 + if (err) {
11751 + pr_err("no MAC address found for %s\n", name);
11752 + return false;
11755 + return true;
11758 +static void __init esr1750_setup(void)
11760 + u8 *caldata = (u8 *) KSEG1ADDR(ESR1750_CALDATA_ADDR);
11761 + u8 mac1[ETH_ALEN];
11763 + ath79_register_m25p80(NULL);
11765 + ath79_register_leds_gpio(-1, ARRAY_SIZE(esr1750_leds_gpio),
11766 + esr1750_leds_gpio);
11767 + ath79_register_gpio_keys_polled(-1, ESR1750_KEYS_POLL_INTERVAL,
11768 + ARRAY_SIZE(esr1750_gpio_keys),
11769 + esr1750_gpio_keys);
11771 + ath79_register_usb();
11773 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
11775 + ath79_register_mdio(0, 0x0);
11777 + mdiobus_register_board_info(esr1750_mdio0_info,
11778 + ARRAY_SIZE(esr1750_mdio0_info));
11780 + /* GMAC0 is connected to an QCA8327N switch */
11781 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
11782 + ath79_eth0_data.phy_mask = BIT(0);
11783 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
11785 + if (esr1750_get_mac("ethaddr=", mac1))
11786 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
11788 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
11789 + ath79_register_eth(0);
11791 + ath79_register_wmac(caldata + ESR1750_WMAC_CALDATA_OFFSET, mac1);
11793 + ath79_register_pci();
11796 +MIPS_MACHINE(ATH79_MACH_ESR1750, "ESR1750",
11797 + "EnGenius ESR1750",
11798 + esr1750_setup);
11799 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-esr900.c linux-4.1.43/arch/mips/ath79/mach-esr900.c
11800 --- linux-4.1.43.orig/arch/mips/ath79/mach-esr900.c 1970-01-01 01:00:00.000000000 +0100
11801 +++ linux-4.1.43/arch/mips/ath79/mach-esr900.c 2017-08-06 20:02:15.000000000 +0200
11802 @@ -0,0 +1,200 @@
11804 + * EnGenius ESR900 board support
11806 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
11807 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
11809 + * This program is free software; you can redistribute it and/or modify it
11810 + * under the terms of the GNU General Public License version 2 as published
11811 + * by the Free Software Foundation.
11812 + */
11814 +#define pr_fmt(fmt) "esr900: " fmt
11816 +#include <linux/platform_device.h>
11817 +#include <linux/ar8216_platform.h>
11819 +#include <asm/mach-ath79/ar71xx_regs.h>
11821 +#include "common.h"
11822 +#include "pci.h"
11823 +#include "dev-ap9x-pci.h"
11824 +#include "dev-gpio-buttons.h"
11825 +#include "dev-eth.h"
11826 +#include "dev-leds-gpio.h"
11827 +#include "dev-m25p80.h"
11828 +#include "dev-usb.h"
11829 +#include "dev-wmac.h"
11830 +#include "machtypes.h"
11831 +#include "nvram.h"
11833 +#define ESR900_GPIO_LED_POWER 2
11834 +#define ESR900_GPIO_LED_WLAN_2G 13
11835 +#define ESR900_GPIO_LED_WPS_BLUE 19
11836 +#define ESR900_GPIO_LED_WPS_AMBER 22
11837 +#define ESR900_GPIO_LED_WLAN_5G 23
11839 +#define ESR900_GPIO_BTN_WPS 16
11840 +#define ESR900_GPIO_BTN_RESET 17
11842 +#define ESR900_KEYS_POLL_INTERVAL 20 /* msecs */
11843 +#define ESR900_KEYS_DEBOUNCE_INTERVAL (3 * ESR900_KEYS_POLL_INTERVAL)
11845 +#define ESR900_CALDATA_ADDR 0x1fff0000
11846 +#define ESR900_WMAC_CALDATA_OFFSET 0x1000
11847 +#define ESR900_PCIE_CALDATA_OFFSET 0x5000
11849 +#define ESR900_CONFIG_ADDR 0x1f030000
11850 +#define ESR900_CONFIG_SIZE 0x10000
11852 +#define ESR900_LAN_PHYMASK BIT(0)
11853 +#define ESR900_WAN_PHYMASK BIT(5)
11854 +#define ESR900_MDIO_MASK (~(ESR900_LAN_PHYMASK | ESR900_WAN_PHYMASK))
11856 +static struct gpio_led esr900_leds_gpio[] __initdata = {
11858 + .name = "engenius:amber:power",
11859 + .gpio = ESR900_GPIO_LED_POWER,
11860 + .active_low = 1,
11861 + },
11863 + .name = "engenius:blue:wlan-2g",
11864 + .gpio = ESR900_GPIO_LED_WLAN_2G,
11865 + .active_low = 1,
11866 + },
11868 + .name = "engenius:blue:wps",
11869 + .gpio = ESR900_GPIO_LED_WPS_BLUE,
11870 + .active_low = 1,
11871 + },
11873 + .name = "engenius:amber:wps",
11874 + .gpio = ESR900_GPIO_LED_WPS_AMBER,
11875 + .active_low = 1,
11876 + },
11878 + .name = "engenius:blue:wlan-5g",
11879 + .gpio = ESR900_GPIO_LED_WLAN_5G,
11880 + .active_low = 1,
11884 +static struct gpio_keys_button esr900_gpio_keys[] __initdata = {
11886 + .desc = "WPS button",
11887 + .type = EV_KEY,
11888 + .code = KEY_WPS_BUTTON,
11889 + .debounce_interval = ESR900_KEYS_DEBOUNCE_INTERVAL,
11890 + .gpio = ESR900_GPIO_BTN_WPS,
11891 + .active_low = 1,
11892 + },
11894 + .desc = "Reset button",
11895 + .type = EV_KEY,
11896 + .code = KEY_RESTART,
11897 + .debounce_interval = ESR900_KEYS_DEBOUNCE_INTERVAL,
11898 + .gpio = ESR900_GPIO_BTN_RESET,
11899 + .active_low = 1,
11900 + },
11903 +static struct ar8327_pad_cfg esr900_ar8327_pad0_cfg = {
11904 + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
11905 + .mode = AR8327_PAD_MAC_RGMII,
11906 + .txclk_delay_en = true,
11907 + .rxclk_delay_en = true,
11908 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
11909 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
11912 +static struct ar8327_pad_cfg esr900_ar8327_pad6_cfg = {
11913 + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
11914 + .mode = AR8327_PAD_MAC_SGMII,
11915 + .rxclk_delay_en = true,
11916 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
11919 +static struct ar8327_platform_data esr900_ar8327_data = {
11920 + .pad0_cfg = &esr900_ar8327_pad0_cfg,
11921 + .pad6_cfg = &esr900_ar8327_pad6_cfg,
11922 + .port0_cfg = {
11923 + .force_link = 1,
11924 + .speed = AR8327_PORT_SPEED_1000,
11925 + .duplex = 1,
11926 + .txpause = 1,
11927 + .rxpause = 1,
11928 + },
11929 + .port6_cfg = {
11930 + .force_link = 1,
11931 + .speed = AR8327_PORT_SPEED_1000,
11932 + .duplex = 1,
11933 + .txpause = 1,
11934 + .rxpause = 1,
11935 + },
11938 +static struct mdio_board_info esr900_mdio0_info[] = {
11940 + .bus_id = "ag71xx-mdio.0",
11941 + .phy_addr = 0,
11942 + .platform_data = &esr900_ar8327_data,
11943 + },
11946 +static void __init esr900_setup(void)
11948 + const char *config = (char *) KSEG1ADDR(ESR900_CONFIG_ADDR);
11949 + u8 *art = (u8 *) KSEG1ADDR(ESR900_CALDATA_ADDR);
11950 + u8 lan_mac[ETH_ALEN];
11951 + u8 wlan0_mac[ETH_ALEN];
11952 + u8 wlan1_mac[ETH_ALEN];
11954 + if (ath79_nvram_parse_mac_addr(config, ESR900_CONFIG_SIZE,
11955 + "ethaddr=", lan_mac) == 0) {
11956 + ath79_init_local_mac(ath79_eth0_data.mac_addr, lan_mac);
11957 + ath79_init_mac(wlan0_mac, lan_mac, 0);
11958 + ath79_init_mac(wlan1_mac, lan_mac, 1);
11959 + } else {
11960 + pr_err("could not find ethaddr in u-boot environment\n");
11963 + ath79_register_m25p80(NULL);
11965 + ath79_register_leds_gpio(-1, ARRAY_SIZE(esr900_leds_gpio),
11966 + esr900_leds_gpio);
11967 + ath79_register_gpio_keys_polled(-1, ESR900_KEYS_POLL_INTERVAL,
11968 + ARRAY_SIZE(esr900_gpio_keys),
11969 + esr900_gpio_keys);
11971 + ath79_register_usb();
11973 + ath79_register_wmac(art + ESR900_WMAC_CALDATA_OFFSET, wlan0_mac);
11975 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
11977 + ath79_register_mdio(0, 0x0);
11979 + mdiobus_register_board_info(esr900_mdio0_info,
11980 + ARRAY_SIZE(esr900_mdio0_info));
11982 + /* GMAC0 is connected to the RMGII interface */
11983 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
11984 + ath79_eth0_data.phy_mask = ESR900_LAN_PHYMASK;
11985 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
11987 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
11988 + ath79_register_eth(0);
11990 + /* GMAC1 is connected to the SGMII interface */
11991 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
11992 + ath79_eth1_data.speed = SPEED_1000;
11993 + ath79_eth1_data.duplex = DUPLEX_FULL;
11995 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
11996 + ath79_register_eth(1);
11998 + ap91_pci_init(art + ESR900_PCIE_CALDATA_OFFSET, wlan1_mac);
12001 +MIPS_MACHINE(ATH79_MACH_ESR900, "ESR900", "EnGenius ESR900", esr900_setup);
12003 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ew-dorin.c linux-4.1.43/arch/mips/ath79/mach-ew-dorin.c
12004 --- linux-4.1.43.orig/arch/mips/ath79/mach-ew-dorin.c 1970-01-01 01:00:00.000000000 +0100
12005 +++ linux-4.1.43/arch/mips/ath79/mach-ew-dorin.c 2017-08-06 20:02:15.000000000 +0200
12006 @@ -0,0 +1,150 @@
12008 + * EW Dorin board support
12009 + * (based on Atheros Ref. Design AP121)
12010 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
12011 + * Copyright (C) 2012-2015 Embedded Wireless GmbH www.80211.de
12013 + * This program is free software; you can redistribute it and/or modify it
12014 + * under the terms of the GNU General Public License version 2 as published
12015 + * by the Free Software Foundation.
12016 + */
12018 +#include <asm/mach-ath79/ath79.h>
12019 +#include <asm/mach-ath79/ar71xx_regs.h>
12021 +#include "dev-eth.h"
12022 +#include "dev-gpio-buttons.h"
12023 +#include "dev-leds-gpio.h"
12024 +#include "dev-m25p80.h"
12025 +#include "dev-spi.h"
12026 +#include "dev-usb.h"
12027 +#include "dev-wmac.h"
12028 +#include "machtypes.h"
12030 +#define DORIN_KEYS_POLL_INTERVAL 20 /* msecs */
12031 +#define DORIN_KEYS_DEBOUNCE_INTERVAL (3 * DORIN_KEYS_POLL_INTERVAL)
12033 +#define DORIN_CALDATA_OFFSET 0x1000
12034 +#define DORIN_WMAC_MAC_OFFSET 0x1002
12036 +#define DORIN_GPIO_LED_21 21
12037 +#define DORIN_GPIO_LED_22 22
12038 +#define DORIN_GPIO_LED_STATUS 23
12040 +#define DORIN_GPIO_BTN_JUMPSTART 11
12041 +#define DORIN_GPIO_BTN_RESET 6
12043 +static struct gpio_led dorin_leds_gpio[] __initdata = {
12045 + .name = "dorin:green:led21",
12046 + .gpio = DORIN_GPIO_LED_21,
12047 + .active_low = 1,
12048 + },
12050 + .name = "dorin:green:led22",
12051 + .gpio = DORIN_GPIO_LED_22,
12052 + .active_low = 1,
12053 + },
12055 + .name = "dorin:green:status",
12056 + .gpio = DORIN_GPIO_LED_STATUS,
12057 + .active_low = 1,
12058 + },
12061 +static struct gpio_keys_button dorin_gpio_keys[] __initdata = {
12063 + .desc = "jumpstart button",
12064 + .type = EV_KEY,
12065 + .code = KEY_WPS_BUTTON,
12066 + .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
12067 + .gpio = DORIN_GPIO_BTN_JUMPSTART,
12068 + .active_low = 1,
12069 + },
12071 + .desc = "reset button",
12072 + .type = EV_KEY,
12073 + .code = KEY_RESTART,
12074 + .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
12075 + .gpio = DORIN_GPIO_BTN_RESET,
12076 + .active_low = 0,
12080 +static void __init ew_dorin_setup(void)
12082 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12083 + static u8 mac[6];
12085 + ath79_register_m25p80(NULL);
12087 + ath79_register_usb();
12089 + if (ar93xx_wmac_read_mac_address(mac)) {
12090 + ath79_register_wmac(NULL, NULL);
12091 + } else {
12092 + ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
12093 + art + DORIN_WMAC_MAC_OFFSET);
12094 + memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
12097 + mac[3] |= 0x40;
12098 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
12100 + ath79_register_mdio(0, 0x0);
12102 + /* LAN ports */
12103 + ath79_register_eth(1);
12105 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
12106 + dorin_leds_gpio);
12107 + ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
12108 + ARRAY_SIZE(dorin_gpio_keys),
12109 + dorin_gpio_keys);
12112 +MIPS_MACHINE(ATH79_MACH_EW_DORIN, "EW-DORIN", "EmbWir-Dorin",
12113 + ew_dorin_setup);
12116 +static void __init ew_dorin_router_setup(void)
12118 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12119 + static u8 mac[6];
12121 + ath79_register_m25p80(NULL);
12123 + ath79_register_usb();
12125 + if (ar93xx_wmac_read_mac_address(mac)) {
12126 + ath79_register_wmac(NULL, NULL);
12127 + } else {
12128 + ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
12129 + art + DORIN_WMAC_MAC_OFFSET);
12130 + memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
12133 + mac[3] |= 0x40;
12134 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
12136 + mac[3] &= 0x3F;
12137 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
12138 + ath79_setup_ar933x_phy4_switch(true, true);
12140 + ath79_register_mdio(0, 0x0);
12142 + /* LAN ports */
12143 + ath79_register_eth(1);
12145 + /* WAN port */
12146 + ath79_register_eth(0);
12148 + ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
12149 + dorin_leds_gpio);
12150 + ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
12151 + ARRAY_SIZE(dorin_gpio_keys),
12152 + dorin_gpio_keys);
12155 +MIPS_MACHINE(ATH79_MACH_EW_DORIN_ROUTER, "EW-DORIN-ROUTER",
12156 + "EmbWir-Dorin-Router", ew_dorin_router_setup);
12157 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-f9k1115v2.c linux-4.1.43/arch/mips/ath79/mach-f9k1115v2.c
12158 --- linux-4.1.43.orig/arch/mips/ath79/mach-f9k1115v2.c 1970-01-01 01:00:00.000000000 +0100
12159 +++ linux-4.1.43/arch/mips/ath79/mach-f9k1115v2.c 2017-08-06 20:02:15.000000000 +0200
12160 @@ -0,0 +1,190 @@
12162 + * Belkin AC1750DB (F9K1115V2) board support
12164 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
12165 + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
12167 + * This program is free software; you can redistribute it and/or modify it
12168 + * under the terms of the GNU General Public License version 2 as published
12169 + * by the Free Software Foundation.
12170 + */
12172 +#include <linux/gpio.h>
12173 +#include <linux/platform_device.h>
12174 +#include <linux/ar8216_platform.h>
12176 +#include <asm/mach-ath79/ar71xx_regs.h>
12178 +#include "common.h"
12179 +#include "pci.h"
12180 +#include "dev-gpio-buttons.h"
12181 +#include "dev-eth.h"
12182 +#include "dev-leds-gpio.h"
12183 +#include "dev-m25p80.h"
12184 +#include "dev-usb.h"
12185 +#include "dev-wmac.h"
12186 +#include "machtypes.h"
12188 +#define F9K1115V2_GPIO_LED_USB2 4
12189 +#define F9K1115V2_GPIO_LED_WPS_AMBER 14
12190 +#define F9K1115V2_GPIO_LED_STATUS_AMBER 15
12191 +#define F9K1115V2_GPIO_LED_WPS_BLUE 19
12192 +#define F9K1115V2_GPIO_LED_STATUS_BLUE 20
12194 +#define F9K1115V2_GPIO_BTN_WPS 16
12195 +#define F9K1115V2_GPIO_BTN_RESET 17
12197 +#define F9K1115V2_GPIO_USB2_POWER 21
12199 +#define F9K1115V2_KEYS_POLL_INTERVAL 20 /* msecs */
12200 +#define F9K1115V2_KEYS_DEBOUNCE_INTERVAL (3 * F9K1115V2_KEYS_POLL_INTERVAL)
12202 +#define F9K1115V2_WAN_MAC_OFFSET 0
12203 +#define F9K1115V2_LAN_MAC_OFFSET 6
12204 +#define F9K1115V2_WMAC_CALDATA_OFFSET 0x1000
12205 +#define F9K1115V2_PCIE_CALDATA_OFFSET 0x5000
12207 +static struct gpio_led f9k1115v2_leds_gpio[] __initdata = {
12209 + .name = "belkin:amber:status",
12210 + .gpio = F9K1115V2_GPIO_LED_STATUS_AMBER,
12211 + .active_low = 1,
12212 + },
12214 + .name = "belkin:blue:status",
12215 + .gpio = F9K1115V2_GPIO_LED_STATUS_BLUE,
12216 + .active_low = 1,
12217 + },
12219 + .name = "belkin:blue:wps",
12220 + .gpio = F9K1115V2_GPIO_LED_WPS_BLUE,
12221 + .active_low = 1,
12222 + },
12224 + .name = "belkin:amber:wps",
12225 + .gpio = F9K1115V2_GPIO_LED_WPS_AMBER,
12226 + .active_low = 1,
12227 + },
12229 + .name = "belkin:green:usb2",
12230 + .gpio = F9K1115V2_GPIO_LED_USB2,
12231 + .active_low = 1,
12232 + },
12235 +static struct gpio_keys_button f9k1115v2_gpio_keys[] __initdata = {
12237 + .desc = "Reset button",
12238 + .type = EV_KEY,
12239 + .code = KEY_RESTART,
12240 + .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
12241 + .gpio = F9K1115V2_GPIO_BTN_RESET,
12242 + .active_low = 1,
12243 + },
12245 + .desc = "WPS button",
12246 + .type = EV_KEY,
12247 + .code = KEY_WPS_BUTTON,
12248 + .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
12249 + .gpio = F9K1115V2_GPIO_BTN_WPS,
12250 + .active_low = 1,
12251 + },
12254 +static struct ar8327_pad_cfg f9k1115v2_ar8327_pad0_cfg = {
12255 + /* Use the RGMII interface for the GMAC0 of the AR8337 switch */
12256 + .mode = AR8327_PAD_MAC_RGMII,
12257 + .txclk_delay_en = true,
12258 + .rxclk_delay_en = true,
12259 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
12260 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
12261 + .mac06_exchange_en = true,
12264 +static struct ar8327_pad_cfg f9k1115v2_ar8327_pad6_cfg = {
12265 + /* Use the SGMII interface for the GMAC6 of the AR8337 switch */
12266 + .mode = AR8327_PAD_MAC_SGMII,
12267 + .rxclk_delay_en = true,
12268 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
12271 +static struct ar8327_platform_data f9k1115v2_ar8327_data = {
12272 + .pad0_cfg = &f9k1115v2_ar8327_pad0_cfg,
12273 + .pad6_cfg = &f9k1115v2_ar8327_pad6_cfg,
12274 + .port0_cfg = {
12275 + .force_link = 1,
12276 + .speed = AR8327_PORT_SPEED_1000,
12277 + .duplex = 1,
12278 + .txpause = 1,
12279 + .rxpause = 1,
12280 + },
12281 + .port6_cfg = {
12282 + .force_link = 1,
12283 + .speed = AR8327_PORT_SPEED_1000,
12284 + .duplex = 1,
12285 + .txpause = 1,
12286 + .rxpause = 1,
12287 + },
12290 +static struct mdio_board_info f9k1115v2_mdio0_info[] = {
12292 + .bus_id = "ag71xx-mdio.0",
12293 + .phy_addr = 0,
12294 + .platform_data = &f9k1115v2_ar8327_data,
12295 + },
12298 +static void __init f9k1115v2_setup(void)
12300 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12302 + ath79_register_m25p80(NULL);
12304 + ath79_register_leds_gpio(-1, ARRAY_SIZE(f9k1115v2_leds_gpio),
12305 + f9k1115v2_leds_gpio);
12306 + ath79_register_gpio_keys_polled(-1, F9K1115V2_KEYS_POLL_INTERVAL,
12307 + ARRAY_SIZE(f9k1115v2_gpio_keys),
12308 + f9k1115v2_gpio_keys);
12310 + ath79_register_wmac(art + F9K1115V2_WMAC_CALDATA_OFFSET, NULL);
12312 + ath79_register_mdio(0, 0x0);
12313 + mdiobus_register_board_info(f9k1115v2_mdio0_info,
12314 + ARRAY_SIZE(f9k1115v2_mdio0_info));
12316 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
12318 + ath79_init_mac(ath79_eth0_data.mac_addr,
12319 + art + F9K1115V2_WAN_MAC_OFFSET, 0);
12321 + ath79_init_mac(ath79_eth1_data.mac_addr,
12322 + art + F9K1115V2_LAN_MAC_OFFSET, 0);
12324 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
12325 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
12327 + /* GMAC0 is connected to the RMGII interface */
12328 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
12329 + ath79_eth0_data.phy_mask = BIT(0);
12330 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
12332 + ath79_register_eth(0);
12334 + /* GMAC1 is connected to the SGMII interface */
12335 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
12336 + ath79_eth1_data.speed = SPEED_1000;
12337 + ath79_eth1_data.duplex = DUPLEX_FULL;
12339 + ath79_register_eth(1);
12341 + ath79_register_pci();
12343 + ath79_register_usb();
12344 + gpio_request_one(F9K1115V2_GPIO_USB2_POWER,
12345 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
12346 + "USB2 power");
12349 +MIPS_MACHINE(ATH79_MACH_F9K1115V2, "F9K1115V2", "Belkin AC1750DB",
12350 + f9k1115v2_setup);
12351 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gl-ar150.c linux-4.1.43/arch/mips/ath79/mach-gl-ar150.c
12352 --- linux-4.1.43.orig/arch/mips/ath79/mach-gl-ar150.c 1970-01-01 01:00:00.000000000 +0100
12353 +++ linux-4.1.43/arch/mips/ath79/mach-gl-ar150.c 2017-08-06 20:02:15.000000000 +0200
12354 @@ -0,0 +1,125 @@
12356 + * GL_ar150 board support
12358 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
12359 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
12360 + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
12361 + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
12363 + * This program is free software; you can redistribute it and/or modify it
12364 + * under the terms of the GNU General Public License version 2 as published
12365 + * by the Free Software Foundation.
12368 +#include <linux/gpio.h>
12370 +#include <asm/mach-ath79/ath79.h>
12372 +#include "dev-eth.h"
12373 +#include "dev-gpio-buttons.h"
12374 +#include "dev-leds-gpio.h"
12375 +#include "dev-m25p80.h"
12376 +#include "dev-usb.h"
12377 +#include "dev-wmac.h"
12378 +#include "machtypes.h"
12380 +#define GL_AR150_GPIO_LED_WLAN 0
12381 +#define GL_AR150_GPIO_LED_LAN 13
12382 +#define GL_AR150_GPIO_LED_WAN 15
12384 +#define GL_AR150_GPIO_BIN_USB 6
12385 +#define GL_AR150_GPIO_BTN_MANUAL 7
12386 +#define GL_AR150_GPIO_BTN_AUTO 8
12387 +#define GL_AR150_GPIO_BTN_RESET 11
12389 +#define GL_AR150_KEYS_POLL_INTERVAL 20 /* msecs */
12390 +#define GL_AR150_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR150_KEYS_POLL_INTERVAL)
12392 +#define GL_AR150_MAC0_OFFSET 0x0000
12393 +#define GL_AR150_MAC1_OFFSET 0x0000
12394 +#define GL_AR150_CALDATA_OFFSET 0x1000
12395 +#define GL_AR150_WMAC_MAC_OFFSET 0x0000
12397 +static struct gpio_led gl_ar150_leds_gpio[] __initdata = {
12399 + .name = "gl_ar150:wlan",
12400 + .gpio = GL_AR150_GPIO_LED_WLAN,
12401 + .active_low = 0,
12402 + },
12404 + .name = "gl_ar150:lan",
12405 + .gpio = GL_AR150_GPIO_LED_LAN,
12406 + .active_low = 0,
12407 + },
12409 + .name = "gl_ar150:wan",
12410 + .gpio = GL_AR150_GPIO_LED_WAN,
12411 + .active_low = 0,
12412 + .default_state = 1,
12413 + },
12416 +static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = {
12418 + .desc = "BTN_7",
12419 + .type = EV_KEY,
12420 + .code = BTN_7,
12421 + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
12422 + .gpio = GL_AR150_GPIO_BTN_MANUAL,
12423 + .active_low = 0,
12424 + },
12426 + .desc = "BTN_8",
12427 + .type = EV_KEY,
12428 + .code = BTN_8,
12429 + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
12430 + .gpio = GL_AR150_GPIO_BTN_AUTO,
12431 + .active_low = 0,
12432 + },
12434 + .desc = "reset",
12435 + .type = EV_KEY,
12436 + .code = KEY_RESTART,
12437 + .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
12438 + .gpio = GL_AR150_GPIO_BTN_RESET,
12439 + .active_low = 0,
12440 + },
12443 +static void __init gl_ar150_setup(void)
12446 + /* ART base address */
12447 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12449 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
12450 + ath79_setup_ar933x_phy4_switch(false, false);
12452 + /* register flash. */
12453 + ath79_register_m25p80(NULL);
12455 + /* register gpio LEDs and keys */
12456 + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio),
12457 + gl_ar150_leds_gpio);
12458 + ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL,
12459 + ARRAY_SIZE(gl_ar150_gpio_keys),
12460 + gl_ar150_gpio_keys);
12462 + /* enable usb */
12463 + gpio_request_one(GL_AR150_GPIO_BIN_USB,
12464 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
12465 + "USB power");
12466 + ath79_register_usb();
12468 + /* register eth0 as WAN, eth1 as LAN */
12469 + ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0);
12470 + ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0);
12471 + ath79_register_mdio(0, 0x0);
12472 + ath79_register_eth(0);
12473 + ath79_register_eth(1);
12475 + /* register wireless mac with cal data */
12476 + ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET);
12479 +MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup);
12480 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gl-ar300.c linux-4.1.43/arch/mips/ath79/mach-gl-ar300.c
12481 --- linux-4.1.43.orig/arch/mips/ath79/mach-gl-ar300.c 1970-01-01 01:00:00.000000000 +0100
12482 +++ linux-4.1.43/arch/mips/ath79/mach-gl-ar300.c 2017-08-06 20:02:15.000000000 +0200
12483 @@ -0,0 +1,103 @@
12485 + * Domino board support
12487 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
12488 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
12489 + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
12490 + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
12492 + * This program is free software; you can redistribute it and/or modify it
12493 + * under the terms of the GNU General Public License version 2 as published
12494 + * by the Free Software Foundation.
12497 +#include <linux/gpio.h>
12498 +#include <linux/platform_device.h>
12499 +#include <linux/ath9k_platform.h>
12500 +#include <asm/mach-ath79/ar71xx_regs.h>
12501 +#include <asm/mach-ath79/ath79.h>
12503 +#include "common.h"
12504 +#include "dev-eth.h"
12505 +#include "dev-gpio-buttons.h"
12506 +#include "dev-leds-gpio.h"
12507 +#include "dev-m25p80.h"
12508 +#include "dev-usb.h"
12509 +#include "dev-wmac.h"
12510 +#include "machtypes.h"
12512 +#define GL_AR300_GPIO_LED_WLAN 13
12513 +#define GL_AR300_GPIO_LED_WAN 14
12514 +#define GL_AR300_GPIO_BTN_RESET 16
12517 +#define GL_AR300_KEYS_POLL_INTERVAL 20 /* msecs */
12518 +#define GL_AR300_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300_KEYS_POLL_INTERVAL)
12520 +#define GL_AR300_MAC0_OFFSET 0x0000
12521 +#define GL_AR300_MAC1_OFFSET 0x0000
12522 +#define GL_AR300_CALDATA_OFFSET 0x1000
12523 +#define GL_AR300_WMAC_MAC_OFFSET 0x0000
12525 +static struct gpio_led gl_ar300_leds_gpio[] __initdata = {
12527 + .name = "gl_ar300:wlan",
12528 + .gpio = GL_AR300_GPIO_LED_WLAN,
12529 + .active_low = 1,
12530 + },
12532 + .name = "gl_ar300:wan",
12533 + .gpio = GL_AR300_GPIO_LED_WAN,
12534 + .active_low = 1,
12535 + },
12538 +static struct gpio_keys_button gl_ar300_gpio_keys[] __initdata = {
12540 + .desc = "reset",
12541 + .type = EV_KEY,
12542 + .code = KEY_RESTART,
12543 + .debounce_interval = GL_AR300_KEYS_DEBOUNCE_INTERVAL,
12544 + .gpio = GL_AR300_GPIO_BTN_RESET,
12545 + .active_low = 1,
12546 + },
12549 +static void __init gl_ar300_setup(void)
12552 + /* ART base address */
12553 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12555 + /* register flash. */
12556 + ath79_register_m25p80(NULL);
12558 + /* register gpio LEDs and keys */
12559 + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300_leds_gpio),
12560 + gl_ar300_leds_gpio);
12561 + ath79_register_gpio_keys_polled(-1, GL_AR300_KEYS_POLL_INTERVAL,
12562 + ARRAY_SIZE(gl_ar300_gpio_keys),
12563 + gl_ar300_gpio_keys);
12565 + /* enable usb */
12566 + ath79_register_usb();
12567 + ath79_register_mdio(1, 0x0);
12569 + /* register eth0 as WAN, eth1 as LAN */
12570 + ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR300_MAC0_OFFSET, 0);
12571 + ath79_switch_data.phy4_mii_en = 1;
12572 + ath79_switch_data.phy_poll_mask = BIT(4);
12573 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
12574 + ath79_eth0_data.phy_mask = BIT(4);
12575 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
12576 + ath79_register_eth(0);
12578 + ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR300_MAC1_OFFSET, 0);
12579 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
12580 + ath79_register_eth(1);
12582 + /* register wireless mac with cal data */
12583 + ath79_register_wmac(art + GL_AR300_CALDATA_OFFSET, art + GL_AR300_WMAC_MAC_OFFSET);
12586 +MIPS_MACHINE(ATH79_MACH_GL_AR300, "GL-AR300", "GL AR300",gl_ar300_setup);
12587 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gl-domino.c linux-4.1.43/arch/mips/ath79/mach-gl-domino.c
12588 --- linux-4.1.43.orig/arch/mips/ath79/mach-gl-domino.c 1970-01-01 01:00:00.000000000 +0100
12589 +++ linux-4.1.43/arch/mips/ath79/mach-gl-domino.c 2017-08-06 20:02:15.000000000 +0200
12590 @@ -0,0 +1,136 @@
12592 + * Domino board support
12594 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
12595 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
12596 + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
12597 + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
12599 + * This program is free software; you can redistribute it and/or modify it
12600 + * under the terms of the GNU General Public License version 2 as published
12601 + * by the Free Software Foundation.
12604 +#include <linux/gpio.h>
12606 +#include <asm/mach-ath79/ath79.h>
12608 +#include "dev-eth.h"
12609 +#include "dev-gpio-buttons.h"
12610 +#include "dev-leds-gpio.h"
12611 +#include "dev-m25p80.h"
12612 +#include "dev-usb.h"
12613 +#include "dev-wmac.h"
12614 +#include "machtypes.h"
12616 +#define DOMINO_GPIO_LED_WLAN 0
12617 +#define DOMINO_GPIO_LED_WAN 17
12618 +#define DOMINO_GPIO_LED_USB 1
12619 +#define DOMINO_GPIO_LED_LAN1 13
12620 +#define DOMINO_GPIO_LED_LAN2 14
12621 +#define DOMINO_GPIO_LED_LAN3 15
12622 +#define DOMINO_GPIO_LED_LAN4 16
12623 +#define DOMINO_GPIO_LED_SYS 27
12624 +#define DOMINO_GPIO_LED_WPS 26
12625 +#define DOMINO_GPIO_USB_POWER 6
12627 +#define DOMINO_GPIO_BTN_RESET 11
12628 +#define DOMINO_GPIO_BTN_WPS 20
12630 +#define DOMINO_KEYS_POLL_INTERVAL 20 /* msecs */
12631 +#define DOMINO_KEYS_DEBOUNCE_INTERVAL (3 * DOMINO_KEYS_POLL_INTERVAL)
12633 +#define DOMINO_MAC0_OFFSET 0x0000
12634 +#define DOMINO_MAC1_OFFSET 0x0000
12635 +#define DOMINO_CALDATA_OFFSET 0x1000
12636 +#define DOMINO_WMAC_MAC_OFFSET 0x0000
12638 +static struct gpio_led domino_leds_gpio[] __initdata = {
12640 + .name = "domino:blue:wlan",
12641 + .gpio = DOMINO_GPIO_LED_WLAN,
12642 + .active_low = 0,
12643 + },
12645 + .name = "domino:red:wan",
12646 + .gpio = DOMINO_GPIO_LED_WAN,
12647 + .active_low = 1,
12648 + },
12650 + .name = "domino:white:usb",
12651 + .gpio = DOMINO_GPIO_LED_USB,
12652 + .active_low = 0,
12653 + },
12655 + .name = "domino:green:lan1",
12656 + .gpio = DOMINO_GPIO_LED_LAN1,
12657 + .active_low = 0,
12658 + },
12660 + .name = "domino:yellow:wps",
12661 + .gpio = DOMINO_GPIO_LED_WPS,
12662 + .active_low = 1,
12663 + },
12665 + .name = "domino:orange:sys",
12666 + .gpio = DOMINO_GPIO_LED_SYS,
12667 + .active_low = 1,
12668 + },
12671 +static struct gpio_keys_button domino_gpio_keys[] __initdata = {
12673 + .desc = "reset",
12674 + .type = EV_KEY,
12675 + .code = KEY_RESTART,
12676 + .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
12677 + .gpio = DOMINO_GPIO_BTN_RESET,
12678 + .active_low = 0,
12679 + },
12681 + .desc = "wps",
12682 + .type = EV_KEY,
12683 + .code = KEY_WPS_BUTTON,
12684 + .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
12685 + .gpio = DOMINO_GPIO_BTN_WPS,
12686 + .active_low = 0,
12690 +static void __init domino_setup(void)
12693 + /* ART base address */
12694 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
12696 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
12697 + ath79_setup_ar933x_phy4_switch(false, false);
12699 + /* register flash. */
12700 + ath79_register_m25p80(NULL);
12702 + /* register gpio LEDs and keys */
12703 + ath79_register_leds_gpio(-1, ARRAY_SIZE(domino_leds_gpio),
12704 + domino_leds_gpio);
12705 + ath79_register_gpio_keys_polled(-1, DOMINO_KEYS_POLL_INTERVAL,
12706 + ARRAY_SIZE(domino_gpio_keys),
12707 + domino_gpio_keys);
12709 + gpio_request_one(DOMINO_GPIO_USB_POWER,
12710 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
12711 + "USB power");
12712 + /* enable usb */
12713 + ath79_register_usb();
12715 + /* register eth0 as WAN, eth1 as LAN */
12716 + ath79_init_mac(ath79_eth0_data.mac_addr, art+DOMINO_MAC0_OFFSET, 0);
12717 + ath79_init_mac(ath79_eth1_data.mac_addr, art+DOMINO_MAC1_OFFSET, 0);
12718 + ath79_register_mdio(0, 0x0);
12719 + ath79_register_eth(0);
12720 + ath79_register_eth(1);
12722 + /* register wireless mac with cal data */
12723 + ath79_register_wmac(art + DOMINO_CALDATA_OFFSET, art + DOMINO_WMAC_MAC_OFFSET);
12726 +MIPS_MACHINE(ATH79_MACH_GL_DOMINO, "DOMINO", "Domino Pi", domino_setup);
12727 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gl-inet.c linux-4.1.43/arch/mips/ath79/mach-gl-inet.c
12728 --- linux-4.1.43.orig/arch/mips/ath79/mach-gl-inet.c 1970-01-01 01:00:00.000000000 +0100
12729 +++ linux-4.1.43/arch/mips/ath79/mach-gl-inet.c 2017-08-06 20:02:15.000000000 +0200
12730 @@ -0,0 +1,104 @@
12732 + * GL-CONNECT iNet board support
12734 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
12735 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
12736 + * Copyright (C) 2013 alzhao <alzhao@gmail.com>
12737 + * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
12739 + * This program is free software; you can redistribute it and/or modify it
12740 + * under the terms of the GNU General Public License version 2 as published
12741 + * by the Free Software Foundation.
12742 + */
12744 +#include <linux/gpio.h>
12746 +#include <asm/mach-ath79/ath79.h>
12748 +#include "dev-eth.h"
12749 +#include "dev-gpio-buttons.h"
12750 +#include "dev-leds-gpio.h"
12751 +#include "dev-m25p80.h"
12752 +#include "dev-usb.h"
12753 +#include "dev-wmac.h"
12754 +#include "machtypes.h"
12756 +#define GL_INET_GPIO_LED_WLAN 0
12757 +#define GL_INET_GPIO_LED_LAN 13
12758 +#define GL_INET_GPIO_BTN_RESET 11
12760 +#define GL_INET_KEYS_POLL_INTERVAL 20 /* msecs */
12761 +#define GL_INET_KEYS_DEBOUNCE_INTERVAL (3 * GL_INET_KEYS_POLL_INTERVAL)
12763 +static const char * gl_inet_part_probes[] = {
12764 + "tp-link", /* dont change, this will use tplink parser */
12765 + NULL ,
12768 +static struct flash_platform_data gl_inet_flash_data = {
12769 + .part_probes = gl_inet_part_probes,
12772 +static struct gpio_led gl_inet_leds_gpio[] __initdata = {
12774 + .name = "gl-connect:red:wlan",
12775 + .gpio = GL_INET_GPIO_LED_WLAN,
12776 + .active_low = 0,
12777 + },
12779 + .name = "gl-connect:green:lan",
12780 + .gpio = GL_INET_GPIO_LED_LAN,
12781 + .active_low = 0,
12782 + .default_state = 1,
12783 + },
12786 +static struct gpio_keys_button gl_inet_gpio_keys[] __initdata = {
12788 + .desc = "reset",
12789 + .type = EV_KEY,
12790 + .code = KEY_RESTART,
12791 + .debounce_interval = GL_INET_KEYS_DEBOUNCE_INTERVAL,
12792 + .gpio = GL_INET_GPIO_BTN_RESET,
12793 + .active_low = 0,
12797 +static void __init gl_inet_setup(void)
12799 + /* get the mac address which is stored in the 1st 64k uboot MTD */
12800 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
12802 + /* get the art address, which is the last 64K. By using
12803 + 0x1fff1000, it doesn't matter it is 4M, 8M or 16M flash */
12804 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
12806 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
12807 + ath79_setup_ar933x_phy4_switch(false, false);
12809 + /* register flash. MTD will use tp-link parser to parser MTD */
12810 + ath79_register_m25p80(&gl_inet_flash_data);
12812 + /* register gpio LEDs and keys */
12813 + ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_inet_leds_gpio),
12814 + gl_inet_leds_gpio);
12815 + ath79_register_gpio_keys_polled(-1, GL_INET_KEYS_POLL_INTERVAL,
12816 + ARRAY_SIZE(gl_inet_gpio_keys),
12817 + gl_inet_gpio_keys);
12819 + /* enable usb */
12820 + ath79_register_usb();
12822 + /* register eth0 as WAN, eth1 as LAN */
12823 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
12824 + ath79_register_mdio(0, 0x0);
12825 + ath79_register_eth(0);
12826 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
12827 + ath79_register_eth(1);
12829 + /* register wireless mac with cal data */
12830 + ath79_register_wmac(ee, mac);
12833 +MIPS_MACHINE(ATH79_MACH_GL_INET, "GL-INET", "GL-CONNECT INET v1",
12834 + gl_inet_setup);
12835 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gs-minibox-v1.c linux-4.1.43/arch/mips/ath79/mach-gs-minibox-v1.c
12836 --- linux-4.1.43.orig/arch/mips/ath79/mach-gs-minibox-v1.c 1970-01-01 01:00:00.000000000 +0100
12837 +++ linux-4.1.43/arch/mips/ath79/mach-gs-minibox-v1.c 2017-08-06 20:02:15.000000000 +0200
12838 @@ -0,0 +1,85 @@
12840 + * Gainstrong MiniBox V1.0 board support
12843 + * This program is free software; you can redistribute it and/or modify it
12844 + * under the terms of the GNU General Public License version 2 as published
12845 + * by the Free Software Foundation.
12846 + */
12848 +#include <linux/gpio.h>
12850 +#include <asm/mach-ath79/ath79.h>
12851 +#include <asm/mach-ath79/ar71xx_regs.h>
12853 +#include "common.h"
12854 +#include "dev-eth.h"
12855 +#include "dev-gpio-buttons.h"
12856 +#include "dev-leds-gpio.h"
12857 +#include "dev-m25p80.h"
12858 +#include "dev-usb.h"
12859 +#include "dev-wmac.h"
12860 +#include "machtypes.h"
12862 +#define GS_MINIBOX_V1_GPIO_BTN_RESET 11
12864 +#define GS_MINIBOX_V1_GPIO_LED_SYSTEM 1
12866 +#define GS_MINIBOX_V1_KEYS_POLL_INTERVAL 20 /* msecs */
12867 +#define GS_MINIBOX_V1_KEYS_DEBOUNCE_INTERVAL (3 * GS_MINIBOX_V1_KEYS_POLL_INTERVAL)
12869 +static const char *gs_minibox_v1_part_probes[] = {
12870 + "tp-link",
12871 + NULL,
12874 +static struct flash_platform_data gs_minibox_v1_flash_data = {
12875 + .part_probes = gs_minibox_v1_part_probes,
12878 +static struct gpio_led gs_minibox_v1_leds_gpio[] __initdata = {
12880 + .name = "minibox-v1:green:system",
12881 + .gpio = GS_MINIBOX_V1_GPIO_LED_SYSTEM,
12882 + .active_low = 1,
12883 + },
12886 +static struct gpio_keys_button gs_minibox_v1_gpio_keys[] __initdata = {
12888 + .desc = "reset",
12889 + .type = EV_KEY,
12890 + .code = KEY_RESTART,
12891 + .debounce_interval = GS_MINIBOX_V1_KEYS_DEBOUNCE_INTERVAL,
12892 + .gpio = GS_MINIBOX_V1_GPIO_BTN_RESET,
12893 + .active_low = 0,
12894 + },
12897 +static void __init gs_minibox_v1_setup(void)
12899 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
12900 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
12902 + ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_minibox_v1_leds_gpio),
12903 + gs_minibox_v1_leds_gpio);
12905 + ath79_register_gpio_keys_polled(-1, GS_MINIBOX_V1_KEYS_POLL_INTERVAL,
12906 + ARRAY_SIZE(gs_minibox_v1_gpio_keys),
12907 + gs_minibox_v1_gpio_keys);
12909 + ath79_register_usb();
12911 + ath79_register_m25p80(&gs_minibox_v1_flash_data);
12912 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
12913 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
12915 + ath79_register_mdio(0, 0x0);
12916 + ath79_register_eth(1);
12917 + ath79_register_eth(0);
12919 + ath79_register_wmac(ee, mac);
12922 +MIPS_MACHINE(ATH79_MACH_GS_MINIBOX_V1, "MINIBOX-V1",
12923 + "MiniBox V1.0", gs_minibox_v1_setup);
12924 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-gs-oolite.c linux-4.1.43/arch/mips/ath79/mach-gs-oolite.c
12925 --- linux-4.1.43.orig/arch/mips/ath79/mach-gs-oolite.c 1970-01-01 01:00:00.000000000 +0100
12926 +++ linux-4.1.43/arch/mips/ath79/mach-gs-oolite.c 2017-08-06 20:02:15.000000000 +0200
12927 @@ -0,0 +1,103 @@
12929 + * Oolite board support
12932 + * This program is free software; you can redistribute it and/or modify it
12933 + * under the terms of the GNU General Public License version 2 as published
12934 + * by the Free Software Foundation.
12935 + */
12937 +#include <linux/gpio.h>
12939 +#include <asm/mach-ath79/ath79.h>
12940 +#include <asm/mach-ath79/ar71xx_regs.h>
12942 +#include "common.h"
12943 +#include "dev-eth.h"
12944 +#include "dev-gpio-buttons.h"
12945 +#include "dev-leds-gpio.h"
12946 +#include "dev-m25p80.h"
12947 +#include "dev-wmac.h"
12948 +#include "machtypes.h"
12949 +#include "dev-usb.h"
12951 +#define GS_OOLITE_GPIO_BTN6 6
12952 +#define GS_OOLITE_GPIO_BTN7 7
12953 +#define GS_OOLITE_GPIO_BTN_RESET 11
12955 +#define GS_OOLITE_GPIO_LED_SYSTEM 27
12957 +#define GS_OOLITE_KEYS_POLL_INTERVAL 20 /* msecs */
12958 +#define GS_OOLITE_KEYS_DEBOUNCE_INTERVAL (3 * GS_OOLITE_KEYS_POLL_INTERVAL)
12960 +static const char *gs_oolite_part_probes[] = {
12961 + "tp-link",
12962 + NULL,
12965 +static struct flash_platform_data gs_oolite_flash_data = {
12966 + .part_probes = gs_oolite_part_probes,
12969 +static struct gpio_led gs_oolite_leds_gpio[] __initdata = {
12971 + .name = "oolite:red:system",
12972 + .gpio = GS_OOLITE_GPIO_LED_SYSTEM,
12973 + .active_low = 1,
12974 + },
12977 +static struct gpio_keys_button gs_oolite_gpio_keys[] __initdata = {
12979 + .desc = "reset",
12980 + .type = EV_KEY,
12981 + .code = KEY_RESTART,
12982 + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
12983 + .gpio = GS_OOLITE_GPIO_BTN_RESET,
12984 + .active_low = 0,
12985 + },
12987 + .desc = "BTN_6",
12988 + .type = EV_KEY,
12989 + .code = BTN_6,
12990 + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
12991 + .gpio = GS_OOLITE_GPIO_BTN6,
12992 + .active_low = 0,
12993 + },
12995 + .desc = "BTN_7",
12996 + .type = EV_KEY,
12997 + .code = BTN_7,
12998 + .debounce_interval = GS_OOLITE_KEYS_DEBOUNCE_INTERVAL,
12999 + .gpio = GS_OOLITE_GPIO_BTN7,
13000 + .active_low = 0,
13001 + },
13004 +static void __init gs_oolite_setup(void)
13006 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
13007 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
13009 + ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_oolite_leds_gpio),
13010 + gs_oolite_leds_gpio);
13012 + ath79_register_gpio_keys_polled(-1, GS_OOLITE_KEYS_POLL_INTERVAL,
13013 + ARRAY_SIZE(gs_oolite_gpio_keys),
13014 + gs_oolite_gpio_keys);
13016 + ath79_register_usb();
13018 + ath79_register_m25p80(&gs_oolite_flash_data);
13019 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
13020 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
13022 + ath79_register_mdio(0, 0x0);
13023 + ath79_register_eth(1);
13024 + ath79_register_eth(0);
13026 + ath79_register_wmac(ee, mac);
13029 +MIPS_MACHINE(ATH79_MACH_GS_OOLITE, "GS-OOLITE",
13030 + "Oolite V1.0", gs_oolite_setup);
13031 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-hiwifi-hc6361.c linux-4.1.43/arch/mips/ath79/mach-hiwifi-hc6361.c
13032 --- linux-4.1.43.orig/arch/mips/ath79/mach-hiwifi-hc6361.c 1970-01-01 01:00:00.000000000 +0100
13033 +++ linux-4.1.43/arch/mips/ath79/mach-hiwifi-hc6361.c 2017-08-06 20:02:15.000000000 +0200
13034 @@ -0,0 +1,115 @@
13036 + * HiWiFi HC6361 board support
13038 + * Copyright (C) 2012-2013 eric
13039 + * Copyright (C) 2014 Yousong Zhou <yszhou4tech@gmail.com>
13041 + * This program is free software; you can redistribute it and/or modify it
13042 + * under the terms of the GNU General Public License version 2 as published
13043 + * by the Free Software Foundation.
13044 + */
13046 +#include <linux/gpio.h>
13047 +#include <linux/proc_fs.h>
13049 +#include <asm/mach-ath79/ath79.h>
13050 +#include <asm/mach-ath79/ar71xx_regs.h>
13052 +#include "common.h"
13053 +#include "dev-eth.h"
13054 +#include "dev-gpio-buttons.h"
13055 +#include "dev-leds-gpio.h"
13056 +#include "dev-m25p80.h"
13057 +#include "dev-usb.h"
13058 +#include "dev-wmac.h"
13059 +#include "machtypes.h"
13061 +#define HIWIFI_HC6361_GPIO_LED_WLAN_2P4 0 /* 2.4G WLAN LED */
13062 +#define HIWIFI_HC6361_GPIO_LED_SYSTEM 1 /* System LED */
13063 +#define HIWIFI_HC6361_GPIO_LED_INTERNET 27 /* Internet LED */
13065 +#define HIWIFI_HC6361_GPIO_USBPOWER 20 /* USB power control */
13066 +#define HIWIFI_HC6361_GPIO_BTN_RST 11 /* Reset button */
13068 +#define HIWIFI_HC6361_KEYS_POLL_INTERVAL 20 /* msecs */
13069 +#define HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL \
13070 + (3 * HIWIFI_HC6361_KEYS_POLL_INTERVAL)
13072 +static struct gpio_led hiwifi_leds_gpio[] __initdata = {
13074 + .name = "hiwifi:blue:wlan-2p4",
13075 + .gpio = HIWIFI_HC6361_GPIO_LED_WLAN_2P4,
13076 + .active_low = 1,
13077 + }, {
13078 + .name = "hiwifi:blue:system",
13079 + .gpio = HIWIFI_HC6361_GPIO_LED_SYSTEM,
13080 + .active_low = 1,
13081 + }, {
13082 + .name = "hiwifi:blue:internet",
13083 + .gpio = HIWIFI_HC6361_GPIO_LED_INTERNET,
13084 + .active_low = 1,
13088 +static struct gpio_keys_button hiwifi_gpio_keys[] __initdata = {
13090 + .desc = "reset",
13091 + .type = EV_KEY,
13092 + .code = KEY_RESTART,
13093 + .debounce_interval = HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL,
13094 + .gpio = HIWIFI_HC6361_GPIO_BTN_RST,
13095 + .active_low = 1,
13099 +static void __init get_mac_from_bdinfo(u8 *mac, void *bdinfo)
13101 + if (sscanf(bdinfo, "fac_mac = %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
13102 + &mac[0], &mac[1], &mac[2], &mac[3],
13103 + &mac[4], &mac[5]) == 6) {
13104 + return;
13107 + printk(KERN_WARNING "Parsing MAC address failed.\n");
13108 + memcpy(mac, "\x00\xba\xbe\x00\x00\x00", 6);
13111 +static void __init hiwifi_hc6361_setup(void)
13113 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
13114 + u8 mac[6];
13116 + ath79_setup_ar933x_phy4_switch(false, false);
13118 + ath79_register_m25p80(NULL);
13119 + ath79_gpio_function_enable(
13120 + AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
13121 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
13122 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
13123 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
13124 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
13126 + ath79_register_leds_gpio(-1, ARRAY_SIZE(hiwifi_leds_gpio),
13127 + hiwifi_leds_gpio);
13128 + ath79_register_gpio_keys_polled(-1, HIWIFI_HC6361_KEYS_POLL_INTERVAL,
13129 + ARRAY_SIZE(hiwifi_gpio_keys),
13130 + hiwifi_gpio_keys);
13131 + gpio_request_one(HIWIFI_HC6361_GPIO_USBPOWER,
13132 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
13133 + "USB power");
13134 + ath79_register_usb();
13136 + get_mac_from_bdinfo(mac, (void *) KSEG1ADDR(0x1f010180));
13137 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
13138 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
13140 + ath79_register_mdio(0, 0x0);
13142 + ath79_register_eth(1);
13143 + ath79_register_eth(0);
13145 + ath79_register_wmac(ee, mac);
13148 +MIPS_MACHINE(ATH79_MACH_HIWIFI_HC6361, "HiWiFi-HC6361",
13149 + "HiWiFi HC6361", hiwifi_hc6361_setup);
13150 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-hornet-ub.c linux-4.1.43/arch/mips/ath79/mach-hornet-ub.c
13151 --- linux-4.1.43.orig/arch/mips/ath79/mach-hornet-ub.c 1970-01-01 01:00:00.000000000 +0100
13152 +++ linux-4.1.43/arch/mips/ath79/mach-hornet-ub.c 2017-08-06 20:02:15.000000000 +0200
13153 @@ -0,0 +1,142 @@
13155 + * ALFA NETWORK Hornet-UB board support
13157 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
13159 + * This program is free software; you can redistribute it and/or modify it
13160 + * under the terms of the GNU General Public License version 2 as published
13161 + * by the Free Software Foundation.
13162 + */
13164 +#include <linux/gpio.h>
13166 +#include <asm/mach-ath79/ath79.h>
13167 +#include <asm/mach-ath79/ar71xx_regs.h>
13169 +#include "common.h"
13170 +#include "dev-eth.h"
13171 +#include "dev-gpio-buttons.h"
13172 +#include "dev-leds-gpio.h"
13173 +#include "dev-m25p80.h"
13174 +#include "dev-usb.h"
13175 +#include "dev-wmac.h"
13176 +#include "machtypes.h"
13178 +#define HORNET_UB_GPIO_LED_WLAN 0
13179 +#define HORNET_UB_GPIO_LED_USB 1
13180 +#define HORNET_UB_GPIO_LED_LAN 13
13181 +#define HORNET_UB_GPIO_LED_WAN 17
13182 +#define HORNET_UB_GPIO_LED_WPS 27
13183 +#define HORNET_UB_GPIO_EXT_LNA 28
13185 +#define HORNET_UB_GPIO_BTN_RESET 12
13186 +#define HORNET_UB_GPIO_BTN_WPS 11
13188 +#define HORNET_UB_GPIO_USB_POWER 26
13190 +#define HORNET_UB_KEYS_POLL_INTERVAL 20 /* msecs */
13191 +#define HORNET_UB_KEYS_DEBOUNCE_INTERVAL (3 * HORNET_UB_KEYS_POLL_INTERVAL)
13193 +#define HORNET_UB_MAC0_OFFSET 0x0000
13194 +#define HORNET_UB_MAC1_OFFSET 0x0006
13195 +#define HORNET_UB_CALDATA_OFFSET 0x1000
13197 +static struct gpio_led hornet_ub_leds_gpio[] __initdata = {
13199 + .name = "alfa:blue:lan",
13200 + .gpio = HORNET_UB_GPIO_LED_LAN,
13201 + .active_low = 0,
13202 + },
13204 + .name = "alfa:blue:usb",
13205 + .gpio = HORNET_UB_GPIO_LED_USB,
13206 + .active_low = 0,
13207 + },
13209 + .name = "alfa:blue:wan",
13210 + .gpio = HORNET_UB_GPIO_LED_WAN,
13211 + .active_low = 1,
13212 + },
13214 + .name = "alfa:blue:wlan",
13215 + .gpio = HORNET_UB_GPIO_LED_WLAN,
13216 + .active_low = 0,
13217 + },
13219 + .name = "alfa:blue:wps",
13220 + .gpio = HORNET_UB_GPIO_LED_WPS,
13221 + .active_low = 1,
13222 + },
13225 +static struct gpio_keys_button hornet_ub_gpio_keys[] __initdata = {
13227 + .desc = "WPS button",
13228 + .type = EV_KEY,
13229 + .code = KEY_WPS_BUTTON,
13230 + .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
13231 + .gpio = HORNET_UB_GPIO_BTN_WPS,
13232 + .active_low = 0,
13233 + },
13235 + .desc = "Reset button",
13236 + .type = EV_KEY,
13237 + .code = KEY_RESTART,
13238 + .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
13239 + .gpio = HORNET_UB_GPIO_BTN_RESET,
13240 + .active_low = 1,
13244 +static void __init hornet_ub_gpio_setup(void)
13246 + u32 t;
13248 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
13249 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
13250 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
13251 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
13252 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
13254 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
13255 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
13256 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
13258 + gpio_request_one(HORNET_UB_GPIO_USB_POWER,
13259 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
13260 + "USB power");
13261 + gpio_request_one(HORNET_UB_GPIO_EXT_LNA,
13262 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
13263 + "external LNA0");
13267 +static void __init hornet_ub_setup(void)
13269 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
13271 + hornet_ub_gpio_setup();
13273 + ath79_register_m25p80(NULL);
13274 + ath79_register_leds_gpio(-1, ARRAY_SIZE(hornet_ub_leds_gpio),
13275 + hornet_ub_leds_gpio);
13276 + ath79_register_gpio_keys_polled(-1, HORNET_UB_KEYS_POLL_INTERVAL,
13277 + ARRAY_SIZE(hornet_ub_gpio_keys),
13278 + hornet_ub_gpio_keys);
13280 + ath79_init_mac(ath79_eth1_data.mac_addr,
13281 + art + HORNET_UB_MAC0_OFFSET, 0);
13282 + ath79_init_mac(ath79_eth0_data.mac_addr,
13283 + art + HORNET_UB_MAC1_OFFSET, 0);
13285 + ath79_register_mdio(0, 0x0);
13287 + ath79_register_eth(1);
13288 + ath79_register_eth(0);
13290 + ath79_register_wmac(art + HORNET_UB_CALDATA_OFFSET, NULL);
13291 + ath79_register_usb();
13294 +MIPS_MACHINE(ATH79_MACH_HORNET_UB, "HORNET-UB", "ALFA NETWORK Hornet-UB",
13295 + hornet_ub_setup);
13296 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ja76pf.c linux-4.1.43/arch/mips/ath79/mach-ja76pf.c
13297 --- linux-4.1.43.orig/arch/mips/ath79/mach-ja76pf.c 1970-01-01 01:00:00.000000000 +0100
13298 +++ linux-4.1.43/arch/mips/ath79/mach-ja76pf.c 2017-08-06 20:02:15.000000000 +0200
13299 @@ -0,0 +1,190 @@
13301 + * jjPlus JA76PF board support
13302 + */
13304 +#include <linux/i2c.h>
13305 +#include <linux/i2c-gpio.h>
13306 +#include <linux/platform_device.h>
13308 +#include <asm/mach-ath79/ath79.h>
13310 +#include "dev-eth.h"
13311 +#include "dev-gpio-buttons.h"
13312 +#include "dev-leds-gpio.h"
13313 +#include "dev-m25p80.h"
13314 +#include "dev-usb.h"
13315 +#include "machtypes.h"
13316 +#include "pci.h"
13318 +#define JA76PF_KEYS_POLL_INTERVAL 20 /* msecs */
13319 +#define JA76PF_KEYS_DEBOUNCE_INTERVAL (3 * JA76PF_KEYS_POLL_INTERVAL)
13321 +#define JA76PF_GPIO_I2C_SCL 0
13322 +#define JA76PF_GPIO_I2C_SDA 1
13323 +#define JA76PF_GPIO_LED_1 5
13324 +#define JA76PF_GPIO_LED_2 4
13325 +#define JA76PF_GPIO_LED_3 3
13326 +#define JA76PF_GPIO_BTN_RESET 11
13328 +static struct gpio_led ja76pf_leds_gpio[] __initdata = {
13330 + .name = "jjplus:green:led1",
13331 + .gpio = JA76PF_GPIO_LED_1,
13332 + .active_low = 1,
13333 + }, {
13334 + .name = "jjplus:green:led2",
13335 + .gpio = JA76PF_GPIO_LED_2,
13336 + .active_low = 1,
13337 + }, {
13338 + .name = "jjplus:green:led3",
13339 + .gpio = JA76PF_GPIO_LED_3,
13340 + .active_low = 1,
13344 +static struct gpio_keys_button ja76pf_gpio_keys[] __initdata = {
13346 + .desc = "reset",
13347 + .type = EV_KEY,
13348 + .code = KEY_RESTART,
13349 + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
13350 + .gpio = JA76PF_GPIO_BTN_RESET,
13351 + .active_low = 1,
13355 +static struct i2c_gpio_platform_data ja76pf_i2c_gpio_data = {
13356 + .sda_pin = JA76PF_GPIO_I2C_SDA,
13357 + .scl_pin = JA76PF_GPIO_I2C_SCL,
13360 +static struct platform_device ja76pf_i2c_gpio_device = {
13361 + .name = "i2c-gpio",
13362 + .id = 0,
13363 + .dev = {
13364 + .platform_data = &ja76pf_i2c_gpio_data,
13368 +static const char *ja76pf_part_probes[] = {
13369 + "RedBoot",
13370 + NULL,
13373 +static struct flash_platform_data ja76pf_flash_data = {
13374 + .part_probes = ja76pf_part_probes,
13377 +#define JA76PF_WAN_PHYMASK (1 << 4)
13378 +#define JA76PF_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 < 3))
13379 +#define JA76PF_MDIO_PHYMASK (JA76PF_LAN_PHYMASK | JA76PF_WAN_PHYMASK)
13381 +static void __init ja76pf_init(void)
13383 + ath79_register_m25p80(&ja76pf_flash_data);
13385 + ath79_register_mdio(0, ~JA76PF_MDIO_PHYMASK);
13387 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
13388 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13389 + ath79_eth0_data.phy_mask = JA76PF_LAN_PHYMASK;
13391 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
13392 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13393 + ath79_eth1_data.phy_mask = JA76PF_WAN_PHYMASK;
13394 + ath79_eth1_data.speed = SPEED_1000;
13395 + ath79_eth1_data.duplex = DUPLEX_FULL;
13397 + ath79_register_eth(0);
13398 + ath79_register_eth(1);
13400 + platform_device_register(&ja76pf_i2c_gpio_device);
13402 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
13403 + ja76pf_leds_gpio);
13405 + ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
13406 + ARRAY_SIZE(ja76pf_gpio_keys),
13407 + ja76pf_gpio_keys);
13409 + ath79_register_usb();
13410 + ath79_register_pci();
13413 +MIPS_MACHINE(ATH79_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);
13415 +#define JA76PF2_GPIO_LED_D2 5
13416 +#define JA76PF2_GPIO_LED_D3 4
13417 +#define JA76PF2_GPIO_LED_D4 3
13418 +#define JA76PF2_GPIO_BTN_RESET 7
13419 +#define JA76PF2_GPIO_BTN_WPS 8
13421 +static struct gpio_led ja76pf2_leds_gpio[] __initdata = {
13423 + .name = "jjplus:green:led1",
13424 + .gpio = JA76PF2_GPIO_LED_D2,
13425 + .active_low = 1,
13426 + }, {
13427 + .name = "jjplus:green:led2",
13428 + .gpio = JA76PF2_GPIO_LED_D3,
13429 + .active_low = 0,
13430 + }, {
13431 + .name = "jjplus:green:led3",
13432 + .gpio = JA76PF2_GPIO_LED_D4,
13433 + .active_low = 0,
13437 +static struct gpio_keys_button ja76pf2_gpio_keys[] __initdata = {
13439 + .desc = "reset",
13440 + .type = EV_KEY,
13441 + .code = KEY_RESTART,
13442 + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
13443 + .gpio = JA76PF2_GPIO_BTN_RESET,
13444 + .active_low = 1,
13445 + },
13447 + .desc = "wps",
13448 + .type = EV_KEY,
13449 + .code = KEY_WPS_BUTTON,
13450 + .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
13451 + .gpio = JA76PF2_GPIO_BTN_WPS,
13452 + .active_low = 1,
13453 + },
13456 +#define JA76PF2_LAN_PHYMASK BIT(0)
13457 +#define JA76PF2_WAN_PHYMASK BIT(4)
13458 +#define JA76PF2_MDIO_PHYMASK (JA76PF2_LAN_PHYMASK | JA76PF2_WAN_PHYMASK)
13460 +static void __init ja76pf2_init(void)
13462 + ath79_register_m25p80(&ja76pf_flash_data);
13464 + ath79_register_mdio(0, ~JA76PF2_MDIO_PHYMASK);
13466 + /* MAC0 is connected to the CPU port of the AR8316 switch */
13467 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
13468 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13469 + ath79_eth0_data.phy_mask = BIT(0);
13471 + /* MAC1 is connected to the PHY4 of the AR8316 switch */
13472 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
13473 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13474 + ath79_eth1_data.phy_mask = BIT(4);
13476 + ath79_register_eth(0);
13477 + ath79_register_eth(1);
13479 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf2_leds_gpio),
13480 + ja76pf2_leds_gpio);
13482 + ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
13483 + ARRAY_SIZE(ja76pf2_gpio_keys),
13484 + ja76pf2_gpio_keys);
13486 + ath79_register_pci();
13489 +MIPS_MACHINE(ATH79_MACH_JA76PF2, "JA76PF2", "jjPlus JA76PF2", ja76pf2_init);
13490 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-jwap003.c linux-4.1.43/arch/mips/ath79/mach-jwap003.c
13491 --- linux-4.1.43.orig/arch/mips/ath79/mach-jwap003.c 1970-01-01 01:00:00.000000000 +0100
13492 +++ linux-4.1.43/arch/mips/ath79/mach-jwap003.c 2017-08-06 20:02:15.000000000 +0200
13493 @@ -0,0 +1,95 @@
13495 + * jjPlus JWAP003 board support
13497 + */
13499 +#include <linux/i2c.h>
13500 +#include <linux/i2c-gpio.h>
13501 +#include <linux/platform_device.h>
13503 +#include <asm/mach-ath79/ath79.h>
13505 +#include "dev-eth.h"
13506 +#include "dev-m25p80.h"
13507 +#include "dev-gpio-buttons.h"
13508 +#include "dev-usb.h"
13509 +#include "machtypes.h"
13510 +#include "pci.h"
13512 +#define JWAP003_KEYS_POLL_INTERVAL 20 /* msecs */
13513 +#define JWAP003_KEYS_DEBOUNCE_INTERVAL (3 * JWAP003_KEYS_POLL_INTERVAL)
13515 +#define JWAP003_GPIO_WPS 11
13516 +#define JWAP003_GPIO_I2C_SCL 0
13517 +#define JWAP003_GPIO_I2C_SDA 1
13519 +static struct gpio_keys_button jwap003_gpio_keys[] __initdata = {
13521 + .desc = "wps",
13522 + .type = EV_KEY,
13523 + .code = KEY_WPS_BUTTON,
13524 + .debounce_interval = JWAP003_KEYS_DEBOUNCE_INTERVAL,
13525 + .gpio = JWAP003_GPIO_WPS,
13526 + .active_low = 1,
13530 +static struct i2c_gpio_platform_data jwap003_i2c_gpio_data = {
13531 + .sda_pin = JWAP003_GPIO_I2C_SDA,
13532 + .scl_pin = JWAP003_GPIO_I2C_SCL,
13535 +static struct platform_device jwap003_i2c_gpio_device = {
13536 + .name = "i2c-gpio",
13537 + .id = 0,
13538 + .dev = {
13539 + .platform_data = &jwap003_i2c_gpio_data,
13543 +static const char *jwap003_part_probes[] = {
13544 + "RedBoot",
13545 + NULL,
13548 +static struct flash_platform_data jwap003_flash_data = {
13549 + .part_probes = jwap003_part_probes,
13552 +#define JWAP003_WAN_PHYMASK BIT(0)
13553 +#define JWAP003_LAN_PHYMASK BIT(4)
13555 +static void __init jwap003_init(void)
13557 + ath79_register_m25p80(&jwap003_flash_data);
13559 + ath79_register_mdio(0, 0x0);
13561 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
13562 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
13563 + ath79_eth0_data.phy_mask = JWAP003_WAN_PHYMASK;
13564 + ath79_eth0_data.speed = SPEED_100;
13565 + ath79_eth0_data.duplex = DUPLEX_FULL;
13566 + ath79_eth0_data.has_ar8216 = 1;
13568 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
13569 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
13570 + ath79_eth1_data.phy_mask = JWAP003_LAN_PHYMASK;
13571 + ath79_eth1_data.speed = SPEED_100;
13572 + ath79_eth1_data.duplex = DUPLEX_FULL;
13574 + ath79_register_eth(0);
13575 + ath79_register_eth(1);
13577 + platform_device_register(&jwap003_i2c_gpio_device);
13579 + ath79_register_usb();
13581 + ath79_register_gpio_keys_polled(-1, JWAP003_KEYS_POLL_INTERVAL,
13582 + ARRAY_SIZE(jwap003_gpio_keys),
13583 + jwap003_gpio_keys);
13585 + ath79_register_pci();
13588 +MIPS_MACHINE(ATH79_MACH_JWAP003, "JWAP003", "jjPlus JWAP003", jwap003_init);
13589 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mc-mac1200r.c linux-4.1.43/arch/mips/ath79/mach-mc-mac1200r.c
13590 --- linux-4.1.43.orig/arch/mips/ath79/mach-mc-mac1200r.c 1970-01-01 01:00:00.000000000 +0100
13591 +++ linux-4.1.43/arch/mips/ath79/mach-mc-mac1200r.c 2017-08-06 20:02:15.000000000 +0200
13592 @@ -0,0 +1,155 @@
13594 + * MERCURY MAC1200R board support
13596 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
13597 + * Copyright (C) 2013 Gui Iribarren <gui@altermundi.net>
13599 + * This program is free software; you can redistribute it and/or modify it
13600 + * under the terms of the GNU General Public License version 2 as published
13601 + * by the Free Software Foundation.
13602 + */
13604 +#include <linux/pci.h>
13605 +#include <linux/phy.h>
13606 +#include <linux/gpio.h>
13607 +#include <linux/platform_device.h>
13608 +#include <linux/ath9k_platform.h>
13609 +#include <linux/ar8216_platform.h>
13611 +#include <asm/mach-ath79/ar71xx_regs.h>
13613 +#include "common.h"
13614 +#include "dev-ap9x-pci.h"
13615 +#include "dev-eth.h"
13616 +#include "dev-gpio-buttons.h"
13617 +#include "dev-leds-gpio.h"
13618 +#include "dev-m25p80.h"
13619 +#include "dev-spi.h"
13620 +#include "dev-wmac.h"
13621 +#include "machtypes.h"
13623 +#define MAC1200R_GPIO_LED_WLAN2G 13
13624 +#define MAC1200R_GPIO_LED_WLAN5G 17
13625 +#define MAC1200R_GPIO_LED_SYSTEM 14
13626 +#define MAC1200R_GPIO_LED_WPS 11
13627 +#define MAC1200R_GPIO_LED_WAN 12
13628 +#define MAC1200R_GPIO_LED_LAN1 15
13629 +#define MAC1200R_GPIO_LED_LAN2 21
13630 +#define MAC1200R_GPIO_LED_LAN3 22
13631 +#define MAC1200R_GPIO_LED_LAN4 20
13633 +#define MAC1200R_GPIO_BTN_WPS 16
13635 +#define MAC1200R_KEYS_POLL_INTERVAL 20 /* msecs */
13636 +#define MAC1200R_KEYS_DEBOUNCE_INTERVAL (3 * MAC1200R_KEYS_POLL_INTERVAL)
13638 +#define MAC1200R_MAC0_OFFSET 0
13639 +#define MAC1200R_MAC1_OFFSET 6
13640 +#define MAC1200R_WMAC_CALDATA_OFFSET 0x1000
13641 +#define MAC1200R_PCIE_CALDATA_OFFSET 0x5000
13643 +static const char *mac1200r_part_probes[] = {
13644 + "tp-link",
13645 + NULL,
13648 +static struct flash_platform_data mac1200r_flash_data = {
13649 + .part_probes = mac1200r_part_probes,
13652 +static struct gpio_led mac1200r_leds_gpio[] __initdata = {
13654 + .name = "mercury:green:wps",
13655 + .gpio = MAC1200R_GPIO_LED_WPS,
13656 + .active_low = 1,
13657 + },
13659 + .name = "mercury:green:system",
13660 + .gpio = MAC1200R_GPIO_LED_SYSTEM,
13661 + .active_low = 1,
13662 + },
13664 + .name = "mercury:green:wlan2g",
13665 + .gpio = MAC1200R_GPIO_LED_WLAN2G,
13666 + .active_low = 1,
13667 + },
13669 + .name = "mercury:green:wlan5g",
13670 + .gpio = MAC1200R_GPIO_LED_WLAN5G,
13671 + .active_low = 1,
13672 + },
13675 +static struct gpio_keys_button mac1200r_gpio_keys[] __initdata = {
13677 + .desc = "Reset button",
13678 + .type = EV_KEY,
13679 + .code = KEY_RESTART,
13680 + .debounce_interval = MAC1200R_KEYS_DEBOUNCE_INTERVAL,
13681 + .gpio = MAC1200R_GPIO_BTN_WPS,
13682 + .active_low = 1,
13683 + },
13687 +static void __init mac1200r_setup(void)
13689 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
13690 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
13691 + u8 tmpmac[ETH_ALEN];
13693 + ath79_register_m25p80(&mac1200r_flash_data);
13695 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mac1200r_leds_gpio),
13696 + mac1200r_leds_gpio);
13698 + ath79_register_gpio_keys_polled(-1, MAC1200R_KEYS_POLL_INTERVAL,
13699 + ARRAY_SIZE(mac1200r_gpio_keys),
13700 + mac1200r_gpio_keys);
13702 + ath79_init_mac(tmpmac, mac, 0);
13703 + ath79_wmac_disable_5ghz();
13704 + ath79_register_wmac(art + MAC1200R_WMAC_CALDATA_OFFSET, tmpmac);
13706 + ath79_init_mac(tmpmac, mac, 1);
13707 + ap91_pci_init(art + MAC1200R_PCIE_CALDATA_OFFSET, tmpmac);
13709 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
13711 + ath79_register_mdio(1, 0x0);
13713 + /* LAN */
13714 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
13716 + /* GMAC1 is connected to the internal switch */
13717 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
13719 + ath79_register_eth(1);
13721 + /* WAN */
13722 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 2);
13724 + /* GMAC0 is connected to the PHY4 of the internal switch */
13725 + ath79_switch_data.phy4_mii_en = 1;
13726 + ath79_switch_data.phy_poll_mask = BIT(4);
13727 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
13728 + ath79_eth0_data.phy_mask = BIT(4);
13729 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
13731 + ath79_register_eth(0);
13733 + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN1,
13734 + AR934X_GPIO_OUT_LED_LINK3);
13735 + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN2,
13736 + AR934X_GPIO_OUT_LED_LINK2);
13737 + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN3,
13738 + AR934X_GPIO_OUT_LED_LINK1);
13739 + ath79_gpio_output_select(MAC1200R_GPIO_LED_LAN4,
13740 + AR934X_GPIO_OUT_LED_LINK0);
13741 + ath79_gpio_output_select(MAC1200R_GPIO_LED_WAN,
13742 + AR934X_GPIO_OUT_LED_LINK4);
13745 +MIPS_MACHINE(ATH79_MACH_MC_MAC1200R, "MC-MAC1200R",
13746 + "MERCURY MAC1200R",
13747 + mac1200r_setup);
13748 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mr12.c linux-4.1.43/arch/mips/ath79/mach-mr12.c
13749 --- linux-4.1.43.orig/arch/mips/ath79/mach-mr12.c 1970-01-01 01:00:00.000000000 +0100
13750 +++ linux-4.1.43/arch/mips/ath79/mach-mr12.c 2017-08-06 20:02:15.000000000 +0200
13751 @@ -0,0 +1,115 @@
13753 + * Cisco Meraki MR12 board support
13755 + * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
13757 + * Based on Atheros AP96 board support configuration
13759 + * Copyright (C) 2009 Marco Porsch
13760 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
13761 + * Copyright (C) 2010 Atheros Communications
13763 + * This program is free software; you can redistribute it and/or modify it
13764 + * under the terms of the GNU General Public License version 2 as published
13765 + * by the Free Software Foundation.
13766 + */
13768 +#include <linux/platform_device.h>
13769 +#include <linux/delay.h>
13771 +#include <asm/mach-ath79/ath79.h>
13773 +#include "dev-ap9x-pci.h"
13774 +#include "dev-eth.h"
13775 +#include "dev-gpio-buttons.h"
13776 +#include "dev-leds-gpio.h"
13777 +#include "dev-m25p80.h"
13778 +#include "machtypes.h"
13780 +#define MR12_GPIO_LED_W4_GREEN 14
13781 +#define MR12_GPIO_LED_W3_GREEN 13
13782 +#define MR12_GPIO_LED_W2_GREEN 12
13783 +#define MR12_GPIO_LED_W1_GREEN 11
13785 +#define MR12_GPIO_LED_WAN 15
13787 +#define MR12_GPIO_LED_POWER_ORANGE 16
13788 +#define MR12_GPIO_LED_POWER_GREEN 17
13790 +#define MR12_GPIO_BTN_RESET 8
13791 +#define MR12_KEYS_POLL_INTERVAL 20 /* msecs */
13792 +#define MR12_KEYS_DEBOUNCE_INTERVAL (3 * MR12_KEYS_POLL_INTERVAL)
13794 +#define MR12_WAN_PHYMASK BIT(4)
13796 +#define MR12_WMAC0_MAC_OFFSET 0x120c
13797 +#define MR12_CALDATA0_OFFSET 0x1000
13799 +static struct gpio_led MR12_leds_gpio[] __initdata = {
13801 + .name = "mr12:green:wan",
13802 + .gpio = MR12_GPIO_LED_WAN,
13803 + .active_low = 1,
13804 + }, {
13805 + .name = "mr12:orange:power",
13806 + .gpio = MR12_GPIO_LED_POWER_ORANGE,
13807 + .active_low = 1,
13808 + }, {
13809 + .name = "mr12:green:power",
13810 + .gpio = MR12_GPIO_LED_POWER_GREEN,
13811 + .active_low = 1,
13812 + }, {
13813 + .name = "mr12:green:wifi4",
13814 + .gpio = MR12_GPIO_LED_W4_GREEN,
13815 + .active_low = 1,
13816 + }, {
13817 + .name = "mr12:green:wifi3",
13818 + .gpio = MR12_GPIO_LED_W3_GREEN,
13819 + .active_low = 1,
13820 + }, {
13821 + .name = "mr12:green:wifi2",
13822 + .gpio = MR12_GPIO_LED_W2_GREEN,
13823 + .active_low = 1,
13824 + }, {
13825 + .name = "mr12:green:wifi1",
13826 + .gpio = MR12_GPIO_LED_W1_GREEN,
13827 + .active_low = 1,
13831 +static struct gpio_keys_button MR12_gpio_keys[] __initdata = {
13833 + .desc = "reset",
13834 + .type = EV_KEY,
13835 + .code = KEY_RESTART,
13836 + .debounce_interval = MR12_KEYS_DEBOUNCE_INTERVAL,
13837 + .gpio = MR12_GPIO_BTN_RESET,
13838 + .active_low = 1,
13842 +static void __init MR12_setup(void)
13844 + u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
13846 + ath79_register_mdio(0,0x0);
13848 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
13849 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13850 + ath79_eth0_data.phy_mask = MR12_WAN_PHYMASK;
13851 + ath79_register_eth(0);
13853 + ath79_register_m25p80(NULL);
13855 + ath79_register_leds_gpio(-1, ARRAY_SIZE(MR12_leds_gpio),
13856 + MR12_leds_gpio);
13857 + ath79_register_gpio_keys_polled(-1, MR12_KEYS_POLL_INTERVAL,
13858 + ARRAY_SIZE(MR12_gpio_keys),
13859 + MR12_gpio_keys);
13861 + ap91_pci_init(mac + MR12_CALDATA0_OFFSET,
13862 + mac + MR12_WMAC0_MAC_OFFSET);
13866 +MIPS_MACHINE(ATH79_MACH_MR12, "MR12", "Meraki MR12", MR12_setup);
13867 \ No newline at end of file
13868 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mr16.c linux-4.1.43/arch/mips/ath79/mach-mr16.c
13869 --- linux-4.1.43.orig/arch/mips/ath79/mach-mr16.c 1970-01-01 01:00:00.000000000 +0100
13870 +++ linux-4.1.43/arch/mips/ath79/mach-mr16.c 2017-08-06 20:02:15.000000000 +0200
13871 @@ -0,0 +1,118 @@
13873 + * Cisco Meraki MR16 board support
13875 + * Copyright (C) 2015 Chris Blake <chrisrblake93@gmail.com>
13877 + * Based on Atheros AP96 board support configuration
13879 + * Copyright (C) 2009 Marco Porsch
13880 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
13881 + * Copyright (C) 2010 Atheros Communications
13883 + * This program is free software; you can redistribute it and/or modify it
13884 + * under the terms of the GNU General Public License version 2 as published
13885 + * by the Free Software Foundation.
13886 + */
13888 +#include <linux/platform_device.h>
13889 +#include <linux/delay.h>
13891 +#include <asm/mach-ath79/ath79.h>
13893 +#include "dev-ap9x-pci.h"
13894 +#include "dev-eth.h"
13895 +#include "dev-gpio-buttons.h"
13896 +#include "dev-leds-gpio.h"
13897 +#include "dev-m25p80.h"
13898 +#include "machtypes.h"
13900 +#define MR16_GPIO_LED_W4_GREEN 3
13901 +#define MR16_GPIO_LED_W3_GREEN 2
13902 +#define MR16_GPIO_LED_W2_GREEN 1
13903 +#define MR16_GPIO_LED_W1_GREEN 0
13905 +#define MR16_GPIO_LED_WAN 4
13907 +#define MR16_GPIO_LED_POWER_ORANGE 5
13908 +#define MR16_GPIO_LED_POWER_GREEN 6
13910 +#define MR16_GPIO_BTN_RESET 7
13911 +#define MR16_KEYS_POLL_INTERVAL 20 /* msecs */
13912 +#define MR16_KEYS_DEBOUNCE_INTERVAL (3 * MR16_KEYS_POLL_INTERVAL)
13914 +#define MR16_WAN_PHYMASK BIT(0)
13916 +#define MR16_WMAC0_MAC_OFFSET 0x120c
13917 +#define MR16_WMAC1_MAC_OFFSET 0x520c
13918 +#define MR16_CALDATA0_OFFSET 0x1000
13919 +#define MR16_CALDATA1_OFFSET 0x5000
13921 +static struct gpio_led MR16_leds_gpio[] __initdata = {
13923 + .name = "mr16:green:wan",
13924 + .gpio = MR16_GPIO_LED_WAN,
13925 + .active_low = 1,
13926 + }, {
13927 + .name = "mr16:orange:power",
13928 + .gpio = MR16_GPIO_LED_POWER_ORANGE,
13929 + .active_low = 1,
13930 + }, {
13931 + .name = "mr16:green:power",
13932 + .gpio = MR16_GPIO_LED_POWER_GREEN,
13933 + .active_low = 1,
13934 + }, {
13935 + .name = "mr16:green:wifi4",
13936 + .gpio = MR16_GPIO_LED_W4_GREEN,
13937 + .active_low = 1,
13938 + }, {
13939 + .name = "mr16:green:wifi3",
13940 + .gpio = MR16_GPIO_LED_W3_GREEN,
13941 + .active_low = 1,
13942 + }, {
13943 + .name = "mr16:green:wifi2",
13944 + .gpio = MR16_GPIO_LED_W2_GREEN,
13945 + .active_low = 1,
13946 + }, {
13947 + .name = "mr16:green:wifi1",
13948 + .gpio = MR16_GPIO_LED_W1_GREEN,
13949 + .active_low = 1,
13953 +static struct gpio_keys_button MR16_gpio_keys[] __initdata = {
13955 + .desc = "reset",
13956 + .type = EV_KEY,
13957 + .code = KEY_RESTART,
13958 + .debounce_interval = MR16_KEYS_DEBOUNCE_INTERVAL,
13959 + .gpio = MR16_GPIO_BTN_RESET,
13960 + .active_low = 1,
13964 +static void __init MR16_setup(void)
13966 + u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
13968 + ath79_register_mdio(0,0x0);
13970 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
13971 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
13972 + ath79_eth0_data.phy_mask = MR16_WAN_PHYMASK;
13973 + ath79_register_eth(0);
13975 + ath79_register_m25p80(NULL);
13977 + ath79_register_leds_gpio(-1, ARRAY_SIZE(MR16_leds_gpio),
13978 + MR16_leds_gpio);
13979 + ath79_register_gpio_keys_polled(-1, MR16_KEYS_POLL_INTERVAL,
13980 + ARRAY_SIZE(MR16_gpio_keys),
13981 + MR16_gpio_keys);
13983 + ap94_pci_init(mac + MR16_CALDATA0_OFFSET,
13984 + mac + MR16_WMAC0_MAC_OFFSET,
13985 + mac + MR16_CALDATA1_OFFSET,
13986 + mac + MR16_WMAC1_MAC_OFFSET);
13989 +MIPS_MACHINE(ATH79_MACH_MR16, "MR16", "Meraki MR16", MR16_setup);
13990 \ No newline at end of file
13991 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mr1750.c linux-4.1.43/arch/mips/ath79/mach-mr1750.c
13992 --- linux-4.1.43.orig/arch/mips/ath79/mach-mr1750.c 1970-01-01 01:00:00.000000000 +0100
13993 +++ linux-4.1.43/arch/mips/ath79/mach-mr1750.c 2017-08-06 20:02:15.000000000 +0200
13994 @@ -0,0 +1,129 @@
13996 + * MR1750 board support
13998 + * Copyright (c) 2012 Qualcomm Atheros
13999 + * Copyright (c) 2012-2013 Marek Lindner <marek@open-mesh.com>
14001 + * Permission to use, copy, modify, and/or distribute this software for any
14002 + * purpose with or without fee is hereby granted, provided that the above
14003 + * copyright notice and this permission notice appear in all copies.
14005 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14006 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14007 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14008 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14009 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14010 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14011 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14013 + */
14015 +#include <linux/platform_device.h>
14016 +#include <linux/ar8216_platform.h>
14018 +#include <asm/mach-ath79/ar71xx_regs.h>
14020 +#include "common.h"
14021 +#include "dev-ap9x-pci.h"
14022 +#include "dev-gpio-buttons.h"
14023 +#include "dev-eth.h"
14024 +#include "dev-leds-gpio.h"
14025 +#include "dev-m25p80.h"
14026 +#include "dev-wmac.h"
14027 +#include "machtypes.h"
14028 +#include "pci.h"
14030 +#define MR1750_GPIO_LED_LAN 12
14031 +#define MR1750_GPIO_LED_WLAN_2G 13
14032 +#define MR1750_GPIO_LED_STATUS_GREEN 19
14033 +#define MR1750_GPIO_LED_STATUS_RED 21
14034 +#define MR1750_GPIO_LED_POWER 22
14035 +#define MR1750_GPIO_LED_WLAN_5G 23
14037 +#define MR1750_GPIO_BTN_RESET 17
14039 +#define MR1750_KEYS_POLL_INTERVAL 20 /* msecs */
14040 +#define MR1750_KEYS_DEBOUNCE_INTERVAL (3 * MR1750_KEYS_POLL_INTERVAL)
14042 +#define MR1750_MAC0_OFFSET 0
14043 +#define MR1750_WMAC_CALDATA_OFFSET 0x1000
14045 +static struct gpio_led mr1750_leds_gpio[] __initdata = {
14047 + .name = "mr1750:blue:power",
14048 + .gpio = MR1750_GPIO_LED_POWER,
14049 + .active_low = 1,
14050 + },
14052 + .name = "mr1750:blue:wan",
14053 + .gpio = MR1750_GPIO_LED_LAN,
14054 + .active_low = 1,
14055 + },
14057 + .name = "mr1750:blue:wlan24",
14058 + .gpio = MR1750_GPIO_LED_WLAN_2G,
14059 + .active_low = 1,
14060 + },
14062 + .name = "mr1750:blue:wlan58",
14063 + .gpio = MR1750_GPIO_LED_WLAN_5G,
14064 + .active_low = 1,
14065 + },
14067 + .name = "mr1750:green:status",
14068 + .gpio = MR1750_GPIO_LED_STATUS_GREEN,
14069 + .active_low = 1,
14070 + },
14072 + .name = "mr1750:red:status",
14073 + .gpio = MR1750_GPIO_LED_STATUS_RED,
14074 + .active_low = 1,
14075 + },
14078 +static struct gpio_keys_button mr1750_gpio_keys[] __initdata = {
14080 + .desc = "Reset button",
14081 + .type = EV_KEY,
14082 + .code = KEY_RESTART,
14083 + .debounce_interval = MR1750_KEYS_DEBOUNCE_INTERVAL,
14084 + .gpio = MR1750_GPIO_BTN_RESET,
14085 + .active_low = 1,
14086 + },
14089 +static void __init mr1750_setup(void)
14091 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
14092 + u8 mac[6];
14094 + ath79_eth0_pll_data.pll_1000 = 0xbe000101;
14095 + ath79_eth0_pll_data.pll_100 = 0x80000101;
14096 + ath79_eth0_pll_data.pll_10 = 0x80001313;
14098 + ath79_register_m25p80(NULL);
14100 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mr1750_leds_gpio),
14101 + mr1750_leds_gpio);
14102 + ath79_register_gpio_keys_polled(-1, MR1750_KEYS_POLL_INTERVAL,
14103 + ARRAY_SIZE(mr1750_gpio_keys),
14104 + mr1750_gpio_keys);
14106 + ath79_init_mac(mac, art + MR1750_MAC0_OFFSET, 1);
14107 + ath79_register_wmac(art + MR1750_WMAC_CALDATA_OFFSET, mac);
14108 + ath79_register_pci();
14110 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
14111 + ath79_register_mdio(0, 0x0);
14113 + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR1750_MAC0_OFFSET, 0);
14115 + /* GMAC0 is connected to the RMGII interface */
14116 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
14117 + ath79_eth0_data.phy_mask = BIT(5);
14118 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
14120 + ath79_register_eth(0);
14123 +MIPS_MACHINE(ATH79_MACH_MR1750, "MR1750", "OpenMesh MR1750", mr1750_setup);
14124 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mr600.c linux-4.1.43/arch/mips/ath79/mach-mr600.c
14125 --- linux-4.1.43.orig/arch/mips/ath79/mach-mr600.c 1970-01-01 01:00:00.000000000 +0100
14126 +++ linux-4.1.43/arch/mips/ath79/mach-mr600.c 2017-08-06 20:02:15.000000000 +0200
14127 @@ -0,0 +1,177 @@
14129 + * OpenMesh OM2P board support
14131 + * Copyright (C) 2012 Marek Lindner <marek@open-mesh.com>
14133 + * Permission to use, copy, modify, and/or distribute this software for any
14134 + * purpose with or without fee is hereby granted, provided that the above
14135 + * copyright notice and this permission notice appear in all copies.
14137 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14138 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14139 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14140 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14141 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14142 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14143 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14145 + */
14147 +#include <linux/pci.h>
14148 +#include <linux/phy.h>
14149 +#include <linux/platform_device.h>
14150 +#include <linux/ath9k_platform.h>
14152 +#include <asm/mach-ath79/ar71xx_regs.h>
14154 +#include "common.h"
14155 +#include "dev-ap9x-pci.h"
14156 +#include "dev-eth.h"
14157 +#include "dev-gpio-buttons.h"
14158 +#include "dev-leds-gpio.h"
14159 +#include "dev-m25p80.h"
14160 +#include "dev-spi.h"
14161 +#include "dev-wmac.h"
14162 +#include "machtypes.h"
14164 +#define MR600_GPIO_LED_WLAN58 12
14165 +#define MR600_GPIO_LED_WPS 13
14166 +#define MR600_GPIO_LED_POWER 14
14168 +#define MR600V2_GPIO_LED_WLAN58_RED 12
14169 +#define MR600V2_GPIO_LED_WPS 13
14170 +#define MR600V2_GPIO_LED_POWER 14
14171 +#define MR600V2_GPIO_LED_WLAN24_GREEN 18
14172 +#define MR600V2_GPIO_LED_WLAN24_YELLOW 19
14173 +#define MR600V2_GPIO_LED_WLAN24_RED 20
14174 +#define MR600V2_GPIO_LED_WLAN58_GREEN 21
14175 +#define MR600V2_GPIO_LED_WLAN58_YELLOW 22
14177 +#define MR600_GPIO_BTN_RESET 17
14179 +#define MR600_KEYS_POLL_INTERVAL 20 /* msecs */
14180 +#define MR600_KEYS_DEBOUNCE_INTERVAL (3 * MR600_KEYS_POLL_INTERVAL)
14182 +#define MR600_MAC_OFFSET 0
14183 +#define MR600_WMAC_CALDATA_OFFSET 0x1000
14184 +#define MR600_PCIE_CALDATA_OFFSET 0x5000
14186 +static struct gpio_led mr600_leds_gpio[] __initdata = {
14188 + .name = "mr600:orange:power",
14189 + .gpio = MR600_GPIO_LED_POWER,
14190 + .active_low = 1,
14191 + },
14193 + .name = "mr600:blue:wps",
14194 + .gpio = MR600_GPIO_LED_WPS,
14195 + .active_low = 1,
14196 + },
14198 + .name = "mr600:green:wlan58",
14199 + .gpio = MR600_GPIO_LED_WLAN58,
14200 + .active_low = 1,
14201 + },
14204 +static struct gpio_led mr600v2_leds_gpio[] __initdata = {
14206 + .name = "mr600:blue:power",
14207 + .gpio = MR600V2_GPIO_LED_POWER,
14208 + .active_low = 1,
14209 + },
14211 + .name = "mr600:blue:wps",
14212 + .gpio = MR600V2_GPIO_LED_WPS,
14213 + .active_low = 1,
14214 + },
14216 + .name = "mr600:red:wlan24",
14217 + .gpio = MR600V2_GPIO_LED_WLAN24_RED,
14218 + .active_low = 1,
14219 + },
14221 + .name = "mr600:yellow:wlan24",
14222 + .gpio = MR600V2_GPIO_LED_WLAN24_YELLOW,
14223 + .active_low = 1,
14224 + },
14226 + .name = "mr600:green:wlan24",
14227 + .gpio = MR600V2_GPIO_LED_WLAN24_GREEN,
14228 + .active_low = 1,
14229 + },
14231 + .name = "mr600:red:wlan58",
14232 + .gpio = MR600V2_GPIO_LED_WLAN58_RED,
14233 + .active_low = 1,
14234 + },
14236 + .name = "mr600:yellow:wlan58",
14237 + .gpio = MR600V2_GPIO_LED_WLAN58_YELLOW,
14238 + .active_low = 1,
14239 + },
14241 + .name = "mr600:green:wlan58",
14242 + .gpio = MR600V2_GPIO_LED_WLAN58_GREEN,
14243 + .active_low = 1,
14244 + },
14247 +static struct gpio_keys_button mr600_gpio_keys[] __initdata = {
14249 + .desc = "Reset button",
14250 + .type = EV_KEY,
14251 + .code = KEY_RESTART,
14252 + .debounce_interval = MR600_KEYS_DEBOUNCE_INTERVAL,
14253 + .gpio = MR600_GPIO_BTN_RESET,
14254 + .active_low = 1,
14255 + },
14258 +static void __init mr600_base_setup(unsigned num_leds, struct gpio_led *leds)
14260 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
14261 + u8 mac[6];
14263 + ath79_register_m25p80(NULL);
14265 + ath79_register_leds_gpio(-1, num_leds, leds);
14266 + ath79_register_gpio_keys_polled(-1, MR600_KEYS_POLL_INTERVAL,
14267 + ARRAY_SIZE(mr600_gpio_keys),
14268 + mr600_gpio_keys);
14270 + ath79_init_mac(mac, art + MR600_MAC_OFFSET, 1);
14271 + ath79_register_wmac(art + MR600_WMAC_CALDATA_OFFSET, mac);
14273 + ath79_init_mac(mac, art + MR600_MAC_OFFSET, 8);
14274 + ap91_pci_init(art + MR600_PCIE_CALDATA_OFFSET, mac);
14276 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
14277 + AR934X_ETH_CFG_SW_ONLY_MODE);
14279 + ath79_register_mdio(0, 0x0);
14281 + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR600_MAC_OFFSET, 0);
14283 + /* GMAC0 is connected to an external PHY */
14284 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
14285 + ath79_eth0_data.phy_mask = BIT(0);
14286 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
14287 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
14288 + ath79_register_eth(0);
14291 +static void __init mr600_setup(void)
14293 + mr600_base_setup(ARRAY_SIZE(mr600_leds_gpio), mr600_leds_gpio);
14294 + ap9x_pci_setup_wmac_led_pin(0, 0);
14297 +MIPS_MACHINE(ATH79_MACH_MR600, "MR600", "OpenMesh MR600", mr600_setup);
14299 +static void __init mr600v2_setup(void)
14301 + mr600_base_setup(ARRAY_SIZE(mr600v2_leds_gpio), mr600v2_leds_gpio);
14304 +MIPS_MACHINE(ATH79_MACH_MR600V2, "MR600v2", "OpenMesh MR600v2", mr600v2_setup);
14305 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mr900.c linux-4.1.43/arch/mips/ath79/mach-mr900.c
14306 --- linux-4.1.43.orig/arch/mips/ath79/mach-mr900.c 1970-01-01 01:00:00.000000000 +0100
14307 +++ linux-4.1.43/arch/mips/ath79/mach-mr900.c 2017-08-06 20:02:15.000000000 +0200
14308 @@ -0,0 +1,140 @@
14310 + * MR900 board support
14312 + * Copyright (c) 2012 Qualcomm Atheros
14313 + * Copyright (c) 2012-2013 Marek Lindner <marek@open-mesh.com>
14315 + * Permission to use, copy, modify, and/or distribute this software for any
14316 + * purpose with or without fee is hereby granted, provided that the above
14317 + * copyright notice and this permission notice appear in all copies.
14319 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14320 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14321 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14322 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14323 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14324 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14325 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14327 + */
14329 +#include <linux/platform_device.h>
14330 +#include <linux/ar8216_platform.h>
14331 +#include <linux/ath9k_platform.h>
14333 +#include <asm/mach-ath79/ar71xx_regs.h>
14335 +#include "common.h"
14336 +#include "dev-ap9x-pci.h"
14337 +#include "dev-gpio-buttons.h"
14338 +#include "dev-eth.h"
14339 +#include "dev-leds-gpio.h"
14340 +#include "dev-m25p80.h"
14341 +#include "dev-wmac.h"
14342 +#include "machtypes.h"
14343 +#include "pci.h"
14345 +#define MR900_GPIO_LED_LAN 12
14346 +#define MR900_GPIO_LED_WLAN_2G 13
14347 +#define MR900_GPIO_LED_STATUS_GREEN 19
14348 +#define MR900_GPIO_LED_STATUS_RED 21
14349 +#define MR900_GPIO_LED_POWER 22
14350 +#define MR900_GPIO_LED_WLAN_5G 23
14352 +#define MR900_GPIO_BTN_RESET 17
14354 +#define MR900_KEYS_POLL_INTERVAL 20 /* msecs */
14355 +#define MR900_KEYS_DEBOUNCE_INTERVAL (3 * MR900_KEYS_POLL_INTERVAL)
14357 +#define MR900_MAC0_OFFSET 0
14358 +#define MR900_WMAC_CALDATA_OFFSET 0x1000
14359 +#define MR900_PCIE_CALDATA_OFFSET 0x5000
14361 +static struct gpio_led mr900_leds_gpio[] __initdata = {
14363 + .name = "mr900:blue:power",
14364 + .gpio = MR900_GPIO_LED_POWER,
14365 + .active_low = 1,
14366 + },
14368 + .name = "mr900:blue:wan",
14369 + .gpio = MR900_GPIO_LED_LAN,
14370 + .active_low = 1,
14371 + },
14373 + .name = "mr900:blue:wlan24",
14374 + .gpio = MR900_GPIO_LED_WLAN_2G,
14375 + .active_low = 1,
14376 + },
14378 + .name = "mr900:blue:wlan58",
14379 + .gpio = MR900_GPIO_LED_WLAN_5G,
14380 + .active_low = 1,
14381 + },
14383 + .name = "mr900:green:status",
14384 + .gpio = MR900_GPIO_LED_STATUS_GREEN,
14385 + .active_low = 1,
14386 + },
14388 + .name = "mr900:red:status",
14389 + .gpio = MR900_GPIO_LED_STATUS_RED,
14390 + .active_low = 1,
14391 + },
14394 +static struct gpio_keys_button mr900_gpio_keys[] __initdata = {
14396 + .desc = "Reset button",
14397 + .type = EV_KEY,
14398 + .code = KEY_RESTART,
14399 + .debounce_interval = MR900_KEYS_DEBOUNCE_INTERVAL,
14400 + .gpio = MR900_GPIO_BTN_RESET,
14401 + .active_low = 1,
14402 + },
14405 +static void __init mr900_setup(void)
14407 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
14408 + u8 mac[6], pcie_mac[6];
14409 + struct ath9k_platform_data *pdata;
14411 + ath79_eth0_pll_data.pll_1000 = 0xbe000101;
14412 + ath79_eth0_pll_data.pll_100 = 0x80000101;
14413 + ath79_eth0_pll_data.pll_10 = 0x80001313;
14415 + ath79_register_m25p80(NULL);
14417 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mr900_leds_gpio),
14418 + mr900_leds_gpio);
14419 + ath79_register_gpio_keys_polled(-1, MR900_KEYS_POLL_INTERVAL,
14420 + ARRAY_SIZE(mr900_gpio_keys),
14421 + mr900_gpio_keys);
14423 + ath79_init_mac(mac, art + MR900_MAC0_OFFSET, 1);
14424 + ath79_register_wmac(art + MR900_WMAC_CALDATA_OFFSET, mac);
14425 + ath79_init_mac(pcie_mac, art + MR900_MAC0_OFFSET, 16);
14426 + ap91_pci_init(art + MR900_PCIE_CALDATA_OFFSET, pcie_mac);
14427 + pdata = ap9x_pci_get_wmac_data(0);
14428 + if (!pdata) {
14429 + pr_err("mr900: unable to get address of wlan data\n");
14430 + return;
14432 + pdata->use_eeprom = true;
14434 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
14435 + ath79_register_mdio(0, 0x0);
14437 + ath79_init_mac(ath79_eth0_data.mac_addr, art + MR900_MAC0_OFFSET, 0);
14439 + /* GMAC0 is connected to the RMGII interface */
14440 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
14441 + ath79_eth0_data.phy_mask = BIT(5);
14442 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
14444 + ath79_register_eth(0);
14447 +MIPS_MACHINE(ATH79_MACH_MR900, "MR900", "OpenMesh MR900", mr900_setup);
14448 +MIPS_MACHINE(ATH79_MACH_MR900v2, "MR900v2", "OpenMesh MR900v2", mr900_setup);
14449 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mynet-n600.c linux-4.1.43/arch/mips/ath79/mach-mynet-n600.c
14450 --- linux-4.1.43.orig/arch/mips/ath79/mach-mynet-n600.c 1970-01-01 01:00:00.000000000 +0100
14451 +++ linux-4.1.43/arch/mips/ath79/mach-mynet-n600.c 2017-08-06 20:02:15.000000000 +0200
14452 @@ -0,0 +1,202 @@
14454 + * WD My Net N600 board support
14456 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
14458 + * This program is free software; you can redistribute it and/or modify it
14459 + * under the terms of the GNU General Public License version 2 as published
14460 + * by the Free Software Foundation.
14461 + */
14463 +#include <linux/pci.h>
14464 +#include <linux/phy.h>
14465 +#include <linux/gpio.h>
14466 +#include <linux/platform_device.h>
14467 +#include <linux/ath9k_platform.h>
14468 +#include <linux/ar8216_platform.h>
14470 +#include <asm/mach-ath79/ar71xx_regs.h>
14472 +#include "common.h"
14473 +#include "dev-ap9x-pci.h"
14474 +#include "dev-eth.h"
14475 +#include "dev-gpio-buttons.h"
14476 +#include "dev-leds-gpio.h"
14477 +#include "dev-m25p80.h"
14478 +#include "dev-spi.h"
14479 +#include "dev-usb.h"
14480 +#include "dev-wmac.h"
14481 +#include "machtypes.h"
14482 +#include "nvram.h"
14484 +#define MYNET_N600_GPIO_LED_WIFI 0
14485 +#define MYNET_N600_GPIO_LED_POWER 11
14486 +#define MYNET_N600_GPIO_LED_INTERNET 12
14487 +#define MYNET_N600_GPIO_LED_WPS 13
14489 +#define MYNET_N600_GPIO_LED_LAN1 4
14490 +#define MYNET_N600_GPIO_LED_LAN2 3
14491 +#define MYNET_N600_GPIO_LED_LAN3 2
14492 +#define MYNET_N600_GPIO_LED_LAN4 1
14494 +#define MYNET_N600_GPIO_BTN_RESET 16
14495 +#define MYNET_N600_GPIO_BTN_WPS 17
14497 +#define MYNET_N600_GPIO_EXTERNAL_LNA0 14
14498 +#define MYNET_N600_GPIO_EXTERNAL_LNA1 15
14500 +#define MYNET_N600_KEYS_POLL_INTERVAL 20 /* msecs */
14501 +#define MYNET_N600_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_N600_KEYS_POLL_INTERVAL)
14503 +#define MYNET_N600_MAC0_OFFSET 0
14504 +#define MYNET_N600_MAC1_OFFSET 6
14505 +#define MYNET_N600_WMAC_CALDATA_OFFSET 0x1000
14506 +#define MYNET_N600_PCIE_CALDATA_OFFSET 0x5000
14508 +#define MYNET_N600_NVRAM_ADDR 0x1f058010
14509 +#define MYNET_N600_NVRAM_SIZE 0x7ff0
14511 +static struct gpio_led mynet_n600_leds_gpio[] __initdata = {
14513 + .name = "wd:blue:power",
14514 + .gpio = MYNET_N600_GPIO_LED_POWER,
14515 + .active_low = 0,
14516 + },
14518 + .name = "wd:blue:wps",
14519 + .gpio = MYNET_N600_GPIO_LED_WPS,
14520 + .active_low = 0,
14521 + },
14523 + .name = "wd:blue:wireless",
14524 + .gpio = MYNET_N600_GPIO_LED_WIFI,
14525 + .active_low = 0,
14526 + },
14528 + .name = "wd:blue:internet",
14529 + .gpio = MYNET_N600_GPIO_LED_INTERNET,
14530 + .active_low = 0,
14531 + },
14533 + .name = "wd:green:lan1",
14534 + .gpio = MYNET_N600_GPIO_LED_LAN1,
14535 + .active_low = 1,
14536 + },
14538 + .name = "wd:green:lan2",
14539 + .gpio = MYNET_N600_GPIO_LED_LAN2,
14540 + .active_low = 1,
14541 + },
14543 + .name = "wd:green:lan3",
14544 + .gpio = MYNET_N600_GPIO_LED_LAN3,
14545 + .active_low = 1,
14546 + },
14548 + .name = "wd:green:lan4",
14549 + .gpio = MYNET_N600_GPIO_LED_LAN4,
14550 + .active_low = 1,
14551 + },
14554 +static struct gpio_keys_button mynet_n600_gpio_keys[] __initdata = {
14556 + .desc = "Reset button",
14557 + .type = EV_KEY,
14558 + .code = KEY_RESTART,
14559 + .debounce_interval = MYNET_N600_KEYS_DEBOUNCE_INTERVAL,
14560 + .gpio = MYNET_N600_GPIO_BTN_RESET,
14561 + .active_low = 1,
14562 + },
14564 + .desc = "WPS button",
14565 + .type = EV_KEY,
14566 + .code = KEY_WPS_BUTTON,
14567 + .debounce_interval = MYNET_N600_KEYS_DEBOUNCE_INTERVAL,
14568 + .gpio = MYNET_N600_GPIO_BTN_WPS,
14569 + .active_low = 1,
14570 + },
14573 +static void mynet_n600_get_mac(const char *name, char *mac)
14575 + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_N600_NVRAM_ADDR);
14576 + int err;
14578 + err = ath79_nvram_parse_mac_addr(nvram, MYNET_N600_NVRAM_SIZE,
14579 + name, mac);
14580 + if (err)
14581 + pr_err("no MAC address found for %s\n", name);
14584 +#define MYNET_N600_WAN_PHY_MASK BIT(0)
14586 +static void __init mynet_n600_setup(void)
14588 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
14589 + u8 tmpmac[ETH_ALEN];
14591 + ath79_register_m25p80(NULL);
14593 + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN1,
14594 + AR934X_GPIO_OUT_GPIO);
14595 + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN2,
14596 + AR934X_GPIO_OUT_GPIO);
14597 + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN3,
14598 + AR934X_GPIO_OUT_GPIO);
14599 + ath79_gpio_output_select(MYNET_N600_GPIO_LED_LAN4,
14600 + AR934X_GPIO_OUT_GPIO);
14601 + ath79_gpio_output_select(MYNET_N600_GPIO_LED_INTERNET,
14602 + AR934X_GPIO_OUT_GPIO);
14603 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_n600_leds_gpio),
14604 + mynet_n600_leds_gpio);
14606 + ath79_register_gpio_keys_polled(-1, MYNET_N600_KEYS_POLL_INTERVAL,
14607 + ARRAY_SIZE(mynet_n600_gpio_keys),
14608 + mynet_n600_gpio_keys);
14610 + /*
14611 + * Control signal for external LNAs 0 and 1
14612 + * Taken from GPL bootloader source:
14613 + * board/ar7240/db12x/alpha_gpio.c
14614 + */
14615 + ath79_wmac_set_ext_lna_gpio(0, MYNET_N600_GPIO_EXTERNAL_LNA0);
14616 + ath79_wmac_set_ext_lna_gpio(1, MYNET_N600_GPIO_EXTERNAL_LNA1);
14618 + mynet_n600_get_mac("wlan24mac=", tmpmac);
14619 + ath79_register_wmac(art + MYNET_N600_WMAC_CALDATA_OFFSET, tmpmac);
14621 + mynet_n600_get_mac("wlan5mac=", tmpmac);
14622 + ap91_pci_init(art + MYNET_N600_PCIE_CALDATA_OFFSET, tmpmac);
14624 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE |
14625 + AR934X_ETH_CFG_SW_PHY_SWAP);
14627 + ath79_register_mdio(1, 0x0);
14629 + /* LAN */
14630 + mynet_n600_get_mac("lanmac=", ath79_eth1_data.mac_addr);
14632 + /* GMAC1 is connected to the internal switch */
14633 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
14635 + ath79_register_eth(1);
14637 + /* WAN */
14638 + mynet_n600_get_mac("wanmac=", ath79_eth0_data.mac_addr);
14640 + /* GMAC0 is connected to the PHY4 of the internal switch */
14641 + ath79_switch_data.phy4_mii_en = 1;
14642 + ath79_switch_data.phy_poll_mask = MYNET_N600_WAN_PHY_MASK;
14644 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
14645 + ath79_eth0_data.phy_mask = MYNET_N600_WAN_PHY_MASK;
14646 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
14648 + ath79_register_eth(0);
14650 + ath79_register_usb();
14653 +MIPS_MACHINE(ATH79_MACH_MYNET_N600, "MYNET-N600", "WD My Net N600",
14654 + mynet_n600_setup);
14655 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mynet-n750.c linux-4.1.43/arch/mips/ath79/mach-mynet-n750.c
14656 --- linux-4.1.43.orig/arch/mips/ath79/mach-mynet-n750.c 1970-01-01 01:00:00.000000000 +0100
14657 +++ linux-4.1.43/arch/mips/ath79/mach-mynet-n750.c 2017-08-06 20:02:15.000000000 +0200
14658 @@ -0,0 +1,226 @@
14660 + * WD My Net N750 board support
14662 + * Copyright (C) 2013 Felix Kaechele <felix@fetzig.org>
14663 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
14665 + * This program is free software; you can redistribute it and/or modify it
14666 + * under the terms of the GNU General Public License version 2 as published
14667 + * by the Free Software Foundation.
14668 + */
14670 +#include <linux/pci.h>
14671 +#include <linux/phy.h>
14672 +#include <linux/gpio.h>
14673 +#include <linux/delay.h>
14674 +#include <linux/platform_device.h>
14675 +#include <linux/ath9k_platform.h>
14676 +#include <linux/ar8216_platform.h>
14678 +#include <asm/mach-ath79/ar71xx_regs.h>
14680 +#include "common.h"
14681 +#include "dev-ap9x-pci.h"
14682 +#include "dev-eth.h"
14683 +#include "dev-gpio-buttons.h"
14684 +#include "dev-leds-gpio.h"
14685 +#include "dev-m25p80.h"
14686 +#include "dev-spi.h"
14687 +#include "dev-usb.h"
14688 +#include "dev-wmac.h"
14689 +#include "machtypes.h"
14690 +#include "nvram.h"
14694 + * Taken from GPL bootloader source:
14695 + * board/ar7240/db12x/alpha_gpio.c
14696 + */
14697 +#define MYNET_N750_GPIO_LED_WIFI 11
14698 +#define MYNET_N750_GPIO_LED_INTERNET 12
14699 +#define MYNET_N750_GPIO_LED_WPS 13
14700 +#define MYNET_N750_GPIO_LED_POWER 14
14702 +#define MYNET_N750_GPIO_BTN_RESET 17
14703 +#define MYNET_N750_GPIO_BTN_WPS 19
14705 +#define MYNET_N750_GPIO_EXTERNAL_LNA0 15
14706 +#define MYNET_N750_GPIO_EXTERNAL_LNA1 18
14708 +#define MYNET_N750_KEYS_POLL_INTERVAL 20 /* msecs */
14709 +#define MYNET_N750_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_N750_KEYS_POLL_INTERVAL)
14711 +#define MYNET_N750_WMAC_CALDATA_OFFSET 0x1000
14712 +#define MYNET_N750_PCIE_CALDATA_OFFSET 0x5000
14714 +#define MYNET_N750_NVRAM_ADDR 0x1f058010
14715 +#define MYNET_N750_NVRAM_SIZE 0x7ff0
14717 +static struct gpio_led mynet_n750_leds_gpio[] __initdata = {
14719 + .name = "wd:blue:power",
14720 + .gpio = MYNET_N750_GPIO_LED_POWER,
14721 + .active_low = 0,
14722 + },
14724 + .name = "wd:blue:wps",
14725 + .gpio = MYNET_N750_GPIO_LED_WPS,
14726 + .active_low = 0,
14727 + },
14729 + .name = "wd:blue:wireless",
14730 + .gpio = MYNET_N750_GPIO_LED_WIFI,
14731 + .active_low = 0,
14732 + },
14734 + .name = "wd:blue:internet",
14735 + .gpio = MYNET_N750_GPIO_LED_INTERNET,
14736 + .active_low = 0,
14737 + },
14740 +static struct gpio_keys_button mynet_n750_gpio_keys[] __initdata = {
14742 + .desc = "Reset button",
14743 + .type = EV_KEY,
14744 + .code = KEY_RESTART,
14745 + .debounce_interval = MYNET_N750_KEYS_DEBOUNCE_INTERVAL,
14746 + .gpio = MYNET_N750_GPIO_BTN_RESET,
14747 + .active_low = 1,
14748 + },
14750 + .desc = "WPS button",
14751 + .type = EV_KEY,
14752 + .code = KEY_WPS_BUTTON,
14753 + .debounce_interval = MYNET_N750_KEYS_DEBOUNCE_INTERVAL,
14754 + .gpio = MYNET_N750_GPIO_BTN_WPS,
14755 + .active_low = 1,
14756 + },
14759 +static const struct ar8327_led_info mynet_n750_leds_ar8327[] __initconst = {
14760 + AR8327_LED_INFO(PHY0_0, HW, "wd:green:lan1"),
14761 + AR8327_LED_INFO(PHY1_0, HW, "wd:green:lan2"),
14762 + AR8327_LED_INFO(PHY2_0, HW, "wd:green:lan3"),
14763 + AR8327_LED_INFO(PHY3_0, HW, "wd:green:lan4"),
14764 + AR8327_LED_INFO(PHY4_0, HW, "wd:green:wan"),
14765 + AR8327_LED_INFO(PHY0_1, HW, "wd:yellow:lan1"),
14766 + AR8327_LED_INFO(PHY1_1, HW, "wd:yellow:lan2"),
14767 + AR8327_LED_INFO(PHY2_1, HW, "wd:yellow:lan3"),
14768 + AR8327_LED_INFO(PHY3_1, HW, "wd:yellow:lan4"),
14769 + AR8327_LED_INFO(PHY4_1, HW, "wd:yellow:wan"),
14772 +static struct ar8327_pad_cfg mynet_n750_ar8327_pad0_cfg = {
14773 + .mode = AR8327_PAD_MAC_RGMII,
14774 + .txclk_delay_en = true,
14775 + .rxclk_delay_en = true,
14776 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
14777 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
14780 +static struct ar8327_led_cfg mynet_n750_ar8327_led_cfg = {
14781 + .led_ctrl0 = 0xcc35cc35,
14782 + .led_ctrl1 = 0xca35ca35,
14783 + .led_ctrl2 = 0xc935c935,
14784 + .led_ctrl3 = 0x03ffff00,
14785 + .open_drain = false,
14788 +static struct ar8327_platform_data mynet_n750_ar8327_data = {
14789 + .pad0_cfg = &mynet_n750_ar8327_pad0_cfg,
14790 + .port0_cfg = {
14791 + .force_link = 1,
14792 + .speed = AR8327_PORT_SPEED_1000,
14793 + .duplex = 1,
14794 + .txpause = 1,
14795 + .rxpause = 1,
14796 + },
14797 + .led_cfg = &mynet_n750_ar8327_led_cfg,
14798 + .num_leds = ARRAY_SIZE(mynet_n750_leds_ar8327),
14799 + .leds = mynet_n750_leds_ar8327,
14802 +static struct mdio_board_info mynet_n750_mdio0_info[] = {
14804 + .bus_id = "ag71xx-mdio.0",
14805 + .phy_addr = 0,
14806 + .platform_data = &mynet_n750_ar8327_data,
14807 + },
14810 +static void mynet_n750_get_mac(const char *name, char *mac)
14812 + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_N750_NVRAM_ADDR);
14813 + int err;
14815 + err = ath79_nvram_parse_mac_addr(nvram, MYNET_N750_NVRAM_SIZE,
14816 + name, mac);
14817 + if (err)
14818 + pr_err("no MAC address found for %s\n", name);
14822 + * The bootloader on this board powers down all PHYs on the switch
14823 + * before booting the kernel. We bring all PHYs back up so that they are
14824 + * discoverable by the mdio bus scan and the switch is detected
14825 + * correctly.
14826 + */
14827 +static void mynet_n750_mdio_fixup(struct mii_bus *bus)
14829 + int i;
14831 + for (i = 0; i < 5; i++)
14832 + bus->write(bus, i, MII_BMCR,
14833 + (BMCR_RESET | BMCR_ANENABLE | BMCR_SPEED1000));
14835 + mdelay(1000);
14838 +static void __init mynet_n750_setup(void)
14840 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
14841 + u8 tmpmac[ETH_ALEN];
14843 + ath79_register_m25p80(NULL);
14844 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_n750_leds_gpio),
14845 + mynet_n750_leds_gpio);
14846 + ath79_register_gpio_keys_polled(-1, MYNET_N750_KEYS_POLL_INTERVAL,
14847 + ARRAY_SIZE(mynet_n750_gpio_keys),
14848 + mynet_n750_gpio_keys);
14849 + /*
14850 + * Control signal for external LNAs 0 and 1
14851 + * Taken from GPL bootloader source:
14852 + * board/ar7240/db12x/alpha_gpio.c
14853 + */
14854 + ath79_wmac_set_ext_lna_gpio(0, MYNET_N750_GPIO_EXTERNAL_LNA0);
14855 + ath79_wmac_set_ext_lna_gpio(1, MYNET_N750_GPIO_EXTERNAL_LNA1);
14857 + mynet_n750_get_mac("wlan24mac=", tmpmac);
14858 + ath79_register_wmac(art + MYNET_N750_WMAC_CALDATA_OFFSET, tmpmac);
14860 + mynet_n750_get_mac("wlan5mac=", tmpmac);
14861 + ap91_pci_init(art + MYNET_N750_PCIE_CALDATA_OFFSET, tmpmac);
14863 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
14865 + mdiobus_register_board_info(mynet_n750_mdio0_info,
14866 + ARRAY_SIZE(mynet_n750_mdio0_info));
14868 + ath79_mdio0_data.reset = mynet_n750_mdio_fixup;
14869 + ath79_register_mdio(0, 0x0);
14871 + mynet_n750_get_mac("lanmac=", ath79_eth0_data.mac_addr);
14873 + /* GMAC0 is connected to an AR8327N switch */
14874 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
14875 + ath79_eth0_data.phy_mask = BIT(0);
14876 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
14877 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
14878 + ath79_register_eth(0);
14880 + ath79_register_usb();
14883 +MIPS_MACHINE(ATH79_MACH_MYNET_N750, "MYNET-N750", "WD My Net N750",
14884 + mynet_n750_setup);
14885 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mynet-rext.c linux-4.1.43/arch/mips/ath79/mach-mynet-rext.c
14886 --- linux-4.1.43.orig/arch/mips/ath79/mach-mynet-rext.c 1970-01-01 01:00:00.000000000 +0100
14887 +++ linux-4.1.43/arch/mips/ath79/mach-mynet-rext.c 2017-08-06 20:02:15.000000000 +0200
14888 @@ -0,0 +1,208 @@
14890 + * WD My Net WI-FI Range Extender (Codename:Starfish db12x) board support
14892 + * Copyright (C) 2013 Christian Lamparter <chunkeey@googlemail.com>
14894 + * This program is free software; you can redistribute it and/or modify it
14895 + * under the terms of the GNU General Public License version 2 as published
14896 + * by the Free Software Foundation.
14897 + */
14899 +#include <linux/pci.h>
14900 +#include <linux/phy.h>
14901 +#include <linux/gpio.h>
14902 +#include <linux/platform_device.h>
14903 +#include <linux/ath9k_platform.h>
14904 +#include <linux/ar8216_platform.h>
14905 +#include <linux/platform_data/phy-at803x.h>
14907 +#include <asm/mach-ath79/ar71xx_regs.h>
14909 +#include "common.h"
14910 +#include "dev-ap9x-pci.h"
14911 +#include "dev-eth.h"
14912 +#include "dev-gpio-buttons.h"
14913 +#include "dev-leds-gpio.h"
14914 +#include "dev-m25p80.h"
14915 +#include "dev-spi.h"
14916 +#include "dev-usb.h"
14917 +#include "dev-wmac.h"
14918 +#include "machtypes.h"
14919 +#include "nvram.h"
14921 +#define MYNET_REXT_GPIO_LED_POWER 11
14922 +#define MYNET_REXT_GPIO_LED_ETHERNET 12
14923 +#define MYNET_REXT_GPIO_LED_WIFI 19
14925 +#define MYNET_REXT_GPIO_LED_RF_QTY1 20
14926 +#define MYNET_REXT_GPIO_LED_RF_QTY2 21
14927 +#define MYNET_REXT_GPIO_LED_RF_QTY3 22
14929 +#define MYNET_REXT_GPIO_BTN_RESET 13
14930 +#define MYNET_REXT_GPIO_BTN_WPS 15
14931 +#define MYNET_REXT_GPIO_SW_RF 14
14933 +#define MYNET_REXT_GPIO_PHY_SWRST 16 /* disables Ethernet PHY */
14934 +#define MYNET_REXT_GPIO_PHY_INT 17
14935 +#define MYNET_REXT_GPIO_18 18
14937 +#define MYNET_REXT_KEYS_POLL_INTERVAL 20 /* msecs */
14938 +#define MYNET_REXT_KEYS_DEBOUNCE_INTERVAL (3 * MYNET_REXT_KEYS_POLL_INTERVAL)
14940 +#define MYNET_REXT_WMAC_CALDATA_OFFSET 0x1000
14942 +#define MYNET_REXT_NVRAM_ADDR 0x1f7e0010
14943 +#define MYNET_REXT_NVRAM_SIZE 0xfff0
14945 +#define MYNET_REXT_ART_ADDR 0x1f7f0000
14947 +static const char *mynet_rext_part_probes[] = {
14948 + "cybertan",
14949 + NULL,
14952 +static struct flash_platform_data mynet_rext_flash_data = {
14953 + .type = "s25fl064k",
14954 + .part_probes = mynet_rext_part_probes,
14957 +static struct gpio_led mynet_rext_leds_gpio[] __initdata = {
14959 + .name = "wd:blue:power",
14960 + .gpio = MYNET_REXT_GPIO_LED_POWER,
14961 + .active_low = 0,
14962 + },
14964 + .name = "wd:blue:wireless",
14965 + .gpio = MYNET_REXT_GPIO_LED_WIFI,
14966 + .active_low = 1,
14967 + },
14969 + .name = "wd:blue:ethernet",
14970 + .gpio = MYNET_REXT_GPIO_LED_ETHERNET,
14971 + .active_low = 1,
14972 + },
14974 + .name = "wd:blue:quality1",
14975 + .gpio = MYNET_REXT_GPIO_LED_RF_QTY1,
14976 + .active_low = 1,
14977 + },
14979 + .name = "wd:blue:quality2",
14980 + .gpio = MYNET_REXT_GPIO_LED_RF_QTY2,
14981 + .active_low = 1,
14982 + },
14984 + .name = "wd:blue:quality3",
14985 + .gpio = MYNET_REXT_GPIO_LED_RF_QTY3,
14986 + .active_low = 1,
14987 + },
14990 +static struct gpio_keys_button mynet_rext_gpio_keys[] __initdata = {
14992 + .desc = "Reset button",
14993 + .type = EV_KEY,
14994 + .code = KEY_RESTART,
14995 + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
14996 + .gpio = MYNET_REXT_GPIO_BTN_RESET,
14997 + .active_low = 1,
14998 + },
15000 + .desc = "WPS button",
15001 + .type = EV_KEY,
15002 + .code = KEY_WPS_BUTTON,
15003 + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
15004 + .gpio = MYNET_REXT_GPIO_BTN_WPS,
15005 + .active_low = 1,
15006 + },
15008 + .desc = "RF Band switch",
15009 + .type = EV_SW,
15010 + .code = BTN_1,
15011 + .debounce_interval = MYNET_REXT_KEYS_DEBOUNCE_INTERVAL,
15012 + .gpio = MYNET_REXT_GPIO_SW_RF,
15013 + },
15016 +static struct at803x_platform_data mynet_rext_at803x_data = {
15017 + .disable_smarteee = 0,
15018 + .enable_rgmii_rx_delay = 1,
15019 + .enable_rgmii_tx_delay = 0,
15020 + .fixup_rgmii_tx_delay = 1,
15023 +static struct mdio_board_info mynet_rext_mdio0_info[] = {
15025 + .bus_id = "ag71xx-mdio.0",
15026 + .phy_addr = 4,
15027 + .platform_data = &mynet_rext_at803x_data,
15028 + },
15031 +static void mynet_rext_get_mac(const char *name, char *mac)
15033 + u8 *nvram = (u8 *) KSEG1ADDR(MYNET_REXT_NVRAM_ADDR);
15034 + int err;
15036 + err = ath79_nvram_parse_mac_addr(nvram, MYNET_REXT_NVRAM_SIZE,
15037 + name, mac);
15038 + if (err)
15039 + pr_err("no MAC address found for %s\n", name);
15042 +static void __init mynet_rext_setup(void)
15044 + u8 *art = (u8 *) KSEG1ADDR(MYNET_REXT_ART_ADDR);
15045 + u8 tmpmac[ETH_ALEN];
15047 + ath79_register_m25p80(&mynet_rext_flash_data);
15049 + /* GPIO configuration from drivers/char/GPIO8.c */
15051 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_POWER,
15052 + AR934X_GPIO_OUT_GPIO);
15053 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_WIFI,
15054 + AR934X_GPIO_OUT_GPIO);
15055 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY1,
15056 + AR934X_GPIO_OUT_GPIO);
15057 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY2,
15058 + AR934X_GPIO_OUT_GPIO);
15059 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_RF_QTY3,
15060 + AR934X_GPIO_OUT_GPIO);
15061 + ath79_gpio_output_select(MYNET_REXT_GPIO_LED_ETHERNET,
15062 + AR934X_GPIO_OUT_GPIO);
15063 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mynet_rext_leds_gpio),
15064 + mynet_rext_leds_gpio);
15066 + ath79_register_gpio_keys_polled(-1, MYNET_REXT_KEYS_POLL_INTERVAL,
15067 + ARRAY_SIZE(mynet_rext_gpio_keys),
15068 + mynet_rext_gpio_keys);
15070 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
15071 + AR934X_ETH_CFG_RXD_DELAY |
15072 + AR934X_ETH_CFG_RDV_DELAY);
15074 + ath79_register_mdio(0, 0x0);
15076 + mdiobus_register_board_info(mynet_rext_mdio0_info,
15077 + ARRAY_SIZE(mynet_rext_mdio0_info));
15079 + /* LAN */
15080 + mynet_rext_get_mac("et0macaddr=", ath79_eth0_data.mac_addr);
15082 + /* GMAC0 is connected to an external PHY on Port 4 */
15083 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
15084 + ath79_eth0_data.phy_mask = BIT(4);
15085 + ath79_eth0_pll_data.pll_10 = 0x00001313; /* athrs_mac.c */
15086 + ath79_eth0_pll_data.pll_1000 = 0x0e000000; /* athrs_mac.c */
15087 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
15088 + ath79_register_eth(0);
15090 + /* WLAN */
15091 + mynet_rext_get_mac("wl0_hwaddr=", tmpmac);
15092 + ap91_pci_init(art + MYNET_REXT_WMAC_CALDATA_OFFSET, tmpmac);
15095 +MIPS_MACHINE(ATH79_MACH_MYNET_REXT, "MYNET-REXT",
15096 + "WD My Net Wi-Fi Range Extender", mynet_rext_setup);
15097 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mzk-w04nu.c linux-4.1.43/arch/mips/ath79/mach-mzk-w04nu.c
15098 --- linux-4.1.43.orig/arch/mips/ath79/mach-mzk-w04nu.c 1970-01-01 01:00:00.000000000 +0100
15099 +++ linux-4.1.43/arch/mips/ath79/mach-mzk-w04nu.c 2017-08-06 20:02:15.000000000 +0200
15100 @@ -0,0 +1,124 @@
15102 + * Planex MZK-W04NU board support
15104 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
15106 + * This program is free software; you can redistribute it and/or modify it
15107 + * under the terms of the GNU General Public License version 2 as published
15108 + * by the Free Software Foundation.
15109 + */
15111 +#include <asm/mach-ath79/ath79.h>
15113 +#include "dev-eth.h"
15114 +#include "dev-gpio-buttons.h"
15115 +#include "dev-leds-gpio.h"
15116 +#include "dev-m25p80.h"
15117 +#include "dev-usb.h"
15118 +#include "dev-wmac.h"
15119 +#include "machtypes.h"
15121 +#define MZK_W04NU_GPIO_LED_USB 0
15122 +#define MZK_W04NU_GPIO_LED_STATUS 1
15123 +#define MZK_W04NU_GPIO_LED_WPS 3
15124 +#define MZK_W04NU_GPIO_LED_WLAN 6
15125 +#define MZK_W04NU_GPIO_LED_AP 15
15126 +#define MZK_W04NU_GPIO_LED_ROUTER 16
15128 +#define MZK_W04NU_GPIO_BTN_APROUTER 5
15129 +#define MZK_W04NU_GPIO_BTN_WPS 12
15130 +#define MZK_W04NU_GPIO_BTN_RESET 21
15132 +#define MZK_W04NU_KEYS_POLL_INTERVAL 20 /* msecs */
15133 +#define MZK_W04NU_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W04NU_KEYS_POLL_INTERVAL)
15135 +static struct gpio_led mzk_w04nu_leds_gpio[] __initdata = {
15137 + .name = "planex:green:status",
15138 + .gpio = MZK_W04NU_GPIO_LED_STATUS,
15139 + .active_low = 1,
15140 + }, {
15141 + .name = "planex:blue:wps",
15142 + .gpio = MZK_W04NU_GPIO_LED_WPS,
15143 + .active_low = 1,
15144 + }, {
15145 + .name = "planex:green:wlan",
15146 + .gpio = MZK_W04NU_GPIO_LED_WLAN,
15147 + .active_low = 1,
15148 + }, {
15149 + .name = "planex:green:usb",
15150 + .gpio = MZK_W04NU_GPIO_LED_USB,
15151 + .active_low = 1,
15152 + }, {
15153 + .name = "planex:green:ap",
15154 + .gpio = MZK_W04NU_GPIO_LED_AP,
15155 + .active_low = 1,
15156 + }, {
15157 + .name = "planex:green:router",
15158 + .gpio = MZK_W04NU_GPIO_LED_ROUTER,
15159 + .active_low = 1,
15163 +static struct gpio_keys_button mzk_w04nu_gpio_keys[] __initdata = {
15165 + .desc = "reset",
15166 + .type = EV_KEY,
15167 + .code = KEY_RESTART,
15168 + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
15169 + .gpio = MZK_W04NU_GPIO_BTN_RESET,
15170 + .active_low = 1,
15171 + }, {
15172 + .desc = "wps",
15173 + .type = EV_KEY,
15174 + .code = KEY_WPS_BUTTON,
15175 + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
15176 + .gpio = MZK_W04NU_GPIO_BTN_WPS,
15177 + .active_low = 1,
15178 + }, {
15179 + .desc = "aprouter",
15180 + .type = EV_KEY,
15181 + .code = BTN_2,
15182 + .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
15183 + .gpio = MZK_W04NU_GPIO_BTN_APROUTER,
15184 + .active_low = 0,
15188 +#define MZK_W04NU_WAN_PHYMASK BIT(4)
15189 +#define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
15191 +static void __init mzk_w04nu_setup(void)
15193 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
15195 + ath79_register_mdio(0, MZK_W04NU_MDIO_MASK);
15197 + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
15198 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
15199 + ath79_eth0_data.speed = SPEED_100;
15200 + ath79_eth0_data.duplex = DUPLEX_FULL;
15201 + ath79_eth0_data.has_ar8216 = 1;
15203 + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
15204 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
15205 + ath79_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK;
15207 + ath79_register_eth(0);
15208 + ath79_register_eth(1);
15210 + ath79_register_m25p80(NULL);
15212 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio),
15213 + mzk_w04nu_leds_gpio);
15215 + ath79_register_gpio_keys_polled(-1, MZK_W04NU_KEYS_POLL_INTERVAL,
15216 + ARRAY_SIZE(mzk_w04nu_gpio_keys),
15217 + mzk_w04nu_gpio_keys);
15218 + ath79_register_usb();
15220 + ath79_register_wmac(eeprom, NULL);
15223 +MIPS_MACHINE(ATH79_MACH_MZK_W04NU, "MZK-W04NU", "Planex MZK-W04NU",
15224 + mzk_w04nu_setup);
15225 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-mzk-w300nh.c linux-4.1.43/arch/mips/ath79/mach-mzk-w300nh.c
15226 --- linux-4.1.43.orig/arch/mips/ath79/mach-mzk-w300nh.c 1970-01-01 01:00:00.000000000 +0100
15227 +++ linux-4.1.43/arch/mips/ath79/mach-mzk-w300nh.c 2017-08-06 20:02:15.000000000 +0200
15228 @@ -0,0 +1,115 @@
15230 + * Planex MZK-W300NH board support
15232 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
15233 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
15235 + * This program is free software; you can redistribute it and/or modify it
15236 + * under the terms of the GNU General Public License version 2 as published
15237 + * by the Free Software Foundation.
15238 + */
15240 +#include <asm/mach-ath79/ath79.h>
15242 +#include "dev-eth.h"
15243 +#include "dev-gpio-buttons.h"
15244 +#include "dev-leds-gpio.h"
15245 +#include "dev-m25p80.h"
15246 +#include "dev-wmac.h"
15247 +#include "machtypes.h"
15249 +#define MZK_W300NH_GPIO_LED_STATUS 1
15250 +#define MZK_W300NH_GPIO_LED_WPS 3
15251 +#define MZK_W300NH_GPIO_LED_WLAN 6
15252 +#define MZK_W300NH_GPIO_LED_AP_GREEN 15
15253 +#define MZK_W300NH_GPIO_LED_AP_AMBER 16
15255 +#define MZK_W300NH_GPIO_BTN_APROUTER 5
15256 +#define MZK_W300NH_GPIO_BTN_WPS 12
15257 +#define MZK_W300NH_GPIO_BTN_RESET 21
15259 +#define MZK_W300NH_KEYS_POLL_INTERVAL 20 /* msecs */
15260 +#define MZK_W300NH_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W300NH_KEYS_POLL_INTERVAL)
15262 +static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
15264 + .name = "planex:green:status",
15265 + .gpio = MZK_W300NH_GPIO_LED_STATUS,
15266 + .active_low = 1,
15267 + }, {
15268 + .name = "planex:blue:wps",
15269 + .gpio = MZK_W300NH_GPIO_LED_WPS,
15270 + .active_low = 1,
15271 + }, {
15272 + .name = "planex:green:wlan",
15273 + .gpio = MZK_W300NH_GPIO_LED_WLAN,
15274 + .active_low = 1,
15275 + }, {
15276 + .name = "planex:green:aprouter",
15277 + .gpio = MZK_W300NH_GPIO_LED_AP_GREEN,
15278 + }, {
15279 + .name = "planex:amber:aprouter",
15280 + .gpio = MZK_W300NH_GPIO_LED_AP_AMBER,
15284 +static struct gpio_keys_button mzk_w300nh_gpio_keys[] __initdata = {
15286 + .desc = "reset",
15287 + .type = EV_KEY,
15288 + .code = KEY_RESTART,
15289 + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
15290 + .gpio = MZK_W300NH_GPIO_BTN_RESET,
15291 + .active_low = 1,
15292 + }, {
15293 + .desc = "wps",
15294 + .type = EV_KEY,
15295 + .code = KEY_WPS_BUTTON,
15296 + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
15297 + .gpio = MZK_W300NH_GPIO_BTN_WPS,
15298 + .active_low = 1,
15299 + }, {
15300 + .desc = "aprouter",
15301 + .type = EV_KEY,
15302 + .code = BTN_2,
15303 + .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
15304 + .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
15305 + .active_low = 0,
15309 +#define MZK_W300NH_WAN_PHYMASK BIT(4)
15310 +#define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
15312 +static void __init mzk_w300nh_setup(void)
15314 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
15316 + ath79_register_mdio(0, MZK_W300NH_MDIO_MASK);
15318 + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
15319 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
15320 + ath79_eth0_data.speed = SPEED_100;
15321 + ath79_eth0_data.duplex = DUPLEX_FULL;
15322 + ath79_eth0_data.has_ar8216 = 1;
15324 + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
15325 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
15326 + ath79_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
15328 + ath79_register_eth(0);
15329 + ath79_register_eth(1);
15331 + ath79_register_m25p80(NULL);
15333 + ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
15334 + mzk_w300nh_leds_gpio);
15336 + ath79_register_gpio_keys_polled(-1, MZK_W300NH_KEYS_POLL_INTERVAL,
15337 + ARRAY_SIZE(mzk_w300nh_gpio_keys),
15338 + mzk_w300nh_gpio_keys);
15339 + ath79_register_wmac(eeprom, NULL);
15342 +MIPS_MACHINE(ATH79_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
15343 + mzk_w300nh_setup);
15344 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-nbg460n.c linux-4.1.43/arch/mips/ath79/mach-nbg460n.c
15345 --- linux-4.1.43.orig/arch/mips/ath79/mach-nbg460n.c 1970-01-01 01:00:00.000000000 +0100
15346 +++ linux-4.1.43/arch/mips/ath79/mach-nbg460n.c 2017-08-06 20:02:15.000000000 +0200
15347 @@ -0,0 +1,220 @@
15349 + * Zyxel NBG 460N/550N/550NH board support
15351 + * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
15353 + * based on mach-tl-wr1043nd.c
15355 + * This program is free software; you can redistribute it and/or modify it
15356 + * under the terms of the GNU General Public License version 2 as published
15357 + * by the Free Software Foundation.
15358 + */
15360 +#include <linux/delay.h>
15361 +#include <linux/i2c.h>
15362 +#include <linux/i2c-algo-bit.h>
15363 +#include <linux/i2c-gpio.h>
15364 +#include <linux/mtd/mtd.h>
15365 +#include <linux/mtd/partitions.h>
15366 +#include <linux/platform_device.h>
15367 +#include <linux/rtl8366.h>
15369 +#include <asm/mach-ath79/ath79.h>
15371 +#include "dev-eth.h"
15372 +#include "dev-gpio-buttons.h"
15373 +#include "dev-leds-gpio.h"
15374 +#include "dev-m25p80.h"
15375 +#include "dev-wmac.h"
15376 +#include "machtypes.h"
15378 +/* LEDs */
15379 +#define NBG460N_GPIO_LED_WPS 3
15380 +#define NBG460N_GPIO_LED_WAN 6
15381 +#define NBG460N_GPIO_LED_POWER 14
15382 +#define NBG460N_GPIO_LED_WLAN 15
15384 +/* Buttons */
15385 +#define NBG460N_GPIO_BTN_WPS 12
15386 +#define NBG460N_GPIO_BTN_RESET 21
15388 +#define NBG460N_KEYS_POLL_INTERVAL 20 /* msecs */
15389 +#define NBG460N_KEYS_DEBOUNCE_INTERVAL (3 * NBG460N_KEYS_POLL_INTERVAL)
15391 +/* RTC chip PCF8563 I2C interface */
15392 +#define NBG460N_GPIO_PCF8563_SDA 8
15393 +#define NBG460N_GPIO_PCF8563_SCK 7
15395 +/* Switch configuration I2C interface */
15396 +#define NBG460N_GPIO_RTL8366_SDA 16
15397 +#define NBG460N_GPIO_RTL8366_SCK 18
15399 +static struct mtd_partition nbg460n_partitions[] = {
15401 + .name = "Bootbase",
15402 + .offset = 0,
15403 + .size = 0x010000,
15404 + .mask_flags = MTD_WRITEABLE,
15405 + }, {
15406 + .name = "U-Boot Config",
15407 + .offset = 0x010000,
15408 + .size = 0x030000,
15409 + }, {
15410 + .name = "U-Boot",
15411 + .offset = 0x040000,
15412 + .size = 0x030000,
15413 + }, {
15414 + .name = "linux",
15415 + .offset = 0x070000,
15416 + .size = 0x0e0000,
15417 + }, {
15418 + .name = "rootfs",
15419 + .offset = 0x150000,
15420 + .size = 0x2a0000,
15421 + }, {
15422 + .name = "CalibData",
15423 + .offset = 0x3f0000,
15424 + .size = 0x010000,
15425 + .mask_flags = MTD_WRITEABLE,
15426 + }, {
15427 + .name = "firmware",
15428 + .offset = 0x070000,
15429 + .size = 0x380000,
15433 +static struct flash_platform_data nbg460n_flash_data = {
15434 + .parts = nbg460n_partitions,
15435 + .nr_parts = ARRAY_SIZE(nbg460n_partitions),
15438 +static struct gpio_led nbg460n_leds_gpio[] __initdata = {
15440 + .name = "nbg460n:green:power",
15441 + .gpio = NBG460N_GPIO_LED_POWER,
15442 + .active_low = 0,
15443 + .default_trigger = "default-on",
15444 + }, {
15445 + .name = "nbg460n:green:wps",
15446 + .gpio = NBG460N_GPIO_LED_WPS,
15447 + .active_low = 0,
15448 + }, {
15449 + .name = "nbg460n:green:wlan",
15450 + .gpio = NBG460N_GPIO_LED_WLAN,
15451 + .active_low = 0,
15452 + }, {
15453 + /* Not really for controlling the LED,
15454 + when set low the LED blinks uncontrollable */
15455 + .name = "nbg460n:green:wan",
15456 + .gpio = NBG460N_GPIO_LED_WAN,
15457 + .active_low = 0,
15461 +static struct gpio_keys_button nbg460n_gpio_keys[] __initdata = {
15463 + .desc = "reset",
15464 + .type = EV_KEY,
15465 + .code = KEY_RESTART,
15466 + .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
15467 + .gpio = NBG460N_GPIO_BTN_RESET,
15468 + .active_low = 1,
15469 + }, {
15470 + .desc = "wps",
15471 + .type = EV_KEY,
15472 + .code = KEY_WPS_BUTTON,
15473 + .debounce_interval = NBG460N_KEYS_DEBOUNCE_INTERVAL,
15474 + .gpio = NBG460N_GPIO_BTN_WPS,
15475 + .active_low = 1,
15479 +static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata = {
15480 + .sda_pin = NBG460N_GPIO_PCF8563_SDA,
15481 + .scl_pin = NBG460N_GPIO_PCF8563_SCK,
15482 + .udelay = 10,
15485 +static struct platform_device nbg460n_i2c_device = {
15486 + .name = "i2c-gpio",
15487 + .id = -1,
15488 + .num_resources = 0,
15489 + .resource = NULL,
15490 + .dev = {
15491 + .platform_data = &nbg460n_i2c_device_platdata,
15492 + },
15495 +static struct i2c_board_info nbg460n_i2c_devs[] __initdata = {
15497 + I2C_BOARD_INFO("pcf8563", 0x51),
15498 + },
15501 +static void nbg460n_i2c_init(void)
15503 + /* The gpio interface */
15504 + platform_device_register(&nbg460n_i2c_device);
15505 + /* I2C devices */
15506 + i2c_register_board_info(0, nbg460n_i2c_devs,
15507 + ARRAY_SIZE(nbg460n_i2c_devs));
15511 +static struct rtl8366_platform_data nbg460n_rtl8366s_data = {
15512 + .gpio_sda = NBG460N_GPIO_RTL8366_SDA,
15513 + .gpio_sck = NBG460N_GPIO_RTL8366_SCK,
15516 +static struct platform_device nbg460n_rtl8366s_device = {
15517 + .name = RTL8366S_DRIVER_NAME,
15518 + .id = -1,
15519 + .dev = {
15520 + .platform_data = &nbg460n_rtl8366s_data,
15524 +static void __init nbg460n_setup(void)
15526 + /* end of bootloader sector contains mac address */
15527 + u8 *mac = (u8 *) KSEG1ADDR(0x1fc0fff8);
15528 + /* last sector contains wlan calib data */
15529 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
15531 + /* LAN Port */
15532 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
15533 + ath79_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
15534 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
15535 + ath79_eth0_data.speed = SPEED_1000;
15536 + ath79_eth0_data.duplex = DUPLEX_FULL;
15538 + /* WAN Port */
15539 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
15540 + ath79_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
15541 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
15542 + ath79_eth1_data.phy_mask = 0x10;
15544 + ath79_register_eth(0);
15545 + ath79_register_eth(1);
15547 + /* register the switch phy */
15548 + platform_device_register(&nbg460n_rtl8366s_device);
15550 + /* register flash */
15551 + ath79_register_m25p80(&nbg460n_flash_data);
15553 + ath79_register_wmac(eeprom, mac);
15555 + /* register RTC chip */
15556 + nbg460n_i2c_init();
15558 + ath79_register_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio),
15559 + nbg460n_leds_gpio);
15561 + ath79_register_gpio_keys_polled(-1, NBG460N_KEYS_POLL_INTERVAL,
15562 + ARRAY_SIZE(nbg460n_gpio_keys),
15563 + nbg460n_gpio_keys);
15566 +MIPS_MACHINE(ATH79_MACH_NBG460N, "NBG460N", "Zyxel NBG460N/550N/550NH",
15567 + nbg460n_setup);
15568 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-nbg6716.c linux-4.1.43/arch/mips/ath79/mach-nbg6716.c
15569 --- linux-4.1.43.orig/arch/mips/ath79/mach-nbg6716.c 1970-01-01 01:00:00.000000000 +0100
15570 +++ linux-4.1.43/arch/mips/ath79/mach-nbg6716.c 2017-08-06 20:02:15.000000000 +0200
15571 @@ -0,0 +1,381 @@
15573 + * ZyXEL NBG6716/NBG6616 board support
15575 + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
15576 + * Copyright (c) 2012 Qualcomm Atheros
15577 + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
15578 + * Copyright (c) 2013 Andre Valentin <avalentin@marcant.net>
15580 + * Permission to use, copy, modify, and/or distribute this software for any
15581 + * purpose with or without fee is hereby granted, provided that the above
15582 + * copyright notice and this permission notice appear in all copies.
15584 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15585 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15586 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15587 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15588 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15589 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15590 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15592 + */
15594 +#include <linux/platform_device.h>
15595 +#include <linux/ar8216_platform.h>
15596 +#include <linux/gpio.h>
15597 +#include <linux/mtd/mtd.h>
15598 +#include <linux/mtd/nand.h>
15599 +#include <linux/platform/ar934x_nfc.h>
15601 +#include <asm/mach-ath79/ar71xx_regs.h>
15603 +#include "common.h"
15604 +#include "pci.h"
15605 +#include "dev-ap9x-pci.h"
15606 +#include "dev-gpio-buttons.h"
15607 +#include "dev-eth.h"
15608 +#include "dev-leds-gpio.h"
15609 +#include "dev-nfc.h"
15610 +#include "dev-m25p80.h"
15611 +#include "dev-usb.h"
15612 +#include "dev-wmac.h"
15613 +#include "machtypes.h"
15614 +#include "nvram.h"
15616 +#define NBG6716_GPIO_LED_INTERNET 18
15617 +#define NBG6716_GPIO_LED_POWER 15
15618 +#define NBG6716_GPIO_LED_USB1 4
15619 +#define NBG6716_GPIO_LED_USB2 13
15620 +#define NBG6716_GPIO_LED_WIFI2G 19
15621 +#define NBG6716_GPIO_LED_WIFI5G 17
15622 +#define NBG6716_GPIO_LED_WPS 21
15624 +#define NBG6716_GPIO_BTN_RESET 23
15625 +#define NBG6716_GPIO_BTN_RFKILL 1
15626 +#define NBG6716_GPIO_BTN_USB1 0
15627 +#define NBG6716_GPIO_BTN_USB2 14
15628 +#define NBG6716_GPIO_BTN_WPS 22
15630 +#define NBG6716_GPIO_USB_POWER 16
15632 +#define NBG6716_KEYS_POLL_INTERVAL 20 /* msecs */
15633 +#define NBG6716_KEYS_DEBOUNCE_INTERVAL (3 * NBG6716_KEYS_POLL_INTERVAL)
15635 +#define NBG6716_MAC0_OFFSET 0
15636 +#define NBG6716_MAC1_OFFSET 6
15637 +#define NBG6716_WMAC_CALDATA_OFFSET 0x1000
15638 +#define NBG6716_PCIE_CALDATA_OFFSET 0x5000
15640 +/* NBG6616 has a different GPIO usage as it does not have USB Buttons */
15641 +#define NBG6616_GPIO_LED_USB0 14
15642 +#define NBG6616_GPIO_LED_USB1 21
15643 +#define NBG6616_GPIO_LED_WPS 0
15645 +static struct gpio_led nbg6716_leds_gpio[] __initdata = {
15647 + .name = "nbg6716:white:internet",
15648 + .gpio = NBG6716_GPIO_LED_INTERNET,
15649 + .active_low = 1,
15650 + },
15652 + .name = "nbg6716:white:power",
15653 + .gpio = NBG6716_GPIO_LED_POWER,
15654 + .active_low = 1,
15655 + },
15657 + .name = "nbg6716:white:usb1",
15658 + .gpio = NBG6716_GPIO_LED_USB1,
15659 + .active_low = 1,
15660 + },
15662 + .name = "nbg6716:white:usb2",
15663 + .gpio = NBG6716_GPIO_LED_USB2,
15664 + .active_low = 1,
15665 + },
15667 + .name = "nbg6716:white:wifi2g",
15668 + .gpio = NBG6716_GPIO_LED_WIFI2G,
15669 + .active_low = 1,
15670 + },
15672 + .name = "nbg6716:white:wifi5g",
15673 + .gpio = NBG6716_GPIO_LED_WIFI5G,
15674 + .active_low = 1,
15675 + },
15677 + .name = "nbg6716:white:wps",
15678 + .gpio = NBG6716_GPIO_LED_WPS,
15679 + .active_low = 1,
15683 +static struct gpio_keys_button nbg6716_gpio_keys[] __initdata = {
15685 + .desc = "RESET button",
15686 + .type = EV_KEY,
15687 + .code = KEY_RESTART,
15688 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15689 + .gpio = NBG6716_GPIO_BTN_RESET,
15690 + .active_low = 1,
15691 + },
15693 + .desc = "RFKILL button",
15694 + .type = EV_SW,
15695 + .code = KEY_RFKILL,
15696 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15697 + .gpio = NBG6716_GPIO_BTN_RFKILL,
15698 + .active_low = 0,
15699 + },
15701 + .desc = "USB1 eject button",
15702 + .type = EV_KEY,
15703 + .code = BTN_1,
15704 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15705 + .gpio = NBG6716_GPIO_BTN_USB1,
15706 + .active_low = 1,
15707 + },
15709 + .desc = "USB2 eject button",
15710 + .type = EV_KEY,
15711 + .code = BTN_2,
15712 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15713 + .gpio = NBG6716_GPIO_BTN_USB2,
15714 + .active_low = 1,
15715 + },
15717 + .desc = "WPS button",
15718 + .type = EV_KEY,
15719 + .code = KEY_WPS_BUTTON,
15720 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15721 + .gpio = NBG6716_GPIO_BTN_WPS,
15722 + .active_low = 1,
15723 + },
15728 +static struct gpio_led nbg6616_leds_gpio[] __initdata = {
15730 + .name = "nbg6616:green:power",
15731 + .gpio = NBG6716_GPIO_LED_POWER,
15732 + .active_low = 1,
15733 + },
15735 + .name = "nbg6616:green:usb2",
15736 + .gpio = NBG6616_GPIO_LED_USB0,
15737 + .active_low = 1,
15738 + },
15740 + .name = "nbg6616:green:usb1",
15741 + .gpio = NBG6616_GPIO_LED_USB1,
15742 + .active_low = 1,
15743 + },
15745 + .name = "nbg6616:green:wifi2g",
15746 + .gpio = NBG6716_GPIO_LED_WIFI2G,
15747 + .active_low = 1,
15748 + },
15750 + .name = "nbg6616:green:wifi5g",
15751 + .gpio = NBG6716_GPIO_LED_WIFI5G,
15752 + .active_low = 1,
15753 + },
15755 + .name = "nbg6616:green:wps",
15756 + .gpio = NBG6616_GPIO_LED_WPS,
15757 + .active_low = 1,
15761 +static struct gpio_keys_button nbg6616_gpio_keys[] __initdata = {
15763 + .desc = "RESET button",
15764 + .type = EV_KEY,
15765 + .code = KEY_RESTART,
15766 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15767 + .gpio = NBG6716_GPIO_BTN_RESET,
15768 + .active_low = 1,
15769 + },
15771 + .desc = "RFKILL button",
15772 + .type = EV_KEY,
15773 + .code = KEY_RFKILL,
15774 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15775 + .gpio = NBG6716_GPIO_BTN_RFKILL,
15776 + .active_low = 1,
15777 + },
15779 + .desc = "WPS button",
15780 + .type = EV_KEY,
15781 + .code = KEY_WPS_BUTTON,
15782 + .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL,
15783 + .gpio = NBG6716_GPIO_BTN_WPS,
15784 + .active_low = 1,
15785 + },
15789 +static struct ar8327_pad_cfg nbg6716_ar8327_pad0_cfg;
15790 +static struct ar8327_pad_cfg nbg6716_ar8327_pad6_cfg;
15791 +static struct ar8327_led_cfg nbg6716_ar8327_led_cfg;
15793 +static struct ar8327_platform_data nbg6716_ar8327_data = {
15794 + .pad0_cfg = &nbg6716_ar8327_pad0_cfg,
15795 + .pad6_cfg = &nbg6716_ar8327_pad6_cfg,
15796 + .port0_cfg = {
15797 + .force_link = 1,
15798 + .speed = AR8327_PORT_SPEED_1000,
15799 + .duplex = 1,
15800 + .txpause = 1,
15801 + .rxpause = 1,
15802 + },
15803 + .port6_cfg = {
15804 + .force_link = 1,
15805 + .speed = AR8327_PORT_SPEED_1000,
15806 + .duplex = 1,
15807 + .txpause = 1,
15808 + .rxpause = 1,
15809 + },
15810 + .led_cfg = &nbg6716_ar8327_led_cfg
15813 +static struct mdio_board_info nbg6716_mdio0_info[] = {
15815 + .bus_id = "ag71xx-mdio.0",
15816 + .phy_addr = 0,
15817 + .platform_data = &nbg6716_ar8327_data,
15818 + },
15821 +static void nbg6716_get_mac(void* nvram_addr, const char *name, char *mac)
15823 + u8 *nvram = (u8 *) KSEG1ADDR(nvram_addr);
15824 + int err;
15826 + err = ath79_nvram_parse_mac_addr(nvram, 0x10000,
15827 + name, mac);
15828 + if (err)
15829 + pr_err("no MAC address found for %s\n", name);
15832 +static void __init nbg6716_common_setup(u32 leds_num, struct gpio_led* leds,
15833 + u32 keys_num,
15834 + struct gpio_keys_button* keys,
15835 + void* art_addr, void* nvram)
15837 + u8 *art = (u8 *) KSEG1ADDR(art_addr);
15838 + u8 tmpmac[ETH_ALEN];
15840 + ath79_register_m25p80(NULL);
15842 + ath79_register_leds_gpio(-1, leds_num, leds);
15843 + ath79_register_gpio_keys_polled(-1, NBG6716_KEYS_POLL_INTERVAL,
15844 + keys_num, keys);
15846 + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
15847 + ath79_register_nfc();
15849 + gpio_request_one(NBG6716_GPIO_USB_POWER,
15850 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
15851 + "USB power");
15853 + ath79_register_usb();
15855 + nbg6716_get_mac(nvram, "ethaddr=", tmpmac);
15857 + ath79_register_pci();
15859 + ath79_register_wmac(art + NBG6716_WMAC_CALDATA_OFFSET, tmpmac);
15861 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
15863 + ath79_register_mdio(0, 0x0);
15865 + ath79_init_mac(ath79_eth0_data.mac_addr, tmpmac, 2);
15866 + ath79_init_mac(ath79_eth1_data.mac_addr, tmpmac, 3);
15868 + mdiobus_register_board_info(nbg6716_mdio0_info,
15869 + ARRAY_SIZE(nbg6716_mdio0_info));
15871 + /* GMAC0 is connected to the RMGII interface */
15872 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
15873 + ath79_eth0_data.phy_mask = BIT(0);
15874 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
15876 + ath79_register_eth(0);
15878 + /* GMAC1 is connected to the SGMII interface */
15879 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
15880 + ath79_eth1_data.speed = SPEED_1000;
15881 + ath79_eth1_data.duplex = DUPLEX_FULL;
15883 + ath79_register_eth(1);
15886 +static void __init nbg6716_010_setup(void)
15888 + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
15889 + nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
15890 + nbg6716_ar8327_pad0_cfg.txclk_delay_en = true;
15891 + nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true;
15892 + nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
15893 + nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
15894 + nbg6716_ar8327_pad0_cfg.mac06_exchange_en = true;
15896 + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
15897 + nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
15898 + nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true;
15899 + nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
15901 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
15902 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
15904 + nbg6716_ar8327_led_cfg.open_drain = 0;
15905 + nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7;
15906 + nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7;
15907 + nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7;
15908 + nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00;
15910 + nbg6716_common_setup(ARRAY_SIZE(nbg6716_leds_gpio), nbg6716_leds_gpio,
15911 + ARRAY_SIZE(nbg6716_gpio_keys), nbg6716_gpio_keys,
15912 + (void*) 0x1f050000, (void*) 0x1f040000);
15915 +static void __init nbg6616_010_setup(void)
15917 + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
15918 + nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
15919 + nbg6716_ar8327_pad0_cfg.txclk_delay_en = true;
15920 + nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true;
15921 + nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
15922 + nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
15924 + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
15925 + nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
15926 + nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true;
15927 + nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
15929 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
15930 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
15932 + nbg6716_ar8327_led_cfg.open_drain = 0;
15933 + nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7;
15934 + nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7;
15935 + nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7;
15936 + nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00;
15939 + nbg6716_common_setup(ARRAY_SIZE(nbg6616_leds_gpio), nbg6616_leds_gpio,
15940 + ARRAY_SIZE(nbg6616_gpio_keys), nbg6616_gpio_keys,
15941 + (void*) 0x1f040000, (void*) 0x1f030000);
15945 +MIPS_MACHINE(ATH79_MACH_NBG6716, "NBG6716",
15946 + "Zyxel NBG6716",
15947 + nbg6716_010_setup);
15949 +MIPS_MACHINE(ATH79_MACH_NBG6616, "NBG6616",
15950 + "Zyxel NBG6616",
15951 + nbg6616_010_setup);
15953 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-om2p.c linux-4.1.43/arch/mips/ath79/mach-om2p.c
15954 --- linux-4.1.43.orig/arch/mips/ath79/mach-om2p.c 1970-01-01 01:00:00.000000000 +0100
15955 +++ linux-4.1.43/arch/mips/ath79/mach-om2p.c 2017-08-06 20:02:15.000000000 +0200
15956 @@ -0,0 +1,225 @@
15958 + * OpenMesh OM2P support
15960 + * Copyright (C) 2011 Marek Lindner <marek@open-mesh.com>
15962 + * This program is free software; you can redistribute it and/or modify it
15963 + * under the terms of the GNU General Public License version 2 as published
15964 + * by the Free Software Foundation.
15965 + */
15967 +#include <linux/gpio.h>
15968 +#include <linux/mtd/mtd.h>
15969 +#include <linux/mtd/partitions.h>
15970 +#include <linux/platform_device.h>
15972 +#include <asm/mach-ath79/ar71xx_regs.h>
15973 +#include <asm/mach-ath79/ath79.h>
15975 +#include "common.h"
15976 +#include "dev-ap9x-pci.h"
15977 +#include "dev-eth.h"
15978 +#include "dev-gpio-buttons.h"
15979 +#include "dev-leds-gpio.h"
15980 +#include "dev-m25p80.h"
15981 +#include "dev-wmac.h"
15982 +#include "machtypes.h"
15984 +#define OM2P_GPIO_LED_POWER 0
15985 +#define OM2P_GPIO_LED_GREEN 13
15986 +#define OM2P_GPIO_LED_RED 14
15987 +#define OM2P_GPIO_LED_YELLOW 15
15988 +#define OM2P_GPIO_LED_LAN 16
15989 +#define OM2P_GPIO_LED_WAN 17
15990 +#define OM2P_GPIO_BTN_RESET 1
15992 +#define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
15993 +#define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
15995 +#define OM2P_WAN_PHYMASK BIT(4)
15997 +#define OM2P_LC_GPIO_LED_POWER 1
15998 +#define OM2P_LC_GPIO_LED_GREEN 15
15999 +#define OM2P_LC_GPIO_LED_RED 16
16000 +#define OM2P_LC_GPIO_LED_YELLOW 0
16001 +#define OM2P_LC_GPIO_LED_LAN 13
16002 +#define OM2P_LC_GPIO_LED_WAN 17
16003 +#define OM2P_LC_GPIO_BTN_RESET 12
16005 +static struct flash_platform_data om2p_flash_data = {
16006 + .type = "s25sl12800",
16007 + .name = "ar7240-nor0",
16010 +static struct gpio_led om2p_leds_gpio[] __initdata = {
16012 + .name = "om2p:blue:power",
16013 + .gpio = OM2P_GPIO_LED_POWER,
16014 + .active_low = 1,
16015 + }, {
16016 + .name = "om2p:red:wifi",
16017 + .gpio = OM2P_GPIO_LED_RED,
16018 + .active_low = 1,
16019 + }, {
16020 + .name = "om2p:yellow:wifi",
16021 + .gpio = OM2P_GPIO_LED_YELLOW,
16022 + .active_low = 1,
16023 + }, {
16024 + .name = "om2p:green:wifi",
16025 + .gpio = OM2P_GPIO_LED_GREEN,
16026 + .active_low = 1,
16027 + }, {
16028 + .name = "om2p:blue:lan",
16029 + .gpio = OM2P_GPIO_LED_LAN,
16030 + .active_low = 1,
16031 + }, {
16032 + .name = "om2p:blue:wan",
16033 + .gpio = OM2P_GPIO_LED_WAN,
16034 + .active_low = 1,
16038 +static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
16040 + .desc = "reset",
16041 + .type = EV_KEY,
16042 + .code = KEY_RESTART,
16043 + .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
16044 + .gpio = OM2P_GPIO_BTN_RESET,
16045 + .active_low = 1,
16049 +static void __init om2p_setup(void)
16051 + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
16052 + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
16053 + u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
16055 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
16056 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
16057 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
16058 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
16059 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
16061 + ath79_register_m25p80(&om2p_flash_data);
16063 + ath79_register_mdio(0, ~OM2P_WAN_PHYMASK);
16065 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
16066 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
16068 + ath79_register_eth(0);
16069 + ath79_register_eth(1);
16071 + ap91_pci_init(ee, NULL);
16073 + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
16074 + om2p_leds_gpio);
16076 + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
16077 + ARRAY_SIZE(om2p_gpio_keys),
16078 + om2p_gpio_keys);
16081 +MIPS_MACHINE(ATH79_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);
16084 +static struct flash_platform_data om2p_lc_flash_data = {
16085 + .type = "s25sl12800",
16088 +static void __init om2p_lc_setup(void)
16090 + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
16091 + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
16092 + u8 *art = (u8 *)KSEG1ADDR(0x1ffc1000);
16093 + u32 t;
16095 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
16096 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
16097 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
16098 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
16099 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
16101 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
16102 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
16103 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
16105 + ath79_register_m25p80(&om2p_lc_flash_data);
16107 + om2p_leds_gpio[0].gpio = OM2P_LC_GPIO_LED_POWER;
16108 + om2p_leds_gpio[1].gpio = OM2P_LC_GPIO_LED_RED;
16109 + om2p_leds_gpio[2].gpio = OM2P_LC_GPIO_LED_YELLOW;
16110 + om2p_leds_gpio[3].gpio = OM2P_LC_GPIO_LED_GREEN;
16111 + om2p_leds_gpio[4].gpio = OM2P_LC_GPIO_LED_LAN;
16112 + om2p_leds_gpio[5].gpio = OM2P_LC_GPIO_LED_WAN;
16113 + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
16114 + om2p_leds_gpio);
16116 + om2p_gpio_keys[0].gpio = OM2P_LC_GPIO_BTN_RESET;
16117 + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
16118 + ARRAY_SIZE(om2p_gpio_keys),
16119 + om2p_gpio_keys);
16121 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
16122 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
16124 + ath79_register_mdio(0, 0x0);
16126 + ath79_register_eth(0);
16127 + ath79_register_eth(1);
16129 + ath79_register_wmac(art, NULL);
16132 +MIPS_MACHINE(ATH79_MACH_OM2P_LC, "OM2P-LC", "OpenMesh OM2P LC", om2p_lc_setup);
16133 +MIPS_MACHINE(ATH79_MACH_OM2Pv2, "OM2Pv2", "OpenMesh OM2Pv2", om2p_lc_setup);
16135 +static void __init om2p_hs_setup(void)
16137 + u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
16138 + u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
16139 + u8 *art = (u8 *)KSEG1ADDR(0x1ffc1000);
16141 + /* make lan / wan leds software controllable */
16142 + ath79_gpio_output_select(OM2P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
16143 + ath79_gpio_output_select(OM2P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
16145 + /* enable reset button */
16146 + ath79_gpio_output_select(OM2P_GPIO_BTN_RESET, AR934X_GPIO_OUT_GPIO);
16147 + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
16149 + om2p_leds_gpio[4].gpio = OM2P_GPIO_LED_WAN;
16150 + om2p_leds_gpio[5].gpio = OM2P_GPIO_LED_LAN;
16152 + ath79_register_m25p80(&om2p_lc_flash_data);
16153 + ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
16154 + om2p_leds_gpio);
16155 + ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
16156 + ARRAY_SIZE(om2p_gpio_keys),
16157 + om2p_gpio_keys);
16159 + ath79_register_wmac(art, NULL);
16161 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
16162 + ath79_register_mdio(1, 0x0);
16164 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
16165 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
16167 + /* GMAC0 is connected to the PHY0 of the internal switch */
16168 + ath79_switch_data.phy4_mii_en = 1;
16169 + ath79_switch_data.phy_poll_mask = BIT(0);
16170 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
16171 + ath79_eth0_data.phy_mask = BIT(0);
16172 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
16173 + ath79_register_eth(0);
16175 + /* GMAC1 is connected to the internal switch */
16176 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
16177 + ath79_register_eth(1);
16180 +MIPS_MACHINE(ATH79_MACH_OM2P_HS, "OM2P-HS", "OpenMesh OM2P HS", om2p_hs_setup);
16181 +MIPS_MACHINE(ATH79_MACH_OM2P_HSv2, "OM2P-HSv2", "OpenMesh OM2P HSv2", om2p_hs_setup);
16182 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-om5p.c linux-4.1.43/arch/mips/ath79/mach-om5p.c
16183 --- linux-4.1.43.orig/arch/mips/ath79/mach-om5p.c 1970-01-01 01:00:00.000000000 +0100
16184 +++ linux-4.1.43/arch/mips/ath79/mach-om5p.c 2017-08-06 20:02:15.000000000 +0200
16185 @@ -0,0 +1,218 @@
16187 + * OpenMesh OM5P support
16189 + * Copyright (C) 2013 Marek Lindner <marek@open-mesh.com>
16190 + * Copyright (C) 2014 Sven Eckelmann <sven@open-mesh.com>
16192 + * This program is free software; you can redistribute it and/or modify it
16193 + * under the terms of the GNU General Public License version 2 as published
16194 + * by the Free Software Foundation.
16195 + */
16197 +#include <linux/gpio.h>
16198 +#include <linux/mtd/mtd.h>
16199 +#include <linux/mtd/partitions.h>
16200 +#include <linux/platform_device.h>
16201 +#include <linux/i2c.h>
16202 +#include <linux/i2c-algo-bit.h>
16203 +#include <linux/i2c-gpio.h>
16204 +#include <linux/platform_data/phy-at803x.h>
16206 +#include <asm/mach-ath79/ar71xx_regs.h>
16207 +#include <asm/mach-ath79/ath79.h>
16209 +#include "common.h"
16210 +#include "dev-ap9x-pci.h"
16211 +#include "dev-eth.h"
16212 +#include "dev-gpio-buttons.h"
16213 +#include "dev-leds-gpio.h"
16214 +#include "dev-m25p80.h"
16215 +#include "dev-wmac.h"
16216 +#include "machtypes.h"
16218 +#define OM5P_GPIO_LED_POWER 13
16219 +#define OM5P_GPIO_LED_GREEN 16
16220 +#define OM5P_GPIO_LED_RED 19
16221 +#define OM5P_GPIO_LED_YELLOW 17
16222 +#define OM5P_GPIO_LED_LAN 14
16223 +#define OM5P_GPIO_LED_WAN 15
16224 +#define OM5P_GPIO_BTN_RESET 4
16225 +#define OM5P_GPIO_I2C_SCL 20
16226 +#define OM5P_GPIO_I2C_SDA 21
16228 +#define OM5P_KEYS_POLL_INTERVAL 20 /* msecs */
16229 +#define OM5P_KEYS_DEBOUNCE_INTERVAL (3 * OM5P_KEYS_POLL_INTERVAL)
16231 +#define OM5P_WMAC_CALDATA_OFFSET 0x1000
16232 +#define OM5P_PCI_CALDATA_OFFSET 0x5000
16234 +static struct gpio_led om5p_leds_gpio[] __initdata = {
16236 + .name = "om5p:blue:power",
16237 + .gpio = OM5P_GPIO_LED_POWER,
16238 + .active_low = 1,
16239 + }, {
16240 + .name = "om5p:red:wifi",
16241 + .gpio = OM5P_GPIO_LED_RED,
16242 + .active_low = 1,
16243 + }, {
16244 + .name = "om5p:yellow:wifi",
16245 + .gpio = OM5P_GPIO_LED_YELLOW,
16246 + .active_low = 1,
16247 + }, {
16248 + .name = "om5p:green:wifi",
16249 + .gpio = OM5P_GPIO_LED_GREEN,
16250 + .active_low = 1,
16251 + }, {
16252 + .name = "om5p:blue:lan",
16253 + .gpio = OM5P_GPIO_LED_LAN,
16254 + .active_low = 1,
16255 + }, {
16256 + .name = "om5p:blue:wan",
16257 + .gpio = OM5P_GPIO_LED_WAN,
16258 + .active_low = 1,
16262 +static struct gpio_keys_button om5p_gpio_keys[] __initdata = {
16264 + .desc = "reset",
16265 + .type = EV_KEY,
16266 + .code = KEY_RESTART,
16267 + .debounce_interval = OM5P_KEYS_DEBOUNCE_INTERVAL,
16268 + .gpio = OM5P_GPIO_BTN_RESET,
16269 + .active_low = 1,
16273 +static struct flash_platform_data om5p_flash_data = {
16274 + .type = "mx25l12805d",
16277 +static void __init om5p_setup(void)
16279 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
16280 + u8 mac[6];
16282 + /* make lan / wan leds software controllable */
16283 + ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
16284 + ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
16286 + ath79_register_m25p80(&om5p_flash_data);
16287 + ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
16288 + om5p_leds_gpio);
16289 + ath79_register_gpio_keys_polled(-1, OM5P_KEYS_POLL_INTERVAL,
16290 + ARRAY_SIZE(om5p_gpio_keys),
16291 + om5p_gpio_keys);
16293 + ath79_init_mac(mac, art, 2);
16294 + ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
16296 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
16297 + ath79_register_mdio(1, 0x0);
16299 + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
16300 + ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
16302 + /* GMAC0 is connected to the PHY0 of the internal switch */
16303 + ath79_switch_data.phy4_mii_en = 1;
16304 + ath79_switch_data.phy_poll_mask = BIT(0);
16305 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
16306 + ath79_eth0_data.phy_mask = BIT(0);
16307 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
16308 + ath79_register_eth(0);
16310 + /* GMAC1 is connected to the internal switch */
16311 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
16312 + ath79_register_eth(1);
16315 +MIPS_MACHINE(ATH79_MACH_OM5P, "OM5P", "OpenMesh OM5P", om5p_setup);
16317 +static struct i2c_gpio_platform_data om5pan_i2c_device_platdata = {
16318 + .sda_pin = OM5P_GPIO_I2C_SDA,
16319 + .scl_pin = OM5P_GPIO_I2C_SCL,
16320 + .udelay = 10,
16321 + .sda_is_open_drain = 1,
16322 + .scl_is_open_drain = 1,
16325 +static struct platform_device om5pan_i2c_device = {
16326 + .name = "i2c-gpio",
16327 + .id = 0,
16328 + .dev = {
16329 + .platform_data = &om5pan_i2c_device_platdata,
16330 + },
16333 +static struct i2c_board_info om5pan_i2c_devs[] __initdata = {
16335 + I2C_BOARD_INFO("tmp423", 0x4c),
16336 + },
16339 +static struct at803x_platform_data om5p_an_at803x_data = {
16340 + .disable_smarteee = 1,
16341 + .enable_rgmii_rx_delay = 1,
16342 + .enable_rgmii_tx_delay = 1,
16345 +static struct mdio_board_info om5p_an_mdio0_info[] = {
16347 + .bus_id = "ag71xx-mdio.0",
16348 + .phy_addr = 7,
16349 + .platform_data = &om5p_an_at803x_data,
16350 + },
16353 +static void __init om5p_an_setup(void)
16355 + u8 *art = (u8 *)KSEG1ADDR(0x1fff0000);
16356 + u8 mac[6];
16358 + /* temperature sensor */
16359 + platform_device_register(&om5pan_i2c_device);
16360 + i2c_register_board_info(0, om5pan_i2c_devs,
16361 + ARRAY_SIZE(om5pan_i2c_devs));
16363 + /* make lan / wan leds software controllable */
16364 + ath79_gpio_output_select(OM5P_GPIO_LED_LAN, AR934X_GPIO_OUT_GPIO);
16365 + ath79_gpio_output_select(OM5P_GPIO_LED_WAN, AR934X_GPIO_OUT_GPIO);
16367 + ath79_register_m25p80(&om5p_flash_data);
16368 + ath79_register_leds_gpio(-1, ARRAY_SIZE(om5p_leds_gpio),
16369 + om5p_leds_gpio);
16371 + ath79_init_mac(mac, art, 0x02);
16372 + ath79_register_wmac(art + OM5P_WMAC_CALDATA_OFFSET, mac);
16374 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
16375 + ath79_setup_ar934x_eth_rx_delay(2, 2);
16376 + ath79_register_mdio(0, 0x0);
16377 + ath79_register_mdio(1, 0x0);
16379 + mdiobus_register_board_info(om5p_an_mdio0_info,
16380 + ARRAY_SIZE(om5p_an_mdio0_info));
16382 + ath79_init_mac(ath79_eth0_data.mac_addr, art, 0x00);
16383 + ath79_init_mac(ath79_eth1_data.mac_addr, art, 0x01);
16385 + /* GMAC0 is connected to the PHY7 */
16386 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
16387 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
16388 + ath79_eth0_data.phy_mask = BIT(7);
16389 + ath79_eth0_pll_data.pll_1000 = 0x02000000;
16390 + ath79_eth0_pll_data.pll_100 = 0x00000101;
16391 + ath79_eth0_pll_data.pll_10 = 0x00001313;
16392 + ath79_register_eth(0);
16394 + /* GMAC1 is connected to the internal switch */
16395 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
16396 + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
16397 + ath79_register_eth(1);
16399 + ath79_init_mac(mac, art, 0x10);
16400 + ap91_pci_init(art + OM5P_PCI_CALDATA_OFFSET, mac);
16403 +MIPS_MACHINE(ATH79_MACH_OM5P_AN, "OM5P-AN", "OpenMesh OM5P AN", om5p_an_setup);
16404 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-onion-omega.c linux-4.1.43/arch/mips/ath79/mach-onion-omega.c
16405 --- linux-4.1.43.orig/arch/mips/ath79/mach-onion-omega.c 1970-01-01 01:00:00.000000000 +0100
16406 +++ linux-4.1.43/arch/mips/ath79/mach-onion-omega.c 2017-08-06 20:02:15.000000000 +0200
16407 @@ -0,0 +1,84 @@
16409 + * Onion Omega board support
16411 + * Copyright (C) 2015 Boken Lin <bl@onion.io>
16413 + * This program is free software; you can redistribute it and/or modify it
16414 + * under the terms of the GNU General Public License version 2 as published
16415 + * by the Free Software Foundation.
16416 + */
16418 +#include <linux/gpio.h>
16420 +#include <asm/mach-ath79/ath79.h>
16422 +#include "dev-eth.h"
16423 +#include "dev-gpio-buttons.h"
16424 +#include "dev-leds-gpio.h"
16425 +#include "dev-m25p80.h"
16426 +#include "dev-usb.h"
16427 +#include "dev-wmac.h"
16428 +#include "machtypes.h"
16430 +#define OMEGA_GPIO_LED_SYSTEM 27
16431 +#define OMEGA_GPIO_BTN_RESET 11
16433 +#define OMEGA_GPIO_USB_POWER 8
16435 +#define OMEGA_KEYS_POLL_INTERVAL 20 /* msecs */
16436 +#define OMEGA_KEYS_DEBOUNCE_INTERVAL (3 * OMEGA_KEYS_POLL_INTERVAL)
16438 +static const char *omega_part_probes[] = {
16439 + "tp-link",
16440 + NULL,
16443 +static struct flash_platform_data omega_flash_data = {
16444 + .part_probes = omega_part_probes,
16447 +static struct gpio_led omega_leds_gpio[] __initdata = {
16449 + .name = "onion:amber:system",
16450 + .gpio = OMEGA_GPIO_LED_SYSTEM,
16451 + .active_low = 1,
16452 + },
16455 +static struct gpio_keys_button omega_gpio_keys[] __initdata = {
16457 + .desc = "reset",
16458 + .type = EV_KEY,
16459 + .code = KEY_RESTART,
16460 + .debounce_interval = OMEGA_KEYS_DEBOUNCE_INTERVAL,
16461 + .gpio = OMEGA_GPIO_BTN_RESET,
16462 + .active_low = 0,
16466 +static void __init onion_omega_setup(void)
16468 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
16469 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
16471 + ath79_register_m25p80(&omega_flash_data);
16472 + ath79_register_leds_gpio(-1, ARRAY_SIZE(omega_leds_gpio),
16473 + omega_leds_gpio);
16474 + ath79_register_gpio_keys_polled(-1, OMEGA_KEYS_POLL_INTERVAL,
16475 + ARRAY_SIZE(omega_gpio_keys),
16476 + omega_gpio_keys);
16478 + gpio_request_one(OMEGA_GPIO_USB_POWER,
16479 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
16480 + "USB power");
16481 + ath79_register_usb();
16483 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
16485 + ath79_register_mdio(0, 0x0);
16486 + ath79_register_eth(0);
16488 + ath79_register_wmac(ee, mac);
16491 +MIPS_MACHINE(ATH79_MACH_ONION_OMEGA, "ONION-OMEGA", "Onion Omega", onion_omega_setup);
16492 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-pb42.c linux-4.1.43/arch/mips/ath79/mach-pb42.c
16493 --- linux-4.1.43.orig/arch/mips/ath79/mach-pb42.c 1970-01-01 01:00:00.000000000 +0100
16494 +++ linux-4.1.43/arch/mips/ath79/mach-pb42.c 2017-08-06 20:02:15.000000000 +0200
16495 @@ -0,0 +1,83 @@
16497 + * Atheros PB42 board support
16499 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
16500 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
16502 + * This program is free software; you can redistribute it and/or modify it
16503 + * under the terms of the GNU General Public License version 2 as published
16504 + * by the Free Software Foundation.
16505 + */
16507 +#include <asm/mach-ath79/ath79.h>
16509 +#include "dev-eth.h"
16510 +#include "dev-gpio-buttons.h"
16511 +#include "dev-m25p80.h"
16512 +#include "dev-usb.h"
16513 +#include "machtypes.h"
16514 +#include "pci.h"
16516 +#define PB42_KEYS_POLL_INTERVAL 20 /* msecs */
16517 +#define PB42_KEYS_DEBOUNCE_INTERVAL (3 * PB42_KEYS_POLL_INTERVAL)
16519 +#define PB42_GPIO_BTN_SW4 8
16520 +#define PB42_GPIO_BTN_SW5 3
16522 +static struct gpio_keys_button pb42_gpio_keys[] __initdata = {
16524 + .desc = "sw4",
16525 + .type = EV_KEY,
16526 + .code = BTN_0,
16527 + .debounce_interval = PB42_KEYS_DEBOUNCE_INTERVAL,
16528 + .gpio = PB42_GPIO_BTN_SW4,
16529 + .active_low = 1,
16530 + }, {
16531 + .desc = "sw5",
16532 + .type = EV_KEY,
16533 + .code = BTN_1,
16534 + .debounce_interval = PB42_KEYS_DEBOUNCE_INTERVAL,
16535 + .gpio = PB42_GPIO_BTN_SW5,
16536 + .active_low = 1,
16540 +static const char *pb42_part_probes[] = {
16541 + "RedBoot",
16542 + NULL,
16545 +static struct flash_platform_data pb42_flash_data = {
16546 + .part_probes = pb42_part_probes,
16549 +#define PB42_WAN_PHYMASK BIT(20)
16550 +#define PB42_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
16551 +#define PB42_MDIO_PHYMASK (PB42_LAN_PHYMASK | PB42_WAN_PHYMASK)
16553 +static void __init pb42_init(void)
16555 + ath79_register_m25p80(&pb42_flash_data);
16557 + ath79_register_mdio(0, ~PB42_MDIO_PHYMASK);
16559 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
16560 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
16561 + ath79_eth0_data.phy_mask = PB42_WAN_PHYMASK;
16563 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
16564 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
16565 + ath79_eth1_data.speed = SPEED_100;
16566 + ath79_eth1_data.duplex = DUPLEX_FULL;
16568 + ath79_register_eth(0);
16569 + ath79_register_eth(1);
16571 + ath79_register_gpio_keys_polled(-1, PB42_KEYS_POLL_INTERVAL,
16572 + ARRAY_SIZE(pb42_gpio_keys),
16573 + pb42_gpio_keys);
16575 + ath79_register_pci();
16578 +MIPS_MACHINE(ATH79_MACH_PB42, "PB42", "Atheros PB42", pb42_init);
16579 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-pb44.c linux-4.1.43/arch/mips/ath79/mach-pb44.c
16580 --- linux-4.1.43.orig/arch/mips/ath79/mach-pb44.c 2017-08-06 01:56:14.000000000 +0200
16581 +++ linux-4.1.43/arch/mips/ath79/mach-pb44.c 2017-08-06 20:02:15.000000000 +0200
16582 @@ -8,23 +8,48 @@
16583 * by the Free Software Foundation.
16586 +#include <linux/delay.h>
16587 #include <linux/init.h>
16588 #include <linux/platform_device.h>
16589 #include <linux/i2c.h>
16590 #include <linux/i2c-gpio.h>
16591 #include <linux/i2c/pcf857x.h>
16592 +#include <linux/i2c/pcf857x.h>
16593 +#include <linux/spi/flash.h>
16594 +#include <linux/spi/vsc7385.h>
16596 -#include "machtypes.h"
16597 +#include <asm/mach-ath79/ar71xx_regs.h>
16598 +#include <asm/mach-ath79/ath79.h>
16600 +#include "dev-eth.h"
16601 #include "dev-gpio-buttons.h"
16602 #include "dev-leds-gpio.h"
16603 #include "dev-spi.h"
16604 #include "dev-usb.h"
16605 +#include "machtypes.h"
16606 #include "pci.h"
16608 #define PB44_GPIO_I2C_SCL 0
16609 #define PB44_GPIO_I2C_SDA 1
16611 +#define PB44_PCF8757_VSC7395_CS 0
16612 +#define PB44_PCF8757_STEREO_CS 1
16613 +#define PB44_PCF8757_SLIC_CS0 2
16614 +#define PB44_PCF8757_SLIC_TEST 3
16615 +#define PB44_PCF8757_SLIC_INT0 4
16616 +#define PB44_PCF8757_SLIC_INT1 5
16617 +#define PB44_PCF8757_SW_RESET 6
16618 +#define PB44_PCF8757_SW_JUMP 8
16619 +#define PB44_PCF8757_LED_JUMP1 9
16620 +#define PB44_PCF8757_LED_JUMP2 10
16621 +#define PB44_PCF8757_TP24 11
16622 +#define PB44_PCF8757_TP25 12
16623 +#define PB44_PCF8757_TP26 13
16624 +#define PB44_PCF8757_TP27 14
16625 +#define PB44_PCF8757_TP28 15
16627 #define PB44_GPIO_EXP_BASE 16
16628 +#define PB44_GPIO_VSC7395_CS (PB44_GPIO_EXP_BASE + PB44_PCF8757_VSC7395_CS)
16629 #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
16630 #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
16631 #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
16632 @@ -87,20 +112,71 @@
16636 +static struct ath79_spi_controller_data pb44_spi0_data = {
16637 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
16638 + .cs_line = 0,
16641 +static struct ath79_spi_controller_data pb44_spi1_data = {
16642 + .cs_type = ATH79_SPI_CS_TYPE_GPIO,
16643 + .cs_line = PB44_GPIO_VSC7395_CS,
16646 +static void pb44_vsc7395_reset(void)
16648 + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
16649 + udelay(10);
16650 + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
16651 + mdelay(50);
16654 +static struct vsc7385_platform_data pb44_vsc7395_data = {
16655 + .reset = pb44_vsc7395_reset,
16656 + .ucode_name = "vsc7395_ucode_pb44.bin",
16657 + .mac_cfg = {
16658 + .tx_ipg = 6,
16659 + .bit2 = 1,
16660 + .clk_sel = 0,
16661 + },
16664 +static const char *pb44_part_probes[] = {
16665 + "RedBoot",
16666 + NULL,
16669 +static struct flash_platform_data pb44_flash_data = {
16670 + .part_probes = pb44_part_probes,
16673 static struct spi_board_info pb44_spi_info[] = {
16675 .bus_num = 0,
16676 .chip_select = 0,
16677 .max_speed_hz = 25000000,
16678 .modalias = "m25p64",
16679 + .platform_data = &pb44_flash_data,
16680 + .controller_data = &pb44_spi0_data,
16683 + .bus_num = 0,
16684 + .chip_select = 1,
16685 + .max_speed_hz = 25000000,
16686 + .modalias = "spi-vsc7385",
16687 + .platform_data = &pb44_vsc7395_data,
16688 + .controller_data = &pb44_spi1_data,
16692 static struct ath79_spi_platform_data pb44_spi_data = {
16693 .bus_num = 0,
16694 - .num_chipselect = 1,
16695 + .num_chipselect = 2,
16698 +#define PB44_WAN_PHYMASK BIT(0)
16699 +#define PB44_LAN_PHYMASK 0
16700 +#define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
16702 static void __init pb44_init(void)
16704 i2c_register_board_info(0, pb44_i2c_board_info,
16705 @@ -116,6 +192,22 @@
16706 ARRAY_SIZE(pb44_spi_info));
16707 ath79_register_usb();
16708 ath79_register_pci();
16710 + ath79_register_mdio(0, ~PB44_MDIO_PHYMASK);
16712 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
16713 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
16714 + ath79_eth0_data.phy_mask = PB44_WAN_PHYMASK;
16716 + ath79_register_eth(0);
16718 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
16719 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
16720 + ath79_eth1_data.speed = SPEED_1000;
16721 + ath79_eth1_data.duplex = DUPLEX_FULL;
16722 + ath79_eth1_pll_data.pll_1000 = 0x110000;
16724 + ath79_register_eth(1);
16727 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
16728 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-pb92.c linux-4.1.43/arch/mips/ath79/mach-pb92.c
16729 --- linux-4.1.43.orig/arch/mips/ath79/mach-pb92.c 1970-01-01 01:00:00.000000000 +0100
16730 +++ linux-4.1.43/arch/mips/ath79/mach-pb92.c 2017-08-06 20:02:15.000000000 +0200
16731 @@ -0,0 +1,70 @@
16733 + * Atheros PB92 board support
16735 + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
16736 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
16737 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
16739 + * This program is free software; you can redistribute it and/or modify it
16740 + * under the terms of the GNU General Public License version 2 as published
16741 + * by the Free Software Foundation.
16742 + */
16744 +#include <asm/mach-ath79/ath79.h>
16746 +#include "dev-eth.h"
16747 +#include "dev-gpio-buttons.h"
16748 +#include "dev-m25p80.h"
16749 +#include "dev-usb.h"
16750 +#include "machtypes.h"
16751 +#include "pci.h"
16753 +#define PB92_KEYS_POLL_INTERVAL 20 /* msecs */
16754 +#define PB92_KEYS_DEBOUNCE_INTERVAL (3 * PB92_KEYS_POLL_INTERVAL)
16756 +#define PB92_GPIO_BTN_SW4 8
16757 +#define PB92_GPIO_BTN_SW5 3
16759 +static struct gpio_keys_button pb92_gpio_keys[] __initdata = {
16761 + .desc = "sw4",
16762 + .type = EV_KEY,
16763 + .code = BTN_0,
16764 + .debounce_interval = PB92_KEYS_DEBOUNCE_INTERVAL,
16765 + .gpio = PB92_GPIO_BTN_SW4,
16766 + .active_low = 1,
16767 + }, {
16768 + .desc = "sw5",
16769 + .type = EV_KEY,
16770 + .code = BTN_1,
16771 + .debounce_interval = PB92_KEYS_DEBOUNCE_INTERVAL,
16772 + .gpio = PB92_GPIO_BTN_SW5,
16773 + .active_low = 1,
16777 +static void __init pb92_init(void)
16779 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
16781 + ath79_register_m25p80(NULL);
16783 + ath79_register_mdio(0, ~BIT(0));
16784 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
16785 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
16786 + ath79_eth0_data.speed = SPEED_1000;
16787 + ath79_eth0_data.duplex = DUPLEX_FULL;
16788 + ath79_eth0_data.phy_mask = BIT(0);
16790 + ath79_register_eth(0);
16792 + ath79_register_gpio_keys_polled(-1, PB92_KEYS_POLL_INTERVAL,
16793 + ARRAY_SIZE(pb92_gpio_keys),
16794 + pb92_gpio_keys);
16796 + ath79_register_usb();
16798 + ath79_register_pci();
16801 +MIPS_MACHINE(ATH79_MACH_PB92, "PB92", "Atheros PB92", pb92_init);
16802 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-qihoo-c301.c linux-4.1.43/arch/mips/ath79/mach-qihoo-c301.c
16803 --- linux-4.1.43.orig/arch/mips/ath79/mach-qihoo-c301.c 1970-01-01 01:00:00.000000000 +0100
16804 +++ linux-4.1.43/arch/mips/ath79/mach-qihoo-c301.c 2017-08-06 20:02:15.000000000 +0200
16805 @@ -0,0 +1,166 @@
16807 + * Qihoo 360 C301 board support
16809 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
16810 + * Copyright (C) 2014 Weijie Gao <hackpascal@gmail.com>
16812 + * This program is free software; you can redistribute it and/or modify it
16813 + * under the terms of the GNU General Public License version 2 as published
16814 + * by the Free Software Foundation.
16815 + */
16817 +#include <linux/pci.h>
16818 +#include <linux/phy.h>
16819 +#include <linux/gpio.h>
16820 +#include <linux/platform_device.h>
16821 +#include <linux/ath9k_platform.h>
16823 +#include <asm/mach-ath79/ar71xx_regs.h>
16825 +#include "common.h"
16826 +#include "pci.h"
16827 +#include "dev-eth.h"
16828 +#include "dev-gpio-buttons.h"
16829 +#include "dev-leds-gpio.h"
16830 +#include "dev-m25p80.h"
16831 +#include "dev-spi.h"
16832 +#include "dev-usb.h"
16833 +#include "dev-wmac.h"
16834 +#include "machtypes.h"
16835 +#include "nvram.h"
16837 +#define QIHOO_C301_GPIO_LED_STATUS_GREEN 0
16838 +#define QIHOO_C301_GPIO_LED_STATUS_RED 11
16840 +#define QIHOO_C301_GPIO_LED_WAN 1
16841 +#define QIHOO_C301_GPIO_LED_LAN1 2
16842 +#define QIHOO_C301_GPIO_LED_LAN2 3
16843 +#define QIHOO_C301_GPIO_ETH_LEN_EN 18
16845 +#define QIHOO_C301_GPIO_BTN_RESET 16
16847 +#define QIHOO_C301_GPIO_USB_POWER 19
16849 +#define QIHOO_C301_GPIO_SPI_CS1 12
16851 +#define QIHOO_C301_GPIO_EXTERNAL_LNA0 14
16852 +#define QIHOO_C301_GPIO_EXTERNAL_LNA1 15
16854 +#define QIHOO_C301_KEYS_POLL_INTERVAL 20 /* msecs */
16855 +#define QIHOO_C301_KEYS_DEBOUNCE_INTERVAL \
16856 + (3 * QIHOO_C301_KEYS_POLL_INTERVAL)
16858 +#define QIHOO_C301_WMAC_CALDATA_OFFSET 0x1000
16860 +#define QIHOO_C301_NVRAM_ADDR 0x1f058010
16861 +#define QIHOO_C301_NVRAM_SIZE 0x7ff0
16863 +static struct gpio_led qihoo_c301_leds_gpio[] __initdata = {
16865 + .name = "qihoo:green:status",
16866 + .gpio = QIHOO_C301_GPIO_LED_STATUS_GREEN,
16867 + .active_low = 1,
16868 + },
16870 + .name = "qihoo:red:status",
16871 + .gpio = QIHOO_C301_GPIO_LED_STATUS_RED,
16872 + .active_low = 1,
16873 + },
16876 +static struct gpio_keys_button qihoo_c301_gpio_keys[] __initdata = {
16878 + .desc = "reset",
16879 + .type = EV_KEY,
16880 + .code = KEY_RESTART,
16881 + .debounce_interval = QIHOO_C301_KEYS_DEBOUNCE_INTERVAL,
16882 + .gpio = QIHOO_C301_GPIO_BTN_RESET,
16883 + .active_low = 1,
16884 + },
16887 +static struct flash_platform_data flash __initdata = {NULL, NULL, 0};
16889 +static void qihoo_c301_get_mac(const char *name, char *mac)
16891 + u8 *nvram = (u8 *) KSEG1ADDR(QIHOO_C301_NVRAM_ADDR);
16892 + int err;
16894 + err = ath79_nvram_parse_mac_addr(nvram, QIHOO_C301_NVRAM_SIZE,
16895 + name, mac);
16896 + if (err)
16897 + pr_err("no MAC address found for %s\n", name);
16900 +static void __init qihoo_c301_setup(void)
16902 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
16903 + u8 tmpmac[ETH_ALEN];
16905 + ath79_register_m25p80_multi(&flash);
16907 + ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
16909 + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_WAN,
16910 + AR934X_GPIO_OUT_LED_LINK4);
16911 + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_LAN1,
16912 + AR934X_GPIO_OUT_LED_LINK1);
16913 + ath79_gpio_output_select(QIHOO_C301_GPIO_LED_LAN2,
16914 + AR934X_GPIO_OUT_LED_LINK2);
16916 + ath79_gpio_output_select(QIHOO_C301_GPIO_SPI_CS1,
16917 + AR934X_GPIO_OUT_SPI_CS1);
16919 + gpio_request_one(QIHOO_C301_GPIO_ETH_LEN_EN,
16920 + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
16921 + "Ethernet LED enable");
16923 + ath79_register_leds_gpio(-1, ARRAY_SIZE(qihoo_c301_leds_gpio),
16924 + qihoo_c301_leds_gpio);
16926 + ath79_register_gpio_keys_polled(-1, QIHOO_C301_KEYS_POLL_INTERVAL,
16927 + ARRAY_SIZE(qihoo_c301_gpio_keys),
16928 + qihoo_c301_gpio_keys);
16930 + ath79_wmac_set_ext_lna_gpio(0, QIHOO_C301_GPIO_EXTERNAL_LNA0);
16931 + ath79_wmac_set_ext_lna_gpio(1, QIHOO_C301_GPIO_EXTERNAL_LNA1);
16933 + qihoo_c301_get_mac("wlan24mac=", tmpmac);
16934 + ath79_register_wmac(art + QIHOO_C301_WMAC_CALDATA_OFFSET, tmpmac);
16936 + ath79_register_pci();
16938 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE |
16939 + AR934X_ETH_CFG_SW_PHY_SWAP);
16941 + ath79_register_mdio(1, 0x0);
16943 + /* LAN */
16944 + qihoo_c301_get_mac("lanmac=", ath79_eth1_data.mac_addr);
16946 + /* GMAC1 is connected to the internal switch */
16947 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
16949 + ath79_register_eth(1);
16951 + /* WAN */
16952 + qihoo_c301_get_mac("wanmac=", ath79_eth0_data.mac_addr);
16954 + /* GMAC0 is connected to the PHY4 of the internal switch */
16955 + ath79_switch_data.phy4_mii_en = 1;
16956 + ath79_switch_data.phy_poll_mask = BIT(0);
16958 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
16959 + ath79_eth0_data.phy_mask = BIT(0);
16960 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
16962 + ath79_register_eth(0);
16964 + gpio_request_one(QIHOO_C301_GPIO_USB_POWER,
16965 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
16966 + "USB power");
16967 + ath79_register_usb();
16970 +MIPS_MACHINE(ATH79_MACH_QIHOO_C301, "QIHOO-C301", "Qihoo 360 C301",
16971 + qihoo_c301_setup);
16972 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-r6100.c linux-4.1.43/arch/mips/ath79/mach-r6100.c
16973 --- linux-4.1.43.orig/arch/mips/ath79/mach-r6100.c 1970-01-01 01:00:00.000000000 +0100
16974 +++ linux-4.1.43/arch/mips/ath79/mach-r6100.c 2017-08-06 20:02:15.000000000 +0200
16975 @@ -0,0 +1,146 @@
16977 + * NETGEAR R6100 board support
16979 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
16980 + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
16982 + * This program is free software; you can redistribute it and/or modify it
16983 + * under the terms of the GNU General Public License version 2 as published
16984 + * by the Free Software Foundation.
16985 + */
16987 +#include <linux/pci.h>
16988 +#include <linux/phy.h>
16989 +#include <linux/gpio.h>
16990 +#include <linux/platform_device.h>
16991 +#include <linux/ath9k_platform.h>
16992 +#include <linux/platform/ar934x_nfc.h>
16994 +#include <asm/mach-ath79/ar71xx_regs.h>
16996 +#include "common.h"
16997 +#include "dev-ap9x-pci.h"
16998 +#include "dev-eth.h"
16999 +#include "dev-gpio-buttons.h"
17000 +#include "dev-leds-gpio.h"
17001 +#include "dev-nfc.h"
17002 +#include "dev-usb.h"
17003 +#include "dev-wmac.h"
17004 +#include "machtypes.h"
17006 +#define R6100_GPIO_LED_WLAN 0
17007 +#define R6100_GPIO_LED_USB 11
17008 +#define R6100_GPIO_LED_WAN_GREEN 13
17009 +#define R6100_GPIO_LED_POWER_AMBER 14
17010 +#define R6100_GPIO_LED_WAN_AMBER 15
17011 +#define R6100_GPIO_LED_POWER_GREEN 17
17013 +#define R6100_GPIO_BTN_WIRELESS 1
17014 +#define R6100_GPIO_BTN_WPS 3
17015 +#define R6100_GPIO_BTN_RESET 12
17017 +#define R6100_GPIO_USB_POWER 16
17019 +#define R6100_KEYS_POLL_INTERVAL 20 /* msecs */
17020 +#define R6100_KEYS_DEBOUNCE_INTERVAL (3 * R6100_KEYS_POLL_INTERVAL)
17022 +static struct gpio_led r6100_leds_gpio[] __initdata = {
17024 + .name = "netgear:green:power",
17025 + .gpio = R6100_GPIO_LED_POWER_GREEN,
17026 + .active_low = 1,
17027 + },
17029 + .name = "netgear:amber:power",
17030 + .gpio = R6100_GPIO_LED_POWER_AMBER,
17031 + .active_low = 1,
17032 + },
17034 + .name = "netgear:green:wan",
17035 + .gpio = R6100_GPIO_LED_WAN_GREEN,
17036 + .active_low = 1,
17037 + },
17039 + .name = "netgear:amber:wan",
17040 + .gpio = R6100_GPIO_LED_WAN_AMBER,
17041 + .active_low = 1,
17042 + },
17044 + .name = "netgear:blue:usb",
17045 + .gpio = R6100_GPIO_LED_USB,
17046 + .active_low = 1,
17047 + },
17049 + .name = "netgear:blue:wlan",
17050 + .gpio = R6100_GPIO_LED_WLAN,
17051 + .active_low = 1,
17052 + },
17055 +static struct gpio_keys_button r6100_gpio_keys[] __initdata = {
17057 + .desc = "Reset button",
17058 + .type = EV_KEY,
17059 + .code = KEY_RESTART,
17060 + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
17061 + .gpio = R6100_GPIO_BTN_RESET,
17062 + .active_low = 0,
17063 + },
17065 + .desc = "WPS button",
17066 + .type = EV_KEY,
17067 + .code = KEY_WPS_BUTTON,
17068 + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
17069 + .gpio = R6100_GPIO_BTN_WPS,
17070 + .active_low = 0,
17071 + },
17073 + .desc = "RFKILL switch",
17074 + .type = EV_SW,
17075 + .code = KEY_RFKILL,
17076 + .debounce_interval = R6100_KEYS_DEBOUNCE_INTERVAL,
17077 + .gpio = R6100_GPIO_BTN_WIRELESS,
17078 + .active_low = 0,
17079 + },
17082 +static void __init r6100_setup(void)
17084 + ath79_register_leds_gpio(-1, ARRAY_SIZE(r6100_leds_gpio),
17085 + r6100_leds_gpio);
17086 + ath79_register_gpio_keys_polled(-1, R6100_KEYS_POLL_INTERVAL,
17087 + ARRAY_SIZE(r6100_gpio_keys),
17088 + r6100_gpio_keys);
17090 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
17092 + ath79_register_mdio(1, 0x0);
17094 + /* GMAC0 is connected to the PHY0 of the internal switch */
17095 + ath79_switch_data.phy4_mii_en = 1;
17096 + ath79_switch_data.phy_poll_mask = BIT(0);
17097 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
17098 + ath79_eth0_data.phy_mask = BIT(0);
17099 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
17100 + ath79_register_eth(0);
17102 + /* GMAC1 is connected to the internal switch */
17103 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
17104 + ath79_register_eth(1);
17106 + gpio_request_one(R6100_GPIO_USB_POWER,
17107 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
17108 + "USB power");
17110 + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
17111 + ath79_register_nfc();
17113 + ath79_register_usb();
17115 + ath79_register_wmac_simple();
17117 + ap91_pci_init_simple();
17120 +MIPS_MACHINE(ATH79_MACH_R6100, "R6100", "NETGEAR R6100",
17121 + r6100_setup);
17122 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb2011.c linux-4.1.43/arch/mips/ath79/mach-rb2011.c
17123 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb2011.c 1970-01-01 01:00:00.000000000 +0100
17124 +++ linux-4.1.43/arch/mips/ath79/mach-rb2011.c 2017-08-06 20:02:15.000000000 +0200
17125 @@ -0,0 +1,338 @@
17127 + * MikroTik RouterBOARD 2011 support
17129 + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
17130 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
17132 + * This program is free software; you can redistribute it and/or modify it
17133 + * under the terms of the GNU General Public License version 2 as published
17134 + * by the Free Software Foundation.
17135 + */
17137 +#define pr_fmt(fmt) "rb2011: " fmt
17139 +#include <linux/phy.h>
17140 +#include <linux/delay.h>
17141 +#include <linux/platform_device.h>
17142 +#include <linux/ath9k_platform.h>
17143 +#include <linux/ar8216_platform.h>
17144 +#include <linux/mtd/mtd.h>
17145 +#include <linux/mtd/nand.h>
17146 +#include <linux/mtd/partitions.h>
17147 +#include <linux/spi/spi.h>
17148 +#include <linux/spi/flash.h>
17149 +#include <linux/routerboot.h>
17150 +#include <linux/gpio.h>
17152 +#include <asm/prom.h>
17153 +#include <asm/mach-ath79/ath79.h>
17154 +#include <asm/mach-ath79/ar71xx_regs.h>
17156 +#include "common.h"
17157 +#include "dev-eth.h"
17158 +#include "dev-m25p80.h"
17159 +#include "dev-nfc.h"
17160 +#include "dev-usb.h"
17161 +#include "dev-wmac.h"
17162 +#include "machtypes.h"
17163 +#include "routerboot.h"
17165 +#define RB2011_GPIO_NAND_NCE 14
17166 +#define RB2011_GPIO_SFP_LOS 21
17168 +#define RB_ROUTERBOOT_OFFSET 0x0000
17169 +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
17170 +#define RB_HARD_CFG_SIZE 0x1000
17171 +#define RB_BIOS_OFFSET 0xd000
17172 +#define RB_BIOS_SIZE 0x1000
17173 +#define RB_SOFT_CFG_OFFSET 0xf000
17174 +#define RB_SOFT_CFG_SIZE 0x1000
17176 +#define RB_ART_SIZE 0x10000
17178 +#define RB2011_FLAG_SFP BIT(0)
17179 +#define RB2011_FLAG_USB BIT(1)
17180 +#define RB2011_FLAG_WLAN BIT(2)
17182 +static struct mtd_partition rb2011_spi_partitions[] = {
17184 + .name = "routerboot",
17185 + .offset = RB_ROUTERBOOT_OFFSET,
17186 + .mask_flags = MTD_WRITEABLE,
17187 + }, {
17188 + .name = "hard_config",
17189 + .size = RB_HARD_CFG_SIZE,
17190 + .mask_flags = MTD_WRITEABLE,
17191 + }, {
17192 + .name = "bios",
17193 + .offset = RB_BIOS_OFFSET,
17194 + .size = RB_BIOS_SIZE,
17195 + .mask_flags = MTD_WRITEABLE,
17196 + }, {
17197 + .name = "soft_config",
17198 + .size = RB_SOFT_CFG_SIZE,
17202 +static void __init rb2011_init_partitions(const struct rb_info *info)
17204 + rb2011_spi_partitions[0].size = info->hard_cfg_offs;
17205 + rb2011_spi_partitions[1].offset = info->hard_cfg_offs;
17206 + rb2011_spi_partitions[3].offset = info->soft_cfg_offs;
17209 +static struct mtd_partition rb2011_nand_partitions[] = {
17211 + .name = "booter",
17212 + .offset = 0,
17213 + .size = (256 * 1024),
17214 + .mask_flags = MTD_WRITEABLE,
17215 + },
17217 + .name = "kernel",
17218 + .offset = (256 * 1024),
17219 + .size = (4 * 1024 * 1024) - (256 * 1024),
17220 + },
17222 + .name = "rootfs",
17223 + .offset = MTDPART_OFS_NXTBLK,
17224 + .size = MTDPART_SIZ_FULL,
17225 + },
17228 +static struct flash_platform_data rb2011_spi_flash_data = {
17229 + .parts = rb2011_spi_partitions,
17230 + .nr_parts = ARRAY_SIZE(rb2011_spi_partitions),
17233 +static struct ar8327_pad_cfg rb2011_ar8327_pad0_cfg = {
17234 + .mode = AR8327_PAD_MAC_RGMII,
17235 + .txclk_delay_en = true,
17236 + .rxclk_delay_en = true,
17237 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL3,
17238 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
17241 +static struct ar8327_pad_cfg rb2011_ar8327_pad6_cfg;
17242 +static struct ar8327_sgmii_cfg rb2011_ar8327_sgmii_cfg;
17244 +static struct ar8327_led_cfg rb2011_ar8327_led_cfg = {
17245 + .led_ctrl0 = 0xc731c731,
17246 + .led_ctrl1 = 0x00000000,
17247 + .led_ctrl2 = 0x00000000,
17248 + .led_ctrl3 = 0x0030c300,
17249 + .open_drain = false,
17252 +static const struct ar8327_led_info rb2011_ar8327_leds[] __initconst = {
17253 + AR8327_LED_INFO(PHY0_0, HW, "rb:green:eth1"),
17254 + AR8327_LED_INFO(PHY1_0, HW, "rb:green:eth2"),
17255 + AR8327_LED_INFO(PHY2_0, HW, "rb:green:eth3"),
17256 + AR8327_LED_INFO(PHY3_0, HW, "rb:green:eth4"),
17257 + AR8327_LED_INFO(PHY4_0, HW, "rb:green:eth5"),
17258 + AR8327_LED_INFO(PHY0_1, SW, "rb:green:eth6"),
17259 + AR8327_LED_INFO(PHY1_1, SW, "rb:green:eth7"),
17260 + AR8327_LED_INFO(PHY2_1, SW, "rb:green:eth8"),
17261 + AR8327_LED_INFO(PHY3_1, SW, "rb:green:eth9"),
17262 + AR8327_LED_INFO(PHY4_1, SW, "rb:green:eth10"),
17263 + AR8327_LED_INFO(PHY4_2, SW, "rb:green:usr"),
17266 +static struct ar8327_platform_data rb2011_ar8327_data = {
17267 + .pad0_cfg = &rb2011_ar8327_pad0_cfg,
17268 + .port0_cfg = {
17269 + .force_link = 1,
17270 + .speed = AR8327_PORT_SPEED_1000,
17271 + .duplex = 1,
17272 + .txpause = 1,
17273 + .rxpause = 1,
17274 + },
17275 + .led_cfg = &rb2011_ar8327_led_cfg,
17276 + .num_leds = ARRAY_SIZE(rb2011_ar8327_leds),
17277 + .leds = rb2011_ar8327_leds,
17280 +static struct mdio_board_info rb2011_mdio0_info[] = {
17282 + .bus_id = "ag71xx-mdio.0",
17283 + .phy_addr = 0,
17284 + .platform_data = &rb2011_ar8327_data,
17285 + },
17288 +static void __init rb2011_wlan_init(void)
17290 + char *art_buf;
17291 + u8 wlan_mac[ETH_ALEN];
17293 + art_buf = rb_get_wlan_data();
17294 + if (art_buf == NULL)
17295 + return;
17297 + ath79_init_mac(wlan_mac, ath79_mac_base, 11);
17298 + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
17300 + kfree(art_buf);
17303 +static void rb2011_nand_select_chip(int chip_no)
17305 + switch (chip_no) {
17306 + case 0:
17307 + gpio_set_value(RB2011_GPIO_NAND_NCE, 0);
17308 + break;
17309 + default:
17310 + gpio_set_value(RB2011_GPIO_NAND_NCE, 1);
17311 + break;
17313 + ndelay(500);
17316 +static struct nand_ecclayout rb2011_nand_ecclayout = {
17317 + .eccbytes = 6,
17318 + .eccpos = { 8, 9, 10, 13, 14, 15 },
17319 + .oobavail = 9,
17320 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
17323 +static int rb2011_nand_scan_fixup(struct mtd_info *mtd)
17325 + struct nand_chip *chip = mtd->priv;
17327 + if (mtd->writesize == 512) {
17328 + /*
17329 + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
17330 + * will not be able to find the kernel that we load.
17331 + */
17332 + chip->ecc.layout = &rb2011_nand_ecclayout;
17335 + return 0;
17338 +static void __init rb2011_nand_init(void)
17340 + gpio_request_one(RB2011_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
17342 + ath79_nfc_set_scan_fixup(rb2011_nand_scan_fixup);
17343 + ath79_nfc_set_parts(rb2011_nand_partitions,
17344 + ARRAY_SIZE(rb2011_nand_partitions));
17345 + ath79_nfc_set_select_chip(rb2011_nand_select_chip);
17346 + ath79_nfc_set_swap_dma(true);
17347 + ath79_register_nfc();
17350 +static int rb2011_get_port_link(unsigned port)
17352 + if (port != 6)
17353 + return -EINVAL;
17355 + /* The Loss of signal line is active low */
17356 + return !gpio_get_value(RB2011_GPIO_SFP_LOS);
17359 +static void __init rb2011_sfp_init(void)
17361 + gpio_request_one(RB2011_GPIO_SFP_LOS, GPIOF_IN, "SFP LOS");
17363 + rb2011_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
17365 + rb2011_ar8327_data.pad6_cfg = &rb2011_ar8327_pad6_cfg;
17367 + rb2011_ar8327_sgmii_cfg.sgmii_ctrl = 0xc70167d0;
17368 + rb2011_ar8327_sgmii_cfg.serdes_aen = true;
17370 + rb2011_ar8327_data.sgmii_cfg = &rb2011_ar8327_sgmii_cfg;
17372 + rb2011_ar8327_data.port6_cfg.force_link = 1;
17373 + rb2011_ar8327_data.port6_cfg.speed = AR8327_PORT_SPEED_1000;
17374 + rb2011_ar8327_data.port6_cfg.duplex = 1;
17376 + rb2011_ar8327_data.get_port_link = rb2011_get_port_link;
17379 +static int __init rb2011_setup(u32 flags)
17381 + const struct rb_info *info;
17382 + char buf[64];
17384 + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
17385 + if (!info)
17386 + return -ENODEV;
17388 + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
17389 + (info->board_name) ? info->board_name : "");
17390 + mips_set_machine_name(buf);
17392 + rb2011_init_partitions(info);
17394 + ath79_register_m25p80(&rb2011_spi_flash_data);
17395 + rb2011_nand_init();
17397 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
17398 + AR934X_ETH_CFG_SW_ONLY_MODE);
17400 + ath79_register_mdio(1, 0x0);
17401 + ath79_register_mdio(0, 0x0);
17403 + mdiobus_register_board_info(rb2011_mdio0_info,
17404 + ARRAY_SIZE(rb2011_mdio0_info));
17406 + /* GMAC0 is connected to an ar8327 switch */
17407 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
17408 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
17409 + ath79_eth0_data.phy_mask = BIT(0);
17410 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
17411 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
17413 + ath79_register_eth(0);
17415 + /* GMAC1 is connected to the internal switch */
17416 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 5);
17417 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
17418 + ath79_eth1_data.speed = SPEED_1000;
17419 + ath79_eth1_data.duplex = DUPLEX_FULL;
17421 + ath79_register_eth(1);
17423 + if (flags & RB2011_FLAG_SFP)
17424 + rb2011_sfp_init();
17426 + if (flags & RB2011_FLAG_WLAN)
17427 + rb2011_wlan_init();
17429 + if (flags & RB2011_FLAG_USB)
17430 + ath79_register_usb();
17432 + return 0;
17435 +static void __init rb2011l_setup(void)
17437 + rb2011_setup(0);
17440 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011L, "2011L", rb2011l_setup);
17442 +static void __init rb2011us_setup(void)
17444 + rb2011_setup(RB2011_FLAG_SFP | RB2011_FLAG_USB);
17447 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011US, "2011US", rb2011us_setup);
17449 +static void __init rb2011r5_setup(void)
17451 + rb2011_setup(RB2011_FLAG_SFP | RB2011_FLAG_USB | RB2011_FLAG_WLAN);
17454 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011R5, "2011r5", rb2011r5_setup);
17456 +static void __init rb2011g_setup(void)
17458 + rb2011_setup(RB2011_FLAG_SFP |
17459 + RB2011_FLAG_USB |
17460 + RB2011_FLAG_WLAN);
17463 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011G, "2011G", rb2011g_setup);
17464 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb4xx.c linux-4.1.43/arch/mips/ath79/mach-rb4xx.c
17465 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb4xx.c 1970-01-01 01:00:00.000000000 +0100
17466 +++ linux-4.1.43/arch/mips/ath79/mach-rb4xx.c 2017-08-06 20:02:15.000000000 +0200
17467 @@ -0,0 +1,465 @@
17469 + * MikroTik RouterBOARD 4xx series support
17471 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
17472 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
17474 + * This program is free software; you can redistribute it and/or modify it
17475 + * under the terms of the GNU General Public License version 2 as published
17476 + * by the Free Software Foundation.
17477 + */
17479 +#include <linux/platform_device.h>
17480 +#include <linux/irq.h>
17481 +#include <linux/mdio-gpio.h>
17482 +#include <linux/mmc/host.h>
17483 +#include <linux/spi/spi.h>
17484 +#include <linux/spi/flash.h>
17485 +#include <linux/spi/mmc_spi.h>
17486 +#include <linux/mtd/mtd.h>
17487 +#include <linux/mtd/partitions.h>
17489 +#include <asm/mach-ath79/ar71xx_regs.h>
17490 +#include <asm/mach-ath79/ath79.h>
17491 +#include <asm/mach-ath79/rb4xx_cpld.h>
17493 +#include "common.h"
17494 +#include "dev-eth.h"
17495 +#include "dev-gpio-buttons.h"
17496 +#include "dev-leds-gpio.h"
17497 +#include "dev-usb.h"
17498 +#include "machtypes.h"
17499 +#include "pci.h"
17501 +#define RB4XX_GPIO_USER_LED 4
17502 +#define RB4XX_GPIO_RESET_SWITCH 7
17504 +#define RB4XX_GPIO_CPLD_BASE 32
17505 +#define RB4XX_GPIO_CPLD_LED1 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED1)
17506 +#define RB4XX_GPIO_CPLD_LED2 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED2)
17507 +#define RB4XX_GPIO_CPLD_LED3 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED3)
17508 +#define RB4XX_GPIO_CPLD_LED4 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED4)
17509 +#define RB4XX_GPIO_CPLD_LED5 (RB4XX_GPIO_CPLD_BASE + CPLD_GPIO_nLED5)
17511 +#define RB4XX_KEYS_POLL_INTERVAL 20 /* msecs */
17512 +#define RB4XX_KEYS_DEBOUNCE_INTERVAL (3 * RB4XX_KEYS_POLL_INTERVAL)
17514 +static struct gpio_led rb4xx_leds_gpio[] __initdata = {
17516 + .name = "rb4xx:yellow:user",
17517 + .gpio = RB4XX_GPIO_USER_LED,
17518 + .active_low = 0,
17519 + }, {
17520 + .name = "rb4xx:green:led1",
17521 + .gpio = RB4XX_GPIO_CPLD_LED1,
17522 + .active_low = 1,
17523 + }, {
17524 + .name = "rb4xx:green:led2",
17525 + .gpio = RB4XX_GPIO_CPLD_LED2,
17526 + .active_low = 1,
17527 + }, {
17528 + .name = "rb4xx:green:led3",
17529 + .gpio = RB4XX_GPIO_CPLD_LED3,
17530 + .active_low = 1,
17531 + }, {
17532 + .name = "rb4xx:green:led4",
17533 + .gpio = RB4XX_GPIO_CPLD_LED4,
17534 + .active_low = 1,
17535 + }, {
17536 + .name = "rb4xx:green:led5",
17537 + .gpio = RB4XX_GPIO_CPLD_LED5,
17538 + .active_low = 0,
17539 + },
17542 +static struct gpio_keys_button rb4xx_gpio_keys[] __initdata = {
17544 + .desc = "reset_switch",
17545 + .type = EV_KEY,
17546 + .code = KEY_RESTART,
17547 + .debounce_interval = RB4XX_KEYS_DEBOUNCE_INTERVAL,
17548 + .gpio = RB4XX_GPIO_RESET_SWITCH,
17549 + .active_low = 1,
17553 +static struct platform_device rb4xx_nand_device = {
17554 + .name = "rb4xx-nand",
17555 + .id = -1,
17558 +static struct ath79_pci_irq rb4xx_pci_irqs[] __initdata = {
17560 + .slot = 17,
17561 + .pin = 1,
17562 + .irq = ATH79_PCI_IRQ(2),
17563 + }, {
17564 + .slot = 18,
17565 + .pin = 1,
17566 + .irq = ATH79_PCI_IRQ(0),
17567 + }, {
17568 + .slot = 18,
17569 + .pin = 2,
17570 + .irq = ATH79_PCI_IRQ(1),
17571 + }, {
17572 + .slot = 19,
17573 + .pin = 1,
17574 + .irq = ATH79_PCI_IRQ(1),
17575 + }, {
17576 + .slot = 19,
17577 + .pin = 2,
17578 + .irq = ATH79_PCI_IRQ(2),
17579 + }, {
17580 + .slot = 20,
17581 + .pin = 1,
17582 + .irq = ATH79_PCI_IRQ(2),
17583 + }, {
17584 + .slot = 20,
17585 + .pin = 2,
17586 + .irq = ATH79_PCI_IRQ(0),
17587 + }, {
17588 + .slot = 21,
17589 + .pin = 1,
17590 + .irq = ATH79_PCI_IRQ(0),
17591 + }, {
17592 + .slot = 22,
17593 + .pin = 1,
17594 + .irq = ATH79_PCI_IRQ(1),
17595 + }, {
17596 + .slot = 22,
17597 + .pin = 2,
17598 + .irq = ATH79_PCI_IRQ(2),
17599 + }, {
17600 + .slot = 23,
17601 + .pin = 1,
17602 + .irq = ATH79_PCI_IRQ(2),
17603 + }, {
17604 + .slot = 23,
17605 + .pin = 2,
17606 + .irq = ATH79_PCI_IRQ(0),
17610 +static struct mtd_partition rb4xx_partitions[] = {
17612 + .name = "routerboot",
17613 + .offset = 0,
17614 + .size = 0x0b000,
17615 + .mask_flags = MTD_WRITEABLE,
17616 + }, {
17617 + .name = "hard_config",
17618 + .offset = 0x0b000,
17619 + .size = 0x01000,
17620 + .mask_flags = MTD_WRITEABLE,
17621 + }, {
17622 + .name = "bios",
17623 + .offset = 0x0d000,
17624 + .size = 0x02000,
17625 + .mask_flags = MTD_WRITEABLE,
17626 + }, {
17627 + .name = "soft_config",
17628 + .offset = 0x0f000,
17629 + .size = 0x01000,
17633 +static struct flash_platform_data rb4xx_flash_data = {
17634 + .type = "pm25lv512",
17635 + .parts = rb4xx_partitions,
17636 + .nr_parts = ARRAY_SIZE(rb4xx_partitions),
17639 +static struct rb4xx_cpld_platform_data rb4xx_cpld_data = {
17640 + .gpio_base = RB4XX_GPIO_CPLD_BASE,
17643 +static struct mmc_spi_platform_data rb4xx_mmc_data = {
17644 + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
17647 +static struct spi_board_info rb4xx_spi_info[] = {
17649 + .bus_num = 0,
17650 + .chip_select = 0,
17651 + .max_speed_hz = 25000000,
17652 + .modalias = "m25p80",
17653 + .platform_data = &rb4xx_flash_data,
17654 + }, {
17655 + .bus_num = 0,
17656 + .chip_select = 1,
17657 + .max_speed_hz = 25000000,
17658 + .modalias = "spi-rb4xx-cpld",
17659 + .platform_data = &rb4xx_cpld_data,
17663 +static struct spi_board_info rb4xx_microsd_info[] = {
17665 + .bus_num = 0,
17666 + .chip_select = 2,
17667 + .max_speed_hz = 25000000,
17668 + .modalias = "mmc_spi",
17669 + .platform_data = &rb4xx_mmc_data,
17674 +static struct resource rb4xx_spi_resources[] = {
17676 + .start = AR71XX_SPI_BASE,
17677 + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
17678 + .flags = IORESOURCE_MEM,
17679 + },
17682 +static struct platform_device rb4xx_spi_device = {
17683 + .name = "rb4xx-spi",
17684 + .id = -1,
17685 + .resource = rb4xx_spi_resources,
17686 + .num_resources = ARRAY_SIZE(rb4xx_spi_resources),
17689 +static void __init rb4xx_generic_setup(void)
17691 + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
17692 + AR71XX_GPIO_FUNC_SPI_CS2_EN);
17694 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
17695 + rb4xx_leds_gpio);
17697 + ath79_register_gpio_keys_polled(-1, RB4XX_KEYS_POLL_INTERVAL,
17698 + ARRAY_SIZE(rb4xx_gpio_keys),
17699 + rb4xx_gpio_keys);
17701 + spi_register_board_info(rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
17702 + platform_device_register(&rb4xx_spi_device);
17703 + platform_device_register(&rb4xx_nand_device);
17706 +static void __init rb411_setup(void)
17708 + rb4xx_generic_setup();
17709 + spi_register_board_info(rb4xx_microsd_info,
17710 + ARRAY_SIZE(rb4xx_microsd_info));
17712 + ath79_register_mdio(0, 0xfffffffc);
17714 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
17715 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
17716 + ath79_eth0_data.phy_mask = 0x00000003;
17718 + ath79_register_eth(0);
17720 + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
17721 + ath79_register_pci();
17724 +MIPS_MACHINE(ATH79_MACH_RB_411, "411", "MikroTik RouterBOARD 411/A/AH",
17725 + rb411_setup);
17727 +static void __init rb411u_setup(void)
17729 + rb411_setup();
17730 + ath79_register_usb();
17733 +MIPS_MACHINE(ATH79_MACH_RB_411U, "411U", "MikroTik RouterBOARD 411U",
17734 + rb411u_setup);
17736 +#define RB433_LAN_PHYMASK BIT(0)
17737 +#define RB433_WAN_PHYMASK BIT(4)
17738 +#define RB433_MDIO_PHYMASK (RB433_LAN_PHYMASK | RB433_WAN_PHYMASK)
17740 +static void __init rb433_setup(void)
17742 + rb4xx_generic_setup();
17743 + spi_register_board_info(rb4xx_microsd_info,
17744 + ARRAY_SIZE(rb4xx_microsd_info));
17746 + ath79_register_mdio(0, ~RB433_MDIO_PHYMASK);
17748 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
17749 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
17750 + ath79_eth0_data.phy_mask = RB433_LAN_PHYMASK;
17752 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
17753 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
17754 + ath79_eth1_data.phy_mask = RB433_WAN_PHYMASK;
17756 + ath79_register_eth(1);
17757 + ath79_register_eth(0);
17759 + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
17760 + ath79_register_pci();
17763 +MIPS_MACHINE(ATH79_MACH_RB_433, "433", "MikroTik RouterBOARD 433/AH",
17764 + rb433_setup);
17766 +static void __init rb433u_setup(void)
17768 + rb433_setup();
17769 + ath79_register_usb();
17772 +MIPS_MACHINE(ATH79_MACH_RB_433U, "433U", "MikroTik RouterBOARD 433UAH",
17773 + rb433u_setup);
17775 +static void __init rb435g_setup(void)
17777 + rb4xx_generic_setup();
17779 + spi_register_board_info(rb4xx_microsd_info,
17780 + ARRAY_SIZE(rb4xx_microsd_info));
17782 + ath79_register_mdio(0, ~RB433_MDIO_PHYMASK);
17784 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
17785 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
17786 + ath79_eth0_data.phy_mask = RB433_LAN_PHYMASK;
17788 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
17789 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
17790 + ath79_eth1_data.phy_mask = RB433_WAN_PHYMASK;
17792 + ath79_register_eth(1);
17793 + ath79_register_eth(0);
17795 + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
17796 + ath79_register_pci();
17798 + ath79_register_usb();
17801 +MIPS_MACHINE(ATH79_MACH_RB_435G, "435G", "MikroTik RouterBOARD 435G",
17802 + rb435g_setup);
17804 +#define RB450_LAN_PHYMASK BIT(0)
17805 +#define RB450_WAN_PHYMASK BIT(4)
17806 +#define RB450_MDIO_PHYMASK (RB450_LAN_PHYMASK | RB450_WAN_PHYMASK)
17808 +static void __init rb450_generic_setup(int gige)
17810 + rb4xx_generic_setup();
17811 + ath79_register_mdio(0, ~RB450_MDIO_PHYMASK);
17813 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 1);
17814 + ath79_eth0_data.phy_if_mode = (gige) ?
17815 + PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII;
17816 + ath79_eth0_data.phy_mask = RB450_LAN_PHYMASK;
17818 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
17819 + ath79_eth1_data.phy_if_mode = (gige) ?
17820 + PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_RMII;
17821 + ath79_eth1_data.phy_mask = RB450_WAN_PHYMASK;
17823 + ath79_register_eth(1);
17824 + ath79_register_eth(0);
17827 +static void __init rb450_setup(void)
17829 + rb450_generic_setup(0);
17832 +MIPS_MACHINE(ATH79_MACH_RB_450, "450", "MikroTik RouterBOARD 450",
17833 + rb450_setup);
17835 +static void __init rb450g_setup(void)
17837 + rb450_generic_setup(1);
17838 + spi_register_board_info(rb4xx_microsd_info,
17839 + ARRAY_SIZE(rb4xx_microsd_info));
17842 +MIPS_MACHINE(ATH79_MACH_RB_450G, "450G", "MikroTik RouterBOARD 450G",
17843 + rb450g_setup);
17845 +static void __init rb493_setup(void)
17847 + rb4xx_generic_setup();
17849 + ath79_register_mdio(0, 0x3fffff00);
17851 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
17852 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
17853 + ath79_eth0_data.speed = SPEED_100;
17854 + ath79_eth0_data.duplex = DUPLEX_FULL;
17856 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
17857 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
17858 + ath79_eth1_data.phy_mask = 0x00000001;
17860 + ath79_register_eth(0);
17861 + ath79_register_eth(1);
17863 + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
17864 + ath79_register_pci();
17867 +MIPS_MACHINE(ATH79_MACH_RB_493, "493", "MikroTik RouterBOARD 493/AH",
17868 + rb493_setup);
17870 +#define RB493G_GPIO_MDIO_MDC 7
17871 +#define RB493G_GPIO_MDIO_DATA 8
17873 +#define RB493G_MDIO_PHYMASK BIT(0)
17875 +static struct mdio_gpio_platform_data rb493g_mdio_data = {
17876 + .mdc = RB493G_GPIO_MDIO_MDC,
17877 + .mdio = RB493G_GPIO_MDIO_DATA,
17879 + .phy_mask = ~RB493G_MDIO_PHYMASK,
17882 +static struct platform_device rb493g_mdio_device = {
17883 + .name = "mdio-gpio",
17884 + .id = -1,
17885 + .dev = {
17886 + .platform_data = &rb493g_mdio_data,
17887 + },
17890 +static void __init rb493g_setup(void)
17892 + ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
17893 + AR71XX_GPIO_FUNC_SPI_CS2_EN);
17895 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
17896 + rb4xx_leds_gpio);
17898 + spi_register_board_info(rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
17899 + spi_register_board_info(rb4xx_microsd_info,
17900 + ARRAY_SIZE(rb4xx_microsd_info));
17902 + platform_device_register(&rb4xx_spi_device);
17903 + platform_device_register(&rb4xx_nand_device);
17905 + ath79_register_mdio(0, ~RB493G_MDIO_PHYMASK);
17907 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
17908 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
17909 + ath79_eth0_data.phy_mask = RB493G_MDIO_PHYMASK;
17910 + ath79_eth0_data.speed = SPEED_1000;
17911 + ath79_eth0_data.duplex = DUPLEX_FULL;
17913 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
17914 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
17915 + ath79_eth1_data.mii_bus_dev = &rb493g_mdio_device.dev;
17916 + ath79_eth1_data.phy_mask = RB493G_MDIO_PHYMASK;
17917 + ath79_eth1_data.speed = SPEED_1000;
17918 + ath79_eth1_data.duplex = DUPLEX_FULL;
17920 + platform_device_register(&rb493g_mdio_device);
17922 + ath79_register_eth(1);
17923 + ath79_register_eth(0);
17925 + ath79_register_usb();
17927 + ath79_pci_set_irq_map(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
17928 + ath79_register_pci();
17931 +MIPS_MACHINE(ATH79_MACH_RB_493G, "493G", "MikroTik RouterBOARD 493G",
17932 + rb493g_setup);
17933 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb750.c linux-4.1.43/arch/mips/ath79/mach-rb750.c
17934 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb750.c 1970-01-01 01:00:00.000000000 +0100
17935 +++ linux-4.1.43/arch/mips/ath79/mach-rb750.c 2017-08-06 20:02:15.000000000 +0200
17936 @@ -0,0 +1,346 @@
17938 + * MikroTik RouterBOARD 750/750GL support
17940 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
17942 + * This program is free software; you can redistribute it and/or modify it
17943 + * under the terms of the GNU General Public License version 2 as published
17944 + * by the Free Software Foundation.
17945 + */
17947 +#include <linux/export.h>
17948 +#include <linux/pci.h>
17949 +#include <linux/ath9k_platform.h>
17950 +#include <linux/platform_device.h>
17951 +#include <linux/phy.h>
17952 +#include <linux/ar8216_platform.h>
17953 +#include <linux/rle.h>
17954 +#include <linux/routerboot.h>
17956 +#include <asm/mach-ath79/ar71xx_regs.h>
17957 +#include <asm/mach-ath79/ath79.h>
17958 +#include <asm/mach-ath79/irq.h>
17959 +#include <asm/mach-ath79/mach-rb750.h>
17961 +#include "common.h"
17962 +#include "dev-ap9x-pci.h"
17963 +#include "dev-usb.h"
17964 +#include "dev-eth.h"
17965 +#include "machtypes.h"
17966 +#include "routerboot.h"
17968 +static struct rb750_led_data rb750_leds[] = {
17970 + .name = "rb750:green:act",
17971 + .mask = RB750_LED_ACT,
17972 + .active_low = 1,
17973 + }, {
17974 + .name = "rb750:green:port1",
17975 + .mask = RB750_LED_PORT5,
17976 + .active_low = 1,
17977 + }, {
17978 + .name = "rb750:green:port2",
17979 + .mask = RB750_LED_PORT4,
17980 + .active_low = 1,
17981 + }, {
17982 + .name = "rb750:green:port3",
17983 + .mask = RB750_LED_PORT3,
17984 + .active_low = 1,
17985 + }, {
17986 + .name = "rb750:green:port4",
17987 + .mask = RB750_LED_PORT2,
17988 + .active_low = 1,
17989 + }, {
17990 + .name = "rb750:green:port5",
17991 + .mask = RB750_LED_PORT1,
17992 + .active_low = 1,
17996 +static struct rb750_led_data rb750gr3_leds[] = {
17998 + .name = "rb750:green:act",
17999 + .mask = RB7XX_LED_ACT,
18000 + .active_low = 1,
18001 + },
18004 +static struct rb750_led_platform_data rb750_leds_data;
18005 +static struct platform_device rb750_leds_device = {
18006 + .name = "leds-rb750",
18007 + .dev = {
18008 + .platform_data = &rb750_leds_data,
18012 +static struct rb7xx_nand_platform_data rb750_nand_data;
18013 +static struct platform_device rb750_nand_device = {
18014 + .name = "rb750-nand",
18015 + .id = -1,
18016 + .dev = {
18017 + .platform_data = &rb750_nand_data,
18021 +static void rb750_latch_change(u32 mask_clr, u32 mask_set)
18023 + static DEFINE_SPINLOCK(lock);
18024 + static u32 latch_set = RB750_LED_BITS | RB750_LVC573_LE;
18025 + static u32 latch_oe;
18026 + static u32 latch_clr;
18027 + unsigned long flags;
18028 + u32 t;
18030 + spin_lock_irqsave(&lock, flags);
18032 + if ((mask_clr & BIT(31)) != 0 &&
18033 + (latch_set & RB750_LVC573_LE) == 0) {
18034 + goto unlock;
18037 + latch_set = (latch_set | mask_set) & ~mask_clr;
18038 + latch_clr = (latch_clr | mask_clr) & ~mask_set;
18040 + if (latch_oe == 0)
18041 + latch_oe = __raw_readl(ath79_gpio_base + AR71XX_GPIO_REG_OE);
18043 + if (likely(latch_set & RB750_LVC573_LE)) {
18044 + void __iomem *base = ath79_gpio_base;
18046 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
18047 + t |= mask_clr | latch_oe | mask_set;
18049 + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
18050 + __raw_writel(latch_clr, base + AR71XX_GPIO_REG_CLEAR);
18051 + __raw_writel(latch_set, base + AR71XX_GPIO_REG_SET);
18052 + } else if (mask_clr & RB750_LVC573_LE) {
18053 + void __iomem *base = ath79_gpio_base;
18055 + latch_oe = __raw_readl(base + AR71XX_GPIO_REG_OE);
18056 + __raw_writel(RB750_LVC573_LE, base + AR71XX_GPIO_REG_CLEAR);
18057 + /* flush write */
18058 + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
18061 +unlock:
18062 + spin_unlock_irqrestore(&lock, flags);
18065 +static void rb750_nand_enable_pins(void)
18067 + rb750_latch_change(RB750_LVC573_LE, 0);
18068 + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
18069 + AR724X_GPIO_FUNC_SPI_EN);
18072 +static void rb750_nand_disable_pins(void)
18074 + ath79_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN,
18075 + AR724X_GPIO_FUNC_JTAG_DISABLE);
18076 + rb750_latch_change(0, RB750_LVC573_LE);
18079 +static void __init rb750_setup(void)
18081 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
18082 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
18083 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
18084 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
18085 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
18087 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
18088 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
18090 + ath79_register_mdio(0, 0x0);
18092 + /* LAN ports */
18093 + ath79_register_eth(1);
18095 + /* WAN port */
18096 + ath79_register_eth(0);
18098 + rb750_leds_data.num_leds = ARRAY_SIZE(rb750_leds);
18099 + rb750_leds_data.leds = rb750_leds;
18100 + rb750_leds_data.latch_change = rb750_latch_change;
18101 + platform_device_register(&rb750_leds_device);
18103 + rb750_nand_data.nce_line = RB750_NAND_NCE;
18104 + rb750_nand_data.enable_pins = rb750_nand_enable_pins;
18105 + rb750_nand_data.disable_pins = rb750_nand_disable_pins;
18106 + rb750_nand_data.latch_change = rb750_latch_change;
18107 + platform_device_register(&rb750_nand_device);
18110 +MIPS_MACHINE(ATH79_MACH_RB_750, "750i", "MikroTik RouterBOARD 750",
18111 + rb750_setup);
18113 +static struct ar8327_pad_cfg rb750gr3_ar8327_pad0_cfg = {
18114 + .mode = AR8327_PAD_MAC_RGMII,
18115 + .txclk_delay_en = true,
18116 + .rxclk_delay_en = true,
18117 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
18118 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
18121 +static struct ar8327_platform_data rb750gr3_ar8327_data = {
18122 + .pad0_cfg = &rb750gr3_ar8327_pad0_cfg,
18123 + .port0_cfg = {
18124 + .force_link = 1,
18125 + .speed = AR8327_PORT_SPEED_1000,
18126 + .duplex = 1,
18127 + .txpause = 1,
18128 + .rxpause = 1,
18132 +static struct mdio_board_info rb750g3_mdio_info[] = {
18134 + .bus_id = "ag71xx-mdio.0",
18135 + .phy_addr = 0,
18136 + .platform_data = &rb750gr3_ar8327_data,
18137 + },
18140 +static void rb750gr3_nand_enable_pins(void)
18142 + ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
18143 + AR724X_GPIO_FUNC_SPI_EN |
18144 + AR724X_GPIO_FUNC_SPI_CS_EN2);
18147 +static void rb750gr3_nand_disable_pins(void)
18149 + ath79_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN |
18150 + AR724X_GPIO_FUNC_SPI_CS_EN2,
18151 + AR724X_GPIO_FUNC_JTAG_DISABLE);
18154 +static void rb750gr3_latch_change(u32 mask_clr, u32 mask_set)
18156 + static DEFINE_SPINLOCK(lock);
18157 + static u32 latch_set = RB7XX_LED_ACT;
18158 + static u32 latch_clr;
18159 + void __iomem *base = ath79_gpio_base;
18160 + unsigned long flags;
18161 + u32 t;
18163 + spin_lock_irqsave(&lock, flags);
18165 + latch_set = (latch_set | mask_set) & ~mask_clr;
18166 + latch_clr = (latch_clr | mask_clr) & ~mask_set;
18168 + mask_set = latch_set & (RB7XX_USB_POWERON | RB7XX_MONITOR);
18169 + mask_clr = latch_clr & (RB7XX_USB_POWERON | RB7XX_MONITOR);
18171 + if ((latch_set ^ RB7XX_LED_ACT) & RB7XX_LED_ACT) {
18172 + /* enable output mode */
18173 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
18174 + t |= RB7XX_LED_ACT;
18175 + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
18177 + mask_clr |= RB7XX_LED_ACT;
18178 + } else {
18179 + /* disable output mode */
18180 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
18181 + t &= ~RB7XX_LED_ACT;
18182 + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
18185 + __raw_writel(mask_set, base + AR71XX_GPIO_REG_SET);
18186 + __raw_writel(mask_clr, base + AR71XX_GPIO_REG_CLEAR);
18188 + spin_unlock_irqrestore(&lock, flags);
18191 +static void __init rb750gr3_setup(void)
18193 + ath79_register_mdio(0, 0x0);
18194 + mdiobus_register_board_info(rb750g3_mdio_info,
18195 + ARRAY_SIZE(rb750g3_mdio_info));
18197 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
18198 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
18199 + ath79_eth0_data.phy_mask = BIT(0);
18200 + ath79_eth0_pll_data.pll_1000 = 0x62000000;
18202 + ath79_register_eth(0);
18204 + rb750_leds_data.num_leds = ARRAY_SIZE(rb750gr3_leds);
18205 + rb750_leds_data.leds = rb750gr3_leds;
18206 + rb750_leds_data.latch_change = rb750gr3_latch_change;
18207 + platform_device_register(&rb750_leds_device);
18209 + rb750_nand_data.nce_line = RB7XX_NAND_NCE;
18210 + rb750_nand_data.enable_pins = rb750gr3_nand_enable_pins;
18211 + rb750_nand_data.disable_pins = rb750gr3_nand_disable_pins;
18212 + rb750_nand_data.latch_change = rb750gr3_latch_change;
18213 + platform_device_register(&rb750_nand_device);
18216 +MIPS_MACHINE(ATH79_MACH_RB_750G_R3, "750Gr3", "MikroTik RouterBOARD 750GL",
18217 + rb750gr3_setup);
18219 +#define RB751_HARDCONFIG 0x1f00b000
18220 +#define RB751_HARDCONFIG_SIZE 0x1000
18222 +static void __init rb751_wlan_setup(void)
18224 + u8 *hardconfig = (u8 *) KSEG1ADDR(RB751_HARDCONFIG);
18225 + struct ath9k_platform_data *wmac_data;
18226 + u16 tag_len;
18227 + u8 *tag;
18228 + u16 mac_len;
18229 + u8 *mac;
18230 + int err;
18232 + wmac_data = ap9x_pci_get_wmac_data(0);
18233 + if (!wmac_data) {
18234 + pr_err("rb75x: unable to get address of wlan data\n");
18235 + return;
18238 + ap9x_pci_setup_wmac_led_pin(0, 9);
18240 + err = routerboot_find_tag(hardconfig, RB751_HARDCONFIG_SIZE,
18241 + RB_ID_WLAN_DATA, &tag, &tag_len);
18242 + if (err) {
18243 + pr_err("rb75x: no calibration data found\n");
18244 + return;
18247 + err = rle_decode(tag, tag_len, (unsigned char *) wmac_data->eeprom_data,
18248 + sizeof(wmac_data->eeprom_data), NULL, NULL);
18249 + if (err) {
18250 + pr_err("rb75x: unable to decode wlan eeprom data\n");
18251 + return;
18254 + err = routerboot_find_tag(hardconfig, RB751_HARDCONFIG_SIZE,
18255 + RB_ID_MAC_ADDRESS_PACK, &mac, &mac_len);
18256 + if (err) {
18257 + pr_err("rb75x: no mac address found\n");
18258 + return;
18261 + ap91_pci_init(NULL, mac);
18264 +static void __init rb751_setup(void)
18266 + rb750_setup();
18267 + ath79_register_usb();
18268 + rb751_wlan_setup();
18271 +MIPS_MACHINE(ATH79_MACH_RB_751, "751", "MikroTik RouterBOARD 751",
18272 + rb751_setup);
18274 +static void __init rb751g_setup(void)
18276 + rb750gr3_setup();
18277 + ath79_register_usb();
18278 + rb751_wlan_setup();
18281 +MIPS_MACHINE(ATH79_MACH_RB_751G, "751g", "MikroTik RouterBOARD 751G",
18282 + rb751g_setup);
18283 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb91x.c linux-4.1.43/arch/mips/ath79/mach-rb91x.c
18284 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb91x.c 1970-01-01 01:00:00.000000000 +0100
18285 +++ linux-4.1.43/arch/mips/ath79/mach-rb91x.c 2017-08-06 20:02:15.000000000 +0200
18286 @@ -0,0 +1,349 @@
18288 + * MikroTik RouterBOARD 91X support
18290 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
18292 + * This program is free software; you can redistribute it and/or modify it
18293 + * under the terms of the GNU General Public License version 2 as published
18294 + * by the Free Software Foundation.
18295 + */
18297 +#define pr_fmt(fmt) "rb91x: " fmt
18299 +#include <linux/phy.h>
18300 +#include <linux/delay.h>
18301 +#include <linux/platform_device.h>
18302 +#include <linux/ath9k_platform.h>
18303 +#include <linux/mtd/mtd.h>
18304 +#include <linux/mtd/nand.h>
18305 +#include <linux/mtd/partitions.h>
18306 +#include <linux/spi/spi.h>
18307 +#include <linux/spi/74x164.h>
18308 +#include <linux/spi/flash.h>
18309 +#include <linux/routerboot.h>
18310 +#include <linux/gpio.h>
18311 +#include <linux/platform_data/gpio-latch.h>
18312 +#include <linux/platform_data/rb91x_nand.h>
18313 +#include <linux/platform_data/phy-at803x.h>
18315 +#include <asm/prom.h>
18316 +#include <asm/mach-ath79/ath79.h>
18317 +#include <asm/mach-ath79/ath79_spi_platform.h>
18318 +#include <asm/mach-ath79/ar71xx_regs.h>
18320 +#include "common.h"
18321 +#include "dev-eth.h"
18322 +#include "dev-leds-gpio.h"
18323 +#include "dev-nfc.h"
18324 +#include "dev-usb.h"
18325 +#include "dev-spi.h"
18326 +#include "dev-wmac.h"
18327 +#include "machtypes.h"
18328 +#include "pci.h"
18329 +#include "routerboot.h"
18331 +#define RB_ROUTERBOOT_OFFSET 0x0000
18332 +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
18333 +#define RB_HARD_CFG_SIZE 0x1000
18334 +#define RB_BIOS_OFFSET 0xd000
18335 +#define RB_BIOS_SIZE 0x1000
18336 +#define RB_SOFT_CFG_OFFSET 0xf000
18337 +#define RB_SOFT_CFG_SIZE 0x1000
18339 +#define RB91X_FLAG_USB BIT(0)
18340 +#define RB91X_FLAG_PCIE BIT(1)
18342 +#define RB91X_LATCH_GPIO_BASE AR934X_GPIO_COUNT
18343 +#define RB91X_LATCH_GPIO(_x) (RB91X_LATCH_GPIO_BASE + (_x))
18345 +#define RB91X_SSR_GPIO_BASE (RB91X_LATCH_GPIO_BASE + AR934X_GPIO_COUNT)
18346 +#define RB91X_SSR_GPIO(_x) (RB91X_SSR_GPIO_BASE + (_x))
18348 +#define RB91X_SSR_BIT_LED1 0
18349 +#define RB91X_SSR_BIT_LED2 1
18350 +#define RB91X_SSR_BIT_LED3 2
18351 +#define RB91X_SSR_BIT_LED4 3
18352 +#define RB91X_SSR_BIT_LED5 4
18353 +#define RB91X_SSR_BIT_5 5
18354 +#define RB91X_SSR_BIT_USB_POWER 6
18355 +#define RB91X_SSR_BIT_PCIE_POWER 7
18357 +#define RB91X_GPIO_SSR_STROBE RB91X_LATCH_GPIO(0)
18358 +#define RB91X_GPIO_LED_POWER RB91X_LATCH_GPIO(1)
18359 +#define RB91X_GPIO_LED_USER RB91X_LATCH_GPIO(2)
18360 +#define RB91X_GPIO_NAND_READ RB91X_LATCH_GPIO(3)
18361 +#define RB91X_GPIO_NAND_RDY RB91X_LATCH_GPIO(4)
18362 +#define RB91X_GPIO_NLE RB91X_LATCH_GPIO(11)
18363 +#define RB91X_GPIO_NAND_NRW RB91X_LATCH_GPIO(12)
18364 +#define RB91X_GPIO_NAND_NCE RB91X_LATCH_GPIO(13)
18365 +#define RB91X_GPIO_NAND_CLE RB91X_LATCH_GPIO(14)
18366 +#define RB91X_GPIO_NAND_ALE RB91X_LATCH_GPIO(15)
18368 +#define RB91X_GPIO_LED_1 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED1)
18369 +#define RB91X_GPIO_LED_2 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED2)
18370 +#define RB91X_GPIO_LED_3 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED3)
18371 +#define RB91X_GPIO_LED_4 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED4)
18372 +#define RB91X_GPIO_LED_5 RB91X_SSR_GPIO(RB91X_SSR_BIT_LED5)
18373 +#define RB91X_GPIO_USB_POWER RB91X_SSR_GPIO(RB91X_SSR_BIT_USB_POWER)
18374 +#define RB91X_GPIO_PCIE_POWER RB91X_SSR_GPIO(RB91X_SSR_BIT_PCIE_POWER)
18376 +struct rb_board_info {
18377 + const char *name;
18378 + u32 flags;
18381 +static struct mtd_partition rb711gr100_spi_partitions[] = {
18383 + .name = "routerboot",
18384 + .offset = RB_ROUTERBOOT_OFFSET,
18385 + .mask_flags = MTD_WRITEABLE,
18386 + }, {
18387 + .name = "hard_config",
18388 + .size = RB_HARD_CFG_SIZE,
18389 + .mask_flags = MTD_WRITEABLE,
18390 + }, {
18391 + .name = "bios",
18392 + .offset = RB_BIOS_OFFSET,
18393 + .size = RB_BIOS_SIZE,
18394 + .mask_flags = MTD_WRITEABLE,
18395 + }, {
18396 + .name = "soft_config",
18397 + .size = RB_SOFT_CFG_SIZE,
18401 +static struct flash_platform_data rb711gr100_spi_flash_data = {
18402 + .parts = rb711gr100_spi_partitions,
18403 + .nr_parts = ARRAY_SIZE(rb711gr100_spi_partitions),
18406 +static int rb711gr100_gpio_latch_gpios[AR934X_GPIO_COUNT] __initdata = {
18407 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
18408 + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
18411 +static struct gpio_latch_platform_data rb711gr100_gpio_latch_data __initdata = {
18412 + .base = RB91X_LATCH_GPIO_BASE,
18413 + .num_gpios = ARRAY_SIZE(rb711gr100_gpio_latch_gpios),
18414 + .gpios = rb711gr100_gpio_latch_gpios,
18415 + .le_gpio_index = 11,
18416 + .le_active_low = true,
18419 +static struct rb91x_nand_platform_data rb711gr100_nand_data __initdata = {
18420 + .gpio_nce = RB91X_GPIO_NAND_NCE,
18421 + .gpio_ale = RB91X_GPIO_NAND_ALE,
18422 + .gpio_cle = RB91X_GPIO_NAND_CLE,
18423 + .gpio_rdy = RB91X_GPIO_NAND_RDY,
18424 + .gpio_read = RB91X_GPIO_NAND_READ,
18425 + .gpio_nrw = RB91X_GPIO_NAND_NRW,
18426 + .gpio_nle = RB91X_GPIO_NLE,
18429 +static u8 rb711gr100_ssr_initdata[] __initdata = {
18430 + BIT(RB91X_SSR_BIT_PCIE_POWER) |
18431 + BIT(RB91X_SSR_BIT_USB_POWER) |
18432 + BIT(RB91X_SSR_BIT_5)
18435 +static struct gen_74x164_chip_platform_data rb711gr100_ssr_data = {
18436 + .base = RB91X_SSR_GPIO_BASE,
18437 + .num_registers = ARRAY_SIZE(rb711gr100_ssr_initdata),
18438 + .init_data = rb711gr100_ssr_initdata,
18441 +static struct ath79_spi_controller_data rb711gr100_spi0_cdata = {
18442 + .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
18443 + .cs_line = 0,
18444 + .is_flash = true,
18447 +static struct ath79_spi_controller_data rb711gr100_spi1_cdata = {
18448 + .cs_type = ATH79_SPI_CS_TYPE_GPIO,
18449 + .cs_line = RB91X_GPIO_SSR_STROBE,
18452 +static struct spi_board_info rb711gr100_spi_info[] = {
18454 + .bus_num = 0,
18455 + .chip_select = 0,
18456 + .max_speed_hz = 25000000,
18457 + .modalias = "m25p80",
18458 + .platform_data = &rb711gr100_spi_flash_data,
18459 + .controller_data = &rb711gr100_spi0_cdata
18460 + }, {
18461 + .bus_num = 0,
18462 + .chip_select = 1,
18463 + .max_speed_hz = 10000000,
18464 + .modalias = "74x164",
18465 + .platform_data = &rb711gr100_ssr_data,
18466 + .controller_data = &rb711gr100_spi1_cdata
18470 +static struct ath79_spi_platform_data rb711gr100_spi_data __initdata = {
18471 + .bus_num = 0,
18472 + .num_chipselect = 2,
18475 +static struct gpio_led rb711gr100_leds[] __initdata = {
18477 + .name = "rb:green:led1",
18478 + .gpio = RB91X_GPIO_LED_1,
18479 + .active_low = 0,
18480 + },
18482 + .name = "rb:green:led2",
18483 + .gpio = RB91X_GPIO_LED_2,
18484 + .active_low = 0,
18485 + },
18487 + .name = "rb:green:led3",
18488 + .gpio = RB91X_GPIO_LED_3,
18489 + .active_low = 0,
18490 + },
18492 + .name = "rb:green:led4",
18493 + .gpio = RB91X_GPIO_LED_4,
18494 + .active_low = 0,
18495 + },
18497 + .name = "rb:green:led5",
18498 + .gpio = RB91X_GPIO_LED_5,
18499 + .active_low = 0,
18500 + },
18502 + .name = "rb:green:user",
18503 + .gpio = RB91X_GPIO_LED_USER,
18504 + .active_low = 0,
18505 + },
18507 + .name = "rb:green:power",
18508 + .gpio = RB91X_GPIO_LED_POWER,
18509 + .active_low = 0,
18510 + },
18513 +static struct at803x_platform_data rb91x_at803x_data = {
18514 + .disable_smarteee = 1,
18515 + .enable_rgmii_rx_delay = 1,
18516 + .enable_rgmii_tx_delay = 1,
18519 +static struct mdio_board_info rb91x_mdio0_info[] = {
18521 + .bus_id = "ag71xx-mdio.0",
18522 + .phy_addr = 0,
18523 + .platform_data = &rb91x_at803x_data,
18524 + },
18527 +static void __init rb711gr100_init_partitions(const struct rb_info *info)
18529 + rb711gr100_spi_partitions[0].size = info->hard_cfg_offs;
18530 + rb711gr100_spi_partitions[1].offset = info->hard_cfg_offs;
18532 + rb711gr100_spi_partitions[3].offset = info->soft_cfg_offs;
18535 +void __init rb711gr100_wlan_init(void)
18537 + char *caldata;
18538 + u8 wlan_mac[ETH_ALEN];
18540 + caldata = rb_get_wlan_data();
18541 + if (caldata == NULL)
18542 + return;
18544 + ath79_init_mac(wlan_mac, ath79_mac_base, 1);
18545 + ath79_register_wmac(caldata + 0x1000, wlan_mac);
18547 + kfree(caldata);
18550 +#define RB_BOARD_INFO(_name, _flags) \
18551 + { \
18552 + .name = (_name), \
18553 + .flags = (_flags), \
18556 +static const struct rb_board_info rb711gr100_boards[] __initconst = {
18557 + RB_BOARD_INFO("911G-2HPnD", 0),
18558 + RB_BOARD_INFO("911G-5HPnD", 0),
18559 + RB_BOARD_INFO("912UAG-2HPnD", RB91X_FLAG_USB | RB91X_FLAG_PCIE),
18560 + RB_BOARD_INFO("912UAG-5HPnD", RB91X_FLAG_USB | RB91X_FLAG_PCIE),
18563 +static u32 rb711gr100_get_flags(const struct rb_info *info)
18565 + int i;
18567 + for (i = 0; i < ARRAY_SIZE(rb711gr100_boards); i++) {
18568 + const struct rb_board_info *bi;
18570 + bi = &rb711gr100_boards[i];
18571 + if (strcmp(info->board_name, bi->name) == 0)
18572 + return bi->flags;
18575 + return 0;
18578 +static void __init rb711gr100_setup(void)
18580 + const struct rb_info *info;
18581 + char buf[64];
18582 + u32 flags;
18584 + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
18585 + if (!info)
18586 + return;
18588 + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
18589 + (info->board_name) ? info->board_name : "");
18590 + mips_set_machine_name(buf);
18592 + rb711gr100_init_partitions(info);
18593 + ath79_register_spi(&rb711gr100_spi_data, rb711gr100_spi_info,
18594 + ARRAY_SIZE(rb711gr100_spi_info));
18596 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
18597 + AR934X_ETH_CFG_RXD_DELAY |
18598 + AR934X_ETH_CFG_SW_ONLY_MODE);
18600 + ath79_register_mdio(0, 0x0);
18602 + mdiobus_register_board_info(rb91x_mdio0_info,
18603 + ARRAY_SIZE(rb91x_mdio0_info));
18605 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
18606 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
18607 + ath79_eth0_data.phy_mask = BIT(0);
18608 + ath79_eth0_pll_data.pll_1000 = 0x02000000;
18610 + ath79_register_eth(0);
18612 + rb711gr100_wlan_init();
18614 + platform_device_register_data(NULL, "rb91x-nand", -1,
18615 + &rb711gr100_nand_data,
18616 + sizeof(rb711gr100_nand_data));
18618 + platform_device_register_data(NULL, "gpio-latch", -1,
18619 + &rb711gr100_gpio_latch_data,
18620 + sizeof(rb711gr100_gpio_latch_data));
18622 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb711gr100_leds),
18623 + rb711gr100_leds);
18625 + flags = rb711gr100_get_flags(info);
18627 + if (flags & RB91X_FLAG_USB)
18628 + ath79_register_usb();
18630 + if (flags & RB91X_FLAG_PCIE)
18631 + ath79_register_pci();
18635 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_711GR100, "711Gr100", rb711gr100_setup);
18636 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb922.c linux-4.1.43/arch/mips/ath79/mach-rb922.c
18637 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb922.c 1970-01-01 01:00:00.000000000 +0100
18638 +++ linux-4.1.43/arch/mips/ath79/mach-rb922.c 2017-08-06 20:02:15.000000000 +0200
18639 @@ -0,0 +1,236 @@
18641 + * MikroTik RouterBOARD 91X support
18643 + * Copyright (C) 2015 Gabor Juhos <juhosg@openwrt.org>
18645 + * This program is free software; you can redistribute it and/or modify it
18646 + * under the terms of the GNU General Public License version 2 as published
18647 + * by the Free Software Foundation.
18648 + */
18650 +#include <linux/phy.h>
18651 +#include <linux/delay.h>
18652 +#include <linux/platform_device.h>
18653 +#include <linux/ath9k_platform.h>
18654 +#include <linux/mtd/mtd.h>
18655 +#include <linux/mtd/nand.h>
18656 +#include <linux/mtd/partitions.h>
18657 +#include <linux/spi/spi.h>
18658 +#include <linux/spi/flash.h>
18659 +#include <linux/routerboot.h>
18660 +#include <linux/gpio.h>
18661 +#include <linux/platform_data/phy-at803x.h>
18663 +#include <asm/prom.h>
18664 +#include <asm/mach-ath79/ath79.h>
18665 +#include <asm/mach-ath79/ar71xx_regs.h>
18667 +#include "common.h"
18668 +#include "dev-gpio-buttons.h"
18669 +#include "dev-eth.h"
18670 +#include "dev-leds-gpio.h"
18671 +#include "dev-m25p80.h"
18672 +#include "dev-nfc.h"
18673 +#include "dev-usb.h"
18674 +#include "dev-spi.h"
18675 +#include "machtypes.h"
18676 +#include "pci.h"
18677 +#include "routerboot.h"
18679 +#define RB922_GPIO_LED_USR 12
18680 +#define RB922_GPIO_USB_POWER 13
18681 +#define RB922_GPIO_FAN_CTRL 14
18682 +#define RB922_GPIO_BTN_RESET 20
18683 +#define RB922_GPIO_NAND_NCE 23
18685 +#define RB922_PHY_ADDR 4
18687 +#define RB922_KEYS_POLL_INTERVAL 20 /* msecs */
18688 +#define RB922_KEYS_DEBOUNCE_INTERVAL (3 * RB922_KEYS_POLL_INTERVAL)
18690 +#define RB_ROUTERBOOT_OFFSET 0x0000
18691 +#define RB_ROUTERBOOT_MIN_SIZE 0xb000
18692 +#define RB_HARD_CFG_SIZE 0x1000
18693 +#define RB_BIOS_OFFSET 0xd000
18694 +#define RB_BIOS_SIZE 0x1000
18695 +#define RB_SOFT_CFG_OFFSET 0xf000
18696 +#define RB_SOFT_CFG_SIZE 0x1000
18698 +static struct mtd_partition rb922gs_spi_partitions[] = {
18700 + .name = "routerboot",
18701 + .offset = RB_ROUTERBOOT_OFFSET,
18702 + .mask_flags = MTD_WRITEABLE,
18703 + }, {
18704 + .name = "hard_config",
18705 + .size = RB_HARD_CFG_SIZE,
18706 + .mask_flags = MTD_WRITEABLE,
18707 + }, {
18708 + .name = "bios",
18709 + .offset = RB_BIOS_OFFSET,
18710 + .size = RB_BIOS_SIZE,
18711 + .mask_flags = MTD_WRITEABLE,
18712 + }, {
18713 + .name = "soft_config",
18714 + .size = RB_SOFT_CFG_SIZE,
18718 +static struct flash_platform_data rb922gs_spi_flash_data = {
18719 + .parts = rb922gs_spi_partitions,
18720 + .nr_parts = ARRAY_SIZE(rb922gs_spi_partitions),
18723 +static struct gpio_led rb922gs_leds[] __initdata = {
18725 + .name = "rb:green:user",
18726 + .gpio = RB922_GPIO_LED_USR,
18727 + .active_low = 1,
18728 + },
18731 +static struct gpio_keys_button rb922gs_gpio_keys[] __initdata = {
18733 + .desc = "Reset button",
18734 + .type = EV_KEY,
18735 + .code = KEY_RESTART,
18736 + .debounce_interval = RB922_KEYS_DEBOUNCE_INTERVAL,
18737 + .gpio = RB922_GPIO_BTN_RESET,
18738 + .active_low = 1,
18739 + },
18742 +static struct at803x_platform_data rb922gs_at803x_data = {
18743 + .disable_smarteee = 1,
18746 +static struct mdio_board_info rb922gs_mdio0_info[] = {
18748 + .bus_id = "ag71xx-mdio.0",
18749 + .phy_addr = RB922_PHY_ADDR,
18750 + .platform_data = &rb922gs_at803x_data,
18751 + },
18754 +static void __init rb922gs_init_partitions(const struct rb_info *info)
18756 + rb922gs_spi_partitions[0].size = info->hard_cfg_offs;
18757 + rb922gs_spi_partitions[1].offset = info->hard_cfg_offs;
18758 + rb922gs_spi_partitions[3].offset = info->soft_cfg_offs;
18761 +static void rb922gs_nand_select_chip(int chip_no)
18763 + switch (chip_no) {
18764 + case 0:
18765 + gpio_set_value(RB922_GPIO_NAND_NCE, 0);
18766 + break;
18767 + default:
18768 + gpio_set_value(RB922_GPIO_NAND_NCE, 1);
18769 + break;
18771 + ndelay(500);
18774 +static struct nand_ecclayout rb922gs_nand_ecclayout = {
18775 + .eccbytes = 6,
18776 + .eccpos = { 8, 9, 10, 13, 14, 15 },
18777 + .oobavail = 9,
18778 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
18781 +static int rb922gs_nand_scan_fixup(struct mtd_info *mtd)
18783 + struct nand_chip *chip = mtd->priv;
18785 + if (mtd->writesize == 512) {
18786 + /*
18787 + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
18788 + * will not be able to find the kernel that we load.
18789 + */
18790 + chip->ecc.layout = &rb922gs_nand_ecclayout;
18793 + return 0;
18796 +static struct mtd_partition rb922gs_nand_partitions[] = {
18798 + .name = "booter",
18799 + .offset = 0,
18800 + .size = (256 * 1024),
18801 + .mask_flags = MTD_WRITEABLE,
18802 + },
18804 + .name = "kernel",
18805 + .offset = (256 * 1024),
18806 + .size = (4 * 1024 * 1024) - (256 * 1024),
18807 + },
18809 + .name = "rootfs",
18810 + .offset = MTDPART_OFS_NXTBLK,
18811 + .size = MTDPART_SIZ_FULL,
18812 + },
18815 +static void __init rb922gs_nand_init(void)
18817 + gpio_request_one(RB922_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
18819 + ath79_nfc_set_scan_fixup(rb922gs_nand_scan_fixup);
18820 + ath79_nfc_set_parts(rb922gs_nand_partitions,
18821 + ARRAY_SIZE(rb922gs_nand_partitions));
18822 + ath79_nfc_set_select_chip(rb922gs_nand_select_chip);
18823 + ath79_nfc_set_swap_dma(true);
18824 + ath79_register_nfc();
18827 +static void __init rb922gs_setup(void)
18829 + const struct rb_info *info;
18830 + char buf[64];
18832 + info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
18833 + if (!info)
18834 + return;
18836 + scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
18837 + (info->board_name) ? info->board_name : "");
18838 + mips_set_machine_name(buf);
18840 + rb922gs_init_partitions(info);
18841 + ath79_register_m25p80(&rb922gs_spi_flash_data);
18843 + rb922gs_nand_init();
18845 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
18847 + ath79_register_mdio(0, 0x0);
18849 + mdiobus_register_board_info(rb922gs_mdio0_info,
18850 + ARRAY_SIZE(rb922gs_mdio0_info));
18852 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
18853 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
18854 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
18855 + ath79_eth0_data.phy_mask = BIT(RB922_PHY_ADDR);
18856 + ath79_eth0_pll_data.pll_10 = 0x81001313;
18857 + ath79_eth0_pll_data.pll_100 = 0x81000101;
18858 + ath79_eth0_pll_data.pll_1000 = 0x8f000000;
18860 + ath79_register_eth(0);
18862 + ath79_register_pci();
18863 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb922gs_leds), rb922gs_leds);
18864 + ath79_register_gpio_keys_polled(-1, RB922_KEYS_POLL_INTERVAL,
18865 + ARRAY_SIZE(rb922gs_gpio_keys),
18866 + rb922gs_gpio_keys);
18868 + /* NOTE:
18869 + * This only supports the RB911G-5HPacD board for now. For other boards
18870 + * more devices must be registered based on the hardware options which
18871 + * can be found in the hardware configuration of RouterBOOT.
18872 + */
18875 +MIPS_MACHINE_NONAME(ATH79_MACH_RB_922GS, "922gs", rb922gs_setup);
18876 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rb95x.c linux-4.1.43/arch/mips/ath79/mach-rb95x.c
18877 --- linux-4.1.43.orig/arch/mips/ath79/mach-rb95x.c 1970-01-01 01:00:00.000000000 +0100
18878 +++ linux-4.1.43/arch/mips/ath79/mach-rb95x.c 2017-08-06 20:02:15.000000000 +0200
18879 @@ -0,0 +1,258 @@
18881 + * MikroTik RouterBOARD 95X support
18883 + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
18884 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
18885 + * Copyright (C) 2013 Kamil Trzcinski <ayufan@ayufan.eu>
18887 + * This program is free software; you can redistribute it and/or modify it
18888 + * under the terms of the GNU General Public License version 2 as published
18889 + * by the Free Software Foundation.
18890 + */
18892 +#define pr_fmt(fmt) "rb95x: " fmt
18894 +#include <linux/phy.h>
18895 +#include <linux/delay.h>
18896 +#include <linux/platform_device.h>
18897 +#include <linux/ath9k_platform.h>
18898 +#include <linux/ar8216_platform.h>
18899 +#include <linux/mtd/mtd.h>
18900 +#include <linux/mtd/nand.h>
18901 +#include <linux/mtd/partitions.h>
18902 +#include <linux/spi/spi.h>
18903 +#include <linux/spi/flash.h>
18904 +#include <linux/routerboot.h>
18905 +#include <linux/gpio.h>
18907 +#include <asm/mach-ath79/ath79.h>
18908 +#include <asm/mach-ath79/ar71xx_regs.h>
18910 +#include "common.h"
18911 +#include "dev-eth.h"
18912 +#include "dev-m25p80.h"
18913 +#include "dev-nfc.h"
18914 +#include "dev-usb.h"
18915 +#include "dev-wmac.h"
18916 +#include "machtypes.h"
18917 +#include "routerboot.h"
18918 +#include "dev-leds-gpio.h"
18920 +#define RB95X_GPIO_NAND_NCE 14
18922 +static struct mtd_partition rb95x_nand_partitions[] = {
18924 + .name = "booter",
18925 + .offset = 0,
18926 + .size = (256 * 1024),
18927 + .mask_flags = MTD_WRITEABLE,
18928 + },
18930 + .name = "kernel",
18931 + .offset = (256 * 1024),
18932 + .size = (4 * 1024 * 1024) - (256 * 1024),
18933 + },
18935 + .name = "rootfs",
18936 + .offset = MTDPART_OFS_NXTBLK,
18937 + .size = MTDPART_SIZ_FULL,
18938 + },
18941 +static struct gpio_led rb951ui_leds_gpio[] __initdata = {
18943 + .name = "rb:green:wlan",
18944 + .gpio = 11,
18945 + .active_low = 1,
18946 + }, {
18947 + .name = "rb:green:act",
18948 + .gpio = 3,
18949 + .active_low = 1,
18950 + }, {
18951 + .name = "rb:green:port1",
18952 + .gpio = 13,
18953 + .active_low = 1,
18954 + }, {
18955 + .name = "rb:green:port2",
18956 + .gpio = 12,
18957 + .active_low = 1,
18958 + }, {
18959 + .name = "rb:green:port3",
18960 + .gpio = 4,
18961 + .active_low = 1,
18962 + }, {
18963 + .name = "rb:green:port4",
18964 + .gpio = 21,
18965 + .active_low = 1,
18966 + }, {
18967 + .name = "rb:green:port5",
18968 + .gpio = 16,
18969 + .active_low = 1,
18973 +static struct ar8327_pad_cfg rb95x_ar8327_pad0_cfg = {
18974 + .mode = AR8327_PAD_MAC_RGMII,
18975 + .txclk_delay_en = true,
18976 + .rxclk_delay_en = true,
18977 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
18978 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
18981 +static struct ar8327_platform_data rb95x_ar8327_data = {
18982 + .pad0_cfg = &rb95x_ar8327_pad0_cfg,
18983 + .port0_cfg = {
18984 + .force_link = 1,
18985 + .speed = AR8327_PORT_SPEED_1000,
18986 + .duplex = 1,
18987 + .txpause = 1,
18988 + .rxpause = 1,
18992 +static struct mdio_board_info rb95x_mdio0_info[] = {
18994 + .bus_id = "ag71xx-mdio.0",
18995 + .phy_addr = 0,
18996 + .platform_data = &rb95x_ar8327_data,
18997 + },
19000 +void __init rb95x_wlan_init(void)
19002 + char *art_buf;
19003 + u8 wlan_mac[ETH_ALEN];
19005 + art_buf = rb_get_wlan_data();
19006 + if (art_buf == NULL)
19007 + return;
19009 + ath79_init_mac(wlan_mac, ath79_mac_base, 11);
19010 + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
19012 + kfree(art_buf);
19015 +static void rb95x_nand_select_chip(int chip_no)
19017 + switch (chip_no) {
19018 + case 0:
19019 + gpio_set_value(RB95X_GPIO_NAND_NCE, 0);
19020 + break;
19021 + default:
19022 + gpio_set_value(RB95X_GPIO_NAND_NCE, 1);
19023 + break;
19025 + ndelay(500);
19028 +static struct nand_ecclayout rb95x_nand_ecclayout = {
19029 + .eccbytes = 6,
19030 + .eccpos = { 8, 9, 10, 13, 14, 15 },
19031 + .oobavail = 9,
19032 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
19035 +static int rb95x_nand_scan_fixup(struct mtd_info *mtd)
19037 + struct nand_chip *chip = mtd->priv;
19039 + if (mtd->writesize == 512) {
19040 + /*
19041 + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
19042 + * will not be able to find the kernel that we load.
19043 + */
19044 + chip->ecc.layout = &rb95x_nand_ecclayout;
19047 + return 0;
19050 +void __init rb95x_nand_init(void)
19052 + gpio_request_one(RB95X_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
19054 + ath79_nfc_set_scan_fixup(rb95x_nand_scan_fixup);
19055 + ath79_nfc_set_parts(rb95x_nand_partitions,
19056 + ARRAY_SIZE(rb95x_nand_partitions));
19057 + ath79_nfc_set_select_chip(rb95x_nand_select_chip);
19058 + ath79_nfc_set_swap_dma(true);
19059 + ath79_register_nfc();
19062 +static int __init rb95x_setup(void)
19064 + const struct rb_info *info;
19066 + info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x10000);
19067 + if (!info)
19068 + return -EINVAL;
19070 + rb95x_nand_init();
19072 + return 0;
19075 +static void __init rb951g_setup(void)
19077 + if (rb95x_setup())
19078 + return;
19080 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
19081 + AR934X_ETH_CFG_SW_ONLY_MODE);
19083 + ath79_register_mdio(0, 0x0);
19085 + mdiobus_register_board_info(rb95x_mdio0_info,
19086 + ARRAY_SIZE(rb95x_mdio0_info));
19088 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
19089 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
19090 + ath79_eth0_data.phy_mask = BIT(0);
19092 + ath79_register_eth(0);
19094 + rb95x_wlan_init();
19095 + ath79_register_usb();
19098 +MIPS_MACHINE(ATH79_MACH_RB_951G, "951G", "MikroTik RouterBOARD 951G-2HnD",
19099 + rb951g_setup);
19101 +static void __init rb951ui_setup(void)
19103 + if (rb95x_setup())
19104 + return;
19106 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
19108 + ath79_register_mdio(1, 0x0);
19110 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
19111 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
19113 + ath79_switch_data.phy4_mii_en = 1;
19114 + ath79_switch_data.phy_poll_mask = BIT(4);
19115 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
19116 + ath79_eth0_data.phy_mask = BIT(4);
19117 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
19118 + ath79_register_eth(0);
19120 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
19121 + ath79_register_eth(1);
19123 + gpio_request_one(20, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
19124 + "USB power");
19126 + gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
19127 + "POE power");
19129 + rb95x_wlan_init();
19130 + ath79_register_usb();
19132 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb951ui_leds_gpio),
19133 + rb951ui_leds_gpio);
19136 +MIPS_MACHINE(ATH79_MACH_RB_951U, "951HnD", "MikroTik RouterBOARD 951Ui-2HnD",
19137 + rb951ui_setup);
19138 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rbsxtlite.c linux-4.1.43/arch/mips/ath79/mach-rbsxtlite.c
19139 --- linux-4.1.43.orig/arch/mips/ath79/mach-rbsxtlite.c 1970-01-01 01:00:00.000000000 +0100
19140 +++ linux-4.1.43/arch/mips/ath79/mach-rbsxtlite.c 2017-08-06 20:02:15.000000000 +0200
19141 @@ -0,0 +1,238 @@
19143 + * MikroTik RouterBOARD SXT Lite support
19145 + * Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
19146 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
19147 + * Copyright (C) 2013 Vyacheslav Adamanov <adamanov@gmail.com>
19149 + * This program is free software; you can redistribute it and/or modify it
19150 + * under the terms of the GNU General Public License version 2 as published
19151 + * by the Free Software Foundation.
19152 + */
19154 +#define pr_fmt(fmt) "sxtlite: " fmt
19156 +#include <linux/phy.h>
19157 +#include <linux/delay.h>
19158 +#include <linux/platform_device.h>
19159 +#include <linux/ath9k_platform.h>
19160 +#include <linux/mtd/mtd.h>
19161 +#include <linux/mtd/nand.h>
19162 +#include <linux/mtd/partitions.h>
19163 +#include <linux/spi/spi.h>
19164 +#include <linux/spi/flash.h>
19165 +#include <linux/rle.h>
19166 +#include <linux/routerboot.h>
19167 +#include <linux/gpio.h>
19169 +#include <asm/mach-ath79/ath79.h>
19170 +#include <asm/mach-ath79/ar71xx_regs.h>
19171 +#include "common.h"
19172 +#include "dev-ap9x-pci.h"
19173 +#include "dev-gpio-buttons.h"
19174 +#include "dev-leds-gpio.h"
19175 +#include "dev-eth.h"
19176 +#include "dev-m25p80.h"
19177 +#include "dev-nfc.h"
19178 +#include "dev-wmac.h"
19179 +#include "dev-usb.h"
19180 +#include "machtypes.h"
19181 +#include "routerboot.h"
19182 +#include <linux/ar8216_platform.h>
19184 +#define SXTLITE_GPIO_NAND_NCE 14
19185 +#define SXTLITE_GPIO_LED_USER 3
19186 +#define SXTLITE_GPIO_LED_1 13
19187 +#define SXTLITE_GPIO_LED_2 12
19188 +#define SXTLITE_GPIO_LED_3 4
19189 +#define SXTLITE_GPIO_LED_4 21
19190 +#define SXTLITE_GPIO_LED_5 18
19191 +#define SXTLITE_GPIO_LED_POWER 11
19193 +#define SXTLITE_GPIO_BUZZER 19
19195 +#define SXTLITE_GPIO_BTN_RESET 15
19197 +#define SXTLITE_KEYS_POLL_INTERVAL 20
19198 +#define SXTLITE_KEYS_DEBOUNCE_INTERVAL (3 * SXTLITE_KEYS_POLL_INTERVAL)
19200 +static struct mtd_partition rbsxtlite_nand_partitions[] = {
19202 + .name = "booter",
19203 + .offset = 0,
19204 + .size = (256 * 1024),
19205 + .mask_flags = MTD_WRITEABLE,
19206 + },
19208 + .name = "kernel",
19209 + .offset = (256 * 1024),
19210 + .size = (4 * 1024 * 1024) - (256 * 1024),
19211 + },
19213 + .name = "rootfs",
19214 + .offset = MTDPART_OFS_NXTBLK,
19215 + .size = MTDPART_SIZ_FULL,
19216 + },
19219 +static struct gpio_led rbsxtlite_leds_gpio[] __initdata = {
19221 + .name = "rb:green:user",
19222 + .gpio = SXTLITE_GPIO_LED_USER,
19223 + .active_low = 1,
19224 + },
19226 + .name = "rb:green:led1",
19227 + .gpio = SXTLITE_GPIO_LED_1,
19228 + .active_low = 1,
19229 + },
19231 + .name = "rb:green:led2",
19232 + .gpio = SXTLITE_GPIO_LED_2,
19233 + .active_low = 1,
19234 + },
19236 + .name = "rb:green:led3",
19237 + .gpio = SXTLITE_GPIO_LED_3,
19238 + .active_low = 1,
19239 + },
19241 + .name = "rb:green:led4",
19242 + .gpio = SXTLITE_GPIO_LED_4,
19243 + .active_low = 1,
19244 + },
19246 + .name = "rb:green:led5",
19247 + .gpio = SXTLITE_GPIO_LED_5,
19248 + .active_low = 1,
19249 + },
19251 + .name = "rb:green:power",
19252 + .gpio = SXTLITE_GPIO_LED_POWER,
19253 + },
19256 +static struct gpio_keys_button rbsxtlite_gpio_keys[] __initdata = {
19258 + .desc = "Reset button",
19259 + .type = EV_KEY,
19260 + .code = KEY_RESTART,
19261 + .debounce_interval = SXTLITE_KEYS_DEBOUNCE_INTERVAL,
19262 + .gpio = SXTLITE_GPIO_BTN_RESET,
19263 + .active_low = 0,
19264 + },
19267 +static int __init rbsxtlite_rbinfo_init(void)
19269 + const struct rb_info *info;
19271 + info = rb_init_info((void *)(KSEG1ADDR(AR71XX_SPI_BASE)), 0x10000);
19272 + if (!info)
19273 + return -EINVAL;
19274 + return 0;
19278 +void __init rbsxtlite_wlan_init(void)
19280 + char *art_buf;
19281 + u8 wlan_mac[ETH_ALEN];
19283 + art_buf = rb_get_wlan_data();
19284 + if (art_buf == NULL)
19285 + return;
19287 + ath79_init_mac(wlan_mac, ath79_mac_base, 1);
19288 + ath79_register_wmac(art_buf + 0x1000, wlan_mac);
19290 + kfree(art_buf);
19293 +static void rbsxtlite_nand_select_chip(int chip_no)
19295 + switch (chip_no) {
19296 + case 0:
19297 + gpio_set_value(SXTLITE_GPIO_NAND_NCE, 0);
19298 + break;
19299 + default:
19300 + gpio_set_value(SXTLITE_GPIO_NAND_NCE, 1);
19301 + break;
19303 + ndelay(500);
19306 +static struct nand_ecclayout rbsxtlite_nand_ecclayout = {
19307 + .eccbytes = 6,
19308 + .eccpos = { 8, 9, 10, 13, 14, 15 },
19309 + .oobavail = 9,
19310 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
19313 +static int rbsxtlite_nand_scan_fixup(struct mtd_info *mtd)
19315 + struct nand_chip *chip = mtd->priv;
19317 + if (mtd->writesize == 512) {
19318 + /*
19319 + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
19320 + * will not be able to find the kernel that we load.
19321 + */
19322 + chip->ecc.layout = &rbsxtlite_nand_ecclayout;
19325 + return 0;
19328 +void __init rbsxtlite_gpio_init(void)
19330 + gpio_request_one(SXTLITE_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");
19333 +void __init rbsxtlite_nand_init(void)
19335 + ath79_nfc_set_scan_fixup(rbsxtlite_nand_scan_fixup);
19336 + ath79_nfc_set_parts(rbsxtlite_nand_partitions,
19337 + ARRAY_SIZE(rbsxtlite_nand_partitions));
19338 + ath79_nfc_set_select_chip(rbsxtlite_nand_select_chip);
19339 + ath79_nfc_set_swap_dma(true);
19340 + ath79_register_nfc();
19344 +static void __init rbsxtlite_setup(void)
19346 + if(rbsxtlite_rbinfo_init())
19347 + return;
19348 + rbsxtlite_nand_init();
19349 + rbsxtlite_wlan_init();
19351 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rbsxtlite_leds_gpio),
19352 + rbsxtlite_leds_gpio);
19353 + ath79_register_gpio_keys_polled(-1, SXTLITE_KEYS_POLL_INTERVAL,
19354 + ARRAY_SIZE(rbsxtlite_gpio_keys),
19355 + rbsxtlite_gpio_keys);
19357 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
19359 + ath79_register_mdio(1, 0x0);
19361 + /* GMAC0 is left unused */
19363 + /* GMAC1 is connected to MAC0 on the internal switch */
19364 + /* The ethernet port connects to PHY P0, which connects to MAC1
19365 + on the internal switch */
19366 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 0);
19367 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
19368 + ath79_register_eth(1);
19374 +MIPS_MACHINE(ATH79_MACH_RB_SXTLITE2ND, "sxt2n", "Mikrotik RouterBOARD SXT Lite2",
19375 + rbsxtlite_setup);
19377 +MIPS_MACHINE(ATH79_MACH_RB_SXTLITE5ND, "sxt5n", "Mikrotik RouterBOARD SXT Lite5",
19378 + rbsxtlite_setup);
19380 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-rw2458n.c linux-4.1.43/arch/mips/ath79/mach-rw2458n.c
19381 --- linux-4.1.43.orig/arch/mips/ath79/mach-rw2458n.c 1970-01-01 01:00:00.000000000 +0100
19382 +++ linux-4.1.43/arch/mips/ath79/mach-rw2458n.c 2017-08-06 20:02:15.000000000 +0200
19383 @@ -0,0 +1,91 @@
19385 + * Redwave RW2458N support
19387 + * Copyright (C) 2011-2013 Cezary Jackiewicz <cezary@eko.one.pl>
19389 + * This program is free software; you can redistribute it and/or modify it
19390 + * under the terms of the GNU General Public License version 2 as published
19391 + * by the Free Software Foundation.
19392 + */
19394 +#include <asm/mach-ath79/ath79.h>
19396 +#include "dev-eth.h"
19397 +#include "dev-ap9x-pci.h"
19398 +#include "dev-gpio-buttons.h"
19399 +#include "dev-leds-gpio.h"
19400 +#include "dev-m25p80.h"
19401 +#include "dev-usb.h"
19402 +#include "machtypes.h"
19403 +#include "pci.h"
19405 +#define RW2458N_GPIO_LED_D3 1
19406 +#define RW2458N_GPIO_LED_D4 0
19407 +#define RW2458N_GPIO_LED_D5 11
19408 +#define RW2458N_GPIO_LED_D6 7
19409 +#define RW2458N_GPIO_BTN_RESET 12
19411 +#define RW2458N_KEYS_POLL_INTERVAL 20 /* msecs */
19412 +#define RW2458N_KEYS_DEBOUNCE_INTERVAL (3 * RW2458N_KEYS_POLL_INTERVAL)
19414 +static struct gpio_keys_button rw2458n_gpio_keys[] __initdata = {
19416 + .desc = "reset",
19417 + .type = EV_KEY,
19418 + .code = KEY_RESTART,
19419 + .debounce_interval = RW2458N_KEYS_DEBOUNCE_INTERVAL,
19420 + .gpio = RW2458N_GPIO_BTN_RESET,
19421 + .active_low = 1,
19425 +#define RW2458N_WAN_PHYMASK BIT(4)
19427 +static struct gpio_led rw2458n_leds_gpio[] __initdata = {
19429 + .name = "rw2458n:green:d3",
19430 + .gpio = RW2458N_GPIO_LED_D3,
19431 + .active_low = 1,
19432 + }, {
19433 + .name = "rw2458n:green:d4",
19434 + .gpio = RW2458N_GPIO_LED_D4,
19435 + .active_low = 1,
19436 + }, {
19437 + .name = "rw2458n:green:d5",
19438 + .gpio = RW2458N_GPIO_LED_D5,
19439 + .active_low = 1,
19440 + }, {
19441 + .name = "rw2458n:green:d6",
19442 + .gpio = RW2458N_GPIO_LED_D6,
19443 + .active_low = 1,
19447 +static void __init rw2458n_setup(void)
19449 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
19450 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
19452 + ath79_register_m25p80(NULL);
19454 + ath79_register_mdio(0, ~RW2458N_WAN_PHYMASK);
19456 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
19457 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
19459 + ath79_register_eth(0);
19460 + ath79_register_eth(1);
19462 + ath79_register_leds_gpio(-1, ARRAY_SIZE(rw2458n_leds_gpio),
19463 + rw2458n_leds_gpio);
19465 + ath79_register_gpio_keys_polled(-1, RW2458N_KEYS_POLL_INTERVAL,
19466 + ARRAY_SIZE(rw2458n_gpio_keys),
19467 + rw2458n_gpio_keys);
19468 + ath79_register_usb();
19470 + ath79_register_pci();
19473 +MIPS_MACHINE(ATH79_MACH_RW2458N, "RW2458N", "Redwave RW2458N",
19474 + rw2458n_setup);
19475 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-smart-300.c linux-4.1.43/arch/mips/ath79/mach-smart-300.c
19476 --- linux-4.1.43.orig/arch/mips/ath79/mach-smart-300.c 1970-01-01 01:00:00.000000000 +0100
19477 +++ linux-4.1.43/arch/mips/ath79/mach-smart-300.c 2017-08-06 20:02:15.000000000 +0200
19478 @@ -0,0 +1,135 @@
19480 + * NC-LINK SMART-300 board support
19482 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
19483 + * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
19485 + * This program is free software; you can redistribute it and/or modify it
19486 + * under the terms of the GNU General Public License version 2 as published
19487 + * by the Free Software Foundation.
19488 + */
19490 +#include <linux/platform_device.h>
19491 +#include <linux/gpio.h>
19492 +#include <asm/mach-ath79/ath79.h>
19493 +#include <asm/mach-ath79/ar71xx_regs.h>
19494 +#include <asm/mach-ath79/ag71xx_platform.h>
19496 +#include "common.h"
19497 +#include "dev-eth.h"
19498 +#include "dev-gpio-buttons.h"
19499 +#include "dev-leds-gpio.h"
19500 +#include "dev-m25p80.h"
19501 +#include "dev-wmac.h"
19502 +#include "machtypes.h"
19504 +#define SMART_300_GPIO_LED_WLAN 13
19505 +#define SMART_300_GPIO_LED_WAN 18
19506 +#define SMART_300_GPIO_LED_LAN4 19
19507 +#define SMART_300_GPIO_LED_LAN3 12
19508 +#define SMART_300_GPIO_LED_LAN2 21
19509 +#define SMART_300_GPIO_LED_LAN1 20
19510 +#define SMART_300_GPIO_LED_SYSTEM 15
19511 +#define SMART_300_GPIO_LED_POWER 14
19513 +#define SMART_300_GPIO_BTN_RESET 17
19514 +#define SMART_300_GPIO_SW_RFKILL 16
19516 +#define SMART_300_KEYS_POLL_INTERVAL 20 /* msecs */
19517 +#define SMART_300_KEYS_DEBOUNCE_INTERVAL (3 * SMART_300_KEYS_POLL_INTERVAL)
19519 +#define SMART_300_GPIO_MASK 0x007fffff
19521 +static const char *smart_300_part_probes[] = {
19522 + "tp-link",
19523 + NULL,
19526 +static struct flash_platform_data smart_300_flash_data = {
19527 + .part_probes = smart_300_part_probes,
19530 +static struct gpio_led smart_300_leds_gpio[] __initdata = {
19532 + .name = "nc-link:green:lan1",
19533 + .gpio = SMART_300_GPIO_LED_LAN1,
19534 + .active_low = 1,
19535 + }, {
19536 + .name = "nc-link:green:lan2",
19537 + .gpio = SMART_300_GPIO_LED_LAN2,
19538 + .active_low = 1,
19539 + }, {
19540 + .name = "nc-link:green:lan3",
19541 + .gpio = SMART_300_GPIO_LED_LAN3,
19542 + .active_low = 1,
19543 + }, {
19544 + .name = "nc-link:green:lan4",
19545 + .gpio = SMART_300_GPIO_LED_LAN4,
19546 + .active_low = 1,
19547 + }, {
19548 + .name = "nc-link:green:system",
19549 + .gpio = SMART_300_GPIO_LED_SYSTEM,
19550 + .active_low = 1,
19551 + }, {
19552 + .name = "nc-link:green:wan",
19553 + .gpio = SMART_300_GPIO_LED_WAN,
19554 + .active_low = 1,
19555 + }, {
19556 + .name = "nc-link:green:wlan",
19557 + .gpio = SMART_300_GPIO_LED_WLAN,
19558 + .active_low = 1,
19559 + },
19562 +static struct gpio_keys_button smart_300_gpio_keys[] __initdata = {
19564 + .desc = "reset",
19565 + .type = EV_KEY,
19566 + .code = KEY_RESTART,
19567 + .debounce_interval = SMART_300_KEYS_DEBOUNCE_INTERVAL,
19568 + .gpio = SMART_300_GPIO_BTN_RESET,
19569 + .active_low = 1,
19573 +static void __init smart_300_setup(void)
19575 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
19576 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
19578 + ath79_register_leds_gpio(-1, ARRAY_SIZE(smart_300_leds_gpio),
19579 + smart_300_leds_gpio);
19581 + ath79_register_gpio_keys_polled(1, SMART_300_KEYS_POLL_INTERVAL,
19582 + ARRAY_SIZE(smart_300_gpio_keys),
19583 + smart_300_gpio_keys);
19585 + ath79_register_m25p80(&smart_300_flash_data);
19587 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
19589 + ath79_register_mdio(1, 0x0);
19591 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
19592 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
19594 + /* GMAC0 is connected to the PHY0 of the internal switch */
19595 + ath79_switch_data.phy4_mii_en = 1;
19596 + ath79_switch_data.phy_poll_mask = BIT(4);
19597 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
19598 + ath79_eth0_data.phy_mask = BIT(4);
19599 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
19600 + ath79_register_eth(0);
19602 + /* GMAC1 is connected to the internal switch */
19603 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
19604 + ath79_register_eth(1);
19606 + ath79_register_wmac(ee, mac);
19608 + gpio_request(SMART_300_GPIO_LED_POWER, "power");
19609 + gpio_direction_output(SMART_300_GPIO_LED_POWER, GPIOF_OUT_INIT_LOW);
19612 +MIPS_MACHINE(ATH79_MACH_SMART_300, "SMART-300", "NC-LINK SMART-300",
19613 + smart_300_setup);
19614 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tew-632brp.c linux-4.1.43/arch/mips/ath79/mach-tew-632brp.c
19615 --- linux-4.1.43.orig/arch/mips/ath79/mach-tew-632brp.c 1970-01-01 01:00:00.000000000 +0100
19616 +++ linux-4.1.43/arch/mips/ath79/mach-tew-632brp.c 2017-08-06 20:02:15.000000000 +0200
19617 @@ -0,0 +1,111 @@
19619 + * TrendNET TEW-632BRP board support
19621 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
19622 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
19624 + * This program is free software; you can redistribute it and/or modify it
19625 + * under the terms of the GNU General Public License version 2 as published
19626 + * by the Free Software Foundation.
19627 + */
19629 +#include <asm/mach-ath79/ath79.h>
19631 +#include "dev-eth.h"
19632 +#include "dev-gpio-buttons.h"
19633 +#include "dev-leds-gpio.h"
19634 +#include "dev-m25p80.h"
19635 +#include "dev-wmac.h"
19636 +#include "machtypes.h"
19637 +#include "nvram.h"
19639 +#define TEW_632BRP_GPIO_LED_STATUS 1
19640 +#define TEW_632BRP_GPIO_LED_WPS 3
19641 +#define TEW_632BRP_GPIO_LED_WLAN 6
19642 +#define TEW_632BRP_GPIO_BTN_WPS 12
19643 +#define TEW_632BRP_GPIO_BTN_RESET 21
19645 +#define TEW_632BRP_KEYS_POLL_INTERVAL 20 /* msecs */
19646 +#define TEW_632BRP_KEYS_DEBOUNCE_INTERVAL (3 * TEW_632BRP_KEYS_POLL_INTERVAL)
19648 +#define TEW_632BRP_CONFIG_ADDR 0x1f020000
19649 +#define TEW_632BRP_CONFIG_SIZE 0x10000
19651 +static struct gpio_led tew_632brp_leds_gpio[] __initdata = {
19653 + .name = "tew-632brp:green:status",
19654 + .gpio = TEW_632BRP_GPIO_LED_STATUS,
19655 + .active_low = 1,
19656 + }, {
19657 + .name = "tew-632brp:blue:wps",
19658 + .gpio = TEW_632BRP_GPIO_LED_WPS,
19659 + .active_low = 1,
19660 + }, {
19661 + .name = "tew-632brp:green:wlan",
19662 + .gpio = TEW_632BRP_GPIO_LED_WLAN,
19663 + .active_low = 1,
19667 +static struct gpio_keys_button tew_632brp_gpio_keys[] __initdata = {
19669 + .desc = "reset",
19670 + .type = EV_KEY,
19671 + .code = KEY_RESTART,
19672 + .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
19673 + .gpio = TEW_632BRP_GPIO_BTN_RESET,
19674 + .active_low = 1,
19675 + }, {
19676 + .desc = "wps",
19677 + .type = EV_KEY,
19678 + .code = KEY_WPS_BUTTON,
19679 + .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
19680 + .gpio = TEW_632BRP_GPIO_BTN_WPS,
19681 + .active_low = 1,
19685 +#define TEW_632BRP_LAN_PHYMASK BIT(0)
19686 +#define TEW_632BRP_WAN_PHYMASK BIT(4)
19687 +#define TEW_632BRP_MDIO_MASK (~(TEW_632BRP_LAN_PHYMASK | \
19688 + TEW_632BRP_WAN_PHYMASK))
19690 +static void __init tew_632brp_setup(void)
19692 + const char *config = (char *) KSEG1ADDR(TEW_632BRP_CONFIG_ADDR);
19693 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
19694 + u8 mac[6];
19695 + u8 *wlan_mac = NULL;
19697 + if (ath79_nvram_parse_mac_addr(config, TEW_632BRP_CONFIG_SIZE,
19698 + "lan_mac=", mac) == 0) {
19699 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
19700 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
19701 + wlan_mac = mac;
19704 + ath79_register_mdio(0, TEW_632BRP_MDIO_MASK);
19706 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
19707 + ath79_eth0_data.phy_mask = TEW_632BRP_LAN_PHYMASK;
19709 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
19710 + ath79_eth1_data.phy_mask = TEW_632BRP_WAN_PHYMASK;
19712 + ath79_register_eth(0);
19713 + ath79_register_eth(1);
19715 + ath79_register_m25p80(NULL);
19717 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_632brp_leds_gpio),
19718 + tew_632brp_leds_gpio);
19720 + ath79_register_gpio_keys_polled(-1, TEW_632BRP_KEYS_POLL_INTERVAL,
19721 + ARRAY_SIZE(tew_632brp_gpio_keys),
19722 + tew_632brp_gpio_keys);
19724 + ath79_register_wmac(eeprom, wlan_mac);
19727 +MIPS_MACHINE(ATH79_MACH_TEW_632BRP, "TEW-632BRP", "TRENDnet TEW-632BRP",
19728 + tew_632brp_setup);
19729 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tew-673gru.c linux-4.1.43/arch/mips/ath79/mach-tew-673gru.c
19730 --- linux-4.1.43.orig/arch/mips/ath79/mach-tew-673gru.c 1970-01-01 01:00:00.000000000 +0100
19731 +++ linux-4.1.43/arch/mips/ath79/mach-tew-673gru.c 2017-08-06 20:02:15.000000000 +0200
19732 @@ -0,0 +1,198 @@
19734 + * TRENDnet TEW-673GRU board support
19736 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
19738 + * This program is free software; you can redistribute it and/or modify it
19739 + * under the terms of the GNU General Public License version 2 as published
19740 + * by the Free Software Foundation.
19741 + */
19743 +#include <linux/platform_device.h>
19744 +#include <linux/delay.h>
19745 +#include <linux/rtl8366.h>
19746 +#include <linux/spi/spi.h>
19747 +#include <linux/spi/spi_gpio.h>
19749 +#include <asm/mach-ath79/ath79.h>
19751 +#include "dev-ap9x-pci.h"
19752 +#include "dev-eth.h"
19753 +#include "dev-gpio-buttons.h"
19754 +#include "dev-leds-gpio.h"
19755 +#include "dev-m25p80.h"
19756 +#include "dev-usb.h"
19757 +#include "machtypes.h"
19759 +#define TEW673GRU_GPIO_LCD_SCK 0
19760 +#define TEW673GRU_GPIO_LCD_MOSI 1
19761 +#define TEW673GRU_GPIO_LCD_MISO 2
19762 +#define TEW673GRU_GPIO_LCD_CS 6
19764 +#define TEW673GRU_GPIO_LED_WPS 9
19766 +#define TEW673GRU_GPIO_BTN_RESET 3
19767 +#define TEW673GRU_GPIO_BTN_WPS 8
19769 +#define TEW673GRU_GPIO_RTL8366_SDA 5
19770 +#define TEW673GRU_GPIO_RTL8366_SCK 7
19772 +#define TEW673GRU_KEYS_POLL_INTERVAL 20 /* msecs */
19773 +#define TEW673GRU_KEYS_DEBOUNCE_INTERVAL (3 * TEW673GRU_KEYS_POLL_INTERVAL)
19775 +#define TEW673GRU_CAL0_OFFSET 0x1000
19776 +#define TEW673GRU_CAL1_OFFSET 0x5000
19777 +#define TEW673GRU_MAC0_OFFSET 0xffa0
19778 +#define TEW673GRU_MAC1_OFFSET 0xffb4
19780 +#define TEW673GRU_CAL_LOCATION_0 0x1f660000
19781 +#define TEW673GRU_CAL_LOCATION_1 0x1f7f0000
19783 +static struct gpio_led tew673gru_leds_gpio[] __initdata = {
19785 + .name = "trendnet:blue:wps",
19786 + .gpio = TEW673GRU_GPIO_LED_WPS,
19787 + .active_low = 1,
19791 +static struct gpio_keys_button tew673gru_gpio_keys[] __initdata = {
19793 + .desc = "reset",
19794 + .type = EV_KEY,
19795 + .code = KEY_RESTART,
19796 + .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
19797 + .gpio = TEW673GRU_GPIO_BTN_RESET,
19798 + .active_low = 1,
19799 + }, {
19800 + .desc = "wps",
19801 + .type = EV_KEY,
19802 + .code = KEY_WPS_BUTTON,
19803 + .debounce_interval = TEW673GRU_KEYS_DEBOUNCE_INTERVAL,
19804 + .gpio = TEW673GRU_GPIO_BTN_WPS,
19805 + .active_low = 1,
19809 +static struct rtl8366_initval tew673gru_rtl8366s_initvals[] = {
19810 + { .reg = 0x06, .val = 0x0108 },
19813 +static struct rtl8366_platform_data tew673gru_rtl8366s_data = {
19814 + .gpio_sda = TEW673GRU_GPIO_RTL8366_SDA,
19815 + .gpio_sck = TEW673GRU_GPIO_RTL8366_SCK,
19816 + .num_initvals = ARRAY_SIZE(tew673gru_rtl8366s_initvals),
19817 + .initvals = tew673gru_rtl8366s_initvals,
19820 +static struct platform_device tew673gru_rtl8366s_device = {
19821 + .name = RTL8366S_DRIVER_NAME,
19822 + .id = -1,
19823 + .dev = {
19824 + .platform_data = &tew673gru_rtl8366s_data,
19828 +static struct spi_board_info tew673gru_spi_info[] = {
19830 + .bus_num = 1,
19831 + .chip_select = 0,
19832 + .max_speed_hz = 400000,
19833 + .modalias = "spidev",
19834 + .mode = SPI_MODE_2,
19835 + .controller_data = (void *) TEW673GRU_GPIO_LCD_CS,
19836 + },
19839 +static struct spi_gpio_platform_data tew673gru_spi_data = {
19840 + .sck = TEW673GRU_GPIO_LCD_SCK,
19841 + .miso = TEW673GRU_GPIO_LCD_MISO,
19842 + .mosi = TEW673GRU_GPIO_LCD_MOSI,
19843 + .num_chipselect = 1,
19846 +static struct platform_device tew673gru_spi_device = {
19847 + .name = "spi_gpio",
19848 + .id = 1,
19849 + .dev = {
19850 + .platform_data = &tew673gru_spi_data,
19851 + },
19854 +static bool __init tew673gru_is_caldata_valid(u8 *p)
19856 + u16 *magic0, *magic1;
19858 + magic0 = (u16 *)(p + TEW673GRU_CAL0_OFFSET);
19859 + magic1 = (u16 *)(p + TEW673GRU_CAL1_OFFSET);
19861 + return (*magic0 == 0xa55a && *magic1 == 0xa55a);
19864 +static void __init tew673gru_wlan_init(void)
19866 + u8 mac1[ETH_ALEN], mac2[ETH_ALEN];
19867 + u8 *caldata;
19869 + caldata = (u8 *) KSEG1ADDR(TEW673GRU_CAL_LOCATION_0);
19870 + if (!tew673gru_is_caldata_valid(caldata)) {
19871 + caldata = (u8 *)KSEG1ADDR(TEW673GRU_CAL_LOCATION_1);
19872 + if (!tew673gru_is_caldata_valid(caldata)) {
19873 + pr_err("no calibration data found\n");
19874 + return;
19878 + ath79_parse_ascii_mac(caldata + TEW673GRU_MAC0_OFFSET, mac1);
19879 + ath79_parse_ascii_mac(caldata + TEW673GRU_MAC1_OFFSET, mac2);
19881 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 2);
19882 + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 3);
19884 + ap9x_pci_setup_wmac_led_pin(0, 5);
19885 + ap9x_pci_setup_wmac_led_pin(1, 5);
19887 + ap94_pci_init(caldata + TEW673GRU_CAL0_OFFSET, mac1,
19888 + caldata + TEW673GRU_CAL1_OFFSET, mac2);
19891 +static void __init tew673gru_setup(void)
19893 + tew673gru_wlan_init();
19895 + ath79_register_mdio(0, 0x0);
19897 + ath79_eth0_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
19898 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
19899 + ath79_eth0_data.speed = SPEED_1000;
19900 + ath79_eth0_data.duplex = DUPLEX_FULL;
19901 + ath79_eth0_pll_data.pll_1000 = 0x11110000;
19903 + ath79_eth1_data.mii_bus_dev = &tew673gru_rtl8366s_device.dev;
19904 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
19905 + ath79_eth1_data.phy_mask = 0x10;
19906 + ath79_eth1_pll_data.pll_1000 = 0x11110000;
19908 + ath79_register_eth(0);
19909 + ath79_register_eth(1);
19911 + ath79_register_m25p80(NULL);
19913 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew673gru_leds_gpio),
19914 + tew673gru_leds_gpio);
19916 + ath79_register_gpio_keys_polled(-1, TEW673GRU_KEYS_POLL_INTERVAL,
19917 + ARRAY_SIZE(tew673gru_gpio_keys),
19918 + tew673gru_gpio_keys);
19920 + ath79_register_usb();
19922 + platform_device_register(&tew673gru_rtl8366s_device);
19924 + spi_register_board_info(tew673gru_spi_info,
19925 + ARRAY_SIZE(tew673gru_spi_info));
19926 + platform_device_register(&tew673gru_spi_device);
19929 +MIPS_MACHINE(ATH79_MACH_TEW_673GRU, "TEW-673GRU", "TRENDnet TEW-673GRU",
19930 + tew673gru_setup);
19931 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tew-712br.c linux-4.1.43/arch/mips/ath79/mach-tew-712br.c
19932 --- linux-4.1.43.orig/arch/mips/ath79/mach-tew-712br.c 1970-01-01 01:00:00.000000000 +0100
19933 +++ linux-4.1.43/arch/mips/ath79/mach-tew-712br.c 2017-08-06 20:02:15.000000000 +0200
19934 @@ -0,0 +1,153 @@
19936 + * TRENDnet TEW-712BR board support
19938 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
19940 + * This program is free software; you can redistribute it and/or modify it
19941 + * under the terms of the GNU General Public License version 2 as published
19942 + * by the Free Software Foundation.
19943 + */
19945 +#include <linux/gpio.h>
19947 +#include <asm/mach-ath79/ath79.h>
19948 +#include <asm/mach-ath79/ar71xx_regs.h>
19950 +#include "common.h"
19951 +#include "dev-eth.h"
19952 +#include "dev-gpio-buttons.h"
19953 +#include "dev-leds-gpio.h"
19954 +#include "dev-m25p80.h"
19955 +#include "dev-wmac.h"
19956 +#include "machtypes.h"
19958 +#define TEW_712BR_GPIO_BTN_WPS 11
19959 +#define TEW_712BR_GPIO_BTN_RESET 12
19961 +#define TEW_712BR_GPIO_LED_LAN1 13
19962 +#define TEW_712BR_GPIO_LED_LAN2 14
19963 +#define TEW_712BR_GPIO_LED_LAN3 15
19964 +#define TEW_712BR_GPIO_LED_LAN4 16
19965 +#define TEW_712BR_GPIO_LED_POWER_GREEN 20
19966 +#define TEW_712BR_GPIO_LED_POWER_ORANGE 27
19967 +#define TEW_712BR_GPIO_LED_WAN_GREEN 17
19968 +#define TEW_712BR_GPIO_LED_WAN_ORANGE 23
19969 +#define TEW_712BR_GPIO_LED_WLAN 0
19970 +#define TEW_712BR_GPIO_LED_WPS 26
19972 +#define TEW_712BR_GPIO_WAN_LED_ENABLE 1
19974 +#define TEW_712BR_KEYS_POLL_INTERVAL 20 /* msecs */
19975 +#define TEW_712BR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_712BR_KEYS_POLL_INTERVAL)
19977 +#define TEW_712BR_ART_ADDRESS 0x1f010000
19978 +#define TEW_712BR_CALDATA_OFFSET 0x1000
19980 +#define TEW_712BR_MAC_PART_ADDRESS 0x1f020000
19981 +#define TEW_712BR_LAN_MAC_OFFSET 0x04
19982 +#define TEW_712BR_WAN_MAC_OFFSET 0x16
19984 +static struct gpio_led tew_712br_leds_gpio[] __initdata = {
19986 + .name = "trendnet:green:lan1",
19987 + .gpio = TEW_712BR_GPIO_LED_LAN1,
19988 + .active_low = 0,
19989 + }, {
19990 + .name = "trendnet:green:lan2",
19991 + .gpio = TEW_712BR_GPIO_LED_LAN2,
19992 + .active_low = 0,
19993 + }, {
19994 + .name = "trendnet:green:lan3",
19995 + .gpio = TEW_712BR_GPIO_LED_LAN3,
19996 + .active_low = 0,
19997 + }, {
19998 + .name = "trendnet:green:lan4",
19999 + .gpio = TEW_712BR_GPIO_LED_LAN4,
20000 + .active_low = 0,
20001 + }, {
20002 + .name = "trendnet:blue:wps",
20003 + .gpio = TEW_712BR_GPIO_LED_WPS,
20004 + .active_low = 1,
20005 + }, {
20006 + .name = "trendnet:green:power",
20007 + .gpio = TEW_712BR_GPIO_LED_POWER_GREEN,
20008 + .active_low = 0,
20009 + }, {
20010 + .name = "trendnet:orange:power",
20011 + .gpio = TEW_712BR_GPIO_LED_POWER_ORANGE,
20012 + .active_low = 0,
20013 + }, {
20014 + .name = "trendnet:green:wan",
20015 + .gpio = TEW_712BR_GPIO_LED_WAN_GREEN,
20016 + .active_low = 1,
20017 + }, {
20018 + .name = "trendnet:orange:wan",
20019 + .gpio = TEW_712BR_GPIO_LED_WAN_ORANGE,
20020 + .active_low = 0,
20021 + }, {
20022 + .name = "trendnet:green:wlan",
20023 + .gpio = TEW_712BR_GPIO_LED_WLAN,
20024 + .active_low = 0,
20025 + },
20028 +static struct gpio_keys_button tew_712br_gpio_keys[] __initdata = {
20030 + .desc = "Reset button",
20031 + .type = EV_KEY,
20032 + .code = KEY_RESTART,
20033 + .debounce_interval = TEW_712BR_KEYS_DEBOUNCE_INTERVAL,
20034 + .gpio = TEW_712BR_GPIO_BTN_RESET,
20035 + .active_low = 1,
20036 + }, {
20037 + .desc = "WPS button",
20038 + .type = EV_KEY,
20039 + .code = KEY_WPS_BUTTON,
20040 + .debounce_interval = TEW_712BR_KEYS_DEBOUNCE_INTERVAL,
20041 + .gpio = TEW_712BR_GPIO_BTN_WPS,
20042 + .active_low = 1,
20046 +static void __init tew_712br_setup(void)
20048 + u8 *art = (u8 *) KSEG1ADDR(TEW_712BR_ART_ADDRESS);
20049 + u8 *mac = (u8 *) KSEG1ADDR(TEW_712BR_MAC_PART_ADDRESS);
20050 + u8 lan_mac[ETH_ALEN];
20051 + u8 wan_mac[ETH_ALEN];
20053 + ath79_setup_ar933x_phy4_switch(false, false);
20055 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
20056 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
20057 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
20058 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
20059 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
20061 + gpio_request_one(TEW_712BR_GPIO_WAN_LED_ENABLE,
20062 + GPIOF_OUT_INIT_LOW, "WAN LED enable");
20064 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_712br_leds_gpio),
20065 + tew_712br_leds_gpio);
20067 + ath79_register_gpio_keys_polled(1, TEW_712BR_KEYS_POLL_INTERVAL,
20068 + ARRAY_SIZE(tew_712br_gpio_keys),
20069 + tew_712br_gpio_keys);
20071 + ath79_register_m25p80(NULL);
20073 + ath79_parse_ascii_mac(mac + TEW_712BR_LAN_MAC_OFFSET, lan_mac);
20074 + ath79_parse_ascii_mac(mac + TEW_712BR_WAN_MAC_OFFSET, wan_mac);
20076 + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
20077 + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
20079 + ath79_register_mdio(0, 0x0);
20080 + ath79_register_eth(1);
20081 + ath79_register_eth(0);
20083 + ath79_register_wmac(art + TEW_712BR_CALDATA_OFFSET, wan_mac);
20086 +MIPS_MACHINE(ATH79_MACH_TEW_712BR, "TEW-712BR",
20087 + "TRENDnet TEW-712BR", tew_712br_setup);
20088 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tew-732br.c linux-4.1.43/arch/mips/ath79/mach-tew-732br.c
20089 --- linux-4.1.43.orig/arch/mips/ath79/mach-tew-732br.c 1970-01-01 01:00:00.000000000 +0100
20090 +++ linux-4.1.43/arch/mips/ath79/mach-tew-732br.c 2017-08-06 20:02:15.000000000 +0200
20091 @@ -0,0 +1,127 @@
20093 + * TRENDnet TEW-732BR board support
20095 + * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
20097 + * This program is free software; you can redistribute it and/or modify it
20098 + * under the terms of the GNU General Public License version 2 as published
20099 + * by the Free Software Foundation.
20100 + */
20102 +#include <linux/gpio.h>
20103 +#include <linux/platform_device.h>
20105 +#include <asm/mach-ath79/ath79.h>
20106 +#include <asm/mach-ath79/ar71xx_regs.h>
20108 +#include "common.h"
20109 +#include "dev-eth.h"
20110 +#include "dev-gpio-buttons.h"
20111 +#include "dev-leds-gpio.h"
20112 +#include "dev-m25p80.h"
20113 +#include "dev-wmac.h"
20114 +#include "machtypes.h"
20116 +#define TEW_732BR_GPIO_BTN_WPS 16
20117 +#define TEW_732BR_GPIO_BTN_RESET 17
20119 +#define TEW_732BR_GPIO_LED_POWER_GREEN 4
20120 +#define TEW_732BR_GPIO_LED_POWER_AMBER 14
20121 +#define TEW_732BR_GPIO_LED_PLANET_GREEN 12
20122 +#define TEW_732BR_GPIO_LED_PLANET_AMBER 22
20124 +#define TEW_732BR_KEYS_POLL_INTERVAL 20 /* msecs */
20125 +#define TEW_732BR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_732BR_KEYS_POLL_INTERVAL)
20127 +#define TEW_732BR_ART_ADDRESS 0x1fff0000
20128 +#define TEW_732BR_CALDATA_OFFSET 0x1000
20129 +#define TEW_732BR_LAN_MAC_OFFSET 0xffa0
20130 +#define TEW_732BR_WAN_MAC_OFFSET 0xffb4
20132 +static struct gpio_led tew_732br_leds_gpio[] __initdata = {
20134 + .name = "trendnet:green:power",
20135 + .gpio = TEW_732BR_GPIO_LED_POWER_GREEN,
20136 + .active_low = 0,
20137 + },
20139 + .name = "trendnet:amber:power",
20140 + .gpio = TEW_732BR_GPIO_LED_POWER_AMBER,
20141 + .active_low = 0,
20142 + },
20144 + .name = "trendnet:green:wan",
20145 + .gpio = TEW_732BR_GPIO_LED_PLANET_GREEN,
20146 + .active_low = 1,
20147 + },
20149 + .name = "trendnet:amber:wan",
20150 + .gpio = TEW_732BR_GPIO_LED_PLANET_AMBER,
20151 + .active_low = 0,
20152 + },
20155 +static struct gpio_keys_button tew_732br_gpio_keys[] __initdata = {
20157 + .desc = "Reset button",
20158 + .type = EV_KEY,
20159 + .code = KEY_RESTART,
20160 + .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
20161 + .gpio = TEW_732BR_GPIO_BTN_RESET,
20162 + .active_low = 1,
20163 + },
20165 + .desc = "WPS button",
20166 + .type = EV_KEY,
20167 + .code = KEY_WPS_BUTTON,
20168 + .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
20169 + .gpio = TEW_732BR_GPIO_BTN_WPS,
20170 + .active_low = 1,
20171 + },
20174 +static void __init tew_732br_setup(void)
20176 + u8 *art = (u8 *) KSEG1ADDR(TEW_732BR_ART_ADDRESS);
20177 + u8 lan_mac[ETH_ALEN];
20178 + u8 wan_mac[ETH_ALEN];
20180 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_732br_leds_gpio),
20181 + tew_732br_leds_gpio);
20183 + ath79_register_gpio_keys_polled(1, TEW_732BR_KEYS_POLL_INTERVAL,
20184 + ARRAY_SIZE(tew_732br_gpio_keys),
20185 + tew_732br_gpio_keys);
20187 + ath79_register_m25p80(NULL);
20189 + ath79_parse_ascii_mac(art + TEW_732BR_LAN_MAC_OFFSET, lan_mac);
20190 + ath79_parse_ascii_mac(art + TEW_732BR_WAN_MAC_OFFSET, wan_mac);
20192 + ath79_register_wmac(art + TEW_732BR_CALDATA_OFFSET, lan_mac);
20194 + ath79_register_mdio(1, 0x0);
20196 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
20198 + /* LAN: GMAC1 is connected to the internal switch */
20199 + ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
20200 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
20202 + ath79_register_eth(1);
20204 + /* WAN: GMAC0 is connected to the PHY4 of the internal switch */
20205 + ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
20207 + ath79_switch_data.phy4_mii_en = 1;
20208 + ath79_switch_data.phy_poll_mask = BIT(4);
20210 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
20211 + ath79_eth0_data.phy_mask = BIT(4);
20212 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
20214 + ath79_register_eth(0);
20217 +MIPS_MACHINE(ATH79_MACH_TEW_732BR, "TEW-732BR", "TRENDnet TEW-732BR",
20218 + tew_732br_setup);
20219 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr11u.c linux-4.1.43/arch/mips/ath79/mach-tl-mr11u.c
20220 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr11u.c 1970-01-01 01:00:00.000000000 +0100
20221 +++ linux-4.1.43/arch/mips/ath79/mach-tl-mr11u.c 2017-08-06 20:02:15.000000000 +0200
20222 @@ -0,0 +1,183 @@
20224 + * TP-LINK TL-MR11U/TL-MR3040 board support
20226 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
20227 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
20229 + * This program is free software; you can redistribute it and/or modify it
20230 + * under the terms of the GNU General Public License version 2 as published
20231 + * by the Free Software Foundation.
20232 + */
20234 +#include <linux/gpio.h>
20236 +#include <asm/mach-ath79/ath79.h>
20237 +#include <asm/mach-ath79/ar71xx_regs.h>
20239 +#include "common.h"
20240 +#include "dev-eth.h"
20241 +#include "dev-gpio-buttons.h"
20242 +#include "dev-leds-gpio.h"
20243 +#include "dev-m25p80.h"
20244 +#include "dev-usb.h"
20245 +#include "dev-wmac.h"
20246 +#include "machtypes.h"
20248 +#define TL_MR11U_GPIO_LED_3G 27
20249 +#define TL_MR11U_GPIO_LED_WLAN 26
20250 +#define TL_MR11U_GPIO_LED_LAN 17
20252 +#define TL_MR11U_GPIO_BTN_WPS 20
20253 +#define TL_MR11U_GPIO_BTN_RESET 11
20255 +#define TL_MR11U_GPIO_USB_POWER 8
20256 +#define TL_MR3040_GPIO_USB_POWER 18
20258 +#define TL_MR3040_V2_GPIO_BTN_SW1 19
20259 +#define TL_MR3040_V2_GPIO_BTN_SW2 20
20261 +#define TL_MR11U_KEYS_POLL_INTERVAL 20 /* msecs */
20262 +#define TL_MR11U_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR11U_KEYS_POLL_INTERVAL)
20264 +static const char *tl_mr11u_part_probes[] = {
20265 + "tp-link",
20266 + NULL,
20269 +static struct flash_platform_data tl_mr11u_flash_data = {
20270 + .part_probes = tl_mr11u_part_probes,
20273 +static struct gpio_led tl_mr11u_leds_gpio[] __initdata = {
20275 + .name = "tp-link:green:3g",
20276 + .gpio = TL_MR11U_GPIO_LED_3G,
20277 + .active_low = 1,
20278 + },
20280 + .name = "tp-link:green:wlan",
20281 + .gpio = TL_MR11U_GPIO_LED_WLAN,
20282 + .active_low = 1,
20283 + },
20285 + .name = "tp-link:green:lan",
20286 + .gpio = TL_MR11U_GPIO_LED_LAN,
20287 + .active_low = 1,
20291 +static struct gpio_keys_button tl_mr11u_gpio_keys[] __initdata = {
20293 + .desc = "reset",
20294 + .type = EV_KEY,
20295 + .code = KEY_RESTART,
20296 + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
20297 + .gpio = TL_MR11U_GPIO_BTN_RESET,
20298 + .active_low = 0,
20299 + },
20301 + .desc = "wps",
20302 + .type = EV_KEY,
20303 + .code = KEY_WPS_BUTTON,
20304 + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
20305 + .gpio = TL_MR11U_GPIO_BTN_WPS,
20306 + .active_low = 0,
20307 + },
20310 +static struct gpio_keys_button tl_mr3040_v2_gpio_keys[] __initdata = {
20312 + .desc = "reset",
20313 + .type = EV_KEY,
20314 + .code = KEY_RESTART,
20315 + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
20316 + .gpio = TL_MR11U_GPIO_BTN_RESET,
20317 + .active_low = 0,
20318 + },
20320 + .desc = "sw1",
20321 + .type = EV_SW,
20322 + .code = BTN_0,
20323 + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
20324 + .gpio = TL_MR3040_V2_GPIO_BTN_SW1,
20325 + .active_low = 0,
20326 + },
20328 + .desc = "sw2",
20329 + .type = EV_SW,
20330 + .code = BTN_1,
20331 + .debounce_interval = TL_MR11U_KEYS_DEBOUNCE_INTERVAL,
20332 + .gpio = TL_MR3040_V2_GPIO_BTN_SW2,
20333 + .active_low = 0,
20337 +static void __init common_setup(void)
20339 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
20340 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
20342 + /* Disable hardware control LAN1 and LAN2 LEDs, enabling GPIO14 and GPIO15 */
20343 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
20344 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN);
20346 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
20347 + ath79_setup_ar933x_phy4_switch(false, false);
20349 + ath79_register_m25p80(&tl_mr11u_flash_data);
20350 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr11u_leds_gpio),
20351 + tl_mr11u_leds_gpio);
20353 + ath79_register_usb();
20355 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
20357 + ath79_register_mdio(0, 0x0);
20358 + ath79_register_eth(0);
20360 + ath79_register_wmac(ee, mac);
20363 +static void __init tl_mr11u_setup(void)
20365 + common_setup();
20367 + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
20368 + ARRAY_SIZE(tl_mr11u_gpio_keys),
20369 + tl_mr11u_gpio_keys);
20370 + gpio_request_one(TL_MR11U_GPIO_USB_POWER,
20371 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20372 + "USB power");
20375 +MIPS_MACHINE(ATH79_MACH_TL_MR11U, "TL-MR11U", "TP-LINK TL-MR11U",
20376 + tl_mr11u_setup);
20378 +static void __init tl_mr3040_setup(void)
20380 + common_setup();
20382 + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
20383 + 1, tl_mr11u_gpio_keys);
20384 + gpio_request_one(TL_MR3040_GPIO_USB_POWER,
20385 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20386 + "USB power");
20389 +MIPS_MACHINE(ATH79_MACH_TL_MR3040, "TL-MR3040", "TP-LINK TL-MR3040",
20390 + tl_mr3040_setup);
20392 +static void __init tl_mr3040_v2_setup(void)
20394 + common_setup();
20396 + ath79_register_gpio_keys_polled(-1, TL_MR11U_KEYS_POLL_INTERVAL,
20397 + ARRAY_SIZE(tl_mr3040_v2_gpio_keys),
20398 + tl_mr3040_v2_gpio_keys);
20399 + gpio_request_one(TL_MR3040_GPIO_USB_POWER,
20400 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20401 + "USB power");
20404 +MIPS_MACHINE(ATH79_MACH_TL_MR3040_V2, "TL-MR3040-v2", "TP-LINK TL-MR3040 v2",
20405 + tl_mr3040_v2_setup);
20406 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr13u.c linux-4.1.43/arch/mips/ath79/mach-tl-mr13u.c
20407 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr13u.c 1970-01-01 01:00:00.000000000 +0100
20408 +++ linux-4.1.43/arch/mips/ath79/mach-tl-mr13u.c 2017-08-06 20:02:15.000000000 +0200
20409 @@ -0,0 +1,107 @@
20411 + * TP-LINK TL-MR13U board support
20413 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
20414 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
20416 + * This program is free software; you can redistribute it and/or modify it
20417 + * under the terms of the GNU General Public License version 2 as published
20418 + * by the Free Software Foundation.
20419 + */
20421 +#include <linux/gpio.h>
20423 +#include <asm/mach-ath79/ath79.h>
20425 +#include "dev-eth.h"
20426 +#include "dev-gpio-buttons.h"
20427 +#include "dev-leds-gpio.h"
20428 +#include "dev-m25p80.h"
20429 +#include "dev-usb.h"
20430 +#include "dev-wmac.h"
20431 +#include "machtypes.h"
20433 +#define TL_MR13U_GPIO_LED_SYSTEM 27
20435 +#define TL_MR13U_GPIO_BTN_RESET 11
20436 +#define TL_MR13U_GPIO_BTN_SW1 6
20437 +#define TL_MR13U_GPIO_BTN_SW2 7
20439 +#define TL_MR13U_GPIO_USB_POWER 18
20441 +#define TL_MR13U_KEYS_POLL_INTERVAL 20 /* msecs */
20442 +#define TL_MR13U_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR13U_KEYS_POLL_INTERVAL)
20444 +static const char *tl_mr13u_part_probes[] = {
20445 + "tp-link",
20446 + NULL,
20449 +static struct flash_platform_data tl_mr13u_flash_data = {
20450 + .part_probes = tl_mr13u_part_probes,
20453 +static struct gpio_led tl_mr13u_leds_gpio[] __initdata = {
20455 + .name = "tp-link:blue:system",
20456 + .gpio = TL_MR13U_GPIO_LED_SYSTEM,
20457 + .active_low = 0,
20458 + },
20461 +static struct gpio_keys_button tl_mr13u_gpio_keys[] __initdata = {
20463 + .desc = "reset",
20464 + .type = EV_KEY,
20465 + .code = KEY_RESTART,
20466 + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
20467 + .gpio = TL_MR13U_GPIO_BTN_RESET,
20468 + .active_low = 0,
20469 + },
20471 + .desc = "sw1",
20472 + .type = EV_KEY,
20473 + .code = BTN_0,
20474 + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
20475 + .gpio = TL_MR13U_GPIO_BTN_SW1,
20476 + .active_low = 0,
20477 + },
20479 + .desc = "sw2",
20480 + .type = EV_KEY,
20481 + .code = BTN_1,
20482 + .debounce_interval = TL_MR13U_KEYS_DEBOUNCE_INTERVAL,
20483 + .gpio = TL_MR13U_GPIO_BTN_SW2,
20484 + .active_low = 0,
20485 + },
20488 +static void __init tl_mr13u_setup(void)
20490 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
20491 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
20493 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
20494 + ath79_setup_ar933x_phy4_switch(false, false);
20496 + ath79_register_m25p80(&tl_mr13u_flash_data);
20497 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr13u_leds_gpio),
20498 + tl_mr13u_leds_gpio);
20499 + ath79_register_gpio_keys_polled(-1, TL_MR13U_KEYS_POLL_INTERVAL,
20500 + ARRAY_SIZE(tl_mr13u_gpio_keys),
20501 + tl_mr13u_gpio_keys);
20503 + gpio_request_one(TL_MR13U_GPIO_USB_POWER,
20504 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20505 + "USB power");
20506 + ath79_register_usb();
20508 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
20510 + ath79_register_mdio(0, 0x0);
20511 + ath79_register_eth(0);
20512 + ath79_register_wmac(ee, mac);
20515 +MIPS_MACHINE(ATH79_MACH_TL_MR13U, "TL-MR13U", "TP-LINK TL-MR13U v1",
20516 + tl_mr13u_setup);
20517 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr3020.c linux-4.1.43/arch/mips/ath79/mach-tl-mr3020.c
20518 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr3020.c 1970-01-01 01:00:00.000000000 +0100
20519 +++ linux-4.1.43/arch/mips/ath79/mach-tl-mr3020.c 2017-08-06 20:02:15.000000000 +0200
20520 @@ -0,0 +1,126 @@
20522 + * TP-LINK TL-MR3020 board support
20524 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
20525 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
20527 + * This program is free software; you can redistribute it and/or modify it
20528 + * under the terms of the GNU General Public License version 2 as published
20529 + * by the Free Software Foundation.
20530 + */
20532 +#include <linux/gpio.h>
20534 +#include <asm/mach-ath79/ath79.h>
20535 +#include <asm/mach-ath79/ar71xx_regs.h>
20537 +#include "dev-eth.h"
20538 +#include "dev-gpio-buttons.h"
20539 +#include "dev-leds-gpio.h"
20540 +#include "dev-m25p80.h"
20541 +#include "dev-usb.h"
20542 +#include "dev-wmac.h"
20543 +#include "machtypes.h"
20545 +#define TL_MR3020_GPIO_LED_3G 27
20546 +#define TL_MR3020_GPIO_LED_WLAN 0
20547 +#define TL_MR3020_GPIO_LED_LAN 17
20548 +#define TL_MR3020_GPIO_LED_WPS 26
20550 +#define TL_MR3020_GPIO_BTN_WPS 11
20551 +#define TL_MR3020_GPIO_BTN_SW1 18
20552 +#define TL_MR3020_GPIO_BTN_SW2 20
20554 +#define TL_MR3020_GPIO_USB_POWER 8
20556 +#define TL_MR3020_KEYS_POLL_INTERVAL 20 /* msecs */
20557 +#define TL_MR3020_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3020_KEYS_POLL_INTERVAL)
20559 +static const char *tl_mr3020_part_probes[] = {
20560 + "tp-link",
20561 + NULL,
20564 +static struct flash_platform_data tl_mr3020_flash_data = {
20565 + .part_probes = tl_mr3020_part_probes,
20568 +static struct gpio_led tl_mr3020_leds_gpio[] __initdata = {
20570 + .name = "tp-link:green:3g",
20571 + .gpio = TL_MR3020_GPIO_LED_3G,
20572 + .active_low = 1,
20573 + },
20575 + .name = "tp-link:green:wlan",
20576 + .gpio = TL_MR3020_GPIO_LED_WLAN,
20577 + .active_low = 0,
20578 + },
20580 + .name = "tp-link:green:lan",
20581 + .gpio = TL_MR3020_GPIO_LED_LAN,
20582 + .active_low = 1,
20583 + },
20585 + .name = "tp-link:green:wps",
20586 + .gpio = TL_MR3020_GPIO_LED_WPS,
20587 + .active_low = 1,
20588 + },
20591 +static struct gpio_keys_button tl_mr3020_gpio_keys[] __initdata = {
20593 + .desc = "wps",
20594 + .type = EV_KEY,
20595 + .code = KEY_WPS_BUTTON,
20596 + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
20597 + .gpio = TL_MR3020_GPIO_BTN_WPS,
20598 + .active_low = 0,
20599 + },
20601 + .desc = "sw1",
20602 + .type = EV_KEY,
20603 + .code = BTN_0,
20604 + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
20605 + .gpio = TL_MR3020_GPIO_BTN_SW1,
20606 + .active_low = 0,
20607 + },
20609 + .desc = "sw2",
20610 + .type = EV_KEY,
20611 + .code = BTN_1,
20612 + .debounce_interval = TL_MR3020_KEYS_DEBOUNCE_INTERVAL,
20613 + .gpio = TL_MR3020_GPIO_BTN_SW2,
20614 + .active_low = 0,
20618 +static void __init tl_mr3020_setup(void)
20620 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
20621 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
20623 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
20624 + ath79_setup_ar933x_phy4_switch(false, false);
20626 + ath79_register_m25p80(&tl_mr3020_flash_data);
20627 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3020_leds_gpio),
20628 + tl_mr3020_leds_gpio);
20629 + ath79_register_gpio_keys_polled(-1, TL_MR3020_KEYS_POLL_INTERVAL,
20630 + ARRAY_SIZE(tl_mr3020_gpio_keys),
20631 + tl_mr3020_gpio_keys);
20633 + gpio_request_one(TL_MR3020_GPIO_USB_POWER,
20634 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20635 + "USB power");
20636 + ath79_register_usb();
20638 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
20640 + ath79_register_mdio(0, 0x0);
20641 + ath79_register_eth(0);
20642 + ath79_register_wmac(ee, mac);
20645 +MIPS_MACHINE(ATH79_MACH_TL_MR3020, "TL-MR3020", "TP-LINK TL-MR3020",
20646 + tl_mr3020_setup);
20647 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr3x20.c linux-4.1.43/arch/mips/ath79/mach-tl-mr3x20.c
20648 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-mr3x20.c 1970-01-01 01:00:00.000000000 +0100
20649 +++ linux-4.1.43/arch/mips/ath79/mach-tl-mr3x20.c 2017-08-06 20:02:15.000000000 +0200
20650 @@ -0,0 +1,147 @@
20652 + * TP-LINK TL-MR3220/3420 board support
20654 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
20656 + * This program is free software; you can redistribute it and/or modify it
20657 + * under the terms of the GNU General Public License version 2 as published
20658 + * by the Free Software Foundation.
20659 + */
20661 +#include <linux/gpio.h>
20663 +#include <asm/mach-ath79/ath79.h>
20665 +#include "dev-eth.h"
20666 +#include "dev-ap9x-pci.h"
20667 +#include "dev-gpio-buttons.h"
20668 +#include "dev-leds-gpio.h"
20669 +#include "dev-m25p80.h"
20670 +#include "dev-usb.h"
20671 +#include "machtypes.h"
20673 +#define TL_MR3X20_GPIO_LED_QSS 0
20674 +#define TL_MR3X20_GPIO_LED_SYSTEM 1
20675 +#define TL_MR3X20_GPIO_LED_3G 8
20677 +#define TL_MR3X20_GPIO_BTN_RESET 11
20678 +#define TL_MR3X20_GPIO_BTN_QSS 12
20680 +#define TL_MR3X20_GPIO_USB_POWER 6
20682 +#define TL_MR3X20_KEYS_POLL_INTERVAL 20 /* msecs */
20683 +#define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
20685 +static const char *tl_mr3x20_part_probes[] = {
20686 + "tp-link",
20687 + NULL,
20690 +static struct flash_platform_data tl_mr3x20_flash_data = {
20691 + .part_probes = tl_mr3x20_part_probes,
20694 +static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
20696 + .name = "tp-link:green:system",
20697 + .gpio = TL_MR3X20_GPIO_LED_SYSTEM,
20698 + .active_low = 1,
20699 + }, {
20700 + .name = "tp-link:green:qss",
20701 + .gpio = TL_MR3X20_GPIO_LED_QSS,
20702 + .active_low = 1,
20703 + }, {
20704 + .name = "tp-link:green:3g",
20705 + .gpio = TL_MR3X20_GPIO_LED_3G,
20706 + .active_low = 1,
20710 +static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
20712 + .desc = "reset",
20713 + .type = EV_KEY,
20714 + .code = KEY_RESTART,
20715 + .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
20716 + .gpio = TL_MR3X20_GPIO_BTN_RESET,
20717 + .active_low = 1,
20718 + }, {
20719 + .desc = "qss",
20720 + .type = EV_KEY,
20721 + .code = KEY_WPS_BUTTON,
20722 + .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
20723 + .gpio = TL_MR3X20_GPIO_BTN_QSS,
20724 + .active_low = 1,
20728 +static void __init tl_ap99_setup(void)
20730 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
20731 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
20733 + ath79_register_m25p80(&tl_mr3x20_flash_data);
20735 + ath79_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
20736 + ARRAY_SIZE(tl_mr3x20_gpio_keys),
20737 + tl_mr3x20_gpio_keys);
20739 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
20740 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
20742 + ath79_register_mdio(0, 0x0);
20744 + /* LAN ports */
20745 + ath79_register_eth(1);
20746 + /* WAN port */
20747 + ath79_register_eth(0);
20749 + ap91_pci_init(ee, mac);
20752 +static void __init tl_mr3x20_usb_setup(void)
20754 + /* enable power for the USB port */
20755 + gpio_request_one(TL_MR3X20_GPIO_USB_POWER,
20756 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20757 + "USB power");
20758 + ath79_register_usb();
20761 +static void __init tl_mr3220_setup(void)
20763 + tl_ap99_setup();
20765 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
20766 + tl_mr3x20_leds_gpio);
20767 + ap9x_pci_setup_wmac_led_pin(0, 1);
20768 + tl_mr3x20_usb_setup();
20771 +MIPS_MACHINE(ATH79_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
20772 + tl_mr3220_setup);
20774 +static void __init tl_mr3420_setup(void)
20776 + tl_ap99_setup();
20778 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
20779 + tl_mr3x20_leds_gpio);
20780 + ap9x_pci_setup_wmac_led_pin(0, 0);
20781 + tl_mr3x20_usb_setup();
20784 +MIPS_MACHINE(ATH79_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",
20785 + tl_mr3420_setup);
20787 +static void __init tl_wr841n_v7_setup(void)
20789 + tl_ap99_setup();
20791 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio) - 1,
20792 + tl_mr3x20_leds_gpio);
20793 + ap9x_pci_setup_wmac_led_pin(0, 0);
20796 +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V7, "TL-WR841N-v7",
20797 + "TP-LINK TL-WR841N/ND v7", tl_wr841n_v7_setup);
20798 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa701nd-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wa701nd-v2.c
20799 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa701nd-v2.c 1970-01-01 01:00:00.000000000 +0100
20800 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wa701nd-v2.c 2017-08-06 20:02:15.000000000 +0200
20801 @@ -0,0 +1,116 @@
20803 + * TP-LINK TL-WA701ND v2 board support
20805 + * Copyright (C) 2015 Luigi Tarenga <luigi.tarenga@gmail.com>
20807 + * This program is free software; you can redistribute it and/or modify it
20808 + * under the terms of the GNU General Public License version 2 as published
20809 + * by the Free Software Foundation.
20810 + */
20812 +#include <linux/gpio.h>
20814 +#include <asm/mach-ath79/ath79.h>
20816 +#include "dev-eth.h"
20817 +#include "dev-gpio-buttons.h"
20818 +#include "dev-leds-gpio.h"
20819 +#include "dev-m25p80.h"
20820 +#include "dev-usb.h"
20821 +#include "dev-wmac.h"
20822 +#include "machtypes.h"
20824 +#define TL_WA701NDV2_GPIO_LED_WLAN 0
20825 +#define TL_WA701NDV2_GPIO_LED_QSS 1
20826 +#define TL_WA701NDV2_GPIO_LED_LAN 17
20827 +#define TL_WA701NDV2_GPIO_LED_SYSTEM 27
20829 +#define TL_WA701NDV2_GPIO_BTN_RESET 11
20830 +#define TL_WA701NDV2_GPIO_BTN_QSS 26
20832 +#define TL_WA701NDV2_GPIO_USB_POWER 8
20834 +#define TL_WA701NDV2_KEYS_POLL_INTERVAL 20 /* msecs */
20835 +#define TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA701NDV2_KEYS_POLL_INTERVAL)
20837 +static const char *tl_wa701ndv2_part_probes[] = {
20838 + "tp-link",
20839 + NULL,
20842 +static struct flash_platform_data tl_wa701ndv2_flash_data = {
20843 + .part_probes = tl_wa701ndv2_part_probes,
20846 +static struct gpio_led tl_wa701ndv2_leds_gpio[] __initdata = {
20848 + .name = "tp-link:green:wlan",
20849 + .gpio = TL_WA701NDV2_GPIO_LED_WLAN,
20850 + .active_low = 0,
20851 + }, {
20852 + .name = "tp-link:green:qss",
20853 + .gpio = TL_WA701NDV2_GPIO_LED_QSS,
20854 + .active_low = 0,
20855 + }, {
20856 + .name = "tp-link:green:lan",
20857 + .gpio = TL_WA701NDV2_GPIO_LED_LAN,
20858 + .active_low = 1,
20859 + }, {
20860 + .name = "tp-link:green:system",
20861 + .gpio = TL_WA701NDV2_GPIO_LED_SYSTEM,
20862 + .active_low = 1,
20866 +static struct gpio_keys_button tl_wa701ndv2_gpio_keys[] __initdata = {
20868 + .desc = "reset",
20869 + .type = EV_KEY,
20870 + .code = KEY_RESTART,
20871 + .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
20872 + .gpio = TL_WA701NDV2_GPIO_BTN_RESET,
20873 + .active_low = 0,
20874 + } , {
20875 + .desc = "qss",
20876 + .type = EV_KEY,
20877 + .code = KEY_WPS_BUTTON,
20878 + .debounce_interval = TL_WA701NDV2_KEYS_DEBOUNCE_INTERVAL,
20879 + .gpio = TL_WA701NDV2_GPIO_BTN_QSS,
20880 + .active_low = 0,
20885 +static void __init tl_wa701ndv2_setup(void)
20887 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
20888 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
20890 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
20891 + ath79_setup_ar933x_phy4_switch(false, false);
20893 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa701ndv2_leds_gpio),
20894 + tl_wa701ndv2_leds_gpio);
20896 + ath79_register_gpio_keys_polled(-1, TL_WA701NDV2_KEYS_POLL_INTERVAL,
20897 + ARRAY_SIZE(tl_wa701ndv2_gpio_keys),
20898 + tl_wa701ndv2_gpio_keys);
20900 + gpio_request_one(TL_WA701NDV2_GPIO_USB_POWER,
20901 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
20902 + "USB power");
20903 + ath79_register_usb();
20905 + ath79_register_m25p80(&tl_wa701ndv2_flash_data);
20906 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
20907 + /* ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); */
20909 + ath79_register_mdio(0, 0x0);
20910 + ath79_register_eth(0);
20911 + ath79_register_eth(1);
20913 + ath79_register_wmac(ee, mac);
20916 +MIPS_MACHINE(ATH79_MACH_TL_WA701ND_V2, "TL-WA701ND-v2",
20917 + "TP-LINK TL-WA701ND v2", tl_wa701ndv2_setup);
20918 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa7210n-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wa7210n-v2.c
20919 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa7210n-v2.c 1970-01-01 01:00:00.000000000 +0100
20920 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wa7210n-v2.c 2017-08-06 20:02:15.000000000 +0200
20921 @@ -0,0 +1,125 @@
20923 + * TP-LINK TL-WA7210N v2.1 board support
20925 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
20926 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
20927 + * Copyright (C) 2014 Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
20928 + * Copyright (C) 2014 Alexander List <alex@graz.funkfeuer.at>
20929 + * Copyright (C) 2015 Hendrik Frenzel <hfrenzel@scunc.net>
20931 + * rebased on TL-WA7510Nv1 support,
20932 + * Copyright (C) 2012 Stefan Helmert <helst_listen@aol.de>
20934 + * This program is free software; you can redistribute it and/or modify it
20935 + * under the terms of the GNU General Public License version 2 as published
20936 + * by the Free Software Foundation.
20937 + */
20939 +#include <linux/mtd/mtd.h>
20940 +#include <linux/mtd/partitions.h>
20941 +#include <linux/platform_device.h>
20942 +#include <linux/gpio.h>
20944 +#include <asm/mach-ath79/ar71xx_regs.h>
20945 +#include <asm/mach-ath79/ath79.h>
20947 +#include "dev-dsa.h"
20948 +#include "dev-eth.h"
20949 +#include "dev-gpio-buttons.h"
20950 +#include "dev-leds-gpio.h"
20951 +#include "dev-m25p80.h"
20952 +#include "dev-wmac.h"
20953 +#include "machtypes.h"
20954 +#include "pci.h"
20956 +#include "common.h"
20958 +#define TL_WA7210N_V2_GPIO_BTN_RESET 11
20959 +#define TL_WA7210N_V2_KEYS_POLL_INT 20
20960 +#define TL_WA7210N_V2_KEYS_DEBOUNCE_INT (3 * TL_WA7210N_V2_KEYS_POLL_INT)
20962 +#define TL_WA7210N_V2_GPIO_LED_LAN 17
20963 +#define TL_WA7210N_V2_GPIO_LED_SIG1 0
20964 +#define TL_WA7210N_V2_GPIO_LED_SIG2 1
20965 +#define TL_WA7210N_V2_GPIO_LED_SIG3 27
20966 +#define TL_WA7210N_V2_GPIO_LED_SIG4 26
20968 +#define TL_WA7210N_V2_GPIO_LNA_EN 28
20970 +static const char *tl_wa7210n_v2_part_probes[] = {
20971 + "tp-link",
20972 + NULL,
20975 +static struct gpio_keys_button tl_wa7210n_v2_gpio_keys[] __initdata = {
20977 + .desc = "reset",
20978 + .type = EV_KEY,
20979 + .code = KEY_RESTART,
20980 + .debounce_interval = TL_WA7210N_V2_KEYS_DEBOUNCE_INT,
20981 + .gpio = TL_WA7210N_V2_GPIO_BTN_RESET,
20982 + .active_low = 0,
20983 + },
20986 +static struct gpio_led tl_wa7210n_v2_leds_gpio[] __initdata = {
20988 + .name = "tp-link:green:lan",
20989 + .gpio = TL_WA7210N_V2_GPIO_LED_LAN,
20990 + .active_low = 1,
20991 + }, {
20992 + .name = "tp-link:green:signal1",
20993 + .gpio = TL_WA7210N_V2_GPIO_LED_SIG1,
20994 + .active_low = 0,
20995 + }, {
20996 + .name = "tp-link:green:signal2",
20997 + .gpio = TL_WA7210N_V2_GPIO_LED_SIG2,
20998 + .active_low = 0,
20999 + }, {
21000 + .name = "tp-link:green:signal3",
21001 + .gpio = TL_WA7210N_V2_GPIO_LED_SIG3,
21002 + .active_low = 1,
21003 + }, {
21004 + .name = "tp-link:green:signal4",
21005 + .gpio = TL_WA7210N_V2_GPIO_LED_SIG4,
21006 + .active_low = 1,
21007 + },
21010 +static struct flash_platform_data tl_wa7210n_v2_flash_data = {
21011 + .part_probes = tl_wa7210n_v2_part_probes,
21014 +static void __init tl_wa7210n_v2_setup(void)
21016 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21017 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
21019 + ath79_register_gpio_keys_polled(-1, TL_WA7210N_V2_KEYS_POLL_INT,
21020 + ARRAY_SIZE(tl_wa7210n_v2_gpio_keys),
21021 + tl_wa7210n_v2_gpio_keys);
21023 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa7210n_v2_leds_gpio),
21024 + tl_wa7210n_v2_leds_gpio);
21026 + ath79_gpio_function_enable(TL_WA7210N_V2_GPIO_LNA_EN);
21028 + ath79_setup_ar933x_phy4_switch(false, false);
21030 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
21031 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
21033 + ath79_register_eth(0);
21034 + ath79_register_eth(1);
21036 + ath79_register_mdio(0, 0x0);
21038 + ath79_register_wmac(ee, mac);
21040 + ath79_register_m25p80(&tl_wa7210n_v2_flash_data);
21042 + ath79_register_pci();
21045 +MIPS_MACHINE(ATH79_MACH_TL_WA7210N_V2, "TL-WA7210N-v2", "TP-LINK TL-WA7210N v2",
21046 + tl_wa7210n_v2_setup);
21047 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa830re-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wa830re-v2.c
21048 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa830re-v2.c 1970-01-01 01:00:00.000000000 +0100
21049 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wa830re-v2.c 2017-08-06 20:02:15.000000000 +0200
21050 @@ -0,0 +1,132 @@
21052 + * TP-LINK TL-WA830RE v2 board support
21054 + * Copyright (C) 2014 Fredrik Jonson <fredrik@famjonson.se>
21056 + * This program is free software; you can redistribute it and/or modify it
21057 + * under the terms of the GNU General Public License version 2 as published
21058 + * by the Free Software Foundation.
21059 + */
21061 +#include <linux/gpio.h>
21062 +#include <linux/platform_device.h>
21064 +#include <asm/mach-ath79/ath79.h>
21065 +#include <asm/mach-ath79/ar71xx_regs.h>
21067 +#include "common.h"
21068 +#include "dev-eth.h"
21069 +#include "dev-gpio-buttons.h"
21070 +#include "dev-leds-gpio.h"
21071 +#include "dev-m25p80.h"
21072 +#include "dev-usb.h"
21073 +#include "dev-wmac.h"
21074 +#include "machtypes.h"
21076 +#define TL_WA830REV2_GPIO_LED_WLAN 13
21077 +#define TL_WA830REV2_GPIO_LED_QSS 15
21078 +#define TL_WA830REV2_GPIO_LED_LAN 18
21079 +#define TL_WA830REV2_GPIO_LED_SYSTEM 14
21081 +#define TL_WA830REV2_GPIO_BTN_RESET 17
21082 +#define TL_WA830REV2_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
21084 +#define TL_WA830REV2_GPIO_USB_POWER 4
21086 +#define TL_WA830REV2_KEYS_POLL_INTERVAL 20 /* msecs */
21087 +#define TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA830REV2_KEYS_POLL_INTERVAL)
21089 +static const char *tl_wa830re_v2_part_probes[] = {
21090 + "tp-link",
21091 + NULL,
21094 +static struct flash_platform_data tl_wa830re_v2_flash_data = {
21095 + .part_probes = tl_wa830re_v2_part_probes,
21098 +static struct gpio_led tl_wa830re_v2_leds_gpio[] __initdata = {
21100 + .name = "tp-link:green:qss",
21101 + .gpio = TL_WA830REV2_GPIO_LED_QSS,
21102 + .active_low = 1,
21103 + }, {
21104 + .name = "tp-link:green:system",
21105 + .gpio = TL_WA830REV2_GPIO_LED_SYSTEM,
21106 + .active_low = 1,
21107 + }, {
21108 + .name = "tp-link:green:lan",
21109 + .gpio = TL_WA830REV2_GPIO_LED_LAN,
21110 + .active_low = 1,
21111 + }, {
21112 + .name = "tp-link:green:wlan",
21113 + .gpio = TL_WA830REV2_GPIO_LED_WLAN,
21114 + .active_low = 1,
21115 + },
21118 +static struct gpio_keys_button tl_wa830re_v2_gpio_keys[] __initdata = {
21120 + .desc = "Reset button",
21121 + .type = EV_KEY,
21122 + .code = KEY_RESTART,
21123 + .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
21124 + .gpio = TL_WA830REV2_GPIO_BTN_RESET,
21125 + .active_low = 1,
21126 + }, {
21127 + .desc = "RFKILL switch",
21128 + .type = EV_SW,
21129 + .code = KEY_RFKILL,
21130 + .debounce_interval = TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL,
21131 + .gpio = TL_WA830REV2_GPIO_SW_RFKILL,
21132 + .active_low = 0,
21136 +static void __init tl_ap123_setup(void)
21138 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21139 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
21141 + /* Disable JTAG, enabling GPIOs 0-3 */
21142 + /* Configure OBS4 line, for GPIO 4*/
21143 + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
21144 + AR934X_GPIO_FUNC_CLK_OBS4_EN);
21146 + /* config gpio4 as normal gpio function */
21147 + ath79_gpio_output_select(TL_WA830REV2_GPIO_USB_POWER,
21148 + AR934X_GPIO_OUT_GPIO);
21150 + ath79_register_m25p80(&tl_wa830re_v2_flash_data);
21152 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
21154 + ath79_register_mdio(1, 0x0);
21156 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
21158 + /* GMAC0 is connected to the PHY0 of the internal switch */
21159 + ath79_switch_data.phy4_mii_en = 1;
21160 + ath79_switch_data.phy_poll_mask = BIT(0);
21161 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
21162 + ath79_eth0_data.phy_mask = BIT(0);
21163 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
21164 + ath79_register_eth(0);
21166 + ath79_register_wmac(ee, mac);
21169 +static void __init tl_wa830re_v2_setup(void)
21171 + tl_ap123_setup();
21173 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa830re_v2_leds_gpio) - 1,
21174 + tl_wa830re_v2_leds_gpio);
21176 + ath79_register_gpio_keys_polled(1, TL_WA830REV2_KEYS_POLL_INTERVAL,
21177 + ARRAY_SIZE(tl_wa830re_v2_gpio_keys),
21178 + tl_wa830re_v2_gpio_keys);
21181 +MIPS_MACHINE(ATH79_MACH_TL_WA830RE_V2, "TL-WA830RE-v2", "TP-LINK TL-WA830RE v2",
21182 + tl_wa830re_v2_setup);
21183 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa901nd-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wa901nd-v2.c
21184 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa901nd-v2.c 1970-01-01 01:00:00.000000000 +0100
21185 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wa901nd-v2.c 2017-08-06 20:02:15.000000000 +0200
21186 @@ -0,0 +1,104 @@
21188 + * TP-LINK TL-WA901N/ND v2 board support
21190 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
21191 + * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
21192 + * Copyright (C) 2011 Jonathan Bennett <jbscience87@gmail.com>
21194 + * This program is free software; you can redistribute it and/or modify it
21195 + * under the terms of the GNU General Public License version 2 as published
21196 + * by the Free Software Foundation.
21197 + */
21199 +#include <asm/mach-ath79/ath79.h>
21200 +#include <asm/mach-ath79/ar71xx_regs.h>
21202 +#include "dev-eth.h"
21203 +#include "dev-m25p80.h"
21204 +#include "dev-gpio-buttons.h"
21205 +#include "dev-leds-gpio.h"
21206 +#include "dev-wmac.h"
21207 +#include "machtypes.h"
21209 +#define TL_WA901ND_V2_GPIO_LED_QSS 4
21210 +#define TL_WA901ND_V2_GPIO_LED_SYSTEM 2
21211 +#define TL_WA901ND_V2_GPIO_LED_WLAN 9
21213 +#define TL_WA901ND_V2_GPIO_BTN_RESET 3
21214 +#define TL_WA901ND_V2_GPIO_BTN_QSS 7
21216 +#define TL_WA901ND_V2_KEYS_POLL_INTERVAL 20 /* msecs */
21217 +#define TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL \
21218 + (3 * TL_WA901ND_V2_KEYS_POLL_INTERVAL)
21220 +static const char *tl_wa901nd_v2_part_probes[] = {
21221 + "tp-link",
21222 + NULL,
21225 +static struct flash_platform_data tl_wa901nd_v2_flash_data = {
21226 + .part_probes = tl_wa901nd_v2_part_probes,
21229 +static struct gpio_led tl_wa901nd_v2_leds_gpio[] __initdata = {
21231 + .name = "tp-link:green:system",
21232 + .gpio = TL_WA901ND_V2_GPIO_LED_SYSTEM,
21233 + .active_low = 1,
21234 + }, {
21235 + .name = "tp-link:green:qss",
21236 + .gpio = TL_WA901ND_V2_GPIO_LED_QSS,
21237 + }, {
21238 + .name = "tp-link:green:wlan",
21239 + .gpio = TL_WA901ND_V2_GPIO_LED_WLAN,
21240 + .active_low = 1,
21244 +static struct gpio_keys_button tl_wa901nd_v2_gpio_keys[] __initdata = {
21246 + .desc = "reset",
21247 + .type = EV_KEY,
21248 + .code = KEY_RESTART,
21249 + .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
21250 + .gpio = TL_WA901ND_V2_GPIO_BTN_RESET,
21251 + .active_low = 1,
21252 + }, {
21253 + .desc = "qss",
21254 + .type = EV_KEY,
21255 + .code = KEY_WPS_BUTTON,
21256 + .debounce_interval = TL_WA901ND_V2_KEYS_DEBOUNCE_INTERVAL,
21257 + .gpio = TL_WA901ND_V2_GPIO_BTN_QSS,
21258 + .active_low = 1,
21262 +static void __init tl_wa901nd_v2_setup(void)
21264 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21265 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
21267 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
21269 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
21270 + ath79_eth0_data.phy_mask = 0x00001000;
21271 + ath79_register_mdio(0, 0x0);
21273 + ath79_eth0_data.reset_bit = AR71XX_RESET_GE0_MAC |
21274 + AR71XX_RESET_GE0_PHY;
21275 + ath79_register_eth(0);
21277 + ath79_register_m25p80(&tl_wa901nd_v2_flash_data);
21279 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_v2_leds_gpio),
21280 + tl_wa901nd_v2_leds_gpio);
21282 + ath79_register_gpio_keys_polled(-1, TL_WA901ND_V2_KEYS_POLL_INTERVAL,
21283 + ARRAY_SIZE(tl_wa901nd_v2_gpio_keys),
21284 + tl_wa901nd_v2_gpio_keys);
21286 + ath79_register_wmac(eeprom, mac);
21289 +MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V2, "TL-WA901ND-v2",
21290 + "TP-LINK TL-WA901ND v2", tl_wa901nd_v2_setup);
21291 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa901nd.c linux-4.1.43/arch/mips/ath79/mach-tl-wa901nd.c
21292 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wa901nd.c 1970-01-01 01:00:00.000000000 +0100
21293 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wa901nd.c 2017-08-06 20:02:15.000000000 +0200
21294 @@ -0,0 +1,127 @@
21296 + * TP-LINK TL-WA901N/ND v1, TL-WA7510N v1 board support
21298 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
21299 + * Copyright (C) 2010 Pieter Hollants <pieter@hollants.com>
21300 + * Copyright (C) 2012 Stefan Helmert <helst_listen@aol.de>
21302 + * This program is free software; you can redistribute it and/or modify it
21303 + * under the terms of the GNU General Public License version 2 as published
21304 + * by the Free Software Foundation.
21305 + */
21307 +#include <asm/mach-ath79/ar71xx_regs.h>
21308 +#include <asm/mach-ath79/ath79.h>
21310 +#include "common.h"
21311 +#include "dev-ap9x-pci.h"
21312 +#include "dev-eth.h"
21313 +#include "dev-gpio-buttons.h"
21314 +#include "dev-leds-gpio.h"
21315 +#include "dev-m25p80.h"
21316 +#include "machtypes.h"
21317 +#include "pci.h"
21319 +#define TL_WA901ND_GPIO_LED_QSS 0
21320 +#define TL_WA901ND_GPIO_LED_SYSTEM 1
21321 +#define TL_WA901ND_GPIO_LED_LAN 13
21323 +#define TL_WA901ND_GPIO_BTN_RESET 11
21324 +#define TL_WA901ND_GPIO_BTN_QSS 12
21326 +#define TL_WA901ND_KEYS_POLL_INTERVAL 20 /* msecs */
21327 +#define TL_WA901ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA901ND_KEYS_POLL_INTERVAL)
21329 +static const char *tl_wa901nd_part_probes[] = {
21330 + "tp-link",
21331 + NULL,
21334 +static struct flash_platform_data tl_wa901nd_flash_data = {
21335 + .part_probes = tl_wa901nd_part_probes,
21338 +static struct gpio_led tl_wa901nd_leds_gpio[] __initdata = {
21340 + .name = "tp-link:green:lan",
21341 + .gpio = TL_WA901ND_GPIO_LED_LAN,
21342 + .active_low = 1,
21343 + }, {
21344 + .name = "tp-link:green:system",
21345 + .gpio = TL_WA901ND_GPIO_LED_SYSTEM,
21346 + .active_low = 1,
21347 + }, {
21348 + .name = "tp-link:green:qss",
21349 + .gpio = TL_WA901ND_GPIO_LED_QSS,
21350 + .active_low = 1,
21354 +static struct gpio_keys_button tl_wa901nd_gpio_keys[] __initdata = {
21356 + .desc = "reset",
21357 + .type = EV_KEY,
21358 + .code = KEY_RESTART,
21359 + .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
21360 + .gpio = TL_WA901ND_GPIO_BTN_RESET,
21361 + .active_low = 1,
21362 + }, {
21363 + .desc = "qss",
21364 + .type = EV_KEY,
21365 + .code = KEY_WPS_BUTTON,
21366 + .debounce_interval = TL_WA901ND_KEYS_DEBOUNCE_INTERVAL,
21367 + .gpio = TL_WA901ND_GPIO_BTN_QSS,
21368 + .active_low = 1,
21372 +static void __init common_setup(void)
21374 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21376 + /*
21377 + * ath79_eth0 would be the WAN port, but is not connected.
21378 + * ath79_eth1 connects to the internal switch chip, however
21379 + * we have a single LAN port only.
21380 + */
21381 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
21382 + ath79_register_mdio(0, 0x0);
21383 + ath79_register_eth(1);
21385 + ath79_register_m25p80(&tl_wa901nd_flash_data);
21388 +static void __init tl_wa901nd_setup(void)
21390 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21391 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
21393 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
21394 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
21395 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
21396 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
21397 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
21399 + common_setup();
21401 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa901nd_leds_gpio),
21402 + tl_wa901nd_leds_gpio);
21404 + ath79_register_gpio_keys_polled(-1, TL_WA901ND_KEYS_POLL_INTERVAL,
21405 + ARRAY_SIZE(tl_wa901nd_gpio_keys),
21406 + tl_wa901nd_gpio_keys);
21408 + ap91_pci_init(ee, mac);
21411 +MIPS_MACHINE(ATH79_MACH_TL_WA901ND, "TL-WA901ND", "TP-LINK TL-WA901ND",
21412 + tl_wa901nd_setup);
21414 +static void __init tl_wa7510n_v1_setup(void)
21416 + common_setup();
21417 + ath79_register_pci();
21420 +MIPS_MACHINE(ATH79_MACH_TL_WA7510N_V1, "TL-WA7510N", "TP-LINK TL-WA7510N v1",
21421 + tl_wa7510n_v1_setup);
21422 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wax50re.c linux-4.1.43/arch/mips/ath79/mach-tl-wax50re.c
21423 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wax50re.c 1970-01-01 01:00:00.000000000 +0100
21424 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wax50re.c 2017-08-06 20:02:15.000000000 +0200
21425 @@ -0,0 +1,313 @@
21427 + * TP-LINK TL-WA750RE v1/TL-WA801ND v2/TL-WA850RE v1/TL-WA901ND v3
21428 + * board support
21430 + * Copyright (C) 2013 Martijn Zilverschoon <thefriedzombie@gmail.com>
21431 + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
21433 + * This program is free software; you can redistribute it and/or modify it
21434 + * under the terms of the GNU General Public License version 2 as published
21435 + * by the Free Software Foundation.
21436 + */
21438 +#include <linux/gpio.h>
21439 +#include <linux/platform_device.h>
21441 +#include <asm/mach-ath79/ath79.h>
21442 +#include <asm/mach-ath79/ar71xx_regs.h>
21444 +#include "common.h"
21445 +#include "dev-eth.h"
21446 +#include "dev-gpio-buttons.h"
21447 +#include "dev-leds-gpio.h"
21448 +#include "dev-m25p80.h"
21449 +#include "dev-wmac.h"
21450 +#include "machtypes.h"
21452 +#define TL_WAX50RE_GPIO_LED_LAN 20
21453 +#define TL_WAX50RE_GPIO_LED_WLAN 13
21454 +#define TL_WAX50RE_GPIO_LED_RE 15
21455 +#define TL_WAX50RE_GPIO_LED_SIGNAL1 0
21456 +#define TL_WAX50RE_GPIO_LED_SIGNAL2 1
21457 +#define TL_WAX50RE_GPIO_LED_SIGNAL3 2
21458 +#define TL_WAX50RE_GPIO_LED_SIGNAL4 3
21459 +#define TL_WAX50RE_GPIO_LED_SIGNAL5 4
21461 +#define TL_WA860RE_GPIO_LED_WLAN_ORANGE 0
21462 +#define TL_WA860RE_GPIO_LED_WLAN_GREEN 2
21463 +#define TL_WA860RE_GPIO_LED_POWER_ORANGE 12
21464 +#define TL_WA860RE_GPIO_LED_POWER_GREEN 14
21465 +#define TL_WA860RE_GPIO_LED_LAN 20
21467 +#define TL_WA801ND_V2_GPIO_LED_LAN 18
21468 +#define TL_WA801ND_V2_GPIO_LED_SYSTEM 14
21470 +#define TL_WAX50RE_GPIO_BTN_RESET 17
21471 +#define TL_WAX50RE_GPIO_BTN_WPS 16
21473 +#define TL_WA860RE_GPIO_BTN_RESET 17
21474 +#define TL_WA860RE_GPIO_BTN_WPS 16
21475 +#define TL_WA860RE_GPIO_BTN_ONOFF 11
21477 +#define TL_WAX50RE_KEYS_POLL_INTERVAL 20 /* msecs */
21478 +#define TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL (3 * TL_WAX50RE_KEYS_POLL_INTERVAL)
21480 +static const char *tl_wax50re_part_probes[] = {
21481 + "tp-link",
21482 + NULL,
21485 +static struct flash_platform_data tl_wax50re_flash_data = {
21486 + .part_probes = tl_wax50re_part_probes,
21489 +static struct gpio_led tl_wa750re_leds_gpio[] __initdata = {
21491 + .name = "tp-link:orange:lan",
21492 + .gpio = TL_WAX50RE_GPIO_LED_LAN,
21493 + .active_low = 1,
21494 + }, {
21495 + .name = "tp-link:orange:wlan",
21496 + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
21497 + .active_low = 1,
21498 + }, {
21499 + .name = "tp-link:orange:re",
21500 + .gpio = TL_WAX50RE_GPIO_LED_RE,
21501 + .active_low = 1,
21502 + }, {
21503 + .name = "tp-link:orange:signal1",
21504 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
21505 + .active_low = 1,
21506 + }, {
21507 + .name = "tp-link:orange:signal2",
21508 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
21509 + .active_low = 1,
21510 + }, {
21511 + .name = "tp-link:orange:signal3",
21512 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
21513 + .active_low = 1,
21514 + }, {
21515 + .name = "tp-link:orange:signal4",
21516 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
21517 + .active_low = 1,
21518 + }, {
21519 + .name = "tp-link:orange:signal5",
21520 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
21521 + .active_low = 1,
21522 + },
21525 +static struct gpio_led tl_wa850re_leds_gpio[] __initdata = {
21527 + .name = "tp-link:blue:lan",
21528 + .gpio = TL_WAX50RE_GPIO_LED_LAN,
21529 + .active_low = 1,
21530 + }, {
21531 + .name = "tp-link:blue:wlan",
21532 + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
21533 + .active_low = 1,
21534 + }, {
21535 + .name = "tp-link:blue:re",
21536 + .gpio = TL_WAX50RE_GPIO_LED_RE,
21537 + .active_low = 1,
21538 + }, {
21539 + .name = "tp-link:blue:signal1",
21540 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL1,
21541 + .active_low = 1,
21542 + }, {
21543 + .name = "tp-link:blue:signal2",
21544 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL2,
21545 + .active_low = 1,
21546 + }, {
21547 + .name = "tp-link:blue:signal3",
21548 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL3,
21549 + .active_low = 1,
21550 + }, {
21551 + .name = "tp-link:blue:signal4",
21552 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL4,
21553 + .active_low = 1,
21554 + }, {
21555 + .name = "tp-link:blue:signal5",
21556 + .gpio = TL_WAX50RE_GPIO_LED_SIGNAL5,
21557 + .active_low = 1,
21558 + },
21561 +static struct gpio_led tl_wa860re_leds_gpio[] __initdata = {
21563 + .name = "tp-link:green:lan",
21564 + .gpio = TL_WA860RE_GPIO_LED_LAN,
21565 + .active_low = 1,
21566 + }, {
21567 + .name = "tp-link:green:power",
21568 + .gpio = TL_WA860RE_GPIO_LED_POWER_GREEN,
21569 + .active_low = 1,
21570 + }, {
21571 + .name = "tp-link:orange:power",
21572 + .gpio = TL_WA860RE_GPIO_LED_POWER_ORANGE,
21573 + .active_low = 1,
21574 + }, {
21575 + .name = "tp-link:green:wlan",
21576 + .gpio = TL_WA860RE_GPIO_LED_WLAN_GREEN,
21577 + .active_low = 1,
21578 + }, {
21579 + .name = "tp-link:orange:wlan",
21580 + .gpio = TL_WA860RE_GPIO_LED_WLAN_ORANGE,
21581 + .active_low = 1,
21582 + },
21586 +static struct gpio_keys_button tl_wax50re_gpio_keys[] __initdata = {
21588 + .desc = "Reset button",
21589 + .type = EV_KEY,
21590 + .code = KEY_RESTART,
21591 + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
21592 + .gpio = TL_WAX50RE_GPIO_BTN_RESET,
21593 + .active_low = 1,
21594 + }, {
21595 + .desc = "WPS",
21596 + .type = EV_KEY,
21597 + .code = KEY_WPS_BUTTON,
21598 + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
21599 + .gpio = TL_WAX50RE_GPIO_BTN_WPS,
21600 + .active_low = 1,
21601 + },
21604 +static struct gpio_keys_button tl_wa860re_gpio_keys[] __initdata = {
21606 + .desc = "Reset button",
21607 + .type = EV_KEY,
21608 + .code = KEY_RESTART,
21609 + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
21610 + .gpio = TL_WA860RE_GPIO_BTN_RESET,
21611 + .active_low = 1,
21612 + }, {
21613 + .desc = "WPS",
21614 + .type = EV_KEY,
21615 + .code = KEY_WPS_BUTTON,
21616 + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
21617 + .gpio = TL_WA860RE_GPIO_BTN_WPS,
21618 + .active_low = 1,
21619 + }, {
21620 + .desc = "ONOFF",
21621 + .type = EV_KEY,
21622 + .code = BTN_1,
21623 + .debounce_interval = TL_WAX50RE_KEYS_DEBOUNCE_INTERVAL,
21624 + .gpio = TL_WA860RE_GPIO_BTN_ONOFF,
21625 + .active_low = 1,
21626 + },
21629 +static struct gpio_led tl_wa801nd_v2_leds_gpio[] __initdata = {
21631 + .name = "tp-link:green:lan",
21632 + .gpio = TL_WA801ND_V2_GPIO_LED_LAN,
21633 + .active_low = 1,
21634 + }, {
21635 + .name = "tp-link:green:wlan",
21636 + .gpio = TL_WAX50RE_GPIO_LED_WLAN,
21637 + .active_low = 1,
21638 + }, {
21639 + .name = "tp-link:green:qss",
21640 + .gpio = TL_WAX50RE_GPIO_LED_RE,
21641 + .active_low = 1,
21642 + }, {
21643 + .name = "tp-link:green:system",
21644 + .gpio = TL_WA801ND_V2_GPIO_LED_SYSTEM,
21645 + .active_low = 1,
21646 + },
21649 +static void __init tl_ap123_setup(void)
21651 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21652 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
21654 + ath79_register_m25p80(&tl_wax50re_flash_data);
21656 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
21658 + ath79_register_mdio(1, 0x0);
21660 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
21662 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
21663 + ath79_eth0_data.phy_mask = BIT(0);
21664 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
21665 + ath79_register_eth(0);
21667 + ath79_register_wmac(ee, mac);
21670 +static void __init tl_wa750re_setup(void)
21672 + tl_ap123_setup();
21673 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa750re_leds_gpio),
21674 + tl_wa750re_leds_gpio);
21676 + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
21677 + ARRAY_SIZE(tl_wax50re_gpio_keys),
21678 + tl_wax50re_gpio_keys);
21681 +MIPS_MACHINE(ATH79_MACH_TL_WA750RE, "TL-WA750RE", "TP-LINK TL-WA750RE",
21682 + tl_wa750re_setup);
21684 +static void __init tl_wa801nd_v2_setup(void)
21686 + tl_ap123_setup();
21687 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
21688 + tl_wa801nd_v2_leds_gpio);
21690 + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
21691 + ARRAY_SIZE(tl_wax50re_gpio_keys),
21692 + tl_wax50re_gpio_keys);
21695 +MIPS_MACHINE(ATH79_MACH_TL_WA801ND_V2, "TL-WA801ND-v2", "TP-LINK TL-WA801ND v2",
21696 + tl_wa801nd_v2_setup);
21698 +static void __init tl_wa850re_setup(void)
21700 + tl_ap123_setup();
21701 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa850re_leds_gpio),
21702 + tl_wa850re_leds_gpio);
21704 + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
21705 + ARRAY_SIZE(tl_wax50re_gpio_keys),
21706 + tl_wax50re_gpio_keys);
21709 +MIPS_MACHINE(ATH79_MACH_TL_WA850RE, "TL-WA850RE", "TP-LINK TL-WA850RE",
21710 + tl_wa850re_setup);
21712 +static void __init tl_wa860re_setup(void)
21714 + tl_ap123_setup();
21715 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa860re_leds_gpio),
21716 + tl_wa860re_leds_gpio);
21718 + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
21719 + ARRAY_SIZE(tl_wa860re_gpio_keys),
21720 + tl_wa860re_gpio_keys);
21723 +MIPS_MACHINE(ATH79_MACH_TL_WA860RE, "TL-WA860RE", "TP-LINK TL-WA860RE",
21724 + tl_wa860re_setup);
21726 +static void __init tl_wa901nd_v3_setup(void)
21728 + tl_ap123_setup();
21729 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa801nd_v2_leds_gpio),
21730 + tl_wa801nd_v2_leds_gpio);
21732 + ath79_register_gpio_keys_polled(-1, TL_WAX50RE_KEYS_POLL_INTERVAL,
21733 + ARRAY_SIZE(tl_wax50re_gpio_keys) - 1,
21734 + tl_wax50re_gpio_keys);
21737 +MIPS_MACHINE(ATH79_MACH_TL_WA901ND_V3, "TL-WA901ND-v3", "TP-LINK TL-WA901ND v3",
21738 + tl_wa901nd_v3_setup);
21739 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr3320-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wdr3320-v2.c
21740 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr3320-v2.c 1970-01-01 01:00:00.000000000 +0100
21741 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wdr3320-v2.c 2017-08-06 20:02:15.000000000 +0200
21742 @@ -0,0 +1,146 @@
21744 + * TP-LINK TL-WDR3320 v2 board support
21746 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
21747 + * Copyright (C) 2015 Weijie Gao <hackpascal@gmail.com>
21749 + * This program is free software; you can redistribute it and/or modify it
21750 + * under the terms of the GNU General Public License version 2 as published
21751 + * by the Free Software Foundation.
21752 + */
21754 +#include <linux/pci.h>
21755 +#include <linux/phy.h>
21756 +#include <linux/gpio.h>
21757 +#include <linux/platform_device.h>
21758 +#include <linux/ath9k_platform.h>
21760 +#include <asm/mach-ath79/ar71xx_regs.h>
21762 +#include "common.h"
21763 +#include "dev-ap9x-pci.h"
21764 +#include "dev-eth.h"
21765 +#include "dev-gpio-buttons.h"
21766 +#include "dev-leds-gpio.h"
21767 +#include "dev-m25p80.h"
21768 +#include "dev-spi.h"
21769 +#include "dev-usb.h"
21770 +#include "dev-wmac.h"
21771 +#include "machtypes.h"
21773 +#define WDR3320_GPIO_LED_WLAN5G 12
21774 +#define WDR3320_GPIO_LED_SYSTEM 14
21775 +#define WDR3320_GPIO_LED_QSS 15
21776 +#define WDR3320_GPIO_LED_WAN 4
21777 +#define WDR3320_GPIO_LED_LAN1 18
21778 +#define WDR3320_GPIO_LED_LAN2 20
21779 +#define WDR3320_GPIO_LED_LAN3 21
21780 +#define WDR3320_GPIO_LED_LAN4 22
21782 +#define WDR3320_GPIO_BTN_RESET 16
21784 +#define WDR3320_KEYS_POLL_INTERVAL 20 /* msecs */
21785 +#define WDR3320_KEYS_DEBOUNCE_INTERVAL (3 * WDR3320_KEYS_POLL_INTERVAL)
21787 +#define WDR3320_WMAC_CALDATA_OFFSET 0x1000
21788 +#define WDR3320_PCIE_CALDATA_OFFSET 0x5000
21790 +static const char *wdr3320_part_probes[] = {
21791 + "tp-link",
21792 + NULL,
21795 +static struct flash_platform_data wdr3320_flash_data = {
21796 + .part_probes = wdr3320_part_probes,
21799 +static struct gpio_led wdr3320_leds_gpio[] __initdata = {
21801 + .name = "tp-link:green:qss",
21802 + .gpio = WDR3320_GPIO_LED_QSS,
21803 + .active_low = 1,
21804 + },
21806 + .name = "tp-link:green:system",
21807 + .gpio = WDR3320_GPIO_LED_SYSTEM,
21808 + .active_low = 1,
21809 + },
21811 + .name = "tp-link:green:wlan5g",
21812 + .gpio = WDR3320_GPIO_LED_WLAN5G,
21813 + .active_low = 1,
21814 + },
21817 +static struct gpio_keys_button wdr3320_gpio_keys[] __initdata = {
21819 + .desc = "reset",
21820 + .type = EV_KEY,
21821 + .code = KEY_RESTART,
21822 + .debounce_interval = WDR3320_KEYS_DEBOUNCE_INTERVAL,
21823 + .gpio = WDR3320_GPIO_BTN_RESET,
21824 + .active_low = 1,
21825 + },
21828 +static void __init wdr3320_setup(void)
21830 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
21831 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
21832 + u8 tmpmac[ETH_ALEN];
21834 + ath79_register_m25p80(&wdr3320_flash_data);
21835 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr3320_leds_gpio),
21836 + wdr3320_leds_gpio);
21837 + ath79_register_gpio_keys_polled(-1, WDR3320_KEYS_POLL_INTERVAL,
21838 + ARRAY_SIZE(wdr3320_gpio_keys),
21839 + wdr3320_gpio_keys);
21841 + ath79_init_mac(tmpmac, mac, 0);
21842 + ath79_register_wmac(art + WDR3320_WMAC_CALDATA_OFFSET, tmpmac);
21844 + ath79_init_mac(tmpmac, mac, -1);
21845 + ap9x_pci_setup_wmac_led_pin(0, 0);
21846 + ap91_pci_init(art + WDR3320_PCIE_CALDATA_OFFSET, tmpmac);
21848 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
21850 + ath79_register_mdio(1, 0x0);
21852 + /* LAN */
21853 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
21855 + /* GMAC1 is connected to the internal switch */
21856 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
21858 + ath79_register_eth(1);
21860 + /* WAN */
21861 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
21863 + /* GMAC0 is connected to the PHY4 of the internal switch */
21864 + ath79_switch_data.phy4_mii_en = 1;
21865 + ath79_switch_data.phy_poll_mask = BIT(4);
21866 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
21867 + ath79_eth0_data.phy_mask = BIT(4);
21868 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
21870 + ath79_register_eth(0);
21872 + ath79_register_usb();
21874 + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN1,
21875 + AR934X_GPIO_OUT_LED_LINK0);
21876 + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN2,
21877 + AR934X_GPIO_OUT_LED_LINK1);
21878 + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN3,
21879 + AR934X_GPIO_OUT_LED_LINK2);
21880 + ath79_gpio_output_select(WDR3320_GPIO_LED_LAN4,
21881 + AR934X_GPIO_OUT_LED_LINK3);
21882 + ath79_gpio_output_select(WDR3320_GPIO_LED_WAN,
21883 + AR934X_GPIO_OUT_LED_LINK4);
21886 +MIPS_MACHINE(ATH79_MACH_TL_WDR3320_V2, "TL-WDR3320-v2",
21887 + "TP-LINK TL-WDR3320 v2",
21888 + wdr3320_setup);
21889 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr3500.c linux-4.1.43/arch/mips/ath79/mach-tl-wdr3500.c
21890 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr3500.c 1970-01-01 01:00:00.000000000 +0100
21891 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wdr3500.c 2017-08-06 20:02:15.000000000 +0200
21892 @@ -0,0 +1,169 @@
21894 + * TP-LINK TL-WDR3500 board support
21896 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
21897 + * Copyright (C) 2013 Gui Iribarren <gui@altermundi.net>
21899 + * This program is free software; you can redistribute it and/or modify it
21900 + * under the terms of the GNU General Public License version 2 as published
21901 + * by the Free Software Foundation.
21902 + */
21904 +#include <linux/pci.h>
21905 +#include <linux/phy.h>
21906 +#include <linux/gpio.h>
21907 +#include <linux/platform_device.h>
21908 +#include <linux/ath9k_platform.h>
21909 +#include <linux/ar8216_platform.h>
21911 +#include <asm/mach-ath79/ar71xx_regs.h>
21913 +#include "common.h"
21914 +#include "dev-ap9x-pci.h"
21915 +#include "dev-eth.h"
21916 +#include "dev-gpio-buttons.h"
21917 +#include "dev-leds-gpio.h"
21918 +#include "dev-m25p80.h"
21919 +#include "dev-spi.h"
21920 +#include "dev-usb.h"
21921 +#include "dev-wmac.h"
21922 +#include "machtypes.h"
21924 +#define WDR3500_GPIO_LED_USB 11
21925 +#define WDR3500_GPIO_LED_WLAN2G 13
21926 +#define WDR3500_GPIO_LED_SYSTEM 14
21927 +#define WDR3500_GPIO_LED_QSS 15
21928 +#define WDR3500_GPIO_LED_WAN 18
21929 +#define WDR3500_GPIO_LED_LAN1 19
21930 +#define WDR3500_GPIO_LED_LAN2 20
21931 +#define WDR3500_GPIO_LED_LAN3 21
21932 +#define WDR3500_GPIO_LED_LAN4 22
21934 +#define WDR3500_GPIO_BTN_WPS 16
21935 +#define WDR3500_GPIO_BTN_RFKILL 17
21937 +#define WDR3500_GPIO_USB_POWER 12
21939 +#define WDR3500_KEYS_POLL_INTERVAL 20 /* msecs */
21940 +#define WDR3500_KEYS_DEBOUNCE_INTERVAL (3 * WDR3500_KEYS_POLL_INTERVAL)
21942 +#define WDR3500_MAC0_OFFSET 0
21943 +#define WDR3500_MAC1_OFFSET 6
21944 +#define WDR3500_WMAC_CALDATA_OFFSET 0x1000
21945 +#define WDR3500_PCIE_CALDATA_OFFSET 0x5000
21947 +static const char *wdr3500_part_probes[] = {
21948 + "tp-link",
21949 + NULL,
21952 +static struct flash_platform_data wdr3500_flash_data = {
21953 + .part_probes = wdr3500_part_probes,
21956 +static struct gpio_led wdr3500_leds_gpio[] __initdata = {
21958 + .name = "tp-link:green:qss",
21959 + .gpio = WDR3500_GPIO_LED_QSS,
21960 + .active_low = 1,
21961 + },
21963 + .name = "tp-link:green:system",
21964 + .gpio = WDR3500_GPIO_LED_SYSTEM,
21965 + .active_low = 1,
21966 + },
21968 + .name = "tp-link:green:usb",
21969 + .gpio = WDR3500_GPIO_LED_USB,
21970 + .active_low = 1,
21971 + },
21973 + .name = "tp-link:green:wlan2g",
21974 + .gpio = WDR3500_GPIO_LED_WLAN2G,
21975 + .active_low = 1,
21976 + },
21979 +static struct gpio_keys_button wdr3500_gpio_keys[] __initdata = {
21981 + .desc = "QSS button",
21982 + .type = EV_KEY,
21983 + .code = KEY_WPS_BUTTON,
21984 + .debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
21985 + .gpio = WDR3500_GPIO_BTN_WPS,
21986 + .active_low = 1,
21987 + },
21989 + .desc = "RFKILL switch",
21990 + .type = EV_SW,
21991 + .code = KEY_RFKILL,
21992 + .debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
21993 + .gpio = WDR3500_GPIO_BTN_RFKILL,
21994 + },
21998 +static void __init wdr3500_setup(void)
22000 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
22001 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
22002 + u8 tmpmac[ETH_ALEN];
22004 + ath79_register_m25p80(&wdr3500_flash_data);
22005 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr3500_leds_gpio),
22006 + wdr3500_leds_gpio);
22007 + ath79_register_gpio_keys_polled(-1, WDR3500_KEYS_POLL_INTERVAL,
22008 + ARRAY_SIZE(wdr3500_gpio_keys),
22009 + wdr3500_gpio_keys);
22011 + ath79_init_mac(tmpmac, mac, 0);
22012 + ath79_register_wmac(art + WDR3500_WMAC_CALDATA_OFFSET, tmpmac);
22014 + ath79_init_mac(tmpmac, mac, 1);
22015 + ap9x_pci_setup_wmac_led_pin(0, 0);
22016 + ap91_pci_init(art + WDR3500_PCIE_CALDATA_OFFSET, tmpmac);
22018 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
22020 + ath79_register_mdio(1, 0x0);
22022 + /* LAN */
22023 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
22025 + /* GMAC1 is connected to the internal switch */
22026 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
22028 + ath79_register_eth(1);
22030 + /* WAN */
22031 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 2);
22033 + /* GMAC0 is connected to the PHY4 of the internal switch */
22034 + ath79_switch_data.phy4_mii_en = 1;
22035 + ath79_switch_data.phy_poll_mask = BIT(4);
22036 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
22037 + ath79_eth0_data.phy_mask = BIT(4);
22038 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
22040 + ath79_register_eth(0);
22042 + gpio_request_one(WDR3500_GPIO_USB_POWER,
22043 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
22044 + "USB power");
22045 + ath79_register_usb();
22047 + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN1,
22048 + AR934X_GPIO_OUT_LED_LINK3);
22049 + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN2,
22050 + AR934X_GPIO_OUT_LED_LINK2);
22051 + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN3,
22052 + AR934X_GPIO_OUT_LED_LINK1);
22053 + ath79_gpio_output_select(WDR3500_GPIO_LED_LAN4,
22054 + AR934X_GPIO_OUT_LED_LINK0);
22055 + ath79_gpio_output_select(WDR3500_GPIO_LED_WAN,
22056 + AR934X_GPIO_OUT_LED_LINK4);
22059 +MIPS_MACHINE(ATH79_MACH_TL_WDR3500, "TL-WDR3500",
22060 + "TP-LINK TL-WDR3500",
22061 + wdr3500_setup);
22062 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr4300.c linux-4.1.43/arch/mips/ath79/mach-tl-wdr4300.c
22063 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr4300.c 1970-01-01 01:00:00.000000000 +0100
22064 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wdr4300.c 2017-08-06 20:02:15.000000000 +0200
22065 @@ -0,0 +1,206 @@
22067 + * TP-LINK TL-WDR4300 board support
22069 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
22071 + * This program is free software; you can redistribute it and/or modify it
22072 + * under the terms of the GNU General Public License version 2 as published
22073 + * by the Free Software Foundation.
22074 + */
22076 +#include <linux/pci.h>
22077 +#include <linux/phy.h>
22078 +#include <linux/gpio.h>
22079 +#include <linux/platform_device.h>
22080 +#include <linux/ath9k_platform.h>
22081 +#include <linux/ar8216_platform.h>
22083 +#include <asm/mach-ath79/ar71xx_regs.h>
22085 +#include "common.h"
22086 +#include "dev-ap9x-pci.h"
22087 +#include "dev-eth.h"
22088 +#include "dev-gpio-buttons.h"
22089 +#include "dev-leds-gpio.h"
22090 +#include "dev-m25p80.h"
22091 +#include "dev-spi.h"
22092 +#include "dev-usb.h"
22093 +#include "dev-wmac.h"
22094 +#include "machtypes.h"
22096 +#define WDR4300_GPIO_LED_USB1 11
22097 +#define WDR4300_GPIO_LED_USB2 12
22098 +#define WDR4300_GPIO_LED_WLAN2G 13
22099 +#define WDR4300_GPIO_LED_SYSTEM 14
22100 +#define WDR4300_GPIO_LED_QSS 15
22102 +#define WDR4300_GPIO_BTN_WPS 16
22103 +#define WDR4300_GPIO_BTN_RFKILL 17
22105 +#define WDR4300_GPIO_EXTERNAL_LNA0 18
22106 +#define WDR4300_GPIO_EXTERNAL_LNA1 19
22108 +#define WDR4300_GPIO_USB1_POWER 22
22109 +#define WDR4300_GPIO_USB2_POWER 21
22111 +#define WDR4300_KEYS_POLL_INTERVAL 20 /* msecs */
22112 +#define WDR4300_KEYS_DEBOUNCE_INTERVAL (3 * WDR4300_KEYS_POLL_INTERVAL)
22114 +#define WDR4300_MAC0_OFFSET 0
22115 +#define WDR4300_MAC1_OFFSET 6
22116 +#define WDR4300_WMAC_CALDATA_OFFSET 0x1000
22117 +#define WDR4300_PCIE_CALDATA_OFFSET 0x5000
22119 +static const char *wdr4300_part_probes[] = {
22120 + "tp-link",
22121 + NULL,
22124 +static struct flash_platform_data wdr4300_flash_data = {
22125 + .part_probes = wdr4300_part_probes,
22128 +static struct gpio_led wdr4300_leds_gpio[] __initdata = {
22130 + .name = "tp-link:blue:qss",
22131 + .gpio = WDR4300_GPIO_LED_QSS,
22132 + .active_low = 1,
22133 + },
22135 + .name = "tp-link:blue:system",
22136 + .gpio = WDR4300_GPIO_LED_SYSTEM,
22137 + .active_low = 1,
22138 + },
22140 + .name = "tp-link:green:usb1",
22141 + .gpio = WDR4300_GPIO_LED_USB1,
22142 + .active_low = 1,
22143 + },
22145 + .name = "tp-link:green:usb2",
22146 + .gpio = WDR4300_GPIO_LED_USB2,
22147 + .active_low = 1,
22148 + },
22150 + .name = "tp-link:blue:wlan2g",
22151 + .gpio = WDR4300_GPIO_LED_WLAN2G,
22152 + .active_low = 1,
22153 + },
22156 +static struct gpio_keys_button wdr4300_gpio_keys[] __initdata = {
22158 + .desc = "QSS button",
22159 + .type = EV_KEY,
22160 + .code = KEY_WPS_BUTTON,
22161 + .debounce_interval = WDR4300_KEYS_DEBOUNCE_INTERVAL,
22162 + .gpio = WDR4300_GPIO_BTN_WPS,
22163 + .active_low = 1,
22164 + },
22166 + .desc = "RFKILL switch",
22167 + .type = EV_SW,
22168 + .code = KEY_RFKILL,
22169 + .debounce_interval = WDR4300_KEYS_DEBOUNCE_INTERVAL,
22170 + .gpio = WDR4300_GPIO_BTN_RFKILL,
22171 + .active_low = 1,
22172 + },
22175 +static const struct ar8327_led_info wdr4300_leds_ar8327[] __initconst = {
22176 + AR8327_LED_INFO(PHY0_0, HW, "tp-link:blue:wan"),
22177 + AR8327_LED_INFO(PHY1_0, HW, "tp-link:blue:lan1"),
22178 + AR8327_LED_INFO(PHY2_0, HW, "tp-link:blue:lan2"),
22179 + AR8327_LED_INFO(PHY3_0, HW, "tp-link:blue:lan3"),
22180 + AR8327_LED_INFO(PHY4_0, HW, "tp-link:blue:lan4"),
22183 +static struct ar8327_pad_cfg wdr4300_ar8327_pad0_cfg = {
22184 + .mode = AR8327_PAD_MAC_RGMII,
22185 + .txclk_delay_en = true,
22186 + .rxclk_delay_en = true,
22187 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
22188 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
22191 +static struct ar8327_led_cfg wdr4300_ar8327_led_cfg = {
22192 + .led_ctrl0 = 0xc737c737,
22193 + .led_ctrl1 = 0x00000000,
22194 + .led_ctrl2 = 0x00000000,
22195 + .led_ctrl3 = 0x0030c300,
22196 + .open_drain = false,
22199 +static struct ar8327_platform_data wdr4300_ar8327_data = {
22200 + .pad0_cfg = &wdr4300_ar8327_pad0_cfg,
22201 + .port0_cfg = {
22202 + .force_link = 1,
22203 + .speed = AR8327_PORT_SPEED_1000,
22204 + .duplex = 1,
22205 + .txpause = 1,
22206 + .rxpause = 1,
22207 + },
22208 + .led_cfg = &wdr4300_ar8327_led_cfg,
22209 + .num_leds = ARRAY_SIZE(wdr4300_leds_ar8327),
22210 + .leds = wdr4300_leds_ar8327,
22213 +static struct mdio_board_info wdr4300_mdio0_info[] = {
22215 + .bus_id = "ag71xx-mdio.0",
22216 + .phy_addr = 0,
22217 + .platform_data = &wdr4300_ar8327_data,
22218 + },
22221 +static void __init wdr4300_setup(void)
22223 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
22224 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
22225 + u8 tmpmac[ETH_ALEN];
22227 + ath79_register_m25p80(&wdr4300_flash_data);
22228 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr4300_leds_gpio),
22229 + wdr4300_leds_gpio);
22230 + ath79_register_gpio_keys_polled(-1, WDR4300_KEYS_POLL_INTERVAL,
22231 + ARRAY_SIZE(wdr4300_gpio_keys),
22232 + wdr4300_gpio_keys);
22234 + ath79_wmac_set_ext_lna_gpio(0, WDR4300_GPIO_EXTERNAL_LNA0);
22235 + ath79_wmac_set_ext_lna_gpio(1, WDR4300_GPIO_EXTERNAL_LNA1);
22237 + ath79_init_mac(tmpmac, mac, -1);
22238 + ath79_register_wmac(art + WDR4300_WMAC_CALDATA_OFFSET, tmpmac);
22240 + ath79_init_mac(tmpmac, mac, 0);
22241 + ap9x_pci_setup_wmac_led_pin(0, 0);
22242 + ap91_pci_init(art + WDR4300_PCIE_CALDATA_OFFSET, tmpmac);
22244 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
22246 + mdiobus_register_board_info(wdr4300_mdio0_info,
22247 + ARRAY_SIZE(wdr4300_mdio0_info));
22249 + ath79_register_mdio(0, 0x0);
22251 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -2);
22253 + /* GMAC0 is connected to an AR8327N switch */
22254 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
22255 + ath79_eth0_data.phy_mask = BIT(0);
22256 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
22257 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
22258 + ath79_register_eth(0);
22260 + gpio_request_one(WDR4300_GPIO_USB1_POWER,
22261 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
22262 + "USB1 power");
22263 + gpio_request_one(WDR4300_GPIO_USB2_POWER,
22264 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
22265 + "USB2 power");
22266 + ath79_register_usb();
22269 +MIPS_MACHINE(ATH79_MACH_TL_WDR4300, "TL-WDR4300",
22270 + "TP-LINK TL-WDR3600/4300/4310",
22271 + wdr4300_setup);
22272 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr6500-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wdr6500-v2.c
22273 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wdr6500-v2.c 1970-01-01 01:00:00.000000000 +0100
22274 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wdr6500-v2.c 2017-08-06 20:02:15.000000000 +0200
22275 @@ -0,0 +1,141 @@
22277 + * TP-LINK TL-WDR6500 v2
22279 + * Copyright (C) 2015 Weijie Gao <hackpascal@gmail.com>
22281 + * This program is free software; you can redistribute it and/or modify it
22282 + * under the terms of the GNU General Public License version 2 as published
22283 + * by the Free Software Foundation.
22284 + */
22286 +#include <linux/pci.h>
22287 +#include <linux/gpio.h>
22288 +#include <linux/platform_device.h>
22290 +#include <asm/mach-ath79/ath79.h>
22291 +#include <asm/mach-ath79/ar71xx_regs.h>
22293 +#include "common.h"
22294 +#include "dev-eth.h"
22295 +#include "dev-ap9x-pci.h"
22296 +#include "dev-gpio-buttons.h"
22297 +#include "dev-leds-gpio.h"
22298 +#include "dev-m25p80.h"
22299 +#include "dev-usb.h"
22300 +#include "dev-wmac.h"
22301 +#include "machtypes.h"
22302 +#include "pci.h"
22304 +#define TL_WDR6500_V2_GPIO_LED_SYS 21
22305 +#define TL_WDR6500_V2_GPIO_LED_WAN 18
22306 +#define TL_WDR6500_V2_GPIO_LED_LAN1 17
22307 +#define TL_WDR6500_V2_GPIO_LED_LAN2 16
22308 +#define TL_WDR6500_V2_GPIO_LED_LAN3 15
22309 +#define TL_WDR6500_V2_GPIO_LED_LAN4 14
22311 +#define TL_WDR6500_V2_GPIO_BTN_RESET 1
22313 +#define TL_WDR6500_V2_KEYS_POLL_INTERVAL 20 /* msecs */
22314 +#define TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WDR6500_V2_KEYS_POLL_INTERVAL)
22316 +#define TL_WDR6500_V2_WMAC_CALDATA_OFFSET 0x1000
22317 +#define TL_WDR6500_V2_PCIE_CALDATA_OFFSET 0x5000
22319 +static const char *tl_wdr6500_v2_part_probes[] = {
22320 + "tp-link-64k",
22321 + NULL,
22324 +static struct flash_platform_data tl_wdr6500_v2_flash_data = {
22325 + .part_probes = tl_wdr6500_v2_part_probes,
22328 +static struct gpio_led tl_wdr6500_v2_leds_gpio[] __initdata = {
22330 + .name = "tp-link:green:lan1",
22331 + .gpio = TL_WDR6500_V2_GPIO_LED_LAN1,
22332 + .active_low = 1,
22333 + }, {
22334 + .name = "tp-link:green:lan2",
22335 + .gpio = TL_WDR6500_V2_GPIO_LED_LAN2,
22336 + .active_low = 1,
22337 + }, {
22338 + .name = "tp-link:green:lan3",
22339 + .gpio = TL_WDR6500_V2_GPIO_LED_LAN3,
22340 + .active_low = 1,
22341 + }, {
22342 + .name = "tp-link:green:lan4",
22343 + .gpio = TL_WDR6500_V2_GPIO_LED_LAN4,
22344 + .active_low = 1,
22345 + }, {
22346 + .name = "tp-link:green:wan",
22347 + .gpio = TL_WDR6500_V2_GPIO_LED_WAN,
22348 + .active_low = 1,
22349 + }, {
22350 + .name = "tp-link:white:system",
22351 + .gpio = TL_WDR6500_V2_GPIO_LED_SYS,
22352 + .active_low = 0,
22353 + },
22356 +static struct gpio_keys_button tl_wdr6500_v2_gpio_keys[] __initdata = {
22358 + .desc = "Reset button",
22359 + .type = EV_KEY,
22360 + .code = KEY_RESTART,
22361 + .debounce_interval = TL_WDR6500_V2_KEYS_DEBOUNCE_INTERVAL,
22362 + .gpio = TL_WDR6500_V2_GPIO_BTN_RESET,
22363 + .active_low = 1,
22368 +static void __init tl_ap151_setup(void)
22370 + u8 *mac = (u8 *) KSEG1ADDR(0x1f00fc00);
22371 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff0000);
22372 + u8 tmpmac[ETH_ALEN];
22374 + ath79_register_m25p80(&tl_wdr6500_v2_flash_data);
22376 + ath79_setup_ar933x_phy4_switch(false, false);
22378 + ath79_register_mdio(0, 0x0);
22380 + /* WAN */
22381 + ath79_switch_data.phy4_mii_en = 1;
22382 + ath79_switch_data.phy_poll_mask = BIT(4);
22383 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
22384 + ath79_eth0_data.phy_mask = BIT(4);
22385 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
22386 + ath79_register_eth(0);
22388 + /* LAN */
22389 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
22390 + ath79_eth1_data.duplex = DUPLEX_FULL;
22391 + ath79_eth1_data.speed = SPEED_1000;
22392 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
22393 + ath79_register_eth(1);
22395 + ath79_init_mac(tmpmac, mac, -1);
22396 + ath79_register_wmac(ee + TL_WDR6500_V2_WMAC_CALDATA_OFFSET, tmpmac);
22398 + ath79_register_pci();
22400 + ath79_register_usb();
22403 +static void __init tl_wdr6500_v2_setup(void)
22405 + tl_ap151_setup();
22407 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wdr6500_v2_leds_gpio),
22408 + tl_wdr6500_v2_leds_gpio);
22410 + ath79_register_gpio_keys_polled(1, TL_WDR6500_V2_KEYS_POLL_INTERVAL,
22411 + ARRAY_SIZE(tl_wdr6500_v2_gpio_keys),
22412 + tl_wdr6500_v2_gpio_keys);
22415 +MIPS_MACHINE(ATH79_MACH_TL_WDR6500_V2, "TL-WDR6500-v2", "TP-LINK TL-WDR6500 v2",
22416 + tl_wdr6500_v2_setup);
22417 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1041n-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wr1041n-v2.c
22418 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1041n-v2.c 1970-01-01 01:00:00.000000000 +0100
22419 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr1041n-v2.c 2017-08-06 20:02:15.000000000 +0200
22420 @@ -0,0 +1,138 @@
22422 + * TP-LINK TL-WR1041 v2 board support
22424 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
22425 + * Copyright (C) 2011-2012 Anan Huang <axishero@foxmail.com>
22427 + * This program is free software; you can redistribute it and/or modify it
22428 + * under the terms of the GNU General Public License version 2 as published
22429 + * by the Free Software Foundation.
22430 + */
22432 +#include <linux/pci.h>
22433 +#include <linux/phy.h>
22434 +#include <linux/platform_device.h>
22435 +#include <linux/ath9k_platform.h>
22436 +#include <linux/ar8216_platform.h>
22438 +#include <asm/mach-ath79/ar71xx_regs.h>
22440 +#include "common.h"
22441 +#include "dev-ap9x-pci.h"
22442 +#include "dev-eth.h"
22443 +#include "dev-gpio-buttons.h"
22444 +#include "dev-leds-gpio.h"
22445 +#include "dev-m25p80.h"
22446 +#include "dev-spi.h"
22447 +#include "dev-wmac.h"
22448 +#include "machtypes.h"
22450 +#define TL_WR1041NV2_GPIO_BTN_RESET 14
22451 +#define TL_WR1041NV2_GPIO_LED_WPS 13
22452 +#define TL_WR1041NV2_GPIO_LED_WLAN 11
22454 +#define TL_WR1041NV2_GPIO_LED_SYSTEM 12
22456 +#define TL_WR1041NV2_KEYS_POLL_INTERVAL 20 /* msecs */
22457 +#define TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1041NV2_KEYS_POLL_INTERVAL)
22459 +#define TL_WR1041NV2_PCIE_CALDATA_OFFSET 0x5000
22461 +static const char *tl_wr1041nv2_part_probes[] = {
22462 + "tp-link",
22463 + NULL,
22466 +static struct flash_platform_data tl_wr1041nv2_flash_data = {
22467 + .part_probes = tl_wr1041nv2_part_probes,
22470 +static struct gpio_led tl_wr1041nv2_leds_gpio[] __initdata = {
22472 + .name = "tp-link:green:system",
22473 + .gpio = TL_WR1041NV2_GPIO_LED_SYSTEM,
22474 + .active_low = 1,
22475 + }, {
22476 + .name = "tp-link:green:wps",
22477 + .gpio = TL_WR1041NV2_GPIO_LED_WPS,
22478 + .active_low = 1,
22479 + }, {
22480 + .name = "tp-link:green:wlan",
22481 + .gpio = TL_WR1041NV2_GPIO_LED_WLAN,
22482 + .active_low = 1,
22486 +static struct gpio_keys_button tl_wr1041nv2_gpio_keys[] __initdata = {
22488 + .desc = "reset",
22489 + .type = EV_KEY,
22490 + .code = KEY_RESTART,
22491 + .debounce_interval = TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL,
22492 + .gpio = TL_WR1041NV2_GPIO_BTN_RESET,
22493 + .active_low = 1,
22497 +static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = {
22498 + .mode = AR8327_PAD_MAC_RGMII,
22499 + .txclk_delay_en = true,
22500 + .rxclk_delay_en = true,
22501 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
22502 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
22505 +static struct ar8327_platform_data db120_ar8327_data = {
22506 + .pad0_cfg = &db120_ar8327_pad0_cfg,
22507 + .port0_cfg = {
22508 + .force_link = 1,
22509 + .speed = AR8327_PORT_SPEED_1000,
22510 + .duplex = 1,
22511 + .txpause = 1,
22512 + .rxpause = 1,
22516 +static struct mdio_board_info db120_mdio0_info[] = {
22518 + .bus_id = "ag71xx-mdio.0",
22519 + .phy_addr = 0,
22520 + .platform_data = &db120_ar8327_data,
22521 + },
22524 +static void __init tl_wr1041nv2_setup(void)
22526 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
22527 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
22529 + ath79_register_m25p80(&tl_wr1041nv2_flash_data);
22531 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1041nv2_leds_gpio),
22532 + tl_wr1041nv2_leds_gpio);
22533 + ath79_register_gpio_keys_polled(-1, TL_WR1041NV2_KEYS_POLL_INTERVAL,
22534 + ARRAY_SIZE(tl_wr1041nv2_gpio_keys),
22535 + tl_wr1041nv2_gpio_keys);
22536 + ath79_register_wmac(ee, mac);
22538 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
22539 + AR934X_ETH_CFG_SW_ONLY_MODE);
22541 + ath79_register_mdio(1, 0x0);
22542 + ath79_register_mdio(0, 0x0);
22544 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
22546 + mdiobus_register_board_info(db120_mdio0_info,
22547 + ARRAY_SIZE(db120_mdio0_info));
22549 + /* GMAC0 is connected to an AR8327 switch */
22550 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
22551 + ath79_eth0_data.phy_mask = BIT(0);
22552 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
22553 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
22554 + ath79_register_eth(0);
22557 +MIPS_MACHINE(ATH79_MACH_TL_WR1041N_V2, "TL-WR1041N-v2",
22558 + "TP-LINK TL-WR1041N v2", tl_wr1041nv2_setup);
22559 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1043nd-v2.c linux-4.1.43/arch/mips/ath79/mach-tl-wr1043nd-v2.c
22560 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1043nd-v2.c 1970-01-01 01:00:00.000000000 +0100
22561 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr1043nd-v2.c 2017-08-06 20:02:15.000000000 +0200
22562 @@ -0,0 +1,215 @@
22564 + * TP-LINK TL-WR1043ND v2 board support
22566 + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
22568 + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
22569 + * Copyright (c) 2012 Qualcomm Atheros
22571 + * Permission to use, copy, modify, and/or distribute this software for any
22572 + * purpose with or without fee is hereby granted, provided that the above
22573 + * copyright notice and this permission notice appear in all copies.
22575 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
22576 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22577 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
22578 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22579 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
22580 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22581 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22583 + */
22585 +#include <linux/phy.h>
22586 +#include <linux/gpio.h>
22587 +#include <linux/platform_device.h>
22588 +#include <linux/ar8216_platform.h>
22590 +#include <asm/mach-ath79/ar71xx_regs.h>
22592 +#include "common.h"
22593 +#include "dev-eth.h"
22594 +#include "dev-gpio-buttons.h"
22595 +#include "dev-leds-gpio.h"
22596 +#include "dev-m25p80.h"
22597 +#include "dev-spi.h"
22598 +#include "dev-usb.h"
22599 +#include "dev-wmac.h"
22600 +#include "machtypes.h"
22602 +#define TL_WR1043_V2_GPIO_LED_WLAN 12
22603 +#define TL_WR1043_V2_GPIO_LED_USB 15
22604 +#define TL_WR1043_V2_GPIO_LED_WPS 18
22605 +#define TL_WR1043_V2_GPIO_LED_SYSTEM 19
22607 +#define TL_WR1043_V2_GPIO_BTN_RESET 16
22608 +#define TL_WR1043_V2_GPIO_BTN_RFKILL 17
22610 +#define TL_WR1043_V2_GPIO_USB_POWER 21
22612 +#define TL_WR1043_V2_KEYS_POLL_INTERVAL 20 /* msecs */
22613 +#define TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043_V2_KEYS_POLL_INTERVAL)
22615 +#define TL_WR1043_V2_WMAC_CALDATA_OFFSET 0x1000
22617 +static const char *wr1043nd_v2_part_probes[] = {
22618 + "tp-link",
22619 + NULL,
22622 +static struct flash_platform_data wr1043nd_v2_flash_data = {
22623 + .part_probes = wr1043nd_v2_part_probes,
22626 +static struct gpio_led tl_wr1043_v2_leds_gpio[] __initdata = {
22628 + .name = "tp-link:green:wps",
22629 + .gpio = TL_WR1043_V2_GPIO_LED_WPS,
22630 + .active_low = 1,
22631 + },
22633 + .name = "tp-link:green:system",
22634 + .gpio = TL_WR1043_V2_GPIO_LED_SYSTEM,
22635 + .active_low = 1,
22636 + },
22638 + .name = "tp-link:green:wlan",
22639 + .gpio = TL_WR1043_V2_GPIO_LED_WLAN,
22640 + .active_low = 1,
22641 + },
22643 + .name = "tp-link:green:usb",
22644 + .gpio = TL_WR1043_V2_GPIO_LED_USB,
22645 + .active_low = 1,
22646 + },
22649 +static struct gpio_keys_button tl_wr1043_v2_gpio_keys[] __initdata = {
22651 + .desc = "Reset button",
22652 + .type = EV_KEY,
22653 + .code = KEY_RESTART,
22654 + .debounce_interval = TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL,
22655 + .gpio = TL_WR1043_V2_GPIO_BTN_RESET,
22656 + .active_low = 1,
22657 + },
22659 + .desc = "RFKILL button",
22660 + .type = EV_KEY,
22661 + .code = KEY_RFKILL,
22662 + .debounce_interval = TL_WR1043_V2_KEYS_DEBOUNCE_INTERVAL,
22663 + .gpio = TL_WR1043_V2_GPIO_BTN_RFKILL,
22664 + .active_low = 1,
22665 + },
22668 +static const struct ar8327_led_info tl_wr1043_leds_ar8327[] = {
22669 + AR8327_LED_INFO(PHY0_0, HW, "tp-link:green:lan4"),
22670 + AR8327_LED_INFO(PHY1_0, HW, "tp-link:green:lan3"),
22671 + AR8327_LED_INFO(PHY2_0, HW, "tp-link:green:lan2"),
22672 + AR8327_LED_INFO(PHY3_0, HW, "tp-link:green:lan1"),
22673 + AR8327_LED_INFO(PHY4_0, HW, "tp-link:green:wan"),
22676 +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
22677 +static struct ar8327_pad_cfg wr1043nd_v2_ar8327_pad0_cfg = {
22678 + .mode = AR8327_PAD_MAC_SGMII,
22679 + .sgmii_delay_en = true,
22682 +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
22683 +static struct ar8327_pad_cfg wr1043nd_v2_ar8327_pad6_cfg = {
22684 + .mode = AR8327_PAD_MAC_RGMII,
22685 + .txclk_delay_en = true,
22686 + .rxclk_delay_en = true,
22687 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
22688 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
22691 +static struct ar8327_led_cfg wr1043nd_v2_ar8327_led_cfg = {
22692 + .led_ctrl0 = 0xcc35cc35,
22693 + .led_ctrl1 = 0xca35ca35,
22694 + .led_ctrl2 = 0xc935c935,
22695 + .led_ctrl3 = 0x03ffff00,
22696 + .open_drain = true,
22699 +static struct ar8327_platform_data wr1043nd_v2_ar8327_data = {
22700 + .pad0_cfg = &wr1043nd_v2_ar8327_pad0_cfg,
22701 + .pad6_cfg = &wr1043nd_v2_ar8327_pad6_cfg,
22702 + .port0_cfg = {
22703 + .force_link = 1,
22704 + .speed = AR8327_PORT_SPEED_1000,
22705 + .duplex = 1,
22706 + .txpause = 1,
22707 + .rxpause = 1,
22708 + },
22709 + .port6_cfg = {
22710 + .force_link = 1,
22711 + .speed = AR8327_PORT_SPEED_1000,
22712 + .duplex = 1,
22713 + .txpause = 1,
22714 + .rxpause = 1,
22715 + },
22716 + .led_cfg = &wr1043nd_v2_ar8327_led_cfg,
22717 + .num_leds = ARRAY_SIZE(tl_wr1043_leds_ar8327),
22718 + .leds = tl_wr1043_leds_ar8327,
22721 +static struct mdio_board_info wr1043nd_v2_mdio0_info[] = {
22723 + .bus_id = "ag71xx-mdio.0",
22724 + .phy_addr = 0,
22725 + .platform_data = &wr1043nd_v2_ar8327_data,
22726 + },
22729 +static void __init tl_wr1043nd_v2_setup(void)
22731 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
22732 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
22734 + ath79_register_m25p80(&wr1043nd_v2_flash_data);
22736 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043_v2_leds_gpio),
22737 + tl_wr1043_v2_leds_gpio);
22738 + ath79_register_gpio_keys_polled(-1, TL_WR1043_V2_KEYS_POLL_INTERVAL,
22739 + ARRAY_SIZE(tl_wr1043_v2_gpio_keys),
22740 + tl_wr1043_v2_gpio_keys);
22742 + ath79_register_wmac(art + TL_WR1043_V2_WMAC_CALDATA_OFFSET, mac);
22744 + mdiobus_register_board_info(wr1043nd_v2_mdio0_info,
22745 + ARRAY_SIZE(wr1043nd_v2_mdio0_info));
22746 + ath79_register_mdio(0, 0x0);
22748 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
22750 + /* GMAC0 is connected to the RMGII interface */
22751 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
22752 + ath79_eth0_data.phy_mask = BIT(0);
22753 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
22754 + ath79_eth0_pll_data.pll_1000 = 0x56000000;
22756 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
22757 + ath79_register_eth(0);
22759 + /* GMAC1 is connected to the SGMII interface */
22760 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
22761 + ath79_eth1_data.speed = SPEED_1000;
22762 + ath79_eth1_data.duplex = DUPLEX_FULL;
22763 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
22765 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
22766 + ath79_register_eth(1);
22768 + ath79_register_usb();
22770 + gpio_request_one(TL_WR1043_V2_GPIO_USB_POWER,
22771 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
22772 + "USB power");
22775 +MIPS_MACHINE(ATH79_MACH_TL_WR1043ND_V2, "TL-WR1043ND-v2",
22776 + "TP-LINK TL-WR1043ND v2", tl_wr1043nd_v2_setup);
22778 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1043nd.c linux-4.1.43/arch/mips/ath79/mach-tl-wr1043nd.c
22779 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr1043nd.c 1970-01-01 01:00:00.000000000 +0100
22780 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr1043nd.c 2017-08-06 20:02:15.000000000 +0200
22781 @@ -0,0 +1,141 @@
22783 + * TP-LINK TL-WR1043N/ND board support
22785 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
22787 + * This program is free software; you can redistribute it and/or modify it
22788 + * under the terms of the GNU General Public License version 2 as published
22789 + * by the Free Software Foundation.
22790 + */
22792 +#include <linux/platform_device.h>
22793 +#include <linux/rtl8366.h>
22795 +#include <asm/mach-ath79/ath79.h>
22796 +#include <asm/mach-ath79/ar71xx_regs.h>
22798 +#include "dev-eth.h"
22799 +#include "dev-m25p80.h"
22800 +#include "dev-gpio-buttons.h"
22801 +#include "dev-leds-gpio.h"
22802 +#include "dev-usb.h"
22803 +#include "dev-wmac.h"
22804 +#include "machtypes.h"
22806 +#define TL_WR1043ND_GPIO_LED_USB 1
22807 +#define TL_WR1043ND_GPIO_LED_SYSTEM 2
22808 +#define TL_WR1043ND_GPIO_LED_QSS 5
22809 +#define TL_WR1043ND_GPIO_LED_WLAN 9
22811 +#define TL_WR1043ND_GPIO_BTN_RESET 3
22812 +#define TL_WR1043ND_GPIO_BTN_QSS 7
22814 +#define TL_WR1043ND_GPIO_RTL8366_SDA 18
22815 +#define TL_WR1043ND_GPIO_RTL8366_SCK 19
22817 +#define TL_WR1043ND_KEYS_POLL_INTERVAL 20 /* msecs */
22818 +#define TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1043ND_KEYS_POLL_INTERVAL)
22820 +static const char *tl_wr1043nd_part_probes[] = {
22821 + "tp-link",
22822 + NULL,
22825 +static struct flash_platform_data tl_wr1043nd_flash_data = {
22826 + .part_probes = tl_wr1043nd_part_probes,
22829 +static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
22831 + .name = "tp-link:green:usb",
22832 + .gpio = TL_WR1043ND_GPIO_LED_USB,
22833 + .active_low = 1,
22834 + }, {
22835 + .name = "tp-link:green:system",
22836 + .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
22837 + .active_low = 1,
22838 + }, {
22839 + .name = "tp-link:green:qss",
22840 + .gpio = TL_WR1043ND_GPIO_LED_QSS,
22841 + .active_low = 0,
22842 + }, {
22843 + .name = "tp-link:green:wlan",
22844 + .gpio = TL_WR1043ND_GPIO_LED_WLAN,
22845 + .active_low = 1,
22849 +static struct gpio_keys_button tl_wr1043nd_gpio_keys[] __initdata = {
22851 + .desc = "reset",
22852 + .type = EV_KEY,
22853 + .code = KEY_RESTART,
22854 + .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
22855 + .gpio = TL_WR1043ND_GPIO_BTN_RESET,
22856 + .active_low = 1,
22857 + }, {
22858 + .desc = "qss",
22859 + .type = EV_KEY,
22860 + .code = KEY_WPS_BUTTON,
22861 + .debounce_interval = TL_WR1043ND_KEYS_DEBOUNCE_INTERVAL,
22862 + .gpio = TL_WR1043ND_GPIO_BTN_QSS,
22863 + .active_low = 1,
22867 +static void tl_wr1043nd_rtl8366rb_hw_reset(bool active)
22869 + if (active)
22870 + ath79_device_reset_set(AR71XX_RESET_GE0_PHY);
22871 + else
22872 + ath79_device_reset_clear(AR71XX_RESET_GE0_PHY);
22875 +static struct rtl8366_platform_data tl_wr1043nd_rtl8366rb_data = {
22876 + .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
22877 + .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
22878 + .hw_reset = tl_wr1043nd_rtl8366rb_hw_reset,
22881 +static struct platform_device tl_wr1043nd_rtl8366rb_device = {
22882 + .name = RTL8366RB_DRIVER_NAME,
22883 + .id = -1,
22884 + .dev = {
22885 + .platform_data = &tl_wr1043nd_rtl8366rb_data,
22889 +static void __init tl_wr1043nd_setup(void)
22891 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
22892 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
22894 + tl_wr1043nd_rtl8366rb_hw_reset(true);
22896 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
22897 + ath79_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
22898 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
22899 + ath79_eth0_data.speed = SPEED_1000;
22900 + ath79_eth0_data.duplex = DUPLEX_FULL;
22901 + ath79_eth0_pll_data.pll_1000 = 0x1a000000;
22903 + ath79_register_eth(0);
22905 + ath79_register_usb();
22907 + ath79_register_m25p80(&tl_wr1043nd_flash_data);
22909 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
22910 + tl_wr1043nd_leds_gpio);
22912 + platform_device_register(&tl_wr1043nd_rtl8366rb_device);
22914 + ath79_register_gpio_keys_polled(-1, TL_WR1043ND_KEYS_POLL_INTERVAL,
22915 + ARRAY_SIZE(tl_wr1043nd_gpio_keys),
22916 + tl_wr1043nd_gpio_keys);
22918 + ath79_register_wmac(eeprom, mac);
22921 +MIPS_MACHINE(ATH79_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
22922 + tl_wr1043nd_setup);
22923 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr2543n.c linux-4.1.43/arch/mips/ath79/mach-tl-wr2543n.c
22924 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr2543n.c 1970-01-01 01:00:00.000000000 +0100
22925 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr2543n.c 2017-08-06 20:02:15.000000000 +0200
22926 @@ -0,0 +1,156 @@
22928 + * TP-LINK TL-WR2543N/ND board support
22930 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
22932 + * This program is free software; you can redistribute it and/or modify it
22933 + * under the terms of the GNU General Public License version 2 as published
22934 + * by the Free Software Foundation.
22935 + */
22937 +#include <linux/platform_device.h>
22938 +#include <linux/rtl8367.h>
22940 +#include <asm/mach-ath79/ath79.h>
22942 +#include "dev-eth.h"
22943 +#include "dev-ap9x-pci.h"
22944 +#include "dev-gpio-buttons.h"
22945 +#include "dev-leds-gpio.h"
22946 +#include "dev-m25p80.h"
22947 +#include "dev-usb.h"
22948 +#include "machtypes.h"
22950 +#define TL_WR2543N_GPIO_LED_WPS 0
22951 +#define TL_WR2543N_GPIO_LED_USB 8
22953 +/* The WLAN LEDs use GPIOs on the discrete AR9380 wmac */
22954 +#define TL_WR2543N_GPIO_WMAC_LED_WLAN2G 0
22955 +#define TL_WR2543N_GPIO_WMAC_LED_WLAN5G 1
22957 +#define TL_WR2543N_GPIO_BTN_RESET 11
22958 +#define TL_WR2543N_GPIO_BTN_WPS 12
22960 +#define TL_WR2543N_GPIO_RTL8367_SDA 1
22961 +#define TL_WR2543N_GPIO_RTL8367_SCK 6
22963 +#define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */
22964 +#define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL)
22966 +static const char *tl_wr2543n_part_probes[] = {
22967 + "tp-link",
22968 + NULL,
22971 +static struct flash_platform_data tl_wr2543n_flash_data = {
22972 + .part_probes = tl_wr2543n_part_probes,
22975 +static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = {
22977 + .name = "tp-link:green:usb",
22978 + .gpio = TL_WR2543N_GPIO_LED_USB,
22979 + .active_low = 1,
22980 + }, {
22981 + .name = "tp-link:green:wps",
22982 + .gpio = TL_WR2543N_GPIO_LED_WPS,
22983 + .active_low = 1,
22987 +static struct gpio_led tl_wr2543n_wmac_leds_gpio[] = {
22989 + .name = "tp-link:green:wlan5g",
22990 + .gpio = TL_WR2543N_GPIO_WMAC_LED_WLAN5G,
22991 + .active_low = 1,
22992 + },
22995 +static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = {
22997 + .desc = "reset",
22998 + .type = EV_KEY,
22999 + .code = KEY_RESTART,
23000 + .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
23001 + .gpio = TL_WR2543N_GPIO_BTN_RESET,
23002 + .active_low = 1,
23003 + }, {
23004 + .desc = "wps",
23005 + .type = EV_KEY,
23006 + .code = KEY_WPS_BUTTON,
23007 + .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL,
23008 + .gpio = TL_WR2543N_GPIO_BTN_WPS,
23009 + .active_low = 1,
23013 +static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = {
23014 + .mode = RTL8367_EXTIF_MODE_RGMII,
23015 + .txdelay = 1,
23016 + .rxdelay = 0,
23017 + .ability = {
23018 + .force_mode = 1,
23019 + .txpause = 1,
23020 + .rxpause = 1,
23021 + .link = 1,
23022 + .duplex = 1,
23023 + .speed = RTL8367_PORT_SPEED_1000,
23024 + },
23027 +static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = {
23028 + .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA,
23029 + .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK,
23030 + .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg,
23033 +static struct platform_device tl_wr2543n_rtl8367_device = {
23034 + .name = RTL8367_DRIVER_NAME,
23035 + .id = -1,
23036 + .dev = {
23037 + .platform_data = &tl_wr2543n_rtl8367_data,
23041 +static void __init tl_wr2543n_setup(void)
23043 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23044 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
23046 + ath79_register_m25p80(&tl_wr2543n_flash_data);
23047 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio),
23048 + tl_wr2543n_leds_gpio);
23049 + ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL,
23050 + ARRAY_SIZE(tl_wr2543n_gpio_keys),
23051 + tl_wr2543n_gpio_keys);
23052 + ath79_register_usb();
23054 + /*
23055 + * The ath9k driver uses this pin for its default led device, which is
23056 + * named ath9k-phy0, and reflects activity on either the 2 GHz or 5 GHz
23057 + * bands. This pin is connected to the WR2543's 2GHz WLAN LED.
23058 + */
23059 + ap9x_pci_setup_wmac_led_pin(0, TL_WR2543N_GPIO_WMAC_LED_WLAN2G);
23061 + /*
23062 + * We also have the driver set up an led device for the WR2543's
23063 + * separate 5 GHz WLAN LED in case the user wants it.
23064 + */
23065 + ap9x_pci_setup_wmac_leds(0, tl_wr2543n_wmac_leds_gpio,
23066 + ARRAY_SIZE(tl_wr2543n_wmac_leds_gpio));
23067 + ap91_pci_init(eeprom, mac);
23069 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
23070 + ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev;
23071 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
23072 + ath79_eth0_data.speed = SPEED_1000;
23073 + ath79_eth0_data.duplex = DUPLEX_FULL;
23074 + ath79_eth0_pll_data.pll_1000 = 0x1a000000;
23076 + ath79_register_eth(0);
23078 + platform_device_register(&tl_wr2543n_rtl8367_device);
23081 +MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND",
23082 + tl_wr2543n_setup);
23083 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr703n.c linux-4.1.43/arch/mips/ath79/mach-tl-wr703n.c
23084 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr703n.c 1970-01-01 01:00:00.000000000 +0100
23085 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr703n.c 2017-08-06 20:02:15.000000000 +0200
23086 @@ -0,0 +1,118 @@
23088 + * TP-LINK TL-WR703N/TL-MR10U board support
23090 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
23091 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
23093 + * This program is free software; you can redistribute it and/or modify it
23094 + * under the terms of the GNU General Public License version 2 as published
23095 + * by the Free Software Foundation.
23096 + */
23098 +#include <linux/gpio.h>
23100 +#include <asm/mach-ath79/ath79.h>
23102 +#include "dev-eth.h"
23103 +#include "dev-gpio-buttons.h"
23104 +#include "dev-leds-gpio.h"
23105 +#include "dev-m25p80.h"
23106 +#include "dev-usb.h"
23107 +#include "dev-wmac.h"
23108 +#include "machtypes.h"
23110 +#define TL_WR703N_GPIO_LED_SYSTEM 27
23111 +#define TL_WR703N_GPIO_BTN_RESET 11
23113 +#define TL_WR703N_GPIO_USB_POWER 8
23115 +#define TL_MR10U_GPIO_USB_POWER 18
23117 +#define TL_WR703N_KEYS_POLL_INTERVAL 20 /* msecs */
23118 +#define TL_WR703N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR703N_KEYS_POLL_INTERVAL)
23120 +static const char *tl_wr703n_part_probes[] = {
23121 + "tp-link",
23122 + NULL,
23125 +static struct flash_platform_data tl_wr703n_flash_data = {
23126 + .part_probes = tl_wr703n_part_probes,
23129 +static struct gpio_led tl_wr703n_leds_gpio[] __initdata = {
23131 + .name = "tp-link:blue:system",
23132 + .gpio = TL_WR703N_GPIO_LED_SYSTEM,
23133 + .active_low = 1,
23134 + },
23137 +static struct gpio_keys_button tl_wr703n_gpio_keys[] __initdata = {
23139 + .desc = "reset",
23140 + .type = EV_KEY,
23141 + .code = KEY_RESTART,
23142 + .debounce_interval = TL_WR703N_KEYS_DEBOUNCE_INTERVAL,
23143 + .gpio = TL_WR703N_GPIO_BTN_RESET,
23144 + .active_low = 0,
23148 +static void __init common_setup(unsigned usb_power_gpio, bool sec_ethernet)
23150 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23151 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
23153 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
23154 + ath79_setup_ar933x_phy4_switch(false, false);
23156 + ath79_register_m25p80(&tl_wr703n_flash_data);
23157 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr703n_leds_gpio),
23158 + tl_wr703n_leds_gpio);
23159 + ath79_register_gpio_keys_polled(-1, TL_WR703N_KEYS_POLL_INTERVAL,
23160 + ARRAY_SIZE(tl_wr703n_gpio_keys),
23161 + tl_wr703n_gpio_keys);
23163 + gpio_request_one(usb_power_gpio,
23164 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
23165 + "USB power");
23166 + ath79_register_usb();
23168 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
23170 + ath79_register_mdio(0, 0x0);
23171 + ath79_register_eth(0);
23173 + if (sec_ethernet)
23175 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
23176 + ath79_register_eth(1);
23179 + ath79_register_wmac(ee, mac);
23182 +static void __init tl_mr10u_setup(void)
23184 + common_setup(TL_MR10U_GPIO_USB_POWER, false);
23187 +MIPS_MACHINE(ATH79_MACH_TL_MR10U, "TL-MR10U", "TP-LINK TL-MR10U",
23188 + tl_mr10u_setup);
23190 +static void __init tl_wr703n_setup(void)
23192 + common_setup(TL_WR703N_GPIO_USB_POWER, false);
23195 +MIPS_MACHINE(ATH79_MACH_TL_WR703N, "TL-WR703N", "TP-LINK TL-WR703N v1",
23196 + tl_wr703n_setup);
23198 +static void __init tl_wr710n_setup(void)
23200 + common_setup(TL_WR703N_GPIO_USB_POWER, true);
23203 +MIPS_MACHINE(ATH79_MACH_TL_WR710N, "TL-WR710N", "TP-LINK TL-WR710N v1",
23204 + tl_wr710n_setup);
23205 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr720n-v3.c linux-4.1.43/arch/mips/ath79/mach-tl-wr720n-v3.c
23206 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr720n-v3.c 1970-01-01 01:00:00.000000000 +0100
23207 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr720n-v3.c 2017-08-06 20:02:15.000000000 +0200
23208 @@ -0,0 +1,108 @@
23210 + * TP-LINK TL-WR720N board support
23212 + * Copyright (C) 2011 dongyuqi <729650915@qq.com>
23213 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
23214 + * Copyright (C) 2013 yousong <yszhou4tech@gmail.com>
23216 + * This program is free software; you can redistribute it and/or modify it
23217 + * under the terms of the GNU General Public License version 2 as published
23218 + * by the Free Software Foundation.
23219 + */
23221 +#include <linux/gpio.h>
23223 +#include <asm/mach-ath79/ath79.h>
23225 +#include "dev-eth.h"
23226 +#include "dev-gpio-buttons.h"
23227 +#include "dev-leds-gpio.h"
23228 +#include "dev-m25p80.h"
23229 +#include "dev-usb.h"
23230 +#include "dev-wmac.h"
23231 +#include "machtypes.h"
23233 +#define TL_WR720N_GPIO_LED_SYSTEM 27
23234 +#define TL_WR720N_GPIO_BTN_RESET 11
23235 +#define TL_WR720N_GPIO_BTN_SW1 18
23236 +#define TL_WR720N_GPIO_BTN_SW2 20
23238 +#define TL_WR720N_GPIO_USB_POWER 8
23240 +#define TL_WR720N_KEYS_POLL_INTERVAL 20 /* msecs */
23241 +#define TL_WR720N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR720N_KEYS_POLL_INTERVAL)
23243 +static const char *tl_wr720n_part_probes[] = {
23244 + "tp-link",
23245 + NULL,
23248 +static struct flash_platform_data tl_wr720n_flash_data = {
23249 + .part_probes = tl_wr720n_part_probes,
23252 +static struct gpio_led tl_wr720n_leds_gpio[] __initdata = {
23254 + .name = "tp-link:blue:system",
23255 + .gpio = TL_WR720N_GPIO_LED_SYSTEM,
23256 + .active_low = 1,
23257 + },
23260 +static struct gpio_keys_button tl_wr720n_gpio_keys[] __initdata = {
23262 + .desc = "reset",
23263 + .type = EV_KEY,
23264 + .code = KEY_RESTART,
23265 + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
23266 + .gpio = TL_WR720N_GPIO_BTN_RESET,
23267 + .active_low = 0,
23268 + }, {
23269 + .desc = "sw1",
23270 + .type = EV_KEY,
23271 + .code = BTN_0,
23272 + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
23273 + .gpio = TL_WR720N_GPIO_BTN_SW1,
23274 + .active_low = 0,
23275 + }, {
23276 + .desc = "sw2",
23277 + .type = EV_KEY,
23278 + .code = BTN_1,
23279 + .debounce_interval = TL_WR720N_KEYS_DEBOUNCE_INTERVAL,
23280 + .gpio = TL_WR720N_GPIO_BTN_SW2,
23281 + .active_low = 0,
23285 +static void __init tl_wr720n_v3_setup(void)
23287 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23288 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
23290 + /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
23291 + ath79_setup_ar933x_phy4_switch(false, false);
23293 + ath79_register_m25p80(&tl_wr720n_flash_data);
23294 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr720n_leds_gpio),
23295 + tl_wr720n_leds_gpio);
23296 + ath79_register_gpio_keys_polled(-1, TL_WR720N_KEYS_POLL_INTERVAL,
23297 + ARRAY_SIZE(tl_wr720n_gpio_keys),
23298 + tl_wr720n_gpio_keys);
23300 + gpio_request_one(TL_WR720N_GPIO_USB_POWER,
23301 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
23302 + "USB power");
23303 + ath79_register_usb();
23305 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
23306 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
23308 + ath79_register_mdio(0, 0x0);
23309 + ath79_register_eth(0);
23310 + ath79_register_eth(1);
23312 + ath79_register_wmac(ee, mac);
23315 +MIPS_MACHINE(ATH79_MACH_TL_WR720N_V3, "TL-WR720N-v3", "TP-LINK TL-WR720N v3/v4",
23316 + tl_wr720n_v3_setup);
23317 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr741nd-v4.c linux-4.1.43/arch/mips/ath79/mach-tl-wr741nd-v4.c
23318 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr741nd-v4.c 1970-01-01 01:00:00.000000000 +0100
23319 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr741nd-v4.c 2017-08-06 20:02:15.000000000 +0200
23320 @@ -0,0 +1,187 @@
23322 + * TP-LINK TL-WR741ND v4/TL-MR3220 v2 board support
23324 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
23326 + * This program is free software; you can redistribute it and/or modify it
23327 + * under the terms of the GNU General Public License version 2 as published
23328 + * by the Free Software Foundation.
23329 + */
23331 +#include <linux/gpio.h>
23333 +#include <asm/mach-ath79/ath79.h>
23334 +#include <asm/mach-ath79/ar71xx_regs.h>
23336 +#include "common.h"
23337 +#include "dev-eth.h"
23338 +#include "dev-gpio-buttons.h"
23339 +#include "dev-leds-gpio.h"
23340 +#include "dev-m25p80.h"
23341 +#include "dev-usb.h"
23342 +#include "dev-wmac.h"
23343 +#include "machtypes.h"
23345 +#define TL_WR741NDV4_GPIO_BTN_RESET 11
23346 +#define TL_WR741NDV4_GPIO_BTN_WPS 26
23348 +#define TL_WR741NDV4_GPIO_LED_WLAN 0
23349 +#define TL_WR741NDV4_GPIO_LED_QSS 1
23350 +#define TL_WR741NDV4_GPIO_LED_WAN 13
23351 +#define TL_WR741NDV4_GPIO_LED_LAN1 14
23352 +#define TL_WR741NDV4_GPIO_LED_LAN2 15
23353 +#define TL_WR741NDV4_GPIO_LED_LAN3 16
23354 +#define TL_WR741NDV4_GPIO_LED_LAN4 17
23355 +#define TL_WR741NDV4_GPIO_LED_SYSTEM 27
23357 +#define TL_MR3220V2_GPIO_BTN_WPS 11
23358 +#define TL_MR3220V2_GPIO_BTN_WIFI 24
23360 +#define TL_MR3220V2_GPIO_LED_3G 26
23361 +#define TL_MR3220V2_GPIO_USB_POWER 8
23363 +#define TL_WR741NDV4_KEYS_POLL_INTERVAL 20 /* msecs */
23364 +#define TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741NDV4_KEYS_POLL_INTERVAL)
23366 +static const char *tl_wr741ndv4_part_probes[] = {
23367 + "tp-link",
23368 + NULL,
23371 +static struct flash_platform_data tl_wr741ndv4_flash_data = {
23372 + .part_probes = tl_wr741ndv4_part_probes,
23375 +static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
23377 + .name = "tp-link:green:lan1",
23378 + .gpio = TL_WR741NDV4_GPIO_LED_LAN1,
23379 + .active_low = 0,
23380 + }, {
23381 + .name = "tp-link:green:lan2",
23382 + .gpio = TL_WR741NDV4_GPIO_LED_LAN2,
23383 + .active_low = 0,
23384 + }, {
23385 + .name = "tp-link:green:lan3",
23386 + .gpio = TL_WR741NDV4_GPIO_LED_LAN3,
23387 + .active_low = 0,
23388 + }, {
23389 + .name = "tp-link:green:lan4",
23390 + .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
23391 + .active_low = 1,
23392 + }, {
23393 + .name = "tp-link:green:qss",
23394 + .gpio = TL_WR741NDV4_GPIO_LED_QSS,
23395 + .active_low = 0,
23396 + }, {
23397 + .name = "tp-link:green:system",
23398 + .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
23399 + .active_low = 1,
23400 + }, {
23401 + .name = "tp-link:green:wan",
23402 + .gpio = TL_WR741NDV4_GPIO_LED_WAN,
23403 + .active_low = 0,
23404 + }, {
23405 + .name = "tp-link:green:wlan",
23406 + .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
23407 + .active_low = 0,
23408 + }, {
23409 + /* the 3G LED is only present on the MR3220 v2 */
23410 + .name = "tp-link:green:3g",
23411 + .gpio = TL_MR3220V2_GPIO_LED_3G,
23412 + .active_low = 0,
23413 + },
23416 +static struct gpio_keys_button tl_wr741ndv4_gpio_keys[] __initdata = {
23418 + .desc = "reset",
23419 + .type = EV_KEY,
23420 + .code = KEY_RESTART,
23421 + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
23422 + .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
23423 + .active_low = 0,
23424 + }, {
23425 + .desc = "WPS",
23426 + .type = EV_KEY,
23427 + .code = KEY_WPS_BUTTON,
23428 + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
23429 + .gpio = TL_WR741NDV4_GPIO_BTN_WPS,
23430 + .active_low = 0,
23434 +static struct gpio_keys_button tl_mr3220v2_gpio_keys[] __initdata = {
23436 + .desc = "WPS",
23437 + .type = EV_KEY,
23438 + .code = KEY_WPS_BUTTON,
23439 + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
23440 + .gpio = TL_MR3220V2_GPIO_BTN_WPS,
23441 + .active_low = 0,
23442 + }, {
23443 + .desc = "WIFI button",
23444 + .type = EV_KEY,
23445 + .code = KEY_RFKILL,
23446 + .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
23447 + .gpio = TL_MR3220V2_GPIO_BTN_WIFI,
23448 + .active_low = 0,
23452 +static void __init tl_ap121_setup(void)
23454 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23455 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
23457 + ath79_setup_ar933x_phy4_switch(true, true);
23459 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
23460 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
23461 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
23462 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
23463 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
23465 + ath79_register_m25p80(&tl_wr741ndv4_flash_data);
23466 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
23467 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
23469 + ath79_register_mdio(0, 0x0);
23470 + ath79_register_eth(1);
23471 + ath79_register_eth(0);
23473 + ath79_register_wmac(ee, mac);
23476 +static void __init tl_wr741ndv4_setup(void)
23478 + tl_ap121_setup();
23480 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
23481 + tl_wr741ndv4_leds_gpio);
23482 + ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
23483 + ARRAY_SIZE(tl_wr741ndv4_gpio_keys),
23484 + tl_wr741ndv4_gpio_keys);
23487 +MIPS_MACHINE(ATH79_MACH_TL_WR741ND_V4, "TL-WR741ND-v4",
23488 + "TP-LINK TL-WR741ND v4", tl_wr741ndv4_setup);
23490 +static void __init tl_mr3220v2_setup(void)
23492 + tl_ap121_setup();
23494 + gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
23495 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
23496 + "USB power");
23497 + ath79_register_usb();
23499 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
23500 + tl_wr741ndv4_leds_gpio);
23501 + ath79_register_gpio_keys_polled(1, TL_WR741NDV4_KEYS_POLL_INTERVAL,
23502 + ARRAY_SIZE(tl_mr3220v2_gpio_keys),
23503 + tl_mr3220v2_gpio_keys);
23506 +MIPS_MACHINE(ATH79_MACH_TL_MR3220_V2, "TL-MR3220-v2",
23507 + "TP-LINK TL-MR3220 v2", tl_mr3220v2_setup);
23508 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr741nd.c linux-4.1.43/arch/mips/ath79/mach-tl-wr741nd.c
23509 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr741nd.c 1970-01-01 01:00:00.000000000 +0100
23510 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr741nd.c 2017-08-06 20:02:15.000000000 +0200
23511 @@ -0,0 +1,130 @@
23513 + * TP-LINK TL-WR741ND board support
23515 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
23517 + * This program is free software; you can redistribute it and/or modify it
23518 + * under the terms of the GNU General Public License version 2 as published
23519 + * by the Free Software Foundation.
23520 + */
23522 +#include <asm/mach-ath79/ath79.h>
23523 +#include <asm/mach-ath79/ar71xx_regs.h>
23525 +#include "common.h"
23526 +#include "dev-ap9x-pci.h"
23527 +#include "dev-eth.h"
23528 +#include "dev-gpio-buttons.h"
23529 +#include "dev-leds-gpio.h"
23530 +#include "dev-m25p80.h"
23531 +#include "machtypes.h"
23533 +#define TL_WR741ND_GPIO_LED_QSS 0
23534 +#define TL_WR741ND_GPIO_LED_SYSTEM 1
23535 +#define TL_WR741ND_GPIO_LED_LAN1 13
23536 +#define TL_WR741ND_GPIO_LED_LAN2 14
23537 +#define TL_WR741ND_GPIO_LED_LAN3 15
23538 +#define TL_WR741ND_GPIO_LED_LAN4 16
23539 +#define TL_WR741ND_GPIO_LED_WAN 17
23541 +#define TL_WR741ND_GPIO_BTN_RESET 11
23542 +#define TL_WR741ND_GPIO_BTN_QSS 12
23544 +#define TL_WR741ND_KEYS_POLL_INTERVAL 20 /* msecs */
23545 +#define TL_WR741ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR741ND_KEYS_POLL_INTERVAL)
23547 +static const char *tl_wr741nd_part_probes[] = {
23548 + "tp-link",
23549 + NULL,
23552 +static struct flash_platform_data tl_wr741nd_flash_data = {
23553 + .part_probes = tl_wr741nd_part_probes,
23556 +static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
23558 + .name = "tp-link:green:lan1",
23559 + .gpio = TL_WR741ND_GPIO_LED_LAN1,
23560 + .active_low = 1,
23561 + }, {
23562 + .name = "tp-link:green:lan2",
23563 + .gpio = TL_WR741ND_GPIO_LED_LAN2,
23564 + .active_low = 1,
23565 + }, {
23566 + .name = "tp-link:green:lan3",
23567 + .gpio = TL_WR741ND_GPIO_LED_LAN3,
23568 + .active_low = 1,
23569 + }, {
23570 + .name = "tp-link:green:lan4",
23571 + .gpio = TL_WR741ND_GPIO_LED_LAN4,
23572 + .active_low = 1,
23573 + }, {
23574 + .name = "tp-link:green:qss",
23575 + .gpio = TL_WR741ND_GPIO_LED_QSS,
23576 + .active_low = 1,
23577 + }, {
23578 + .name = "tp-link:green:system",
23579 + .gpio = TL_WR741ND_GPIO_LED_SYSTEM,
23580 + .active_low = 1,
23581 + }, {
23582 + .name = "tp-link:green:wan",
23583 + .gpio = TL_WR741ND_GPIO_LED_WAN,
23584 + .active_low = 1,
23585 + },
23588 +static struct gpio_keys_button tl_wr741nd_gpio_keys[] __initdata = {
23590 + .desc = "reset",
23591 + .type = EV_KEY,
23592 + .code = KEY_RESTART,
23593 + .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
23594 + .gpio = TL_WR741ND_GPIO_BTN_RESET,
23595 + .active_low = 1,
23596 + }, {
23597 + .desc = "qss",
23598 + .type = EV_KEY,
23599 + .code = KEY_WPS_BUTTON,
23600 + .debounce_interval = TL_WR741ND_KEYS_DEBOUNCE_INTERVAL,
23601 + .gpio = TL_WR741ND_GPIO_BTN_QSS,
23602 + .active_low = 1,
23606 +static void __init tl_wr741nd_setup(void)
23608 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23609 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
23611 + ath79_register_m25p80(&tl_wr741nd_flash_data);
23613 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
23614 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
23615 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
23616 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
23617 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
23619 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
23620 + tl_wr741nd_leds_gpio);
23622 + ath79_register_gpio_keys_polled(-1, TL_WR741ND_KEYS_POLL_INTERVAL,
23623 + ARRAY_SIZE(tl_wr741nd_gpio_keys),
23624 + tl_wr741nd_gpio_keys);
23626 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
23627 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
23629 + ath79_register_mdio(0, 0x0);
23631 + /* LAN ports */
23632 + ath79_register_eth(1);
23634 + /* WAN port */
23635 + ath79_register_eth(0);
23637 + ap9x_pci_setup_wmac_led_pin(0, 1);
23638 + ap91_pci_init(ee, mac);
23640 +MIPS_MACHINE(ATH79_MACH_TL_WR741ND, "TL-WR741ND", "TP-LINK TL-WR741ND",
23641 + tl_wr741nd_setup);
23642 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n-v8.c linux-4.1.43/arch/mips/ath79/mach-tl-wr841n-v8.c
23643 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n-v8.c 1970-01-01 01:00:00.000000000 +0100
23644 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr841n-v8.c 2017-08-06 20:02:15.000000000 +0200
23645 @@ -0,0 +1,286 @@
23647 + * TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support
23649 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
23651 + * This program is free software; you can redistribute it and/or modify it
23652 + * under the terms of the GNU General Public License version 2 as published
23653 + * by the Free Software Foundation.
23654 + */
23656 +#include <linux/gpio.h>
23657 +#include <linux/platform_device.h>
23659 +#include <asm/mach-ath79/ath79.h>
23660 +#include <asm/mach-ath79/ar71xx_regs.h>
23662 +#include "common.h"
23663 +#include "dev-eth.h"
23664 +#include "dev-gpio-buttons.h"
23665 +#include "dev-leds-gpio.h"
23666 +#include "dev-m25p80.h"
23667 +#include "dev-usb.h"
23668 +#include "dev-wmac.h"
23669 +#include "machtypes.h"
23671 +#define TL_WR841NV8_GPIO_LED_WLAN 13
23672 +#define TL_WR841NV8_GPIO_LED_QSS 15
23673 +#define TL_WR841NV8_GPIO_LED_WAN 18
23674 +#define TL_WR841NV8_GPIO_LED_LAN1 19
23675 +#define TL_WR841NV8_GPIO_LED_LAN2 20
23676 +#define TL_WR841NV8_GPIO_LED_LAN3 21
23677 +#define TL_WR841NV8_GPIO_LED_LAN4 12
23678 +#define TL_WR841NV8_GPIO_LED_SYSTEM 14
23680 +#define TL_WR841NV8_GPIO_BTN_RESET 17
23681 +#define TL_WR841NV8_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
23683 +#define TL_MR3420V2_GPIO_LED_3G 11
23684 +#define TL_MR3420V2_GPIO_USB_POWER 4
23686 +#define TL_WR941NDV5_GPIO_LED_WLAN 13
23687 +#define TL_WR941NDV5_GPIO_LED_QSS 15
23688 +#define TL_WR941NDV5_GPIO_LED_WAN 18
23689 +#define TL_WR941NDV5_GPIO_LED_LAN1 19
23690 +#define TL_WR941NDV5_GPIO_LED_LAN2 20
23691 +#define TL_WR941NDV5_GPIO_LED_LAN3 2
23692 +#define TL_WR941NDV5_GPIO_LED_LAN4 3
23693 +#define TL_WR941NDV5_GPIO_LED_SYSTEM 14
23695 +#define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */
23696 +#define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL)
23698 +static const char *tl_wr841n_v8_part_probes[] = {
23699 + "tp-link",
23700 + NULL,
23703 +static struct flash_platform_data tl_wr841n_v8_flash_data = {
23704 + .part_probes = tl_wr841n_v8_part_probes,
23707 +static struct gpio_led tl_wr841n_v8_leds_gpio[] __initdata = {
23709 + .name = "tp-link:green:lan1",
23710 + .gpio = TL_WR841NV8_GPIO_LED_LAN1,
23711 + .active_low = 1,
23712 + }, {
23713 + .name = "tp-link:green:lan2",
23714 + .gpio = TL_WR841NV8_GPIO_LED_LAN2,
23715 + .active_low = 1,
23716 + }, {
23717 + .name = "tp-link:green:lan3",
23718 + .gpio = TL_WR841NV8_GPIO_LED_LAN3,
23719 + .active_low = 1,
23720 + }, {
23721 + .name = "tp-link:green:lan4",
23722 + .gpio = TL_WR841NV8_GPIO_LED_LAN4,
23723 + .active_low = 1,
23724 + }, {
23725 + .name = "tp-link:green:qss",
23726 + .gpio = TL_WR841NV8_GPIO_LED_QSS,
23727 + .active_low = 1,
23728 + }, {
23729 + .name = "tp-link:green:system",
23730 + .gpio = TL_WR841NV8_GPIO_LED_SYSTEM,
23731 + .active_low = 1,
23732 + }, {
23733 + .name = "tp-link:green:wan",
23734 + .gpio = TL_WR841NV8_GPIO_LED_WAN,
23735 + .active_low = 1,
23736 + }, {
23737 + .name = "tp-link:green:wlan",
23738 + .gpio = TL_WR841NV8_GPIO_LED_WLAN,
23739 + .active_low = 1,
23740 + }, {
23741 + /* the 3G LED is only present on the MR3420 v2 */
23742 + .name = "tp-link:green:3g",
23743 + .gpio = TL_MR3420V2_GPIO_LED_3G,
23744 + .active_low = 1,
23745 + },
23748 +static struct gpio_keys_button tl_wr841n_v8_gpio_keys[] __initdata = {
23750 + .desc = "Reset button",
23751 + .type = EV_KEY,
23752 + .code = KEY_RESTART,
23753 + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
23754 + .gpio = TL_WR841NV8_GPIO_BTN_RESET,
23755 + .active_low = 1,
23756 + }, {
23757 + .desc = "RFKILL switch",
23758 + .type = EV_SW,
23759 + .code = KEY_RFKILL,
23760 + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
23761 + .gpio = TL_WR841NV8_GPIO_SW_RFKILL,
23762 + .active_low = 0,
23766 +static struct gpio_keys_button tl_mr3420v2_gpio_keys[] __initdata = {
23768 + .desc = "Reset button",
23769 + .type = EV_KEY,
23770 + .code = KEY_RESTART,
23771 + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
23772 + .gpio = TL_WR841NV8_GPIO_BTN_RESET,
23773 + .active_low = 1,
23774 + }, {
23775 + .desc = "WPS",
23776 + .type = EV_KEY,
23777 + .code = KEY_WPS_BUTTON,
23778 + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL,
23779 + .gpio = TL_WR841NV8_GPIO_SW_RFKILL,
23780 + .active_low = 0,
23784 +static struct gpio_led tl_wr941nd_v5_leds_gpio[] __initdata = {
23786 + .name = "tp-link:green:lan1",
23787 + .gpio = TL_WR941NDV5_GPIO_LED_LAN1,
23788 + .active_low = 1,
23789 + }, {
23790 + .name = "tp-link:green:lan2",
23791 + .gpio = TL_WR941NDV5_GPIO_LED_LAN2,
23792 + .active_low = 1,
23793 + }, {
23794 + .name = "tp-link:green:lan3",
23795 + .gpio = TL_WR941NDV5_GPIO_LED_LAN3,
23796 + .active_low = 1,
23797 + }, {
23798 + .name = "tp-link:green:lan4",
23799 + .gpio = TL_WR941NDV5_GPIO_LED_LAN4,
23800 + .active_low = 1,
23801 + }, {
23802 + .name = "tp-link:green:qss",
23803 + .gpio = TL_WR941NDV5_GPIO_LED_QSS,
23804 + .active_low = 1,
23805 + }, {
23806 + .name = "tp-link:green:system",
23807 + .gpio = TL_WR941NDV5_GPIO_LED_SYSTEM,
23808 + .active_low = 1,
23809 + }, {
23810 + .name = "tp-link:green:wan",
23811 + .gpio = TL_WR941NDV5_GPIO_LED_WAN,
23812 + .active_low = 1,
23813 + }, {
23814 + .name = "tp-link:green:wlan",
23815 + .gpio = TL_WR941NDV5_GPIO_LED_WLAN,
23816 + .active_low = 1,
23817 + },
23820 +static void __init tl_ap123_setup(void)
23822 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
23823 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
23825 + /* Disable JTAG, enabling GPIOs 0-3 */
23826 + /* Configure OBS4 line, for GPIO 4*/
23827 + ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
23828 + AR934X_GPIO_FUNC_CLK_OBS4_EN);
23830 + /* config gpio4 as normal gpio function */
23831 + ath79_gpio_output_select(TL_MR3420V2_GPIO_USB_POWER,
23832 + AR934X_GPIO_OUT_GPIO);
23834 + ath79_register_m25p80(&tl_wr841n_v8_flash_data);
23836 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
23838 + ath79_register_mdio(1, 0x0);
23840 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
23841 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
23843 + /* GMAC0 is connected to the PHY0 of the internal switch */
23844 + ath79_switch_data.phy4_mii_en = 1;
23845 + ath79_switch_data.phy_poll_mask = BIT(0);
23846 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
23847 + ath79_eth0_data.phy_mask = BIT(0);
23848 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
23849 + ath79_register_eth(0);
23851 + /* GMAC1 is connected to the internal switch */
23852 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
23853 + ath79_register_eth(1);
23855 + ath79_register_wmac(ee, mac);
23858 +static void __init tl_wr841n_v8_setup(void)
23860 + tl_ap123_setup();
23862 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio) - 1,
23863 + tl_wr841n_v8_leds_gpio);
23865 + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
23866 + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
23867 + tl_wr841n_v8_gpio_keys);
23870 +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8",
23871 + tl_wr841n_v8_setup);
23874 +static void __init tl_wr842n_v2_setup(void)
23876 + tl_ap123_setup();
23878 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
23879 + tl_wr841n_v8_leds_gpio);
23881 + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
23882 + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
23883 + tl_wr841n_v8_gpio_keys);
23885 + gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,
23886 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
23887 + "USB power");
23889 + ath79_register_usb();
23892 +MIPS_MACHINE(ATH79_MACH_TL_WR842N_V2, "TL-WR842N-v2", "TP-LINK TL-WR842N/ND v2",
23893 + tl_wr842n_v2_setup);
23895 +static void __init tl_mr3420v2_setup(void)
23897 + tl_ap123_setup();
23899 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio),
23900 + tl_wr841n_v8_leds_gpio);
23902 + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
23903 + ARRAY_SIZE(tl_mr3420v2_gpio_keys),
23904 + tl_mr3420v2_gpio_keys);
23906 + /* enable power for the USB port */
23907 + gpio_request_one(TL_MR3420V2_GPIO_USB_POWER,
23908 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
23909 + "USB power");
23911 + ath79_register_usb();
23914 +MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2",
23915 + tl_mr3420v2_setup);
23918 +static void __init tl_wr941nd_v5_setup(void)
23920 + tl_ap123_setup();
23922 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v5_leds_gpio),
23923 + tl_wr941nd_v5_leds_gpio);
23925 + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL,
23926 + ARRAY_SIZE(tl_wr841n_v8_gpio_keys),
23927 + tl_wr841n_v8_gpio_keys);
23930 +MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V5, "TL-WR941ND-v5", "TP-LINK TL-WR941N/ND v5",
23931 + tl_wr941nd_v5_setup);
23932 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n-v9.c linux-4.1.43/arch/mips/ath79/mach-tl-wr841n-v9.c
23933 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n-v9.c 1970-01-01 01:00:00.000000000 +0100
23934 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr841n-v9.c 2017-08-06 20:02:15.000000000 +0200
23935 @@ -0,0 +1,144 @@
23937 + * TP-LINK TL-WR841N/ND v9
23939 + * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
23941 + * This program is free software; you can redistribute it and/or modify it
23942 + * under the terms of the GNU General Public License version 2 as published
23943 + * by the Free Software Foundation.
23944 + */
23946 +#include <linux/gpio.h>
23947 +#include <linux/platform_device.h>
23949 +#include <asm/mach-ath79/ath79.h>
23950 +#include <asm/mach-ath79/ar71xx_regs.h>
23952 +#include "common.h"
23953 +#include "dev-eth.h"
23954 +#include "dev-gpio-buttons.h"
23955 +#include "dev-leds-gpio.h"
23956 +#include "dev-m25p80.h"
23957 +#include "dev-wmac.h"
23958 +#include "machtypes.h"
23960 +#define TL_WR841NV9_GPIO_LED_WLAN 13
23961 +#define TL_WR841NV9_GPIO_LED_QSS 3
23962 +#define TL_WR841NV9_GPIO_LED_WAN 4
23963 +#define TL_WR841NV9_GPIO_LED_LAN1 16
23964 +#define TL_WR841NV9_GPIO_LED_LAN2 15
23965 +#define TL_WR841NV9_GPIO_LED_LAN3 14
23966 +#define TL_WR841NV9_GPIO_LED_LAN4 11
23968 +#define TL_WR841NV9_GPIO_BTN_RESET 12
23969 +#define TL_WR841NV9_GPIO_BTN_WIFI 17
23971 +#define TL_WR841NV9_KEYS_POLL_INTERVAL 20 /* msecs */
23972 +#define TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV9_KEYS_POLL_INTERVAL)
23974 +static const char *tl_wr841n_v9_part_probes[] = {
23975 + "tp-link",
23976 + NULL,
23979 +static struct flash_platform_data tl_wr841n_v9_flash_data = {
23980 + .part_probes = tl_wr841n_v9_part_probes,
23983 +static struct gpio_led tl_wr841n_v9_leds_gpio[] __initdata = {
23985 + .name = "tp-link:green:lan1",
23986 + .gpio = TL_WR841NV9_GPIO_LED_LAN1,
23987 + .active_low = 1,
23988 + }, {
23989 + .name = "tp-link:green:lan2",
23990 + .gpio = TL_WR841NV9_GPIO_LED_LAN2,
23991 + .active_low = 1,
23992 + }, {
23993 + .name = "tp-link:green:lan3",
23994 + .gpio = TL_WR841NV9_GPIO_LED_LAN3,
23995 + .active_low = 1,
23996 + }, {
23997 + .name = "tp-link:green:lan4",
23998 + .gpio = TL_WR841NV9_GPIO_LED_LAN4,
23999 + .active_low = 1,
24000 + }, {
24001 + .name = "tp-link:green:qss",
24002 + .gpio = TL_WR841NV9_GPIO_LED_QSS,
24003 + .active_low = 1,
24004 + }, {
24005 + .name = "tp-link:green:wan",
24006 + .gpio = TL_WR841NV9_GPIO_LED_WAN,
24007 + .active_low = 1,
24008 + }, {
24009 + .name = "tp-link:green:wlan",
24010 + .gpio = TL_WR841NV9_GPIO_LED_WLAN,
24011 + .active_low = 1,
24012 + },
24015 +static struct gpio_keys_button tl_wr841n_v9_gpio_keys[] __initdata = {
24017 + .desc = "Reset button",
24018 + .type = EV_KEY,
24019 + .code = KEY_RESTART,
24020 + .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
24021 + .gpio = TL_WR841NV9_GPIO_BTN_RESET,
24022 + .active_low = 1,
24023 + }, {
24024 + .desc = "WIFI button",
24025 + .type = EV_KEY,
24026 + .code = KEY_RFKILL,
24027 + .debounce_interval = TL_WR841NV9_KEYS_DEBOUNCE_INTERVAL,
24028 + .gpio = TL_WR841NV9_GPIO_BTN_WIFI,
24029 + .active_low = 1,
24034 +static void __init tl_ap143_setup(void)
24036 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
24037 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24038 + u8 tmpmac[ETH_ALEN];
24040 + ath79_register_m25p80(&tl_wr841n_v9_flash_data);
24042 + ath79_setup_ar933x_phy4_switch(false, false);
24044 + ath79_register_mdio(0, 0x0);
24046 + /* LAN */
24047 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
24048 + ath79_eth1_data.duplex = DUPLEX_FULL;
24049 + ath79_switch_data.phy_poll_mask |= BIT(4);
24050 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
24051 + ath79_register_eth(1);
24053 + /* WAN */
24054 + ath79_switch_data.phy4_mii_en = 1;
24055 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
24056 + ath79_eth0_data.duplex = DUPLEX_FULL;
24057 + ath79_eth0_data.speed = SPEED_100;
24058 + ath79_eth0_data.phy_mask = BIT(4);
24059 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
24060 + ath79_register_eth(0);
24062 + ath79_init_mac(tmpmac, mac, 0);
24063 + ath79_register_wmac(ee, tmpmac);
24066 +static void __init tl_wr841n_v9_setup(void)
24068 + tl_ap143_setup();
24070 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v9_leds_gpio),
24071 + tl_wr841n_v9_leds_gpio);
24073 + ath79_register_gpio_keys_polled(1, TL_WR841NV9_KEYS_POLL_INTERVAL,
24074 + ARRAY_SIZE(tl_wr841n_v9_gpio_keys),
24075 + tl_wr841n_v9_gpio_keys);
24078 +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V9, "TL-WR841N-v9", "TP-LINK TL-WR841N/ND v9",
24079 + tl_wr841n_v9_setup);
24080 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n.c linux-4.1.43/arch/mips/ath79/mach-tl-wr841n.c
24081 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr841n.c 1970-01-01 01:00:00.000000000 +0100
24082 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr841n.c 2017-08-06 20:02:15.000000000 +0200
24083 @@ -0,0 +1,140 @@
24085 + * TP-LINK TL-WR841N/ND v1 board support
24087 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
24089 + * This program is free software; you can redistribute it and/or modify it
24090 + * under the terms of the GNU General Public License version 2 as published
24091 + * by the Free Software Foundation.
24092 + */
24094 +#include <linux/mtd/mtd.h>
24095 +#include <linux/mtd/partitions.h>
24096 +#include <linux/platform_device.h>
24098 +#include <asm/mach-ath79/ath79.h>
24100 +#include "dev-dsa.h"
24101 +#include "dev-eth.h"
24102 +#include "dev-gpio-buttons.h"
24103 +#include "dev-leds-gpio.h"
24104 +#include "dev-m25p80.h"
24105 +#include "machtypes.h"
24106 +#include "pci.h"
24108 +#define TL_WR841ND_V1_GPIO_LED_SYSTEM 2
24109 +#define TL_WR841ND_V1_GPIO_LED_QSS_GREEN 4
24110 +#define TL_WR841ND_V1_GPIO_LED_QSS_RED 5
24112 +#define TL_WR841ND_V1_GPIO_BTN_RESET 3
24113 +#define TL_WR841ND_V1_GPIO_BTN_QSS 7
24115 +#define TL_WR841ND_V1_KEYS_POLL_INTERVAL 20 /* msecs */
24116 +#define TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL \
24117 + (3 * TL_WR841ND_V1_KEYS_POLL_INTERVAL)
24119 +static struct mtd_partition tl_wr841n_v1_partitions[] = {
24121 + .name = "redboot",
24122 + .offset = 0,
24123 + .size = 0x020000,
24124 + .mask_flags = MTD_WRITEABLE,
24125 + }, {
24126 + .name = "kernel",
24127 + .offset = 0x020000,
24128 + .size = 0x140000,
24129 + }, {
24130 + .name = "rootfs",
24131 + .offset = 0x160000,
24132 + .size = 0x280000,
24133 + }, {
24134 + .name = "config",
24135 + .offset = 0x3e0000,
24136 + .size = 0x020000,
24137 + .mask_flags = MTD_WRITEABLE,
24138 + }, {
24139 + .name = "firmware",
24140 + .offset = 0x020000,
24141 + .size = 0x3c0000,
24145 +static struct flash_platform_data tl_wr841n_v1_flash_data = {
24146 + .parts = tl_wr841n_v1_partitions,
24147 + .nr_parts = ARRAY_SIZE(tl_wr841n_v1_partitions),
24150 +static struct gpio_led tl_wr841n_v1_leds_gpio[] __initdata = {
24152 + .name = "tp-link:green:system",
24153 + .gpio = TL_WR841ND_V1_GPIO_LED_SYSTEM,
24154 + .active_low = 1,
24155 + }, {
24156 + .name = "tp-link:red:qss",
24157 + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_RED,
24158 + }, {
24159 + .name = "tp-link:green:qss",
24160 + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_GREEN,
24164 +static struct gpio_keys_button tl_wr841n_v1_gpio_keys[] __initdata = {
24166 + .desc = "reset",
24167 + .type = EV_KEY,
24168 + .code = KEY_RESTART,
24169 + .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
24170 + .gpio = TL_WR841ND_V1_GPIO_BTN_RESET,
24171 + .active_low = 1,
24172 + }, {
24173 + .desc = "qss",
24174 + .type = EV_KEY,
24175 + .code = KEY_WPS_BUTTON,
24176 + .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
24177 + .gpio = TL_WR841ND_V1_GPIO_BTN_QSS,
24178 + .active_low = 1,
24182 +static struct dsa_chip_data tl_wr841n_v1_dsa_chip = {
24183 + .port_names[0] = "wan",
24184 + .port_names[1] = "lan1",
24185 + .port_names[2] = "lan2",
24186 + .port_names[3] = "lan3",
24187 + .port_names[4] = "lan4",
24188 + .port_names[5] = "cpu",
24191 +static struct dsa_platform_data tl_wr841n_v1_dsa_data = {
24192 + .nr_chips = 1,
24193 + .chip = &tl_wr841n_v1_dsa_chip,
24196 +static void __init tl_wr841n_v1_setup(void)
24198 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
24200 + ath79_register_mdio(0, 0x0);
24202 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
24203 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
24204 + ath79_eth0_data.speed = SPEED_100;
24205 + ath79_eth0_data.duplex = DUPLEX_FULL;
24207 + ath79_register_eth(0);
24208 + ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
24209 + &tl_wr841n_v1_dsa_data);
24211 + ath79_register_m25p80(&tl_wr841n_v1_flash_data);
24213 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v1_leds_gpio),
24214 + tl_wr841n_v1_leds_gpio);
24216 + ath79_register_gpio_keys_polled(-1, TL_WR841ND_V1_KEYS_POLL_INTERVAL,
24217 + ARRAY_SIZE(tl_wr841n_v1_gpio_keys),
24218 + tl_wr841n_v1_gpio_keys);
24219 + ath79_register_pci();
24222 +MIPS_MACHINE(ATH79_MACH_TL_WR841N_V1, "TL-WR841N-v1.5", "TP-LINK TL-WR841N v1",
24223 + tl_wr841n_v1_setup);
24224 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr941nd-v6.c linux-4.1.43/arch/mips/ath79/mach-tl-wr941nd-v6.c
24225 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr941nd-v6.c 1970-01-01 01:00:00.000000000 +0100
24226 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr941nd-v6.c 2017-08-06 20:02:15.000000000 +0200
24227 @@ -0,0 +1,149 @@
24229 + * TP-LINK TL-WR941N/ND v6 board support
24231 + * Copyright (C) 2015 Matthias Schiffer <mschiffer@universe-factory.net>
24233 + * This program is free software; you can redistribute it and/or modify it
24234 + * under the terms of the GNU General Public License version 2 as published
24235 + * by the Free Software Foundation.
24236 + */
24238 +#include <linux/gpio.h>
24239 +#include <linux/platform_device.h>
24241 +#include <asm/mach-ath79/ath79.h>
24242 +#include <asm/mach-ath79/ar71xx_regs.h>
24244 +#include "common.h"
24245 +#include "dev-eth.h"
24246 +#include "dev-gpio-buttons.h"
24247 +#include "dev-leds-gpio.h"
24248 +#include "dev-m25p80.h"
24249 +#include "dev-wmac.h"
24250 +#include "machtypes.h"
24253 +#define TL_WR941ND_V6_GPIO_LED_QSS 3
24254 +#define TL_WR941ND_V6_GPIO_LED_WAN 14
24255 +#define TL_WR941ND_V6_GPIO_LED_WAN_RED 15
24256 +#define TL_WR941ND_V6_GPIO_LED_LAN1 7
24257 +#define TL_WR941ND_V6_GPIO_LED_LAN2 6
24258 +#define TL_WR941ND_V6_GPIO_LED_LAN3 5
24259 +#define TL_WR941ND_V6_GPIO_LED_LAN4 4
24260 +#define TL_WR941ND_V6_GPIO_LED_WLAN 8
24261 +#define TL_WR941ND_V6_GPIO_LED_SYSTEM 18
24263 +#define TL_WR941ND_V6_GPIO_BTN_RESET 1
24264 +#define TL_WR941ND_V6_GPIO_BTN_RFKILL 2
24266 +#define TL_WR941ND_V6_KEYS_POLL_INTERVAL 20
24267 +#define TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_V6_KEYS_POLL_INTERVAL)
24270 +static struct gpio_led tl_wr941nd_v6_leds_gpio[] __initdata = {
24272 + .name = "tp-link:blue:qss",
24273 + .gpio = TL_WR941ND_V6_GPIO_LED_QSS,
24274 + .active_low = 1,
24275 + },
24277 + .name = "tp-link:blue:wan",
24278 + .gpio = TL_WR941ND_V6_GPIO_LED_WAN,
24279 + .active_low = 1,
24280 + },
24282 + .name = "tp-link:red:wan",
24283 + .gpio = TL_WR941ND_V6_GPIO_LED_WAN_RED,
24284 + .active_low = 0,
24285 + },
24287 + .name = "tp-link:blue:lan1",
24288 + .gpio = TL_WR941ND_V6_GPIO_LED_LAN1,
24289 + .active_low = 1,
24290 + },
24292 + .name = "tp-link:blue:lan2",
24293 + .gpio = TL_WR941ND_V6_GPIO_LED_LAN2,
24294 + .active_low = 1,
24295 + },
24297 + .name = "tp-link:blue:lan3",
24298 + .gpio = TL_WR941ND_V6_GPIO_LED_LAN3,
24299 + .active_low = 1,
24300 + },
24302 + .name = "tp-link:blue:lan4",
24303 + .gpio = TL_WR941ND_V6_GPIO_LED_LAN4,
24304 + .active_low = 1,
24305 + },
24307 + .name = "tp-link:blue:wlan",
24308 + .gpio = TL_WR941ND_V6_GPIO_LED_WLAN,
24309 + .active_low = 1,
24310 + },
24312 + .name = "tp-link:blue:system",
24313 + .gpio = TL_WR941ND_V6_GPIO_LED_SYSTEM,
24314 + .active_low = 1,
24315 + },
24318 +static struct gpio_keys_button tl_wr941nd_v6_gpio_keys[] __initdata = {
24320 + .desc = "Reset button",
24321 + .type = EV_KEY,
24322 + .code = KEY_RESTART,
24323 + .debounce_interval = TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL,
24324 + .gpio = TL_WR941ND_V6_GPIO_BTN_RESET,
24325 + .active_low = 1,
24326 + }, {
24327 + .desc = "RFKILL button",
24328 + .type = EV_KEY,
24329 + .code = KEY_RFKILL,
24330 + .debounce_interval = TL_WR941ND_V6_KEYS_DEBOUNCE_INTERVAL,
24331 + .gpio = TL_WR941ND_V6_GPIO_BTN_RFKILL,
24332 + .active_low = 1,
24337 +static const char *tl_wr941n_v6_part_probes[] = {
24338 + "tp-link",
24339 + NULL,
24342 +static struct flash_platform_data tl_wr941n_v6_flash_data = {
24343 + .part_probes = tl_wr941n_v6_part_probes,
24347 +static void __init tl_wr941nd_v6_setup(void)
24349 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
24350 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24352 + ath79_register_m25p80(&tl_wr941n_v6_flash_data);
24354 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_v6_leds_gpio),
24355 + tl_wr941nd_v6_leds_gpio);
24357 + ath79_register_gpio_keys_polled(-1, TL_WR941ND_V6_KEYS_POLL_INTERVAL,
24358 + ARRAY_SIZE(tl_wr941nd_v6_gpio_keys),
24359 + tl_wr941nd_v6_gpio_keys);
24361 + ath79_register_mdio(0, 0x0);
24363 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
24364 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
24366 + ath79_switch_data.phy4_mii_en = 1;
24368 + ath79_register_eth(0);
24369 + ath79_register_eth(1);
24371 + ath79_register_wmac(ee, mac);
24375 +MIPS_MACHINE(ATH79_MACH_TL_WR941ND_V6, "TL-WR941ND-v6", "TP-LINK TL-WR941N/ND v6",
24376 + tl_wr941nd_v6_setup);
24377 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr941nd.c linux-4.1.43/arch/mips/ath79/mach-tl-wr941nd.c
24378 --- linux-4.1.43.orig/arch/mips/ath79/mach-tl-wr941nd.c 1970-01-01 01:00:00.000000000 +0100
24379 +++ linux-4.1.43/arch/mips/ath79/mach-tl-wr941nd.c 2017-08-06 20:02:15.000000000 +0200
24380 @@ -0,0 +1,121 @@
24382 + * TP-LINK TL-WR941ND board support
24384 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
24386 + * This program is free software; you can redistribute it and/or modify it
24387 + * under the terms of the GNU General Public License version 2 as published
24388 + * by the Free Software Foundation.
24389 + */
24391 +#include <linux/platform_device.h>
24393 +#include <asm/mach-ath79/ath79.h>
24395 +#include "dev-dsa.h"
24396 +#include "dev-eth.h"
24397 +#include "dev-gpio-buttons.h"
24398 +#include "dev-leds-gpio.h"
24399 +#include "dev-m25p80.h"
24400 +#include "dev-wmac.h"
24401 +#include "machtypes.h"
24403 +#define TL_WR941ND_GPIO_LED_SYSTEM 2
24404 +#define TL_WR941ND_GPIO_LED_QSS_RED 4
24405 +#define TL_WR941ND_GPIO_LED_QSS_GREEN 5
24406 +#define TL_WR941ND_GPIO_LED_WLAN 9
24408 +#define TL_WR941ND_GPIO_BTN_RESET 3
24409 +#define TL_WR941ND_GPIO_BTN_QSS 7
24411 +#define TL_WR941ND_KEYS_POLL_INTERVAL 20 /* msecs */
24412 +#define TL_WR941ND_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR941ND_KEYS_POLL_INTERVAL)
24414 +static const char *tl_wr941nd_part_probes[] = {
24415 + "tp-link",
24416 + NULL,
24419 +static struct flash_platform_data tl_wr941nd_flash_data = {
24420 + .part_probes = tl_wr941nd_part_probes,
24423 +static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
24425 + .name = "tp-link:green:system",
24426 + .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
24427 + .active_low = 1,
24428 + }, {
24429 + .name = "tp-link:red:qss",
24430 + .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
24431 + }, {
24432 + .name = "tp-link:green:qss",
24433 + .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
24434 + }, {
24435 + .name = "tp-link:green:wlan",
24436 + .gpio = TL_WR941ND_GPIO_LED_WLAN,
24437 + .active_low = 1,
24441 +static struct gpio_keys_button tl_wr941nd_gpio_keys[] __initdata = {
24443 + .desc = "reset",
24444 + .type = EV_KEY,
24445 + .code = KEY_RESTART,
24446 + .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
24447 + .gpio = TL_WR941ND_GPIO_BTN_RESET,
24448 + .active_low = 1,
24449 + }, {
24450 + .desc = "qss",
24451 + .type = EV_KEY,
24452 + .code = KEY_WPS_BUTTON,
24453 + .debounce_interval = TL_WR941ND_KEYS_DEBOUNCE_INTERVAL,
24454 + .gpio = TL_WR941ND_GPIO_BTN_QSS,
24455 + .active_low = 1,
24459 +static struct dsa_chip_data tl_wr941nd_dsa_chip = {
24460 + .port_names[0] = "wan",
24461 + .port_names[1] = "lan1",
24462 + .port_names[2] = "lan2",
24463 + .port_names[3] = "lan3",
24464 + .port_names[4] = "lan4",
24465 + .port_names[5] = "cpu",
24468 +static struct dsa_platform_data tl_wr941nd_dsa_data = {
24469 + .nr_chips = 1,
24470 + .chip = &tl_wr941nd_dsa_chip,
24473 +static void __init tl_wr941nd_setup(void)
24475 + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
24476 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
24478 + ath79_register_mdio(0, 0x0);
24480 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
24481 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
24482 + ath79_eth0_data.speed = SPEED_100;
24483 + ath79_eth0_data.duplex = DUPLEX_FULL;
24485 + ath79_register_eth(0);
24486 + ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
24487 + &tl_wr941nd_dsa_data);
24489 + ath79_register_m25p80(&tl_wr941nd_flash_data);
24491 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
24492 + tl_wr941nd_leds_gpio);
24494 + ath79_register_gpio_keys_polled(-1, TL_WR941ND_KEYS_POLL_INTERVAL,
24495 + ARRAY_SIZE(tl_wr941nd_gpio_keys),
24496 + tl_wr941nd_gpio_keys);
24497 + ath79_register_wmac(eeprom, mac);
24500 +MIPS_MACHINE(ATH79_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
24501 + tl_wr941nd_setup);
24502 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-tube2h.c linux-4.1.43/arch/mips/ath79/mach-tube2h.c
24503 --- linux-4.1.43.orig/arch/mips/ath79/mach-tube2h.c 1970-01-01 01:00:00.000000000 +0100
24504 +++ linux-4.1.43/arch/mips/ath79/mach-tube2h.c 2017-08-06 20:02:15.000000000 +0200
24505 @@ -0,0 +1,118 @@
24507 + * ALFA NETWORK Tube2H board support
24509 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
24511 + * This program is free software; you can redistribute it and/or modify it
24512 + * under the terms of the GNU General Public License version 2 as published
24513 + * by the Free Software Foundation.
24514 + */
24516 +#include <linux/gpio.h>
24518 +#include <asm/mach-ath79/ath79.h>
24519 +#include <asm/mach-ath79/ar71xx_regs.h>
24521 +#include "common.h"
24522 +#include "dev-eth.h"
24523 +#include "dev-gpio-buttons.h"
24524 +#include "dev-leds-gpio.h"
24525 +#include "dev-m25p80.h"
24526 +#include "dev-wmac.h"
24527 +#include "machtypes.h"
24529 +#define TUBE2H_GPIO_LED_SIGNAL4 0
24530 +#define TUBE2H_GPIO_LED_SIGNAL3 1
24531 +#define TUBE2H_GPIO_LED_SIGNAL2 13
24532 +#define TUBE2H_GPIO_LED_LAN 17
24533 +#define TUBE2H_GPIO_LED_SIGNAL1 27
24534 +#define TUBE2H_GPIO_EXT_LNA 28
24536 +#define TUBE2H_GPIO_BTN_RESET 12
24538 +#define TUBE2H_KEYS_POLL_INTERVAL 20 /* msecs */
24539 +#define TUBE2H_KEYS_DEBOUNCE_INTERVAL (3 * TUBE2H_KEYS_POLL_INTERVAL)
24541 +#define TUBE2H_ART_ADDRESS 0x1f7f0000
24542 +#define TUBE2H_LAN_MAC_OFFSET 0x06
24543 +#define TUBE2H_CALDATA_OFFSET 0x1000
24545 +static struct gpio_led tube2h_leds_gpio[] __initdata = {
24547 + .name = "alfa:blue:lan",
24548 + .gpio = TUBE2H_GPIO_LED_LAN,
24549 + .active_low = 1,
24550 + },
24552 + .name = "alfa:red:signal1",
24553 + .gpio = TUBE2H_GPIO_LED_SIGNAL1,
24554 + .active_low = 1,
24555 + },
24557 + .name = "alfa:orange:signal2",
24558 + .gpio = TUBE2H_GPIO_LED_SIGNAL2,
24559 + .active_low = 0,
24560 + },
24562 + .name = "alfa:green:signal3",
24563 + .gpio = TUBE2H_GPIO_LED_SIGNAL3,
24564 + .active_low = 0,
24565 + },
24567 + .name = "alfa:green:signal4",
24568 + .gpio = TUBE2H_GPIO_LED_SIGNAL4,
24569 + .active_low = 0,
24570 + },
24573 +static struct gpio_keys_button tube2h_gpio_keys[] __initdata = {
24575 + .desc = "Reset button",
24576 + .type = EV_KEY,
24577 + .code = KEY_RESTART,
24578 + .debounce_interval = TUBE2H_KEYS_DEBOUNCE_INTERVAL,
24579 + .gpio = TUBE2H_GPIO_BTN_RESET,
24580 + .active_low = 1,
24581 + },
24584 +static void __init tube2h_setup(void)
24586 + u8 *art = (u8 *) KSEG1ADDR(TUBE2H_ART_ADDRESS);
24587 + u32 t;
24589 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_JTAG_DISABLE |
24590 + AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
24591 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
24592 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
24593 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
24594 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
24596 + /* Ensure that GPIO26 and GPIO27 are controllable by software */
24597 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
24598 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
24599 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
24601 + gpio_request_one(TUBE2H_GPIO_EXT_LNA,
24602 + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
24603 + "external LNA0");
24605 + ath79_register_wmac(art + TUBE2H_CALDATA_OFFSET, NULL);
24607 + ath79_register_m25p80(NULL);
24609 + ath79_register_leds_gpio(-1, ARRAY_SIZE(tube2h_leds_gpio),
24610 + tube2h_leds_gpio);
24611 + ath79_register_gpio_keys_polled(-1, TUBE2H_KEYS_POLL_INTERVAL,
24612 + ARRAY_SIZE(tube2h_gpio_keys),
24613 + tube2h_gpio_keys);
24615 + ath79_init_mac(ath79_eth0_data.mac_addr,
24616 + art + TUBE2H_LAN_MAC_OFFSET, 0);
24617 + ath79_register_mdio(0, 0x0);
24618 + ath79_register_eth(0);
24621 +MIPS_MACHINE(ATH79_MACH_TUBE2H, "TUBE2H", "ALFA NETWORK Tube2H",
24622 + tube2h_setup);
24624 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ubnt-xm.c linux-4.1.43/arch/mips/ath79/mach-ubnt-xm.c
24625 --- linux-4.1.43.orig/arch/mips/ath79/mach-ubnt-xm.c 2017-08-06 01:56:14.000000000 +0200
24626 +++ linux-4.1.43/arch/mips/ath79/mach-ubnt-xm.c 2017-08-06 20:02:15.000000000 +0200
24627 @@ -12,15 +12,26 @@
24629 #include <linux/init.h>
24630 #include <linux/pci.h>
24631 +#include <linux/platform_device.h>
24632 #include <linux/ath9k_platform.h>
24633 +#include <linux/etherdevice.h>
24634 +#include <linux/ar8216_platform.h>
24636 +#include <asm/mach-ath79/ath79.h>
24637 #include <asm/mach-ath79/irq.h>
24638 +#include <asm/mach-ath79/ar71xx_regs.h>
24640 -#include "machtypes.h"
24641 +#include <linux/platform_data/phy-at803x.h>
24643 +#include "common.h"
24644 +#include "dev-ap9x-pci.h"
24645 +#include "dev-eth.h"
24646 #include "dev-gpio-buttons.h"
24647 #include "dev-leds-gpio.h"
24648 -#include "dev-spi.h"
24649 -#include "pci.h"
24650 +#include "dev-m25p80.h"
24651 +#include "dev-usb.h"
24652 +#include "dev-wmac.h"
24653 +#include "machtypes.h"
24655 #define UBNT_XM_GPIO_LED_L1 0
24656 #define UBNT_XM_GPIO_LED_L2 1
24657 @@ -32,23 +43,23 @@
24658 #define UBNT_XM_KEYS_POLL_INTERVAL 20
24659 #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
24661 -#define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
24662 +#define UBNT_XM_EEPROM_ADDR 0x1fff1000
24664 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
24666 - .name = "ubnt-xm:red:link1",
24667 + .name = "ubnt:red:link1",
24668 .gpio = UBNT_XM_GPIO_LED_L1,
24669 .active_low = 0,
24670 }, {
24671 - .name = "ubnt-xm:orange:link2",
24672 + .name = "ubnt:orange:link2",
24673 .gpio = UBNT_XM_GPIO_LED_L2,
24674 .active_low = 0,
24675 }, {
24676 - .name = "ubnt-xm:green:link3",
24677 + .name = "ubnt:green:link3",
24678 .gpio = UBNT_XM_GPIO_LED_L3,
24679 .active_low = 0,
24680 }, {
24681 - .name = "ubnt-xm:green:link4",
24682 + .name = "ubnt:green:link4",
24683 .gpio = UBNT_XM_GPIO_LED_L4,
24684 .active_low = 0,
24686 @@ -65,62 +76,625 @@
24690 -static struct spi_board_info ubnt_xm_spi_info[] = {
24691 +#define UBNT_M_WAN_PHYMASK BIT(4)
24693 +static void __init ubnt_xm_init(void)
24695 + u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
24696 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
24697 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
24699 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
24700 + ubnt_xm_leds_gpio);
24702 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24703 + ARRAY_SIZE(ubnt_xm_gpio_keys),
24704 + ubnt_xm_gpio_keys);
24706 + ath79_register_m25p80(NULL);
24707 + ap91_pci_init(eeprom, NULL);
24709 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
24710 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
24711 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
24712 + ath79_register_eth(0);
24715 +MIPS_MACHINE(ATH79_MACH_UBNT_XM,
24716 + "UBNT-XM",
24717 + "Ubiquiti Networks XM (rev 1.0) board",
24718 + ubnt_xm_init);
24720 +MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
24721 + ubnt_xm_init);
24723 +static void __init ubnt_rocket_m_setup(void)
24725 + ubnt_xm_init();
24726 + ath79_register_usb();
24729 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
24730 + ubnt_rocket_m_setup);
24732 +static void __init ubnt_nano_m_setup(void)
24734 + ubnt_xm_init();
24735 + ath79_register_eth(1);
24738 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
24739 + ubnt_nano_m_setup);
24741 +static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
24743 - .bus_num = 0,
24744 - .chip_select = 0,
24745 - .max_speed_hz = 25000000,
24746 - .modalias = "mx25l6405d",
24747 + .name = "ubnt:green:globe",
24748 + .gpio = 0,
24749 + .active_low = 1,
24750 + }, {
24751 + .name = "ubnt:green:power",
24752 + .gpio = 11,
24753 + .active_low = 1,
24754 + .default_state = LEDS_GPIO_DEFSTATE_ON,
24758 -static struct ath79_spi_platform_data ubnt_xm_spi_data = {
24759 - .bus_num = 0,
24760 - .num_chipselect = 1,
24761 +static void __init ubnt_airrouter_setup(void)
24763 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
24764 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24766 + ath79_register_m25p80(NULL);
24767 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
24769 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
24770 + ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
24772 + ath79_register_eth(1);
24773 + ath79_register_eth(0);
24774 + ath79_register_usb();
24776 + ap91_pci_init(ee, NULL);
24777 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
24778 + ubnt_airrouter_leds_gpio);
24780 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24781 + ARRAY_SIZE(ubnt_xm_gpio_keys),
24782 + ubnt_xm_gpio_keys);
24785 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
24786 + ubnt_airrouter_setup);
24788 +static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
24790 + .name = "ubnt:orange:dome",
24791 + .gpio = 1,
24792 + .active_low = 0,
24793 + }, {
24794 + .name = "ubnt:green:dome",
24795 + .gpio = 0,
24796 + .active_low = 0,
24800 -#ifdef CONFIG_PCI
24801 -static struct ath9k_platform_data ubnt_xm_eeprom_data;
24802 +static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
24804 + .name = "ubnt:orange:front",
24805 + .gpio = 1,
24806 + .active_low = 0,
24807 + }, {
24808 + .name = "ubnt:green:front",
24809 + .gpio = 0,
24810 + .active_low = 0,
24814 -static int ubnt_xm_pci_plat_dev_init(struct pci_dev *dev)
24815 +static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
24817 + .name = "ubnt:white:front",
24818 + .gpio = 1,
24819 + .active_low = 0,
24820 + }, {
24821 + .name = "ubnt:blue:front",
24822 + .gpio = 0,
24823 + .active_low = 0,
24828 +static void __init ubnt_unifi_setup(void)
24830 - switch (PCI_SLOT(dev->devfn)) {
24831 - case 0:
24832 - dev->dev.platform_data = &ubnt_xm_eeprom_data;
24833 - break;
24834 + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
24835 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24837 + ath79_register_m25p80(NULL);
24839 + ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
24841 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
24842 + ath79_register_eth(0);
24844 + ap91_pci_init(ee, NULL);
24846 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
24847 + ubnt_unifi_leds_gpio);
24849 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24850 + ARRAY_SIZE(ubnt_xm_gpio_keys),
24851 + ubnt_xm_gpio_keys);
24854 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
24855 + ubnt_unifi_setup);
24858 +#define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
24859 +#define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
24861 +static void __init ubnt_unifi_outdoor_setup(void)
24863 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
24864 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
24865 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24867 + ath79_register_m25p80(NULL);
24869 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
24870 + UBNT_UNIFIOD_2ND_PHYMASK));
24872 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
24873 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
24874 + ath79_register_eth(0);
24875 + ath79_register_eth(1);
24877 + ap91_pci_init(ee, NULL);
24879 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
24880 + ubnt_unifi_outdoor_leds_gpio);
24882 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24883 + ARRAY_SIZE(ubnt_xm_gpio_keys),
24884 + ubnt_xm_gpio_keys);
24887 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
24888 + "Ubiquiti UniFiAP Outdoor",
24889 + ubnt_unifi_outdoor_setup);
24892 +static void __init ubnt_unifi_outdoor_plus_setup(void)
24894 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
24895 + u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
24896 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
24898 + ath79_register_m25p80(NULL);
24900 + ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
24901 + UBNT_UNIFIOD_2ND_PHYMASK));
24903 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
24904 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
24905 + ath79_register_eth(0);
24906 + ath79_register_eth(1);
24908 + ap91_pci_init(ee, NULL);
24910 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
24911 + ubnt_unifi_outdoor_plus_leds_gpio);
24913 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24914 + ARRAY_SIZE(ubnt_xm_gpio_keys),
24915 + ubnt_xm_gpio_keys);
24918 +MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
24919 + "Ubiquiti UniFiAP Outdoor+",
24920 + ubnt_unifi_outdoor_plus_setup);
24923 +static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
24925 + .name = "ubnt:white:dome",
24926 + .gpio = 12,
24927 + }, {
24928 + .name = "ubnt:blue:dome",
24929 + .gpio = 13,
24933 +static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
24935 + .desc = "reset",
24936 + .type = EV_KEY,
24937 + .code = KEY_RESTART,
24938 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
24939 + .gpio = 17,
24940 + .active_low = 1,
24944 +static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
24945 + .mode = AR8327_PAD_MAC_RGMII,
24946 + .txclk_delay_en = true,
24947 + .rxclk_delay_en = true,
24948 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
24949 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
24952 +static struct ar8327_platform_data uap_pro_ar8327_data = {
24953 + .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
24954 + .port0_cfg = {
24955 + .force_link = 1,
24956 + .speed = AR8327_PORT_SPEED_1000,
24957 + .duplex = 1,
24958 + .txpause = 1,
24959 + .rxpause = 1,
24960 + },
24963 +static struct mdio_board_info uap_pro_mdio0_info[] = {
24965 + .bus_id = "ag71xx-mdio.0",
24966 + .phy_addr = 0,
24967 + .platform_data = &uap_pro_ar8327_data,
24968 + },
24971 +#define UAP_PRO_MAC0_OFFSET 0x0000
24972 +#define UAP_PRO_MAC1_OFFSET 0x0006
24973 +#define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
24974 +#define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
24976 +static void __init ubnt_uap_pro_setup(void)
24978 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
24980 + ath79_register_m25p80(NULL);
24982 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
24983 + ubnt_uap_pro_gpio_leds);
24984 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
24985 + ARRAY_SIZE(uap_pro_gpio_keys),
24986 + uap_pro_gpio_keys);
24988 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
24989 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
24991 + ath79_register_mdio(0, 0x0);
24992 + mdiobus_register_board_info(uap_pro_mdio0_info,
24993 + ARRAY_SIZE(uap_pro_mdio0_info));
24995 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
24996 + ath79_init_mac(ath79_eth0_data.mac_addr,
24997 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
24999 + /* GMAC0 is connected to an AR8327 switch */
25000 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25001 + ath79_eth0_data.phy_mask = BIT(0);
25002 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
25003 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
25004 + ath79_register_eth(0);
25007 +MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
25008 + ubnt_uap_pro_setup);
25010 +#define UBNT_XW_GPIO_LED_L1 11
25011 +#define UBNT_XW_GPIO_LED_L2 16
25012 +#define UBNT_XW_GPIO_LED_L3 13
25013 +#define UBNT_XW_GPIO_LED_L4 14
25015 +static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
25017 + .name = "ubnt:red:link1",
25018 + .gpio = UBNT_XW_GPIO_LED_L1,
25019 + .active_low = 1,
25020 + }, {
25021 + .name = "ubnt:orange:link2",
25022 + .gpio = UBNT_XW_GPIO_LED_L2,
25023 + .active_low = 1,
25024 + }, {
25025 + .name = "ubnt:green:link3",
25026 + .gpio = UBNT_XW_GPIO_LED_L3,
25027 + .active_low = 1,
25028 + }, {
25029 + .name = "ubnt:green:link4",
25030 + .gpio = UBNT_XW_GPIO_LED_L4,
25031 + .active_low = 1,
25032 + },
25035 +#define UBNT_ROCKET_TI_GPIO_LED_L1 16
25036 +#define UBNT_ROCKET_TI_GPIO_LED_L2 17
25037 +#define UBNT_ROCKET_TI_GPIO_LED_L3 18
25038 +#define UBNT_ROCKET_TI_GPIO_LED_L4 19
25039 +#define UBNT_ROCKET_TI_GPIO_LED_L5 20
25040 +#define UBNT_ROCKET_TI_GPIO_LED_L6 21
25041 +static struct gpio_led ubnt_rocket_ti_leds_gpio[] __initdata = {
25043 + .name = "ubnt:green:link1",
25044 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L1,
25045 + .active_low = 1,
25046 + }, {
25047 + .name = "ubnt:green:link2",
25048 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L2,
25049 + .active_low = 1,
25050 + }, {
25051 + .name = "ubnt:green:link3",
25052 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L3,
25053 + .active_low = 1,
25054 + }, {
25055 + .name = "ubnt:green:link4",
25056 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L4,
25057 + .active_low = 0,
25058 + }, {
25059 + .name = "ubnt:green:link5",
25060 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L5,
25061 + .active_low = 0,
25062 + }, {
25063 + .name = "ubnt:green:link6",
25064 + .gpio = UBNT_ROCKET_TI_GPIO_LED_L6,
25065 + .active_low = 0,
25066 + },
25069 - return 0;
25070 +static void __init ubnt_xw_init(void)
25072 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
25074 + ath79_register_m25p80(NULL);
25076 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
25077 + ubnt_xw_leds_gpio);
25078 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
25079 + ARRAY_SIZE(ubnt_xm_gpio_keys),
25080 + ubnt_xm_gpio_keys);
25082 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
25083 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
25086 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
25087 + ath79_init_mac(ath79_eth0_data.mac_addr,
25088 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
25090 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
25091 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
25094 -static void __init ubnt_xm_pci_init(void)
25095 +static void __init ubnt_nano_m_xw_setup(void)
25097 - memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
25098 - sizeof(ubnt_xm_eeprom_data.eeprom_data));
25099 + ubnt_xw_init();
25101 - ath79_pci_set_plat_dev_init(ubnt_xm_pci_plat_dev_init);
25102 - ath79_register_pci();
25103 + /* GMAC0 is connected to an AR8326 switch */
25104 + ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
25105 + ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
25106 + ath79_eth0_data.speed = SPEED_100;
25107 + ath79_eth0_data.duplex = DUPLEX_FULL;
25108 + ath79_register_eth(0);
25110 -#else
25111 -static inline void ubnt_xm_pci_init(void) {}
25112 -#endif /* CONFIG_PCI */
25114 -static void __init ubnt_xm_init(void)
25115 +static void __init ubnt_loco_m_xw_setup(void)
25117 - ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
25118 - ubnt_xm_leds_gpio);
25119 + ubnt_xw_init();
25121 + ath79_register_mdio(0, ~BIT(1));
25122 + ath79_eth0_data.phy_mask = BIT(1);
25123 + ath79_register_eth(0);
25126 +static void __init ubnt_rocket_m_xw_setup(void)
25128 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
25130 + ath79_register_m25p80(NULL);
25132 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
25133 + ubnt_xw_leds_gpio);
25134 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
25135 - ARRAY_SIZE(ubnt_xm_gpio_keys),
25136 - ubnt_xm_gpio_keys);
25137 + ARRAY_SIZE(ubnt_xm_gpio_keys),
25138 + ubnt_xm_gpio_keys);
25140 - ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
25141 - ARRAY_SIZE(ubnt_xm_spi_info));
25142 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
25143 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
25145 - ubnt_xm_pci_init();
25146 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
25147 + ath79_init_mac(ath79_eth0_data.mac_addr,
25148 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
25150 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25151 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
25153 + ath79_register_mdio(0, ~BIT(4));
25154 + ath79_eth0_data.phy_mask = BIT(4);
25155 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
25156 + ath79_register_eth(0);
25159 -MIPS_MACHINE(ATH79_MACH_UBNT_XM,
25160 - "UBNT-XM",
25161 - "Ubiquiti Networks XM (rev 1.0) board",
25162 - ubnt_xm_init);
25163 +static struct at803x_platform_data ubnt_rocket_m_ti_at803_data = {
25164 + .disable_smarteee = 1,
25165 + .enable_rgmii_rx_delay = 1,
25166 + .enable_rgmii_tx_delay = 1,
25168 +static struct mdio_board_info ubnt_rocket_m_ti_mdio_info[] = {
25170 + .bus_id = "ag71xx-mdio.0",
25171 + .phy_addr = 4,
25172 + .platform_data = &ubnt_rocket_m_ti_at803_data,
25173 + },
25176 +static void __init ubnt_rocket_m_ti_setup(void)
25178 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
25180 + ath79_register_m25p80(NULL);
25182 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rocket_ti_leds_gpio),
25183 + ubnt_rocket_ti_leds_gpio);
25184 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
25185 + ARRAY_SIZE(ubnt_xm_gpio_keys),
25186 + ubnt_xm_gpio_keys);
25188 + ap91_pci_init(eeprom + 0x1000, NULL);
25190 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
25191 + ath79_setup_ar934x_eth_rx_delay(3, 3);
25192 + ath79_init_mac(ath79_eth0_data.mac_addr,
25193 + eeprom + UAP_PRO_MAC0_OFFSET, 0);
25194 + ath79_init_mac(ath79_eth1_data.mac_addr,
25195 + eeprom + UAP_PRO_MAC1_OFFSET, 0);
25197 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25198 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
25199 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
25200 + ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
25202 + mdiobus_register_board_info(ubnt_rocket_m_ti_mdio_info,
25203 + ARRAY_SIZE(ubnt_rocket_m_ti_mdio_info));
25204 + ath79_register_mdio(0, 0x0);
25207 + ath79_eth0_data.phy_mask = BIT(4);
25208 + /* read out from vendor */
25209 + ath79_eth0_pll_data.pll_1000 = 0x2000000;
25210 + ath79_eth0_pll_data.pll_10 = 0x1313;
25211 + ath79_register_eth(0);
25213 + ath79_register_mdio(1, 0x0);
25214 + ath79_eth1_data.phy_mask = BIT(3);
25215 + ath79_register_eth(1);
25219 +MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
25220 + ubnt_nano_m_xw_setup);
25222 +MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
25223 + ubnt_loco_m_xw_setup);
25225 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_XW, "UBNT-RM-XW", "Ubiquiti Rocket M XW",
25226 + ubnt_rocket_m_xw_setup);
25228 +MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_TI, "UBNT-RM-TI", "Ubiquiti Rocket M TI",
25229 + ubnt_rocket_m_ti_setup);
25231 +static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
25233 + .name = "ubnt:blue:wlan",
25234 + .gpio = 0,
25235 + }, {
25236 + .name = "ubnt:white:status",
25237 + .gpio = 1,
25238 + },
25241 +static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
25243 + .desc = "reset",
25244 + .type = EV_KEY,
25245 + .code = KEY_RESTART,
25246 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
25247 + .gpio = 12,
25248 + .active_low = 1,
25252 +static void __init ubnt_airgateway_setup(void)
25254 + u32 t;
25255 + u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
25256 + u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
25257 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
25260 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
25261 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
25262 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
25263 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
25264 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
25266 + t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
25267 + t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
25268 + ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
25270 + ath79_register_m25p80(NULL);
25271 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
25272 + ubnt_airgateway_gpio_leds);
25274 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
25275 + ARRAY_SIZE(airgateway_gpio_keys),
25276 + airgateway_gpio_keys);
25278 + ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
25279 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
25281 + ath79_register_mdio(0, 0x0);
25283 + ath79_register_eth(1);
25284 + ath79_register_eth(0);
25286 + ath79_register_wmac(ee, NULL);
25289 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
25290 + ubnt_airgateway_setup);
25292 +static struct gpio_led ubnt_airgateway_pro_gpio_leds[] __initdata = {
25294 + .name = "ubnt:blue:wlan",
25295 + .gpio = 13,
25296 + }, {
25297 + .name = "ubnt:white:status",
25298 + .gpio = 17,
25299 + },
25303 +static struct gpio_keys_button airgateway_pro_gpio_keys[] __initdata = {
25305 + .desc = "reset",
25306 + .type = EV_KEY,
25307 + .code = KEY_RESTART,
25308 + .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
25309 + .gpio = 12,
25310 + .active_low = 1,
25314 +static void __init ubnt_airgateway_pro_setup(void)
25316 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
25317 + u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
25319 + ath79_register_m25p80(NULL);
25320 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_pro_gpio_leds),
25321 + ubnt_airgateway_pro_gpio_leds);
25323 + ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
25324 + ARRAY_SIZE(airgateway_pro_gpio_keys),
25325 + airgateway_pro_gpio_keys);
25327 + ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
25328 + ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
25331 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
25333 + ath79_register_mdio(1, 0x0);
25335 + /* GMAC0 is left unused in this configuration */
25337 + /* GMAC1 is connected to MAC0 on the internal switch */
25338 + /* The PoE/WAN port connects to port 5 on the internal switch */
25339 + /* The LAN port connects to port 4 on the internal switch */
25340 + ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
25341 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
25342 + ath79_register_eth(1);
25346 +MIPS_MACHINE(ATH79_MACH_UBNT_AIRGWP, "UBNT-AGWP", "Ubiquiti AirGateway Pro",
25347 + ubnt_airgateway_pro_setup);
25348 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-ubnt.c linux-4.1.43/arch/mips/ath79/mach-ubnt.c
25349 --- linux-4.1.43.orig/arch/mips/ath79/mach-ubnt.c 1970-01-01 01:00:00.000000000 +0100
25350 +++ linux-4.1.43/arch/mips/ath79/mach-ubnt.c 2017-08-06 20:02:15.000000000 +0200
25351 @@ -0,0 +1,205 @@
25353 + * Ubiquiti RouterStation support
25355 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
25356 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
25357 + * Copyright (C) 2008 Ubiquiti <support@ubnt.com>
25359 + * This program is free software; you can redistribute it and/or modify it
25360 + * under the terms of the GNU General Public License version 2 as published
25361 + * by the Free Software Foundation.
25362 + */
25364 +#include <asm/mach-ath79/ath79.h>
25366 +#include "dev-eth.h"
25367 +#include "dev-gpio-buttons.h"
25368 +#include "dev-leds-gpio.h"
25369 +#include "dev-m25p80.h"
25370 +#include "dev-usb.h"
25371 +#include "machtypes.h"
25372 +#include "pci.h"
25374 +#define UBNT_RS_GPIO_LED_RF 2
25375 +#define UBNT_RS_GPIO_SW4 8
25377 +#define UBNT_LS_SR71_GPIO_LED_D25 0
25378 +#define UBNT_LS_SR71_GPIO_LED_D26 1
25379 +#define UBNT_LS_SR71_GPIO_LED_D24 2
25380 +#define UBNT_LS_SR71_GPIO_LED_D23 4
25381 +#define UBNT_LS_SR71_GPIO_LED_D22 5
25382 +#define UBNT_LS_SR71_GPIO_LED_D27 6
25383 +#define UBNT_LS_SR71_GPIO_LED_D28 7
25385 +#define UBNT_KEYS_POLL_INTERVAL 20 /* msecs */
25386 +#define UBNT_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_KEYS_POLL_INTERVAL)
25388 +static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
25390 + .name = "ubnt:green:rf",
25391 + .gpio = UBNT_RS_GPIO_LED_RF,
25392 + .active_low = 0,
25396 +static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
25398 + .name = "ubnt:green:d22",
25399 + .gpio = UBNT_LS_SR71_GPIO_LED_D22,
25400 + .active_low = 0,
25401 + }, {
25402 + .name = "ubnt:green:d23",
25403 + .gpio = UBNT_LS_SR71_GPIO_LED_D23,
25404 + .active_low = 0,
25405 + }, {
25406 + .name = "ubnt:green:d24",
25407 + .gpio = UBNT_LS_SR71_GPIO_LED_D24,
25408 + .active_low = 0,
25409 + }, {
25410 + .name = "ubnt:red:d25",
25411 + .gpio = UBNT_LS_SR71_GPIO_LED_D25,
25412 + .active_low = 0,
25413 + }, {
25414 + .name = "ubnt:red:d26",
25415 + .gpio = UBNT_LS_SR71_GPIO_LED_D26,
25416 + .active_low = 0,
25417 + }, {
25418 + .name = "ubnt:green:d27",
25419 + .gpio = UBNT_LS_SR71_GPIO_LED_D27,
25420 + .active_low = 0,
25421 + }, {
25422 + .name = "ubnt:green:d28",
25423 + .gpio = UBNT_LS_SR71_GPIO_LED_D28,
25424 + .active_low = 0,
25428 +static struct gpio_keys_button ubnt_gpio_keys[] __initdata = {
25430 + .desc = "sw4",
25431 + .type = EV_KEY,
25432 + .code = KEY_RESTART,
25433 + .debounce_interval = UBNT_KEYS_DEBOUNCE_INTERVAL,
25434 + .gpio = UBNT_RS_GPIO_SW4,
25435 + .active_low = 1,
25439 +static const char *ubnt_part_probes[] = {
25440 + "RedBoot",
25441 + NULL,
25444 +static struct flash_platform_data ubnt_flash_data = {
25445 + .part_probes = ubnt_part_probes,
25448 +static void __init ubnt_generic_setup(void)
25450 + ath79_register_m25p80(&ubnt_flash_data);
25452 + ath79_register_gpio_keys_polled(-1, UBNT_KEYS_POLL_INTERVAL,
25453 + ARRAY_SIZE(ubnt_gpio_keys),
25454 + ubnt_gpio_keys);
25455 + ath79_register_pci();
25458 +#define UBNT_RS_WAN_PHYMASK BIT(20)
25459 +#define UBNT_RS_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
25461 +static void __init ubnt_rs_setup(void)
25463 + ubnt_generic_setup();
25465 + ath79_register_mdio(0, ~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
25467 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
25468 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
25469 + ath79_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
25471 + /*
25472 + * There is Secondary MAC address duplicate problem with some
25473 + * UBNT HW batches. Do not increase Secondary MAC address by 1
25474 + * but do workaround with 'Locally Administrated' bit.
25475 + */
25476 + ath79_init_local_mac(ath79_eth1_data.mac_addr, ath79_mac_base);
25477 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
25478 + ath79_eth1_data.speed = SPEED_100;
25479 + ath79_eth1_data.duplex = DUPLEX_FULL;
25481 + ath79_register_eth(0);
25482 + ath79_register_eth(1);
25484 + ath79_register_usb();
25486 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
25487 + ubnt_rs_leds_gpio);
25490 +MIPS_MACHINE(ATH79_MACH_UBNT_RS, "UBNT-RS", "Ubiquiti RouterStation",
25491 + ubnt_rs_setup);
25493 +#define UBNT_RSPRO_WAN_PHYMASK BIT(4)
25494 +#define UBNT_RSPRO_LAN_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
25496 +static void __init ubnt_rspro_setup(void)
25498 + ubnt_generic_setup();
25500 + ath79_register_mdio(0, ~(UBNT_RSPRO_WAN_PHYMASK |
25501 + UBNT_RSPRO_LAN_PHYMASK));
25503 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
25504 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25505 + ath79_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
25507 + /*
25508 + * There is Secondary MAC address duplicate problem with some
25509 + * UBNT HW batches. Do not increase Secondary MAC address by 1
25510 + * but do workaround with 'Locally Administrated' bit.
25511 + */
25512 + ath79_init_local_mac(ath79_eth1_data.mac_addr, ath79_mac_base);
25513 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25514 + ath79_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
25515 + ath79_eth1_data.speed = SPEED_1000;
25516 + ath79_eth1_data.duplex = DUPLEX_FULL;
25518 + ath79_register_eth(0);
25519 + ath79_register_eth(1);
25521 + ath79_register_usb();
25523 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
25524 + ubnt_rs_leds_gpio);
25527 +MIPS_MACHINE(ATH79_MACH_UBNT_RSPRO, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
25528 + ubnt_rspro_setup);
25530 +static void __init ubnt_lsx_setup(void)
25532 + ubnt_generic_setup();
25535 +MIPS_MACHINE(ATH79_MACH_UBNT_LSX, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup);
25537 +#define UBNT_LSSR71_PHY_MASK BIT(1)
25539 +static void __init ubnt_lssr71_setup(void)
25541 + ubnt_generic_setup();
25543 + ath79_register_mdio(0, ~UBNT_LSSR71_PHY_MASK);
25545 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
25546 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
25547 + ath79_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
25549 + ath79_register_eth(0);
25551 + ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
25552 + ubnt_ls_sr71_leds_gpio);
25555 +MIPS_MACHINE(ATH79_MACH_UBNT_LSSR71, "UBNT-LS-SR71", "Ubiquiti LS-SR71",
25556 + ubnt_lssr71_setup);
25557 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-weio.c linux-4.1.43/arch/mips/ath79/mach-weio.c
25558 --- linux-4.1.43.orig/arch/mips/ath79/mach-weio.c 1970-01-01 01:00:00.000000000 +0100
25559 +++ linux-4.1.43/arch/mips/ath79/mach-weio.c 2017-08-06 20:02:15.000000000 +0200
25560 @@ -0,0 +1,140 @@
25561 +/**
25562 + * WEIO Web Of Things Platform
25564 + * Copyright (C) 2013 Drasko DRASKOVIC and Uros PETREVSKI
25566 + * ## ## ######## #### #######
25567 + * ## ## ## ## ## ## ##
25568 + * ## ## ## ## ## ## ##
25569 + * ## ## ## ###### ## ## ##
25570 + * ## ## ## ## ## ## ##
25571 + * ## ## ## ## ## ## ##
25572 + * ### ### ######## #### #######
25574 + * Web Of Things Platform
25576 + * This program is free software; you can redistribute it and/or
25577 + * modify it under the terms of the GNU General Public License
25578 + * as published by the Free Software Foundation; either version 2
25579 + * of the License, or (at your option) any later version.
25581 + * This program is distributed in the hope that it will be useful,
25582 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25583 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25584 + * GNU General Public License for more details.
25586 + * You should have received a copy of the GNU General Public License
25587 + * along with this program; if not, write to the Free Software
25588 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25590 + * Authors :
25591 + * Drasko DRASKOVIC <drasko.draskovic@gmail.com>
25592 + * Uros PETREVSKI <uros@nodesign.net>
25593 + */
25595 +#include <asm/mach-ath79/ath79.h>
25596 +#include <asm/mach-ath79/ar71xx_regs.h>
25597 +#include <linux/i2c-gpio.h>
25598 +#include <linux/platform_device.h>
25599 +#include "common.h"
25600 +#include "dev-eth.h"
25601 +#include "dev-gpio-buttons.h"
25602 +#include "dev-leds-gpio.h"
25603 +#include "dev-m25p80.h"
25604 +#include "dev-spi.h"
25605 +#include "dev-usb.h"
25606 +#include "dev-wmac.h"
25607 +#include "machtypes.h"
25609 +#define WEIO_GPIO_LED_STA 1
25610 +#define WEIO_GPIO_LED_AP 16
25612 +#define WEIO_GPIO_BTN_AP 20
25613 +#define WEIO_GPIO_BTN_RESET 23
25615 +#define WEIO_KEYS_POLL_INTERVAL 20 /* msecs */
25616 +#define WEIO_KEYS_DEBOUNCE_INTERVAL (3 * WEIO_KEYS_POLL_INTERVAL)
25618 +#define WEIO_MAC0_OFFSET 0x0000
25619 +#define WEIO_MAC1_OFFSET 0x0006
25620 +#define WEIO_CALDATA_OFFSET 0x1000
25621 +#define WEIO_WMAC_MAC_OFFSET 0x1002
25623 +static struct gpio_led weio_leds_gpio[] __initdata = {
25625 + .name = "weio:green:sta",
25626 + .gpio = WEIO_GPIO_LED_STA,
25627 + .active_low = 1,
25628 + .default_state = LEDS_GPIO_DEFSTATE_ON,
25629 + },
25631 + .name = "weio:green:ap",
25632 + .gpio = WEIO_GPIO_LED_AP,
25633 + .active_low = 1,
25634 + .default_state = LEDS_GPIO_DEFSTATE_ON,
25638 +static struct gpio_keys_button weio_gpio_keys[] __initdata = {
25640 + .desc = "ap button",
25641 + .type = EV_KEY,
25642 + .code = BTN_0,
25643 + .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
25644 + .gpio = WEIO_GPIO_BTN_AP,
25645 + .active_low = 1,
25646 + },
25648 + .desc = "soft-reset button",
25649 + .type = EV_KEY,
25650 + .code = BTN_1,
25651 + .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
25652 + .gpio = WEIO_GPIO_BTN_RESET,
25653 + .active_low = 1,
25657 +static struct i2c_gpio_platform_data weio_i2c_gpio_data = {
25658 + .sda_pin = 18,
25659 + .scl_pin = 19,
25662 +static struct platform_device weio_i2c_gpio = {
25663 + .name = "i2c-gpio",
25664 + .id = 0,
25665 + .dev = {
25666 + .platform_data = &weio_i2c_gpio_data,
25667 + },
25670 +static void __init weio_common_setup(void)
25672 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
25674 + ath79_register_m25p80(NULL);
25675 + ath79_register_wmac(art + WEIO_CALDATA_OFFSET, art + WEIO_WMAC_MAC_OFFSET);
25678 +static void __init weio_setup(void)
25680 + weio_common_setup();
25682 + ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
25683 + AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
25684 + AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
25685 + AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
25686 + AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
25688 + platform_device_register(&weio_i2c_gpio);
25690 + ath79_register_leds_gpio(-1, ARRAY_SIZE(weio_leds_gpio),
25691 + weio_leds_gpio);
25693 + ath79_register_gpio_keys_polled(-1, WEIO_KEYS_POLL_INTERVAL,
25694 + ARRAY_SIZE(weio_gpio_keys),
25695 + weio_gpio_keys);
25697 + ath79_register_usb();
25700 +MIPS_MACHINE(ATH79_MACH_WEIO, "WEIO", "WeIO board", weio_setup);
25701 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-whr-hp-g300n.c linux-4.1.43/arch/mips/ath79/mach-whr-hp-g300n.c
25702 --- linux-4.1.43.orig/arch/mips/ath79/mach-whr-hp-g300n.c 1970-01-01 01:00:00.000000000 +0100
25703 +++ linux-4.1.43/arch/mips/ath79/mach-whr-hp-g300n.c 2017-08-06 20:02:15.000000000 +0200
25704 @@ -0,0 +1,155 @@
25706 + * Buffalo WHR-HP-G300N board support
25708 + * based on ...
25710 + * TP-LINK TL-WR741ND board support
25712 + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
25714 + * This program is free software; you can redistribute it and/or modify it
25715 + * under the terms of the GNU General Public License version 2 as published
25716 + * by the Free Software Foundation.
25717 + */
25719 +#include <asm/mach-ath79/ath79.h>
25720 +#include <asm/mach-ath79/ar71xx_regs.h>
25722 +#include "common.h"
25723 +#include "dev-ap9x-pci.h"
25724 +#include "dev-eth.h"
25725 +#include "dev-gpio-buttons.h"
25726 +#include "dev-leds-gpio.h"
25727 +#include "dev-m25p80.h"
25728 +#include "machtypes.h"
25730 +#define WHRHPG300N_GPIO_LED_SECURITY 0
25731 +#define WHRHPG300N_GPIO_LED_DIAG 1
25732 +#define WHRHPG300N_GPIO_LED_ROUTER 6
25734 +#define WHRHPG300N_GPIO_BTN_ROUTER_ON 7
25735 +#define WHRHPG300N_GPIO_BTN_ROUTER_AUTO 8
25736 +#define WHRHPG300N_GPIO_BTN_RESET 11
25737 +#define WHRHPG300N_GPIO_BTN_AOSS 12
25738 +#define WHRHPG300N_GPIO_LED_LAN1 13
25739 +#define WHRHPG300N_GPIO_LED_LAN2 14
25740 +#define WHRHPG300N_GPIO_LED_LAN3 15
25741 +#define WHRHPG300N_GPIO_LED_LAN4 16
25742 +#define WHRHPG300N_GPIO_LED_WAN 17
25744 +#define WHRHPG300N_KEYS_POLL_INTERVAL 20 /* msecs */
25745 +#define WHRHPG300N_KEYS_DEBOUNCE_INTERVAL (3 * WHRHPG300N_KEYS_POLL_INTERVAL)
25747 +#define WHRHPG300N_MAC_OFFSET 0x20c
25749 +static struct gpio_led whrhpg300n_leds_gpio[] __initdata = {
25751 + .name = "buffalo:orange:security",
25752 + .gpio = WHRHPG300N_GPIO_LED_SECURITY,
25753 + .active_low = 1,
25754 + }, {
25755 + .name = "buffalo:red:diag",
25756 + .gpio = WHRHPG300N_GPIO_LED_DIAG,
25757 + .active_low = 1,
25758 + }, {
25759 + .name = "buffalo:green:router",
25760 + .gpio = WHRHPG300N_GPIO_LED_ROUTER,
25761 + .active_low = 1,
25762 + }, {
25763 + .name = "buffalo:green:wan",
25764 + .gpio = WHRHPG300N_GPIO_LED_WAN,
25765 + .active_low = 1,
25766 + }, {
25767 + .name = "buffalo:green:lan1",
25768 + .gpio = WHRHPG300N_GPIO_LED_LAN1,
25769 + .active_low = 1,
25770 + }, {
25771 + .name = "buffalo:green:lan2",
25772 + .gpio = WHRHPG300N_GPIO_LED_LAN2,
25773 + .active_low = 1,
25774 + }, {
25775 + .name = "buffalo:green:lan3",
25776 + .gpio = WHRHPG300N_GPIO_LED_LAN3,
25777 + .active_low = 1,
25778 + }, {
25779 + .name = "buffalo:green:lan4",
25780 + .gpio = WHRHPG300N_GPIO_LED_LAN4,
25781 + .active_low = 1,
25785 +static struct gpio_keys_button whrhpg300n_gpio_keys[] __initdata = {
25787 + .desc = "reset",
25788 + .type = EV_KEY,
25789 + .code = KEY_RESTART,
25790 + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
25791 + .gpio = WHRHPG300N_GPIO_BTN_RESET,
25792 + .active_low = 1,
25793 + }, {
25794 + .desc = "aoss/wps",
25795 + .type = EV_KEY,
25796 + .code = KEY_WPS_BUTTON,
25797 + .gpio = WHRHPG300N_GPIO_BTN_AOSS,
25798 + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
25799 + .active_low = 1,
25800 + }, {
25801 + .desc = "router_on",
25802 + .type = EV_KEY,
25803 + .code = BTN_2,
25804 + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_ON,
25805 + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
25806 + .active_low = 1,
25807 + }, {
25808 + .desc = "router_auto",
25809 + .type = EV_KEY,
25810 + .code = BTN_3,
25811 + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_AUTO,
25812 + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
25813 + .active_low = 1,
25817 +static void __init whrhpg300n_setup(void)
25819 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
25820 + u8 *mac = (u8 *) KSEG1ADDR(ee + WHRHPG300N_MAC_OFFSET);
25822 + ath79_register_m25p80(NULL);
25824 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
25825 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
25826 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
25827 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
25828 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
25830 + ath79_register_leds_gpio(-1, ARRAY_SIZE(whrhpg300n_leds_gpio),
25831 + whrhpg300n_leds_gpio);
25833 + ath79_register_gpio_keys_polled(-1, WHRHPG300N_KEYS_POLL_INTERVAL,
25834 + ARRAY_SIZE(whrhpg300n_gpio_keys),
25835 + whrhpg300n_gpio_keys);
25837 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
25838 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
25840 + ath79_register_mdio(0, 0x0);
25842 + /* LAN ports */
25843 + ath79_register_eth(1);
25844 + /* WAN port */
25845 + ath79_register_eth(0);
25847 + ap9x_pci_setup_wmac_led_pin(0, 1);
25849 + ap91_pci_init(ee, mac);
25852 +MIPS_MACHINE(ATH79_MACH_WHR_HP_G300N, "WHR-HP-G300N", "Buffalo WHR-HP-G300N",
25853 + whrhpg300n_setup);
25855 +MIPS_MACHINE(ATH79_MACH_WHR_G301N, "WHR-G301N", "Buffalo WHR-G301N",
25856 + whrhpg300n_setup);
25858 +MIPS_MACHINE(ATH79_MACH_WHR_HP_GN, "WHR-HP-GN", "Buffalo WHR-HP-GN",
25859 + whrhpg300n_setup);
25860 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wlae-ag300n.c linux-4.1.43/arch/mips/ath79/mach-wlae-ag300n.c
25861 --- linux-4.1.43.orig/arch/mips/ath79/mach-wlae-ag300n.c 1970-01-01 01:00:00.000000000 +0100
25862 +++ linux-4.1.43/arch/mips/ath79/mach-wlae-ag300n.c 2017-08-06 20:02:15.000000000 +0200
25863 @@ -0,0 +1,114 @@
25865 + * Buffalo WLAE-AG300N board support
25866 + */
25868 +#include <linux/gpio.h>
25869 +#include <linux/mtd/mtd.h>
25870 +#include <linux/mtd/partitions.h>
25872 +#include <asm/mach-ath79/ath79.h>
25874 +#include "dev-eth.h"
25875 +#include "dev-ap9x-pci.h"
25876 +#include "dev-gpio-buttons.h"
25877 +#include "dev-leds-gpio.h"
25878 +#include "dev-m25p80.h"
25879 +#include "dev-usb.h"
25880 +#include "machtypes.h"
25882 +#define WLAEAG300N_MAC_OFFSET 0x20c
25883 +#define WLAEAG300N_KEYS_POLL_INTERVAL 20 /* msecs */
25884 +#define WLAEAG300N_KEYS_DEBOUNCE_INTERVAL (3 * WLAEAG300N_KEYS_POLL_INTERVAL)
25887 +static struct gpio_led wlaeag300n_leds_gpio[] __initdata = {
25888 + /*
25889 + * Note: Writing 1 into GPIO 13 will power down the device.
25890 + */
25892 + .name = "buffalo:green:wireless",
25893 + .gpio = 14,
25894 + .active_low = 1,
25895 + }, {
25896 + .name = "buffalo:red:wireless",
25897 + .gpio = 15,
25898 + .active_low = 1,
25899 + }, {
25900 + .name = "buffalo:green:status",
25901 + .gpio = 16,
25902 + .active_low = 1,
25903 + }, {
25904 + .name = "buffalo:red:status",
25905 + .gpio = 17,
25906 + .active_low = 1,
25911 +static struct gpio_keys_button wlaeag300n_gpio_keys[] __initdata = {
25913 + .desc = "function",
25914 + .type = EV_KEY,
25915 + .code = KEY_MODE,
25916 + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
25917 + .gpio = 0,
25918 + .active_low = 1,
25919 + }, {
25920 + .desc = "reset",
25921 + .type = EV_KEY,
25922 + .code = KEY_RESTART,
25923 + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
25924 + .gpio = 1,
25925 + .active_low = 1,
25926 + }, {
25927 + .desc = "power",
25928 + .type = EV_KEY,
25929 + .code = KEY_POWER,
25930 + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
25931 + .gpio = 11,
25932 + .active_low = 1,
25933 + }, {
25934 + .desc = "aoss",
25935 + .type = EV_KEY,
25936 + .code = KEY_WPS_BUTTON,
25937 + .debounce_interval = WLAEAG300N_KEYS_DEBOUNCE_INTERVAL,
25938 + .gpio = 12,
25939 + .active_low = 1,
25943 +static void __init wlaeag300n_setup(void)
25945 + u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1fff1000);
25946 + u8 *mac1 = eeprom1 + WLAEAG300N_MAC_OFFSET;
25948 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
25949 + ath79_init_mac(ath79_eth1_data.mac_addr, mac1, 1);
25951 + ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
25953 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25954 + ath79_eth0_data.speed = SPEED_1000;
25955 + ath79_eth0_data.duplex = DUPLEX_FULL;
25956 + ath79_eth0_data.phy_mask = BIT(0);
25958 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
25959 + ath79_eth1_data.phy_mask = BIT(4);
25961 + ath79_register_eth(0);
25962 + ath79_register_eth(1);
25964 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wlaeag300n_leds_gpio),
25965 + wlaeag300n_leds_gpio);
25967 + ath79_register_gpio_keys_polled(-1, WLAEAG300N_KEYS_POLL_INTERVAL,
25968 + ARRAY_SIZE(wlaeag300n_gpio_keys),
25969 + wlaeag300n_gpio_keys);
25971 + ath79_register_m25p80(NULL);
25973 + ap91_pci_init(eeprom1, mac1);
25976 +MIPS_MACHINE(ATH79_MACH_WLAE_AG300N, "WLAE-AG300N",
25977 + "Buffalo WLAE-AG300N", wlaeag300n_setup);
25978 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wlr8100.c linux-4.1.43/arch/mips/ath79/mach-wlr8100.c
25979 --- linux-4.1.43.orig/arch/mips/ath79/mach-wlr8100.c 1970-01-01 01:00:00.000000000 +0100
25980 +++ linux-4.1.43/arch/mips/ath79/mach-wlr8100.c 2017-08-06 20:02:15.000000000 +0200
25981 @@ -0,0 +1,206 @@
25983 + * Sitecom X8 AC1750 WLR-8100 board support
25985 + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
25986 + * Copyright (c) 2012 Qualcomm Atheros
25987 + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
25989 + * Permission to use, copy, modify, and/or distribute this software for any
25990 + * purpose with or without fee is hereby granted, provided that the above
25991 + * copyright notice and this permission notice appear in all copies.
25993 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
25994 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
25995 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
25996 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25997 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25998 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
25999 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26001 + */
26003 +#include <linux/platform_device.h>
26004 +#include <linux/ar8216_platform.h>
26006 +#include <asm/mach-ath79/ar71xx_regs.h>
26008 +#include "common.h"
26009 +#include "pci.h"
26010 +#include "dev-ap9x-pci.h"
26011 +#include "dev-gpio-buttons.h"
26012 +#include "dev-eth.h"
26013 +#include "dev-leds-gpio.h"
26014 +#include "dev-m25p80.h"
26015 +#include "dev-usb.h"
26016 +#include "dev-wmac.h"
26017 +#include "machtypes.h"
26019 +#define WLR8100_GPIO_LED_USB 4
26020 +#define WLR8100_GPIO_LED_WLAN_5G 12
26021 +#define WLR8100_GPIO_LED_WLAN_2G 13
26022 +#define WLR8100_GPIO_LED_STATUS_RED 14
26023 +#define WLR8100_GPIO_LED_WPS_RED 15
26024 +#define WLR8100_GPIO_LED_STATUS_AMBER 19
26025 +#define WLR8100_GPIO_LED_WPS_GREEN 20
26027 +#define WLR8100_GPIO_BTN_WPS 16
26028 +#define WLR8100_GPIO_BTN_RFKILL 21
26030 +#define WLR8100_KEYS_POLL_INTERVAL 20 /* msecs */
26031 +#define WLR8100_KEYS_DEBOUNCE_INTERVAL (3 * WLR8100_KEYS_POLL_INTERVAL)
26033 +#define WLR8100_MAC0_OFFSET 0
26034 +#define WLR8100_MAC1_OFFSET 6
26035 +#define WLR8100_WMAC_CALDATA_OFFSET 0x1000
26036 +#define WLR8100_PCIE_CALDATA_OFFSET 0x5000
26038 +static struct gpio_led wlr8100_leds_gpio[] __initdata = {
26040 + .name = "wlr8100:amber:status",
26041 + .gpio = WLR8100_GPIO_LED_STATUS_AMBER,
26042 + .active_low = 1,
26043 + },
26045 + .name = "wlr8100:red:status",
26046 + .gpio = WLR8100_GPIO_LED_STATUS_RED,
26047 + .active_low = 1,
26048 + },
26050 + .name = "wlr8100:green:wps",
26051 + .gpio = WLR8100_GPIO_LED_WPS_GREEN,
26052 + .active_low = 1,
26053 + },
26055 + .name = "wlr8100:red:wps",
26056 + .gpio = WLR8100_GPIO_LED_WPS_RED,
26057 + .active_low = 1,
26058 + },
26060 + .name = "wlr8100:red:wlan-2g",
26061 + .gpio = WLR8100_GPIO_LED_WLAN_2G,
26062 + .active_low = 1,
26063 + },
26065 + .name = "wlr8100:red:usb",
26066 + .gpio = WLR8100_GPIO_LED_USB,
26067 + .active_low = 1,
26071 +static struct gpio_keys_button wlr8100_gpio_keys[] __initdata = {
26073 + .desc = "WPS button",
26074 + .type = EV_KEY,
26075 + .code = KEY_WPS_BUTTON,
26076 + .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
26077 + .gpio = WLR8100_GPIO_BTN_WPS,
26078 + .active_low = 1,
26079 + },
26081 + .desc = "RFKILL button",
26082 + .type = EV_KEY,
26083 + .code = KEY_RFKILL,
26084 + .debounce_interval = WLR8100_KEYS_DEBOUNCE_INTERVAL,
26085 + .gpio = WLR8100_GPIO_BTN_RFKILL,
26086 + .active_low = 1,
26087 + },
26090 +static struct ar8327_pad_cfg wlr8100_ar8327_pad0_cfg;
26091 +static struct ar8327_pad_cfg wlr8100_ar8327_pad6_cfg;
26093 +static struct ar8327_platform_data wlr8100_ar8327_data = {
26094 + .pad0_cfg = &wlr8100_ar8327_pad0_cfg,
26095 + .pad6_cfg = &wlr8100_ar8327_pad6_cfg,
26096 + .port0_cfg = {
26097 + .force_link = 1,
26098 + .speed = AR8327_PORT_SPEED_1000,
26099 + .duplex = 1,
26100 + .txpause = 1,
26101 + .rxpause = 1,
26102 + },
26103 + .port6_cfg = {
26104 + .force_link = 1,
26105 + .speed = AR8327_PORT_SPEED_1000,
26106 + .duplex = 1,
26107 + .txpause = 1,
26108 + .rxpause = 1,
26109 + },
26112 +static struct mdio_board_info wlr8100_mdio0_info[] = {
26114 + .bus_id = "ag71xx-mdio.0",
26115 + .phy_addr = 0,
26116 + .platform_data = &wlr8100_ar8327_data,
26117 + },
26120 +static void __init wlr8100_common_setup(void)
26122 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26124 + ath79_register_m25p80(NULL);
26126 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wlr8100_leds_gpio),
26127 + wlr8100_leds_gpio);
26128 + ath79_register_gpio_keys_polled(-1, WLR8100_KEYS_POLL_INTERVAL,
26129 + ARRAY_SIZE(wlr8100_gpio_keys),
26130 + wlr8100_gpio_keys);
26132 + ath79_register_usb();
26134 + ath79_register_wmac(art + WLR8100_WMAC_CALDATA_OFFSET, NULL);
26136 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
26138 + ath79_register_mdio(0, 0x0);
26140 + ath79_init_mac(ath79_eth0_data.mac_addr, art + WLR8100_MAC0_OFFSET, 0);
26142 + mdiobus_register_board_info(wlr8100_mdio0_info,
26143 + ARRAY_SIZE(wlr8100_mdio0_info));
26145 + /* GMAC0 is connected to the RMGII interface */
26146 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
26147 + ath79_eth0_data.phy_mask = BIT(0);
26148 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
26150 + ath79_register_eth(0);
26152 + /* GMAC1 is connected tot eh SGMII interface */
26153 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
26154 + ath79_eth1_data.speed = SPEED_1000;
26155 + ath79_eth1_data.duplex = DUPLEX_FULL;
26157 + ath79_register_eth(1);
26160 +static void __init wlr8100_010_setup(void)
26162 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26164 + /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */
26165 + wlr8100_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
26166 + wlr8100_ar8327_pad0_cfg.txclk_delay_en = true;
26167 + wlr8100_ar8327_pad0_cfg.rxclk_delay_en = true;
26168 + wlr8100_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
26169 + wlr8100_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
26170 + wlr8100_ar8327_pad0_cfg.mac06_exchange_en = true;
26172 + /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */
26173 + wlr8100_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
26174 + wlr8100_ar8327_pad6_cfg.rxclk_delay_en = true;
26175 + wlr8100_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
26177 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
26178 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
26180 + wlr8100_common_setup();
26181 + ap91_pci_init(art + WLR8100_PCIE_CALDATA_OFFSET, NULL);
26184 +MIPS_MACHINE(ATH79_MACH_WLR8100, "WLR8100",
26185 + "Sitecom WLR-8100",
26186 + wlr8100_010_setup);
26188 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wndap360.c linux-4.1.43/arch/mips/ath79/mach-wndap360.c
26189 --- linux-4.1.43.orig/arch/mips/ath79/mach-wndap360.c 1970-01-01 01:00:00.000000000 +0100
26190 +++ linux-4.1.43/arch/mips/ath79/mach-wndap360.c 2017-08-06 20:02:15.000000000 +0200
26191 @@ -0,0 +1,105 @@
26193 + * Netgear WNDAP360 board support (proper leds / button support missing)
26195 + * Based on AP96
26196 + * Copyright (C) 2013 Jacek Kikiewicz
26197 + * Copyright (C) 2009 Marco Porsch
26198 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
26199 + * Copyright (C) 2010 Atheros Communications
26201 + * This program is free software; you can redistribute it and/or modify it
26202 + * under the terms of the GNU General Public License version 2 as published
26203 + * by the Free Software Foundation.
26204 + */
26206 +#include <linux/platform_device.h>
26207 +#include <linux/delay.h>
26209 +#include <asm/mach-ath79/ath79.h>
26211 +#include "dev-ap9x-pci.h"
26212 +#include "dev-eth.h"
26213 +#include "dev-gpio-buttons.h"
26214 +#include "dev-leds-gpio.h"
26215 +#include "dev-m25p80.h"
26216 +#include "machtypes.h"
26218 +#define WNDAP360_GPIO_LED_POWER_ORANGE 0
26219 +#define WNDAP360_GPIO_LED_POWER_GREEN 2
26221 +/* Reset button - next to the power connector */
26222 +#define WNDAP360_GPIO_BTN_RESET 8
26224 +#define WNDAP360_KEYS_POLL_INTERVAL 20 /* msecs */
26225 +#define WNDAP360_KEYS_DEBOUNCE_INTERVAL (3 * WNDAP360_KEYS_POLL_INTERVAL)
26227 +#define WNDAP360_WMAC0_MAC_OFFSET 0x120c
26228 +#define WNDAP360_WMAC1_MAC_OFFSET 0x520c
26229 +#define WNDAP360_CALDATA0_OFFSET 0x1000
26230 +#define WNDAP360_CALDATA1_OFFSET 0x5000
26233 + * WNDAP360 this still uses leds definitions from AP96
26235 + */
26236 +static struct gpio_led wndap360_leds_gpio[] __initdata = {
26238 + .name = "netgear:green:power",
26239 + .gpio = WNDAP360_GPIO_LED_POWER_GREEN,
26240 + .active_low = 1,
26241 + }, {
26242 + .name = "netgear:orange:power",
26243 + .gpio = WNDAP360_GPIO_LED_POWER_ORANGE,
26244 + .active_low = 1,
26248 +static struct gpio_keys_button wndap360_gpio_keys[] __initdata = {
26250 + .desc = "reset",
26251 + .type = EV_KEY,
26252 + .code = KEY_RESTART,
26253 + .debounce_interval = WNDAP360_KEYS_DEBOUNCE_INTERVAL,
26254 + .gpio = WNDAP360_GPIO_BTN_RESET,
26255 + .active_low = 1,
26259 +#define WNDAP360_LAN_PHYMASK 0x0f
26261 +static void __init wndap360_setup(void)
26263 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26265 + ath79_register_mdio(0, ~(WNDAP360_LAN_PHYMASK));
26267 + /* Reusing wifi MAC with offset of 1 as eth0 MAC */
26268 + ath79_init_mac(ath79_eth0_data.mac_addr,
26269 + art + WNDAP360_WMAC0_MAC_OFFSET, 1);
26270 + ath79_eth0_pll_data.pll_1000 = 0x11110000;
26271 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
26272 + ath79_eth0_data.phy_mask = WNDAP360_LAN_PHYMASK;
26273 + ath79_eth0_data.speed = SPEED_1000;
26274 + ath79_eth0_data.duplex = DUPLEX_FULL;
26276 + ath79_register_eth(0);
26278 + ath79_register_m25p80(NULL);
26280 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndap360_leds_gpio),
26281 + wndap360_leds_gpio);
26283 + ath79_register_gpio_keys_polled(-1, WNDAP360_KEYS_POLL_INTERVAL,
26284 + ARRAY_SIZE(wndap360_gpio_keys),
26285 + wndap360_gpio_keys);
26287 + ap9x_pci_setup_wmac_led_pin(0, 5);
26288 + ap9x_pci_setup_wmac_led_pin(1, 5);
26290 + ap94_pci_init(art + WNDAP360_CALDATA0_OFFSET,
26291 + art + WNDAP360_WMAC0_MAC_OFFSET,
26292 + art + WNDAP360_CALDATA1_OFFSET,
26293 + art + WNDAP360_WMAC1_MAC_OFFSET);
26296 +MIPS_MACHINE(ATH79_MACH_WNDAP360, "WNDAP360", "Netgear WNDAP360", wndap360_setup);
26297 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wndr3700.c linux-4.1.43/arch/mips/ath79/mach-wndr3700.c
26298 --- linux-4.1.43.orig/arch/mips/ath79/mach-wndr3700.c 1970-01-01 01:00:00.000000000 +0100
26299 +++ linux-4.1.43/arch/mips/ath79/mach-wndr3700.c 2017-08-06 20:02:15.000000000 +0200
26300 @@ -0,0 +1,172 @@
26302 + * Netgear WNDR3700 board support
26304 + * Copyright (C) 2009 Marco Porsch
26305 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
26307 + * This program is free software; you can redistribute it and/or modify it
26308 + * under the terms of the GNU General Public License version 2 as published
26309 + * by the Free Software Foundation.
26310 + */
26312 +#include <linux/platform_device.h>
26313 +#include <linux/mtd/mtd.h>
26314 +#include <linux/mtd/partitions.h>
26315 +#include <linux/delay.h>
26316 +#include <linux/rtl8366.h>
26318 +#include <asm/mach-ath79/ath79.h>
26320 +#include "dev-ap9x-pci.h"
26321 +#include "dev-eth.h"
26322 +#include "dev-gpio-buttons.h"
26323 +#include "dev-leds-gpio.h"
26324 +#include "dev-m25p80.h"
26325 +#include "dev-usb.h"
26326 +#include "machtypes.h"
26328 +#define WNDR3700_GPIO_LED_WPS_ORANGE 0
26329 +#define WNDR3700_GPIO_LED_POWER_ORANGE 1
26330 +#define WNDR3700_GPIO_LED_POWER_GREEN 2
26331 +#define WNDR3700_GPIO_LED_WPS_GREEN 4
26332 +#define WNDR3700_GPIO_LED_WAN_GREEN 6
26334 +#define WNDR3700_GPIO_BTN_WPS 3
26335 +#define WNDR3700_GPIO_BTN_RESET 8
26336 +#define WNDR3700_GPIO_BTN_WIFI 11
26338 +#define WNDR3700_GPIO_RTL8366_SDA 5
26339 +#define WNDR3700_GPIO_RTL8366_SCK 7
26341 +#define WNDR3700_KEYS_POLL_INTERVAL 20 /* msecs */
26342 +#define WNDR3700_KEYS_DEBOUNCE_INTERVAL (3 * WNDR3700_KEYS_POLL_INTERVAL)
26344 +#define WNDR3700_ETH0_MAC_OFFSET 0
26345 +#define WNDR3700_ETH1_MAC_OFFSET 0x6
26347 +#define WNDR3700_WMAC0_MAC_OFFSET 0
26348 +#define WNDR3700_WMAC1_MAC_OFFSET 0xc
26349 +#define WNDR3700_CALDATA0_OFFSET 0x1000
26350 +#define WNDR3700_CALDATA1_OFFSET 0x5000
26352 +static struct gpio_led wndr3700_leds_gpio[] __initdata = {
26354 + .name = "netgear:green:power",
26355 + .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
26356 + .active_low = 1,
26357 + }, {
26358 + .name = "netgear:orange:power",
26359 + .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
26360 + .active_low = 1,
26361 + }, {
26362 + .name = "netgear:green:wps",
26363 + .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
26364 + .active_low = 1,
26365 + }, {
26366 + .name = "netgear:orange:wps",
26367 + .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
26368 + .active_low = 1,
26369 + }, {
26370 + .name = "netgear:green:wan",
26371 + .gpio = WNDR3700_GPIO_LED_WAN_GREEN,
26372 + .active_low = 1,
26376 +static struct gpio_keys_button wndr3700_gpio_keys[] __initdata = {
26378 + .desc = "reset",
26379 + .type = EV_KEY,
26380 + .code = KEY_RESTART,
26381 + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
26382 + .gpio = WNDR3700_GPIO_BTN_RESET,
26383 + .active_low = 1,
26384 + }, {
26385 + .desc = "wps",
26386 + .type = EV_KEY,
26387 + .code = KEY_WPS_BUTTON,
26388 + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
26389 + .gpio = WNDR3700_GPIO_BTN_WPS,
26390 + .active_low = 1,
26391 + }, {
26392 + .desc = "wifi",
26393 + .type = EV_KEY,
26394 + .code = BTN_2,
26395 + .debounce_interval = WNDR3700_KEYS_DEBOUNCE_INTERVAL,
26396 + .gpio = WNDR3700_GPIO_BTN_WIFI,
26397 + .active_low = 1,
26401 +static struct rtl8366_platform_data wndr3700_rtl8366s_data = {
26402 + .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
26403 + .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
26406 +static struct platform_device wndr3700_rtl8366s_device = {
26407 + .name = RTL8366S_DRIVER_NAME,
26408 + .id = -1,
26409 + .dev = {
26410 + .platform_data = &wndr3700_rtl8366s_data,
26414 +static void __init wndr3700_setup(void)
26416 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26418 + /*
26419 + * The eth0 and wmac0 interfaces share the same MAC address which
26420 + * can lead to problems if operated unbridged. Set the locally
26421 + * administered bit on the eth0 MAC to make it unique.
26422 + */
26423 + ath79_init_local_mac(ath79_eth0_data.mac_addr,
26424 + art + WNDR3700_ETH0_MAC_OFFSET);
26425 + ath79_eth0_pll_data.pll_1000 = 0x11110000;
26426 + ath79_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
26427 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
26428 + ath79_eth0_data.speed = SPEED_1000;
26429 + ath79_eth0_data.duplex = DUPLEX_FULL;
26431 + ath79_init_mac(ath79_eth1_data.mac_addr,
26432 + art + WNDR3700_ETH1_MAC_OFFSET, 0);
26433 + ath79_eth1_pll_data.pll_1000 = 0x11110000;
26434 + ath79_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
26435 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
26436 + ath79_eth1_data.phy_mask = 0x10;
26438 + ath79_register_eth(0);
26439 + ath79_register_eth(1);
26441 + ath79_register_usb();
26443 + ath79_register_m25p80(NULL);
26445 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
26446 + wndr3700_leds_gpio);
26448 + ath79_register_gpio_keys_polled(-1, WNDR3700_KEYS_POLL_INTERVAL,
26449 + ARRAY_SIZE(wndr3700_gpio_keys),
26450 + wndr3700_gpio_keys);
26452 + platform_device_register(&wndr3700_rtl8366s_device);
26453 + platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
26455 + ap9x_pci_setup_wmac_led_pin(0, 5);
26456 + ap9x_pci_setup_wmac_led_pin(1, 5);
26458 + /* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
26459 + ap9x_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));
26461 + /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
26462 + ap9x_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
26464 + ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
26465 + art + WNDR3700_WMAC0_MAC_OFFSET,
26466 + art + WNDR3700_CALDATA1_OFFSET,
26467 + art + WNDR3700_WMAC1_MAC_OFFSET);
26470 +MIPS_MACHINE(ATH79_MACH_WNDR3700, "WNDR3700",
26471 + "NETGEAR WNDR3700/WNDR3800/WNDRMAC",
26472 + wndr3700_setup);
26473 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wndr4300.c linux-4.1.43/arch/mips/ath79/mach-wndr4300.c
26474 --- linux-4.1.43.orig/arch/mips/ath79/mach-wndr4300.c 1970-01-01 01:00:00.000000000 +0100
26475 +++ linux-4.1.43/arch/mips/ath79/mach-wndr4300.c 2017-08-06 20:02:15.000000000 +0200
26476 @@ -0,0 +1,210 @@
26478 + * NETGEAR WNDR3700v4/WNDR4300 board support
26480 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
26481 + * Copyright (C) 2014 Ralph Perlich <rpsoft@arcor.de>
26483 + * This program is free software; you can redistribute it and/or modify it
26484 + * under the terms of the GNU General Public License version 2 as published
26485 + * by the Free Software Foundation.
26486 + */
26488 +#include <linux/pci.h>
26489 +#include <linux/phy.h>
26490 +#include <linux/gpio.h>
26491 +#include <linux/platform_device.h>
26492 +#include <linux/ath9k_platform.h>
26493 +#include <linux/ar8216_platform.h>
26494 +#include <linux/mtd/mtd.h>
26495 +#include <linux/mtd/nand.h>
26496 +#include <linux/platform/ar934x_nfc.h>
26498 +#include <asm/mach-ath79/ar71xx_regs.h>
26500 +#include "common.h"
26501 +#include "dev-ap9x-pci.h"
26502 +#include "dev-eth.h"
26503 +#include "dev-gpio-buttons.h"
26504 +#include "dev-leds-gpio.h"
26505 +#include "dev-nfc.h"
26506 +#include "dev-usb.h"
26507 +#include "dev-wmac.h"
26508 +#include "machtypes.h"
26510 +/* AR9344 GPIOs */
26511 +#define WNDR4300_GPIO_LED_POWER_GREEN 0
26512 +#define WNDR4300_GPIO_LED_POWER_AMBER 2
26513 +#define WNDR4300_GPIO_LED_USB 13
26514 +#define WNDR4300_GPIO_LED_WAN_GREEN 1
26515 +#define WNDR4300_GPIO_LED_WAN_AMBER 3
26516 +#define WNDR4300_GPIO_LED_WLAN2G 11
26517 +#define WNDR4300_GPIO_LED_WLAN5G 14
26518 +#define WNDR4300_GPIO_LED_WPS_GREEN 16
26519 +#define WNDR4300_GPIO_LED_WPS_AMBER 17
26521 +#define WNDR4300_GPIO_BTN_RESET 21
26522 +#define WNDR4300_GPIO_BTN_WIRELESS 15
26523 +#define WNDR4300_GPIO_BTN_WPS 12
26525 +/* AR9580 GPIOs */
26526 +#define WNDR4300_GPIO_USB_5V 0
26528 +#define WNDR4300_KEYS_POLL_INTERVAL 20 /* msecs */
26529 +#define WNDR4300_KEYS_DEBOUNCE_INTERVAL (3 * WNDR4300_KEYS_POLL_INTERVAL)
26531 +static struct gpio_led wndr4300_leds_gpio[] __initdata = {
26533 + .name = "netgear:green:power",
26534 + .gpio = WNDR4300_GPIO_LED_POWER_GREEN,
26535 + .active_low = 1,
26536 + },
26538 + .name = "netgear:amber:power",
26539 + .gpio = WNDR4300_GPIO_LED_POWER_AMBER,
26540 + .active_low = 1,
26541 + },
26543 + .name = "netgear:green:wan",
26544 + .gpio = WNDR4300_GPIO_LED_WAN_GREEN,
26545 + .active_low = 1,
26546 + },
26548 + .name = "netgear:amber:wan",
26549 + .gpio = WNDR4300_GPIO_LED_WAN_AMBER,
26550 + .active_low = 1,
26551 + },
26553 + .name = "netgear:green:usb",
26554 + .gpio = WNDR4300_GPIO_LED_USB,
26555 + .active_low = 1,
26556 + },
26558 + .name = "netgear:green:wps",
26559 + .gpio = WNDR4300_GPIO_LED_WPS_GREEN,
26560 + .active_low = 1,
26561 + },
26563 + .name = "netgear:amber:wps",
26564 + .gpio = WNDR4300_GPIO_LED_WPS_AMBER,
26565 + .active_low = 1,
26566 + },
26568 + .name = "netgear:green:wlan2g",
26569 + .gpio = WNDR4300_GPIO_LED_WLAN2G,
26570 + .active_low = 1,
26571 + },
26573 + .name = "netgear:blue:wlan5g",
26574 + .gpio = WNDR4300_GPIO_LED_WLAN5G,
26575 + .active_low = 1,
26576 + },
26579 +static struct gpio_keys_button wndr4300_gpio_keys[] __initdata = {
26581 + .desc = "Reset button",
26582 + .type = EV_KEY,
26583 + .code = KEY_RESTART,
26584 + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
26585 + .gpio = WNDR4300_GPIO_BTN_RESET,
26586 + .active_low = 1,
26587 + },
26589 + .desc = "WPS button",
26590 + .type = EV_KEY,
26591 + .code = KEY_WPS_BUTTON,
26592 + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
26593 + .gpio = WNDR4300_GPIO_BTN_WPS,
26594 + .active_low = 1,
26595 + },
26597 + .desc = "Wireless button",
26598 + .type = EV_KEY,
26599 + .code = KEY_RFKILL,
26600 + .debounce_interval = WNDR4300_KEYS_DEBOUNCE_INTERVAL,
26601 + .gpio = WNDR4300_GPIO_BTN_WIRELESS,
26602 + .active_low = 1,
26603 + },
26606 +static struct ar8327_pad_cfg wndr4300_ar8327_pad0_cfg = {
26607 + .mode = AR8327_PAD_MAC_RGMII,
26608 + .txclk_delay_en = true,
26609 + .rxclk_delay_en = true,
26610 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
26611 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
26614 +static struct ar8327_led_cfg wndr4300_ar8327_led_cfg = {
26615 + .led_ctrl0 = 0xc737c737,
26616 + .led_ctrl1 = 0x00000000,
26617 + .led_ctrl2 = 0x00000000,
26618 + .led_ctrl3 = 0x0030c300,
26619 + .open_drain = false,
26622 +static struct ar8327_platform_data wndr4300_ar8327_data = {
26623 + .pad0_cfg = &wndr4300_ar8327_pad0_cfg,
26624 + .port0_cfg = {
26625 + .force_link = 1,
26626 + .speed = AR8327_PORT_SPEED_1000,
26627 + .duplex = 1,
26628 + .txpause = 1,
26629 + .rxpause = 1,
26630 + },
26631 + .led_cfg = &wndr4300_ar8327_led_cfg,
26634 +static struct mdio_board_info wndr4300_mdio0_info[] = {
26636 + .bus_id = "ag71xx-mdio.0",
26637 + .phy_addr = 0,
26638 + .platform_data = &wndr4300_ar8327_data,
26639 + },
26642 +static void __init wndr4300_setup(void)
26644 + int i;
26646 + for (i = 0; i < ARRAY_SIZE(wndr4300_leds_gpio); i++)
26647 + ath79_gpio_output_select(wndr4300_leds_gpio[i].gpio,
26648 + AR934X_GPIO_OUT_GPIO);
26650 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr4300_leds_gpio),
26651 + wndr4300_leds_gpio);
26652 + ath79_register_gpio_keys_polled(-1, WNDR4300_KEYS_POLL_INTERVAL,
26653 + ARRAY_SIZE(wndr4300_gpio_keys),
26654 + wndr4300_gpio_keys);
26656 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
26658 + mdiobus_register_board_info(wndr4300_mdio0_info,
26659 + ARRAY_SIZE(wndr4300_mdio0_info));
26661 + ath79_register_mdio(0, 0x0);
26663 + /* GMAC0 is connected to an AR8327N switch */
26664 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
26665 + ath79_eth0_data.phy_mask = BIT(0);
26666 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
26667 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
26668 + ath79_register_eth(0);
26670 + ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
26671 + ath79_register_nfc();
26672 + ath79_register_usb();
26674 + ath79_register_wmac_simple();
26676 + /* enable power for the USB port */
26677 + ap9x_pci_setup_wmac_gpio(0, BIT(WNDR4300_GPIO_USB_5V),
26678 + BIT(WNDR4300_GPIO_USB_5V));
26680 + ap91_pci_init_simple();
26683 +MIPS_MACHINE(ATH79_MACH_WNDR3700_V4, "WNDR3700_V4", "NETGEAR WNDR3700v4",
26684 + wndr4300_setup);
26685 +MIPS_MACHINE(ATH79_MACH_WNDR4300, "WNDR4300", "NETGEAR WNDR4300",
26686 + wndr4300_setup);
26687 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000-v3.c linux-4.1.43/arch/mips/ath79/mach-wnr2000-v3.c
26688 --- linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000-v3.c 1970-01-01 01:00:00.000000000 +0100
26689 +++ linux-4.1.43/arch/mips/ath79/mach-wnr2000-v3.c 2017-08-06 20:02:15.000000000 +0200
26690 @@ -0,0 +1,140 @@
26692 + * NETGEAR WNR2000v3/WNR612v2/WNR1000v2 board support
26694 + * Copytight (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
26695 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
26696 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
26697 + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
26699 + * This program is free software; you can redistribute it and/or modify it
26700 + * under the terms of the GNU General Public License version 2 as published
26701 + * by the Free Software Foundation.
26702 + */
26704 +#include <linux/mtd/mtd.h>
26705 +#include <linux/mtd/partitions.h>
26707 +#include <asm/mach-ath79/ath79.h>
26709 +#include "dev-ap9x-pci.h"
26710 +#include "dev-eth.h"
26711 +#include "dev-gpio-buttons.h"
26712 +#include "dev-leds-gpio.h"
26713 +#include "dev-m25p80.h"
26714 +#include "machtypes.h"
26716 +#define WNR2000V3_GPIO_LED_WAN_GREEN 0
26717 +#define WNR2000V3_GPIO_LED_LAN1_AMBER 1
26718 +#define WNR2000V3_GPIO_LED_LAN4_AMBER 12
26719 +#define WNR2000V3_GPIO_LED_PWR_GREEN 14
26720 +#define WNR2000V3_GPIO_BTN_WPS 11
26722 +#define WNR612V2_GPIO_LED_PWR_GREEN 11
26724 +#define WNR1000V2_GPIO_LED_PWR_AMBER 1
26725 +#define WNR1000V2_GPIO_LED_PWR_GREEN 11
26727 +#define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
26728 +#define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
26730 +#define WNR2000V3_MAC0_OFFSET 0
26731 +#define WNR2000V3_MAC1_OFFSET 6
26732 +#define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
26734 +static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
26736 + .name = "wnr2000v3:green:power",
26737 + .gpio = WNR2000V3_GPIO_LED_PWR_GREEN,
26738 + .active_low = 1,
26739 + }, {
26740 + .name = "wnr2000v3:green:wan",
26741 + .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
26742 + .active_low = 1,
26746 +static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
26748 + .name = "netgear:green:power",
26749 + .gpio = WNR612V2_GPIO_LED_PWR_GREEN,
26750 + .active_low = 1,
26754 +static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
26756 + .name = "netgear:green:power",
26757 + .gpio = WNR1000V2_GPIO_LED_PWR_GREEN,
26758 + .active_low = 1,
26759 + }, {
26760 + .name = "netgear:amber:power",
26761 + .gpio = WNR1000V2_GPIO_LED_PWR_AMBER,
26762 + .active_low = 1,
26766 +static struct gpio_keys_button wnr2000v3_gpio_keys[] __initdata = {
26768 + .desc = "wps",
26769 + .type = EV_KEY,
26770 + .code = KEY_WPS_BUTTON,
26771 + .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
26772 + .gpio = WNR2000V3_GPIO_BTN_WPS,
26776 +static void __init wnr_common_setup(void)
26778 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26780 + ath79_register_mdio(0, 0x0);
26782 + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
26783 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
26784 + ath79_eth0_data.speed = SPEED_100;
26785 + ath79_eth0_data.duplex = DUPLEX_FULL;
26787 + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
26788 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
26789 + ath79_eth1_data.phy_mask = 0x10;
26791 + ath79_register_eth(0);
26792 + ath79_register_eth(1);
26794 + ath79_register_m25p80(NULL);
26795 + ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, NULL);
26798 +static void __init wnr2000v3_setup(void)
26800 + wnr_common_setup();
26802 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
26803 + wnr2000v3_leds_gpio);
26805 + ath79_register_gpio_keys_polled(-1, WNR2000V3_KEYS_POLL_INTERVAL,
26806 + ARRAY_SIZE(wnr2000v3_gpio_keys),
26807 + wnr2000v3_gpio_keys);
26810 +MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
26812 +static void __init wnr612v2_setup(void)
26814 + wnr_common_setup();
26816 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
26817 + wnr612v2_leds_gpio);
26820 +MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
26822 +static void __init wnr1000v2_setup(void)
26824 + wnr_common_setup();
26826 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
26827 + wnr1000v2_leds_gpio);
26830 +MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
26831 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000-v4.c linux-4.1.43/arch/mips/ath79/mach-wnr2000-v4.c
26832 --- linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000-v4.c 1970-01-01 01:00:00.000000000 +0100
26833 +++ linux-4.1.43/arch/mips/ath79/mach-wnr2000-v4.c 2017-08-06 20:02:15.000000000 +0200
26834 @@ -0,0 +1,214 @@
26836 + * NETGEAR WNR2000v4 board support
26838 + * Copyright (C) 2015 Michael Bazzinotti <mbazzinotti@gmail.com>
26839 + * Copyright (C) 2014 Michaël Burtin <mburtin@gmail.com>
26840 + * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
26841 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
26842 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
26843 + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
26845 + * This program is free software; you can redistribute it and/or modify it
26846 + * under the terms of the GNU General Public License version 2 as published
26847 + * by the Free Software Foundation.
26848 + */
26850 +#include <linux/mtd/mtd.h>
26851 +#include <linux/mtd/partitions.h>
26852 +#include <linux/platform_device.h>
26854 +#include <asm/mach-ath79/ath79.h>
26855 +#include <asm/mach-ath79/ar71xx_regs.h>
26857 +#include "common.h"
26858 +#include "dev-eth.h"
26859 +#include "dev-gpio-buttons.h"
26860 +#include "dev-leds-gpio.h"
26861 +#include "dev-m25p80.h"
26862 +#include "dev-usb.h"
26863 +#include "dev-wmac.h"
26864 +#include "machtypes.h"
26866 +/* AR9341 GPIOs */
26867 +#define WNR2000V4_GPIO_LED_PWR_GREEN 0
26868 +#define WNR2000V4_GPIO_LED_PWR_AMBER 1
26869 +#define WNR2000V4_GPIO_LED_WPS 2
26870 +#define WNR2000V4_GPIO_LED_WLAN 12
26871 +#define WNR2000V4_GPIO_LED_LAN1_GREEN 13
26872 +#define WNR2000V4_GPIO_LED_LAN2_GREEN 14
26873 +#define WNR2000V4_GPIO_LED_LAN3_GREEN 15
26874 +#define WNR2000V4_GPIO_LED_LAN4_GREEN 16
26875 +#define WNR2000V4_GPIO_LED_LAN1_AMBER 18
26876 +#define WNR2000V4_GPIO_LED_LAN2_AMBER 19
26877 +#define WNR2000V4_GPIO_LED_LAN3_AMBER 20
26878 +#define WNR2000V4_GPIO_LED_LAN4_AMBER 21
26879 +#define WNR2000V4_GPIO_LED_WAN_GREEN 17
26880 +#define WNR2000V4_GPIO_LED_WAN_AMBER 22
26881 +/* Buttons */
26882 +#define WNR2000V4_GPIO_BTN_WPS 3
26883 +#define WNR2000V4_GPIO_BTN_RESET 4
26884 +#define WNR2000V4_GPIO_BTN_WLAN 11
26885 +#define WNR2000V4_KEYS_POLL_INTERVAL 20 /* msecs */
26886 +#define WNR2000V4_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V4_KEYS_POLL_INTERVAL)
26889 +/* ART offsets */
26890 +#define WNR2000V4_MAC0_OFFSET 0 /* WAN/WLAN0 MAC */
26891 +#define WNR2000V4_MAC1_OFFSET 6 /* Eth-switch0 MAC */
26893 +static struct gpio_led wnr2000v4_leds_gpio[] __initdata = {
26895 + .name = "netgear:green:power",
26896 + .gpio = WNR2000V4_GPIO_LED_PWR_GREEN,
26897 + .active_low = 1,
26898 + .default_trigger = "default-on",
26899 + },
26901 + .name = "netgear:amber:status",
26902 + .gpio = WNR2000V4_GPIO_LED_PWR_AMBER,
26903 + .active_low = 1,
26904 + },
26906 + .name = "netgear:green:wan",
26907 + .gpio = WNR2000V4_GPIO_LED_WAN_GREEN,
26908 + .active_low = 1,
26909 + },
26911 + .name = "netgear:amber:wan",
26912 + .gpio = WNR2000V4_GPIO_LED_WAN_AMBER,
26913 + .active_low = 1,
26914 + },
26916 + .name = "netgear:blue:wlan",
26917 + .gpio = WNR2000V4_GPIO_LED_WLAN,
26918 + .active_low = 1,
26919 + },
26920 + /* LAN LEDS */
26922 + .name = "netgear:green:lan1",
26923 + .gpio = WNR2000V4_GPIO_LED_LAN1_GREEN,
26924 + .active_low = 1,
26925 + },
26927 + .name = "netgear:green:lan2",
26928 + .gpio = WNR2000V4_GPIO_LED_LAN2_GREEN,
26929 + .active_low = 1,
26930 + },
26932 + .name = "netgear:green:lan3",
26933 + .gpio = WNR2000V4_GPIO_LED_LAN3_GREEN,
26934 + .active_low = 1,
26935 + },
26937 + .name = "netgear:green:lan4",
26938 + .gpio = WNR2000V4_GPIO_LED_LAN4_GREEN,
26939 + .active_low = 1,
26940 + },
26942 + .name = "netgear:amber:lan1",
26943 + .gpio = WNR2000V4_GPIO_LED_LAN1_AMBER,
26944 + .active_low = 1,
26945 + },
26947 + .name = "netgear:amber:lan2",
26948 + .gpio = WNR2000V4_GPIO_LED_LAN2_AMBER,
26949 + .active_low = 1,
26950 + },
26952 + .name = "netgear:amber:lan3",
26953 + .gpio = WNR2000V4_GPIO_LED_LAN3_AMBER,
26954 + .active_low = 1,
26955 + },
26957 + .name = "netgear:amber:lan4",
26958 + .gpio = WNR2000V4_GPIO_LED_LAN4_AMBER,
26959 + .active_low = 1,
26960 + },
26962 + .name = "netgear:green:wps",
26963 + .gpio = WNR2000V4_GPIO_LED_WPS,
26964 + .active_low = 1,
26965 + },
26968 +static struct gpio_keys_button wnr2000v4_gpio_keys[] __initdata = {
26970 + .desc = "WPS button",
26971 + .type = EV_KEY,
26972 + .code = KEY_WPS_BUTTON,
26973 + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
26974 + .gpio = WNR2000V4_GPIO_BTN_WPS,
26975 + .active_low = 1,
26976 + },
26978 + .desc = "Reset button",
26979 + .type = EV_KEY,
26980 + .code = KEY_RESTART,
26981 + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
26982 + .gpio = WNR2000V4_GPIO_BTN_RESET,
26983 + .active_low = 1,
26984 + },
26986 + .desc = "WLAN button",
26987 + .type = EV_KEY,
26988 + .code = KEY_RFKILL,
26989 + .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
26990 + .gpio = WNR2000V4_GPIO_BTN_WLAN,
26991 + .active_low = 1,
26992 + },
26995 +static void __init wnr_common_setup(void)
26997 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
26998 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
27000 + ath79_register_mdio(1, 0x0);
27002 + ath79_register_usb();
27004 + ath79_register_m25p80(NULL);
27006 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
27008 + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V4_MAC0_OFFSET, 0);
27009 + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V4_MAC1_OFFSET, 0);
27011 + /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
27012 + ath79_switch_data.phy4_mii_en = 1;
27013 + ath79_switch_data.phy_poll_mask = BIT(4);
27014 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
27015 + ath79_eth0_data.phy_mask = BIT(4);
27016 + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
27017 + ath79_register_eth(0);
27019 + /* GMAC1 is connected to the internal switch, GE1 */
27020 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
27021 + ath79_register_eth(1);
27023 + ath79_register_wmac(ee, art);
27026 +static void __init wnr2000v4_setup(void)
27028 + int i;
27030 + wnr_common_setup();
27032 + /* Ensure no LED has an internal MUX signal, otherwise
27033 + control of LED could be lost... This is especially important
27034 + for most green LEDS (Eth,WAN).. who arrive in this function with
27035 + MUX signals set. */
27036 + for (i = 0; i < ARRAY_SIZE(wnr2000v4_leds_gpio); i++)
27037 + ath79_gpio_output_select(wnr2000v4_leds_gpio[i].gpio,
27038 + AR934X_GPIO_OUT_GPIO);
27040 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio),
27041 + wnr2000v4_leds_gpio);
27043 + ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL,
27044 + ARRAY_SIZE(wnr2000v4_gpio_keys),
27045 + wnr2000v4_gpio_keys);
27048 +MIPS_MACHINE(ATH79_MACH_WNR2000_V4, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup);
27049 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000.c linux-4.1.43/arch/mips/ath79/mach-wnr2000.c
27050 --- linux-4.1.43.orig/arch/mips/ath79/mach-wnr2000.c 1970-01-01 01:00:00.000000000 +0100
27051 +++ linux-4.1.43/arch/mips/ath79/mach-wnr2000.c 2017-08-06 20:02:15.000000000 +0200
27052 @@ -0,0 +1,145 @@
27054 + * NETGEAR WNR2000 board support
27056 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
27057 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
27058 + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
27060 + * This program is free software; you can redistribute it and/or modify it
27061 + * under the terms of the GNU General Public License version 2 as published
27062 + * by the Free Software Foundation.
27063 + */
27065 +#include <linux/mtd/mtd.h>
27066 +#include <linux/mtd/partitions.h>
27068 +#include <asm/mach-ath79/ath79.h>
27070 +#include "dev-eth.h"
27071 +#include "dev-gpio-buttons.h"
27072 +#include "dev-leds-gpio.h"
27073 +#include "dev-m25p80.h"
27074 +#include "dev-wmac.h"
27075 +#include "machtypes.h"
27077 +#define WNR2000_GPIO_LED_PWR_GREEN 14
27078 +#define WNR2000_GPIO_LED_PWR_AMBER 7
27079 +#define WNR2000_GPIO_LED_WPS 4
27080 +#define WNR2000_GPIO_LED_WLAN 6
27081 +#define WNR2000_GPIO_BTN_RESET 21
27082 +#define WNR2000_GPIO_BTN_WPS 8
27084 +#define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */
27085 +#define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL)
27087 +static struct mtd_partition wnr2000_partitions[] = {
27089 + .name = "u-boot",
27090 + .offset = 0,
27091 + .size = 0x040000,
27092 + .mask_flags = MTD_WRITEABLE,
27093 + }, {
27094 + .name = "u-boot-env",
27095 + .offset = 0x040000,
27096 + .size = 0x010000,
27097 + }, {
27098 + .name = "rootfs",
27099 + .offset = 0x050000,
27100 + .size = 0x240000,
27101 + }, {
27102 + .name = "user-config",
27103 + .offset = 0x290000,
27104 + .size = 0x010000,
27105 + }, {
27106 + .name = "uImage",
27107 + .offset = 0x2a0000,
27108 + .size = 0x120000,
27109 + }, {
27110 + .name = "language_table",
27111 + .offset = 0x3c0000,
27112 + .size = 0x020000,
27113 + }, {
27114 + .name = "rootfs_checksum",
27115 + .offset = 0x3e0000,
27116 + .size = 0x010000,
27117 + }, {
27118 + .name = "art",
27119 + .offset = 0x3f0000,
27120 + .size = 0x010000,
27121 + .mask_flags = MTD_WRITEABLE,
27125 +static struct flash_platform_data wnr2000_flash_data = {
27126 + .parts = wnr2000_partitions,
27127 + .nr_parts = ARRAY_SIZE(wnr2000_partitions),
27130 +static struct gpio_led wnr2000_leds_gpio[] __initdata = {
27132 + .name = "netgear:green:power",
27133 + .gpio = WNR2000_GPIO_LED_PWR_GREEN,
27134 + .active_low = 1,
27135 + }, {
27136 + .name = "netgear:amber:power",
27137 + .gpio = WNR2000_GPIO_LED_PWR_AMBER,
27138 + .active_low = 1,
27139 + }, {
27140 + .name = "netgear:green:wps",
27141 + .gpio = WNR2000_GPIO_LED_WPS,
27142 + .active_low = 1,
27143 + }, {
27144 + .name = "netgear:blue:wlan",
27145 + .gpio = WNR2000_GPIO_LED_WLAN,
27146 + .active_low = 1,
27150 +static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = {
27152 + .desc = "reset",
27153 + .type = EV_KEY,
27154 + .code = KEY_RESTART,
27155 + .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
27156 + .gpio = WNR2000_GPIO_BTN_RESET,
27157 + }, {
27158 + .desc = "wps",
27159 + .type = EV_KEY,
27160 + .code = KEY_WPS_BUTTON,
27161 + .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
27162 + .gpio = WNR2000_GPIO_BTN_WPS,
27166 +static void __init wnr2000_setup(void)
27168 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
27170 + ath79_register_mdio(0, 0x0);
27172 + ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
27173 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
27174 + ath79_eth0_data.speed = SPEED_100;
27175 + ath79_eth0_data.duplex = DUPLEX_FULL;
27176 + ath79_eth0_data.has_ar8216 = 1;
27178 + ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
27179 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
27180 + ath79_eth1_data.phy_mask = 0x10;
27182 + ath79_register_eth(0);
27183 + ath79_register_eth(1);
27185 + ath79_register_m25p80(&wnr2000_flash_data);
27187 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
27188 + wnr2000_leds_gpio);
27190 + ath79_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL,
27191 + ARRAY_SIZE(wnr2000_gpio_keys),
27192 + wnr2000_gpio_keys);
27194 + ath79_register_wmac(eeprom, NULL);
27197 +MIPS_MACHINE(ATH79_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);
27198 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wnr2200.c linux-4.1.43/arch/mips/ath79/mach-wnr2200.c
27199 --- linux-4.1.43.orig/arch/mips/ath79/mach-wnr2200.c 1970-01-01 01:00:00.000000000 +0100
27200 +++ linux-4.1.43/arch/mips/ath79/mach-wnr2200.c 2017-08-06 20:02:15.000000000 +0200
27201 @@ -0,0 +1,137 @@
27203 + * NETGEAR WNR2200 board support
27205 + * Copyright (C) 2013 Aidan Kissane <aidankissane at googlemail.com>
27207 + * This program is free software; you can redistribute it and/or modify it
27208 + * under the terms of the GNU General Public License version 2 as published
27209 + * by the Free Software Foundation.
27210 + */
27212 +#include <linux/gpio.h>
27214 +#include <linux/mtd/mtd.h>
27215 +#include <linux/mtd/partitions.h>
27217 +#include <asm/mach-ath79/ath79.h>
27219 +#include "dev-ap9x-pci.h"
27220 +#include "dev-eth.h"
27221 +#include "dev-gpio-buttons.h"
27222 +#include "dev-leds-gpio.h"
27223 +#include "dev-m25p80.h"
27224 +#include "dev-usb.h"
27225 +#include "machtypes.h"
27227 +#define WNR2200_GPIO_LED_LAN2_AMBER 0
27228 +#define WNR2200_GPIO_LED_LAN4_AMBER 1
27229 +#define WNR2200_GPIO_LED_WPS 5
27230 +#define WNR2200_GPIO_LED_WAN_GREEN 7
27231 +#define WNR2200_GPIO_LED_USB 8
27232 +#define WNR2200_GPIO_LED_LAN3_AMBER 11
27233 +#define WNR2200_GPIO_LED_WAN_AMBER 12
27234 +#define WNR2200_GPIO_LED_LAN1_GREEN 13
27235 +#define WNR2200_GPIO_LED_LAN2_GREEN 14
27236 +#define WNR2200_GPIO_LED_LAN3_GREEN 15
27237 +#define WNR2200_GPIO_LED_LAN4_GREEN 16
27238 +#define WNR2200_GPIO_LED_PWR_AMBER 21
27239 +#define WNR2200_GPIO_LED_PWR_GREEN 22
27240 +#define WNR2200_GPIO_USB_5V 4
27241 +#define WNR2200_GPIO_USB_POWER 24
27243 +#define WNR2200_KEYS_POLL_INTERVAL 20 /* msecs */
27244 +#define WNR2200_KEYS_DEBOUNCE_INTERVAL (3 * WNR2200_KEYS_POLL_INTERVAL)
27246 +#define WNR2200_MAC0_OFFSET 0
27247 +#define WNR2200_MAC1_OFFSET 6
27248 +#define WNR2200_PCIE_CALDATA_OFFSET 0x1000
27250 +static struct gpio_led wnr2200_leds_gpio[] __initdata = {
27252 + .name = "netgear:amber:lan2",
27253 + .gpio = WNR2200_GPIO_LED_LAN2_AMBER,
27254 + .active_low = 1,
27255 + }, {
27256 + .name = "netgear:amber:lan4",
27257 + .gpio = WNR2200_GPIO_LED_LAN4_AMBER,
27258 + .active_low = 1,
27259 + }, {
27260 + .name = "netgear:green:wps",
27261 + .gpio = WNR2200_GPIO_LED_WPS,
27262 + .active_low = 1,
27263 + }, {
27264 + .name = "netgear:green:wan",
27265 + .gpio = WNR2200_GPIO_LED_WAN_GREEN,
27266 + .active_low = 1,
27267 + }, {
27268 + .name = "netgear:green:usb",
27269 + .gpio = WNR2200_GPIO_LED_USB,
27270 + .active_low = 1,
27271 + }, {
27272 + .name = "netgear:amber:lan3",
27273 + .gpio = WNR2200_GPIO_LED_LAN3_AMBER,
27274 + .active_low = 1,
27275 + }, {
27276 + .name = "netgear:amber:wan",
27277 + .gpio = WNR2200_GPIO_LED_WAN_AMBER,
27278 + .active_low = 1,
27279 + }, {
27280 + .name = "netgear:green:lan1",
27281 + .gpio = WNR2200_GPIO_LED_LAN1_GREEN,
27282 + .active_low = 1,
27283 + }, {
27284 + .name = "netgear:green:lan2",
27285 + .gpio = WNR2200_GPIO_LED_LAN2_GREEN,
27286 + .active_low = 1,
27287 + }, {
27288 + .name = "netgear:green:lan3",
27289 + .gpio = WNR2200_GPIO_LED_LAN3_GREEN,
27290 + .active_low = 1,
27291 + }, {
27292 + .name = "netgear:green:lan4",
27293 + .gpio = WNR2200_GPIO_LED_LAN4_GREEN,
27294 + .active_low = 1,
27295 + }, {
27296 + .name = "netgear:amber:power",
27297 + .gpio = WNR2200_GPIO_LED_PWR_AMBER,
27298 + .active_low = 1,
27299 + }, {
27300 + .name = "netgear:green:power",
27301 + .gpio = WNR2200_GPIO_LED_PWR_GREEN,
27302 + .active_low = 1,
27306 +static void __init wnr2200_setup(void)
27308 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
27310 + ath79_register_mdio(0, 0x0);
27312 + ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2200_MAC0_OFFSET, 0);
27313 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
27314 + ath79_eth0_data.speed = SPEED_100;
27315 + ath79_eth0_data.duplex = DUPLEX_FULL;
27317 + ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2200_MAC1_OFFSET, 0);
27318 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
27319 + ath79_eth1_data.phy_mask = 0x10;
27321 + ath79_register_eth(0);
27322 + ath79_register_eth(1);
27324 + ath79_register_m25p80(NULL);
27325 + ap91_pci_init(art + WNR2200_PCIE_CALDATA_OFFSET, NULL);
27327 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2200_leds_gpio),
27328 + wnr2200_leds_gpio);
27330 + /* enable power for the USB port */
27331 + ap9x_pci_setup_wmac_gpio(0,
27332 + BIT(WNR2200_GPIO_USB_5V),
27333 + BIT(WNR2200_GPIO_USB_5V));
27335 + ath79_register_usb();
27338 +MIPS_MACHINE(ATH79_MACH_WNR2200, "WNR2200", "NETGEAR WNR2200", wnr2200_setup);
27339 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wp543.c linux-4.1.43/arch/mips/ath79/mach-wp543.c
27340 --- linux-4.1.43.orig/arch/mips/ath79/mach-wp543.c 1970-01-01 01:00:00.000000000 +0100
27341 +++ linux-4.1.43/arch/mips/ath79/mach-wp543.c 2017-08-06 20:02:15.000000000 +0200
27342 @@ -0,0 +1,109 @@
27344 + * Compex WP543/WPJ543 board support
27346 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
27347 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
27349 + * This program is free software; you can redistribute it and/or modify it
27350 + * under the terms of the GNU General Public License version 2 as published
27351 + * by the Free Software Foundation.
27352 + */
27354 +#include <asm/mach-ath79/ar71xx_regs.h>
27355 +#include <asm/mach-ath79/ath79.h>
27357 +#include "dev-eth.h"
27358 +#include "dev-gpio-buttons.h"
27359 +#include "dev-leds-gpio.h"
27360 +#include "dev-m25p80.h"
27361 +#include "dev-usb.h"
27362 +#include "machtypes.h"
27363 +#include "pci.h"
27365 +#define WP543_GPIO_SW6 2
27366 +#define WP543_GPIO_LED_1 3
27367 +#define WP543_GPIO_LED_2 4
27368 +#define WP543_GPIO_LED_WLAN 5
27369 +#define WP543_GPIO_LED_CONN 6
27370 +#define WP543_GPIO_LED_DIAG 7
27371 +#define WP543_GPIO_SW4 8
27373 +#define WP543_KEYS_POLL_INTERVAL 20 /* msecs */
27374 +#define WP543_KEYS_DEBOUNCE_INTERVAL (3 * WP543_KEYS_POLL_INTERVAL)
27376 +static struct gpio_led wp543_leds_gpio[] __initdata = {
27378 + .name = "wp543:green:led1",
27379 + .gpio = WP543_GPIO_LED_1,
27380 + .active_low = 1,
27381 + }, {
27382 + .name = "wp543:green:led2",
27383 + .gpio = WP543_GPIO_LED_2,
27384 + .active_low = 1,
27385 + }, {
27386 + .name = "wp543:green:wlan",
27387 + .gpio = WP543_GPIO_LED_WLAN,
27388 + .active_low = 1,
27389 + }, {
27390 + .name = "wp543:green:conn",
27391 + .gpio = WP543_GPIO_LED_CONN,
27392 + .active_low = 1,
27393 + }, {
27394 + .name = "wp543:green:diag",
27395 + .gpio = WP543_GPIO_LED_DIAG,
27396 + .active_low = 1,
27400 +static struct gpio_keys_button wp543_gpio_keys[] __initdata = {
27402 + .desc = "sw6",
27403 + .type = EV_KEY,
27404 + .code = BTN_0,
27405 + .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
27406 + .gpio = WP543_GPIO_SW6,
27407 + .active_low = 1,
27408 + }, {
27409 + .desc = "sw4",
27410 + .type = EV_KEY,
27411 + .code = KEY_RESTART,
27412 + .debounce_interval = WP543_KEYS_DEBOUNCE_INTERVAL,
27413 + .gpio = WP543_GPIO_SW4,
27414 + .active_low = 1,
27418 +static const char *wp543_part_probes[] = {
27419 + "MyLoader",
27420 + NULL,
27423 +static struct flash_platform_data wp543_flash_data = {
27424 + .part_probes = wp543_part_probes,
27427 +static void __init wp543_setup(void)
27429 + ath79_register_m25p80(&wp543_flash_data);
27431 + ath79_register_mdio(0, 0xfffffff0);
27433 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
27434 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
27435 + ath79_eth0_data.phy_mask = 0x0f;
27436 + ath79_eth0_data.reset_bit = AR71XX_RESET_GE0_MAC |
27437 + AR71XX_RESET_GE0_PHY;
27438 + ath79_register_eth(0);
27440 + ath79_register_usb();
27441 + ath79_register_pci();
27443 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
27444 + wp543_leds_gpio);
27446 + ath79_register_gpio_keys_polled(-1, WP543_KEYS_POLL_INTERVAL,
27447 + ARRAY_SIZE(wp543_gpio_keys),
27448 + wp543_gpio_keys);
27451 +MIPS_MACHINE(ATH79_MACH_WP543, "WP543", "Compex WP543", wp543_setup);
27452 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wpe72.c linux-4.1.43/arch/mips/ath79/mach-wpe72.c
27453 --- linux-4.1.43.orig/arch/mips/ath79/mach-wpe72.c 1970-01-01 01:00:00.000000000 +0100
27454 +++ linux-4.1.43/arch/mips/ath79/mach-wpe72.c 2017-08-06 20:02:15.000000000 +0200
27455 @@ -0,0 +1,97 @@
27457 + * Compex WPE72 board support
27459 + * Copyright (C) 2012 Johnathan Boyce<jon.boyce@globalreach.eu.com>
27461 + * This program is free software; you can redistribute it and/or modify it
27462 + * under the terms of the GNU General Public License version 2 as published
27463 + * by the Free Software Foundation.
27464 + */
27466 +#include <asm/mach-ath79/ath79.h>
27468 +#include "dev-eth.h"
27469 +#include "dev-gpio-buttons.h"
27470 +#include "dev-leds-gpio.h"
27471 +#include "dev-m25p80.h"
27472 +#include "dev-usb.h"
27473 +#include "machtypes.h"
27474 +#include "pci.h"
27476 +#define WPE72_GPIO_RESET 12
27477 +#define WPE72_GPIO_LED_DIAG 13
27478 +#define WPE72_GPIO_LED_1 14
27479 +#define WPE72_GPIO_LED_2 15
27480 +#define WPE72_GPIO_LED_3 16
27481 +#define WPE72_GPIO_LED_4 17
27483 +#define WPE72_KEYS_POLL_INTERVAL 20 /* msecs */
27484 +#define WPE72_KEYS_DEBOUNCE_INTERVAL (3 * WPE72_KEYS_POLL_INTERVAL)
27486 +static struct gpio_led wpe72_leds_gpio[] __initdata = {
27488 + .name = "wpe72:green:led1",
27489 + .gpio = WPE72_GPIO_LED_1,
27490 + .active_low = 1,
27491 + }, {
27492 + .name = "wpe72:green:led2",
27493 + .gpio = WPE72_GPIO_LED_2,
27494 + .active_low = 1,
27495 + }, {
27496 + .name = "wpe72:green:led3",
27497 + .gpio = WPE72_GPIO_LED_3,
27498 + .active_low = 1,
27499 + }, {
27500 + .name = "wpe72:green:led4",
27501 + .gpio = WPE72_GPIO_LED_4,
27502 + .active_low = 1,
27503 + }, {
27504 + .name = "wpe72:green:diag",
27505 + .gpio = WPE72_GPIO_LED_DIAG,
27506 + .active_low = 1,
27510 +static struct gpio_keys_button wpe72_gpio_keys[] __initdata = {
27512 + .desc = "reset",
27513 + .type = EV_KEY,
27514 + .code = KEY_RESTART,
27515 + .debounce_interval = WPE72_KEYS_DEBOUNCE_INTERVAL,
27516 + .gpio = WPE72_GPIO_RESET,
27517 + .active_low = 1,
27521 +static const char *wpe72_part_probes[] = {
27522 + "MyLoader",
27523 + NULL,
27526 +static struct flash_platform_data wpe72_flash_data = {
27527 + .part_probes = wpe72_part_probes,
27530 +static void __init wpe72_setup(void)
27532 + ath79_register_m25p80(&wpe72_flash_data);
27533 + ath79_register_mdio(0, 0x0);
27535 + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
27536 + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
27538 + ath79_register_eth(0);
27539 + ath79_register_eth(1);
27541 + ath79_register_usb();
27542 + ath79_register_pci();
27544 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpe72_leds_gpio),
27545 + wpe72_leds_gpio);
27547 + ath79_register_gpio_keys_polled(-1, WPE72_KEYS_POLL_INTERVAL,
27548 + ARRAY_SIZE(wpe72_gpio_keys),
27549 + wpe72_gpio_keys);
27552 +MIPS_MACHINE(ATH79_MACH_WPE72, "WPE72", "Compex WPE72", wpe72_setup);
27553 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wpj344.c linux-4.1.43/arch/mips/ath79/mach-wpj344.c
27554 --- linux-4.1.43.orig/arch/mips/ath79/mach-wpj344.c 1970-01-01 01:00:00.000000000 +0100
27555 +++ linux-4.1.43/arch/mips/ath79/mach-wpj344.c 2017-08-06 20:02:15.000000000 +0200
27556 @@ -0,0 +1,175 @@
27558 + * Compex WPJ344 board support
27560 + * Copyright (c) 2011 Qualcomm Atheros
27561 + * Copyright (c) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
27563 + * Permission to use, copy, modify, and/or distribute this software for any
27564 + * purpose with or without fee is hereby granted, provided that the above
27565 + * copyright notice and this permission notice appear in all copies.
27567 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
27568 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
27569 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
27570 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27571 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
27572 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27573 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27575 + */
27577 +#include <linux/phy.h>
27578 +#include <linux/platform_device.h>
27579 +#include <linux/ath9k_platform.h>
27580 +#include <linux/ar8216_platform.h>
27582 +#include <asm/mach-ath79/ar71xx_regs.h>
27584 +#include "common.h"
27585 +#include "pci.h"
27586 +#include "dev-ap9x-pci.h"
27587 +#include "dev-gpio-buttons.h"
27588 +#include "dev-eth.h"
27589 +#include "dev-usb.h"
27590 +#include "dev-leds-gpio.h"
27591 +#include "dev-m25p80.h"
27592 +#include "dev-spi.h"
27593 +#include "dev-wmac.h"
27594 +#include "machtypes.h"
27596 +#define WPJ344_GPIO_LED_SIG1 15
27597 +#define WPJ344_GPIO_LED_SIG2 20
27598 +#define WPJ344_GPIO_LED_SIG3 21
27599 +#define WPJ344_GPIO_LED_SIG4 22
27600 +#define WPJ344_GPIO_LED_STATUS 14
27602 +#define WPJ344_GPIO_BTN_RESET 12
27604 +#define WPJ344_KEYS_POLL_INTERVAL 20 /* msecs */
27605 +#define WPJ344_KEYS_DEBOUNCE_INTERVAL (3 * WPJ344_KEYS_POLL_INTERVAL)
27607 +#define WPJ344_MAC0_OFFSET 0
27608 +#define WPJ344_MAC1_OFFSET 6
27609 +#define WPJ344_WMAC_CALDATA_OFFSET 0x1000
27610 +#define WPJ344_PCIE_CALDATA_OFFSET 0x5000
27612 +static struct gpio_led wpj344_leds_gpio[] __initdata = {
27614 + .name = "wpj344:green:status",
27615 + .gpio = WPJ344_GPIO_LED_STATUS,
27616 + .active_low = 1,
27617 + },
27619 + .name = "wpj344:red:sig1",
27620 + .gpio = WPJ344_GPIO_LED_SIG1,
27621 + .active_low = 1,
27622 + },
27624 + .name = "wpj344:yellow:sig2",
27625 + .gpio = WPJ344_GPIO_LED_SIG2,
27626 + .active_low = 1,
27627 + },
27629 + .name = "wpj344:green:sig3",
27630 + .gpio = WPJ344_GPIO_LED_SIG3,
27631 + .active_low = 1,
27632 + },
27634 + .name = "wpj344:green:sig4",
27635 + .gpio = WPJ344_GPIO_LED_SIG4,
27636 + .active_low = 1,
27640 +static struct gpio_keys_button wpj344_gpio_keys[] __initdata = {
27642 + .desc = "reset",
27643 + .type = EV_KEY,
27644 + .code = KEY_RESTART,
27645 + .debounce_interval = WPJ344_KEYS_DEBOUNCE_INTERVAL,
27646 + .gpio = WPJ344_GPIO_BTN_RESET,
27647 + .active_low = 1,
27648 + },
27651 +static struct ar8327_pad_cfg wpj344_ar8327_pad0_cfg = {
27652 + .mode = AR8327_PAD_MAC_RGMII,
27653 + .txclk_delay_en = true,
27654 + .rxclk_delay_en = true,
27655 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
27656 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
27659 +static struct ar8327_led_cfg wpj344_ar8327_led_cfg = {
27660 + .led_ctrl0 = 0x00000000,
27661 + .led_ctrl1 = 0xc737c737,
27662 + .led_ctrl2 = 0x00000000,
27663 + .led_ctrl3 = 0x00c30c00,
27664 + .open_drain = true,
27667 +static struct ar8327_platform_data wpj344_ar8327_data = {
27668 + .pad0_cfg = &wpj344_ar8327_pad0_cfg,
27669 + .port0_cfg = {
27670 + .force_link = 1,
27671 + .speed = AR8327_PORT_SPEED_1000,
27672 + .duplex = 1,
27673 + .txpause = 1,
27674 + .rxpause = 1,
27675 + },
27676 + .led_cfg = &wpj344_ar8327_led_cfg,
27679 +static struct mdio_board_info wpj344_mdio0_info[] = {
27681 + .bus_id = "ag71xx-mdio.0",
27682 + .phy_addr = 0,
27683 + .platform_data = &wpj344_ar8327_data,
27684 + },
27687 +static void __init wpj344_setup(void)
27689 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
27691 + ath79_register_m25p80(NULL);
27692 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpj344_leds_gpio),
27693 + wpj344_leds_gpio);
27694 + ath79_register_gpio_keys_polled(-1, WPJ344_KEYS_POLL_INTERVAL,
27695 + ARRAY_SIZE(wpj344_gpio_keys),
27696 + wpj344_gpio_keys);
27698 + ath79_register_usb();
27700 + ath79_register_wmac(art + WPJ344_WMAC_CALDATA_OFFSET, NULL);
27702 + ath79_register_pci();
27704 + mdiobus_register_board_info(wpj344_mdio0_info,
27705 + ARRAY_SIZE(wpj344_mdio0_info));
27707 + ath79_register_mdio(1, 0x0);
27708 + ath79_register_mdio(0, 0x0);
27710 + ath79_init_mac(ath79_eth0_data.mac_addr, art + WPJ344_MAC0_OFFSET, 0);
27711 + ath79_init_mac(ath79_eth1_data.mac_addr, art + WPJ344_MAC1_OFFSET, 0);
27713 + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
27714 + AR934X_ETH_CFG_SW_ONLY_MODE);
27716 + /* GMAC0 is connected to an AR8327 switch */
27717 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
27718 + ath79_eth0_data.phy_mask = BIT(0);
27719 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
27720 + ath79_eth0_pll_data.pll_1000 = 0x06000000;
27722 + /* GMAC1 is connected to the internal switch */
27723 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
27724 + ath79_eth1_data.speed = SPEED_1000;
27725 + ath79_eth1_data.duplex = DUPLEX_FULL;
27727 + ath79_register_eth(0);
27728 + ath79_register_eth(1);
27731 +MIPS_MACHINE(ATH79_MACH_WPJ344, "WPJ344", "Compex WPJ344", wpj344_setup);
27732 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wpj531.c linux-4.1.43/arch/mips/ath79/mach-wpj531.c
27733 --- linux-4.1.43.orig/arch/mips/ath79/mach-wpj531.c 1970-01-01 01:00:00.000000000 +0100
27734 +++ linux-4.1.43/arch/mips/ath79/mach-wpj531.c 2017-08-06 20:02:15.000000000 +0200
27735 @@ -0,0 +1,143 @@
27737 + * Compex WPJ531 board support
27739 + * Copyright (c) 2012 Qualcomm Atheros
27740 + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
27742 + * Permission to use, copy, modify, and/or distribute this software for any
27743 + * purpose with or without fee is hereby granted, provided that the above
27744 + * copyright notice and this permission notice appear in all copies.
27746 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
27747 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
27748 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
27749 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27750 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
27751 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27752 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27754 + */
27756 +#include <linux/irq.h>
27757 +#include <linux/platform_device.h>
27758 +#include <linux/ar8216_platform.h>
27760 +#include <asm/mach-ath79/ar71xx_regs.h>
27762 +#include "pci.h"
27763 +#include "common.h"
27764 +#include "dev-ap9x-pci.h"
27765 +#include "dev-gpio-buttons.h"
27766 +#include "dev-eth.h"
27767 +#include "dev-leds-gpio.h"
27768 +#include "dev-m25p80.h"
27769 +#include "dev-usb.h"
27770 +#include "dev-wmac.h"
27771 +#include "machtypes.h"
27773 +#define WPJ531_GPIO_LED_SIG1 14
27774 +#define WPJ531_GPIO_LED_SIG2 15
27775 +#define WPJ531_GPIO_LED_SIG3 22
27776 +#define WPJ531_GPIO_LED_SIG4 23
27777 +#define WPJ531_GPIO_BUZZER 4
27779 +#define WPJ531_GPIO_BTN_RESET 17
27781 +#define WPJ531_KEYS_POLL_INTERVAL 20 /* msecs */
27782 +#define WPJ531_KEYS_DEBOUNCE_INTERVAL (3 * WPJ531_KEYS_POLL_INTERVAL)
27784 +#define WPJ531_MAC0_OFFSET 0x10
27785 +#define WPJ531_MAC1_OFFSET 0x18
27786 +#define WPJ531_WMAC_CALDATA_OFFSET 0x1000
27787 +#define WPJ531_PCIE_CALDATA_OFFSET 0x5000
27789 +#define WPJ531_ART_SIZE 0x8000
27791 +static struct gpio_led wpj531_leds_gpio[] __initdata = {
27793 + .name = "wpj531:red:sig1",
27794 + .gpio = WPJ531_GPIO_LED_SIG1,
27795 + .active_low = 1,
27796 + },
27798 + .name = "wpj531:yellow:sig2",
27799 + .gpio = WPJ531_GPIO_LED_SIG2,
27800 + .active_low = 1,
27801 + },
27803 + .name = "wpj531:green:sig3",
27804 + .gpio = WPJ531_GPIO_LED_SIG3,
27805 + .active_low = 1,
27806 + },
27808 + .name = "wpj531:green:sig4",
27809 + .gpio = WPJ531_GPIO_LED_SIG4,
27810 + .active_low = 1,
27811 + },
27813 + .name = "wpj531:buzzer",
27814 + .gpio = WPJ531_GPIO_BUZZER,
27815 + .active_low = 0,
27819 +static struct gpio_keys_button wpj531_gpio_keys[] __initdata = {
27821 + .desc = "reset",
27822 + .type = EV_KEY,
27823 + .code = KEY_RESTART,
27824 + .debounce_interval = WPJ531_KEYS_DEBOUNCE_INTERVAL,
27825 + .gpio = WPJ531_GPIO_BTN_RESET,
27826 + .active_low = 1,
27827 + },
27830 +static void __init common_setup(void)
27832 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
27833 + u8 *mac = (u8 *) KSEG1ADDR(0x1f02e000);
27835 + ath79_register_m25p80(NULL);
27837 + ath79_setup_ar933x_phy4_switch(false, false);
27839 + ath79_register_mdio(0, 0x0);
27841 + /* LAN */
27842 + ath79_eth0_data.duplex = DUPLEX_FULL;
27843 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
27844 + ath79_eth0_data.speed = SPEED_100;
27845 + ath79_eth0_data.phy_mask = BIT(4);
27846 + ath79_init_mac(ath79_eth0_data.mac_addr, mac + WPJ531_MAC0_OFFSET, 0);
27847 + ath79_register_eth(0);
27849 + /* WAN */
27850 + ath79_switch_data.phy4_mii_en = 1;
27851 + ath79_eth1_data.duplex = DUPLEX_FULL;
27852 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
27853 + ath79_eth1_data.speed = SPEED_1000;
27854 + ath79_switch_data.phy_poll_mask |= BIT(4);
27855 + ath79_init_mac(ath79_eth1_data.mac_addr, mac + WPJ531_MAC1_OFFSET, 0);
27856 + ath79_register_eth(1);
27858 + ath79_register_wmac(art + WPJ531_WMAC_CALDATA_OFFSET, NULL);
27860 + ath79_register_pci();
27861 + ath79_register_usb();
27864 +static void __init wpj531_setup(void)
27866 + common_setup();
27868 + ath79_register_leds_gpio(-1,
27869 + ARRAY_SIZE(wpj531_leds_gpio),
27870 + wpj531_leds_gpio);
27872 + ath79_register_gpio_keys_polled(-1,
27873 + WPJ531_KEYS_POLL_INTERVAL,
27874 + ARRAY_SIZE(wpj531_gpio_keys),
27875 + wpj531_gpio_keys);
27878 +MIPS_MACHINE(ATH79_MACH_WPJ531, "WPJ531", "Compex WPJ531", wpj531_setup);
27879 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wpj558.c linux-4.1.43/arch/mips/ath79/mach-wpj558.c
27880 --- linux-4.1.43.orig/arch/mips/ath79/mach-wpj558.c 1970-01-01 01:00:00.000000000 +0100
27881 +++ linux-4.1.43/arch/mips/ath79/mach-wpj558.c 2017-08-06 20:02:15.000000000 +0200
27882 @@ -0,0 +1,177 @@
27884 + * Compex WPJ558 board support
27886 + * Copyright (c) 2012 Qualcomm Atheros
27887 + * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
27889 + * Permission to use, copy, modify, and/or distribute this software for any
27890 + * purpose with or without fee is hereby granted, provided that the above
27891 + * copyright notice and this permission notice appear in all copies.
27893 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
27894 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
27895 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
27896 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27897 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
27898 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27899 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27901 + */
27903 +#include <linux/pci.h>
27904 +#include <linux/phy.h>
27905 +#include <linux/gpio.h>
27906 +#include <linux/platform_device.h>
27907 +#include <linux/ath9k_platform.h>
27908 +#include <linux/ar8216_platform.h>
27910 +#include <asm/mach-ath79/ar71xx_regs.h>
27912 +#include "common.h"
27913 +#include "pci.h"
27914 +#include "dev-ap9x-pci.h"
27915 +#include "dev-gpio-buttons.h"
27916 +#include "dev-eth.h"
27917 +#include "dev-usb.h"
27918 +#include "dev-leds-gpio.h"
27919 +#include "dev-m25p80.h"
27920 +#include "dev-spi.h"
27921 +#include "dev-wmac.h"
27922 +#include "machtypes.h"
27924 +#define WPJ558_GPIO_LED_SIG1 14
27925 +#define WPJ558_GPIO_LED_SIG2 15
27926 +#define WPJ558_GPIO_LED_SIG3 22
27927 +#define WPJ558_GPIO_LED_SIG4 23
27928 +#define WPJ558_GPIO_BUZZER 4
27930 +#define WPJ558_GPIO_BTN_RESET 17
27932 +#define WPJ558_KEYS_POLL_INTERVAL 20 /* msecs */
27933 +#define WPJ558_KEYS_DEBOUNCE_INTERVAL (3 * WPJ558_KEYS_POLL_INTERVAL)
27935 +#define WPJ558_MAC_OFFSET 0x1002
27936 +#define WPJ558_WMAC_CALDATA_OFFSET 0x1000
27938 +static struct gpio_led wpj558_leds_gpio[] __initdata = {
27940 + .name = "wpj558:red:sig1",
27941 + .gpio = WPJ558_GPIO_LED_SIG1,
27942 + .active_low = 1,
27943 + },
27945 + .name = "wpj558:yellow:sig2",
27946 + .gpio = WPJ558_GPIO_LED_SIG2,
27947 + .active_low = 1,
27948 + },
27950 + .name = "wpj558:green:sig3",
27951 + .gpio = WPJ558_GPIO_LED_SIG3,
27952 + .active_low = 1,
27953 + },
27955 + .name = "wpj558:green:sig4",
27956 + .gpio = WPJ558_GPIO_LED_SIG4,
27957 + .active_low = 1,
27958 + },
27960 + .name = "wpj558:buzzer",
27961 + .gpio = WPJ558_GPIO_BUZZER,
27962 + .active_low = 0,
27966 +static struct gpio_keys_button wpj558_gpio_keys[] __initdata = {
27968 + .desc = "reset",
27969 + .type = EV_KEY,
27970 + .code = KEY_RESTART,
27971 + .debounce_interval = WPJ558_KEYS_DEBOUNCE_INTERVAL,
27972 + .gpio = WPJ558_GPIO_BTN_RESET,
27973 + .active_low = 1,
27974 + },
27977 +static struct ar8327_pad_cfg wpj558_ar8327_pad0_cfg = {
27978 + .mode = AR8327_PAD_MAC_SGMII,
27979 + .sgmii_delay_en = true,
27982 +static struct ar8327_pad_cfg wpj558_ar8327_pad6_cfg = {
27983 + .mode = AR8327_PAD_MAC_RGMII,
27984 + .txclk_delay_en = true,
27985 + .rxclk_delay_en = true,
27986 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
27987 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
27990 +static struct ar8327_platform_data wpj558_ar8327_data = {
27991 + .pad0_cfg = &wpj558_ar8327_pad0_cfg,
27992 + .pad6_cfg = &wpj558_ar8327_pad6_cfg,
27993 + .port0_cfg = {
27994 + .force_link = 1,
27995 + .speed = AR8327_PORT_SPEED_1000,
27996 + .duplex = 1,
27997 + .txpause = 1,
27998 + .rxpause = 1,
27999 + },
28000 + .port6_cfg = {
28001 + .force_link = 1,
28002 + .speed = AR8327_PORT_SPEED_1000,
28003 + .duplex = 1,
28004 + .txpause = 1,
28005 + .rxpause = 1,
28006 + },
28009 +static struct mdio_board_info wpj558_mdio0_info[] = {
28011 + .bus_id = "ag71xx-mdio.0",
28012 + .phy_addr = 0,
28013 + .platform_data = &wpj558_ar8327_data,
28014 + },
28017 +static void __init wpj558_setup(void)
28019 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
28021 + ath79_register_m25p80(NULL);
28022 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wpj558_leds_gpio),
28023 + wpj558_leds_gpio);
28024 + ath79_register_gpio_keys_polled(-1, WPJ558_KEYS_POLL_INTERVAL,
28025 + ARRAY_SIZE(wpj558_gpio_keys),
28026 + wpj558_gpio_keys);
28028 + ath79_register_usb();
28030 + ath79_register_wmac(art + WPJ558_WMAC_CALDATA_OFFSET, NULL);
28032 + ath79_register_pci();
28034 + mdiobus_register_board_info(wpj558_mdio0_info,
28035 + ARRAY_SIZE(wpj558_mdio0_info));
28036 + ath79_register_mdio(0, 0x0);
28038 + ath79_init_mac(ath79_eth0_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
28039 + ath79_init_mac(ath79_eth1_data.mac_addr, art + WPJ558_MAC_OFFSET, 0);
28041 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
28043 + /* GMAC0 is connected to an AR8327 switch */
28044 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
28045 + ath79_eth0_data.phy_mask = BIT(0);
28046 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
28047 + ath79_eth0_pll_data.pll_1000 = 0x56000000;
28049 + /* GMAC1 is connected to the SGMII interface */
28050 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
28051 + ath79_eth1_data.speed = SPEED_1000;
28052 + ath79_eth1_data.duplex = DUPLEX_FULL;
28053 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
28055 + ath79_register_eth(0);
28056 + ath79_register_eth(1);
28059 +MIPS_MACHINE(ATH79_MACH_WPJ558, "WPJ558", "Compex WPJ558", wpj558_setup);
28060 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wrt160nl.c linux-4.1.43/arch/mips/ath79/mach-wrt160nl.c
28061 --- linux-4.1.43.orig/arch/mips/ath79/mach-wrt160nl.c 1970-01-01 01:00:00.000000000 +0100
28062 +++ linux-4.1.43/arch/mips/ath79/mach-wrt160nl.c 2017-08-06 20:02:15.000000000 +0200
28063 @@ -0,0 +1,126 @@
28065 + * Linksys WRT160NL board support
28067 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
28069 + * This program is free software; you can redistribute it and/or modify it
28070 + * under the terms of the GNU General Public License version 2 as published
28071 + * by the Free Software Foundation.
28072 + */
28074 +#include <asm/mach-ath79/ath79.h>
28076 +#include "dev-eth.h"
28077 +#include "dev-gpio-buttons.h"
28078 +#include "dev-leds-gpio.h"
28079 +#include "dev-m25p80.h"
28080 +#include "dev-usb.h"
28081 +#include "dev-wmac.h"
28082 +#include "nvram.h"
28083 +#include "machtypes.h"
28085 +#define WRT160NL_GPIO_LED_POWER 14
28086 +#define WRT160NL_GPIO_LED_WPS_AMBER 9
28087 +#define WRT160NL_GPIO_LED_WPS_BLUE 8
28088 +#define WRT160NL_GPIO_LED_WLAN 6
28090 +#define WRT160NL_GPIO_BTN_WPS 7
28091 +#define WRT160NL_GPIO_BTN_RESET 21
28093 +#define WRT160NL_KEYS_POLL_INTERVAL 20 /* msecs */
28094 +#define WRT160NL_KEYS_DEBOUNCE_INTERVAL (3 * WRT160NL_KEYS_POLL_INTERVAL)
28096 +#define WRT160NL_NVRAM_ADDR 0x1f7e0000
28097 +#define WRT160NL_NVRAM_SIZE 0x10000
28099 +static const char *wrt160nl_part_probes[] = {
28100 + "cybertan",
28101 + NULL,
28104 +static struct flash_platform_data wrt160nl_flash_data = {
28105 + .part_probes = wrt160nl_part_probes,
28108 +static struct gpio_led wrt160nl_leds_gpio[] __initdata = {
28110 + .name = "wrt160nl:blue:power",
28111 + .gpio = WRT160NL_GPIO_LED_POWER,
28112 + .active_low = 1,
28113 + .default_trigger = "default-on",
28114 + }, {
28115 + .name = "wrt160nl:amber:wps",
28116 + .gpio = WRT160NL_GPIO_LED_WPS_AMBER,
28117 + .active_low = 1,
28118 + }, {
28119 + .name = "wrt160nl:blue:wps",
28120 + .gpio = WRT160NL_GPIO_LED_WPS_BLUE,
28121 + .active_low = 1,
28122 + }, {
28123 + .name = "wrt160nl:blue:wlan",
28124 + .gpio = WRT160NL_GPIO_LED_WLAN,
28125 + .active_low = 1,
28129 +static struct gpio_keys_button wrt160nl_gpio_keys[] __initdata = {
28131 + .desc = "reset",
28132 + .type = EV_KEY,
28133 + .code = KEY_RESTART,
28134 + .debounce_interval = WRT160NL_KEYS_DEBOUNCE_INTERVAL,
28135 + .gpio = WRT160NL_GPIO_BTN_RESET,
28136 + .active_low = 1,
28137 + }, {
28138 + .desc = "wps",
28139 + .type = EV_KEY,
28140 + .code = KEY_WPS_BUTTON,
28141 + .debounce_interval = WRT160NL_KEYS_DEBOUNCE_INTERVAL,
28142 + .gpio = WRT160NL_GPIO_BTN_WPS,
28143 + .active_low = 1,
28147 +static void __init wrt160nl_setup(void)
28149 + const char *nvram = (char *) KSEG1ADDR(WRT160NL_NVRAM_ADDR);
28150 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
28151 + u8 mac[6];
28153 + if (ath79_nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
28154 + "lan_hwaddr=", mac) == 0) {
28155 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
28156 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
28159 + ath79_register_mdio(0, 0x0);
28161 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
28162 + ath79_eth0_data.phy_mask = 0x01;
28164 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
28165 + ath79_eth1_data.phy_mask = 0x10;
28167 + ath79_register_eth(0);
28168 + ath79_register_eth(1);
28170 + ath79_register_m25p80(&wrt160nl_flash_data);
28172 + ath79_register_usb();
28174 + if (ath79_nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
28175 + "wl0_hwaddr=", mac) == 0)
28176 + ath79_register_wmac(eeprom, mac);
28177 + else
28178 + ath79_register_wmac(eeprom, NULL);
28180 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wrt160nl_leds_gpio),
28181 + wrt160nl_leds_gpio);
28183 + ath79_register_gpio_keys_polled(-1, WRT160NL_KEYS_POLL_INTERVAL,
28184 + ARRAY_SIZE(wrt160nl_gpio_keys),
28185 + wrt160nl_gpio_keys);
28188 +MIPS_MACHINE(ATH79_MACH_WRT160NL, "WRT160NL", "Linksys WRT160NL",
28189 + wrt160nl_setup);
28190 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wrt400n.c linux-4.1.43/arch/mips/ath79/mach-wrt400n.c
28191 --- linux-4.1.43.orig/arch/mips/ath79/mach-wrt400n.c 1970-01-01 01:00:00.000000000 +0100
28192 +++ linux-4.1.43/arch/mips/ath79/mach-wrt400n.c 2017-08-06 20:02:15.000000000 +0200
28193 @@ -0,0 +1,161 @@
28195 + * Linksys WRT400N board support
28197 + * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
28198 + * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
28200 + * This program is free software; you can redistribute it and/or modify it
28201 + * under the terms of the GNU General Public License version 2 as published
28202 + * by the Free Software Foundation.
28203 + */
28205 +#include <linux/mtd/mtd.h>
28206 +#include <linux/mtd/partitions.h>
28208 +#include <asm/mach-ath79/ath79.h>
28210 +#include "dev-ap9x-pci.h"
28211 +#include "dev-eth.h"
28212 +#include "dev-gpio-buttons.h"
28213 +#include "dev-leds-gpio.h"
28214 +#include "dev-m25p80.h"
28215 +#include "machtypes.h"
28217 +#define WRT400N_GPIO_LED_POWER 1
28218 +#define WRT400N_GPIO_LED_WPS_BLUE 4
28219 +#define WRT400N_GPIO_LED_WPS_AMBER 5
28220 +#define WRT400N_GPIO_LED_WLAN 6
28222 +#define WRT400N_GPIO_BTN_RESET 8
28223 +#define WRT400N_GPIO_BTN_WLSEC 3
28225 +#define WRT400N_KEYS_POLL_INTERVAL 20 /* msecs */
28226 +#define WRT400N_KEYS_DEBOUNE_INTERVAL (3 * WRT400N_KEYS_POLL_INTERVAL)
28228 +#define WRT400N_MAC_ADDR_OFFSET 0x120c
28229 +#define WRT400N_CALDATA0_OFFSET 0x1000
28230 +#define WRT400N_CALDATA1_OFFSET 0x5000
28232 +static struct mtd_partition wrt400n_partitions[] = {
28234 + .name = "uboot",
28235 + .offset = 0,
28236 + .size = 0x030000,
28237 + .mask_flags = MTD_WRITEABLE,
28238 + }, {
28239 + .name = "env",
28240 + .offset = 0x030000,
28241 + .size = 0x010000,
28242 + .mask_flags = MTD_WRITEABLE,
28243 + }, {
28244 + .name = "linux",
28245 + .offset = 0x040000,
28246 + .size = 0x140000,
28247 + }, {
28248 + .name = "rootfs",
28249 + .offset = 0x180000,
28250 + .size = 0x630000,
28251 + }, {
28252 + .name = "nvram",
28253 + .offset = 0x7b0000,
28254 + .size = 0x010000,
28255 + .mask_flags = MTD_WRITEABLE,
28256 + }, {
28257 + .name = "factory",
28258 + .offset = 0x7c0000,
28259 + .size = 0x010000,
28260 + .mask_flags = MTD_WRITEABLE,
28261 + }, {
28262 + .name = "language",
28263 + .offset = 0x7d0000,
28264 + .size = 0x020000,
28265 + .mask_flags = MTD_WRITEABLE,
28266 + }, {
28267 + .name = "caldata",
28268 + .offset = 0x7f0000,
28269 + .size = 0x010000,
28270 + .mask_flags = MTD_WRITEABLE,
28271 + }, {
28272 + .name = "firmware",
28273 + .offset = 0x040000,
28274 + .size = 0x770000,
28278 +static struct flash_platform_data wrt400n_flash_data = {
28279 + .parts = wrt400n_partitions,
28280 + .nr_parts = ARRAY_SIZE(wrt400n_partitions),
28283 +static struct gpio_led wrt400n_leds_gpio[] __initdata = {
28285 + .name = "wrt400n:blue:wps",
28286 + .gpio = WRT400N_GPIO_LED_WPS_BLUE,
28287 + .active_low = 1,
28288 + }, {
28289 + .name = "wrt400n:amber:wps",
28290 + .gpio = WRT400N_GPIO_LED_WPS_AMBER,
28291 + .active_low = 1,
28292 + }, {
28293 + .name = "wrt400n:blue:wlan",
28294 + .gpio = WRT400N_GPIO_LED_WLAN,
28295 + .active_low = 1,
28296 + }, {
28297 + .name = "wrt400n:blue:power",
28298 + .gpio = WRT400N_GPIO_LED_POWER,
28299 + .active_low = 0,
28300 + .default_trigger = "default-on",
28304 +static struct gpio_keys_button wrt400n_gpio_keys[] __initdata = {
28306 + .desc = "reset",
28307 + .type = EV_KEY,
28308 + .code = KEY_RESTART,
28309 + .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
28310 + .gpio = WRT400N_GPIO_BTN_RESET,
28311 + .active_low = 1,
28312 + }, {
28313 + .desc = "wlsec",
28314 + .type = EV_KEY,
28315 + .code = KEY_WPS_BUTTON,
28316 + .debounce_interval = WRT400N_KEYS_DEBOUNE_INTERVAL,
28317 + .gpio = WRT400N_GPIO_BTN_WLSEC,
28318 + .active_low = 1,
28322 +static void __init wrt400n_setup(void)
28324 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
28325 + u8 *mac = art + WRT400N_MAC_ADDR_OFFSET;
28327 + ath79_register_mdio(0, 0x0);
28329 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
28330 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
28331 + ath79_eth0_data.speed = SPEED_100;
28332 + ath79_eth0_data.duplex = DUPLEX_FULL;
28334 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 2);
28335 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
28336 + ath79_eth1_data.phy_mask = 0x10;
28338 + ath79_register_eth(0);
28339 + ath79_register_eth(1);
28341 + ath79_register_m25p80(&wrt400n_flash_data);
28343 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wrt400n_leds_gpio),
28344 + wrt400n_leds_gpio);
28346 + ath79_register_gpio_keys_polled(-1, WRT400N_KEYS_POLL_INTERVAL,
28347 + ARRAY_SIZE(wrt400n_gpio_keys),
28348 + wrt400n_gpio_keys);
28350 + ap94_pci_init(art + WRT400N_CALDATA0_OFFSET, NULL,
28351 + art + WRT400N_CALDATA1_OFFSET, NULL);
28354 +MIPS_MACHINE(ATH79_MACH_WRT400N, "WRT400N", "Linksys WRT400N", wrt400n_setup);
28355 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wzr-450hp2.c linux-4.1.43/arch/mips/ath79/mach-wzr-450hp2.c
28356 --- linux-4.1.43.orig/arch/mips/ath79/mach-wzr-450hp2.c 1970-01-01 01:00:00.000000000 +0100
28357 +++ linux-4.1.43/arch/mips/ath79/mach-wzr-450hp2.c 2017-08-06 20:02:15.000000000 +0200
28358 @@ -0,0 +1,221 @@
28360 + * Buffalo WZR-450HP2 board support
28362 + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
28364 + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
28365 + * Copyright (c) 2012 Qualcomm Atheros
28367 + * Permission to use, copy, modify, and/or distribute this software for any
28368 + * purpose with or without fee is hereby granted, provided that the above
28369 + * copyright notice and this permission notice appear in all copies.
28371 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
28372 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
28373 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
28374 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
28375 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28376 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
28377 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28379 + */
28381 +#include <linux/phy.h>
28382 +#include <linux/gpio.h>
28383 +#include <linux/mtd/mtd.h>
28384 +#include <linux/mtd/partitions.h>
28385 +#include <linux/platform_device.h>
28386 +#include <linux/ar8216_platform.h>
28388 +#include <asm/mach-ath79/ar71xx_regs.h>
28390 +#include "common.h"
28391 +#include "dev-eth.h"
28392 +#include "dev-gpio-buttons.h"
28393 +#include "dev-leds-gpio.h"
28394 +#include "dev-m25p80.h"
28395 +#include "dev-spi.h"
28396 +#include "dev-usb.h"
28397 +#include "dev-wmac.h"
28398 +#include "machtypes.h"
28400 +#define WZR_450HP2_KEYS_POLL_INTERVAL 20 /* msecs */
28401 +#define WZR_450HP2_KEYS_DEBOUNCE_INTERVAL (3 * WZR_450HP2_KEYS_POLL_INTERVAL)
28403 +#define WZR_450HP2_WMAC_CALDATA_OFFSET 0x1000
28405 +static struct mtd_partition wzrhpg450h_partitions[] = {
28407 + .name = "u-boot",
28408 + .offset = 0,
28409 + .size = 0x0040000,
28410 + .mask_flags = MTD_WRITEABLE,
28411 + }, {
28412 + .name = "u-boot-env",
28413 + .offset = 0x0040000,
28414 + .size = 0x0010000,
28415 + }, {
28416 + .name = "ART",
28417 + .offset = 0x0ff0000,
28418 + .size = 0x0010000,
28419 + .mask_flags = MTD_WRITEABLE,
28420 + }, {
28421 + .name = "firmware",
28422 + .offset = 0x0050000,
28423 + .size = 0x0f90000,
28424 + }, {
28425 + .name = "user_property",
28426 + .offset = 0x0fe0000,
28427 + .size = 0x0010000,
28431 +static struct flash_platform_data wzr_450hp2_flash_data = {
28432 + .parts = wzrhpg450h_partitions,
28433 + .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
28436 +static struct gpio_led wzr_450hp2_leds_gpio[] __initdata = {
28438 + .name = "buffalo:green:wps",
28439 + .gpio = 3,
28440 + .active_low = 1,
28441 + },
28443 + .name = "buffalo:green:system",
28444 + .gpio = 20,
28445 + .active_low = 1,
28446 + },
28448 + .name = "buffalo:green:wlan",
28449 + .gpio = 18,
28450 + .active_low = 1,
28451 + },
28454 +static struct gpio_keys_button wzr_450hp2_gpio_keys[] __initdata = {
28456 + .desc = "Reset button",
28457 + .type = EV_KEY,
28458 + .code = KEY_RESTART,
28459 + .debounce_interval = WZR_450HP2_KEYS_DEBOUNCE_INTERVAL,
28460 + .gpio = 17,
28461 + .active_low = 1,
28462 + },
28464 + .desc = "RFKILL button",
28465 + .type = EV_KEY,
28466 + .code = KEY_RFKILL,
28467 + .debounce_interval = WZR_450HP2_KEYS_DEBOUNCE_INTERVAL,
28468 + .gpio = 21,
28469 + .active_low = 1,
28470 + },
28473 +static const struct ar8327_led_info wzr_450hp2_leds_ar8327[] = {
28474 + AR8327_LED_INFO(PHY0_0, HW, "buffalo:green:lan1"),
28475 + AR8327_LED_INFO(PHY1_0, HW, "buffalo:green:lan2"),
28476 + AR8327_LED_INFO(PHY2_0, HW, "buffalo:green:lan3"),
28477 + AR8327_LED_INFO(PHY3_0, HW, "buffalo:green:lan4"),
28478 + AR8327_LED_INFO(PHY4_0, HW, "buffalo:green:wan"),
28481 +/* GMAC0 of the AR8327 switch is connected to the QCA9558 SoC via SGMII */
28482 +static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad0_cfg = {
28483 + .mode = AR8327_PAD_MAC_SGMII,
28484 + .sgmii_delay_en = true,
28487 +/* GMAC6 of the AR8327 switch is connected to the QCA9558 SoC via RGMII */
28488 +static struct ar8327_pad_cfg wzr_450hp2_ar8327_pad6_cfg = {
28489 + .mode = AR8327_PAD_MAC_RGMII,
28490 + .txclk_delay_en = true,
28491 + .rxclk_delay_en = true,
28492 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
28493 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
28496 +static struct ar8327_led_cfg wzr_450hp2_ar8327_led_cfg = {
28497 + .led_ctrl0 = 0xcc35cc35,
28498 + .led_ctrl1 = 0xca35ca35,
28499 + .led_ctrl2 = 0xc935c935,
28500 + .led_ctrl3 = 0x03ffff00,
28501 + .open_drain = true,
28504 +static struct ar8327_platform_data wzr_450hp2_ar8327_data = {
28505 + .pad0_cfg = &wzr_450hp2_ar8327_pad0_cfg,
28506 + .pad6_cfg = &wzr_450hp2_ar8327_pad6_cfg,
28507 + .port0_cfg = {
28508 + .force_link = 1,
28509 + .speed = AR8327_PORT_SPEED_1000,
28510 + .duplex = 1,
28511 + .txpause = 1,
28512 + .rxpause = 1,
28513 + },
28514 + .port6_cfg = {
28515 + .force_link = 1,
28516 + .speed = AR8327_PORT_SPEED_1000,
28517 + .duplex = 1,
28518 + .txpause = 1,
28519 + .rxpause = 1,
28520 + },
28521 + .led_cfg = &wzr_450hp2_ar8327_led_cfg,
28522 + .num_leds = ARRAY_SIZE(wzr_450hp2_leds_ar8327),
28523 + .leds = wzr_450hp2_leds_ar8327,
28526 +static struct mdio_board_info wzr_450hp2_mdio0_info[] = {
28528 + .bus_id = "ag71xx-mdio.0",
28529 + .phy_addr = 0,
28530 + .platform_data = &wzr_450hp2_ar8327_data,
28531 + },
28534 +static void __init wzr_450hp2_setup(void)
28536 + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
28537 + u8 *mac_wan = art;
28538 + u8 *mac_lan = mac_wan + ETH_ALEN;
28540 + ath79_register_m25p80(&wzr_450hp2_flash_data);
28542 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzr_450hp2_leds_gpio),
28543 + wzr_450hp2_leds_gpio);
28544 + ath79_register_gpio_keys_polled(-1, WZR_450HP2_KEYS_POLL_INTERVAL,
28545 + ARRAY_SIZE(wzr_450hp2_gpio_keys),
28546 + wzr_450hp2_gpio_keys);
28548 + ath79_register_wmac(art + WZR_450HP2_WMAC_CALDATA_OFFSET, mac_lan);
28550 + mdiobus_register_board_info(wzr_450hp2_mdio0_info,
28551 + ARRAY_SIZE(wzr_450hp2_mdio0_info));
28552 + ath79_register_mdio(0, 0x0);
28554 + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
28556 + /* GMAC0 is connected to the RMGII interface */
28557 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
28558 + ath79_eth0_data.phy_mask = BIT(0);
28559 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
28560 + ath79_eth0_pll_data.pll_1000 = 0x56000000;
28562 + ath79_init_mac(ath79_eth0_data.mac_addr, mac_wan, 0);
28563 + ath79_register_eth(0);
28565 + /* GMAC1 is connected to the SGMII interface */
28566 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
28567 + ath79_eth1_data.speed = SPEED_1000;
28568 + ath79_eth1_data.duplex = DUPLEX_FULL;
28569 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
28571 + ath79_init_mac(ath79_eth1_data.mac_addr, mac_lan, 0);
28572 + ath79_register_eth(1);
28574 + ath79_register_usb();
28577 +MIPS_MACHINE(ATH79_MACH_WZR_450HP2, "WZR-450HP2",
28578 + "Buffalo WZR-450HP2", wzr_450hp2_setup);
28580 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-ag300h.c linux-4.1.43/arch/mips/ath79/mach-wzr-hp-ag300h.c
28581 --- linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-ag300h.c 1970-01-01 01:00:00.000000000 +0100
28582 +++ linux-4.1.43/arch/mips/ath79/mach-wzr-hp-ag300h.c 2017-08-06 20:02:15.000000000 +0200
28583 @@ -0,0 +1,205 @@
28585 + * Buffalo WZR-HP-AG300H board support
28587 + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
28589 + * This program is free software; you can redistribute it and/or modify it
28590 + * under the terms of the GNU General Public License version 2 as published
28591 + * by the Free Software Foundation.
28592 + */
28594 +#include <linux/gpio.h>
28595 +#include <linux/mtd/mtd.h>
28596 +#include <linux/mtd/partitions.h>
28598 +#include <asm/mach-ath79/ath79.h>
28600 +#include "dev-eth.h"
28601 +#include "dev-ap9x-pci.h"
28602 +#include "dev-gpio-buttons.h"
28603 +#include "dev-leds-gpio.h"
28604 +#include "dev-m25p80.h"
28605 +#include "dev-usb.h"
28606 +#include "machtypes.h"
28608 +#define WZRHPAG300H_MAC_OFFSET 0x20c
28609 +#define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */
28610 +#define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL)
28612 +static struct mtd_partition wzrhpag300h_flash_partitions[] = {
28614 + .name = "u-boot",
28615 + .offset = 0,
28616 + .size = 0x0040000,
28617 + .mask_flags = MTD_WRITEABLE,
28618 + }, {
28619 + .name = "u-boot-env",
28620 + .offset = 0x0040000,
28621 + .size = 0x0010000,
28622 + .mask_flags = MTD_WRITEABLE,
28623 + }, {
28624 + .name = "art",
28625 + .offset = 0x0050000,
28626 + .size = 0x0010000,
28627 + .mask_flags = MTD_WRITEABLE,
28628 + }, {
28629 + .name = "firmware",
28630 + .offset = 0x0060000,
28631 + .size = 0x1f90000,
28632 + }, {
28633 + .name = "user_property",
28634 + .offset = 0x1ff0000,
28635 + .size = 0x0010000,
28636 + .mask_flags = MTD_WRITEABLE,
28640 +static struct flash_platform_data wzrhpag300h_flash_data = {
28641 + .parts = wzrhpag300h_flash_partitions,
28642 + .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions),
28645 +static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
28647 + .name = "buffalo:red:diag",
28648 + .gpio = 1,
28649 + .active_low = 1,
28650 + },
28653 +static struct gpio_led wzrhpag300h_wmac0_leds_gpio[] = {
28655 + .name = "buffalo:amber:band2g",
28656 + .gpio = 1,
28657 + .active_low = 1,
28658 + },
28660 + .name = "buffalo:green:usb",
28661 + .gpio = 3,
28662 + .active_low = 1,
28663 + },
28665 + .name = "buffalo:green:band2g",
28666 + .gpio = 5,
28667 + .active_low = 1,
28668 + },
28671 +static struct gpio_led wzrhpag300h_wmac1_leds_gpio[] = {
28673 + .name = "buffalo:green:band5g",
28674 + .gpio = 1,
28675 + .active_low = 1,
28676 + },
28678 + .name = "buffalo:green:router",
28679 + .gpio = 3,
28680 + .active_low = 1,
28681 + },
28683 + .name = "buffalo:blue:movie_engine",
28684 + .gpio = 4,
28685 + .active_low = 1,
28686 + },
28688 + .name = "buffalo:amber:band5g",
28689 + .gpio = 5,
28690 + .active_low = 1,
28691 + },
28694 +static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = {
28696 + .desc = "reset",
28697 + .type = EV_KEY,
28698 + .code = KEY_RESTART,
28699 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28700 + .gpio = 11,
28701 + .active_low = 1,
28702 + }, {
28703 + .desc = "usb",
28704 + .type = EV_KEY,
28705 + .code = BTN_2,
28706 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28707 + .gpio = 3,
28708 + .active_low = 1,
28709 + }, {
28710 + .desc = "aoss",
28711 + .type = EV_KEY,
28712 + .code = KEY_WPS_BUTTON,
28713 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28714 + .gpio = 5,
28715 + .active_low = 1,
28716 + }, {
28717 + .desc = "router_auto",
28718 + .type = EV_SW,
28719 + .code = BTN_6,
28720 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28721 + .gpio = 6,
28722 + .active_low = 1,
28723 + }, {
28724 + .desc = "router_off",
28725 + .type = EV_SW,
28726 + .code = BTN_5,
28727 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28728 + .gpio = 7,
28729 + .active_low = 1,
28730 + }, {
28731 + .desc = "movie_engine",
28732 + .type = EV_SW,
28733 + .code = BTN_7,
28734 + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
28735 + .gpio = 8,
28736 + .active_low = 1,
28740 +static void __init wzrhpag300h_setup(void)
28742 + u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000);
28743 + u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000);
28744 + u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET;
28745 + u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET;
28747 + ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
28748 + ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1);
28750 + ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
28752 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
28753 + ath79_eth0_data.speed = SPEED_1000;
28754 + ath79_eth0_data.duplex = DUPLEX_FULL;
28755 + ath79_eth0_data.phy_mask = BIT(0);
28757 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
28758 + ath79_eth1_data.phy_mask = BIT(4);
28760 + ath79_register_eth(0);
28761 + ath79_register_eth(1);
28763 + gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
28764 + "USB power");
28765 + ath79_register_usb();
28767 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
28768 + wzrhpag300h_leds_gpio);
28770 + ath79_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL,
28771 + ARRAY_SIZE(wzrhpag300h_gpio_keys),
28772 + wzrhpag300h_gpio_keys);
28774 + ath79_register_m25p80_multi(&wzrhpag300h_flash_data);
28776 + ap94_pci_init(eeprom1, mac1, eeprom2, mac2);
28778 + ap9x_pci_setup_wmac_led_pin(0, 1);
28779 + ap9x_pci_setup_wmac_led_pin(1, 5);
28781 + ap9x_pci_setup_wmac_leds(0, wzrhpag300h_wmac0_leds_gpio,
28782 + ARRAY_SIZE(wzrhpag300h_wmac0_leds_gpio));
28783 + ap9x_pci_setup_wmac_leds(1, wzrhpag300h_wmac1_leds_gpio,
28784 + ARRAY_SIZE(wzrhpag300h_wmac1_leds_gpio));
28787 +MIPS_MACHINE(ATH79_MACH_WZR_HP_AG300H, "WZR-HP-AG300H",
28788 + "Buffalo WZR-HP-AG300H/WZR-600DHP", wzrhpag300h_setup);
28789 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g300nh.c linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g300nh.c
28790 --- linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g300nh.c 1970-01-01 01:00:00.000000000 +0100
28791 +++ linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g300nh.c 2017-08-06 20:02:15.000000000 +0200
28792 @@ -0,0 +1,279 @@
28794 + * Buffalo WZR-HP-G300NH board support
28796 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
28798 + * This program is free software; you can redistribute it and/or modify it
28799 + * under the terms of the GNU General Public License version 2 as published
28800 + * by the Free Software Foundation.
28801 + */
28803 +#include <linux/platform_device.h>
28804 +#include <linux/mtd/mtd.h>
28805 +#include <linux/mtd/partitions.h>
28806 +#include <linux/mtd/physmap.h>
28807 +#include <linux/nxp_74hc153.h>
28808 +#include <linux/rtl8366.h>
28810 +#include <asm/mach-ath79/ath79.h>
28812 +#include "dev-eth.h"
28813 +#include "dev-gpio-buttons.h"
28814 +#include "dev-leds-gpio.h"
28815 +#include "dev-usb.h"
28816 +#include "dev-wmac.h"
28817 +#include "machtypes.h"
28819 +#define WZRHPG300NH_GPIO_LED_USB 0
28820 +#define WZRHPG300NH_GPIO_LED_DIAG 1
28821 +#define WZRHPG300NH_GPIO_LED_WIRELESS 6
28822 +#define WZRHPG300NH_GPIO_LED_SECURITY 17
28823 +#define WZRHPG300NH_GPIO_LED_ROUTER 18
28825 +#define WZRHPG300NH_GPIO_RTL8366_SDA 19
28826 +#define WZRHPG300NH_GPIO_RTL8366_SCK 20
28828 +#define WZRHPG300NH_GPIO_74HC153_S0 9
28829 +#define WZRHPG300NH_GPIO_74HC153_S1 11
28830 +#define WZRHPG300NH_GPIO_74HC153_1Y 12
28831 +#define WZRHPG300NH_GPIO_74HC153_2Y 14
28833 +#define WZRHPG300NH_GPIO_EXP_BASE 32
28834 +#define WZRHPG300NH_GPIO_BTN_AOSS (WZRHPG300NH_GPIO_EXP_BASE + 0)
28835 +#define WZRHPG300NH_GPIO_BTN_RESET (WZRHPG300NH_GPIO_EXP_BASE + 1)
28836 +#define WZRHPG300NH_GPIO_BTN_ROUTER_ON (WZRHPG300NH_GPIO_EXP_BASE + 2)
28837 +#define WZRHPG300NH_GPIO_BTN_QOS_ON (WZRHPG300NH_GPIO_EXP_BASE + 3)
28838 +#define WZRHPG300NH_GPIO_BTN_USB (WZRHPG300NH_GPIO_EXP_BASE + 5)
28839 +#define WZRHPG300NH_GPIO_BTN_ROUTER_AUTO (WZRHPG300NH_GPIO_EXP_BASE + 6)
28840 +#define WZRHPG300NH_GPIO_BTN_QOS_OFF (WZRHPG300NH_GPIO_EXP_BASE + 7)
28842 +#define WZRHPG300NH_KEYS_POLL_INTERVAL 20 /* msecs */
28843 +#define WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH_KEYS_POLL_INTERVAL)
28845 +#define WZRHPG300NH_MAC_OFFSET 0x20c
28847 +static struct mtd_partition wzrhpg300nh_flash_partitions[] = {
28849 + .name = "u-boot",
28850 + .offset = 0,
28851 + .size = 0x0040000,
28852 + .mask_flags = MTD_WRITEABLE,
28853 + }, {
28854 + .name = "u-boot-env",
28855 + .offset = 0x0040000,
28856 + .size = 0x0020000,
28857 + .mask_flags = MTD_WRITEABLE,
28858 + }, {
28859 + .name = "firmware",
28860 + .offset = 0x0060000,
28861 + .size = 0x1f60000,
28862 + }, {
28863 + .name = "user_property",
28864 + .offset = 0x1fc0000,
28865 + .size = 0x0020000,
28866 + .mask_flags = MTD_WRITEABLE,
28867 + }, {
28868 + .name = "art",
28869 + .offset = 0x1fe0000,
28870 + .size = 0x0020000,
28871 + .mask_flags = MTD_WRITEABLE,
28875 +static struct physmap_flash_data wzrhpg300nh_flash_data = {
28876 + .width = 2,
28877 + .parts = wzrhpg300nh_flash_partitions,
28878 + .nr_parts = ARRAY_SIZE(wzrhpg300nh_flash_partitions),
28881 +#define WZRHPG300NH_FLASH_BASE 0x1e000000
28882 +#define WZRHPG300NH_FLASH_SIZE (32 * 1024 * 1024)
28884 +static struct resource wzrhpg300nh_flash_resources[] = {
28885 + [0] = {
28886 + .start = WZRHPG300NH_FLASH_BASE,
28887 + .end = WZRHPG300NH_FLASH_BASE + WZRHPG300NH_FLASH_SIZE - 1,
28888 + .flags = IORESOURCE_MEM,
28889 + },
28892 +static struct platform_device wzrhpg300nh_flash_device = {
28893 + .name = "physmap-flash",
28894 + .id = -1,
28895 + .resource = wzrhpg300nh_flash_resources,
28896 + .num_resources = ARRAY_SIZE(wzrhpg300nh_flash_resources),
28897 + .dev = {
28898 + .platform_data = &wzrhpg300nh_flash_data,
28902 +static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = {
28904 + .name = "buffalo:orange:security",
28905 + .gpio = WZRHPG300NH_GPIO_LED_SECURITY,
28906 + .active_low = 1,
28907 + }, {
28908 + .name = "buffalo:green:wireless",
28909 + .gpio = WZRHPG300NH_GPIO_LED_WIRELESS,
28910 + .active_low = 1,
28911 + }, {
28912 + .name = "buffalo:green:router",
28913 + .gpio = WZRHPG300NH_GPIO_LED_ROUTER,
28914 + .active_low = 1,
28915 + }, {
28916 + .name = "buffalo:red:diag",
28917 + .gpio = WZRHPG300NH_GPIO_LED_DIAG,
28918 + .active_low = 1,
28919 + }, {
28920 + .name = "buffalo:blue:usb",
28921 + .gpio = WZRHPG300NH_GPIO_LED_USB,
28922 + .active_low = 1,
28926 +static struct gpio_keys_button wzrhpg300nh_gpio_keys[] __initdata = {
28928 + .desc = "reset",
28929 + .type = EV_KEY,
28930 + .code = KEY_RESTART,
28931 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28932 + .gpio = WZRHPG300NH_GPIO_BTN_RESET,
28933 + .active_low = 1,
28934 + }, {
28935 + .desc = "aoss",
28936 + .type = EV_KEY,
28937 + .code = KEY_WPS_BUTTON,
28938 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28939 + .gpio = WZRHPG300NH_GPIO_BTN_AOSS,
28940 + .active_low = 1,
28941 + }, {
28942 + .desc = "usb",
28943 + .type = EV_KEY,
28944 + .code = BTN_2,
28945 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28946 + .gpio = WZRHPG300NH_GPIO_BTN_USB,
28947 + .active_low = 1,
28948 + }, {
28949 + .desc = "qos_on",
28950 + .type = EV_KEY,
28951 + .code = BTN_3,
28952 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28953 + .gpio = WZRHPG300NH_GPIO_BTN_QOS_ON,
28954 + .active_low = 0,
28955 + }, {
28956 + .desc = "qos_off",
28957 + .type = EV_KEY,
28958 + .code = BTN_4,
28959 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28960 + .gpio = WZRHPG300NH_GPIO_BTN_QOS_OFF,
28961 + .active_low = 0,
28962 + }, {
28963 + .desc = "router_on",
28964 + .type = EV_KEY,
28965 + .code = BTN_5,
28966 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28967 + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_ON,
28968 + .active_low = 0,
28969 + }, {
28970 + .desc = "router_auto",
28971 + .type = EV_KEY,
28972 + .code = BTN_6,
28973 + .debounce_interval = WZRHPG300NH_KEYS_DEBOUNCE_INTERVAL,
28974 + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_AUTO,
28975 + .active_low = 0,
28979 +static struct nxp_74hc153_platform_data wzrhpg300nh_74hc153_data = {
28980 + .gpio_base = WZRHPG300NH_GPIO_EXP_BASE,
28981 + .gpio_pin_s0 = WZRHPG300NH_GPIO_74HC153_S0,
28982 + .gpio_pin_s1 = WZRHPG300NH_GPIO_74HC153_S1,
28983 + .gpio_pin_1y = WZRHPG300NH_GPIO_74HC153_1Y,
28984 + .gpio_pin_2y = WZRHPG300NH_GPIO_74HC153_2Y,
28987 +static struct platform_device wzrhpg300nh_74hc153_device = {
28988 + .name = NXP_74HC153_DRIVER_NAME,
28989 + .id = -1,
28990 + .dev = {
28991 + .platform_data = &wzrhpg300nh_74hc153_data,
28995 +static struct rtl8366_platform_data wzrhpg300nh_rtl8366_data = {
28996 + .gpio_sda = WZRHPG300NH_GPIO_RTL8366_SDA,
28997 + .gpio_sck = WZRHPG300NH_GPIO_RTL8366_SCK,
29000 +static struct platform_device wzrhpg300nh_rtl8366s_device = {
29001 + .name = RTL8366S_DRIVER_NAME,
29002 + .id = -1,
29003 + .dev = {
29004 + .platform_data = &wzrhpg300nh_rtl8366_data,
29008 +static struct platform_device wzrhpg300nh_rtl8366rb_device = {
29009 + .name = RTL8366RB_DRIVER_NAME,
29010 + .id = -1,
29011 + .dev = {
29012 + .platform_data = &wzrhpg300nh_rtl8366_data,
29016 +static void __init wzrhpg300nh_setup(void)
29018 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
29019 + u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET;
29020 + bool hasrtl8366rb = false;
29022 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
29023 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
29025 + if (rtl8366_smi_detect(&wzrhpg300nh_rtl8366_data) == RTL8366_TYPE_RB)
29026 + hasrtl8366rb = true;
29028 + if (hasrtl8366rb) {
29029 + ath79_eth0_pll_data.pll_1000 = 0x1f000000;
29030 + ath79_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
29031 + ath79_eth1_pll_data.pll_1000 = 0x100;
29032 + ath79_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
29033 + } else {
29034 + ath79_eth0_pll_data.pll_1000 = 0x1e000100;
29035 + ath79_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
29036 + ath79_eth1_pll_data.pll_1000 = 0x1e000100;
29037 + ath79_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
29040 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
29041 + ath79_eth0_data.speed = SPEED_1000;
29042 + ath79_eth0_data.duplex = DUPLEX_FULL;
29044 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
29045 + ath79_eth1_data.phy_mask = 0x10;
29047 + ath79_register_eth(0);
29048 + ath79_register_eth(1);
29050 + ath79_register_usb();
29051 + ath79_register_wmac(eeprom, NULL);
29053 + platform_device_register(&wzrhpg300nh_74hc153_device);
29054 + platform_device_register(&wzrhpg300nh_flash_device);
29056 + if (hasrtl8366rb)
29057 + platform_device_register(&wzrhpg300nh_rtl8366rb_device);
29058 + else
29059 + platform_device_register(&wzrhpg300nh_rtl8366s_device);
29061 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh_leds_gpio),
29062 + wzrhpg300nh_leds_gpio);
29064 + ath79_register_gpio_keys_polled(-1, WZRHPG300NH_KEYS_POLL_INTERVAL,
29065 + ARRAY_SIZE(wzrhpg300nh_gpio_keys),
29066 + wzrhpg300nh_gpio_keys);
29070 +MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH, "WZR-HP-G300NH",
29071 + "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup);
29072 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g300nh2.c linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g300nh2.c
29073 --- linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g300nh2.c 1970-01-01 01:00:00.000000000 +0100
29074 +++ linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g300nh2.c 2017-08-06 20:02:15.000000000 +0200
29075 @@ -0,0 +1,170 @@
29077 + * Buffalo WZR-HP-G300NH2 board support
29079 + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
29080 + * Copyright (C) 2011 Mark Deneen <mdeneen@gmail.com>
29082 + * This program is free software; you can redistribute it and/or modify it
29083 + * under the terms of the GNU General Public License version 2 as published
29084 + * by the Free Software Foundation.
29085 + */
29087 +#include <linux/gpio.h>
29088 +#include <linux/mtd/mtd.h>
29089 +#include <linux/mtd/partitions.h>
29091 +#include <asm/mach-ath79/ath79.h>
29093 +#include "dev-ap9x-pci.h"
29094 +#include "dev-eth.h"
29095 +#include "dev-gpio-buttons.h"
29096 +#include "dev-leds-gpio.h"
29097 +#include "dev-m25p80.h"
29098 +#include "dev-usb.h"
29099 +#include "machtypes.h"
29101 +#define WZRHPG300NH2_MAC_OFFSET 0x20c
29102 +#define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
29103 +#define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
29105 +static struct mtd_partition wzrhpg300nh2_flash_partitions[] = {
29107 + .name = "u-boot",
29108 + .offset = 0,
29109 + .size = 0x0040000,
29110 + .mask_flags = MTD_WRITEABLE,
29111 + }, {
29112 + .name = "u-boot-env",
29113 + .offset = 0x0040000,
29114 + .size = 0x0010000,
29115 + .mask_flags = MTD_WRITEABLE,
29116 + }, {
29117 + .name = "art",
29118 + .offset = 0x0050000,
29119 + .size = 0x0010000,
29120 + .mask_flags = MTD_WRITEABLE,
29121 + }, {
29122 + .name = "firmware",
29123 + .offset = 0x0060000,
29124 + .size = 0x1f90000,
29125 + }, {
29126 + .name = "user_property",
29127 + .offset = 0x1ff0000,
29128 + .size = 0x0010000,
29129 + .mask_flags = MTD_WRITEABLE,
29133 +static struct flash_platform_data wzrhpg300nh2_flash_data = {
29134 + .parts = wzrhpg300nh2_flash_partitions,
29135 + .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions),
29138 +static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = {
29140 + .name = "buffalo:red:diag",
29141 + .gpio = 16,
29142 + .active_low = 1,
29143 + },
29146 +static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = {
29148 + .name = "buffalo:blue:usb",
29149 + .gpio = 4,
29150 + .active_low = 1,
29151 + },
29153 + .name = "buffalo:orange:security",
29154 + .gpio = 6,
29155 + .active_low = 1,
29156 + },
29158 + .name = "buffalo:green:router",
29159 + .gpio = 7,
29160 + .active_low = 1,
29161 + },
29163 + .name = "buffalo:blue:movie_engine_on",
29164 + .gpio = 8,
29165 + .active_low = 1,
29166 + },
29168 + .name = "buffalo:blue:movie_engine_off",
29169 + .gpio = 9,
29170 + .active_low = 1,
29171 + },
29174 +/* The AOSS button is wmac gpio 12 */
29175 +static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = {
29177 + .desc = "reset",
29178 + .type = EV_KEY,
29179 + .code = KEY_RESTART,
29180 + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
29181 + .gpio = 1,
29182 + .active_low = 1,
29183 + }, {
29184 + .desc = "usb",
29185 + .type = EV_KEY,
29186 + .code = BTN_2,
29187 + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
29188 + .gpio = 7,
29189 + .active_low = 1,
29190 + }, {
29191 + .desc = "qos",
29192 + .type = EV_KEY,
29193 + .code = BTN_3,
29194 + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
29195 + .gpio = 11,
29196 + .active_low = 0,
29197 + }, {
29198 + .desc = "router_on",
29199 + .type = EV_KEY,
29200 + .code = BTN_5,
29201 + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
29202 + .gpio = 8,
29203 + .active_low = 0,
29204 + },
29207 +static void __init wzrhpg300nh2_setup(void)
29210 + u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000);
29211 + u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET;
29212 + /* There is an eth1 but it is not connected to the switch */
29214 + ath79_register_m25p80_multi(&wzrhpg300nh2_flash_data);
29216 + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
29217 + ath79_register_mdio(0, ~(BIT(0)));
29219 + ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 0);
29220 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
29221 + ath79_eth0_data.speed = SPEED_1000;
29222 + ath79_eth0_data.duplex = DUPLEX_FULL;
29223 + ath79_eth0_data.phy_mask = BIT(0);
29225 + ath79_register_eth(0);
29227 + /* gpio13 is usb power. Turn it on. */
29228 + gpio_request_one(13, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
29229 + "USB power");
29230 + ath79_register_usb();
29232 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
29233 + wzrhpg300nh2_leds_gpio);
29234 + ath79_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL,
29235 + ARRAY_SIZE(wzrhpg300nh2_gpio_keys),
29236 + wzrhpg300nh2_gpio_keys);
29237 + ap9x_pci_setup_wmac_led_pin(0, 5);
29238 + ap9x_pci_setup_wmac_leds(0, wzrhpg300nh2_wmac_leds_gpio,
29239 + ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio));
29241 + ap91_pci_init(eeprom, mac0);
29244 +MIPS_MACHINE(ATH79_MACH_WZR_HP_G300NH2, "WZR-HP-G300NH2",
29245 + "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup);
29246 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g450h.c linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g450h.c
29247 --- linux-4.1.43.orig/arch/mips/ath79/mach-wzr-hp-g450h.c 1970-01-01 01:00:00.000000000 +0100
29248 +++ linux-4.1.43/arch/mips/ath79/mach-wzr-hp-g450h.c 2017-08-06 20:02:15.000000000 +0200
29249 @@ -0,0 +1,165 @@
29251 + * Buffalo WZR-HP-G450G board support
29253 + * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
29254 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
29255 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
29257 + * This program is free software; you can redistribute it and/or modify it
29258 + * under the terms of the GNU General Public License version 2 as published
29259 + * by the Free Software Foundation.
29260 + */
29262 +#include <linux/gpio.h>
29263 +#include <linux/mtd/mtd.h>
29264 +#include <linux/mtd/partitions.h>
29265 +#include <linux/ath9k_platform.h>
29267 +#include <asm/mach-ath79/ath79.h>
29269 +#include "dev-eth.h"
29270 +#include "dev-m25p80.h"
29271 +#include "dev-ap9x-pci.h"
29272 +#include "dev-gpio-buttons.h"
29273 +#include "dev-leds-gpio.h"
29274 +#include "dev-usb.h"
29275 +#include "machtypes.h"
29277 +#define WZRHPG450H_KEYS_POLL_INTERVAL 20 /* msecs */
29278 +#define WZRHPG450H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG450H_KEYS_POLL_INTERVAL)
29280 +static struct mtd_partition wzrhpg450h_partitions[] = {
29282 + .name = "u-boot",
29283 + .offset = 0,
29284 + .size = 0x0040000,
29285 + .mask_flags = MTD_WRITEABLE,
29286 + }, {
29287 + .name = "u-boot-env",
29288 + .offset = 0x0040000,
29289 + .size = 0x0010000,
29290 + }, {
29291 + .name = "ART",
29292 + .offset = 0x0050000,
29293 + .size = 0x0010000,
29294 + .mask_flags = MTD_WRITEABLE,
29295 + }, {
29296 + .name = "firmware",
29297 + .offset = 0x0060000,
29298 + .size = 0x1f80000,
29299 + }, {
29300 + .name = "user_property",
29301 + .offset = 0x1fe0000,
29302 + .size = 0x0020000,
29306 +static struct flash_platform_data wzrhpg450h_flash_data = {
29307 + .parts = wzrhpg450h_partitions,
29308 + .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
29311 +static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
29313 + .name = "buffalo:red:diag",
29314 + .gpio = 14,
29315 + .active_low = 1,
29316 + },
29318 + .name = "buffalo:orange:security",
29319 + .gpio = 13,
29320 + .active_low = 1,
29321 + },
29325 +static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
29327 + .name = "buffalo:blue:movie_engine",
29328 + .gpio = 13,
29329 + .active_low = 1,
29330 + },
29332 + .name = "buffalo:green:router",
29333 + .gpio = 14,
29334 + .active_low = 1,
29335 + },
29338 +static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
29340 + .desc = "reset",
29341 + .type = EV_KEY,
29342 + .code = KEY_RESTART,
29343 + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
29344 + .gpio = 6,
29345 + .active_low = 1,
29346 + }, {
29347 + .desc = "usb",
29348 + .type = EV_KEY,
29349 + .code = BTN_2,
29350 + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
29351 + .gpio = 1,
29352 + .active_low = 1,
29353 + }, {
29354 + .desc = "aoss",
29355 + .type = EV_KEY,
29356 + .code = KEY_WPS_BUTTON,
29357 + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
29358 + .gpio = 8,
29359 + .active_low = 1,
29360 + }, {
29361 + .desc = "movie_engine",
29362 + .type = EV_KEY,
29363 + .code = BTN_6,
29364 + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
29365 + .gpio = 7,
29366 + .active_low = 0,
29367 + }, {
29368 + .desc = "router_off",
29369 + .type = EV_KEY,
29370 + .code = BTN_5,
29371 + .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
29372 + .gpio = 12,
29373 + .active_low = 0,
29378 +static void __init wzrhpg450h_init(void)
29380 + u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
29381 + u8 *mac = (u8 *) ee + 2;
29383 + ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
29385 + ath79_register_mdio(0, ~BIT(0));
29386 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
29387 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
29388 + ath79_eth0_data.speed = SPEED_1000;
29389 + ath79_eth0_data.duplex = DUPLEX_FULL;
29390 + ath79_eth0_data.phy_mask = BIT(0);
29392 + ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
29393 + wzrhpg450h_leds_gpio);
29395 + ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
29396 + ARRAY_SIZE(wzrhpg450h_gpio_keys),
29397 + wzrhpg450h_gpio_keys);
29399 + ath79_register_eth(0);
29401 + gpio_request_one(16, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
29402 + "USB power");
29403 + ath79_register_usb();
29405 + ap91_pci_init(ee, NULL);
29406 + ap9x_pci_get_wmac_data(0)->tx_gain_buffalo = true;
29407 + ap9x_pci_get_wmac_data(1)->tx_gain_buffalo = true;
29408 + ap9x_pci_setup_wmac_led_pin(0, 15);
29409 + ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
29410 + ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
29413 +MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
29414 + wzrhpg450h_init);
29415 diff -Nur linux-4.1.43.orig/arch/mips/ath79/mach-zcn-1523h.c linux-4.1.43/arch/mips/ath79/mach-zcn-1523h.c
29416 --- linux-4.1.43.orig/arch/mips/ath79/mach-zcn-1523h.c 1970-01-01 01:00:00.000000000 +0100
29417 +++ linux-4.1.43/arch/mips/ath79/mach-zcn-1523h.c 2017-08-06 20:02:15.000000000 +0200
29418 @@ -0,0 +1,154 @@
29420 + * Zcomax ZCN-1523H-2-8/5-16 board support
29422 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
29424 + * This program is free software; you can redistribute it and/or modify it
29425 + * under the terms of the GNU General Public License version 2 as published
29426 + * by the Free Software Foundation.
29427 + */
29429 +#include <asm/mach-ath79/ath79.h>
29430 +#include <asm/mach-ath79/ar71xx_regs.h>
29432 +#include "common.h"
29433 +#include "dev-eth.h"
29434 +#include "dev-m25p80.h"
29435 +#include "dev-ap9x-pci.h"
29436 +#include "dev-gpio-buttons.h"
29437 +#include "dev-leds-gpio.h"
29438 +#include "machtypes.h"
29440 +#define ZCN_1523H_GPIO_BTN_RESET 0
29441 +#define ZCN_1523H_GPIO_LED_INIT 11
29442 +#define ZCN_1523H_GPIO_LED_LAN1 17
29444 +#define ZCN_1523H_2_GPIO_LED_WEAK 13
29445 +#define ZCN_1523H_2_GPIO_LED_MEDIUM 14
29446 +#define ZCN_1523H_2_GPIO_LED_STRONG 15
29448 +#define ZCN_1523H_5_GPIO_LAN2_POWER 1
29449 +#define ZCN_1523H_5_GPIO_LED_LAN2 13
29450 +#define ZCN_1523H_5_GPIO_LED_WEAK 14
29451 +#define ZCN_1523H_5_GPIO_LED_MEDIUM 15
29452 +#define ZCN_1523H_5_GPIO_LED_STRONG 16
29454 +#define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */
29455 +#define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL)
29457 +static struct gpio_keys_button zcn_1523h_gpio_keys[] __initdata = {
29459 + .desc = "reset",
29460 + .type = EV_KEY,
29461 + .code = KEY_RESTART,
29462 + .debounce_interval = ZCN_1523H_KEYS_DEBOUNCE_INTERVAL,
29463 + .gpio = ZCN_1523H_GPIO_BTN_RESET,
29464 + .active_low = 1,
29468 +static struct gpio_led zcn_1523h_leds_gpio[] __initdata = {
29470 + .name = "zcn-1523h:amber:init",
29471 + .gpio = ZCN_1523H_GPIO_LED_INIT,
29472 + .active_low = 1,
29473 + }, {
29474 + .name = "zcn-1523h:green:lan1",
29475 + .gpio = ZCN_1523H_GPIO_LED_LAN1,
29476 + .active_low = 1,
29480 +static struct gpio_led zcn_1523h_2_leds_gpio[] __initdata = {
29482 + .name = "zcn-1523h:red:weak",
29483 + .gpio = ZCN_1523H_2_GPIO_LED_WEAK,
29484 + .active_low = 1,
29485 + }, {
29486 + .name = "zcn-1523h:amber:medium",
29487 + .gpio = ZCN_1523H_2_GPIO_LED_MEDIUM,
29488 + .active_low = 1,
29489 + }, {
29490 + .name = "zcn-1523h:green:strong",
29491 + .gpio = ZCN_1523H_2_GPIO_LED_STRONG,
29492 + .active_low = 1,
29496 +static struct gpio_led zcn_1523h_5_leds_gpio[] __initdata = {
29498 + .name = "zcn-1523h:red:weak",
29499 + .gpio = ZCN_1523H_5_GPIO_LED_WEAK,
29500 + .active_low = 1,
29501 + }, {
29502 + .name = "zcn-1523h:amber:medium",
29503 + .gpio = ZCN_1523H_5_GPIO_LED_MEDIUM,
29504 + .active_low = 1,
29505 + }, {
29506 + .name = "zcn-1523h:green:strong",
29507 + .gpio = ZCN_1523H_5_GPIO_LED_STRONG,
29508 + .active_low = 1,
29509 + }, {
29510 + .name = "zcn-1523h:green:lan2",
29511 + .gpio = ZCN_1523H_5_GPIO_LED_LAN2,
29512 + .active_low = 1,
29516 +static void __init zcn_1523h_generic_setup(void)
29518 + u8 *mac = (u8 *) KSEG1ADDR(0x1f7e0004);
29519 + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
29521 + ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
29522 + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
29523 + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
29524 + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
29525 + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
29527 + ath79_register_m25p80(NULL);
29529 + ath79_register_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio),
29530 + zcn_1523h_leds_gpio);
29532 + ath79_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL,
29533 + ARRAY_SIZE(zcn_1523h_gpio_keys),
29534 + zcn_1523h_gpio_keys);
29536 + ap91_pci_init(ee, mac);
29538 + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
29539 + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
29541 + ath79_register_mdio(0, 0x0);
29543 + /* LAN1 port */
29544 + ath79_register_eth(0);
29547 +static void __init zcn_1523h_2_setup(void)
29549 + zcn_1523h_generic_setup();
29550 + ap9x_pci_setup_wmac_gpio(0, BIT(9), 0);
29552 + ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio),
29553 + zcn_1523h_2_leds_gpio);
29556 +MIPS_MACHINE(ATH79_MACH_ZCN_1523H_2, "ZCN-1523H-2", "Zcomax ZCN-1523H-2",
29557 + zcn_1523h_2_setup);
29559 +static void __init zcn_1523h_5_setup(void)
29561 + zcn_1523h_generic_setup();
29562 + ap9x_pci_setup_wmac_gpio(0, BIT(8), 0);
29564 + ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio),
29565 + zcn_1523h_5_leds_gpio);
29567 + /* LAN2 port */
29568 + ath79_register_eth(1);
29571 +MIPS_MACHINE(ATH79_MACH_ZCN_1523H_5, "ZCN-1523H-5", "Zcomax ZCN-1523H-5",
29572 + zcn_1523h_5_setup);
29573 diff -Nur linux-4.1.43.orig/arch/mips/ath79/machtypes.h linux-4.1.43/arch/mips/ath79/machtypes.h
29574 --- linux-4.1.43.orig/arch/mips/ath79/machtypes.h 2017-08-06 01:56:14.000000000 +0200
29575 +++ linux-4.1.43/arch/mips/ath79/machtypes.h 2017-08-06 20:02:15.000000000 +0200
29576 @@ -16,12 +16,224 @@
29578 enum ath79_mach_type {
29579 ATH79_MACH_GENERIC = 0,
29580 + ATH79_MACH_ALFA_AP96, /* ALFA Network AP96 board */
29581 + ATH79_MACH_ALFA_NX, /* ALFA Network N2/N5 board */
29582 + ATH79_MACH_ALL0258N, /* Allnet ALL0258N */
29583 + ATH79_MACH_ALL0305, /* Allnet ALL0305 */
29584 + ATH79_MACH_ALL0315N, /* Allnet ALL0315N */
29585 + ATH79_MACH_ANTMINER_S1, /* Antminer S1 */
29586 + ATH79_MACH_ANTMINER_S3, /* Antminer S3 */
29587 + ATH79_MACH_ARDUINO_YUN, /* Yun */
29588 + ATH79_MACH_AP113, /* Atheros AP113 reference board */
29589 ATH79_MACH_AP121, /* Atheros AP121 reference board */
29590 + ATH79_MACH_AP121_MINI, /* Atheros AP121-MINI reference board */
29591 + ATH79_MACH_AP132, /* Atheros AP132 reference board */
29592 + ATH79_MACH_AP135_020, /* Atheros AP135-020 reference board */
29593 ATH79_MACH_AP136_010, /* Atheros AP136-010 reference board */
29594 + ATH79_MACH_AP136_020, /* Atheros AP136-020 reference board */
29595 + ATH79_MACH_AP143, /* Atheros AP143 reference board */
29596 + ATH79_MACH_AP147_010, /* Atheros AP147-010 reference board */
29597 + ATH79_MACH_AP152, /* Atheros AP152 reference board */
29598 ATH79_MACH_AP81, /* Atheros AP81 reference board */
29599 + ATH79_MACH_AP83, /* Atheros AP83 */
29600 + ATH79_MACH_AP96, /* Atheros AP96 */
29601 + ATH79_MACH_ARCHER_C5, /* TP-LINK Archer C5 board */
29602 + ATH79_MACH_ARCHER_C7, /* TP-LINK Archer C7 board */
29603 + ATH79_MACH_AW_NR580, /* AzureWave AW-NR580 */
29604 + ATH79_MACH_BHU_BXU2000N2_A1, /* BHU BXU2000n-2 A1 */
29605 + ATH79_MACH_BSB, /* Smart Electronics Black Swift board */
29606 + ATH79_MACH_CAP4200AG, /* Senao CAP4200AG */
29607 + ATH79_MACH_CARAMBOLA2, /* 8devices Carambola2 */
29608 + ATH79_MACH_CF_E316N_V2, /* COMFAST CF-E316N v2 */
29609 + ATH79_MACH_CPE510, /* TP-LINK CPE510 */
29610 ATH79_MACH_DB120, /* Atheros DB120 reference board */
29611 ATH79_MACH_PB44, /* Atheros PB44 reference board */
29612 + ATH79_MACH_DGL_5500_A1, /* D-link DGL-5500 rev. A1 */
29613 + ATH79_MACH_DHP_1565_A1, /* D-Link DHP-1565 rev. A1 */
29614 + ATH79_MACH_DIR_505_A1, /* D-Link DIR-505 rev. A1 */
29615 + ATH79_MACH_DIR_600_A1, /* D-Link DIR-600 rev. A1 */
29616 + ATH79_MACH_DIR_615_C1, /* D-Link DIR-615 rev. C1 */
29617 + ATH79_MACH_DIR_615_E1, /* D-Link DIR-615 rev. E1 */
29618 + ATH79_MACH_DIR_615_E4, /* D-Link DIR-615 rev. E4 */
29619 + ATH79_MACH_DIR_615_I1, /* D-Link DIR-615 rev. I1 */
29620 + ATH79_MACH_DIR_825_B1, /* D-Link DIR-825 rev. B1 */
29621 + ATH79_MACH_DIR_825_C1, /* D-Link DIR-825 rev. C1 */
29622 + ATH79_MACH_DIR_835_A1, /* D-Link DIR-835 rev. A1 */
29623 + ATH79_MACH_DLAN_HOTSPOT, /* devolo dLAN Hotspot */
29624 + ATH79_MACH_DLAN_PRO_500_WP, /* devolo dLAN pro 500 Wireless+ */
29625 + ATH79_MACH_DLAN_PRO_1200_AC, /* devolo dLAN pro 1200+ WiFi ac*/
29626 + ATH79_MACH_DRAGINO2, /* Dragino Version 2 */
29627 + ATH79_MACH_ESR900, /* EnGenius ESR900 */
29628 + ATH79_MACH_EW_DORIN, /* embedded wireless Dorin Platform */
29629 + ATH79_MACH_EW_DORIN_ROUTER, /* embedded wireless Dorin Router Platform */
29630 + ATH79_MACH_EAP300V2, /* EnGenius EAP300 v2 */
29631 + ATH79_MACH_EAP7660D, /* Senao EAP7660D */
29632 + ATH79_MACH_EL_M150, /* EasyLink EL-M150 */
29633 + ATH79_MACH_EL_MINI, /* EasyLink EL-MINI */
29634 + ATH79_MACH_ESR1750, /* EnGenius ESR1750 */
29635 + ATH79_MACH_EPG5000, /* EnGenius EPG5000 */
29636 + ATH79_MACH_F9K1115V2, /* Belkin AC1750DB */
29637 + ATH79_MACH_GL_AR150, /* GL-AR150 support */
29638 + ATH79_MACH_GL_AR300, /* GL-AR300 */
29639 + ATH79_MACH_GL_DOMINO, /* Domino */
29640 + ATH79_MACH_GL_INET, /* GL-CONNECT GL-INET */
29641 + ATH79_MACH_GS_MINIBOX_V1, /* Gainstrong MiniBox V1.0 */
29642 + ATH79_MACH_GS_OOLITE, /* GS OOLITE V1.0 */
29643 + ATH79_MACH_HIWIFI_HC6361, /* HiWiFi HC6361 */
29644 + ATH79_MACH_JA76PF, /* jjPlus JA76PF */
29645 + ATH79_MACH_JA76PF2, /* jjPlus JA76PF2 */
29646 + ATH79_MACH_JWAP003, /* jjPlus JWAP003 */
29647 + ATH79_MACH_HORNET_UB, /* ALFA Networks Hornet-UB */
29648 + ATH79_MACH_MR12, /* Cisco Meraki MR12 */
29649 + ATH79_MACH_MR16, /* Cisco Meraki MR16 */
29650 + ATH79_MACH_MR1750, /* OpenMesh MR1750 */
29651 + ATH79_MACH_MR600V2, /* OpenMesh MR600v2 */
29652 + ATH79_MACH_MR600, /* OpenMesh MR600 */
29653 + ATH79_MACH_MR900, /* OpenMesh MR900 */
29654 + ATH79_MACH_MR900v2, /* OpenMesh MR900v2 */
29655 + ATH79_MACH_MYNET_N600, /* WD My Net N600 */
29656 + ATH79_MACH_MYNET_N750, /* WD My Net N750 */
29657 + ATH79_MACH_MYNET_REXT, /* WD My Net Wi-Fi Range Extender */
29658 + ATH79_MACH_MZK_W04NU, /* Planex MZK-W04NU */
29659 + ATH79_MACH_MZK_W300NH, /* Planex MZK-W300NH */
29660 + ATH79_MACH_NBG460N, /* Zyxel NBG460N/550N/550NH */
29661 + ATH79_MACH_NBG6616, /* Zyxel NBG6616 */
29662 + ATH79_MACH_NBG6716, /* Zyxel NBG6716 */
29663 + ATH79_MACH_OM2P_HSv2, /* OpenMesh OM2P-HSv2 */
29664 + ATH79_MACH_OM2P_HS, /* OpenMesh OM2P-HS */
29665 + ATH79_MACH_OM2P_LC, /* OpenMesh OM2P-LC */
29666 + ATH79_MACH_OM2Pv2, /* OpenMesh OM2Pv2 */
29667 + ATH79_MACH_OM2P, /* OpenMesh OM2P */
29668 + ATH79_MACH_OM5P_AN, /* OpenMesh OM5P-AN */
29669 + ATH79_MACH_OM5P, /* OpenMesh OM5P */
29670 + ATH79_MACH_ONION_OMEGA, /* ONION OMEGA */
29671 + ATH79_MACH_PB42, /* Atheros PB42 */
29672 + ATH79_MACH_PB92, /* Atheros PB92 */
29673 + ATH79_MACH_QIHOO_C301, /* Qihoo 360 C301 */
29674 + ATH79_MACH_R6100, /* NETGEAR R6100 */
29675 + ATH79_MACH_RB_411, /* MikroTik RouterBOARD 411/411A/411AH */
29676 + ATH79_MACH_RB_411U, /* MikroTik RouterBOARD 411U */
29677 + ATH79_MACH_RB_433, /* MikroTik RouterBOARD 433/433AH */
29678 + ATH79_MACH_RB_433U, /* MikroTik RouterBOARD 433UAH */
29679 + ATH79_MACH_RB_435G, /* MikroTik RouterBOARD 435G */
29680 + ATH79_MACH_RB_450G, /* MikroTik RouterBOARD 450G */
29681 + ATH79_MACH_RB_450, /* MikroTik RouterBOARD 450 */
29682 + ATH79_MACH_RB_493, /* Mikrotik RouterBOARD 493/493AH */
29683 + ATH79_MACH_RB_493G, /* Mikrotik RouterBOARD 493G */
29684 + ATH79_MACH_RB_711GR100, /* Mikrotik RouterBOARD 911/912 boards */
29685 + ATH79_MACH_RB_750, /* MikroTik RouterBOARD 750 */
29686 + ATH79_MACH_RB_750G_R3, /* MikroTik RouterBOARD 750GL */
29687 + ATH79_MACH_RB_751, /* MikroTik RouterBOARD 751 */
29688 + ATH79_MACH_RB_751G, /* Mikrotik RouterBOARD 751G */
29689 + ATH79_MACH_RB_922GS, /* Mikrotik RouterBOARD 911/922GS boards */
29690 + ATH79_MACH_RB_951G, /* Mikrotik RouterBOARD 951G */
29691 + ATH79_MACH_RB_951U, /* Mikrotik RouterBOARD 951Ui-2HnD */
29692 + ATH79_MACH_RB_2011G, /* Mikrotik RouterBOARD 2011UAS-2HnD */
29693 + ATH79_MACH_RB_2011L, /* Mikrotik RouterBOARD 2011L */
29694 + ATH79_MACH_RB_2011US, /* Mikrotik RouterBOARD 2011UAS */
29695 + ATH79_MACH_RB_2011R5, /* Mikrotik RouterBOARD 2011UiAS(-2Hnd) */
29696 + ATH79_MACH_RB_SXTLITE2ND, /* Mikrotik RouterBOARD SXT Lite 2nD */
29697 + ATH79_MACH_RB_SXTLITE5ND, /* Mikrotik RouterBOARD SXT Lite 5nD */
29698 + ATH79_MACH_RW2458N, /* Redwave RW2458N */
29699 + ATH79_MACH_SMART_300, /* NC-LINK SMART-300 */
29700 + ATH79_MACH_TEW_632BRP, /* TRENDnet TEW-632BRP */
29701 + ATH79_MACH_TEW_673GRU, /* TRENDnet TEW-673GRU */
29702 + ATH79_MACH_TEW_712BR, /* TRENDnet TEW-712BR */
29703 + ATH79_MACH_TEW_732BR, /* TRENDnet TEW-732BR */
29704 + ATH79_MACH_MC_MAC1200R, /* MERCURY MAC1200R*/
29705 + ATH79_MACH_TL_MR10U, /* TP-LINK TL-MR10U */
29706 + ATH79_MACH_TL_MR11U, /* TP-LINK TL-MR11U */
29707 + ATH79_MACH_TL_MR13U, /* TP-LINK TL-MR13U */
29708 + ATH79_MACH_TL_MR3020, /* TP-LINK TL-MR3020 */
29709 + ATH79_MACH_TL_MR3040, /* TP-LINK TL-MR3040 */
29710 + ATH79_MACH_TL_MR3040_V2, /* TP-LINK TL-MR3040 v2 */
29711 + ATH79_MACH_TL_MR3220, /* TP-LINK TL-MR3220 */
29712 + ATH79_MACH_TL_MR3220_V2, /* TP-LINK TL-MR3220 v2 */
29713 + ATH79_MACH_TL_MR3420, /* TP-LINK TL-MR3420 */
29714 + ATH79_MACH_TL_MR3420_V2, /* TP-LINK TL-MR3420 v2 */
29715 + ATH79_MACH_TL_WA701ND_V2, /* TP-LINK TL-WA701ND v2 */
29716 + ATH79_MACH_TL_WA750RE, /* TP-LINK TL-WA750RE */
29717 + ATH79_MACH_TL_WA7210N_V2, /* TP-LINK TL-WA7210N v2 */
29718 + ATH79_MACH_TL_WA7510N_V1, /* TP-LINK TL-WA7510N v1*/
29719 + ATH79_MACH_TL_WA850RE, /* TP-LINK TL-WA850RE */
29720 + ATH79_MACH_TL_WA860RE, /* TP-LINK TL-WA860RE */
29721 + ATH79_MACH_TL_WA801ND_V2, /* TP-LINK TL-WA801ND v2 */
29722 + ATH79_MACH_TL_WA830RE_V2, /* TP-LINK TL-WA830RE v2 */
29723 + ATH79_MACH_TL_WA901ND, /* TP-LINK TL-WA901ND */
29724 + ATH79_MACH_TL_WA901ND_V2, /* TP-LINK TL-WA901ND v2 */
29725 + ATH79_MACH_TL_WA901ND_V3, /* TP-LINK TL-WA901ND v3 */
29726 + ATH79_MACH_TL_WDR3320_V2, /* TP-LINK TL-WDR3320 v2 */
29727 + ATH79_MACH_TL_WDR3500, /* TP-LINK TL-WDR3500 */
29728 + ATH79_MACH_TL_WDR4300, /* TP-LINK TL-WDR4300 */
29729 + ATH79_MACH_TL_WDR6500_V2, /* TP-LINK TL-WDR6500 v2 */
29730 + ATH79_MACH_TL_WDR4900_V2, /* TP-LINK TL-WDR4900 v2 */
29731 + ATH79_MACH_TL_WR1041N_V2, /* TP-LINK TL-WR1041N v2 */
29732 + ATH79_MACH_TL_WR1043ND, /* TP-LINK TL-WR1043ND */
29733 + ATH79_MACH_TL_WR1043ND_V2, /* TP-LINK TL-WR1043ND v2 */
29734 + ATH79_MACH_TL_WR2543N, /* TP-LINK TL-WR2543N/ND */
29735 + ATH79_MACH_TL_WR703N, /* TP-LINK TL-WR703N */
29736 + ATH79_MACH_TL_WR710N, /* TP-LINK TL-WR710N */
29737 + ATH79_MACH_TL_WR720N_V3, /* TP-LINK TL-WR720N v3/v4 */
29738 + ATH79_MACH_TL_WR741ND, /* TP-LINK TL-WR741ND */
29739 + ATH79_MACH_TL_WR741ND_V4, /* TP-LINK TL-WR741ND v4*/
29740 + ATH79_MACH_TL_WR841N_V1, /* TP-LINK TL-WR841N v1 */
29741 + ATH79_MACH_TL_WR841N_V7, /* TP-LINK TL-WR841N/ND v7 */
29742 + ATH79_MACH_TL_WR841N_V8, /* TP-LINK TL-WR841N/ND v8 */
29743 + ATH79_MACH_TL_WR841N_V9, /* TP-LINK TL-WR841N/ND v9 */
29744 + ATH79_MACH_TL_WR842N_V2, /* TP-LINK TL-WR842N/ND v2 */
29745 + ATH79_MACH_TL_WR941ND, /* TP-LINK TL-WR941ND */
29746 + ATH79_MACH_TL_WR941ND_V5, /* TP-LINK TL-WR941ND v5 */
29747 + ATH79_MACH_TL_WR941ND_V6, /* TP-LINK TL-WR941ND v6 */
29748 + ATH79_MACH_TUBE2H, /* Alfa Network Tube2H */
29749 + ATH79_MACH_UBNT_AIRGW, /* Ubiquiti AirGateway */
29750 + ATH79_MACH_UBNT_AIRGWP, /* Ubiquiti AirGateway Pro */
29751 + ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
29752 + ATH79_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
29753 + ATH79_MACH_UBNT_LOCO_M_XW, /* Ubiquiti Loco M XW */
29754 + ATH79_MACH_UBNT_LSSR71, /* Ubiquiti LS-SR71 */
29755 + ATH79_MACH_UBNT_LSX, /* Ubiquiti LSX */
29756 + ATH79_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
29757 + ATH79_MACH_UBNT_NANO_M_XW, /* Ubiquiti NanoStation M XW */
29758 + ATH79_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
29759 + ATH79_MACH_UBNT_ROCKET_M_XW, /* Ubiquiti Rocket M XW*/
29760 + ATH79_MACH_UBNT_ROCKET_M_TI, /* Ubiquiti Rocket M TI*/
29761 + ATH79_MACH_UBNT_RSPRO, /* Ubiquiti RouterStation Pro */
29762 + ATH79_MACH_UBNT_RS, /* Ubiquiti RouterStation */
29763 + ATH79_MACH_UBNT_UAP_PRO, /* Ubiquiti UniFi AP Pro */
29764 + ATH79_MACH_UBNT_UNIFI, /* Ubiquiti Unifi */
29765 + ATH79_MACH_UBNT_UNIFI_OUTDOOR, /* Ubiquiti UnifiAP Outdoor */
29766 + ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, /* Ubiquiti UnifiAP Outdoor+ */
29767 ATH79_MACH_UBNT_XM, /* Ubiquiti Networks XM board rev 1.0 */
29768 + ATH79_MACH_WEIO, /* WeIO board */
29769 + ATH79_MACH_WHR_G301N, /* Buffalo WHR-G301N */
29770 + ATH79_MACH_WHR_HP_G300N, /* Buffalo WHR-HP-G300N */
29771 + ATH79_MACH_WHR_HP_GN, /* Buffalo WHR-HP-GN */
29772 + ATH79_MACH_WLAE_AG300N, /* Buffalo WLAE-AG300N */
29773 + ATH79_MACH_WLR8100, /* SITECOM WLR-8100 */
29774 + ATH79_MACH_WNDAP360, /* NETGEAR WNDAP360 */
29775 + ATH79_MACH_WNDR3700, /* NETGEAR WNDR3700/WNDR3800/WNDRMAC */
29776 + ATH79_MACH_WNDR3700_V4, /* NETGEAR WNDR3700v4 */
29777 + ATH79_MACH_WNDR4300, /* NETGEAR WNDR4300 */
29778 + ATH79_MACH_WNR2000, /* NETGEAR WNR2000 */
29779 + ATH79_MACH_WNR2000_V3, /* NETGEAR WNR2000 v3 */
29780 + ATH79_MACH_WNR2000_V4, /* NETGEAR WNR2000 v4 */
29781 + ATH79_MACH_WNR2200, /* NETGEAR WNR2200 */
29782 + ATH79_MACH_WNR612_V2, /* NETGEAR WNR612 v2 */
29783 + ATH79_MACH_WNR1000_V2, /* NETGEAR WNR1000 v2 */
29784 + ATH79_MACH_WP543, /* Compex WP543 */
29785 + ATH79_MACH_WPE72, /* Compex WPE72 */
29786 + ATH79_MACH_WPJ344, /* Compex WPJ344 */
29787 + ATH79_MACH_WPJ531, /* Compex WPJ531 */
29788 + ATH79_MACH_WPJ558, /* Compex WPJ558 */
29789 + ATH79_MACH_WRT160NL, /* Linksys WRT160NL */
29790 + ATH79_MACH_WRT400N, /* Linksys WRT400N */
29791 + ATH79_MACH_WZR_HP_AG300H, /* Buffalo WZR-HP-AG300H */
29792 + ATH79_MACH_WZR_HP_G300NH, /* Buffalo WZR-HP-G300NH */
29793 + ATH79_MACH_WZR_HP_G300NH2, /* Buffalo WZR-HP-G300NH2 */
29794 + ATH79_MACH_WZR_HP_G450H, /* Buffalo WZR-HP-G450H */
29795 + ATH79_MACH_WZR_450HP2, /* Buffalo WZR-450HP2 */
29796 + ATH79_MACH_ZCN_1523H_2, /* Zcomax ZCN-1523H-2-xx */
29797 + ATH79_MACH_ZCN_1523H_5, /* Zcomax ZCN-1523H-5-xx */
29800 #endif /* _ATH79_MACHTYPE_H */
29801 diff -Nur linux-4.1.43.orig/arch/mips/ath79/nvram.c linux-4.1.43/arch/mips/ath79/nvram.c
29802 --- linux-4.1.43.orig/arch/mips/ath79/nvram.c 1970-01-01 01:00:00.000000000 +0100
29803 +++ linux-4.1.43/arch/mips/ath79/nvram.c 2017-08-06 20:02:15.000000000 +0200
29804 @@ -0,0 +1,80 @@
29806 + * Atheros AR71xx minimal nvram support
29808 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
29810 + * This program is free software; you can redistribute it and/or modify it
29811 + * under the terms of the GNU General Public License version 2 as published
29812 + * by the Free Software Foundation.
29813 + */
29815 +#include <linux/kernel.h>
29816 +#include <linux/vmalloc.h>
29817 +#include <linux/errno.h>
29818 +#include <linux/init.h>
29819 +#include <linux/string.h>
29821 +#include "nvram.h"
29823 +char *ath79_nvram_find_var(const char *name, const char *buf, unsigned buf_len)
29825 + unsigned len = strlen(name);
29826 + char *cur, *last;
29828 + if (buf_len == 0 || len == 0)
29829 + return NULL;
29831 + if (buf_len < len)
29832 + return NULL;
29834 + if (len == 1)
29835 + return memchr(buf, (int) *name, buf_len);
29837 + last = (char *) buf + buf_len - len;
29838 + for (cur = (char *) buf; cur <= last; cur++)
29839 + if (cur[0] == name[0] && memcmp(cur, name, len) == 0)
29840 + return cur + len;
29842 + return NULL;
29845 +int ath79_nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
29846 + const char *name, char *mac)
29848 + char *buf;
29849 + char *mac_str;
29850 + int ret;
29851 + int t;
29853 + buf = vmalloc(nvram_len);
29854 + if (!buf)
29855 + return -ENOMEM;
29857 + memcpy(buf, nvram, nvram_len);
29858 + buf[nvram_len - 1] = '\0';
29860 + mac_str = ath79_nvram_find_var(name, buf, nvram_len);
29861 + if (!mac_str) {
29862 + ret = -EINVAL;
29863 + goto free;
29866 + if (strlen(mac_str) == 19 && mac_str[0] == '"' && mac_str[18] == '"') {
29867 + mac_str[18] = 0;
29868 + mac_str++;
29871 + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
29872 + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
29874 + if (t != 6) {
29875 + ret = -EINVAL;
29876 + goto free;
29879 + ret = 0;
29881 +free:
29882 + vfree(buf);
29883 + return ret;
29885 diff -Nur linux-4.1.43.orig/arch/mips/ath79/nvram.h linux-4.1.43/arch/mips/ath79/nvram.h
29886 --- linux-4.1.43.orig/arch/mips/ath79/nvram.h 1970-01-01 01:00:00.000000000 +0100
29887 +++ linux-4.1.43/arch/mips/ath79/nvram.h 2017-08-06 20:02:15.000000000 +0200
29888 @@ -0,0 +1,19 @@
29890 + * Atheros AR71xx minimal nvram support
29892 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
29894 + * This program is free software; you can redistribute it and/or modify it
29895 + * under the terms of the GNU General Public License version 2 as published
29896 + * by the Free Software Foundation.
29897 + */
29899 +#ifndef _ATH79_NVRAM_H
29900 +#define _ATH79_NVRAM_H
29902 +char *ath79_nvram_find_var(const char *name, const char *buf,
29903 + unsigned buf_len);
29904 +int ath79_nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
29905 + const char *name, char *mac);
29907 +#endif /* _ATH79_NVRAM_H */
29908 diff -Nur linux-4.1.43.orig/arch/mips/ath79/pci-ath9k-fixup.c linux-4.1.43/arch/mips/ath79/pci-ath9k-fixup.c
29909 --- linux-4.1.43.orig/arch/mips/ath79/pci-ath9k-fixup.c 1970-01-01 01:00:00.000000000 +0100
29910 +++ linux-4.1.43/arch/mips/ath79/pci-ath9k-fixup.c 2017-08-06 20:02:15.000000000 +0200
29911 @@ -0,0 +1,126 @@
29913 + * Atheros AP94 reference board PCI initialization
29915 + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
29917 + * This program is free software; you can redistribute it and/or modify it
29918 + * under the terms of the GNU General Public License version 2 as published
29919 + * by the Free Software Foundation.
29920 + */
29922 +#include <linux/pci.h>
29923 +#include <linux/delay.h>
29925 +#include <asm/mach-ath79/ar71xx_regs.h>
29926 +#include <asm/mach-ath79/ath79.h>
29928 +struct ath9k_fixup {
29929 + u16 *cal_data;
29930 + unsigned slot;
29933 +static int ath9k_num_fixups;
29934 +static struct ath9k_fixup ath9k_fixups[2];
29936 +static void ath9k_pci_fixup(struct pci_dev *dev)
29938 + void __iomem *mem;
29939 + u16 *cal_data = NULL;
29940 + u16 cmd;
29941 + u32 bar0;
29942 + u32 val;
29943 + unsigned i;
29945 + for (i = 0; i < ath9k_num_fixups; i++) {
29946 + if (ath9k_fixups[i].cal_data == NULL)
29947 + continue;
29949 + if (ath9k_fixups[i].slot != PCI_SLOT(dev->devfn))
29950 + continue;
29952 + cal_data = ath9k_fixups[i].cal_data;
29953 + break;
29956 + if (cal_data == NULL)
29957 + return;
29959 + if (*cal_data != 0xa55a) {
29960 + pr_err("pci %s: invalid calibration data\n", pci_name(dev));
29961 + return;
29964 + pr_info("pci %s: fixup device configuration\n", pci_name(dev));
29966 + mem = ioremap(AR71XX_PCI_MEM_BASE, 0x10000);
29967 + if (!mem) {
29968 + pr_err("pci %s: ioremap error\n", pci_name(dev));
29969 + return;
29972 + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0);
29974 + switch (ath79_soc) {
29975 + case ATH79_SOC_AR7161:
29976 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0,
29977 + AR71XX_PCI_MEM_BASE);
29978 + break;
29979 + case ATH79_SOC_AR7240:
29980 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0xffff);
29981 + break;
29983 + case ATH79_SOC_AR7241:
29984 + case ATH79_SOC_AR7242:
29985 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000ffff);
29986 + break;
29987 + case ATH79_SOC_AR9344:
29988 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0x1000ffff);
29989 + break;
29991 + default:
29992 + BUG();
29995 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
29996 + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
29997 + pci_write_config_word(dev, PCI_COMMAND, cmd);
29999 + /* set pointer to first reg address */
30000 + cal_data += 3;
30001 + while (*cal_data != 0xffff) {
30002 + u32 reg;
30003 + reg = *cal_data++;
30004 + val = *cal_data++;
30005 + val |= (*cal_data++) << 16;
30007 + __raw_writel(val, mem + reg);
30008 + udelay(100);
30011 + pci_read_config_dword(dev, PCI_VENDOR_ID, &val);
30012 + dev->vendor = val & 0xffff;
30013 + dev->device = (val >> 16) & 0xffff;
30015 + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val);
30016 + dev->revision = val & 0xff;
30017 + dev->class = val >> 8; /* upper 3 bytes */
30019 + pci_read_config_word(dev, PCI_COMMAND, &cmd);
30020 + cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
30021 + pci_write_config_word(dev, PCI_COMMAND, cmd);
30023 + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0);
30025 + iounmap(mem);
30027 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath9k_pci_fixup);
30029 +void __init pci_enable_ath9k_fixup(unsigned slot, u16 *cal_data)
30031 + if (ath9k_num_fixups >= ARRAY_SIZE(ath9k_fixups))
30032 + return;
30034 + ath9k_fixups[ath9k_num_fixups].slot = slot;
30035 + ath9k_fixups[ath9k_num_fixups].cal_data = cal_data;
30036 + ath9k_num_fixups++;
30038 diff -Nur linux-4.1.43.orig/arch/mips/ath79/pci-ath9k-fixup.h linux-4.1.43/arch/mips/ath79/pci-ath9k-fixup.h
30039 --- linux-4.1.43.orig/arch/mips/ath79/pci-ath9k-fixup.h 1970-01-01 01:00:00.000000000 +0100
30040 +++ linux-4.1.43/arch/mips/ath79/pci-ath9k-fixup.h 2017-08-06 20:02:15.000000000 +0200
30041 @@ -0,0 +1,6 @@
30042 +#ifndef _PCI_ATH9K_FIXUP
30043 +#define _PCI_ATH9K_FIXUP
30045 +void pci_enable_ath9k_fixup(unsigned slot, u16 *cal_data) __init;
30047 +#endif /* _PCI_ATH9K_FIXUP */
30048 diff -Nur linux-4.1.43.orig/arch/mips/ath79/pci.c linux-4.1.43/arch/mips/ath79/pci.c
30049 --- linux-4.1.43.orig/arch/mips/ath79/pci.c 2017-08-06 01:56:14.000000000 +0200
30050 +++ linux-4.1.43/arch/mips/ath79/pci.c 2017-08-06 20:02:15.000000000 +0200
30051 @@ -13,6 +13,7 @@
30054 #include <linux/init.h>
30055 +#include <linux/export.h>
30056 #include <linux/pci.h>
30057 #include <linux/resource.h>
30058 #include <linux/platform_device.h>
30059 @@ -25,6 +26,9 @@
30060 static const struct ath79_pci_irq *ath79_pci_irq_map __initdata;
30061 static unsigned ath79_pci_nr_irqs __initdata;
30063 +static unsigned long (*__ath79_pci_swizzle_b)(unsigned long port);
30064 +static unsigned long (*__ath79_pci_swizzle_w)(unsigned long port);
30066 static const struct ath79_pci_irq ar71xx_pci_irq_map[] __initconst = {
30068 .slot = 17,
30069 @@ -49,6 +53,15 @@
30073 +static const struct ath79_pci_irq qca953x_pci_irq_map[] __initconst = {
30075 + .bus = 0,
30076 + .slot = 0,
30077 + .pin = 1,
30078 + .irq = ATH79_PCI_IRQ(0),
30079 + },
30082 static const struct ath79_pci_irq qca955x_pci_irq_map[] __initconst = {
30084 .bus = 0,
30085 @@ -64,6 +77,21 @@
30089 +static const struct ath79_pci_irq qca956x_pci_irq_map[] __initconst = {
30091 + .bus = 0,
30092 + .slot = 0,
30093 + .pin = 1,
30094 + .irq = ATH79_PCI_IRQ(0),
30095 + },
30097 + .bus = 1,
30098 + .slot = 0,
30099 + .pin = 1,
30100 + .irq = ATH79_PCI_IRQ(1),
30101 + },
30104 int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
30106 int irq = -1;
30107 @@ -79,9 +107,15 @@
30108 soc_is_ar9344()) {
30109 ath79_pci_irq_map = ar724x_pci_irq_map;
30110 ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
30111 + } else if (soc_is_qca953x()) {
30112 + ath79_pci_irq_map = qca953x_pci_irq_map;
30113 + ath79_pci_nr_irqs = ARRAY_SIZE(qca953x_pci_irq_map);
30114 } else if (soc_is_qca955x()) {
30115 ath79_pci_irq_map = qca955x_pci_irq_map;
30116 ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
30117 + } else if (soc_is_qca9561()) {
30118 + ath79_pci_irq_map = qca956x_pci_irq_map;
30119 + ath79_pci_nr_irqs = ARRAY_SIZE(qca956x_pci_irq_map);
30120 } else {
30121 pr_crit("pci %s: invalid irq map\n",
30122 pci_name((struct pci_dev *) dev));
30123 @@ -212,12 +246,50 @@
30124 return pdev;
30127 +static inline bool ar71xx_is_pci_addr(unsigned long port)
30129 + unsigned long phys = CPHYSADDR(port);
30131 + return (phys >= AR71XX_PCI_MEM_BASE &&
30132 + phys < AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE);
30135 +static unsigned long ar71xx_pci_swizzle_b(unsigned long port)
30137 + return ar71xx_is_pci_addr(port) ? port ^ 3 : port;
30140 +static unsigned long ar71xx_pci_swizzle_w(unsigned long port)
30142 + return ar71xx_is_pci_addr(port) ? port ^ 2 : port;
30145 +unsigned long ath79_pci_swizzle_b(unsigned long port)
30147 + if (__ath79_pci_swizzle_b)
30148 + return __ath79_pci_swizzle_b(port);
30150 + return port;
30152 +EXPORT_SYMBOL(ath79_pci_swizzle_b);
30154 +unsigned long ath79_pci_swizzle_w(unsigned long port)
30156 + if (__ath79_pci_swizzle_w)
30157 + return __ath79_pci_swizzle_w(port);
30159 + return port;
30161 +EXPORT_SYMBOL(ath79_pci_swizzle_w);
30163 int __init ath79_register_pci(void)
30165 struct platform_device *pdev = NULL;
30167 if (soc_is_ar71xx()) {
30168 pdev = ath79_register_pci_ar71xx();
30169 + __ath79_pci_swizzle_b = ar71xx_pci_swizzle_b;
30170 + __ath79_pci_swizzle_w = ar71xx_pci_swizzle_w;
30171 } else if (soc_is_ar724x()) {
30172 pdev = ath79_register_pci_ar724x(-1,
30173 AR724X_PCI_CFG_BASE,
30174 @@ -243,6 +315,15 @@
30175 AR724X_PCI_MEM_SIZE,
30177 ATH79_IP2_IRQ(0));
30178 + } else if (soc_is_qca9533()) {
30179 + pdev = ath79_register_pci_ar724x(0,
30180 + QCA953X_PCI_CFG_BASE0,
30181 + QCA953X_PCI_CTRL_BASE0,
30182 + QCA953X_PCI_CRP_BASE0,
30183 + QCA953X_PCI_MEM_BASE0,
30184 + QCA953X_PCI_MEM_SIZE,
30185 + 0,
30186 + ATH79_IP2_IRQ(0));
30187 } else if (soc_is_qca9558()) {
30188 pdev = ath79_register_pci_ar724x(0,
30189 QCA955X_PCI_CFG_BASE0,
30190 @@ -261,6 +342,15 @@
30191 QCA955X_PCI_MEM_SIZE,
30193 ATH79_IP3_IRQ(2));
30194 + } else if (soc_is_qca9561()) {
30195 + pdev = ath79_register_pci_ar724x(0,
30196 + QCA956X_PCI_CFG_BASE1,
30197 + QCA956X_PCI_CTRL_BASE1,
30198 + QCA956X_PCI_CRP_BASE1,
30199 + QCA956X_PCI_MEM_BASE1,
30200 + QCA956X_PCI_MEM_SIZE,
30201 + 1,
30202 + ATH79_IP3_IRQ(2));
30203 } else {
30204 /* No PCI support */
30205 return -ENODEV;
30206 diff -Nur linux-4.1.43.orig/arch/mips/ath79/prom.c linux-4.1.43/arch/mips/ath79/prom.c
30207 --- linux-4.1.43.orig/arch/mips/ath79/prom.c 2017-08-06 01:56:14.000000000 +0200
30208 +++ linux-4.1.43/arch/mips/ath79/prom.c 2017-08-06 20:02:15.000000000 +0200
30209 @@ -19,12 +19,114 @@
30210 #include <asm/bootinfo.h>
30211 #include <asm/addrspace.h>
30212 #include <asm/fw/fw.h>
30213 +#include <asm/fw/myloader/myloader.h>
30215 #include "common.h"
30217 +static char ath79_cmdline_buf[COMMAND_LINE_SIZE] __initdata;
30219 +static void __init ath79_prom_append_cmdline(const char *name,
30220 + const char *value)
30222 + snprintf(ath79_cmdline_buf, sizeof(ath79_cmdline_buf),
30223 + " %s=%s", name, value);
30224 + strlcat(arcs_cmdline, ath79_cmdline_buf, sizeof(arcs_cmdline));
30227 +#ifdef CONFIG_IMAGE_CMDLINE_HACK
30228 +extern char __image_cmdline[];
30230 +static int __init ath79_use_image_cmdline(void)
30232 + char *p = __image_cmdline;
30233 + int replace = 0;
30235 + if (*p == '-') {
30236 + replace = 1;
30237 + p++;
30240 + if (*p == '\0')
30241 + return 0;
30243 + if (replace) {
30244 + strlcpy(arcs_cmdline, p, sizeof(arcs_cmdline));
30245 + } else {
30246 + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
30247 + strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
30250 + /* Validate and setup environment pointer */
30251 + if (fw_arg2 < CKSEG0)
30252 + _fw_envp = NULL;
30253 + else
30254 + _fw_envp = (int *)fw_arg2;
30256 + return 1;
30258 +#else
30259 +static inline int ath79_use_image_cmdline(void) { return 0; }
30260 +#endif
30262 +static int __init ath79_prom_init_myloader(void)
30264 + struct myloader_info *mylo;
30265 + char mac_buf[32];
30266 + unsigned char *mac;
30268 + mylo = myloader_get_info();
30269 + if (!mylo)
30270 + return 0;
30272 + switch (mylo->did) {
30273 + case DEVID_COMPEX_WP543:
30274 + ath79_prom_append_cmdline("board", "WP543");
30275 + break;
30276 + case DEVID_COMPEX_WPE72:
30277 + ath79_prom_append_cmdline("board", "WPE72");
30278 + break;
30279 + default:
30280 + pr_warn("prom: unknown device id: %x\n", mylo->did);
30281 + return 0;
30284 + mac = mylo->macs[0];
30285 + snprintf(mac_buf, sizeof(mac_buf), "%02x:%02x:%02x:%02x:%02x:%02x",
30286 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
30288 + ath79_prom_append_cmdline("ethaddr", mac_buf);
30290 + ath79_use_image_cmdline();
30292 + return 1;
30295 void __init prom_init(void)
30297 - fw_init_cmdline();
30298 + const char *env;
30300 + if (ath79_prom_init_myloader())
30301 + return;
30303 + if (!ath79_use_image_cmdline())
30304 + fw_init_cmdline();
30306 + env = fw_getenv("ethaddr");
30307 + if (env)
30308 + ath79_prom_append_cmdline("ethaddr", env);
30310 + env = fw_getenv("board");
30311 + if (env) {
30312 + /* Workaround for buggy bootloaders */
30313 + if (strcmp(env, "RouterStation") == 0 ||
30314 + strcmp(env, "Ubiquiti AR71xx-based board") == 0)
30315 + env = "UBNT-RS";
30317 + if (strcmp(env, "RouterStation PRO") == 0)
30318 + env = "UBNT-RSPRO";
30320 + ath79_prom_append_cmdline("board", env);
30323 #ifdef CONFIG_BLK_DEV_INITRD
30324 /* Read the initrd address from the firmware environment */
30325 @@ -34,6 +136,13 @@
30326 initrd_end = initrd_start + fw_getenvl("initrd_size");
30328 #endif
30330 + if (strstr(arcs_cmdline, "board=750Gr3") ||
30331 + strstr(arcs_cmdline, "board=951G") ||
30332 + strstr(arcs_cmdline, "board=2011L") ||
30333 + strstr(arcs_cmdline, "board=711Gr100") ||
30334 + strstr(arcs_cmdline, "board=922gs"))
30335 + ath79_prom_append_cmdline("console", "ttyS0,115200");
30338 void __init prom_free_prom_memory(void)
30339 diff -Nur linux-4.1.43.orig/arch/mips/ath79/routerboot.c linux-4.1.43/arch/mips/ath79/routerboot.c
30340 --- linux-4.1.43.orig/arch/mips/ath79/routerboot.c 1970-01-01 01:00:00.000000000 +0100
30341 +++ linux-4.1.43/arch/mips/ath79/routerboot.c 2017-08-06 20:02:15.000000000 +0200
30342 @@ -0,0 +1,358 @@
30344 + * RouterBoot helper routines
30346 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
30348 + * This program is free software; you can redistribute it and/or modify it
30349 + * under the terms of the GNU General Public License version 2 as published
30350 + * by the Free Software Foundation.
30351 + */
30353 +#define pr_fmt(fmt) "rb: " fmt
30355 +#include <linux/kernel.h>
30356 +#include <linux/kobject.h>
30357 +#include <linux/slab.h>
30358 +#include <linux/errno.h>
30359 +#include <linux/routerboot.h>
30360 +#include <linux/rle.h>
30361 +#include <linux/lzo.h>
30363 +#include "routerboot.h"
30365 +#define RB_BLOCK_SIZE 0x1000
30366 +#define RB_ART_SIZE 0x10000
30367 +#define RB_MAGIC_ERD 0x00455244 /* extended radio data */
30369 +static struct rb_info rb_info;
30371 +static u32 get_u32(void *buf)
30373 + u8 *p = buf;
30375 + return ((u32) p[3] + ((u32) p[2] << 8) + ((u32) p[1] << 16) +
30376 + ((u32) p[0] << 24));
30379 +static u16 get_u16(void *buf)
30381 + u8 *p = buf;
30383 + return (u16) p[1] + ((u16) p[0] << 8);
30386 +__init int
30387 +routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard)
30389 + u32 magic_ref = hard ? RB_MAGIC_HARD : RB_MAGIC_SOFT;
30390 + u32 magic;
30391 + u32 cur = *offset;
30393 + while (cur < buflen) {
30394 + magic = get_u32(buf + cur);
30395 + if (magic == magic_ref) {
30396 + *offset = cur;
30397 + return 0;
30400 + cur += 0x1000;
30403 + return -ENOENT;
30406 +__init int
30407 +routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
30408 + u8 **tag_data, u16 *tag_len)
30410 + uint32_t magic;
30411 + bool align = false;
30412 + int ret;
30414 + if (buflen < 4)
30415 + return -EINVAL;
30417 + magic = get_u32(buf);
30418 + switch (magic) {
30419 + case RB_MAGIC_ERD:
30420 + align = true;
30421 + /* fall trough */
30422 + case RB_MAGIC_HARD:
30423 + /* skip magic value */
30424 + buf += 4;
30425 + buflen -= 4;
30426 + break;
30428 + case RB_MAGIC_SOFT:
30429 + if (buflen < 8)
30430 + return -EINVAL;
30432 + /* skip magic and CRC value */
30433 + buf += 8;
30434 + buflen -= 8;
30436 + break;
30438 + default:
30439 + return -EINVAL;
30442 + ret = -ENOENT;
30443 + while (buflen > 2) {
30444 + u16 id;
30445 + u16 len;
30447 + len = get_u16(buf);
30448 + buf += 2;
30449 + buflen -= 2;
30451 + if (buflen < 2)
30452 + break;
30454 + id = get_u16(buf);
30455 + buf += 2;
30456 + buflen -= 2;
30458 + if (id == RB_ID_TERMINATOR)
30459 + break;
30461 + if (buflen < len)
30462 + break;
30464 + if (id == tag_id) {
30465 + if (tag_len)
30466 + *tag_len = len;
30467 + if (tag_data)
30468 + *tag_data = buf;
30469 + ret = 0;
30470 + break;
30473 + if (align)
30474 + len = (len + 3) / 4;
30476 + buf += len;
30477 + buflen -= len;
30480 + return ret;
30483 +static inline int
30484 +rb_find_hard_cfg_tag(u16 tag_id, u8 **tag_data, u16 *tag_len)
30486 + if (!rb_info.hard_cfg_data ||
30487 + !rb_info.hard_cfg_size)
30488 + return -ENOENT;
30490 + return routerboot_find_tag(rb_info.hard_cfg_data,
30491 + rb_info.hard_cfg_size,
30492 + tag_id, tag_data, tag_len);
30495 +__init const char *
30496 +rb_get_board_name(void)
30498 + u16 tag_len;
30499 + u8 *tag;
30500 + int err;
30502 + err = rb_find_hard_cfg_tag(RB_ID_BOARD_NAME, &tag, &tag_len);
30503 + if (err)
30504 + return NULL;
30506 + return tag;
30509 +__init u32
30510 +rb_get_hw_options(void)
30512 + u16 tag_len;
30513 + u8 *tag;
30514 + int err;
30516 + err = rb_find_hard_cfg_tag(RB_ID_HW_OPTIONS, &tag, &tag_len);
30517 + if (err)
30518 + return 0;
30520 + return get_u32(tag);
30523 +static void * __init
30524 +__rb_get_wlan_data(u16 id)
30526 + u16 tag_len;
30527 + u8 *tag;
30528 + void *buf;
30529 + int err;
30530 + u32 magic;
30531 + size_t src_done;
30532 + size_t dst_done;
30534 + err = rb_find_hard_cfg_tag(RB_ID_WLAN_DATA, &tag, &tag_len);
30535 + if (err) {
30536 + pr_err("no calibration data found\n");
30537 + goto err;
30540 + buf = kmalloc(RB_ART_SIZE, GFP_KERNEL);
30541 + if (buf == NULL) {
30542 + pr_err("no memory for calibration data\n");
30543 + goto err;
30546 + magic = get_u32(tag);
30547 + if (magic == RB_MAGIC_ERD) {
30548 + u8 *erd_data;
30549 + u16 erd_len;
30551 + if (id == 0)
30552 + goto err_free;
30554 + err = routerboot_find_tag(tag, tag_len, id,
30555 + &erd_data, &erd_len);
30556 + if (err) {
30557 + pr_err("no ERD data found for id %u\n", id);
30558 + goto err_free;
30561 + dst_done = RB_ART_SIZE;
30562 + err = lzo1x_decompress_safe(erd_data, erd_len, buf, &dst_done);
30563 + if (err) {
30564 + pr_err("unable to decompress calibration data %d\n",
30565 + err);
30566 + goto err_free;
30568 + } else {
30569 + if (id != 0)
30570 + goto err_free;
30572 + err = rle_decode((char *) tag, tag_len, buf, RB_ART_SIZE,
30573 + &src_done, &dst_done);
30574 + if (err) {
30575 + pr_err("unable to decode calibration data\n");
30576 + goto err_free;
30580 + return buf;
30582 +err_free:
30583 + kfree(buf);
30584 +err:
30585 + return NULL;
30588 +__init void *
30589 +rb_get_wlan_data(void)
30591 + return __rb_get_wlan_data(0);
30594 +__init void *
30595 +rb_get_ext_wlan_data(u16 id)
30597 + return __rb_get_wlan_data(id);
30600 +__init const struct rb_info *
30601 +rb_init_info(void *data, unsigned int size)
30603 + unsigned int offset;
30605 + if (size == 0 || (size % RB_BLOCK_SIZE) != 0)
30606 + return NULL;
30608 + for (offset = 0; offset < size; offset += RB_BLOCK_SIZE) {
30609 + u32 magic;
30611 + magic = get_u32(data + offset);
30612 + switch (magic) {
30613 + case RB_MAGIC_HARD:
30614 + rb_info.hard_cfg_offs = offset;
30615 + break;
30617 + case RB_MAGIC_SOFT:
30618 + rb_info.soft_cfg_offs = offset;
30619 + break;
30623 + if (!rb_info.hard_cfg_offs) {
30624 + pr_err("could not find a valid RouterBOOT hard config\n");
30625 + return NULL;
30628 + if (!rb_info.soft_cfg_offs) {
30629 + pr_err("could not find a valid RouterBOOT soft config\n");
30630 + return NULL;
30633 + rb_info.hard_cfg_size = RB_BLOCK_SIZE;
30634 + rb_info.hard_cfg_data = kmemdup(data + rb_info.hard_cfg_offs,
30635 + RB_BLOCK_SIZE, GFP_KERNEL);
30636 + if (!rb_info.hard_cfg_data)
30637 + return NULL;
30639 + rb_info.board_name = rb_get_board_name();
30640 + rb_info.hw_options = rb_get_hw_options();
30642 + return &rb_info;
30645 +static char *rb_ext_wlan_data;
30647 +static ssize_t
30648 +rb_ext_wlan_data_read(struct file *filp, struct kobject *kobj,
30649 + struct bin_attribute *attr, char *buf,
30650 + loff_t off, size_t count)
30652 + if (off + count > attr->size)
30653 + return -EFBIG;
30655 + memcpy(buf, &rb_ext_wlan_data[off], count);
30657 + return count;
30660 +static const struct bin_attribute rb_ext_wlan_data_attr = {
30661 + .attr = {
30662 + .name = "ext_wlan_data",
30663 + .mode = S_IRUSR | S_IWUSR,
30664 + },
30665 + .read = rb_ext_wlan_data_read,
30666 + .size = RB_ART_SIZE,
30669 +static int __init rb_sysfs_init(void)
30671 + struct kobject *rb_kobj;
30672 + int ret;
30674 + rb_ext_wlan_data = rb_get_ext_wlan_data(1);
30675 + if (rb_ext_wlan_data == NULL)
30676 + return -ENOENT;
30678 + rb_kobj = kobject_create_and_add("routerboot", firmware_kobj);
30679 + if (rb_kobj == NULL) {
30680 + ret = -ENOMEM;
30681 + pr_err("unable to create sysfs entry\n");
30682 + goto err_free_wlan_data;
30685 + ret = sysfs_create_bin_file(rb_kobj, &rb_ext_wlan_data_attr);
30686 + if (ret) {
30687 + pr_err("unable to create sysfs file, %d\n", ret);
30688 + goto err_put_kobj;
30691 + return 0;
30693 +err_put_kobj:
30694 + kobject_put(rb_kobj);
30695 +err_free_wlan_data:
30696 + kfree(rb_ext_wlan_data);
30697 + return ret;
30700 +late_initcall(rb_sysfs_init);
30701 diff -Nur linux-4.1.43.orig/arch/mips/ath79/routerboot.h linux-4.1.43/arch/mips/ath79/routerboot.h
30702 --- linux-4.1.43.orig/arch/mips/ath79/routerboot.h 1970-01-01 01:00:00.000000000 +0100
30703 +++ linux-4.1.43/arch/mips/ath79/routerboot.h 2017-08-06 20:02:15.000000000 +0200
30704 @@ -0,0 +1,63 @@
30706 + * RouterBoot definitions
30708 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
30710 + * This program is free software; you can redistribute it and/or modify it
30711 + * under the terms of the GNU General Public License version 2 as published
30712 + * by the Free Software Foundation.
30713 + */
30715 +#ifndef _ATH79_ROUTERBOOT_H_
30716 +#define _ATH79_ROUTERBOOT_H_
30718 +struct rb_info {
30719 + unsigned int hard_cfg_offs;
30720 + unsigned int hard_cfg_size;
30721 + void *hard_cfg_data;
30722 + unsigned int soft_cfg_offs;
30724 + const char *board_name;
30725 + u32 hw_options;
30728 +#ifdef CONFIG_ATH79_ROUTERBOOT
30729 +const struct rb_info *rb_init_info(void *data, unsigned int size);
30730 +void *rb_get_wlan_data(void);
30731 +void *rb_get_ext_wlan_data(u16 id);
30733 +int routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
30734 + u8 **tag_data, u16 *tag_len);
30735 +int routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard);
30736 +#else
30737 +static inline const struct rb_info *
30738 +rb_init_info(void *data, unsigned int size)
30740 + return NULL;
30743 +static inline void *rb_get_wlan_data(void)
30745 + return NULL;
30748 +static inline void *rb_get_wlan_data(u16 id)
30750 + return NULL;
30753 +static inline int
30754 +routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
30755 + u8 **tag_data, u16 *tag_len)
30757 + return -ENOENT;
30760 +static inline int
30761 +routerboot_find_magic(u8 *buf, unsigned int buflen, u32 *offset, bool hard)
30763 + return -ENOENT;
30765 +#endif
30767 +#endif /* _ATH79_ROUTERBOOT_H_ */
30768 diff -Nur linux-4.1.43.orig/arch/mips/ath79/setup.c linux-4.1.43/arch/mips/ath79/setup.c
30769 --- linux-4.1.43.orig/arch/mips/ath79/setup.c 2017-08-06 01:56:14.000000000 +0200
30770 +++ linux-4.1.43/arch/mips/ath79/setup.c 2017-08-06 20:02:15.000000000 +0200
30771 @@ -40,6 +40,7 @@
30773 static void ath79_restart(char *command)
30775 + local_irq_disable();
30776 ath79_device_reset_set(AR71XX_RESET_FULL_CHIP);
30777 for (;;)
30778 if (cpu_wait)
30779 @@ -59,6 +60,7 @@
30780 u32 major;
30781 u32 minor;
30782 u32 rev = 0;
30783 + u32 ver = 1;
30785 id = ath79_reset_rr(AR71XX_RESET_REG_REV_ID);
30786 major = id & REV_ID_MAJOR_MASK;
30787 @@ -151,6 +153,17 @@
30788 rev = id & AR934X_REV_ID_REVISION_MASK;
30789 break;
30791 + case REV_ID_MAJOR_QCA9533_V2:
30792 + ver = 2;
30793 + ath79_soc_rev = 2;
30794 + /* drop through */
30796 + case REV_ID_MAJOR_QCA9533:
30797 + ath79_soc = ATH79_SOC_QCA9533;
30798 + chip = "9533";
30799 + rev = id & QCA953X_REV_ID_REVISION_MASK;
30800 + break;
30802 case REV_ID_MAJOR_QCA9556:
30803 ath79_soc = ATH79_SOC_QCA9556;
30804 chip = "9556";
30805 @@ -163,14 +176,30 @@
30806 rev = id & QCA955X_REV_ID_REVISION_MASK;
30807 break;
30809 + case REV_ID_MAJOR_TP9343:
30810 + ath79_soc = ATH79_SOC_TP9343;
30811 + chip = "9343";
30812 + rev = id & QCA956X_REV_ID_REVISION_MASK;
30813 + break;
30815 + case REV_ID_MAJOR_QCA9561:
30816 + ath79_soc = ATH79_SOC_QCA9561;
30817 + chip = "9561";
30818 + rev = id & QCA956X_REV_ID_REVISION_MASK;
30819 + break;
30821 default:
30822 panic("ath79: unknown SoC, id:0x%08x", id);
30825 - ath79_soc_rev = rev;
30826 + if (ver == 1)
30827 + ath79_soc_rev = rev;
30829 - if (soc_is_qca955x())
30830 - sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s rev %u",
30831 + if (soc_is_qca953x() || soc_is_qca955x() || soc_is_qca9561())
30832 + sprintf(ath79_sys_type, "Qualcomm Atheros QCA%s ver %u rev %u",
30833 + chip, ver, rev);
30834 + else if (soc_is_tp9343())
30835 + sprintf(ath79_sys_type, "Qualcomm Atheros TP%s rev %u",
30836 chip, rev);
30837 else
30838 sprintf(ath79_sys_type, "Atheros AR%s rev %u", chip, rev);
30839 @@ -235,6 +264,8 @@
30840 mips_hpt_frequency = cpu_clk_rate / 2;
30843 +__setup("board=", mips_machtype_setup);
30845 static int __init ath79_setup(void)
30847 ath79_gpio_init();
30848 diff -Nur linux-4.1.43.orig/arch/mips/fw/lib/cmdline.c linux-4.1.43/arch/mips/fw/lib/cmdline.c
30849 --- linux-4.1.43.orig/arch/mips/fw/lib/cmdline.c 2017-08-06 01:56:14.000000000 +0200
30850 +++ linux-4.1.43/arch/mips/fw/lib/cmdline.c 2017-08-06 20:02:15.000000000 +0200
30851 @@ -35,6 +35,7 @@
30852 else
30853 _fw_envp = (int *)fw_arg2;
30855 + arcs_cmdline[0] = '\0';
30856 for (i = 1; i < fw_argc; i++) {
30857 strlcat(arcs_cmdline, fw_argv(i), COMMAND_LINE_SIZE);
30858 if (i < (fw_argc - 1))
30859 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/checksum.h linux-4.1.43/arch/mips/include/asm/checksum.h
30860 --- linux-4.1.43.orig/arch/mips/include/asm/checksum.h 2017-08-06 01:56:14.000000000 +0200
30861 +++ linux-4.1.43/arch/mips/include/asm/checksum.h 2017-08-06 20:02:15.000000000 +0200
30862 @@ -134,26 +134,30 @@
30863 const unsigned int *stop = word + ihl;
30864 unsigned int csum;
30865 int carry;
30866 + unsigned int w;
30868 - csum = word[0];
30869 - csum += word[1];
30870 - carry = (csum < word[1]);
30871 + csum = net_hdr_word(word++);
30873 + w = net_hdr_word(word++);
30874 + csum += w;
30875 + carry = (csum < w);
30876 csum += carry;
30878 - csum += word[2];
30879 - carry = (csum < word[2]);
30880 + w = net_hdr_word(word++);
30881 + csum += w;
30882 + carry = (csum < w);
30883 csum += carry;
30885 - csum += word[3];
30886 - carry = (csum < word[3]);
30887 + w = net_hdr_word(word++);
30888 + csum += w;
30889 + carry = (csum < w);
30890 csum += carry;
30892 - word += 4;
30893 do {
30894 - csum += *word;
30895 - carry = (csum < *word);
30896 + w = net_hdr_word(word++);
30897 + csum += w;
30898 + carry = (csum < w);
30899 csum += carry;
30900 - word++;
30901 } while (word != stop);
30903 return csum_fold(csum);
30904 @@ -214,73 +218,6 @@
30905 return csum_fold(csum_partial(buff, len, 0));
30908 -#define _HAVE_ARCH_IPV6_CSUM
30909 -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
30910 - const struct in6_addr *daddr,
30911 - __u32 len, unsigned short proto,
30912 - __wsum sum)
30914 - __wsum tmp;
30916 - __asm__(
30917 - " .set push # csum_ipv6_magic\n"
30918 - " .set noreorder \n"
30919 - " .set noat \n"
30920 - " addu %0, %5 # proto (long in network byte order)\n"
30921 - " sltu $1, %0, %5 \n"
30922 - " addu %0, $1 \n"
30924 - " addu %0, %6 # csum\n"
30925 - " sltu $1, %0, %6 \n"
30926 - " lw %1, 0(%2) # four words source address\n"
30927 - " addu %0, $1 \n"
30928 - " addu %0, %1 \n"
30929 - " sltu $1, %0, %1 \n"
30931 - " lw %1, 4(%2) \n"
30932 - " addu %0, $1 \n"
30933 - " addu %0, %1 \n"
30934 - " sltu $1, %0, %1 \n"
30936 - " lw %1, 8(%2) \n"
30937 - " addu %0, $1 \n"
30938 - " addu %0, %1 \n"
30939 - " sltu $1, %0, %1 \n"
30941 - " lw %1, 12(%2) \n"
30942 - " addu %0, $1 \n"
30943 - " addu %0, %1 \n"
30944 - " sltu $1, %0, %1 \n"
30946 - " lw %1, 0(%3) \n"
30947 - " addu %0, $1 \n"
30948 - " addu %0, %1 \n"
30949 - " sltu $1, %0, %1 \n"
30951 - " lw %1, 4(%3) \n"
30952 - " addu %0, $1 \n"
30953 - " addu %0, %1 \n"
30954 - " sltu $1, %0, %1 \n"
30956 - " lw %1, 8(%3) \n"
30957 - " addu %0, $1 \n"
30958 - " addu %0, %1 \n"
30959 - " sltu $1, %0, %1 \n"
30961 - " lw %1, 12(%3) \n"
30962 - " addu %0, $1 \n"
30963 - " addu %0, %1 \n"
30964 - " sltu $1, %0, %1 \n"
30966 - " addu %0, $1 # Add final carry\n"
30967 - " .set pop"
30968 - : "=&r" (sum), "=&r" (tmp)
30969 - : "r" (saddr), "r" (daddr),
30970 - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
30972 - return csum_fold(sum);
30975 #include <asm-generic/checksum.h>
30976 #endif /* CONFIG_GENERIC_CSUM */
30978 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/fw/myloader/myloader.h linux-4.1.43/arch/mips/include/asm/fw/myloader/myloader.h
30979 --- linux-4.1.43.orig/arch/mips/include/asm/fw/myloader/myloader.h 1970-01-01 01:00:00.000000000 +0100
30980 +++ linux-4.1.43/arch/mips/include/asm/fw/myloader/myloader.h 2017-08-06 20:02:15.000000000 +0200
30981 @@ -0,0 +1,34 @@
30983 + * Compex's MyLoader specific definitions
30985 + * Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
30987 + * This program is free software; you can redistribute it and/or modify it
30988 + * under the terms of the GNU General Public License version 2 as published
30989 + * by the Free Software Foundation.
30991 + */
30993 +#ifndef _ASM_MIPS_FW_MYLOADER_H
30994 +#define _ASM_MIPS_FW_MYLOADER_H
30996 +#include <linux/myloader.h>
30998 +struct myloader_info {
30999 + uint32_t vid;
31000 + uint32_t did;
31001 + uint32_t svid;
31002 + uint32_t sdid;
31003 + uint8_t macs[MYLO_ETHADDR_COUNT][6];
31006 +#ifdef CONFIG_MYLOADER
31007 +extern struct myloader_info *myloader_get_info(void) __init;
31008 +#else
31009 +static inline struct myloader_info *myloader_get_info(void)
31011 + return NULL;
31013 +#endif /* CONFIG_MYLOADER */
31015 +#endif /* _ASM_MIPS_FW_MYLOADER_H */
31016 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ag71xx_platform.h linux-4.1.43/arch/mips/include/asm/mach-ath79/ag71xx_platform.h
31017 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ag71xx_platform.h 1970-01-01 01:00:00.000000000 +0100
31018 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/ag71xx_platform.h 2017-08-06 20:02:15.000000000 +0200
31019 @@ -0,0 +1,65 @@
31021 + * Atheros AR71xx SoC specific platform data definitions
31023 + * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
31024 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
31026 + * This program is free software; you can redistribute it and/or modify it
31027 + * under the terms of the GNU General Public License version 2 as published
31028 + * by the Free Software Foundation.
31029 + */
31031 +#ifndef __ASM_MACH_ATH79_PLATFORM_H
31032 +#define __ASM_MACH_ATH79_PLATFORM_H
31034 +#include <linux/if_ether.h>
31035 +#include <linux/skbuff.h>
31036 +#include <linux/phy.h>
31037 +#include <linux/spi/spi.h>
31039 +struct ag71xx_switch_platform_data {
31040 + u8 phy4_mii_en:1;
31041 + u8 phy_poll_mask;
31044 +struct ag71xx_platform_data {
31045 + phy_interface_t phy_if_mode;
31046 + u32 phy_mask;
31047 + int speed;
31048 + int duplex;
31049 + u32 reset_bit;
31050 + u8 mac_addr[ETH_ALEN];
31051 + struct device *mii_bus_dev;
31053 + u8 has_gbit:1;
31054 + u8 is_ar91xx:1;
31055 + u8 is_ar7240:1;
31056 + u8 is_ar724x:1;
31057 + u8 has_ar8216:1;
31059 + struct ag71xx_switch_platform_data *switch_data;
31061 + void (*ddr_flush)(void);
31062 + void (*set_speed)(int speed);
31064 + u32 fifo_cfg1;
31065 + u32 fifo_cfg2;
31066 + u32 fifo_cfg3;
31068 + unsigned int max_frame_len;
31069 + unsigned int desc_pktlen_mask;
31072 +struct ag71xx_mdio_platform_data {
31073 + u32 phy_mask;
31074 + u8 builtin_switch:1;
31075 + u8 is_ar7240:1;
31076 + u8 is_ar9330:1;
31077 + u8 is_ar934x:1;
31078 + unsigned long mdio_clock;
31079 + unsigned long ref_clock;
31081 + void (*reset)(struct mii_bus *bus);
31084 +#endif /* __ASM_MACH_ATH79_PLATFORM_H */
31085 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ar71xx_regs.h linux-4.1.43/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
31086 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ar71xx_regs.h 2017-08-06 01:56:14.000000000 +0200
31087 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/ar71xx_regs.h 2017-08-06 20:02:15.000000000 +0200
31088 @@ -20,6 +20,10 @@
31089 #include <linux/bitops.h>
31091 #define AR71XX_APB_BASE 0x18000000
31092 +#define AR71XX_GE0_BASE 0x19000000
31093 +#define AR71XX_GE0_SIZE 0x10000
31094 +#define AR71XX_GE1_BASE 0x1a000000
31095 +#define AR71XX_GE1_SIZE 0x10000
31096 #define AR71XX_EHCI_BASE 0x1b000000
31097 #define AR71XX_EHCI_SIZE 0x1000
31098 #define AR71XX_OHCI_BASE 0x1c000000
31099 @@ -39,6 +43,8 @@
31100 #define AR71XX_PLL_SIZE 0x100
31101 #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
31102 #define AR71XX_RESET_SIZE 0x100
31103 +#define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
31104 +#define AR71XX_MII_SIZE 0x100
31106 #define AR71XX_PCI_MEM_BASE 0x10000000
31107 #define AR71XX_PCI_MEM_SIZE 0x07000000
31108 @@ -81,18 +87,39 @@
31110 #define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
31111 #define AR933X_UART_SIZE 0x14
31112 +#define AR933X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
31113 +#define AR933X_GMAC_SIZE 0x04
31114 #define AR933X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
31115 #define AR933X_WMAC_SIZE 0x20000
31116 #define AR933X_EHCI_BASE 0x1b000000
31117 #define AR933X_EHCI_SIZE 0x1000
31119 +#define AR934X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
31120 +#define AR934X_GMAC_SIZE 0x14
31121 #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
31122 #define AR934X_WMAC_SIZE 0x20000
31123 #define AR934X_EHCI_BASE 0x1b000000
31124 #define AR934X_EHCI_SIZE 0x200
31125 +#define AR934X_NFC_BASE 0x1b000200
31126 +#define AR934X_NFC_SIZE 0xb8
31127 #define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
31128 #define AR934X_SRIF_SIZE 0x1000
31130 +#define QCA953X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
31131 +#define QCA953X_GMAC_SIZE 0x14
31132 +#define QCA953X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
31133 +#define QCA953X_WMAC_SIZE 0x20000
31134 +#define QCA953X_EHCI_BASE 0x1b000000
31135 +#define QCA953X_EHCI_SIZE 0x200
31136 +#define QCA953X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000)
31137 +#define QCA953X_SRIF_SIZE 0x1000
31139 +#define QCA953X_PCI_CFG_BASE0 0x14000000
31140 +#define QCA953X_PCI_CTRL_BASE0 (AR71XX_APB_BASE + 0x000f0000)
31141 +#define QCA953X_PCI_CRP_BASE0 (AR71XX_APB_BASE + 0x000c0000)
31142 +#define QCA953X_PCI_MEM_BASE0 0x10000000
31143 +#define QCA953X_PCI_MEM_SIZE 0x02000000
31145 #define QCA955X_PCI_MEM_BASE0 0x10000000
31146 #define QCA955X_PCI_MEM_BASE1 0x12000000
31147 #define QCA955X_PCI_MEM_SIZE 0x02000000
31148 @@ -106,11 +133,40 @@
31149 #define QCA955X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
31150 #define QCA955X_PCI_CTRL_SIZE 0x100
31152 +#define QCA955X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
31153 +#define QCA955X_GMAC_SIZE 0x40
31154 #define QCA955X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
31155 #define QCA955X_WMAC_SIZE 0x20000
31156 #define QCA955X_EHCI0_BASE 0x1b000000
31157 #define QCA955X_EHCI1_BASE 0x1b400000
31158 #define QCA955X_EHCI_SIZE 0x1000
31159 +#define QCA955X_NFC_BASE 0x1b800200
31160 +#define QCA955X_NFC_SIZE 0xb8
31162 +#define QCA956X_PCI_MEM_BASE1 0x12000000
31163 +#define QCA956X_PCI_MEM_SIZE 0x02000000
31164 +#define QCA956X_PCI_CFG_BASE1 0x16000000
31165 +#define QCA956X_PCI_CFG_SIZE 0x1000
31166 +#define QCA956X_PCI_CRP_BASE1 (AR71XX_APB_BASE + 0x00250000)
31167 +#define QCA956X_PCI_CRP_SIZE 0x1000
31168 +#define QCA956X_PCI_CTRL_BASE1 (AR71XX_APB_BASE + 0x00280000)
31169 +#define QCA956X_PCI_CTRL_SIZE 0x100
31171 +#define QCA956X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
31172 +#define QCA956X_WMAC_SIZE 0x20000
31173 +#define QCA956X_EHCI0_BASE 0x1b000000
31174 +#define QCA956X_EHCI1_BASE 0x1b400000
31175 +#define QCA956X_EHCI_SIZE 0x200
31176 +#define QCA956X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
31177 +#define QCA956X_GMAC_SIZE 0x64
31179 +#define AR9300_OTP_BASE 0x14000
31180 +#define AR9300_OTP_STATUS 0x15f18
31181 +#define AR9300_OTP_STATUS_TYPE 0x7
31182 +#define AR9300_OTP_STATUS_VALID 0x4
31183 +#define AR9300_OTP_STATUS_ACCESS_BUSY 0x2
31184 +#define AR9300_OTP_STATUS_SM_BUSY 0x1
31185 +#define AR9300_OTP_READ_DATA 0x15f1c
31188 * DDR_CTRL block
31189 @@ -149,6 +205,12 @@
31190 #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
31191 #define AR934X_DDR_REG_FLUSH_WMAC 0xac
31193 +#define QCA953X_DDR_REG_FLUSH_GE0 0x9c
31194 +#define QCA953X_DDR_REG_FLUSH_GE1 0xa0
31195 +#define QCA953X_DDR_REG_FLUSH_USB 0xa4
31196 +#define QCA953X_DDR_REG_FLUSH_PCIE 0xa8
31197 +#define QCA953X_DDR_REG_FLUSH_WMAC 0xac
31200 * PLL block
31202 @@ -166,6 +228,9 @@
31203 #define AR71XX_AHB_DIV_SHIFT 20
31204 #define AR71XX_AHB_DIV_MASK 0x7
31206 +#define AR71XX_ETH0_PLL_SHIFT 17
31207 +#define AR71XX_ETH1_PLL_SHIFT 19
31209 #define AR724X_PLL_REG_CPU_CONFIG 0x00
31210 #define AR724X_PLL_REG_PCIE_CONFIG 0x18
31212 @@ -178,6 +243,8 @@
31213 #define AR724X_DDR_DIV_SHIFT 22
31214 #define AR724X_DDR_DIV_MASK 0x3
31216 +#define AR7242_PLL_REG_ETH0_INT_CLOCK 0x2c
31218 #define AR913X_PLL_REG_CPU_CONFIG 0x00
31219 #define AR913X_PLL_REG_ETH_CONFIG 0x04
31220 #define AR913X_PLL_REG_ETH0_INT_CLOCK 0x14
31221 @@ -190,6 +257,9 @@
31222 #define AR913X_AHB_DIV_SHIFT 19
31223 #define AR913X_AHB_DIV_MASK 0x1
31225 +#define AR913X_ETH0_PLL_SHIFT 20
31226 +#define AR913X_ETH1_PLL_SHIFT 22
31228 #define AR933X_PLL_CPU_CONFIG_REG 0x00
31229 #define AR933X_PLL_CLOCK_CTRL_REG 0x08
31231 @@ -211,6 +281,8 @@
31232 #define AR934X_PLL_CPU_CONFIG_REG 0x00
31233 #define AR934X_PLL_DDR_CONFIG_REG 0x04
31234 #define AR934X_PLL_CPU_DDR_CLK_CTRL_REG 0x08
31235 +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
31236 +#define AR934X_PLL_ETH_XMII_CONTROL_REG 0x2c
31238 #define AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
31239 #define AR934X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
31240 @@ -243,9 +315,51 @@
31241 #define AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
31242 #define AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
31244 +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL BIT(6)
31246 +#define QCA953X_PLL_CPU_CONFIG_REG 0x00
31247 +#define QCA953X_PLL_DDR_CONFIG_REG 0x04
31248 +#define QCA953X_PLL_CLK_CTRL_REG 0x08
31249 +#define QCA953X_PLL_SWITCH_CLOCK_CONTROL_REG 0x24
31250 +#define QCA953X_PLL_ETH_XMII_CONTROL_REG 0x2c
31251 +#define QCA953X_PLL_ETH_SGMII_CONTROL_REG 0x48
31253 +#define QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
31254 +#define QCA953X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
31255 +#define QCA953X_PLL_CPU_CONFIG_NINT_SHIFT 6
31256 +#define QCA953X_PLL_CPU_CONFIG_NINT_MASK 0x3f
31257 +#define QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
31258 +#define QCA953X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
31259 +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
31260 +#define QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
31262 +#define QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT 0
31263 +#define QCA953X_PLL_DDR_CONFIG_NFRAC_MASK 0x3ff
31264 +#define QCA953X_PLL_DDR_CONFIG_NINT_SHIFT 10
31265 +#define QCA953X_PLL_DDR_CONFIG_NINT_MASK 0x3f
31266 +#define QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
31267 +#define QCA953X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
31268 +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
31269 +#define QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
31271 +#define QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
31272 +#define QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
31273 +#define QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
31274 +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
31275 +#define QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
31276 +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
31277 +#define QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
31278 +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
31279 +#define QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
31280 +#define QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
31281 +#define QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
31282 +#define QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
31284 #define QCA955X_PLL_CPU_CONFIG_REG 0x00
31285 #define QCA955X_PLL_DDR_CONFIG_REG 0x04
31286 #define QCA955X_PLL_CLK_CTRL_REG 0x08
31287 +#define QCA955X_PLL_ETH_XMII_CONTROL_REG 0x28
31288 +#define QCA955X_PLL_ETH_SGMII_CONTROL_REG 0x48
31290 #define QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT 0
31291 #define QCA955X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f
31292 @@ -278,6 +392,49 @@
31293 #define QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
31294 #define QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
31296 +#define QCA956X_PLL_CPU_CONFIG_REG 0x00
31297 +#define QCA956X_PLL_CPU_CONFIG1_REG 0x04
31298 +#define QCA956X_PLL_DDR_CONFIG_REG 0x08
31299 +#define QCA956X_PLL_DDR_CONFIG1_REG 0x0c
31300 +#define QCA956X_PLL_CLK_CTRL_REG 0x10
31302 +#define QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT 12
31303 +#define QCA956X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
31304 +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT 19
31305 +#define QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
31307 +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT 0
31308 +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK 0x1f
31309 +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT 5
31310 +#define QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK 0x1fff
31311 +#define QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT 18
31312 +#define QCA956X_PLL_CPU_CONFIG1_NINT_MASK 0x1ff
31314 +#define QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT 16
31315 +#define QCA956X_PLL_DDR_CONFIG_REFDIV_MASK 0x1f
31316 +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT 23
31317 +#define QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK 0x7
31319 +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT 0
31320 +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK 0x1f
31321 +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT 5
31322 +#define QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK 0x1fff
31323 +#define QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT 18
31324 +#define QCA956X_PLL_DDR_CONFIG1_NINT_MASK 0x1ff
31326 +#define QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
31327 +#define QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
31328 +#define QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
31329 +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT 5
31330 +#define QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK 0x1f
31331 +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT 10
31332 +#define QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK 0x1f
31333 +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT 15
31334 +#define QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK 0x1f
31335 +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL BIT(20)
31336 +#define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL BIT(21)
31337 +#define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
31340 * USB_CONFIG block
31342 @@ -317,10 +474,19 @@
31343 #define AR934X_RESET_REG_BOOTSTRAP 0xb0
31344 #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
31346 +#define QCA953X_RESET_REG_RESET_MODULE 0x1c
31347 +#define QCA953X_RESET_REG_BOOTSTRAP 0xb0
31348 +#define QCA953X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
31350 #define QCA955X_RESET_REG_RESET_MODULE 0x1c
31351 #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
31352 #define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
31354 +#define QCA956X_RESET_REG_RESET_MODULE 0x1c
31355 +#define QCA956X_RESET_REG_BOOTSTRAP 0xb0
31356 +#define QCA956X_RESET_REG_EXT_INT_STATUS 0xac
31358 +#define MISC_INT_MIPS_SI_TIMERINT_MASK BIT(28)
31359 #define MISC_INT_ETHSW BIT(12)
31360 #define MISC_INT_TIMER4 BIT(10)
31361 #define MISC_INT_TIMER3 BIT(9)
31362 @@ -370,16 +536,104 @@
31363 #define AR913X_RESET_USB_HOST BIT(5)
31364 #define AR913X_RESET_USB_PHY BIT(4)
31366 +#define AR933X_RESET_GE1_MDIO BIT(23)
31367 +#define AR933X_RESET_GE0_MDIO BIT(22)
31368 +#define AR933X_RESET_GE1_MAC BIT(13)
31369 #define AR933X_RESET_WMAC BIT(11)
31370 +#define AR933X_RESET_GE0_MAC BIT(9)
31371 #define AR933X_RESET_USB_HOST BIT(5)
31372 #define AR933X_RESET_USB_PHY BIT(4)
31373 #define AR933X_RESET_USBSUS_OVERRIDE BIT(3)
31375 +#define AR934X_RESET_HOST BIT(31)
31376 +#define AR934X_RESET_SLIC BIT(30)
31377 +#define AR934X_RESET_HDMA BIT(29)
31378 +#define AR934X_RESET_EXTERNAL BIT(28)
31379 +#define AR934X_RESET_RTC BIT(27)
31380 +#define AR934X_RESET_PCIE_EP_INT BIT(26)
31381 +#define AR934X_RESET_CHKSUM_ACC BIT(25)
31382 +#define AR934X_RESET_FULL_CHIP BIT(24)
31383 +#define AR934X_RESET_GE1_MDIO BIT(23)
31384 +#define AR934X_RESET_GE0_MDIO BIT(22)
31385 +#define AR934X_RESET_CPU_NMI BIT(21)
31386 +#define AR934X_RESET_CPU_COLD BIT(20)
31387 +#define AR934X_RESET_HOST_RESET_INT BIT(19)
31388 +#define AR934X_RESET_PCIE_EP BIT(18)
31389 +#define AR934X_RESET_UART1 BIT(17)
31390 +#define AR934X_RESET_DDR BIT(16)
31391 +#define AR934X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
31392 +#define AR934X_RESET_NANDF BIT(14)
31393 +#define AR934X_RESET_GE1_MAC BIT(13)
31394 +#define AR934X_RESET_ETH_SWITCH_ANALOG BIT(12)
31395 #define AR934X_RESET_USB_PHY_ANALOG BIT(11)
31396 +#define AR934X_RESET_HOST_DMA_INT BIT(10)
31397 +#define AR934X_RESET_GE0_MAC BIT(9)
31398 +#define AR934X_RESET_ETH_SWITCH BIT(8)
31399 +#define AR934X_RESET_PCIE_PHY BIT(7)
31400 +#define AR934X_RESET_PCIE BIT(6)
31401 #define AR934X_RESET_USB_HOST BIT(5)
31402 #define AR934X_RESET_USB_PHY BIT(4)
31403 #define AR934X_RESET_USBSUS_OVERRIDE BIT(3)
31404 +#define AR934X_RESET_LUT BIT(2)
31405 +#define AR934X_RESET_MBOX BIT(1)
31406 +#define AR934X_RESET_I2S BIT(0)
31408 +#define QCA953X_RESET_USB_EXT_PWR BIT(29)
31409 +#define QCA953X_RESET_EXTERNAL BIT(28)
31410 +#define QCA953X_RESET_RTC BIT(27)
31411 +#define QCA953X_RESET_FULL_CHIP BIT(24)
31412 +#define QCA953X_RESET_GE1_MDIO BIT(23)
31413 +#define QCA953X_RESET_GE0_MDIO BIT(22)
31414 +#define QCA953X_RESET_CPU_NMI BIT(21)
31415 +#define QCA953X_RESET_CPU_COLD BIT(20)
31416 +#define QCA953X_RESET_DDR BIT(16)
31417 +#define QCA953X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
31418 +#define QCA953X_RESET_GE1_MAC BIT(13)
31419 +#define QCA953X_RESET_ETH_SWITCH_ANALOG BIT(12)
31420 +#define QCA953X_RESET_USB_PHY_ANALOG BIT(11)
31421 +#define QCA953X_RESET_GE0_MAC BIT(9)
31422 +#define QCA953X_RESET_ETH_SWITCH BIT(8)
31423 +#define QCA953X_RESET_PCIE_PHY BIT(7)
31424 +#define QCA953X_RESET_PCIE BIT(6)
31425 +#define QCA953X_RESET_USB_HOST BIT(5)
31426 +#define QCA953X_RESET_USB_PHY BIT(4)
31427 +#define QCA953X_RESET_USBSUS_OVERRIDE BIT(3)
31429 +#define QCA955X_RESET_HOST BIT(31)
31430 +#define QCA955X_RESET_SLIC BIT(30)
31431 +#define QCA955X_RESET_HDMA BIT(29)
31432 +#define QCA955X_RESET_EXTERNAL BIT(28)
31433 +#define QCA955X_RESET_RTC BIT(27)
31434 +#define QCA955X_RESET_PCIE_EP_INT BIT(26)
31435 +#define QCA955X_RESET_CHKSUM_ACC BIT(25)
31436 +#define QCA955X_RESET_FULL_CHIP BIT(24)
31437 +#define QCA955X_RESET_GE1_MDIO BIT(23)
31438 +#define QCA955X_RESET_GE0_MDIO BIT(22)
31439 +#define QCA955X_RESET_CPU_NMI BIT(21)
31440 +#define QCA955X_RESET_CPU_COLD BIT(20)
31441 +#define QCA955X_RESET_HOST_RESET_INT BIT(19)
31442 +#define QCA955X_RESET_PCIE_EP BIT(18)
31443 +#define QCA955X_RESET_UART1 BIT(17)
31444 +#define QCA955X_RESET_DDR BIT(16)
31445 +#define QCA955X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
31446 +#define QCA955X_RESET_NANDF BIT(14)
31447 +#define QCA955X_RESET_GE1_MAC BIT(13)
31448 +#define QCA955X_RESET_SGMII_ANALOG BIT(12)
31449 +#define QCA955X_RESET_USB_PHY_ANALOG BIT(11)
31450 +#define QCA955X_RESET_HOST_DMA_INT BIT(10)
31451 +#define QCA955X_RESET_GE0_MAC BIT(9)
31452 +#define QCA955X_RESET_SGMII BIT(8)
31453 +#define QCA955X_RESET_PCIE_PHY BIT(7)
31454 +#define QCA955X_RESET_PCIE BIT(6)
31455 +#define QCA955X_RESET_USB_HOST BIT(5)
31456 +#define QCA955X_RESET_USB_PHY BIT(4)
31457 +#define QCA955X_RESET_USBSUS_OVERRIDE BIT(3)
31458 +#define QCA955X_RESET_LUT BIT(2)
31459 +#define QCA955X_RESET_MBOX BIT(1)
31460 +#define QCA955X_RESET_I2S BIT(0)
31462 +#define AR933X_BOOTSTRAP_MDIO_GPIO_EN BIT(18)
31463 +#define AR933X_BOOTSTRAP_EEPBUSY BIT(4)
31464 #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
31466 #define AR934X_BOOTSTRAP_SW_OPTION8 BIT(23)
31467 @@ -398,8 +652,17 @@
31468 #define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
31469 #define AR934X_BOOTSTRAP_DDR1 BIT(0)
31471 +#define QCA953X_BOOTSTRAP_SW_OPTION2 BIT(12)
31472 +#define QCA953X_BOOTSTRAP_SW_OPTION1 BIT(11)
31473 +#define QCA953X_BOOTSTRAP_EJTAG_MODE BIT(5)
31474 +#define QCA953X_BOOTSTRAP_REF_CLK_40 BIT(4)
31475 +#define QCA953X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
31476 +#define QCA953X_BOOTSTRAP_DDR1 BIT(0)
31478 #define QCA955X_BOOTSTRAP_REF_CLK_40 BIT(4)
31480 +#define QCA956X_BOOTSTRAP_REF_CLK_40 BIT(2)
31482 #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
31483 #define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
31484 #define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
31485 @@ -418,6 +681,24 @@
31486 AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
31487 AR934X_PCIE_WMAC_INT_PCIE_RC3)
31489 +#define QCA953X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
31490 +#define QCA953X_PCIE_WMAC_INT_WMAC_TX BIT(1)
31491 +#define QCA953X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
31492 +#define QCA953X_PCIE_WMAC_INT_WMAC_RXHP BIT(3)
31493 +#define QCA953X_PCIE_WMAC_INT_PCIE_RC BIT(4)
31494 +#define QCA953X_PCIE_WMAC_INT_PCIE_RC0 BIT(5)
31495 +#define QCA953X_PCIE_WMAC_INT_PCIE_RC1 BIT(6)
31496 +#define QCA953X_PCIE_WMAC_INT_PCIE_RC2 BIT(7)
31497 +#define QCA953X_PCIE_WMAC_INT_PCIE_RC3 BIT(8)
31498 +#define QCA953X_PCIE_WMAC_INT_WMAC_ALL \
31499 + (QCA953X_PCIE_WMAC_INT_WMAC_MISC | QCA953X_PCIE_WMAC_INT_WMAC_TX | \
31500 + QCA953X_PCIE_WMAC_INT_WMAC_RXLP | QCA953X_PCIE_WMAC_INT_WMAC_RXHP)
31502 +#define QCA953X_PCIE_WMAC_INT_PCIE_ALL \
31503 + (QCA953X_PCIE_WMAC_INT_PCIE_RC | QCA953X_PCIE_WMAC_INT_PCIE_RC0 | \
31504 + QCA953X_PCIE_WMAC_INT_PCIE_RC1 | QCA953X_PCIE_WMAC_INT_PCIE_RC2 | \
31505 + QCA953X_PCIE_WMAC_INT_PCIE_RC3)
31507 #define QCA955X_EXT_INT_WMAC_MISC BIT(0)
31508 #define QCA955X_EXT_INT_WMAC_TX BIT(1)
31509 #define QCA955X_EXT_INT_WMAC_RXLP BIT(2)
31510 @@ -449,6 +730,37 @@
31511 QCA955X_EXT_INT_PCIE_RC2_INT1 | QCA955X_EXT_INT_PCIE_RC2_INT2 | \
31512 QCA955X_EXT_INT_PCIE_RC2_INT3)
31514 +#define QCA956X_EXT_INT_WMAC_MISC BIT(0)
31515 +#define QCA956X_EXT_INT_WMAC_TX BIT(1)
31516 +#define QCA956X_EXT_INT_WMAC_RXLP BIT(2)
31517 +#define QCA956X_EXT_INT_WMAC_RXHP BIT(3)
31518 +#define QCA956X_EXT_INT_PCIE_RC1 BIT(4)
31519 +#define QCA956X_EXT_INT_PCIE_RC1_INT0 BIT(5)
31520 +#define QCA956X_EXT_INT_PCIE_RC1_INT1 BIT(6)
31521 +#define QCA956X_EXT_INT_PCIE_RC1_INT2 BIT(7)
31522 +#define QCA956X_EXT_INT_PCIE_RC1_INT3 BIT(8)
31523 +#define QCA956X_EXT_INT_PCIE_RC2 BIT(12)
31524 +#define QCA956X_EXT_INT_PCIE_RC2_INT0 BIT(13)
31525 +#define QCA956X_EXT_INT_PCIE_RC2_INT1 BIT(14)
31526 +#define QCA956X_EXT_INT_PCIE_RC2_INT2 BIT(15)
31527 +#define QCA956X_EXT_INT_PCIE_RC2_INT3 BIT(16)
31528 +#define QCA956X_EXT_INT_USB1 BIT(24)
31529 +#define QCA956X_EXT_INT_USB2 BIT(28)
31531 +#define QCA956X_EXT_INT_WMAC_ALL \
31532 + (QCA956X_EXT_INT_WMAC_MISC | QCA956X_EXT_INT_WMAC_TX | \
31533 + QCA956X_EXT_INT_WMAC_RXLP | QCA956X_EXT_INT_WMAC_RXHP)
31535 +#define QCA956X_EXT_INT_PCIE_RC1_ALL \
31536 + (QCA956X_EXT_INT_PCIE_RC1 | QCA956X_EXT_INT_PCIE_RC1_INT0 | \
31537 + QCA956X_EXT_INT_PCIE_RC1_INT1 | QCA956X_EXT_INT_PCIE_RC1_INT2 | \
31538 + QCA956X_EXT_INT_PCIE_RC1_INT3)
31540 +#define QCA956X_EXT_INT_PCIE_RC2_ALL \
31541 + (QCA956X_EXT_INT_PCIE_RC2 | QCA956X_EXT_INT_PCIE_RC2_INT0 | \
31542 + QCA956X_EXT_INT_PCIE_RC2_INT1 | QCA956X_EXT_INT_PCIE_RC2_INT2 | \
31543 + QCA956X_EXT_INT_PCIE_RC2_INT3)
31545 #define REV_ID_MAJOR_MASK 0xfff0
31546 #define REV_ID_MAJOR_AR71XX 0x00a0
31547 #define REV_ID_MAJOR_AR913X 0x00b0
31548 @@ -460,8 +772,12 @@
31549 #define REV_ID_MAJOR_AR9341 0x0120
31550 #define REV_ID_MAJOR_AR9342 0x1120
31551 #define REV_ID_MAJOR_AR9344 0x2120
31552 +#define REV_ID_MAJOR_QCA9533 0x0140
31553 +#define REV_ID_MAJOR_QCA9533_V2 0x0160
31554 #define REV_ID_MAJOR_QCA9556 0x0130
31555 #define REV_ID_MAJOR_QCA9558 0x1130
31556 +#define REV_ID_MAJOR_TP9343 0x0150
31557 +#define REV_ID_MAJOR_QCA9561 0x1150
31559 #define AR71XX_REV_ID_MINOR_MASK 0x3
31560 #define AR71XX_REV_ID_MINOR_AR7130 0x0
31561 @@ -482,8 +798,12 @@
31563 #define AR934X_REV_ID_REVISION_MASK 0xf
31565 +#define QCA953X_REV_ID_REVISION_MASK 0xf
31567 #define QCA955X_REV_ID_REVISION_MASK 0xf
31569 +#define QCA956X_REV_ID_REVISION_MASK 0xf
31572 * SPI block
31574 @@ -520,16 +840,65 @@
31575 #define AR71XX_GPIO_REG_INT_PENDING 0x20
31576 #define AR71XX_GPIO_REG_INT_ENABLE 0x24
31577 #define AR71XX_GPIO_REG_FUNC 0x28
31578 +#define AR71XX_GPIO_REG_FUNC_2 0x30
31580 +#define AR934X_GPIO_REG_OUT_FUNC0 0x2c
31581 +#define AR934X_GPIO_REG_OUT_FUNC1 0x30
31582 +#define AR934X_GPIO_REG_OUT_FUNC2 0x34
31583 +#define AR934X_GPIO_REG_OUT_FUNC3 0x38
31584 +#define AR934X_GPIO_REG_OUT_FUNC4 0x3c
31585 +#define AR934X_GPIO_REG_OUT_FUNC5 0x40
31586 #define AR934X_GPIO_REG_FUNC 0x6c
31588 +#define QCA953X_GPIO_REG_OUT_FUNC0 0x2c
31589 +#define QCA953X_GPIO_REG_OUT_FUNC1 0x30
31590 +#define QCA953X_GPIO_REG_OUT_FUNC2 0x34
31591 +#define QCA953X_GPIO_REG_OUT_FUNC3 0x38
31592 +#define QCA953X_GPIO_REG_OUT_FUNC4 0x3c
31593 +#define QCA953X_GPIO_REG_IN_ENABLE0 0x44
31594 +#define QCA953X_GPIO_REG_FUNC 0x6c
31596 +#define QCA953X_GPIO_OUT_MUX_SPI_CS1 10
31597 +#define QCA953X_GPIO_OUT_MUX_SPI_CS2 11
31598 +#define QCA953X_GPIO_OUT_MUX_SPI_CS0 9
31599 +#define QCA953X_GPIO_OUT_MUX_SPI_CLK 8
31600 +#define QCA953X_GPIO_OUT_MUX_SPI_MOSI 12
31601 +#define QCA953X_GPIO_OUT_MUX_LED_LINK1 41
31602 +#define QCA953X_GPIO_OUT_MUX_LED_LINK2 42
31603 +#define QCA953X_GPIO_OUT_MUX_LED_LINK3 43
31604 +#define QCA953X_GPIO_OUT_MUX_LED_LINK4 44
31605 +#define QCA953X_GPIO_OUT_MUX_LED_LINK5 45
31607 +#define QCA955X_GPIO_REG_OUT_FUNC0 0x2c
31608 +#define QCA955X_GPIO_REG_OUT_FUNC1 0x30
31609 +#define QCA955X_GPIO_REG_OUT_FUNC2 0x34
31610 +#define QCA955X_GPIO_REG_OUT_FUNC3 0x38
31611 +#define QCA955X_GPIO_REG_OUT_FUNC4 0x3c
31612 +#define QCA955X_GPIO_REG_OUT_FUNC5 0x40
31613 +#define QCA955X_GPIO_REG_FUNC 0x6c
31615 +#define QCA956X_GPIO_REG_OUT_FUNC0 0x2c
31616 +#define QCA956X_GPIO_REG_OUT_FUNC1 0x30
31617 +#define QCA956X_GPIO_REG_OUT_FUNC2 0x34
31618 +#define QCA956X_GPIO_REG_OUT_FUNC3 0x38
31619 +#define QCA956X_GPIO_REG_OUT_FUNC4 0x3c
31620 +#define QCA956X_GPIO_REG_OUT_FUNC5 0x40
31621 +#define QCA956X_GPIO_REG_IN_ENABLE0 0x44
31622 +#define QCA956X_GPIO_REG_IN_ENABLE3 0x50
31623 +#define QCA956X_GPIO_REG_FUNC 0x6c
31625 +#define QCA956X_GPIO_OUT_MUX_GE0_MDO 32
31626 +#define QCA956X_GPIO_OUT_MUX_GE0_MDC 33
31628 #define AR71XX_GPIO_COUNT 16
31629 #define AR7240_GPIO_COUNT 18
31630 #define AR7241_GPIO_COUNT 20
31631 #define AR913X_GPIO_COUNT 22
31632 #define AR933X_GPIO_COUNT 30
31633 #define AR934X_GPIO_COUNT 23
31634 +#define QCA953X_GPIO_COUNT 18
31635 #define QCA955X_GPIO_COUNT 24
31636 +#define QCA956X_GPIO_COUNT 23
31639 * SRIF block
31640 @@ -552,4 +921,185 @@
31641 #define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
31642 #define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
31644 +#define QCA953X_SRIF_CPU_DPLL1_REG 0x1c0
31645 +#define QCA953X_SRIF_CPU_DPLL2_REG 0x1c4
31646 +#define QCA953X_SRIF_CPU_DPLL3_REG 0x1c8
31648 +#define QCA953X_SRIF_DDR_DPLL1_REG 0x240
31649 +#define QCA953X_SRIF_DDR_DPLL2_REG 0x244
31650 +#define QCA953X_SRIF_DDR_DPLL3_REG 0x248
31652 +#define QCA953X_SRIF_DPLL1_REFDIV_SHIFT 27
31653 +#define QCA953X_SRIF_DPLL1_REFDIV_MASK 0x1f
31654 +#define QCA953X_SRIF_DPLL1_NINT_SHIFT 18
31655 +#define QCA953X_SRIF_DPLL1_NINT_MASK 0x1ff
31656 +#define QCA953X_SRIF_DPLL1_NFRAC_MASK 0x0003ffff
31658 +#define QCA953X_SRIF_DPLL2_LOCAL_PLL BIT(30)
31659 +#define QCA953X_SRIF_DPLL2_OUTDIV_SHIFT 13
31660 +#define QCA953X_SRIF_DPLL2_OUTDIV_MASK 0x7
31662 +#define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
31663 +#define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
31664 +#define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
31665 +#define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
31666 +#define AR71XX_GPIO_FUNC_UART_EN BIT(8)
31667 +#define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
31668 +#define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
31670 +#define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
31671 +#define AR724X_GPIO_FUNC_SPI_EN BIT(18)
31672 +#define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
31673 +#define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
31674 +#define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
31675 +#define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
31676 +#define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
31677 +#define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
31678 +#define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
31679 +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
31680 +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
31681 +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
31682 +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
31683 +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
31684 +#define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
31685 +#define AR724X_GPIO_FUNC_UART_EN BIT(1)
31686 +#define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
31688 +#define AR933X_GPIO_FUNC2_JUMPSTART_DISABLE BIT(9)
31690 +#define AR913X_GPIO_FUNC_WMAC_LED_EN BIT(22)
31691 +#define AR913X_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
31692 +#define AR913X_GPIO_FUNC_I2S_REFCLKEN BIT(20)
31693 +#define AR913X_GPIO_FUNC_I2S_MCKEN BIT(19)
31694 +#define AR913X_GPIO_FUNC_I2S1_EN BIT(18)
31695 +#define AR913X_GPIO_FUNC_I2S0_EN BIT(17)
31696 +#define AR913X_GPIO_FUNC_SLIC_EN BIT(16)
31697 +#define AR913X_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
31698 +#define AR913X_GPIO_FUNC_UART_EN BIT(8)
31699 +#define AR913X_GPIO_FUNC_USB_CLK_EN BIT(4)
31701 +#define AR933X_GPIO_FUNC_SPDIF2TCK BIT(31)
31702 +#define AR933X_GPIO_FUNC_SPDIF_EN BIT(30)
31703 +#define AR933X_GPIO_FUNC_I2SO_22_18_EN BIT(29)
31704 +#define AR933X_GPIO_FUNC_I2S_MCK_EN BIT(27)
31705 +#define AR933X_GPIO_FUNC_I2SO_EN BIT(26)
31706 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_DUPL BIT(25)
31707 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_COLL BIT(24)
31708 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED_ACT BIT(23)
31709 +#define AR933X_GPIO_FUNC_SPI_EN BIT(18)
31710 +#define AR933X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
31711 +#define AR933X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
31712 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
31713 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
31714 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
31715 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
31716 +#define AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
31717 +#define AR933X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
31718 +#define AR933X_GPIO_FUNC_UART_EN BIT(1)
31719 +#define AR933X_GPIO_FUNC_JTAG_DISABLE BIT(0)
31721 +#define AR934X_GPIO_FUNC_CLK_OBS7_EN BIT(9)
31722 +#define AR934X_GPIO_FUNC_CLK_OBS6_EN BIT(8)
31723 +#define AR934X_GPIO_FUNC_CLK_OBS5_EN BIT(7)
31724 +#define AR934X_GPIO_FUNC_CLK_OBS4_EN BIT(6)
31725 +#define AR934X_GPIO_FUNC_CLK_OBS3_EN BIT(5)
31726 +#define AR934X_GPIO_FUNC_CLK_OBS2_EN BIT(4)
31727 +#define AR934X_GPIO_FUNC_CLK_OBS1_EN BIT(3)
31728 +#define AR934X_GPIO_FUNC_CLK_OBS0_EN BIT(2)
31729 +#define AR934X_GPIO_FUNC_JTAG_DISABLE BIT(1)
31731 +#define AR934X_GPIO_OUT_GPIO 0
31732 +#define AR934X_GPIO_OUT_SPI_CS1 7
31733 +#define AR934X_GPIO_OUT_LED_LINK0 41
31734 +#define AR934X_GPIO_OUT_LED_LINK1 42
31735 +#define AR934X_GPIO_OUT_LED_LINK2 43
31736 +#define AR934X_GPIO_OUT_LED_LINK3 44
31737 +#define AR934X_GPIO_OUT_LED_LINK4 45
31738 +#define AR934X_GPIO_OUT_EXT_LNA0 46
31739 +#define AR934X_GPIO_OUT_EXT_LNA1 47
31741 +#define QCA955X_GPIO_OUT_GPIO 0
31744 + * MII_CTRL block
31745 + */
31746 +#define AR71XX_MII_REG_MII0_CTRL 0x00
31747 +#define AR71XX_MII_REG_MII1_CTRL 0x04
31749 +#define AR71XX_MII_CTRL_IF_MASK 3
31750 +#define AR71XX_MII_CTRL_SPEED_SHIFT 4
31751 +#define AR71XX_MII_CTRL_SPEED_MASK 3
31752 +#define AR71XX_MII_CTRL_SPEED_10 0
31753 +#define AR71XX_MII_CTRL_SPEED_100 1
31754 +#define AR71XX_MII_CTRL_SPEED_1000 2
31756 +#define AR71XX_MII0_CTRL_IF_GMII 0
31757 +#define AR71XX_MII0_CTRL_IF_MII 1
31758 +#define AR71XX_MII0_CTRL_IF_RGMII 2
31759 +#define AR71XX_MII0_CTRL_IF_RMII 3
31761 +#define AR71XX_MII1_CTRL_IF_RGMII 0
31762 +#define AR71XX_MII1_CTRL_IF_RMII 1
31765 + * AR933X GMAC interface
31766 + */
31767 +#define AR933X_GMAC_REG_ETH_CFG 0x00
31769 +#define AR933X_ETH_CFG_RGMII_GE0 BIT(0)
31770 +#define AR933X_ETH_CFG_MII_GE0 BIT(1)
31771 +#define AR933X_ETH_CFG_GMII_GE0 BIT(2)
31772 +#define AR933X_ETH_CFG_MII_GE0_MASTER BIT(3)
31773 +#define AR933X_ETH_CFG_MII_GE0_SLAVE BIT(4)
31774 +#define AR933X_ETH_CFG_MII_GE0_ERR_EN BIT(5)
31775 +#define AR933X_ETH_CFG_SW_PHY_SWAP BIT(7)
31776 +#define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP BIT(8)
31777 +#define AR933X_ETH_CFG_RMII_GE0 BIT(9)
31778 +#define AR933X_ETH_CFG_RMII_GE0_SPD_10 0
31779 +#define AR933X_ETH_CFG_RMII_GE0_SPD_100 BIT(10)
31782 + * AR934X GMAC Interface
31783 + */
31784 +#define AR934X_GMAC_REG_ETH_CFG 0x00
31786 +#define AR934X_ETH_CFG_RGMII_GMAC0 BIT(0)
31787 +#define AR934X_ETH_CFG_MII_GMAC0 BIT(1)
31788 +#define AR934X_ETH_CFG_GMII_GMAC0 BIT(2)
31789 +#define AR934X_ETH_CFG_MII_GMAC0_MASTER BIT(3)
31790 +#define AR934X_ETH_CFG_MII_GMAC0_SLAVE BIT(4)
31791 +#define AR934X_ETH_CFG_MII_GMAC0_ERR_EN BIT(5)
31792 +#define AR934X_ETH_CFG_SW_ONLY_MODE BIT(6)
31793 +#define AR934X_ETH_CFG_SW_PHY_SWAP BIT(7)
31794 +#define AR934X_ETH_CFG_SW_APB_ACCESS BIT(9)
31795 +#define AR934X_ETH_CFG_RMII_GMAC0 BIT(10)
31796 +#define AR933X_ETH_CFG_MII_CNTL_SPEED BIT(11)
31797 +#define AR934X_ETH_CFG_RMII_GMAC0_MASTER BIT(12)
31798 +#define AR933X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
31799 +#define AR934X_ETH_CFG_RXD_DELAY BIT(14)
31800 +#define AR934X_ETH_CFG_RXD_DELAY_MASK 0x3
31801 +#define AR934X_ETH_CFG_RXD_DELAY_SHIFT 14
31802 +#define AR934X_ETH_CFG_RDV_DELAY BIT(16)
31803 +#define AR934X_ETH_CFG_RDV_DELAY_MASK 0x3
31804 +#define AR934X_ETH_CFG_RDV_DELAY_SHIFT 16
31807 + * QCA953X GMAC Interface
31808 + */
31809 +#define QCA953X_GMAC_REG_ETH_CFG 0x00
31811 +#define QCA953X_ETH_CFG_SW_ONLY_MODE BIT(6)
31812 +#define QCA953X_ETH_CFG_SW_PHY_SWAP BIT(7)
31813 +#define QCA953X_ETH_CFG_SW_APB_ACCESS BIT(9)
31814 +#define QCA953X_ETH_CFG_SW_ACC_MSB_FIRST BIT(13)
31817 + * QCA955X GMAC Interface
31818 + */
31820 +#define QCA955X_GMAC_REG_ETH_CFG 0x00
31822 +#define QCA955X_ETH_CFG_RGMII_EN BIT(0)
31823 +#define QCA955X_ETH_CFG_GE0_SGMII BIT(6)
31825 #endif /* __ASM_MACH_AR71XX_REGS_H */
31826 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ath79.h linux-4.1.43/arch/mips/include/asm/mach-ath79/ath79.h
31827 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ath79.h 2017-08-06 01:56:14.000000000 +0200
31828 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/ath79.h 2017-08-06 20:02:15.000000000 +0200
31829 @@ -32,8 +32,11 @@
31830 ATH79_SOC_AR9341,
31831 ATH79_SOC_AR9342,
31832 ATH79_SOC_AR9344,
31833 + ATH79_SOC_QCA9533,
31834 ATH79_SOC_QCA9556,
31835 ATH79_SOC_QCA9558,
31836 + ATH79_SOC_TP9343,
31837 + ATH79_SOC_QCA9561,
31840 extern enum ath79_soc_type ath79_soc;
31841 @@ -100,6 +103,16 @@
31842 return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
31845 +static inline int soc_is_qca9533(void)
31847 + return ath79_soc == ATH79_SOC_QCA9533;
31850 +static inline int soc_is_qca953x(void)
31852 + return soc_is_qca9533();
31855 static inline int soc_is_qca9556(void)
31857 return ath79_soc == ATH79_SOC_QCA9556;
31858 @@ -115,7 +128,23 @@
31859 return soc_is_qca9556() || soc_is_qca9558();
31862 +static inline int soc_is_tp9343(void)
31864 + return ath79_soc == ATH79_SOC_TP9343;
31867 +static inline int soc_is_qca9561(void)
31869 + return ath79_soc == ATH79_SOC_QCA9561;
31872 +static inline int soc_is_qca956x(void)
31874 + return soc_is_tp9343() || soc_is_qca9561();
31877 extern void __iomem *ath79_ddr_base;
31878 +extern void __iomem *ath79_gpio_base;
31879 extern void __iomem *ath79_pll_base;
31880 extern void __iomem *ath79_reset_base;
31882 @@ -132,6 +161,7 @@
31883 static inline void ath79_reset_wr(unsigned reg, u32 val)
31885 __raw_writel(val, ath79_reset_base + reg);
31886 + (void) __raw_readl(ath79_reset_base + reg); /* flush */
31889 static inline u32 ath79_reset_rr(unsigned reg)
31890 @@ -141,5 +171,9 @@
31892 void ath79_device_reset_set(u32 mask);
31893 void ath79_device_reset_clear(u32 mask);
31894 +u32 ath79_device_reset_get(u32 mask);
31896 +void ath79_flash_acquire(void);
31897 +void ath79_flash_release(void);
31899 #endif /* __ASM_MACH_ATH79_H */
31900 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h linux-4.1.43/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
31901 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h 2017-08-06 01:56:14.000000000 +0200
31902 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h 2017-08-06 20:02:15.000000000 +0200
31903 @@ -16,8 +16,15 @@
31904 unsigned num_chipselect;
31907 +enum ath79_spi_cs_type {
31908 + ATH79_SPI_CS_TYPE_INTERNAL,
31909 + ATH79_SPI_CS_TYPE_GPIO,
31912 struct ath79_spi_controller_data {
31913 - unsigned gpio;
31914 + enum ath79_spi_cs_type cs_type;
31915 + unsigned cs_line;
31916 + bool is_flash;
31919 #endif /* _ATH79_SPI_PLATFORM_H */
31920 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h linux-4.1.43/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
31921 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h 2017-08-06 01:56:14.000000000 +0200
31922 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h 2017-08-06 20:02:15.000000000 +0200
31923 @@ -36,6 +36,7 @@
31924 #define cpu_has_mdmx 0
31925 #define cpu_has_mips3d 0
31926 #define cpu_has_smartmips 0
31927 +#define cpu_has_rixi 0
31929 #define cpu_has_mips32r1 1
31930 #define cpu_has_mips32r2 1
31931 @@ -43,6 +44,7 @@
31932 #define cpu_has_mips64r2 0
31934 #define cpu_has_mipsmt 0
31935 +#define cpu_has_userlocal 0
31937 #define cpu_has_64bits 0
31938 #define cpu_has_64bit_zero_reg 0
31939 @@ -51,5 +53,9 @@
31941 #define cpu_dcache_line_size() 32
31942 #define cpu_icache_line_size() 32
31943 +#define cpu_has_vtag_icache 0
31944 +#define cpu_has_dc_aliases 1
31945 +#define cpu_has_ic_fills_f_dc 0
31946 +#define cpu_has_pindexed_dcache 0
31948 #endif /* __ASM_MACH_ATH79_CPU_FEATURE_OVERRIDES_H */
31949 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/irq.h linux-4.1.43/arch/mips/include/asm/mach-ath79/irq.h
31950 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/irq.h 2017-08-06 01:56:14.000000000 +0200
31951 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/irq.h 2017-08-06 20:02:15.000000000 +0200
31952 @@ -10,7 +10,7 @@
31953 #define __ASM_MACH_ATH79_IRQ_H
31955 #define MIPS_CPU_IRQ_BASE 0
31956 -#define NR_IRQS 51
31957 +#define NR_IRQS 83
31959 #define ATH79_CPU_IRQ(_x) (MIPS_CPU_IRQ_BASE + (_x))
31961 @@ -30,6 +30,10 @@
31962 #define ATH79_IP3_IRQ_COUNT 3
31963 #define ATH79_IP3_IRQ(_x) (ATH79_IP3_IRQ_BASE + (_x))
31965 +#define ATH79_GPIO_IRQ_BASE (ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT)
31966 +#define ATH79_GPIO_IRQ_COUNT 32
31967 +#define ATH79_GPIO_IRQ(_x) (ATH79_GPIO_IRQ_BASE + (_x))
31969 #include_next <irq.h>
31971 #endif /* __ASM_MACH_ATH79_IRQ_H */
31972 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/mach-rb750.h linux-4.1.43/arch/mips/include/asm/mach-ath79/mach-rb750.h
31973 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/mach-rb750.h 1970-01-01 01:00:00.000000000 +0100
31974 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/mach-rb750.h 2017-08-06 20:02:15.000000000 +0200
31975 @@ -0,0 +1,84 @@
31977 + * MikroTik RouterBOARD 750 definitions
31979 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
31981 + * This program is free software; you can redistribute it and/or modify it
31982 + * under the terms of the GNU General Public License version 2 as published
31983 + * by the Free Software Foundation.
31984 + */
31985 +#ifndef _MACH_RB750_H
31986 +#define _MACH_RB750_H
31988 +#include <linux/bitops.h>
31990 +#define RB750_GPIO_LVC573_LE 0 /* Latch enable on LVC573 */
31991 +#define RB750_GPIO_NAND_IO0 1 /* NAND I/O 0 */
31992 +#define RB750_GPIO_NAND_IO1 2 /* NAND I/O 1 */
31993 +#define RB750_GPIO_NAND_IO2 3 /* NAND I/O 2 */
31994 +#define RB750_GPIO_NAND_IO3 4 /* NAND I/O 3 */
31995 +#define RB750_GPIO_NAND_IO4 5 /* NAND I/O 4 */
31996 +#define RB750_GPIO_NAND_IO5 6 /* NAND I/O 5 */
31997 +#define RB750_GPIO_NAND_IO6 7 /* NAND I/O 6 */
31998 +#define RB750_GPIO_NAND_IO7 8 /* NAND I/O 7 */
31999 +#define RB750_GPIO_NAND_NCE 11 /* NAND Chip Enable (active low) */
32000 +#define RB750_GPIO_NAND_RDY 12 /* NAND Ready */
32001 +#define RB750_GPIO_NAND_CLE 14 /* NAND Command Latch Enable */
32002 +#define RB750_GPIO_NAND_ALE 15 /* NAND Address Latch Enable */
32003 +#define RB750_GPIO_NAND_NRE 16 /* NAND Read Enable (active low) */
32004 +#define RB750_GPIO_NAND_NWE 17 /* NAND Write Enable (active low) */
32006 +#define RB750_GPIO_BTN_RESET 1
32007 +#define RB750_GPIO_SPI_CS0 2
32008 +#define RB750_GPIO_LED_ACT 12
32009 +#define RB750_GPIO_LED_PORT1 13
32010 +#define RB750_GPIO_LED_PORT2 14
32011 +#define RB750_GPIO_LED_PORT3 15
32012 +#define RB750_GPIO_LED_PORT4 16
32013 +#define RB750_GPIO_LED_PORT5 17
32015 +#define RB750_LED_ACT BIT(RB750_GPIO_LED_ACT)
32016 +#define RB750_LED_PORT1 BIT(RB750_GPIO_LED_PORT1)
32017 +#define RB750_LED_PORT2 BIT(RB750_GPIO_LED_PORT2)
32018 +#define RB750_LED_PORT3 BIT(RB750_GPIO_LED_PORT3)
32019 +#define RB750_LED_PORT4 BIT(RB750_GPIO_LED_PORT4)
32020 +#define RB750_LED_PORT5 BIT(RB750_GPIO_LED_PORT5)
32021 +#define RB750_NAND_NCE BIT(RB750_GPIO_NAND_NCE)
32023 +#define RB750_LVC573_LE BIT(RB750_GPIO_LVC573_LE)
32025 +#define RB750_LED_BITS (RB750_LED_PORT1 | RB750_LED_PORT2 | RB750_LED_PORT3 | \
32026 + RB750_LED_PORT4 | RB750_LED_PORT5 | RB750_LED_ACT)
32028 +#define RB7XX_GPIO_NAND_NCE 0
32029 +#define RB7XX_GPIO_MON 9
32030 +#define RB7XX_GPIO_LED_ACT 11
32031 +#define RB7XX_GPIO_USB_POWERON 13
32033 +#define RB7XX_NAND_NCE BIT(RB7XX_GPIO_NAND_NCE)
32034 +#define RB7XX_LED_ACT BIT(RB7XX_GPIO_LED_ACT)
32035 +#define RB7XX_MONITOR BIT(RB7XX_GPIO_MON)
32036 +#define RB7XX_USB_POWERON BIT(RB7XX_GPIO_USB_POWERON)
32038 +struct rb750_led_data {
32039 + char *name;
32040 + char *default_trigger;
32041 + u32 mask;
32042 + int active_low;
32045 +struct rb750_led_platform_data {
32046 + int num_leds;
32047 + struct rb750_led_data *leds;
32048 + void (*latch_change)(u32 clear, u32 set);
32051 +struct rb7xx_nand_platform_data {
32052 + u32 nce_line;
32054 + void (*enable_pins)(void);
32055 + void (*disable_pins)(void);
32056 + void (*latch_change)(u32, u32);
32059 +#endif /* _MACH_RB750_H */
32060 \ No newline at end of file
32061 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/mangle-port.h linux-4.1.43/arch/mips/include/asm/mach-ath79/mangle-port.h
32062 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/mangle-port.h 1970-01-01 01:00:00.000000000 +0100
32063 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/mangle-port.h 2017-08-06 20:02:15.000000000 +0200
32064 @@ -0,0 +1,37 @@
32066 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
32068 + * This file was derived from: inlude/asm-mips/mach-generic/mangle-port.h
32069 + * Copyright (C) 2003, 2004 Ralf Baechle
32071 + * This program is free software; you can redistribute it and/or modify it
32072 + * under the terms of the GNU General Public License version 2 as published
32073 + * by the Free Software Foundation.
32074 + */
32076 +#ifndef __ASM_MACH_ATH79_MANGLE_PORT_H
32077 +#define __ASM_MACH_ATH79_MANGLE_PORT_H
32079 +#ifdef CONFIG_PCI
32080 +extern unsigned long (ath79_pci_swizzle_b)(unsigned long port);
32081 +extern unsigned long (ath79_pci_swizzle_w)(unsigned long port);
32082 +#else
32083 +#define ath79_pci_swizzle_b(port) (port)
32084 +#define ath79_pci_swizzle_w(port) (port)
32085 +#endif
32087 +#define __swizzle_addr_b(port) ath79_pci_swizzle_b(port)
32088 +#define __swizzle_addr_w(port) ath79_pci_swizzle_w(port)
32089 +#define __swizzle_addr_l(port) (port)
32090 +#define __swizzle_addr_q(port) (port)
32092 +# define ioswabb(a, x) (x)
32093 +# define __mem_ioswabb(a, x) (x)
32094 +# define ioswabw(a, x) (x)
32095 +# define __mem_ioswabw(a, x) cpu_to_le16(x)
32096 +# define ioswabl(a, x) (x)
32097 +# define __mem_ioswabl(a, x) cpu_to_le32(x)
32098 +# define ioswabq(a, x) (x)
32099 +# define __mem_ioswabq(a, x) cpu_to_le64(x)
32101 +#endif /* __ASM_MACH_ATH79_MANGLE_PORT_H */
32102 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h linux-4.1.43/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h
32103 --- linux-4.1.43.orig/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h 1970-01-01 01:00:00.000000000 +0100
32104 +++ linux-4.1.43/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h 2017-08-06 20:02:15.000000000 +0200
32105 @@ -0,0 +1,48 @@
32107 + * SPI driver definitions for the CPLD chip on the Mikrotik RB4xx boards
32109 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
32111 + * This file was based on the patches for Linux 2.6.27.39 published by
32112 + * MikroTik for their RouterBoard 4xx series devices.
32114 + * This program is free software; you can redistribute it and/or modify it
32115 + * under the terms of the GNU General Public License version 2 as published
32116 + * by the Free Software Foundation.
32117 + */
32119 +#define CPLD_GPIO_nLED1 0
32120 +#define CPLD_GPIO_nLED2 1
32121 +#define CPLD_GPIO_nLED3 2
32122 +#define CPLD_GPIO_nLED4 3
32123 +#define CPLD_GPIO_FAN 4
32124 +#define CPLD_GPIO_ALE 5
32125 +#define CPLD_GPIO_CLE 6
32126 +#define CPLD_GPIO_nCE 7
32127 +#define CPLD_GPIO_nLED5 8
32129 +#define CPLD_NUM_GPIOS 9
32131 +#define CPLD_CFG_nLED1 BIT(CPLD_GPIO_nLED1)
32132 +#define CPLD_CFG_nLED2 BIT(CPLD_GPIO_nLED2)
32133 +#define CPLD_CFG_nLED3 BIT(CPLD_GPIO_nLED3)
32134 +#define CPLD_CFG_nLED4 BIT(CPLD_GPIO_nLED4)
32135 +#define CPLD_CFG_FAN BIT(CPLD_GPIO_FAN)
32136 +#define CPLD_CFG_ALE BIT(CPLD_GPIO_ALE)
32137 +#define CPLD_CFG_CLE BIT(CPLD_GPIO_CLE)
32138 +#define CPLD_CFG_nCE BIT(CPLD_GPIO_nCE)
32139 +#define CPLD_CFG_nLED5 BIT(CPLD_GPIO_nLED5)
32141 +struct rb4xx_cpld_platform_data {
32142 + unsigned gpio_base;
32145 +extern int rb4xx_cpld_change_cfg(unsigned mask, unsigned value);
32146 +extern int rb4xx_cpld_read(unsigned char *rx_buf,
32147 + const unsigned char *verify_buf,
32148 + unsigned cnt);
32149 +extern int rb4xx_cpld_read_from(unsigned addr,
32150 + unsigned char *rx_buf,
32151 + const unsigned char *verify_buf,
32152 + unsigned cnt);
32153 +extern int rb4xx_cpld_write(const unsigned char *buf, unsigned count);
32154 diff -Nur linux-4.1.43.orig/arch/mips/include/asm/mips_machine.h linux-4.1.43/arch/mips/include/asm/mips_machine.h
32155 --- linux-4.1.43.orig/arch/mips/include/asm/mips_machine.h 2017-08-06 01:56:14.000000000 +0200
32156 +++ linux-4.1.43/arch/mips/include/asm/mips_machine.h 2017-08-06 20:02:15.000000000 +0200
32157 @@ -36,6 +36,18 @@
32158 .mach_setup = _setup, \
32161 +#define MIPS_MACHINE_NONAME(_type, _id, _setup) \
32162 +static const char machine_id_##_type[] __initconst \
32163 + __aligned(1) = _id; \
32164 +static struct mips_machine machine_##_type \
32165 + __used __section(.mips.machines.init) = \
32166 +{ \
32167 + .mach_type = _type, \
32168 + .mach_id = machine_id_##_type, \
32169 + .mach_name = NULL, \
32170 + .mach_setup = _setup, \
32173 extern long __mips_machines_start;
32174 extern long __mips_machines_end;
32176 diff -Nur linux-4.1.43.orig/drivers/Makefile linux-4.1.43/drivers/Makefile
32177 --- linux-4.1.43.orig/drivers/Makefile 2017-08-06 01:56:14.000000000 +0200
32178 +++ linux-4.1.43/drivers/Makefile 2017-08-06 20:02:16.000000000 +0200
32179 @@ -71,8 +71,8 @@
32180 obj-$(CONFIG_SCSI) += scsi/
32181 obj-$(CONFIG_ATA) += ata/
32182 obj-$(CONFIG_TARGET_CORE) += target/
32183 -obj-$(CONFIG_MTD) += mtd/
32184 obj-$(CONFIG_SPI) += spi/
32185 +obj-$(CONFIG_MTD) += mtd/
32186 obj-$(CONFIG_SPMI) += spmi/
32187 obj-y += hsi/
32188 obj-y += net/
32189 diff -Nur linux-4.1.43.orig/drivers/gpio/Kconfig linux-4.1.43/drivers/gpio/Kconfig
32190 --- linux-4.1.43.orig/drivers/gpio/Kconfig 2017-08-06 01:56:14.000000000 +0200
32191 +++ linux-4.1.43/drivers/gpio/Kconfig 2017-08-06 20:02:15.000000000 +0200
32192 @@ -942,7 +942,7 @@
32194 config GPIO_74X164
32195 tristate "74x164 serial-in/parallel-out 8-bits shift register"
32196 - depends on SPI_MASTER && OF
32197 + depends on SPI_MASTER
32198 help
32199 Driver for 74x164 compatible serial-in/parallel-out 8-outputs
32200 shift registers. This driver can be used to provide access
32201 @@ -989,4 +989,17 @@
32203 endmenu
32205 +comment "Other GPIO expanders"
32207 +config GPIO_NXP_74HC153
32208 + tristate "NXP 74HC153 Dual 4-input multiplexer"
32209 + help
32210 + Platform driver for NXP 74HC153 Dual 4-input Multiplexer. This
32211 + provides a GPIO interface supporting input mode only.
32213 +config GPIO_LATCH
32214 + tristate "GPIO latch driver"
32215 + help
32216 + Say yes here to enable a GPIO latch driver.
32218 endif
32219 diff -Nur linux-4.1.43.orig/drivers/gpio/Makefile linux-4.1.43/drivers/gpio/Makefile
32220 --- linux-4.1.43.orig/drivers/gpio/Makefile 2017-08-06 01:56:14.000000000 +0200
32221 +++ linux-4.1.43/drivers/gpio/Makefile 2017-08-06 20:02:16.000000000 +0200
32222 @@ -42,6 +42,7 @@
32223 obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o
32224 obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o
32225 obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o
32226 +obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o
32227 obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o
32228 obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o
32229 obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o
32230 @@ -64,6 +65,7 @@
32231 obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o
32232 obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o
32233 obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o
32234 +obj-$(CONFIG_GPIO_NXP_74HC153) += gpio-nxp-74hc153.o
32235 obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
32236 obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o
32237 obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o
32238 diff -Nur linux-4.1.43.orig/drivers/gpio/gpio-74x164.c linux-4.1.43/drivers/gpio/gpio-74x164.c
32239 --- linux-4.1.43.orig/drivers/gpio/gpio-74x164.c 2017-08-06 01:56:14.000000000 +0200
32240 +++ linux-4.1.43/drivers/gpio/gpio-74x164.c 2017-08-06 20:02:15.000000000 +0200
32241 @@ -12,6 +12,7 @@
32242 #include <linux/init.h>
32243 #include <linux/mutex.h>
32244 #include <linux/spi/spi.h>
32245 +#include <linux/spi/74x164.h>
32246 #include <linux/gpio.h>
32247 #include <linux/of_gpio.h>
32248 #include <linux/slab.h>
32249 @@ -107,8 +108,18 @@
32250 static int gen_74x164_probe(struct spi_device *spi)
32252 struct gen_74x164_chip *chip;
32253 + struct gen_74x164_chip_platform_data *pdata;
32254 + struct device_node *np;
32255 int ret;
32257 + pdata = spi->dev.platform_data;
32258 + np = spi->dev.of_node;
32260 + if (!np && !pdata) {
32261 + dev_err(&spi->dev, "No configuration data available.\n");
32262 + return -EINVAL;
32266 * bits_per_word cannot be configured in platform data
32268 @@ -130,18 +141,28 @@
32269 chip->gpio_chip.set = gen_74x164_set_value;
32270 chip->gpio_chip.base = -1;
32272 - if (of_property_read_u32(spi->dev.of_node, "registers-number",
32273 - &chip->registers)) {
32274 - dev_err(&spi->dev,
32275 - "Missing registers-number property in the DT.\n");
32276 - return -EINVAL;
32277 + if (np) {
32278 + if (of_property_read_u32(spi->dev.of_node, "registers-number", &chip->registers)) {
32279 + dev_err(&spi->dev, "Missing registers-number property in the DT.\n");
32280 + ret = -EINVAL;
32281 + goto exit_destroy;
32283 + } else if (pdata) {
32284 + chip->gpio_chip.base = pdata->base;
32285 + chip->registers = pdata->num_registers;
32288 + if (!chip->registers)
32289 + chip->registers = 1;
32291 chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
32292 chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
32293 if (!chip->buffer)
32294 return -ENOMEM;
32296 + if (pdata && pdata->init_data)
32297 + memcpy(chip->buffer, pdata->init_data, chip->registers);
32299 chip->gpio_chip.can_sleep = true;
32300 chip->gpio_chip.dev = &spi->dev;
32301 chip->gpio_chip.owner = THIS_MODULE;
32302 @@ -174,17 +195,19 @@
32303 return 0;
32306 +#ifdef CONFIG_OF
32307 static const struct of_device_id gen_74x164_dt_ids[] = {
32308 { .compatible = "fairchild,74hc595" },
32311 MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
32312 +#endif /* CONFIG_OF */
32314 static struct spi_driver gen_74x164_driver = {
32315 .driver = {
32316 .name = "74x164",
32317 .owner = THIS_MODULE,
32318 - .of_match_table = gen_74x164_dt_ids,
32319 + .of_match_table = of_match_ptr(gen_74x164_dt_ids),
32321 .probe = gen_74x164_probe,
32322 .remove = gen_74x164_remove,
32323 diff -Nur linux-4.1.43.orig/drivers/gpio/gpio-latch.c linux-4.1.43/drivers/gpio/gpio-latch.c
32324 --- linux-4.1.43.orig/drivers/gpio/gpio-latch.c 1970-01-01 01:00:00.000000000 +0100
32325 +++ linux-4.1.43/drivers/gpio/gpio-latch.c 2017-08-06 20:02:15.000000000 +0200
32326 @@ -0,0 +1,220 @@
32328 + * GPIO latch driver
32330 + * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
32332 + * This program is free software; you can redistribute it and/or modify it
32333 + * under the terms of the GNU General Public License version 2 as published
32334 + * by the Free Software Foundation.
32335 + */
32337 +#include <linux/kernel.h>
32338 +#include <linux/init.h>
32339 +#include <linux/module.h>
32340 +#include <linux/types.h>
32341 +#include <linux/gpio.h>
32342 +#include <linux/slab.h>
32343 +#include <linux/platform_device.h>
32345 +#include <linux/platform_data/gpio-latch.h>
32347 +struct gpio_latch_chip {
32348 + struct gpio_chip gc;
32350 + struct mutex mutex;
32351 + struct mutex latch_mutex;
32352 + bool latch_enabled;
32353 + int le_gpio;
32354 + bool le_active_low;
32355 + int *gpios;
32358 +static inline struct gpio_latch_chip *to_gpio_latch_chip(struct gpio_chip *gc)
32360 + return container_of(gc, struct gpio_latch_chip, gc);
32363 +static void gpio_latch_lock(struct gpio_latch_chip *glc, bool enable)
32365 + mutex_lock(&glc->mutex);
32367 + if (enable)
32368 + glc->latch_enabled = true;
32370 + if (glc->latch_enabled)
32371 + mutex_lock(&glc->latch_mutex);
32374 +static void gpio_latch_unlock(struct gpio_latch_chip *glc, bool disable)
32376 + if (glc->latch_enabled)
32377 + mutex_unlock(&glc->latch_mutex);
32379 + if (disable)
32380 + glc->latch_enabled = true;
32382 + mutex_unlock(&glc->mutex);
32385 +static int
32386 +gpio_latch_get(struct gpio_chip *gc, unsigned offset)
32388 + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
32389 + int ret;
32391 + gpio_latch_lock(glc, false);
32392 + ret = gpio_get_value(glc->gpios[offset]);
32393 + gpio_latch_unlock(glc, false);
32395 + return ret;
32398 +static void
32399 +gpio_latch_set(struct gpio_chip *gc, unsigned offset, int value)
32401 + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
32402 + bool enable_latch = false;
32403 + bool disable_latch = false;
32404 + int gpio;
32406 + gpio = glc->gpios[offset];
32408 + if (gpio == glc->le_gpio) {
32409 + enable_latch = value ^ glc->le_active_low;
32410 + disable_latch = !enable_latch;
32413 + gpio_latch_lock(glc, enable_latch);
32414 + gpio_set_value(gpio, value);
32415 + gpio_latch_unlock(glc, disable_latch);
32418 +static int
32419 +gpio_latch_direction_input(struct gpio_chip *gc, unsigned offset)
32421 + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
32422 + int ret;
32424 + gpio_latch_lock(glc, false);
32425 + ret = gpio_direction_input(glc->gpios[offset]);
32426 + gpio_latch_unlock(glc, false);
32428 + return ret;
32431 +static int
32432 +gpio_latch_direction_output(struct gpio_chip *gc, unsigned offset, int value)
32434 + struct gpio_latch_chip *glc = to_gpio_latch_chip(gc);
32435 + bool enable_latch = false;
32436 + bool disable_latch = false;
32437 + int gpio;
32438 + int ret;
32440 + gpio = glc->gpios[offset];
32442 + if (gpio == glc->le_gpio) {
32443 + enable_latch = value ^ glc->le_active_low;
32444 + disable_latch = !enable_latch;
32447 + gpio_latch_lock(glc, enable_latch);
32448 + ret = gpio_direction_output(gpio, value);
32449 + gpio_latch_unlock(glc, disable_latch);
32451 + return ret;
32454 +static int gpio_latch_probe(struct platform_device *pdev)
32456 + struct gpio_latch_chip *glc;
32457 + struct gpio_latch_platform_data *pdata;
32458 + struct gpio_chip *gc;
32459 + int size;
32460 + int ret;
32461 + int i;
32463 + pdata = dev_get_platdata(&pdev->dev);
32464 + if (!pdata)
32465 + return -EINVAL;
32467 + if (pdata->le_gpio_index >= pdata->num_gpios ||
32468 + !pdata->num_gpios ||
32469 + !pdata->gpios)
32470 + return -EINVAL;
32472 + for (i = 0; i < pdata->num_gpios; i++) {
32473 + int gpio = pdata->gpios[i];
32475 + ret = devm_gpio_request(&pdev->dev, gpio,
32476 + GPIO_LATCH_DRIVER_NAME);
32477 + if (ret)
32478 + return ret;
32481 + glc = devm_kzalloc(&pdev->dev, sizeof(*glc), GFP_KERNEL);
32482 + if (!glc)
32483 + return -ENOMEM;
32485 + mutex_init(&glc->mutex);
32486 + mutex_init(&glc->latch_mutex);
32488 + size = pdata->num_gpios * sizeof(glc->gpios[0]);
32489 + glc->gpios = devm_kzalloc(&pdev->dev, size , GFP_KERNEL);
32490 + if (!glc->gpios)
32491 + return -ENOMEM;
32493 + memcpy(glc->gpios, pdata->gpios, size);
32495 + glc->le_gpio = glc->gpios[pdata->le_gpio_index];
32496 + glc->le_active_low = pdata->le_active_low;
32498 + gc = &glc->gc;
32500 + gc->label = GPIO_LATCH_DRIVER_NAME;
32501 + gc->base = pdata->base;
32502 + gc->can_sleep = true;
32503 + gc->ngpio = pdata->num_gpios;
32504 + gc->get = gpio_latch_get;
32505 + gc->set = gpio_latch_set;
32506 + gc->direction_input = gpio_latch_direction_input,
32507 + gc->direction_output = gpio_latch_direction_output;
32509 + platform_set_drvdata(pdev, glc);
32511 + ret = gpiochip_add(&glc->gc);
32512 + if (ret)
32513 + return ret;
32515 + return 0;
32518 +static int gpio_latch_remove(struct platform_device *pdev)
32520 + struct gpio_latch_chip *glc = platform_get_drvdata(pdev);
32522 + gpiochip_remove(&glc->gc);
32523 + return 0;
32527 +static struct platform_driver gpio_latch_driver = {
32528 + .probe = gpio_latch_probe,
32529 + .remove = gpio_latch_remove,
32530 + .driver = {
32531 + .name = GPIO_LATCH_DRIVER_NAME,
32532 + .owner = THIS_MODULE,
32533 + },
32536 +static int __init gpio_latch_init(void)
32538 + return platform_driver_register(&gpio_latch_driver);
32541 +postcore_initcall(gpio_latch_init);
32543 +MODULE_DESCRIPTION("GPIO latch driver");
32544 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
32545 +MODULE_LICENSE("GPL v2");
32546 +MODULE_ALIAS("platform:" GPIO_LATCH_DRIVER_NAME);
32547 diff -Nur linux-4.1.43.orig/drivers/gpio/gpio-nxp-74hc153.c linux-4.1.43/drivers/gpio/gpio-nxp-74hc153.c
32548 --- linux-4.1.43.orig/drivers/gpio/gpio-nxp-74hc153.c 1970-01-01 01:00:00.000000000 +0100
32549 +++ linux-4.1.43/drivers/gpio/gpio-nxp-74hc153.c 2017-08-06 20:02:15.000000000 +0200
32550 @@ -0,0 +1,251 @@
32552 + * NXP 74HC153 - Dual 4-input multiplexer GPIO driver
32554 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
32556 + * This program is free software; you can redistribute it and/or modify
32557 + * it under the terms of the GNU General Public License version 2 as
32558 + * published by the Free Software Foundation.
32559 + */
32561 +#include <linux/version.h>
32562 +#include <linux/module.h>
32563 +#include <linux/init.h>
32564 +#include <linux/gpio.h>
32565 +#include <linux/slab.h>
32566 +#include <linux/platform_device.h>
32567 +#include <linux/nxp_74hc153.h>
32569 +#define NXP_74HC153_NUM_GPIOS 8
32570 +#define NXP_74HC153_S0_MASK 0x1
32571 +#define NXP_74HC153_S1_MASK 0x2
32572 +#define NXP_74HC153_BANK_MASK 0x4
32574 +struct nxp_74hc153_chip {
32575 + struct device *parent;
32576 + struct gpio_chip gpio_chip;
32577 + struct mutex lock;
32580 +static struct nxp_74hc153_chip *gpio_to_nxp(struct gpio_chip *gc)
32582 + return container_of(gc, struct nxp_74hc153_chip, gpio_chip);
32585 +static int nxp_74hc153_direction_input(struct gpio_chip *gc, unsigned offset)
32587 + return 0;
32590 +static int nxp_74hc153_direction_output(struct gpio_chip *gc,
32591 + unsigned offset, int val)
32593 + return -EINVAL;
32596 +static int nxp_74hc153_get_value(struct gpio_chip *gc, unsigned offset)
32598 + struct nxp_74hc153_chip *nxp;
32599 + struct nxp_74hc153_platform_data *pdata;
32600 + unsigned s0;
32601 + unsigned s1;
32602 + unsigned pin;
32603 + int ret;
32605 + nxp = gpio_to_nxp(gc);
32606 + pdata = nxp->parent->platform_data;
32608 + s0 = !!(offset & NXP_74HC153_S0_MASK);
32609 + s1 = !!(offset & NXP_74HC153_S1_MASK);
32610 + pin = (offset & NXP_74HC153_BANK_MASK) ? pdata->gpio_pin_2y
32611 + : pdata->gpio_pin_1y;
32613 + mutex_lock(&nxp->lock);
32614 + gpio_set_value(pdata->gpio_pin_s0, s0);
32615 + gpio_set_value(pdata->gpio_pin_s1, s1);
32616 + ret = gpio_get_value(pin);
32617 + mutex_unlock(&nxp->lock);
32619 + return ret;
32622 +static void nxp_74hc153_set_value(struct gpio_chip *gc,
32623 + unsigned offset, int val)
32625 + /* not supported */
32628 +static int nxp_74hc153_probe(struct platform_device *pdev)
32630 + struct nxp_74hc153_platform_data *pdata;
32631 + struct nxp_74hc153_chip *nxp;
32632 + struct gpio_chip *gc;
32633 + int err;
32635 + pdata = pdev->dev.platform_data;
32636 + if (pdata == NULL) {
32637 + dev_dbg(&pdev->dev, "no platform data specified\n");
32638 + return -EINVAL;
32641 + nxp = kzalloc(sizeof(struct nxp_74hc153_chip), GFP_KERNEL);
32642 + if (nxp == NULL) {
32643 + dev_err(&pdev->dev, "no memory for private data\n");
32644 + return -ENOMEM;
32647 + err = gpio_request(pdata->gpio_pin_s0, dev_name(&pdev->dev));
32648 + if (err) {
32649 + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
32650 + pdata->gpio_pin_s0, err);
32651 + goto err_free_nxp;
32654 + err = gpio_request(pdata->gpio_pin_s1, dev_name(&pdev->dev));
32655 + if (err) {
32656 + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
32657 + pdata->gpio_pin_s1, err);
32658 + goto err_free_s0;
32661 + err = gpio_request(pdata->gpio_pin_1y, dev_name(&pdev->dev));
32662 + if (err) {
32663 + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
32664 + pdata->gpio_pin_1y, err);
32665 + goto err_free_s1;
32668 + err = gpio_request(pdata->gpio_pin_2y, dev_name(&pdev->dev));
32669 + if (err) {
32670 + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
32671 + pdata->gpio_pin_2y, err);
32672 + goto err_free_1y;
32675 + err = gpio_direction_output(pdata->gpio_pin_s0, 0);
32676 + if (err) {
32677 + dev_err(&pdev->dev,
32678 + "unable to set direction of gpio %u, err=%d\n",
32679 + pdata->gpio_pin_s0, err);
32680 + goto err_free_2y;
32683 + err = gpio_direction_output(pdata->gpio_pin_s1, 0);
32684 + if (err) {
32685 + dev_err(&pdev->dev,
32686 + "unable to set direction of gpio %u, err=%d\n",
32687 + pdata->gpio_pin_s1, err);
32688 + goto err_free_2y;
32691 + err = gpio_direction_input(pdata->gpio_pin_1y);
32692 + if (err) {
32693 + dev_err(&pdev->dev,
32694 + "unable to set direction of gpio %u, err=%d\n",
32695 + pdata->gpio_pin_1y, err);
32696 + goto err_free_2y;
32699 + err = gpio_direction_input(pdata->gpio_pin_2y);
32700 + if (err) {
32701 + dev_err(&pdev->dev,
32702 + "unable to set direction of gpio %u, err=%d\n",
32703 + pdata->gpio_pin_2y, err);
32704 + goto err_free_2y;
32707 + nxp->parent = &pdev->dev;
32708 + mutex_init(&nxp->lock);
32710 + gc = &nxp->gpio_chip;
32712 + gc->direction_input = nxp_74hc153_direction_input;
32713 + gc->direction_output = nxp_74hc153_direction_output;
32714 + gc->get = nxp_74hc153_get_value;
32715 + gc->set = nxp_74hc153_set_value;
32716 + gc->can_sleep = 1;
32718 + gc->base = pdata->gpio_base;
32719 + gc->ngpio = NXP_74HC153_NUM_GPIOS;
32720 + gc->label = dev_name(nxp->parent);
32721 + gc->dev = nxp->parent;
32722 + gc->owner = THIS_MODULE;
32724 + err = gpiochip_add(&nxp->gpio_chip);
32725 + if (err) {
32726 + dev_err(&pdev->dev, "unable to add gpio chip, err=%d\n", err);
32727 + goto err_free_2y;
32730 + platform_set_drvdata(pdev, nxp);
32731 + return 0;
32733 +err_free_2y:
32734 + gpio_free(pdata->gpio_pin_2y);
32735 +err_free_1y:
32736 + gpio_free(pdata->gpio_pin_1y);
32737 +err_free_s1:
32738 + gpio_free(pdata->gpio_pin_s1);
32739 +err_free_s0:
32740 + gpio_free(pdata->gpio_pin_s0);
32741 +err_free_nxp:
32742 + kfree(nxp);
32743 + return err;
32746 +static int nxp_74hc153_remove(struct platform_device *pdev)
32748 + struct nxp_74hc153_chip *nxp = platform_get_drvdata(pdev);
32749 + struct nxp_74hc153_platform_data *pdata = pdev->dev.platform_data;
32751 + if (nxp) {
32752 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
32753 + int err;
32755 + err = gpiochip_remove(&nxp->gpio_chip);
32756 + if (err) {
32757 + dev_err(&pdev->dev,
32758 + "unable to remove gpio chip, err=%d\n",
32759 + err);
32760 + return err;
32762 +#else
32763 + gpiochip_remove(&nxp->gpio_chip);
32764 +#endif
32765 + gpio_free(pdata->gpio_pin_2y);
32766 + gpio_free(pdata->gpio_pin_1y);
32767 + gpio_free(pdata->gpio_pin_s1);
32768 + gpio_free(pdata->gpio_pin_s0);
32770 + kfree(nxp);
32771 + platform_set_drvdata(pdev, NULL);
32774 + return 0;
32777 +static struct platform_driver nxp_74hc153_driver = {
32778 + .probe = nxp_74hc153_probe,
32779 + .remove = nxp_74hc153_remove,
32780 + .driver = {
32781 + .name = NXP_74HC153_DRIVER_NAME,
32782 + .owner = THIS_MODULE,
32783 + },
32786 +static int __init nxp_74hc153_init(void)
32788 + return platform_driver_register(&nxp_74hc153_driver);
32790 +subsys_initcall(nxp_74hc153_init);
32792 +static void __exit nxp_74hc153_exit(void)
32794 + platform_driver_unregister(&nxp_74hc153_driver);
32796 +module_exit(nxp_74hc153_exit);
32798 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
32799 +MODULE_DESCRIPTION("GPIO expander driver for NXP 74HC153");
32800 +MODULE_LICENSE("GPL v2");
32801 +MODULE_ALIAS("platform:" NXP_74HC153_DRIVER_NAME);
32802 diff -Nur linux-4.1.43.orig/drivers/leds/Kconfig linux-4.1.43/drivers/leds/Kconfig
32803 --- linux-4.1.43.orig/drivers/leds/Kconfig 2017-08-06 01:56:14.000000000 +0200
32804 +++ linux-4.1.43/drivers/leds/Kconfig 2017-08-06 20:02:16.000000000 +0200
32805 @@ -534,6 +534,17 @@
32806 This option enables support for the 'White' LED block
32807 on Qualcomm PM8941 PMICs.
32809 +config LEDS_WNDR3700_USB
32810 + tristate "NETGEAR WNDR3700 USB LED driver"
32811 + depends on LEDS_CLASS && ATH79_MACH_WNDR3700
32812 + help
32813 + This option enables support for the USB LED found on the
32814 + NETGEAR WNDR3700 board.
32816 +config LEDS_RB750
32817 + tristate "LED driver for the Mikrotik RouterBOARD 750"
32818 + depends on LEDS_CLASS && ATH79_MACH_RB750
32820 comment "LED Triggers"
32821 source "drivers/leds/trigger/Kconfig"
32823 diff -Nur linux-4.1.43.orig/drivers/leds/Makefile linux-4.1.43/drivers/leds/Makefile
32824 --- linux-4.1.43.orig/drivers/leds/Makefile 2017-08-06 01:56:14.000000000 +0200
32825 +++ linux-4.1.43/drivers/leds/Makefile 2017-08-06 20:02:16.000000000 +0200
32826 @@ -43,12 +43,14 @@
32827 obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
32828 obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
32829 obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
32830 +obj-${CONFIG_LEDS_WNDR3700_USB} += leds-wndr3700-usb.o
32831 obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o
32832 obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o
32833 obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o
32834 obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
32835 obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o
32836 obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
32837 +obj-$(CONFIG_LEDS_RB750) += leds-rb750.o
32838 obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
32839 obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
32840 obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
32841 diff -Nur linux-4.1.43.orig/drivers/leds/leds-rb750.c linux-4.1.43/drivers/leds/leds-rb750.c
32842 --- linux-4.1.43.orig/drivers/leds/leds-rb750.c 1970-01-01 01:00:00.000000000 +0100
32843 +++ linux-4.1.43/drivers/leds/leds-rb750.c 2017-08-06 20:02:16.000000000 +0200
32844 @@ -0,0 +1,144 @@
32846 + * LED driver for the RouterBOARD 750
32848 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
32850 + * This program is free software; you can redistribute it and/or modify
32851 + * it under the terms of the GNU General Public License version 2 as
32852 + * published by the Free Software Foundation.
32854 + */
32855 +#include <linux/kernel.h>
32856 +#include <linux/module.h>
32857 +#include <linux/init.h>
32858 +#include <linux/platform_device.h>
32859 +#include <linux/leds.h>
32860 +#include <linux/slab.h>
32862 +#include <asm/mach-ath79/mach-rb750.h>
32864 +#define DRV_NAME "leds-rb750"
32866 +struct rb750_led_dev {
32867 + struct led_classdev cdev;
32868 + u32 mask;
32869 + int active_low;
32870 + void (*latch_change)(u32 clear, u32 set);
32873 +struct rb750_led_drvdata {
32874 + struct rb750_led_dev *led_devs;
32875 + int num_leds;
32878 +static inline struct rb750_led_dev *to_rbled(struct led_classdev *led_cdev)
32880 + return (struct rb750_led_dev *)container_of(led_cdev,
32881 + struct rb750_led_dev, cdev);
32884 +static void rb750_led_brightness_set(struct led_classdev *led_cdev,
32885 + enum led_brightness value)
32887 + struct rb750_led_dev *rbled = to_rbled(led_cdev);
32888 + int level;
32890 + level = (value == LED_OFF) ? 0 : 1;
32891 + level ^= rbled->active_low;
32893 + if (level)
32894 + rbled->latch_change(0, rbled->mask);
32895 + else
32896 + rbled->latch_change(rbled->mask, 0);
32899 +static int rb750_led_probe(struct platform_device *pdev)
32901 + struct rb750_led_platform_data *pdata;
32902 + struct rb750_led_drvdata *drvdata;
32903 + int ret = 0;
32904 + int i;
32906 + pdata = pdev->dev.platform_data;
32907 + if (!pdata)
32908 + return -EINVAL;
32910 + drvdata = kzalloc(sizeof(struct rb750_led_drvdata) +
32911 + sizeof(struct rb750_led_dev) * pdata->num_leds,
32912 + GFP_KERNEL);
32913 + if (!drvdata)
32914 + return -ENOMEM;
32916 + drvdata->num_leds = pdata->num_leds;
32917 + drvdata->led_devs = (struct rb750_led_dev *) &drvdata[1];
32919 + for (i = 0; i < drvdata->num_leds; i++) {
32920 + struct rb750_led_dev *rbled = &drvdata->led_devs[i];
32921 + struct rb750_led_data *led_data = &pdata->leds[i];
32923 + rbled->cdev.name = led_data->name;
32924 + rbled->cdev.default_trigger = led_data->default_trigger;
32925 + rbled->cdev.brightness_set = rb750_led_brightness_set;
32926 + rbled->cdev.brightness = LED_OFF;
32928 + rbled->mask = led_data->mask;
32929 + rbled->active_low = !!led_data->active_low;
32930 + rbled->latch_change = pdata->latch_change;
32932 + ret = led_classdev_register(&pdev->dev, &rbled->cdev);
32933 + if (ret)
32934 + goto err;
32937 + platform_set_drvdata(pdev, drvdata);
32938 + return 0;
32940 +err:
32941 + for (i = i - 1; i >= 0; i--)
32942 + led_classdev_unregister(&drvdata->led_devs[i].cdev);
32944 + kfree(drvdata);
32945 + return ret;
32948 +static int rb750_led_remove(struct platform_device *pdev)
32950 + struct rb750_led_drvdata *drvdata;
32951 + int i;
32953 + drvdata = platform_get_drvdata(pdev);
32954 + for (i = 0; i < drvdata->num_leds; i++)
32955 + led_classdev_unregister(&drvdata->led_devs[i].cdev);
32957 + kfree(drvdata);
32958 + return 0;
32961 +static struct platform_driver rb750_led_driver = {
32962 + .probe = rb750_led_probe,
32963 + .remove = rb750_led_remove,
32964 + .driver = {
32965 + .name = DRV_NAME,
32966 + .owner = THIS_MODULE,
32967 + },
32970 +MODULE_ALIAS("platform:leds-rb750");
32972 +static int __init rb750_led_init(void)
32974 + return platform_driver_register(&rb750_led_driver);
32977 +static void __exit rb750_led_exit(void)
32979 + platform_driver_unregister(&rb750_led_driver);
32982 +module_init(rb750_led_init);
32983 +module_exit(rb750_led_exit);
32985 +MODULE_DESCRIPTION(DRV_NAME);
32986 +MODULE_DESCRIPTION("LED driver for the RouterBOARD 750");
32987 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
32988 +MODULE_LICENSE("GPL v2");
32989 diff -Nur linux-4.1.43.orig/drivers/leds/leds-wndr3700-usb.c linux-4.1.43/drivers/leds/leds-wndr3700-usb.c
32990 --- linux-4.1.43.orig/drivers/leds/leds-wndr3700-usb.c 1970-01-01 01:00:00.000000000 +0100
32991 +++ linux-4.1.43/drivers/leds/leds-wndr3700-usb.c 2017-08-06 20:02:16.000000000 +0200
32992 @@ -0,0 +1,76 @@
32994 + * USB LED driver for the NETGEAR WNDR3700
32996 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
32998 + * This program is free software; you can redistribute it and/or modify it
32999 + * under the terms of the GNU General Public License version 2 as published
33000 + * by the Free Software Foundation.
33001 + */
33003 +#include <linux/leds.h>
33004 +#include <linux/module.h>
33005 +#include <linux/platform_device.h>
33007 +#include <asm/mach-ath79/ar71xx_regs.h>
33008 +#include <asm/mach-ath79/ath79.h>
33010 +#define DRIVER_NAME "wndr3700-led-usb"
33012 +static void wndr3700_usb_led_set(struct led_classdev *cdev,
33013 + enum led_brightness brightness)
33015 + if (brightness)
33016 + ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
33017 + else
33018 + ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
33021 +static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
33023 + return ath79_device_reset_get(AR71XX_RESET_GE1_PHY) ? LED_OFF : LED_FULL;
33026 +static struct led_classdev wndr3700_usb_led = {
33027 + .name = "netgear:green:usb",
33028 + .brightness_set = wndr3700_usb_led_set,
33029 + .brightness_get = wndr3700_usb_led_get,
33032 +static int wndr3700_usb_led_probe(struct platform_device *pdev)
33034 + return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
33037 +static int wndr3700_usb_led_remove(struct platform_device *pdev)
33039 + led_classdev_unregister(&wndr3700_usb_led);
33040 + return 0;
33043 +static struct platform_driver wndr3700_usb_led_driver = {
33044 + .probe = wndr3700_usb_led_probe,
33045 + .remove = wndr3700_usb_led_remove,
33046 + .driver = {
33047 + .name = DRIVER_NAME,
33048 + .owner = THIS_MODULE,
33049 + },
33052 +static int __init wndr3700_usb_led_init(void)
33054 + return platform_driver_register(&wndr3700_usb_led_driver);
33057 +static void __exit wndr3700_usb_led_exit(void)
33059 + platform_driver_unregister(&wndr3700_usb_led_driver);
33062 +module_init(wndr3700_usb_led_init);
33063 +module_exit(wndr3700_usb_led_exit);
33065 +MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
33066 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
33067 +MODULE_LICENSE("GPL v2");
33068 +MODULE_ALIAS("platform:" DRIVER_NAME);
33069 diff -Nur linux-4.1.43.orig/drivers/mtd/Kconfig linux-4.1.43/drivers/mtd/Kconfig
33070 --- linux-4.1.43.orig/drivers/mtd/Kconfig 2017-08-06 01:56:14.000000000 +0200
33071 +++ linux-4.1.43/drivers/mtd/Kconfig 2017-08-06 20:02:16.000000000 +0200
33072 @@ -155,6 +155,12 @@
33073 This provides partitions parser for devices based on BCM47xx
33074 boards.
33076 +config MTD_TPLINK_PARTS
33077 + tristate "TP-Link AR7XXX/AR9XXX partitioning support"
33078 + depends on ATH79
33079 + ---help---
33080 + TBD.
33082 comment "User Modules And Translation Layers"
33085 diff -Nur linux-4.1.43.orig/drivers/mtd/chips/cfi_cmdset_0002.c linux-4.1.43/drivers/mtd/chips/cfi_cmdset_0002.c
33086 --- linux-4.1.43.orig/drivers/mtd/chips/cfi_cmdset_0002.c 2017-08-06 01:56:14.000000000 +0200
33087 +++ linux-4.1.43/drivers/mtd/chips/cfi_cmdset_0002.c 2017-08-06 20:02:16.000000000 +0200
33088 @@ -40,7 +40,7 @@
33089 #include <linux/mtd/xip.h>
33091 #define AMD_BOOTLOC_BUG
33092 -#define FORCE_WORD_WRITE 0
33093 +#define FORCE_WORD_WRITE 1
33095 #define MAX_WORD_RETRIES 3
33097 @@ -51,7 +51,9 @@
33099 static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
33100 static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
33101 +#if !FORCE_WORD_WRITE
33102 static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
33103 +#endif
33104 static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *);
33105 static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *);
33106 static void cfi_amdstd_sync (struct mtd_info *);
33107 @@ -202,6 +204,7 @@
33109 #endif
33111 +#if !FORCE_WORD_WRITE
33112 static void fixup_use_write_buffers(struct mtd_info *mtd)
33114 struct map_info *map = mtd->priv;
33115 @@ -211,6 +214,7 @@
33116 mtd->_write = cfi_amdstd_write_buffers;
33119 +#endif /* !FORCE_WORD_WRITE */
33121 /* Atmel chips don't use the same PRI format as AMD chips */
33122 static void fixup_convert_atmel_pri(struct mtd_info *mtd)
33123 @@ -1632,8 +1636,8 @@
33124 break;
33127 - if (chip_ready(map, adr))
33128 - break;
33129 + if (chip_good(map, adr, datum))
33130 + goto enable_xip;
33132 /* Latency issues. Drop the lock, wait a while and retry */
33133 UDELAY(map, chip, adr, 1);
33134 @@ -1649,6 +1653,8 @@
33136 ret = -EIO;
33139 + enable_xip:
33140 xip_enable(map, chip, adr);
33141 op_done:
33142 if (mode == FL_OTP_WRITE)
33143 @@ -1789,6 +1795,7 @@
33145 * FIXME: interleaved mode not tested, and probably not supported!
33147 +#if !FORCE_WORD_WRITE
33148 static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
33149 unsigned long adr, const u_char *buf,
33150 int len)
33151 @@ -1916,7 +1923,6 @@
33152 return ret;
33156 static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
33157 size_t *retlen, const u_char *buf)
33159 @@ -1991,6 +1997,7 @@
33161 return 0;
33163 +#endif /* !FORCE_WORD_WRITE */
33166 * Wait for the flash chip to become ready to write data
33167 @@ -2226,7 +2233,6 @@
33168 return 0;
33173 * Handle devices with one erase region, that only implement
33174 * the chip erase command.
33175 @@ -2290,8 +2296,8 @@
33176 chip->erase_suspended = 0;
33179 - if (chip_ready(map, adr))
33180 - break;
33181 + if (chip_good(map, adr, map_word_ff(map)))
33182 + goto op_done;
33184 if (time_after(jiffies, timeo)) {
33185 printk(KERN_WARNING "MTD %s(): software timeout\n",
33186 @@ -2311,6 +2317,7 @@
33187 ret = -EIO;
33190 + op_done:
33191 chip->state = FL_READY;
33192 xip_enable(map, chip, adr);
33193 DISABLE_VPP(map);
33194 @@ -2379,9 +2386,9 @@
33195 chip->erase_suspended = 0;
33198 - if (chip_ready(map, adr)) {
33199 + if (chip_good(map, adr, map_word_ff(map))) {
33200 xip_enable(map, chip, adr);
33201 - break;
33202 + goto op_done;
33205 if (time_after(jiffies, timeo)) {
33206 @@ -2403,6 +2410,7 @@
33207 ret = -EIO;
33210 + op_done:
33211 chip->state = FL_READY;
33212 DISABLE_VPP(map);
33213 put_chip(map, chip, adr);
33214 diff -Nur linux-4.1.43.orig/drivers/mtd/chips/jedec_probe.c linux-4.1.43/drivers/mtd/chips/jedec_probe.c
33215 --- linux-4.1.43.orig/drivers/mtd/chips/jedec_probe.c 2017-08-06 01:56:14.000000000 +0200
33216 +++ linux-4.1.43/drivers/mtd/chips/jedec_probe.c 2017-08-06 20:02:16.000000000 +0200
33217 @@ -148,6 +148,7 @@
33218 #define SST39LF160 0x2782
33219 #define SST39VF1601 0x234b
33220 #define SST39VF3201 0x235b
33221 +#define SST39VF6401B 0x236d
33222 #define SST39WF1601 0x274b
33223 #define SST39WF1602 0x274a
33224 #define SST39LF512 0x00D4
33225 @@ -1569,6 +1570,18 @@
33226 ERASEINFO(0x10000,64),
33228 }, {
33229 + .mfr_id = CFI_MFR_SST,
33230 + .dev_id = SST39VF6401B,
33231 + .name = "SST 39VF6401B",
33232 + .devtypes = CFI_DEVICETYPE_X16,
33233 + .uaddr = MTD_UADDR_0xAAAA_0x5555,
33234 + .dev_size = SIZE_8MiB,
33235 + .cmd_set = P_ID_AMD_STD,
33236 + .nr_regions = 1,
33237 + .regions = {
33238 + ERASEINFO(0x10000,128)
33240 + }, {
33241 .mfr_id = CFI_MFR_ST,
33242 .dev_id = M29F800AB,
33243 .name = "ST M29F800AB",
33244 diff -Nur linux-4.1.43.orig/drivers/mtd/cybertan_part.c linux-4.1.43/drivers/mtd/cybertan_part.c
33245 --- linux-4.1.43.orig/drivers/mtd/cybertan_part.c 1970-01-01 01:00:00.000000000 +0100
33246 +++ linux-4.1.43/drivers/mtd/cybertan_part.c 2017-08-06 20:02:16.000000000 +0200
33247 @@ -0,0 +1,201 @@
33249 + * Copyright (C) 2009 Christian Daniel <cd@maintech.de>
33250 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
33252 + * This program is free software; you can redistribute it and/or modify
33253 + * it under the terms of the GNU General Public License as published by
33254 + * the Free Software Foundation; either version 2 of the License, or
33255 + * (at your option) any later version.
33257 + * This program is distributed in the hope that it will be useful,
33258 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
33259 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33260 + * GNU General Public License for more details.
33262 + * You should have received a copy of the GNU General Public License
33263 + * along with this program; if not, write to the Free Software
33264 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33266 + * TRX flash partition table.
33267 + * Based on ar7 map by Felix Fietkau <nbd@openwrt.org>
33269 + */
33271 +#include <linux/kernel.h>
33272 +#include <linux/module.h>
33273 +#include <linux/slab.h>
33274 +#include <linux/vmalloc.h>
33276 +#include <linux/mtd/mtd.h>
33277 +#include <linux/mtd/partitions.h>
33279 +struct cybertan_header {
33280 + char magic[4];
33281 + u8 res1[4];
33282 + char fw_date[3];
33283 + char fw_ver[3];
33284 + char id[4];
33285 + char hw_ver;
33286 + char unused;
33287 + u8 flags[2];
33288 + u8 res2[10];
33291 +#define TRX_PARTS 6
33292 +#define TRX_MAGIC 0x30524448
33293 +#define TRX_MAX_OFFSET 3
33295 +struct trx_header {
33296 + uint32_t magic; /* "HDR0" */
33297 + uint32_t len; /* Length of file including header */
33298 + uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
33299 + uint32_t flag_version; /* 0:15 flags, 16:31 version */
33300 + uint32_t offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
33303 +#define IH_MAGIC 0x27051956 /* Image Magic Number */
33304 +#define IH_NMLEN 32 /* Image Name Length */
33306 +struct uimage_header {
33307 + uint32_t ih_magic; /* Image Header Magic Number */
33308 + uint32_t ih_hcrc; /* Image Header CRC Checksum */
33309 + uint32_t ih_time; /* Image Creation Timestamp */
33310 + uint32_t ih_size; /* Image Data Size */
33311 + uint32_t ih_load; /* Data» Load Address */
33312 + uint32_t ih_ep; /* Entry Point Address */
33313 + uint32_t ih_dcrc; /* Image Data CRC Checksum */
33314 + uint8_t ih_os; /* Operating System */
33315 + uint8_t ih_arch; /* CPU architecture */
33316 + uint8_t ih_type; /* Image Type */
33317 + uint8_t ih_comp; /* Compression Type */
33318 + uint8_t ih_name[IH_NMLEN]; /* Image Name */
33321 +struct firmware_header {
33322 + struct cybertan_header cybertan;
33323 + struct trx_header trx;
33324 + struct uimage_header uimage;
33325 +} __packed;
33327 +#define UBOOT_LEN 0x40000
33328 +#define ART_LEN 0x10000
33329 +#define NVRAM_LEN 0x10000
33331 +static int cybertan_parse_partitions(struct mtd_info *master,
33332 + struct mtd_partition **pparts,
33333 + struct mtd_part_parser_data *data)
33335 + struct firmware_header *header;
33336 + struct trx_header *theader;
33337 + struct uimage_header *uheader;
33338 + struct mtd_partition *trx_parts;
33339 + size_t retlen;
33340 + unsigned int kernel_len;
33341 + unsigned int uboot_len;
33342 + unsigned int nvram_len;
33343 + unsigned int art_len;
33344 + int ret;
33346 + uboot_len = max_t(unsigned int, master->erasesize, UBOOT_LEN);
33347 + nvram_len = max_t(unsigned int, master->erasesize, NVRAM_LEN);
33348 + art_len = max_t(unsigned int, master->erasesize, ART_LEN);
33350 + trx_parts = kzalloc(TRX_PARTS * sizeof(struct mtd_partition),
33351 + GFP_KERNEL);
33352 + if (!trx_parts) {
33353 + ret = -ENOMEM;
33354 + goto out;
33357 + header = vmalloc(sizeof(*header));
33358 + if (!header) {
33359 + return -ENOMEM;
33360 + goto free_parts;
33363 + ret = mtd_read(master, uboot_len, sizeof(*header),
33364 + &retlen, (void *) header);
33365 + if (ret)
33366 + goto free_hdr;
33368 + if (retlen != sizeof(*header)) {
33369 + ret = -EIO;
33370 + goto free_hdr;
33373 + theader = &header->trx;
33374 + if (le32_to_cpu(theader->magic) != TRX_MAGIC) {
33375 + printk(KERN_NOTICE "%s: no TRX header found\n", master->name);
33376 + goto free_hdr;
33379 + uheader = &header->uimage;
33380 + if (uheader->ih_magic != IH_MAGIC) {
33381 + printk(KERN_NOTICE "%s: no uImage found\n", master->name);
33382 + goto free_hdr;
33385 + kernel_len = le32_to_cpu(theader->offsets[1]) +
33386 + sizeof(struct cybertan_header);
33388 + trx_parts[0].name = "u-boot";
33389 + trx_parts[0].offset = 0;
33390 + trx_parts[0].size = uboot_len;
33391 + trx_parts[0].mask_flags = MTD_WRITEABLE;
33393 + trx_parts[1].name = "kernel";
33394 + trx_parts[1].offset = trx_parts[0].offset + trx_parts[0].size;
33395 + trx_parts[1].size = kernel_len;
33396 + trx_parts[1].mask_flags = 0;
33398 + trx_parts[2].name = "rootfs";
33399 + trx_parts[2].offset = trx_parts[1].offset + trx_parts[1].size;
33400 + trx_parts[2].size = master->size - uboot_len - nvram_len - art_len -
33401 + trx_parts[1].size;
33402 + trx_parts[2].mask_flags = 0;
33404 + trx_parts[3].name = "nvram";
33405 + trx_parts[3].offset = master->size - nvram_len - art_len;
33406 + trx_parts[3].size = nvram_len;
33407 + trx_parts[3].mask_flags = MTD_WRITEABLE;
33409 + trx_parts[4].name = "art";
33410 + trx_parts[4].offset = master->size - art_len;
33411 + trx_parts[4].size = art_len;
33412 + trx_parts[4].mask_flags = MTD_WRITEABLE;
33414 + trx_parts[5].name = "firmware";
33415 + trx_parts[5].offset = uboot_len;
33416 + trx_parts[5].size = master->size - uboot_len - nvram_len - art_len;
33417 + trx_parts[5].mask_flags = 0;
33419 + vfree(header);
33421 + *pparts = trx_parts;
33422 + return TRX_PARTS;
33424 +free_hdr:
33425 + vfree(header);
33426 +free_parts:
33427 + kfree(trx_parts);
33428 +out:
33429 + return ret;
33432 +static struct mtd_part_parser cybertan_parser = {
33433 + .owner = THIS_MODULE,
33434 + .parse_fn = cybertan_parse_partitions,
33435 + .name = "cybertan",
33438 +static int __init cybertan_parser_init(void)
33440 + register_mtd_parser(&cybertan_parser);
33442 + return 0;
33445 +module_init(cybertan_parser_init);
33447 +MODULE_LICENSE("GPL");
33448 +MODULE_AUTHOR("Christian Daniel <cd@maintech.de>");
33449 diff -Nur linux-4.1.43.orig/drivers/mtd/devices/m25p80.c linux-4.1.43/drivers/mtd/devices/m25p80.c
33450 --- linux-4.1.43.orig/drivers/mtd/devices/m25p80.c 2017-08-06 01:56:14.000000000 +0200
33451 +++ linux-4.1.43/drivers/mtd/devices/m25p80.c 2017-08-06 20:02:16.000000000 +0200
33452 @@ -139,10 +139,15 @@
33453 flash->command[0] = nor->read_opcode;
33454 m25p_addr2cmd(nor, from, flash->command);
33456 + if (dummy == 1)
33457 + t[0].dummy = true;
33459 + t[0].type = SPI_TRANSFER_FLASH_READ_CMD;
33460 t[0].tx_buf = flash->command;
33461 t[0].len = m25p_cmdsz(nor) + dummy;
33462 spi_message_add_tail(&t[0], &m);
33464 + t[1].type = SPI_TRANSFER_FLASH_READ_DATA;
33465 t[1].rx_buf = buf;
33466 t[1].rx_nbits = m25p80_rx_nbits(nor);
33467 t[1].len = len;
33468 @@ -232,6 +237,7 @@
33469 if (ret)
33470 return ret;
33472 + memset(&ppdata, '\0', sizeof(ppdata));
33473 ppdata.of_node = spi->dev.of_node;
33475 return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
33476 diff -Nur linux-4.1.43.orig/drivers/mtd/maps/physmap.c linux-4.1.43/drivers/mtd/maps/physmap.c
33477 --- linux-4.1.43.orig/drivers/mtd/maps/physmap.c 2017-08-06 01:56:14.000000000 +0200
33478 +++ linux-4.1.43/drivers/mtd/maps/physmap.c 2017-08-06 20:02:16.000000000 +0200
33479 @@ -31,6 +31,66 @@
33480 int vpp_refcnt;
33483 +static struct platform_device *physmap_map2pdev(struct map_info *map)
33485 + return (struct platform_device *) map->map_priv_1;
33488 +static void physmap_lock(struct map_info *map)
33490 + struct platform_device *pdev;
33491 + struct physmap_flash_data *physmap_data;
33493 + pdev = physmap_map2pdev(map);
33494 + physmap_data = pdev->dev.platform_data;
33495 + physmap_data->lock(pdev);
33498 +static void physmap_unlock(struct map_info *map)
33500 + struct platform_device *pdev;
33501 + struct physmap_flash_data *physmap_data;
33503 + pdev = physmap_map2pdev(map);
33504 + physmap_data = pdev->dev.platform_data;
33505 + physmap_data->unlock(pdev);
33508 +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
33510 + map_word ret;
33512 + physmap_lock(map);
33513 + ret = inline_map_read(map, ofs);
33514 + physmap_unlock(map);
33516 + return ret;
33519 +static void physmap_flash_write_lock(struct map_info *map, map_word d,
33520 + unsigned long ofs)
33522 + physmap_lock(map);
33523 + inline_map_write(map, d, ofs);
33524 + physmap_unlock(map);
33527 +static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
33528 + unsigned long from, ssize_t len)
33530 + physmap_lock(map);
33531 + inline_map_copy_from(map, to, from, len);
33532 + physmap_unlock(map);
33535 +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
33536 + const void *from, ssize_t len)
33538 + physmap_lock(map);
33539 + inline_map_copy_to(map, to, from, len);
33540 + physmap_unlock(map);
33543 static int physmap_flash_remove(struct platform_device *dev)
33545 struct physmap_flash_info *info;
33546 @@ -153,6 +213,13 @@
33548 simple_map_init(&info->map[i]);
33550 + if (physmap_data->lock && physmap_data->unlock) {
33551 + info->map[i].read = physmap_flash_read_lock;
33552 + info->map[i].write = physmap_flash_write_lock;
33553 + info->map[i].copy_from = physmap_flash_copy_from_lock;
33554 + info->map[i].copy_to = physmap_flash_copy_to_lock;
33557 probe_type = rom_probe_types;
33558 if (physmap_data->probe_type == NULL) {
33559 for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
33560 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/Kconfig linux-4.1.43/drivers/mtd/nand/Kconfig
33561 --- linux-4.1.43.orig/drivers/mtd/nand/Kconfig 2017-08-06 01:56:14.000000000 +0200
33562 +++ linux-4.1.43/drivers/mtd/nand/Kconfig 2017-08-06 20:02:16.000000000 +0200
33563 @@ -530,4 +530,24 @@
33564 help
33565 Enables support for NAND controller on Hisilicon SoC Hip04.
33567 +config MTD_NAND_RB4XX
33568 + tristate "NAND flash driver for RouterBoard 4xx series"
33569 + depends on MTD_NAND && ATH79_MACH_RB4XX
33571 +config MTD_NAND_RB750
33572 + tristate "NAND flash driver for the RouterBoard 750"
33573 + depends on MTD_NAND && ATH79_MACH_RB750
33575 +config MTD_NAND_RB91X
33576 + tristate "NAND flash driver for the RouterBOARD 91x series"
33577 + depends on MTD_NAND && ATH79_MACH_RB91X
33579 +config MTD_NAND_AR934X
33580 + tristate "NAND flash driver for the Qualcomm Atheros AR934x/QCA955x SoCs"
33581 + depends on (SOC_AR934X || SOC_QCA955X)
33583 +config MTD_NAND_AR934X_HW_ECC
33584 + bool "Hardware ECC support for the AR934X NAND Controller (EXPERIMENTAL)"
33585 + depends on MTD_NAND_AR934X
33587 endif # MTD_NAND
33588 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/Makefile linux-4.1.43/drivers/mtd/nand/Makefile
33589 --- linux-4.1.43.orig/drivers/mtd/nand/Makefile 2017-08-06 01:56:14.000000000 +0200
33590 +++ linux-4.1.43/drivers/mtd/nand/Makefile 2017-08-06 20:02:16.000000000 +0200
33591 @@ -13,6 +13,7 @@
33592 obj-$(CONFIG_MTD_NAND_DENALI) += denali.o
33593 obj-$(CONFIG_MTD_NAND_DENALI_PCI) += denali_pci.o
33594 obj-$(CONFIG_MTD_NAND_DENALI_DT) += denali_dt.o
33595 +obj-$(CONFIG_MTD_NAND_AR934X) += ar934x_nfc.o
33596 obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
33597 obj-$(CONFIG_MTD_NAND_BF5XX) += bf5xx_nand.o
33598 obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
33599 @@ -32,6 +33,9 @@
33600 obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
33601 obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
33602 obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
33603 +obj-$(CONFIG_MTD_NAND_RB4XX) += rb4xx_nand.o
33604 +obj-$(CONFIG_MTD_NAND_RB750) += rb750_nand.o
33605 +obj-$(CONFIG_MTD_NAND_RB91X) += rb91x_nand.o
33606 obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
33607 obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
33608 obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o
33609 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/ar934x_nfc.c linux-4.1.43/drivers/mtd/nand/ar934x_nfc.c
33610 --- linux-4.1.43.orig/drivers/mtd/nand/ar934x_nfc.c 1970-01-01 01:00:00.000000000 +0100
33611 +++ linux-4.1.43/drivers/mtd/nand/ar934x_nfc.c 2017-08-06 20:02:16.000000000 +0200
33612 @@ -0,0 +1,1508 @@
33614 + * Driver for the built-in NAND controller of the Atheros AR934x SoCs
33616 + * Copyright (C) 2011-2013 Gabor Juhos <juhosg@openwrt.org>
33618 + * This program is free software; you can redistribute it and/or modify it
33619 + * under the terms of the GNU General Public License version 2 as published
33620 + * by the Free Software Foundation.
33621 + */
33623 +#include <linux/init.h>
33624 +#include <linux/interrupt.h>
33625 +#include <linux/module.h>
33626 +#include <linux/dma-mapping.h>
33627 +#include <linux/mtd/mtd.h>
33628 +#include <linux/mtd/nand.h>
33629 +#include <linux/mtd/partitions.h>
33630 +#include <linux/platform_device.h>
33631 +#include <linux/delay.h>
33632 +#include <linux/slab.h>
33634 +#include <linux/platform/ar934x_nfc.h>
33636 +#define AR934X_NFC_REG_CMD 0x00
33637 +#define AR934X_NFC_REG_CTRL 0x04
33638 +#define AR934X_NFC_REG_STATUS 0x08
33639 +#define AR934X_NFC_REG_INT_MASK 0x0c
33640 +#define AR934X_NFC_REG_INT_STATUS 0x10
33641 +#define AR934X_NFC_REG_ECC_CTRL 0x14
33642 +#define AR934X_NFC_REG_ECC_OFFSET 0x18
33643 +#define AR934X_NFC_REG_ADDR0_0 0x1c
33644 +#define AR934X_NFC_REG_ADDR0_1 0x24
33645 +#define AR934X_NFC_REG_ADDR1_0 0x20
33646 +#define AR934X_NFC_REG_ADDR1_1 0x28
33647 +#define AR934X_NFC_REG_SPARE_SIZE 0x30
33648 +#define AR934X_NFC_REG_PROTECT 0x38
33649 +#define AR934X_NFC_REG_LOOKUP_EN 0x40
33650 +#define AR934X_NFC_REG_LOOKUP(_x) (0x44 + (_i) * 4)
33651 +#define AR934X_NFC_REG_DMA_ADDR 0x64
33652 +#define AR934X_NFC_REG_DMA_COUNT 0x68
33653 +#define AR934X_NFC_REG_DMA_CTRL 0x6c
33654 +#define AR934X_NFC_REG_MEM_CTRL 0x80
33655 +#define AR934X_NFC_REG_DATA_SIZE 0x84
33656 +#define AR934X_NFC_REG_READ_STATUS 0x88
33657 +#define AR934X_NFC_REG_TIME_SEQ 0x8c
33658 +#define AR934X_NFC_REG_TIMINGS_ASYN 0x90
33659 +#define AR934X_NFC_REG_TIMINGS_SYN 0x94
33660 +#define AR934X_NFC_REG_FIFO_DATA 0x98
33661 +#define AR934X_NFC_REG_TIME_MODE 0x9c
33662 +#define AR934X_NFC_REG_DMA_ADDR_OFFS 0xa0
33663 +#define AR934X_NFC_REG_FIFO_INIT 0xb0
33664 +#define AR934X_NFC_REG_GEN_SEQ_CTRL 0xb4
33666 +#define AR934X_NFC_CMD_CMD_SEQ_S 0
33667 +#define AR934X_NFC_CMD_CMD_SEQ_M 0x3f
33668 +#define AR934X_NFC_CMD_SEQ_1C 0x00
33669 +#define AR934X_NFC_CMD_SEQ_ERASE 0x0e
33670 +#define AR934X_NFC_CMD_SEQ_12 0x0c
33671 +#define AR934X_NFC_CMD_SEQ_1C1AXR 0x21
33672 +#define AR934X_NFC_CMD_SEQ_S 0x24
33673 +#define AR934X_NFC_CMD_SEQ_1C3AXR 0x27
33674 +#define AR934X_NFC_CMD_SEQ_1C5A1CXR 0x2a
33675 +#define AR934X_NFC_CMD_SEQ_18 0x32
33676 +#define AR934X_NFC_CMD_INPUT_SEL_SIU 0
33677 +#define AR934X_NFC_CMD_INPUT_SEL_DMA BIT(6)
33678 +#define AR934X_NFC_CMD_ADDR_SEL_0 0
33679 +#define AR934X_NFC_CMD_ADDR_SEL_1 BIT(7)
33680 +#define AR934X_NFC_CMD_CMD0_S 8
33681 +#define AR934X_NFC_CMD_CMD0_M 0xff
33682 +#define AR934X_NFC_CMD_CMD1_S 16
33683 +#define AR934X_NFC_CMD_CMD1_M 0xff
33684 +#define AR934X_NFC_CMD_CMD2_S 24
33685 +#define AR934X_NFC_CMD_CMD2_M 0xff
33687 +#define AR934X_NFC_CTRL_ADDR_CYCLE0_M 0x7
33688 +#define AR934X_NFC_CTRL_ADDR_CYCLE0_S 0
33689 +#define AR934X_NFC_CTRL_SPARE_EN BIT(3)
33690 +#define AR934X_NFC_CTRL_INT_EN BIT(4)
33691 +#define AR934X_NFC_CTRL_ECC_EN BIT(5)
33692 +#define AR934X_NFC_CTRL_BLOCK_SIZE_S 6
33693 +#define AR934X_NFC_CTRL_BLOCK_SIZE_M 0x3
33694 +#define AR934X_NFC_CTRL_BLOCK_SIZE_32 0
33695 +#define AR934X_NFC_CTRL_BLOCK_SIZE_64 1
33696 +#define AR934X_NFC_CTRL_BLOCK_SIZE_128 2
33697 +#define AR934X_NFC_CTRL_BLOCK_SIZE_256 3
33698 +#define AR934X_NFC_CTRL_PAGE_SIZE_S 8
33699 +#define AR934X_NFC_CTRL_PAGE_SIZE_M 0x7
33700 +#define AR934X_NFC_CTRL_PAGE_SIZE_256 0
33701 +#define AR934X_NFC_CTRL_PAGE_SIZE_512 1
33702 +#define AR934X_NFC_CTRL_PAGE_SIZE_1024 2
33703 +#define AR934X_NFC_CTRL_PAGE_SIZE_2048 3
33704 +#define AR934X_NFC_CTRL_PAGE_SIZE_4096 4
33705 +#define AR934X_NFC_CTRL_PAGE_SIZE_8192 5
33706 +#define AR934X_NFC_CTRL_PAGE_SIZE_16384 6
33707 +#define AR934X_NFC_CTRL_CUSTOM_SIZE_EN BIT(11)
33708 +#define AR934X_NFC_CTRL_IO_WIDTH_8BITS 0
33709 +#define AR934X_NFC_CTRL_IO_WIDTH_16BITS BIT(12)
33710 +#define AR934X_NFC_CTRL_LOOKUP_EN BIT(13)
33711 +#define AR934X_NFC_CTRL_PROT_EN BIT(14)
33712 +#define AR934X_NFC_CTRL_WORK_MODE_ASYNC 0
33713 +#define AR934X_NFC_CTRL_WORK_MODE_SYNC BIT(15)
33714 +#define AR934X_NFC_CTRL_ADDR0_AUTO_INC BIT(16)
33715 +#define AR934X_NFC_CTRL_ADDR1_AUTO_INC BIT(17)
33716 +#define AR934X_NFC_CTRL_ADDR_CYCLE1_M 0x7
33717 +#define AR934X_NFC_CTRL_ADDR_CYCLE1_S 18
33718 +#define AR934X_NFC_CTRL_SMALL_PAGE BIT(21)
33720 +#define AR934X_NFC_DMA_CTRL_DMA_START BIT(7)
33721 +#define AR934X_NFC_DMA_CTRL_DMA_DIR_WRITE 0
33722 +#define AR934X_NFC_DMA_CTRL_DMA_DIR_READ BIT(6)
33723 +#define AR934X_NFC_DMA_CTRL_DMA_MODE_SG BIT(5)
33724 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_S 2
33725 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_0 0
33726 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_1 1
33727 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_2 2
33728 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_3 3
33729 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_4 4
33730 +#define AR934X_NFC_DMA_CTRL_DMA_BURST_5 5
33731 +#define AR934X_NFC_DMA_CTRL_ERR_FLAG BIT(1)
33732 +#define AR934X_NFC_DMA_CTRL_DMA_READY BIT(0)
33734 +#define AR934X_NFC_INT_DEV_RDY(_x) BIT(4 + (_x))
33735 +#define AR934X_NFC_INT_CMD_END BIT(1)
33737 +#define AR934X_NFC_ECC_CTRL_ERR_THRES_S 8
33738 +#define AR934X_NFC_ECC_CTRL_ERR_THRES_M 0x1f
33739 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_S 5
33740 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_M 0x7
33741 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_2 0
33742 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_4 1
33743 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_6 2
33744 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_8 3
33745 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_10 4
33746 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_12 5
33747 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_14 6
33748 +#define AR934X_NFC_ECC_CTRL_ECC_CAP_16 7
33749 +#define AR934X_NFC_ECC_CTRL_ERR_OVER BIT(2)
33750 +#define AR934X_NFC_ECC_CTRL_ERR_UNCORRECT BIT(1)
33751 +#define AR934X_NFC_ECC_CTRL_ERR_CORRECT BIT(0)
33753 +#define AR934X_NFC_ECC_OFFS_OFSET_M 0xffff
33755 +/* default timing values */
33756 +#define AR934X_NFC_TIME_SEQ_DEFAULT 0x7fff
33757 +#define AR934X_NFC_TIMINGS_ASYN_DEFAULT 0x22
33758 +#define AR934X_NFC_TIMINGS_SYN_DEFAULT 0xf
33760 +#define AR934X_NFC_ID_BUF_SIZE 8
33761 +#define AR934X_NFC_DEV_READY_TIMEOUT 25 /* msecs */
33762 +#define AR934X_NFC_DMA_READY_TIMEOUT 25 /* msecs */
33763 +#define AR934X_NFC_DONE_TIMEOUT 1000
33764 +#define AR934X_NFC_DMA_RETRIES 20
33766 +#define AR934X_NFC_USE_IRQ true
33767 +#define AR934X_NFC_IRQ_MASK AR934X_NFC_INT_DEV_RDY(0)
33769 +#define AR934X_NFC_GENSEQ_SMALL_PAGE_READ 0x30043
33771 +#undef AR934X_NFC_DEBUG_DATA
33772 +#undef AR934X_NFC_DEBUG
33774 +struct ar934x_nfc;
33776 +static inline __attribute__ ((format (printf, 2, 3)))
33777 +void _nfc_dbg(struct ar934x_nfc *nfc, const char *fmt, ...)
33781 +#ifdef AR934X_NFC_DEBUG
33782 +#define nfc_dbg(_nfc, fmt, ...) \
33783 + dev_info((_nfc)->parent, fmt, ##__VA_ARGS__)
33784 +#else
33785 +#define nfc_dbg(_nfc, fmt, ...) \
33786 + _nfc_dbg((_nfc), fmt, ##__VA_ARGS__)
33787 +#endif /* AR934X_NFC_DEBUG */
33789 +#ifdef AR934X_NFC_DEBUG_DATA
33790 +static void
33791 +nfc_debug_data(const char *label, void *data, int len)
33793 + print_hex_dump(KERN_WARNING, label, DUMP_PREFIX_OFFSET, 16, 1,
33794 + data, len, 0);
33796 +#else
33797 +static inline void
33798 +nfc_debug_data(const char *label, void *data, int len) {}
33799 +#endif /* AR934X_NFC_DEBUG_DATA */
33801 +struct ar934x_nfc {
33802 + struct mtd_info mtd;
33803 + struct nand_chip nand_chip;
33804 + struct device *parent;
33805 + void __iomem *base;
33806 + void (*select_chip)(int chip_no);
33807 + bool swap_dma;
33808 + int irq;
33809 + wait_queue_head_t irq_waitq;
33811 + bool spurious_irq_expected;
33812 + u32 irq_status;
33814 + u32 ctrl_reg;
33815 + u32 ecc_ctrl_reg;
33816 + u32 ecc_offset_reg;
33817 + u32 ecc_thres;
33818 + u32 ecc_oob_pos;
33820 + bool small_page;
33821 + unsigned int addr_count0;
33822 + unsigned int addr_count1;
33824 + u8 *buf;
33825 + dma_addr_t buf_dma;
33826 + unsigned int buf_size;
33827 + int buf_index;
33829 + bool read_id;
33831 + int erase1_page_addr;
33833 + int rndout_page_addr;
33834 + int rndout_read_cmd;
33836 + int seqin_page_addr;
33837 + int seqin_column;
33838 + int seqin_read_cmd;
33841 +static void ar934x_nfc_restart(struct ar934x_nfc *nfc);
33843 +static inline bool
33844 +is_all_ff(u8 *buf, int len)
33846 + while (len--)
33847 + if (buf[len] != 0xff)
33848 + return false;
33850 + return true;
33853 +static inline void
33854 +ar934x_nfc_wr(struct ar934x_nfc *nfc, unsigned reg, u32 val)
33856 + __raw_writel(val, nfc->base + reg);
33859 +static inline u32
33860 +ar934x_nfc_rr(struct ar934x_nfc *nfc, unsigned reg)
33862 + return __raw_readl(nfc->base + reg);
33865 +static inline struct ar934x_nfc_platform_data *
33866 +ar934x_nfc_get_platform_data(struct ar934x_nfc *nfc)
33868 + return nfc->parent->platform_data;
33871 +static inline struct
33872 +ar934x_nfc *mtd_to_ar934x_nfc(struct mtd_info *mtd)
33874 + return container_of(mtd, struct ar934x_nfc, mtd);
33877 +static inline bool ar934x_nfc_use_irq(struct ar934x_nfc *nfc)
33879 + return AR934X_NFC_USE_IRQ;
33882 +static inline void ar934x_nfc_write_cmd_reg(struct ar934x_nfc *nfc, u32 cmd_reg)
33884 + wmb();
33886 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CMD, cmd_reg);
33887 + /* flush write */
33888 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_CMD);
33891 +static bool
33892 +__ar934x_nfc_dev_ready(struct ar934x_nfc *nfc)
33894 + u32 status;
33896 + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_STATUS);
33897 + return (status & 0xff) == 0xff;
33900 +static inline bool
33901 +__ar934x_nfc_is_dma_ready(struct ar934x_nfc *nfc)
33903 + u32 status;
33905 + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_DMA_CTRL);
33906 + return (status & AR934X_NFC_DMA_CTRL_DMA_READY) != 0;
33909 +static int
33910 +ar934x_nfc_wait_dev_ready(struct ar934x_nfc *nfc)
33912 + unsigned long timeout;
33914 + timeout = jiffies + msecs_to_jiffies(AR934X_NFC_DEV_READY_TIMEOUT);
33915 + do {
33916 + if (__ar934x_nfc_dev_ready(nfc))
33917 + return 0;
33918 + } while time_before(jiffies, timeout);
33920 + nfc_dbg(nfc, "timeout waiting for device ready, status:%08x int:%08x\n",
33921 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_STATUS),
33922 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS));
33923 + return -ETIMEDOUT;
33926 +static int
33927 +ar934x_nfc_wait_dma_ready(struct ar934x_nfc *nfc)
33929 + unsigned long timeout;
33931 + timeout = jiffies + msecs_to_jiffies(AR934X_NFC_DMA_READY_TIMEOUT);
33932 + do {
33933 + if (__ar934x_nfc_is_dma_ready(nfc))
33934 + return 0;
33935 + } while time_before(jiffies, timeout);
33937 + nfc_dbg(nfc, "timeout waiting for DMA ready, dma_ctrl:%08x\n",
33938 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_DMA_CTRL));
33939 + return -ETIMEDOUT;
33942 +static int
33943 +ar934x_nfc_wait_irq(struct ar934x_nfc *nfc)
33945 + long timeout;
33946 + int ret;
33948 + timeout = wait_event_timeout(nfc->irq_waitq,
33949 + (nfc->irq_status & AR934X_NFC_IRQ_MASK) != 0,
33950 + msecs_to_jiffies(AR934X_NFC_DEV_READY_TIMEOUT));
33952 + ret = 0;
33953 + if (!timeout) {
33954 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_MASK, 0);
33955 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
33956 + /* flush write */
33957 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
33959 + nfc_dbg(nfc,
33960 + "timeout waiting for interrupt, status:%08x\n",
33961 + nfc->irq_status);
33962 + ret = -ETIMEDOUT;
33965 + nfc->irq_status = 0;
33966 + return ret;
33969 +static int
33970 +ar934x_nfc_wait_done(struct ar934x_nfc *nfc)
33972 + int ret;
33974 + if (ar934x_nfc_use_irq(nfc))
33975 + ret = ar934x_nfc_wait_irq(nfc);
33976 + else
33977 + ret = ar934x_nfc_wait_dev_ready(nfc);
33979 + if (ret)
33980 + return ret;
33982 + return ar934x_nfc_wait_dma_ready(nfc);
33985 +static int
33986 +ar934x_nfc_alloc_buf(struct ar934x_nfc *nfc, unsigned size)
33988 + nfc->buf = dma_alloc_coherent(nfc->parent, size,
33989 + &nfc->buf_dma, GFP_KERNEL);
33990 + if (nfc->buf == NULL) {
33991 + dev_err(nfc->parent, "no memory for DMA buffer\n");
33992 + return -ENOMEM;
33995 + nfc->buf_size = size;
33996 + nfc_dbg(nfc, "buf:%p size:%u\n", nfc->buf, nfc->buf_size);
33998 + return 0;
34001 +static void
34002 +ar934x_nfc_free_buf(struct ar934x_nfc *nfc)
34004 + dma_free_coherent(nfc->parent, nfc->buf_size, nfc->buf, nfc->buf_dma);
34007 +static void
34008 +ar934x_nfc_get_addr(struct ar934x_nfc *nfc, int column, int page_addr,
34009 + u32 *addr0, u32 *addr1)
34011 + u32 a0, a1;
34013 + a0 = 0;
34014 + a1 = 0;
34016 + if (column == -1) {
34017 + /* ERASE1 */
34018 + a0 = (page_addr & 0xffff) << 16;
34019 + a1 = (page_addr >> 16) & 0xf;
34020 + } else if (page_addr != -1) {
34021 + /* SEQIN, READ0, etc.. */
34023 + /* TODO: handle 16bit bus width */
34024 + if (nfc->small_page) {
34025 + a0 = column & 0xff;
34026 + a0 |= (page_addr & 0xff) << 8;
34027 + a0 |= ((page_addr >> 8) & 0xff) << 16;
34028 + a0 |= ((page_addr >> 16) & 0xff) << 24;
34029 + } else {
34030 + a0 = column & 0x0FFF;
34031 + a0 |= (page_addr & 0xffff) << 16;
34033 + if (nfc->addr_count0 > 4)
34034 + a1 = (page_addr >> 16) & 0xf;
34038 + *addr0 = a0;
34039 + *addr1 = a1;
34042 +static void
34043 +ar934x_nfc_send_cmd(struct ar934x_nfc *nfc, unsigned command)
34045 + u32 cmd_reg;
34047 + cmd_reg = AR934X_NFC_CMD_INPUT_SEL_SIU | AR934X_NFC_CMD_ADDR_SEL_0 |
34048 + AR934X_NFC_CMD_SEQ_1C;
34049 + cmd_reg |= (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
34051 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
34052 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
34054 + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
34055 + ar934x_nfc_wait_dev_ready(nfc);
34058 +static int
34059 +ar934x_nfc_do_rw_command(struct ar934x_nfc *nfc, int column, int page_addr,
34060 + int len, u32 cmd_reg, u32 ctrl_reg, bool write)
34062 + u32 addr0, addr1;
34063 + u32 dma_ctrl;
34064 + int dir;
34065 + int err;
34066 + int retries = 0;
34068 + WARN_ON(len & 3);
34070 + if (WARN_ON(len > nfc->buf_size))
34071 + dev_err(nfc->parent, "len=%d > buf_size=%d", len, nfc->buf_size);
34073 + if (write) {
34074 + dma_ctrl = AR934X_NFC_DMA_CTRL_DMA_DIR_WRITE;
34075 + dir = DMA_TO_DEVICE;
34076 + } else {
34077 + dma_ctrl = AR934X_NFC_DMA_CTRL_DMA_DIR_READ;
34078 + dir = DMA_FROM_DEVICE;
34081 + ar934x_nfc_get_addr(nfc, column, page_addr, &addr0, &addr1);
34083 + dma_ctrl |= AR934X_NFC_DMA_CTRL_DMA_START |
34084 + (AR934X_NFC_DMA_CTRL_DMA_BURST_3 <<
34085 + AR934X_NFC_DMA_CTRL_DMA_BURST_S);
34087 + cmd_reg |= AR934X_NFC_CMD_INPUT_SEL_DMA | AR934X_NFC_CMD_ADDR_SEL_0;
34088 + ctrl_reg |= AR934X_NFC_CTRL_INT_EN;
34090 + nfc_dbg(nfc, "%s a0:%08x a1:%08x len:%x cmd:%08x dma:%08x ctrl:%08x\n",
34091 + (write) ? "write" : "read",
34092 + addr0, addr1, len, cmd_reg, dma_ctrl, ctrl_reg);
34094 +retry:
34095 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
34096 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_0, addr0);
34097 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_1, addr1);
34098 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_ADDR, nfc->buf_dma);
34099 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_COUNT, len);
34100 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DATA_SIZE, len);
34101 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, ctrl_reg);
34102 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_CTRL, dma_ctrl);
34103 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ECC_CTRL, nfc->ecc_ctrl_reg);
34104 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ECC_OFFSET, nfc->ecc_offset_reg);
34106 + if (ar934x_nfc_use_irq(nfc)) {
34107 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_MASK, AR934X_NFC_IRQ_MASK);
34108 + /* flush write */
34109 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_MASK);
34112 + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
34113 + err = ar934x_nfc_wait_done(nfc);
34114 + if (err) {
34115 + dev_dbg(nfc->parent, "%s operation stuck at page %d\n",
34116 + (write) ? "write" : "read", page_addr);
34118 + ar934x_nfc_restart(nfc);
34119 + if (retries++ < AR934X_NFC_DMA_RETRIES)
34120 + goto retry;
34122 + dev_err(nfc->parent, "%s operation failed on page %d\n",
34123 + (write) ? "write" : "read", page_addr);
34126 + return err;
34129 +static int
34130 +ar934x_nfc_send_readid(struct ar934x_nfc *nfc, unsigned command)
34132 + u32 cmd_reg;
34133 + int err;
34135 + nfc_dbg(nfc, "readid, cmd:%02x\n", command);
34137 + cmd_reg = AR934X_NFC_CMD_SEQ_1C1AXR;
34138 + cmd_reg |= (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
34140 + err = ar934x_nfc_do_rw_command(nfc, -1, -1, AR934X_NFC_ID_BUF_SIZE,
34141 + cmd_reg, nfc->ctrl_reg, false);
34143 + nfc_debug_data("[id] ", nfc->buf, AR934X_NFC_ID_BUF_SIZE);
34145 + return err;
34148 +static int
34149 +ar934x_nfc_send_read(struct ar934x_nfc *nfc, unsigned command, int column,
34150 + int page_addr, int len)
34152 + u32 cmd_reg;
34153 + int err;
34155 + nfc_dbg(nfc, "read, column=%d page=%d len=%d\n",
34156 + column, page_addr, len);
34158 + cmd_reg = (command & AR934X_NFC_CMD_CMD0_M) << AR934X_NFC_CMD_CMD0_S;
34160 + if (nfc->small_page) {
34161 + cmd_reg |= AR934X_NFC_CMD_SEQ_18;
34162 + } else {
34163 + cmd_reg |= NAND_CMD_READSTART << AR934X_NFC_CMD_CMD1_S;
34164 + cmd_reg |= AR934X_NFC_CMD_SEQ_1C5A1CXR;
34167 + err = ar934x_nfc_do_rw_command(nfc, column, page_addr, len,
34168 + cmd_reg, nfc->ctrl_reg, false);
34170 + nfc_debug_data("[data] ", nfc->buf, len);
34172 + return err;
34175 +static void
34176 +ar934x_nfc_send_erase(struct ar934x_nfc *nfc, unsigned command, int column,
34177 + int page_addr)
34179 + u32 addr0, addr1;
34180 + u32 ctrl_reg;
34181 + u32 cmd_reg;
34183 + ar934x_nfc_get_addr(nfc, column, page_addr, &addr0, &addr1);
34185 + ctrl_reg = nfc->ctrl_reg;
34186 + if (nfc->small_page) {
34187 + /* override number of address cycles for the erase command */
34188 + ctrl_reg &= ~(AR934X_NFC_CTRL_ADDR_CYCLE0_M <<
34189 + AR934X_NFC_CTRL_ADDR_CYCLE0_S);
34190 + ctrl_reg &= ~(AR934X_NFC_CTRL_ADDR_CYCLE1_M <<
34191 + AR934X_NFC_CTRL_ADDR_CYCLE1_S);
34192 + ctrl_reg &= ~(AR934X_NFC_CTRL_SMALL_PAGE);
34193 + ctrl_reg |= (nfc->addr_count0 + 1) <<
34194 + AR934X_NFC_CTRL_ADDR_CYCLE0_S;
34197 + cmd_reg = NAND_CMD_ERASE1 << AR934X_NFC_CMD_CMD0_S;
34198 + cmd_reg |= command << AR934X_NFC_CMD_CMD1_S;
34199 + cmd_reg |= AR934X_NFC_CMD_SEQ_ERASE;
34201 + nfc_dbg(nfc, "erase page %d, a0:%08x a1:%08x cmd:%08x ctrl:%08x\n",
34202 + page_addr, addr0, addr1, cmd_reg, ctrl_reg);
34204 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
34205 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, ctrl_reg);
34206 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_0, addr0);
34207 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_ADDR0_1, addr1);
34209 + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
34210 + ar934x_nfc_wait_dev_ready(nfc);
34213 +static int
34214 +ar934x_nfc_send_write(struct ar934x_nfc *nfc, unsigned command, int column,
34215 + int page_addr, int len)
34217 + u32 cmd_reg;
34219 + nfc_dbg(nfc, "write, column=%d page=%d len=%d\n",
34220 + column, page_addr, len);
34222 + nfc_debug_data("[data] ", nfc->buf, len);
34224 + cmd_reg = NAND_CMD_SEQIN << AR934X_NFC_CMD_CMD0_S;
34225 + cmd_reg |= command << AR934X_NFC_CMD_CMD1_S;
34226 + cmd_reg |= AR934X_NFC_CMD_SEQ_12;
34228 + return ar934x_nfc_do_rw_command(nfc, column, page_addr, len,
34229 + cmd_reg, nfc->ctrl_reg, true);
34232 +static void
34233 +ar934x_nfc_read_status(struct ar934x_nfc *nfc)
34235 + u32 cmd_reg;
34236 + u32 status;
34238 + cmd_reg = NAND_CMD_STATUS << AR934X_NFC_CMD_CMD0_S;
34239 + cmd_reg |= AR934X_NFC_CMD_SEQ_S;
34241 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
34242 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
34244 + ar934x_nfc_write_cmd_reg(nfc, cmd_reg);
34245 + ar934x_nfc_wait_dev_ready(nfc);
34247 + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_READ_STATUS);
34249 + nfc_dbg(nfc, "read status, cmd:%08x status:%02x\n",
34250 + cmd_reg, (status & 0xff));
34252 + if (nfc->swap_dma)
34253 + nfc->buf[0 ^ 3] = status;
34254 + else
34255 + nfc->buf[0] = status;
34258 +static void
34259 +ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command, int column,
34260 + int page_addr)
34262 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34263 + struct nand_chip *nand = mtd->priv;
34265 + nfc->read_id = false;
34266 + if (command != NAND_CMD_PAGEPROG)
34267 + nfc->buf_index = 0;
34269 + switch (command) {
34270 + case NAND_CMD_RESET:
34271 + ar934x_nfc_send_cmd(nfc, command);
34272 + break;
34274 + case NAND_CMD_READID:
34275 + nfc->read_id = true;
34276 + ar934x_nfc_send_readid(nfc, command);
34277 + break;
34279 + case NAND_CMD_READ0:
34280 + case NAND_CMD_READ1:
34281 + if (nfc->small_page) {
34282 + ar934x_nfc_send_read(nfc, command, column, page_addr,
34283 + mtd->writesize + mtd->oobsize);
34284 + } else {
34285 + ar934x_nfc_send_read(nfc, command, 0, page_addr,
34286 + mtd->writesize + mtd->oobsize);
34287 + nfc->buf_index = column;
34288 + nfc->rndout_page_addr = page_addr;
34289 + nfc->rndout_read_cmd = command;
34291 + break;
34293 + case NAND_CMD_READOOB:
34294 + if (nfc->small_page)
34295 + ar934x_nfc_send_read(nfc, NAND_CMD_READOOB,
34296 + column, page_addr,
34297 + mtd->oobsize);
34298 + else
34299 + ar934x_nfc_send_read(nfc, NAND_CMD_READ0,
34300 + mtd->writesize, page_addr,
34301 + mtd->oobsize);
34302 + break;
34304 + case NAND_CMD_RNDOUT:
34305 + if (WARN_ON(nfc->small_page))
34306 + break;
34308 + /* emulate subpage read */
34309 + ar934x_nfc_send_read(nfc, nfc->rndout_read_cmd, 0,
34310 + nfc->rndout_page_addr,
34311 + mtd->writesize + mtd->oobsize);
34312 + nfc->buf_index = column;
34313 + break;
34315 + case NAND_CMD_ERASE1:
34316 + nfc->erase1_page_addr = page_addr;
34317 + break;
34319 + case NAND_CMD_ERASE2:
34320 + ar934x_nfc_send_erase(nfc, command, -1, nfc->erase1_page_addr);
34321 + break;
34323 + case NAND_CMD_STATUS:
34324 + ar934x_nfc_read_status(nfc);
34325 + break;
34327 + case NAND_CMD_SEQIN:
34328 + if (nfc->small_page) {
34329 + /* output read command */
34330 + if (column >= mtd->writesize) {
34331 + column -= mtd->writesize;
34332 + nfc->seqin_read_cmd = NAND_CMD_READOOB;
34333 + } else if (column < 256) {
34334 + nfc->seqin_read_cmd = NAND_CMD_READ0;
34335 + } else {
34336 + column -= 256;
34337 + nfc->seqin_read_cmd = NAND_CMD_READ1;
34339 + } else {
34340 + nfc->seqin_read_cmd = NAND_CMD_READ0;
34342 + nfc->seqin_column = column;
34343 + nfc->seqin_page_addr = page_addr;
34344 + break;
34346 + case NAND_CMD_PAGEPROG:
34347 + if (nand->ecc.mode == NAND_ECC_HW) {
34348 + /* the data is already written */
34349 + break;
34352 + if (nfc->small_page)
34353 + ar934x_nfc_send_cmd(nfc, nfc->seqin_read_cmd);
34355 + ar934x_nfc_send_write(nfc, command, nfc->seqin_column,
34356 + nfc->seqin_page_addr,
34357 + nfc->buf_index);
34358 + break;
34360 + default:
34361 + dev_err(nfc->parent,
34362 + "unsupported command: %x, column:%d page_addr=%d\n",
34363 + command, column, page_addr);
34364 + break;
34368 +static int
34369 +ar934x_nfc_dev_ready(struct mtd_info *mtd)
34371 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34373 + return __ar934x_nfc_dev_ready(nfc);
34376 +static void
34377 +ar934x_nfc_select_chip(struct mtd_info *mtd, int chip_no)
34379 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34381 + if (nfc->select_chip)
34382 + nfc->select_chip(chip_no);
34385 +static u8
34386 +ar934x_nfc_read_byte(struct mtd_info *mtd)
34388 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34389 + u8 data;
34391 + WARN_ON(nfc->buf_index >= nfc->buf_size);
34393 + if (nfc->swap_dma || nfc->read_id)
34394 + data = nfc->buf[nfc->buf_index ^ 3];
34395 + else
34396 + data = nfc->buf[nfc->buf_index];
34398 + nfc->buf_index++;
34400 + return data;
34403 +static void
34404 +ar934x_nfc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
34406 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34407 + int i;
34409 + WARN_ON(nfc->buf_index + len > nfc->buf_size);
34411 + if (nfc->swap_dma) {
34412 + for (i = 0; i < len; i++) {
34413 + nfc->buf[nfc->buf_index ^ 3] = buf[i];
34414 + nfc->buf_index++;
34416 + } else {
34417 + for (i = 0; i < len; i++) {
34418 + nfc->buf[nfc->buf_index] = buf[i];
34419 + nfc->buf_index++;
34424 +static void
34425 +ar934x_nfc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
34427 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34428 + int buf_index;
34429 + int i;
34431 + WARN_ON(nfc->buf_index + len > nfc->buf_size);
34433 + buf_index = nfc->buf_index;
34435 + if (nfc->swap_dma || nfc->read_id) {
34436 + for (i = 0; i < len; i++) {
34437 + buf[i] = nfc->buf[buf_index ^ 3];
34438 + buf_index++;
34440 + } else {
34441 + for (i = 0; i < len; i++) {
34442 + buf[i] = nfc->buf[buf_index];
34443 + buf_index++;
34447 + nfc->buf_index = buf_index;
34450 +static inline void
34451 +ar934x_nfc_enable_hwecc(struct ar934x_nfc *nfc)
34453 + nfc->ctrl_reg |= AR934X_NFC_CTRL_ECC_EN;
34454 + nfc->ctrl_reg &= ~AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
34457 +static inline void
34458 +ar934x_nfc_disable_hwecc(struct ar934x_nfc *nfc)
34460 + nfc->ctrl_reg &= ~AR934X_NFC_CTRL_ECC_EN;
34461 + nfc->ctrl_reg |= AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
34464 +static int
34465 +ar934x_nfc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
34466 + int page)
34468 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34469 + int err;
34471 + nfc_dbg(nfc, "read_oob: page:%d\n", page);
34473 + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, mtd->writesize, page,
34474 + mtd->oobsize);
34475 + if (err)
34476 + return err;
34478 + memcpy(chip->oob_poi, nfc->buf, mtd->oobsize);
34480 + return 0;
34483 +static int
34484 +ar934x_nfc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
34485 + int page)
34487 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34489 + nfc_dbg(nfc, "write_oob: page:%d\n", page);
34491 + memcpy(nfc->buf, chip->oob_poi, mtd->oobsize);
34493 + return ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, mtd->writesize,
34494 + page, mtd->oobsize);
34497 +static int
34498 +ar934x_nfc_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
34499 + u8 *buf, int oob_required, int page)
34501 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34502 + int len;
34503 + int err;
34505 + nfc_dbg(nfc, "read_page_raw: page:%d oob:%d\n", page, oob_required);
34507 + len = mtd->writesize;
34508 + if (oob_required)
34509 + len += mtd->oobsize;
34511 + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, 0, page, len);
34512 + if (err)
34513 + return err;
34515 + memcpy(buf, nfc->buf, mtd->writesize);
34517 + if (oob_required)
34518 + memcpy(chip->oob_poi, &nfc->buf[mtd->writesize], mtd->oobsize);
34520 + return 0;
34523 +static int
34524 +ar934x_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
34525 + u8 *buf, int oob_required, int page)
34527 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34528 + u32 ecc_ctrl;
34529 + int max_bitflips = 0;
34530 + bool ecc_failed;
34531 + bool ecc_corrected;
34532 + int err;
34534 + nfc_dbg(nfc, "read_page: page:%d oob:%d\n", page, oob_required);
34536 + ar934x_nfc_enable_hwecc(nfc);
34537 + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, 0, page,
34538 + mtd->writesize);
34539 + ar934x_nfc_disable_hwecc(nfc);
34541 + if (err)
34542 + return err;
34544 + /* TODO: optimize to avoid memcpy */
34545 + memcpy(buf, nfc->buf, mtd->writesize);
34547 + /* read the ECC status */
34548 + ecc_ctrl = ar934x_nfc_rr(nfc, AR934X_NFC_REG_ECC_CTRL);
34549 + ecc_failed = ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_UNCORRECT;
34550 + ecc_corrected = ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_CORRECT;
34552 + if (oob_required || ecc_failed) {
34553 + err = ar934x_nfc_send_read(nfc, NAND_CMD_READ0, mtd->writesize,
34554 + page, mtd->oobsize);
34555 + if (err)
34556 + return err;
34558 + if (oob_required)
34559 + memcpy(chip->oob_poi, nfc->buf, mtd->oobsize);
34562 + if (ecc_failed) {
34563 + /*
34564 + * The hardware ECC engine reports uncorrectable errors
34565 + * on empty pages. Check the ECC bytes and the data. If
34566 + * both contains 0xff bytes only, dont report a failure.
34568 + * TODO: prebuild a buffer with 0xff bytes and use memcmp
34569 + * for better performance?
34570 + */
34571 + if (!is_all_ff(&nfc->buf[nfc->ecc_oob_pos], chip->ecc.total) ||
34572 + !is_all_ff(buf, mtd->writesize))
34573 + mtd->ecc_stats.failed++;
34574 + } else if (ecc_corrected) {
34575 + /*
34576 + * The hardware does not report the exact count of the
34577 + * corrected bitflips, use assumptions based on the
34578 + * threshold.
34579 + */
34580 + if (ecc_ctrl & AR934X_NFC_ECC_CTRL_ERR_OVER) {
34581 + /*
34582 + * The number of corrected bitflips exceeds the
34583 + * threshold. Assume the maximum.
34584 + */
34585 + max_bitflips = chip->ecc.strength * chip->ecc.steps;
34586 + } else {
34587 + max_bitflips = nfc->ecc_thres * chip->ecc.steps;
34590 + mtd->ecc_stats.corrected += max_bitflips;
34593 + return max_bitflips;
34596 +static int
34597 +ar934x_nfc_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
34598 + const u8 *buf, int oob_required)
34600 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34601 + int page;
34602 + int len;
34604 + page = nfc->seqin_page_addr;
34606 + nfc_dbg(nfc, "write_page_raw: page:%d oob:%d\n", page, oob_required);
34608 + memcpy(nfc->buf, buf, mtd->writesize);
34609 + len = mtd->writesize;
34611 + if (oob_required) {
34612 + memcpy(&nfc->buf[mtd->writesize], chip->oob_poi, mtd->oobsize);
34613 + len += mtd->oobsize;
34616 + return ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, 0, page, len);
34619 +static int
34620 +ar934x_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
34621 + const u8 *buf, int oob_required)
34623 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34624 + int page;
34625 + int err;
34627 + page = nfc->seqin_page_addr;
34629 + nfc_dbg(nfc, "write_page: page:%d oob:%d\n", page, oob_required);
34631 + /* write OOB first */
34632 + if (oob_required &&
34633 + !is_all_ff(chip->oob_poi, mtd->oobsize)) {
34634 + err = ar934x_nfc_write_oob(mtd, chip, page);
34635 + if (err)
34636 + return err;
34639 + /* TODO: optimize to avoid memcopy */
34640 + memcpy(nfc->buf, buf, mtd->writesize);
34642 + ar934x_nfc_enable_hwecc(nfc);
34643 + err = ar934x_nfc_send_write(nfc, NAND_CMD_PAGEPROG, 0, page,
34644 + mtd->writesize);
34645 + ar934x_nfc_disable_hwecc(nfc);
34647 + return err;
34650 +static void
34651 +ar934x_nfc_hw_init(struct ar934x_nfc *nfc)
34653 + struct ar934x_nfc_platform_data *pdata;
34655 + pdata = ar934x_nfc_get_platform_data(nfc);
34656 + if (pdata->hw_reset) {
34657 + pdata->hw_reset(true);
34658 + pdata->hw_reset(false);
34661 + /*
34662 + * setup timings
34663 + * TODO: make it configurable via platform data
34664 + */
34665 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIME_SEQ,
34666 + AR934X_NFC_TIME_SEQ_DEFAULT);
34667 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIMINGS_ASYN,
34668 + AR934X_NFC_TIMINGS_ASYN_DEFAULT);
34669 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_TIMINGS_SYN,
34670 + AR934X_NFC_TIMINGS_SYN_DEFAULT);
34672 + /* disable WP on all chips, and select chip 0 */
34673 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_MEM_CTRL, 0xff00);
34675 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_DMA_ADDR_OFFS, 0);
34677 + /* initialize Control register */
34678 + nfc->ctrl_reg = AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
34679 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
34681 + if (nfc->small_page) {
34682 + /* Setup generic sequence register for small page reads. */
34683 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_GEN_SEQ_CTRL,
34684 + AR934X_NFC_GENSEQ_SMALL_PAGE_READ);
34688 +static void
34689 +ar934x_nfc_restart(struct ar934x_nfc *nfc)
34691 + u32 ctrl_reg;
34693 + if (nfc->select_chip)
34694 + nfc->select_chip(-1);
34696 + ctrl_reg = nfc->ctrl_reg;
34697 + ar934x_nfc_hw_init(nfc);
34698 + nfc->ctrl_reg = ctrl_reg;
34700 + if (nfc->select_chip)
34701 + nfc->select_chip(0);
34703 + ar934x_nfc_send_cmd(nfc, NAND_CMD_RESET);
34706 +static irqreturn_t
34707 +ar934x_nfc_irq_handler(int irq, void *data)
34709 + struct ar934x_nfc *nfc = data;
34710 + u32 status;
34712 + status = ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
34714 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_INT_STATUS, 0);
34715 + /* flush write */
34716 + ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_STATUS);
34718 + status &= ar934x_nfc_rr(nfc, AR934X_NFC_REG_INT_MASK);
34719 + if (status) {
34720 + nfc_dbg(nfc, "got IRQ, status:%08x\n", status);
34722 + nfc->irq_status = status;
34723 + nfc->spurious_irq_expected = true;
34724 + wake_up(&nfc->irq_waitq);
34725 + } else {
34726 + if (nfc->spurious_irq_expected) {
34727 + nfc->spurious_irq_expected = false;
34728 + } else {
34729 + dev_warn(nfc->parent, "spurious interrupt\n");
34733 + return IRQ_HANDLED;
34736 +static int
34737 +ar934x_nfc_init_tail(struct mtd_info *mtd)
34739 + struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
34740 + struct nand_chip *chip = &nfc->nand_chip;
34741 + u32 ctrl;
34742 + u32 t;
34743 + int err;
34745 + switch (mtd->oobsize) {
34746 + case 16:
34747 + case 64:
34748 + case 128:
34749 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_SPARE_SIZE, mtd->oobsize);
34750 + break;
34752 + default:
34753 + dev_err(nfc->parent, "unsupported OOB size: %d bytes\n",
34754 + mtd->oobsize);
34755 + return -ENXIO;
34758 + ctrl = AR934X_NFC_CTRL_CUSTOM_SIZE_EN;
34760 + switch (mtd->erasesize / mtd->writesize) {
34761 + case 32:
34762 + t = AR934X_NFC_CTRL_BLOCK_SIZE_32;
34763 + break;
34765 + case 64:
34766 + t = AR934X_NFC_CTRL_BLOCK_SIZE_64;
34767 + break;
34769 + case 128:
34770 + t = AR934X_NFC_CTRL_BLOCK_SIZE_128;
34771 + break;
34773 + case 256:
34774 + t = AR934X_NFC_CTRL_BLOCK_SIZE_256;
34775 + break;
34777 + default:
34778 + dev_err(nfc->parent, "unsupported block size: %u\n",
34779 + mtd->erasesize / mtd->writesize);
34780 + return -ENXIO;
34783 + ctrl |= t << AR934X_NFC_CTRL_BLOCK_SIZE_S;
34785 + switch (mtd->writesize) {
34786 + case 256:
34787 + nfc->small_page = 1;
34788 + t = AR934X_NFC_CTRL_PAGE_SIZE_256;
34789 + break;
34791 + case 512:
34792 + nfc->small_page = 1;
34793 + t = AR934X_NFC_CTRL_PAGE_SIZE_512;
34794 + break;
34796 + case 1024:
34797 + t = AR934X_NFC_CTRL_PAGE_SIZE_1024;
34798 + break;
34800 + case 2048:
34801 + t = AR934X_NFC_CTRL_PAGE_SIZE_2048;
34802 + break;
34804 + case 4096:
34805 + t = AR934X_NFC_CTRL_PAGE_SIZE_4096;
34806 + break;
34808 + case 8192:
34809 + t = AR934X_NFC_CTRL_PAGE_SIZE_8192;
34810 + break;
34812 + case 16384:
34813 + t = AR934X_NFC_CTRL_PAGE_SIZE_16384;
34814 + break;
34816 + default:
34817 + dev_err(nfc->parent, "unsupported write size: %d bytes\n",
34818 + mtd->writesize);
34819 + return -ENXIO;
34822 + ctrl |= t << AR934X_NFC_CTRL_PAGE_SIZE_S;
34824 + if (nfc->small_page) {
34825 + ctrl |= AR934X_NFC_CTRL_SMALL_PAGE;
34827 + if (chip->chipsize > (32 << 20)) {
34828 + nfc->addr_count0 = 4;
34829 + nfc->addr_count1 = 3;
34830 + } else if (chip->chipsize > (2 << 16)) {
34831 + nfc->addr_count0 = 3;
34832 + nfc->addr_count1 = 2;
34833 + } else {
34834 + nfc->addr_count0 = 2;
34835 + nfc->addr_count1 = 1;
34837 + } else {
34838 + if (chip->chipsize > (128 << 20)) {
34839 + nfc->addr_count0 = 5;
34840 + nfc->addr_count1 = 3;
34841 + } else if (chip->chipsize > (8 << 16)) {
34842 + nfc->addr_count0 = 4;
34843 + nfc->addr_count1 = 2;
34844 + } else {
34845 + nfc->addr_count0 = 3;
34846 + nfc->addr_count1 = 1;
34850 + ctrl |= nfc->addr_count0 << AR934X_NFC_CTRL_ADDR_CYCLE0_S;
34851 + ctrl |= nfc->addr_count1 << AR934X_NFC_CTRL_ADDR_CYCLE1_S;
34853 + nfc->ctrl_reg = ctrl;
34854 + ar934x_nfc_wr(nfc, AR934X_NFC_REG_CTRL, nfc->ctrl_reg);
34856 + ar934x_nfc_free_buf(nfc);
34857 + err = ar934x_nfc_alloc_buf(nfc, mtd->writesize + mtd->oobsize);
34859 + return err;
34862 +static struct nand_ecclayout ar934x_nfc_oob_64_hwecc = {
34863 + .eccbytes = 28,
34864 + .eccpos = {
34865 + 20, 21, 22, 23, 24, 25, 26,
34866 + 27, 28, 29, 30, 31, 32, 33,
34867 + 34, 35, 36, 37, 38, 39, 40,
34868 + 41, 42, 43, 44, 45, 46, 47,
34869 + },
34870 + .oobfree = {
34872 + .offset = 4,
34873 + .length = 16,
34874 + },
34876 + .offset = 48,
34877 + .length = 16,
34878 + },
34879 + },
34882 +static int
34883 +ar934x_nfc_setup_hwecc(struct ar934x_nfc *nfc)
34885 + struct nand_chip *nand = &nfc->nand_chip;
34886 + u32 ecc_cap;
34887 + u32 ecc_thres;
34889 + if (!config_enabled(CONFIG_MTD_NAND_AR934X_HW_ECC)) {
34890 + dev_err(nfc->parent, "hardware ECC support is disabled\n");
34891 + return -EINVAL;
34894 + switch (nfc->mtd.writesize) {
34895 + case 2048:
34896 + /*
34897 + * Writing a subpage separately is not supported, because
34898 + * the controller only does ECC on full-page accesses.
34899 + */
34900 + nand->options = NAND_NO_SUBPAGE_WRITE;
34902 + nand->ecc.size = 512;
34903 + nand->ecc.bytes = 7;
34904 + nand->ecc.strength = 4;
34905 + nand->ecc.layout = &ar934x_nfc_oob_64_hwecc;
34906 + break;
34908 + default:
34909 + dev_err(nfc->parent,
34910 + "hardware ECC is not available for %d byte pages\n",
34911 + nfc->mtd.writesize);
34912 + return -EINVAL;
34915 + BUG_ON(!nand->ecc.layout);
34917 + switch (nand->ecc.strength) {
34918 + case 4:
34919 + ecc_cap = AR934X_NFC_ECC_CTRL_ECC_CAP_4;
34920 + ecc_thres = 4;
34921 + break;
34923 + default:
34924 + dev_err(nfc->parent, "unsupported ECC strength %u\n",
34925 + nand->ecc.strength);
34926 + return -EINVAL;
34929 + nfc->ecc_thres = ecc_thres;
34930 + nfc->ecc_oob_pos = nand->ecc.layout->eccpos[0];
34932 + nfc->ecc_ctrl_reg = ecc_cap << AR934X_NFC_ECC_CTRL_ECC_CAP_S;
34933 + nfc->ecc_ctrl_reg |= ecc_thres << AR934X_NFC_ECC_CTRL_ERR_THRES_S;
34935 + nfc->ecc_offset_reg = nfc->mtd.writesize + nfc->ecc_oob_pos;
34937 + nand->ecc.mode = NAND_ECC_HW;
34938 + nand->ecc.read_page = ar934x_nfc_read_page;
34939 + nand->ecc.read_page_raw = ar934x_nfc_read_page_raw;
34940 + nand->ecc.write_page = ar934x_nfc_write_page;
34941 + nand->ecc.write_page_raw = ar934x_nfc_write_page_raw;
34942 + nand->ecc.read_oob = ar934x_nfc_read_oob;
34943 + nand->ecc.write_oob = ar934x_nfc_write_oob;
34945 + return 0;
34948 +static int
34949 +ar934x_nfc_probe(struct platform_device *pdev)
34951 + static const char *part_probes[] = { "cmdlinepart", NULL, };
34952 + struct ar934x_nfc_platform_data *pdata;
34953 + struct ar934x_nfc *nfc;
34954 + struct resource *res;
34955 + struct mtd_info *mtd;
34956 + struct nand_chip *nand;
34957 + struct mtd_part_parser_data ppdata;
34958 + int ret;
34960 + pdata = pdev->dev.platform_data;
34961 + if (pdata == NULL) {
34962 + dev_err(&pdev->dev, "no platform data defined\n");
34963 + return -EINVAL;
34966 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
34967 + if (!res) {
34968 + dev_err(&pdev->dev, "failed to get I/O memory\n");
34969 + return -EINVAL;
34972 + nfc = devm_kzalloc(&pdev->dev, sizeof(struct ar934x_nfc), GFP_KERNEL);
34973 + if (!nfc) {
34974 + dev_err(&pdev->dev, "failed to allocate driver data\n");
34975 + return -ENOMEM;
34978 + nfc->base = devm_ioremap_resource(&pdev->dev, res);
34979 + if (IS_ERR(nfc->base)) {
34980 + dev_err(&pdev->dev, "failed to remap I/O memory\n");
34981 + return PTR_ERR(nfc->base);
34984 + nfc->irq = platform_get_irq(pdev, 0);
34985 + if (nfc->irq < 0) {
34986 + dev_err(&pdev->dev, "no IRQ resource specified\n");
34987 + return -EINVAL;
34990 + init_waitqueue_head(&nfc->irq_waitq);
34991 + ret = request_irq(nfc->irq, ar934x_nfc_irq_handler, 0,
34992 + dev_name(&pdev->dev), nfc);
34993 + if (ret) {
34994 + dev_err(&pdev->dev, "requast_irq failed, err:%d\n", ret);
34995 + return ret;
34998 + nfc->parent = &pdev->dev;
34999 + nfc->select_chip = pdata->select_chip;
35000 + nfc->swap_dma = pdata->swap_dma;
35002 + nand = &nfc->nand_chip;
35003 + mtd = &nfc->mtd;
35005 + mtd->priv = nand;
35006 + mtd->owner = THIS_MODULE;
35007 + if (pdata->name)
35008 + mtd->name = pdata->name;
35009 + else
35010 + mtd->name = dev_name(&pdev->dev);
35012 + nand->chip_delay = 25;
35014 + nand->dev_ready = ar934x_nfc_dev_ready;
35015 + nand->cmdfunc = ar934x_nfc_cmdfunc;
35016 + nand->read_byte = ar934x_nfc_read_byte;
35017 + nand->write_buf = ar934x_nfc_write_buf;
35018 + nand->read_buf = ar934x_nfc_read_buf;
35019 + nand->select_chip = ar934x_nfc_select_chip;
35021 + ret = ar934x_nfc_alloc_buf(nfc, AR934X_NFC_ID_BUF_SIZE);
35022 + if (ret)
35023 + goto err_free_irq;
35025 + platform_set_drvdata(pdev, nfc);
35027 + ar934x_nfc_hw_init(nfc);
35029 + ret = nand_scan_ident(mtd, 1, NULL);
35030 + if (ret) {
35031 + dev_err(&pdev->dev, "nand_scan_ident failed, err:%d\n", ret);
35032 + goto err_free_buf;
35035 + ret = ar934x_nfc_init_tail(mtd);
35036 + if (ret) {
35037 + dev_err(&pdev->dev, "init tail failed, err:%d\n", ret);
35038 + goto err_free_buf;
35041 + if (pdata->scan_fixup) {
35042 + ret = pdata->scan_fixup(mtd);
35043 + if (ret)
35044 + goto err_free_buf;
35047 + switch (pdata->ecc_mode) {
35048 + case AR934X_NFC_ECC_SOFT:
35049 + nand->ecc.mode = NAND_ECC_SOFT;
35050 + break;
35052 + case AR934X_NFC_ECC_SOFT_BCH:
35053 + nand->ecc.mode = NAND_ECC_SOFT_BCH;
35054 + break;
35056 + case AR934X_NFC_ECC_HW:
35057 + ret = ar934x_nfc_setup_hwecc(nfc);
35058 + if (ret)
35059 + goto err_free_buf;
35061 + break;
35063 + default:
35064 + dev_err(nfc->parent, "unknown ECC mode %d\n", pdata->ecc_mode);
35065 + return -EINVAL;
35068 + ret = nand_scan_tail(mtd);
35069 + if (ret) {
35070 + dev_err(&pdev->dev, "scan tail failed, err:%d\n", ret);
35071 + goto err_free_buf;
35074 + memset(&ppdata, '\0', sizeof(ppdata));
35075 + ret = mtd_device_parse_register(mtd, part_probes, &ppdata,
35076 + pdata->parts, pdata->nr_parts);
35077 + if (ret) {
35078 + dev_err(&pdev->dev, "unable to register mtd, err:%d\n", ret);
35079 + goto err_free_buf;
35082 + return 0;
35084 +err_free_buf:
35085 + ar934x_nfc_free_buf(nfc);
35086 +err_free_irq:
35087 + free_irq(nfc->irq, nfc);
35088 + return ret;
35091 +static int
35092 +ar934x_nfc_remove(struct platform_device *pdev)
35094 + struct ar934x_nfc *nfc;
35096 + nfc = platform_get_drvdata(pdev);
35097 + if (nfc) {
35098 + nand_release(&nfc->mtd);
35099 + ar934x_nfc_free_buf(nfc);
35100 + free_irq(nfc->irq, nfc);
35103 + return 0;
35106 +static struct platform_driver ar934x_nfc_driver = {
35107 + .probe = ar934x_nfc_probe,
35108 + .remove = ar934x_nfc_remove,
35109 + .driver = {
35110 + .name = AR934X_NFC_DRIVER_NAME,
35111 + .owner = THIS_MODULE,
35112 + },
35115 +module_platform_driver(ar934x_nfc_driver);
35117 +MODULE_LICENSE("GPL v2");
35118 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
35119 +MODULE_DESCRIPTION("Atheros AR934x NAND Flash Controller driver");
35120 +MODULE_ALIAS("platform:" AR934X_NFC_DRIVER_NAME);
35121 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/rb4xx_nand.c linux-4.1.43/drivers/mtd/nand/rb4xx_nand.c
35122 --- linux-4.1.43.orig/drivers/mtd/nand/rb4xx_nand.c 1970-01-01 01:00:00.000000000 +0100
35123 +++ linux-4.1.43/drivers/mtd/nand/rb4xx_nand.c 2017-08-06 20:02:16.000000000 +0200
35124 @@ -0,0 +1,305 @@
35126 + * NAND flash driver for the MikroTik RouterBoard 4xx series
35128 + * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
35129 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
35131 + * This file was based on the driver for Linux 2.6.22 published by
35132 + * MikroTik for their RouterBoard 4xx series devices.
35134 + * This program is free software; you can redistribute it and/or modify it
35135 + * under the terms of the GNU General Public License version 2 as published
35136 + * by the Free Software Foundation.
35137 + */
35139 +#include <linux/kernel.h>
35140 +#include <linux/module.h>
35141 +#include <linux/init.h>
35142 +#include <linux/mtd/nand.h>
35143 +#include <linux/mtd/mtd.h>
35144 +#include <linux/mtd/partitions.h>
35145 +#include <linux/platform_device.h>
35146 +#include <linux/delay.h>
35147 +#include <linux/io.h>
35148 +#include <linux/gpio.h>
35149 +#include <linux/slab.h>
35151 +#include <asm/mach-ath79/ath79.h>
35152 +#include <asm/mach-ath79/rb4xx_cpld.h>
35154 +#define DRV_NAME "rb4xx-nand"
35155 +#define DRV_VERSION "0.2.0"
35156 +#define DRV_DESC "NAND flash driver for RouterBoard 4xx series"
35158 +#define RB4XX_NAND_GPIO_READY 5
35159 +#define RB4XX_NAND_GPIO_ALE 37
35160 +#define RB4XX_NAND_GPIO_CLE 38
35161 +#define RB4XX_NAND_GPIO_NCE 39
35163 +struct rb4xx_nand_info {
35164 + struct nand_chip chip;
35165 + struct mtd_info mtd;
35169 + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
35170 + * will not be able to find the kernel that we load.
35171 + */
35172 +static struct nand_ecclayout rb4xx_nand_ecclayout = {
35173 + .eccbytes = 6,
35174 + .eccpos = { 8, 9, 10, 13, 14, 15 },
35175 + .oobavail = 9,
35176 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
35179 +static struct mtd_partition rb4xx_nand_partitions[] = {
35181 + .name = "booter",
35182 + .offset = 0,
35183 + .size = (256 * 1024),
35184 + .mask_flags = MTD_WRITEABLE,
35185 + },
35187 + .name = "kernel",
35188 + .offset = (256 * 1024),
35189 + .size = (4 * 1024 * 1024) - (256 * 1024),
35190 + },
35192 + .name = "rootfs",
35193 + .offset = MTDPART_OFS_NXTBLK,
35194 + .size = MTDPART_SIZ_FULL,
35195 + },
35198 +static int rb4xx_nand_dev_ready(struct mtd_info *mtd)
35200 + return gpio_get_value_cansleep(RB4XX_NAND_GPIO_READY);
35203 +static void rb4xx_nand_write_cmd(unsigned char cmd)
35205 + unsigned char data = cmd;
35206 + int err;
35208 + err = rb4xx_cpld_write(&data, 1);
35209 + if (err)
35210 + pr_err("rb4xx_nand: write cmd failed, err=%d\n", err);
35213 +static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
35214 + unsigned int ctrl)
35216 + if (ctrl & NAND_CTRL_CHANGE) {
35217 + gpio_set_value_cansleep(RB4XX_NAND_GPIO_CLE,
35218 + (ctrl & NAND_CLE) ? 1 : 0);
35219 + gpio_set_value_cansleep(RB4XX_NAND_GPIO_ALE,
35220 + (ctrl & NAND_ALE) ? 1 : 0);
35221 + gpio_set_value_cansleep(RB4XX_NAND_GPIO_NCE,
35222 + (ctrl & NAND_NCE) ? 0 : 1);
35225 + if (cmd != NAND_CMD_NONE)
35226 + rb4xx_nand_write_cmd(cmd);
35229 +static unsigned char rb4xx_nand_read_byte(struct mtd_info *mtd)
35231 + unsigned char data = 0;
35232 + int err;
35234 + err = rb4xx_cpld_read(&data, NULL, 1);
35235 + if (err) {
35236 + pr_err("rb4xx_nand: read data failed, err=%d\n", err);
35237 + data = 0xff;
35240 + return data;
35243 +static void rb4xx_nand_write_buf(struct mtd_info *mtd, const unsigned char *buf,
35244 + int len)
35246 + int err;
35248 + err = rb4xx_cpld_write(buf, len);
35249 + if (err)
35250 + pr_err("rb4xx_nand: write buf failed, err=%d\n", err);
35253 +static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf,
35254 + int len)
35256 + int err;
35258 + err = rb4xx_cpld_read(buf, NULL, len);
35259 + if (err)
35260 + pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
35263 +static int rb4xx_nand_probe(struct platform_device *pdev)
35265 + struct rb4xx_nand_info *info;
35266 + int ret;
35268 + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
35270 + ret = gpio_request(RB4XX_NAND_GPIO_READY, "NAND RDY");
35271 + if (ret) {
35272 + dev_err(&pdev->dev, "unable to request gpio %d\n",
35273 + RB4XX_NAND_GPIO_READY);
35274 + goto err;
35277 + ret = gpio_direction_input(RB4XX_NAND_GPIO_READY);
35278 + if (ret) {
35279 + dev_err(&pdev->dev, "unable to set input mode on gpio %d\n",
35280 + RB4XX_NAND_GPIO_READY);
35281 + goto err_free_gpio_ready;
35284 + ret = gpio_request(RB4XX_NAND_GPIO_ALE, "NAND ALE");
35285 + if (ret) {
35286 + dev_err(&pdev->dev, "unable to request gpio %d\n",
35287 + RB4XX_NAND_GPIO_ALE);
35288 + goto err_free_gpio_ready;
35291 + ret = gpio_direction_output(RB4XX_NAND_GPIO_ALE, 0);
35292 + if (ret) {
35293 + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
35294 + RB4XX_NAND_GPIO_ALE);
35295 + goto err_free_gpio_ale;
35298 + ret = gpio_request(RB4XX_NAND_GPIO_CLE, "NAND CLE");
35299 + if (ret) {
35300 + dev_err(&pdev->dev, "unable to request gpio %d\n",
35301 + RB4XX_NAND_GPIO_CLE);
35302 + goto err_free_gpio_ale;
35305 + ret = gpio_direction_output(RB4XX_NAND_GPIO_CLE, 0);
35306 + if (ret) {
35307 + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
35308 + RB4XX_NAND_GPIO_CLE);
35309 + goto err_free_gpio_cle;
35312 + ret = gpio_request(RB4XX_NAND_GPIO_NCE, "NAND NCE");
35313 + if (ret) {
35314 + dev_err(&pdev->dev, "unable to request gpio %d\n",
35315 + RB4XX_NAND_GPIO_NCE);
35316 + goto err_free_gpio_cle;
35319 + ret = gpio_direction_output(RB4XX_NAND_GPIO_NCE, 1);
35320 + if (ret) {
35321 + dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
35322 + RB4XX_NAND_GPIO_ALE);
35323 + goto err_free_gpio_nce;
35326 + info = kzalloc(sizeof(*info), GFP_KERNEL);
35327 + if (!info) {
35328 + dev_err(&pdev->dev, "rb4xx-nand: no memory for private data\n");
35329 + ret = -ENOMEM;
35330 + goto err_free_gpio_nce;
35333 + info->chip.priv = &info;
35334 + info->mtd.priv = &info->chip;
35335 + info->mtd.owner = THIS_MODULE;
35337 + info->chip.cmd_ctrl = rb4xx_nand_cmd_ctrl;
35338 + info->chip.dev_ready = rb4xx_nand_dev_ready;
35339 + info->chip.read_byte = rb4xx_nand_read_byte;
35340 + info->chip.write_buf = rb4xx_nand_write_buf;
35341 + info->chip.read_buf = rb4xx_nand_read_buf;
35343 + info->chip.chip_delay = 25;
35344 + info->chip.ecc.mode = NAND_ECC_SOFT;
35346 + platform_set_drvdata(pdev, info);
35348 + ret = nand_scan_ident(&info->mtd, 1, NULL);
35349 + if (ret) {
35350 + ret = -ENXIO;
35351 + goto err_free_info;
35354 + if (info->mtd.writesize == 512)
35355 + info->chip.ecc.layout = &rb4xx_nand_ecclayout;
35357 + ret = nand_scan_tail(&info->mtd);
35358 + if (ret) {
35359 + return -ENXIO;
35360 + goto err_set_drvdata;
35363 + mtd_device_register(&info->mtd, rb4xx_nand_partitions,
35364 + ARRAY_SIZE(rb4xx_nand_partitions));
35365 + if (ret)
35366 + goto err_release_nand;
35368 + return 0;
35370 +err_release_nand:
35371 + nand_release(&info->mtd);
35372 +err_set_drvdata:
35373 + platform_set_drvdata(pdev, NULL);
35374 +err_free_info:
35375 + kfree(info);
35376 +err_free_gpio_nce:
35377 + gpio_free(RB4XX_NAND_GPIO_NCE);
35378 +err_free_gpio_cle:
35379 + gpio_free(RB4XX_NAND_GPIO_CLE);
35380 +err_free_gpio_ale:
35381 + gpio_free(RB4XX_NAND_GPIO_ALE);
35382 +err_free_gpio_ready:
35383 + gpio_free(RB4XX_NAND_GPIO_READY);
35384 +err:
35385 + return ret;
35388 +static int rb4xx_nand_remove(struct platform_device *pdev)
35390 + struct rb4xx_nand_info *info = platform_get_drvdata(pdev);
35392 + nand_release(&info->mtd);
35393 + platform_set_drvdata(pdev, NULL);
35394 + kfree(info);
35395 + gpio_free(RB4XX_NAND_GPIO_NCE);
35396 + gpio_free(RB4XX_NAND_GPIO_CLE);
35397 + gpio_free(RB4XX_NAND_GPIO_ALE);
35398 + gpio_free(RB4XX_NAND_GPIO_READY);
35400 + return 0;
35403 +static struct platform_driver rb4xx_nand_driver = {
35404 + .probe = rb4xx_nand_probe,
35405 + .remove = rb4xx_nand_remove,
35406 + .driver = {
35407 + .name = DRV_NAME,
35408 + .owner = THIS_MODULE,
35409 + },
35412 +static int __init rb4xx_nand_init(void)
35414 + return platform_driver_register(&rb4xx_nand_driver);
35417 +static void __exit rb4xx_nand_exit(void)
35419 + platform_driver_unregister(&rb4xx_nand_driver);
35422 +module_init(rb4xx_nand_init);
35423 +module_exit(rb4xx_nand_exit);
35425 +MODULE_DESCRIPTION(DRV_DESC);
35426 +MODULE_VERSION(DRV_VERSION);
35427 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
35428 +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
35429 +MODULE_LICENSE("GPL v2");
35430 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/rb750_nand.c linux-4.1.43/drivers/mtd/nand/rb750_nand.c
35431 --- linux-4.1.43.orig/drivers/mtd/nand/rb750_nand.c 1970-01-01 01:00:00.000000000 +0100
35432 +++ linux-4.1.43/drivers/mtd/nand/rb750_nand.c 2017-08-06 20:02:16.000000000 +0200
35433 @@ -0,0 +1,354 @@
35435 + * NAND flash driver for the MikroTik RouterBOARD 750
35437 + * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
35439 + * This program is free software; you can redistribute it and/or modify it
35440 + * under the terms of the GNU General Public License version 2 as published
35441 + * by the Free Software Foundation.
35442 + */
35444 +#include <linux/kernel.h>
35445 +#include <linux/module.h>
35446 +#include <linux/mtd/nand.h>
35447 +#include <linux/mtd/mtd.h>
35448 +#include <linux/mtd/partitions.h>
35449 +#include <linux/platform_device.h>
35450 +#include <linux/io.h>
35451 +#include <linux/slab.h>
35453 +#include <asm/mach-ath79/ar71xx_regs.h>
35454 +#include <asm/mach-ath79/ath79.h>
35455 +#include <asm/mach-ath79/mach-rb750.h>
35457 +#define DRV_NAME "rb750-nand"
35458 +#define DRV_VERSION "0.1.0"
35459 +#define DRV_DESC "NAND flash driver for the RouterBOARD 750"
35461 +#define RB750_NAND_IO0 BIT(RB750_GPIO_NAND_IO0)
35462 +#define RB750_NAND_ALE BIT(RB750_GPIO_NAND_ALE)
35463 +#define RB750_NAND_CLE BIT(RB750_GPIO_NAND_CLE)
35464 +#define RB750_NAND_NRE BIT(RB750_GPIO_NAND_NRE)
35465 +#define RB750_NAND_NWE BIT(RB750_GPIO_NAND_NWE)
35466 +#define RB750_NAND_RDY BIT(RB750_GPIO_NAND_RDY)
35468 +#define RB750_NAND_DATA_SHIFT 1
35469 +#define RB750_NAND_DATA_BITS (0xff << RB750_NAND_DATA_SHIFT)
35470 +#define RB750_NAND_INPUT_BITS (RB750_NAND_DATA_BITS | RB750_NAND_RDY)
35471 +#define RB750_NAND_OUTPUT_BITS (RB750_NAND_ALE | RB750_NAND_CLE | \
35472 + RB750_NAND_NRE | RB750_NAND_NWE)
35474 +struct rb750_nand_info {
35475 + struct nand_chip chip;
35476 + struct mtd_info mtd;
35477 + struct rb7xx_nand_platform_data *pdata;
35480 +static inline struct rb750_nand_info *mtd_to_rbinfo(struct mtd_info *mtd)
35482 + return container_of(mtd, struct rb750_nand_info, mtd);
35486 + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
35487 + * will not be able to find the kernel that we load.
35488 + */
35489 +static struct nand_ecclayout rb750_nand_ecclayout = {
35490 + .eccbytes = 6,
35491 + .eccpos = { 8, 9, 10, 13, 14, 15 },
35492 + .oobavail = 9,
35493 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
35496 +static struct mtd_partition rb750_nand_partitions[] = {
35498 + .name = "booter",
35499 + .offset = 0,
35500 + .size = (256 * 1024),
35501 + .mask_flags = MTD_WRITEABLE,
35502 + }, {
35503 + .name = "kernel",
35504 + .offset = (256 * 1024),
35505 + .size = (4 * 1024 * 1024) - (256 * 1024),
35506 + }, {
35507 + .name = "rootfs",
35508 + .offset = MTDPART_OFS_NXTBLK,
35509 + .size = MTDPART_SIZ_FULL,
35510 + },
35513 +static void rb750_nand_write(const u8 *buf, unsigned len)
35515 + void __iomem *base = ath79_gpio_base;
35516 + u32 out;
35517 + u32 t;
35518 + unsigned i;
35520 + /* set data lines to output mode */
35521 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35522 + __raw_writel(t | RB750_NAND_DATA_BITS, base + AR71XX_GPIO_REG_OE);
35524 + out = __raw_readl(base + AR71XX_GPIO_REG_OUT);
35525 + out &= ~(RB750_NAND_DATA_BITS | RB750_NAND_NWE);
35526 + for (i = 0; i != len; i++) {
35527 + u32 data;
35529 + data = buf[i];
35530 + data <<= RB750_NAND_DATA_SHIFT;
35531 + data |= out;
35532 + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
35534 + __raw_writel(data | RB750_NAND_NWE, base + AR71XX_GPIO_REG_OUT);
35535 + /* flush write */
35536 + __raw_readl(base + AR71XX_GPIO_REG_OUT);
35539 + /* set data lines to input mode */
35540 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35541 + __raw_writel(t & ~RB750_NAND_DATA_BITS, base + AR71XX_GPIO_REG_OE);
35542 + /* flush write */
35543 + __raw_readl(base + AR71XX_GPIO_REG_OE);
35546 +static void rb750_nand_read(u8 *read_buf, unsigned len)
35548 + void __iomem *base = ath79_gpio_base;
35549 + unsigned i;
35551 + for (i = 0; i < len; i++) {
35552 + u8 data;
35554 + /* activate RE line */
35555 + __raw_writel(RB750_NAND_NRE, base + AR71XX_GPIO_REG_CLEAR);
35556 + /* flush write */
35557 + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
35559 + /* read input lines */
35560 + data = __raw_readl(base + AR71XX_GPIO_REG_IN) >>
35561 + RB750_NAND_DATA_SHIFT;
35563 + /* deactivate RE line */
35564 + __raw_writel(RB750_NAND_NRE, base + AR71XX_GPIO_REG_SET);
35566 + read_buf[i] = data;
35570 +static void rb750_nand_select_chip(struct mtd_info *mtd, int chip)
35572 + struct rb750_nand_info *rbinfo = mtd_to_rbinfo(mtd);
35573 + void __iomem *base = ath79_gpio_base;
35574 + u32 t;
35576 + if (chip >= 0) {
35577 + rbinfo->pdata->enable_pins();
35579 + /* set input mode for data lines */
35580 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35581 + __raw_writel(t & ~RB750_NAND_INPUT_BITS,
35582 + base + AR71XX_GPIO_REG_OE);
35584 + /* deactivate RE and WE lines */
35585 + __raw_writel(RB750_NAND_NRE | RB750_NAND_NWE,
35586 + base + AR71XX_GPIO_REG_SET);
35587 + /* flush write */
35588 + (void) __raw_readl(base + AR71XX_GPIO_REG_SET);
35590 + /* activate CE line */
35591 + __raw_writel(rbinfo->pdata->nce_line,
35592 + base + AR71XX_GPIO_REG_CLEAR);
35593 + } else {
35594 + /* deactivate CE line */
35595 + __raw_writel(rbinfo->pdata->nce_line,
35596 + base + AR71XX_GPIO_REG_SET);
35597 + /* flush write */
35598 + (void) __raw_readl(base + AR71XX_GPIO_REG_SET);
35600 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35601 + __raw_writel(t | RB750_NAND_IO0 | RB750_NAND_RDY,
35602 + base + AR71XX_GPIO_REG_OE);
35604 + rbinfo->pdata->disable_pins();
35608 +static int rb750_nand_dev_ready(struct mtd_info *mtd)
35610 + void __iomem *base = ath79_gpio_base;
35612 + return !!(__raw_readl(base + AR71XX_GPIO_REG_IN) & RB750_NAND_RDY);
35615 +static void rb750_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
35616 + unsigned int ctrl)
35618 + if (ctrl & NAND_CTRL_CHANGE) {
35619 + void __iomem *base = ath79_gpio_base;
35620 + u32 t;
35622 + t = __raw_readl(base + AR71XX_GPIO_REG_OUT);
35624 + t &= ~(RB750_NAND_CLE | RB750_NAND_ALE);
35625 + t |= (ctrl & NAND_CLE) ? RB750_NAND_CLE : 0;
35626 + t |= (ctrl & NAND_ALE) ? RB750_NAND_ALE : 0;
35628 + __raw_writel(t, base + AR71XX_GPIO_REG_OUT);
35629 + /* flush write */
35630 + __raw_readl(base + AR71XX_GPIO_REG_OUT);
35633 + if (cmd != NAND_CMD_NONE) {
35634 + u8 t = cmd;
35635 + rb750_nand_write(&t, 1);
35639 +static u8 rb750_nand_read_byte(struct mtd_info *mtd)
35641 + u8 data = 0;
35642 + rb750_nand_read(&data, 1);
35643 + return data;
35646 +static void rb750_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
35648 + rb750_nand_read(buf, len);
35651 +static void rb750_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
35653 + rb750_nand_write(buf, len);
35656 +static void __init rb750_nand_gpio_init(struct rb750_nand_info *info)
35658 + void __iomem *base = ath79_gpio_base;
35659 + u32 out;
35660 + u32 t;
35662 + out = __raw_readl(base + AR71XX_GPIO_REG_OUT);
35664 + /* setup output levels */
35665 + __raw_writel(RB750_NAND_NCE | RB750_NAND_NRE | RB750_NAND_NWE,
35666 + base + AR71XX_GPIO_REG_SET);
35668 + __raw_writel(RB750_NAND_ALE | RB750_NAND_CLE,
35669 + base + AR71XX_GPIO_REG_CLEAR);
35671 + /* setup input lines */
35672 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35673 + __raw_writel(t & ~(RB750_NAND_INPUT_BITS), base + AR71XX_GPIO_REG_OE);
35675 + /* setup output lines */
35676 + t = __raw_readl(base + AR71XX_GPIO_REG_OE);
35677 + t |= RB750_NAND_OUTPUT_BITS;
35678 + t |= info->pdata->nce_line;
35679 + __raw_writel(t, base + AR71XX_GPIO_REG_OE);
35681 + info->pdata->latch_change(~out & RB750_NAND_IO0, out & RB750_NAND_IO0);
35684 +static int rb750_nand_probe(struct platform_device *pdev)
35686 + struct rb750_nand_info *info;
35687 + struct rb7xx_nand_platform_data *pdata;
35688 + int ret;
35690 + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
35692 + pdata = pdev->dev.platform_data;
35693 + if (!pdata)
35694 + return -EINVAL;
35696 + info = kzalloc(sizeof(*info), GFP_KERNEL);
35697 + if (!info)
35698 + return -ENOMEM;
35700 + info->chip.priv = &info;
35701 + info->mtd.priv = &info->chip;
35702 + info->mtd.owner = THIS_MODULE;
35704 + info->chip.select_chip = rb750_nand_select_chip;
35705 + info->chip.cmd_ctrl = rb750_nand_cmd_ctrl;
35706 + info->chip.dev_ready = rb750_nand_dev_ready;
35707 + info->chip.read_byte = rb750_nand_read_byte;
35708 + info->chip.write_buf = rb750_nand_write_buf;
35709 + info->chip.read_buf = rb750_nand_read_buf;
35711 + info->chip.chip_delay = 25;
35712 + info->chip.ecc.mode = NAND_ECC_SOFT;
35714 + info->pdata = pdata;
35716 + platform_set_drvdata(pdev, info);
35718 + rb750_nand_gpio_init(info);
35720 + ret = nand_scan_ident(&info->mtd, 1, NULL);
35721 + if (ret) {
35722 + ret = -ENXIO;
35723 + goto err_free_info;
35726 + if (info->mtd.writesize == 512)
35727 + info->chip.ecc.layout = &rb750_nand_ecclayout;
35729 + ret = nand_scan_tail(&info->mtd);
35730 + if (ret) {
35731 + return -ENXIO;
35732 + goto err_set_drvdata;
35735 + ret = mtd_device_register(&info->mtd, rb750_nand_partitions,
35736 + ARRAY_SIZE(rb750_nand_partitions));
35737 + if (ret)
35738 + goto err_release_nand;
35740 + return 0;
35742 +err_release_nand:
35743 + nand_release(&info->mtd);
35744 +err_set_drvdata:
35745 + platform_set_drvdata(pdev, NULL);
35746 +err_free_info:
35747 + kfree(info);
35748 + return ret;
35751 +static int rb750_nand_remove(struct platform_device *pdev)
35753 + struct rb750_nand_info *info = platform_get_drvdata(pdev);
35755 + nand_release(&info->mtd);
35756 + platform_set_drvdata(pdev, NULL);
35757 + kfree(info);
35759 + return 0;
35762 +static struct platform_driver rb750_nand_driver = {
35763 + .probe = rb750_nand_probe,
35764 + .remove = rb750_nand_remove,
35765 + .driver = {
35766 + .name = DRV_NAME,
35767 + .owner = THIS_MODULE,
35768 + },
35771 +static int __init rb750_nand_init(void)
35773 + return platform_driver_register(&rb750_nand_driver);
35776 +static void __exit rb750_nand_exit(void)
35778 + platform_driver_unregister(&rb750_nand_driver);
35781 +module_init(rb750_nand_init);
35782 +module_exit(rb750_nand_exit);
35784 +MODULE_DESCRIPTION(DRV_DESC);
35785 +MODULE_VERSION(DRV_VERSION);
35786 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
35787 +MODULE_LICENSE("GPL v2");
35788 diff -Nur linux-4.1.43.orig/drivers/mtd/nand/rb91x_nand.c linux-4.1.43/drivers/mtd/nand/rb91x_nand.c
35789 --- linux-4.1.43.orig/drivers/mtd/nand/rb91x_nand.c 1970-01-01 01:00:00.000000000 +0100
35790 +++ linux-4.1.43/drivers/mtd/nand/rb91x_nand.c 2017-08-06 20:02:16.000000000 +0200
35791 @@ -0,0 +1,377 @@
35793 + * NAND flash driver for the MikroTik RouterBOARD 91x series
35795 + * Copyright (C) 2013-2014 Gabor Juhos <juhosg@openwrt.org>
35797 + * This program is free software; you can redistribute it and/or modify it
35798 + * under the terms of the GNU General Public License version 2 as published
35799 + * by the Free Software Foundation.
35800 + */
35802 +#include <linux/kernel.h>
35803 +#include <linux/spinlock.h>
35804 +#include <linux/module.h>
35805 +#include <linux/mtd/nand.h>
35806 +#include <linux/mtd/mtd.h>
35807 +#include <linux/mtd/partitions.h>
35808 +#include <linux/platform_device.h>
35809 +#include <linux/io.h>
35810 +#include <linux/slab.h>
35811 +#include <linux/gpio.h>
35812 +#include <linux/platform_data/rb91x_nand.h>
35814 +#include <asm/mach-ath79/ar71xx_regs.h>
35815 +#include <asm/mach-ath79/ath79.h>
35817 +#define DRV_DESC "NAND flash driver for the RouterBOARD 91x series"
35819 +#define RB91X_NAND_NRWE BIT(12)
35821 +#define RB91X_NAND_DATA_BITS (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) |\
35822 + BIT(13) | BIT(14) | BIT(15))
35824 +#define RB91X_NAND_INPUT_BITS (RB91X_NAND_DATA_BITS | RB91X_NAND_RDY)
35825 +#define RB91X_NAND_OUTPUT_BITS (RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE)
35827 +#define RB91X_NAND_LOW_DATA_MASK 0x1f
35828 +#define RB91X_NAND_HIGH_DATA_MASK 0xe0
35829 +#define RB91X_NAND_HIGH_DATA_SHIFT 8
35831 +struct rb91x_nand_info {
35832 + struct nand_chip chip;
35833 + struct mtd_info mtd;
35834 + struct device *dev;
35836 + int gpio_nce;
35837 + int gpio_ale;
35838 + int gpio_cle;
35839 + int gpio_rdy;
35840 + int gpio_read;
35841 + int gpio_nrw;
35842 + int gpio_nle;
35845 +static inline struct rb91x_nand_info *mtd_to_rbinfo(struct mtd_info *mtd)
35847 + return container_of(mtd, struct rb91x_nand_info, mtd);
35851 + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
35852 + * will not be able to find the kernel that we load.
35853 + */
35854 +static struct nand_ecclayout rb91x_nand_ecclayout = {
35855 + .eccbytes = 6,
35856 + .eccpos = { 8, 9, 10, 13, 14, 15 },
35857 + .oobavail = 9,
35858 + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
35861 +static struct mtd_partition rb91x_nand_partitions[] = {
35863 + .name = "booter",
35864 + .offset = 0,
35865 + .size = (256 * 1024),
35866 + .mask_flags = MTD_WRITEABLE,
35867 + }, {
35868 + .name = "kernel",
35869 + .offset = (256 * 1024),
35870 + .size = (4 * 1024 * 1024) - (256 * 1024),
35871 + }, {
35872 + .name = "rootfs",
35873 + .offset = MTDPART_OFS_NXTBLK,
35874 + .size = MTDPART_SIZ_FULL,
35875 + },
35878 +static void rb91x_nand_write(struct rb91x_nand_info *rbni,
35879 + const u8 *buf,
35880 + unsigned len)
35882 + void __iomem *base = ath79_gpio_base;
35883 + u32 oe_reg;
35884 + u32 out_reg;
35885 + u32 out;
35886 + unsigned i;
35888 + /* enable the latch */
35889 + gpio_set_value_cansleep(rbni->gpio_nle, 0);
35891 + oe_reg = __raw_readl(base + AR71XX_GPIO_REG_OE);
35892 + out_reg = __raw_readl(base + AR71XX_GPIO_REG_OUT);
35894 + /* set data lines to output mode */
35895 + __raw_writel(oe_reg & ~(RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE),
35896 + base + AR71XX_GPIO_REG_OE);
35898 + out = out_reg & ~(RB91X_NAND_DATA_BITS | RB91X_NAND_NRWE);
35899 + for (i = 0; i != len; i++) {
35900 + u32 data;
35902 + data = (buf[i] & RB91X_NAND_HIGH_DATA_MASK) <<
35903 + RB91X_NAND_HIGH_DATA_SHIFT;
35904 + data |= buf[i] & RB91X_NAND_LOW_DATA_MASK;
35905 + data |= out;
35906 + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
35908 + /* deactivate WE line */
35909 + data |= RB91X_NAND_NRWE;
35910 + __raw_writel(data, base + AR71XX_GPIO_REG_OUT);
35911 + /* flush write */
35912 + __raw_readl(base + AR71XX_GPIO_REG_OUT);
35915 + /* restore registers */
35916 + __raw_writel(out_reg, base + AR71XX_GPIO_REG_OUT);
35917 + __raw_writel(oe_reg, base + AR71XX_GPIO_REG_OE);
35918 + /* flush write */
35919 + __raw_readl(base + AR71XX_GPIO_REG_OUT);
35921 + /* disable the latch */
35922 + gpio_set_value_cansleep(rbni->gpio_nle, 1);
35925 +static void rb91x_nand_read(struct rb91x_nand_info *rbni,
35926 + u8 *read_buf,
35927 + unsigned len)
35929 + void __iomem *base = ath79_gpio_base;
35930 + u32 oe_reg;
35931 + u32 out_reg;
35932 + unsigned i;
35934 + /* enable read mode */
35935 + gpio_set_value_cansleep(rbni->gpio_read, 1);
35937 + /* enable latch */
35938 + gpio_set_value_cansleep(rbni->gpio_nle, 0);
35940 + /* save registers */
35941 + oe_reg = __raw_readl(base + AR71XX_GPIO_REG_OE);
35942 + out_reg = __raw_readl(base + AR71XX_GPIO_REG_OUT);
35944 + /* set data lines to input mode */
35945 + __raw_writel(oe_reg | RB91X_NAND_DATA_BITS,
35946 + base + AR71XX_GPIO_REG_OE);
35948 + for (i = 0; i < len; i++) {
35949 + u32 in;
35950 + u8 data;
35952 + /* activate RE line */
35953 + __raw_writel(RB91X_NAND_NRWE, base + AR71XX_GPIO_REG_CLEAR);
35954 + /* flush write */
35955 + __raw_readl(base + AR71XX_GPIO_REG_CLEAR);
35957 + /* read input lines */
35958 + in = __raw_readl(base + AR71XX_GPIO_REG_IN);
35960 + /* deactivate RE line */
35961 + __raw_writel(RB91X_NAND_NRWE, base + AR71XX_GPIO_REG_SET);
35963 + data = (in & RB91X_NAND_LOW_DATA_MASK);
35964 + data |= (in >> RB91X_NAND_HIGH_DATA_SHIFT) &
35965 + RB91X_NAND_HIGH_DATA_MASK;
35967 + read_buf[i] = data;
35970 + /* restore registers */
35971 + __raw_writel(out_reg, base + AR71XX_GPIO_REG_OUT);
35972 + __raw_writel(oe_reg, base + AR71XX_GPIO_REG_OE);
35973 + /* flush write */
35974 + __raw_readl(base + AR71XX_GPIO_REG_OUT);
35976 + /* disable latch */
35977 + gpio_set_value_cansleep(rbni->gpio_nle, 1);
35979 + /* disable read mode */
35980 + gpio_set_value_cansleep(rbni->gpio_read, 0);
35983 +static int rb91x_nand_dev_ready(struct mtd_info *mtd)
35985 + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
35987 + return gpio_get_value_cansleep(rbni->gpio_rdy);
35990 +static void rb91x_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
35991 + unsigned int ctrl)
35993 + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
35995 + if (ctrl & NAND_CTRL_CHANGE) {
35996 + gpio_set_value_cansleep(rbni->gpio_cle,
35997 + (ctrl & NAND_CLE) ? 1 : 0);
35998 + gpio_set_value_cansleep(rbni->gpio_ale,
35999 + (ctrl & NAND_ALE) ? 1 : 0);
36000 + gpio_set_value_cansleep(rbni->gpio_nce,
36001 + (ctrl & NAND_NCE) ? 0 : 1);
36004 + if (cmd != NAND_CMD_NONE) {
36005 + u8 t = cmd;
36007 + rb91x_nand_write(rbni, &t, 1);
36011 +static u8 rb91x_nand_read_byte(struct mtd_info *mtd)
36013 + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
36014 + u8 data = 0xff;
36016 + rb91x_nand_read(rbni, &data, 1);
36018 + return data;
36021 +static void rb91x_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
36023 + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
36025 + rb91x_nand_read(rbni, buf, len);
36028 +static void rb91x_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
36030 + struct rb91x_nand_info *rbni = mtd_to_rbinfo(mtd);
36032 + rb91x_nand_write(rbni, buf, len);
36035 +static int rb91x_nand_gpio_init(struct rb91x_nand_info *info)
36037 + int ret;
36039 + /*
36040 + * Ensure that the LATCH is disabled before initializing
36041 + * control lines.
36042 + */
36043 + ret = devm_gpio_request_one(info->dev, info->gpio_nle,
36044 + GPIOF_OUT_INIT_HIGH, "LATCH enable");
36045 + if (ret)
36046 + return ret;
36048 + ret = devm_gpio_request_one(info->dev, info->gpio_nce,
36049 + GPIOF_OUT_INIT_HIGH, "NAND nCE");
36050 + if (ret)
36051 + return ret;
36053 + ret = devm_gpio_request_one(info->dev, info->gpio_nrw,
36054 + GPIOF_OUT_INIT_HIGH, "NAND nRW");
36055 + if (ret)
36056 + return ret;
36058 + ret = devm_gpio_request_one(info->dev, info->gpio_cle,
36059 + GPIOF_OUT_INIT_LOW, "NAND CLE");
36060 + if (ret)
36061 + return ret;
36063 + ret = devm_gpio_request_one(info->dev, info->gpio_ale,
36064 + GPIOF_OUT_INIT_LOW, "NAND ALE");
36065 + if (ret)
36066 + return ret;
36068 + ret = devm_gpio_request_one(info->dev, info->gpio_read,
36069 + GPIOF_OUT_INIT_LOW, "NAND READ");
36070 + if (ret)
36071 + return ret;
36073 + ret = devm_gpio_request_one(info->dev, info->gpio_rdy,
36074 + GPIOF_IN, "NAND RDY");
36075 + return ret;
36078 +static int rb91x_nand_probe(struct platform_device *pdev)
36080 + struct rb91x_nand_info *rbni;
36081 + struct rb91x_nand_platform_data *pdata;
36082 + int ret;
36084 + pr_info(DRV_DESC "\n");
36086 + pdata = dev_get_platdata(&pdev->dev);
36087 + if (!pdata)
36088 + return -EINVAL;
36090 + rbni = devm_kzalloc(&pdev->dev, sizeof(*rbni), GFP_KERNEL);
36091 + if (!rbni)
36092 + return -ENOMEM;
36094 + rbni->dev = &pdev->dev;
36095 + rbni->gpio_nce = pdata->gpio_nce;
36096 + rbni->gpio_ale = pdata->gpio_ale;
36097 + rbni->gpio_cle = pdata->gpio_cle;
36098 + rbni->gpio_read = pdata->gpio_read;
36099 + rbni->gpio_nrw = pdata->gpio_nrw;
36100 + rbni->gpio_rdy = pdata->gpio_rdy;
36101 + rbni->gpio_nle = pdata->gpio_nle;
36103 + rbni->chip.priv = &rbni;
36104 + rbni->mtd.priv = &rbni->chip;
36105 + rbni->mtd.owner = THIS_MODULE;
36107 + rbni->chip.cmd_ctrl = rb91x_nand_cmd_ctrl;
36108 + rbni->chip.dev_ready = rb91x_nand_dev_ready;
36109 + rbni->chip.read_byte = rb91x_nand_read_byte;
36110 + rbni->chip.write_buf = rb91x_nand_write_buf;
36111 + rbni->chip.read_buf = rb91x_nand_read_buf;
36113 + rbni->chip.chip_delay = 25;
36114 + rbni->chip.ecc.mode = NAND_ECC_SOFT;
36116 + platform_set_drvdata(pdev, rbni);
36118 + ret = rb91x_nand_gpio_init(rbni);
36119 + if (ret)
36120 + return ret;
36122 + ret = nand_scan_ident(&rbni->mtd, 1, NULL);
36123 + if (ret)
36124 + return ret;
36126 + if (rbni->mtd.writesize == 512)
36127 + rbni->chip.ecc.layout = &rb91x_nand_ecclayout;
36129 + ret = nand_scan_tail(&rbni->mtd);
36130 + if (ret)
36131 + return ret;
36133 + ret = mtd_device_register(&rbni->mtd, rb91x_nand_partitions,
36134 + ARRAY_SIZE(rb91x_nand_partitions));
36135 + if (ret)
36136 + goto err_release_nand;
36138 + return 0;
36140 +err_release_nand:
36141 + nand_release(&rbni->mtd);
36142 + return ret;
36145 +static int rb91x_nand_remove(struct platform_device *pdev)
36147 + struct rb91x_nand_info *info = platform_get_drvdata(pdev);
36149 + nand_release(&info->mtd);
36151 + return 0;
36154 +static struct platform_driver rb91x_nand_driver = {
36155 + .probe = rb91x_nand_probe,
36156 + .remove = rb91x_nand_remove,
36157 + .driver = {
36158 + .name = RB91X_NAND_DRIVER_NAME,
36159 + .owner = THIS_MODULE,
36160 + },
36163 +module_platform_driver(rb91x_nand_driver);
36165 +MODULE_DESCRIPTION(DRV_DESC);
36166 +MODULE_VERSION(DRV_VERSION);
36167 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
36168 +MODULE_LICENSE("GPL v2");
36169 diff -Nur linux-4.1.43.orig/drivers/mtd/redboot.c linux-4.1.43/drivers/mtd/redboot.c
36170 --- linux-4.1.43.orig/drivers/mtd/redboot.c 2017-08-06 01:56:14.000000000 +0200
36171 +++ linux-4.1.43/drivers/mtd/redboot.c 2017-08-06 20:02:16.000000000 +0200
36172 @@ -76,12 +76,18 @@
36173 static char nullstring[] = "unallocated";
36174 #endif
36176 + buf = vmalloc(master->erasesize);
36177 + if (!buf)
36178 + return -ENOMEM;
36180 + restart:
36181 if ( directory < 0 ) {
36182 offset = master->size + directory * master->erasesize;
36183 while (mtd_block_isbad(master, offset)) {
36184 if (!offset) {
36185 nogood:
36186 printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
36187 + vfree(buf);
36188 return -EIO;
36190 offset -= master->erasesize;
36191 @@ -94,10 +100,6 @@
36192 goto nogood;
36195 - buf = vmalloc(master->erasesize);
36197 - if (!buf)
36198 - return -ENOMEM;
36200 printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
36201 master->name, offset);
36202 @@ -170,6 +172,11 @@
36204 if (i == numslots) {
36205 /* Didn't find it */
36206 + if (offset + master->erasesize < master->size) {
36207 + /* not at the end of the flash yet, maybe next block :) */
36208 + directory++;
36209 + goto restart;
36211 printk(KERN_NOTICE "No RedBoot partition table detected in %s\n",
36212 master->name);
36213 ret = 0;
36214 diff -Nur linux-4.1.43.orig/drivers/mtd/tplinkpart.c linux-4.1.43/drivers/mtd/tplinkpart.c
36215 --- linux-4.1.43.orig/drivers/mtd/tplinkpart.c 1970-01-01 01:00:00.000000000 +0100
36216 +++ linux-4.1.43/drivers/mtd/tplinkpart.c 2017-08-06 20:02:16.000000000 +0200
36217 @@ -0,0 +1,222 @@
36219 + * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
36221 + * This program is free software; you can redistribute it and/or modify it
36222 + * under the terms of the GNU General Public License version 2 as published
36223 + * by the Free Software Foundation.
36225 + */
36227 +#include <linux/kernel.h>
36228 +#include <linux/module.h>
36229 +#include <linux/slab.h>
36230 +#include <linux/vmalloc.h>
36231 +#include <linux/magic.h>
36233 +#include <linux/mtd/mtd.h>
36234 +#include <linux/mtd/partitions.h>
36236 +#define TPLINK_NUM_PARTS 5
36237 +#define TPLINK_HEADER_V1 0x01000000
36238 +#define TPLINK_HEADER_V2 0x02000000
36239 +#define MD5SUM_LEN 16
36241 +#define TPLINK_ART_LEN 0x10000
36242 +#define TPLINK_KERNEL_OFFS 0x20000
36243 +#define TPLINK_64K_KERNEL_OFFS 0x10000
36245 +struct tplink_fw_header {
36246 + uint32_t version; /* header version */
36247 + char vendor_name[24];
36248 + char fw_version[36];
36249 + uint32_t hw_id; /* hardware id */
36250 + uint32_t hw_rev; /* hardware revision */
36251 + uint32_t unk1;
36252 + uint8_t md5sum1[MD5SUM_LEN];
36253 + uint32_t unk2;
36254 + uint8_t md5sum2[MD5SUM_LEN];
36255 + uint32_t unk3;
36256 + uint32_t kernel_la; /* kernel load address */
36257 + uint32_t kernel_ep; /* kernel entry point */
36258 + uint32_t fw_length; /* total length of the firmware */
36259 + uint32_t kernel_ofs; /* kernel data offset */
36260 + uint32_t kernel_len; /* kernel data length */
36261 + uint32_t rootfs_ofs; /* rootfs data offset */
36262 + uint32_t rootfs_len; /* rootfs data length */
36263 + uint32_t boot_ofs; /* bootloader data offset */
36264 + uint32_t boot_len; /* bootloader data length */
36265 + uint8_t pad[360];
36266 +} __attribute__ ((packed));
36268 +static struct tplink_fw_header *
36269 +tplink_read_header(struct mtd_info *mtd, size_t offset)
36271 + struct tplink_fw_header *header;
36272 + size_t header_len;
36273 + size_t retlen;
36274 + int ret;
36275 + u32 t;
36277 + header = vmalloc(sizeof(*header));
36278 + if (!header)
36279 + goto err;
36281 + header_len = sizeof(struct tplink_fw_header);
36282 + ret = mtd_read(mtd, offset, header_len, &retlen,
36283 + (unsigned char *) header);
36284 + if (ret)
36285 + goto err_free_header;
36287 + if (retlen != header_len)
36288 + goto err_free_header;
36290 + /* sanity checks */
36291 + t = be32_to_cpu(header->version);
36292 + if ((t != TPLINK_HEADER_V1) && (t != TPLINK_HEADER_V2))
36293 + goto err_free_header;
36295 + t = be32_to_cpu(header->kernel_ofs);
36296 + if (t != header_len)
36297 + goto err_free_header;
36299 + return header;
36301 +err_free_header:
36302 + vfree(header);
36303 +err:
36304 + return NULL;
36307 +static int tplink_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
36309 + u32 magic;
36310 + size_t retlen;
36311 + int ret;
36313 + ret = mtd_read(mtd, offset, sizeof(magic), &retlen,
36314 + (unsigned char *) &magic);
36315 + if (ret)
36316 + return ret;
36318 + if (retlen != sizeof(magic))
36319 + return -EIO;
36321 + if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
36322 + magic != 0x19852003)
36323 + return -EINVAL;
36325 + return 0;
36328 +static int tplink_parse_partitions_offset(struct mtd_info *master,
36329 + struct mtd_partition **pparts,
36330 + struct mtd_part_parser_data *data,
36331 + size_t offset)
36333 + struct mtd_partition *parts;
36334 + struct tplink_fw_header *header;
36335 + int nr_parts;
36336 + size_t art_offset;
36337 + size_t rootfs_offset;
36338 + size_t squashfs_offset;
36339 + int ret;
36341 + nr_parts = TPLINK_NUM_PARTS;
36342 + parts = kzalloc(nr_parts * sizeof(struct mtd_partition), GFP_KERNEL);
36343 + if (!parts) {
36344 + ret = -ENOMEM;
36345 + goto err;
36348 + header = tplink_read_header(master, offset);
36349 + if (!header) {
36350 + pr_notice("%s: no TP-Link header found\n", master->name);
36351 + ret = -ENODEV;
36352 + goto err_free_parts;
36355 + squashfs_offset = offset + sizeof(struct tplink_fw_header) +
36356 + be32_to_cpu(header->kernel_len);
36358 + ret = tplink_check_rootfs_magic(master, squashfs_offset);
36359 + if (ret == 0)
36360 + rootfs_offset = squashfs_offset;
36361 + else
36362 + rootfs_offset = offset + be32_to_cpu(header->rootfs_ofs);
36364 + art_offset = master->size - TPLINK_ART_LEN;
36366 + parts[0].name = "u-boot";
36367 + parts[0].offset = 0;
36368 + parts[0].size = offset;
36369 + parts[0].mask_flags = MTD_WRITEABLE;
36371 + parts[1].name = "kernel";
36372 + parts[1].offset = offset;
36373 + parts[1].size = rootfs_offset - offset;
36375 + parts[2].name = "rootfs";
36376 + parts[2].offset = rootfs_offset;
36377 + parts[2].size = art_offset - rootfs_offset;
36379 + parts[3].name = "art";
36380 + parts[3].offset = art_offset;
36381 + parts[3].size = TPLINK_ART_LEN;
36382 + parts[3].mask_flags = MTD_WRITEABLE;
36384 + parts[4].name = "firmware";
36385 + parts[4].offset = offset;
36386 + parts[4].size = art_offset - offset;
36388 + vfree(header);
36390 + *pparts = parts;
36391 + return nr_parts;
36393 +err_free_parts:
36394 + kfree(parts);
36395 +err:
36396 + *pparts = NULL;
36397 + return ret;
36400 +static int tplink_parse_partitions(struct mtd_info *master,
36401 + struct mtd_partition **pparts,
36402 + struct mtd_part_parser_data *data)
36404 + return tplink_parse_partitions_offset(master, pparts, data,
36405 + TPLINK_KERNEL_OFFS);
36408 +static int tplink_parse_64k_partitions(struct mtd_info *master,
36409 + struct mtd_partition **pparts,
36410 + struct mtd_part_parser_data *data)
36412 + return tplink_parse_partitions_offset(master, pparts, data,
36413 + TPLINK_64K_KERNEL_OFFS);
36416 +static struct mtd_part_parser tplink_parser = {
36417 + .owner = THIS_MODULE,
36418 + .parse_fn = tplink_parse_partitions,
36419 + .name = "tp-link",
36422 +static struct mtd_part_parser tplink_64k_parser = {
36423 + .owner = THIS_MODULE,
36424 + .parse_fn = tplink_parse_64k_partitions,
36425 + .name = "tp-link-64k",
36428 +static int __init tplink_parser_init(void)
36430 + register_mtd_parser(&tplink_parser);
36431 + register_mtd_parser(&tplink_64k_parser);
36433 + return 0;
36436 +module_init(tplink_parser_init);
36438 +MODULE_LICENSE("GPL v2");
36439 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
36440 diff -Nur linux-4.1.43.orig/drivers/net/dsa/Kconfig linux-4.1.43/drivers/net/dsa/Kconfig
36441 --- linux-4.1.43.orig/drivers/net/dsa/Kconfig 2017-08-06 01:56:14.000000000 +0200
36442 +++ linux-4.1.43/drivers/net/dsa/Kconfig 2017-08-06 20:02:16.000000000 +0200
36443 @@ -13,6 +13,13 @@
36444 This enables support for the Marvell 88E6060 ethernet switch
36445 chip.
36447 +config NET_DSA_MV88E6063
36448 + bool "Marvell 88E6063 ethernet switch chip support"
36449 + select NET_DSA_TAG_TRAILER
36450 + ---help---
36451 + This enables support for the Marvell 88E6063 ethernet switch
36452 + chip
36454 config NET_DSA_MV88E6XXX_NEED_PPU
36455 bool
36456 default n
36457 diff -Nur linux-4.1.43.orig/drivers/net/dsa/Makefile linux-4.1.43/drivers/net/dsa/Makefile
36458 --- linux-4.1.43.orig/drivers/net/dsa/Makefile 2017-08-06 01:56:14.000000000 +0200
36459 +++ linux-4.1.43/drivers/net/dsa/Makefile 2017-08-06 20:02:16.000000000 +0200
36460 @@ -1,4 +1,5 @@
36461 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
36462 +obj-$(CONFIG_NET_DSA_MV88E6063) += mv88e6063.o
36463 obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
36464 mv88e6xxx_drv-y += mv88e6xxx.o
36465 ifdef CONFIG_NET_DSA_MV88E6123_61_65
36466 diff -Nur linux-4.1.43.orig/drivers/net/dsa/mv88e6063.c linux-4.1.43/drivers/net/dsa/mv88e6063.c
36467 --- linux-4.1.43.orig/drivers/net/dsa/mv88e6063.c 1970-01-01 01:00:00.000000000 +0100
36468 +++ linux-4.1.43/drivers/net/dsa/mv88e6063.c 2017-08-06 20:02:16.000000000 +0200
36469 @@ -0,0 +1,311 @@
36471 + * net/dsa/mv88e6063.c - Driver for Marvell 88e6063 switch chips
36472 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
36474 + * This driver was base on: net/dsa/mv88e6060.c
36475 + * net/dsa/mv88e6063.c - Driver for Marvell 88e6060 switch chips
36476 + * Copyright (c) 2008-2009 Marvell Semiconductor
36478 + * This program is free software; you can redistribute it and/or modify
36479 + * it under the terms of the GNU General Public License as published by
36480 + * the Free Software Foundation; either version 2 of the License, or
36481 + * (at your option) any later version.
36482 + */
36484 +#include <linux/version.h>
36485 +#include <linux/list.h>
36486 +#include <linux/netdevice.h>
36487 +#include <linux/phy.h>
36488 +#include <net/dsa.h>
36490 +#define REG_BASE 0x10
36491 +#define REG_PHY(p) (REG_BASE + (p))
36492 +#define REG_PORT(p) (REG_BASE + 8 + (p))
36493 +#define REG_GLOBAL (REG_BASE + 0x0f)
36494 +#define NUM_PORTS 7
36496 +static int reg_read(struct dsa_switch *ds, int addr, int reg)
36498 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
36499 + return mdiobus_read(ds->master_mii_bus, addr, reg);
36500 +#else
36501 + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
36502 + return mdiobus_read(bus, addr, reg);
36503 +#endif
36506 +#define REG_READ(addr, reg) \
36507 + ({ \
36508 + int __ret; \
36510 + __ret = reg_read(ds, addr, reg); \
36511 + if (__ret < 0) \
36512 + return __ret; \
36513 + __ret; \
36514 + })
36517 +static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
36519 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
36520 + return mdiobus_write(ds->master_mii_bus, addr, reg, val);
36521 +#else
36522 + struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev);
36523 + return mdiobus_write(bus, addr, reg, val);
36524 +#endif
36527 +#define REG_WRITE(addr, reg, val) \
36528 + ({ \
36529 + int __ret; \
36531 + __ret = reg_write(ds, addr, reg, val); \
36532 + if (__ret < 0) \
36533 + return __ret; \
36534 + })
36536 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
36537 +static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
36539 +#else
36540 +static char *mv88e6063_probe(struct device *host_dev, int sw_addr)
36542 + struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
36543 +#endif
36544 + int ret;
36546 + ret = mdiobus_read(bus, REG_PORT(0), 0x03);
36547 + if (ret >= 0) {
36548 + ret &= 0xfff0;
36549 + if (ret == 0x1530)
36550 + return "Marvell 88E6063";
36553 + return NULL;
36556 +static int mv88e6063_switch_reset(struct dsa_switch *ds)
36558 + int i;
36559 + int ret;
36561 + /*
36562 + * Set all ports to the disabled state.
36563 + */
36564 + for (i = 0; i < NUM_PORTS; i++) {
36565 + ret = REG_READ(REG_PORT(i), 0x04);
36566 + REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
36569 + /*
36570 + * Wait for transmit queues to drain.
36571 + */
36572 + msleep(2);
36574 + /*
36575 + * Reset the switch.
36576 + */
36577 + REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
36579 + /*
36580 + * Wait up to one second for reset to complete.
36581 + */
36582 + for (i = 0; i < 1000; i++) {
36583 + ret = REG_READ(REG_GLOBAL, 0x00);
36584 + if ((ret & 0x8000) == 0x0000)
36585 + break;
36587 + msleep(1);
36589 + if (i == 1000)
36590 + return -ETIMEDOUT;
36592 + return 0;
36595 +static int mv88e6063_setup_global(struct dsa_switch *ds)
36597 + /*
36598 + * Disable discarding of frames with excessive collisions,
36599 + * set the maximum frame size to 1536 bytes, and mask all
36600 + * interrupt sources.
36601 + */
36602 + REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
36604 + /*
36605 + * Enable automatic address learning, set the address
36606 + * database size to 1024 entries, and set the default aging
36607 + * time to 5 minutes.
36608 + */
36609 + REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
36611 + return 0;
36614 +static int mv88e6063_setup_port(struct dsa_switch *ds, int p)
36616 + int addr = REG_PORT(p);
36618 + /*
36619 + * Do not force flow control, disable Ingress and Egress
36620 + * Header tagging, disable VLAN tunneling, and set the port
36621 + * state to Forwarding. Additionally, if this is the CPU
36622 + * port, enable Ingress and Egress Trailer tagging mode.
36623 + */
36624 + REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ? 0x4103 : 0x0003);
36626 + /*
36627 + * Port based VLAN map: give each port its own address
36628 + * database, allow the CPU port to talk to each of the 'real'
36629 + * ports, and allow each of the 'real' ports to only talk to
36630 + * the CPU port.
36631 + */
36632 + REG_WRITE(addr, 0x06,
36633 + ((p & 0xf) << 12) |
36634 + (dsa_is_cpu_port(ds, p) ?
36635 + ds->phys_port_mask :
36636 + (1 << ds->dst->cpu_port)));
36638 + /*
36639 + * Port Association Vector: when learning source addresses
36640 + * of packets, add the address to the address database using
36641 + * a port bitmap that has only the bit for this port set and
36642 + * the other bits clear.
36643 + */
36644 + REG_WRITE(addr, 0x0b, 1 << p);
36646 + return 0;
36649 +static int mv88e6063_setup(struct dsa_switch *ds)
36651 + int i;
36652 + int ret;
36654 + ret = mv88e6063_switch_reset(ds);
36655 + if (ret < 0)
36656 + return ret;
36658 + /* @@@ initialise atu */
36660 + ret = mv88e6063_setup_global(ds);
36661 + if (ret < 0)
36662 + return ret;
36664 + for (i = 0; i < NUM_PORTS; i++) {
36665 + ret = mv88e6063_setup_port(ds, i);
36666 + if (ret < 0)
36667 + return ret;
36670 + return 0;
36673 +static int mv88e6063_set_addr(struct dsa_switch *ds, u8 *addr)
36675 + REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
36676 + REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
36677 + REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);
36679 + return 0;
36682 +static int mv88e6063_port_to_phy_addr(int port)
36684 + if (port >= 0 && port <= NUM_PORTS)
36685 + return REG_PHY(port);
36686 + return -1;
36689 +static int mv88e6063_phy_read(struct dsa_switch *ds, int port, int regnum)
36691 + int addr;
36693 + addr = mv88e6063_port_to_phy_addr(port);
36694 + if (addr == -1)
36695 + return 0xffff;
36697 + return reg_read(ds, addr, regnum);
36700 +static int
36701 +mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
36703 + int addr;
36705 + addr = mv88e6063_port_to_phy_addr(port);
36706 + if (addr == -1)
36707 + return 0xffff;
36709 + return reg_write(ds, addr, regnum, val);
36712 +static void mv88e6063_poll_link(struct dsa_switch *ds)
36714 + int i;
36716 + for (i = 0; i < DSA_MAX_PORTS; i++) {
36717 + struct net_device *dev;
36718 + int uninitialized_var(port_status);
36719 + int link;
36720 + int speed;
36721 + int duplex;
36722 + int fc;
36724 + dev = ds->ports[i];
36725 + if (dev == NULL)
36726 + continue;
36728 + link = 0;
36729 + if (dev->flags & IFF_UP) {
36730 + port_status = reg_read(ds, REG_PORT(i), 0x00);
36731 + if (port_status < 0)
36732 + continue;
36734 + link = !!(port_status & 0x1000);
36737 + if (!link) {
36738 + if (netif_carrier_ok(dev)) {
36739 + printk(KERN_INFO "%s: link down\n", dev->name);
36740 + netif_carrier_off(dev);
36742 + continue;
36745 + speed = (port_status & 0x0100) ? 100 : 10;
36746 + duplex = (port_status & 0x0200) ? 1 : 0;
36747 + fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
36749 + if (!netif_carrier_ok(dev)) {
36750 + printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
36751 + "flow control %sabled\n", dev->name,
36752 + speed, duplex ? "full" : "half",
36753 + fc ? "en" : "dis");
36754 + netif_carrier_on(dev);
36759 +static struct dsa_switch_driver mv88e6063_switch_driver = {
36760 + .tag_protocol = htons(ETH_P_TRAILER),
36761 + .probe = mv88e6063_probe,
36762 + .setup = mv88e6063_setup,
36763 + .set_addr = mv88e6063_set_addr,
36764 + .phy_read = mv88e6063_phy_read,
36765 + .phy_write = mv88e6063_phy_write,
36766 + .poll_link = mv88e6063_poll_link,
36769 +static int __init mv88e6063_init(void)
36771 + register_switch_driver(&mv88e6063_switch_driver);
36772 + return 0;
36774 +module_init(mv88e6063_init);
36776 +static void __exit mv88e6063_cleanup(void)
36778 + unregister_switch_driver(&mv88e6063_switch_driver);
36780 +module_exit(mv88e6063_cleanup);
36781 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/Kconfig linux-4.1.43/drivers/net/ethernet/atheros/Kconfig
36782 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/Kconfig 2017-08-06 01:56:14.000000000 +0200
36783 +++ linux-4.1.43/drivers/net/ethernet/atheros/Kconfig 2017-08-06 20:02:16.000000000 +0200
36784 @@ -5,7 +5,7 @@
36785 config NET_VENDOR_ATHEROS
36786 bool "Atheros devices"
36787 default y
36788 - depends on PCI
36789 + depends on (PCI || ATH79)
36790 ---help---
36791 If you have a network (Ethernet) card belonging to this class, say Y
36792 and read the Ethernet-HOWTO, available from
36793 @@ -80,4 +80,6 @@
36794 To compile this driver as a module, choose M here. The module
36795 will be called alx.
36797 +source drivers/net/ethernet/atheros/ag71xx/Kconfig
36799 endif # NET_VENDOR_ATHEROS
36800 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/Makefile linux-4.1.43/drivers/net/ethernet/atheros/Makefile
36801 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/Makefile 2017-08-06 01:56:14.000000000 +0200
36802 +++ linux-4.1.43/drivers/net/ethernet/atheros/Makefile 2017-08-06 20:02:16.000000000 +0200
36803 @@ -2,6 +2,7 @@
36804 # Makefile for the Atheros network device drivers.
36807 +obj-$(CONFIG_AG71XX) += ag71xx/
36808 obj-$(CONFIG_ATL1) += atlx/
36809 obj-$(CONFIG_ATL2) += atlx/
36810 obj-$(CONFIG_ATL1E) += atl1e/
36811 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/Kconfig linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/Kconfig
36812 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
36813 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/Kconfig 2017-08-06 20:02:16.000000000 +0200
36814 @@ -0,0 +1,33 @@
36815 +config AG71XX
36816 + tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
36817 + depends on ATH79
36818 + select PHYLIB
36819 + help
36820 + If you wish to compile a kernel for AR7XXX/91XXX and enable
36821 + ethernet support, then you should always answer Y to this.
36823 +if AG71XX
36825 +config AG71XX_DEBUG
36826 + bool "Atheros AR71xx built-in ethernet driver debugging"
36827 + default n
36828 + help
36829 + Atheros AR71xx built-in ethernet driver debugging messages.
36831 +config AG71XX_DEBUG_FS
36832 + bool "Atheros AR71xx built-in ethernet driver debugfs support"
36833 + depends on DEBUG_FS
36834 + default n
36835 + help
36836 + Say Y, if you need access to various statistics provided by
36837 + the ag71xx driver.
36839 +config AG71XX_AR8216_SUPPORT
36840 + bool "special support for the Atheros AR8216 switch"
36841 + default n
36842 + default y if ATH79_MACH_WNR2000 || ATH79_MACH_MZK_W04NU
36843 + help
36844 + Say 'y' here if you want to enable special support for the
36845 + Atheros AR8216 switch found on some boards.
36847 +endif
36848 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/Makefile linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/Makefile
36849 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/Makefile 1970-01-01 01:00:00.000000000 +0100
36850 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/Makefile 2017-08-06 20:02:16.000000000 +0200
36851 @@ -0,0 +1,15 @@
36853 +# Makefile for the Atheros AR71xx built-in ethernet macs
36856 +ag71xx-y += ag71xx_main.o
36857 +ag71xx-y += ag71xx_ethtool.o
36858 +ag71xx-y += ag71xx_phy.o
36859 +ag71xx-y += ag71xx_mdio.o
36860 +ag71xx-y += ag71xx_ar7240.o
36862 +ag71xx-$(CONFIG_AG71XX_DEBUG_FS) += ag71xx_debugfs.o
36863 +ag71xx-$(CONFIG_AG71XX_AR8216_SUPPORT) += ag71xx_ar8216.o
36865 +obj-$(CONFIG_AG71XX) += ag71xx.o
36867 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx.h linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
36868 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 1970-01-01 01:00:00.000000000 +0100
36869 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx.h 2017-08-06 20:02:16.000000000 +0200
36870 @@ -0,0 +1,485 @@
36872 + * Atheros AR71xx built-in ethernet mac driver
36874 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
36875 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
36877 + * Based on Atheros' AG7100 driver
36879 + * This program is free software; you can redistribute it and/or modify it
36880 + * under the terms of the GNU General Public License version 2 as published
36881 + * by the Free Software Foundation.
36882 + */
36884 +#ifndef __AG71XX_H
36885 +#define __AG71XX_H
36887 +#include <linux/kernel.h>
36888 +#include <linux/version.h>
36889 +#include <linux/module.h>
36890 +#include <linux/init.h>
36891 +#include <linux/types.h>
36892 +#include <linux/random.h>
36893 +#include <linux/spinlock.h>
36894 +#include <linux/interrupt.h>
36895 +#include <linux/platform_device.h>
36896 +#include <linux/ethtool.h>
36897 +#include <linux/etherdevice.h>
36898 +#include <linux/if_vlan.h>
36899 +#include <linux/phy.h>
36900 +#include <linux/skbuff.h>
36901 +#include <linux/dma-mapping.h>
36902 +#include <linux/workqueue.h>
36904 +#include <linux/bitops.h>
36906 +#include <asm/mach-ath79/ar71xx_regs.h>
36907 +#include <asm/mach-ath79/ath79.h>
36908 +#include <asm/mach-ath79/ag71xx_platform.h>
36910 +#define AG71XX_DRV_NAME "ag71xx"
36911 +#define AG71XX_DRV_VERSION "0.5.35"
36913 +#define AG71XX_NAPI_WEIGHT 64
36914 +#define AG71XX_OOM_REFILL (1 + HZ/10)
36916 +#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
36917 +#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
36918 +#define AG71XX_INT_RX (AG71XX_INT_RX_PR | AG71XX_INT_RX_OF)
36920 +#define AG71XX_INT_POLL (AG71XX_INT_RX | AG71XX_INT_TX)
36921 +#define AG71XX_INT_INIT (AG71XX_INT_ERR | AG71XX_INT_POLL)
36923 +#define AG71XX_TX_MTU_LEN 1540
36925 +#define AG71XX_TX_RING_SPLIT 512
36926 +#define AG71XX_TX_RING_DS_PER_PKT DIV_ROUND_UP(AG71XX_TX_MTU_LEN, \
36927 + AG71XX_TX_RING_SPLIT)
36928 +#define AG71XX_TX_RING_SIZE_DEFAULT 48
36929 +#define AG71XX_RX_RING_SIZE_DEFAULT 128
36931 +#define AG71XX_TX_RING_SIZE_MAX 48
36932 +#define AG71XX_RX_RING_SIZE_MAX 128
36934 +#ifdef CONFIG_AG71XX_DEBUG
36935 +#define DBG(fmt, args...) pr_debug(fmt, ## args)
36936 +#else
36937 +#define DBG(fmt, args...) do {} while (0)
36938 +#endif
36940 +#define ag71xx_assert(_cond) \
36941 +do { \
36942 + if (_cond) \
36943 + break; \
36944 + printk("%s,%d: assertion failed\n", __FILE__, __LINE__); \
36945 + BUG(); \
36946 +} while (0)
36948 +struct ag71xx_desc {
36949 + u32 data;
36950 + u32 ctrl;
36951 +#define DESC_EMPTY BIT(31)
36952 +#define DESC_MORE BIT(24)
36953 +#define DESC_PKTLEN_M 0xfff
36954 + u32 next;
36955 + u32 pad;
36956 +} __attribute__((aligned(4)));
36958 +struct ag71xx_buf {
36959 + union {
36960 + struct sk_buff *skb;
36961 + void *rx_buf;
36962 + };
36963 + union {
36964 + dma_addr_t dma_addr;
36965 + unsigned long timestamp;
36966 + };
36967 + unsigned int len;
36970 +struct ag71xx_ring {
36971 + struct ag71xx_buf *buf;
36972 + u8 *descs_cpu;
36973 + dma_addr_t descs_dma;
36974 + u16 desc_split;
36975 + u16 desc_size;
36976 + unsigned int curr;
36977 + unsigned int dirty;
36978 + unsigned int size;
36981 +struct ag71xx_mdio {
36982 + struct mii_bus *mii_bus;
36983 + int mii_irq[PHY_MAX_ADDR];
36984 + void __iomem *mdio_base;
36985 + struct ag71xx_mdio_platform_data *pdata;
36988 +struct ag71xx_int_stats {
36989 + unsigned long rx_pr;
36990 + unsigned long rx_be;
36991 + unsigned long rx_of;
36992 + unsigned long tx_ps;
36993 + unsigned long tx_be;
36994 + unsigned long tx_ur;
36995 + unsigned long total;
36998 +struct ag71xx_napi_stats {
36999 + unsigned long napi_calls;
37000 + unsigned long rx_count;
37001 + unsigned long rx_packets;
37002 + unsigned long rx_packets_max;
37003 + unsigned long tx_count;
37004 + unsigned long tx_packets;
37005 + unsigned long tx_packets_max;
37007 + unsigned long rx[AG71XX_NAPI_WEIGHT + 1];
37008 + unsigned long tx[AG71XX_NAPI_WEIGHT + 1];
37011 +struct ag71xx_debug {
37012 + struct dentry *debugfs_dir;
37014 + struct ag71xx_int_stats int_stats;
37015 + struct ag71xx_napi_stats napi_stats;
37018 +struct ag71xx {
37019 + void __iomem *mac_base;
37021 + spinlock_t lock;
37022 + struct platform_device *pdev;
37023 + struct net_device *dev;
37024 + struct napi_struct napi;
37025 + u32 msg_enable;
37027 + struct ag71xx_desc *stop_desc;
37028 + dma_addr_t stop_desc_dma;
37030 + struct ag71xx_ring rx_ring;
37031 + struct ag71xx_ring tx_ring;
37033 + struct mii_bus *mii_bus;
37034 + struct phy_device *phy_dev;
37035 + void *phy_priv;
37037 + unsigned int link;
37038 + unsigned int speed;
37039 + int duplex;
37041 + unsigned int max_frame_len;
37042 + unsigned int desc_pktlen_mask;
37043 + unsigned int rx_buf_size;
37045 + struct work_struct restart_work;
37046 + struct delayed_work link_work;
37047 + struct timer_list oom_timer;
37049 +#ifdef CONFIG_AG71XX_DEBUG_FS
37050 + struct ag71xx_debug debug;
37051 +#endif
37054 +extern struct ethtool_ops ag71xx_ethtool_ops;
37055 +void ag71xx_link_adjust(struct ag71xx *ag);
37057 +int ag71xx_mdio_driver_init(void) __init;
37058 +void ag71xx_mdio_driver_exit(void);
37060 +int ag71xx_phy_connect(struct ag71xx *ag);
37061 +void ag71xx_phy_disconnect(struct ag71xx *ag);
37062 +void ag71xx_phy_start(struct ag71xx *ag);
37063 +void ag71xx_phy_stop(struct ag71xx *ag);
37065 +static inline struct ag71xx_platform_data *ag71xx_get_pdata(struct ag71xx *ag)
37067 + return ag->pdev->dev.platform_data;
37070 +static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
37072 + return (desc->ctrl & DESC_EMPTY) != 0;
37075 +static inline struct ag71xx_desc *
37076 +ag71xx_ring_desc(struct ag71xx_ring *ring, int idx)
37078 + return (struct ag71xx_desc *) &ring->descs_cpu[idx * ring->desc_size];
37081 +/* Register offsets */
37082 +#define AG71XX_REG_MAC_CFG1 0x0000
37083 +#define AG71XX_REG_MAC_CFG2 0x0004
37084 +#define AG71XX_REG_MAC_IPG 0x0008
37085 +#define AG71XX_REG_MAC_HDX 0x000c
37086 +#define AG71XX_REG_MAC_MFL 0x0010
37087 +#define AG71XX_REG_MII_CFG 0x0020
37088 +#define AG71XX_REG_MII_CMD 0x0024
37089 +#define AG71XX_REG_MII_ADDR 0x0028
37090 +#define AG71XX_REG_MII_CTRL 0x002c
37091 +#define AG71XX_REG_MII_STATUS 0x0030
37092 +#define AG71XX_REG_MII_IND 0x0034
37093 +#define AG71XX_REG_MAC_IFCTL 0x0038
37094 +#define AG71XX_REG_MAC_ADDR1 0x0040
37095 +#define AG71XX_REG_MAC_ADDR2 0x0044
37096 +#define AG71XX_REG_FIFO_CFG0 0x0048
37097 +#define AG71XX_REG_FIFO_CFG1 0x004c
37098 +#define AG71XX_REG_FIFO_CFG2 0x0050
37099 +#define AG71XX_REG_FIFO_CFG3 0x0054
37100 +#define AG71XX_REG_FIFO_CFG4 0x0058
37101 +#define AG71XX_REG_FIFO_CFG5 0x005c
37102 +#define AG71XX_REG_FIFO_RAM0 0x0060
37103 +#define AG71XX_REG_FIFO_RAM1 0x0064
37104 +#define AG71XX_REG_FIFO_RAM2 0x0068
37105 +#define AG71XX_REG_FIFO_RAM3 0x006c
37106 +#define AG71XX_REG_FIFO_RAM4 0x0070
37107 +#define AG71XX_REG_FIFO_RAM5 0x0074
37108 +#define AG71XX_REG_FIFO_RAM6 0x0078
37109 +#define AG71XX_REG_FIFO_RAM7 0x007c
37111 +#define AG71XX_REG_TX_CTRL 0x0180
37112 +#define AG71XX_REG_TX_DESC 0x0184
37113 +#define AG71XX_REG_TX_STATUS 0x0188
37114 +#define AG71XX_REG_RX_CTRL 0x018c
37115 +#define AG71XX_REG_RX_DESC 0x0190
37116 +#define AG71XX_REG_RX_STATUS 0x0194
37117 +#define AG71XX_REG_INT_ENABLE 0x0198
37118 +#define AG71XX_REG_INT_STATUS 0x019c
37120 +#define AG71XX_REG_FIFO_DEPTH 0x01a8
37121 +#define AG71XX_REG_RX_SM 0x01b0
37122 +#define AG71XX_REG_TX_SM 0x01b4
37124 +#define MAC_CFG1_TXE BIT(0) /* Tx Enable */
37125 +#define MAC_CFG1_STX BIT(1) /* Synchronize Tx Enable */
37126 +#define MAC_CFG1_RXE BIT(2) /* Rx Enable */
37127 +#define MAC_CFG1_SRX BIT(3) /* Synchronize Rx Enable */
37128 +#define MAC_CFG1_TFC BIT(4) /* Tx Flow Control Enable */
37129 +#define MAC_CFG1_RFC BIT(5) /* Rx Flow Control Enable */
37130 +#define MAC_CFG1_LB BIT(8) /* Loopback mode */
37131 +#define MAC_CFG1_SR BIT(31) /* Soft Reset */
37133 +#define MAC_CFG2_FDX BIT(0)
37134 +#define MAC_CFG2_CRC_EN BIT(1)
37135 +#define MAC_CFG2_PAD_CRC_EN BIT(2)
37136 +#define MAC_CFG2_LEN_CHECK BIT(4)
37137 +#define MAC_CFG2_HUGE_FRAME_EN BIT(5)
37138 +#define MAC_CFG2_IF_1000 BIT(9)
37139 +#define MAC_CFG2_IF_10_100 BIT(8)
37141 +#define FIFO_CFG0_WTM BIT(0) /* Watermark Module */
37142 +#define FIFO_CFG0_RXS BIT(1) /* Rx System Module */
37143 +#define FIFO_CFG0_RXF BIT(2) /* Rx Fabric Module */
37144 +#define FIFO_CFG0_TXS BIT(3) /* Tx System Module */
37145 +#define FIFO_CFG0_TXF BIT(4) /* Tx Fabric Module */
37146 +#define FIFO_CFG0_ALL (FIFO_CFG0_WTM | FIFO_CFG0_RXS | FIFO_CFG0_RXF \
37147 + | FIFO_CFG0_TXS | FIFO_CFG0_TXF)
37149 +#define FIFO_CFG0_ENABLE_SHIFT 8
37151 +#define FIFO_CFG4_DE BIT(0) /* Drop Event */
37152 +#define FIFO_CFG4_DV BIT(1) /* RX_DV Event */
37153 +#define FIFO_CFG4_FC BIT(2) /* False Carrier */
37154 +#define FIFO_CFG4_CE BIT(3) /* Code Error */
37155 +#define FIFO_CFG4_CR BIT(4) /* CRC error */
37156 +#define FIFO_CFG4_LM BIT(5) /* Length Mismatch */
37157 +#define FIFO_CFG4_LO BIT(6) /* Length out of range */
37158 +#define FIFO_CFG4_OK BIT(7) /* Packet is OK */
37159 +#define FIFO_CFG4_MC BIT(8) /* Multicast Packet */
37160 +#define FIFO_CFG4_BC BIT(9) /* Broadcast Packet */
37161 +#define FIFO_CFG4_DR BIT(10) /* Dribble */
37162 +#define FIFO_CFG4_LE BIT(11) /* Long Event */
37163 +#define FIFO_CFG4_CF BIT(12) /* Control Frame */
37164 +#define FIFO_CFG4_PF BIT(13) /* Pause Frame */
37165 +#define FIFO_CFG4_UO BIT(14) /* Unsupported Opcode */
37166 +#define FIFO_CFG4_VT BIT(15) /* VLAN tag detected */
37167 +#define FIFO_CFG4_FT BIT(16) /* Frame Truncated */
37168 +#define FIFO_CFG4_UC BIT(17) /* Unicast Packet */
37170 +#define FIFO_CFG5_DE BIT(0) /* Drop Event */
37171 +#define FIFO_CFG5_DV BIT(1) /* RX_DV Event */
37172 +#define FIFO_CFG5_FC BIT(2) /* False Carrier */
37173 +#define FIFO_CFG5_CE BIT(3) /* Code Error */
37174 +#define FIFO_CFG5_LM BIT(4) /* Length Mismatch */
37175 +#define FIFO_CFG5_LO BIT(5) /* Length Out of Range */
37176 +#define FIFO_CFG5_OK BIT(6) /* Packet is OK */
37177 +#define FIFO_CFG5_MC BIT(7) /* Multicast Packet */
37178 +#define FIFO_CFG5_BC BIT(8) /* Broadcast Packet */
37179 +#define FIFO_CFG5_DR BIT(9) /* Dribble */
37180 +#define FIFO_CFG5_CF BIT(10) /* Control Frame */
37181 +#define FIFO_CFG5_PF BIT(11) /* Pause Frame */
37182 +#define FIFO_CFG5_UO BIT(12) /* Unsupported Opcode */
37183 +#define FIFO_CFG5_VT BIT(13) /* VLAN tag detected */
37184 +#define FIFO_CFG5_LE BIT(14) /* Long Event */
37185 +#define FIFO_CFG5_FT BIT(15) /* Frame Truncated */
37186 +#define FIFO_CFG5_16 BIT(16) /* unknown */
37187 +#define FIFO_CFG5_17 BIT(17) /* unknown */
37188 +#define FIFO_CFG5_SF BIT(18) /* Short Frame */
37189 +#define FIFO_CFG5_BM BIT(19) /* Byte Mode */
37191 +#define AG71XX_INT_TX_PS BIT(0)
37192 +#define AG71XX_INT_TX_UR BIT(1)
37193 +#define AG71XX_INT_TX_BE BIT(3)
37194 +#define AG71XX_INT_RX_PR BIT(4)
37195 +#define AG71XX_INT_RX_OF BIT(6)
37196 +#define AG71XX_INT_RX_BE BIT(7)
37198 +#define MAC_IFCTL_SPEED BIT(16)
37200 +#define MII_CFG_CLK_DIV_4 0
37201 +#define MII_CFG_CLK_DIV_6 2
37202 +#define MII_CFG_CLK_DIV_8 3
37203 +#define MII_CFG_CLK_DIV_10 4
37204 +#define MII_CFG_CLK_DIV_14 5
37205 +#define MII_CFG_CLK_DIV_20 6
37206 +#define MII_CFG_CLK_DIV_28 7
37207 +#define MII_CFG_CLK_DIV_34 8
37208 +#define MII_CFG_CLK_DIV_42 9
37209 +#define MII_CFG_CLK_DIV_50 10
37210 +#define MII_CFG_CLK_DIV_58 11
37211 +#define MII_CFG_CLK_DIV_66 12
37212 +#define MII_CFG_CLK_DIV_74 13
37213 +#define MII_CFG_CLK_DIV_82 14
37214 +#define MII_CFG_CLK_DIV_98 15
37215 +#define MII_CFG_RESET BIT(31)
37217 +#define MII_CMD_WRITE 0x0
37218 +#define MII_CMD_READ 0x1
37219 +#define MII_ADDR_SHIFT 8
37220 +#define MII_IND_BUSY BIT(0)
37221 +#define MII_IND_INVALID BIT(2)
37223 +#define TX_CTRL_TXE BIT(0) /* Tx Enable */
37225 +#define TX_STATUS_PS BIT(0) /* Packet Sent */
37226 +#define TX_STATUS_UR BIT(1) /* Tx Underrun */
37227 +#define TX_STATUS_BE BIT(3) /* Bus Error */
37229 +#define RX_CTRL_RXE BIT(0) /* Rx Enable */
37231 +#define RX_STATUS_PR BIT(0) /* Packet Received */
37232 +#define RX_STATUS_OF BIT(2) /* Rx Overflow */
37233 +#define RX_STATUS_BE BIT(3) /* Bus Error */
37235 +static inline void ag71xx_check_reg_offset(struct ag71xx *ag, unsigned reg)
37237 + switch (reg) {
37238 + case AG71XX_REG_MAC_CFG1 ... AG71XX_REG_MAC_MFL:
37239 + case AG71XX_REG_MAC_IFCTL ... AG71XX_REG_TX_SM:
37240 + case AG71XX_REG_MII_CFG:
37241 + break;
37243 + default:
37244 + BUG();
37248 +static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
37250 + ag71xx_check_reg_offset(ag, reg);
37252 + __raw_writel(value, ag->mac_base + reg);
37253 + /* flush write */
37254 + (void) __raw_readl(ag->mac_base + reg);
37257 +static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
37259 + ag71xx_check_reg_offset(ag, reg);
37261 + return __raw_readl(ag->mac_base + reg);
37264 +static inline void ag71xx_sb(struct ag71xx *ag, unsigned reg, u32 mask)
37266 + void __iomem *r;
37268 + ag71xx_check_reg_offset(ag, reg);
37270 + r = ag->mac_base + reg;
37271 + __raw_writel(__raw_readl(r) | mask, r);
37272 + /* flush write */
37273 + (void)__raw_readl(r);
37276 +static inline void ag71xx_cb(struct ag71xx *ag, unsigned reg, u32 mask)
37278 + void __iomem *r;
37280 + ag71xx_check_reg_offset(ag, reg);
37282 + r = ag->mac_base + reg;
37283 + __raw_writel(__raw_readl(r) & ~mask, r);
37284 + /* flush write */
37285 + (void) __raw_readl(r);
37288 +static inline void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
37290 + ag71xx_sb(ag, AG71XX_REG_INT_ENABLE, ints);
37293 +static inline void ag71xx_int_disable(struct ag71xx *ag, u32 ints)
37295 + ag71xx_cb(ag, AG71XX_REG_INT_ENABLE, ints);
37298 +#ifdef CONFIG_AG71XX_AR8216_SUPPORT
37299 +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb);
37300 +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
37301 + int pktlen);
37302 +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
37304 + return ag71xx_get_pdata(ag)->has_ar8216;
37306 +#else
37307 +static inline void ag71xx_add_ar8216_header(struct ag71xx *ag,
37308 + struct sk_buff *skb)
37312 +static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
37313 + struct sk_buff *skb,
37314 + int pktlen)
37316 + return 0;
37318 +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
37320 + return 0;
37322 +#endif
37324 +#ifdef CONFIG_AG71XX_DEBUG_FS
37325 +int ag71xx_debugfs_root_init(void);
37326 +void ag71xx_debugfs_root_exit(void);
37327 +int ag71xx_debugfs_init(struct ag71xx *ag);
37328 +void ag71xx_debugfs_exit(struct ag71xx *ag);
37329 +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status);
37330 +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx);
37331 +#else
37332 +static inline int ag71xx_debugfs_root_init(void) { return 0; }
37333 +static inline void ag71xx_debugfs_root_exit(void) {}
37334 +static inline int ag71xx_debugfs_init(struct ag71xx *ag) { return 0; }
37335 +static inline void ag71xx_debugfs_exit(struct ag71xx *ag) {}
37336 +static inline void ag71xx_debugfs_update_int_stats(struct ag71xx *ag,
37337 + u32 status) {}
37338 +static inline void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag,
37339 + int rx, int tx) {}
37340 +#endif /* CONFIG_AG71XX_DEBUG_FS */
37342 +void ag71xx_ar7240_start(struct ag71xx *ag);
37343 +void ag71xx_ar7240_stop(struct ag71xx *ag);
37344 +int ag71xx_ar7240_init(struct ag71xx *ag);
37345 +void ag71xx_ar7240_cleanup(struct ag71xx *ag);
37347 +int ag71xx_mdio_mii_read(struct ag71xx_mdio *am, int addr, int reg);
37348 +void ag71xx_mdio_mii_write(struct ag71xx_mdio *am, int addr, int reg, u16 val);
37350 +u16 ar7240sw_phy_read(struct mii_bus *mii, unsigned phy_addr,
37351 + unsigned reg_addr);
37352 +int ar7240sw_phy_write(struct mii_bus *mii, unsigned phy_addr,
37353 + unsigned reg_addr, u16 reg_val);
37355 +#endif /* _AG71XX_H */
37356 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
37357 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c 1970-01-01 01:00:00.000000000 +0100
37358 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c 2017-08-06 20:02:16.000000000 +0200
37359 @@ -0,0 +1,1229 @@
37361 + * Driver for the built-in ethernet switch of the Atheros AR7240 SoC
37362 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
37363 + * Copyright (c) 2010 Felix Fietkau <nbd@openwrt.org>
37365 + * This program is free software; you can redistribute it and/or modify it
37366 + * under the terms of the GNU General Public License version 2 as published
37367 + * by the Free Software Foundation.
37369 + */
37371 +#include <linux/etherdevice.h>
37372 +#include <linux/list.h>
37373 +#include <linux/netdevice.h>
37374 +#include <linux/phy.h>
37375 +#include <linux/mii.h>
37376 +#include <linux/bitops.h>
37377 +#include <linux/switch.h>
37378 +#include "ag71xx.h"
37380 +#define BITM(_count) (BIT(_count) - 1)
37381 +#define BITS(_shift, _count) (BITM(_count) << _shift)
37383 +#define AR7240_REG_MASK_CTRL 0x00
37384 +#define AR7240_MASK_CTRL_REVISION_M BITM(8)
37385 +#define AR7240_MASK_CTRL_VERSION_M BITM(8)
37386 +#define AR7240_MASK_CTRL_VERSION_S 8
37387 +#define AR7240_MASK_CTRL_VERSION_AR7240 0x01
37388 +#define AR7240_MASK_CTRL_VERSION_AR934X 0x02
37389 +#define AR7240_MASK_CTRL_SOFT_RESET BIT(31)
37391 +#define AR7240_REG_MAC_ADDR0 0x20
37392 +#define AR7240_REG_MAC_ADDR1 0x24
37394 +#define AR7240_REG_FLOOD_MASK 0x2c
37395 +#define AR7240_FLOOD_MASK_BROAD_TO_CPU BIT(26)
37397 +#define AR7240_REG_GLOBAL_CTRL 0x30
37398 +#define AR7240_GLOBAL_CTRL_MTU_M BITM(11)
37399 +#define AR9340_GLOBAL_CTRL_MTU_M BITM(14)
37401 +#define AR7240_REG_VTU 0x0040
37402 +#define AR7240_VTU_OP BITM(3)
37403 +#define AR7240_VTU_OP_NOOP 0x0
37404 +#define AR7240_VTU_OP_FLUSH 0x1
37405 +#define AR7240_VTU_OP_LOAD 0x2
37406 +#define AR7240_VTU_OP_PURGE 0x3
37407 +#define AR7240_VTU_OP_REMOVE_PORT 0x4
37408 +#define AR7240_VTU_ACTIVE BIT(3)
37409 +#define AR7240_VTU_FULL BIT(4)
37410 +#define AR7240_VTU_PORT BITS(8, 4)
37411 +#define AR7240_VTU_PORT_S 8
37412 +#define AR7240_VTU_VID BITS(16, 12)
37413 +#define AR7240_VTU_VID_S 16
37414 +#define AR7240_VTU_PRIO BITS(28, 3)
37415 +#define AR7240_VTU_PRIO_S 28
37416 +#define AR7240_VTU_PRIO_EN BIT(31)
37418 +#define AR7240_REG_VTU_DATA 0x0044
37419 +#define AR7240_VTUDATA_MEMBER BITS(0, 10)
37420 +#define AR7240_VTUDATA_VALID BIT(11)
37422 +#define AR7240_REG_ATU 0x50
37423 +#define AR7240_ATU_FLUSH_ALL 0x1
37425 +#define AR7240_REG_AT_CTRL 0x5c
37426 +#define AR7240_AT_CTRL_AGE_TIME BITS(0, 15)
37427 +#define AR7240_AT_CTRL_AGE_EN BIT(17)
37428 +#define AR7240_AT_CTRL_LEARN_CHANGE BIT(18)
37429 +#define AR7240_AT_CTRL_RESERVED BIT(19)
37430 +#define AR7240_AT_CTRL_ARP_EN BIT(20)
37432 +#define AR7240_REG_TAG_PRIORITY 0x70
37434 +#define AR7240_REG_SERVICE_TAG 0x74
37435 +#define AR7240_SERVICE_TAG_M BITM(16)
37437 +#define AR7240_REG_CPU_PORT 0x78
37438 +#define AR7240_MIRROR_PORT_S 4
37439 +#define AR7240_CPU_PORT_EN BIT(8)
37441 +#define AR7240_REG_MIB_FUNCTION0 0x80
37442 +#define AR7240_MIB_TIMER_M BITM(16)
37443 +#define AR7240_MIB_AT_HALF_EN BIT(16)
37444 +#define AR7240_MIB_BUSY BIT(17)
37445 +#define AR7240_MIB_FUNC_S 24
37446 +#define AR7240_MIB_FUNC_M BITM(3)
37447 +#define AR7240_MIB_FUNC_NO_OP 0x0
37448 +#define AR7240_MIB_FUNC_FLUSH 0x1
37449 +#define AR7240_MIB_FUNC_CAPTURE 0x3
37451 +#define AR7240_REG_MDIO_CTRL 0x98
37452 +#define AR7240_MDIO_CTRL_DATA_M BITM(16)
37453 +#define AR7240_MDIO_CTRL_REG_ADDR_S 16
37454 +#define AR7240_MDIO_CTRL_PHY_ADDR_S 21
37455 +#define AR7240_MDIO_CTRL_CMD_WRITE 0
37456 +#define AR7240_MDIO_CTRL_CMD_READ BIT(27)
37457 +#define AR7240_MDIO_CTRL_MASTER_EN BIT(30)
37458 +#define AR7240_MDIO_CTRL_BUSY BIT(31)
37460 +#define AR7240_REG_PORT_BASE(_port) (0x100 + (_port) * 0x100)
37462 +#define AR7240_REG_PORT_STATUS(_port) (AR7240_REG_PORT_BASE((_port)) + 0x00)
37463 +#define AR7240_PORT_STATUS_SPEED_S 0
37464 +#define AR7240_PORT_STATUS_SPEED_M BITM(2)
37465 +#define AR7240_PORT_STATUS_SPEED_10 0
37466 +#define AR7240_PORT_STATUS_SPEED_100 1
37467 +#define AR7240_PORT_STATUS_SPEED_1000 2
37468 +#define AR7240_PORT_STATUS_TXMAC BIT(2)
37469 +#define AR7240_PORT_STATUS_RXMAC BIT(3)
37470 +#define AR7240_PORT_STATUS_TXFLOW BIT(4)
37471 +#define AR7240_PORT_STATUS_RXFLOW BIT(5)
37472 +#define AR7240_PORT_STATUS_DUPLEX BIT(6)
37473 +#define AR7240_PORT_STATUS_LINK_UP BIT(8)
37474 +#define AR7240_PORT_STATUS_LINK_AUTO BIT(9)
37475 +#define AR7240_PORT_STATUS_LINK_PAUSE BIT(10)
37477 +#define AR7240_REG_PORT_CTRL(_port) (AR7240_REG_PORT_BASE((_port)) + 0x04)
37478 +#define AR7240_PORT_CTRL_STATE_M BITM(3)
37479 +#define AR7240_PORT_CTRL_STATE_DISABLED 0
37480 +#define AR7240_PORT_CTRL_STATE_BLOCK 1
37481 +#define AR7240_PORT_CTRL_STATE_LISTEN 2
37482 +#define AR7240_PORT_CTRL_STATE_LEARN 3
37483 +#define AR7240_PORT_CTRL_STATE_FORWARD 4
37484 +#define AR7240_PORT_CTRL_LEARN_LOCK BIT(7)
37485 +#define AR7240_PORT_CTRL_VLAN_MODE_S 8
37486 +#define AR7240_PORT_CTRL_VLAN_MODE_KEEP 0
37487 +#define AR7240_PORT_CTRL_VLAN_MODE_STRIP 1
37488 +#define AR7240_PORT_CTRL_VLAN_MODE_ADD 2
37489 +#define AR7240_PORT_CTRL_VLAN_MODE_DOUBLE_TAG 3
37490 +#define AR7240_PORT_CTRL_IGMP_SNOOP BIT(10)
37491 +#define AR7240_PORT_CTRL_HEADER BIT(11)
37492 +#define AR7240_PORT_CTRL_MAC_LOOP BIT(12)
37493 +#define AR7240_PORT_CTRL_SINGLE_VLAN BIT(13)
37494 +#define AR7240_PORT_CTRL_LEARN BIT(14)
37495 +#define AR7240_PORT_CTRL_DOUBLE_TAG BIT(15)
37496 +#define AR7240_PORT_CTRL_MIRROR_TX BIT(16)
37497 +#define AR7240_PORT_CTRL_MIRROR_RX BIT(17)
37499 +#define AR7240_REG_PORT_VLAN(_port) (AR7240_REG_PORT_BASE((_port)) + 0x08)
37501 +#define AR7240_PORT_VLAN_DEFAULT_ID_S 0
37502 +#define AR7240_PORT_VLAN_DEST_PORTS_S 16
37503 +#define AR7240_PORT_VLAN_MODE_S 30
37504 +#define AR7240_PORT_VLAN_MODE_PORT_ONLY 0
37505 +#define AR7240_PORT_VLAN_MODE_PORT_FALLBACK 1
37506 +#define AR7240_PORT_VLAN_MODE_VLAN_ONLY 2
37507 +#define AR7240_PORT_VLAN_MODE_SECURE 3
37510 +#define AR7240_REG_STATS_BASE(_port) (0x20000 + (_port) * 0x100)
37512 +#define AR7240_STATS_RXBROAD 0x00
37513 +#define AR7240_STATS_RXPAUSE 0x04
37514 +#define AR7240_STATS_RXMULTI 0x08
37515 +#define AR7240_STATS_RXFCSERR 0x0c
37516 +#define AR7240_STATS_RXALIGNERR 0x10
37517 +#define AR7240_STATS_RXRUNT 0x14
37518 +#define AR7240_STATS_RXFRAGMENT 0x18
37519 +#define AR7240_STATS_RX64BYTE 0x1c
37520 +#define AR7240_STATS_RX128BYTE 0x20
37521 +#define AR7240_STATS_RX256BYTE 0x24
37522 +#define AR7240_STATS_RX512BYTE 0x28
37523 +#define AR7240_STATS_RX1024BYTE 0x2c
37524 +#define AR7240_STATS_RX1518BYTE 0x30
37525 +#define AR7240_STATS_RXMAXBYTE 0x34
37526 +#define AR7240_STATS_RXTOOLONG 0x38
37527 +#define AR7240_STATS_RXGOODBYTE 0x3c
37528 +#define AR7240_STATS_RXBADBYTE 0x44
37529 +#define AR7240_STATS_RXOVERFLOW 0x4c
37530 +#define AR7240_STATS_FILTERED 0x50
37531 +#define AR7240_STATS_TXBROAD 0x54
37532 +#define AR7240_STATS_TXPAUSE 0x58
37533 +#define AR7240_STATS_TXMULTI 0x5c
37534 +#define AR7240_STATS_TXUNDERRUN 0x60
37535 +#define AR7240_STATS_TX64BYTE 0x64
37536 +#define AR7240_STATS_TX128BYTE 0x68
37537 +#define AR7240_STATS_TX256BYTE 0x6c
37538 +#define AR7240_STATS_TX512BYTE 0x70
37539 +#define AR7240_STATS_TX1024BYTE 0x74
37540 +#define AR7240_STATS_TX1518BYTE 0x78
37541 +#define AR7240_STATS_TXMAXBYTE 0x7c
37542 +#define AR7240_STATS_TXOVERSIZE 0x80
37543 +#define AR7240_STATS_TXBYTE 0x84
37544 +#define AR7240_STATS_TXCOLLISION 0x8c
37545 +#define AR7240_STATS_TXABORTCOL 0x90
37546 +#define AR7240_STATS_TXMULTICOL 0x94
37547 +#define AR7240_STATS_TXSINGLECOL 0x98
37548 +#define AR7240_STATS_TXEXCDEFER 0x9c
37549 +#define AR7240_STATS_TXDEFER 0xa0
37550 +#define AR7240_STATS_TXLATECOL 0xa4
37552 +#define AR7240_PORT_CPU 0
37553 +#define AR7240_NUM_PORTS 6
37554 +#define AR7240_NUM_PHYS 5
37556 +#define AR7240_PHY_ID1 0x004d
37557 +#define AR7240_PHY_ID2 0xd041
37559 +#define AR934X_PHY_ID1 0x004d
37560 +#define AR934X_PHY_ID2 0xd042
37562 +#define AR7240_MAX_VLANS 16
37564 +#define AR934X_REG_OPER_MODE0 0x04
37565 +#define AR934X_OPER_MODE0_MAC_GMII_EN BIT(6)
37566 +#define AR934X_OPER_MODE0_PHY_MII_EN BIT(10)
37568 +#define AR934X_REG_OPER_MODE1 0x08
37569 +#define AR934X_REG_OPER_MODE1_PHY4_MII_EN BIT(28)
37571 +#define AR934X_REG_FLOOD_MASK 0x2c
37572 +#define AR934X_FLOOD_MASK_MC_DP(_p) BIT(16 + (_p))
37573 +#define AR934X_FLOOD_MASK_BC_DP(_p) BIT(25 + (_p))
37575 +#define AR934X_REG_QM_CTRL 0x3c
37576 +#define AR934X_QM_CTRL_ARP_EN BIT(15)
37578 +#define AR934X_REG_AT_CTRL 0x5c
37579 +#define AR934X_AT_CTRL_AGE_TIME BITS(0, 15)
37580 +#define AR934X_AT_CTRL_AGE_EN BIT(17)
37581 +#define AR934X_AT_CTRL_LEARN_CHANGE BIT(18)
37583 +#define AR934X_MIB_ENABLE BIT(30)
37585 +#define AR934X_REG_PORT_BASE(_port) (0x100 + (_port) * 0x100)
37587 +#define AR934X_REG_PORT_VLAN1(_port) (AR934X_REG_PORT_BASE((_port)) + 0x08)
37588 +#define AR934X_PORT_VLAN1_DEFAULT_SVID_S 0
37589 +#define AR934X_PORT_VLAN1_FORCE_DEFAULT_VID_EN BIT(12)
37590 +#define AR934X_PORT_VLAN1_PORT_TLS_MODE BIT(13)
37591 +#define AR934X_PORT_VLAN1_PORT_VLAN_PROP_EN BIT(14)
37592 +#define AR934X_PORT_VLAN1_PORT_CLONE_EN BIT(15)
37593 +#define AR934X_PORT_VLAN1_DEFAULT_CVID_S 16
37594 +#define AR934X_PORT_VLAN1_FORCE_PORT_VLAN_EN BIT(28)
37595 +#define AR934X_PORT_VLAN1_ING_PORT_PRI_S 29
37597 +#define AR934X_REG_PORT_VLAN2(_port) (AR934X_REG_PORT_BASE((_port)) + 0x0c)
37598 +#define AR934X_PORT_VLAN2_PORT_VID_MEM_S 16
37599 +#define AR934X_PORT_VLAN2_8021Q_MODE_S 30
37600 +#define AR934X_PORT_VLAN2_8021Q_MODE_PORT_ONLY 0
37601 +#define AR934X_PORT_VLAN2_8021Q_MODE_PORT_FALLBACK 1
37602 +#define AR934X_PORT_VLAN2_8021Q_MODE_VLAN_ONLY 2
37603 +#define AR934X_PORT_VLAN2_8021Q_MODE_SECURE 3
37605 +#define sw_to_ar7240(_dev) container_of(_dev, struct ar7240sw, swdev)
37607 +struct ar7240sw_port_stat {
37608 + unsigned long rx_broadcast;
37609 + unsigned long rx_pause;
37610 + unsigned long rx_multicast;
37611 + unsigned long rx_fcs_error;
37612 + unsigned long rx_align_error;
37613 + unsigned long rx_runt;
37614 + unsigned long rx_fragments;
37615 + unsigned long rx_64byte;
37616 + unsigned long rx_128byte;
37617 + unsigned long rx_256byte;
37618 + unsigned long rx_512byte;
37619 + unsigned long rx_1024byte;
37620 + unsigned long rx_1518byte;
37621 + unsigned long rx_maxbyte;
37622 + unsigned long rx_toolong;
37623 + unsigned long rx_good_byte;
37624 + unsigned long rx_bad_byte;
37625 + unsigned long rx_overflow;
37626 + unsigned long filtered;
37628 + unsigned long tx_broadcast;
37629 + unsigned long tx_pause;
37630 + unsigned long tx_multicast;
37631 + unsigned long tx_underrun;
37632 + unsigned long tx_64byte;
37633 + unsigned long tx_128byte;
37634 + unsigned long tx_256byte;
37635 + unsigned long tx_512byte;
37636 + unsigned long tx_1024byte;
37637 + unsigned long tx_1518byte;
37638 + unsigned long tx_maxbyte;
37639 + unsigned long tx_oversize;
37640 + unsigned long tx_byte;
37641 + unsigned long tx_collision;
37642 + unsigned long tx_abortcol;
37643 + unsigned long tx_multicol;
37644 + unsigned long tx_singlecol;
37645 + unsigned long tx_excdefer;
37646 + unsigned long tx_defer;
37647 + unsigned long tx_xlatecol;
37650 +struct ar7240sw {
37651 + struct mii_bus *mii_bus;
37652 + struct ag71xx_switch_platform_data *swdata;
37653 + struct switch_dev swdev;
37654 + int num_ports;
37655 + u8 ver;
37656 + bool vlan;
37657 + u16 vlan_id[AR7240_MAX_VLANS];
37658 + u8 vlan_table[AR7240_MAX_VLANS];
37659 + u8 vlan_tagged;
37660 + u16 pvid[AR7240_NUM_PORTS];
37661 + char buf[80];
37663 + rwlock_t stats_lock;
37664 + struct ar7240sw_port_stat port_stats[AR7240_NUM_PORTS];
37667 +struct ar7240sw_hw_stat {
37668 + char string[ETH_GSTRING_LEN];
37669 + int sizeof_stat;
37670 + int reg;
37673 +static DEFINE_MUTEX(reg_mutex);
37675 +static inline int sw_is_ar7240(struct ar7240sw *as)
37677 + return as->ver == AR7240_MASK_CTRL_VERSION_AR7240;
37680 +static inline int sw_is_ar934x(struct ar7240sw *as)
37682 + return as->ver == AR7240_MASK_CTRL_VERSION_AR934X;
37685 +static inline u32 ar7240sw_port_mask(struct ar7240sw *as, int port)
37687 + return BIT(port);
37690 +static inline u32 ar7240sw_port_mask_all(struct ar7240sw *as)
37692 + return BIT(as->swdev.ports) - 1;
37695 +static inline u32 ar7240sw_port_mask_but(struct ar7240sw *as, int port)
37697 + return ar7240sw_port_mask_all(as) & ~BIT(port);
37700 +static inline u16 mk_phy_addr(u32 reg)
37702 + return 0x17 & ((reg >> 4) | 0x10);
37705 +static inline u16 mk_phy_reg(u32 reg)
37707 + return (reg << 1) & 0x1e;
37710 +static inline u16 mk_high_addr(u32 reg)
37712 + return (reg >> 7) & 0x1ff;
37715 +static u32 __ar7240sw_reg_read(struct mii_bus *mii, u32 reg)
37717 + unsigned long flags;
37718 + u16 phy_addr;
37719 + u16 phy_reg;
37720 + u32 hi, lo;
37722 + reg = (reg & 0xfffffffc) >> 2;
37723 + phy_addr = mk_phy_addr(reg);
37724 + phy_reg = mk_phy_reg(reg);
37726 + local_irq_save(flags);
37727 + ag71xx_mdio_mii_write(mii->priv, 0x1f, 0x10, mk_high_addr(reg));
37728 + lo = (u32) ag71xx_mdio_mii_read(mii->priv, phy_addr, phy_reg);
37729 + hi = (u32) ag71xx_mdio_mii_read(mii->priv, phy_addr, phy_reg + 1);
37730 + local_irq_restore(flags);
37732 + return (hi << 16) | lo;
37735 +static void __ar7240sw_reg_write(struct mii_bus *mii, u32 reg, u32 val)
37737 + unsigned long flags;
37738 + u16 phy_addr;
37739 + u16 phy_reg;
37741 + reg = (reg & 0xfffffffc) >> 2;
37742 + phy_addr = mk_phy_addr(reg);
37743 + phy_reg = mk_phy_reg(reg);
37745 + local_irq_save(flags);
37746 + ag71xx_mdio_mii_write(mii->priv, 0x1f, 0x10, mk_high_addr(reg));
37747 + ag71xx_mdio_mii_write(mii->priv, phy_addr, phy_reg + 1, (val >> 16));
37748 + ag71xx_mdio_mii_write(mii->priv, phy_addr, phy_reg, (val & 0xffff));
37749 + local_irq_restore(flags);
37752 +static u32 ar7240sw_reg_read(struct mii_bus *mii, u32 reg_addr)
37754 + u32 ret;
37756 + mutex_lock(&reg_mutex);
37757 + ret = __ar7240sw_reg_read(mii, reg_addr);
37758 + mutex_unlock(&reg_mutex);
37760 + return ret;
37763 +static void ar7240sw_reg_write(struct mii_bus *mii, u32 reg_addr, u32 reg_val)
37765 + mutex_lock(&reg_mutex);
37766 + __ar7240sw_reg_write(mii, reg_addr, reg_val);
37767 + mutex_unlock(&reg_mutex);
37770 +static u32 ar7240sw_reg_rmw(struct mii_bus *mii, u32 reg, u32 mask, u32 val)
37772 + u32 t;
37774 + mutex_lock(&reg_mutex);
37775 + t = __ar7240sw_reg_read(mii, reg);
37776 + t &= ~mask;
37777 + t |= val;
37778 + __ar7240sw_reg_write(mii, reg, t);
37779 + mutex_unlock(&reg_mutex);
37781 + return t;
37784 +static void ar7240sw_reg_set(struct mii_bus *mii, u32 reg, u32 val)
37786 + u32 t;
37788 + mutex_lock(&reg_mutex);
37789 + t = __ar7240sw_reg_read(mii, reg);
37790 + t |= val;
37791 + __ar7240sw_reg_write(mii, reg, t);
37792 + mutex_unlock(&reg_mutex);
37795 +static int __ar7240sw_reg_wait(struct mii_bus *mii, u32 reg, u32 mask, u32 val,
37796 + unsigned timeout)
37798 + int i;
37800 + for (i = 0; i < timeout; i++) {
37801 + u32 t;
37803 + t = __ar7240sw_reg_read(mii, reg);
37804 + if ((t & mask) == val)
37805 + return 0;
37807 + usleep_range(1000, 2000);
37810 + return -ETIMEDOUT;
37813 +static int ar7240sw_reg_wait(struct mii_bus *mii, u32 reg, u32 mask, u32 val,
37814 + unsigned timeout)
37816 + int ret;
37818 + mutex_lock(&reg_mutex);
37819 + ret = __ar7240sw_reg_wait(mii, reg, mask, val, timeout);
37820 + mutex_unlock(&reg_mutex);
37821 + return ret;
37824 +u16 ar7240sw_phy_read(struct mii_bus *mii, unsigned phy_addr,
37825 + unsigned reg_addr)
37827 + u32 t, val = 0xffff;
37828 + int err;
37830 + if (phy_addr >= AR7240_NUM_PHYS)
37831 + return 0xffff;
37833 + mutex_lock(&reg_mutex);
37834 + t = (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
37835 + (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
37836 + AR7240_MDIO_CTRL_MASTER_EN |
37837 + AR7240_MDIO_CTRL_BUSY |
37838 + AR7240_MDIO_CTRL_CMD_READ;
37840 + __ar7240sw_reg_write(mii, AR7240_REG_MDIO_CTRL, t);
37841 + err = __ar7240sw_reg_wait(mii, AR7240_REG_MDIO_CTRL,
37842 + AR7240_MDIO_CTRL_BUSY, 0, 5);
37843 + if (!err)
37844 + val = __ar7240sw_reg_read(mii, AR7240_REG_MDIO_CTRL);
37845 + mutex_unlock(&reg_mutex);
37847 + return val & AR7240_MDIO_CTRL_DATA_M;
37850 +int ar7240sw_phy_write(struct mii_bus *mii, unsigned phy_addr,
37851 + unsigned reg_addr, u16 reg_val)
37853 + u32 t;
37854 + int ret;
37856 + if (phy_addr >= AR7240_NUM_PHYS)
37857 + return -EINVAL;
37859 + mutex_lock(&reg_mutex);
37860 + t = (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
37861 + (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
37862 + AR7240_MDIO_CTRL_MASTER_EN |
37863 + AR7240_MDIO_CTRL_BUSY |
37864 + AR7240_MDIO_CTRL_CMD_WRITE |
37865 + reg_val;
37867 + __ar7240sw_reg_write(mii, AR7240_REG_MDIO_CTRL, t);
37868 + ret = __ar7240sw_reg_wait(mii, AR7240_REG_MDIO_CTRL,
37869 + AR7240_MDIO_CTRL_BUSY, 0, 5);
37870 + mutex_unlock(&reg_mutex);
37872 + return ret;
37875 +static int ar7240sw_capture_stats(struct ar7240sw *as)
37877 + struct mii_bus *mii = as->mii_bus;
37878 + int port;
37879 + int ret;
37881 + write_lock(&as->stats_lock);
37883 + /* Capture the hardware statistics for all ports */
37884 + ar7240sw_reg_rmw(mii, AR7240_REG_MIB_FUNCTION0,
37885 + (AR7240_MIB_FUNC_M << AR7240_MIB_FUNC_S),
37886 + (AR7240_MIB_FUNC_CAPTURE << AR7240_MIB_FUNC_S));
37888 + /* Wait for the capturing to complete. */
37889 + ret = ar7240sw_reg_wait(mii, AR7240_REG_MIB_FUNCTION0,
37890 + AR7240_MIB_BUSY, 0, 10);
37892 + if (ret)
37893 + goto unlock;
37895 + for (port = 0; port < AR7240_NUM_PORTS; port++) {
37896 + unsigned int base;
37897 + struct ar7240sw_port_stat *stats;
37899 + base = AR7240_REG_STATS_BASE(port);
37900 + stats = &as->port_stats[port];
37902 +#define READ_STAT(_r) ar7240sw_reg_read(mii, base + AR7240_STATS_ ## _r)
37904 + stats->rx_good_byte += READ_STAT(RXGOODBYTE);
37905 + stats->tx_byte += READ_STAT(TXBYTE);
37907 +#undef READ_STAT
37910 + ret = 0;
37912 +unlock:
37913 + write_unlock(&as->stats_lock);
37914 + return ret;
37917 +static void ar7240sw_disable_port(struct ar7240sw *as, unsigned port)
37919 + ar7240sw_reg_write(as->mii_bus, AR7240_REG_PORT_CTRL(port),
37920 + AR7240_PORT_CTRL_STATE_DISABLED);
37923 +static void ar7240sw_setup(struct ar7240sw *as)
37925 + struct mii_bus *mii = as->mii_bus;
37927 + /* Enable CPU port, and disable mirror port */
37928 + ar7240sw_reg_write(mii, AR7240_REG_CPU_PORT,
37929 + AR7240_CPU_PORT_EN |
37930 + (15 << AR7240_MIRROR_PORT_S));
37932 + /* Setup TAG priority mapping */
37933 + ar7240sw_reg_write(mii, AR7240_REG_TAG_PRIORITY, 0xfa50);
37935 + if (sw_is_ar934x(as)) {
37936 + /* Enable aging, MAC replacing */
37937 + ar7240sw_reg_write(mii, AR934X_REG_AT_CTRL,
37938 + 0x2b /* 5 min age time */ |
37939 + AR934X_AT_CTRL_AGE_EN |
37940 + AR934X_AT_CTRL_LEARN_CHANGE);
37941 + /* Enable ARP frame acknowledge */
37942 + ar7240sw_reg_set(mii, AR934X_REG_QM_CTRL,
37943 + AR934X_QM_CTRL_ARP_EN);
37944 + /* Enable Broadcast/Multicast frames transmitted to the CPU */
37945 + ar7240sw_reg_set(mii, AR934X_REG_FLOOD_MASK,
37946 + AR934X_FLOOD_MASK_BC_DP(0) |
37947 + AR934X_FLOOD_MASK_MC_DP(0));
37949 + /* setup MTU */
37950 + ar7240sw_reg_rmw(mii, AR7240_REG_GLOBAL_CTRL,
37951 + AR9340_GLOBAL_CTRL_MTU_M,
37952 + AR9340_GLOBAL_CTRL_MTU_M);
37954 + /* Enable MIB counters */
37955 + ar7240sw_reg_set(mii, AR7240_REG_MIB_FUNCTION0,
37956 + AR934X_MIB_ENABLE);
37958 + } else {
37959 + /* Enable ARP frame acknowledge, aging, MAC replacing */
37960 + ar7240sw_reg_write(mii, AR7240_REG_AT_CTRL,
37961 + AR7240_AT_CTRL_RESERVED |
37962 + 0x2b /* 5 min age time */ |
37963 + AR7240_AT_CTRL_AGE_EN |
37964 + AR7240_AT_CTRL_ARP_EN |
37965 + AR7240_AT_CTRL_LEARN_CHANGE);
37966 + /* Enable Broadcast frames transmitted to the CPU */
37967 + ar7240sw_reg_set(mii, AR7240_REG_FLOOD_MASK,
37968 + AR7240_FLOOD_MASK_BROAD_TO_CPU);
37970 + /* setup MTU */
37971 + ar7240sw_reg_rmw(mii, AR7240_REG_GLOBAL_CTRL,
37972 + AR7240_GLOBAL_CTRL_MTU_M,
37973 + AR7240_GLOBAL_CTRL_MTU_M);
37976 + /* setup Service TAG */
37977 + ar7240sw_reg_rmw(mii, AR7240_REG_SERVICE_TAG, AR7240_SERVICE_TAG_M, 0);
37980 +/* inspired by phy_poll_reset in drivers/net/phy/phy_device.c */
37981 +static int
37982 +ar7240sw_phy_poll_reset(struct mii_bus *bus)
37984 + const unsigned int sleep_msecs = 20;
37985 + int ret, elapsed, i;
37987 + for (elapsed = sleep_msecs; elapsed <= 600;
37988 + elapsed += sleep_msecs) {
37989 + msleep(sleep_msecs);
37990 + for (i = 0; i < AR7240_NUM_PHYS; i++) {
37991 + ret = ar7240sw_phy_read(bus, i, MII_BMCR);
37992 + if (ret < 0)
37993 + return ret;
37994 + if (ret & BMCR_RESET)
37995 + break;
37996 + if (i == AR7240_NUM_PHYS - 1) {
37997 + usleep_range(1000, 2000);
37998 + return 0;
38002 + return -ETIMEDOUT;
38005 +static int ar7240sw_reset(struct ar7240sw *as)
38007 + struct mii_bus *mii = as->mii_bus;
38008 + int ret;
38009 + int i;
38011 + /* Set all ports to disabled state. */
38012 + for (i = 0; i < AR7240_NUM_PORTS; i++)
38013 + ar7240sw_disable_port(as, i);
38015 + /* Wait for transmit queues to drain. */
38016 + usleep_range(2000, 3000);
38018 + /* Reset the switch. */
38019 + ar7240sw_reg_write(mii, AR7240_REG_MASK_CTRL,
38020 + AR7240_MASK_CTRL_SOFT_RESET);
38022 + ret = ar7240sw_reg_wait(mii, AR7240_REG_MASK_CTRL,
38023 + AR7240_MASK_CTRL_SOFT_RESET, 0, 1000);
38025 + /* setup PHYs */
38026 + for (i = 0; i < AR7240_NUM_PHYS; i++) {
38027 + ar7240sw_phy_write(mii, i, MII_ADVERTISE,
38028 + ADVERTISE_ALL | ADVERTISE_PAUSE_CAP |
38029 + ADVERTISE_PAUSE_ASYM);
38030 + ar7240sw_phy_write(mii, i, MII_BMCR,
38031 + BMCR_RESET | BMCR_ANENABLE);
38033 + ret = ar7240sw_phy_poll_reset(mii);
38034 + if (ret)
38035 + return ret;
38037 + ar7240sw_setup(as);
38038 + return ret;
38041 +static void ar7240sw_setup_port(struct ar7240sw *as, unsigned port, u8 portmask)
38043 + struct mii_bus *mii = as->mii_bus;
38044 + u32 ctrl;
38045 + u32 vid, mode;
38047 + ctrl = AR7240_PORT_CTRL_STATE_FORWARD | AR7240_PORT_CTRL_LEARN |
38048 + AR7240_PORT_CTRL_SINGLE_VLAN;
38050 + if (port == AR7240_PORT_CPU) {
38051 + ar7240sw_reg_write(mii, AR7240_REG_PORT_STATUS(port),
38052 + AR7240_PORT_STATUS_SPEED_1000 |
38053 + AR7240_PORT_STATUS_TXFLOW |
38054 + AR7240_PORT_STATUS_RXFLOW |
38055 + AR7240_PORT_STATUS_TXMAC |
38056 + AR7240_PORT_STATUS_RXMAC |
38057 + AR7240_PORT_STATUS_DUPLEX);
38058 + } else {
38059 + ar7240sw_reg_write(mii, AR7240_REG_PORT_STATUS(port),
38060 + AR7240_PORT_STATUS_LINK_AUTO);
38063 + /* Set the default VID for this port */
38064 + if (as->vlan) {
38065 + vid = as->vlan_id[as->pvid[port]];
38066 + mode = AR7240_PORT_VLAN_MODE_SECURE;
38067 + } else {
38068 + vid = port;
38069 + mode = AR7240_PORT_VLAN_MODE_PORT_ONLY;
38072 + if (as->vlan) {
38073 + if (as->vlan_tagged & BIT(port))
38074 + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_ADD <<
38075 + AR7240_PORT_CTRL_VLAN_MODE_S;
38076 + else
38077 + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_STRIP <<
38078 + AR7240_PORT_CTRL_VLAN_MODE_S;
38079 + } else {
38080 + ctrl |= AR7240_PORT_CTRL_VLAN_MODE_KEEP <<
38081 + AR7240_PORT_CTRL_VLAN_MODE_S;
38084 + if (!portmask) {
38085 + if (port == AR7240_PORT_CPU)
38086 + portmask = ar7240sw_port_mask_but(as, AR7240_PORT_CPU);
38087 + else
38088 + portmask = ar7240sw_port_mask(as, AR7240_PORT_CPU);
38091 + /* allow the port to talk to all other ports, but exclude its
38092 + * own ID to prevent frames from being reflected back to the
38093 + * port that they came from */
38094 + portmask &= ar7240sw_port_mask_but(as, port);
38096 + ar7240sw_reg_write(mii, AR7240_REG_PORT_CTRL(port), ctrl);
38097 + if (sw_is_ar934x(as)) {
38098 + u32 vlan1, vlan2;
38100 + vlan1 = (vid << AR934X_PORT_VLAN1_DEFAULT_CVID_S);
38101 + vlan2 = (portmask << AR934X_PORT_VLAN2_PORT_VID_MEM_S) |
38102 + (mode << AR934X_PORT_VLAN2_8021Q_MODE_S);
38103 + ar7240sw_reg_write(mii, AR934X_REG_PORT_VLAN1(port), vlan1);
38104 + ar7240sw_reg_write(mii, AR934X_REG_PORT_VLAN2(port), vlan2);
38105 + } else {
38106 + u32 vlan;
38108 + vlan = vid | (mode << AR7240_PORT_VLAN_MODE_S) |
38109 + (portmask << AR7240_PORT_VLAN_DEST_PORTS_S);
38111 + ar7240sw_reg_write(mii, AR7240_REG_PORT_VLAN(port), vlan);
38115 +static int ar7240_set_addr(struct ar7240sw *as, u8 *addr)
38117 + struct mii_bus *mii = as->mii_bus;
38118 + u32 t;
38120 + t = (addr[4] << 8) | addr[5];
38121 + ar7240sw_reg_write(mii, AR7240_REG_MAC_ADDR0, t);
38123 + t = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3];
38124 + ar7240sw_reg_write(mii, AR7240_REG_MAC_ADDR1, t);
38126 + return 0;
38129 +static int
38130 +ar7240_set_vid(struct switch_dev *dev, const struct switch_attr *attr,
38131 + struct switch_val *val)
38133 + struct ar7240sw *as = sw_to_ar7240(dev);
38134 + as->vlan_id[val->port_vlan] = val->value.i;
38135 + return 0;
38138 +static int
38139 +ar7240_get_vid(struct switch_dev *dev, const struct switch_attr *attr,
38140 + struct switch_val *val)
38142 + struct ar7240sw *as = sw_to_ar7240(dev);
38143 + val->value.i = as->vlan_id[val->port_vlan];
38144 + return 0;
38147 +static int
38148 +ar7240_set_pvid(struct switch_dev *dev, int port, int vlan)
38150 + struct ar7240sw *as = sw_to_ar7240(dev);
38152 + /* make sure no invalid PVIDs get set */
38154 + if (vlan >= dev->vlans)
38155 + return -EINVAL;
38157 + as->pvid[port] = vlan;
38158 + return 0;
38161 +static int
38162 +ar7240_get_pvid(struct switch_dev *dev, int port, int *vlan)
38164 + struct ar7240sw *as = sw_to_ar7240(dev);
38165 + *vlan = as->pvid[port];
38166 + return 0;
38169 +static int
38170 +ar7240_get_ports(struct switch_dev *dev, struct switch_val *val)
38172 + struct ar7240sw *as = sw_to_ar7240(dev);
38173 + u8 ports = as->vlan_table[val->port_vlan];
38174 + int i;
38176 + val->len = 0;
38177 + for (i = 0; i < as->swdev.ports; i++) {
38178 + struct switch_port *p;
38180 + if (!(ports & (1 << i)))
38181 + continue;
38183 + p = &val->value.ports[val->len++];
38184 + p->id = i;
38185 + if (as->vlan_tagged & (1 << i))
38186 + p->flags = (1 << SWITCH_PORT_FLAG_TAGGED);
38187 + else
38188 + p->flags = 0;
38190 + return 0;
38193 +static int
38194 +ar7240_set_ports(struct switch_dev *dev, struct switch_val *val)
38196 + struct ar7240sw *as = sw_to_ar7240(dev);
38197 + u8 *vt = &as->vlan_table[val->port_vlan];
38198 + int i, j;
38200 + *vt = 0;
38201 + for (i = 0; i < val->len; i++) {
38202 + struct switch_port *p = &val->value.ports[i];
38204 + if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED))
38205 + as->vlan_tagged |= (1 << p->id);
38206 + else {
38207 + as->vlan_tagged &= ~(1 << p->id);
38208 + as->pvid[p->id] = val->port_vlan;
38210 + /* make sure that an untagged port does not
38211 + * appear in other vlans */
38212 + for (j = 0; j < AR7240_MAX_VLANS; j++) {
38213 + if (j == val->port_vlan)
38214 + continue;
38215 + as->vlan_table[j] &= ~(1 << p->id);
38219 + *vt |= 1 << p->id;
38221 + return 0;
38224 +static int
38225 +ar7240_set_vlan(struct switch_dev *dev, const struct switch_attr *attr,
38226 + struct switch_val *val)
38228 + struct ar7240sw *as = sw_to_ar7240(dev);
38229 + as->vlan = !!val->value.i;
38230 + return 0;
38233 +static int
38234 +ar7240_get_vlan(struct switch_dev *dev, const struct switch_attr *attr,
38235 + struct switch_val *val)
38237 + struct ar7240sw *as = sw_to_ar7240(dev);
38238 + val->value.i = as->vlan;
38239 + return 0;
38242 +static void
38243 +ar7240_vtu_op(struct ar7240sw *as, u32 op, u32 val)
38245 + struct mii_bus *mii = as->mii_bus;
38247 + if (ar7240sw_reg_wait(mii, AR7240_REG_VTU, AR7240_VTU_ACTIVE, 0, 5))
38248 + return;
38250 + if ((op & AR7240_VTU_OP) == AR7240_VTU_OP_LOAD) {
38251 + val &= AR7240_VTUDATA_MEMBER;
38252 + val |= AR7240_VTUDATA_VALID;
38253 + ar7240sw_reg_write(mii, AR7240_REG_VTU_DATA, val);
38255 + op |= AR7240_VTU_ACTIVE;
38256 + ar7240sw_reg_write(mii, AR7240_REG_VTU, op);
38259 +static int
38260 +ar7240_hw_apply(struct switch_dev *dev)
38262 + struct ar7240sw *as = sw_to_ar7240(dev);
38263 + u8 portmask[AR7240_NUM_PORTS];
38264 + int i, j;
38266 + /* flush all vlan translation unit entries */
38267 + ar7240_vtu_op(as, AR7240_VTU_OP_FLUSH, 0);
38269 + memset(portmask, 0, sizeof(portmask));
38270 + if (as->vlan) {
38271 + /* calculate the port destination masks and load vlans
38272 + * into the vlan translation unit */
38273 + for (j = 0; j < AR7240_MAX_VLANS; j++) {
38274 + u8 vp = as->vlan_table[j];
38276 + if (!vp)
38277 + continue;
38279 + for (i = 0; i < as->swdev.ports; i++) {
38280 + u8 mask = (1 << i);
38281 + if (vp & mask)
38282 + portmask[i] |= vp & ~mask;
38285 + ar7240_vtu_op(as,
38286 + AR7240_VTU_OP_LOAD |
38287 + (as->vlan_id[j] << AR7240_VTU_VID_S),
38288 + as->vlan_table[j]);
38290 + } else {
38291 + /* vlan disabled:
38292 + * isolate all ports, but connect them to the cpu port */
38293 + for (i = 0; i < as->swdev.ports; i++) {
38294 + if (i == AR7240_PORT_CPU)
38295 + continue;
38297 + portmask[i] = 1 << AR7240_PORT_CPU;
38298 + portmask[AR7240_PORT_CPU] |= (1 << i);
38302 + /* update the port destination mask registers and tag settings */
38303 + for (i = 0; i < as->swdev.ports; i++)
38304 + ar7240sw_setup_port(as, i, portmask[i]);
38306 + return 0;
38309 +static int
38310 +ar7240_reset_switch(struct switch_dev *dev)
38312 + struct ar7240sw *as = sw_to_ar7240(dev);
38313 + ar7240sw_reset(as);
38314 + return 0;
38317 +static int
38318 +ar7240_get_port_link(struct switch_dev *dev, int port,
38319 + struct switch_port_link *link)
38321 + struct ar7240sw *as = sw_to_ar7240(dev);
38322 + struct mii_bus *mii = as->mii_bus;
38323 + u32 status;
38325 + if (port > AR7240_NUM_PORTS)
38326 + return -EINVAL;
38328 + status = ar7240sw_reg_read(mii, AR7240_REG_PORT_STATUS(port));
38329 + link->aneg = !!(status & AR7240_PORT_STATUS_LINK_AUTO);
38330 + if (link->aneg) {
38331 + link->link = !!(status & AR7240_PORT_STATUS_LINK_UP);
38332 + if (!link->link)
38333 + return 0;
38334 + } else {
38335 + link->link = true;
38338 + link->duplex = !!(status & AR7240_PORT_STATUS_DUPLEX);
38339 + link->tx_flow = !!(status & AR7240_PORT_STATUS_TXFLOW);
38340 + link->rx_flow = !!(status & AR7240_PORT_STATUS_RXFLOW);
38341 + switch (status & AR7240_PORT_STATUS_SPEED_M) {
38342 + case AR7240_PORT_STATUS_SPEED_10:
38343 + link->speed = SWITCH_PORT_SPEED_10;
38344 + break;
38345 + case AR7240_PORT_STATUS_SPEED_100:
38346 + link->speed = SWITCH_PORT_SPEED_100;
38347 + break;
38348 + case AR7240_PORT_STATUS_SPEED_1000:
38349 + link->speed = SWITCH_PORT_SPEED_1000;
38350 + break;
38353 + return 0;
38356 +static int
38357 +ar7240_get_port_stats(struct switch_dev *dev, int port,
38358 + struct switch_port_stats *stats)
38360 + struct ar7240sw *as = sw_to_ar7240(dev);
38362 + if (port > AR7240_NUM_PORTS)
38363 + return -EINVAL;
38365 + ar7240sw_capture_stats(as);
38367 + read_lock(&as->stats_lock);
38368 + stats->rx_bytes = as->port_stats[port].rx_good_byte;
38369 + stats->tx_bytes = as->port_stats[port].tx_byte;
38370 + read_unlock(&as->stats_lock);
38372 + return 0;
38375 +static struct switch_attr ar7240_globals[] = {
38377 + .type = SWITCH_TYPE_INT,
38378 + .name = "enable_vlan",
38379 + .description = "Enable VLAN mode",
38380 + .set = ar7240_set_vlan,
38381 + .get = ar7240_get_vlan,
38382 + .max = 1
38383 + },
38386 +static struct switch_attr ar7240_port[] = {
38389 +static struct switch_attr ar7240_vlan[] = {
38391 + .type = SWITCH_TYPE_INT,
38392 + .name = "vid",
38393 + .description = "VLAN ID",
38394 + .set = ar7240_set_vid,
38395 + .get = ar7240_get_vid,
38396 + .max = 4094,
38397 + },
38400 +static const struct switch_dev_ops ar7240_ops = {
38401 + .attr_global = {
38402 + .attr = ar7240_globals,
38403 + .n_attr = ARRAY_SIZE(ar7240_globals),
38404 + },
38405 + .attr_port = {
38406 + .attr = ar7240_port,
38407 + .n_attr = ARRAY_SIZE(ar7240_port),
38408 + },
38409 + .attr_vlan = {
38410 + .attr = ar7240_vlan,
38411 + .n_attr = ARRAY_SIZE(ar7240_vlan),
38412 + },
38413 + .get_port_pvid = ar7240_get_pvid,
38414 + .set_port_pvid = ar7240_set_pvid,
38415 + .get_vlan_ports = ar7240_get_ports,
38416 + .set_vlan_ports = ar7240_set_ports,
38417 + .apply_config = ar7240_hw_apply,
38418 + .reset_switch = ar7240_reset_switch,
38419 + .get_port_link = ar7240_get_port_link,
38420 + .get_port_stats = ar7240_get_port_stats,
38423 +static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
38425 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
38426 + struct mii_bus *mii = ag->mii_bus;
38427 + struct ar7240sw *as;
38428 + struct switch_dev *swdev;
38429 + u32 ctrl;
38430 + u16 phy_id1;
38431 + u16 phy_id2;
38432 + int i;
38434 + phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
38435 + phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
38436 + if ((phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) &&
38437 + (phy_id1 != AR934X_PHY_ID1 || phy_id2 != AR934X_PHY_ID2)) {
38438 + pr_err("%s: unknown phy id '%04x:%04x'\n",
38439 + dev_name(&mii->dev), phy_id1, phy_id2);
38440 + return NULL;
38443 + as = kzalloc(sizeof(*as), GFP_KERNEL);
38444 + if (!as)
38445 + return NULL;
38447 + as->mii_bus = mii;
38448 + as->swdata = pdata->switch_data;
38450 + swdev = &as->swdev;
38452 + ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
38453 + as->ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) &
38454 + AR7240_MASK_CTRL_VERSION_M;
38456 + if (sw_is_ar7240(as)) {
38457 + swdev->name = "AR7240/AR9330 built-in switch";
38458 + swdev->ports = AR7240_NUM_PORTS - 1;
38459 + } else if (sw_is_ar934x(as)) {
38460 + swdev->name = "AR934X built-in switch";
38462 + if (pdata->phy_if_mode == PHY_INTERFACE_MODE_GMII) {
38463 + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE0,
38464 + AR934X_OPER_MODE0_MAC_GMII_EN);
38465 + } else if (pdata->phy_if_mode == PHY_INTERFACE_MODE_MII) {
38466 + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE0,
38467 + AR934X_OPER_MODE0_PHY_MII_EN);
38468 + } else {
38469 + pr_err("%s: invalid PHY interface mode\n",
38470 + dev_name(&mii->dev));
38471 + goto err_free;
38474 + if (as->swdata->phy4_mii_en) {
38475 + ar7240sw_reg_set(mii, AR934X_REG_OPER_MODE1,
38476 + AR934X_REG_OPER_MODE1_PHY4_MII_EN);
38477 + swdev->ports = AR7240_NUM_PORTS - 1;
38478 + } else {
38479 + swdev->ports = AR7240_NUM_PORTS;
38481 + } else {
38482 + pr_err("%s: unsupported chip, ctrl=%08x\n",
38483 + dev_name(&mii->dev), ctrl);
38484 + goto err_free;
38487 + swdev->cpu_port = AR7240_PORT_CPU;
38488 + swdev->vlans = AR7240_MAX_VLANS;
38489 + swdev->ops = &ar7240_ops;
38491 + if (register_switch(&as->swdev, ag->dev) < 0)
38492 + goto err_free;
38494 + pr_info("%s: Found an %s\n", dev_name(&mii->dev), swdev->name);
38496 + /* initialize defaults */
38497 + for (i = 0; i < AR7240_MAX_VLANS; i++)
38498 + as->vlan_id[i] = i;
38500 + as->vlan_table[0] = ar7240sw_port_mask_all(as);
38502 + return as;
38504 +err_free:
38505 + kfree(as);
38506 + return NULL;
38509 +static void link_function(struct work_struct *work) {
38510 + struct ag71xx *ag = container_of(work, struct ag71xx, link_work.work);
38511 + struct ar7240sw *as = ag->phy_priv;
38512 + unsigned long flags;
38513 + u8 mask;
38514 + int i;
38515 + int status = 0;
38517 + mask = ~as->swdata->phy_poll_mask;
38518 + for (i = 0; i < AR7240_NUM_PHYS; i++) {
38519 + int link;
38521 + if (!(mask & BIT(i)))
38522 + continue;
38524 + link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
38525 + if (link & BMSR_LSTATUS) {
38526 + status = 1;
38527 + break;
38531 + spin_lock_irqsave(&ag->lock, flags);
38532 + if (status != ag->link) {
38533 + ag->link = status;
38534 + ag71xx_link_adjust(ag);
38536 + spin_unlock_irqrestore(&ag->lock, flags);
38538 + schedule_delayed_work(&ag->link_work, HZ / 2);
38541 +void ag71xx_ar7240_start(struct ag71xx *ag)
38543 + struct ar7240sw *as = ag->phy_priv;
38545 + ar7240sw_reset(as);
38547 + ag->speed = SPEED_1000;
38548 + ag->duplex = 1;
38550 + ar7240_set_addr(as, ag->dev->dev_addr);
38551 + ar7240_hw_apply(&as->swdev);
38553 + schedule_delayed_work(&ag->link_work, HZ / 10);
38556 +void ag71xx_ar7240_stop(struct ag71xx *ag)
38558 + cancel_delayed_work_sync(&ag->link_work);
38561 +int ag71xx_ar7240_init(struct ag71xx *ag)
38563 + struct ar7240sw *as;
38565 + as = ar7240_probe(ag);
38566 + if (!as)
38567 + return -ENODEV;
38569 + ag->phy_priv = as;
38570 + ar7240sw_reset(as);
38572 + rwlock_init(&as->stats_lock);
38573 + INIT_DELAYED_WORK(&ag->link_work, link_function);
38575 + return 0;
38578 +void ag71xx_ar7240_cleanup(struct ag71xx *ag)
38580 + struct ar7240sw *as = ag->phy_priv;
38582 + if (!as)
38583 + return;
38585 + unregister_switch(&as->swdev);
38586 + kfree(as);
38587 + ag->phy_priv = NULL;
38589 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c
38590 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c 1970-01-01 01:00:00.000000000 +0100
38591 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c 2017-08-06 20:02:16.000000000 +0200
38592 @@ -0,0 +1,44 @@
38594 + * Atheros AR71xx built-in ethernet mac driver
38595 + * Special support for the Atheros ar8216 switch chip
38597 + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
38599 + * Based on Atheros' AG7100 driver
38601 + * This program is free software; you can redistribute it and/or modify it
38602 + * under the terms of the GNU General Public License version 2 as published
38603 + * by the Free Software Foundation.
38604 + */
38606 +#include "ag71xx.h"
38608 +#define AR8216_PACKET_TYPE_MASK 0xf
38609 +#define AR8216_PACKET_TYPE_NORMAL 0
38611 +#define AR8216_HEADER_LEN 2
38613 +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb)
38615 + skb_push(skb, AR8216_HEADER_LEN);
38616 + skb->data[0] = 0x10;
38617 + skb->data[1] = 0x80;
38620 +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
38621 + int pktlen)
38623 + u8 type;
38625 + type = skb->data[1] & AR8216_PACKET_TYPE_MASK;
38626 + switch (type) {
38627 + case AR8216_PACKET_TYPE_NORMAL:
38628 + break;
38630 + default:
38631 + return -EINVAL;
38634 + skb_pull(skb, AR8216_HEADER_LEN);
38635 + return 0;
38637 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
38638 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c 1970-01-01 01:00:00.000000000 +0100
38639 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c 2017-08-06 20:02:16.000000000 +0200
38640 @@ -0,0 +1,285 @@
38642 + * Atheros AR71xx built-in ethernet mac driver
38644 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
38645 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
38647 + * Based on Atheros' AG7100 driver
38649 + * This program is free software; you can redistribute it and/or modify it
38650 + * under the terms of the GNU General Public License version 2 as published
38651 + * by the Free Software Foundation.
38652 + */
38654 +#include <linux/debugfs.h>
38656 +#include "ag71xx.h"
38658 +static struct dentry *ag71xx_debugfs_root;
38660 +static int ag71xx_debugfs_generic_open(struct inode *inode, struct file *file)
38662 + file->private_data = inode->i_private;
38663 + return 0;
38666 +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status)
38668 + if (status)
38669 + ag->debug.int_stats.total++;
38670 + if (status & AG71XX_INT_TX_PS)
38671 + ag->debug.int_stats.tx_ps++;
38672 + if (status & AG71XX_INT_TX_UR)
38673 + ag->debug.int_stats.tx_ur++;
38674 + if (status & AG71XX_INT_TX_BE)
38675 + ag->debug.int_stats.tx_be++;
38676 + if (status & AG71XX_INT_RX_PR)
38677 + ag->debug.int_stats.rx_pr++;
38678 + if (status & AG71XX_INT_RX_OF)
38679 + ag->debug.int_stats.rx_of++;
38680 + if (status & AG71XX_INT_RX_BE)
38681 + ag->debug.int_stats.rx_be++;
38684 +static ssize_t read_file_int_stats(struct file *file, char __user *user_buf,
38685 + size_t count, loff_t *ppos)
38687 +#define PR_INT_STAT(_label, _field) \
38688 + len += snprintf(buf + len, sizeof(buf) - len, \
38689 + "%20s: %10lu\n", _label, ag->debug.int_stats._field);
38691 + struct ag71xx *ag = file->private_data;
38692 + char buf[256];
38693 + unsigned int len = 0;
38695 + PR_INT_STAT("TX Packet Sent", tx_ps);
38696 + PR_INT_STAT("TX Underrun", tx_ur);
38697 + PR_INT_STAT("TX Bus Error", tx_be);
38698 + PR_INT_STAT("RX Packet Received", rx_pr);
38699 + PR_INT_STAT("RX Overflow", rx_of);
38700 + PR_INT_STAT("RX Bus Error", rx_be);
38701 + len += snprintf(buf + len, sizeof(buf) - len, "\n");
38702 + PR_INT_STAT("Total", total);
38704 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
38705 +#undef PR_INT_STAT
38708 +static const struct file_operations ag71xx_fops_int_stats = {
38709 + .open = ag71xx_debugfs_generic_open,
38710 + .read = read_file_int_stats,
38711 + .owner = THIS_MODULE
38714 +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx)
38716 + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
38718 + if (rx) {
38719 + stats->rx_count++;
38720 + stats->rx_packets += rx;
38721 + if (rx <= AG71XX_NAPI_WEIGHT)
38722 + stats->rx[rx]++;
38723 + if (rx > stats->rx_packets_max)
38724 + stats->rx_packets_max = rx;
38727 + if (tx) {
38728 + stats->tx_count++;
38729 + stats->tx_packets += tx;
38730 + if (tx <= AG71XX_NAPI_WEIGHT)
38731 + stats->tx[tx]++;
38732 + if (tx > stats->tx_packets_max)
38733 + stats->tx_packets_max = tx;
38737 +static ssize_t read_file_napi_stats(struct file *file, char __user *user_buf,
38738 + size_t count, loff_t *ppos)
38740 + struct ag71xx *ag = file->private_data;
38741 + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
38742 + char *buf;
38743 + unsigned int buflen;
38744 + unsigned int len = 0;
38745 + unsigned long rx_avg = 0;
38746 + unsigned long tx_avg = 0;
38747 + int ret;
38748 + int i;
38750 + buflen = 2048;
38751 + buf = kmalloc(buflen, GFP_KERNEL);
38752 + if (!buf)
38753 + return -ENOMEM;
38755 + if (stats->rx_count)
38756 + rx_avg = stats->rx_packets / stats->rx_count;
38758 + if (stats->tx_count)
38759 + tx_avg = stats->tx_packets / stats->tx_count;
38761 + len += snprintf(buf + len, buflen - len, "%3s %10s %10s\n",
38762 + "len", "rx", "tx");
38764 + for (i = 1; i <= AG71XX_NAPI_WEIGHT; i++)
38765 + len += snprintf(buf + len, buflen - len,
38766 + "%3d: %10lu %10lu\n",
38767 + i, stats->rx[i], stats->tx[i]);
38769 + len += snprintf(buf + len, buflen - len, "\n");
38771 + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
38772 + "sum", stats->rx_count, stats->tx_count);
38773 + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
38774 + "avg", rx_avg, tx_avg);
38775 + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
38776 + "max", stats->rx_packets_max, stats->tx_packets_max);
38777 + len += snprintf(buf + len, buflen - len, "%3s: %10lu %10lu\n",
38778 + "pkt", stats->rx_packets, stats->tx_packets);
38780 + ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
38781 + kfree(buf);
38783 + return ret;
38786 +static const struct file_operations ag71xx_fops_napi_stats = {
38787 + .open = ag71xx_debugfs_generic_open,
38788 + .read = read_file_napi_stats,
38789 + .owner = THIS_MODULE
38792 +#define DESC_PRINT_LEN 64
38794 +static ssize_t read_file_ring(struct file *file, char __user *user_buf,
38795 + size_t count, loff_t *ppos,
38796 + struct ag71xx *ag,
38797 + struct ag71xx_ring *ring,
38798 + unsigned desc_reg)
38800 + char *buf;
38801 + unsigned int buflen;
38802 + unsigned int len = 0;
38803 + unsigned long flags;
38804 + ssize_t ret;
38805 + int curr;
38806 + int dirty;
38807 + u32 desc_hw;
38808 + int i;
38810 + buflen = (ring->size * DESC_PRINT_LEN);
38811 + buf = kmalloc(buflen, GFP_KERNEL);
38812 + if (!buf)
38813 + return -ENOMEM;
38815 + len += snprintf(buf + len, buflen - len,
38816 + "Idx ... %-8s %-8s %-8s %-8s . %-10s\n",
38817 + "desc", "next", "data", "ctrl", "timestamp");
38819 + spin_lock_irqsave(&ag->lock, flags);
38821 + curr = (ring->curr % ring->size);
38822 + dirty = (ring->dirty % ring->size);
38823 + desc_hw = ag71xx_rr(ag, desc_reg);
38824 + for (i = 0; i < ring->size; i++) {
38825 + struct ag71xx_buf *ab = &ring->buf[i];
38826 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
38827 + u32 desc_dma = ((u32) ring->descs_dma) + i * ring->desc_size;
38829 + len += snprintf(buf + len, buflen - len,
38830 + "%3d %c%c%c %08x %08x %08x %08x %c %10lu\n",
38831 + i,
38832 + (i == curr) ? 'C' : ' ',
38833 + (i == dirty) ? 'D' : ' ',
38834 + (desc_hw == desc_dma) ? 'H' : ' ',
38835 + desc_dma,
38836 + desc->next,
38837 + desc->data,
38838 + desc->ctrl,
38839 + (desc->ctrl & DESC_EMPTY) ? 'E' : '*',
38840 + ab->timestamp);
38843 + spin_unlock_irqrestore(&ag->lock, flags);
38845 + ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
38846 + kfree(buf);
38848 + return ret;
38851 +static ssize_t read_file_tx_ring(struct file *file, char __user *user_buf,
38852 + size_t count, loff_t *ppos)
38854 + struct ag71xx *ag = file->private_data;
38856 + return read_file_ring(file, user_buf, count, ppos, ag, &ag->tx_ring,
38857 + AG71XX_REG_TX_DESC);
38860 +static const struct file_operations ag71xx_fops_tx_ring = {
38861 + .open = ag71xx_debugfs_generic_open,
38862 + .read = read_file_tx_ring,
38863 + .owner = THIS_MODULE
38866 +static ssize_t read_file_rx_ring(struct file *file, char __user *user_buf,
38867 + size_t count, loff_t *ppos)
38869 + struct ag71xx *ag = file->private_data;
38871 + return read_file_ring(file, user_buf, count, ppos, ag, &ag->rx_ring,
38872 + AG71XX_REG_RX_DESC);
38875 +static const struct file_operations ag71xx_fops_rx_ring = {
38876 + .open = ag71xx_debugfs_generic_open,
38877 + .read = read_file_rx_ring,
38878 + .owner = THIS_MODULE
38881 +void ag71xx_debugfs_exit(struct ag71xx *ag)
38883 + debugfs_remove_recursive(ag->debug.debugfs_dir);
38886 +int ag71xx_debugfs_init(struct ag71xx *ag)
38888 + struct device *dev = &ag->pdev->dev;
38890 + ag->debug.debugfs_dir = debugfs_create_dir(dev_name(dev),
38891 + ag71xx_debugfs_root);
38892 + if (!ag->debug.debugfs_dir) {
38893 + dev_err(dev, "unable to create debugfs directory\n");
38894 + return -ENOENT;
38897 + debugfs_create_file("int_stats", S_IRUGO, ag->debug.debugfs_dir,
38898 + ag, &ag71xx_fops_int_stats);
38899 + debugfs_create_file("napi_stats", S_IRUGO, ag->debug.debugfs_dir,
38900 + ag, &ag71xx_fops_napi_stats);
38901 + debugfs_create_file("tx_ring", S_IRUGO, ag->debug.debugfs_dir,
38902 + ag, &ag71xx_fops_tx_ring);
38903 + debugfs_create_file("rx_ring", S_IRUGO, ag->debug.debugfs_dir,
38904 + ag, &ag71xx_fops_rx_ring);
38906 + return 0;
38909 +int ag71xx_debugfs_root_init(void)
38911 + if (ag71xx_debugfs_root)
38912 + return -EBUSY;
38914 + ag71xx_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
38915 + if (!ag71xx_debugfs_root)
38916 + return -ENOENT;
38918 + return 0;
38921 +void ag71xx_debugfs_root_exit(void)
38923 + debugfs_remove(ag71xx_debugfs_root);
38924 + ag71xx_debugfs_root = NULL;
38926 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
38927 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c 1970-01-01 01:00:00.000000000 +0100
38928 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c 2017-08-06 20:02:16.000000000 +0200
38929 @@ -0,0 +1,130 @@
38931 + * Atheros AR71xx built-in ethernet mac driver
38933 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
38934 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
38936 + * Based on Atheros' AG7100 driver
38938 + * This program is free software; you can redistribute it and/or modify it
38939 + * under the terms of the GNU General Public License version 2 as published
38940 + * by the Free Software Foundation.
38941 + */
38943 +#include "ag71xx.h"
38945 +static int ag71xx_ethtool_get_settings(struct net_device *dev,
38946 + struct ethtool_cmd *cmd)
38948 + struct ag71xx *ag = netdev_priv(dev);
38949 + struct phy_device *phydev = ag->phy_dev;
38951 + if (!phydev)
38952 + return -ENODEV;
38954 + return phy_ethtool_gset(phydev, cmd);
38957 +static int ag71xx_ethtool_set_settings(struct net_device *dev,
38958 + struct ethtool_cmd *cmd)
38960 + struct ag71xx *ag = netdev_priv(dev);
38961 + struct phy_device *phydev = ag->phy_dev;
38963 + if (!phydev)
38964 + return -ENODEV;
38966 + return phy_ethtool_sset(phydev, cmd);
38969 +static void ag71xx_ethtool_get_drvinfo(struct net_device *dev,
38970 + struct ethtool_drvinfo *info)
38972 + struct ag71xx *ag = netdev_priv(dev);
38974 + strcpy(info->driver, ag->pdev->dev.driver->name);
38975 + strcpy(info->version, AG71XX_DRV_VERSION);
38976 + strcpy(info->bus_info, dev_name(&ag->pdev->dev));
38979 +static u32 ag71xx_ethtool_get_msglevel(struct net_device *dev)
38981 + struct ag71xx *ag = netdev_priv(dev);
38983 + return ag->msg_enable;
38986 +static void ag71xx_ethtool_set_msglevel(struct net_device *dev, u32 msg_level)
38988 + struct ag71xx *ag = netdev_priv(dev);
38990 + ag->msg_enable = msg_level;
38993 +static void ag71xx_ethtool_get_ringparam(struct net_device *dev,
38994 + struct ethtool_ringparam *er)
38996 + struct ag71xx *ag = netdev_priv(dev);
38998 + er->tx_max_pending = AG71XX_TX_RING_SIZE_MAX;
38999 + er->rx_max_pending = AG71XX_RX_RING_SIZE_MAX;
39000 + er->rx_mini_max_pending = 0;
39001 + er->rx_jumbo_max_pending = 0;
39003 + er->tx_pending = ag->tx_ring.size;
39004 + er->rx_pending = ag->rx_ring.size;
39005 + er->rx_mini_pending = 0;
39006 + er->rx_jumbo_pending = 0;
39008 + if (ag->tx_ring.desc_split)
39009 + er->tx_pending /= AG71XX_TX_RING_DS_PER_PKT;
39012 +static int ag71xx_ethtool_set_ringparam(struct net_device *dev,
39013 + struct ethtool_ringparam *er)
39015 + struct ag71xx *ag = netdev_priv(dev);
39016 + unsigned tx_size;
39017 + unsigned rx_size;
39018 + int err;
39020 + if (er->rx_mini_pending != 0||
39021 + er->rx_jumbo_pending != 0 ||
39022 + er->rx_pending == 0 ||
39023 + er->tx_pending == 0)
39024 + return -EINVAL;
39026 + tx_size = er->tx_pending < AG71XX_TX_RING_SIZE_MAX ?
39027 + er->tx_pending : AG71XX_TX_RING_SIZE_MAX;
39029 + rx_size = er->rx_pending < AG71XX_RX_RING_SIZE_MAX ?
39030 + er->rx_pending : AG71XX_RX_RING_SIZE_MAX;
39032 + if (netif_running(dev)) {
39033 + err = dev->netdev_ops->ndo_stop(dev);
39034 + if (err)
39035 + return err;
39038 + if (ag->tx_ring.desc_split)
39039 + tx_size *= AG71XX_TX_RING_DS_PER_PKT;
39041 + ag->tx_ring.size = tx_size;
39042 + ag->rx_ring.size = rx_size;
39044 + if (netif_running(dev))
39045 + err = dev->netdev_ops->ndo_open(dev);
39047 + return err;
39050 +struct ethtool_ops ag71xx_ethtool_ops = {
39051 + .set_settings = ag71xx_ethtool_set_settings,
39052 + .get_settings = ag71xx_ethtool_get_settings,
39053 + .get_drvinfo = ag71xx_ethtool_get_drvinfo,
39054 + .get_msglevel = ag71xx_ethtool_get_msglevel,
39055 + .set_msglevel = ag71xx_ethtool_set_msglevel,
39056 + .get_ringparam = ag71xx_ethtool_get_ringparam,
39057 + .set_ringparam = ag71xx_ethtool_set_ringparam,
39058 + .get_link = ethtool_op_get_link,
39060 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
39061 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 1970-01-01 01:00:00.000000000 +0100
39062 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 2017-08-06 20:02:16.000000000 +0200
39063 @@ -0,0 +1,1406 @@
39065 + * Atheros AR71xx built-in ethernet mac driver
39067 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
39068 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
39070 + * Based on Atheros' AG7100 driver
39072 + * This program is free software; you can redistribute it and/or modify it
39073 + * under the terms of the GNU General Public License version 2 as published
39074 + * by the Free Software Foundation.
39075 + */
39077 +#include "ag71xx.h"
39079 +#define AG71XX_DEFAULT_MSG_ENABLE \
39080 + (NETIF_MSG_DRV \
39081 + | NETIF_MSG_PROBE \
39082 + | NETIF_MSG_LINK \
39083 + | NETIF_MSG_TIMER \
39084 + | NETIF_MSG_IFDOWN \
39085 + | NETIF_MSG_IFUP \
39086 + | NETIF_MSG_RX_ERR \
39087 + | NETIF_MSG_TX_ERR)
39089 +static int ag71xx_msg_level = -1;
39091 +module_param_named(msg_level, ag71xx_msg_level, int, 0);
39092 +MODULE_PARM_DESC(msg_level, "Message level (-1=defaults,0=none,...,16=all)");
39094 +#define ETH_SWITCH_HEADER_LEN 2
39096 +static inline unsigned int ag71xx_max_frame_len(unsigned int mtu)
39098 + return ETH_SWITCH_HEADER_LEN + ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN;
39101 +static void ag71xx_dump_dma_regs(struct ag71xx *ag)
39103 + DBG("%s: dma_tx_ctrl=%08x, dma_tx_desc=%08x, dma_tx_status=%08x\n",
39104 + ag->dev->name,
39105 + ag71xx_rr(ag, AG71XX_REG_TX_CTRL),
39106 + ag71xx_rr(ag, AG71XX_REG_TX_DESC),
39107 + ag71xx_rr(ag, AG71XX_REG_TX_STATUS));
39109 + DBG("%s: dma_rx_ctrl=%08x, dma_rx_desc=%08x, dma_rx_status=%08x\n",
39110 + ag->dev->name,
39111 + ag71xx_rr(ag, AG71XX_REG_RX_CTRL),
39112 + ag71xx_rr(ag, AG71XX_REG_RX_DESC),
39113 + ag71xx_rr(ag, AG71XX_REG_RX_STATUS));
39116 +static void ag71xx_dump_regs(struct ag71xx *ag)
39118 + DBG("%s: mac_cfg1=%08x, mac_cfg2=%08x, ipg=%08x, hdx=%08x, mfl=%08x\n",
39119 + ag->dev->name,
39120 + ag71xx_rr(ag, AG71XX_REG_MAC_CFG1),
39121 + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
39122 + ag71xx_rr(ag, AG71XX_REG_MAC_IPG),
39123 + ag71xx_rr(ag, AG71XX_REG_MAC_HDX),
39124 + ag71xx_rr(ag, AG71XX_REG_MAC_MFL));
39125 + DBG("%s: mac_ifctl=%08x, mac_addr1=%08x, mac_addr2=%08x\n",
39126 + ag->dev->name,
39127 + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
39128 + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR1),
39129 + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR2));
39130 + DBG("%s: fifo_cfg0=%08x, fifo_cfg1=%08x, fifo_cfg2=%08x\n",
39131 + ag->dev->name,
39132 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
39133 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
39134 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
39135 + DBG("%s: fifo_cfg3=%08x, fifo_cfg4=%08x, fifo_cfg5=%08x\n",
39136 + ag->dev->name,
39137 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
39138 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
39139 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
39142 +static inline void ag71xx_dump_intr(struct ag71xx *ag, char *label, u32 intr)
39144 + DBG("%s: %s intr=%08x %s%s%s%s%s%s\n",
39145 + ag->dev->name, label, intr,
39146 + (intr & AG71XX_INT_TX_PS) ? "TXPS " : "",
39147 + (intr & AG71XX_INT_TX_UR) ? "TXUR " : "",
39148 + (intr & AG71XX_INT_TX_BE) ? "TXBE " : "",
39149 + (intr & AG71XX_INT_RX_PR) ? "RXPR " : "",
39150 + (intr & AG71XX_INT_RX_OF) ? "RXOF " : "",
39151 + (intr & AG71XX_INT_RX_BE) ? "RXBE " : "");
39154 +static void ag71xx_ring_free(struct ag71xx_ring *ring)
39156 + kfree(ring->buf);
39158 + if (ring->descs_cpu)
39159 + dma_free_coherent(NULL, ring->size * ring->desc_size,
39160 + ring->descs_cpu, ring->descs_dma);
39163 +static int ag71xx_ring_alloc(struct ag71xx_ring *ring)
39165 + int err;
39167 + ring->desc_size = sizeof(struct ag71xx_desc);
39168 + if (ring->desc_size % cache_line_size()) {
39169 + DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
39170 + ring, ring->desc_size,
39171 + roundup(ring->desc_size, cache_line_size()));
39172 + ring->desc_size = roundup(ring->desc_size, cache_line_size());
39175 + ring->descs_cpu = dma_alloc_coherent(NULL, ring->size * ring->desc_size,
39176 + &ring->descs_dma, GFP_ATOMIC);
39177 + if (!ring->descs_cpu) {
39178 + err = -ENOMEM;
39179 + goto err;
39183 + ring->buf = kzalloc(ring->size * sizeof(*ring->buf), GFP_KERNEL);
39184 + if (!ring->buf) {
39185 + err = -ENOMEM;
39186 + goto err;
39189 + return 0;
39191 +err:
39192 + return err;
39195 +static void ag71xx_ring_tx_clean(struct ag71xx *ag)
39197 + struct ag71xx_ring *ring = &ag->tx_ring;
39198 + struct net_device *dev = ag->dev;
39199 + u32 bytes_compl = 0, pkts_compl = 0;
39201 + while (ring->curr != ring->dirty) {
39202 + struct ag71xx_desc *desc;
39203 + u32 i = ring->dirty % ring->size;
39205 + desc = ag71xx_ring_desc(ring, i);
39206 + if (!ag71xx_desc_empty(desc)) {
39207 + desc->ctrl = 0;
39208 + dev->stats.tx_errors++;
39211 + if (ring->buf[i].skb) {
39212 + bytes_compl += ring->buf[i].len;
39213 + pkts_compl++;
39214 + dev_kfree_skb_any(ring->buf[i].skb);
39216 + ring->buf[i].skb = NULL;
39217 + ring->dirty++;
39220 + /* flush descriptors */
39221 + wmb();
39223 + netdev_completed_queue(dev, pkts_compl, bytes_compl);
39226 +static void ag71xx_ring_tx_init(struct ag71xx *ag)
39228 + struct ag71xx_ring *ring = &ag->tx_ring;
39229 + int i;
39231 + for (i = 0; i < ring->size; i++) {
39232 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
39234 + desc->next = (u32) (ring->descs_dma +
39235 + ring->desc_size * ((i + 1) % ring->size));
39237 + desc->ctrl = DESC_EMPTY;
39238 + ring->buf[i].skb = NULL;
39241 + /* flush descriptors */
39242 + wmb();
39244 + ring->curr = 0;
39245 + ring->dirty = 0;
39246 + netdev_reset_queue(ag->dev);
39249 +static void ag71xx_ring_rx_clean(struct ag71xx *ag)
39251 + struct ag71xx_ring *ring = &ag->rx_ring;
39252 + int i;
39254 + if (!ring->buf)
39255 + return;
39257 + for (i = 0; i < ring->size; i++)
39258 + if (ring->buf[i].rx_buf) {
39259 + dma_unmap_single(&ag->dev->dev, ring->buf[i].dma_addr,
39260 + ag->rx_buf_size, DMA_FROM_DEVICE);
39261 + kfree(ring->buf[i].rx_buf);
39265 +static int ag71xx_buffer_offset(struct ag71xx *ag)
39267 + int offset = NET_SKB_PAD;
39269 + /*
39270 + * On AR71xx/AR91xx packets must be 4-byte aligned.
39272 + * When using builtin AR8216 support, hardware adds a 2-byte header,
39273 + * so we don't need any extra alignment in that case.
39274 + */
39275 + if (!ag71xx_get_pdata(ag)->is_ar724x || ag71xx_has_ar8216(ag))
39276 + return offset;
39278 + return offset + NET_IP_ALIGN;
39281 +static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct ag71xx_buf *buf,
39282 + int offset)
39284 + struct ag71xx_ring *ring = &ag->rx_ring;
39285 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, buf - &ring->buf[0]);
39286 + void *data;
39288 + data = kmalloc(ag->rx_buf_size +
39289 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
39290 + GFP_ATOMIC);
39291 + if (!data)
39292 + return false;
39294 + buf->rx_buf = data;
39295 + buf->dma_addr = dma_map_single(&ag->dev->dev, data, ag->rx_buf_size,
39296 + DMA_FROM_DEVICE);
39297 + desc->data = (u32) buf->dma_addr + offset;
39298 + return true;
39301 +static int ag71xx_ring_rx_init(struct ag71xx *ag)
39303 + struct ag71xx_ring *ring = &ag->rx_ring;
39304 + unsigned int i;
39305 + int ret;
39306 + int offset = ag71xx_buffer_offset(ag);
39308 + ret = 0;
39309 + for (i = 0; i < ring->size; i++) {
39310 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
39312 + desc->next = (u32) (ring->descs_dma +
39313 + ring->desc_size * ((i + 1) % ring->size));
39315 + DBG("ag71xx: RX desc at %p, next is %08x\n",
39316 + desc, desc->next);
39319 + for (i = 0; i < ring->size; i++) {
39320 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
39322 + if (!ag71xx_fill_rx_buf(ag, &ring->buf[i], offset)) {
39323 + ret = -ENOMEM;
39324 + break;
39327 + desc->ctrl = DESC_EMPTY;
39330 + /* flush descriptors */
39331 + wmb();
39333 + ring->curr = 0;
39334 + ring->dirty = 0;
39336 + return ret;
39339 +static int ag71xx_ring_rx_refill(struct ag71xx *ag)
39341 + struct ag71xx_ring *ring = &ag->rx_ring;
39342 + unsigned int count;
39343 + int offset = ag71xx_buffer_offset(ag);
39345 + count = 0;
39346 + for (; ring->curr - ring->dirty > 0; ring->dirty++) {
39347 + struct ag71xx_desc *desc;
39348 + unsigned int i;
39350 + i = ring->dirty % ring->size;
39351 + desc = ag71xx_ring_desc(ring, i);
39353 + if (!ring->buf[i].rx_buf &&
39354 + !ag71xx_fill_rx_buf(ag, &ring->buf[i], offset))
39355 + break;
39357 + desc->ctrl = DESC_EMPTY;
39358 + count++;
39361 + /* flush descriptors */
39362 + wmb();
39364 + DBG("%s: %u rx descriptors refilled\n", ag->dev->name, count);
39366 + return count;
39369 +static int ag71xx_rings_init(struct ag71xx *ag)
39371 + int ret;
39373 + ret = ag71xx_ring_alloc(&ag->tx_ring);
39374 + if (ret)
39375 + return ret;
39377 + ag71xx_ring_tx_init(ag);
39379 + ret = ag71xx_ring_alloc(&ag->rx_ring);
39380 + if (ret)
39381 + return ret;
39383 + ret = ag71xx_ring_rx_init(ag);
39384 + return ret;
39387 +static void ag71xx_rings_cleanup(struct ag71xx *ag)
39389 + ag71xx_ring_rx_clean(ag);
39390 + ag71xx_ring_free(&ag->rx_ring);
39392 + ag71xx_ring_tx_clean(ag);
39393 + netdev_reset_queue(ag->dev);
39394 + ag71xx_ring_free(&ag->tx_ring);
39397 +static unsigned char *ag71xx_speed_str(struct ag71xx *ag)
39399 + switch (ag->speed) {
39400 + case SPEED_1000:
39401 + return "1000";
39402 + case SPEED_100:
39403 + return "100";
39404 + case SPEED_10:
39405 + return "10";
39408 + return "?";
39411 +static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
39413 + u32 t;
39415 + t = (((u32) mac[5]) << 24) | (((u32) mac[4]) << 16)
39416 + | (((u32) mac[3]) << 8) | ((u32) mac[2]);
39418 + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR1, t);
39420 + t = (((u32) mac[1]) << 24) | (((u32) mac[0]) << 16);
39421 + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR2, t);
39424 +static void ag71xx_dma_reset(struct ag71xx *ag)
39426 + u32 val;
39427 + int i;
39429 + ag71xx_dump_dma_regs(ag);
39431 + /* stop RX and TX */
39432 + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
39433 + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
39435 + /*
39436 + * give the hardware some time to really stop all rx/tx activity
39437 + * clearing the descriptors too early causes random memory corruption
39438 + */
39439 + mdelay(1);
39441 + /* clear descriptor addresses */
39442 + ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->stop_desc_dma);
39443 + ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->stop_desc_dma);
39445 + /* clear pending RX/TX interrupts */
39446 + for (i = 0; i < 256; i++) {
39447 + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
39448 + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
39451 + /* clear pending errors */
39452 + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE | RX_STATUS_OF);
39453 + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE | TX_STATUS_UR);
39455 + val = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
39456 + if (val)
39457 + pr_alert("%s: unable to clear DMA Rx status: %08x\n",
39458 + ag->dev->name, val);
39460 + val = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
39462 + /* mask out reserved bits */
39463 + val &= ~0xff000000;
39465 + if (val)
39466 + pr_alert("%s: unable to clear DMA Tx status: %08x\n",
39467 + ag->dev->name, val);
39469 + ag71xx_dump_dma_regs(ag);
39472 +#define MAC_CFG1_INIT (MAC_CFG1_RXE | MAC_CFG1_TXE | \
39473 + MAC_CFG1_SRX | MAC_CFG1_STX)
39475 +#define FIFO_CFG0_INIT (FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT)
39477 +#define FIFO_CFG4_INIT (FIFO_CFG4_DE | FIFO_CFG4_DV | FIFO_CFG4_FC | \
39478 + FIFO_CFG4_CE | FIFO_CFG4_CR | FIFO_CFG4_LM | \
39479 + FIFO_CFG4_LO | FIFO_CFG4_OK | FIFO_CFG4_MC | \
39480 + FIFO_CFG4_BC | FIFO_CFG4_DR | FIFO_CFG4_LE | \
39481 + FIFO_CFG4_CF | FIFO_CFG4_PF | FIFO_CFG4_UO | \
39482 + FIFO_CFG4_VT)
39484 +#define FIFO_CFG5_INIT (FIFO_CFG5_DE | FIFO_CFG5_DV | FIFO_CFG5_FC | \
39485 + FIFO_CFG5_CE | FIFO_CFG5_LO | FIFO_CFG5_OK | \
39486 + FIFO_CFG5_MC | FIFO_CFG5_BC | FIFO_CFG5_DR | \
39487 + FIFO_CFG5_CF | FIFO_CFG5_PF | FIFO_CFG5_VT | \
39488 + FIFO_CFG5_LE | FIFO_CFG5_FT | FIFO_CFG5_16 | \
39489 + FIFO_CFG5_17 | FIFO_CFG5_SF)
39491 +static void ag71xx_hw_stop(struct ag71xx *ag)
39493 + /* disable all interrupts and stop the rx/tx engine */
39494 + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, 0);
39495 + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
39496 + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
39499 +static void ag71xx_hw_setup(struct ag71xx *ag)
39501 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
39503 + /* setup MAC configuration registers */
39504 + ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_INIT);
39506 + ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
39507 + MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
39509 + /* setup max frame length to zero */
39510 + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, 0);
39512 + /* setup FIFO configuration registers */
39513 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT);
39514 + if (pdata->is_ar724x) {
39515 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, pdata->fifo_cfg1);
39516 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, pdata->fifo_cfg2);
39517 + } else {
39518 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, 0x0fff0000);
39519 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, 0x00001fff);
39521 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG4, FIFO_CFG4_INIT);
39522 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, FIFO_CFG5_INIT);
39525 +static void ag71xx_hw_init(struct ag71xx *ag)
39527 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
39528 + u32 reset_mask = pdata->reset_bit;
39530 + ag71xx_hw_stop(ag);
39532 + if (pdata->is_ar724x) {
39533 + u32 reset_phy = reset_mask;
39535 + reset_phy &= AR71XX_RESET_GE0_PHY | AR71XX_RESET_GE1_PHY;
39536 + reset_mask &= ~(AR71XX_RESET_GE0_PHY | AR71XX_RESET_GE1_PHY);
39538 + ath79_device_reset_set(reset_phy);
39539 + msleep(50);
39540 + ath79_device_reset_clear(reset_phy);
39541 + msleep(200);
39544 + ag71xx_sb(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_SR);
39545 + udelay(20);
39547 + ath79_device_reset_set(reset_mask);
39548 + msleep(100);
39549 + ath79_device_reset_clear(reset_mask);
39550 + msleep(200);
39552 + ag71xx_hw_setup(ag);
39554 + ag71xx_dma_reset(ag);
39557 +static void ag71xx_fast_reset(struct ag71xx *ag)
39559 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
39560 + struct net_device *dev = ag->dev;
39561 + u32 reset_mask = pdata->reset_bit;
39562 + u32 rx_ds, tx_ds;
39563 + u32 mii_reg;
39565 + reset_mask &= AR71XX_RESET_GE0_MAC | AR71XX_RESET_GE1_MAC;
39567 + mii_reg = ag71xx_rr(ag, AG71XX_REG_MII_CFG);
39568 + rx_ds = ag71xx_rr(ag, AG71XX_REG_RX_DESC);
39569 + tx_ds = ag71xx_rr(ag, AG71XX_REG_TX_DESC);
39571 + ath79_device_reset_set(reset_mask);
39572 + udelay(10);
39573 + ath79_device_reset_clear(reset_mask);
39574 + udelay(10);
39576 + ag71xx_dma_reset(ag);
39577 + ag71xx_hw_setup(ag);
39579 + /* setup max frame length */
39580 + ag71xx_wr(ag, AG71XX_REG_MAC_MFL,
39581 + ag71xx_max_frame_len(ag->dev->mtu));
39583 + ag71xx_wr(ag, AG71XX_REG_RX_DESC, rx_ds);
39584 + ag71xx_wr(ag, AG71XX_REG_TX_DESC, tx_ds);
39585 + ag71xx_wr(ag, AG71XX_REG_MII_CFG, mii_reg);
39587 + ag71xx_hw_set_macaddr(ag, dev->dev_addr);
39590 +static void ag71xx_hw_start(struct ag71xx *ag)
39592 + /* start RX engine */
39593 + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
39595 + /* enable interrupts */
39596 + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, AG71XX_INT_INIT);
39599 +void ag71xx_link_adjust(struct ag71xx *ag)
39601 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
39602 + u32 cfg2;
39603 + u32 ifctl;
39604 + u32 fifo5;
39605 + u32 fifo3;
39607 + if (!ag->link) {
39608 + ag71xx_hw_stop(ag);
39609 + netif_carrier_off(ag->dev);
39610 + if (netif_msg_link(ag))
39611 + pr_info("%s: link down\n", ag->dev->name);
39612 + return;
39615 + if (pdata->is_ar724x)
39616 + ag71xx_fast_reset(ag);
39618 + cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
39619 + cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
39620 + cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
39622 + ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
39623 + ifctl &= ~(MAC_IFCTL_SPEED);
39625 + fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
39626 + fifo5 &= ~FIFO_CFG5_BM;
39628 + switch (ag->speed) {
39629 + case SPEED_1000:
39630 + cfg2 |= MAC_CFG2_IF_1000;
39631 + fifo5 |= FIFO_CFG5_BM;
39632 + break;
39633 + case SPEED_100:
39634 + cfg2 |= MAC_CFG2_IF_10_100;
39635 + ifctl |= MAC_IFCTL_SPEED;
39636 + break;
39637 + case SPEED_10:
39638 + cfg2 |= MAC_CFG2_IF_10_100;
39639 + break;
39640 + default:
39641 + BUG();
39642 + return;
39645 + if (pdata->is_ar91xx)
39646 + fifo3 = 0x00780fff;
39647 + else if (pdata->is_ar724x)
39648 + fifo3 = pdata->fifo_cfg3;
39649 + else
39650 + fifo3 = 0x008001ff;
39652 + if (ag->tx_ring.desc_split) {
39653 + fifo3 &= 0xffff;
39654 + fifo3 |= ((2048 - ag->tx_ring.desc_split) / 4) << 16;
39657 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, fifo3);
39659 + if (pdata->set_speed)
39660 + pdata->set_speed(ag->speed);
39662 + ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
39663 + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
39664 + ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
39665 + ag71xx_hw_start(ag);
39667 + netif_carrier_on(ag->dev);
39668 + if (netif_msg_link(ag))
39669 + pr_info("%s: link up (%sMbps/%s duplex)\n",
39670 + ag->dev->name,
39671 + ag71xx_speed_str(ag),
39672 + (DUPLEX_FULL == ag->duplex) ? "Full" : "Half");
39674 + DBG("%s: fifo_cfg0=%#x, fifo_cfg1=%#x, fifo_cfg2=%#x\n",
39675 + ag->dev->name,
39676 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
39677 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
39678 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
39680 + DBG("%s: fifo_cfg3=%#x, fifo_cfg4=%#x, fifo_cfg5=%#x\n",
39681 + ag->dev->name,
39682 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
39683 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
39684 + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
39686 + DBG("%s: mac_cfg2=%#x, mac_ifctl=%#x\n",
39687 + ag->dev->name,
39688 + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
39689 + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL));
39692 +static int ag71xx_open(struct net_device *dev)
39694 + struct ag71xx *ag = netdev_priv(dev);
39695 + unsigned int max_frame_len;
39696 + int ret;
39698 + max_frame_len = ag71xx_max_frame_len(dev->mtu);
39699 + ag->rx_buf_size = max_frame_len + NET_SKB_PAD + NET_IP_ALIGN;
39701 + /* setup max frame length */
39702 + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, max_frame_len);
39704 + ret = ag71xx_rings_init(ag);
39705 + if (ret)
39706 + goto err;
39708 + napi_enable(&ag->napi);
39710 + netif_carrier_off(dev);
39711 + ag71xx_phy_start(ag);
39713 + ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->tx_ring.descs_dma);
39714 + ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->rx_ring.descs_dma);
39716 + ag71xx_hw_set_macaddr(ag, dev->dev_addr);
39718 + netif_start_queue(dev);
39720 + return 0;
39722 +err:
39723 + ag71xx_rings_cleanup(ag);
39724 + return ret;
39727 +static int ag71xx_stop(struct net_device *dev)
39729 + struct ag71xx *ag = netdev_priv(dev);
39730 + unsigned long flags;
39732 + netif_carrier_off(dev);
39733 + ag71xx_phy_stop(ag);
39735 + spin_lock_irqsave(&ag->lock, flags);
39737 + netif_stop_queue(dev);
39739 + ag71xx_hw_stop(ag);
39740 + ag71xx_dma_reset(ag);
39742 + napi_disable(&ag->napi);
39743 + del_timer_sync(&ag->oom_timer);
39745 + spin_unlock_irqrestore(&ag->lock, flags);
39747 + ag71xx_rings_cleanup(ag);
39749 + return 0;
39752 +static int ag71xx_fill_dma_desc(struct ag71xx_ring *ring, u32 addr, int len)
39754 + int i;
39755 + struct ag71xx_desc *desc;
39756 + int ndesc = 0;
39757 + int split = ring->desc_split;
39759 + if (!split)
39760 + split = len;
39762 + while (len > 0) {
39763 + unsigned int cur_len = len;
39765 + i = (ring->curr + ndesc) % ring->size;
39766 + desc = ag71xx_ring_desc(ring, i);
39768 + if (!ag71xx_desc_empty(desc))
39769 + return -1;
39771 + if (cur_len > split) {
39772 + cur_len = split;
39774 + /*
39775 + * TX will hang if DMA transfers <= 4 bytes,
39776 + * make sure next segment is more than 4 bytes long.
39777 + */
39778 + if (len <= split + 4)
39779 + cur_len -= 4;
39782 + desc->data = addr;
39783 + addr += cur_len;
39784 + len -= cur_len;
39786 + if (len > 0)
39787 + cur_len |= DESC_MORE;
39789 + /* prevent early tx attempt of this descriptor */
39790 + if (!ndesc)
39791 + cur_len |= DESC_EMPTY;
39793 + desc->ctrl = cur_len;
39794 + ndesc++;
39797 + return ndesc;
39800 +static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
39801 + struct net_device *dev)
39803 + struct ag71xx *ag = netdev_priv(dev);
39804 + struct ag71xx_ring *ring = &ag->tx_ring;
39805 + struct ag71xx_desc *desc;
39806 + dma_addr_t dma_addr;
39807 + int i, n, ring_min;
39809 + if (ag71xx_has_ar8216(ag))
39810 + ag71xx_add_ar8216_header(ag, skb);
39812 + if (skb->len <= 4) {
39813 + DBG("%s: packet len is too small\n", ag->dev->name);
39814 + goto err_drop;
39817 + dma_addr = dma_map_single(&dev->dev, skb->data, skb->len,
39818 + DMA_TO_DEVICE);
39820 + i = ring->curr % ring->size;
39821 + desc = ag71xx_ring_desc(ring, i);
39823 + /* setup descriptor fields */
39824 + n = ag71xx_fill_dma_desc(ring, (u32) dma_addr, skb->len & ag->desc_pktlen_mask);
39825 + if (n < 0)
39826 + goto err_drop_unmap;
39828 + i = (ring->curr + n - 1) % ring->size;
39829 + ring->buf[i].len = skb->len;
39830 + ring->buf[i].skb = skb;
39831 + ring->buf[i].timestamp = jiffies;
39833 + netdev_sent_queue(dev, skb->len);
39835 + desc->ctrl &= ~DESC_EMPTY;
39836 + ring->curr += n;
39838 + /* flush descriptor */
39839 + wmb();
39841 + ring_min = 2;
39842 + if (ring->desc_split)
39843 + ring_min *= AG71XX_TX_RING_DS_PER_PKT;
39845 + if (ring->curr - ring->dirty >= ring->size - ring_min) {
39846 + DBG("%s: tx queue full\n", dev->name);
39847 + netif_stop_queue(dev);
39850 + DBG("%s: packet injected into TX queue\n", ag->dev->name);
39852 + /* enable TX engine */
39853 + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
39855 + return NETDEV_TX_OK;
39857 +err_drop_unmap:
39858 + dma_unmap_single(&dev->dev, dma_addr, skb->len, DMA_TO_DEVICE);
39860 +err_drop:
39861 + dev->stats.tx_dropped++;
39863 + dev_kfree_skb(skb);
39864 + return NETDEV_TX_OK;
39867 +static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39869 + struct ag71xx *ag = netdev_priv(dev);
39870 + int ret;
39872 + switch (cmd) {
39873 + case SIOCETHTOOL:
39874 + if (ag->phy_dev == NULL)
39875 + break;
39877 + spin_lock_irq(&ag->lock);
39878 + ret = phy_ethtool_ioctl(ag->phy_dev, (void *) ifr->ifr_data);
39879 + spin_unlock_irq(&ag->lock);
39880 + return ret;
39882 + case SIOCSIFHWADDR:
39883 + if (copy_from_user
39884 + (dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
39885 + return -EFAULT;
39886 + return 0;
39888 + case SIOCGIFHWADDR:
39889 + if (copy_to_user
39890 + (ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
39891 + return -EFAULT;
39892 + return 0;
39894 + case SIOCGMIIPHY:
39895 + case SIOCGMIIREG:
39896 + case SIOCSMIIREG:
39897 + if (ag->phy_dev == NULL)
39898 + break;
39900 + return phy_mii_ioctl(ag->phy_dev, ifr, cmd);
39902 + default:
39903 + break;
39906 + return -EOPNOTSUPP;
39909 +static void ag71xx_oom_timer_handler(unsigned long data)
39911 + struct net_device *dev = (struct net_device *) data;
39912 + struct ag71xx *ag = netdev_priv(dev);
39914 + napi_schedule(&ag->napi);
39917 +static void ag71xx_tx_timeout(struct net_device *dev)
39919 + struct ag71xx *ag = netdev_priv(dev);
39921 + if (netif_msg_tx_err(ag))
39922 + pr_info("%s: tx timeout\n", ag->dev->name);
39924 + schedule_work(&ag->restart_work);
39927 +static void ag71xx_restart_work_func(struct work_struct *work)
39929 + struct ag71xx *ag = container_of(work, struct ag71xx, restart_work);
39931 + if (ag71xx_get_pdata(ag)->is_ar724x) {
39932 + ag->link = 0;
39933 + ag71xx_link_adjust(ag);
39934 + return;
39937 + ag71xx_stop(ag->dev);
39938 + ag71xx_open(ag->dev);
39941 +static bool ag71xx_check_dma_stuck(struct ag71xx *ag, unsigned long timestamp)
39943 + u32 rx_sm, tx_sm, rx_fd;
39945 + if (likely(time_before(jiffies, timestamp + HZ/10)))
39946 + return false;
39948 + if (!netif_carrier_ok(ag->dev))
39949 + return false;
39951 + rx_sm = ag71xx_rr(ag, AG71XX_REG_RX_SM);
39952 + if ((rx_sm & 0x7) == 0x3 && ((rx_sm >> 4) & 0x7) == 0x6)
39953 + return true;
39955 + tx_sm = ag71xx_rr(ag, AG71XX_REG_TX_SM);
39956 + rx_fd = ag71xx_rr(ag, AG71XX_REG_FIFO_DEPTH);
39957 + if (((tx_sm >> 4) & 0x7) == 0 && ((rx_sm & 0x7) == 0) &&
39958 + ((rx_sm >> 4) & 0x7) == 0 && rx_fd == 0)
39959 + return true;
39961 + return false;
39964 +static int ag71xx_tx_packets(struct ag71xx *ag)
39966 + struct ag71xx_ring *ring = &ag->tx_ring;
39967 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
39968 + int sent = 0;
39969 + int bytes_compl = 0;
39970 + int n = 0;
39972 + DBG("%s: processing TX ring\n", ag->dev->name);
39974 + while (ring->dirty + n != ring->curr) {
39975 + unsigned int i = (ring->dirty + n) % ring->size;
39976 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
39977 + struct sk_buff *skb = ring->buf[i].skb;
39979 + if (!ag71xx_desc_empty(desc)) {
39980 + if (pdata->is_ar7240 &&
39981 + ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp))
39982 + schedule_work(&ag->restart_work);
39983 + break;
39986 + n++;
39987 + if (!skb)
39988 + continue;
39990 + dev_kfree_skb_any(skb);
39991 + ring->buf[i].skb = NULL;
39993 + bytes_compl += ring->buf[i].len;
39995 + sent++;
39996 + ring->dirty += n;
39998 + while (n > 0) {
39999 + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
40000 + n--;
40004 + DBG("%s: %d packets sent out\n", ag->dev->name, sent);
40006 + ag->dev->stats.tx_bytes += bytes_compl;
40007 + ag->dev->stats.tx_packets += sent;
40009 + if (!sent)
40010 + return 0;
40012 + netdev_completed_queue(ag->dev, sent, bytes_compl);
40013 + if ((ring->curr - ring->dirty) < (ring->size * 3) / 4)
40014 + netif_wake_queue(ag->dev);
40016 + return sent;
40019 +static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
40021 + struct net_device *dev = ag->dev;
40022 + struct ag71xx_ring *ring = &ag->rx_ring;
40023 + int offset = ag71xx_buffer_offset(ag);
40024 + unsigned int pktlen_mask = ag->desc_pktlen_mask;
40025 + int done = 0;
40027 + DBG("%s: rx packets, limit=%d, curr=%u, dirty=%u\n",
40028 + dev->name, limit, ring->curr, ring->dirty);
40030 + while (done < limit) {
40031 + unsigned int i = ring->curr % ring->size;
40032 + struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
40033 + struct sk_buff *skb;
40034 + int pktlen;
40035 + int err = 0;
40037 + if (ag71xx_desc_empty(desc))
40038 + break;
40040 + if ((ring->dirty + ring->size) == ring->curr) {
40041 + ag71xx_assert(0);
40042 + break;
40045 + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
40047 + pktlen = desc->ctrl & pktlen_mask;
40048 + pktlen -= ETH_FCS_LEN;
40050 + dma_unmap_single(&dev->dev, ring->buf[i].dma_addr,
40051 + ag->rx_buf_size, DMA_FROM_DEVICE);
40053 + dev->stats.rx_packets++;
40054 + dev->stats.rx_bytes += pktlen;
40056 + skb = build_skb(ring->buf[i].rx_buf, 0);
40057 + if (!skb) {
40058 + kfree(ring->buf[i].rx_buf);
40059 + goto next;
40062 + skb_reserve(skb, offset);
40063 + skb_put(skb, pktlen);
40065 + if (ag71xx_has_ar8216(ag))
40066 + err = ag71xx_remove_ar8216_header(ag, skb, pktlen);
40068 + if (err) {
40069 + dev->stats.rx_dropped++;
40070 + kfree_skb(skb);
40071 + } else {
40072 + skb->dev = dev;
40073 + skb->ip_summed = CHECKSUM_NONE;
40074 + skb->protocol = eth_type_trans(skb, dev);
40075 + netif_receive_skb(skb);
40078 +next:
40079 + ring->buf[i].rx_buf = NULL;
40080 + done++;
40082 + ring->curr++;
40085 + ag71xx_ring_rx_refill(ag);
40087 + DBG("%s: rx finish, curr=%u, dirty=%u, done=%d\n",
40088 + dev->name, ring->curr, ring->dirty, done);
40090 + return done;
40093 +static int ag71xx_poll(struct napi_struct *napi, int limit)
40095 + struct ag71xx *ag = container_of(napi, struct ag71xx, napi);
40096 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40097 + struct net_device *dev = ag->dev;
40098 + struct ag71xx_ring *rx_ring;
40099 + unsigned long flags;
40100 + u32 status;
40101 + int tx_done;
40102 + int rx_done;
40104 + pdata->ddr_flush();
40105 + tx_done = ag71xx_tx_packets(ag);
40107 + DBG("%s: processing RX ring\n", dev->name);
40108 + rx_done = ag71xx_rx_packets(ag, limit);
40110 + ag71xx_debugfs_update_napi_stats(ag, rx_done, tx_done);
40112 + rx_ring = &ag->rx_ring;
40113 + if (rx_ring->buf[rx_ring->dirty % rx_ring->size].rx_buf == NULL)
40114 + goto oom;
40116 + status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
40117 + if (unlikely(status & RX_STATUS_OF)) {
40118 + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_OF);
40119 + dev->stats.rx_fifo_errors++;
40121 + /* restart RX */
40122 + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
40125 + if (rx_done < limit) {
40126 + if (status & RX_STATUS_PR)
40127 + goto more;
40129 + status = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
40130 + if (status & TX_STATUS_PS)
40131 + goto more;
40133 + DBG("%s: disable polling mode, rx=%d, tx=%d,limit=%d\n",
40134 + dev->name, rx_done, tx_done, limit);
40136 + napi_complete(napi);
40138 + /* enable interrupts */
40139 + spin_lock_irqsave(&ag->lock, flags);
40140 + ag71xx_int_enable(ag, AG71XX_INT_POLL);
40141 + spin_unlock_irqrestore(&ag->lock, flags);
40142 + return rx_done;
40145 +more:
40146 + DBG("%s: stay in polling mode, rx=%d, tx=%d, limit=%d\n",
40147 + dev->name, rx_done, tx_done, limit);
40148 + return limit;
40150 +oom:
40151 + if (netif_msg_rx_err(ag))
40152 + pr_info("%s: out of memory\n", dev->name);
40154 + mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
40155 + napi_complete(napi);
40156 + return 0;
40159 +static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
40161 + struct net_device *dev = dev_id;
40162 + struct ag71xx *ag = netdev_priv(dev);
40163 + u32 status;
40165 + status = ag71xx_rr(ag, AG71XX_REG_INT_STATUS);
40166 + ag71xx_dump_intr(ag, "raw", status);
40168 + if (unlikely(!status))
40169 + return IRQ_NONE;
40171 + if (unlikely(status & AG71XX_INT_ERR)) {
40172 + if (status & AG71XX_INT_TX_BE) {
40173 + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE);
40174 + dev_err(&dev->dev, "TX BUS error\n");
40176 + if (status & AG71XX_INT_RX_BE) {
40177 + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE);
40178 + dev_err(&dev->dev, "RX BUS error\n");
40182 + if (likely(status & AG71XX_INT_POLL)) {
40183 + ag71xx_int_disable(ag, AG71XX_INT_POLL);
40184 + DBG("%s: enable polling mode\n", dev->name);
40185 + napi_schedule(&ag->napi);
40188 + ag71xx_debugfs_update_int_stats(ag, status);
40190 + return IRQ_HANDLED;
40193 +#ifdef CONFIG_NET_POLL_CONTROLLER
40195 + * Polling 'interrupt' - used by things like netconsole to send skbs
40196 + * without having to re-enable interrupts. It's not called while
40197 + * the interrupt routine is executing.
40198 + */
40199 +static void ag71xx_netpoll(struct net_device *dev)
40201 + disable_irq(dev->irq);
40202 + ag71xx_interrupt(dev->irq, dev);
40203 + enable_irq(dev->irq);
40205 +#endif
40207 +static int ag71xx_change_mtu(struct net_device *dev, int new_mtu)
40209 + struct ag71xx *ag = netdev_priv(dev);
40210 + unsigned int max_frame_len;
40212 + max_frame_len = ag71xx_max_frame_len(new_mtu);
40213 + if (new_mtu < 68 || max_frame_len > ag->max_frame_len)
40214 + return -EINVAL;
40216 + if (netif_running(dev))
40217 + return -EBUSY;
40219 + dev->mtu = new_mtu;
40220 + return 0;
40223 +static const struct net_device_ops ag71xx_netdev_ops = {
40224 + .ndo_open = ag71xx_open,
40225 + .ndo_stop = ag71xx_stop,
40226 + .ndo_start_xmit = ag71xx_hard_start_xmit,
40227 + .ndo_do_ioctl = ag71xx_do_ioctl,
40228 + .ndo_tx_timeout = ag71xx_tx_timeout,
40229 + .ndo_change_mtu = ag71xx_change_mtu,
40230 + .ndo_set_mac_address = eth_mac_addr,
40231 + .ndo_validate_addr = eth_validate_addr,
40232 +#ifdef CONFIG_NET_POLL_CONTROLLER
40233 + .ndo_poll_controller = ag71xx_netpoll,
40234 +#endif
40237 +static const char *ag71xx_get_phy_if_mode_name(phy_interface_t mode)
40239 + switch (mode) {
40240 + case PHY_INTERFACE_MODE_MII:
40241 + return "MII";
40242 + case PHY_INTERFACE_MODE_GMII:
40243 + return "GMII";
40244 + case PHY_INTERFACE_MODE_RMII:
40245 + return "RMII";
40246 + case PHY_INTERFACE_MODE_RGMII:
40247 + return "RGMII";
40248 + case PHY_INTERFACE_MODE_SGMII:
40249 + return "SGMII";
40250 + default:
40251 + break;
40254 + return "unknown";
40258 +static int ag71xx_probe(struct platform_device *pdev)
40260 + struct net_device *dev;
40261 + struct resource *res;
40262 + struct ag71xx *ag;
40263 + struct ag71xx_platform_data *pdata;
40264 + int err;
40266 + pdata = pdev->dev.platform_data;
40267 + if (!pdata) {
40268 + dev_err(&pdev->dev, "no platform data specified\n");
40269 + err = -ENXIO;
40270 + goto err_out;
40273 + if (pdata->mii_bus_dev == NULL && pdata->phy_mask) {
40274 + dev_err(&pdev->dev, "no MII bus device specified\n");
40275 + err = -EINVAL;
40276 + goto err_out;
40279 + dev = alloc_etherdev(sizeof(*ag));
40280 + if (!dev) {
40281 + dev_err(&pdev->dev, "alloc_etherdev failed\n");
40282 + err = -ENOMEM;
40283 + goto err_out;
40286 + if (!pdata->max_frame_len || !pdata->desc_pktlen_mask)
40287 + return -EINVAL;
40289 + SET_NETDEV_DEV(dev, &pdev->dev);
40291 + ag = netdev_priv(dev);
40292 + ag->pdev = pdev;
40293 + ag->dev = dev;
40294 + ag->msg_enable = netif_msg_init(ag71xx_msg_level,
40295 + AG71XX_DEFAULT_MSG_ENABLE);
40296 + spin_lock_init(&ag->lock);
40298 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base");
40299 + if (!res) {
40300 + dev_err(&pdev->dev, "no mac_base resource found\n");
40301 + err = -ENXIO;
40302 + goto err_out;
40305 + ag->mac_base = ioremap_nocache(res->start, res->end - res->start + 1);
40306 + if (!ag->mac_base) {
40307 + dev_err(&pdev->dev, "unable to ioremap mac_base\n");
40308 + err = -ENOMEM;
40309 + goto err_free_dev;
40312 + dev->irq = platform_get_irq(pdev, 0);
40313 + err = request_irq(dev->irq, ag71xx_interrupt,
40314 + 0x0,
40315 + dev->name, dev);
40316 + if (err) {
40317 + dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq);
40318 + goto err_unmap_base;
40321 + dev->base_addr = (unsigned long)ag->mac_base;
40322 + dev->netdev_ops = &ag71xx_netdev_ops;
40323 + dev->ethtool_ops = &ag71xx_ethtool_ops;
40325 + INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
40327 + init_timer(&ag->oom_timer);
40328 + ag->oom_timer.data = (unsigned long) dev;
40329 + ag->oom_timer.function = ag71xx_oom_timer_handler;
40331 + ag->tx_ring.size = AG71XX_TX_RING_SIZE_DEFAULT;
40332 + ag->rx_ring.size = AG71XX_RX_RING_SIZE_DEFAULT;
40334 + ag->max_frame_len = pdata->max_frame_len;
40335 + ag->desc_pktlen_mask = pdata->desc_pktlen_mask;
40337 + if (!pdata->is_ar724x && !pdata->is_ar91xx) {
40338 + ag->tx_ring.desc_split = AG71XX_TX_RING_SPLIT;
40339 + ag->tx_ring.size *= AG71XX_TX_RING_DS_PER_PKT;
40342 + ag->stop_desc = dma_alloc_coherent(NULL,
40343 + sizeof(struct ag71xx_desc), &ag->stop_desc_dma, GFP_KERNEL);
40345 + if (!ag->stop_desc)
40346 + goto err_free_irq;
40348 + ag->stop_desc->data = 0;
40349 + ag->stop_desc->ctrl = 0;
40350 + ag->stop_desc->next = (u32) ag->stop_desc_dma;
40352 + memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN);
40354 + netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT);
40356 + ag71xx_dump_regs(ag);
40358 + ag71xx_hw_init(ag);
40360 + ag71xx_dump_regs(ag);
40362 + err = ag71xx_phy_connect(ag);
40363 + if (err)
40364 + goto err_free_desc;
40366 + err = ag71xx_debugfs_init(ag);
40367 + if (err)
40368 + goto err_phy_disconnect;
40370 + platform_set_drvdata(pdev, dev);
40372 + err = register_netdev(dev);
40373 + if (err) {
40374 + dev_err(&pdev->dev, "unable to register net device\n");
40375 + goto err_debugfs_exit;
40378 + pr_info("%s: Atheros AG71xx at 0x%08lx, irq %d, mode:%s\n",
40379 + dev->name, dev->base_addr, dev->irq,
40380 + ag71xx_get_phy_if_mode_name(pdata->phy_if_mode));
40382 + return 0;
40384 +err_debugfs_exit:
40385 + ag71xx_debugfs_exit(ag);
40386 +err_phy_disconnect:
40387 + ag71xx_phy_disconnect(ag);
40388 +err_free_desc:
40389 + dma_free_coherent(NULL, sizeof(struct ag71xx_desc), ag->stop_desc,
40390 + ag->stop_desc_dma);
40391 +err_free_irq:
40392 + free_irq(dev->irq, dev);
40393 +err_unmap_base:
40394 + iounmap(ag->mac_base);
40395 +err_free_dev:
40396 + kfree(dev);
40397 +err_out:
40398 + platform_set_drvdata(pdev, NULL);
40399 + return err;
40402 +static int ag71xx_remove(struct platform_device *pdev)
40404 + struct net_device *dev = platform_get_drvdata(pdev);
40406 + if (dev) {
40407 + struct ag71xx *ag = netdev_priv(dev);
40409 + ag71xx_debugfs_exit(ag);
40410 + ag71xx_phy_disconnect(ag);
40411 + unregister_netdev(dev);
40412 + free_irq(dev->irq, dev);
40413 + iounmap(ag->mac_base);
40414 + kfree(dev);
40415 + platform_set_drvdata(pdev, NULL);
40418 + return 0;
40421 +static struct platform_driver ag71xx_driver = {
40422 + .probe = ag71xx_probe,
40423 + .remove = ag71xx_remove,
40424 + .driver = {
40425 + .name = AG71XX_DRV_NAME,
40429 +static int __init ag71xx_module_init(void)
40431 + int ret;
40433 + ret = ag71xx_debugfs_root_init();
40434 + if (ret)
40435 + goto err_out;
40437 + ret = ag71xx_mdio_driver_init();
40438 + if (ret)
40439 + goto err_debugfs_exit;
40441 + ret = platform_driver_register(&ag71xx_driver);
40442 + if (ret)
40443 + goto err_mdio_exit;
40445 + return 0;
40447 +err_mdio_exit:
40448 + ag71xx_mdio_driver_exit();
40449 +err_debugfs_exit:
40450 + ag71xx_debugfs_root_exit();
40451 +err_out:
40452 + return ret;
40455 +static void __exit ag71xx_module_exit(void)
40457 + platform_driver_unregister(&ag71xx_driver);
40458 + ag71xx_mdio_driver_exit();
40459 + ag71xx_debugfs_root_exit();
40462 +module_init(ag71xx_module_init);
40463 +module_exit(ag71xx_module_exit);
40465 +MODULE_VERSION(AG71XX_DRV_VERSION);
40466 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
40467 +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
40468 +MODULE_LICENSE("GPL v2");
40469 +MODULE_ALIAS("platform:" AG71XX_DRV_NAME);
40470 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
40471 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c 1970-01-01 01:00:00.000000000 +0100
40472 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c 2017-08-06 20:02:16.000000000 +0200
40473 @@ -0,0 +1,318 @@
40475 + * Atheros AR71xx built-in ethernet mac driver
40477 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
40478 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
40480 + * Based on Atheros' AG7100 driver
40482 + * This program is free software; you can redistribute it and/or modify it
40483 + * under the terms of the GNU General Public License version 2 as published
40484 + * by the Free Software Foundation.
40485 + */
40487 +#include "ag71xx.h"
40489 +#define AG71XX_MDIO_RETRY 1000
40490 +#define AG71XX_MDIO_DELAY 5
40492 +static inline void ag71xx_mdio_wr(struct ag71xx_mdio *am, unsigned reg,
40493 + u32 value)
40495 + void __iomem *r;
40497 + r = am->mdio_base + reg;
40498 + __raw_writel(value, r);
40500 + /* flush write */
40501 + (void) __raw_readl(r);
40504 +static inline u32 ag71xx_mdio_rr(struct ag71xx_mdio *am, unsigned reg)
40506 + return __raw_readl(am->mdio_base + reg);
40509 +static void ag71xx_mdio_dump_regs(struct ag71xx_mdio *am)
40511 + DBG("%s: mii_cfg=%08x, mii_cmd=%08x, mii_addr=%08x\n",
40512 + am->mii_bus->name,
40513 + ag71xx_mdio_rr(am, AG71XX_REG_MII_CFG),
40514 + ag71xx_mdio_rr(am, AG71XX_REG_MII_CMD),
40515 + ag71xx_mdio_rr(am, AG71XX_REG_MII_ADDR));
40516 + DBG("%s: mii_ctrl=%08x, mii_status=%08x, mii_ind=%08x\n",
40517 + am->mii_bus->name,
40518 + ag71xx_mdio_rr(am, AG71XX_REG_MII_CTRL),
40519 + ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS),
40520 + ag71xx_mdio_rr(am, AG71XX_REG_MII_IND));
40523 +static int ag71xx_mdio_wait_busy(struct ag71xx_mdio *am)
40525 + int i;
40527 + for (i = 0; i < AG71XX_MDIO_RETRY; i++) {
40528 + u32 busy;
40530 + udelay(AG71XX_MDIO_DELAY);
40532 + busy = ag71xx_mdio_rr(am, AG71XX_REG_MII_IND);
40533 + if (!busy)
40534 + return 0;
40536 + udelay(AG71XX_MDIO_DELAY);
40539 + pr_err("%s: MDIO operation timed out\n", am->mii_bus->name);
40541 + return -ETIMEDOUT;
40544 +int ag71xx_mdio_mii_read(struct ag71xx_mdio *am, int addr, int reg)
40546 + int err;
40547 + int ret;
40549 + err = ag71xx_mdio_wait_busy(am);
40550 + if (err)
40551 + return 0xffff;
40553 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
40554 + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
40555 + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
40556 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_READ);
40558 + err = ag71xx_mdio_wait_busy(am);
40559 + if (err)
40560 + return 0xffff;
40562 + ret = ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS) & 0xffff;
40563 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
40565 + DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, ret);
40567 + return ret;
40570 +void ag71xx_mdio_mii_write(struct ag71xx_mdio *am, int addr, int reg, u16 val)
40572 + DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val);
40574 + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
40575 + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
40576 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CTRL, val);
40578 + ag71xx_mdio_wait_busy(am);
40581 +static const u32 ar71xx_mdio_div_table[] = {
40582 + 4, 4, 6, 8, 10, 14, 20, 28,
40585 +static const u32 ar7240_mdio_div_table[] = {
40586 + 2, 2, 4, 6, 8, 12, 18, 26, 32, 40, 48, 56, 62, 70, 78, 96,
40589 +static const u32 ar933x_mdio_div_table[] = {
40590 + 4, 4, 6, 8, 10, 14, 20, 28, 34, 42, 50, 58, 66, 74, 82, 98,
40593 +static int ag71xx_mdio_get_divider(struct ag71xx_mdio *am, u32 *div)
40595 + unsigned long ref_clock, mdio_clock;
40596 + const u32 *table;
40597 + int ndivs;
40598 + int i;
40600 + ref_clock = am->pdata->ref_clock;
40601 + mdio_clock = am->pdata->mdio_clock;
40603 + if (!ref_clock || !mdio_clock)
40604 + return -EINVAL;
40606 + if (am->pdata->is_ar9330 || am->pdata->is_ar934x) {
40607 + table = ar933x_mdio_div_table;
40608 + ndivs = ARRAY_SIZE(ar933x_mdio_div_table);
40609 + } else if (am->pdata->is_ar7240) {
40610 + table = ar7240_mdio_div_table;
40611 + ndivs = ARRAY_SIZE(ar7240_mdio_div_table);
40612 + } else {
40613 + table = ar71xx_mdio_div_table;
40614 + ndivs = ARRAY_SIZE(ar71xx_mdio_div_table);
40617 + for (i = 0; i < ndivs; i++) {
40618 + unsigned long t;
40620 + t = ref_clock / table[i];
40621 + if (t <= mdio_clock) {
40622 + *div = i;
40623 + return 0;
40627 + dev_err(&am->mii_bus->dev, "no divider found for %lu/%lu\n",
40628 + ref_clock, mdio_clock);
40629 + return -ENOENT;
40632 +static int ag71xx_mdio_reset(struct mii_bus *bus)
40634 + struct ag71xx_mdio *am = bus->priv;
40635 + u32 t;
40636 + int err;
40638 + err = ag71xx_mdio_get_divider(am, &t);
40639 + if (err) {
40640 + /* fallback */
40641 + if (am->pdata->is_ar7240)
40642 + t = MII_CFG_CLK_DIV_6;
40643 + else if (am->pdata->builtin_switch && !am->pdata->is_ar934x)
40644 + t = MII_CFG_CLK_DIV_10;
40645 + else if (!am->pdata->builtin_switch && am->pdata->is_ar934x)
40646 + t = MII_CFG_CLK_DIV_58;
40647 + else
40648 + t = MII_CFG_CLK_DIV_28;
40651 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t | MII_CFG_RESET);
40652 + udelay(100);
40654 + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t);
40655 + udelay(100);
40657 + if (am->pdata->reset)
40658 + am->pdata->reset(bus);
40660 + return 0;
40663 +static int ag71xx_mdio_read(struct mii_bus *bus, int addr, int reg)
40665 + struct ag71xx_mdio *am = bus->priv;
40667 + if (am->pdata->builtin_switch)
40668 + return ar7240sw_phy_read(bus, addr, reg);
40669 + else
40670 + return ag71xx_mdio_mii_read(am, addr, reg);
40673 +static int ag71xx_mdio_write(struct mii_bus *bus, int addr, int reg, u16 val)
40675 + struct ag71xx_mdio *am = bus->priv;
40677 + if (am->pdata->builtin_switch)
40678 + ar7240sw_phy_write(bus, addr, reg, val);
40679 + else
40680 + ag71xx_mdio_mii_write(am, addr, reg, val);
40681 + return 0;
40684 +static int ag71xx_mdio_probe(struct platform_device *pdev)
40686 + struct ag71xx_mdio_platform_data *pdata;
40687 + struct ag71xx_mdio *am;
40688 + struct resource *res;
40689 + int i;
40690 + int err;
40692 + pdata = pdev->dev.platform_data;
40693 + if (!pdata) {
40694 + dev_err(&pdev->dev, "no platform data specified\n");
40695 + return -EINVAL;
40698 + am = kzalloc(sizeof(*am), GFP_KERNEL);
40699 + if (!am) {
40700 + err = -ENOMEM;
40701 + goto err_out;
40704 + am->pdata = pdata;
40706 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
40707 + if (!res) {
40708 + dev_err(&pdev->dev, "no iomem resource found\n");
40709 + err = -ENXIO;
40710 + goto err_out;
40713 + am->mdio_base = ioremap_nocache(res->start, res->end - res->start + 1);
40714 + if (!am->mdio_base) {
40715 + dev_err(&pdev->dev, "unable to ioremap registers\n");
40716 + err = -ENOMEM;
40717 + goto err_free_mdio;
40720 + am->mii_bus = mdiobus_alloc();
40721 + if (am->mii_bus == NULL) {
40722 + err = -ENOMEM;
40723 + goto err_iounmap;
40726 + am->mii_bus->name = "ag71xx_mdio";
40727 + am->mii_bus->read = ag71xx_mdio_read;
40728 + am->mii_bus->write = ag71xx_mdio_write;
40729 + am->mii_bus->reset = ag71xx_mdio_reset;
40730 + am->mii_bus->irq = am->mii_irq;
40731 + am->mii_bus->priv = am;
40732 + am->mii_bus->parent = &pdev->dev;
40733 + snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev));
40734 + am->mii_bus->phy_mask = pdata->phy_mask;
40736 + for (i = 0; i < PHY_MAX_ADDR; i++)
40737 + am->mii_irq[i] = PHY_POLL;
40739 + ag71xx_mdio_wr(am, AG71XX_REG_MAC_CFG1, 0);
40741 + err = mdiobus_register(am->mii_bus);
40742 + if (err)
40743 + goto err_free_bus;
40745 + ag71xx_mdio_dump_regs(am);
40747 + platform_set_drvdata(pdev, am);
40748 + return 0;
40750 +err_free_bus:
40751 + mdiobus_free(am->mii_bus);
40752 +err_iounmap:
40753 + iounmap(am->mdio_base);
40754 +err_free_mdio:
40755 + kfree(am);
40756 +err_out:
40757 + return err;
40760 +static int ag71xx_mdio_remove(struct platform_device *pdev)
40762 + struct ag71xx_mdio *am = platform_get_drvdata(pdev);
40764 + if (am) {
40765 + mdiobus_unregister(am->mii_bus);
40766 + mdiobus_free(am->mii_bus);
40767 + iounmap(am->mdio_base);
40768 + kfree(am);
40769 + platform_set_drvdata(pdev, NULL);
40772 + return 0;
40775 +static struct platform_driver ag71xx_mdio_driver = {
40776 + .probe = ag71xx_mdio_probe,
40777 + .remove = ag71xx_mdio_remove,
40778 + .driver = {
40779 + .name = "ag71xx-mdio",
40783 +int __init ag71xx_mdio_driver_init(void)
40785 + return platform_driver_register(&ag71xx_mdio_driver);
40788 +void ag71xx_mdio_driver_exit(void)
40790 + platform_driver_unregister(&ag71xx_mdio_driver);
40792 diff -Nur linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
40793 --- linux-4.1.43.orig/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c 1970-01-01 01:00:00.000000000 +0100
40794 +++ linux-4.1.43/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c 2017-08-06 20:02:16.000000000 +0200
40795 @@ -0,0 +1,235 @@
40797 + * Atheros AR71xx built-in ethernet mac driver
40799 + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
40800 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
40802 + * Based on Atheros' AG7100 driver
40804 + * This program is free software; you can redistribute it and/or modify it
40805 + * under the terms of the GNU General Public License version 2 as published
40806 + * by the Free Software Foundation.
40807 + */
40809 +#include "ag71xx.h"
40811 +static void ag71xx_phy_link_adjust(struct net_device *dev)
40813 + struct ag71xx *ag = netdev_priv(dev);
40814 + struct phy_device *phydev = ag->phy_dev;
40815 + unsigned long flags;
40816 + int status_change = 0;
40818 + spin_lock_irqsave(&ag->lock, flags);
40820 + if (phydev->link) {
40821 + if (ag->duplex != phydev->duplex
40822 + || ag->speed != phydev->speed) {
40823 + status_change = 1;
40827 + if (phydev->link != ag->link)
40828 + status_change = 1;
40830 + ag->link = phydev->link;
40831 + ag->duplex = phydev->duplex;
40832 + ag->speed = phydev->speed;
40834 + if (status_change)
40835 + ag71xx_link_adjust(ag);
40837 + spin_unlock_irqrestore(&ag->lock, flags);
40840 +void ag71xx_phy_start(struct ag71xx *ag)
40842 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40844 + if (ag->phy_dev) {
40845 + phy_start(ag->phy_dev);
40846 + } else if (pdata->mii_bus_dev && pdata->switch_data) {
40847 + ag71xx_ar7240_start(ag);
40848 + } else {
40849 + ag->link = 1;
40850 + ag71xx_link_adjust(ag);
40854 +void ag71xx_phy_stop(struct ag71xx *ag)
40856 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40857 + unsigned long flags;
40859 + if (ag->phy_dev)
40860 + phy_stop(ag->phy_dev);
40861 + else if (pdata->mii_bus_dev && pdata->switch_data)
40862 + ag71xx_ar7240_stop(ag);
40864 + spin_lock_irqsave(&ag->lock, flags);
40865 + if (ag->link) {
40866 + ag->link = 0;
40867 + ag71xx_link_adjust(ag);
40869 + spin_unlock_irqrestore(&ag->lock, flags);
40872 +static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
40874 + struct device *dev = &ag->pdev->dev;
40875 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40876 + int ret = 0;
40878 + /* use fixed settings */
40879 + switch (pdata->speed) {
40880 + case SPEED_10:
40881 + case SPEED_100:
40882 + case SPEED_1000:
40883 + break;
40884 + default:
40885 + dev_err(dev, "invalid speed specified\n");
40886 + ret = -EINVAL;
40887 + break;
40890 + dev_dbg(dev, "using fixed link parameters\n");
40892 + ag->duplex = pdata->duplex;
40893 + ag->speed = pdata->speed;
40895 + return ret;
40898 +static int ag71xx_phy_connect_multi(struct ag71xx *ag)
40900 + struct device *dev = &ag->pdev->dev;
40901 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40902 + struct phy_device *phydev = NULL;
40903 + int phy_addr;
40904 + int ret = 0;
40906 + for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
40907 + if (!(pdata->phy_mask & (1 << phy_addr)))
40908 + continue;
40910 + if (ag->mii_bus->phy_map[phy_addr] == NULL)
40911 + continue;
40913 + DBG("%s: PHY found at %s, uid=%08x\n",
40914 + dev_name(dev),
40915 + dev_name(&ag->mii_bus->phy_map[phy_addr]->dev),
40916 + ag->mii_bus->phy_map[phy_addr]->phy_id);
40918 + if (phydev == NULL)
40919 + phydev = ag->mii_bus->phy_map[phy_addr];
40922 + if (!phydev) {
40923 + dev_err(dev, "no PHY found with phy_mask=%08x\n",
40924 + pdata->phy_mask);
40925 + return -ENODEV;
40928 + ag->phy_dev = phy_connect(ag->dev, dev_name(&phydev->dev),
40929 + &ag71xx_phy_link_adjust,
40930 + pdata->phy_if_mode);
40932 + if (IS_ERR(ag->phy_dev)) {
40933 + dev_err(dev, "could not connect to PHY at %s\n",
40934 + dev_name(&phydev->dev));
40935 + return PTR_ERR(ag->phy_dev);
40938 + /* mask with MAC supported features */
40939 + if (pdata->has_gbit)
40940 + phydev->supported &= PHY_GBIT_FEATURES;
40941 + else
40942 + phydev->supported &= PHY_BASIC_FEATURES;
40944 + phydev->advertising = phydev->supported;
40946 + dev_info(dev, "connected to PHY at %s [uid=%08x, driver=%s]\n",
40947 + dev_name(&phydev->dev), phydev->phy_id, phydev->drv->name);
40949 + ag->link = 0;
40950 + ag->speed = 0;
40951 + ag->duplex = -1;
40953 + return ret;
40956 +static int dev_is_class(struct device *dev, void *class)
40958 + if (dev->class != NULL && !strcmp(dev->class->name, class))
40959 + return 1;
40961 + return 0;
40964 +static struct device *dev_find_class(struct device *parent, char *class)
40966 + if (dev_is_class(parent, class)) {
40967 + get_device(parent);
40968 + return parent;
40971 + return device_find_child(parent, class, dev_is_class);
40974 +static struct mii_bus *dev_to_mii_bus(struct device *dev)
40976 + struct device *d;
40978 + d = dev_find_class(dev, "mdio_bus");
40979 + if (d != NULL) {
40980 + struct mii_bus *bus;
40982 + bus = to_mii_bus(d);
40983 + put_device(d);
40985 + return bus;
40988 + return NULL;
40991 +int ag71xx_phy_connect(struct ag71xx *ag)
40993 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
40995 + if (pdata->mii_bus_dev == NULL ||
40996 + pdata->mii_bus_dev->bus == NULL )
40997 + return ag71xx_phy_connect_fixed(ag);
40999 + ag->mii_bus = dev_to_mii_bus(pdata->mii_bus_dev);
41000 + if (ag->mii_bus == NULL) {
41001 + dev_err(&ag->pdev->dev, "unable to find MII bus on device '%s'\n",
41002 + dev_name(pdata->mii_bus_dev));
41003 + return -ENODEV;
41006 + /* Reset the mdio bus explicitly */
41007 + if (ag->mii_bus->reset) {
41008 + mutex_lock(&ag->mii_bus->mdio_lock);
41009 + ag->mii_bus->reset(ag->mii_bus);
41010 + mutex_unlock(&ag->mii_bus->mdio_lock);
41013 + if (pdata->switch_data)
41014 + return ag71xx_ar7240_init(ag);
41016 + if (pdata->phy_mask)
41017 + return ag71xx_phy_connect_multi(ag);
41019 + return ag71xx_phy_connect_fixed(ag);
41022 +void ag71xx_phy_disconnect(struct ag71xx *ag)
41024 + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
41026 + if (pdata->switch_data)
41027 + ag71xx_ar7240_cleanup(ag);
41028 + else if (ag->phy_dev)
41029 + phy_disconnect(ag->phy_dev);
41031 diff -Nur linux-4.1.43.orig/drivers/net/phy/Kconfig linux-4.1.43/drivers/net/phy/Kconfig
41032 --- linux-4.1.43.orig/drivers/net/phy/Kconfig 2017-08-06 01:56:14.000000000 +0200
41033 +++ linux-4.1.43/drivers/net/phy/Kconfig 2017-08-06 20:02:16.000000000 +0200
41034 @@ -12,6 +12,16 @@
41036 if PHYLIB
41038 +config SWCONFIG
41039 + tristate "Switch configuration API"
41040 + ---help---
41041 + Switch configuration API using netlink. This allows
41042 + you to configure the VLAN features of certain switches.
41044 +config SWCONFIG_LEDS
41045 + bool "Switch LED trigger support"
41046 + depends on (SWCONFIG && LEDS_TRIGGERS)
41048 comment "MII PHY device drivers"
41050 config AT803X_PHY
41051 diff -Nur linux-4.1.43.orig/drivers/net/phy/Makefile linux-4.1.43/drivers/net/phy/Makefile
41052 --- linux-4.1.43.orig/drivers/net/phy/Makefile 2017-08-06 01:56:14.000000000 +0200
41053 +++ linux-4.1.43/drivers/net/phy/Makefile 2017-08-06 20:02:16.000000000 +0200
41054 @@ -3,6 +3,7 @@
41055 libphy-objs := phy.o phy_device.o mdio_bus.o
41057 obj-$(CONFIG_PHYLIB) += libphy.o
41058 +obj-$(CONFIG_SWCONFIG) += swconfig.o
41059 obj-$(CONFIG_MARVELL_PHY) += marvell.o
41060 obj-$(CONFIG_DAVICOM_PHY) += davicom.o
41061 obj-$(CONFIG_CICADA_PHY) += cicada.o
41062 diff -Nur linux-4.1.43.orig/drivers/net/phy/at803x.c linux-4.1.43/drivers/net/phy/at803x.c
41063 --- linux-4.1.43.orig/drivers/net/phy/at803x.c 2017-08-06 01:56:14.000000000 +0200
41064 +++ linux-4.1.43/drivers/net/phy/at803x.c 2017-08-06 20:02:16.000000000 +0200
41065 @@ -12,12 +12,14 @@
41068 #include <linux/phy.h>
41069 +#include <linux/mdio.h>
41070 #include <linux/module.h>
41071 #include <linux/string.h>
41072 #include <linux/netdevice.h>
41073 #include <linux/etherdevice.h>
41074 #include <linux/of_gpio.h>
41075 #include <linux/gpio/consumer.h>
41076 +#include <linux/platform_data/phy-at803x.h>
41078 #define AT803X_INTR_ENABLE 0x12
41079 #define AT803X_INTR_STATUS 0x13
41080 @@ -34,8 +36,16 @@
41081 #define AT803X_INER 0x0012
41082 #define AT803X_INER_INIT 0xec00
41083 #define AT803X_INSR 0x0013
41085 +#define AT803X_PCS_SMART_EEE_CTRL3 0x805D
41086 +#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3
41087 +#define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT 12
41088 +#define AT803X_SMART_EEE_CTRL3_LPI_EN BIT(8)
41090 #define AT803X_DEBUG_ADDR 0x1D
41091 #define AT803X_DEBUG_DATA 0x1E
41092 +#define AT803X_DBG0_REG 0x00
41093 +#define AT803X_DEBUG_RGMII_RX_CLK_DLY BIT(8)
41094 #define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05
41095 #define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8)
41097 @@ -50,6 +60,7 @@
41098 struct at803x_priv {
41099 bool phy_reset:1;
41100 struct gpio_desc *gpiod_reset;
41101 + int prev_speed;
41104 struct at803x_context {
41105 @@ -61,6 +72,43 @@
41106 u16 led_control;
41109 +static u16
41110 +at803x_dbg_reg_rmw(struct phy_device *phydev, u16 reg, u16 clear, u16 set)
41112 + struct mii_bus *bus = phydev->bus;
41113 + int val;
41115 + mutex_lock(&bus->mdio_lock);
41117 + bus->write(bus, phydev->addr, AT803X_DEBUG_ADDR, reg);
41118 + val = bus->read(bus, phydev->addr, AT803X_DEBUG_DATA);
41119 + if (val < 0) {
41120 + val = 0xffff;
41121 + goto out;
41124 + val &= ~clear;
41125 + val |= set;
41126 + bus->write(bus, phydev->addr, AT803X_DEBUG_DATA, val);
41128 +out:
41129 + mutex_unlock(&bus->mdio_lock);
41130 + return val;
41133 +static inline void
41134 +at803x_dbg_reg_set(struct phy_device *phydev, u16 reg, u16 set)
41136 + at803x_dbg_reg_rmw(phydev, reg, 0, set);
41139 +static inline void
41140 +at803x_dbg_reg_clr(struct phy_device *phydev, u16 reg, u16 clear)
41142 + at803x_dbg_reg_rmw(phydev, reg, clear, 0);
41146 /* save relevant PHY registers to private copy */
41147 static void at803x_context_save(struct phy_device *phydev,
41148 struct at803x_context *context)
41149 @@ -209,8 +257,16 @@
41150 return 0;
41153 +static void at803x_disable_smarteee(struct phy_device *phydev)
41155 + phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_PCS_SMART_EEE_CTRL3,
41156 + 1 << AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_SHIFT);
41157 + phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0);
41160 static int at803x_config_init(struct phy_device *phydev)
41162 + struct at803x_platform_data *pdata;
41163 int ret;
41165 ret = genphy_config_init(phydev);
41166 @@ -228,6 +284,26 @@
41167 return ret;
41170 + pdata = dev_get_platdata(&phydev->dev);
41171 + if (pdata) {
41172 + if (pdata->disable_smarteee)
41173 + at803x_disable_smarteee(phydev);
41175 + if (pdata->enable_rgmii_rx_delay)
41176 + at803x_dbg_reg_set(phydev, AT803X_DBG0_REG,
41177 + AT803X_DEBUG_RGMII_RX_CLK_DLY);
41178 + else
41179 + at803x_dbg_reg_clr(phydev, AT803X_DBG0_REG,
41180 + AT803X_DEBUG_RGMII_RX_CLK_DLY);
41182 + if (pdata->enable_rgmii_tx_delay)
41183 + at803x_dbg_reg_set(phydev, AT803X_DEBUG_SYSTEM_MODE_CTRL,
41184 + AT803X_DEBUG_RGMII_TX_CLK_DLY);
41185 + else
41186 + at803x_dbg_reg_clr(phydev, AT803X_DEBUG_SYSTEM_MODE_CTRL,
41187 + AT803X_DEBUG_RGMII_TX_CLK_DLY);
41190 return 0;
41193 @@ -259,6 +335,8 @@
41194 static void at803x_link_change_notify(struct phy_device *phydev)
41196 struct at803x_priv *priv = phydev->priv;
41197 + struct at803x_platform_data *pdata;
41198 + pdata = dev_get_platdata(&phydev->dev);
41201 * Conduct a hardware reset for AT8030 every time a link loss is
41202 @@ -289,6 +367,26 @@
41203 priv->phy_reset = false;
41206 + if (pdata && pdata->fixup_rgmii_tx_delay &&
41207 + phydev->speed != priv->prev_speed) {
41208 + switch (phydev->speed) {
41209 + case SPEED_10:
41210 + case SPEED_100:
41211 + at803x_dbg_reg_set(phydev,
41212 + AT803X_DEBUG_SYSTEM_MODE_CTRL,
41213 + AT803X_DEBUG_RGMII_TX_CLK_DLY);
41214 + break;
41215 + case SPEED_1000:
41216 + at803x_dbg_reg_clr(phydev,
41217 + AT803X_DEBUG_SYSTEM_MODE_CTRL,
41218 + AT803X_DEBUG_RGMII_TX_CLK_DLY);
41219 + break;
41220 + default:
41221 + break;
41224 + priv->prev_speed = phydev->speed;
41228 static struct phy_driver at803x_driver[] = {
41229 diff -Nur linux-4.1.43.orig/drivers/net/phy/mdio-bitbang.c linux-4.1.43/drivers/net/phy/mdio-bitbang.c
41230 --- linux-4.1.43.orig/drivers/net/phy/mdio-bitbang.c 2017-08-06 01:56:14.000000000 +0200
41231 +++ linux-4.1.43/drivers/net/phy/mdio-bitbang.c 2017-08-06 20:02:16.000000000 +0200
41232 @@ -17,6 +17,7 @@
41233 * kind, whether express or implied.
41236 +#include <linux/irqflags.h>
41237 #include <linux/module.h>
41238 #include <linux/mdio-bitbang.h>
41239 #include <linux/types.h>
41240 @@ -156,7 +157,9 @@
41242 struct mdiobb_ctrl *ctrl = bus->priv;
41243 int ret, i;
41244 + long flags;
41246 + local_irq_save(flags);
41247 if (reg & MII_ADDR_C45) {
41248 reg = mdiobb_cmd_addr(ctrl, phy, reg);
41249 mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
41250 @@ -165,26 +168,21 @@
41252 ctrl->ops->set_mdio_dir(ctrl, 0);
41254 - /* check the turnaround bit: the PHY should be driving it to zero */
41255 - if (mdiobb_get_bit(ctrl) != 0) {
41256 - /* PHY didn't drive TA low -- flush any bits it
41257 - * may be trying to send.
41258 - */
41259 - for (i = 0; i < 32; i++)
41260 - mdiobb_get_bit(ctrl);
41262 - return 0xffff;
41264 + mdiobb_get_bit(ctrl);
41266 ret = mdiobb_get_num(ctrl, 16);
41267 mdiobb_get_bit(ctrl);
41268 + local_irq_restore(flags);
41270 return ret;
41273 static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
41275 struct mdiobb_ctrl *ctrl = bus->priv;
41276 + long flags;
41278 + local_irq_save(flags);
41279 if (reg & MII_ADDR_C45) {
41280 reg = mdiobb_cmd_addr(ctrl, phy, reg);
41281 mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
41282 @@ -199,6 +197,8 @@
41284 ctrl->ops->set_mdio_dir(ctrl, 0);
41285 mdiobb_get_bit(ctrl);
41286 + local_irq_restore(flags);
41288 return 0;
41291 diff -Nur linux-4.1.43.orig/drivers/net/phy/phy.c linux-4.1.43/drivers/net/phy/phy.c
41292 --- linux-4.1.43.orig/drivers/net/phy/phy.c 2017-08-06 01:56:14.000000000 +0200
41293 +++ linux-4.1.43/drivers/net/phy/phy.c 2017-08-06 20:02:16.000000000 +0200
41294 @@ -357,6 +357,50 @@
41296 EXPORT_SYMBOL(phy_ethtool_gset);
41298 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
41300 + u32 cmd;
41301 + int tmp;
41302 + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
41303 + struct ethtool_value edata = { ETHTOOL_GLINK };
41305 + if (get_user(cmd, (u32 *) useraddr))
41306 + return -EFAULT;
41308 + switch (cmd) {
41309 + case ETHTOOL_GSET:
41310 + phy_ethtool_gset(phydev, &ecmd);
41311 + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
41312 + return -EFAULT;
41313 + return 0;
41315 + case ETHTOOL_SSET:
41316 + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
41317 + return -EFAULT;
41318 + return phy_ethtool_sset(phydev, &ecmd);
41320 + case ETHTOOL_NWAY_RST:
41321 + /* if autoneg is off, it's an error */
41322 + tmp = phy_read(phydev, MII_BMCR);
41323 + if (tmp & BMCR_ANENABLE) {
41324 + tmp |= (BMCR_ANRESTART);
41325 + phy_write(phydev, MII_BMCR, tmp);
41326 + return 0;
41328 + return -EINVAL;
41330 + case ETHTOOL_GLINK:
41331 + edata.data = (phy_read(phydev,
41332 + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
41333 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
41334 + return -EFAULT;
41335 + return 0;
41338 + return -EOPNOTSUPP;
41340 +EXPORT_SYMBOL(phy_ethtool_ioctl);
41343 * phy_mii_ioctl - generic PHY MII ioctl interface
41344 * @phydev: the phy_device struct
41345 diff -Nur linux-4.1.43.orig/drivers/net/phy/swconfig.c linux-4.1.43/drivers/net/phy/swconfig.c
41346 --- linux-4.1.43.orig/drivers/net/phy/swconfig.c 1970-01-01 01:00:00.000000000 +0100
41347 +++ linux-4.1.43/drivers/net/phy/swconfig.c 2017-08-06 20:02:16.000000000 +0200
41348 @@ -0,0 +1,1153 @@
41350 + * swconfig.c: Switch configuration API
41352 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
41354 + * This program is free software; you can redistribute it and/or
41355 + * modify it under the terms of the GNU General Public License
41356 + * as published by the Free Software Foundation; either version 2
41357 + * of the License, or (at your option) any later version.
41359 + * This program is distributed in the hope that it will be useful,
41360 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
41361 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41362 + * GNU General Public License for more details.
41363 + */
41365 +#include <linux/types.h>
41366 +#include <linux/module.h>
41367 +#include <linux/init.h>
41368 +#include <linux/list.h>
41369 +#include <linux/if.h>
41370 +#include <linux/if_ether.h>
41371 +#include <linux/capability.h>
41372 +#include <linux/skbuff.h>
41373 +#include <linux/switch.h>
41374 +#include <linux/of.h>
41375 +#include <linux/version.h>
41377 +#define SWCONFIG_DEVNAME "switch%d"
41379 +#include "swconfig_leds.c"
41381 +MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
41382 +MODULE_LICENSE("GPL");
41384 +static int swdev_id;
41385 +static struct list_head swdevs;
41386 +static DEFINE_SPINLOCK(swdevs_lock);
41387 +struct swconfig_callback;
41389 +struct swconfig_callback {
41390 + struct sk_buff *msg;
41391 + struct genlmsghdr *hdr;
41392 + struct genl_info *info;
41393 + int cmd;
41395 + /* callback for filling in the message data */
41396 + int (*fill)(struct swconfig_callback *cb, void *arg);
41398 + /* callback for closing the message before sending it */
41399 + int (*close)(struct swconfig_callback *cb, void *arg);
41401 + struct nlattr *nest[4];
41402 + int args[4];
41405 +/* defaults */
41407 +static int
41408 +swconfig_get_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr,
41409 + struct switch_val *val)
41411 + int ret;
41412 + if (val->port_vlan >= dev->vlans)
41413 + return -EINVAL;
41415 + if (!dev->ops->get_vlan_ports)
41416 + return -EOPNOTSUPP;
41418 + ret = dev->ops->get_vlan_ports(dev, val);
41419 + return ret;
41422 +static int
41423 +swconfig_set_vlan_ports(struct switch_dev *dev, const struct switch_attr *attr,
41424 + struct switch_val *val)
41426 + struct switch_port *ports = val->value.ports;
41427 + const struct switch_dev_ops *ops = dev->ops;
41428 + int i;
41430 + if (val->port_vlan >= dev->vlans)
41431 + return -EINVAL;
41433 + /* validate ports */
41434 + if (val->len > dev->ports)
41435 + return -EINVAL;
41437 + if (!ops->set_vlan_ports)
41438 + return -EOPNOTSUPP;
41440 + for (i = 0; i < val->len; i++) {
41441 + if (ports[i].id >= dev->ports)
41442 + return -EINVAL;
41444 + if (ops->set_port_pvid &&
41445 + !(ports[i].flags & (1 << SWITCH_PORT_FLAG_TAGGED)))
41446 + ops->set_port_pvid(dev, ports[i].id, val->port_vlan);
41449 + return ops->set_vlan_ports(dev, val);
41452 +static int
41453 +swconfig_set_pvid(struct switch_dev *dev, const struct switch_attr *attr,
41454 + struct switch_val *val)
41456 + if (val->port_vlan >= dev->ports)
41457 + return -EINVAL;
41459 + if (!dev->ops->set_port_pvid)
41460 + return -EOPNOTSUPP;
41462 + return dev->ops->set_port_pvid(dev, val->port_vlan, val->value.i);
41465 +static int
41466 +swconfig_get_pvid(struct switch_dev *dev, const struct switch_attr *attr,
41467 + struct switch_val *val)
41469 + if (val->port_vlan >= dev->ports)
41470 + return -EINVAL;
41472 + if (!dev->ops->get_port_pvid)
41473 + return -EOPNOTSUPP;
41475 + return dev->ops->get_port_pvid(dev, val->port_vlan, &val->value.i);
41478 +static const char *
41479 +swconfig_speed_str(enum switch_port_speed speed)
41481 + switch (speed) {
41482 + case SWITCH_PORT_SPEED_10:
41483 + return "10baseT";
41484 + case SWITCH_PORT_SPEED_100:
41485 + return "100baseT";
41486 + case SWITCH_PORT_SPEED_1000:
41487 + return "1000baseT";
41488 + default:
41489 + break;
41492 + return "unknown";
41495 +static int
41496 +swconfig_get_link(struct switch_dev *dev, const struct switch_attr *attr,
41497 + struct switch_val *val)
41499 + struct switch_port_link link;
41500 + int len;
41501 + int ret;
41503 + if (val->port_vlan >= dev->ports)
41504 + return -EINVAL;
41506 + if (!dev->ops->get_port_link)
41507 + return -EOPNOTSUPP;
41509 + memset(&link, 0, sizeof(link));
41510 + ret = dev->ops->get_port_link(dev, val->port_vlan, &link);
41511 + if (ret)
41512 + return ret;
41514 + memset(dev->buf, 0, sizeof(dev->buf));
41516 + if (link.link)
41517 + len = snprintf(dev->buf, sizeof(dev->buf),
41518 + "port:%d link:up speed:%s %s-duplex %s%s%s%s%s",
41519 + val->port_vlan,
41520 + swconfig_speed_str(link.speed),
41521 + link.duplex ? "full" : "half",
41522 + link.tx_flow ? "txflow " : "",
41523 + link.rx_flow ? "rxflow " : "",
41524 + link.eee & ADVERTISED_100baseT_Full ? "eee100 " : "",
41525 + link.eee & ADVERTISED_1000baseT_Full ? "eee1000 " : "",
41526 + link.aneg ? "auto" : "");
41527 + else
41528 + len = snprintf(dev->buf, sizeof(dev->buf), "port:%d link:down",
41529 + val->port_vlan);
41531 + val->value.s = dev->buf;
41532 + val->len = len;
41534 + return 0;
41537 +static int
41538 +swconfig_apply_config(struct switch_dev *dev, const struct switch_attr *attr,
41539 + struct switch_val *val)
41541 + /* don't complain if not supported by the switch driver */
41542 + if (!dev->ops->apply_config)
41543 + return 0;
41545 + return dev->ops->apply_config(dev);
41548 +static int
41549 +swconfig_reset_switch(struct switch_dev *dev, const struct switch_attr *attr,
41550 + struct switch_val *val)
41552 + /* don't complain if not supported by the switch driver */
41553 + if (!dev->ops->reset_switch)
41554 + return 0;
41556 + return dev->ops->reset_switch(dev);
41559 +enum global_defaults {
41560 + GLOBAL_APPLY,
41561 + GLOBAL_RESET,
41564 +enum vlan_defaults {
41565 + VLAN_PORTS,
41568 +enum port_defaults {
41569 + PORT_PVID,
41570 + PORT_LINK,
41573 +static struct switch_attr default_global[] = {
41574 + [GLOBAL_APPLY] = {
41575 + .type = SWITCH_TYPE_NOVAL,
41576 + .name = "apply",
41577 + .description = "Activate changes in the hardware",
41578 + .set = swconfig_apply_config,
41579 + },
41580 + [GLOBAL_RESET] = {
41581 + .type = SWITCH_TYPE_NOVAL,
41582 + .name = "reset",
41583 + .description = "Reset the switch",
41584 + .set = swconfig_reset_switch,
41588 +static struct switch_attr default_port[] = {
41589 + [PORT_PVID] = {
41590 + .type = SWITCH_TYPE_INT,
41591 + .name = "pvid",
41592 + .description = "Primary VLAN ID",
41593 + .set = swconfig_set_pvid,
41594 + .get = swconfig_get_pvid,
41595 + },
41596 + [PORT_LINK] = {
41597 + .type = SWITCH_TYPE_STRING,
41598 + .name = "link",
41599 + .description = "Get port link information",
41600 + .set = NULL,
41601 + .get = swconfig_get_link,
41605 +static struct switch_attr default_vlan[] = {
41606 + [VLAN_PORTS] = {
41607 + .type = SWITCH_TYPE_PORTS,
41608 + .name = "ports",
41609 + .description = "VLAN port mapping",
41610 + .set = swconfig_set_vlan_ports,
41611 + .get = swconfig_get_vlan_ports,
41612 + },
41615 +static const struct switch_attr *
41616 +swconfig_find_attr_by_name(const struct switch_attrlist *alist,
41617 + const char *name)
41619 + int i;
41621 + for (i = 0; i < alist->n_attr; i++)
41622 + if (strcmp(name, alist->attr[i].name) == 0)
41623 + return &alist->attr[i];
41625 + return NULL;
41628 +static void swconfig_defaults_init(struct switch_dev *dev)
41630 + const struct switch_dev_ops *ops = dev->ops;
41632 + dev->def_global = 0;
41633 + dev->def_vlan = 0;
41634 + dev->def_port = 0;
41636 + if (ops->get_vlan_ports || ops->set_vlan_ports)
41637 + set_bit(VLAN_PORTS, &dev->def_vlan);
41639 + if (ops->get_port_pvid || ops->set_port_pvid)
41640 + set_bit(PORT_PVID, &dev->def_port);
41642 + if (ops->get_port_link &&
41643 + !swconfig_find_attr_by_name(&ops->attr_port, "link"))
41644 + set_bit(PORT_LINK, &dev->def_port);
41646 + /* always present, can be no-op */
41647 + set_bit(GLOBAL_APPLY, &dev->def_global);
41648 + set_bit(GLOBAL_RESET, &dev->def_global);
41652 +static struct genl_family switch_fam = {
41653 + .id = GENL_ID_GENERATE,
41654 + .name = "switch",
41655 + .hdrsize = 0,
41656 + .version = 1,
41657 + .maxattr = SWITCH_ATTR_MAX,
41660 +static const struct nla_policy switch_policy[SWITCH_ATTR_MAX+1] = {
41661 + [SWITCH_ATTR_ID] = { .type = NLA_U32 },
41662 + [SWITCH_ATTR_OP_ID] = { .type = NLA_U32 },
41663 + [SWITCH_ATTR_OP_PORT] = { .type = NLA_U32 },
41664 + [SWITCH_ATTR_OP_VLAN] = { .type = NLA_U32 },
41665 + [SWITCH_ATTR_OP_VALUE_INT] = { .type = NLA_U32 },
41666 + [SWITCH_ATTR_OP_VALUE_STR] = { .type = NLA_NUL_STRING },
41667 + [SWITCH_ATTR_OP_VALUE_PORTS] = { .type = NLA_NESTED },
41668 + [SWITCH_ATTR_TYPE] = { .type = NLA_U32 },
41671 +static const struct nla_policy port_policy[SWITCH_PORT_ATTR_MAX+1] = {
41672 + [SWITCH_PORT_ID] = { .type = NLA_U32 },
41673 + [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG },
41676 +static inline void
41677 +swconfig_lock(void)
41679 + spin_lock(&swdevs_lock);
41682 +static inline void
41683 +swconfig_unlock(void)
41685 + spin_unlock(&swdevs_lock);
41688 +static struct switch_dev *
41689 +swconfig_get_dev(struct genl_info *info)
41691 + struct switch_dev *dev = NULL;
41692 + struct switch_dev *p;
41693 + int id;
41695 + if (!info->attrs[SWITCH_ATTR_ID])
41696 + goto done;
41698 + id = nla_get_u32(info->attrs[SWITCH_ATTR_ID]);
41699 + swconfig_lock();
41700 + list_for_each_entry(p, &swdevs, dev_list) {
41701 + if (id != p->id)
41702 + continue;
41704 + dev = p;
41705 + break;
41707 + if (dev)
41708 + mutex_lock(&dev->sw_mutex);
41709 + else
41710 + pr_debug("device %d not found\n", id);
41711 + swconfig_unlock();
41712 +done:
41713 + return dev;
41716 +static inline void
41717 +swconfig_put_dev(struct switch_dev *dev)
41719 + mutex_unlock(&dev->sw_mutex);
41722 +static int
41723 +swconfig_dump_attr(struct swconfig_callback *cb, void *arg)
41725 + struct switch_attr *op = arg;
41726 + struct genl_info *info = cb->info;
41727 + struct sk_buff *msg = cb->msg;
41728 + int id = cb->args[0];
41729 + void *hdr;
41731 + hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam,
41732 + NLM_F_MULTI, SWITCH_CMD_NEW_ATTR);
41733 + if (IS_ERR(hdr))
41734 + return -1;
41736 + if (nla_put_u32(msg, SWITCH_ATTR_OP_ID, id))
41737 + goto nla_put_failure;
41738 + if (nla_put_u32(msg, SWITCH_ATTR_OP_TYPE, op->type))
41739 + goto nla_put_failure;
41740 + if (nla_put_string(msg, SWITCH_ATTR_OP_NAME, op->name))
41741 + goto nla_put_failure;
41742 + if (op->description)
41743 + if (nla_put_string(msg, SWITCH_ATTR_OP_DESCRIPTION,
41744 + op->description))
41745 + goto nla_put_failure;
41747 + genlmsg_end(msg, hdr);
41748 + return msg->len;
41749 +nla_put_failure:
41750 + genlmsg_cancel(msg, hdr);
41751 + return -EMSGSIZE;
41754 +/* spread multipart messages across multiple message buffers */
41755 +static int
41756 +swconfig_send_multipart(struct swconfig_callback *cb, void *arg)
41758 + struct genl_info *info = cb->info;
41759 + int restart = 0;
41760 + int err;
41762 + do {
41763 + if (!cb->msg) {
41764 + cb->msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
41765 + if (cb->msg == NULL)
41766 + goto error;
41769 + if (!(cb->fill(cb, arg) < 0))
41770 + break;
41772 + /* fill failed, check if this was already the second attempt */
41773 + if (restart)
41774 + goto error;
41776 + /* try again in a new message, send the current one */
41777 + restart = 1;
41778 + if (cb->close) {
41779 + if (cb->close(cb, arg) < 0)
41780 + goto error;
41782 + err = genlmsg_reply(cb->msg, info);
41783 + cb->msg = NULL;
41784 + if (err < 0)
41785 + goto error;
41787 + } while (restart);
41789 + return 0;
41791 +error:
41792 + if (cb->msg)
41793 + nlmsg_free(cb->msg);
41794 + return -1;
41797 +static int
41798 +swconfig_list_attrs(struct sk_buff *skb, struct genl_info *info)
41800 + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
41801 + const struct switch_attrlist *alist;
41802 + struct switch_dev *dev;
41803 + struct swconfig_callback cb;
41804 + int err = -EINVAL;
41805 + int i;
41807 + /* defaults */
41808 + struct switch_attr *def_list;
41809 + unsigned long *def_active;
41810 + int n_def;
41812 + dev = swconfig_get_dev(info);
41813 + if (!dev)
41814 + return -EINVAL;
41816 + switch (hdr->cmd) {
41817 + case SWITCH_CMD_LIST_GLOBAL:
41818 + alist = &dev->ops->attr_global;
41819 + def_list = default_global;
41820 + def_active = &dev->def_global;
41821 + n_def = ARRAY_SIZE(default_global);
41822 + break;
41823 + case SWITCH_CMD_LIST_VLAN:
41824 + alist = &dev->ops->attr_vlan;
41825 + def_list = default_vlan;
41826 + def_active = &dev->def_vlan;
41827 + n_def = ARRAY_SIZE(default_vlan);
41828 + break;
41829 + case SWITCH_CMD_LIST_PORT:
41830 + alist = &dev->ops->attr_port;
41831 + def_list = default_port;
41832 + def_active = &dev->def_port;
41833 + n_def = ARRAY_SIZE(default_port);
41834 + break;
41835 + default:
41836 + WARN_ON(1);
41837 + goto out;
41840 + memset(&cb, 0, sizeof(cb));
41841 + cb.info = info;
41842 + cb.fill = swconfig_dump_attr;
41843 + for (i = 0; i < alist->n_attr; i++) {
41844 + if (alist->attr[i].disabled)
41845 + continue;
41846 + cb.args[0] = i;
41847 + err = swconfig_send_multipart(&cb, (void *) &alist->attr[i]);
41848 + if (err < 0)
41849 + goto error;
41852 + /* defaults */
41853 + for (i = 0; i < n_def; i++) {
41854 + if (!test_bit(i, def_active))
41855 + continue;
41856 + cb.args[0] = SWITCH_ATTR_DEFAULTS_OFFSET + i;
41857 + err = swconfig_send_multipart(&cb, (void *) &def_list[i]);
41858 + if (err < 0)
41859 + goto error;
41861 + swconfig_put_dev(dev);
41863 + if (!cb.msg)
41864 + return 0;
41866 + return genlmsg_reply(cb.msg, info);
41868 +error:
41869 + if (cb.msg)
41870 + nlmsg_free(cb.msg);
41871 +out:
41872 + swconfig_put_dev(dev);
41873 + return err;
41876 +static const struct switch_attr *
41877 +swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
41878 + struct switch_val *val)
41880 + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
41881 + const struct switch_attrlist *alist;
41882 + const struct switch_attr *attr = NULL;
41883 + int attr_id;
41885 + /* defaults */
41886 + struct switch_attr *def_list;
41887 + unsigned long *def_active;
41888 + int n_def;
41890 + if (!info->attrs[SWITCH_ATTR_OP_ID])
41891 + goto done;
41893 + switch (hdr->cmd) {
41894 + case SWITCH_CMD_SET_GLOBAL:
41895 + case SWITCH_CMD_GET_GLOBAL:
41896 + alist = &dev->ops->attr_global;
41897 + def_list = default_global;
41898 + def_active = &dev->def_global;
41899 + n_def = ARRAY_SIZE(default_global);
41900 + break;
41901 + case SWITCH_CMD_SET_VLAN:
41902 + case SWITCH_CMD_GET_VLAN:
41903 + alist = &dev->ops->attr_vlan;
41904 + def_list = default_vlan;
41905 + def_active = &dev->def_vlan;
41906 + n_def = ARRAY_SIZE(default_vlan);
41907 + if (!info->attrs[SWITCH_ATTR_OP_VLAN])
41908 + goto done;
41909 + val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]);
41910 + if (val->port_vlan >= dev->vlans)
41911 + goto done;
41912 + break;
41913 + case SWITCH_CMD_SET_PORT:
41914 + case SWITCH_CMD_GET_PORT:
41915 + alist = &dev->ops->attr_port;
41916 + def_list = default_port;
41917 + def_active = &dev->def_port;
41918 + n_def = ARRAY_SIZE(default_port);
41919 + if (!info->attrs[SWITCH_ATTR_OP_PORT])
41920 + goto done;
41921 + val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]);
41922 + if (val->port_vlan >= dev->ports)
41923 + goto done;
41924 + break;
41925 + default:
41926 + WARN_ON(1);
41927 + goto done;
41930 + if (!alist)
41931 + goto done;
41933 + attr_id = nla_get_u32(info->attrs[SWITCH_ATTR_OP_ID]);
41934 + if (attr_id >= SWITCH_ATTR_DEFAULTS_OFFSET) {
41935 + attr_id -= SWITCH_ATTR_DEFAULTS_OFFSET;
41936 + if (attr_id >= n_def)
41937 + goto done;
41938 + if (!test_bit(attr_id, def_active))
41939 + goto done;
41940 + attr = &def_list[attr_id];
41941 + } else {
41942 + if (attr_id >= alist->n_attr)
41943 + goto done;
41944 + attr = &alist->attr[attr_id];
41947 + if (attr->disabled)
41948 + attr = NULL;
41950 +done:
41951 + if (!attr)
41952 + pr_debug("attribute lookup failed\n");
41953 + val->attr = attr;
41954 + return attr;
41957 +static int
41958 +swconfig_parse_ports(struct sk_buff *msg, struct nlattr *head,
41959 + struct switch_val *val, int max)
41961 + struct nlattr *nla;
41962 + int rem;
41964 + val->len = 0;
41965 + nla_for_each_nested(nla, head, rem) {
41966 + struct nlattr *tb[SWITCH_PORT_ATTR_MAX+1];
41967 + struct switch_port *port = &val->value.ports[val->len];
41969 + if (val->len >= max)
41970 + return -EINVAL;
41972 + if (nla_parse_nested(tb, SWITCH_PORT_ATTR_MAX, nla,
41973 + port_policy))
41974 + return -EINVAL;
41976 + if (!tb[SWITCH_PORT_ID])
41977 + return -EINVAL;
41979 + port->id = nla_get_u32(tb[SWITCH_PORT_ID]);
41980 + if (tb[SWITCH_PORT_FLAG_TAGGED])
41981 + port->flags |= (1 << SWITCH_PORT_FLAG_TAGGED);
41982 + val->len++;
41985 + return 0;
41988 +static int
41989 +swconfig_set_attr(struct sk_buff *skb, struct genl_info *info)
41991 + const struct switch_attr *attr;
41992 + struct switch_dev *dev;
41993 + struct switch_val val;
41994 + int err = -EINVAL;
41996 + dev = swconfig_get_dev(info);
41997 + if (!dev)
41998 + return -EINVAL;
42000 + memset(&val, 0, sizeof(val));
42001 + attr = swconfig_lookup_attr(dev, info, &val);
42002 + if (!attr || !attr->set)
42003 + goto error;
42005 + val.attr = attr;
42006 + switch (attr->type) {
42007 + case SWITCH_TYPE_NOVAL:
42008 + break;
42009 + case SWITCH_TYPE_INT:
42010 + if (!info->attrs[SWITCH_ATTR_OP_VALUE_INT])
42011 + goto error;
42012 + val.value.i =
42013 + nla_get_u32(info->attrs[SWITCH_ATTR_OP_VALUE_INT]);
42014 + break;
42015 + case SWITCH_TYPE_STRING:
42016 + if (!info->attrs[SWITCH_ATTR_OP_VALUE_STR])
42017 + goto error;
42018 + val.value.s =
42019 + nla_data(info->attrs[SWITCH_ATTR_OP_VALUE_STR]);
42020 + break;
42021 + case SWITCH_TYPE_PORTS:
42022 + val.value.ports = dev->portbuf;
42023 + memset(dev->portbuf, 0,
42024 + sizeof(struct switch_port) * dev->ports);
42026 + /* TODO: implement multipart? */
42027 + if (info->attrs[SWITCH_ATTR_OP_VALUE_PORTS]) {
42028 + err = swconfig_parse_ports(skb,
42029 + info->attrs[SWITCH_ATTR_OP_VALUE_PORTS],
42030 + &val, dev->ports);
42031 + if (err < 0)
42032 + goto error;
42033 + } else {
42034 + val.len = 0;
42035 + err = 0;
42037 + break;
42038 + default:
42039 + goto error;
42042 + err = attr->set(dev, attr, &val);
42043 +error:
42044 + swconfig_put_dev(dev);
42045 + return err;
42048 +static int
42049 +swconfig_close_portlist(struct swconfig_callback *cb, void *arg)
42051 + if (cb->nest[0])
42052 + nla_nest_end(cb->msg, cb->nest[0]);
42053 + return 0;
42056 +static int
42057 +swconfig_send_port(struct swconfig_callback *cb, void *arg)
42059 + const struct switch_port *port = arg;
42060 + struct nlattr *p = NULL;
42062 + if (!cb->nest[0]) {
42063 + cb->nest[0] = nla_nest_start(cb->msg, cb->cmd);
42064 + if (!cb->nest[0])
42065 + return -1;
42068 + p = nla_nest_start(cb->msg, SWITCH_ATTR_PORT);
42069 + if (!p)
42070 + goto error;
42072 + if (nla_put_u32(cb->msg, SWITCH_PORT_ID, port->id))
42073 + goto nla_put_failure;
42074 + if (port->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) {
42075 + if (nla_put_flag(cb->msg, SWITCH_PORT_FLAG_TAGGED))
42076 + goto nla_put_failure;
42079 + nla_nest_end(cb->msg, p);
42080 + return 0;
42082 +nla_put_failure:
42083 + nla_nest_cancel(cb->msg, p);
42084 +error:
42085 + nla_nest_cancel(cb->msg, cb->nest[0]);
42086 + return -1;
42089 +static int
42090 +swconfig_send_ports(struct sk_buff **msg, struct genl_info *info, int attr,
42091 + const struct switch_val *val)
42093 + struct swconfig_callback cb;
42094 + int err = 0;
42095 + int i;
42097 + if (!val->value.ports)
42098 + return -EINVAL;
42100 + memset(&cb, 0, sizeof(cb));
42101 + cb.cmd = attr;
42102 + cb.msg = *msg;
42103 + cb.info = info;
42104 + cb.fill = swconfig_send_port;
42105 + cb.close = swconfig_close_portlist;
42107 + cb.nest[0] = nla_nest_start(cb.msg, cb.cmd);
42108 + for (i = 0; i < val->len; i++) {
42109 + err = swconfig_send_multipart(&cb, &val->value.ports[i]);
42110 + if (err)
42111 + goto done;
42113 + err = val->len;
42114 + swconfig_close_portlist(&cb, NULL);
42115 + *msg = cb.msg;
42117 +done:
42118 + return err;
42121 +static int
42122 +swconfig_get_attr(struct sk_buff *skb, struct genl_info *info)
42124 + struct genlmsghdr *hdr = nlmsg_data(info->nlhdr);
42125 + const struct switch_attr *attr;
42126 + struct switch_dev *dev;
42127 + struct sk_buff *msg = NULL;
42128 + struct switch_val val;
42129 + int err = -EINVAL;
42130 + int cmd = hdr->cmd;
42132 + dev = swconfig_get_dev(info);
42133 + if (!dev)
42134 + return -EINVAL;
42136 + memset(&val, 0, sizeof(val));
42137 + attr = swconfig_lookup_attr(dev, info, &val);
42138 + if (!attr || !attr->get)
42139 + goto error;
42141 + if (attr->type == SWITCH_TYPE_PORTS) {
42142 + val.value.ports = dev->portbuf;
42143 + memset(dev->portbuf, 0,
42144 + sizeof(struct switch_port) * dev->ports);
42147 + err = attr->get(dev, attr, &val);
42148 + if (err)
42149 + goto error;
42151 + msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
42152 + if (!msg)
42153 + goto error;
42155 + hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, &switch_fam,
42156 + 0, cmd);
42157 + if (IS_ERR(hdr))
42158 + goto nla_put_failure;
42160 + switch (attr->type) {
42161 + case SWITCH_TYPE_INT:
42162 + if (nla_put_u32(msg, SWITCH_ATTR_OP_VALUE_INT, val.value.i))
42163 + goto nla_put_failure;
42164 + break;
42165 + case SWITCH_TYPE_STRING:
42166 + if (nla_put_string(msg, SWITCH_ATTR_OP_VALUE_STR, val.value.s))
42167 + goto nla_put_failure;
42168 + break;
42169 + case SWITCH_TYPE_PORTS:
42170 + err = swconfig_send_ports(&msg, info,
42171 + SWITCH_ATTR_OP_VALUE_PORTS, &val);
42172 + if (err < 0)
42173 + goto nla_put_failure;
42174 + break;
42175 + default:
42176 + pr_debug("invalid type in attribute\n");
42177 + err = -EINVAL;
42178 + goto error;
42180 + genlmsg_end(msg, hdr);
42181 + err = msg->len;
42182 + if (err < 0)
42183 + goto nla_put_failure;
42185 + swconfig_put_dev(dev);
42186 + return genlmsg_reply(msg, info);
42188 +nla_put_failure:
42189 + if (msg)
42190 + nlmsg_free(msg);
42191 +error:
42192 + swconfig_put_dev(dev);
42193 + if (!err)
42194 + err = -ENOMEM;
42195 + return err;
42198 +static int
42199 +swconfig_send_switch(struct sk_buff *msg, u32 pid, u32 seq, int flags,
42200 + const struct switch_dev *dev)
42202 + struct nlattr *p = NULL, *m = NULL;
42203 + void *hdr;
42204 + int i;
42206 + hdr = genlmsg_put(msg, pid, seq, &switch_fam, flags,
42207 + SWITCH_CMD_NEW_ATTR);
42208 + if (IS_ERR(hdr))
42209 + return -1;
42211 + if (nla_put_u32(msg, SWITCH_ATTR_ID, dev->id))
42212 + goto nla_put_failure;
42213 + if (nla_put_string(msg, SWITCH_ATTR_DEV_NAME, dev->devname))
42214 + goto nla_put_failure;
42215 + if (nla_put_string(msg, SWITCH_ATTR_ALIAS, dev->alias))
42216 + goto nla_put_failure;
42217 + if (nla_put_string(msg, SWITCH_ATTR_NAME, dev->name))
42218 + goto nla_put_failure;
42219 + if (nla_put_u32(msg, SWITCH_ATTR_VLANS, dev->vlans))
42220 + goto nla_put_failure;
42221 + if (nla_put_u32(msg, SWITCH_ATTR_PORTS, dev->ports))
42222 + goto nla_put_failure;
42223 + if (nla_put_u32(msg, SWITCH_ATTR_CPU_PORT, dev->cpu_port))
42224 + goto nla_put_failure;
42226 + m = nla_nest_start(msg, SWITCH_ATTR_PORTMAP);
42227 + if (!m)
42228 + goto nla_put_failure;
42229 + for (i = 0; i < dev->ports; i++) {
42230 + p = nla_nest_start(msg, SWITCH_ATTR_PORTS);
42231 + if (!p)
42232 + continue;
42233 + if (dev->portmap[i].s) {
42234 + if (nla_put_string(msg, SWITCH_PORTMAP_SEGMENT,
42235 + dev->portmap[i].s))
42236 + goto nla_put_failure;
42237 + if (nla_put_u32(msg, SWITCH_PORTMAP_VIRT,
42238 + dev->portmap[i].virt))
42239 + goto nla_put_failure;
42241 + nla_nest_end(msg, p);
42243 + nla_nest_end(msg, m);
42244 + genlmsg_end(msg, hdr);
42245 + return msg->len;
42246 +nla_put_failure:
42247 + genlmsg_cancel(msg, hdr);
42248 + return -EMSGSIZE;
42251 +static int swconfig_dump_switches(struct sk_buff *skb,
42252 + struct netlink_callback *cb)
42254 + struct switch_dev *dev;
42255 + int start = cb->args[0];
42256 + int idx = 0;
42258 + swconfig_lock();
42259 + list_for_each_entry(dev, &swdevs, dev_list) {
42260 + if (++idx <= start)
42261 + continue;
42262 + if (swconfig_send_switch(skb, NETLINK_CB(cb->skb).portid,
42263 + cb->nlh->nlmsg_seq, NLM_F_MULTI,
42264 + dev) < 0)
42265 + break;
42267 + swconfig_unlock();
42268 + cb->args[0] = idx;
42270 + return skb->len;
42273 +static int
42274 +swconfig_done(struct netlink_callback *cb)
42276 + return 0;
42279 +static struct genl_ops swconfig_ops[] = {
42281 + .cmd = SWITCH_CMD_LIST_GLOBAL,
42282 + .doit = swconfig_list_attrs,
42283 + .policy = switch_policy,
42284 + },
42286 + .cmd = SWITCH_CMD_LIST_VLAN,
42287 + .doit = swconfig_list_attrs,
42288 + .policy = switch_policy,
42289 + },
42291 + .cmd = SWITCH_CMD_LIST_PORT,
42292 + .doit = swconfig_list_attrs,
42293 + .policy = switch_policy,
42294 + },
42296 + .cmd = SWITCH_CMD_GET_GLOBAL,
42297 + .doit = swconfig_get_attr,
42298 + .policy = switch_policy,
42299 + },
42301 + .cmd = SWITCH_CMD_GET_VLAN,
42302 + .doit = swconfig_get_attr,
42303 + .policy = switch_policy,
42304 + },
42306 + .cmd = SWITCH_CMD_GET_PORT,
42307 + .doit = swconfig_get_attr,
42308 + .policy = switch_policy,
42309 + },
42311 + .cmd = SWITCH_CMD_SET_GLOBAL,
42312 + .doit = swconfig_set_attr,
42313 + .policy = switch_policy,
42314 + },
42316 + .cmd = SWITCH_CMD_SET_VLAN,
42317 + .doit = swconfig_set_attr,
42318 + .policy = switch_policy,
42319 + },
42321 + .cmd = SWITCH_CMD_SET_PORT,
42322 + .doit = swconfig_set_attr,
42323 + .policy = switch_policy,
42324 + },
42326 + .cmd = SWITCH_CMD_GET_SWITCH,
42327 + .dumpit = swconfig_dump_switches,
42328 + .policy = switch_policy,
42329 + .done = swconfig_done,
42333 +#ifdef CONFIG_OF
42334 +void
42335 +of_switch_load_portmap(struct switch_dev *dev)
42337 + struct device_node *port;
42339 + if (!dev->of_node)
42340 + return;
42342 + for_each_child_of_node(dev->of_node, port) {
42343 + const __be32 *prop;
42344 + const char *segment;
42345 + int size, phys;
42347 + if (!of_device_is_compatible(port, "swconfig,port"))
42348 + continue;
42350 + if (of_property_read_string(port, "swconfig,segment", &segment))
42351 + continue;
42353 + prop = of_get_property(port, "swconfig,portmap", &size);
42354 + if (!prop)
42355 + continue;
42357 + if (size != (2 * sizeof(*prop))) {
42358 + pr_err("%s: failed to parse port mapping\n",
42359 + port->name);
42360 + continue;
42363 + phys = be32_to_cpup(prop++);
42364 + if ((phys < 0) | (phys >= dev->ports)) {
42365 + pr_err("%s: physical port index out of range\n",
42366 + port->name);
42367 + continue;
42370 + dev->portmap[phys].s = kstrdup(segment, GFP_KERNEL);
42371 + dev->portmap[phys].virt = be32_to_cpup(prop);
42372 + pr_debug("Found port: %s, physical: %d, virtual: %d\n",
42373 + segment, phys, dev->portmap[phys].virt);
42376 +#endif
42378 +int
42379 +register_switch(struct switch_dev *dev, struct net_device *netdev)
42381 + struct switch_dev *sdev;
42382 + const int max_switches = 8 * sizeof(unsigned long);
42383 + unsigned long in_use = 0;
42384 + int err;
42385 + int i;
42387 + INIT_LIST_HEAD(&dev->dev_list);
42388 + if (netdev) {
42389 + dev->netdev = netdev;
42390 + if (!dev->alias)
42391 + dev->alias = netdev->name;
42393 + BUG_ON(!dev->alias);
42395 + if (dev->ports > 0) {
42396 + dev->portbuf = kzalloc(sizeof(struct switch_port) *
42397 + dev->ports, GFP_KERNEL);
42398 + if (!dev->portbuf)
42399 + return -ENOMEM;
42400 + dev->portmap = kzalloc(sizeof(struct switch_portmap) *
42401 + dev->ports, GFP_KERNEL);
42402 + if (!dev->portmap) {
42403 + kfree(dev->portbuf);
42404 + return -ENOMEM;
42407 + swconfig_defaults_init(dev);
42408 + mutex_init(&dev->sw_mutex);
42409 + swconfig_lock();
42410 + dev->id = ++swdev_id;
42412 + list_for_each_entry(sdev, &swdevs, dev_list) {
42413 + if (!sscanf(sdev->devname, SWCONFIG_DEVNAME, &i))
42414 + continue;
42415 + if (i < 0 || i > max_switches)
42416 + continue;
42418 + set_bit(i, &in_use);
42420 + i = find_first_zero_bit(&in_use, max_switches);
42422 + if (i == max_switches) {
42423 + swconfig_unlock();
42424 + return -ENFILE;
42427 +#ifdef CONFIG_OF
42428 + if (dev->ports)
42429 + of_switch_load_portmap(dev);
42430 +#endif
42432 + /* fill device name */
42433 + snprintf(dev->devname, IFNAMSIZ, SWCONFIG_DEVNAME, i);
42435 + list_add_tail(&dev->dev_list, &swdevs);
42436 + swconfig_unlock();
42438 + err = swconfig_create_led_trigger(dev);
42439 + if (err)
42440 + return err;
42442 + return 0;
42444 +EXPORT_SYMBOL_GPL(register_switch);
42446 +void
42447 +unregister_switch(struct switch_dev *dev)
42449 + swconfig_destroy_led_trigger(dev);
42450 + kfree(dev->portbuf);
42451 + mutex_lock(&dev->sw_mutex);
42452 + swconfig_lock();
42453 + list_del(&dev->dev_list);
42454 + swconfig_unlock();
42455 + mutex_unlock(&dev->sw_mutex);
42457 +EXPORT_SYMBOL_GPL(unregister_switch);
42460 +static int __init
42461 +swconfig_init(void)
42463 + int err;
42464 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0))
42465 + int i;
42466 +#endif
42468 + INIT_LIST_HEAD(&swdevs);
42470 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0))
42471 + err = genl_register_family(&switch_fam);
42472 + if (err)
42473 + return err;
42475 + for (i = 0; i < ARRAY_SIZE(swconfig_ops); i++) {
42476 + err = genl_register_ops(&switch_fam, &swconfig_ops[i]);
42477 + if (err)
42478 + goto unregister;
42480 + return 0;
42482 +unregister:
42483 + genl_unregister_family(&switch_fam);
42484 + return err;
42485 +#else
42486 + err = genl_register_family_with_ops(&switch_fam, swconfig_ops);
42487 + if (err)
42488 + return err;
42489 + return 0;
42490 +#endif
42493 +static void __exit
42494 +swconfig_exit(void)
42496 + genl_unregister_family(&switch_fam);
42499 +module_init(swconfig_init);
42500 +module_exit(swconfig_exit);
42502 diff -Nur linux-4.1.43.orig/drivers/net/phy/swconfig_leds.c linux-4.1.43/drivers/net/phy/swconfig_leds.c
42503 --- linux-4.1.43.orig/drivers/net/phy/swconfig_leds.c 1970-01-01 01:00:00.000000000 +0100
42504 +++ linux-4.1.43/drivers/net/phy/swconfig_leds.c 2017-08-06 20:02:16.000000000 +0200
42505 @@ -0,0 +1,354 @@
42507 + * swconfig_led.c: LED trigger support for the switch configuration API
42509 + * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
42511 + * This program is free software; you can redistribute it and/or
42512 + * modify it under the terms of the GNU General Public License
42513 + * as published by the Free Software Foundation; either version 2
42514 + * of the License, or (at your option) any later version.
42516 + */
42518 +#ifdef CONFIG_SWCONFIG_LEDS
42520 +#include <linux/leds.h>
42521 +#include <linux/ctype.h>
42522 +#include <linux/device.h>
42523 +#include <linux/workqueue.h>
42525 +#define SWCONFIG_LED_TIMER_INTERVAL (HZ / 10)
42526 +#define SWCONFIG_LED_NUM_PORTS 32
42528 +struct switch_led_trigger {
42529 + struct led_trigger trig;
42530 + struct switch_dev *swdev;
42532 + struct delayed_work sw_led_work;
42533 + u32 port_mask;
42534 + u32 port_link;
42535 + unsigned long port_traffic[SWCONFIG_LED_NUM_PORTS];
42538 +struct swconfig_trig_data {
42539 + struct led_classdev *led_cdev;
42540 + struct switch_dev *swdev;
42542 + rwlock_t lock;
42543 + u32 port_mask;
42545 + bool prev_link;
42546 + unsigned long prev_traffic;
42547 + enum led_brightness prev_brightness;
42550 +static void
42551 +swconfig_trig_set_brightness(struct swconfig_trig_data *trig_data,
42552 + enum led_brightness brightness)
42554 + led_set_brightness(trig_data->led_cdev, brightness);
42555 + trig_data->prev_brightness = brightness;
42558 +static void
42559 +swconfig_trig_update_port_mask(struct led_trigger *trigger)
42561 + struct list_head *entry;
42562 + struct switch_led_trigger *sw_trig;
42563 + u32 port_mask;
42565 + if (!trigger)
42566 + return;
42568 + sw_trig = (void *) trigger;
42570 + port_mask = 0;
42571 + read_lock(&trigger->leddev_list_lock);
42572 + list_for_each(entry, &trigger->led_cdevs) {
42573 + struct led_classdev *led_cdev;
42574 + struct swconfig_trig_data *trig_data;
42576 + led_cdev = list_entry(entry, struct led_classdev, trig_list);
42577 + trig_data = led_cdev->trigger_data;
42578 + if (trig_data) {
42579 + read_lock(&trig_data->lock);
42580 + port_mask |= trig_data->port_mask;
42581 + read_unlock(&trig_data->lock);
42584 + read_unlock(&trigger->leddev_list_lock);
42586 + sw_trig->port_mask = port_mask;
42588 + if (port_mask)
42589 + schedule_delayed_work(&sw_trig->sw_led_work,
42590 + SWCONFIG_LED_TIMER_INTERVAL);
42591 + else
42592 + cancel_delayed_work_sync(&sw_trig->sw_led_work);
42595 +static ssize_t
42596 +swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr,
42597 + const char *buf, size_t size)
42599 + struct led_classdev *led_cdev = dev_get_drvdata(dev);
42600 + struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
42601 + unsigned long port_mask;
42602 + ssize_t ret = -EINVAL;
42603 + char *after;
42604 + size_t count;
42606 + port_mask = simple_strtoul(buf, &after, 16);
42607 + count = after - buf;
42609 + if (*after && isspace(*after))
42610 + count++;
42612 + if (count == size) {
42613 + bool changed;
42615 + write_lock(&trig_data->lock);
42617 + changed = (trig_data->port_mask != port_mask);
42618 + if (changed) {
42619 + trig_data->port_mask = port_mask;
42620 + if (port_mask == 0)
42621 + swconfig_trig_set_brightness(trig_data, LED_OFF);
42624 + write_unlock(&trig_data->lock);
42626 + if (changed)
42627 + swconfig_trig_update_port_mask(led_cdev->trigger);
42629 + ret = count;
42632 + return ret;
42635 +static ssize_t
42636 +swconfig_trig_port_mask_show(struct device *dev, struct device_attribute *attr,
42637 + char *buf)
42639 + struct led_classdev *led_cdev = dev_get_drvdata(dev);
42640 + struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
42642 + read_lock(&trig_data->lock);
42643 + sprintf(buf, "%#x\n", trig_data->port_mask);
42644 + read_unlock(&trig_data->lock);
42646 + return strlen(buf) + 1;
42649 +static DEVICE_ATTR(port_mask, 0644, swconfig_trig_port_mask_show,
42650 + swconfig_trig_port_mask_store);
42652 +static void
42653 +swconfig_trig_activate(struct led_classdev *led_cdev)
42655 + struct switch_led_trigger *sw_trig;
42656 + struct swconfig_trig_data *trig_data;
42657 + int err;
42659 + if (led_cdev->trigger->activate != swconfig_trig_activate)
42660 + return;
42662 + trig_data = kzalloc(sizeof(struct swconfig_trig_data), GFP_KERNEL);
42663 + if (!trig_data)
42664 + return;
42666 + sw_trig = (void *) led_cdev->trigger;
42668 + rwlock_init(&trig_data->lock);
42669 + trig_data->led_cdev = led_cdev;
42670 + trig_data->swdev = sw_trig->swdev;
42671 + led_cdev->trigger_data = trig_data;
42673 + err = device_create_file(led_cdev->dev, &dev_attr_port_mask);
42674 + if (err)
42675 + goto err_free;
42677 + return;
42679 +err_free:
42680 + led_cdev->trigger_data = NULL;
42681 + kfree(trig_data);
42684 +static void
42685 +swconfig_trig_deactivate(struct led_classdev *led_cdev)
42687 + struct swconfig_trig_data *trig_data;
42689 + swconfig_trig_update_port_mask(led_cdev->trigger);
42691 + trig_data = (void *) led_cdev->trigger_data;
42692 + if (trig_data) {
42693 + device_remove_file(led_cdev->dev, &dev_attr_port_mask);
42694 + kfree(trig_data);
42698 +static void
42699 +swconfig_trig_led_event(struct switch_led_trigger *sw_trig,
42700 + struct led_classdev *led_cdev)
42702 + struct swconfig_trig_data *trig_data;
42703 + u32 port_mask;
42704 + bool link;
42706 + trig_data = led_cdev->trigger_data;
42707 + if (!trig_data)
42708 + return;
42710 + read_lock(&trig_data->lock);
42711 + port_mask = trig_data->port_mask;
42712 + read_unlock(&trig_data->lock);
42714 + link = !!(sw_trig->port_link & port_mask);
42715 + if (!link) {
42716 + if (link != trig_data->prev_link)
42717 + swconfig_trig_set_brightness(trig_data, LED_OFF);
42718 + } else {
42719 + unsigned long traffic;
42720 + int i;
42722 + traffic = 0;
42723 + for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) {
42724 + if (port_mask & (1 << i))
42725 + traffic += sw_trig->port_traffic[i];
42728 + if (trig_data->prev_brightness != LED_FULL)
42729 + swconfig_trig_set_brightness(trig_data, LED_FULL);
42730 + else if (traffic != trig_data->prev_traffic)
42731 + swconfig_trig_set_brightness(trig_data, LED_OFF);
42733 + trig_data->prev_traffic = traffic;
42736 + trig_data->prev_link = link;
42739 +static void
42740 +swconfig_trig_update_leds(struct switch_led_trigger *sw_trig)
42742 + struct list_head *entry;
42743 + struct led_trigger *trigger;
42745 + trigger = &sw_trig->trig;
42746 + read_lock(&trigger->leddev_list_lock);
42747 + list_for_each(entry, &trigger->led_cdevs) {
42748 + struct led_classdev *led_cdev;
42750 + led_cdev = list_entry(entry, struct led_classdev, trig_list);
42751 + swconfig_trig_led_event(sw_trig, led_cdev);
42753 + read_unlock(&trigger->leddev_list_lock);
42756 +static void
42757 +swconfig_led_work_func(struct work_struct *work)
42759 + struct switch_led_trigger *sw_trig;
42760 + struct switch_dev *swdev;
42761 + u32 port_mask;
42762 + u32 link;
42763 + int i;
42765 + sw_trig = container_of(work, struct switch_led_trigger,
42766 + sw_led_work.work);
42768 + port_mask = sw_trig->port_mask;
42769 + swdev = sw_trig->swdev;
42771 + link = 0;
42772 + for (i = 0; i < SWCONFIG_LED_NUM_PORTS; i++) {
42773 + u32 port_bit;
42775 + port_bit = BIT(i);
42776 + if ((port_mask & port_bit) == 0)
42777 + continue;
42779 + if (swdev->ops->get_port_link) {
42780 + struct switch_port_link port_link;
42782 + memset(&port_link, '\0', sizeof(port_link));
42783 + swdev->ops->get_port_link(swdev, i, &port_link);
42785 + if (port_link.link)
42786 + link |= port_bit;
42789 + if (swdev->ops->get_port_stats) {
42790 + struct switch_port_stats port_stats;
42792 + memset(&port_stats, '\0', sizeof(port_stats));
42793 + swdev->ops->get_port_stats(swdev, i, &port_stats);
42794 + sw_trig->port_traffic[i] = port_stats.tx_bytes +
42795 + port_stats.rx_bytes;
42799 + sw_trig->port_link = link;
42801 + swconfig_trig_update_leds(sw_trig);
42803 + schedule_delayed_work(&sw_trig->sw_led_work,
42804 + SWCONFIG_LED_TIMER_INTERVAL);
42807 +static int
42808 +swconfig_create_led_trigger(struct switch_dev *swdev)
42810 + struct switch_led_trigger *sw_trig;
42811 + int err;
42813 + if (!swdev->ops->get_port_link)
42814 + return 0;
42816 + sw_trig = kzalloc(sizeof(struct switch_led_trigger), GFP_KERNEL);
42817 + if (!sw_trig)
42818 + return -ENOMEM;
42820 + sw_trig->swdev = swdev;
42821 + sw_trig->trig.name = swdev->devname;
42822 + sw_trig->trig.activate = swconfig_trig_activate;
42823 + sw_trig->trig.deactivate = swconfig_trig_deactivate;
42825 + INIT_DELAYED_WORK(&sw_trig->sw_led_work, swconfig_led_work_func);
42827 + err = led_trigger_register(&sw_trig->trig);
42828 + if (err)
42829 + goto err_free;
42831 + swdev->led_trigger = sw_trig;
42833 + return 0;
42835 +err_free:
42836 + kfree(sw_trig);
42837 + return err;
42840 +static void
42841 +swconfig_destroy_led_trigger(struct switch_dev *swdev)
42843 + struct switch_led_trigger *sw_trig;
42845 + sw_trig = swdev->led_trigger;
42846 + if (sw_trig) {
42847 + cancel_delayed_work_sync(&sw_trig->sw_led_work);
42848 + led_trigger_unregister(&sw_trig->trig);
42849 + kfree(sw_trig);
42853 +#else /* SWCONFIG_LEDS */
42854 +static inline int
42855 +swconfig_create_led_trigger(struct switch_dev *swdev) { return 0; }
42857 +static inline void
42858 +swconfig_destroy_led_trigger(struct switch_dev *swdev) { }
42859 +#endif /* CONFIG_SWCONFIG_LEDS */
42860 diff -Nur linux-4.1.43.orig/drivers/spi/Kconfig linux-4.1.43/drivers/spi/Kconfig
42861 --- linux-4.1.43.orig/drivers/spi/Kconfig 2017-08-06 01:56:14.000000000 +0200
42862 +++ linux-4.1.43/drivers/spi/Kconfig 2017-08-06 20:02:16.000000000 +0200
42863 @@ -59,6 +59,14 @@
42864 help
42865 This is the driver for the Altera SPI Controller.
42867 +config SPI_AP83
42868 + tristate "Atheros AP83 specific SPI Controller"
42869 + depends on SPI_MASTER && ATH79_MACH_AP83
42870 + select SPI_BITBANG
42871 + help
42872 + This is a specific SPI controller driver for the Atheros AP83
42873 + reference board.
42875 config SPI_ATH79
42876 tristate "Atheros AR71XX/AR724X/AR913X SPI controller driver"
42877 depends on ATH79 && GPIOLIB
42878 @@ -448,6 +456,12 @@
42879 This driver can also be built as a module. If so, the module
42880 will be called spi_qup.
42882 +config SPI_RB4XX
42883 + tristate "Mikrotik RB4XX SPI master"
42884 + depends on SPI_MASTER && ATH79_MACH_RB4XX
42885 + help
42886 + SPI controller driver for the Mikrotik RB4xx series boards.
42888 config SPI_S3C24XX
42889 tristate "Samsung S3C24XX series SPI"
42890 depends on ARCH_S3C24XX
42891 @@ -661,6 +675,18 @@
42892 sysfs interface, with each line presented as a kind of GPIO
42893 exposing both switch control and diagnostic feedback.
42895 +config SPI_RB4XX_CPLD
42896 + tristate "MikroTik RB4XX CPLD driver"
42897 + depends on ATH79_MACH_RB4XX
42898 + help
42899 + SPI driver for the Xilinx CPLD chip present on the
42900 + MikroTik RB4xx boards.
42902 +config SPI_VSC7385
42903 + tristate "Vitesse VSC7385 ethernet switch driver"
42904 + help
42905 + SPI driver for the Vitesse VSC7385 ethernet switch.
42908 # Add new SPI protocol masters in alphabetical order above this line
42910 diff -Nur linux-4.1.43.orig/drivers/spi/Makefile linux-4.1.43/drivers/spi/Makefile
42911 --- linux-4.1.43.orig/drivers/spi/Makefile 2017-08-06 01:56:14.000000000 +0200
42912 +++ linux-4.1.43/drivers/spi/Makefile 2017-08-06 20:02:16.000000000 +0200
42913 @@ -12,6 +12,7 @@
42914 # SPI master controller drivers (bus)
42915 obj-$(CONFIG_SPI_ALTERA) += spi-altera.o
42916 obj-$(CONFIG_SPI_ATMEL) += spi-atmel.o
42917 +obj-$(CONFIG_SPI_AP83) += spi-ap83.o
42918 obj-$(CONFIG_SPI_ATH79) += spi-ath79.o
42919 obj-$(CONFIG_SPI_AU1550) += spi-au1550.o
42920 obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o
42921 @@ -64,6 +65,8 @@
42922 spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_DMA) += spi-pxa2xx-dma.o
42923 obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-platform.o
42924 obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o
42925 +obj-$(CONFIG_SPI_RB4XX) += spi-rb4xx.o
42926 +obj-$(CONFIG_SPI_RB4XX_CPLD) += spi-rb4xx-cpld.o
42927 obj-$(CONFIG_SPI_QUP) += spi-qup.o
42928 obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o
42929 obj-$(CONFIG_SPI_RSPI) += spi-rspi.o
42930 @@ -86,6 +89,7 @@
42931 obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o
42932 obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o
42933 obj-$(CONFIG_SPI_TXX9) += spi-txx9.o
42934 +obj-$(CONFIG_SPI_VSC7385) += spi-vsc7385.o
42935 obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o
42936 obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o
42937 obj-$(CONFIG_SPI_XTENSA_XTFPGA) += spi-xtensa-xtfpga.o
42938 diff -Nur linux-4.1.43.orig/drivers/spi/spi-ap83.c linux-4.1.43/drivers/spi/spi-ap83.c
42939 --- linux-4.1.43.orig/drivers/spi/spi-ap83.c 1970-01-01 01:00:00.000000000 +0100
42940 +++ linux-4.1.43/drivers/spi/spi-ap83.c 2017-08-06 20:02:16.000000000 +0200
42941 @@ -0,0 +1,283 @@
42943 + * Atheros AP83 board specific SPI Controller driver
42945 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
42947 + * This program is free software; you can redistribute it and/or modify
42948 + * it under the terms of the GNU General Public License version 2 as
42949 + * published by the Free Software Foundation.
42951 + */
42953 +#include <linux/kernel.h>
42954 +#include <linux/module.h>
42955 +#include <linux/init.h>
42956 +#include <linux/delay.h>
42957 +#include <linux/spinlock.h>
42958 +#include <linux/workqueue.h>
42959 +#include <linux/platform_device.h>
42960 +#include <linux/io.h>
42961 +#include <linux/spi/spi.h>
42962 +#include <linux/spi/spi_bitbang.h>
42963 +#include <linux/bitops.h>
42964 +#include <linux/gpio.h>
42966 +#include <asm/mach-ath79/ath79.h>
42968 +#define DRV_DESC "Atheros AP83 board SPI Controller driver"
42969 +#define DRV_VERSION "0.1.0"
42970 +#define DRV_NAME "ap83-spi"
42972 +#define AP83_SPI_CLK_HIGH (1 << 23)
42973 +#define AP83_SPI_CLK_LOW 0
42974 +#define AP83_SPI_MOSI_HIGH (1 << 22)
42975 +#define AP83_SPI_MOSI_LOW 0
42977 +#define AP83_SPI_GPIO_CS 1
42978 +#define AP83_SPI_GPIO_MISO 3
42980 +struct ap83_spi {
42981 + struct spi_bitbang bitbang;
42982 + void __iomem *base;
42983 + u32 addr;
42985 + struct platform_device *pdev;
42988 +static inline u32 ap83_spi_rr(struct ap83_spi *sp, u32 reg)
42990 + return __raw_readl(sp->base + reg);
42993 +static inline struct ap83_spi *spidev_to_sp(struct spi_device *spi)
42995 + return spi_master_get_devdata(spi->master);
42998 +static inline void setsck(struct spi_device *spi, int val)
43000 + struct ap83_spi *sp = spidev_to_sp(spi);
43002 + if (val)
43003 + sp->addr |= AP83_SPI_CLK_HIGH;
43004 + else
43005 + sp->addr &= ~AP83_SPI_CLK_HIGH;
43007 + dev_dbg(&spi->dev, "addr=%08x, SCK set to %s\n",
43008 + sp->addr, (val) ? "HIGH" : "LOW");
43010 + ap83_spi_rr(sp, sp->addr);
43013 +static inline void setmosi(struct spi_device *spi, int val)
43015 + struct ap83_spi *sp = spidev_to_sp(spi);
43017 + if (val)
43018 + sp->addr |= AP83_SPI_MOSI_HIGH;
43019 + else
43020 + sp->addr &= ~AP83_SPI_MOSI_HIGH;
43022 + dev_dbg(&spi->dev, "addr=%08x, MOSI set to %s\n",
43023 + sp->addr, (val) ? "HIGH" : "LOW");
43025 + ap83_spi_rr(sp, sp->addr);
43028 +static inline u32 getmiso(struct spi_device *spi)
43030 + u32 ret;
43032 + ret = gpio_get_value(AP83_SPI_GPIO_MISO) ? 1 : 0;
43033 + dev_dbg(&spi->dev, "get MISO: %d\n", ret);
43035 + return ret;
43038 +static inline void do_spidelay(struct spi_device *spi, unsigned nsecs)
43040 + ndelay(nsecs);
43043 +static void ap83_spi_chipselect(struct spi_device *spi, int on)
43045 + struct ap83_spi *sp = spidev_to_sp(spi);
43047 + dev_dbg(&spi->dev, "set CS to %d\n", (on) ? 0 : 1);
43049 + if (on) {
43050 + ath79_flash_acquire();
43052 + sp->addr = 0;
43053 + ap83_spi_rr(sp, sp->addr);
43055 + gpio_set_value(AP83_SPI_GPIO_CS, 0);
43056 + } else {
43057 + gpio_set_value(AP83_SPI_GPIO_CS, 1);
43058 + ath79_flash_release();
43062 +#define spidelay(nsecs) \
43063 + do { \
43064 + /* Steal the spi_device pointer from our caller. \
43065 + * The bitbang-API should probably get fixed here... */ \
43066 + do_spidelay(spi, nsecs); \
43067 + } while (0)
43069 +#define EXPAND_BITBANG_TXRX
43070 +#include <linux/spi/spi_bitbang.h>
43071 +#include "spi-bitbang-txrx.h"
43073 +static u32 ap83_spi_txrx_mode0(struct spi_device *spi,
43074 + unsigned nsecs, u32 word, u8 bits)
43076 + dev_dbg(&spi->dev, "TXRX0 word=%08x, bits=%u\n", word, bits);
43077 + return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
43080 +static u32 ap83_spi_txrx_mode1(struct spi_device *spi,
43081 + unsigned nsecs, u32 word, u8 bits)
43083 + dev_dbg(&spi->dev, "TXRX1 word=%08x, bits=%u\n", word, bits);
43084 + return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
43087 +static u32 ap83_spi_txrx_mode2(struct spi_device *spi,
43088 + unsigned nsecs, u32 word, u8 bits)
43090 + dev_dbg(&spi->dev, "TXRX2 word=%08x, bits=%u\n", word, bits);
43091 + return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
43094 +static u32 ap83_spi_txrx_mode3(struct spi_device *spi,
43095 + unsigned nsecs, u32 word, u8 bits)
43097 + dev_dbg(&spi->dev, "TXRX3 word=%08x, bits=%u\n", word, bits);
43098 + return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
43101 +static int ap83_spi_probe(struct platform_device *pdev)
43103 + struct spi_master *master;
43104 + struct ap83_spi *sp;
43105 + struct ap83_spi_platform_data *pdata;
43106 + struct resource *r;
43107 + int ret;
43109 + ret = gpio_request(AP83_SPI_GPIO_MISO, "spi-miso");
43110 + if (ret) {
43111 + dev_err(&pdev->dev, "gpio request failed for MISO\n");
43112 + return ret;
43115 + ret = gpio_request(AP83_SPI_GPIO_CS, "spi-cs");
43116 + if (ret) {
43117 + dev_err(&pdev->dev, "gpio request failed for CS\n");
43118 + goto err_free_miso;
43121 + ret = gpio_direction_input(AP83_SPI_GPIO_MISO);
43122 + if (ret) {
43123 + dev_err(&pdev->dev, "unable to set direction of MISO\n");
43124 + goto err_free_cs;
43127 + ret = gpio_direction_output(AP83_SPI_GPIO_CS, 0);
43128 + if (ret) {
43129 + dev_err(&pdev->dev, "unable to set direction of CS\n");
43130 + goto err_free_cs;
43133 + master = spi_alloc_master(&pdev->dev, sizeof(*sp));
43134 + if (master == NULL) {
43135 + dev_err(&pdev->dev, "failed to allocate spi master\n");
43136 + return -ENOMEM;
43139 + sp = spi_master_get_devdata(master);
43140 + platform_set_drvdata(pdev, sp);
43142 + pdata = pdev->dev.platform_data;
43144 + sp->bitbang.master = spi_master_get(master);
43145 + sp->bitbang.chipselect = ap83_spi_chipselect;
43146 + sp->bitbang.txrx_word[SPI_MODE_0] = ap83_spi_txrx_mode0;
43147 + sp->bitbang.txrx_word[SPI_MODE_1] = ap83_spi_txrx_mode1;
43148 + sp->bitbang.txrx_word[SPI_MODE_2] = ap83_spi_txrx_mode2;
43149 + sp->bitbang.txrx_word[SPI_MODE_3] = ap83_spi_txrx_mode3;
43151 + sp->bitbang.master->bus_num = pdev->id;
43152 + sp->bitbang.master->num_chipselect = 1;
43154 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43155 + if (r == NULL) {
43156 + ret = -ENOENT;
43157 + goto err_spi_put;
43160 + sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
43161 + if (!sp->base) {
43162 + ret = -ENXIO;
43163 + goto err_spi_put;
43166 + ret = spi_bitbang_start(&sp->bitbang);
43167 + if (!ret)
43168 + goto err_unmap;
43170 + dev_info(&pdev->dev, "AP83 SPI adapter at %08x\n", r->start);
43172 + return 0;
43174 +err_unmap:
43175 + iounmap(sp->base);
43176 +err_spi_put:
43177 + platform_set_drvdata(pdev, NULL);
43178 + spi_master_put(sp->bitbang.master);
43180 +err_free_cs:
43181 + gpio_free(AP83_SPI_GPIO_CS);
43182 +err_free_miso:
43183 + gpio_free(AP83_SPI_GPIO_MISO);
43184 + return ret;
43187 +static int ap83_spi_remove(struct platform_device *pdev)
43189 + struct ap83_spi *sp = platform_get_drvdata(pdev);
43191 + spi_bitbang_stop(&sp->bitbang);
43192 + iounmap(sp->base);
43193 + platform_set_drvdata(pdev, NULL);
43194 + spi_master_put(sp->bitbang.master);
43196 + return 0;
43199 +static struct platform_driver ap83_spi_drv = {
43200 + .probe = ap83_spi_probe,
43201 + .remove = ap83_spi_remove,
43202 + .driver = {
43203 + .name = DRV_NAME,
43204 + .owner = THIS_MODULE,
43205 + },
43208 +static int __init ap83_spi_init(void)
43210 + return platform_driver_register(&ap83_spi_drv);
43212 +module_init(ap83_spi_init);
43214 +static void __exit ap83_spi_exit(void)
43216 + platform_driver_unregister(&ap83_spi_drv);
43218 +module_exit(ap83_spi_exit);
43220 +MODULE_ALIAS("platform:" DRV_NAME);
43221 +MODULE_DESCRIPTION(DRV_DESC);
43222 +MODULE_VERSION(DRV_VERSION);
43223 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
43224 +MODULE_LICENSE("GPL v2");
43225 diff -Nur linux-4.1.43.orig/drivers/spi/spi-ath79.c linux-4.1.43/drivers/spi/spi-ath79.c
43226 --- linux-4.1.43.orig/drivers/spi/spi-ath79.c 2017-08-06 01:56:14.000000000 +0200
43227 +++ linux-4.1.43/drivers/spi/spi-ath79.c 2017-08-06 20:02:16.000000000 +0200
43228 @@ -33,6 +33,13 @@
43229 #define ATH79_SPI_RRW_DELAY_FACTOR 12000
43230 #define MHZ (1000 * 1000)
43232 +#define ATH79_SPI_CS_LINE_MAX 2
43234 +enum ath79_spi_state {
43235 + ATH79_SPI_STATE_WAIT_CMD = 0,
43236 + ATH79_SPI_STATE_WAIT_READ,
43239 struct ath79_spi {
43240 struct spi_bitbang bitbang;
43241 u32 ioc_base;
43242 @@ -40,6 +47,11 @@
43243 void __iomem *base;
43244 struct clk *clk;
43245 unsigned rrw_delay;
43247 + enum ath79_spi_state state;
43248 + u32 clk_div;
43249 + unsigned long read_addr;
43250 + unsigned long ahb_rate;
43253 static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned reg)
43254 @@ -67,6 +79,7 @@
43256 struct ath79_spi *sp = ath79_spidev_to_sp(spi);
43257 int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active;
43258 + struct ath79_spi_controller_data *cdata = spi->controller_data;
43260 if (is_active) {
43261 /* set initial clock polarity */
43262 @@ -78,20 +91,24 @@
43263 ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
43266 - if (spi->chip_select) {
43267 - struct ath79_spi_controller_data *cdata = spi->controller_data;
43269 - /* SPI is normally active-low */
43270 - gpio_set_value(cdata->gpio, cs_high);
43271 - } else {
43272 + switch (cdata->cs_type) {
43273 + case ATH79_SPI_CS_TYPE_INTERNAL:
43274 if (cs_high)
43275 - sp->ioc_base |= AR71XX_SPI_IOC_CS0;
43276 + sp->ioc_base |= AR71XX_SPI_IOC_CS(cdata->cs_line);
43277 else
43278 - sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
43279 + sp->ioc_base &= ~AR71XX_SPI_IOC_CS(cdata->cs_line);
43281 ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
43283 + break;
43285 + case ATH79_SPI_CS_TYPE_GPIO:
43286 + /* SPI is normally active-low */
43287 + if (gpio_cansleep(cdata->cs_line))
43288 + gpio_set_value_cansleep(cdata->cs_line, cs_high);
43289 + else
43290 + gpio_set_value(cdata->cs_line, cs_high);
43291 + break;
43295 static void ath79_spi_enable(struct ath79_spi *sp)
43296 @@ -102,9 +119,6 @@
43297 /* save CTRL register */
43298 sp->reg_ctrl = ath79_spi_rr(sp, AR71XX_SPI_REG_CTRL);
43299 sp->ioc_base = ath79_spi_rr(sp, AR71XX_SPI_REG_IOC);
43301 - /* TODO: setup speed? */
43302 - ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43);
43305 static void ath79_spi_disable(struct ath79_spi *sp)
43306 @@ -118,24 +132,30 @@
43307 static int ath79_spi_setup_cs(struct spi_device *spi)
43309 struct ath79_spi_controller_data *cdata;
43310 + unsigned long flags;
43311 int status;
43313 cdata = spi->controller_data;
43314 - if (spi->chip_select && !cdata)
43315 + if (!cdata)
43316 return -EINVAL;
43318 status = 0;
43319 - if (spi->chip_select) {
43320 - unsigned long flags;
43321 + switch (cdata->cs_type) {
43322 + case ATH79_SPI_CS_TYPE_INTERNAL:
43323 + if (cdata->cs_line > ATH79_SPI_CS_LINE_MAX)
43324 + status = -EINVAL;
43325 + break;
43327 + case ATH79_SPI_CS_TYPE_GPIO:
43328 flags = GPIOF_DIR_OUT;
43329 if (spi->mode & SPI_CS_HIGH)
43330 flags |= GPIOF_INIT_LOW;
43331 else
43332 flags |= GPIOF_INIT_HIGH;
43334 - status = gpio_request_one(cdata->gpio, flags,
43335 + status = gpio_request_one(cdata->cs_line, flags,
43336 dev_name(&spi->dev));
43337 + break;
43340 return status;
43341 @@ -143,9 +163,19 @@
43343 static void ath79_spi_cleanup_cs(struct spi_device *spi)
43345 - if (spi->chip_select) {
43346 - struct ath79_spi_controller_data *cdata = spi->controller_data;
43347 - gpio_free(cdata->gpio);
43348 + struct ath79_spi_controller_data *cdata;
43350 + cdata = spi->controller_data;
43351 + if (!cdata)
43352 + return;
43354 + switch (cdata->cs_type) {
43355 + case ATH79_SPI_CS_TYPE_INTERNAL:
43356 + /* nothing to do */
43357 + break;
43358 + case ATH79_SPI_CS_TYPE_GPIO:
43359 + gpio_free(cdata->cs_line);
43360 + break;
43364 @@ -201,6 +231,114 @@
43365 return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS);
43368 +static int ath79_spi_do_read_flash_data(struct spi_device *spi,
43369 + struct spi_transfer *t)
43371 + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
43373 + /* disable GPIO mode */
43374 + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
43376 + memcpy_fromio(t->rx_buf, sp->base + sp->read_addr, t->len);
43378 + /* enable GPIO mode */
43379 + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
43381 + /* restore IOC register */
43382 + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
43384 + return t->len;
43387 +static int ath79_spi_do_read_flash_cmd(struct spi_device *spi,
43388 + struct spi_transfer *t)
43390 + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
43391 + int len;
43392 + const u8 *p;
43394 + sp->read_addr = 0;
43396 + len = t->len - 1;
43398 + if (t->dummy)
43399 + len -= 1;
43401 + p = t->tx_buf;
43403 + while (len--) {
43404 + p++;
43405 + sp->read_addr <<= 8;
43406 + sp->read_addr |= *p;
43409 + return t->len;
43412 +static bool ath79_spi_is_read_cmd(struct spi_device *spi,
43413 + struct spi_transfer *t)
43415 + return t->type == SPI_TRANSFER_FLASH_READ_CMD;
43418 +static bool ath79_spi_is_data_read(struct spi_device *spi,
43419 + struct spi_transfer *t)
43421 + return t->type == SPI_TRANSFER_FLASH_READ_DATA;
43424 +static int ath79_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
43426 + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
43427 + int ret;
43429 + switch (sp->state) {
43430 + case ATH79_SPI_STATE_WAIT_CMD:
43431 + if (ath79_spi_is_read_cmd(spi, t)) {
43432 + ret = ath79_spi_do_read_flash_cmd(spi, t);
43433 + sp->state = ATH79_SPI_STATE_WAIT_READ;
43434 + } else {
43435 + ret = spi_bitbang_bufs(spi, t);
43437 + break;
43439 + case ATH79_SPI_STATE_WAIT_READ:
43440 + if (ath79_spi_is_data_read(spi, t)) {
43441 + ret = ath79_spi_do_read_flash_data(spi, t);
43442 + } else {
43443 + dev_warn(&spi->dev, "flash data read expected\n");
43444 + ret = -EIO;
43446 + sp->state = ATH79_SPI_STATE_WAIT_CMD;
43447 + break;
43449 + default:
43450 + BUG();
43453 + return ret;
43456 +static int ath79_spi_setup_transfer(struct spi_device *spi,
43457 + struct spi_transfer *t)
43459 + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
43460 + struct ath79_spi_controller_data *cdata;
43461 + int ret;
43463 + ret = spi_bitbang_setup_transfer(spi, t);
43464 + if (ret)
43465 + return ret;
43467 + cdata = spi->controller_data;
43468 + if (cdata->is_flash)
43469 + sp->bitbang.txrx_bufs = ath79_spi_txrx_bufs;
43470 + else
43471 + sp->bitbang.txrx_bufs = spi_bitbang_bufs;
43473 + return ret;
43476 static int ath79_spi_probe(struct platform_device *pdev)
43478 struct spi_master *master;
43479 @@ -210,6 +348,10 @@
43480 unsigned long rate;
43481 int ret;
43483 + pdata = pdev->dev.platform_data;
43484 + if (!pdata)
43485 + return -EINVAL;
43487 master = spi_alloc_master(&pdev->dev, sizeof(*sp));
43488 if (master == NULL) {
43489 dev_err(&pdev->dev, "failed to allocate spi master\n");
43490 @@ -219,20 +361,18 @@
43491 sp = spi_master_get_devdata(master);
43492 platform_set_drvdata(pdev, sp);
43494 - pdata = dev_get_platdata(&pdev->dev);
43495 + sp->state = ATH79_SPI_STATE_WAIT_CMD;
43497 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
43498 master->setup = ath79_spi_setup;
43499 master->cleanup = ath79_spi_cleanup;
43500 - if (pdata) {
43501 - master->bus_num = pdata->bus_num;
43502 - master->num_chipselect = pdata->num_chipselect;
43504 + master->bus_num = pdata->bus_num;
43505 + master->num_chipselect = pdata->num_chipselect;
43507 sp->bitbang.master = master;
43508 sp->bitbang.chipselect = ath79_spi_chipselect;
43509 sp->bitbang.txrx_word[SPI_MODE_0] = ath79_spi_txrx_mode0;
43510 - sp->bitbang.setup_transfer = spi_bitbang_setup_transfer;
43511 + sp->bitbang.setup_transfer = ath79_spi_setup_transfer;
43512 sp->bitbang.flags = SPI_CS_HIGH;
43514 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43515 @@ -257,7 +397,8 @@
43516 if (ret)
43517 goto err_put_master;
43519 - rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
43520 + sp->ahb_rate = clk_get_rate(sp->clk);
43521 + rate = DIV_ROUND_UP(sp->ahb_rate, MHZ);
43522 if (!rate) {
43523 ret = -EINVAL;
43524 goto err_clk_disable;
43525 diff -Nur linux-4.1.43.orig/drivers/spi/spi-bitbang.c linux-4.1.43/drivers/spi/spi-bitbang.c
43526 --- linux-4.1.43.orig/drivers/spi/spi-bitbang.c 2017-08-06 01:56:14.000000000 +0200
43527 +++ linux-4.1.43/drivers/spi/spi-bitbang.c 2017-08-06 20:02:16.000000000 +0200
43528 @@ -230,13 +230,14 @@
43530 EXPORT_SYMBOL_GPL(spi_bitbang_cleanup);
43532 -static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
43533 +int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
43535 struct spi_bitbang_cs *cs = spi->controller_state;
43536 unsigned nsecs = cs->nsecs;
43538 return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t);
43540 +EXPORT_SYMBOL_GPL(spi_bitbang_bufs);
43542 /*----------------------------------------------------------------------*/
43544 diff -Nur linux-4.1.43.orig/drivers/spi/spi-rb4xx-cpld.c linux-4.1.43/drivers/spi/spi-rb4xx-cpld.c
43545 --- linux-4.1.43.orig/drivers/spi/spi-rb4xx-cpld.c 1970-01-01 01:00:00.000000000 +0100
43546 +++ linux-4.1.43/drivers/spi/spi-rb4xx-cpld.c 2017-08-06 20:02:16.000000000 +0200
43547 @@ -0,0 +1,441 @@
43549 + * SPI driver for the CPLD chip on the Mikrotik RB4xx boards
43551 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
43553 + * This file was based on the patches for Linux 2.6.27.39 published by
43554 + * MikroTik for their RouterBoard 4xx series devices.
43556 + * This program is free software; you can redistribute it and/or modify it
43557 + * under the terms of the GNU General Public License version 2 as published
43558 + * by the Free Software Foundation.
43559 + */
43561 +#include <linux/types.h>
43562 +#include <linux/kernel.h>
43563 +#include <linux/module.h>
43564 +#include <linux/init.h>
43565 +#include <linux/module.h>
43566 +#include <linux/device.h>
43567 +#include <linux/bitops.h>
43568 +#include <linux/spi/spi.h>
43569 +#include <linux/gpio.h>
43570 +#include <linux/slab.h>
43572 +#include <asm/mach-ath79/rb4xx_cpld.h>
43574 +#define DRV_NAME "spi-rb4xx-cpld"
43575 +#define DRV_DESC "RB4xx CPLD driver"
43576 +#define DRV_VERSION "0.1.0"
43578 +#define CPLD_CMD_WRITE_NAND 0x08 /* send cmd, n x send data, send indle */
43579 +#define CPLD_CMD_WRITE_CFG 0x09 /* send cmd, n x send cfg */
43580 +#define CPLD_CMD_READ_NAND 0x0a /* send cmd, send idle, n x read data */
43581 +#define CPLD_CMD_READ_FAST 0x0b /* send cmd, 4 x idle, n x read data */
43582 +#define CPLD_CMD_LED5_ON 0x0c /* send cmd */
43583 +#define CPLD_CMD_LED5_OFF 0x0d /* send cmd */
43585 +struct rb4xx_cpld {
43586 + struct spi_device *spi;
43587 + struct mutex lock;
43588 + struct gpio_chip chip;
43589 + unsigned int config;
43592 +static struct rb4xx_cpld *rb4xx_cpld;
43594 +static inline struct rb4xx_cpld *gpio_to_cpld(struct gpio_chip *chip)
43596 + return container_of(chip, struct rb4xx_cpld, chip);
43599 +static int rb4xx_cpld_write_cmd(struct rb4xx_cpld *cpld, unsigned char cmd)
43601 + struct spi_transfer t[1];
43602 + struct spi_message m;
43603 + unsigned char tx_buf[1];
43604 + int err;
43606 + spi_message_init(&m);
43607 + memset(&t, 0, sizeof(t));
43609 + t[0].tx_buf = tx_buf;
43610 + t[0].len = sizeof(tx_buf);
43611 + spi_message_add_tail(&t[0], &m);
43613 + tx_buf[0] = cmd;
43615 + err = spi_sync(cpld->spi, &m);
43616 + return err;
43619 +static int rb4xx_cpld_write_cfg(struct rb4xx_cpld *cpld, unsigned char config)
43621 + struct spi_transfer t[1];
43622 + struct spi_message m;
43623 + unsigned char cmd[2];
43624 + int err;
43626 + spi_message_init(&m);
43627 + memset(&t, 0, sizeof(t));
43629 + t[0].tx_buf = cmd;
43630 + t[0].len = sizeof(cmd);
43631 + spi_message_add_tail(&t[0], &m);
43633 + cmd[0] = CPLD_CMD_WRITE_CFG;
43634 + cmd[1] = config;
43636 + err = spi_sync(cpld->spi, &m);
43637 + return err;
43640 +static int __rb4xx_cpld_change_cfg(struct rb4xx_cpld *cpld, unsigned mask,
43641 + unsigned value)
43643 + unsigned int config;
43644 + int err;
43646 + config = cpld->config & ~mask;
43647 + config |= value;
43649 + if ((cpld->config ^ config) & 0xff) {
43650 + err = rb4xx_cpld_write_cfg(cpld, config);
43651 + if (err)
43652 + return err;
43655 + if ((cpld->config ^ config) & CPLD_CFG_nLED5) {
43656 + err = rb4xx_cpld_write_cmd(cpld, (value) ? CPLD_CMD_LED5_ON :
43657 + CPLD_CMD_LED5_OFF);
43658 + if (err)
43659 + return err;
43662 + cpld->config = config;
43663 + return 0;
43666 +int rb4xx_cpld_change_cfg(unsigned mask, unsigned value)
43668 + int ret;
43670 + if (rb4xx_cpld == NULL)
43671 + return -ENODEV;
43673 + mutex_lock(&rb4xx_cpld->lock);
43674 + ret = __rb4xx_cpld_change_cfg(rb4xx_cpld, mask, value);
43675 + mutex_unlock(&rb4xx_cpld->lock);
43677 + return ret;
43679 +EXPORT_SYMBOL_GPL(rb4xx_cpld_change_cfg);
43681 +int rb4xx_cpld_read_from(unsigned addr, unsigned char *rx_buf,
43682 + const unsigned char *verify_buf, unsigned count)
43684 + const unsigned char cmd[5] = {
43685 + CPLD_CMD_READ_FAST,
43686 + (addr >> 16) & 0xff,
43687 + (addr >> 8) & 0xff,
43688 + addr & 0xff,
43690 + };
43691 + struct spi_transfer t[2] = {
43693 + .tx_buf = &cmd,
43694 + .len = 5,
43695 + },
43697 + .tx_buf = verify_buf,
43698 + .rx_buf = rx_buf,
43699 + .len = count,
43700 + .verify = (verify_buf != NULL),
43701 + },
43702 + };
43703 + struct spi_message m;
43705 + if (rb4xx_cpld == NULL)
43706 + return -ENODEV;
43708 + spi_message_init(&m);
43709 + m.fast_read = 1;
43710 + spi_message_add_tail(&t[0], &m);
43711 + spi_message_add_tail(&t[1], &m);
43712 + return spi_sync(rb4xx_cpld->spi, &m);
43714 +EXPORT_SYMBOL_GPL(rb4xx_cpld_read_from);
43716 +#if 0
43717 +int rb4xx_cpld_read(unsigned char *buf, unsigned char *verify_buf,
43718 + unsigned count)
43720 + struct spi_transfer t[2];
43721 + struct spi_message m;
43722 + unsigned char cmd[2];
43724 + if (rb4xx_cpld == NULL)
43725 + return -ENODEV;
43727 + spi_message_init(&m);
43728 + memset(&t, 0, sizeof(t));
43730 + /* send command */
43731 + t[0].tx_buf = cmd;
43732 + t[0].len = sizeof(cmd);
43733 + spi_message_add_tail(&t[0], &m);
43735 + cmd[0] = CPLD_CMD_READ_NAND;
43736 + cmd[1] = 0;
43738 + /* read data */
43739 + t[1].rx_buf = buf;
43740 + t[1].len = count;
43741 + spi_message_add_tail(&t[1], &m);
43743 + return spi_sync(rb4xx_cpld->spi, &m);
43745 +#else
43746 +int rb4xx_cpld_read(unsigned char *rx_buf, const unsigned char *verify_buf,
43747 + unsigned count)
43749 + static const unsigned char cmd[2] = { CPLD_CMD_READ_NAND, 0 };
43750 + struct spi_transfer t[2] = {
43752 + .tx_buf = &cmd,
43753 + .len = 2,
43754 + }, {
43755 + .tx_buf = verify_buf,
43756 + .rx_buf = rx_buf,
43757 + .len = count,
43758 + .verify = (verify_buf != NULL),
43759 + },
43760 + };
43761 + struct spi_message m;
43763 + if (rb4xx_cpld == NULL)
43764 + return -ENODEV;
43766 + spi_message_init(&m);
43767 + spi_message_add_tail(&t[0], &m);
43768 + spi_message_add_tail(&t[1], &m);
43769 + return spi_sync(rb4xx_cpld->spi, &m);
43771 +#endif
43772 +EXPORT_SYMBOL_GPL(rb4xx_cpld_read);
43774 +int rb4xx_cpld_write(const unsigned char *buf, unsigned count)
43776 +#if 0
43777 + struct spi_transfer t[3];
43778 + struct spi_message m;
43779 + unsigned char cmd[1];
43781 + if (rb4xx_cpld == NULL)
43782 + return -ENODEV;
43784 + memset(&t, 0, sizeof(t));
43785 + spi_message_init(&m);
43787 + /* send command */
43788 + t[0].tx_buf = cmd;
43789 + t[0].len = sizeof(cmd);
43790 + spi_message_add_tail(&t[0], &m);
43792 + cmd[0] = CPLD_CMD_WRITE_NAND;
43794 + /* write data */
43795 + t[1].tx_buf = buf;
43796 + t[1].len = count;
43797 + spi_message_add_tail(&t[1], &m);
43799 + /* send idle */
43800 + t[2].len = 1;
43801 + spi_message_add_tail(&t[2], &m);
43803 + return spi_sync(rb4xx_cpld->spi, &m);
43804 +#else
43805 + static const unsigned char cmd = CPLD_CMD_WRITE_NAND;
43806 + struct spi_transfer t[3] = {
43808 + .tx_buf = &cmd,
43809 + .len = 1,
43810 + }, {
43811 + .tx_buf = buf,
43812 + .len = count,
43813 + .fast_write = 1,
43814 + }, {
43815 + .len = 1,
43816 + .fast_write = 1,
43817 + },
43818 + };
43819 + struct spi_message m;
43821 + if (rb4xx_cpld == NULL)
43822 + return -ENODEV;
43824 + spi_message_init(&m);
43825 + spi_message_add_tail(&t[0], &m);
43826 + spi_message_add_tail(&t[1], &m);
43827 + spi_message_add_tail(&t[2], &m);
43828 + return spi_sync(rb4xx_cpld->spi, &m);
43829 +#endif
43831 +EXPORT_SYMBOL_GPL(rb4xx_cpld_write);
43833 +static int rb4xx_cpld_gpio_get(struct gpio_chip *chip, unsigned offset)
43835 + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
43836 + int ret;
43838 + mutex_lock(&cpld->lock);
43839 + ret = (cpld->config >> offset) & 1;
43840 + mutex_unlock(&cpld->lock);
43842 + return ret;
43845 +static void rb4xx_cpld_gpio_set(struct gpio_chip *chip, unsigned offset,
43846 + int value)
43848 + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
43850 + mutex_lock(&cpld->lock);
43851 + __rb4xx_cpld_change_cfg(cpld, (1 << offset), !!value << offset);
43852 + mutex_unlock(&cpld->lock);
43855 +static int rb4xx_cpld_gpio_direction_input(struct gpio_chip *chip,
43856 + unsigned offset)
43858 + return -EOPNOTSUPP;
43861 +static int rb4xx_cpld_gpio_direction_output(struct gpio_chip *chip,
43862 + unsigned offset,
43863 + int value)
43865 + struct rb4xx_cpld *cpld = gpio_to_cpld(chip);
43866 + int ret;
43868 + mutex_lock(&cpld->lock);
43869 + ret = __rb4xx_cpld_change_cfg(cpld, (1 << offset), !!value << offset);
43870 + mutex_unlock(&cpld->lock);
43872 + return ret;
43875 +static int rb4xx_cpld_gpio_init(struct rb4xx_cpld *cpld, unsigned int base)
43877 + int err;
43879 + /* init config */
43880 + cpld->config = CPLD_CFG_nLED1 | CPLD_CFG_nLED2 | CPLD_CFG_nLED3 |
43881 + CPLD_CFG_nLED4 | CPLD_CFG_nCE;
43882 + rb4xx_cpld_write_cfg(cpld, cpld->config);
43884 + /* setup GPIO chip */
43885 + cpld->chip.label = DRV_NAME;
43887 + cpld->chip.get = rb4xx_cpld_gpio_get;
43888 + cpld->chip.set = rb4xx_cpld_gpio_set;
43889 + cpld->chip.direction_input = rb4xx_cpld_gpio_direction_input;
43890 + cpld->chip.direction_output = rb4xx_cpld_gpio_direction_output;
43892 + cpld->chip.base = base;
43893 + cpld->chip.ngpio = CPLD_NUM_GPIOS;
43894 + cpld->chip.can_sleep = 1;
43895 + cpld->chip.dev = &cpld->spi->dev;
43896 + cpld->chip.owner = THIS_MODULE;
43898 + err = gpiochip_add(&cpld->chip);
43899 + if (err)
43900 + dev_err(&cpld->spi->dev, "adding GPIO chip failed, err=%d\n",
43901 + err);
43903 + return err;
43906 +static int rb4xx_cpld_probe(struct spi_device *spi)
43908 + struct rb4xx_cpld *cpld;
43909 + struct rb4xx_cpld_platform_data *pdata;
43910 + int err;
43912 + pdata = spi->dev.platform_data;
43913 + if (!pdata) {
43914 + dev_dbg(&spi->dev, "no platform data\n");
43915 + return -EINVAL;
43918 + cpld = kzalloc(sizeof(*cpld), GFP_KERNEL);
43919 + if (!cpld) {
43920 + dev_err(&spi->dev, "no memory for private data\n");
43921 + return -ENOMEM;
43924 + mutex_init(&cpld->lock);
43925 + cpld->spi = spi_dev_get(spi);
43926 + dev_set_drvdata(&spi->dev, cpld);
43928 + spi->mode = SPI_MODE_0;
43929 + spi->bits_per_word = 8;
43930 + err = spi_setup(spi);
43931 + if (err) {
43932 + dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
43933 + goto err_drvdata;
43936 + err = rb4xx_cpld_gpio_init(cpld, pdata->gpio_base);
43937 + if (err)
43938 + goto err_drvdata;
43940 + rb4xx_cpld = cpld;
43942 + return 0;
43944 +err_drvdata:
43945 + dev_set_drvdata(&spi->dev, NULL);
43946 + kfree(cpld);
43948 + return err;
43951 +static int rb4xx_cpld_remove(struct spi_device *spi)
43953 + struct rb4xx_cpld *cpld;
43955 + rb4xx_cpld = NULL;
43956 + cpld = dev_get_drvdata(&spi->dev);
43957 + dev_set_drvdata(&spi->dev, NULL);
43958 + kfree(cpld);
43960 + return 0;
43963 +static struct spi_driver rb4xx_cpld_driver = {
43964 + .driver = {
43965 + .name = DRV_NAME,
43966 + .bus = &spi_bus_type,
43967 + .owner = THIS_MODULE,
43968 + },
43969 + .probe = rb4xx_cpld_probe,
43970 + .remove = rb4xx_cpld_remove,
43973 +static int __init rb4xx_cpld_init(void)
43975 + return spi_register_driver(&rb4xx_cpld_driver);
43977 +module_init(rb4xx_cpld_init);
43979 +static void __exit rb4xx_cpld_exit(void)
43981 + spi_unregister_driver(&rb4xx_cpld_driver);
43983 +module_exit(rb4xx_cpld_exit);
43985 +MODULE_DESCRIPTION(DRV_DESC);
43986 +MODULE_VERSION(DRV_VERSION);
43987 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
43988 +MODULE_LICENSE("GPL v2");
43989 diff -Nur linux-4.1.43.orig/drivers/spi/spi-rb4xx.c linux-4.1.43/drivers/spi/spi-rb4xx.c
43990 --- linux-4.1.43.orig/drivers/spi/spi-rb4xx.c 1970-01-01 01:00:00.000000000 +0100
43991 +++ linux-4.1.43/drivers/spi/spi-rb4xx.c 2017-08-06 20:02:16.000000000 +0200
43992 @@ -0,0 +1,507 @@
43994 + * SPI controller driver for the Mikrotik RB4xx boards
43996 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
43998 + * This file was based on the patches for Linux 2.6.27.39 published by
43999 + * MikroTik for their RouterBoard 4xx series devices.
44001 + * This program is free software; you can redistribute it and/or modify
44002 + * it under the terms of the GNU General Public License version 2 as
44003 + * published by the Free Software Foundation.
44005 + */
44007 +#include <linux/clk.h>
44008 +#include <linux/err.h>
44009 +#include <linux/kernel.h>
44010 +#include <linux/module.h>
44011 +#include <linux/init.h>
44012 +#include <linux/delay.h>
44013 +#include <linux/spinlock.h>
44014 +#include <linux/workqueue.h>
44015 +#include <linux/platform_device.h>
44016 +#include <linux/spi/spi.h>
44018 +#include <asm/mach-ath79/ar71xx_regs.h>
44019 +#include <asm/mach-ath79/ath79.h>
44021 +#define DRV_NAME "rb4xx-spi"
44022 +#define DRV_DESC "Mikrotik RB4xx SPI controller driver"
44023 +#define DRV_VERSION "0.1.0"
44025 +#define SPI_CTRL_FASTEST 0x40
44026 +#define SPI_FLASH_HZ 33333334
44027 +#define SPI_CPLD_HZ 33333334
44029 +#define CPLD_CMD_READ_FAST 0x0b
44031 +#undef RB4XX_SPI_DEBUG
44033 +struct rb4xx_spi {
44034 + void __iomem *base;
44035 + struct spi_master *master;
44037 + unsigned spi_ctrl_flash;
44038 + unsigned spi_ctrl_fread;
44040 + struct clk *ahb_clk;
44041 + unsigned long ahb_freq;
44043 + spinlock_t lock;
44044 + struct list_head queue;
44045 + int busy:1;
44046 + int cs_wait;
44049 +static unsigned spi_clk_low = AR71XX_SPI_IOC_CS1;
44051 +#ifdef RB4XX_SPI_DEBUG
44052 +static inline void do_spi_delay(void)
44054 + ndelay(20000);
44056 +#else
44057 +static inline void do_spi_delay(void) { }
44058 +#endif
44060 +static inline void do_spi_init(struct spi_device *spi)
44062 + unsigned cs = AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1;
44064 + if (!(spi->mode & SPI_CS_HIGH))
44065 + cs ^= (spi->chip_select == 2) ? AR71XX_SPI_IOC_CS1 :
44066 + AR71XX_SPI_IOC_CS0;
44068 + spi_clk_low = cs;
44071 +static inline void do_spi_finish(void __iomem *base)
44073 + do_spi_delay();
44074 + __raw_writel(AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1,
44075 + base + AR71XX_SPI_REG_IOC);
44078 +static inline void do_spi_clk(void __iomem *base, int bit)
44080 + unsigned bval = spi_clk_low | ((bit & 1) ? AR71XX_SPI_IOC_DO : 0);
44082 + do_spi_delay();
44083 + __raw_writel(bval, base + AR71XX_SPI_REG_IOC);
44084 + do_spi_delay();
44085 + __raw_writel(bval | AR71XX_SPI_IOC_CLK, base + AR71XX_SPI_REG_IOC);
44088 +static void do_spi_byte(void __iomem *base, unsigned char byte)
44090 + do_spi_clk(base, byte >> 7);
44091 + do_spi_clk(base, byte >> 6);
44092 + do_spi_clk(base, byte >> 5);
44093 + do_spi_clk(base, byte >> 4);
44094 + do_spi_clk(base, byte >> 3);
44095 + do_spi_clk(base, byte >> 2);
44096 + do_spi_clk(base, byte >> 1);
44097 + do_spi_clk(base, byte);
44099 + pr_debug("spi_byte sent 0x%02x got 0x%02x\n",
44100 + (unsigned)byte,
44101 + (unsigned char)__raw_readl(base + AR71XX_SPI_REG_RDS));
44104 +static inline void do_spi_clk_fast(void __iomem *base, unsigned bit1,
44105 + unsigned bit2)
44107 + unsigned bval = (spi_clk_low |
44108 + ((bit1 & 1) ? AR71XX_SPI_IOC_DO : 0) |
44109 + ((bit2 & 1) ? AR71XX_SPI_IOC_CS2 : 0));
44110 + do_spi_delay();
44111 + __raw_writel(bval, base + AR71XX_SPI_REG_IOC);
44112 + do_spi_delay();
44113 + __raw_writel(bval | AR71XX_SPI_IOC_CLK, base + AR71XX_SPI_REG_IOC);
44116 +static void do_spi_byte_fast(void __iomem *base, unsigned char byte)
44118 + do_spi_clk_fast(base, byte >> 7, byte >> 6);
44119 + do_spi_clk_fast(base, byte >> 5, byte >> 4);
44120 + do_spi_clk_fast(base, byte >> 3, byte >> 2);
44121 + do_spi_clk_fast(base, byte >> 1, byte >> 0);
44123 + pr_debug("spi_byte_fast sent 0x%02x got 0x%02x\n",
44124 + (unsigned)byte,
44125 + (unsigned char) __raw_readl(base + AR71XX_SPI_REG_RDS));
44128 +static int rb4xx_spi_txrx(void __iomem *base, struct spi_transfer *t)
44130 + const unsigned char *rxv_ptr = NULL;
44131 + const unsigned char *tx_ptr = t->tx_buf;
44132 + unsigned char *rx_ptr = t->rx_buf;
44133 + unsigned i;
44135 + pr_debug("spi_txrx len %u tx %u rx %u\n",
44136 + t->len,
44137 + (t->tx_buf ? 1 : 0),
44138 + (t->rx_buf ? 1 : 0));
44140 + if (t->verify) {
44141 + rxv_ptr = tx_ptr;
44142 + tx_ptr = NULL;
44145 + for (i = 0; i < t->len; ++i) {
44146 + unsigned char sdata = tx_ptr ? tx_ptr[i] : 0;
44148 + if (t->fast_write)
44149 + do_spi_byte_fast(base, sdata);
44150 + else
44151 + do_spi_byte(base, sdata);
44153 + if (rx_ptr) {
44154 + rx_ptr[i] = __raw_readl(base + AR71XX_SPI_REG_RDS) & 0xff;
44155 + } else if (rxv_ptr) {
44156 + unsigned char c = __raw_readl(base + AR71XX_SPI_REG_RDS);
44157 + if (rxv_ptr[i] != c)
44158 + return i;
44162 + return i;
44165 +static int rb4xx_spi_read_fast(struct rb4xx_spi *rbspi,
44166 + struct spi_message *m)
44168 + struct spi_transfer *t;
44169 + const unsigned char *tx_ptr;
44170 + unsigned addr;
44171 + void __iomem *base = rbspi->base;
44173 + /* check for exactly two transfers */
44174 + if (list_empty(&m->transfers) ||
44175 + list_is_last(m->transfers.next, &m->transfers) ||
44176 + !list_is_last(m->transfers.next->next, &m->transfers)) {
44177 + return -1;
44180 + /* first transfer contains command and address */
44181 + t = list_entry(m->transfers.next,
44182 + struct spi_transfer, transfer_list);
44184 + if (t->len != 5 || t->tx_buf == NULL)
44185 + return -1;
44187 + tx_ptr = t->tx_buf;
44188 + if (tx_ptr[0] != CPLD_CMD_READ_FAST)
44189 + return -1;
44191 + addr = tx_ptr[1];
44192 + addr = tx_ptr[2] | (addr << 8);
44193 + addr = tx_ptr[3] | (addr << 8);
44194 + addr += (unsigned) base;
44196 + m->actual_length += t->len;
44198 + /* second transfer contains data itself */
44199 + t = list_entry(m->transfers.next->next,
44200 + struct spi_transfer, transfer_list);
44202 + if (t->tx_buf && !t->verify)
44203 + return -1;
44205 + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
44206 + __raw_writel(rbspi->spi_ctrl_fread, base + AR71XX_SPI_REG_CTRL);
44207 + __raw_writel(0, base + AR71XX_SPI_REG_FS);
44209 + if (t->rx_buf) {
44210 + memcpy(t->rx_buf, (const void *)addr, t->len);
44211 + } else if (t->tx_buf) {
44212 + unsigned char buf[t->len];
44213 + memcpy(buf, (const void *)addr, t->len);
44214 + if (memcmp(t->tx_buf, buf, t->len) != 0)
44215 + m->status = -EMSGSIZE;
44217 + m->actual_length += t->len;
44219 + if (rbspi->spi_ctrl_flash != rbspi->spi_ctrl_fread) {
44220 + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
44221 + __raw_writel(rbspi->spi_ctrl_flash, base + AR71XX_SPI_REG_CTRL);
44222 + __raw_writel(0, base + AR71XX_SPI_REG_FS);
44225 + return 0;
44228 +static int rb4xx_spi_msg(struct rb4xx_spi *rbspi, struct spi_message *m)
44230 + struct spi_transfer *t = NULL;
44231 + void __iomem *base = rbspi->base;
44233 + m->status = 0;
44234 + if (list_empty(&m->transfers))
44235 + return -1;
44237 + if (m->fast_read)
44238 + if (rb4xx_spi_read_fast(rbspi, m) == 0)
44239 + return -1;
44241 + __raw_writel(AR71XX_SPI_FS_GPIO, base + AR71XX_SPI_REG_FS);
44242 + __raw_writel(SPI_CTRL_FASTEST, base + AR71XX_SPI_REG_CTRL);
44243 + do_spi_init(m->spi);
44245 + list_for_each_entry(t, &m->transfers, transfer_list) {
44246 + int len;
44248 + len = rb4xx_spi_txrx(base, t);
44249 + if (len != t->len) {
44250 + m->status = -EMSGSIZE;
44251 + break;
44253 + m->actual_length += len;
44255 + if (t->cs_change) {
44256 + if (list_is_last(&t->transfer_list, &m->transfers)) {
44257 + /* wait for continuation */
44258 + return m->spi->chip_select;
44260 + do_spi_finish(base);
44261 + ndelay(100);
44265 + do_spi_finish(base);
44266 + __raw_writel(rbspi->spi_ctrl_flash, base + AR71XX_SPI_REG_CTRL);
44267 + __raw_writel(0, base + AR71XX_SPI_REG_FS);
44268 + return -1;
44271 +static void rb4xx_spi_process_queue_locked(struct rb4xx_spi *rbspi,
44272 + unsigned long *flags)
44274 + int cs = rbspi->cs_wait;
44276 + rbspi->busy = 1;
44277 + while (!list_empty(&rbspi->queue)) {
44278 + struct spi_message *m;
44280 + list_for_each_entry(m, &rbspi->queue, queue)
44281 + if (cs < 0 || cs == m->spi->chip_select)
44282 + break;
44284 + if (&m->queue == &rbspi->queue)
44285 + break;
44287 + list_del_init(&m->queue);
44288 + spin_unlock_irqrestore(&rbspi->lock, *flags);
44290 + cs = rb4xx_spi_msg(rbspi, m);
44291 + m->complete(m->context);
44293 + spin_lock_irqsave(&rbspi->lock, *flags);
44296 + rbspi->cs_wait = cs;
44297 + rbspi->busy = 0;
44299 + if (cs >= 0) {
44300 + /* TODO: add timer to unlock cs after 1s inactivity */
44304 +static int rb4xx_spi_transfer(struct spi_device *spi,
44305 + struct spi_message *m)
44307 + struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master);
44308 + unsigned long flags;
44310 + m->actual_length = 0;
44311 + m->status = -EINPROGRESS;
44313 + spin_lock_irqsave(&rbspi->lock, flags);
44314 + list_add_tail(&m->queue, &rbspi->queue);
44315 + if (rbspi->busy ||
44316 + (rbspi->cs_wait >= 0 && rbspi->cs_wait != m->spi->chip_select)) {
44317 + /* job will be done later */
44318 + spin_unlock_irqrestore(&rbspi->lock, flags);
44319 + return 0;
44322 + /* process job in current context */
44323 + rb4xx_spi_process_queue_locked(rbspi, &flags);
44324 + spin_unlock_irqrestore(&rbspi->lock, flags);
44326 + return 0;
44329 +static int rb4xx_spi_setup(struct spi_device *spi)
44331 + struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master);
44332 + unsigned long flags;
44334 + if (spi->mode & ~(SPI_CS_HIGH)) {
44335 + dev_err(&spi->dev, "mode %x not supported\n",
44336 + (unsigned) spi->mode);
44337 + return -EINVAL;
44340 + if (spi->bits_per_word != 8 && spi->bits_per_word != 0) {
44341 + dev_err(&spi->dev, "bits_per_word %u not supported\n",
44342 + (unsigned) spi->bits_per_word);
44343 + return -EINVAL;
44346 + spin_lock_irqsave(&rbspi->lock, flags);
44347 + if (rbspi->cs_wait == spi->chip_select && !rbspi->busy) {
44348 + rbspi->cs_wait = -1;
44349 + rb4xx_spi_process_queue_locked(rbspi, &flags);
44351 + spin_unlock_irqrestore(&rbspi->lock, flags);
44353 + return 0;
44356 +static unsigned get_spi_ctrl(struct rb4xx_spi *rbspi, unsigned hz_max,
44357 + const char *name)
44359 + unsigned div;
44361 + div = (rbspi->ahb_freq - 1) / (2 * hz_max);
44363 + /*
44364 + * CPU has a bug at (div == 0) - first bit read is random
44365 + */
44366 + if (div == 0)
44367 + ++div;
44369 + if (name) {
44370 + unsigned ahb_khz = (rbspi->ahb_freq + 500) / 1000;
44371 + unsigned div_real = 2 * (div + 1);
44372 + pr_debug("rb4xx: %s SPI clock %u kHz (AHB %u kHz / %u)\n",
44373 + name,
44374 + ahb_khz / div_real,
44375 + ahb_khz, div_real);
44378 + return SPI_CTRL_FASTEST + div;
44381 +static int rb4xx_spi_probe(struct platform_device *pdev)
44383 + struct spi_master *master;
44384 + struct rb4xx_spi *rbspi;
44385 + struct resource *r;
44386 + int err = 0;
44388 + master = spi_alloc_master(&pdev->dev, sizeof(*rbspi));
44389 + if (master == NULL) {
44390 + dev_err(&pdev->dev, "no memory for spi_master\n");
44391 + err = -ENOMEM;
44392 + goto err_out;
44395 + master->bus_num = 0;
44396 + master->num_chipselect = 3;
44397 + master->setup = rb4xx_spi_setup;
44398 + master->transfer = rb4xx_spi_transfer;
44400 + rbspi = spi_master_get_devdata(master);
44402 + rbspi->ahb_clk = clk_get(&pdev->dev, "ahb");
44403 + if (IS_ERR(rbspi->ahb_clk)) {
44404 + err = PTR_ERR(rbspi->ahb_clk);
44405 + goto err_put_master;
44408 + err = clk_enable(rbspi->ahb_clk);
44409 + if (err)
44410 + goto err_clk_put;
44412 + rbspi->ahb_freq = clk_get_rate(rbspi->ahb_clk);
44413 + if (!rbspi->ahb_freq) {
44414 + err = -EINVAL;
44415 + goto err_clk_disable;
44418 + platform_set_drvdata(pdev, rbspi);
44420 + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
44421 + if (r == NULL) {
44422 + err = -ENOENT;
44423 + goto err_clk_disable;
44426 + rbspi->base = ioremap(r->start, r->end - r->start + 1);
44427 + if (!rbspi->base) {
44428 + err = -ENXIO;
44429 + goto err_clk_disable;
44432 + rbspi->master = master;
44433 + rbspi->spi_ctrl_flash = get_spi_ctrl(rbspi, SPI_FLASH_HZ, "FLASH");
44434 + rbspi->spi_ctrl_fread = get_spi_ctrl(rbspi, SPI_CPLD_HZ, "CPLD");
44435 + rbspi->cs_wait = -1;
44437 + spin_lock_init(&rbspi->lock);
44438 + INIT_LIST_HEAD(&rbspi->queue);
44440 + err = spi_register_master(master);
44441 + if (err) {
44442 + dev_err(&pdev->dev, "failed to register SPI master\n");
44443 + goto err_iounmap;
44446 + return 0;
44448 +err_iounmap:
44449 + iounmap(rbspi->base);
44450 +err_clk_disable:
44451 + clk_disable(rbspi->ahb_clk);
44452 +err_clk_put:
44453 + clk_put(rbspi->ahb_clk);
44454 +err_put_master:
44455 + platform_set_drvdata(pdev, NULL);
44456 + spi_master_put(master);
44457 +err_out:
44458 + return err;
44461 +static int rb4xx_spi_remove(struct platform_device *pdev)
44463 + struct rb4xx_spi *rbspi = platform_get_drvdata(pdev);
44465 + iounmap(rbspi->base);
44466 + clk_disable(rbspi->ahb_clk);
44467 + clk_put(rbspi->ahb_clk);
44468 + platform_set_drvdata(pdev, NULL);
44469 + spi_master_put(rbspi->master);
44471 + return 0;
44474 +static struct platform_driver rb4xx_spi_drv = {
44475 + .probe = rb4xx_spi_probe,
44476 + .remove = rb4xx_spi_remove,
44477 + .driver = {
44478 + .name = DRV_NAME,
44479 + .owner = THIS_MODULE,
44480 + },
44483 +static int __init rb4xx_spi_init(void)
44485 + return platform_driver_register(&rb4xx_spi_drv);
44487 +subsys_initcall(rb4xx_spi_init);
44489 +static void __exit rb4xx_spi_exit(void)
44491 + platform_driver_unregister(&rb4xx_spi_drv);
44494 +module_exit(rb4xx_spi_exit);
44496 +MODULE_DESCRIPTION(DRV_DESC);
44497 +MODULE_VERSION(DRV_VERSION);
44498 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
44499 +MODULE_LICENSE("GPL v2");
44500 diff -Nur linux-4.1.43.orig/drivers/spi/spi-vsc7385.c linux-4.1.43/drivers/spi/spi-vsc7385.c
44501 --- linux-4.1.43.orig/drivers/spi/spi-vsc7385.c 1970-01-01 01:00:00.000000000 +0100
44502 +++ linux-4.1.43/drivers/spi/spi-vsc7385.c 2017-08-06 20:02:16.000000000 +0200
44503 @@ -0,0 +1,621 @@
44505 + * SPI driver for the Vitesse VSC7385 ethernet switch
44507 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
44509 + * Parts of this file are based on Atheros' 2.6.15 BSP
44511 + * This program is free software; you can redistribute it and/or modify it
44512 + * under the terms of the GNU General Public License version 2 as published
44513 + * by the Free Software Foundation.
44514 + */
44516 +#include <linux/types.h>
44517 +#include <linux/kernel.h>
44518 +#include <linux/init.h>
44519 +#include <linux/module.h>
44520 +#include <linux/delay.h>
44521 +#include <linux/device.h>
44522 +#include <linux/bitops.h>
44523 +#include <linux/firmware.h>
44524 +#include <linux/spi/spi.h>
44525 +#include <linux/spi/vsc7385.h>
44527 +#define DRV_NAME "spi-vsc7385"
44528 +#define DRV_DESC "Vitesse VSC7385 Gbit ethernet switch driver"
44529 +#define DRV_VERSION "0.1.0"
44531 +#define VSC73XX_BLOCK_MAC 0x1
44532 +#define VSC73XX_BLOCK_2 0x2
44533 +#define VSC73XX_BLOCK_MII 0x3
44534 +#define VSC73XX_BLOCK_4 0x4
44535 +#define VSC73XX_BLOCK_5 0x5
44536 +#define VSC73XX_BLOCK_SYSTEM 0x7
44538 +#define VSC73XX_SUBBLOCK_PORT_0 0
44539 +#define VSC73XX_SUBBLOCK_PORT_1 1
44540 +#define VSC73XX_SUBBLOCK_PORT_2 2
44541 +#define VSC73XX_SUBBLOCK_PORT_3 3
44542 +#define VSC73XX_SUBBLOCK_PORT_4 4
44543 +#define VSC73XX_SUBBLOCK_PORT_MAC 6
44545 +/* MAC Block registers */
44546 +#define VSC73XX_MAC_CFG 0x0
44547 +#define VSC73XX_ADVPORTM 0x19
44548 +#define VSC73XX_RXOCT 0x50
44549 +#define VSC73XX_TXOCT 0x51
44550 +#define VSC73XX_C_RX0 0x52
44551 +#define VSC73XX_C_RX1 0x53
44552 +#define VSC73XX_C_RX2 0x54
44553 +#define VSC73XX_C_TX0 0x55
44554 +#define VSC73XX_C_TX1 0x56
44555 +#define VSC73XX_C_TX2 0x57
44556 +#define VSC73XX_C_CFG 0x58
44558 +/* MAC_CFG register bits */
44559 +#define VSC73XX_MAC_CFG_WEXC_DIS (1 << 31)
44560 +#define VSC73XX_MAC_CFG_PORT_RST (1 << 29)
44561 +#define VSC73XX_MAC_CFG_TX_EN (1 << 28)
44562 +#define VSC73XX_MAC_CFG_SEED_LOAD (1 << 27)
44563 +#define VSC73XX_MAC_CFG_FDX (1 << 18)
44564 +#define VSC73XX_MAC_CFG_GIGE (1 << 17)
44565 +#define VSC73XX_MAC_CFG_RX_EN (1 << 16)
44566 +#define VSC73XX_MAC_CFG_VLAN_DBLAWR (1 << 15)
44567 +#define VSC73XX_MAC_CFG_VLAN_AWR (1 << 14)
44568 +#define VSC73XX_MAC_CFG_100_BASE_T (1 << 13)
44569 +#define VSC73XX_MAC_CFG_TX_IPG(x) (((x) & 0x1f) << 6)
44570 +#define VSC73XX_MAC_CFG_MAC_RX_RST (1 << 5)
44571 +#define VSC73XX_MAC_CFG_MAC_TX_RST (1 << 4)
44572 +#define VSC73XX_MAC_CFG_BIT2 (1 << 2)
44573 +#define VSC73XX_MAC_CFG_CLK_SEL(x) ((x) & 0x3)
44575 +/* ADVPORTM register bits */
44576 +#define VSC73XX_ADVPORTM_IFG_PPM (1 << 7)
44577 +#define VSC73XX_ADVPORTM_EXC_COL_CONT (1 << 6)
44578 +#define VSC73XX_ADVPORTM_EXT_PORT (1 << 5)
44579 +#define VSC73XX_ADVPORTM_INV_GTX (1 << 4)
44580 +#define VSC73XX_ADVPORTM_ENA_GTX (1 << 3)
44581 +#define VSC73XX_ADVPORTM_DDR_MODE (1 << 2)
44582 +#define VSC73XX_ADVPORTM_IO_LOOPBACK (1 << 1)
44583 +#define VSC73XX_ADVPORTM_HOST_LOOPBACK (1 << 0)
44585 +/* MII Block registers */
44586 +#define VSC73XX_MII_STAT 0x0
44587 +#define VSC73XX_MII_CMD 0x1
44588 +#define VSC73XX_MII_DATA 0x2
44590 +/* System Block registers */
44591 +#define VSC73XX_ICPU_SIPAD 0x01
44592 +#define VSC73XX_ICPU_CLOCK_DELAY 0x05
44593 +#define VSC73XX_ICPU_CTRL 0x10
44594 +#define VSC73XX_ICPU_ADDR 0x11
44595 +#define VSC73XX_ICPU_SRAM 0x12
44596 +#define VSC73XX_ICPU_MBOX_VAL 0x15
44597 +#define VSC73XX_ICPU_MBOX_SET 0x16
44598 +#define VSC73XX_ICPU_MBOX_CLR 0x17
44599 +#define VSC73XX_ICPU_CHIPID 0x18
44600 +#define VSC73XX_ICPU_GPIO 0x34
44602 +#define VSC73XX_ICPU_CTRL_CLK_DIV (1 << 8)
44603 +#define VSC73XX_ICPU_CTRL_SRST_HOLD (1 << 7)
44604 +#define VSC73XX_ICPU_CTRL_BOOT_EN (1 << 3)
44605 +#define VSC73XX_ICPU_CTRL_EXT_ACC_EN (1 << 2)
44606 +#define VSC73XX_ICPU_CTRL_CLK_EN (1 << 1)
44607 +#define VSC73XX_ICPU_CTRL_SRST (1 << 0)
44609 +#define VSC73XX_ICPU_CHIPID_ID_SHIFT 12
44610 +#define VSC73XX_ICPU_CHIPID_ID_MASK 0xffff
44611 +#define VSC73XX_ICPU_CHIPID_REV_SHIFT 28
44612 +#define VSC73XX_ICPU_CHIPID_REV_MASK 0xf
44613 +#define VSC73XX_ICPU_CHIPID_ID_7385 0x7385
44614 +#define VSC73XX_ICPU_CHIPID_ID_7395 0x7395
44616 +#define VSC73XX_CMD_MODE_READ 0
44617 +#define VSC73XX_CMD_MODE_WRITE 1
44618 +#define VSC73XX_CMD_MODE_SHIFT 4
44619 +#define VSC73XX_CMD_BLOCK_SHIFT 5
44620 +#define VSC73XX_CMD_BLOCK_MASK 0x7
44621 +#define VSC73XX_CMD_SUBBLOCK_MASK 0xf
44623 +#define VSC7385_CLOCK_DELAY ((3 << 4) | 3)
44624 +#define VSC7385_CLOCK_DELAY_MASK ((3 << 4) | 3)
44626 +#define VSC73XX_ICPU_CTRL_STOP (VSC73XX_ICPU_CTRL_SRST_HOLD | \
44627 + VSC73XX_ICPU_CTRL_BOOT_EN | \
44628 + VSC73XX_ICPU_CTRL_EXT_ACC_EN)
44630 +#define VSC73XX_ICPU_CTRL_START (VSC73XX_ICPU_CTRL_CLK_DIV | \
44631 + VSC73XX_ICPU_CTRL_BOOT_EN | \
44632 + VSC73XX_ICPU_CTRL_CLK_EN | \
44633 + VSC73XX_ICPU_CTRL_SRST)
44635 +#define VSC7385_ADVPORTM_MASK (VSC73XX_ADVPORTM_IFG_PPM | \
44636 + VSC73XX_ADVPORTM_EXC_COL_CONT | \
44637 + VSC73XX_ADVPORTM_EXT_PORT | \
44638 + VSC73XX_ADVPORTM_INV_GTX | \
44639 + VSC73XX_ADVPORTM_ENA_GTX | \
44640 + VSC73XX_ADVPORTM_DDR_MODE | \
44641 + VSC73XX_ADVPORTM_IO_LOOPBACK | \
44642 + VSC73XX_ADVPORTM_HOST_LOOPBACK)
44644 +#define VSC7385_ADVPORTM_INIT (VSC73XX_ADVPORTM_EXT_PORT | \
44645 + VSC73XX_ADVPORTM_ENA_GTX | \
44646 + VSC73XX_ADVPORTM_DDR_MODE)
44648 +#define VSC7385_MAC_CFG_RESET (VSC73XX_MAC_CFG_PORT_RST | \
44649 + VSC73XX_MAC_CFG_MAC_RX_RST | \
44650 + VSC73XX_MAC_CFG_MAC_TX_RST)
44652 +#define VSC73XX_MAC_CFG_INIT (VSC73XX_MAC_CFG_TX_EN | \
44653 + VSC73XX_MAC_CFG_FDX | \
44654 + VSC73XX_MAC_CFG_GIGE | \
44655 + VSC73XX_MAC_CFG_RX_EN)
44657 +#define VSC73XX_RESET_DELAY 100
44659 +struct vsc7385 {
44660 + struct spi_device *spi;
44661 + struct mutex lock;
44662 + struct vsc7385_platform_data *pdata;
44665 +static int vsc7385_is_addr_valid(u8 block, u8 subblock)
44667 + switch (block) {
44668 + case VSC73XX_BLOCK_MAC:
44669 + switch (subblock) {
44670 + case 0 ... 4:
44671 + case 6:
44672 + return 1;
44674 + break;
44676 + case VSC73XX_BLOCK_2:
44677 + case VSC73XX_BLOCK_SYSTEM:
44678 + switch (subblock) {
44679 + case 0:
44680 + return 1;
44682 + break;
44684 + case VSC73XX_BLOCK_MII:
44685 + case VSC73XX_BLOCK_4:
44686 + case VSC73XX_BLOCK_5:
44687 + switch (subblock) {
44688 + case 0 ... 1:
44689 + return 1;
44691 + break;
44694 + return 0;
44697 +static inline u8 vsc7385_make_addr(u8 mode, u8 block, u8 subblock)
44699 + u8 ret;
44701 + ret = (block & VSC73XX_CMD_BLOCK_MASK) << VSC73XX_CMD_BLOCK_SHIFT;
44702 + ret |= (mode & 1) << VSC73XX_CMD_MODE_SHIFT;
44703 + ret |= subblock & VSC73XX_CMD_SUBBLOCK_MASK;
44705 + return ret;
44708 +static int vsc7385_read(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
44709 + u32 *value)
44711 + u8 cmd[4];
44712 + u8 buf[4];
44713 + struct spi_transfer t[2];
44714 + struct spi_message m;
44715 + int err;
44717 + if (!vsc7385_is_addr_valid(block, subblock))
44718 + return -EINVAL;
44720 + spi_message_init(&m);
44722 + memset(&t, 0, sizeof(t));
44724 + t[0].tx_buf = cmd;
44725 + t[0].len = sizeof(cmd);
44726 + spi_message_add_tail(&t[0], &m);
44728 + t[1].rx_buf = buf;
44729 + t[1].len = sizeof(buf);
44730 + spi_message_add_tail(&t[1], &m);
44732 + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_READ, block, subblock);
44733 + cmd[1] = reg;
44734 + cmd[2] = 0;
44735 + cmd[3] = 0;
44737 + mutex_lock(&vsc->lock);
44738 + err = spi_sync(vsc->spi, &m);
44739 + mutex_unlock(&vsc->lock);
44741 + if (err)
44742 + return err;
44744 + *value = (((u32) buf[0]) << 24) | (((u32) buf[1]) << 16) |
44745 + (((u32) buf[2]) << 8) | ((u32) buf[3]);
44747 + return 0;
44751 +static int vsc7385_write(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
44752 + u32 value)
44754 + u8 cmd[2];
44755 + u8 buf[4];
44756 + struct spi_transfer t[2];
44757 + struct spi_message m;
44758 + int err;
44760 + if (!vsc7385_is_addr_valid(block, subblock))
44761 + return -EINVAL;
44763 + spi_message_init(&m);
44765 + memset(&t, 0, sizeof(t));
44767 + t[0].tx_buf = cmd;
44768 + t[0].len = sizeof(cmd);
44769 + spi_message_add_tail(&t[0], &m);
44771 + t[1].tx_buf = buf;
44772 + t[1].len = sizeof(buf);
44773 + spi_message_add_tail(&t[1], &m);
44775 + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_WRITE, block, subblock);
44776 + cmd[1] = reg;
44778 + buf[0] = (value >> 24) & 0xff;
44779 + buf[1] = (value >> 16) & 0xff;
44780 + buf[2] = (value >> 8) & 0xff;
44781 + buf[3] = value & 0xff;
44783 + mutex_lock(&vsc->lock);
44784 + err = spi_sync(vsc->spi, &m);
44785 + mutex_unlock(&vsc->lock);
44787 + return err;
44790 +static inline int vsc7385_write_verify(struct vsc7385 *vsc, u8 block,
44791 + u8 subblock, u8 reg, u32 value,
44792 + u32 read_mask, u32 read_val)
44794 + struct spi_device *spi = vsc->spi;
44795 + u32 t;
44796 + int err;
44798 + err = vsc7385_write(vsc, block, subblock, reg, value);
44799 + if (err)
44800 + return err;
44802 + err = vsc7385_read(vsc, block, subblock, reg, &t);
44803 + if (err)
44804 + return err;
44806 + if ((t & read_mask) != read_val) {
44807 + dev_err(&spi->dev, "register write error\n");
44808 + return -EIO;
44811 + return 0;
44814 +static inline int vsc7385_set_clock_delay(struct vsc7385 *vsc, u32 val)
44816 + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44817 + VSC73XX_ICPU_CLOCK_DELAY, val);
44820 +static inline int vsc7385_get_clock_delay(struct vsc7385 *vsc, u32 *val)
44822 + return vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44823 + VSC73XX_ICPU_CLOCK_DELAY, val);
44826 +static inline int vsc7385_icpu_stop(struct vsc7385 *vsc)
44828 + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
44829 + VSC73XX_ICPU_CTRL_STOP);
44832 +static inline int vsc7385_icpu_start(struct vsc7385 *vsc)
44834 + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
44835 + VSC73XX_ICPU_CTRL_START);
44838 +static inline int vsc7385_icpu_reset(struct vsc7385 *vsc)
44840 + int rc;
44842 + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_ADDR,
44843 + 0x0000);
44844 + if (rc)
44845 + dev_err(&vsc->spi->dev,
44846 + "could not reset microcode, err=%d\n", rc);
44848 + return rc;
44851 +static int vsc7385_upload_ucode(struct vsc7385 *vsc)
44853 + struct spi_device *spi = vsc->spi;
44854 + const struct firmware *firmware;
44855 + char *ucode_name;
44856 + unsigned char *dp;
44857 + unsigned int curVal;
44858 + int i;
44859 + int diffs;
44860 + int rc;
44862 + ucode_name = (vsc->pdata->ucode_name) ? vsc->pdata->ucode_name
44863 + : "vsc7385_ucode.bin";
44864 + rc = request_firmware(&firmware, ucode_name, &spi->dev);
44865 + if (rc) {
44866 + dev_err(&spi->dev, "request_firmware failed, err=%d\n",
44867 + rc);
44868 + return rc;
44871 + rc = vsc7385_icpu_stop(vsc);
44872 + if (rc)
44873 + goto out;
44875 + rc = vsc7385_icpu_reset(vsc);
44876 + if (rc)
44877 + goto out;
44879 + dev_info(&spi->dev, "uploading microcode...\n");
44881 + dp = (unsigned char *) firmware->data;
44882 + for (i = 0; i < firmware->size; i++) {
44883 + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44884 + VSC73XX_ICPU_SRAM, *dp++);
44885 + if (rc) {
44886 + dev_err(&spi->dev, "could not load microcode, err=%d\n",
44887 + rc);
44888 + goto out;
44892 + rc = vsc7385_icpu_reset(vsc);
44893 + if (rc)
44894 + goto out;
44896 + dev_info(&spi->dev, "verifying microcode...\n");
44898 + dp = (unsigned char *) firmware->data;
44899 + diffs = 0;
44900 + for (i = 0; i < firmware->size; i++) {
44901 + rc = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44902 + VSC73XX_ICPU_SRAM, &curVal);
44903 + if (rc) {
44904 + dev_err(&spi->dev, "could not read microcode %d\n",
44905 + rc);
44906 + goto out;
44909 + if (curVal > 0xff) {
44910 + dev_err(&spi->dev, "bad val read: %04x : %02x %02x\n",
44911 + i, *dp, curVal);
44912 + rc = -EIO;
44913 + goto out;
44916 + if ((curVal & 0xff) != *dp) {
44917 + diffs++;
44918 + dev_err(&spi->dev, "verify error: %04x : %02x %02x\n",
44919 + i, *dp, curVal);
44921 + if (diffs > 4)
44922 + break;
44924 + dp++;
44927 + if (diffs) {
44928 + dev_err(&spi->dev, "microcode verification failed\n");
44929 + rc = -EIO;
44930 + goto out;
44933 + dev_info(&spi->dev, "microcode uploaded\n");
44935 + rc = vsc7385_icpu_start(vsc);
44937 +out:
44938 + release_firmware(firmware);
44939 + return rc;
44942 +static int vsc7385_setup(struct vsc7385 *vsc)
44944 + struct vsc7385_platform_data *pdata = vsc->pdata;
44945 + u32 t;
44946 + int err;
44948 + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44949 + VSC73XX_ICPU_CLOCK_DELAY,
44950 + VSC7385_CLOCK_DELAY,
44951 + VSC7385_CLOCK_DELAY_MASK,
44952 + VSC7385_CLOCK_DELAY);
44953 + if (err)
44954 + goto err;
44956 + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_MAC,
44957 + VSC73XX_SUBBLOCK_PORT_MAC, VSC73XX_ADVPORTM,
44958 + VSC7385_ADVPORTM_INIT,
44959 + VSC7385_ADVPORTM_MASK,
44960 + VSC7385_ADVPORTM_INIT);
44961 + if (err)
44962 + goto err;
44964 + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
44965 + VSC73XX_MAC_CFG, VSC7385_MAC_CFG_RESET);
44966 + if (err)
44967 + goto err;
44969 + t = VSC73XX_MAC_CFG_INIT;
44970 + t |= VSC73XX_MAC_CFG_TX_IPG(pdata->mac_cfg.tx_ipg);
44971 + t |= VSC73XX_MAC_CFG_CLK_SEL(pdata->mac_cfg.clk_sel);
44972 + if (pdata->mac_cfg.bit2)
44973 + t |= VSC73XX_MAC_CFG_BIT2;
44975 + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
44976 + VSC73XX_MAC_CFG, t);
44977 + if (err)
44978 + goto err;
44980 + return 0;
44982 +err:
44983 + return err;
44986 +static int vsc7385_detect(struct vsc7385 *vsc)
44988 + struct spi_device *spi = vsc->spi;
44989 + u32 t;
44990 + u32 id;
44991 + u32 rev;
44992 + int err;
44994 + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
44995 + VSC73XX_ICPU_MBOX_VAL, &t);
44996 + if (err) {
44997 + dev_err(&spi->dev, "unable to read mailbox, err=%d\n", err);
44998 + return err;
45001 + if (t == 0xffffffff) {
45002 + dev_dbg(&spi->dev, "assert chip reset\n");
45003 + if (vsc->pdata->reset)
45004 + vsc->pdata->reset();
45008 + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
45009 + VSC73XX_ICPU_CHIPID, &t);
45010 + if (err) {
45011 + dev_err(&spi->dev, "unable to read chip id, err=%d\n", err);
45012 + return err;
45015 + id = (t >> VSC73XX_ICPU_CHIPID_ID_SHIFT) & VSC73XX_ICPU_CHIPID_ID_MASK;
45016 + switch (id) {
45017 + case VSC73XX_ICPU_CHIPID_ID_7385:
45018 + case VSC73XX_ICPU_CHIPID_ID_7395:
45019 + break;
45020 + default:
45021 + dev_err(&spi->dev, "unsupported chip, id=%04x\n", id);
45022 + return -ENODEV;
45025 + rev = (t >> VSC73XX_ICPU_CHIPID_REV_SHIFT) &
45026 + VSC73XX_ICPU_CHIPID_REV_MASK;
45027 + dev_info(&spi->dev, "VSC%04X (rev. %d) switch found\n", id, rev);
45029 + return 0;
45032 +static int vsc7385_probe(struct spi_device *spi)
45034 + struct vsc7385 *vsc;
45035 + struct vsc7385_platform_data *pdata;
45036 + int err;
45038 + printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
45040 + pdata = spi->dev.platform_data;
45041 + if (!pdata) {
45042 + dev_err(&spi->dev, "no platform data specified\n");
45043 + return -ENODEV;
45046 + vsc = kzalloc(sizeof(*vsc), GFP_KERNEL);
45047 + if (!vsc) {
45048 + dev_err(&spi->dev, "no memory for private data\n");
45049 + return -ENOMEM;
45052 + mutex_init(&vsc->lock);
45053 + vsc->pdata = pdata;
45054 + vsc->spi = spi_dev_get(spi);
45055 + dev_set_drvdata(&spi->dev, vsc);
45057 + spi->mode = SPI_MODE_0;
45058 + spi->bits_per_word = 8;
45059 + err = spi_setup(spi);
45060 + if (err) {
45061 + dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
45062 + goto err_drvdata;
45065 + err = vsc7385_detect(vsc);
45066 + if (err) {
45067 + dev_err(&spi->dev, "no chip found, err=%d\n", err);
45068 + goto err_drvdata;
45071 + err = vsc7385_upload_ucode(vsc);
45072 + if (err)
45073 + goto err_drvdata;
45075 + err = vsc7385_setup(vsc);
45076 + if (err)
45077 + goto err_drvdata;
45079 + return 0;
45081 +err_drvdata:
45082 + dev_set_drvdata(&spi->dev, NULL);
45083 + kfree(vsc);
45084 + return err;
45087 +static int vsc7385_remove(struct spi_device *spi)
45089 + struct vsc7385_data *vsc;
45091 + vsc = dev_get_drvdata(&spi->dev);
45092 + dev_set_drvdata(&spi->dev, NULL);
45093 + kfree(vsc);
45095 + return 0;
45098 +static struct spi_driver vsc7385_driver = {
45099 + .driver = {
45100 + .name = DRV_NAME,
45101 + .bus = &spi_bus_type,
45102 + .owner = THIS_MODULE,
45103 + },
45104 + .probe = vsc7385_probe,
45105 + .remove = vsc7385_remove,
45108 +static int __init vsc7385_init(void)
45110 + return spi_register_driver(&vsc7385_driver);
45112 +module_init(vsc7385_init);
45114 +static void __exit vsc7385_exit(void)
45116 + spi_unregister_driver(&vsc7385_driver);
45118 +module_exit(vsc7385_exit);
45120 +MODULE_DESCRIPTION(DRV_DESC);
45121 +MODULE_VERSION(DRV_VERSION);
45122 +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
45123 +MODULE_LICENSE("GPL v2");
45125 diff -Nur linux-4.1.43.orig/drivers/tty/serial/serial_core.c linux-4.1.43/drivers/tty/serial/serial_core.c
45126 --- linux-4.1.43.orig/drivers/tty/serial/serial_core.c 2017-08-06 01:56:14.000000000 +0200
45127 +++ linux-4.1.43/drivers/tty/serial/serial_core.c 2017-08-06 20:02:16.000000000 +0200
45128 @@ -164,6 +164,8 @@
45129 if (retval == 0) {
45130 if (uart_console(uport) && uport->cons->cflag) {
45131 tty->termios.c_cflag = uport->cons->cflag;
45132 + tty->termios.c_ospeed = uport->cons->baud;
45133 + tty->termios.c_ispeed = uport->cons->baud;
45134 uport->cons->cflag = 0;
45137 @@ -1901,7 +1903,7 @@
45138 { 4800, B4800 },
45139 { 2400, B2400 },
45140 { 1200, B1200 },
45141 - { 0, B38400 }
45142 + { 0, BOTHER }
45146 @@ -1940,10 +1942,13 @@
45147 * Construct a cflag setting.
45149 for (i = 0; baud_rates[i].rate; i++)
45150 - if (baud_rates[i].rate <= baud)
45151 + if (baud_rates[i].rate == baud)
45152 break;
45154 termios.c_cflag |= baud_rates[i].cflag;
45155 + if (!baud_rates[i].rate) {
45156 + termios.c_ospeed = baud;
45159 if (bits == 7)
45160 termios.c_cflag |= CS7;
45161 @@ -1973,8 +1978,10 @@
45162 * Allow the setting of the UART parameters with a NULL console
45163 * too:
45165 - if (co)
45166 + if (co) {
45167 co->cflag = termios.c_cflag;
45168 + co->baud = baud;
45171 return 0;
45173 diff -Nur linux-4.1.43.orig/drivers/usb/host/ehci-hcd.c linux-4.1.43/drivers/usb/host/ehci-hcd.c
45174 --- linux-4.1.43.orig/drivers/usb/host/ehci-hcd.c 2017-08-06 01:56:14.000000000 +0200
45175 +++ linux-4.1.43/drivers/usb/host/ehci-hcd.c 2017-08-06 20:02:16.000000000 +0200
45176 @@ -252,6 +252,37 @@
45177 command |= CMD_RESET;
45178 dbg_cmd (ehci, "reset", command);
45179 ehci_writel(ehci, command, &ehci->regs->command);
45181 + if (ehci->qca_force_host_mode) {
45182 + u32 usbmode;
45184 + udelay(1000);
45186 + usbmode = ehci_readl(ehci, &ehci->regs->usbmode);
45187 + usbmode |= USBMODE_CM_HC | (1 << 4);
45188 + ehci_writel(ehci, usbmode, &ehci->regs->usbmode);
45190 + ehci_dbg(ehci, "forced host mode, usbmode: %08x\n",
45191 + ehci_readl(ehci, &ehci->regs->usbmode));
45194 + if (ehci->qca_force_16bit_ptw) {
45195 + u32 port_status;
45197 + udelay(1000);
45199 + /* enable 16-bit UTMI interface */
45200 + port_status = ehci_readl(ehci, &ehci->regs->port_status[0]);
45201 + port_status |= BIT(28);
45202 + ehci_writel(ehci, port_status, &ehci->regs->port_status[0]);
45204 + ehci_dbg(ehci, "16-bit UTMI interface enabled, status: %08x\n",
45205 + ehci_readl(ehci, &ehci->regs->port_status[0]));
45208 + if (ehci->reset_notifier)
45209 + ehci->reset_notifier(ehci_to_hcd(ehci));
45211 ehci->rh_state = EHCI_RH_HALTED;
45212 ehci->next_statechange = jiffies;
45213 retval = ehci_handshake(ehci, &ehci->regs->command,
45214 diff -Nur linux-4.1.43.orig/drivers/usb/host/ehci-platform.c linux-4.1.43/drivers/usb/host/ehci-platform.c
45215 --- linux-4.1.43.orig/drivers/usb/host/ehci-platform.c 2017-08-06 01:56:14.000000000 +0200
45216 +++ linux-4.1.43/drivers/usb/host/ehci-platform.c 2017-08-06 20:02:16.000000000 +0200
45217 @@ -49,6 +49,14 @@
45219 static const char hcd_name[] = "ehci-platform";
45221 +static void ehci_platform_reset_notifier(struct usb_hcd *hcd)
45223 + struct platform_device *pdev = to_platform_device(hcd->self.controller);
45224 + struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
45226 + pdata->reset_notifier(pdev);
45229 static int ehci_platform_reset(struct usb_hcd *hcd)
45231 struct platform_device *pdev = to_platform_device(hcd->self.controller);
45232 diff -Nur linux-4.1.43.orig/drivers/watchdog/ath79_wdt.c linux-4.1.43/drivers/watchdog/ath79_wdt.c
45233 --- linux-4.1.43.orig/drivers/watchdog/ath79_wdt.c 2017-08-06 01:56:14.000000000 +0200
45234 +++ linux-4.1.43/drivers/watchdog/ath79_wdt.c 2017-08-06 20:02:16.000000000 +0200
45235 @@ -114,10 +114,14 @@
45237 static int ath79_wdt_set_timeout(int val)
45239 - if (val < 1 || val > max_timeout)
45240 + if (val < 1)
45241 return -EINVAL;
45243 - timeout = val;
45244 + if (val > max_timeout)
45245 + timeout = max_timeout;
45246 + else
45247 + timeout = val;
45249 ath79_wdt_keepalive();
45251 return 0;
45252 diff -Nur linux-4.1.43.orig/include/linux/console.h linux-4.1.43/include/linux/console.h
45253 --- linux-4.1.43.orig/include/linux/console.h 2017-08-06 01:56:14.000000000 +0200
45254 +++ linux-4.1.43/include/linux/console.h 2017-08-06 20:02:16.000000000 +0200
45255 @@ -127,6 +127,7 @@
45256 short flags;
45257 short index;
45258 int cflag;
45259 + int baud;
45260 void *data;
45261 struct console *next;
45263 diff -Nur linux-4.1.43.orig/include/linux/ipv6.h linux-4.1.43/include/linux/ipv6.h
45264 --- linux-4.1.43.orig/include/linux/ipv6.h 2017-08-06 01:56:14.000000000 +0200
45265 +++ linux-4.1.43/include/linux/ipv6.h 2017-08-06 20:02:16.000000000 +0200
45266 @@ -5,6 +5,7 @@
45268 #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
45269 #define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
45272 * This structure contains configuration options per IPv6 link.
45274 diff -Nur linux-4.1.43.orig/include/linux/mtd/physmap.h linux-4.1.43/include/linux/mtd/physmap.h
45275 --- linux-4.1.43.orig/include/linux/mtd/physmap.h 2017-08-06 01:56:14.000000000 +0200
45276 +++ linux-4.1.43/include/linux/mtd/physmap.h 2017-08-06 20:02:16.000000000 +0200
45277 @@ -25,6 +25,8 @@
45278 unsigned int width;
45279 int (*init)(struct platform_device *);
45280 void (*exit)(struct platform_device *);
45281 + void (*lock)(struct platform_device *);
45282 + void (*unlock)(struct platform_device *);
45283 void (*set_vpp)(struct platform_device *, int);
45284 unsigned int nr_parts;
45285 unsigned int pfow_base;
45286 diff -Nur linux-4.1.43.orig/include/linux/myloader.h linux-4.1.43/include/linux/myloader.h
45287 --- linux-4.1.43.orig/include/linux/myloader.h 1970-01-01 01:00:00.000000000 +0100
45288 +++ linux-4.1.43/include/linux/myloader.h 2017-08-06 20:02:16.000000000 +0200
45289 @@ -0,0 +1,121 @@
45291 + * Compex's MyLoader specific definitions
45293 + * Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
45295 + * This program is free software; you can redistribute it and/or modify it
45296 + * under the terms of the GNU General Public License version 2 as published
45297 + * by the Free Software Foundation.
45299 + */
45301 +#ifndef _MYLOADER_H_
45302 +#define _MYLOADER_H_
45304 +/* Myloader specific magic numbers */
45305 +#define MYLO_MAGIC_SYS_PARAMS 0x20021107
45306 +#define MYLO_MAGIC_PARTITIONS 0x20021103
45307 +#define MYLO_MAGIC_BOARD_PARAMS 0x20021103
45309 +/* Vendor ID's (seems to be same as the PCI vendor ID's) */
45310 +#define VENID_COMPEX 0x11F6
45312 +/* Devices based on the ADM5120 */
45313 +#define DEVID_COMPEX_NP27G 0x0078
45314 +#define DEVID_COMPEX_NP28G 0x044C
45315 +#define DEVID_COMPEX_NP28GHS 0x044E
45316 +#define DEVID_COMPEX_WP54Gv1C 0x0514
45317 +#define DEVID_COMPEX_WP54G 0x0515
45318 +#define DEVID_COMPEX_WP54AG 0x0546
45319 +#define DEVID_COMPEX_WPP54AG 0x0550
45320 +#define DEVID_COMPEX_WPP54G 0x0555
45322 +/* Devices based on the Atheros AR2317 */
45323 +#define DEVID_COMPEX_NP25G 0x05E6
45324 +#define DEVID_COMPEX_WPE53G 0x05DC
45326 +/* Devices based on the Atheros AR71xx */
45327 +#define DEVID_COMPEX_WP543 0x0640
45328 +#define DEVID_COMPEX_WPE72 0x0672
45330 +/* Devices based on the IXP422 */
45331 +#define DEVID_COMPEX_WP18 0x047E
45332 +#define DEVID_COMPEX_NP18A 0x0489
45334 +/* Other devices */
45335 +#define DEVID_COMPEX_NP26G8M 0x03E8
45336 +#define DEVID_COMPEX_NP26G16M 0x03E9
45338 +struct mylo_partition {
45339 + uint16_t flags; /* partition flags */
45340 + uint16_t type; /* type of the partition */
45341 + uint32_t addr; /* relative address of the partition from the
45342 + flash start */
45343 + uint32_t size; /* size of the partition in bytes */
45344 + uint32_t param; /* if this is the active partition, the
45345 + MyLoader load code to this address */
45348 +#define PARTITION_FLAG_ACTIVE 0x8000 /* this is the active partition,
45349 + * MyLoader loads firmware from here */
45350 +#define PARTITION_FLAG_ISRAM 0x2000 /* FIXME: this is a RAM partition? */
45351 +#define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
45352 +#define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
45353 + * before decompression */
45354 +#define PARTITION_FLAG_LZMA 0x0100 /* partition data compressed by LZMA */
45355 +#define PARTITION_FLAG_HAVEHDR 0x0002 /* the partition data have a header */
45357 +#define PARTITION_TYPE_FREE 0
45358 +#define PARTITION_TYPE_USED 1
45360 +#define MYLO_MAX_PARTITIONS 8 /* maximum number of partitions in the
45361 + partition table */
45363 +struct mylo_partition_table {
45364 + uint32_t magic; /* must be MYLO_MAGIC_PARTITIONS */
45365 + uint32_t res0; /* unknown/unused */
45366 + uint32_t res1; /* unknown/unused */
45367 + uint32_t res2; /* unknown/unused */
45368 + struct mylo_partition partitions[MYLO_MAX_PARTITIONS];
45371 +struct mylo_partition_header {
45372 + uint32_t len; /* length of the partition data */
45373 + uint32_t crc; /* CRC value of the partition data */
45376 +struct mylo_system_params {
45377 + uint32_t magic; /* must be MYLO_MAGIC_SYS_PARAMS */
45378 + uint32_t res0;
45379 + uint32_t res1;
45380 + uint32_t mylo_ver;
45381 + uint16_t vid; /* Vendor ID */
45382 + uint16_t did; /* Device ID */
45383 + uint16_t svid; /* Sub Vendor ID */
45384 + uint16_t sdid; /* Sub Device ID */
45385 + uint32_t rev; /* device revision */
45386 + uint32_t fwhi;
45387 + uint32_t fwlo;
45388 + uint32_t tftp_addr;
45389 + uint32_t prog_start;
45390 + uint32_t flash_size; /* size of boot FLASH in bytes */
45391 + uint32_t dram_size; /* size of onboard RAM in bytes */
45394 +struct mylo_eth_addr {
45395 + uint8_t mac[6];
45396 + uint8_t csum[2];
45399 +#define MYLO_ETHADDR_COUNT 8 /* maximum number of ethernet address
45400 + in the board parameters */
45402 +struct mylo_board_params {
45403 + uint32_t magic; /* must be MYLO_MAGIC_BOARD_PARAMS */
45404 + uint32_t res0;
45405 + uint32_t res1;
45406 + uint32_t res2;
45407 + struct mylo_eth_addr addr[MYLO_ETHADDR_COUNT];
45410 +#endif /* _MYLOADER_H_*/
45411 diff -Nur linux-4.1.43.orig/include/linux/nxp_74hc153.h linux-4.1.43/include/linux/nxp_74hc153.h
45412 --- linux-4.1.43.orig/include/linux/nxp_74hc153.h 1970-01-01 01:00:00.000000000 +0100
45413 +++ linux-4.1.43/include/linux/nxp_74hc153.h 2017-08-06 20:02:16.000000000 +0200
45414 @@ -0,0 +1,24 @@
45416 + * NXP 74HC153 - Dual 4-input multiplexer defines
45418 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
45420 + * This program is free software; you can redistribute it and/or modify
45421 + * it under the terms of the GNU General Public License version 2 as
45422 + * published by the Free Software Foundation.
45423 + */
45425 +#ifndef _NXP_74HC153_H
45426 +#define _NXP_74HC153_H
45428 +#define NXP_74HC153_DRIVER_NAME "nxp-74hc153"
45430 +struct nxp_74hc153_platform_data {
45431 + unsigned gpio_base;
45432 + unsigned gpio_pin_s0;
45433 + unsigned gpio_pin_s1;
45434 + unsigned gpio_pin_1y;
45435 + unsigned gpio_pin_2y;
45438 +#endif /* _NXP_74HC153_H */
45439 diff -Nur linux-4.1.43.orig/include/linux/phy.h linux-4.1.43/include/linux/phy.h
45440 --- linux-4.1.43.orig/include/linux/phy.h 2017-08-06 01:56:14.000000000 +0200
45441 +++ linux-4.1.43/include/linux/phy.h 2017-08-06 20:02:16.000000000 +0200
45442 @@ -762,6 +762,7 @@
45443 void phy_stop_machine(struct phy_device *phydev);
45444 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
45445 int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
45446 +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
45447 int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
45448 int phy_start_interrupts(struct phy_device *phydev);
45449 void phy_print_status(struct phy_device *phydev);
45450 diff -Nur linux-4.1.43.orig/include/linux/platform/ar934x_nfc.h linux-4.1.43/include/linux/platform/ar934x_nfc.h
45451 --- linux-4.1.43.orig/include/linux/platform/ar934x_nfc.h 1970-01-01 01:00:00.000000000 +0100
45452 +++ linux-4.1.43/include/linux/platform/ar934x_nfc.h 2017-08-06 20:02:16.000000000 +0200
45453 @@ -0,0 +1,39 @@
45455 + * Platform data definition for the built-in NAND controller of the
45456 + * Atheros AR934x SoCs
45458 + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
45460 + * This program is free software; you can redistribute it and/or modify it
45461 + * under the terms of the GNU General Public License version 2 as published
45462 + * by the Free Software Foundation.
45463 + */
45465 +#ifndef _AR934X_NFC_PLATFORM_H
45466 +#define _AR934X_NFC_PLATFORM_H
45468 +#define AR934X_NFC_DRIVER_NAME "ar934x-nfc"
45470 +struct mtd_info;
45471 +struct mtd_partition;
45473 +enum ar934x_nfc_ecc_mode {
45474 + AR934X_NFC_ECC_SOFT = 0,
45475 + AR934X_NFC_ECC_HW,
45476 + AR934X_NFC_ECC_SOFT_BCH,
45479 +struct ar934x_nfc_platform_data {
45480 + const char *name;
45481 + struct mtd_partition *parts;
45482 + int nr_parts;
45484 + bool swap_dma;
45485 + enum ar934x_nfc_ecc_mode ecc_mode;
45487 + void (*hw_reset)(bool active);
45488 + void (*select_chip)(int chip_no);
45489 + int (*scan_fixup)(struct mtd_info *mtd);
45492 +#endif /* _AR934X_NFC_PLATFORM_H */
45493 diff -Nur linux-4.1.43.orig/include/linux/platform_data/gpio-latch.h linux-4.1.43/include/linux/platform_data/gpio-latch.h
45494 --- linux-4.1.43.orig/include/linux/platform_data/gpio-latch.h 1970-01-01 01:00:00.000000000 +0100
45495 +++ linux-4.1.43/include/linux/platform_data/gpio-latch.h 2017-08-06 20:02:16.000000000 +0200
45496 @@ -0,0 +1,14 @@
45497 +#ifndef _GPIO_LATCH_H_
45498 +#define _GPIO_LATCH_H_
45500 +#define GPIO_LATCH_DRIVER_NAME "gpio-latch"
45502 +struct gpio_latch_platform_data {
45503 + int base;
45504 + int num_gpios;
45505 + int *gpios;
45506 + int le_gpio_index;
45507 + bool le_active_low;
45510 +#endif /* _GPIO_LATCH_H_ */
45511 diff -Nur linux-4.1.43.orig/include/linux/platform_data/phy-at803x.h linux-4.1.43/include/linux/platform_data/phy-at803x.h
45512 --- linux-4.1.43.orig/include/linux/platform_data/phy-at803x.h 1970-01-01 01:00:00.000000000 +0100
45513 +++ linux-4.1.43/include/linux/platform_data/phy-at803x.h 2017-08-06 20:02:16.000000000 +0200
45514 @@ -0,0 +1,11 @@
45515 +#ifndef _PHY_AT803X_PDATA_H
45516 +#define _PHY_AT803X_PDATA_H
45518 +struct at803x_platform_data {
45519 + int disable_smarteee:1;
45520 + int enable_rgmii_tx_delay:1;
45521 + int enable_rgmii_rx_delay:1;
45522 + int fixup_rgmii_tx_delay:1;
45525 +#endif /* _PHY_AT803X_PDATA_H */
45526 diff -Nur linux-4.1.43.orig/include/linux/platform_data/rb91x_nand.h linux-4.1.43/include/linux/platform_data/rb91x_nand.h
45527 --- linux-4.1.43.orig/include/linux/platform_data/rb91x_nand.h 1970-01-01 01:00:00.000000000 +0100
45528 +++ linux-4.1.43/include/linux/platform_data/rb91x_nand.h 2017-08-06 20:02:16.000000000 +0200
45529 @@ -0,0 +1,16 @@
45530 +#ifndef _RB91X_NAND_H_
45531 +#define _RB91X_NAND_H_
45533 +#define RB91X_NAND_DRIVER_NAME "rb91x-nand"
45535 +struct rb91x_nand_platform_data {
45536 + int gpio_nce; /* chip enable, active low */
45537 + int gpio_ale; /* address latch enable */
45538 + int gpio_cle; /* command latch enable */
45539 + int gpio_rdy;
45540 + int gpio_read;
45541 + int gpio_nrw; /* read/write enable, active low */
45542 + int gpio_nle; /* latch enable, active low */
45545 +#endif /* _RB91X_NAND_H_ */
45546 \ No newline at end of file
45547 diff -Nur linux-4.1.43.orig/include/linux/rle.h linux-4.1.43/include/linux/rle.h
45548 --- linux-4.1.43.orig/include/linux/rle.h 1970-01-01 01:00:00.000000000 +0100
45549 +++ linux-4.1.43/include/linux/rle.h 2017-08-06 20:02:16.000000000 +0200
45550 @@ -0,0 +1,18 @@
45551 +#ifndef _RLE_H_
45552 +#define _RLE_H_
45554 +#ifdef CONFIG_RLE_DECOMPRESS
45555 +int rle_decode(const unsigned char *src, size_t srclen,
45556 + unsigned char *dst, size_t dstlen,
45557 + size_t *src_done, size_t *dst_done);
45558 +#else
45559 +static inline int
45560 +rle_decode(const unsigned char *src, size_t srclen,
45561 + unsigned char *dst, size_t dstlen,
45562 + size_t *src_done, size_t *dst_done)
45564 + return -ENOTSUPP;
45566 +#endif /* CONFIG_RLE_DECOMPRESS */
45568 +#endif /* _RLE_H_ */
45569 diff -Nur linux-4.1.43.orig/include/linux/spi/74x164.h linux-4.1.43/include/linux/spi/74x164.h
45570 --- linux-4.1.43.orig/include/linux/spi/74x164.h 1970-01-01 01:00:00.000000000 +0100
45571 +++ linux-4.1.43/include/linux/spi/74x164.h 2017-08-06 20:02:16.000000000 +0200
45572 @@ -0,0 +1,13 @@
45573 +#ifndef LINUX_SPI_74X164_H
45574 +#define LINUX_SPI_74X164_H
45576 +struct gen_74x164_chip_platform_data {
45577 + /* number assigned to the first GPIO */
45578 + unsigned base;
45579 + /* number of chained registers */
45580 + unsigned num_registers;
45581 + /* address of a buffer containing initial data */
45582 + u8 *init_data;
45585 +#endif
45586 diff -Nur linux-4.1.43.orig/include/linux/spi/flash.h linux-4.1.43/include/linux/spi/flash.h
45587 --- linux-4.1.43.orig/include/linux/spi/flash.h 2017-08-06 01:56:14.000000000 +0200
45588 +++ linux-4.1.43/include/linux/spi/flash.h 2017-08-06 20:02:17.000000000 +0200
45589 @@ -24,6 +24,7 @@
45590 unsigned int nr_parts;
45592 char *type;
45593 + const char **part_probes;
45595 /* we'll likely add more ... use JEDEC IDs, etc */
45597 diff -Nur linux-4.1.43.orig/include/linux/spi/spi.h linux-4.1.43/include/linux/spi/spi.h
45598 --- linux-4.1.43.orig/include/linux/spi/spi.h 2017-08-06 01:56:14.000000000 +0200
45599 +++ linux-4.1.43/include/linux/spi/spi.h 2017-08-06 20:02:17.000000000 +0200
45600 @@ -506,6 +506,12 @@
45602 /*---------------------------------------------------------------------------*/
45604 +enum spi_transfer_type {
45605 + SPI_TRANSFER_GENERIC = 0,
45606 + SPI_TRANSFER_FLASH_READ_CMD,
45607 + SPI_TRANSFER_FLASH_READ_DATA,
45611 * I/O INTERFACE between SPI controller and protocol drivers
45613 @@ -618,12 +624,16 @@
45614 unsigned cs_change:1;
45615 unsigned tx_nbits:3;
45616 unsigned rx_nbits:3;
45617 + unsigned verify:1;
45618 + unsigned fast_write:1;
45619 #define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
45620 #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
45621 #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
45622 u8 bits_per_word;
45623 u16 delay_usecs;
45624 u32 speed_hz;
45625 + enum spi_transfer_type type;
45626 + bool dummy;
45628 struct list_head transfer_list;
45630 @@ -663,6 +673,7 @@
45631 struct spi_device *spi;
45633 unsigned is_dma_mapped:1;
45634 + unsigned fast_read:1;
45636 /* REVISIT: we might want a flag affecting the behavior of the
45637 * last transfer ... allowing things like "read 16 bit length L"
45638 diff -Nur linux-4.1.43.orig/include/linux/spi/spi_bitbang.h linux-4.1.43/include/linux/spi/spi_bitbang.h
45639 --- linux-4.1.43.orig/include/linux/spi/spi_bitbang.h 2017-08-06 01:56:14.000000000 +0200
45640 +++ linux-4.1.43/include/linux/spi/spi_bitbang.h 2017-08-06 20:02:17.000000000 +0200
45641 @@ -39,6 +39,7 @@
45642 extern void spi_bitbang_cleanup(struct spi_device *spi);
45643 extern int spi_bitbang_setup_transfer(struct spi_device *spi,
45644 struct spi_transfer *t);
45645 +extern int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t);
45647 /* start or stop queue processing */
45648 extern int spi_bitbang_start(struct spi_bitbang *spi);
45649 diff -Nur linux-4.1.43.orig/include/linux/spi/vsc7385.h linux-4.1.43/include/linux/spi/vsc7385.h
45650 --- linux-4.1.43.orig/include/linux/spi/vsc7385.h 1970-01-01 01:00:00.000000000 +0100
45651 +++ linux-4.1.43/include/linux/spi/vsc7385.h 2017-08-06 20:02:17.000000000 +0200
45652 @@ -0,0 +1,19 @@
45654 + * Platform data definition for the Vitesse VSC7385 ethernet switch driver
45656 + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
45658 + * This program is free software; you can redistribute it and/or modify it
45659 + * under the terms of the GNU General Public License version 2 as published
45660 + * by the Free Software Foundation.
45661 + */
45663 +struct vsc7385_platform_data {
45664 + void (*reset)(void);
45665 + char *ucode_name;
45666 + struct {
45667 + u32 tx_ipg:5;
45668 + u32 bit2:1;
45669 + u32 clk_sel:3;
45670 + } mac_cfg;
45672 diff -Nur linux-4.1.43.orig/include/linux/switch.h linux-4.1.43/include/linux/switch.h
45673 --- linux-4.1.43.orig/include/linux/switch.h 1970-01-01 01:00:00.000000000 +0100
45674 +++ linux-4.1.43/include/linux/switch.h 2017-08-06 20:02:17.000000000 +0200
45675 @@ -0,0 +1,169 @@
45677 + * switch.h: Switch configuration API
45679 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
45681 + * This program is free software; you can redistribute it and/or
45682 + * modify it under the terms of the GNU General Public License
45683 + * as published by the Free Software Foundation; either version 2
45684 + * of the License, or (at your option) any later version.
45686 + * This program is distributed in the hope that it will be useful,
45687 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
45688 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45689 + * GNU General Public License for more details.
45690 + */
45691 +#ifndef _LINUX_SWITCH_H
45692 +#define _LINUX_SWITCH_H
45694 +#include <net/genetlink.h>
45695 +#include <uapi/linux/switch.h>
45697 +struct switch_dev;
45698 +struct switch_op;
45699 +struct switch_val;
45700 +struct switch_attr;
45701 +struct switch_attrlist;
45702 +struct switch_led_trigger;
45704 +int register_switch(struct switch_dev *dev, struct net_device *netdev);
45705 +void unregister_switch(struct switch_dev *dev);
45707 +/**
45708 + * struct switch_attrlist - attribute list
45710 + * @n_attr: number of attributes
45711 + * @attr: pointer to the attributes array
45712 + */
45713 +struct switch_attrlist {
45714 + int n_attr;
45715 + const struct switch_attr *attr;
45718 +enum switch_port_speed {
45719 + SWITCH_PORT_SPEED_UNKNOWN = 0,
45720 + SWITCH_PORT_SPEED_10 = 10,
45721 + SWITCH_PORT_SPEED_100 = 100,
45722 + SWITCH_PORT_SPEED_1000 = 1000,
45725 +struct switch_port_link {
45726 + bool link;
45727 + bool duplex;
45728 + bool aneg;
45729 + bool tx_flow;
45730 + bool rx_flow;
45731 + enum switch_port_speed speed;
45732 + /* in ethtool adv_t format */
45733 + u32 eee;
45736 +struct switch_port_stats {
45737 + unsigned long tx_bytes;
45738 + unsigned long rx_bytes;
45741 +/**
45742 + * struct switch_dev_ops - switch driver operations
45744 + * @attr_global: global switch attribute list
45745 + * @attr_port: port attribute list
45746 + * @attr_vlan: vlan attribute list
45748 + * Callbacks:
45750 + * @get_vlan_ports: read the port list of a VLAN
45751 + * @set_vlan_ports: set the port list of a VLAN
45753 + * @get_port_pvid: get the primary VLAN ID of a port
45754 + * @set_port_pvid: set the primary VLAN ID of a port
45756 + * @apply_config: apply all changed settings to the switch
45757 + * @reset_switch: resetting the switch
45758 + */
45759 +struct switch_dev_ops {
45760 + struct switch_attrlist attr_global, attr_port, attr_vlan;
45762 + int (*get_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
45763 + int (*set_vlan_ports)(struct switch_dev *dev, struct switch_val *val);
45765 + int (*get_port_pvid)(struct switch_dev *dev, int port, int *val);
45766 + int (*set_port_pvid)(struct switch_dev *dev, int port, int val);
45768 + int (*apply_config)(struct switch_dev *dev);
45769 + int (*reset_switch)(struct switch_dev *dev);
45771 + int (*get_port_link)(struct switch_dev *dev, int port,
45772 + struct switch_port_link *link);
45773 + int (*get_port_stats)(struct switch_dev *dev, int port,
45774 + struct switch_port_stats *stats);
45777 +struct switch_dev {
45778 + struct device_node *of_node;
45779 + const struct switch_dev_ops *ops;
45780 + /* will be automatically filled */
45781 + char devname[IFNAMSIZ];
45783 + const char *name;
45784 + /* NB: either alias or netdev must be set */
45785 + const char *alias;
45786 + struct net_device *netdev;
45788 + int ports;
45789 + int vlans;
45790 + int cpu_port;
45792 + /* the following fields are internal for swconfig */
45793 + int id;
45794 + struct list_head dev_list;
45795 + unsigned long def_global, def_port, def_vlan;
45797 + struct mutex sw_mutex;
45798 + struct switch_port *portbuf;
45799 + struct switch_portmap *portmap;
45801 + char buf[128];
45803 +#ifdef CONFIG_SWCONFIG_LEDS
45804 + struct switch_led_trigger *led_trigger;
45805 +#endif
45808 +struct switch_port {
45809 + u32 id;
45810 + u32 flags;
45813 +struct switch_portmap {
45814 + u32 virt;
45815 + const char *s;
45818 +struct switch_val {
45819 + const struct switch_attr *attr;
45820 + int port_vlan;
45821 + int len;
45822 + union {
45823 + const char *s;
45824 + u32 i;
45825 + struct switch_port *ports;
45826 + } value;
45829 +struct switch_attr {
45830 + int disabled;
45831 + int type;
45832 + const char *name;
45833 + const char *description;
45835 + int (*set)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val);
45836 + int (*get)(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val);
45838 + /* for driver internal use */
45839 + int id;
45840 + int ofs;
45841 + int max;
45844 +#endif /* _LINUX_SWITCH_H */
45845 diff -Nur linux-4.1.43.orig/include/linux/types.h linux-4.1.43/include/linux/types.h
45846 --- linux-4.1.43.orig/include/linux/types.h 2017-08-06 01:56:14.000000000 +0200
45847 +++ linux-4.1.43/include/linux/types.h 2017-08-06 20:02:17.000000000 +0200
45848 @@ -215,5 +215,11 @@
45849 /* clocksource cycle base type */
45850 typedef u64 cycle_t;
45852 +struct net_hdr_word {
45853 + u32 words[1];
45854 +} __attribute__((packed, aligned(2)));
45856 +#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0])
45858 #endif /* __ASSEMBLY__ */
45859 #endif /* _LINUX_TYPES_H */
45860 diff -Nur linux-4.1.43.orig/include/linux/usb/ehci_pdriver.h linux-4.1.43/include/linux/usb/ehci_pdriver.h
45861 --- linux-4.1.43.orig/include/linux/usb/ehci_pdriver.h 2017-08-06 01:56:14.000000000 +0200
45862 +++ linux-4.1.43/include/linux/usb/ehci_pdriver.h 2017-08-06 20:02:17.000000000 +0200
45863 @@ -49,6 +49,8 @@
45864 unsigned no_io_watchdog:1;
45865 unsigned reset_on_resume:1;
45866 unsigned dma_mask_64:1;
45867 + unsigned qca_force_host_mode:1;
45868 + unsigned qca_force_16bit_ptw:1;
45870 /* Turn on all power and clocks */
45871 int (*power_on)(struct platform_device *pdev);
45872 @@ -58,6 +60,7 @@
45873 * turn off everything else */
45874 void (*power_suspend)(struct platform_device *pdev);
45875 int (*pre_setup)(struct usb_hcd *hcd);
45876 + void (*reset_notifier)(struct platform_device *pdev);
45879 #endif /* __USB_CORE_EHCI_PDRIVER_H */
45880 diff -Nur linux-4.1.43.orig/include/net/addrconf.h linux-4.1.43/include/net/addrconf.h
45881 --- linux-4.1.43.orig/include/net/addrconf.h 2017-08-06 01:56:14.000000000 +0200
45882 +++ linux-4.1.43/include/net/addrconf.h 2017-08-06 20:02:17.000000000 +0200
45883 @@ -45,7 +45,7 @@
45884 __be32 reserved2;
45886 struct in6_addr prefix;
45888 +} __attribute__((packed, aligned(2)));
45891 #include <linux/netdevice.h>
45892 diff -Nur linux-4.1.43.orig/include/net/ipv6.h linux-4.1.43/include/net/ipv6.h
45893 --- linux-4.1.43.orig/include/net/ipv6.h 2017-08-06 01:56:14.000000000 +0200
45894 +++ linux-4.1.43/include/net/ipv6.h 2017-08-06 20:02:17.000000000 +0200
45895 @@ -107,7 +107,7 @@
45896 __u8 reserved;
45897 __be16 frag_off;
45898 __be32 identification;
45900 +} __attribute__((packed, aligned(2)));
45902 #define IP6_MF 0x0001
45903 #define IP6_OFFSET 0xFFF8
45904 @@ -415,8 +415,8 @@
45906 #endif
45907 #endif
45908 - addr[0] = wh;
45909 - addr[1] = wl;
45910 + net_hdr_word(&addr[0]) = wh;
45911 + net_hdr_word(&addr[1]) = wl;
45914 static inline void ipv6_addr_set(struct in6_addr *addr,
45915 @@ -475,6 +475,8 @@
45916 const __be32 *a1 = addr1->s6_addr32;
45917 const __be32 *a2 = addr2->s6_addr32;
45918 unsigned int pdw, pbi;
45919 + /* Used for last <32-bit fraction of prefix */
45920 + u32 pbia1, pbia2;
45922 /* check complete u32 in prefix */
45923 pdw = prefixlen >> 5;
45924 @@ -483,7 +485,9 @@
45926 /* check incomplete u32 in prefix */
45927 pbi = prefixlen & 0x1f;
45928 - if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
45929 + pbia1 = net_hdr_word(&a1[pdw]);
45930 + pbia2 = net_hdr_word(&a2[pdw]);
45931 + if (pbi && ((pbia1 ^ pbia2) & htonl((0xffffffff) << (32 - pbi))))
45932 return false;
45934 return true;
45935 @@ -627,13 +631,13 @@
45937 static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen)
45939 - const __be32 *a1 = token1, *a2 = token2;
45940 + const struct in6_addr *a1 = token1, *a2 = token2;
45941 int i;
45943 addrlen >>= 2;
45945 for (i = 0; i < addrlen; i++) {
45946 - __be32 xb = a1[i] ^ a2[i];
45947 + __be32 xb = a1->s6_addr32[i] ^ a2->s6_addr32[i];
45948 if (xb)
45949 return i * 32 + 31 - __fls(ntohl(xb));
45951 @@ -759,17 +763,18 @@
45952 static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
45953 __be32 flowlabel)
45955 - *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | flowlabel;
45956 + net_hdr_word((__be32 *)hdr) =
45957 + htonl(0x60000000 | (tclass << 20)) | flowlabel;
45960 static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
45962 - return *(__be32 *)hdr & IPV6_FLOWINFO_MASK;
45963 + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWINFO_MASK;
45966 static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
45968 - return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK;
45969 + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWLABEL_MASK;
45972 static inline u8 ip6_tclass(__be32 flowinfo)
45973 diff -Nur linux-4.1.43.orig/include/net/ndisc.h linux-4.1.43/include/net/ndisc.h
45974 --- linux-4.1.43.orig/include/net/ndisc.h 2017-08-06 01:56:14.000000000 +0200
45975 +++ linux-4.1.43/include/net/ndisc.h 2017-08-06 20:02:17.000000000 +0200
45976 @@ -76,7 +76,7 @@
45977 struct icmp6hdr icmph;
45978 __be32 reachable_time;
45979 __be32 retrans_timer;
45981 +} __attribute__((packed, aligned(2)));
45983 struct rd_msg {
45984 struct icmp6hdr icmph;
45985 @@ -148,10 +148,10 @@
45987 const u32 *p32 = pkey;
45989 - return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
45990 - (p32[1] * hash_rnd[1]) +
45991 - (p32[2] * hash_rnd[2]) +
45992 - (p32[3] * hash_rnd[3]));
45993 + return (((net_hdr_word(&p32[0]) ^ hash32_ptr(dev)) * hash_rnd[0]) +
45994 + (net_hdr_word(&p32[1]) * hash_rnd[1]) +
45995 + (net_hdr_word(&p32[2]) * hash_rnd[2]) +
45996 + (net_hdr_word(&p32[3]) * hash_rnd[3]));
45999 static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
46000 diff -Nur linux-4.1.43.orig/include/net/neighbour.h linux-4.1.43/include/net/neighbour.h
46001 --- linux-4.1.43.orig/include/net/neighbour.h 2017-08-06 01:56:14.000000000 +0200
46002 +++ linux-4.1.43/include/net/neighbour.h 2017-08-06 20:02:17.000000000 +0200
46003 @@ -262,8 +262,10 @@
46004 const u32 *n32 = (const u32 *)n->primary_key;
46005 const u32 *p32 = pkey;
46007 - return ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
46008 - (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0;
46009 + return ((n32[0] ^ net_hdr_word(&p32[0])) |
46010 + (n32[1] ^ net_hdr_word(&p32[1])) |
46011 + (n32[2] ^ net_hdr_word(&p32[2])) |
46012 + (n32[3] ^ net_hdr_word(&p32[3]))) == 0;
46015 static inline struct neighbour *___neigh_lookup_noref(
46016 diff -Nur linux-4.1.43.orig/include/net/secure_seq.h linux-4.1.43/include/net/secure_seq.h
46017 --- linux-4.1.43.orig/include/net/secure_seq.h 2017-08-06 01:56:14.000000000 +0200
46018 +++ linux-4.1.43/include/net/secure_seq.h 2017-08-06 20:02:17.000000000 +0200
46019 @@ -2,6 +2,7 @@
46020 #define _NET_SECURE_SEQ
46022 #include <linux/types.h>
46023 +#include <linux/in6.h>
46025 u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
46026 u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
46027 diff -Nur linux-4.1.43.orig/include/uapi/linux/Kbuild linux-4.1.43/include/uapi/linux/Kbuild
46028 --- linux-4.1.43.orig/include/uapi/linux/Kbuild 2017-08-06 01:56:14.000000000 +0200
46029 +++ linux-4.1.43/include/uapi/linux/Kbuild 2017-08-06 20:02:17.000000000 +0200
46030 @@ -380,6 +380,7 @@
46031 header-y += string.h
46032 header-y += suspend_ioctls.h
46033 header-y += swab.h
46034 +header-y += switch.h
46035 header-y += synclink.h
46036 header-y += sysctl.h
46037 header-y += sysinfo.h
46038 diff -Nur linux-4.1.43.orig/include/uapi/linux/icmp.h linux-4.1.43/include/uapi/linux/icmp.h
46039 --- linux-4.1.43.orig/include/uapi/linux/icmp.h 2017-08-06 01:56:14.000000000 +0200
46040 +++ linux-4.1.43/include/uapi/linux/icmp.h 2017-08-06 20:02:17.000000000 +0200
46041 @@ -80,7 +80,7 @@
46042 __be16 mtu;
46043 } frag;
46044 } un;
46046 +} __attribute__((packed, aligned(2)));
46050 diff -Nur linux-4.1.43.orig/include/uapi/linux/icmpv6.h linux-4.1.43/include/uapi/linux/icmpv6.h
46051 --- linux-4.1.43.orig/include/uapi/linux/icmpv6.h 2017-08-06 01:56:14.000000000 +0200
46052 +++ linux-4.1.43/include/uapi/linux/icmpv6.h 2017-08-06 20:02:17.000000000 +0200
46053 @@ -76,7 +76,7 @@
46054 #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
46055 #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
46056 #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
46058 +} __attribute__((packed, aligned(2)));
46061 #define ICMPV6_ROUTER_PREF_LOW 0x3
46062 diff -Nur linux-4.1.43.orig/include/uapi/linux/if_pppox.h linux-4.1.43/include/uapi/linux/if_pppox.h
46063 --- linux-4.1.43.orig/include/uapi/linux/if_pppox.h 2017-08-06 01:56:14.000000000 +0200
46064 +++ linux-4.1.43/include/uapi/linux/if_pppox.h 2017-08-06 20:02:17.000000000 +0200
46065 @@ -47,6 +47,7 @@
46067 struct pptp_addr {
46068 __u16 call_id;
46069 + __u16 pad;
46070 struct in_addr sin_addr;
46073 diff -Nur linux-4.1.43.orig/include/uapi/linux/igmp.h linux-4.1.43/include/uapi/linux/igmp.h
46074 --- linux-4.1.43.orig/include/uapi/linux/igmp.h 2017-08-06 01:56:14.000000000 +0200
46075 +++ linux-4.1.43/include/uapi/linux/igmp.h 2017-08-06 20:02:17.000000000 +0200
46076 @@ -32,7 +32,7 @@
46077 __u8 code; /* For newer IGMP */
46078 __sum16 csum;
46079 __be32 group;
46081 +} __attribute__((packed, aligned(2)));
46083 /* V3 group record types [grec_type] */
46084 #define IGMPV3_MODE_IS_INCLUDE 1
46085 @@ -48,7 +48,7 @@
46086 __be16 grec_nsrcs;
46087 __be32 grec_mca;
46088 __be32 grec_src[0];
46090 +} __attribute__((packed, aligned(2)));
46092 struct igmpv3_report {
46093 __u8 type;
46094 @@ -57,7 +57,7 @@
46095 __be16 resv2;
46096 __be16 ngrec;
46097 struct igmpv3_grec grec[0];
46099 +} __attribute__((packed, aligned(2)));
46101 struct igmpv3_query {
46102 __u8 type;
46103 @@ -78,7 +78,7 @@
46104 __u8 qqic;
46105 __be16 nsrcs;
46106 __be32 srcs[0];
46108 +} __attribute__((packed, aligned(2)));
46110 #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
46111 #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
46112 diff -Nur linux-4.1.43.orig/include/uapi/linux/in.h linux-4.1.43/include/uapi/linux/in.h
46113 --- linux-4.1.43.orig/include/uapi/linux/in.h 2017-08-06 01:56:14.000000000 +0200
46114 +++ linux-4.1.43/include/uapi/linux/in.h 2017-08-06 20:02:17.000000000 +0200
46115 @@ -78,7 +78,7 @@
46116 /* Internet address. */
46117 struct in_addr {
46118 __be32 s_addr;
46120 +} __attribute__((packed, aligned(2)));
46122 #define IP_TOS 1
46123 #define IP_TTL 2
46124 diff -Nur linux-4.1.43.orig/include/uapi/linux/in6.h linux-4.1.43/include/uapi/linux/in6.h
46125 --- linux-4.1.43.orig/include/uapi/linux/in6.h 2017-08-06 01:56:14.000000000 +0200
46126 +++ linux-4.1.43/include/uapi/linux/in6.h 2017-08-06 20:02:17.000000000 +0200
46127 @@ -42,7 +42,7 @@
46128 #define s6_addr16 in6_u.u6_addr16
46129 #define s6_addr32 in6_u.u6_addr32
46130 #endif
46132 +} __attribute__((packed, aligned(2)));
46133 #endif /* __UAPI_DEF_IN6_ADDR */
46135 #if __UAPI_DEF_SOCKADDR_IN6
46136 diff -Nur linux-4.1.43.orig/include/uapi/linux/ip.h linux-4.1.43/include/uapi/linux/ip.h
46137 --- linux-4.1.43.orig/include/uapi/linux/ip.h 2017-08-06 01:56:14.000000000 +0200
46138 +++ linux-4.1.43/include/uapi/linux/ip.h 2017-08-06 20:02:17.000000000 +0200
46139 @@ -102,7 +102,7 @@
46140 __be32 saddr;
46141 __be32 daddr;
46142 /*The options start here. */
46144 +} __attribute__((packed, aligned(2)));
46147 struct ip_auth_hdr {
46148 diff -Nur linux-4.1.43.orig/include/uapi/linux/ipv6.h linux-4.1.43/include/uapi/linux/ipv6.h
46149 --- linux-4.1.43.orig/include/uapi/linux/ipv6.h 2017-08-06 01:56:14.000000000 +0200
46150 +++ linux-4.1.43/include/uapi/linux/ipv6.h 2017-08-06 20:02:17.000000000 +0200
46151 @@ -129,7 +129,7 @@
46153 struct in6_addr saddr;
46154 struct in6_addr daddr;
46156 +} __attribute__((packed, aligned(2)));
46159 /* index values for the variables in ipv6_devconf */
46160 diff -Nur linux-4.1.43.orig/include/uapi/linux/netfilter_arp/arp_tables.h linux-4.1.43/include/uapi/linux/netfilter_arp/arp_tables.h
46161 --- linux-4.1.43.orig/include/uapi/linux/netfilter_arp/arp_tables.h 2017-08-06 01:56:14.000000000 +0200
46162 +++ linux-4.1.43/include/uapi/linux/netfilter_arp/arp_tables.h 2017-08-06 20:02:17.000000000 +0200
46163 @@ -68,7 +68,7 @@
46164 __u8 flags;
46165 /* Inverse flags */
46166 __u16 invflags;
46168 +} __attribute__((aligned(4)));
46170 /* Values for "flag" field in struct arpt_ip (general arp structure).
46171 * No flags defined yet.
46172 diff -Nur linux-4.1.43.orig/include/uapi/linux/switch.h linux-4.1.43/include/uapi/linux/switch.h
46173 --- linux-4.1.43.orig/include/uapi/linux/switch.h 1970-01-01 01:00:00.000000000 +0100
46174 +++ linux-4.1.43/include/uapi/linux/switch.h 2017-08-06 20:02:17.000000000 +0200
46175 @@ -0,0 +1,103 @@
46177 + * switch.h: Switch configuration API
46179 + * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
46181 + * This program is free software; you can redistribute it and/or
46182 + * modify it under the terms of the GNU General Public License
46183 + * as published by the Free Software Foundation; either version 2
46184 + * of the License, or (at your option) any later version.
46186 + * This program is distributed in the hope that it will be useful,
46187 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
46188 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46189 + * GNU General Public License for more details.
46190 + */
46192 +#ifndef _UAPI_LINUX_SWITCH_H
46193 +#define _UAPI_LINUX_SWITCH_H
46195 +#include <linux/types.h>
46196 +#include <linux/netdevice.h>
46197 +#include <linux/netlink.h>
46198 +#include <linux/genetlink.h>
46199 +#ifndef __KERNEL__
46200 +#include <netlink/netlink.h>
46201 +#include <netlink/genl/genl.h>
46202 +#include <netlink/genl/ctrl.h>
46203 +#endif
46205 +/* main attributes */
46206 +enum {
46207 + SWITCH_ATTR_UNSPEC,
46208 + /* global */
46209 + SWITCH_ATTR_TYPE,
46210 + /* device */
46211 + SWITCH_ATTR_ID,
46212 + SWITCH_ATTR_DEV_NAME,
46213 + SWITCH_ATTR_ALIAS,
46214 + SWITCH_ATTR_NAME,
46215 + SWITCH_ATTR_VLANS,
46216 + SWITCH_ATTR_PORTS,
46217 + SWITCH_ATTR_PORTMAP,
46218 + SWITCH_ATTR_CPU_PORT,
46219 + /* attributes */
46220 + SWITCH_ATTR_OP_ID,
46221 + SWITCH_ATTR_OP_TYPE,
46222 + SWITCH_ATTR_OP_NAME,
46223 + SWITCH_ATTR_OP_PORT,
46224 + SWITCH_ATTR_OP_VLAN,
46225 + SWITCH_ATTR_OP_VALUE_INT,
46226 + SWITCH_ATTR_OP_VALUE_STR,
46227 + SWITCH_ATTR_OP_VALUE_PORTS,
46228 + SWITCH_ATTR_OP_DESCRIPTION,
46229 + /* port lists */
46230 + SWITCH_ATTR_PORT,
46231 + SWITCH_ATTR_MAX
46234 +enum {
46235 + /* port map */
46236 + SWITCH_PORTMAP_PORTS,
46237 + SWITCH_PORTMAP_SEGMENT,
46238 + SWITCH_PORTMAP_VIRT,
46239 + SWITCH_PORTMAP_MAX
46242 +/* commands */
46243 +enum {
46244 + SWITCH_CMD_UNSPEC,
46245 + SWITCH_CMD_GET_SWITCH,
46246 + SWITCH_CMD_NEW_ATTR,
46247 + SWITCH_CMD_LIST_GLOBAL,
46248 + SWITCH_CMD_GET_GLOBAL,
46249 + SWITCH_CMD_SET_GLOBAL,
46250 + SWITCH_CMD_LIST_PORT,
46251 + SWITCH_CMD_GET_PORT,
46252 + SWITCH_CMD_SET_PORT,
46253 + SWITCH_CMD_LIST_VLAN,
46254 + SWITCH_CMD_GET_VLAN,
46255 + SWITCH_CMD_SET_VLAN
46258 +/* data types */
46259 +enum switch_val_type {
46260 + SWITCH_TYPE_UNSPEC,
46261 + SWITCH_TYPE_INT,
46262 + SWITCH_TYPE_STRING,
46263 + SWITCH_TYPE_PORTS,
46264 + SWITCH_TYPE_NOVAL,
46267 +/* port nested attributes */
46268 +enum {
46269 + SWITCH_PORT_UNSPEC,
46270 + SWITCH_PORT_ID,
46271 + SWITCH_PORT_FLAG_TAGGED,
46272 + SWITCH_PORT_ATTR_MAX
46275 +#define SWITCH_ATTR_DEFAULTS_OFFSET 0x1000
46278 +#endif /* _UAPI_LINUX_SWITCH_H */
46279 diff -Nur linux-4.1.43.orig/include/uapi/linux/tcp.h linux-4.1.43/include/uapi/linux/tcp.h
46280 --- linux-4.1.43.orig/include/uapi/linux/tcp.h 2017-08-06 01:56:14.000000000 +0200
46281 +++ linux-4.1.43/include/uapi/linux/tcp.h 2017-08-06 20:02:17.000000000 +0200
46282 @@ -54,7 +54,7 @@
46283 __be16 window;
46284 __sum16 check;
46285 __be16 urg_ptr;
46287 +} __attribute__((packed, aligned(2)));
46290 * The union cast uses a gcc extension to avoid aliasing problems
46291 @@ -64,7 +64,7 @@
46292 union tcp_word_hdr {
46293 struct tcphdr hdr;
46294 __be32 words[5];
46295 -};
46296 +} __attribute__((packed, aligned(2)));
46298 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
46300 diff -Nur linux-4.1.43.orig/include/uapi/linux/udp.h linux-4.1.43/include/uapi/linux/udp.h
46301 --- linux-4.1.43.orig/include/uapi/linux/udp.h 2017-08-06 01:56:14.000000000 +0200
46302 +++ linux-4.1.43/include/uapi/linux/udp.h 2017-08-06 20:02:17.000000000 +0200
46303 @@ -24,7 +24,7 @@
46304 __be16 dest;
46305 __be16 len;
46306 __sum16 check;
46308 +} __attribute__((packed, aligned(2)));
46310 /* UDP socket options */
46311 #define UDP_CORK 1 /* Never send partially complete segments */
46312 diff -Nur linux-4.1.43.orig/lib/Kconfig linux-4.1.43/lib/Kconfig
46313 --- linux-4.1.43.orig/lib/Kconfig 2017-08-06 01:56:14.000000000 +0200
46314 +++ linux-4.1.43/lib/Kconfig 2017-08-06 20:02:17.000000000 +0200
46315 @@ -235,6 +235,9 @@
46317 source "lib/xz/Kconfig"
46319 +config RLE_DECOMPRESS
46320 + tristate
46323 # These all provide a common interface (hence the apparent duplication with
46324 # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
46325 diff -Nur linux-4.1.43.orig/lib/rle.c linux-4.1.43/lib/rle.c
46326 --- linux-4.1.43.orig/lib/rle.c 1970-01-01 01:00:00.000000000 +0100
46327 +++ linux-4.1.43/lib/rle.c 2017-08-06 20:02:17.000000000 +0200
46328 @@ -0,0 +1,78 @@
46330 + * RLE decoding routine
46332 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
46334 + * This program is free software; you can redistribute it and/or modify it
46335 + * under the terms of the GNU General Public License version 2 as published
46336 + * by the Free Software Foundation.
46337 + */
46339 +#include <linux/kernel.h>
46340 +#include <linux/module.h>
46341 +#include <linux/rle.h>
46343 +int rle_decode(const unsigned char *src, size_t srclen,
46344 + unsigned char *dst, size_t dstlen,
46345 + size_t *src_done, size_t *dst_done)
46347 + size_t srcpos, dstpos;
46348 + int ret;
46350 + srcpos = 0;
46351 + dstpos = 0;
46352 + ret = -EINVAL;
46354 + /* sanity checks */
46355 + if (!src || !srclen || !dst || !dstlen)
46356 + goto out;
46358 + while (1) {
46359 + char count;
46361 + if (srcpos >= srclen)
46362 + break;
46364 + count = (char) src[srcpos++];
46365 + if (count == 0) {
46366 + ret = 0;
46367 + break;
46370 + if (count > 0) {
46371 + unsigned char c;
46373 + if (srcpos >= srclen)
46374 + break;
46376 + c = src[srcpos++];
46378 + while (count--) {
46379 + if (dstpos >= dstlen)
46380 + break;
46382 + dst[dstpos++] = c;
46384 + } else {
46385 + count *= -1;
46387 + while (count--) {
46388 + if (srcpos >= srclen)
46389 + break;
46390 + if (dstpos >= dstlen)
46391 + break;
46392 + dst[dstpos++] = src[srcpos++];
46397 +out:
46398 + if (src_done)
46399 + *src_done = srcpos;
46400 + if (dst_done)
46401 + *dst_done = dstpos;
46403 + return ret;
46406 +EXPORT_SYMBOL_GPL(rle_decode);
46407 diff -Nur linux-4.1.43.orig/net/core/flow_dissector.c linux-4.1.43/net/core/flow_dissector.c
46408 --- linux-4.1.43.orig/net/core/flow_dissector.c 2017-08-06 01:56:14.000000000 +0200
46409 +++ linux-4.1.43/net/core/flow_dissector.c 2017-08-06 20:02:17.000000000 +0200
46410 @@ -53,7 +53,7 @@
46411 ports = __skb_header_pointer(skb, thoff + poff,
46412 sizeof(_ports), data, hlen, &_ports);
46413 if (ports)
46414 - return *ports;
46415 + return (__be32)net_hdr_word(ports);
46418 return 0;
46419 diff -Nur linux-4.1.43.orig/net/core/secure_seq.c linux-4.1.43/net/core/secure_seq.c
46420 --- linux-4.1.43.orig/net/core/secure_seq.c 2017-08-06 01:56:14.000000000 +0200
46421 +++ linux-4.1.43/net/core/secure_seq.c 2017-08-06 20:02:17.000000000 +0200
46422 @@ -46,11 +46,12 @@
46423 u32 secret[MD5_MESSAGE_BYTES / 4];
46424 u32 hash[MD5_DIGEST_WORDS];
46425 u32 i;
46426 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
46428 net_secret_init();
46429 memcpy(hash, saddr, 16);
46430 for (i = 0; i < 4; i++)
46431 - secret[i] = net_secret[i] + (__force u32)daddr[i];
46432 + secret[i] = net_secret[i] + (__force u32)daddr6->s6_addr32[i];
46433 secret[4] = net_secret[4] +
46434 (((__force u16)sport << 16) + (__force u16)dport);
46435 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
46436 @@ -68,11 +69,12 @@
46437 u32 secret[MD5_MESSAGE_BYTES / 4];
46438 u32 hash[MD5_DIGEST_WORDS];
46439 u32 i;
46440 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
46442 net_secret_init();
46443 memcpy(hash, saddr, 16);
46444 for (i = 0; i < 4; i++)
46445 - secret[i] = net_secret[i] + (__force u32) daddr[i];
46446 + secret[i] = net_secret[i] + (__force u32) daddr6->s6_addr32[i];
46447 secret[4] = net_secret[4] + (__force u32)dport;
46448 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
46449 secret[i] = net_secret[i];
46450 @@ -150,11 +152,12 @@
46451 u32 hash[MD5_DIGEST_WORDS];
46452 u64 seq;
46453 u32 i;
46454 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
46456 net_secret_init();
46457 memcpy(hash, saddr, 16);
46458 for (i = 0; i < 4; i++)
46459 - secret[i] = net_secret[i] + daddr[i];
46460 + secret[i] = net_secret[i] + daddr6->s6_addr32[i];
46461 secret[4] = net_secret[4] +
46462 (((__force u16)sport << 16) + (__force u16)dport);
46463 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
46464 diff -Nur linux-4.1.43.orig/net/dsa/mv88e6063.c linux-4.1.43/net/dsa/mv88e6063.c
46465 --- linux-4.1.43.orig/net/dsa/mv88e6063.c 1970-01-01 01:00:00.000000000 +0100
46466 +++ linux-4.1.43/net/dsa/mv88e6063.c 2017-08-06 20:02:17.000000000 +0200
46467 @@ -0,0 +1,294 @@
46469 + * net/dsa/mv88e6063.c - Driver for Marvell 88e6063 switch chips
46470 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
46472 + * This driver was base on: net/dsa/mv88e6060.c
46473 + * net/dsa/mv88e6063.c - Driver for Marvell 88e6060 switch chips
46474 + * Copyright (c) 2008-2009 Marvell Semiconductor
46476 + * This program is free software; you can redistribute it and/or modify
46477 + * it under the terms of the GNU General Public License as published by
46478 + * the Free Software Foundation; either version 2 of the License, or
46479 + * (at your option) any later version.
46480 + */
46482 +#include <linux/list.h>
46483 +#include <linux/netdevice.h>
46484 +#include <linux/phy.h>
46485 +#include "dsa_priv.h"
46487 +#define REG_BASE 0x10
46488 +#define REG_PHY(p) (REG_BASE + (p))
46489 +#define REG_PORT(p) (REG_BASE + 8 + (p))
46490 +#define REG_GLOBAL (REG_BASE + 0x0f)
46491 +#define NUM_PORTS 7
46493 +static int reg_read(struct dsa_switch *ds, int addr, int reg)
46495 + return mdiobus_read(ds->master_mii_bus, addr, reg);
46498 +#define REG_READ(addr, reg) \
46499 + ({ \
46500 + int __ret; \
46502 + __ret = reg_read(ds, addr, reg); \
46503 + if (__ret < 0) \
46504 + return __ret; \
46505 + __ret; \
46506 + })
46509 +static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
46511 + return mdiobus_write(ds->master_mii_bus, addr, reg, val);
46514 +#define REG_WRITE(addr, reg, val) \
46515 + ({ \
46516 + int __ret; \
46518 + __ret = reg_write(ds, addr, reg, val); \
46519 + if (__ret < 0) \
46520 + return __ret; \
46521 + })
46523 +static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
46525 + int ret;
46527 + ret = mdiobus_read(bus, REG_PORT(0), 0x03);
46528 + if (ret >= 0) {
46529 + ret &= 0xfff0;
46530 + if (ret == 0x1530)
46531 + return "Marvell 88E6063";
46534 + return NULL;
46537 +static int mv88e6063_switch_reset(struct dsa_switch *ds)
46539 + int i;
46540 + int ret;
46542 + /*
46543 + * Set all ports to the disabled state.
46544 + */
46545 + for (i = 0; i < NUM_PORTS; i++) {
46546 + ret = REG_READ(REG_PORT(i), 0x04);
46547 + REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
46550 + /*
46551 + * Wait for transmit queues to drain.
46552 + */
46553 + msleep(2);
46555 + /*
46556 + * Reset the switch.
46557 + */
46558 + REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
46560 + /*
46561 + * Wait up to one second for reset to complete.
46562 + */
46563 + for (i = 0; i < 1000; i++) {
46564 + ret = REG_READ(REG_GLOBAL, 0x00);
46565 + if ((ret & 0x8000) == 0x0000)
46566 + break;
46568 + msleep(1);
46570 + if (i == 1000)
46571 + return -ETIMEDOUT;
46573 + return 0;
46576 +static int mv88e6063_setup_global(struct dsa_switch *ds)
46578 + /*
46579 + * Disable discarding of frames with excessive collisions,
46580 + * set the maximum frame size to 1536 bytes, and mask all
46581 + * interrupt sources.
46582 + */
46583 + REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
46585 + /*
46586 + * Enable automatic address learning, set the address
46587 + * database size to 1024 entries, and set the default aging
46588 + * time to 5 minutes.
46589 + */
46590 + REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
46592 + return 0;
46595 +static int mv88e6063_setup_port(struct dsa_switch *ds, int p)
46597 + int addr = REG_PORT(p);
46599 + /*
46600 + * Do not force flow control, disable Ingress and Egress
46601 + * Header tagging, disable VLAN tunneling, and set the port
46602 + * state to Forwarding. Additionally, if this is the CPU
46603 + * port, enable Ingress and Egress Trailer tagging mode.
46604 + */
46605 + REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ? 0x4103 : 0x0003);
46607 + /*
46608 + * Port based VLAN map: give each port its own address
46609 + * database, allow the CPU port to talk to each of the 'real'
46610 + * ports, and allow each of the 'real' ports to only talk to
46611 + * the CPU port.
46612 + */
46613 + REG_WRITE(addr, 0x06,
46614 + ((p & 0xf) << 12) |
46615 + (dsa_is_cpu_port(ds, p) ?
46616 + ds->phys_port_mask :
46617 + (1 << ds->dst->cpu_port)));
46619 + /*
46620 + * Port Association Vector: when learning source addresses
46621 + * of packets, add the address to the address database using
46622 + * a port bitmap that has only the bit for this port set and
46623 + * the other bits clear.
46624 + */
46625 + REG_WRITE(addr, 0x0b, 1 << p);
46627 + return 0;
46630 +static int mv88e6063_setup(struct dsa_switch *ds)
46632 + int i;
46633 + int ret;
46635 + ret = mv88e6063_switch_reset(ds);
46636 + if (ret < 0)
46637 + return ret;
46639 + /* @@@ initialise atu */
46641 + ret = mv88e6063_setup_global(ds);
46642 + if (ret < 0)
46643 + return ret;
46645 + for (i = 0; i < NUM_PORTS; i++) {
46646 + ret = mv88e6063_setup_port(ds, i);
46647 + if (ret < 0)
46648 + return ret;
46651 + return 0;
46654 +static int mv88e6063_set_addr(struct dsa_switch *ds, u8 *addr)
46656 + REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
46657 + REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
46658 + REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);
46660 + return 0;
46663 +static int mv88e6063_port_to_phy_addr(int port)
46665 + if (port >= 0 && port <= NUM_PORTS)
46666 + return REG_PHY(port);
46667 + return -1;
46670 +static int mv88e6063_phy_read(struct dsa_switch *ds, int port, int regnum)
46672 + int addr;
46674 + addr = mv88e6063_port_to_phy_addr(port);
46675 + if (addr == -1)
46676 + return 0xffff;
46678 + return reg_read(ds, addr, regnum);
46681 +static int
46682 +mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
46684 + int addr;
46686 + addr = mv88e6063_port_to_phy_addr(port);
46687 + if (addr == -1)
46688 + return 0xffff;
46690 + return reg_write(ds, addr, regnum, val);
46693 +static void mv88e6063_poll_link(struct dsa_switch *ds)
46695 + int i;
46697 + for (i = 0; i < DSA_MAX_PORTS; i++) {
46698 + struct net_device *dev;
46699 + int uninitialized_var(port_status);
46700 + int link;
46701 + int speed;
46702 + int duplex;
46703 + int fc;
46705 + dev = ds->ports[i];
46706 + if (dev == NULL)
46707 + continue;
46709 + link = 0;
46710 + if (dev->flags & IFF_UP) {
46711 + port_status = reg_read(ds, REG_PORT(i), 0x00);
46712 + if (port_status < 0)
46713 + continue;
46715 + link = !!(port_status & 0x1000);
46718 + if (!link) {
46719 + if (netif_carrier_ok(dev)) {
46720 + printk(KERN_INFO "%s: link down\n", dev->name);
46721 + netif_carrier_off(dev);
46723 + continue;
46726 + speed = (port_status & 0x0100) ? 100 : 10;
46727 + duplex = (port_status & 0x0200) ? 1 : 0;
46728 + fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
46730 + if (!netif_carrier_ok(dev)) {
46731 + printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
46732 + "flow control %sabled\n", dev->name,
46733 + speed, duplex ? "full" : "half",
46734 + fc ? "en" : "dis");
46735 + netif_carrier_on(dev);
46740 +static struct dsa_switch_driver mv88e6063_switch_driver = {
46741 + .tag_protocol = htons(ETH_P_TRAILER),
46742 + .probe = mv88e6063_probe,
46743 + .setup = mv88e6063_setup,
46744 + .set_addr = mv88e6063_set_addr,
46745 + .phy_read = mv88e6063_phy_read,
46746 + .phy_write = mv88e6063_phy_write,
46747 + .poll_link = mv88e6063_poll_link,
46750 +static int __init mv88e6063_init(void)
46752 + register_switch_driver(&mv88e6063_switch_driver);
46753 + return 0;
46755 +module_init(mv88e6063_init);
46757 +static void __exit mv88e6063_cleanup(void)
46759 + unregister_switch_driver(&mv88e6063_switch_driver);
46761 +module_exit(mv88e6063_cleanup);
46762 diff -Nur linux-4.1.43.orig/net/dsa/tag_trailer.c linux-4.1.43/net/dsa/tag_trailer.c
46763 --- linux-4.1.43.orig/net/dsa/tag_trailer.c 2017-08-06 01:56:14.000000000 +0200
46764 +++ linux-4.1.43/net/dsa/tag_trailer.c 2017-08-06 20:02:17.000000000 +0200
46765 @@ -84,7 +84,7 @@
46767 trailer = skb_tail_pointer(skb) - 4;
46768 if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
46769 - (trailer[3] & 0xef) != 0x00 || trailer[3] != 0x00)
46770 + (trailer[2] & 0xef) != 0x00 || (trailer[3] & 0xfe) != 0x00)
46771 goto out_drop;
46773 source_port = trailer[1] & 7;
46774 diff -Nur linux-4.1.43.orig/net/ipv4/af_inet.c linux-4.1.43/net/ipv4/af_inet.c
46775 --- linux-4.1.43.orig/net/ipv4/af_inet.c 2017-08-06 01:56:14.000000000 +0200
46776 +++ linux-4.1.43/net/ipv4/af_inet.c 2017-08-06 20:02:17.000000000 +0200
46777 @@ -1326,8 +1326,8 @@
46778 if (unlikely(ip_fast_csum((u8 *)iph, 5)))
46779 goto out_unlock;
46781 - id = ntohl(*(__be32 *)&iph->id);
46782 - flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));
46783 + id = ntohl(net_hdr_word(&iph->id));
46784 + flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id & ~IP_DF));
46785 id >>= 16;
46787 for (p = *head; p; p = p->next) {
46788 diff -Nur linux-4.1.43.orig/net/ipv4/igmp.c linux-4.1.43/net/ipv4/igmp.c
46789 --- linux-4.1.43.orig/net/ipv4/igmp.c 2017-08-06 01:56:14.000000000 +0200
46790 +++ linux-4.1.43/net/ipv4/igmp.c 2017-08-06 20:02:17.000000000 +0200
46791 @@ -495,7 +495,7 @@
46792 if (!skb)
46793 return NULL;
46794 psrc = (__be32 *)skb_put(skb, sizeof(__be32));
46795 - *psrc = psf->sf_inaddr;
46796 + net_hdr_word(psrc) = psf->sf_inaddr;
46797 scount++; stotal++;
46798 if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
46799 type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
46800 diff -Nur linux-4.1.43.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux-4.1.43/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
46801 --- linux-4.1.43.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2017-08-06 01:56:14.000000000 +0200
46802 +++ linux-4.1.43/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2017-08-06 20:02:17.000000000 +0200
46803 @@ -41,8 +41,8 @@
46804 if (ap == NULL)
46805 return false;
46807 - tuple->src.u3.ip = ap[0];
46808 - tuple->dst.u3.ip = ap[1];
46809 + tuple->src.u3.ip = net_hdr_word(ap++);
46810 + tuple->dst.u3.ip = net_hdr_word(ap);
46812 return true;
46814 diff -Nur linux-4.1.43.orig/net/ipv4/route.c linux-4.1.43/net/ipv4/route.c
46815 --- linux-4.1.43.orig/net/ipv4/route.c 2017-08-06 01:56:14.000000000 +0200
46816 +++ linux-4.1.43/net/ipv4/route.c 2017-08-06 20:02:17.000000000 +0200
46817 @@ -451,7 +451,7 @@
46818 else if (skb)
46819 pkey = &ip_hdr(skb)->daddr;
46821 - n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey);
46822 + n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey));
46823 if (n)
46824 return n;
46825 return neigh_create(&arp_tbl, pkey, dev);
46826 diff -Nur linux-4.1.43.orig/net/ipv4/tcp_input.c linux-4.1.43/net/ipv4/tcp_input.c
46827 --- linux-4.1.43.orig/net/ipv4/tcp_input.c 2017-08-06 01:56:14.000000000 +0200
46828 +++ linux-4.1.43/net/ipv4/tcp_input.c 2017-08-06 20:02:17.000000000 +0200
46829 @@ -3771,14 +3771,16 @@
46831 const __be32 *ptr = (const __be32 *)(th + 1);
46833 - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
46834 - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
46835 + if (net_hdr_word(ptr) ==
46836 + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
46837 + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
46838 tp->rx_opt.saw_tstamp = 1;
46839 ++ptr;
46840 - tp->rx_opt.rcv_tsval = ntohl(*ptr);
46841 + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr);
46842 ++ptr;
46843 - if (*ptr)
46844 - tp->rx_opt.rcv_tsecr = ntohl(*ptr) - tp->tsoffset;
46845 + if (net_hdr_word(ptr))
46846 + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr) -
46847 + tp->tsoffset;
46848 else
46849 tp->rx_opt.rcv_tsecr = 0;
46850 return true;
46851 diff -Nur linux-4.1.43.orig/net/ipv4/tcp_output.c linux-4.1.43/net/ipv4/tcp_output.c
46852 --- linux-4.1.43.orig/net/ipv4/tcp_output.c 2017-08-06 01:56:14.000000000 +0200
46853 +++ linux-4.1.43/net/ipv4/tcp_output.c 2017-08-06 20:02:17.000000000 +0200
46854 @@ -452,48 +452,53 @@
46855 u16 options = opts->options; /* mungable copy */
46857 if (unlikely(OPTION_MD5 & options)) {
46858 - *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
46859 - (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
46860 + net_hdr_word(ptr++) =
46861 + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
46862 + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
46863 /* overload cookie hash location */
46864 opts->hash_location = (__u8 *)ptr;
46865 ptr += 4;
46868 if (unlikely(opts->mss)) {
46869 - *ptr++ = htonl((TCPOPT_MSS << 24) |
46870 - (TCPOLEN_MSS << 16) |
46871 - opts->mss);
46872 + net_hdr_word(ptr++) =
46873 + htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) |
46874 + opts->mss);
46877 if (likely(OPTION_TS & options)) {
46878 if (unlikely(OPTION_SACK_ADVERTISE & options)) {
46879 - *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
46880 - (TCPOLEN_SACK_PERM << 16) |
46881 - (TCPOPT_TIMESTAMP << 8) |
46882 - TCPOLEN_TIMESTAMP);
46883 + net_hdr_word(ptr++) =
46884 + htonl((TCPOPT_SACK_PERM << 24) |
46885 + (TCPOLEN_SACK_PERM << 16) |
46886 + (TCPOPT_TIMESTAMP << 8) |
46887 + TCPOLEN_TIMESTAMP);
46888 options &= ~OPTION_SACK_ADVERTISE;
46889 } else {
46890 - *ptr++ = htonl((TCPOPT_NOP << 24) |
46891 - (TCPOPT_NOP << 16) |
46892 - (TCPOPT_TIMESTAMP << 8) |
46893 - TCPOLEN_TIMESTAMP);
46894 + net_hdr_word(ptr++) =
46895 + htonl((TCPOPT_NOP << 24) |
46896 + (TCPOPT_NOP << 16) |
46897 + (TCPOPT_TIMESTAMP << 8) |
46898 + TCPOLEN_TIMESTAMP);
46900 - *ptr++ = htonl(opts->tsval);
46901 - *ptr++ = htonl(opts->tsecr);
46902 + net_hdr_word(ptr++) = htonl(opts->tsval);
46903 + net_hdr_word(ptr++) = htonl(opts->tsecr);
46906 if (unlikely(OPTION_SACK_ADVERTISE & options)) {
46907 - *ptr++ = htonl((TCPOPT_NOP << 24) |
46908 - (TCPOPT_NOP << 16) |
46909 - (TCPOPT_SACK_PERM << 8) |
46910 - TCPOLEN_SACK_PERM);
46911 + net_hdr_word(ptr++) =
46912 + htonl((TCPOPT_NOP << 24) |
46913 + (TCPOPT_NOP << 16) |
46914 + (TCPOPT_SACK_PERM << 8) |
46915 + TCPOLEN_SACK_PERM);
46918 if (unlikely(OPTION_WSCALE & options)) {
46919 - *ptr++ = htonl((TCPOPT_NOP << 24) |
46920 - (TCPOPT_WINDOW << 16) |
46921 - (TCPOLEN_WINDOW << 8) |
46922 - opts->ws);
46923 + net_hdr_word(ptr++) =
46924 + htonl((TCPOPT_NOP << 24) |
46925 + (TCPOPT_WINDOW << 16) |
46926 + (TCPOLEN_WINDOW << 8) |
46927 + opts->ws);
46930 if (unlikely(opts->num_sack_blocks)) {
46931 @@ -501,16 +506,17 @@
46932 tp->duplicate_sack : tp->selective_acks;
46933 int this_sack;
46935 - *ptr++ = htonl((TCPOPT_NOP << 24) |
46936 - (TCPOPT_NOP << 16) |
46937 - (TCPOPT_SACK << 8) |
46938 - (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
46939 + net_hdr_word(ptr++) =
46940 + htonl((TCPOPT_NOP << 24) |
46941 + (TCPOPT_NOP << 16) |
46942 + (TCPOPT_SACK << 8) |
46943 + (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
46944 TCPOLEN_SACK_PERBLOCK)));
46946 for (this_sack = 0; this_sack < opts->num_sack_blocks;
46947 ++this_sack) {
46948 - *ptr++ = htonl(sp[this_sack].start_seq);
46949 - *ptr++ = htonl(sp[this_sack].end_seq);
46950 + net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq);
46951 + net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq);
46954 tp->rx_opt.dsack = 0;
46955 @@ -523,13 +529,14 @@
46957 if (foc->exp) {
46958 len = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
46959 - *ptr = htonl((TCPOPT_EXP << 24) | (len << 16) |
46960 + net_hdr_word(ptr) =
46961 + htonl((TCPOPT_EXP << 24) | (len << 16) |
46962 TCPOPT_FASTOPEN_MAGIC);
46963 p += TCPOLEN_EXP_FASTOPEN_BASE;
46964 } else {
46965 len = TCPOLEN_FASTOPEN_BASE + foc->len;
46966 - *p++ = TCPOPT_FASTOPEN;
46967 - *p++ = len;
46968 + net_hdr_word(p++) = TCPOPT_FASTOPEN;
46969 + net_hdr_word(p++) = len;
46972 memcpy(p, foc->val, foc->len);
46973 diff -Nur linux-4.1.43.orig/net/ipv6/datagram.c linux-4.1.43/net/ipv6/datagram.c
46974 --- linux-4.1.43.orig/net/ipv6/datagram.c 2017-08-06 01:56:14.000000000 +0200
46975 +++ linux-4.1.43/net/ipv6/datagram.c 2017-08-06 20:02:17.000000000 +0200
46976 @@ -433,7 +433,7 @@
46977 ipv6_iface_scope_id(&sin->sin6_addr,
46978 IP6CB(skb)->iif);
46979 } else {
46980 - ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),
46981 + ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset),
46982 &sin->sin6_addr);
46983 sin->sin6_scope_id = 0;
46985 @@ -770,12 +770,12 @@
46988 if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
46989 - if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
46990 + if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) {
46991 err = -EINVAL;
46992 goto exit_f;
46995 - fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
46996 + fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg));
46997 break;
46999 case IPV6_2292HOPOPTS:
47000 diff -Nur linux-4.1.43.orig/net/ipv6/exthdrs.c linux-4.1.43/net/ipv6/exthdrs.c
47001 --- linux-4.1.43.orig/net/ipv6/exthdrs.c 2017-08-06 01:56:14.000000000 +0200
47002 +++ linux-4.1.43/net/ipv6/exthdrs.c 2017-08-06 20:02:17.000000000 +0200
47003 @@ -573,7 +573,7 @@
47004 goto drop;
47007 - pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
47008 + pkt_len = ntohl(net_hdr_word(nh + optoff + 2));
47009 if (pkt_len <= IPV6_MAXPLEN) {
47010 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
47011 IPSTATS_MIB_INHDRERRORS);
47012 diff -Nur linux-4.1.43.orig/net/ipv6/ip6_fib.c linux-4.1.43/net/ipv6/ip6_fib.c
47013 --- linux-4.1.43.orig/net/ipv6/ip6_fib.c 2017-08-06 01:56:14.000000000 +0200
47014 +++ linux-4.1.43/net/ipv6/ip6_fib.c 2017-08-06 20:02:17.000000000 +0200
47015 @@ -137,7 +137,7 @@
47016 * See include/asm-generic/bitops/le.h.
47018 return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) &
47019 - addr[fn_bit >> 5];
47020 + net_hdr_word(&addr[fn_bit >> 5]);
47023 static struct fib6_node *node_alloc(void)
47024 diff -Nur linux-4.1.43.orig/net/ipv6/ip6_gre.c linux-4.1.43/net/ipv6/ip6_gre.c
47025 --- linux-4.1.43.orig/net/ipv6/ip6_gre.c 2017-08-06 01:56:14.000000000 +0200
47026 +++ linux-4.1.43/net/ipv6/ip6_gre.c 2017-08-06 20:02:17.000000000 +0200
47027 @@ -394,7 +394,7 @@
47029 t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
47030 flags & GRE_KEY ?
47031 - *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
47032 + net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1) : 0,
47033 p[1]);
47034 if (!t)
47035 return;
47036 @@ -476,11 +476,11 @@
47037 offset += 4;
47039 if (flags&GRE_KEY) {
47040 - key = *(__be32 *)(h + offset);
47041 + key = net_hdr_word(h + offset);
47042 offset += 4;
47044 if (flags&GRE_SEQ) {
47045 - seqno = ntohl(*(__be32 *)(h + offset));
47046 + seqno = ntohl(net_hdr_word(h + offset));
47047 offset += 4;
47050 @@ -745,7 +745,7 @@
47052 if (tunnel->parms.o_flags&GRE_SEQ) {
47053 ++tunnel->o_seqno;
47054 - *ptr = htonl(tunnel->o_seqno);
47055 + net_hdr_word(ptr) = htonl(tunnel->o_seqno);
47056 ptr--;
47058 if (tunnel->parms.o_flags&GRE_KEY) {
47059 @@ -843,7 +843,7 @@
47061 dsfield = ipv6_get_dsfield(ipv6h);
47062 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
47063 - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
47064 + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
47065 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
47066 fl6.flowlabel |= ip6_flowlabel(ipv6h);
47067 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
47068 diff -Nur linux-4.1.43.orig/net/ipv6/ip6_offload.c linux-4.1.43/net/ipv6/ip6_offload.c
47069 --- linux-4.1.43.orig/net/ipv6/ip6_offload.c 2017-08-06 01:56:14.000000000 +0200
47070 +++ linux-4.1.43/net/ipv6/ip6_offload.c 2017-08-06 20:02:17.000000000 +0200
47071 @@ -224,7 +224,7 @@
47072 continue;
47074 iph2 = (struct ipv6hdr *)(p->data + off);
47075 - first_word = *(__be32 *)iph ^ *(__be32 *)iph2;
47076 + first_word = net_hdr_word(iph) ^ net_hdr_word(iph2);
47078 /* All fields must match except length and Traffic Class.
47079 * XXX skbs on the gro_list have all been parsed and pulled
47080 diff -Nur linux-4.1.43.orig/net/ipv6/ip6_tunnel.c linux-4.1.43/net/ipv6/ip6_tunnel.c
47081 --- linux-4.1.43.orig/net/ipv6/ip6_tunnel.c 2017-08-06 01:56:14.000000000 +0200
47082 +++ linux-4.1.43/net/ipv6/ip6_tunnel.c 2017-08-06 20:02:17.000000000 +0200
47083 @@ -1192,7 +1192,7 @@
47085 dsfield = ipv6_get_dsfield(ipv6h);
47086 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
47087 - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
47088 + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
47089 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
47090 fl6.flowlabel |= ip6_flowlabel(ipv6h);
47091 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
47092 diff -Nur linux-4.1.43.orig/net/ipv6/netfilter/nf_log_ipv6.c linux-4.1.43/net/ipv6/netfilter/nf_log_ipv6.c
47093 --- linux-4.1.43.orig/net/ipv6/netfilter/nf_log_ipv6.c 2017-08-06 01:56:14.000000000 +0200
47094 +++ linux-4.1.43/net/ipv6/netfilter/nf_log_ipv6.c 2017-08-06 20:02:17.000000000 +0200
47095 @@ -66,9 +66,9 @@
47096 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
47097 nf_log_buf_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
47098 ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
47099 - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
47100 + (ntohl(net_hdr_word(ih)) & 0x0ff00000) >> 20,
47101 ih->hop_limit,
47102 - (ntohl(*(__be32 *)ih) & 0x000fffff));
47103 + (ntohl(net_hdr_word(ih)) & 0x000fffff));
47105 fragment = 0;
47106 ptr = ip6hoff + sizeof(struct ipv6hdr);
47107 diff -Nur linux-4.1.43.orig/net/ipv6/tcp_ipv6.c linux-4.1.43/net/ipv6/tcp_ipv6.c
47108 --- linux-4.1.43.orig/net/ipv6/tcp_ipv6.c 2017-08-06 01:56:14.000000000 +0200
47109 +++ linux-4.1.43/net/ipv6/tcp_ipv6.c 2017-08-06 20:02:17.000000000 +0200
47110 @@ -39,6 +39,7 @@
47111 #include <linux/ipsec.h>
47112 #include <linux/times.h>
47113 #include <linux/slab.h>
47114 +#include <asm/unaligned.h>
47115 #include <linux/uaccess.h>
47116 #include <linux/ipv6.h>
47117 #include <linux/icmpv6.h>
47118 @@ -781,10 +782,10 @@
47119 topt = (__be32 *)(t1 + 1);
47121 if (tsecr) {
47122 - *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
47123 - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
47124 - *topt++ = htonl(tsval);
47125 - *topt++ = htonl(tsecr);
47126 + put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
47127 + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++);
47128 + put_unaligned_be32(tsval, topt++);
47129 + put_unaligned_be32(tsecr, topt++);
47132 #ifdef CONFIG_TCP_MD5SIG
47133 diff -Nur linux-4.1.43.orig/net/netfilter/nf_conntrack_proto_tcp.c linux-4.1.43/net/netfilter/nf_conntrack_proto_tcp.c
47134 --- linux-4.1.43.orig/net/netfilter/nf_conntrack_proto_tcp.c 2017-08-06 01:56:14.000000000 +0200
47135 +++ linux-4.1.43/net/netfilter/nf_conntrack_proto_tcp.c 2017-08-06 20:02:17.000000000 +0200
47136 @@ -453,7 +453,7 @@
47138 /* Fast path for timestamp-only option */
47139 if (length == TCPOLEN_TSTAMP_ALIGNED
47140 - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24)
47141 + && net_hdr_word(ptr) == htonl((TCPOPT_NOP << 24)
47142 | (TCPOPT_NOP << 16)
47143 | (TCPOPT_TIMESTAMP << 8)
47144 | TCPOLEN_TIMESTAMP))
47145 diff -Nur linux-4.1.43.orig/net/sched/cls_u32.c linux-4.1.43/net/sched/cls_u32.c
47146 --- linux-4.1.43.orig/net/sched/cls_u32.c 2017-08-06 01:56:14.000000000 +0200
47147 +++ linux-4.1.43/net/sched/cls_u32.c 2017-08-06 20:02:17.000000000 +0200
47148 @@ -151,7 +151,7 @@
47149 data = skb_header_pointer(skb, toff, 4, &hdata);
47150 if (!data)
47151 goto out;
47152 - if ((*data ^ key->val) & key->mask) {
47153 + if ((net_hdr_word(data) ^ key->val) & key->mask) {
47154 n = rcu_dereference_bh(n->next);
47155 goto next_knode;
47157 @@ -204,8 +204,8 @@
47158 &hdata);
47159 if (!data)
47160 goto out;
47161 - sel = ht->divisor & u32_hash_fold(*data, &n->sel,
47162 - n->fshift);
47163 + sel = ht->divisor & u32_hash_fold(net_hdr_word(data),
47164 + &n->sel, n->fshift);
47166 if (!(n->sel.flags & (TC_U32_VAROFFSET | TC_U32_OFFSET | TC_U32_EAT)))
47167 goto next_ht;
47168 diff -Nur linux-4.1.43.orig/net/xfrm/xfrm_input.c linux-4.1.43/net/xfrm/xfrm_input.c
47169 --- linux-4.1.43.orig/net/xfrm/xfrm_input.c 2017-08-06 01:56:14.000000000 +0200
47170 +++ linux-4.1.43/net/xfrm/xfrm_input.c 2017-08-06 20:02:17.000000000 +0200
47171 @@ -154,8 +154,8 @@
47172 if (!pskb_may_pull(skb, hlen))
47173 return -EINVAL;
47175 - *spi = *(__be32 *)(skb_transport_header(skb) + offset);
47176 - *seq = *(__be32 *)(skb_transport_header(skb) + offset_seq);
47177 + *spi = net_hdr_word(skb_transport_header(skb) + offset);
47178 + *seq = net_hdr_word(skb_transport_header(skb) + offset_seq);
47179 return 0;