653-0028-rtl8xxxu-Implement-rtl8188eu_config_channel.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. From 9796f3807764567ecde6e3787a66e4b4edbc35df Mon Sep 17 00:00:00 2001
  2. From: Jes Sorensen <Jes.Sorensen@redhat.com>
  3. Date: Fri, 22 Jul 2016 11:40:13 -0400
  4. Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_config_channel()
  5. The 8188eu doesn't seem to have REG_FPGA0_ANALOG2, so implement it's
  6. own specific version.
  7. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
  8. ---
  9. .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 117 +++++++++++++++++++++
  10. 1 file changed, 117 insertions(+)
  11. --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
  12. +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
  13. @@ -283,6 +283,122 @@ static struct rtl8xxxu_rfregval rtl8188e
  14. {0xff, 0xffffffff}
  15. };
  16. +void rtl8188eu_config_channel(struct ieee80211_hw *hw)
  17. +{
  18. + struct rtl8xxxu_priv *priv = hw->priv;
  19. + u32 val32, rsr;
  20. + u8 val8, opmode;
  21. + bool ht = true;
  22. + int sec_ch_above, channel;
  23. + int i;
  24. +
  25. + opmode = rtl8xxxu_read8(priv, REG_BW_OPMODE);
  26. + rsr = rtl8xxxu_read32(priv, REG_RESPONSE_RATE_SET);
  27. + channel = hw->conf.chandef.chan->hw_value;
  28. +
  29. + switch (hw->conf.chandef.width) {
  30. + case NL80211_CHAN_WIDTH_20_NOHT:
  31. + ht = false;
  32. + case NL80211_CHAN_WIDTH_20:
  33. + opmode |= BW_OPMODE_20MHZ;
  34. + rtl8xxxu_write8(priv, REG_BW_OPMODE, opmode);
  35. +
  36. + val32 = rtl8xxxu_read32(priv, REG_FPGA0_RF_MODE);
  37. + val32 &= ~FPGA_RF_MODE;
  38. + rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32);
  39. +
  40. + val32 = rtl8xxxu_read32(priv, REG_FPGA1_RF_MODE);
  41. + val32 &= ~FPGA_RF_MODE;
  42. + rtl8xxxu_write32(priv, REG_FPGA1_RF_MODE, val32);
  43. + break;
  44. + case NL80211_CHAN_WIDTH_40:
  45. + if (hw->conf.chandef.center_freq1 >
  46. + hw->conf.chandef.chan->center_freq) {
  47. + sec_ch_above = 1;
  48. + channel += 2;
  49. + } else {
  50. + sec_ch_above = 0;
  51. + channel -= 2;
  52. + }
  53. +
  54. + opmode &= ~BW_OPMODE_20MHZ;
  55. + rtl8xxxu_write8(priv, REG_BW_OPMODE, opmode);
  56. + rsr &= ~RSR_RSC_BANDWIDTH_40M;
  57. + if (sec_ch_above)
  58. + rsr |= RSR_RSC_UPPER_SUB_CHANNEL;
  59. + else
  60. + rsr |= RSR_RSC_LOWER_SUB_CHANNEL;
  61. + rtl8xxxu_write32(priv, REG_RESPONSE_RATE_SET, rsr);
  62. +
  63. + val32 = rtl8xxxu_read32(priv, REG_FPGA0_RF_MODE);
  64. + val32 |= FPGA_RF_MODE;
  65. + rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32);
  66. +
  67. + val32 = rtl8xxxu_read32(priv, REG_FPGA1_RF_MODE);
  68. + val32 |= FPGA_RF_MODE;
  69. + rtl8xxxu_write32(priv, REG_FPGA1_RF_MODE, val32);
  70. +
  71. + /*
  72. + * Set Control channel to upper or lower. These settings
  73. + * are required only for 40MHz
  74. + */
  75. + val32 = rtl8xxxu_read32(priv, REG_CCK0_SYSTEM);
  76. + val32 &= ~CCK0_SIDEBAND;
  77. + if (!sec_ch_above)
  78. + val32 |= CCK0_SIDEBAND;
  79. + rtl8xxxu_write32(priv, REG_CCK0_SYSTEM, val32);
  80. +
  81. + val32 = rtl8xxxu_read32(priv, REG_OFDM1_LSTF);
  82. + val32 &= ~OFDM_LSTF_PRIME_CH_MASK; /* 0xc00 */
  83. + if (sec_ch_above)
  84. + val32 |= OFDM_LSTF_PRIME_CH_LOW;
  85. + else
  86. + val32 |= OFDM_LSTF_PRIME_CH_HIGH;
  87. + rtl8xxxu_write32(priv, REG_OFDM1_LSTF, val32);
  88. +
  89. + val32 = rtl8xxxu_read32(priv, REG_FPGA0_POWER_SAVE);
  90. + val32 &= ~(FPGA0_PS_LOWER_CHANNEL | FPGA0_PS_UPPER_CHANNEL);
  91. + if (sec_ch_above)
  92. + val32 |= FPGA0_PS_UPPER_CHANNEL;
  93. + else
  94. + val32 |= FPGA0_PS_LOWER_CHANNEL;
  95. + rtl8xxxu_write32(priv, REG_FPGA0_POWER_SAVE, val32);
  96. + break;
  97. +
  98. + default:
  99. + break;
  100. + }
  101. +
  102. + for (i = RF_A; i < priv->rf_paths; i++) {
  103. + val32 = rtl8xxxu_read_rfreg(priv, i, RF6052_REG_MODE_AG);
  104. + val32 &= ~MODE_AG_CHANNEL_MASK;
  105. + val32 |= channel;
  106. + rtl8xxxu_write_rfreg(priv, i, RF6052_REG_MODE_AG, val32);
  107. + }
  108. +
  109. + if (ht)
  110. + val8 = 0x0e;
  111. + else
  112. + val8 = 0x0a;
  113. +
  114. +#if 0
  115. + rtl8xxxu_write8(priv, REG_SIFS_CCK + 1, val8);
  116. + rtl8xxxu_write8(priv, REG_SIFS_OFDM + 1, val8);
  117. +
  118. + rtl8xxxu_write16(priv, REG_R2T_SIFS, 0x0808);
  119. + rtl8xxxu_write16(priv, REG_T2T_SIFS, 0x0a0a);
  120. +#endif
  121. +
  122. + for (i = RF_A; i < priv->rf_paths; i++) {
  123. + val32 = rtl8xxxu_read_rfreg(priv, i, RF6052_REG_MODE_AG);
  124. + if (hw->conf.chandef.width == NL80211_CHAN_WIDTH_40)
  125. + val32 &= ~MODE_AG_CHANNEL_20MHZ;
  126. + else
  127. + val32 |= MODE_AG_CHANNEL_20MHZ;
  128. + rtl8xxxu_write_rfreg(priv, i, RF6052_REG_MODE_AG, val32);
  129. + }
  130. +}
  131. +
  132. static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv)
  133. {
  134. struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu;
  135. @@ -1009,6 +1125,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops =
  136. .init_phy_bb = rtl8188eu_init_phy_bb,
  137. .init_phy_rf = rtl8188eu_init_phy_rf,
  138. .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate,
  139. + .config_channel = rtl8188eu_config_channel,
  140. .parse_rx_desc = rtl8xxxu_parse_rxdesc16,
  141. .usb_quirks = rtl8188e_usb_quirks,
  142. .writeN_block_size = 128,