mach-ubnt-xm.c 18 KB

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