iwl-6000.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2008-2009 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/init.h>
  29. #include <linux/pci.h>
  30. #include <linux/dma-mapping.h>
  31. #include <linux/delay.h>
  32. #include <linux/skbuff.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/wireless.h>
  35. #include <net/mac80211.h>
  36. #include <linux/etherdevice.h>
  37. #include <asm/unaligned.h>
  38. #include "iwl-eeprom.h"
  39. #include "iwl-dev.h"
  40. #include "iwl-core.h"
  41. #include "iwl-io.h"
  42. #include "iwl-sta.h"
  43. #include "iwl-helpers.h"
  44. #include "iwl-5000-hw.h"
  45. /* Highest firmware API version supported */
  46. #define IWL6000_UCODE_API_MAX 4
  47. #define IWL6050_UCODE_API_MAX 4
  48. /* Lowest firmware API version supported */
  49. #define IWL6000_UCODE_API_MIN 1
  50. #define IWL6050_UCODE_API_MIN 1
  51. #define IWL6000_FW_PRE "iwlwifi-6000-"
  52. #define _IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode"
  53. #define IWL6000_MODULE_FIRMWARE(api) _IWL6000_MODULE_FIRMWARE(api)
  54. #define IWL6050_FW_PRE "iwlwifi-6050-"
  55. #define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
  56. #define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
  57. static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
  58. {
  59. /* want Celsius */
  60. priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
  61. priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
  62. }
  63. /* NIC configuration for 6000 series */
  64. static void iwl6000_nic_config(struct iwl_priv *priv)
  65. {
  66. iwl5000_nic_config(priv);
  67. /* no locking required for register write */
  68. if (priv->cfg->pa_type == IWL_PA_HYBRID) {
  69. /* 2x2 hybrid phy type */
  70. iwl_write32(priv, CSR_GP_DRIVER_REG,
  71. CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB);
  72. } else if (priv->cfg->pa_type == IWL_PA_INTERNAL) {
  73. /* 2x2 IPA phy type */
  74. iwl_write32(priv, CSR_GP_DRIVER_REG,
  75. CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
  76. }
  77. /* else do nothing, uCode configured */
  78. }
  79. static struct iwl_lib_ops iwl6000_lib = {
  80. .set_hw_params = iwl5000_hw_set_hw_params,
  81. .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
  82. .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
  83. .txq_set_sched = iwl5000_txq_set_sched,
  84. .txq_agg_enable = iwl5000_txq_agg_enable,
  85. .txq_agg_disable = iwl5000_txq_agg_disable,
  86. .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
  87. .txq_free_tfd = iwl_hw_txq_free_tfd,
  88. .txq_init = iwl_hw_tx_queue_init,
  89. .rx_handler_setup = iwl5000_rx_handler_setup,
  90. .setup_deferred_work = iwl5000_setup_deferred_work,
  91. .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
  92. .load_ucode = iwl5000_load_ucode,
  93. .init_alive_start = iwl5000_init_alive_start,
  94. .alive_notify = iwl5000_alive_notify,
  95. .send_tx_power = iwl5000_send_tx_power,
  96. .update_chain_flags = iwl_update_chain_flags,
  97. .apm_ops = {
  98. .init = iwl5000_apm_init,
  99. .reset = iwl5000_apm_reset,
  100. .stop = iwl5000_apm_stop,
  101. .config = iwl6000_nic_config,
  102. .set_pwr_src = iwl_set_pwr_src,
  103. },
  104. .eeprom_ops = {
  105. .regulatory_bands = {
  106. EEPROM_5000_REG_BAND_1_CHANNELS,
  107. EEPROM_5000_REG_BAND_2_CHANNELS,
  108. EEPROM_5000_REG_BAND_3_CHANNELS,
  109. EEPROM_5000_REG_BAND_4_CHANNELS,
  110. EEPROM_5000_REG_BAND_5_CHANNELS,
  111. EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
  112. EEPROM_5000_REG_BAND_52_HT40_CHANNELS
  113. },
  114. .verify_signature = iwlcore_eeprom_verify_signature,
  115. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  116. .release_semaphore = iwlcore_eeprom_release_semaphore,
  117. .calib_version = iwl5000_eeprom_calib_version,
  118. .query_addr = iwl5000_eeprom_query_addr,
  119. .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
  120. },
  121. .post_associate = iwl_post_associate,
  122. .isr = iwl_isr_ict,
  123. .config_ap = iwl_config_ap,
  124. .temp_ops = {
  125. .temperature = iwl5000_temperature,
  126. .set_ct_kill = iwl6000_set_ct_threshold,
  127. },
  128. };
  129. static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
  130. .get_hcmd_size = iwl5000_get_hcmd_size,
  131. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  132. .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
  133. .calc_rssi = iwl5000_calc_rssi,
  134. };
  135. static struct iwl_ops iwl6000_ops = {
  136. .ucode = &iwl5000_ucode,
  137. .lib = &iwl6000_lib,
  138. .hcmd = &iwl5000_hcmd,
  139. .utils = &iwl6000_hcmd_utils,
  140. };
  141. /*
  142. * "h": Hybrid configuration, use both internal and external Power Amplifier
  143. */
  144. struct iwl_cfg iwl6000h_2agn_cfg = {
  145. .name = "6000 Series 2x2 AGN",
  146. .fw_name_pre = IWL6000_FW_PRE,
  147. .ucode_api_max = IWL6000_UCODE_API_MAX,
  148. .ucode_api_min = IWL6000_UCODE_API_MIN,
  149. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  150. .ops = &iwl6000_ops,
  151. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  152. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  153. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  154. .mod_params = &iwl50_mod_params,
  155. .valid_tx_ant = ANT_AB,
  156. .valid_rx_ant = ANT_AB,
  157. .need_pll_cfg = false,
  158. .pa_type = IWL_PA_HYBRID,
  159. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  160. .shadow_ram_support = true,
  161. .ht_greenfield_support = true,
  162. };
  163. /*
  164. * "i": Internal configuration, use internal Power Amplifier
  165. */
  166. struct iwl_cfg iwl6000i_2agn_cfg = {
  167. .name = "6000 Series 2x2 AGN",
  168. .fw_name_pre = IWL6000_FW_PRE,
  169. .ucode_api_max = IWL6000_UCODE_API_MAX,
  170. .ucode_api_min = IWL6000_UCODE_API_MIN,
  171. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  172. .ops = &iwl6000_ops,
  173. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  174. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  175. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  176. .mod_params = &iwl50_mod_params,
  177. .valid_tx_ant = ANT_BC,
  178. .valid_rx_ant = ANT_BC,
  179. .need_pll_cfg = false,
  180. .pa_type = IWL_PA_INTERNAL,
  181. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  182. .shadow_ram_support = true,
  183. .ht_greenfield_support = true,
  184. };
  185. struct iwl_cfg iwl6050_2agn_cfg = {
  186. .name = "6050 Series 2x2 AGN",
  187. .fw_name_pre = IWL6050_FW_PRE,
  188. .ucode_api_max = IWL6050_UCODE_API_MAX,
  189. .ucode_api_min = IWL6050_UCODE_API_MIN,
  190. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  191. .ops = &iwl6000_ops,
  192. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  193. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  194. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  195. .mod_params = &iwl50_mod_params,
  196. .valid_tx_ant = ANT_AB,
  197. .valid_rx_ant = ANT_AB,
  198. .need_pll_cfg = false,
  199. .pa_type = IWL_PA_SYSTEM,
  200. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  201. .shadow_ram_support = true,
  202. .ht_greenfield_support = true,
  203. };
  204. struct iwl_cfg iwl6000_3agn_cfg = {
  205. .name = "6000 Series 3x3 AGN",
  206. .fw_name_pre = IWL6000_FW_PRE,
  207. .ucode_api_max = IWL6000_UCODE_API_MAX,
  208. .ucode_api_min = IWL6000_UCODE_API_MIN,
  209. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  210. .ops = &iwl6000_ops,
  211. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  212. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  213. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  214. .mod_params = &iwl50_mod_params,
  215. .valid_tx_ant = ANT_ABC,
  216. .valid_rx_ant = ANT_ABC,
  217. .need_pll_cfg = false,
  218. .pa_type = IWL_PA_SYSTEM,
  219. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  220. .shadow_ram_support = true,
  221. .ht_greenfield_support = true,
  222. };
  223. struct iwl_cfg iwl6050_3agn_cfg = {
  224. .name = "6050 Series 3x3 AGN",
  225. .fw_name_pre = IWL6050_FW_PRE,
  226. .ucode_api_max = IWL6050_UCODE_API_MAX,
  227. .ucode_api_min = IWL6050_UCODE_API_MIN,
  228. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  229. .ops = &iwl6000_ops,
  230. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  231. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  232. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  233. .mod_params = &iwl50_mod_params,
  234. .valid_tx_ant = ANT_ABC,
  235. .valid_rx_ant = ANT_ABC,
  236. .need_pll_cfg = false,
  237. .pa_type = IWL_PA_SYSTEM,
  238. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  239. .shadow_ram_support = true,
  240. .ht_greenfield_support = true,
  241. };
  242. MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
  243. MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));