Merge tag 'wireless-drivers-next-2020-03-27' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / drivers / net / wireless / intel / iwlwifi / mvm / fw.c
index 98263cd..a4038f2 100644 (file)
@@ -5,10 +5,9 @@
  *
  * GPL LICENSE SUMMARY
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019        Intel Corporation
+ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
  *
  * BSD LICENSE
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019       Intel Corporation
+ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -89,6 +87,36 @@ struct iwl_mvm_alive_data {
        u32 scd_base_addr;
 };
 
+/* set device type and latency */
+static int iwl_set_soc_latency(struct iwl_mvm *mvm)
+{
+       struct iwl_soc_configuration_cmd cmd = {};
+       int ret;
+
+       /*
+        * In VER_1 of this command, the discrete value is considered
+        * an integer; In VER_2, it's a bitmask.  Since we have only 2
+        * values in VER_1, this is backwards-compatible with VER_2,
+        * as long as we don't set any other bits.
+        */
+       if (!mvm->trans->trans_cfg->integrated)
+               cmd.flags = cpu_to_le32(SOC_CONFIG_CMD_FLAGS_DISCRETE);
+
+       if (iwl_mvm_lookup_cmd_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP,
+                                  SCAN_REQ_UMAC) >= 2 &&
+           (mvm->trans->trans_cfg->low_latency_xtal))
+               cmd.flags |= cpu_to_le32(SOC_CONFIG_CMD_FLAGS_LOW_LATENCY);
+
+       cmd.latency = cpu_to_le32(mvm->trans->trans_cfg->xtal_latency);
+
+       ret = iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(SOC_CONFIGURATION_CMD,
+                                                  SYSTEM_GROUP, 0), 0,
+                                  sizeof(cmd), &cmd);
+       if (ret)
+               IWL_ERR(mvm, "Failed to set soc latency: %d\n", ret);
+       return ret;
+}
+
 static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
 {
        struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
@@ -544,7 +572,8 @@ static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
        phy_cfg_cmd.phy_cfg = cpu_to_le32(iwl_mvm_get_phy_config(mvm));
 
        /* set flags extra PHY configuration flags from the device's cfg */
-       phy_cfg_cmd.phy_cfg |= cpu_to_le32(mvm->cfg->extra_phy_cfg_flags);
+       phy_cfg_cmd.phy_cfg |=
+               cpu_to_le32(mvm->trans->trans_cfg->extra_phy_cfg_flags);
 
        phy_cfg_cmd.calib_control.event_trigger =
                mvm->fw->default_calib[ucode_type].event_trigger;
@@ -1110,6 +1139,13 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
        if (ret)
                goto error;
 
+       if (fw_has_capa(&mvm->fw->ucode_capa,
+                       IWL_UCODE_TLV_CAPA_SOC_LATENCY_SUPPORT)) {
+               ret = iwl_set_soc_latency(mvm);
+               if (ret)
+                       goto error;
+       }
+
        /* Init RSS configuration */
        if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000) {
                ret = iwl_configure_rxq(mvm);