1
0

mach-ubnt-unifiac.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Ubiquiti UniFi AC (LITE) board support
  3. *
  4. * Copyright (C) 2015-2016 P. Wassi <p.wassi at gmx.at>
  5. *
  6. * Derived from: mach-ubnt-xm.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 <asm/mach-ath79/ath79.h>
  18. #include <asm/mach-ath79/irq.h>
  19. #include <asm/mach-ath79/ar71xx_regs.h>
  20. #include <linux/platform_data/phy-at803x.h>
  21. #include <linux/ar8216_platform.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-wmac.h"
  29. #include "dev-usb.h"
  30. #include "machtypes.h"
  31. #define UNIFIAC_KEYS_POLL_INTERVAL 20
  32. #define UNIFIAC_KEYS_DEBOUNCE_INTERVAL (3 * UNIFIAC_KEYS_POLL_INTERVAL)
  33. #define UNIFIAC_GPIO_LED_WHITE 7
  34. #define UNIFIAC_GPIO_LED_BLUE 8
  35. #define UNIFIAC_GPIO_BTN_RESET 2
  36. #define UNIFIAC_MAC0_OFFSET 0x0000
  37. #define UNIFIAC_WMAC_CALDATA_OFFSET 0x1000
  38. #define UNIFIAC_PCI_CALDATA_OFFSET 0x5000
  39. static struct flash_platform_data ubnt_unifiac_flash_data = {
  40. /* mx25l12805d and mx25l12835f have the same JEDEC ID */
  41. .type = "mx25l12805d",
  42. };
  43. static struct gpio_led ubnt_unifiac_leds_gpio[] __initdata = {
  44. {
  45. .name = "ubnt:white:dome",
  46. .gpio = UNIFIAC_GPIO_LED_WHITE,
  47. .active_low = 0,
  48. }, {
  49. .name = "ubnt:blue:dome",
  50. .gpio = UNIFIAC_GPIO_LED_BLUE,
  51. .active_low = 0,
  52. }
  53. };
  54. static struct gpio_keys_button ubnt_unifiac_gpio_keys[] __initdata = {
  55. {
  56. .desc = "reset",
  57. .type = EV_KEY,
  58. .code = KEY_RESTART,
  59. .debounce_interval = UNIFIAC_KEYS_DEBOUNCE_INTERVAL,
  60. .gpio = UNIFIAC_GPIO_BTN_RESET,
  61. .active_low = 1,
  62. }
  63. };
  64. static void __init ubnt_unifiac_lite_setup(void)
  65. {
  66. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  67. ath79_register_m25p80(&ubnt_unifiac_flash_data);
  68. ath79_init_mac(ath79_eth0_data.mac_addr,
  69. eeprom + UNIFIAC_MAC0_OFFSET, 0);
  70. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  71. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  72. ath79_eth0_data.phy_mask = BIT(4);
  73. ath79_eth0_pll_data.pll_10 = 0x00001313;
  74. ath79_register_mdio(0, ~BIT(4));
  75. ath79_register_eth(0);
  76. ath79_register_wmac(eeprom + UNIFIAC_WMAC_CALDATA_OFFSET, NULL);
  77. ap91_pci_init(eeprom + UNIFIAC_PCI_CALDATA_OFFSET, NULL);
  78. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifiac_leds_gpio),
  79. ubnt_unifiac_leds_gpio);
  80. ath79_register_gpio_keys_polled(-1, UNIFIAC_KEYS_POLL_INTERVAL,
  81. ARRAY_SIZE(ubnt_unifiac_gpio_keys),
  82. ubnt_unifiac_gpio_keys);
  83. }
  84. MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC_LITE, "UBNT-UF-AC-LITE", "Ubiquiti UniFi-AC-LITE",
  85. ubnt_unifiac_lite_setup);
  86. static struct ar8327_pad_cfg ubnt_unifiac_pro_ar8327_pad0_cfg = {
  87. .mode = AR8327_PAD_MAC_SGMII,
  88. .sgmii_delay_en = true,
  89. };
  90. static struct ar8327_platform_data ubnt_unifiac_pro_ar8327_data = {
  91. .pad0_cfg = &ubnt_unifiac_pro_ar8327_pad0_cfg,
  92. .port0_cfg = {
  93. .force_link = 1,
  94. .speed = AR8327_PORT_SPEED_1000,
  95. .duplex = 1,
  96. .txpause = 1,
  97. .rxpause = 1,
  98. },
  99. };
  100. static struct mdio_board_info ubnt_unifiac_pro_mdio0_info[] = {
  101. {
  102. .bus_id = "ag71xx-mdio.0",
  103. .phy_addr = 0,
  104. .platform_data = &ubnt_unifiac_pro_ar8327_data,
  105. },
  106. };
  107. static void __init ubnt_unifiac_pro_setup(void)
  108. {
  109. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff0000);
  110. ath79_register_m25p80(&ubnt_unifiac_flash_data);
  111. ath79_init_mac(ath79_eth0_data.mac_addr,
  112. eeprom + UNIFIAC_MAC0_OFFSET, 0);
  113. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  114. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  115. ath79_eth0_data.phy_mask = BIT(0);
  116. mdiobus_register_board_info(ubnt_unifiac_pro_mdio0_info,
  117. ARRAY_SIZE(ubnt_unifiac_pro_mdio0_info));
  118. ath79_register_mdio(0, 0x00);
  119. ath79_register_eth(0);
  120. ath79_register_usb();
  121. ath79_register_wmac(eeprom + UNIFIAC_WMAC_CALDATA_OFFSET, NULL);
  122. ap91_pci_init(eeprom + UNIFIAC_PCI_CALDATA_OFFSET, NULL);
  123. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_unifiac_leds_gpio),
  124. ubnt_unifiac_leds_gpio);
  125. ath79_register_gpio_keys_polled(-1, UNIFIAC_KEYS_POLL_INTERVAL,
  126. ARRAY_SIZE(ubnt_unifiac_gpio_keys),
  127. ubnt_unifiac_gpio_keys);
  128. }
  129. MIPS_MACHINE(ATH79_MACH_UBNT_UNIFIAC_PRO, "UBNT-UF-AC-PRO", "Ubiquiti UniFi-AC-PRO",
  130. ubnt_unifiac_pro_setup);