610-rt2x00-fix-rt3352-ext-pa.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  2. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  3. @@ -3529,11 +3529,18 @@ static void rt2800_config_channel(struct
  4. /*
  5. * Change BBP settings
  6. */
  7. +
  8. if (rt2x00_rt(rt2x00dev, RT3352)) {
  9. + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
  10. + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
  11. + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
  12. +
  13. rt2800_bbp_write(rt2x00dev, 27, 0x0);
  14. rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
  15. rt2800_bbp_write(rt2x00dev, 27, 0x20);
  16. rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
  17. + rt2800_bbp_write(rt2x00dev, 86, 0x38);
  18. + rt2800_bbp_write(rt2x00dev, 83, 0x6a);
  19. } else if (rt2x00_rt(rt2x00dev, RT3593)) {
  20. if (rf->channel > 14) {
  21. /* Disable CCK Packet detection on 5GHz */
  22. @@ -6595,6 +6602,12 @@ static void rt2800_init_rfcsr_3290(struc
  23. static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
  24. {
  25. + int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
  26. + &rt2x00dev->cap_flags);
  27. + int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
  28. + &rt2x00dev->cap_flags);
  29. + u8 rfcsr;
  30. +
  31. rt2800_rf_init_calibration(rt2x00dev, 30);
  32. rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
  33. @@ -6630,15 +6643,30 @@ static void rt2800_init_rfcsr_3352(struc
  34. rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
  35. rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
  36. rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
  37. - rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
  38. + rfcsr = 0x01;
  39. + if (!tx0_int_pa)
  40. + rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
  41. + if (!tx1_int_pa)
  42. + rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
  43. + rt2800_rfcsr_write(rt2x00dev, 34, rfcsr);
  44. rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
  45. rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
  46. rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
  47. rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
  48. rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
  49. rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
  50. - rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
  51. - rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
  52. + rfcsr = 0x52;
  53. + if (tx0_int_pa) {
  54. + rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
  55. + rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
  56. + }
  57. + rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
  58. + rfcsr = 0x52;
  59. + if (tx1_int_pa) {
  60. + rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
  61. + rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
  62. + }
  63. + rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
  64. rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
  65. rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
  66. rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
  67. @@ -6646,15 +6674,20 @@ static void rt2800_init_rfcsr_3352(struc
  68. rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
  69. rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
  70. rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
  71. - rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
  72. - rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
  73. - rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
  74. - rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
  75. - rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
  76. - rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
  77. - rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
  78. - rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
  79. - rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
  80. + rfcsr = 0x2d;
  81. + if (!tx0_int_pa)
  82. + rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
  83. + if (!tx1_int_pa)
  84. + rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
  85. + rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
  86. + rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
  87. + rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
  88. + rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
  89. + rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
  90. + rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
  91. + rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
  92. + rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
  93. + rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
  94. rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
  95. rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
  96. rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
  97. @@ -7675,6 +7708,7 @@ static int rt2800_init_eeprom(struct rt2
  98. * RT53xx: defined in "EEPROM_CHIP_ID" field
  99. */
  100. if (rt2x00_rt(rt2x00dev, RT3290) ||
  101. + rt2x00_rt(rt2x00dev, RT3352) ||
  102. rt2x00_rt(rt2x00dev, RT5390) ||
  103. rt2x00_rt(rt2x00dev, RT5392))
  104. rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
  105. @@ -7770,7 +7804,8 @@ static int rt2800_init_eeprom(struct rt2
  106. /*
  107. * Detect if this device has Bluetooth co-existence.
  108. */
  109. - if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
  110. + if (!rt2x00_rt(rt2x00dev, RT3352) &&
  111. + rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
  112. __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
  113. /*
  114. @@ -7799,6 +7834,22 @@ static int rt2800_init_eeprom(struct rt2
  115. EIRP_MAX_TX_POWER_LIMIT)
  116. __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
  117. + /*
  118. + * Detect if device uses internal or external PA
  119. + */
  120. + rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
  121. +
  122. + if (rt2x00_rt(rt2x00dev, RT3352)) {
  123. + if (!rt2x00_get_field16(eeprom,
  124. + EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
  125. + __set_bit(CAPABILITY_INTERNAL_PA_TX0,
  126. + &rt2x00dev->cap_flags);
  127. + if (!rt2x00_get_field16(eeprom,
  128. + EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
  129. + __set_bit(CAPABILITY_INTERNAL_PA_TX1,
  130. + &rt2x00dev->cap_flags);
  131. + }
  132. +
  133. return 0;
  134. }
  135. --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
  136. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
  137. @@ -2335,6 +2335,12 @@ struct mac_iveiv_entry {
  138. #define RFCSR36_RF_BS FIELD8(0x80)
  139. /*
  140. + * RFCSR 34:
  141. + */
  142. +#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
  143. +#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
  144. +
  145. +/*
  146. * RFCSR 38:
  147. */
  148. #define RFCSR38_RX_LO1_EN FIELD8(0x20)
  149. @@ -2346,6 +2352,18 @@ struct mac_iveiv_entry {
  150. #define RFCSR39_RX_LO2_EN FIELD8(0x80)
  151. /*
  152. + * RFCSR 41:
  153. + */
  154. +#define RFCSR41_BIT1 FIELD8(0x01)
  155. +#define RFCSR41_BIT4 FIELD8(0x08)
  156. +
  157. +/*
  158. + * RFCSR 42:
  159. + */
  160. +#define RFCSR42_BIT1 FIELD8(0x01)
  161. +#define RFCSR42_BIT4 FIELD8(0x08)
  162. +
  163. +/*
  164. * RFCSR 49:
  165. */
  166. #define RFCSR49_TX FIELD8(0x3f)
  167. @@ -2358,6 +2376,8 @@ struct mac_iveiv_entry {
  168. * RFCSR 50:
  169. */
  170. #define RFCSR50_TX FIELD8(0x3f)
  171. +#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
  172. +#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
  173. #define RFCSR50_EP FIELD8(0xc0)
  174. /* bits for RT3593 */
  175. #define RFCSR50_TX_LO1_EN FIELD8(0x20)
  176. @@ -2505,6 +2525,8 @@ enum rt2800_eeprom_word {
  177. * INTERNAL_TX_ALC: 0: disable, 1: enable
  178. * BT_COEXIST: 0: disable, 1: enable
  179. * DAC_TEST: 0: disable, 1: enable
  180. + * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
  181. + * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
  182. */
  183. #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
  184. #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC FIELD16(0x0002)
  185. @@ -2521,6 +2543,8 @@ enum rt2800_eeprom_word {
  186. #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
  187. #define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
  188. #define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
  189. +#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352 FIELD16(0x4000)
  190. +#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352 FIELD16(0x8000)
  191. /*
  192. * EEPROM frequency
  193. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  194. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  195. @@ -719,6 +719,8 @@ enum rt2x00_capability_flags {
  196. CAPABILITY_DOUBLE_ANTENNA,
  197. CAPABILITY_BT_COEXIST,
  198. CAPABILITY_VCO_RECALIBRATION,
  199. + CAPABILITY_INTERNAL_PA_TX0,
  200. + CAPABILITY_INTERNAL_PA_TX1,
  201. };
  202. /*