wl1251.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*
  2. * This file is part of wl1251
  3. *
  4. * Copyright (c) 1998-2007 Texas Instruments Incorporated
  5. * Copyright (C) 2008-2009 Nokia Corporation
  6. *
  7. * Contact: Kalle Valo <kalle.valo@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef __WL1251_H__
  25. #define __WL1251_H__
  26. #include <linux/mutex.h>
  27. #include <linux/list.h>
  28. #include <linux/bitops.h>
  29. #include <net/mac80211.h>
  30. #define DRIVER_NAME "wl1251"
  31. #define DRIVER_PREFIX DRIVER_NAME ": "
  32. enum {
  33. DEBUG_NONE = 0,
  34. DEBUG_IRQ = BIT(0),
  35. DEBUG_SPI = BIT(1),
  36. DEBUG_BOOT = BIT(2),
  37. DEBUG_MAILBOX = BIT(3),
  38. DEBUG_NETLINK = BIT(4),
  39. DEBUG_EVENT = BIT(5),
  40. DEBUG_TX = BIT(6),
  41. DEBUG_RX = BIT(7),
  42. DEBUG_SCAN = BIT(8),
  43. DEBUG_CRYPT = BIT(9),
  44. DEBUG_PSM = BIT(10),
  45. DEBUG_MAC80211 = BIT(11),
  46. DEBUG_CMD = BIT(12),
  47. DEBUG_ACX = BIT(13),
  48. DEBUG_ALL = ~0,
  49. };
  50. #define DEBUG_LEVEL (DEBUG_NONE)
  51. #define DEBUG_DUMP_LIMIT 1024
  52. #define wl1251_error(fmt, arg...) \
  53. printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
  54. #define wl1251_warning(fmt, arg...) \
  55. printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
  56. #define wl1251_notice(fmt, arg...) \
  57. printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
  58. #define wl1251_info(fmt, arg...) \
  59. printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
  60. #define wl1251_debug(level, fmt, arg...) \
  61. do { \
  62. if (level & DEBUG_LEVEL) \
  63. printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
  64. } while (0)
  65. #define wl1251_dump(level, prefix, buf, len) \
  66. do { \
  67. if (level & DEBUG_LEVEL) \
  68. print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
  69. DUMP_PREFIX_OFFSET, 16, 1, \
  70. buf, \
  71. min_t(size_t, len, DEBUG_DUMP_LIMIT), \
  72. 0); \
  73. } while (0)
  74. #define wl1251_dump_ascii(level, prefix, buf, len) \
  75. do { \
  76. if (level & DEBUG_LEVEL) \
  77. print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
  78. DUMP_PREFIX_OFFSET, 16, 1, \
  79. buf, \
  80. min_t(size_t, len, DEBUG_DUMP_LIMIT), \
  81. true); \
  82. } while (0)
  83. #define WL1251_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
  84. CFG_BSSID_FILTER_EN)
  85. #define WL1251_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \
  86. CFG_RX_MGMT_EN | \
  87. CFG_RX_DATA_EN | \
  88. CFG_RX_CTL_EN | \
  89. CFG_RX_BCN_EN | \
  90. CFG_RX_AUTH_EN | \
  91. CFG_RX_ASSOC_EN)
  92. #define WL1251_BUSY_WORD_LEN 8
  93. struct boot_attr {
  94. u32 radio_type;
  95. u8 mac_clock;
  96. u8 arm_clock;
  97. int firmware_debug;
  98. u32 minor;
  99. u32 major;
  100. u32 bugfix;
  101. };
  102. enum wl1251_state {
  103. WL1251_STATE_OFF,
  104. WL1251_STATE_ON,
  105. WL1251_STATE_PLT,
  106. };
  107. enum wl1251_partition_type {
  108. PART_DOWN,
  109. PART_WORK,
  110. PART_DRPW,
  111. PART_TABLE_LEN
  112. };
  113. struct wl1251_partition {
  114. u32 size;
  115. u32 start;
  116. };
  117. struct wl1251_partition_set {
  118. struct wl1251_partition mem;
  119. struct wl1251_partition reg;
  120. };
  121. struct wl1251;
  122. struct wl1251_stats {
  123. struct acx_statistics *fw_stats;
  124. unsigned long fw_stats_update;
  125. unsigned int retry_count;
  126. unsigned int excessive_retries;
  127. };
  128. struct wl1251_debugfs {
  129. struct dentry *rootdir;
  130. struct dentry *fw_statistics;
  131. struct dentry *tx_internal_desc_overflow;
  132. struct dentry *rx_out_of_mem;
  133. struct dentry *rx_hdr_overflow;
  134. struct dentry *rx_hw_stuck;
  135. struct dentry *rx_dropped;
  136. struct dentry *rx_fcs_err;
  137. struct dentry *rx_xfr_hint_trig;
  138. struct dentry *rx_path_reset;
  139. struct dentry *rx_reset_counter;
  140. struct dentry *dma_rx_requested;
  141. struct dentry *dma_rx_errors;
  142. struct dentry *dma_tx_requested;
  143. struct dentry *dma_tx_errors;
  144. struct dentry *isr_cmd_cmplt;
  145. struct dentry *isr_fiqs;
  146. struct dentry *isr_rx_headers;
  147. struct dentry *isr_rx_mem_overflow;
  148. struct dentry *isr_rx_rdys;
  149. struct dentry *isr_irqs;
  150. struct dentry *isr_tx_procs;
  151. struct dentry *isr_decrypt_done;
  152. struct dentry *isr_dma0_done;
  153. struct dentry *isr_dma1_done;
  154. struct dentry *isr_tx_exch_complete;
  155. struct dentry *isr_commands;
  156. struct dentry *isr_rx_procs;
  157. struct dentry *isr_hw_pm_mode_changes;
  158. struct dentry *isr_host_acknowledges;
  159. struct dentry *isr_pci_pm;
  160. struct dentry *isr_wakeups;
  161. struct dentry *isr_low_rssi;
  162. struct dentry *wep_addr_key_count;
  163. struct dentry *wep_default_key_count;
  164. /* skipping wep.reserved */
  165. struct dentry *wep_key_not_found;
  166. struct dentry *wep_decrypt_fail;
  167. struct dentry *wep_packets;
  168. struct dentry *wep_interrupt;
  169. struct dentry *pwr_ps_enter;
  170. struct dentry *pwr_elp_enter;
  171. struct dentry *pwr_missing_bcns;
  172. struct dentry *pwr_wake_on_host;
  173. struct dentry *pwr_wake_on_timer_exp;
  174. struct dentry *pwr_tx_with_ps;
  175. struct dentry *pwr_tx_without_ps;
  176. struct dentry *pwr_rcvd_beacons;
  177. struct dentry *pwr_power_save_off;
  178. struct dentry *pwr_enable_ps;
  179. struct dentry *pwr_disable_ps;
  180. struct dentry *pwr_fix_tsf_ps;
  181. /* skipping cont_miss_bcns_spread for now */
  182. struct dentry *pwr_rcvd_awake_beacons;
  183. struct dentry *mic_rx_pkts;
  184. struct dentry *mic_calc_failure;
  185. struct dentry *aes_encrypt_fail;
  186. struct dentry *aes_decrypt_fail;
  187. struct dentry *aes_encrypt_packets;
  188. struct dentry *aes_decrypt_packets;
  189. struct dentry *aes_encrypt_interrupt;
  190. struct dentry *aes_decrypt_interrupt;
  191. struct dentry *event_heart_beat;
  192. struct dentry *event_calibration;
  193. struct dentry *event_rx_mismatch;
  194. struct dentry *event_rx_mem_empty;
  195. struct dentry *event_rx_pool;
  196. struct dentry *event_oom_late;
  197. struct dentry *event_phy_transmit_error;
  198. struct dentry *event_tx_stuck;
  199. struct dentry *ps_pspoll_timeouts;
  200. struct dentry *ps_upsd_timeouts;
  201. struct dentry *ps_upsd_max_sptime;
  202. struct dentry *ps_upsd_max_apturn;
  203. struct dentry *ps_pspoll_max_apturn;
  204. struct dentry *ps_pspoll_utilization;
  205. struct dentry *ps_upsd_utilization;
  206. struct dentry *rxpipe_rx_prep_beacon_drop;
  207. struct dentry *rxpipe_descr_host_int_trig_rx_data;
  208. struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data;
  209. struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data;
  210. struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data;
  211. struct dentry *tx_queue_len;
  212. struct dentry *retry_count;
  213. struct dentry *excessive_retries;
  214. };
  215. struct wl1251_if_operations {
  216. void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
  217. void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
  218. void (*reset)(struct wl1251 *wl);
  219. void (*enable_irq)(struct wl1251 *wl);
  220. void (*disable_irq)(struct wl1251 *wl);
  221. };
  222. struct wl1251 {
  223. struct ieee80211_hw *hw;
  224. bool mac80211_registered;
  225. void *if_priv;
  226. const struct wl1251_if_operations *if_ops;
  227. void (*set_power)(bool enable);
  228. int irq;
  229. enum wl1251_state state;
  230. struct mutex mutex;
  231. int physical_mem_addr;
  232. int physical_reg_addr;
  233. int virtual_mem_addr;
  234. int virtual_reg_addr;
  235. int cmd_box_addr;
  236. int event_box_addr;
  237. struct boot_attr boot_attr;
  238. u8 *fw;
  239. size_t fw_len;
  240. u8 *nvs;
  241. size_t nvs_len;
  242. u8 bssid[ETH_ALEN];
  243. u8 mac_addr[ETH_ALEN];
  244. u8 bss_type;
  245. u8 listen_int;
  246. int channel;
  247. void *target_mem_map;
  248. struct acx_data_path_params_resp *data_path;
  249. /* Number of TX packets transferred to the FW, modulo 16 */
  250. u32 data_in_count;
  251. /* Frames scheduled for transmission, not handled yet */
  252. struct sk_buff_head tx_queue;
  253. bool tx_queue_stopped;
  254. struct work_struct tx_work;
  255. struct work_struct filter_work;
  256. /* Pending TX frames */
  257. struct sk_buff *tx_frames[16];
  258. /*
  259. * Index pointing to the next TX complete entry
  260. * in the cyclic XT complete array we get from
  261. * the FW.
  262. */
  263. u32 next_tx_complete;
  264. /* FW Rx counter */
  265. u32 rx_counter;
  266. /* Rx frames handled */
  267. u32 rx_handled;
  268. /* Current double buffer */
  269. u32 rx_current_buffer;
  270. u32 rx_last_id;
  271. /* The target interrupt mask */
  272. u32 intr_mask;
  273. struct work_struct irq_work;
  274. /* The mbox event mask */
  275. u32 event_mask;
  276. /* Mailbox pointers */
  277. u32 mbox_ptr[2];
  278. /* Are we currently scanning */
  279. bool scanning;
  280. /* Our association ID */
  281. u16 aid;
  282. /* Default key (for WEP) */
  283. u32 default_key;
  284. unsigned int tx_mgmt_frm_rate;
  285. unsigned int tx_mgmt_frm_mod;
  286. unsigned int rx_config;
  287. unsigned int rx_filter;
  288. /* is firmware in elp mode */
  289. bool elp;
  290. /* we can be in psm, but not in elp, we have to differentiate */
  291. bool psm;
  292. /* PSM mode requested */
  293. bool psm_requested;
  294. u16 beacon_int;
  295. u8 dtim_period;
  296. /* in dBm */
  297. int power_level;
  298. struct wl1251_stats stats;
  299. struct wl1251_debugfs debugfs;
  300. u32 buffer_32;
  301. u32 buffer_cmd;
  302. u8 buffer_busyword[WL1251_BUSY_WORD_LEN];
  303. struct wl1251_rx_descriptor *rx_descriptor;
  304. u32 chip_id;
  305. char fw_ver[21];
  306. };
  307. int wl1251_plt_start(struct wl1251 *wl);
  308. int wl1251_plt_stop(struct wl1251 *wl);
  309. struct ieee80211_hw *wl1251_alloc_hw(void);
  310. int wl1251_free_hw(struct wl1251 *wl);
  311. int wl1251_init_ieee80211(struct wl1251 *wl);
  312. void wl1251_enable_interrupts(struct wl1251 *wl);
  313. void wl1251_disable_interrupts(struct wl1251 *wl);
  314. #define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */
  315. #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
  316. #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
  317. #define WL1251_DEFAULT_POWER_LEVEL 20
  318. #define WL1251_TX_QUEUE_MAX_LENGTH 20
  319. #define WL1251_DEFAULT_BEACON_INT 100
  320. #define WL1251_DEFAULT_DTIM_PERIOD 1
  321. #define WL1251_DEFAULT_CHANNEL 0
  322. #define CHIP_ID_1251_PG10 (0x7010101)
  323. #define CHIP_ID_1251_PG11 (0x7020101)
  324. #define CHIP_ID_1251_PG12 (0x7030101)
  325. #define CHIP_ID_1271_PG10 (0x4030101)
  326. #define CHIP_ID_1271_PG20 (0x4030111)
  327. #define WL1251_FW_NAME "wl1251-fw.bin"
  328. #define WL1251_NVS_NAME "wl1251-nvs.bin"
  329. #define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */
  330. #define WL1251_PART_DOWN_MEM_START 0x0
  331. #define WL1251_PART_DOWN_MEM_SIZE 0x16800
  332. #define WL1251_PART_DOWN_REG_START REGISTERS_BASE
  333. #define WL1251_PART_DOWN_REG_SIZE REGISTERS_DOWN_SIZE
  334. #define WL1251_PART_WORK_MEM_START 0x28000
  335. #define WL1251_PART_WORK_MEM_SIZE 0x14000
  336. #define WL1251_PART_WORK_REG_START REGISTERS_BASE
  337. #define WL1251_PART_WORK_REG_SIZE REGISTERS_WORK_SIZE
  338. #endif