mach-hiveap-121.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Aerohive HiveAP 121 board support
  3. *
  4. * Copyright (C) 2017 Chris Blake <chrisrblake93@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/i2c.h>
  12. #include <linux/i2c-gpio.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/ath9k_platform.h>
  15. #include <linux/platform/ar934x_nfc.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h>
  18. #include "common.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-nfc.h"
  23. #include "dev-usb.h"
  24. #include "dev-wmac.h"
  25. #include "dev-ap9x-pci.h"
  26. #include "dev-m25p80.h"
  27. #include "machtypes.h"
  28. #define HIVEAP_121_GPIO_LED_ORANGE 14
  29. #define HIVEAP_121_GPIO_LED_WHITE 21
  30. #define HIVEAP_121_GPIO_I2C_SCL 12
  31. #define HIVEAP_121_GPIO_I2C_SDA 13
  32. #define HIVEAP_121_GPIO_XLNA0 20
  33. #define HIVEAP_121_GPIO_XLNA1 19
  34. #define HIVEAP_121_GPIO_USB_POWER 15
  35. #define HIVEAP_121_GPIO_BTN_RESET 4
  36. #define HIVEAP_121_KEYS_POLL_INTERVAL 20 /* msecs */
  37. #define HIVEAP_121_KEYS_DEBOUNCE_INTERVAL \
  38. (3 * HIVEAP_121_KEYS_POLL_INTERVAL)
  39. #define HIVEAP_121_MAC_OFFSET 0x90000
  40. #define HIVEAP_121_LAN_PHYADDR 0
  41. static struct gpio_led hiveap_121_leds_gpio[] __initdata = {
  42. {
  43. .name = "hiveap-121:orange:power",
  44. .gpio = HIVEAP_121_GPIO_LED_ORANGE,
  45. .active_low = 1,
  46. }, {
  47. .name = "hiveap-121:white:power",
  48. .gpio = HIVEAP_121_GPIO_LED_WHITE,
  49. .active_low = 1,
  50. }
  51. };
  52. static struct gpio_keys_button hiveap_121_gpio_keys[] __initdata = {
  53. {
  54. .desc = "reset",
  55. .type = EV_KEY,
  56. .code = KEY_RESTART,
  57. .debounce_interval = HIVEAP_121_KEYS_DEBOUNCE_INTERVAL,
  58. .gpio = HIVEAP_121_GPIO_BTN_RESET,
  59. .active_low = 1,
  60. },
  61. };
  62. static struct i2c_gpio_platform_data hiveap_121_i2c_gpio_data = {
  63. .sda_pin = HIVEAP_121_GPIO_I2C_SDA,
  64. .scl_pin = HIVEAP_121_GPIO_I2C_SCL,
  65. };
  66. static struct platform_device hiveap_121_i2c_gpio_device = {
  67. .name = "i2c-gpio",
  68. .id = 0,
  69. .dev = {
  70. .platform_data = &hiveap_121_i2c_gpio_data,
  71. }
  72. };
  73. static struct i2c_board_info tpm_i2c_info[] __initdata = {
  74. {
  75. I2C_BOARD_INFO("tpm_i2c_atmel", 0x29),
  76. }
  77. };
  78. static void __init hiveap_121_setup(void)
  79. {
  80. u8 *base = (u8 *) KSEG1ADDR(0x1f000000);
  81. u8 wlan0_mac[ETH_ALEN];
  82. u8 wlan1_mac[ETH_ALEN];
  83. /* NAND */
  84. ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
  85. ath79_register_nfc();
  86. /* SPI */
  87. ath79_register_m25p80(NULL);
  88. /* MDIO Interface */
  89. ath79_register_mdio(0, 0x0);
  90. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  91. AR934X_ETH_CFG_RXD_DELAY |
  92. AR934X_ETH_CFG_RDV_DELAY);
  93. /* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
  94. ath79_init_mac(ath79_eth0_data.mac_addr,
  95. base + HIVEAP_121_MAC_OFFSET, 0);
  96. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  97. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  98. ath79_eth0_data.phy_mask = BIT(HIVEAP_121_LAN_PHYADDR);
  99. ath79_eth0_pll_data.pll_1000 = 0x0e000000;
  100. ath79_eth0_pll_data.pll_100 = 0x00000101;
  101. ath79_eth0_pll_data.pll_10 = 0x00001313;
  102. ath79_register_eth(0);
  103. /* i2c */
  104. ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
  105. platform_device_register(&hiveap_121_i2c_gpio_device);
  106. /* TPM */
  107. i2c_register_board_info(0, tpm_i2c_info, ARRAY_SIZE(tpm_i2c_info));
  108. /* LEDs and Buttons */
  109. ath79_register_leds_gpio(-1, ARRAY_SIZE(hiveap_121_leds_gpio),
  110. hiveap_121_leds_gpio);
  111. ath79_register_gpio_keys_polled(-1, HIVEAP_121_KEYS_POLL_INTERVAL,
  112. ARRAY_SIZE(hiveap_121_gpio_keys),
  113. hiveap_121_gpio_keys);
  114. /* USB */
  115. gpio_request_one(HIVEAP_121_GPIO_USB_POWER,
  116. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  117. "USB power");
  118. ath79_register_usb();
  119. /* XLNA - SoC Wireless */
  120. ath79_wmac_set_ext_lna_gpio(0, HIVEAP_121_GPIO_XLNA0);
  121. ath79_wmac_set_ext_lna_gpio(1, HIVEAP_121_GPIO_XLNA1);
  122. /* SoC Wireless */
  123. ath79_init_mac(wlan0_mac, base + HIVEAP_121_MAC_OFFSET, 1);
  124. ath79_register_wmac(NULL, wlan0_mac); /* Caldata in OTP */
  125. /* PCIe Wireless */
  126. ath79_init_mac(wlan1_mac, base + HIVEAP_121_MAC_OFFSET, 2);
  127. ap91_pci_init(NULL, wlan1_mac); /* Caldata in OTP */
  128. }
  129. MIPS_MACHINE(ATH79_MACH_HIVEAP_121, "HiveAP-121", "Aerohive HiveAP-121",
  130. hiveap_121_setup);