600-0020-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. From 269f19c848a2380db03a3f207cafb88e28d71c53 Mon Sep 17 00:00:00 2001
  2. From: Gabor Juhos <juhosg@openwrt.org>
  3. Date: Sun, 24 Mar 2013 19:26:28 +0100
  4. Subject: [PATCH] rt2x00: rt2800lib: add channel configuration code for RT3883
  5. Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  6. ---
  7. drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 +++++++++++++++++++++++++++++--
  8. 1 file changed, 69 insertions(+), 3 deletions(-)
  9. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  10. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  11. @@ -3406,6 +3406,36 @@ static char rt2800_txpower_to_dev(struct
  12. return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
  13. }
  14. +static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
  15. + struct rf_channel *rf)
  16. +{
  17. + u8 bbp;
  18. +
  19. + bbp = (rf->channel > 14) ? 0x48 : 0x38;
  20. + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp);
  21. +
  22. + rt2800_bbp_write(rt2x00dev, 69, 0x12);
  23. +
  24. + if (rf->channel <= 14) {
  25. + rt2800_bbp_write(rt2x00dev, 70, 0x0a);
  26. + } else {
  27. + /* Disable CCK packet detection */
  28. + rt2800_bbp_write(rt2x00dev, 70, 0x00);
  29. + }
  30. +
  31. + rt2800_bbp_write(rt2x00dev, 73, 0x10);
  32. +
  33. + if (rf->channel > 14) {
  34. + rt2800_bbp_write(rt2x00dev, 62, 0x1d);
  35. + rt2800_bbp_write(rt2x00dev, 63, 0x1d);
  36. + rt2800_bbp_write(rt2x00dev, 64, 0x1d);
  37. + } else {
  38. + rt2800_bbp_write(rt2x00dev, 62, 0x2d);
  39. + rt2800_bbp_write(rt2x00dev, 63, 0x2d);
  40. + rt2800_bbp_write(rt2x00dev, 64, 0x2d);
  41. + }
  42. +}
  43. +
  44. static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
  45. struct ieee80211_conf *conf,
  46. struct rf_channel *rf,
  47. @@ -3424,6 +3454,12 @@ static void rt2800_config_channel(struct
  48. rt2800_txpower_to_dev(rt2x00dev, rf->channel,
  49. info->default_power3);
  50. + switch (rt2x00dev->chip.rt) {
  51. + case RT3883:
  52. + rt3883_bbp_adjust(rt2x00dev, rf);
  53. + break;
  54. + }
  55. +
  56. switch (rt2x00dev->chip.rf) {
  57. case RF2020:
  58. case RF3020:
  59. @@ -3507,6 +3543,15 @@ static void rt2800_config_channel(struct
  60. rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
  61. rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
  62. rt2800_bbp_write(rt2x00dev, 77, 0x98);
  63. + } else if (rt2x00_rt(rt2x00dev, RT3883)) {
  64. + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
  65. + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
  66. + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
  67. +
  68. + if (rt2x00dev->default_ant.rx_chain_num > 1)
  69. + rt2800_bbp_write(rt2x00dev, 86, 0x46);
  70. + else
  71. + rt2800_bbp_write(rt2x00dev, 86, 0);
  72. } else {
  73. rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
  74. rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
  75. @@ -3519,6 +3564,7 @@ static void rt2800_config_channel(struct
  76. !rt2x00_rt(rt2x00dev, RT5392)) {
  77. if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  78. rt2800_bbp_write(rt2x00dev, 82, 0x62);
  79. + rt2800_bbp_write(rt2x00dev, 82, 0x62);
  80. rt2800_bbp_write(rt2x00dev, 75, 0x46);
  81. } else {
  82. if (rt2x00_rt(rt2x00dev, RT3593))
  83. @@ -3527,19 +3573,22 @@ static void rt2800_config_channel(struct
  84. rt2800_bbp_write(rt2x00dev, 82, 0x84);
  85. rt2800_bbp_write(rt2x00dev, 75, 0x50);
  86. }
  87. - if (rt2x00_rt(rt2x00dev, RT3593))
  88. + if (rt2x00_rt(rt2x00dev, RT3593) ||
  89. + rt2x00_rt(rt2x00dev, RT3883))
  90. rt2800_bbp_write(rt2x00dev, 83, 0x8a);
  91. }
  92. } else {
  93. if (rt2x00_rt(rt2x00dev, RT3572))
  94. rt2800_bbp_write(rt2x00dev, 82, 0x94);
  95. - else if (rt2x00_rt(rt2x00dev, RT3593))
  96. + else if (rt2x00_rt(rt2x00dev, RT3593) ||
  97. + rt2x00_rt(rt2x00dev, RT3883))
  98. rt2800_bbp_write(rt2x00dev, 82, 0x82);
  99. else
  100. rt2800_bbp_write(rt2x00dev, 82, 0xf2);
  101. - if (rt2x00_rt(rt2x00dev, RT3593))
  102. + if (rt2x00_rt(rt2x00dev, RT3593) ||
  103. + rt2x00_rt(rt2x00dev, RT3883))
  104. rt2800_bbp_write(rt2x00dev, 83, 0x9a);
  105. if (rt2x00_has_cap_external_lna_a(rt2x00dev))
  106. @@ -3661,6 +3710,23 @@ static void rt2800_config_channel(struct
  107. rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
  108. + usleep_range(1000, 1500);
  109. + }
  110. +
  111. + if (rt2x00_rt(rt2x00dev, RT3883)) {
  112. + if (!conf_is_ht40(conf))
  113. + rt2800_bbp_write(rt2x00dev, 105, 0x34);
  114. + else
  115. + rt2800_bbp_write(rt2x00dev, 105, 0x04);
  116. +
  117. + /* AGC init */
  118. + if (rf->channel <= 14)
  119. + reg = 0x2e + rt2x00dev->lna_gain;
  120. + else
  121. + reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3);
  122. +
  123. + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
  124. +
  125. usleep_range(1000, 1500);
  126. }