334-ath9k-allow-disabling-bands-via-platform-data.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From: Felix Fietkau <[email protected]>
  2. Date: Sat, 18 Oct 2014 18:27:23 +0200
  3. Subject: [PATCH] ath9k: allow disabling bands via platform data
  4. Some devices have multiple bands enables in the EEPROM data, even though
  5. they are only calibrated for one. Allow platform data to disable
  6. unsupported bands.
  7. Signed-off-by: Gabor Juhos <[email protected]>
  8. Signed-off-by: Felix Fietkau <[email protected]>
  9. ---
  10. --- a/drivers/net/wireless/ath/ath9k/hw.c
  11. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  12. @@ -2344,17 +2344,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
  13. }
  14. eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
  15. - if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
  16. - ath_err(common,
  17. - "no band has been marked as supported in EEPROM\n");
  18. - return -EINVAL;
  19. +
  20. + if (eeval & AR5416_OPFLAGS_11A) {
  21. + if (ah->disable_5ghz)
  22. + ath_warn(common, "disabling 5GHz band\n");
  23. + else
  24. + pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
  25. }
  26. - if (eeval & AR5416_OPFLAGS_11A)
  27. - pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
  28. + if (eeval & AR5416_OPFLAGS_11G) {
  29. + if (ah->disable_2ghz)
  30. + ath_warn(common, "disabling 2GHz band\n");
  31. + else
  32. + pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
  33. + }
  34. - if (eeval & AR5416_OPFLAGS_11G)
  35. - pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
  36. + if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ | ATH9K_HW_CAP_5GHZ)) == 0) {
  37. + ath_err(common, "both bands are disabled\n");
  38. + return -EINVAL;
  39. + }
  40. if (AR_SREV_9485(ah) ||
  41. AR_SREV_9285(ah) ||
  42. --- a/drivers/net/wireless/ath/ath9k/hw.h
  43. +++ b/drivers/net/wireless/ath/ath9k/hw.h
  44. @@ -930,6 +930,8 @@ struct ath_hw {
  45. bool is_clk_25mhz;
  46. int (*get_mac_revision)(void);
  47. int (*external_reset)(void);
  48. + bool disable_2ghz;
  49. + bool disable_5ghz;
  50. const struct firmware *eeprom_blob;
  51. --- a/drivers/net/wireless/ath/ath9k/init.c
  52. +++ b/drivers/net/wireless/ath/ath9k/init.c
  53. @@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, s
  54. ah->is_clk_25mhz = pdata->is_clk_25mhz;
  55. ah->get_mac_revision = pdata->get_mac_revision;
  56. ah->external_reset = pdata->external_reset;
  57. + ah->disable_2ghz = pdata->disable_2ghz;
  58. + ah->disable_5ghz = pdata->disable_5ghz;
  59. if (!pdata->endian_check)
  60. ah->ah_flags |= AH_NO_EEP_SWAP;
  61. }
  62. --- a/include/linux/ath9k_platform.h
  63. +++ b/include/linux/ath9k_platform.h
  64. @@ -34,6 +34,8 @@ struct ath9k_platform_data {
  65. bool endian_check;
  66. bool is_clk_25mhz;
  67. bool tx_gain_buffalo;
  68. + bool disable_2ghz;
  69. + bool disable_5ghz;
  70. int (*get_mac_revision)(void);
  71. int (*external_reset)(void);