mach-wnr2000-v3.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * NETGEAR WNR2000v3/WNR612v2/WNR1000v2/WPN824N board support
  3. *
  4. * Copyright (C) 2015 Hartmut Knaack <knaack.h@gmx.de>
  5. * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
  6. * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8. * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <linux/mtd/mtd.h>
  15. #include <linux/mtd/partitions.h>
  16. #include <linux/kernel.h> /* for max() macro */
  17. #include <linux/platform_device.h> /* PLATFORM_DEVID_AUTO is defined here */
  18. #include <asm/mach-ath79/ath79.h>
  19. #include <asm/mach-ath79/ar71xx_regs.h> /* needed to disable switch LEDs */
  20. #include "common.h" /* needed to disable switch LEDs */
  21. #include "dev-ap9x-pci.h"
  22. #include "dev-eth.h"
  23. #include "dev-gpio-buttons.h"
  24. #include "dev-leds-gpio.h"
  25. #include "dev-m25p80.h"
  26. #include "machtypes.h"
  27. /* WNR2000v3 - connected through AR7241 */
  28. #define WNR2000V3_GPIO_LED_WAN_GREEN 0
  29. #define WNR2000V3_GPIO_LED_LAN1_AMBER 1
  30. #define WNR2000V3_GPIO_LED_LAN2_AMBER 6
  31. #define WNR2000V3_GPIO_LED_WPS_GREEN 7
  32. #define WNR2000V3_GPIO_LED_LAN3_AMBER 8
  33. #define WNR2000V3_GPIO_BTN_WPS 11
  34. #define WNR2000V3_GPIO_LED_LAN4_AMBER 12
  35. #define WNR2000V3_GPIO_LED_LAN1_GREEN 13
  36. #define WNR2000V3_GPIO_LED_LAN2_GREEN 14
  37. #define WNR2000V3_GPIO_LED_LAN3_GREEN 15
  38. #define WNR2000V3_GPIO_LED_LAN4_GREEN 16
  39. #define WNR2000V3_GPIO_LED_WAN_AMBER 17
  40. /* WNR2000v3 - connected through AR9287 */
  41. #define WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE 1
  42. #define WNR2000V3_GPIO_WMAC_LED_TEST_AMBER 2
  43. #define WNR2000V3_GPIO_WMAC_LED_POWER_GREEN 3
  44. #define WNR2000V3_GPIO_WMAC_BTN_RESET 8
  45. #define WNR2000V3_GPIO_WMAC_BTN_RFKILL 9
  46. /* WNR612v2 - connected through AR7241 */
  47. #define WNR612V2_GPIO_LED_POWER_GREEN 11
  48. #define WNR612V2_GPIO_LED_LAN1_GREEN 13
  49. #define WNR612V2_GPIO_LED_LAN2_GREEN 14
  50. #define WNR612V2_GPIO_LED_WAN_GREEN 17
  51. /* WNR612v2 - connected through AR9285 */
  52. #define WNR612V2_GPIO_WMAC_LED_WLAN_GREEN 1
  53. #define WNR612V2_GPIO_WMAC_BTN_RESET 7
  54. /* WNR1000v2 - connected through AR7240 */
  55. #define WNR1000V2_GPIO_LED_WAN_AMBER 0
  56. #define WNR1000V2_GPIO_LED_TEST_AMBER 1
  57. #define WNR1000V2_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  58. #define WNR1000V2_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  59. #define WNR1000V2_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  60. #define WNR1000V2_GPIO_LED_POWER_GREEN 11
  61. #define WNR1000V2_GPIO_LED_LAN4_AMBER 12
  62. #define WNR1000V2_GPIO_LED_LAN1_GREEN 13 /* AR724X_..._ETH_SWITCH_LED0 */
  63. #define WNR1000V2_GPIO_LED_LAN2_GREEN 14 /* AR724X_..._ETH_SWITCH_LED1 */
  64. #define WNR1000V2_GPIO_LED_LAN3_GREEN 15 /* AR724X_..._ETH_SWITCH_LED2 */
  65. #define WNR1000V2_GPIO_LED_LAN4_GREEN 16 /* AR724X_..._ETH_SWITCH_LED3 */
  66. #define WNR1000V2_GPIO_LED_WAN_GREEN 17 /* AR724X_..._ETH_SWITCH_LED4 */
  67. /* WNR1000v2 - connected through AR9285 */
  68. #define WNR1000V2_GPIO_WMAC_LED_WLAN_BLUE 1
  69. #define WNR1000V2_GPIO_WMAC_LED_WPS_GREEN 5
  70. #define WNR1000V2_GPIO_WMAC_BTN_WPS 6
  71. #define WNR1000V2_GPIO_WMAC_BTN_RESET 7
  72. #define WNR1000V2_GPIO_WMAC_BTN_RFKILL 8
  73. /* WPN824N - connected through AR7240 */
  74. #define WPN824N_GPIO_LED_WAN_AMBER 0
  75. #define WPN824N_GPIO_LED_STATUS_AMBER 1
  76. #define WPN824N_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  77. #define WPN824N_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  78. #define WPN824N_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
  79. #define WPN824N_GPIO_LED_LAN4_AMBER 12
  80. #define WPN824N_GPIO_LED_LAN1_GREEN 13
  81. #define WPN824N_GPIO_LED_LAN2_GREEN 14
  82. #define WPN824N_GPIO_LED_LAN3_GREEN 15 /* AR724X_GPIO_FUNC_CLK_OBS3_EN */
  83. #define WPN824N_GPIO_LED_LAN4_GREEN 16
  84. #define WPN824N_GPIO_LED_WAN_GREEN 17
  85. /* WPN824N - connected through AR9285 */
  86. #define WPN824N_WGPIO_LED_PWR_GREEN 0
  87. #define WPN824N_WGPIO_LED_WLAN_BLUE 1
  88. #define WPN824N_WGPIO_LED_WPS1_BLUE 5
  89. #define WPN824N_WGPIO_LED_WPS2_BLUE 9
  90. #define WPN824N_WGPIO_LED_TEST_AMBER 10
  91. #define WPN824N_WGPIO_BTN_WPS 6
  92. #define WPN824N_WGPIO_BTN_RESET 7
  93. #define WPN824N_WGPIO_BTN_WLAN 8
  94. #define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
  95. #define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
  96. /* ART offsets for: WNR2000v3, WNR612v2, WNR1000v2 */
  97. #define WNR2000V3_MAC0_OFFSET 0
  98. #define WNR2000V3_MAC1_OFFSET 6
  99. #define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
  100. #define WNR2000V3_WMAC_OFFSET 0x108c /* wireless MAC is inside ART */
  101. static struct gpio_led wnr2000v3_leds_gpio[] __initdata = {
  102. {
  103. .name = "netgear:green:wan",
  104. .gpio = WNR2000V3_GPIO_LED_WAN_GREEN,
  105. .active_low = 1,
  106. }, {
  107. .name = "netgear:amber:lan1",
  108. .gpio = WNR2000V3_GPIO_LED_LAN1_AMBER,
  109. .active_low = 1,
  110. }, {
  111. .name = "netgear:amber:lan2",
  112. .gpio = WNR2000V3_GPIO_LED_LAN2_AMBER,
  113. .active_low = 1,
  114. }, {
  115. .name = "netgear:amber:lan3",
  116. .gpio = WNR2000V3_GPIO_LED_LAN3_AMBER,
  117. .active_low = 1,
  118. }, {
  119. .name = "netgear:amber:lan4",
  120. .gpio = WNR2000V3_GPIO_LED_LAN4_AMBER,
  121. .active_low = 1,
  122. }, {
  123. .name = "netgear:green:wps",
  124. .gpio = WNR2000V3_GPIO_LED_WPS_GREEN,
  125. .active_low = 1,
  126. }, {
  127. .name = "netgear:green:lan1",
  128. .gpio = WNR2000V3_GPIO_LED_LAN1_GREEN,
  129. .active_low = 1,
  130. }, {
  131. .name = "netgear:green:lan2",
  132. .gpio = WNR2000V3_GPIO_LED_LAN2_GREEN,
  133. .active_low = 1,
  134. }, {
  135. .name = "netgear:green:lan3",
  136. .gpio = WNR2000V3_GPIO_LED_LAN3_GREEN,
  137. .active_low = 1,
  138. }, {
  139. .name = "netgear:green:lan4",
  140. .gpio = WNR2000V3_GPIO_LED_LAN4_GREEN,
  141. .active_low = 1,
  142. }, {
  143. .name = "netgear:amber:wan",
  144. .gpio = WNR2000V3_GPIO_LED_WAN_AMBER,
  145. .active_low = 1,
  146. }
  147. };
  148. static struct gpio_led wnr2000v3_wmac_leds_gpio[] = {
  149. {
  150. .name = "netgear:green:power",
  151. .gpio = WNR2000V3_GPIO_WMAC_LED_POWER_GREEN,
  152. .active_low = 1,
  153. .default_state = LEDS_GPIO_DEFSTATE_ON,
  154. }, {
  155. .name = "netgear:amber:test",
  156. .gpio = WNR2000V3_GPIO_WMAC_LED_TEST_AMBER,
  157. .active_low = 1,
  158. }, {
  159. .name = "netgear:blue:wlan",
  160. .gpio = WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE,
  161. .active_low = 1,
  162. }
  163. };
  164. static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
  165. {
  166. .name = "netgear:green:power",
  167. .gpio = WNR612V2_GPIO_LED_POWER_GREEN,
  168. .active_low = 1,
  169. }, {
  170. .name = "netgear:green:lan1",
  171. .gpio = WNR612V2_GPIO_LED_LAN1_GREEN,
  172. .active_low = 1,
  173. }, {
  174. .name = "netgear:green:lan2",
  175. .gpio = WNR612V2_GPIO_LED_LAN2_GREEN,
  176. .active_low = 1,
  177. }, {
  178. .name = "netgear:green:wan",
  179. .gpio = WNR612V2_GPIO_LED_WAN_GREEN,
  180. .active_low = 1,
  181. }
  182. };
  183. static struct gpio_led wnr612v2_wmac_leds_gpio[] = {
  184. {
  185. .name = "netgear:green:wlan",
  186. .gpio = WNR612V2_GPIO_WMAC_LED_WLAN_GREEN,
  187. .active_low = 1,
  188. }
  189. };
  190. static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
  191. {
  192. .name = "netgear:amber:lan1",
  193. .gpio = WNR1000V2_GPIO_LED_LAN1_AMBER,
  194. .active_low = 1,
  195. }, {
  196. .name = "netgear:amber:lan2",
  197. .gpio = WNR1000V2_GPIO_LED_LAN2_AMBER,
  198. .active_low = 1,
  199. }, {
  200. .name = "netgear:amber:lan3",
  201. .gpio = WNR1000V2_GPIO_LED_LAN3_AMBER,
  202. .active_low = 1,
  203. }, {
  204. .name = "netgear:amber:lan4",
  205. .gpio = WNR1000V2_GPIO_LED_LAN4_AMBER,
  206. .active_low = 1,
  207. }, {
  208. .name = "netgear:amber:test",
  209. .gpio = WNR1000V2_GPIO_LED_TEST_AMBER,
  210. .active_low = 1,
  211. }, {
  212. .name = "netgear:amber:wan",
  213. .gpio = WNR1000V2_GPIO_LED_WAN_AMBER,
  214. .active_low = 1,
  215. }, {
  216. .name = "netgear:green:lan1",
  217. .gpio = WNR1000V2_GPIO_LED_LAN1_GREEN,
  218. .active_low = 1,
  219. }, {
  220. .name = "netgear:green:lan2",
  221. .gpio = WNR1000V2_GPIO_LED_LAN2_GREEN,
  222. .active_low = 1,
  223. }, {
  224. .name = "netgear:green:lan3",
  225. .gpio = WNR1000V2_GPIO_LED_LAN3_GREEN,
  226. .active_low = 1,
  227. }, {
  228. .name = "netgear:green:lan4",
  229. .gpio = WNR1000V2_GPIO_LED_LAN4_GREEN,
  230. .active_low = 1,
  231. }, {
  232. .name = "netgear:green:power",
  233. .gpio = WNR1000V2_GPIO_LED_POWER_GREEN,
  234. .active_low = 1,
  235. }, {
  236. .name = "netgear:green:wan",
  237. .gpio = WNR1000V2_GPIO_LED_WAN_GREEN,
  238. .active_low = 1,
  239. }
  240. };
  241. static struct gpio_led wnr1000v2_wmac_leds_gpio[] = {
  242. {
  243. .name = "netgear:green:wps",
  244. .gpio = WNR1000V2_GPIO_WMAC_LED_WPS_GREEN,
  245. .active_low = 1,
  246. }, {
  247. .name = "netgear:blue:wlan",
  248. .gpio = WNR1000V2_GPIO_WMAC_LED_WLAN_BLUE,
  249. .active_low = 1,
  250. }
  251. };
  252. static struct gpio_led wpn824n_leds_gpio[] __initdata = {
  253. {
  254. .name = "netgear:amber:wan",
  255. .gpio = WPN824N_GPIO_LED_WAN_AMBER,
  256. .active_low = 1,
  257. }, {
  258. .name = "netgear:amber:status",
  259. .gpio = WPN824N_GPIO_LED_STATUS_AMBER,
  260. .active_low = 1,
  261. }, {
  262. .name = "netgear:amber:lan1",
  263. .gpio = WPN824N_GPIO_LED_LAN1_AMBER,
  264. .active_low = 1,
  265. }, {
  266. .name = "netgear:amber:lan2",
  267. .gpio = WPN824N_GPIO_LED_LAN2_AMBER,
  268. .active_low = 1,
  269. }, {
  270. .name = "netgear:amber:lan3",
  271. .gpio = WPN824N_GPIO_LED_LAN3_AMBER,
  272. .active_low = 1,
  273. }, {
  274. .name = "netgear:amber:lan4",
  275. .gpio = WPN824N_GPIO_LED_LAN4_AMBER,
  276. .active_low = 1,
  277. }, {
  278. .name = "netgear:green:lan1",
  279. .gpio = WPN824N_GPIO_LED_LAN1_GREEN,
  280. .active_low = 1,
  281. }, {
  282. .name = "netgear:green:lan2",
  283. .gpio = WPN824N_GPIO_LED_LAN2_GREEN,
  284. .active_low = 1,
  285. }, {
  286. .name = "netgear:green:lan3",
  287. .gpio = WPN824N_GPIO_LED_LAN3_GREEN,
  288. .active_low = 1,
  289. }, {
  290. .name = "netgear:green:lan4",
  291. .gpio = WPN824N_GPIO_LED_LAN4_GREEN,
  292. .active_low = 1,
  293. }, {
  294. .name = "netgear:green:wan",
  295. .gpio = WPN824N_GPIO_LED_WAN_GREEN,
  296. .active_low = 1,
  297. }
  298. };
  299. static struct gpio_led wpn824n_wmac_leds_gpio[] = {
  300. {
  301. .name = "netgear:green:power",
  302. .gpio = WPN824N_WGPIO_LED_PWR_GREEN,
  303. .active_low = 1,
  304. }, {
  305. .name = "netgear:blue:wps1",
  306. .gpio = WPN824N_WGPIO_LED_WPS1_BLUE,
  307. .active_low = 1,
  308. }, {
  309. .name = "netgear:blue:wps2",
  310. .gpio = WPN824N_WGPIO_LED_WPS2_BLUE,
  311. .active_low = 1,
  312. }, {
  313. .name = "netgear:amber:test",
  314. .gpio = WPN824N_WGPIO_LED_TEST_AMBER,
  315. .active_low = 1,
  316. }, {
  317. .name = "netgear:blue:wlan",
  318. .gpio = WPN824N_WGPIO_LED_WLAN_BLUE,
  319. .active_low = 1,
  320. }
  321. };
  322. static struct gpio_keys_button wnr2000v3_keys_gpio[] __initdata = {
  323. {
  324. .desc = "wps",
  325. .type = EV_KEY,
  326. .code = KEY_WPS_BUTTON,
  327. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  328. .gpio = WNR2000V3_GPIO_BTN_WPS,
  329. .active_low = 1,
  330. }
  331. };
  332. static struct gpio_keys_button wnr2000v3_wmac_keys_gpio[] = {
  333. {
  334. .desc = "reset",
  335. .type = EV_KEY,
  336. .code = KEY_RESTART,
  337. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  338. .gpio = WNR2000V3_GPIO_WMAC_BTN_RESET,
  339. .active_low = 1,
  340. }, {
  341. .desc = "rfkill",
  342. .type = EV_KEY,
  343. .code = KEY_RFKILL,
  344. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  345. .gpio = WNR2000V3_GPIO_WMAC_BTN_RFKILL,
  346. .active_low = 1,
  347. }
  348. };
  349. static struct gpio_keys_button wnr612v2_wmac_keys_gpio[] = {
  350. {
  351. .desc = "reset",
  352. .type = EV_KEY,
  353. .code = KEY_RESTART,
  354. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  355. .gpio = WNR612V2_GPIO_WMAC_BTN_RESET,
  356. .active_low = 1,
  357. }
  358. };
  359. static struct gpio_keys_button wnr1000v2_wmac_keys_gpio[] = {
  360. {
  361. .desc = "reset",
  362. .type = EV_KEY,
  363. .code = KEY_RESTART,
  364. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  365. .gpio = WNR1000V2_GPIO_WMAC_BTN_RESET,
  366. .active_low = 1,
  367. }, {
  368. .desc = "rfkill",
  369. .type = EV_KEY,
  370. .code = KEY_RFKILL,
  371. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  372. .gpio = WNR1000V2_GPIO_WMAC_BTN_RFKILL,
  373. .active_low = 1,
  374. }, {
  375. .desc = "wps",
  376. .type = EV_KEY,
  377. .code = KEY_WPS_BUTTON,
  378. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  379. .gpio = WNR1000V2_GPIO_WMAC_BTN_WPS,
  380. .active_low = 1,
  381. }
  382. };
  383. static struct gpio_keys_button wpn824n_wmac_keys_gpio[] = {
  384. {
  385. .desc = "reset",
  386. .type = EV_KEY,
  387. .code = KEY_RESTART,
  388. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  389. .gpio = WPN824N_WGPIO_BTN_RESET,
  390. .active_low = 1,
  391. }, {
  392. .desc = "rfkill",
  393. .type = EV_KEY,
  394. .code = KEY_RFKILL,
  395. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  396. .gpio = WPN824N_WGPIO_BTN_WLAN,
  397. .active_low = 1,
  398. }, {
  399. .desc = "wps",
  400. .type = EV_KEY,
  401. .code = KEY_WPS_BUTTON,
  402. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  403. .gpio = WPN824N_WGPIO_BTN_WPS,
  404. .active_low = 1,
  405. }
  406. };
  407. /*
  408. * For WNR2000v3 ART flash area used for WLAN MAC is usually empty (0xff)
  409. * so ath9k driver uses random MAC instead each time module is loaded.
  410. * To fix that, assign permanent WLAN MAC equal to ethN's MAC plus 1,
  411. * so network interfaces get sequential addresses.
  412. * If ART wireless MAC address field has been filled by user, use it.
  413. */
  414. static void __init wnr_get_wmac(u8 *wmac_gen_addr, int mac0_art_offset,
  415. int mac1_art_offset, int wmac_art_offset)
  416. {
  417. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  418. u8 *eth0_mac_addr = (u8 *) (art + mac0_art_offset);
  419. u8 *eth1_mac_addr = (u8 *) (art + mac1_art_offset);
  420. u8 *wlan_mac_addr = (u8 *) (art + wmac_art_offset);
  421. /* only 0xff if all bits are set - address is invalid, empty area */
  422. if ((wlan_mac_addr[0] & wlan_mac_addr[1] & wlan_mac_addr[2] &
  423. wlan_mac_addr[3] & wlan_mac_addr[4] & wlan_mac_addr[5]) == 0xff) {
  424. memcpy(wmac_gen_addr, eth0_mac_addr, 5);
  425. wmac_gen_addr[5] = max(eth0_mac_addr[5], eth1_mac_addr[5]) + 1;
  426. /* Avoid potential conflict in case max(0xff,0x00)+1==0x00 */
  427. if (!wmac_gen_addr[5])
  428. wmac_gen_addr[5] = 1;
  429. } else
  430. memcpy(wmac_gen_addr, wlan_mac_addr, 6);
  431. }
  432. static void __init wnr_common_setup(u8 *wmac_addr)
  433. {
  434. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  435. ath79_register_mdio(0, 0x0);
  436. ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
  437. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  438. ath79_eth0_data.speed = SPEED_100;
  439. ath79_eth0_data.duplex = DUPLEX_FULL;
  440. ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
  441. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  442. ath79_eth1_data.phy_mask = 0x10;
  443. ath79_register_eth(0);
  444. ath79_register_eth(1);
  445. ath79_register_m25p80(NULL);
  446. ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, wmac_addr);
  447. }
  448. static void __init wnr2000v3_setup(void)
  449. {
  450. u8 wlan_mac_addr[6];
  451. /*
  452. * Disable JTAG to use all AR724X GPIO LEDs.
  453. * Also disable CLKs and bit 20 as u-boot does.
  454. * Finally, allow OS to control all link LEDs.
  455. */
  456. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  457. AR724X_GPIO_FUNC_UART_EN,
  458. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  459. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  460. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  461. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  462. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  463. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  464. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  465. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  466. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  467. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  468. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  469. BIT(20));
  470. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  471. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  472. wnr_common_setup(wlan_mac_addr);
  473. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
  474. wnr2000v3_leds_gpio);
  475. /* Do not use id=-1, we can have more GPIO key-polled devices */
  476. ath79_register_gpio_keys_polled(PLATFORM_DEVID_AUTO,
  477. WNR2000V3_KEYS_POLL_INTERVAL,
  478. ARRAY_SIZE(wnr2000v3_keys_gpio),
  479. wnr2000v3_keys_gpio);
  480. ap9x_pci_setup_wmac_leds(0, wnr2000v3_wmac_leds_gpio,
  481. ARRAY_SIZE(wnr2000v3_wmac_leds_gpio));
  482. ap9x_pci_setup_wmac_btns(0, wnr2000v3_wmac_keys_gpio,
  483. ARRAY_SIZE(wnr2000v3_wmac_keys_gpio),
  484. WNR2000V3_KEYS_POLL_INTERVAL);
  485. }
  486. MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
  487. static void __init wnr612v2_setup(void)
  488. {
  489. u8 wlan_mac_addr[6];
  490. /*
  491. * Disable JTAG and CLKs. Allow OS to control all link LEDs.
  492. * Note: U-Boot for WNR612v2 sets undocumented bit 15 but
  493. * we leave it for now.
  494. */
  495. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  496. AR724X_GPIO_FUNC_UART_EN,
  497. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  498. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  499. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  500. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  501. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  502. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  503. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  504. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  505. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  506. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  507. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  508. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  509. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  510. wnr_common_setup(wlan_mac_addr);
  511. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
  512. wnr612v2_leds_gpio);
  513. ap9x_pci_setup_wmac_leds(0, wnr612v2_wmac_leds_gpio,
  514. ARRAY_SIZE(wnr612v2_wmac_leds_gpio));
  515. ap9x_pci_setup_wmac_btns(0, wnr612v2_wmac_keys_gpio,
  516. ARRAY_SIZE(wnr612v2_wmac_keys_gpio),
  517. WNR2000V3_KEYS_POLL_INTERVAL);
  518. }
  519. MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
  520. static void __init wnr1000v2_setup(void)
  521. {
  522. u8 wlan_mac_addr[6];
  523. /*
  524. * Disable JTAG and CLKs. Allow OS to control all link LEDs.
  525. * Note: U-Boot for WNR1000v2 sets undocumented bit 15 but
  526. * we leave it for now.
  527. */
  528. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  529. AR724X_GPIO_FUNC_UART_EN,
  530. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  531. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  532. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  533. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  534. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  535. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  536. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  537. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  538. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  539. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  540. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  541. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  542. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  543. wnr_common_setup(wlan_mac_addr);
  544. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
  545. wnr1000v2_leds_gpio);
  546. ap9x_pci_setup_wmac_leds(0, wnr1000v2_wmac_leds_gpio,
  547. ARRAY_SIZE(wnr1000v2_wmac_leds_gpio));
  548. /* All 3 buttons are connected to wireless chip */
  549. ap9x_pci_setup_wmac_btns(0, wnr1000v2_wmac_keys_gpio,
  550. ARRAY_SIZE(wnr1000v2_wmac_keys_gpio),
  551. WNR2000V3_KEYS_POLL_INTERVAL);
  552. }
  553. MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
  554. static void __init wpn824n_setup(void)
  555. {
  556. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  557. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  558. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  559. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  560. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  561. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  562. AR724X_GPIO_FUNC_CLK_OBS3_EN);
  563. wnr_common_setup(NULL);
  564. ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio),
  565. wpn824n_leds_gpio);
  566. ap9x_pci_setup_wmac_leds(0, wpn824n_wmac_leds_gpio,
  567. ARRAY_SIZE(wpn824n_wmac_leds_gpio));
  568. ap9x_pci_setup_wmac_btns(0, wpn824n_wmac_keys_gpio,
  569. ARRAY_SIZE(wpn824n_wmac_keys_gpio),
  570. WNR2000V3_KEYS_POLL_INTERVAL);
  571. }
  572. MIPS_MACHINE(ATH79_MACH_WPN824N, "WPN824N", "NETGEAR WPN824N", wpn824n_setup);