812-b43-add-antenna-control.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. --- a/drivers/net/wireless/broadcom/b43/main.c
  2. +++ b/drivers/net/wireless/broadcom/b43/main.c
  3. @@ -1643,7 +1643,7 @@ static void b43_write_beacon_template(st
  4. len, ram_offset, shm_size_offset, rate);
  5. /* Write the PHY TX control parameters. */
  6. - antenna = B43_ANTENNA_DEFAULT;
  7. + antenna = dev->tx_antenna;
  8. antenna = b43_antenna_to_phyctl(antenna);
  9. ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL);
  10. /* We can't send beacons with short preamble. Would get PHY errors. */
  11. @@ -3285,8 +3285,8 @@ static int b43_chip_init(struct b43_wlde
  12. /* Select the antennae */
  13. if (phy->ops->set_rx_antenna)
  14. - phy->ops->set_rx_antenna(dev, B43_ANTENNA_DEFAULT);
  15. - b43_mgmtframe_txantenna(dev, B43_ANTENNA_DEFAULT);
  16. + phy->ops->set_rx_antenna(dev, dev->rx_antenna);
  17. + b43_mgmtframe_txantenna(dev, dev->tx_antenna);
  18. if (phy->type == B43_PHYTYPE_B) {
  19. value16 = b43_read16(dev, 0x005E);
  20. @@ -3988,7 +3988,6 @@ static int b43_op_config(struct ieee8021
  21. struct b43_wldev *dev = wl->current_dev;
  22. struct b43_phy *phy = &dev->phy;
  23. struct ieee80211_conf *conf = &hw->conf;
  24. - int antenna;
  25. int err = 0;
  26. mutex_lock(&wl->mutex);
  27. @@ -4031,11 +4030,9 @@ static int b43_op_config(struct ieee8021
  28. }
  29. /* Antennas for RX and management frame TX. */
  30. - antenna = B43_ANTENNA_DEFAULT;
  31. - b43_mgmtframe_txantenna(dev, antenna);
  32. - antenna = B43_ANTENNA_DEFAULT;
  33. + b43_mgmtframe_txantenna(dev, dev->tx_antenna);
  34. if (phy->ops->set_rx_antenna)
  35. - phy->ops->set_rx_antenna(dev, antenna);
  36. + phy->ops->set_rx_antenna(dev, dev->rx_antenna);
  37. if (wl->radio_enabled != phy->radio_on) {
  38. if (wl->radio_enabled) {
  39. @@ -5178,6 +5175,49 @@ static int b43_op_get_survey(struct ieee
  40. return 0;
  41. }
  42. +static int b43_op_set_antenna(struct ieee80211_hw *hw, int radio_idx,
  43. + u32 tx_ant, u32 rx_ant)
  44. +{
  45. + struct b43_wl *wl = hw_to_b43_wl(hw);
  46. + struct b43_wldev *dev = wl->current_dev;
  47. +
  48. + if (tx_ant == 1 && rx_ant == 1) {
  49. + dev->tx_antenna = B43_ANTENNA0;
  50. + dev->rx_antenna = B43_ANTENNA0;
  51. + }
  52. + else if (tx_ant == 2 && rx_ant == 2) {
  53. + dev->tx_antenna = B43_ANTENNA1;
  54. + dev->rx_antenna = B43_ANTENNA1;
  55. + }
  56. + else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) {
  57. + dev->tx_antenna = B43_ANTENNA_DEFAULT;
  58. + dev->rx_antenna = B43_ANTENNA_DEFAULT;
  59. + }
  60. + else {
  61. + return -EINVAL;
  62. + }
  63. +
  64. + return 0;
  65. +}
  66. +
  67. +
  68. +static int b43_op_get_antenna(struct ieee80211_hw *hw, int radio_idx,
  69. + u32 *tx_ant, u32 *rx_ant)
  70. +{
  71. + struct b43_wl *wl = hw_to_b43_wl(hw);
  72. + struct b43_wldev *dev = wl->current_dev;
  73. +
  74. + switch (dev->tx_antenna) {
  75. + case B43_ANTENNA0:
  76. + *tx_ant = 1; *rx_ant = 1; break;
  77. + case B43_ANTENNA1:
  78. + *tx_ant = 2; *rx_ant = 2; break;
  79. + case B43_ANTENNA_DEFAULT:
  80. + *tx_ant = 3; *rx_ant = 3; break;
  81. + }
  82. + return 0;
  83. +}
  84. +
  85. static const struct ieee80211_ops b43_hw_ops = {
  86. .add_chanctx = ieee80211_emulate_add_chanctx,
  87. .remove_chanctx = ieee80211_emulate_remove_chanctx,
  88. @@ -5204,6 +5244,8 @@ static const struct ieee80211_ops b43_hw
  89. .sw_scan_complete = b43_op_sw_scan_complete_notifier,
  90. .get_survey = b43_op_get_survey,
  91. .rfkill_poll = b43_rfkill_poll,
  92. + .set_antenna = b43_op_set_antenna,
  93. + .get_antenna = b43_op_get_antenna,
  94. };
  95. /* Hard-reset the chip. Do not call this directly.
  96. @@ -5505,6 +5547,8 @@ static int b43_one_core_attach(struct b4
  97. if (!wldev)
  98. goto out;
  99. + wldev->rx_antenna = B43_ANTENNA_DEFAULT;
  100. + wldev->tx_antenna = B43_ANTENNA_DEFAULT;
  101. wldev->use_pio = b43_modparam_pio;
  102. wldev->dev = dev;
  103. wldev->wl = wl;
  104. @@ -5596,6 +5640,9 @@ static struct b43_wl *b43_wireless_init(
  105. wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
  106. + hw->wiphy->available_antennas_rx = 0x3;
  107. + hw->wiphy->available_antennas_tx = 0x3;
  108. +
  109. wl->hw_registered = false;
  110. hw->max_rates = 2;
  111. SET_IEEE80211_DEV(hw, dev->dev);
  112. --- a/drivers/net/wireless/broadcom/b43/b43.h
  113. +++ b/drivers/net/wireless/broadcom/b43/b43.h
  114. @@ -841,6 +841,8 @@ struct b43_wldev {
  115. bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
  116. bool use_pio; /* TRUE if next init should use PIO */
  117. int gpiomask; /* GPIO LED mask as a module parameter */
  118. + int rx_antenna; /* Used RX antenna (B43_ANTENNAxxx) */
  119. + int tx_antenna; /* Used TX antenna (B43_ANTENNAxxx) */
  120. /* PHY/Radio device. */
  121. struct b43_phy phy;