Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
0002 /*
0003  * Copyright (C) 2020 - 2021 Intel Corporation
0004  */
0005 
0006 #include "mvm.h"
0007 #include "fw/api/commands.h"
0008 #include "fw/api/phy-ctxt.h"
0009 
0010 /*
0011  * DDR needs frequency in units of 16.666MHz, so provide FW with the
0012  * frequency values in the adjusted format.
0013  */
0014 static const struct iwl_rfi_lut_entry iwl_rfi_table[IWL_RFI_LUT_SIZE] = {
0015     /* frequency 2667MHz */
0016     {cpu_to_le16(160), {50, 58, 60, 62, 64, 52, 54, 56},
0017           {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0018            PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},
0019 
0020     /* frequency 2933MHz */
0021     {cpu_to_le16(176), {149, 151, 153, 157, 159, 161, 165, 163, 167, 169,
0022                 171, 173, 175},
0023           {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0024            PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0025            PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},
0026 
0027     /* frequency 3200MHz */
0028     {cpu_to_le16(192), {79, 81, 83, 85, 87, 89, 91, 93},
0029           {PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,
0030            PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,}},
0031 
0032     /* frequency 3733MHz */
0033     {cpu_to_le16(223), {114, 116, 118, 120, 122, 106, 110, 124, 126},
0034           {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0035            PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},
0036 
0037     /* frequency 4000MHz */
0038     {cpu_to_le16(240), {114, 151, 155, 157, 159, 161, 165},
0039           {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0040            PHY_BAND_5, PHY_BAND_5,}},
0041 
0042     /* frequency 4267MHz */
0043     {cpu_to_le16(256), {79, 83, 85, 87, 89, 91, 93,},
0044            {PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,
0045         PHY_BAND_6, PHY_BAND_6,}},
0046 
0047     /* frequency 4400MHz */
0048     {cpu_to_le16(264), {111, 119, 123, 125, 129, 131, 133, 135, 143,},
0049           {PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,
0050            PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,}},
0051 
0052     /* frequency 5200MHz */
0053     {cpu_to_le16(312), {36, 38, 40, 42, 44, 46, 50,},
0054            {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0055         PHY_BAND_5, PHY_BAND_5,}},
0056 
0057     /* frequency 5600MHz */
0058     {cpu_to_le16(336), {106, 110, 112, 114, 116, 118, 120, 122},
0059            {PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,
0060         PHY_BAND_5, PHY_BAND_5, PHY_BAND_5,}},
0061 
0062     /* frequency 6000MHz */
0063     {cpu_to_le16(360), {3, 5, 7, 9, 11, 13, 15,},
0064            {PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,
0065         PHY_BAND_6, PHY_BAND_6,}},
0066 
0067     /* frequency 6400MHz */
0068     {cpu_to_le16(384), {79, 83, 85, 87, 89, 91, 93,},
0069            {PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6, PHY_BAND_6,
0070         PHY_BAND_6, PHY_BAND_6,}},
0071 };
0072 
0073 int iwl_rfi_send_config_cmd(struct iwl_mvm *mvm, struct iwl_rfi_lut_entry *rfi_table)
0074 {
0075     int ret;
0076     struct iwl_rfi_config_cmd cmd;
0077     struct iwl_host_cmd hcmd = {
0078         .id = WIDE_ID(SYSTEM_GROUP, RFI_CONFIG_CMD),
0079         .dataflags[0] = IWL_HCMD_DFL_DUP,
0080         .data[0] = &cmd,
0081         .len[0] = sizeof(cmd),
0082     };
0083 
0084     if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_RFIM_SUPPORT))
0085         return -EOPNOTSUPP;
0086 
0087     lockdep_assert_held(&mvm->mutex);
0088 
0089     /* in case no table is passed, use the default one */
0090     if (!rfi_table) {
0091         memcpy(cmd.table, iwl_rfi_table, sizeof(cmd.table));
0092     } else {
0093         memcpy(cmd.table, rfi_table, sizeof(cmd.table));
0094         /* notify FW the table is not the default one */
0095         cmd.oem = 1;
0096     }
0097 
0098     ret = iwl_mvm_send_cmd(mvm, &hcmd);
0099 
0100     if (ret)
0101         IWL_ERR(mvm, "Failed to send RFI config cmd %d\n", ret);
0102 
0103     return ret;
0104 }
0105 
0106 struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm)
0107 {
0108     struct iwl_rfi_freq_table_resp_cmd *resp;
0109     int resp_size = sizeof(*resp);
0110     int ret;
0111     struct iwl_host_cmd cmd = {
0112         .id = WIDE_ID(SYSTEM_GROUP, RFI_GET_FREQ_TABLE_CMD),
0113         .flags = CMD_WANT_SKB,
0114     };
0115 
0116     if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_RFIM_SUPPORT))
0117         return ERR_PTR(-EOPNOTSUPP);
0118 
0119     mutex_lock(&mvm->mutex);
0120     ret = iwl_mvm_send_cmd(mvm, &cmd);
0121     mutex_unlock(&mvm->mutex);
0122     if (ret)
0123         return ERR_PTR(ret);
0124 
0125     if (WARN_ON_ONCE(iwl_rx_packet_payload_len(cmd.resp_pkt) != resp_size))
0126         return ERR_PTR(-EIO);
0127 
0128     resp = kmemdup(cmd.resp_pkt->data, resp_size, GFP_KERNEL);
0129     if (!resp)
0130         return ERR_PTR(-ENOMEM);
0131 
0132     iwl_free_resp(&cmd);
0133     return resp;
0134 }
0135 
0136 void iwl_rfi_deactivate_notif_handler(struct iwl_mvm *mvm,
0137                       struct iwl_rx_cmd_buffer *rxb)
0138 {
0139     struct iwl_rx_packet *pkt = rxb_addr(rxb);
0140     struct iwl_rfi_deactivate_notif *notif = (void *)pkt->data;
0141 
0142     IWL_INFO(mvm, "RFIm is deactivated, reason = %d\n", notif->reason);
0143 }