820-b43-add-antenna-control.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. --- a/drivers/net/wireless/broadcom/b43/main.c
  2. +++ b/drivers/net/wireless/broadcom/b43/main.c
  3. @@ -1648,7 +1648,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. @@ -3300,8 +3300,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. @@ -4001,7 +4001,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. @@ -4044,11 +4043,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. @@ -5209,6 +5206,47 @@ static int b43_op_get_survey(struct ieee
  40. return 0;
  41. }
  42. +static int b43_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
  43. +{
  44. + struct b43_wl *wl = hw_to_b43_wl(hw);
  45. + struct b43_wldev *dev = wl->current_dev;
  46. +
  47. + if (tx_ant == 1 && rx_ant == 1) {
  48. + dev->tx_antenna = B43_ANTENNA0;
  49. + dev->rx_antenna = B43_ANTENNA0;
  50. + }
  51. + else if (tx_ant == 2 && rx_ant == 2) {
  52. + dev->tx_antenna = B43_ANTENNA1;
  53. + dev->rx_antenna = B43_ANTENNA1;
  54. + }
  55. + else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3) {
  56. + dev->tx_antenna = B43_ANTENNA_DEFAULT;
  57. + dev->rx_antenna = B43_ANTENNA_DEFAULT;
  58. + }
  59. + else {
  60. + return -EINVAL;
  61. + }
  62. +
  63. + return 0;
  64. +}
  65. +
  66. +
  67. +static int b43_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
  68. +{
  69. + struct b43_wl *wl = hw_to_b43_wl(hw);
  70. + struct b43_wldev *dev = wl->current_dev;
  71. +
  72. + switch (dev->tx_antenna) {
  73. + case B43_ANTENNA0:
  74. + *tx_ant = 1; *rx_ant = 1; break;
  75. + case B43_ANTENNA1:
  76. + *tx_ant = 2; *rx_ant = 2; break;
  77. + case B43_ANTENNA_DEFAULT:
  78. + *tx_ant = 3; *rx_ant = 3; break;
  79. + }
  80. + return 0;
  81. +}
  82. +
  83. static const struct ieee80211_ops b43_hw_ops = {
  84. .tx = b43_op_tx,
  85. .conf_tx = b43_op_conf_tx,
  86. @@ -5230,6 +5268,8 @@ static const struct ieee80211_ops b43_hw
  87. .sw_scan_complete = b43_op_sw_scan_complete_notifier,
  88. .get_survey = b43_op_get_survey,
  89. .rfkill_poll = b43_rfkill_poll,
  90. + .set_antenna = b43_op_set_antenna,
  91. + .get_antenna = b43_op_get_antenna,
  92. };
  93. /* Hard-reset the chip. Do not call this directly.
  94. @@ -5538,6 +5578,8 @@ static int b43_one_core_attach(struct b4
  95. if (!wldev)
  96. goto out;
  97. + wldev->rx_antenna = B43_ANTENNA_DEFAULT;
  98. + wldev->tx_antenna = B43_ANTENNA_DEFAULT;
  99. wldev->use_pio = b43_modparam_pio;
  100. wldev->dev = dev;
  101. wldev->wl = wl;
  102. @@ -5628,6 +5670,9 @@ static struct b43_wl *b43_wireless_init(
  103. hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
  104. + hw->wiphy->available_antennas_rx = 0x3;
  105. + hw->wiphy->available_antennas_tx = 0x3;
  106. +
  107. wl->hw_registred = false;
  108. hw->max_rates = 2;
  109. SET_IEEE80211_DEV(hw, dev->dev);
  110. --- a/drivers/net/wireless/broadcom/b43/b43.h
  111. +++ b/drivers/net/wireless/broadcom/b43/b43.h
  112. @@ -840,6 +840,8 @@ struct b43_wldev {
  113. bool hwcrypto_enabled; /* TRUE, if HW crypto acceleration is enabled. */
  114. bool use_pio; /* TRUE if next init should use PIO */
  115. int gpiomask; /* GPIO LED mask as a module parameter */
  116. + int rx_antenna; /* Used RX antenna (B43_ANTENNAxxx) */
  117. + int tx_antenna; /* Used TX antenna (B43_ANTENNAxxx) */
  118. /* PHY/Radio device. */
  119. struct b43_phy phy;