iwl-6000.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. .dump_nic_event_log = iwl_dump_nic_event_log,
  94. .dump_nic_error_log = iwl_dump_nic_error_log,
  95. .init_alive_start = iwl5000_init_alive_start,
  96. .alive_notify = iwl5000_alive_notify,
  97. .send_tx_power = iwl5000_send_tx_power,
  98. .update_chain_flags = iwl_update_chain_flags,
  99. .apm_ops = {
  100. .init = iwl5000_apm_init,
  101. .reset = iwl5000_apm_reset,
  102. .stop = iwl5000_apm_stop,
  103. .config = iwl6000_nic_config,
  104. .set_pwr_src = iwl_set_pwr_src,
  105. },
  106. .eeprom_ops = {
  107. .regulatory_bands = {
  108. EEPROM_5000_REG_BAND_1_CHANNELS,
  109. EEPROM_5000_REG_BAND_2_CHANNELS,
  110. EEPROM_5000_REG_BAND_3_CHANNELS,
  111. EEPROM_5000_REG_BAND_4_CHANNELS,
  112. EEPROM_5000_REG_BAND_5_CHANNELS,
  113. EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
  114. EEPROM_5000_REG_BAND_52_HT40_CHANNELS
  115. },
  116. .verify_signature = iwlcore_eeprom_verify_signature,
  117. .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
  118. .release_semaphore = iwlcore_eeprom_release_semaphore,
  119. .calib_version = iwl5000_eeprom_calib_version,
  120. .query_addr = iwl5000_eeprom_query_addr,
  121. .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
  122. },
  123. .post_associate = iwl_post_associate,
  124. .isr = iwl_isr_ict,
  125. .config_ap = iwl_config_ap,
  126. .temp_ops = {
  127. .temperature = iwl5000_temperature,
  128. .set_ct_kill = iwl6000_set_ct_threshold,
  129. },
  130. };
  131. static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
  132. .get_hcmd_size = iwl5000_get_hcmd_size,
  133. .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
  134. .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
  135. .calc_rssi = iwl5000_calc_rssi,
  136. };
  137. static struct iwl_ops iwl6000_ops = {
  138. .ucode = &iwl5000_ucode,
  139. .lib = &iwl6000_lib,
  140. .hcmd = &iwl5000_hcmd,
  141. .utils = &iwl6000_hcmd_utils,
  142. };
  143. /*
  144. * "h": Hybrid configuration, use both internal and external Power Amplifier
  145. */
  146. struct iwl_cfg iwl6000h_2agn_cfg = {
  147. .name = "6000 Series 2x2 AGN",
  148. .fw_name_pre = IWL6000_FW_PRE,
  149. .ucode_api_max = IWL6000_UCODE_API_MAX,
  150. .ucode_api_min = IWL6000_UCODE_API_MIN,
  151. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  152. .ops = &iwl6000_ops,
  153. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  154. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  155. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  156. .mod_params = &iwl50_mod_params,
  157. .valid_tx_ant = ANT_AB,
  158. .valid_rx_ant = ANT_AB,
  159. .need_pll_cfg = false,
  160. .pa_type = IWL_PA_HYBRID,
  161. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  162. .shadow_ram_support = true,
  163. .ht_greenfield_support = true,
  164. .use_rts_for_ht = true, /* use rts/cts protection */
  165. };
  166. /*
  167. * "i": Internal configuration, use internal Power Amplifier
  168. */
  169. struct iwl_cfg iwl6000i_2agn_cfg = {
  170. .name = "6000 Series 2x2 AGN",
  171. .fw_name_pre = IWL6000_FW_PRE,
  172. .ucode_api_max = IWL6000_UCODE_API_MAX,
  173. .ucode_api_min = IWL6000_UCODE_API_MIN,
  174. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  175. .ops = &iwl6000_ops,
  176. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  177. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  178. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  179. .mod_params = &iwl50_mod_params,
  180. .valid_tx_ant = ANT_BC,
  181. .valid_rx_ant = ANT_BC,
  182. .need_pll_cfg = false,
  183. .pa_type = IWL_PA_INTERNAL,
  184. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  185. .shadow_ram_support = true,
  186. .ht_greenfield_support = true,
  187. .use_rts_for_ht = true, /* use rts/cts protection */
  188. };
  189. struct iwl_cfg iwl6050_2agn_cfg = {
  190. .name = "6050 Series 2x2 AGN",
  191. .fw_name_pre = IWL6050_FW_PRE,
  192. .ucode_api_max = IWL6050_UCODE_API_MAX,
  193. .ucode_api_min = IWL6050_UCODE_API_MIN,
  194. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  195. .ops = &iwl6000_ops,
  196. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  197. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  198. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  199. .mod_params = &iwl50_mod_params,
  200. .valid_tx_ant = ANT_AB,
  201. .valid_rx_ant = ANT_AB,
  202. .need_pll_cfg = false,
  203. .pa_type = IWL_PA_SYSTEM,
  204. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  205. .shadow_ram_support = true,
  206. .ht_greenfield_support = true,
  207. .use_rts_for_ht = true, /* use rts/cts protection */
  208. };
  209. struct iwl_cfg iwl6000_3agn_cfg = {
  210. .name = "6000 Series 3x3 AGN",
  211. .fw_name_pre = IWL6000_FW_PRE,
  212. .ucode_api_max = IWL6000_UCODE_API_MAX,
  213. .ucode_api_min = IWL6000_UCODE_API_MIN,
  214. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  215. .ops = &iwl6000_ops,
  216. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  217. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  218. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  219. .mod_params = &iwl50_mod_params,
  220. .valid_tx_ant = ANT_ABC,
  221. .valid_rx_ant = ANT_ABC,
  222. .need_pll_cfg = false,
  223. .pa_type = IWL_PA_SYSTEM,
  224. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  225. .shadow_ram_support = true,
  226. .ht_greenfield_support = true,
  227. .use_rts_for_ht = true, /* use rts/cts protection */
  228. };
  229. struct iwl_cfg iwl6050_3agn_cfg = {
  230. .name = "6050 Series 3x3 AGN",
  231. .fw_name_pre = IWL6050_FW_PRE,
  232. .ucode_api_max = IWL6050_UCODE_API_MAX,
  233. .ucode_api_min = IWL6050_UCODE_API_MIN,
  234. .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
  235. .ops = &iwl6000_ops,
  236. .eeprom_size = OTP_LOW_IMAGE_SIZE,
  237. .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
  238. .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
  239. .mod_params = &iwl50_mod_params,
  240. .valid_tx_ant = ANT_ABC,
  241. .valid_rx_ant = ANT_ABC,
  242. .need_pll_cfg = false,
  243. .pa_type = IWL_PA_SYSTEM,
  244. .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
  245. .shadow_ram_support = true,
  246. .ht_greenfield_support = true,
  247. .use_rts_for_ht = true, /* use rts/cts protection */
  248. };
  249. MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
  250. MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));