mach-wnr2000-v3.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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. };
  160. /* Blue WLAN LED for: WNR2000v3, WNR1000v2, WPN824N */
  161. static const char *wnr2000v3_wmac_led_name = "netgear:blue:wlan";
  162. static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
  163. {
  164. .name = "netgear:green:power",
  165. .gpio = WNR612V2_GPIO_LED_POWER_GREEN,
  166. .active_low = 1,
  167. }, {
  168. .name = "netgear:green:lan1",
  169. .gpio = WNR612V2_GPIO_LED_LAN1_GREEN,
  170. .active_low = 1,
  171. }, {
  172. .name = "netgear:green:lan2",
  173. .gpio = WNR612V2_GPIO_LED_LAN2_GREEN,
  174. .active_low = 1,
  175. }, {
  176. .name = "netgear:green:wan",
  177. .gpio = WNR612V2_GPIO_LED_WAN_GREEN,
  178. .active_low = 1,
  179. }
  180. };
  181. static const char *wnr612v2_wmac_led_name = "netgear:green:wlan";
  182. static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
  183. {
  184. .name = "netgear:amber:lan1",
  185. .gpio = WNR1000V2_GPIO_LED_LAN1_AMBER,
  186. .active_low = 1,
  187. }, {
  188. .name = "netgear:amber:lan2",
  189. .gpio = WNR1000V2_GPIO_LED_LAN2_AMBER,
  190. .active_low = 1,
  191. }, {
  192. .name = "netgear:amber:lan3",
  193. .gpio = WNR1000V2_GPIO_LED_LAN3_AMBER,
  194. .active_low = 1,
  195. }, {
  196. .name = "netgear:amber:lan4",
  197. .gpio = WNR1000V2_GPIO_LED_LAN4_AMBER,
  198. .active_low = 1,
  199. }, {
  200. .name = "netgear:amber:test",
  201. .gpio = WNR1000V2_GPIO_LED_TEST_AMBER,
  202. .active_low = 1,
  203. }, {
  204. .name = "netgear:amber:wan",
  205. .gpio = WNR1000V2_GPIO_LED_WAN_AMBER,
  206. .active_low = 1,
  207. }, {
  208. .name = "netgear:green:lan1",
  209. .gpio = WNR1000V2_GPIO_LED_LAN1_GREEN,
  210. .active_low = 1,
  211. }, {
  212. .name = "netgear:green:lan2",
  213. .gpio = WNR1000V2_GPIO_LED_LAN2_GREEN,
  214. .active_low = 1,
  215. }, {
  216. .name = "netgear:green:lan3",
  217. .gpio = WNR1000V2_GPIO_LED_LAN3_GREEN,
  218. .active_low = 1,
  219. }, {
  220. .name = "netgear:green:lan4",
  221. .gpio = WNR1000V2_GPIO_LED_LAN4_GREEN,
  222. .active_low = 1,
  223. }, {
  224. .name = "netgear:green:power",
  225. .gpio = WNR1000V2_GPIO_LED_POWER_GREEN,
  226. .active_low = 1,
  227. }, {
  228. .name = "netgear:green:wan",
  229. .gpio = WNR1000V2_GPIO_LED_WAN_GREEN,
  230. .active_low = 1,
  231. }
  232. };
  233. static struct gpio_led wnr1000v2_wmac_leds_gpio[] = {
  234. {
  235. .name = "netgear:green:wps",
  236. .gpio = WNR1000V2_GPIO_WMAC_LED_WPS_GREEN,
  237. .active_low = 1,
  238. }
  239. };
  240. static struct gpio_led wpn824n_leds_gpio[] __initdata = {
  241. {
  242. .name = "netgear:amber:wan",
  243. .gpio = WPN824N_GPIO_LED_WAN_AMBER,
  244. .active_low = 1,
  245. }, {
  246. .name = "netgear:amber:status",
  247. .gpio = WPN824N_GPIO_LED_STATUS_AMBER,
  248. .active_low = 1,
  249. }, {
  250. .name = "netgear:amber:lan1",
  251. .gpio = WPN824N_GPIO_LED_LAN1_AMBER,
  252. .active_low = 1,
  253. }, {
  254. .name = "netgear:amber:lan2",
  255. .gpio = WPN824N_GPIO_LED_LAN2_AMBER,
  256. .active_low = 1,
  257. }, {
  258. .name = "netgear:amber:lan3",
  259. .gpio = WPN824N_GPIO_LED_LAN3_AMBER,
  260. .active_low = 1,
  261. }, {
  262. .name = "netgear:amber:lan4",
  263. .gpio = WPN824N_GPIO_LED_LAN4_AMBER,
  264. .active_low = 1,
  265. }, {
  266. .name = "netgear:green:lan1",
  267. .gpio = WPN824N_GPIO_LED_LAN1_GREEN,
  268. .active_low = 1,
  269. }, {
  270. .name = "netgear:green:lan2",
  271. .gpio = WPN824N_GPIO_LED_LAN2_GREEN,
  272. .active_low = 1,
  273. }, {
  274. .name = "netgear:green:lan3",
  275. .gpio = WPN824N_GPIO_LED_LAN3_GREEN,
  276. .active_low = 1,
  277. }, {
  278. .name = "netgear:green:lan4",
  279. .gpio = WPN824N_GPIO_LED_LAN4_GREEN,
  280. .active_low = 1,
  281. }, {
  282. .name = "netgear:green:wan",
  283. .gpio = WPN824N_GPIO_LED_WAN_GREEN,
  284. .active_low = 1,
  285. }
  286. };
  287. static struct gpio_led wpn824n_wmac_leds_gpio[] = {
  288. {
  289. .name = "netgear:green:power",
  290. .gpio = WPN824N_WGPIO_LED_PWR_GREEN,
  291. .active_low = 1,
  292. }, {
  293. .name = "netgear:blue:wps1",
  294. .gpio = WPN824N_WGPIO_LED_WPS1_BLUE,
  295. .active_low = 1,
  296. }, {
  297. .name = "netgear:blue:wps2",
  298. .gpio = WPN824N_WGPIO_LED_WPS2_BLUE,
  299. .active_low = 1,
  300. }, {
  301. .name = "netgear:amber:test",
  302. .gpio = WPN824N_WGPIO_LED_TEST_AMBER,
  303. .active_low = 1,
  304. }
  305. };
  306. static struct gpio_keys_button wnr2000v3_keys_gpio[] __initdata = {
  307. {
  308. .desc = "wps",
  309. .type = EV_KEY,
  310. .code = KEY_WPS_BUTTON,
  311. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  312. .gpio = WNR2000V3_GPIO_BTN_WPS,
  313. .active_low = 1,
  314. }
  315. };
  316. static struct gpio_keys_button wnr2000v3_wmac_keys_gpio[] = {
  317. {
  318. .desc = "reset",
  319. .type = EV_KEY,
  320. .code = KEY_RESTART,
  321. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  322. .gpio = WNR2000V3_GPIO_WMAC_BTN_RESET,
  323. .active_low = 1,
  324. }, {
  325. .desc = "rfkill",
  326. .type = EV_KEY,
  327. .code = KEY_RFKILL,
  328. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  329. .gpio = WNR2000V3_GPIO_WMAC_BTN_RFKILL,
  330. .active_low = 1,
  331. }
  332. };
  333. static struct gpio_keys_button wnr612v2_wmac_keys_gpio[] = {
  334. {
  335. .desc = "reset",
  336. .type = EV_KEY,
  337. .code = KEY_RESTART,
  338. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  339. .gpio = WNR612V2_GPIO_WMAC_BTN_RESET,
  340. .active_low = 1,
  341. }
  342. };
  343. static struct gpio_keys_button wnr1000v2_wmac_keys_gpio[] = {
  344. {
  345. .desc = "reset",
  346. .type = EV_KEY,
  347. .code = KEY_RESTART,
  348. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  349. .gpio = WNR1000V2_GPIO_WMAC_BTN_RESET,
  350. .active_low = 1,
  351. }, {
  352. .desc = "rfkill",
  353. .type = EV_KEY,
  354. .code = KEY_RFKILL,
  355. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  356. .gpio = WNR1000V2_GPIO_WMAC_BTN_RFKILL,
  357. .active_low = 1,
  358. }, {
  359. .desc = "wps",
  360. .type = EV_KEY,
  361. .code = KEY_WPS_BUTTON,
  362. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  363. .gpio = WNR1000V2_GPIO_WMAC_BTN_WPS,
  364. .active_low = 1,
  365. }
  366. };
  367. static struct gpio_keys_button wpn824n_wmac_keys_gpio[] = {
  368. {
  369. .desc = "reset",
  370. .type = EV_KEY,
  371. .code = KEY_RESTART,
  372. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  373. .gpio = WPN824N_WGPIO_BTN_RESET,
  374. .active_low = 1,
  375. }, {
  376. .desc = "rfkill",
  377. .type = EV_KEY,
  378. .code = KEY_RFKILL,
  379. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  380. .gpio = WPN824N_WGPIO_BTN_WLAN,
  381. .active_low = 1,
  382. }, {
  383. .desc = "wps",
  384. .type = EV_KEY,
  385. .code = KEY_WPS_BUTTON,
  386. .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
  387. .gpio = WPN824N_WGPIO_BTN_WPS,
  388. .active_low = 1,
  389. }
  390. };
  391. /*
  392. * For WNR2000v3 ART flash area used for WLAN MAC is usually empty (0xff)
  393. * so ath9k driver uses random MAC instead each time module is loaded.
  394. * To fix that, assign permanent WLAN MAC equal to ethN's MAC plus 1,
  395. * so network interfaces get sequential addresses.
  396. * If ART wireless MAC address field has been filled by user, use it.
  397. */
  398. static void __init wnr_get_wmac(u8 *wmac_gen_addr, int mac0_art_offset,
  399. int mac1_art_offset, int wmac_art_offset)
  400. {
  401. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  402. u8 *eth0_mac_addr = (u8 *) (art + mac0_art_offset);
  403. u8 *eth1_mac_addr = (u8 *) (art + mac1_art_offset);
  404. u8 *wlan_mac_addr = (u8 *) (art + wmac_art_offset);
  405. /* only 0xff if all bits are set - address is invalid, empty area */
  406. if ((wlan_mac_addr[0] & wlan_mac_addr[1] & wlan_mac_addr[2] &
  407. wlan_mac_addr[3] & wlan_mac_addr[4] & wlan_mac_addr[5]) == 0xff) {
  408. memcpy(wmac_gen_addr, eth0_mac_addr, 5);
  409. wmac_gen_addr[5] = max(eth0_mac_addr[5], eth1_mac_addr[5]) + 1;
  410. /* Avoid potential conflict in case max(0xff,0x00)+1==0x00 */
  411. if (!wmac_gen_addr[5])
  412. wmac_gen_addr[5] = 1;
  413. } else
  414. memcpy(wmac_gen_addr, wlan_mac_addr, 6);
  415. }
  416. static void __init wnr_common_setup(u8 *wmac_addr)
  417. {
  418. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  419. ath79_register_mdio(0, 0x0);
  420. ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V3_MAC0_OFFSET, 0);
  421. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  422. ath79_eth0_data.speed = SPEED_100;
  423. ath79_eth0_data.duplex = DUPLEX_FULL;
  424. ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V3_MAC1_OFFSET, 0);
  425. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  426. ath79_eth1_data.phy_mask = 0x10;
  427. ath79_register_eth(0);
  428. ath79_register_eth(1);
  429. ath79_register_m25p80(NULL);
  430. ap91_pci_init(art + WNR2000V3_PCIE_CALDATA_OFFSET, wmac_addr);
  431. }
  432. static void __init wnr2000v3_setup(void)
  433. {
  434. u8 wlan_mac_addr[6];
  435. /*
  436. * Disable JTAG to use all AR724X GPIO LEDs.
  437. * Also disable CLKs and bit 20 as u-boot does.
  438. * Finally, allow OS to control all link LEDs.
  439. */
  440. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  441. AR724X_GPIO_FUNC_UART_EN,
  442. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  443. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  444. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  445. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  446. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  447. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  448. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  449. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  450. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  451. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  452. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  453. BIT(20));
  454. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  455. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  456. wnr_common_setup(wlan_mac_addr);
  457. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio),
  458. wnr2000v3_leds_gpio);
  459. /* Do not use id=-1, we can have more GPIO key-polled devices */
  460. ath79_register_gpio_keys_polled(PLATFORM_DEVID_AUTO,
  461. WNR2000V3_KEYS_POLL_INTERVAL,
  462. ARRAY_SIZE(wnr2000v3_keys_gpio),
  463. wnr2000v3_keys_gpio);
  464. ap9x_pci_setup_wmac_led_pin(0, WNR2000V3_GPIO_WMAC_LED_WLAN_BLUE);
  465. ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
  466. ap9x_pci_setup_wmac_leds(0, wnr2000v3_wmac_leds_gpio,
  467. ARRAY_SIZE(wnr2000v3_wmac_leds_gpio));
  468. ap9x_pci_setup_wmac_btns(0, wnr2000v3_wmac_keys_gpio,
  469. ARRAY_SIZE(wnr2000v3_wmac_keys_gpio),
  470. WNR2000V3_KEYS_POLL_INTERVAL);
  471. }
  472. MIPS_MACHINE(ATH79_MACH_WNR2000_V3, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup);
  473. static void __init wnr612v2_setup(void)
  474. {
  475. u8 wlan_mac_addr[6];
  476. /*
  477. * Disable JTAG and CLKs. Allow OS to control all link LEDs.
  478. * Note: U-Boot for WNR612v2 sets undocumented bit 15 but
  479. * we leave it for now.
  480. */
  481. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  482. AR724X_GPIO_FUNC_UART_EN,
  483. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  484. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  485. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  486. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  487. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  488. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  489. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  490. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  491. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  492. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  493. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  494. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  495. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  496. wnr_common_setup(wlan_mac_addr);
  497. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
  498. wnr612v2_leds_gpio);
  499. /*
  500. * This device has no buttons on AR7241 GPIO and no extra LEDs
  501. * connected to AR9285 so setup is simpler than for WNR2000v3.
  502. */
  503. ap9x_pci_setup_wmac_led_pin(0, WNR612V2_GPIO_WMAC_LED_WLAN_GREEN);
  504. ap9x_pci_setup_wmac_led_name(0, wnr612v2_wmac_led_name);
  505. ap9x_pci_setup_wmac_leds(0, NULL, 0);
  506. ap9x_pci_setup_wmac_btns(0, wnr612v2_wmac_keys_gpio,
  507. ARRAY_SIZE(wnr612v2_wmac_keys_gpio),
  508. WNR2000V3_KEYS_POLL_INTERVAL);
  509. }
  510. MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
  511. static void __init wnr1000v2_setup(void)
  512. {
  513. u8 wlan_mac_addr[6];
  514. /*
  515. * Disable JTAG and CLKs. Allow OS to control all link LEDs.
  516. * Note: U-Boot for WNR1000v2 sets undocumented bit 15 but
  517. * we leave it for now.
  518. */
  519. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
  520. AR724X_GPIO_FUNC_UART_EN,
  521. AR724X_GPIO_FUNC_CLK_OBS1_EN |
  522. AR724X_GPIO_FUNC_CLK_OBS2_EN |
  523. AR724X_GPIO_FUNC_CLK_OBS3_EN |
  524. AR724X_GPIO_FUNC_CLK_OBS4_EN |
  525. AR724X_GPIO_FUNC_CLK_OBS5_EN |
  526. AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
  527. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  528. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  529. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  530. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  531. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  532. wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
  533. WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
  534. wnr_common_setup(wlan_mac_addr);
  535. ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio),
  536. wnr1000v2_leds_gpio);
  537. ap9x_pci_setup_wmac_led_pin(0, WNR1000V2_GPIO_WMAC_LED_WLAN_BLUE);
  538. ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
  539. ap9x_pci_setup_wmac_leds(0, wnr1000v2_wmac_leds_gpio,
  540. ARRAY_SIZE(wnr1000v2_wmac_leds_gpio));
  541. /* All 3 buttons are connected to wireless chip */
  542. ap9x_pci_setup_wmac_btns(0, wnr1000v2_wmac_keys_gpio,
  543. ARRAY_SIZE(wnr1000v2_wmac_keys_gpio),
  544. WNR2000V3_KEYS_POLL_INTERVAL);
  545. }
  546. MIPS_MACHINE(ATH79_MACH_WNR1000_V2, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup);
  547. static void __init wpn824n_setup(void)
  548. {
  549. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  550. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  551. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  552. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  553. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  554. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN |
  555. AR724X_GPIO_FUNC_CLK_OBS3_EN);
  556. wnr_common_setup(NULL);
  557. ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio),
  558. wpn824n_leds_gpio);
  559. ap9x_pci_setup_wmac_led_pin(0, WPN824N_WGPIO_LED_WLAN_BLUE);
  560. ap9x_pci_setup_wmac_led_name(0, wnr2000v3_wmac_led_name);
  561. ap9x_pci_setup_wmac_leds(0, wpn824n_wmac_leds_gpio,
  562. ARRAY_SIZE(wpn824n_wmac_leds_gpio));
  563. ap9x_pci_setup_wmac_btns(0, wpn824n_wmac_keys_gpio,
  564. ARRAY_SIZE(wpn824n_wmac_keys_gpio),
  565. WNR2000V3_KEYS_POLL_INTERVAL);
  566. }
  567. MIPS_MACHINE(ATH79_MACH_WPN824N, "WPN824N", "NETGEAR WPN824N", wpn824n_setup);