mach-ubnt-xm.c 19 KB

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