These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / rtl8192e / rtl8192e / r8190P_rtl8256.c
index 01d2201..81b3cf6 100644 (file)
@@ -6,10 +6,6 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
  * The full GNU General Public License is included in this distribution in the
  * file called LICENSE.
  *
 #include "r8192E_phy.h"
 #include "r8190P_rtl8256.h"
 
-void PHY_SetRF8256Bandwidth(struct net_device *dev,
-                           enum ht_channel_width Bandwidth)
+void rtl92e_set_bandwidth(struct net_device *dev,
+                         enum ht_channel_width Bandwidth)
 {
        u8      eRFPath;
        struct r8192_priv *priv = rtllib_priv(dev);
 
+       if (priv->card_8192_version != VERSION_8190_BD &&
+           priv->card_8192_version != VERSION_8190_BE) {
+               netdev_warn(dev, "%s(): Unknown HW version.\n", __func__);
+               return;
+       }
+
        for (eRFPath = 0; eRFPath < priv->NumTotalRFPath; eRFPath++) {
-               if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
-                               continue;
+               if (!rtl92e_is_legal_rf_path(dev, eRFPath))
+                       continue;
 
                switch (Bandwidth) {
                case HT_CHANNEL_WIDTH_20:
-                       if (priv->card_8192_version == VERSION_8190_BD ||
-                           priv->card_8192_version == VERSION_8190_BE) {
-                               rtl8192_phy_SetRFReg(dev,
-                                               (enum rf90_radio_path)eRFPath,
-                                               0x0b, bMask12Bits, 0x100);
-                               rtl8192_phy_SetRFReg(dev,
-                                               (enum rf90_radio_path)eRFPath,
-                                               0x2c, bMask12Bits, 0x3d7);
-                               rtl8192_phy_SetRFReg(dev,
-                                               (enum rf90_radio_path)eRFPath,
-                                               0x0e, bMask12Bits, 0x021);
-
-                       } else {
-                               RT_TRACE(COMP_ERR,
-                                        "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
-                       }
-
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x0b, bMask12Bits, 0x100);
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x2c, bMask12Bits, 0x3d7);
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x0e, bMask12Bits, 0x021);
                        break;
                case HT_CHANNEL_WIDTH_20_40:
-                       if (priv->card_8192_version == VERSION_8190_BD ||
-                           priv->card_8192_version == VERSION_8190_BE) {
-                               rtl8192_phy_SetRFReg(dev,
-                                                (enum rf90_radio_path)eRFPath,
-                                                0x0b, bMask12Bits, 0x300);
-                               rtl8192_phy_SetRFReg(dev,
-                                                (enum rf90_radio_path)eRFPath,
-                                                0x2c, bMask12Bits, 0x3ff);
-                               rtl8192_phy_SetRFReg(dev,
-                                                (enum rf90_radio_path)eRFPath,
-                                                0x0e, bMask12Bits, 0x0e1);
-
-                       } else {
-                               RT_TRACE(COMP_ERR,
-                                        "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
-                       }
-
-
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x0b, bMask12Bits, 0x300);
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x2c, bMask12Bits, 0x3ff);
+                       rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath,
+                                         0x0e, bMask12Bits, 0x0e1);
                        break;
                default:
-                       RT_TRACE(COMP_ERR,
-                                "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",
-                                Bandwidth);
+                       netdev_err(dev, "%s(): Unknown bandwidth: %#X\n",
+                                  __func__, Bandwidth);
                        break;
 
                }
        }
 }
 
-bool PHY_RF8256_Config(struct net_device *dev)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-
-       priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
-       return phy_RF8256_Config_ParaFile(dev);
-}
-
-bool phy_RF8256_Config_ParaFile(struct net_device *dev)
+bool rtl92e_config_rf(struct net_device *dev)
 {
        u32     u4RegValue = 0;
        u8      eRFPath;
@@ -103,10 +73,12 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
        u8      ConstRetryTimes = 5, RetryTimes = 5;
        u8 ret = 0;
 
+       priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
+
        for (eRFPath = (enum rf90_radio_path)RF90_PATH_A;
             eRFPath < priv->NumTotalRFPath; eRFPath++) {
-               if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
-                               continue;
+               if (!rtl92e_is_legal_rf_path(dev, eRFPath))
+                       continue;
 
                pPhyReg = &priv->PHYRegDef[eRFPath];
 
@@ -114,123 +86,71 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                switch (eRFPath) {
                case RF90_PATH_A:
                case RF90_PATH_C:
-                       u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs,
-                                                       bRFSI_RFENV);
+                       u4RegValue = rtl92e_get_bb_reg(dev, pPhyReg->rfintfs,
+                                                      bRFSI_RFENV);
                        break;
                case RF90_PATH_B:
                case RF90_PATH_D:
-                       u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs,
-                                                       bRFSI_RFENV<<16);
+                       u4RegValue = rtl92e_get_bb_reg(dev, pPhyReg->rfintfs,
+                                                      bRFSI_RFENV<<16);
                        break;
                }
 
-               rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
+               rtl92e_set_bb_reg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
 
-               rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
+               rtl92e_set_bb_reg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
 
-               rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2,
-                                b3WireAddressLength, 0x0);
-               rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2,
-                                b3WireDataLength, 0x0);
+               rtl92e_set_bb_reg(dev, pPhyReg->rfHSSIPara2,
+                                 b3WireAddressLength, 0x0);
+               rtl92e_set_bb_reg(dev, pPhyReg->rfHSSIPara2,
+                                 b3WireDataLength, 0x0);
 
-               rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0,
-                                    bMask12Bits, 0xbf);
+               rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath, 0x0,
+                                 bMask12Bits, 0xbf);
 
-               rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF,
-                                               (enum rf90_radio_path)eRFPath);
+               rtStatus = rtl92e_check_bb_and_rf(dev, HW90_BLOCK_RF,
+                                                 (enum rf90_radio_path)eRFPath);
                if (!rtStatus) {
-                       RT_TRACE(COMP_ERR,
-                                "PHY_RF8256_Config():Check Radio[%d] Fail!!\n",
-                                eRFPath);
-                       goto phy_RF8256_Config_ParaFile_Fail;
+                       netdev_err(dev, "%s(): Failed to check RF Path %d.\n",
+                                  __func__, eRFPath);
+                       goto fail;
                }
 
                RetryTimes = ConstRetryTimes;
                RF3_Final_Value = 0;
-               switch (eRFPath) {
-               case RF90_PATH_A:
-                       while (RF3_Final_Value != RegValueToBeCheck &&
-                              RetryTimes != 0) {
-                               ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,
+               while (RF3_Final_Value != RegValueToBeCheck &&
+                      RetryTimes != 0) {
+                       ret = rtl92e_config_rf_path(dev,
                                                (enum rf90_radio_path)eRFPath);
-                               RF3_Final_Value = rtl8192_phy_QueryRFReg(dev,
-                                                (enum rf90_radio_path)eRFPath,
-                                                RegOffSetToBeCheck,
-                                                bMask12Bits);
-                               RT_TRACE(COMP_RF,
-                                        "RF %d %d register final value: %x\n",
-                                        eRFPath, RegOffSetToBeCheck,
-                                        RF3_Final_Value);
-                               RetryTimes--;
-                       }
-                       break;
-               case RF90_PATH_B:
-                       while (RF3_Final_Value != RegValueToBeCheck &&
-                              RetryTimes != 0) {
-                               ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,
-                                               (enum rf90_radio_path)eRFPath);
-                               RF3_Final_Value = rtl8192_phy_QueryRFReg(dev,
-                                                (enum rf90_radio_path)eRFPath,
-                                                RegOffSetToBeCheck,
-                                                bMask12Bits);
-                               RT_TRACE(COMP_RF,
-                                        "RF %d %d register final value: %x\n",
-                                        eRFPath, RegOffSetToBeCheck,
-                                        RF3_Final_Value);
-                               RetryTimes--;
-                       }
-                       break;
-               case RF90_PATH_C:
-                       while (RF3_Final_Value != RegValueToBeCheck &&
-                              RetryTimes != 0) {
-                               ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,
-                                               (enum rf90_radio_path)eRFPath);
-                               RF3_Final_Value = rtl8192_phy_QueryRFReg(dev,
+                       RF3_Final_Value = rtl92e_get_rf_reg(dev,
                                                (enum rf90_radio_path)eRFPath,
                                                RegOffSetToBeCheck,
                                                bMask12Bits);
-                               RT_TRACE(COMP_RF,
-                                        "RF %d %d register final value: %x\n",
-                                        eRFPath, RegOffSetToBeCheck,
-                                        RF3_Final_Value);
-                               RetryTimes--;
-                       }
-                       break;
-               case RF90_PATH_D:
-                       while (RF3_Final_Value != RegValueToBeCheck &&
-                              RetryTimes != 0) {
-                               ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,
-                                              (enum rf90_radio_path)eRFPath);
-                               RF3_Final_Value = rtl8192_phy_QueryRFReg(dev,
-                                              (enum rf90_radio_path)eRFPath,
-                                              RegOffSetToBeCheck, bMask12Bits);
-                               RT_TRACE(COMP_RF,
-                                        "RF %d %d register final value: %x\n",
-                                        eRFPath, RegOffSetToBeCheck,
-                                        RF3_Final_Value);
-                               RetryTimes--;
-                       }
-                       break;
+                       RT_TRACE(COMP_RF,
+                                "RF %d %d register final value: %x\n",
+                                eRFPath, RegOffSetToBeCheck,
+                                RF3_Final_Value);
+                       RetryTimes--;
                }
 
                switch (eRFPath) {
                case RF90_PATH_A:
                case RF90_PATH_C:
-                       rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV,
-                                        u4RegValue);
+                       rtl92e_set_bb_reg(dev, pPhyReg->rfintfs, bRFSI_RFENV,
+                                         u4RegValue);
                        break;
                case RF90_PATH_B:
                case RF90_PATH_D:
-                       rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16,
-                                        u4RegValue);
+                       rtl92e_set_bb_reg(dev, pPhyReg->rfintfs,
+                                         bRFSI_RFENV<<16, u4RegValue);
                        break;
                }
 
                if (ret) {
-                       RT_TRACE(COMP_ERR,
-                                "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!",
-                                eRFPath);
-                       goto phy_RF8256_Config_ParaFile_Fail;
+                       netdev_err(dev,
+                                  "%s(): Failed to initialize RF Path %d.\n",
+                                  __func__, eRFPath);
+                       goto fail;
                }
 
        }
@@ -238,12 +158,11 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
        RT_TRACE(COMP_PHY, "PHY Initialization Success\n");
        return true;
 
-phy_RF8256_Config_ParaFile_Fail:
-       RT_TRACE(COMP_ERR, "PHY Initialization failed\n");
+fail:
        return false;
 }
 
-void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8        powerlevel)
+void rtl92e_set_cck_tx_power(struct net_device *dev, u8 powerlevel)
 {
        u32     TxAGC = 0;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -257,11 +176,11 @@ void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8   powerlevel)
        }
        if (TxAGC > 0x24)
                TxAGC = 0x24;
-       rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
+       rtl92e_set_bb_reg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
 }
 
 
-void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel)
+void rtl92e_set_ofdm_tx_power(struct net_device *dev, u8 powerlevel)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        u32 writeVal, powerBase0, powerBase1, writeVal_tmp;
@@ -303,7 +222,7 @@ void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel)
                else
                        writeVal = (byte3 << 24) | (byte2 << 16) |
                                   (byte1 << 8) | byte0;
-               rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
+               rtl92e_set_bb_reg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
        }
 
 }