18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/******************************************************************************
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
58c2ecf20Sopenharmony_ci * Copyright (C) 2019 Intel Corporation
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Contact Information:
88c2ecf20Sopenharmony_ci *  Intel Linux Wireless <linuxwifi@intel.com>
98c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci *****************************************************************************/
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/units.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * DVM device-specific data & functions
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#include "iwl-io.h"
198c2ecf20Sopenharmony_ci#include "iwl-prph.h"
208c2ecf20Sopenharmony_ci#include "iwl-eeprom-parse.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include "agn.h"
238c2ecf20Sopenharmony_ci#include "dev.h"
248c2ecf20Sopenharmony_ci#include "commands.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci * 1000 series
298c2ecf20Sopenharmony_ci * ===========
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/*
338c2ecf20Sopenharmony_ci * For 1000, use advance thermal throttling critical temperature threshold,
348c2ecf20Sopenharmony_ci * but legacy thermal management implementation for now.
358c2ecf20Sopenharmony_ci * This is for the reason of 1000 uCode using advance thermal throttling API
368c2ecf20Sopenharmony_ci * but not implement ct_kill_exit based on ct_kill exit temperature
378c2ecf20Sopenharmony_ci * so the thermal throttling will still based on legacy thermal throttling
388c2ecf20Sopenharmony_ci * management.
398c2ecf20Sopenharmony_ci * The code here need to be modified once 1000 uCode has the advanced thermal
408c2ecf20Sopenharmony_ci * throttling algorithm in place
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_cistatic void iwl1000_set_ct_threshold(struct iwl_priv *priv)
438c2ecf20Sopenharmony_ci{
448c2ecf20Sopenharmony_ci	/* want Celsius */
458c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
468c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* NIC configuration for 1000 series */
508c2ecf20Sopenharmony_cistatic void iwl1000_nic_config(struct iwl_priv *priv)
518c2ecf20Sopenharmony_ci{
528c2ecf20Sopenharmony_ci	/* Setting digital SVR for 1000 card to 1.32V */
538c2ecf20Sopenharmony_ci	/* locking is acquired in iwl_set_bits_mask_prph() function */
548c2ecf20Sopenharmony_ci	iwl_set_bits_mask_prph(priv->trans, APMG_DIGITAL_SVR_REG,
558c2ecf20Sopenharmony_ci				APMG_SVR_DIGITAL_VOLTAGE_1_32,
568c2ecf20Sopenharmony_ci				~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
578c2ecf20Sopenharmony_ci}
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/**
608c2ecf20Sopenharmony_ci * iwl_beacon_time_mask_low - mask of lower 32 bit of beacon time
618c2ecf20Sopenharmony_ci * @priv: pointer to iwl_priv data structure
628c2ecf20Sopenharmony_ci * @tsf_bits: number of bits need to shift for masking)
638c2ecf20Sopenharmony_ci */
648c2ecf20Sopenharmony_cistatic inline u32 iwl_beacon_time_mask_low(struct iwl_priv *priv,
658c2ecf20Sopenharmony_ci					   u16 tsf_bits)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	return (1 << tsf_bits) - 1;
688c2ecf20Sopenharmony_ci}
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/**
718c2ecf20Sopenharmony_ci * iwl_beacon_time_mask_high - mask of higher 32 bit of beacon time
728c2ecf20Sopenharmony_ci * @priv: pointer to iwl_priv data structure
738c2ecf20Sopenharmony_ci * @tsf_bits: number of bits need to shift for masking)
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_cistatic inline u32 iwl_beacon_time_mask_high(struct iwl_priv *priv,
768c2ecf20Sopenharmony_ci					    u16 tsf_bits)
778c2ecf20Sopenharmony_ci{
788c2ecf20Sopenharmony_ci	return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/*
828c2ecf20Sopenharmony_ci * extended beacon time format
838c2ecf20Sopenharmony_ci * time in usec will be changed into a 32-bit value in extended:internal format
848c2ecf20Sopenharmony_ci * the extended part is the beacon counts
858c2ecf20Sopenharmony_ci * the internal part is the time in usec within one beacon interval
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_cistatic u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec,
888c2ecf20Sopenharmony_ci				u32 beacon_interval)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	u32 quot;
918c2ecf20Sopenharmony_ci	u32 rem;
928c2ecf20Sopenharmony_ci	u32 interval = beacon_interval * TIME_UNIT;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	if (!interval || !usec)
958c2ecf20Sopenharmony_ci		return 0;
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	quot = (usec / interval) &
988c2ecf20Sopenharmony_ci		(iwl_beacon_time_mask_high(priv, IWLAGN_EXT_BEACON_TIME_POS) >>
998c2ecf20Sopenharmony_ci		IWLAGN_EXT_BEACON_TIME_POS);
1008c2ecf20Sopenharmony_ci	rem = (usec % interval) & iwl_beacon_time_mask_low(priv,
1018c2ecf20Sopenharmony_ci				   IWLAGN_EXT_BEACON_TIME_POS);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	return (quot << IWLAGN_EXT_BEACON_TIME_POS) + rem;
1048c2ecf20Sopenharmony_ci}
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* base is usually what we get from ucode with each received frame,
1078c2ecf20Sopenharmony_ci * the same as HW timer counter counting down
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_cistatic __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
1108c2ecf20Sopenharmony_ci			   u32 addon, u32 beacon_interval)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	u32 base_low = base & iwl_beacon_time_mask_low(priv,
1138c2ecf20Sopenharmony_ci				IWLAGN_EXT_BEACON_TIME_POS);
1148c2ecf20Sopenharmony_ci	u32 addon_low = addon & iwl_beacon_time_mask_low(priv,
1158c2ecf20Sopenharmony_ci				IWLAGN_EXT_BEACON_TIME_POS);
1168c2ecf20Sopenharmony_ci	u32 interval = beacon_interval * TIME_UNIT;
1178c2ecf20Sopenharmony_ci	u32 res = (base & iwl_beacon_time_mask_high(priv,
1188c2ecf20Sopenharmony_ci				IWLAGN_EXT_BEACON_TIME_POS)) +
1198c2ecf20Sopenharmony_ci				(addon & iwl_beacon_time_mask_high(priv,
1208c2ecf20Sopenharmony_ci				IWLAGN_EXT_BEACON_TIME_POS));
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	if (base_low > addon_low)
1238c2ecf20Sopenharmony_ci		res += base_low - addon_low;
1248c2ecf20Sopenharmony_ci	else if (base_low < addon_low) {
1258c2ecf20Sopenharmony_ci		res += interval + base_low - addon_low;
1268c2ecf20Sopenharmony_ci		res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
1278c2ecf20Sopenharmony_ci	} else
1288c2ecf20Sopenharmony_ci		res += (1 << IWLAGN_EXT_BEACON_TIME_POS);
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	return cpu_to_le32(res);
1318c2ecf20Sopenharmony_ci}
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistatic const struct iwl_sensitivity_ranges iwl1000_sensitivity = {
1348c2ecf20Sopenharmony_ci	.min_nrg_cck = 95,
1358c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm = 90,
1368c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc = 170,
1378c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_x1 = 120,
1388c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc_x1 = 240,
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm = 120,
1418c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc = 210,
1428c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_x1 = 155,
1438c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc_x1 = 290,
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	.auto_corr_min_cck = 125,
1468c2ecf20Sopenharmony_ci	.auto_corr_max_cck = 200,
1478c2ecf20Sopenharmony_ci	.auto_corr_min_cck_mrc = 170,
1488c2ecf20Sopenharmony_ci	.auto_corr_max_cck_mrc = 400,
1498c2ecf20Sopenharmony_ci	.nrg_th_cck = 95,
1508c2ecf20Sopenharmony_ci	.nrg_th_ofdm = 95,
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	.barker_corr_th_min = 190,
1538c2ecf20Sopenharmony_ci	.barker_corr_th_min_mrc = 390,
1548c2ecf20Sopenharmony_ci	.nrg_th_cca = 62,
1558c2ecf20Sopenharmony_ci};
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistatic void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
1588c2ecf20Sopenharmony_ci{
1598c2ecf20Sopenharmony_ci	iwl1000_set_ct_threshold(priv);
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	/* Set initial sensitivity parameters */
1628c2ecf20Sopenharmony_ci	priv->hw_params.sens = &iwl1000_sensitivity;
1638c2ecf20Sopenharmony_ci}
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_1000_cfg = {
1668c2ecf20Sopenharmony_ci	.set_hw_params = iwl1000_hw_set_hw_params,
1678c2ecf20Sopenharmony_ci	.nic_config = iwl1000_nic_config,
1688c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
1698c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
1708c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
1718c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/*
1768c2ecf20Sopenharmony_ci * 2000 series
1778c2ecf20Sopenharmony_ci * ===========
1788c2ecf20Sopenharmony_ci */
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic void iwl2000_set_ct_threshold(struct iwl_priv *priv)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	/* want Celsius */
1838c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
1848c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci/* NIC configuration for 2000 series */
1888c2ecf20Sopenharmony_cistatic void iwl2000_nic_config(struct iwl_priv *priv)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
1918c2ecf20Sopenharmony_ci		    CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
1928c2ecf20Sopenharmony_ci}
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistatic const struct iwl_sensitivity_ranges iwl2000_sensitivity = {
1958c2ecf20Sopenharmony_ci	.min_nrg_cck = 97,
1968c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm = 80,
1978c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc = 128,
1988c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_x1 = 105,
1998c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc_x1 = 192,
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm = 145,
2028c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc = 232,
2038c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_x1 = 110,
2048c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc_x1 = 232,
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	.auto_corr_min_cck = 125,
2078c2ecf20Sopenharmony_ci	.auto_corr_max_cck = 175,
2088c2ecf20Sopenharmony_ci	.auto_corr_min_cck_mrc = 160,
2098c2ecf20Sopenharmony_ci	.auto_corr_max_cck_mrc = 310,
2108c2ecf20Sopenharmony_ci	.nrg_th_cck = 97,
2118c2ecf20Sopenharmony_ci	.nrg_th_ofdm = 100,
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	.barker_corr_th_min = 190,
2148c2ecf20Sopenharmony_ci	.barker_corr_th_min_mrc = 390,
2158c2ecf20Sopenharmony_ci	.nrg_th_cca = 62,
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	iwl2000_set_ct_threshold(priv);
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	/* Set initial sensitivity parameters */
2238c2ecf20Sopenharmony_ci	priv->hw_params.sens = &iwl2000_sensitivity;
2248c2ecf20Sopenharmony_ci}
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_2000_cfg = {
2278c2ecf20Sopenharmony_ci	.set_hw_params = iwl2000_hw_set_hw_params,
2288c2ecf20Sopenharmony_ci	.nic_config = iwl2000_nic_config,
2298c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
2308c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
2318c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
2328c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2338c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
2348c2ecf20Sopenharmony_ci	.hd_v2 = true,
2358c2ecf20Sopenharmony_ci	.need_temp_offset_calib = true,
2368c2ecf20Sopenharmony_ci	.temp_offset_v2 = true,
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_105_cfg = {
2408c2ecf20Sopenharmony_ci	.set_hw_params = iwl2000_hw_set_hw_params,
2418c2ecf20Sopenharmony_ci	.nic_config = iwl2000_nic_config,
2428c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
2438c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
2448c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
2458c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2468c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
2478c2ecf20Sopenharmony_ci	.hd_v2 = true,
2488c2ecf20Sopenharmony_ci	.need_temp_offset_calib = true,
2498c2ecf20Sopenharmony_ci	.temp_offset_v2 = true,
2508c2ecf20Sopenharmony_ci	.adv_pm = true,
2518c2ecf20Sopenharmony_ci};
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_cistatic const struct iwl_dvm_bt_params iwl2030_bt_params = {
2548c2ecf20Sopenharmony_ci	/* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
2558c2ecf20Sopenharmony_ci	.advanced_bt_coexist = true,
2568c2ecf20Sopenharmony_ci	.agg_time_limit = BT_AGG_THRESHOLD_DEF,
2578c2ecf20Sopenharmony_ci	.bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
2588c2ecf20Sopenharmony_ci	.bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT32,
2598c2ecf20Sopenharmony_ci	.bt_sco_disable = true,
2608c2ecf20Sopenharmony_ci	.bt_session_2 = true,
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_2030_cfg = {
2648c2ecf20Sopenharmony_ci	.set_hw_params = iwl2000_hw_set_hw_params,
2658c2ecf20Sopenharmony_ci	.nic_config = iwl2000_nic_config,
2668c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
2678c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
2688c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
2698c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2708c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
2718c2ecf20Sopenharmony_ci	.hd_v2 = true,
2728c2ecf20Sopenharmony_ci	.bt_params = &iwl2030_bt_params,
2738c2ecf20Sopenharmony_ci	.need_temp_offset_calib = true,
2748c2ecf20Sopenharmony_ci	.temp_offset_v2 = true,
2758c2ecf20Sopenharmony_ci	.adv_pm = true,
2768c2ecf20Sopenharmony_ci};
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/*
2798c2ecf20Sopenharmony_ci * 5000 series
2808c2ecf20Sopenharmony_ci * ===========
2818c2ecf20Sopenharmony_ci */
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci/* NIC configuration for 5000 series */
2848c2ecf20Sopenharmony_cistatic const struct iwl_sensitivity_ranges iwl5000_sensitivity = {
2858c2ecf20Sopenharmony_ci	.min_nrg_cck = 100,
2868c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm = 90,
2878c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc = 170,
2888c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_x1 = 105,
2898c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc_x1 = 220,
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm = 120,
2928c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc = 210,
2938c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_x1 = 120,
2948c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc_x1 = 240,
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	.auto_corr_min_cck = 125,
2978c2ecf20Sopenharmony_ci	.auto_corr_max_cck = 200,
2988c2ecf20Sopenharmony_ci	.auto_corr_min_cck_mrc = 200,
2998c2ecf20Sopenharmony_ci	.auto_corr_max_cck_mrc = 400,
3008c2ecf20Sopenharmony_ci	.nrg_th_cck = 100,
3018c2ecf20Sopenharmony_ci	.nrg_th_ofdm = 100,
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	.barker_corr_th_min = 190,
3048c2ecf20Sopenharmony_ci	.barker_corr_th_min_mrc = 390,
3058c2ecf20Sopenharmony_ci	.nrg_th_cca = 62,
3068c2ecf20Sopenharmony_ci};
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic const struct iwl_sensitivity_ranges iwl5150_sensitivity = {
3098c2ecf20Sopenharmony_ci	.min_nrg_cck = 95,
3108c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm = 90,
3118c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc = 170,
3128c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_x1 = 105,
3138c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc_x1 = 220,
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm = 120,
3168c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc = 210,
3178c2ecf20Sopenharmony_ci	/* max = min for performance bug in 5150 DSP */
3188c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_x1 = 105,
3198c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc_x1 = 220,
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	.auto_corr_min_cck = 125,
3228c2ecf20Sopenharmony_ci	.auto_corr_max_cck = 200,
3238c2ecf20Sopenharmony_ci	.auto_corr_min_cck_mrc = 170,
3248c2ecf20Sopenharmony_ci	.auto_corr_max_cck_mrc = 400,
3258c2ecf20Sopenharmony_ci	.nrg_th_cck = 95,
3268c2ecf20Sopenharmony_ci	.nrg_th_ofdm = 95,
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	.barker_corr_th_min = 190,
3298c2ecf20Sopenharmony_ci	.barker_corr_th_min_mrc = 390,
3308c2ecf20Sopenharmony_ci	.nrg_th_cca = 62,
3318c2ecf20Sopenharmony_ci};
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci#define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF	(-5)
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
3368c2ecf20Sopenharmony_ci{
3378c2ecf20Sopenharmony_ci	u16 temperature, voltage;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	temperature = le16_to_cpu(priv->nvm_data->kelvin_temperature);
3408c2ecf20Sopenharmony_ci	voltage = le16_to_cpu(priv->nvm_data->kelvin_voltage);
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci	/* offset = temp - volt / coeff */
3438c2ecf20Sopenharmony_ci	return (s32)(temperature -
3448c2ecf20Sopenharmony_ci			voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
3458c2ecf20Sopenharmony_ci}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistatic void iwl5150_set_ct_threshold(struct iwl_priv *priv)
3488c2ecf20Sopenharmony_ci{
3498c2ecf20Sopenharmony_ci	const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
3508c2ecf20Sopenharmony_ci	s32 threshold = (s32)celsius_to_kelvin(CT_KILL_THRESHOLD_LEGACY) -
3518c2ecf20Sopenharmony_ci			iwl_temp_calib_to_offset(priv);
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
3548c2ecf20Sopenharmony_ci}
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_cistatic void iwl5000_set_ct_threshold(struct iwl_priv *priv)
3578c2ecf20Sopenharmony_ci{
3588c2ecf20Sopenharmony_ci	/* want Celsius */
3598c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
3608c2ecf20Sopenharmony_ci}
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
3638c2ecf20Sopenharmony_ci{
3648c2ecf20Sopenharmony_ci	iwl5000_set_ct_threshold(priv);
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci	/* Set initial sensitivity parameters */
3678c2ecf20Sopenharmony_ci	priv->hw_params.sens = &iwl5000_sensitivity;
3688c2ecf20Sopenharmony_ci}
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_cistatic void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
3718c2ecf20Sopenharmony_ci{
3728c2ecf20Sopenharmony_ci	iwl5150_set_ct_threshold(priv);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	/* Set initial sensitivity parameters */
3758c2ecf20Sopenharmony_ci	priv->hw_params.sens = &iwl5150_sensitivity;
3768c2ecf20Sopenharmony_ci}
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistatic void iwl5150_temperature(struct iwl_priv *priv)
3798c2ecf20Sopenharmony_ci{
3808c2ecf20Sopenharmony_ci	u32 vt = 0;
3818c2ecf20Sopenharmony_ci	s32 offset =  iwl_temp_calib_to_offset(priv);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	vt = le32_to_cpu(priv->statistics.common.temperature);
3848c2ecf20Sopenharmony_ci	vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
3858c2ecf20Sopenharmony_ci	/* now vt hold the temperature in Kelvin */
3868c2ecf20Sopenharmony_ci	priv->temperature = kelvin_to_celsius(vt);
3878c2ecf20Sopenharmony_ci	iwl_tt_handler(priv);
3888c2ecf20Sopenharmony_ci}
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cistatic int iwl5000_hw_channel_switch(struct iwl_priv *priv,
3918c2ecf20Sopenharmony_ci				     struct ieee80211_channel_switch *ch_switch)
3928c2ecf20Sopenharmony_ci{
3938c2ecf20Sopenharmony_ci	/*
3948c2ecf20Sopenharmony_ci	 * MULTI-FIXME
3958c2ecf20Sopenharmony_ci	 * See iwlagn_mac_channel_switch.
3968c2ecf20Sopenharmony_ci	 */
3978c2ecf20Sopenharmony_ci	struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3988c2ecf20Sopenharmony_ci	struct iwl5000_channel_switch_cmd cmd;
3998c2ecf20Sopenharmony_ci	u32 switch_time_in_usec, ucode_switch_time;
4008c2ecf20Sopenharmony_ci	u16 ch;
4018c2ecf20Sopenharmony_ci	u32 tsf_low;
4028c2ecf20Sopenharmony_ci	u8 switch_count;
4038c2ecf20Sopenharmony_ci	u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
4048c2ecf20Sopenharmony_ci	struct ieee80211_vif *vif = ctx->vif;
4058c2ecf20Sopenharmony_ci	struct iwl_host_cmd hcmd = {
4068c2ecf20Sopenharmony_ci		.id = REPLY_CHANNEL_SWITCH,
4078c2ecf20Sopenharmony_ci		.len = { sizeof(cmd), },
4088c2ecf20Sopenharmony_ci		.data = { &cmd, },
4098c2ecf20Sopenharmony_ci	};
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci	cmd.band = priv->band == NL80211_BAND_2GHZ;
4128c2ecf20Sopenharmony_ci	ch = ch_switch->chandef.chan->hw_value;
4138c2ecf20Sopenharmony_ci	IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
4148c2ecf20Sopenharmony_ci		      ctx->active.channel, ch);
4158c2ecf20Sopenharmony_ci	cmd.channel = cpu_to_le16(ch);
4168c2ecf20Sopenharmony_ci	cmd.rxon_flags = ctx->staging.flags;
4178c2ecf20Sopenharmony_ci	cmd.rxon_filter_flags = ctx->staging.filter_flags;
4188c2ecf20Sopenharmony_ci	switch_count = ch_switch->count;
4198c2ecf20Sopenharmony_ci	tsf_low = ch_switch->timestamp & 0x0ffffffff;
4208c2ecf20Sopenharmony_ci	/*
4218c2ecf20Sopenharmony_ci	 * calculate the ucode channel switch time
4228c2ecf20Sopenharmony_ci	 * adding TSF as one of the factor for when to switch
4238c2ecf20Sopenharmony_ci	 */
4248c2ecf20Sopenharmony_ci	if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
4258c2ecf20Sopenharmony_ci		if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
4268c2ecf20Sopenharmony_ci		    beacon_interval)) {
4278c2ecf20Sopenharmony_ci			switch_count -= (priv->ucode_beacon_time -
4288c2ecf20Sopenharmony_ci				tsf_low) / beacon_interval;
4298c2ecf20Sopenharmony_ci		} else
4308c2ecf20Sopenharmony_ci			switch_count = 0;
4318c2ecf20Sopenharmony_ci	}
4328c2ecf20Sopenharmony_ci	if (switch_count <= 1)
4338c2ecf20Sopenharmony_ci		cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time);
4348c2ecf20Sopenharmony_ci	else {
4358c2ecf20Sopenharmony_ci		switch_time_in_usec =
4368c2ecf20Sopenharmony_ci			vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
4378c2ecf20Sopenharmony_ci		ucode_switch_time = iwl_usecs_to_beacons(priv,
4388c2ecf20Sopenharmony_ci							 switch_time_in_usec,
4398c2ecf20Sopenharmony_ci							 beacon_interval);
4408c2ecf20Sopenharmony_ci		cmd.switch_time = iwl_add_beacon_time(priv,
4418c2ecf20Sopenharmony_ci						      priv->ucode_beacon_time,
4428c2ecf20Sopenharmony_ci						      ucode_switch_time,
4438c2ecf20Sopenharmony_ci						      beacon_interval);
4448c2ecf20Sopenharmony_ci	}
4458c2ecf20Sopenharmony_ci	IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
4468c2ecf20Sopenharmony_ci		      cmd.switch_time);
4478c2ecf20Sopenharmony_ci	cmd.expect_beacon =
4488c2ecf20Sopenharmony_ci		ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci	return iwl_dvm_send_cmd(priv, &hcmd);
4518c2ecf20Sopenharmony_ci}
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_5000_cfg = {
4548c2ecf20Sopenharmony_ci	.set_hw_params = iwl5000_hw_set_hw_params,
4558c2ecf20Sopenharmony_ci	.set_channel_switch = iwl5000_hw_channel_switch,
4568c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
4578c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
4588c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
4598c2ecf20Sopenharmony_ci	.no_idle_support = true,
4608c2ecf20Sopenharmony_ci};
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_5150_cfg = {
4638c2ecf20Sopenharmony_ci	.set_hw_params = iwl5150_hw_set_hw_params,
4648c2ecf20Sopenharmony_ci	.set_channel_switch = iwl5000_hw_channel_switch,
4658c2ecf20Sopenharmony_ci	.temperature = iwl5150_temperature,
4668c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
4678c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
4688c2ecf20Sopenharmony_ci	.no_idle_support = true,
4698c2ecf20Sopenharmony_ci	.no_xtal_calib = true,
4708c2ecf20Sopenharmony_ci};
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci/*
4758c2ecf20Sopenharmony_ci * 6000 series
4768c2ecf20Sopenharmony_ci * ===========
4778c2ecf20Sopenharmony_ci */
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_cistatic void iwl6000_set_ct_threshold(struct iwl_priv *priv)
4808c2ecf20Sopenharmony_ci{
4818c2ecf20Sopenharmony_ci	/* want Celsius */
4828c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
4838c2ecf20Sopenharmony_ci	priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
4848c2ecf20Sopenharmony_ci}
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci/* NIC configuration for 6000 series */
4878c2ecf20Sopenharmony_cistatic void iwl6000_nic_config(struct iwl_priv *priv)
4888c2ecf20Sopenharmony_ci{
4898c2ecf20Sopenharmony_ci	switch (priv->trans->trans_cfg->device_family) {
4908c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6005:
4918c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6030:
4928c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6000:
4938c2ecf20Sopenharmony_ci		break;
4948c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6000i:
4958c2ecf20Sopenharmony_ci		/* 2x2 IPA phy type */
4968c2ecf20Sopenharmony_ci		iwl_write32(priv->trans, CSR_GP_DRIVER_REG,
4978c2ecf20Sopenharmony_ci			     CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
4988c2ecf20Sopenharmony_ci		break;
4998c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6050:
5008c2ecf20Sopenharmony_ci		/* Indicate calibration version to uCode. */
5018c2ecf20Sopenharmony_ci		if (priv->nvm_data->calib_version >= 6)
5028c2ecf20Sopenharmony_ci			iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
5038c2ecf20Sopenharmony_ci					CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
5048c2ecf20Sopenharmony_ci		break;
5058c2ecf20Sopenharmony_ci	case IWL_DEVICE_FAMILY_6150:
5068c2ecf20Sopenharmony_ci		/* Indicate calibration version to uCode. */
5078c2ecf20Sopenharmony_ci		if (priv->nvm_data->calib_version >= 6)
5088c2ecf20Sopenharmony_ci			iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
5098c2ecf20Sopenharmony_ci					CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
5108c2ecf20Sopenharmony_ci		iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
5118c2ecf20Sopenharmony_ci			    CSR_GP_DRIVER_REG_BIT_6050_1x2);
5128c2ecf20Sopenharmony_ci		break;
5138c2ecf20Sopenharmony_ci	default:
5148c2ecf20Sopenharmony_ci		WARN_ON(1);
5158c2ecf20Sopenharmony_ci	}
5168c2ecf20Sopenharmony_ci}
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_cistatic const struct iwl_sensitivity_ranges iwl6000_sensitivity = {
5198c2ecf20Sopenharmony_ci	.min_nrg_cck = 110,
5208c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm = 80,
5218c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc = 128,
5228c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_x1 = 105,
5238c2ecf20Sopenharmony_ci	.auto_corr_min_ofdm_mrc_x1 = 192,
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm = 145,
5268c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc = 232,
5278c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_x1 = 110,
5288c2ecf20Sopenharmony_ci	.auto_corr_max_ofdm_mrc_x1 = 232,
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	.auto_corr_min_cck = 125,
5318c2ecf20Sopenharmony_ci	.auto_corr_max_cck = 175,
5328c2ecf20Sopenharmony_ci	.auto_corr_min_cck_mrc = 160,
5338c2ecf20Sopenharmony_ci	.auto_corr_max_cck_mrc = 310,
5348c2ecf20Sopenharmony_ci	.nrg_th_cck = 110,
5358c2ecf20Sopenharmony_ci	.nrg_th_ofdm = 110,
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	.barker_corr_th_min = 190,
5388c2ecf20Sopenharmony_ci	.barker_corr_th_min_mrc = 336,
5398c2ecf20Sopenharmony_ci	.nrg_th_cca = 62,
5408c2ecf20Sopenharmony_ci};
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_cistatic void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
5438c2ecf20Sopenharmony_ci{
5448c2ecf20Sopenharmony_ci	iwl6000_set_ct_threshold(priv);
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	/* Set initial sensitivity parameters */
5478c2ecf20Sopenharmony_ci	priv->hw_params.sens = &iwl6000_sensitivity;
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci}
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_cistatic int iwl6000_hw_channel_switch(struct iwl_priv *priv,
5528c2ecf20Sopenharmony_ci				     struct ieee80211_channel_switch *ch_switch)
5538c2ecf20Sopenharmony_ci{
5548c2ecf20Sopenharmony_ci	/*
5558c2ecf20Sopenharmony_ci	 * MULTI-FIXME
5568c2ecf20Sopenharmony_ci	 * See iwlagn_mac_channel_switch.
5578c2ecf20Sopenharmony_ci	 */
5588c2ecf20Sopenharmony_ci	struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
5598c2ecf20Sopenharmony_ci	struct iwl6000_channel_switch_cmd *cmd;
5608c2ecf20Sopenharmony_ci	u32 switch_time_in_usec, ucode_switch_time;
5618c2ecf20Sopenharmony_ci	u16 ch;
5628c2ecf20Sopenharmony_ci	u32 tsf_low;
5638c2ecf20Sopenharmony_ci	u8 switch_count;
5648c2ecf20Sopenharmony_ci	u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
5658c2ecf20Sopenharmony_ci	struct ieee80211_vif *vif = ctx->vif;
5668c2ecf20Sopenharmony_ci	struct iwl_host_cmd hcmd = {
5678c2ecf20Sopenharmony_ci		.id = REPLY_CHANNEL_SWITCH,
5688c2ecf20Sopenharmony_ci		.len = { sizeof(*cmd), },
5698c2ecf20Sopenharmony_ci		.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
5708c2ecf20Sopenharmony_ci	};
5718c2ecf20Sopenharmony_ci	int err;
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
5748c2ecf20Sopenharmony_ci	if (!cmd)
5758c2ecf20Sopenharmony_ci		return -ENOMEM;
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	hcmd.data[0] = cmd;
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci	cmd->band = priv->band == NL80211_BAND_2GHZ;
5808c2ecf20Sopenharmony_ci	ch = ch_switch->chandef.chan->hw_value;
5818c2ecf20Sopenharmony_ci	IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
5828c2ecf20Sopenharmony_ci		      ctx->active.channel, ch);
5838c2ecf20Sopenharmony_ci	cmd->channel = cpu_to_le16(ch);
5848c2ecf20Sopenharmony_ci	cmd->rxon_flags = ctx->staging.flags;
5858c2ecf20Sopenharmony_ci	cmd->rxon_filter_flags = ctx->staging.filter_flags;
5868c2ecf20Sopenharmony_ci	switch_count = ch_switch->count;
5878c2ecf20Sopenharmony_ci	tsf_low = ch_switch->timestamp & 0x0ffffffff;
5888c2ecf20Sopenharmony_ci	/*
5898c2ecf20Sopenharmony_ci	 * calculate the ucode channel switch time
5908c2ecf20Sopenharmony_ci	 * adding TSF as one of the factor for when to switch
5918c2ecf20Sopenharmony_ci	 */
5928c2ecf20Sopenharmony_ci	if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) {
5938c2ecf20Sopenharmony_ci		if (switch_count > ((priv->ucode_beacon_time - tsf_low) /
5948c2ecf20Sopenharmony_ci		    beacon_interval)) {
5958c2ecf20Sopenharmony_ci			switch_count -= (priv->ucode_beacon_time -
5968c2ecf20Sopenharmony_ci				tsf_low) / beacon_interval;
5978c2ecf20Sopenharmony_ci		} else
5988c2ecf20Sopenharmony_ci			switch_count = 0;
5998c2ecf20Sopenharmony_ci	}
6008c2ecf20Sopenharmony_ci	if (switch_count <= 1)
6018c2ecf20Sopenharmony_ci		cmd->switch_time = cpu_to_le32(priv->ucode_beacon_time);
6028c2ecf20Sopenharmony_ci	else {
6038c2ecf20Sopenharmony_ci		switch_time_in_usec =
6048c2ecf20Sopenharmony_ci			vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
6058c2ecf20Sopenharmony_ci		ucode_switch_time = iwl_usecs_to_beacons(priv,
6068c2ecf20Sopenharmony_ci							 switch_time_in_usec,
6078c2ecf20Sopenharmony_ci							 beacon_interval);
6088c2ecf20Sopenharmony_ci		cmd->switch_time = iwl_add_beacon_time(priv,
6098c2ecf20Sopenharmony_ci						       priv->ucode_beacon_time,
6108c2ecf20Sopenharmony_ci						       ucode_switch_time,
6118c2ecf20Sopenharmony_ci						       beacon_interval);
6128c2ecf20Sopenharmony_ci	}
6138c2ecf20Sopenharmony_ci	IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
6148c2ecf20Sopenharmony_ci		      cmd->switch_time);
6158c2ecf20Sopenharmony_ci	cmd->expect_beacon =
6168c2ecf20Sopenharmony_ci		ch_switch->chandef.chan->flags & IEEE80211_CHAN_RADAR;
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci	err = iwl_dvm_send_cmd(priv, &hcmd);
6198c2ecf20Sopenharmony_ci	kfree(cmd);
6208c2ecf20Sopenharmony_ci	return err;
6218c2ecf20Sopenharmony_ci}
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_6000_cfg = {
6248c2ecf20Sopenharmony_ci	.set_hw_params = iwl6000_hw_set_hw_params,
6258c2ecf20Sopenharmony_ci	.set_channel_switch = iwl6000_hw_channel_switch,
6268c2ecf20Sopenharmony_ci	.nic_config = iwl6000_nic_config,
6278c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
6288c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
6298c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
6308c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
6318c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
6328c2ecf20Sopenharmony_ci};
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_6005_cfg = {
6358c2ecf20Sopenharmony_ci	.set_hw_params = iwl6000_hw_set_hw_params,
6368c2ecf20Sopenharmony_ci	.set_channel_switch = iwl6000_hw_channel_switch,
6378c2ecf20Sopenharmony_ci	.nic_config = iwl6000_nic_config,
6388c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
6398c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
6408c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
6418c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
6428c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
6438c2ecf20Sopenharmony_ci	.need_temp_offset_calib = true,
6448c2ecf20Sopenharmony_ci};
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_6050_cfg = {
6478c2ecf20Sopenharmony_ci	.set_hw_params = iwl6000_hw_set_hw_params,
6488c2ecf20Sopenharmony_ci	.set_channel_switch = iwl6000_hw_channel_switch,
6498c2ecf20Sopenharmony_ci	.nic_config = iwl6000_nic_config,
6508c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
6518c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
6528c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
6538c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
6548c2ecf20Sopenharmony_ci	.chain_noise_scale = 1500,
6558c2ecf20Sopenharmony_ci};
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_cistatic const struct iwl_dvm_bt_params iwl6000_bt_params = {
6588c2ecf20Sopenharmony_ci	/* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
6598c2ecf20Sopenharmony_ci	.advanced_bt_coexist = true,
6608c2ecf20Sopenharmony_ci	.agg_time_limit = BT_AGG_THRESHOLD_DEF,
6618c2ecf20Sopenharmony_ci	.bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
6628c2ecf20Sopenharmony_ci	.bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
6638c2ecf20Sopenharmony_ci	.bt_sco_disable = true,
6648c2ecf20Sopenharmony_ci};
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_ciconst struct iwl_dvm_cfg iwl_dvm_6030_cfg = {
6678c2ecf20Sopenharmony_ci	.set_hw_params = iwl6000_hw_set_hw_params,
6688c2ecf20Sopenharmony_ci	.set_channel_switch = iwl6000_hw_channel_switch,
6698c2ecf20Sopenharmony_ci	.nic_config = iwl6000_nic_config,
6708c2ecf20Sopenharmony_ci	.temperature = iwlagn_temperature,
6718c2ecf20Sopenharmony_ci	.adv_thermal_throttle = true,
6728c2ecf20Sopenharmony_ci	.support_ct_kill_exit = true,
6738c2ecf20Sopenharmony_ci	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
6748c2ecf20Sopenharmony_ci	.chain_noise_scale = 1000,
6758c2ecf20Sopenharmony_ci	.bt_params = &iwl6000_bt_params,
6768c2ecf20Sopenharmony_ci	.need_temp_offset_calib = true,
6778c2ecf20Sopenharmony_ci	.adv_pm = true,
6788c2ecf20Sopenharmony_ci};
679