3945.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 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. #ifndef __il_3945_h__
  27. #define __il_3945_h__
  28. #include <linux/pci.h> /* for struct pci_device_id */
  29. #include <linux/kernel.h>
  30. #include <net/ieee80211_radiotap.h>
  31. /* Hardware specific file defines the PCI IDs table for that hardware module */
  32. extern const struct pci_device_id il3945_hw_card_ids[];
  33. #include "common.h"
  34. #include "iwl-prph.h"
  35. #include "iwl-debug.h"
  36. #include "iwl-power.h"
  37. #include "iwl-led.h"
  38. #include "iwl-eeprom.h"
  39. /* Highest firmware API version supported */
  40. #define IL3945_UCODE_API_MAX 2
  41. /* Lowest firmware API version supported */
  42. #define IL3945_UCODE_API_MIN 1
  43. #define IL3945_FW_PRE "iwlwifi-3945-"
  44. #define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode"
  45. #define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api)
  46. /* Default noise level to report when noise measurement is not available.
  47. * This may be because we're:
  48. * 1) Not associated (4965, no beacon stats being sent to driver)
  49. * 2) Scanning (noise measurement does not apply to associated channel)
  50. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  51. * Use default noise value of -127 ... this is below the range of measurable
  52. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  53. * Also, -127 works better than 0 when averaging frames with/without
  54. * noise info (e.g. averaging might be done in app); measured dBm values are
  55. * always negative ... using a negative value as the default keeps all
  56. * averages within an s8's (used in some apps) range of negative values. */
  57. #define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
  58. /* Module parameters accessible from iwl-*.c */
  59. extern struct il_mod_params il3945_mod_params;
  60. struct il3945_rate_scale_data {
  61. u64 data;
  62. s32 success_counter;
  63. s32 success_ratio;
  64. s32 counter;
  65. s32 average_tpt;
  66. unsigned long stamp;
  67. };
  68. struct il3945_rs_sta {
  69. spinlock_t lock;
  70. struct il_priv *il;
  71. s32 *expected_tpt;
  72. unsigned long last_partial_flush;
  73. unsigned long last_flush;
  74. u32 flush_time;
  75. u32 last_tx_packets;
  76. u32 tx_packets;
  77. u8 tgg;
  78. u8 flush_pending;
  79. u8 start_rate;
  80. struct timer_list rate_scale_flush;
  81. struct il3945_rate_scale_data win[RATE_COUNT_3945];
  82. #ifdef CONFIG_MAC80211_DEBUGFS
  83. struct dentry *rs_sta_dbgfs_stats_table_file;
  84. #endif
  85. /* used to be in sta_info */
  86. int last_txrate_idx;
  87. };
  88. /*
  89. * The common struct MUST be first because it is shared between
  90. * 3945 and 4965!
  91. */
  92. struct il3945_sta_priv {
  93. struct il_station_priv_common common;
  94. struct il3945_rs_sta rs_sta;
  95. };
  96. enum il3945_antenna {
  97. IL_ANTENNA_DIVERSITY,
  98. IL_ANTENNA_MAIN,
  99. IL_ANTENNA_AUX
  100. };
  101. /*
  102. * RTS threshold here is total size [2347] minus 4 FCS bytes
  103. * Per spec:
  104. * a value of 0 means RTS on all data/management packets
  105. * a value > max MSDU size means no RTS
  106. * else RTS for data/management frames where MPDU is larger
  107. * than RTS value.
  108. */
  109. #define DEFAULT_RTS_THRESHOLD 2347U
  110. #define MIN_RTS_THRESHOLD 0U
  111. #define MAX_RTS_THRESHOLD 2347U
  112. #define MAX_MSDU_SIZE 2304U
  113. #define MAX_MPDU_SIZE 2346U
  114. #define DEFAULT_BEACON_INTERVAL 100U
  115. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  116. #define DEFAULT_LONG_RETRY_LIMIT 4U
  117. #define IL_TX_FIFO_AC0 0
  118. #define IL_TX_FIFO_AC1 1
  119. #define IL_TX_FIFO_AC2 2
  120. #define IL_TX_FIFO_AC3 3
  121. #define IL_TX_FIFO_HCCA_1 5
  122. #define IL_TX_FIFO_HCCA_2 6
  123. #define IL_TX_FIFO_NONE 7
  124. #define IEEE80211_DATA_LEN 2304
  125. #define IEEE80211_4ADDR_LEN 30
  126. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  127. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  128. struct il3945_frame {
  129. union {
  130. struct ieee80211_hdr frame;
  131. struct il3945_tx_beacon_cmd beacon;
  132. u8 raw[IEEE80211_FRAME_LEN];
  133. u8 cmd[360];
  134. } u;
  135. struct list_head list;
  136. };
  137. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  138. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  139. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  140. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  141. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  142. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  143. #define IL_SUPPORTED_RATES_IE_LEN 8
  144. #define SCAN_INTERVAL 100
  145. #define MAX_TID_COUNT 9
  146. #define IL_INVALID_RATE 0xFF
  147. #define IL_INVALID_VALUE -1
  148. #define STA_PS_STATUS_WAKE 0
  149. #define STA_PS_STATUS_SLEEP 1
  150. struct il3945_ibss_seq {
  151. u8 mac[ETH_ALEN];
  152. u16 seq_num;
  153. u16 frag_num;
  154. unsigned long packet_time;
  155. struct list_head list;
  156. };
  157. #define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\
  158. x->u.rx_frame.stats.payload + \
  159. x->u.rx_frame.stats.phy_count))
  160. #define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\
  161. IL_RX_HDR(x)->payload + \
  162. le16_to_cpu(IL_RX_HDR(x)->len)))
  163. #define IL_RX_STATS(x) (&x->u.rx_frame.stats)
  164. #define IL_RX_DATA(x) (IL_RX_HDR(x)->payload)
  165. /******************************************************************************
  166. *
  167. * Functions implemented in iwl3945-base.c which are forward declared here
  168. * for use by iwl-*.c
  169. *
  170. *****************************************************************************/
  171. extern int il3945_calc_db_from_ratio(int sig_ratio);
  172. extern void il3945_rx_replenish(void *data);
  173. extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
  174. extern unsigned int il3945_fill_beacon_frame(struct il_priv *il,
  175. struct ieee80211_hdr *hdr, int left);
  176. extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log,
  177. char **buf, bool display);
  178. extern void il3945_dump_nic_error_log(struct il_priv *il);
  179. /******************************************************************************
  180. *
  181. * Functions implemented in iwl-[34]*.c which are forward declared here
  182. * for use by iwl3945-base.c
  183. *
  184. * NOTE: The implementation of these functions are hardware specific
  185. * which is why they are in the hardware specific files (vs. iwl-base.c)
  186. *
  187. * Naming convention --
  188. * il3945_ <-- Its part of iwlwifi (should be changed to il3945_)
  189. * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  190. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  191. * il3945_bg_ <-- Called from work queue context
  192. * il3945_mac_ <-- mac80211 callback
  193. *
  194. ****************************************************************************/
  195. extern void il3945_hw_handler_setup(struct il_priv *il);
  196. extern void il3945_hw_setup_deferred_work(struct il_priv *il);
  197. extern void il3945_hw_cancel_deferred_work(struct il_priv *il);
  198. extern int il3945_hw_rxq_stop(struct il_priv *il);
  199. extern int il3945_hw_set_hw_params(struct il_priv *il);
  200. extern int il3945_hw_nic_init(struct il_priv *il);
  201. extern int il3945_hw_nic_stop_master(struct il_priv *il);
  202. extern void il3945_hw_txq_ctx_free(struct il_priv *il);
  203. extern void il3945_hw_txq_ctx_stop(struct il_priv *il);
  204. extern int il3945_hw_nic_reset(struct il_priv *il);
  205. extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il,
  206. struct il_tx_queue *txq,
  207. dma_addr_t addr, u16 len,
  208. u8 reset, u8 pad);
  209. extern void il3945_hw_txq_free_tfd(struct il_priv *il,
  210. struct il_tx_queue *txq);
  211. extern int il3945_hw_get_temperature(struct il_priv *il);
  212. extern int il3945_hw_tx_queue_init(struct il_priv *il,
  213. struct il_tx_queue *txq);
  214. extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
  215. struct il3945_frame *frame, u8 rate);
  216. void il3945_hw_build_tx_cmd_rate(struct il_priv *il,
  217. struct il_device_cmd *cmd,
  218. struct ieee80211_tx_info *info,
  219. struct ieee80211_hdr *hdr,
  220. int sta_id, int tx_id);
  221. extern int il3945_hw_reg_send_txpower(struct il_priv *il);
  222. extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power);
  223. extern void il3945_hdl_stats(struct il_priv *il,
  224. struct il_rx_buf *rxb);
  225. void il3945_hdl_c_stats(struct il_priv *il,
  226. struct il_rx_buf *rxb);
  227. extern void il3945_disable_events(struct il_priv *il);
  228. extern int il4965_get_temperature(const struct il_priv *il);
  229. extern void il3945_post_associate(struct il_priv *il);
  230. extern void il3945_config_ap(struct il_priv *il);
  231. extern int il3945_commit_rxon(struct il_priv *il,
  232. struct il_rxon_context *ctx);
  233. /**
  234. * il3945_hw_find_station - Find station id for a given BSSID
  235. * @bssid: MAC address of station ID to find
  236. *
  237. * NOTE: This should not be hardware specific but the code has
  238. * not yet been merged into a single common layer for managing the
  239. * station tables.
  240. */
  241. extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid);
  242. extern struct ieee80211_ops il3945_hw_ops;
  243. extern __le32 il3945_get_antenna_flags(const struct il_priv *il);
  244. extern int il3945_init_hw_rate_table(struct il_priv *il);
  245. extern void il3945_reg_txpower_periodic(struct il_priv *il);
  246. extern int il3945_txpower_set_from_eeprom(struct il_priv *il);
  247. extern const struct il_channel_info *il3945_get_channel_info(
  248. const struct il_priv *il, enum ieee80211_band band, u16 channel);
  249. extern int il3945_rs_next_rate(struct il_priv *il, int rate);
  250. /* scanning */
  251. int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
  252. void il3945_post_scan(struct il_priv *il);
  253. /* rates */
  254. extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945];
  255. /* RSSI to dBm */
  256. #define IL39_RSSI_OFFSET 95
  257. /*
  258. * EEPROM related constants, enums, and structures.
  259. */
  260. #define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
  261. /*
  262. * Mapping of a Tx power level, at factory calibration temperature,
  263. * to a radio/DSP gain table idx.
  264. * One for each of 5 "sample" power levels in each band.
  265. * v_det is measured at the factory, using the 3945's built-in power amplifier
  266. * (PA) output voltage detector. This same detector is used during Tx of
  267. * long packets in normal operation to provide feedback as to proper output
  268. * level.
  269. * Data copied from EEPROM.
  270. * DO NOT ALTER THIS STRUCTURE!!!
  271. */
  272. struct il3945_eeprom_txpower_sample {
  273. u8 gain_idx; /* idx into power (gain) setup table ... */
  274. s8 power; /* ... for this pwr level for this chnl group */
  275. u16 v_det; /* PA output voltage */
  276. } __packed;
  277. /*
  278. * Mappings of Tx power levels -> nominal radio/DSP gain table idxes.
  279. * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
  280. * Tx power setup code interpolates between the 5 "sample" power levels
  281. * to determine the nominal setup for a requested power level.
  282. * Data copied from EEPROM.
  283. * DO NOT ALTER THIS STRUCTURE!!!
  284. */
  285. struct il3945_eeprom_txpower_group {
  286. struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
  287. s32 a, b, c, d, e; /* coefficients for voltage->power
  288. * formula (signed) */
  289. s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
  290. * frequency (signed) */
  291. s8 saturation_power; /* highest power possible by h/w in this
  292. * band */
  293. u8 group_channel; /* "representative" channel # in this band */
  294. s16 temperature; /* h/w temperature at factory calib this band
  295. * (signed) */
  296. } __packed;
  297. /*
  298. * Temperature-based Tx-power compensation data, not band-specific.
  299. * These coefficients are use to modify a/b/c/d/e coeffs based on
  300. * difference between current temperature and factory calib temperature.
  301. * Data copied from EEPROM.
  302. */
  303. struct il3945_eeprom_temperature_corr {
  304. u32 Ta;
  305. u32 Tb;
  306. u32 Tc;
  307. u32 Td;
  308. u32 Te;
  309. } __packed;
  310. /*
  311. * EEPROM map
  312. */
  313. struct il3945_eeprom {
  314. u8 reserved0[16];
  315. u16 device_id; /* abs.ofs: 16 */
  316. u8 reserved1[2];
  317. u16 pmc; /* abs.ofs: 20 */
  318. u8 reserved2[20];
  319. u8 mac_address[6]; /* abs.ofs: 42 */
  320. u8 reserved3[58];
  321. u16 board_revision; /* abs.ofs: 106 */
  322. u8 reserved4[11];
  323. u8 board_pba_number[9]; /* abs.ofs: 119 */
  324. u8 reserved5[8];
  325. u16 version; /* abs.ofs: 136 */
  326. u8 sku_cap; /* abs.ofs: 138 */
  327. u8 leds_mode; /* abs.ofs: 139 */
  328. u16 oem_mode;
  329. u16 wowlan_mode; /* abs.ofs: 142 */
  330. u16 leds_time_interval; /* abs.ofs: 144 */
  331. u8 leds_off_time; /* abs.ofs: 146 */
  332. u8 leds_on_time; /* abs.ofs: 147 */
  333. u8 almgor_m_version; /* abs.ofs: 148 */
  334. u8 antenna_switch_type; /* abs.ofs: 149 */
  335. u8 reserved6[42];
  336. u8 sku_id[4]; /* abs.ofs: 192 */
  337. /*
  338. * Per-channel regulatory data.
  339. *
  340. * Each channel that *might* be supported by 3945 has a fixed location
  341. * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
  342. * txpower (MSB).
  343. *
  344. * Entries immediately below are for 20 MHz channel width.
  345. *
  346. * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  347. */
  348. u16 band_1_count; /* abs.ofs: 196 */
  349. struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */
  350. /*
  351. * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
  352. * 5.0 GHz channels 7, 8, 11, 12, 16
  353. * (4915-5080MHz) (none of these is ever supported)
  354. */
  355. u16 band_2_count; /* abs.ofs: 226 */
  356. struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
  357. /*
  358. * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
  359. * (5170-5320MHz)
  360. */
  361. u16 band_3_count; /* abs.ofs: 254 */
  362. struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
  363. /*
  364. * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
  365. * (5500-5700MHz)
  366. */
  367. u16 band_4_count; /* abs.ofs: 280 */
  368. struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
  369. /*
  370. * 5.7 GHz channels 145, 149, 153, 157, 161, 165
  371. * (5725-5825MHz)
  372. */
  373. u16 band_5_count; /* abs.ofs: 304 */
  374. struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
  375. u8 reserved9[194];
  376. /*
  377. * 3945 Txpower calibration data.
  378. */
  379. #define IL_NUM_TX_CALIB_GROUPS 5
  380. struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS];
  381. /* abs.ofs: 512 */
  382. struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
  383. u8 reserved16[172]; /* fill out to full 1024 byte block */
  384. } __packed;
  385. #define IL3945_EEPROM_IMG_SIZE 1024
  386. /* End of EEPROM */
  387. #define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
  388. #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
  389. /* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
  390. #define IL39_NUM_QUEUES 5
  391. #define IL39_CMD_QUEUE_NUM 4
  392. #define IL_DEFAULT_TX_RETRY 15
  393. /*********************************************/
  394. #define RFD_SIZE 4
  395. #define NUM_TFD_CHUNKS 4
  396. #define TFD_CTL_COUNT_SET(n) (n << 24)
  397. #define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7)
  398. #define TFD_CTL_PAD_SET(n) (n << 28)
  399. #define TFD_CTL_PAD_GET(ctl) (ctl >> 28)
  400. /* Sizes and addresses for instruction and data memory (SRAM) in
  401. * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
  402. #define IL39_RTC_INST_LOWER_BOUND (0x000000)
  403. #define IL39_RTC_INST_UPPER_BOUND (0x014000)
  404. #define IL39_RTC_DATA_LOWER_BOUND (0x800000)
  405. #define IL39_RTC_DATA_UPPER_BOUND (0x808000)
  406. #define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \
  407. IL39_RTC_INST_LOWER_BOUND)
  408. #define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \
  409. IL39_RTC_DATA_LOWER_BOUND)
  410. #define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE
  411. #define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE
  412. /* Size of uCode instruction memory in bootstrap state machine */
  413. #define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE
  414. static inline int il3945_hw_valid_rtc_data_addr(u32 addr)
  415. {
  416. return (addr >= IL39_RTC_DATA_LOWER_BOUND &&
  417. addr < IL39_RTC_DATA_UPPER_BOUND);
  418. }
  419. /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE
  420. * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */
  421. struct il3945_shared {
  422. __le32 tx_base_ptr[8];
  423. } __packed;
  424. static inline u8 il3945_hw_get_rate(__le16 rate_n_flags)
  425. {
  426. return le16_to_cpu(rate_n_flags) & 0xFF;
  427. }
  428. static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags)
  429. {
  430. return le16_to_cpu(rate_n_flags);
  431. }
  432. static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags)
  433. {
  434. return cpu_to_le16((u16)rate|flags);
  435. }
  436. /************************************/
  437. /* iwl3945 Flow Handler Definitions */
  438. /************************************/
  439. /**
  440. * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
  441. * Addresses are offsets from device's PCI hardware base address.
  442. */
  443. #define FH39_MEM_LOWER_BOUND (0x0800)
  444. #define FH39_MEM_UPPER_BOUND (0x1000)
  445. #define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140)
  446. #define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180)
  447. #define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400)
  448. #define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0)
  449. #define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500)
  450. #define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680)
  451. /* TFDB (Transmit Frame Buffer Descriptor) */
  452. #define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \
  453. ((_ch) * 2 + (buf)) * 0x28)
  454. #define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch))
  455. /* CBCC channel is [0,2] */
  456. #define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8)
  457. #define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00)
  458. #define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04)
  459. /* RCSR channel is [0,2] */
  460. #define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40)
  461. #define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00)
  462. #define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04)
  463. #define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20)
  464. #define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24)
  465. #define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0))
  466. /* RSSR */
  467. #define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000)
  468. #define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004)
  469. /* TCSR */
  470. #define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20)
  471. #define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00)
  472. #define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04)
  473. #define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08)
  474. /* TSSR */
  475. #define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000)
  476. #define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008)
  477. #define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010)
  478. /* DBM */
  479. #define FH39_SRVC_CHNL (6)
  480. #define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
  481. #define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
  482. #define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
  483. #define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
  484. #define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
  485. #define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
  486. #define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
  487. #define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
  488. #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
  489. #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
  490. #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
  491. #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  492. #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
  493. #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
  494. #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
  495. #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  496. #define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
  497. #define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
  498. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
  499. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
  500. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
  501. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
  502. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
  503. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
  504. #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
  505. #define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24)
  506. #define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16)
  507. #define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \
  508. (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \
  509. FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch))
  510. #define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
  511. struct il3945_tfd_tb {
  512. __le32 addr;
  513. __le32 len;
  514. } __packed;
  515. struct il3945_tfd {
  516. __le32 control_flags;
  517. struct il3945_tfd_tb tbs[4];
  518. u8 __pad[28];
  519. } __packed;
  520. #ifdef CONFIG_IWLEGACY_DEBUGFS
  521. ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
  522. size_t count, loff_t *ppos);
  523. ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
  524. size_t count, loff_t *ppos);
  525. ssize_t il3945_ucode_general_stats_read(struct file *file,
  526. char __user *user_buf, size_t count,
  527. loff_t *ppos);
  528. #else
  529. static ssize_t il3945_ucode_rx_stats_read(struct file *file,
  530. char __user *user_buf, size_t count,
  531. loff_t *ppos)
  532. {
  533. return 0;
  534. }
  535. static ssize_t il3945_ucode_tx_stats_read(struct file *file,
  536. char __user *user_buf, size_t count,
  537. loff_t *ppos)
  538. {
  539. return 0;
  540. }
  541. static ssize_t il3945_ucode_general_stats_read(struct file *file,
  542. char __user *user_buf,
  543. size_t count, loff_t *ppos)
  544. {
  545. return 0;
  546. }
  547. #endif
  548. #endif