mach-ubnt-xm.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /*
  2. * Ubiquiti Networks XM (rev 1.0) board support
  3. *
  4. * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
  5. *
  6. * Derived from: mach-pb44.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/pci.h>
  14. #include <linux/gpio.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/ath9k_platform.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/ar8216_platform.h>
  19. #include <linux/platform_data/phy-at803x.h>
  20. #include <asm/mach-ath79/ath79.h>
  21. #include <asm/mach-ath79/irq.h>
  22. #include <asm/mach-ath79/ar71xx_regs.h>
  23. #include <linux/platform_data/phy-at803x.h>
  24. #include "common.h"
  25. #include "dev-ap9x-pci.h"
  26. #include "dev-eth.h"
  27. #include "dev-gpio-buttons.h"
  28. #include "dev-leds-gpio.h"
  29. #include "dev-m25p80.h"
  30. #include "dev-usb.h"
  31. #include "dev-wmac.h"
  32. #include "machtypes.h"
  33. #define UBNT_XM_GPIO_LED_L1 0
  34. #define UBNT_XM_GPIO_LED_L2 1
  35. #define UBNT_XM_GPIO_LED_L3 11
  36. #define UBNT_XM_GPIO_LED_L4 7
  37. #define UBNT_XM_GPIO_BTN_RESET 12
  38. #define UBNT_XM_KEYS_POLL_INTERVAL 20
  39. #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
  40. #define UBNT_XM_EEPROM_ADDR 0x1fff1000
  41. static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
  42. {
  43. .name = "ubnt:red:link1",
  44. .gpio = UBNT_XM_GPIO_LED_L1,
  45. .active_low = 0,
  46. }, {
  47. .name = "ubnt:orange:link2",
  48. .gpio = UBNT_XM_GPIO_LED_L2,
  49. .active_low = 0,
  50. }, {
  51. .name = "ubnt:green:link3",
  52. .gpio = UBNT_XM_GPIO_LED_L3,
  53. .active_low = 0,
  54. }, {
  55. .name = "ubnt:green:link4",
  56. .gpio = UBNT_XM_GPIO_LED_L4,
  57. .active_low = 0,
  58. },
  59. };
  60. static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
  61. {
  62. .desc = "reset",
  63. .type = EV_KEY,
  64. .code = KEY_RESTART,
  65. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  66. .gpio = UBNT_XM_GPIO_BTN_RESET,
  67. .active_low = 1,
  68. }
  69. };
  70. #define UBNT_M_WAN_PHYMASK BIT(4)
  71. static void __init ubnt_xm_init(void)
  72. {
  73. u8 *eeprom = (u8 *) KSEG1ADDR(UBNT_XM_EEPROM_ADDR);
  74. u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  75. u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  76. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
  77. ubnt_xm_leds_gpio);
  78. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  79. ARRAY_SIZE(ubnt_xm_gpio_keys),
  80. ubnt_xm_gpio_keys);
  81. ath79_register_m25p80(NULL);
  82. ap91_pci_init(eeprom, NULL);
  83. ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  84. ath79_eth0_data.speed = SPEED_100;
  85. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  86. ath79_eth1_data.speed = SPEED_100;
  87. ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  88. ath79_register_eth(0);
  89. }
  90. MIPS_MACHINE(ATH79_MACH_UBNT_XM,
  91. "UBNT-XM",
  92. "Ubiquiti Networks XM (rev 1.0) board",
  93. ubnt_xm_init);
  94. MIPS_MACHINE(ATH79_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
  95. ubnt_xm_init);
  96. static void __init ubnt_rocket_m_setup(void)
  97. {
  98. ubnt_xm_init();
  99. ath79_register_usb();
  100. }
  101. MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
  102. ubnt_rocket_m_setup);
  103. static void __init ubnt_nano_m_setup(void)
  104. {
  105. ubnt_xm_init();
  106. ath79_register_eth(1);
  107. }
  108. MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
  109. ubnt_nano_m_setup);
  110. static struct gpio_led ubnt_airrouter_leds_gpio[] __initdata = {
  111. {
  112. .name = "ubnt:green:globe",
  113. .gpio = 0,
  114. .active_low = 1,
  115. }, {
  116. .name = "ubnt:green:power",
  117. .gpio = 11,
  118. .active_low = 1,
  119. .default_state = LEDS_GPIO_DEFSTATE_ON,
  120. }
  121. };
  122. static void __init ubnt_airrouter_setup(void)
  123. {
  124. u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  125. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  126. ath79_register_m25p80(NULL);
  127. ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  128. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  129. ath79_init_local_mac(ath79_eth1_data.mac_addr, mac1);
  130. ath79_register_eth(1);
  131. ath79_register_eth(0);
  132. ath79_register_usb();
  133. ap91_pci_init(ee, NULL);
  134. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airrouter_leds_gpio),
  135. ubnt_airrouter_leds_gpio);
  136. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  137. ARRAY_SIZE(ubnt_xm_gpio_keys),
  138. ubnt_xm_gpio_keys);
  139. }
  140. MIPS_MACHINE(ATH79_MACH_UBNT_AIRROUTER, "UBNT-AR", "Ubiquiti AirRouter",
  141. ubnt_airrouter_setup);
  142. static struct gpio_led ubnt_unifi_leds_gpio[] __initdata = {
  143. {
  144. .name = "ubnt:orange:dome",
  145. .gpio = 1,
  146. .active_low = 0,
  147. }, {
  148. .name = "ubnt:green:dome",
  149. .gpio = 0,
  150. .active_low = 0,
  151. }
  152. };
  153. static struct gpio_led ubnt_unifi_outdoor_leds_gpio[] __initdata = {
  154. {
  155. .name = "ubnt:orange:front",
  156. .gpio = 1,
  157. .active_low = 0,
  158. }, {
  159. .name = "ubnt:green:front",
  160. .gpio = 0,
  161. .active_low = 0,
  162. }
  163. };
  164. static struct gpio_led ubnt_unifi_outdoor_plus_leds_gpio[] __initdata = {
  165. {
  166. .name = "ubnt:white:front",
  167. .gpio = 1,
  168. .active_low = 0,
  169. }, {
  170. .name = "ubnt:blue:front",
  171. .gpio = 0,
  172. .active_low = 0,
  173. }
  174. };
  175. static void __init ubnt_unifi_setup(void)
  176. {
  177. u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  178. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  179. ath79_register_m25p80(NULL);
  180. ath79_register_mdio(0, ~UBNT_M_WAN_PHYMASK);
  181. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  182. ath79_register_eth(0);
  183. ap91_pci_init(ee, NULL);
  184. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_leds_gpio),
  185. ubnt_unifi_leds_gpio);
  186. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  187. ARRAY_SIZE(ubnt_xm_gpio_keys),
  188. ubnt_xm_gpio_keys);
  189. }
  190. MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI, "UBNT-UF", "Ubiquiti UniFi",
  191. ubnt_unifi_setup);
  192. #define UBNT_UNIFIOD_PRI_PHYMASK BIT(4)
  193. #define UBNT_UNIFIOD_2ND_PHYMASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
  194. static void __init ubnt_unifi_outdoor_setup(void)
  195. {
  196. u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  197. u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  198. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  199. ath79_register_m25p80(NULL);
  200. ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
  201. UBNT_UNIFIOD_2ND_PHYMASK));
  202. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  203. ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  204. ath79_register_eth(0);
  205. ath79_register_eth(1);
  206. ap91_pci_init(ee, NULL);
  207. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_leds_gpio),
  208. ubnt_unifi_outdoor_leds_gpio);
  209. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  210. ARRAY_SIZE(ubnt_xm_gpio_keys),
  211. ubnt_xm_gpio_keys);
  212. }
  213. MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR, "UBNT-U20",
  214. "Ubiquiti UniFiAP Outdoor",
  215. ubnt_unifi_outdoor_setup);
  216. static void __init ubnt_unifi_outdoor_plus_setup(void)
  217. {
  218. u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000);
  219. u8 *mac2 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  220. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  221. ath79_register_m25p80(NULL);
  222. ath79_register_mdio(0, ~(UBNT_UNIFIOD_PRI_PHYMASK |
  223. UBNT_UNIFIOD_2ND_PHYMASK));
  224. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  225. ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  226. ath79_register_eth(0);
  227. ath79_register_eth(1);
  228. ap9x_pci_get_wmac_data(0)->ubnt_hsr = true;
  229. ap91_pci_init(ee, NULL);
  230. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifi_outdoor_plus_leds_gpio),
  231. ubnt_unifi_outdoor_plus_leds_gpio);
  232. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  233. ARRAY_SIZE(ubnt_xm_gpio_keys),
  234. ubnt_xm_gpio_keys);
  235. }
  236. MIPS_MACHINE(ATH79_MACH_UBNT_UNIFI_OUTDOOR_PLUS, "UBNT-UOP",
  237. "Ubiquiti UniFiAP Outdoor+",
  238. ubnt_unifi_outdoor_plus_setup);
  239. static struct gpio_led ubnt_uap_pro_gpio_leds[] __initdata = {
  240. {
  241. .name = "ubnt:white:dome",
  242. .gpio = 12,
  243. }, {
  244. .name = "ubnt:blue:dome",
  245. .gpio = 13,
  246. }
  247. };
  248. static struct gpio_keys_button uap_pro_gpio_keys[] __initdata = {
  249. {
  250. .desc = "reset",
  251. .type = EV_KEY,
  252. .code = KEY_RESTART,
  253. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  254. .gpio = 17,
  255. .active_low = 1,
  256. }
  257. };
  258. static struct ar8327_pad_cfg uap_pro_ar8327_pad0_cfg = {
  259. .mode = AR8327_PAD_MAC_RGMII,
  260. .txclk_delay_en = true,
  261. .rxclk_delay_en = true,
  262. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  263. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  264. };
  265. static struct ar8327_platform_data uap_pro_ar8327_data = {
  266. .pad0_cfg = &uap_pro_ar8327_pad0_cfg,
  267. .port0_cfg = {
  268. .force_link = 1,
  269. .speed = AR8327_PORT_SPEED_1000,
  270. .duplex = 1,
  271. .txpause = 1,
  272. .rxpause = 1,
  273. },
  274. };
  275. static struct mdio_board_info uap_pro_mdio0_info[] = {
  276. {
  277. .bus_id = "ag71xx-mdio.0",
  278. .mdio_addr = 0,
  279. .platform_data = &uap_pro_ar8327_data,
  280. },
  281. };
  282. #define UAP_PRO_MAC0_OFFSET 0x0000
  283. #define UAP_PRO_MAC1_OFFSET 0x0006
  284. #define UAP_PRO_WMAC_CALDATA_OFFSET 0x1000
  285. #define UAP_PRO_PCI_CALDATA_OFFSET 0x5000
  286. static void __init ubnt_uap_pro_setup(void)
  287. {
  288. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  289. ath79_register_m25p80(NULL);
  290. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_uap_pro_gpio_leds),
  291. ubnt_uap_pro_gpio_leds);
  292. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  293. ARRAY_SIZE(uap_pro_gpio_keys),
  294. uap_pro_gpio_keys);
  295. ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  296. ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  297. ath79_register_mdio(0, 0x0);
  298. mdiobus_register_board_info(uap_pro_mdio0_info,
  299. ARRAY_SIZE(uap_pro_mdio0_info));
  300. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  301. ath79_init_mac(ath79_eth0_data.mac_addr,
  302. eeprom + UAP_PRO_MAC0_OFFSET, 0);
  303. /* GMAC0 is connected to an AR8327 switch */
  304. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  305. ath79_eth0_data.phy_mask = BIT(0);
  306. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  307. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  308. ath79_register_eth(0);
  309. }
  310. MIPS_MACHINE(ATH79_MACH_UBNT_UAP_PRO, "UAP-PRO", "Ubiquiti UniFi AP Pro",
  311. ubnt_uap_pro_setup);
  312. #define UBNT_XW_GPIO_LED_L1 11
  313. #define UBNT_XW_GPIO_LED_L2 16
  314. #define UBNT_XW_GPIO_LED_L3 13
  315. #define UBNT_XW_GPIO_LED_L4 14
  316. static struct gpio_led ubnt_xw_leds_gpio[] __initdata = {
  317. {
  318. .name = "ubnt:red:link1",
  319. .gpio = UBNT_XW_GPIO_LED_L1,
  320. .active_low = 1,
  321. }, {
  322. .name = "ubnt:orange:link2",
  323. .gpio = UBNT_XW_GPIO_LED_L2,
  324. .active_low = 1,
  325. }, {
  326. .name = "ubnt:green:link3",
  327. .gpio = UBNT_XW_GPIO_LED_L3,
  328. .active_low = 1,
  329. }, {
  330. .name = "ubnt:green:link4",
  331. .gpio = UBNT_XW_GPIO_LED_L4,
  332. .active_low = 1,
  333. },
  334. };
  335. #define UBNT_ROCKET_TI_GPIO_LED_L1 16
  336. #define UBNT_ROCKET_TI_GPIO_LED_L2 17
  337. #define UBNT_ROCKET_TI_GPIO_LED_L3 18
  338. #define UBNT_ROCKET_TI_GPIO_LED_L4 19
  339. #define UBNT_ROCKET_TI_GPIO_LED_L5 20
  340. #define UBNT_ROCKET_TI_GPIO_LED_L6 21
  341. static struct gpio_led ubnt_rocket_ti_leds_gpio[] __initdata = {
  342. {
  343. .name = "ubnt:green:link1",
  344. .gpio = UBNT_ROCKET_TI_GPIO_LED_L1,
  345. .active_low = 1,
  346. }, {
  347. .name = "ubnt:green:link2",
  348. .gpio = UBNT_ROCKET_TI_GPIO_LED_L2,
  349. .active_low = 1,
  350. }, {
  351. .name = "ubnt:green:link3",
  352. .gpio = UBNT_ROCKET_TI_GPIO_LED_L3,
  353. .active_low = 1,
  354. }, {
  355. .name = "ubnt:green:link4",
  356. .gpio = UBNT_ROCKET_TI_GPIO_LED_L4,
  357. .active_low = 0,
  358. }, {
  359. .name = "ubnt:green:link5",
  360. .gpio = UBNT_ROCKET_TI_GPIO_LED_L5,
  361. .active_low = 0,
  362. }, {
  363. .name = "ubnt:green:link6",
  364. .gpio = UBNT_ROCKET_TI_GPIO_LED_L6,
  365. .active_low = 0,
  366. },
  367. };
  368. static void __init ubnt_xw_init(void)
  369. {
  370. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  371. ath79_register_m25p80(NULL);
  372. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
  373. ubnt_xw_leds_gpio);
  374. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  375. ARRAY_SIZE(ubnt_xm_gpio_keys),
  376. ubnt_xm_gpio_keys);
  377. ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  378. ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  379. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 | AR934X_ETH_CFG_MII_GMAC0_SLAVE);
  380. ath79_init_mac(ath79_eth0_data.mac_addr,
  381. eeprom + UAP_PRO_MAC0_OFFSET, 0);
  382. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  383. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  384. }
  385. static void __init ubnt_nano_m_xw_setup(void)
  386. {
  387. ubnt_xw_init();
  388. /* GMAC0 is connected to an AR8326 switch */
  389. ath79_register_mdio(0, ~(BIT(0) | BIT(1) | BIT(5)));
  390. ath79_eth0_data.phy_mask = (BIT(0) | BIT(1) | BIT(5));
  391. ath79_eth0_data.speed = SPEED_100;
  392. ath79_eth0_data.duplex = DUPLEX_FULL;
  393. ath79_register_eth(0);
  394. }
  395. static struct at803x_platform_data ubnt_loco_m_xw_at803x_data = {
  396. .has_reset_gpio = 1,
  397. .reset_gpio = 0,
  398. };
  399. static struct mdio_board_info ubnt_loco_m_xw_mdio_info[] = {
  400. {
  401. .bus_id = "ag71xx-mdio.0",
  402. .mdio_addr = 1,
  403. .platform_data = &ubnt_loco_m_xw_at803x_data,
  404. },
  405. };
  406. static void __init ubnt_loco_m_xw_setup(void)
  407. {
  408. ubnt_xw_init();
  409. mdiobus_register_board_info(ubnt_loco_m_xw_mdio_info,
  410. ARRAY_SIZE(ubnt_loco_m_xw_mdio_info));
  411. ath79_register_mdio(0, ~BIT(1));
  412. ath79_eth0_data.phy_mask = BIT(1);
  413. ath79_register_eth(0);
  414. }
  415. #define UBNT_LBE_M5_GPIO_LED_LAN 13
  416. #define UBNT_LBE_M5_GPIO_LED_WLAN 14
  417. #define UBNT_LBE_M5_GPIO_LED_SYS 16
  418. static struct gpio_led ubnt_lbe_m5_leds_gpio[] __initdata = {
  419. {
  420. .name = "ubnt:green:lan",
  421. .gpio = UBNT_LBE_M5_GPIO_LED_LAN,
  422. .active_low = 1,
  423. }, {
  424. .name = "ubnt:green:wlan",
  425. .gpio = UBNT_LBE_M5_GPIO_LED_WLAN,
  426. .active_low = 1,
  427. }, {
  428. .name = "ubnt:green:sys",
  429. .gpio = UBNT_LBE_M5_GPIO_LED_SYS,
  430. .active_low = 1,
  431. },
  432. };
  433. static void __init ubnt_lbe_m5_setup(void)
  434. {
  435. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  436. ath79_register_m25p80(NULL);
  437. ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  438. ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  439. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_lbe_m5_leds_gpio),
  440. ubnt_lbe_m5_leds_gpio);
  441. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  442. ARRAY_SIZE(ubnt_xm_gpio_keys),
  443. ubnt_xm_gpio_keys);
  444. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_MII_GMAC0 |
  445. AR934X_ETH_CFG_MII_GMAC0_SLAVE);
  446. ath79_init_mac(ath79_eth0_data.mac_addr,
  447. eeprom + UAP_PRO_MAC0_OFFSET, 0);
  448. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  449. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  450. gpio_request_one(0, GPIOF_OUT_INIT_LOW | GPIOF_ACTIVE_LOW |
  451. GPIOF_EXPORT_DIR_FIXED, "SPI nWP");
  452. mdiobus_register_board_info(ubnt_loco_m_xw_mdio_info,
  453. ARRAY_SIZE(ubnt_loco_m_xw_mdio_info));
  454. ath79_register_mdio(0, ~BIT(1));
  455. ath79_eth0_data.phy_mask = BIT(1);
  456. ath79_register_eth(0);
  457. }
  458. static void __init ubnt_rocket_m_xw_setup(void)
  459. {
  460. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  461. ath79_register_m25p80(NULL);
  462. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xw_leds_gpio),
  463. ubnt_xw_leds_gpio);
  464. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  465. ARRAY_SIZE(ubnt_xm_gpio_keys),
  466. ubnt_xm_gpio_keys);
  467. ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  468. ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  469. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  470. ath79_init_mac(ath79_eth0_data.mac_addr,
  471. eeprom + UAP_PRO_MAC0_OFFSET, 0);
  472. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  473. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  474. ath79_register_mdio(0, ~BIT(4));
  475. ath79_eth0_data.phy_mask = BIT(4);
  476. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  477. ath79_register_eth(0);
  478. }
  479. static struct at803x_platform_data ubnt_rocket_m_ti_at803_data = {
  480. .disable_smarteee = 1,
  481. .enable_rgmii_rx_delay = 1,
  482. .enable_rgmii_tx_delay = 1,
  483. };
  484. static struct mdio_board_info ubnt_rocket_m_ti_mdio_info[] = {
  485. {
  486. .bus_id = "ag71xx-mdio.0",
  487. .mdio_addr = 4,
  488. .platform_data = &ubnt_rocket_m_ti_at803_data,
  489. },
  490. };
  491. static void __init ubnt_rocket_m_ti_setup(void)
  492. {
  493. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  494. ath79_register_m25p80(NULL);
  495. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_rocket_ti_leds_gpio),
  496. ubnt_rocket_ti_leds_gpio);
  497. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  498. ARRAY_SIZE(ubnt_xm_gpio_keys),
  499. ubnt_xm_gpio_keys);
  500. ap91_pci_init(eeprom + 0x1000, NULL);
  501. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  502. ath79_setup_ar934x_eth_rx_delay(3, 3);
  503. ath79_init_mac(ath79_eth0_data.mac_addr,
  504. eeprom + UAP_PRO_MAC0_OFFSET, 0);
  505. ath79_init_mac(ath79_eth1_data.mac_addr,
  506. eeprom + UAP_PRO_MAC1_OFFSET, 0);
  507. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  508. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  509. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  510. ath79_eth1_data.mii_bus_dev = &ath79_mdio1_device.dev;
  511. mdiobus_register_board_info(ubnt_rocket_m_ti_mdio_info,
  512. ARRAY_SIZE(ubnt_rocket_m_ti_mdio_info));
  513. ath79_register_mdio(0, 0x0);
  514. ath79_eth0_data.phy_mask = BIT(4);
  515. /* read out from vendor */
  516. ath79_eth0_pll_data.pll_1000 = 0x2000000;
  517. ath79_eth0_pll_data.pll_10 = 0x1313;
  518. ath79_register_eth(0);
  519. ath79_register_mdio(1, 0x0);
  520. ath79_eth1_data.phy_mask = BIT(3);
  521. ath79_register_eth(1);
  522. }
  523. MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, "UBNT-NM-XW", "Ubiquiti Nanostation M XW",
  524. ubnt_nano_m_xw_setup);
  525. MIPS_MACHINE(ATH79_MACH_UBNT_LBE_M5, "UBNT-LBE-M5", "Ubiquiti Litebeam M5",
  526. ubnt_lbe_m5_setup);
  527. MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
  528. ubnt_loco_m_xw_setup);
  529. MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_XW, "UBNT-RM-XW", "Ubiquiti Rocket M XW",
  530. ubnt_rocket_m_xw_setup);
  531. MIPS_MACHINE(ATH79_MACH_UBNT_ROCKET_M_TI, "UBNT-RM-TI", "Ubiquiti Rocket M TI",
  532. ubnt_rocket_m_ti_setup);
  533. static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
  534. {
  535. .name = "ubnt:blue:wlan",
  536. .gpio = 0,
  537. }, {
  538. .name = "ubnt:white:status",
  539. .gpio = 1,
  540. },
  541. };
  542. static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
  543. {
  544. .desc = "reset",
  545. .type = EV_KEY,
  546. .code = KEY_RESTART,
  547. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  548. .gpio = 12,
  549. .active_low = 1,
  550. }
  551. };
  552. static void __init ubnt_airgateway_setup(void)
  553. {
  554. u32 t;
  555. u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
  556. u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
  557. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  558. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  559. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  560. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  561. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  562. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  563. t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  564. t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  565. ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  566. ath79_register_m25p80(NULL);
  567. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
  568. ubnt_airgateway_gpio_leds);
  569. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  570. ARRAY_SIZE(airgateway_gpio_keys),
  571. airgateway_gpio_keys);
  572. ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
  573. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  574. ath79_register_mdio(0, 0x0);
  575. ath79_register_eth(1);
  576. ath79_register_eth(0);
  577. ath79_register_wmac(ee, NULL);
  578. }
  579. MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
  580. ubnt_airgateway_setup);
  581. static struct gpio_led ubnt_airgateway_pro_gpio_leds[] __initdata = {
  582. {
  583. .name = "ubnt:blue:wlan",
  584. .gpio = 13,
  585. }, {
  586. .name = "ubnt:white:status",
  587. .gpio = 17,
  588. },
  589. };
  590. static struct gpio_keys_button airgateway_pro_gpio_keys[] __initdata = {
  591. {
  592. .desc = "reset",
  593. .type = EV_KEY,
  594. .code = KEY_RESTART,
  595. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  596. .gpio = 12,
  597. .active_low = 1,
  598. }
  599. };
  600. static void __init ubnt_airgateway_pro_setup(void)
  601. {
  602. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  603. u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
  604. ath79_register_m25p80(NULL);
  605. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_pro_gpio_leds),
  606. ubnt_airgateway_pro_gpio_leds);
  607. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  608. ARRAY_SIZE(airgateway_pro_gpio_keys),
  609. airgateway_pro_gpio_keys);
  610. ath79_register_wmac(eeprom + UAP_PRO_WMAC_CALDATA_OFFSET, NULL);
  611. ap91_pci_init(eeprom + UAP_PRO_PCI_CALDATA_OFFSET, NULL);
  612. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  613. ath79_register_mdio(1, 0x0);
  614. /* GMAC0 is left unused in this configuration */
  615. /* GMAC1 is connected to MAC0 on the internal switch */
  616. /* The PoE/WAN port connects to port 5 on the internal switch */
  617. /* The LAN port connects to port 4 on the internal switch */
  618. ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
  619. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  620. ath79_register_eth(1);
  621. }
  622. MIPS_MACHINE(ATH79_MACH_UBNT_AIRGWP, "UBNT-AGWP", "Ubiquiti AirGateway Pro",
  623. ubnt_airgateway_pro_setup);