613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --- a/arch/mips/ath79/dev-wmac.c
  2. +++ b/arch/mips/ath79/dev-wmac.c
  3. @@ -18,9 +18,11 @@
  4. #include <linux/etherdevice.h>
  5. #include <linux/platform_device.h>
  6. #include <linux/ath9k_platform.h>
  7. +#include <linux/gpio.h>
  8. #include <asm/mach-ath79/ath79.h>
  9. #include <asm/mach-ath79/ar71xx_regs.h>
  10. +#include "common.h"
  11. #include "dev-wmac.h"
  12. static u8 ath79_wmac_mac[ETH_ALEN];
  13. @@ -313,6 +315,51 @@ void __init ath79_wmac_set_tx_gain_buffa
  14. ath79_wmac_data.tx_gain_buffalo = true;
  15. }
  16. +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
  17. +{
  18. + char *label;
  19. + int err;
  20. +
  21. + label = kasprintf(GFP_KERNEL, "external LNA%u", chain);
  22. + if (!label)
  23. + return -ENOMEM;
  24. +
  25. + err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
  26. + if (err) {
  27. + pr_err("unable to request GPIO%d for external LNA%u\n",
  28. + gpio, chain);
  29. + kfree(label);
  30. + }
  31. +
  32. + return err;
  33. +}
  34. +
  35. +static void ar934x_set_ext_lna_gpio(unsigned chain, int gpio)
  36. +{
  37. + unsigned int sel;
  38. + int err;
  39. +
  40. + if (WARN_ON(chain > 1))
  41. + return;
  42. +
  43. + err = ath79_request_ext_lna_gpio(chain, gpio);
  44. + if (err)
  45. + return;
  46. +
  47. + if (chain == 0)
  48. + sel = AR934X_GPIO_OUT_EXT_LNA0;
  49. + else
  50. + sel = AR934X_GPIO_OUT_EXT_LNA1;
  51. +
  52. + ath79_gpio_output_select(gpio, sel);
  53. +}
  54. +
  55. +void __init ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio)
  56. +{
  57. + if (soc_is_ar934x())
  58. + ar934x_set_ext_lna_gpio(chain, gpio);
  59. +}
  60. +
  61. void __init ath79_register_wmac(u8 *cal_data, u8 *mac_addr)
  62. {
  63. if (soc_is_ar913x())
  64. --- a/arch/mips/ath79/dev-wmac.h
  65. +++ b/arch/mips/ath79/dev-wmac.h
  66. @@ -17,6 +17,7 @@ void ath79_register_wmac_simple(void);
  67. void ath79_wmac_disable_2ghz(void);
  68. void ath79_wmac_disable_5ghz(void);
  69. void ath79_wmac_set_tx_gain_buffalo(void);
  70. +void ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio);
  71. bool ar93xx_wmac_read_mac_address(u8 *dest);