1*16da78b7SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27ac9a364SKalle Valo /******************************************************************************
37ac9a364SKalle Valo *
47ac9a364SKalle Valo * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
57ac9a364SKalle Valo *
67ac9a364SKalle Valo * Contact Information:
77ac9a364SKalle Valo * Intel Linux Wireless <ilw@linux.intel.com>
87ac9a364SKalle Valo * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
97ac9a364SKalle Valo *
107ac9a364SKalle Valo *****************************************************************************/
117ac9a364SKalle Valo
127ac9a364SKalle Valo #ifndef __il_3945_h__
137ac9a364SKalle Valo #define __il_3945_h__
147ac9a364SKalle Valo
157ac9a364SKalle Valo #include <linux/pci.h> /* for struct pci_device_id */
167ac9a364SKalle Valo #include <linux/kernel.h>
177ac9a364SKalle Valo #include <net/ieee80211_radiotap.h>
187ac9a364SKalle Valo
197ac9a364SKalle Valo /* Hardware specific file defines the PCI IDs table for that hardware module */
207ac9a364SKalle Valo extern const struct pci_device_id il3945_hw_card_ids[];
217ac9a364SKalle Valo
227ac9a364SKalle Valo #include "common.h"
237ac9a364SKalle Valo
247ac9a364SKalle Valo extern const struct il_ops il3945_ops;
257ac9a364SKalle Valo
267ac9a364SKalle Valo /* Highest firmware API version supported */
277ac9a364SKalle Valo #define IL3945_UCODE_API_MAX 2
287ac9a364SKalle Valo
297ac9a364SKalle Valo /* Lowest firmware API version supported */
307ac9a364SKalle Valo #define IL3945_UCODE_API_MIN 1
317ac9a364SKalle Valo
327ac9a364SKalle Valo #define IL3945_FW_PRE "iwlwifi-3945-"
337ac9a364SKalle Valo #define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode"
347ac9a364SKalle Valo #define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api)
357ac9a364SKalle Valo
367ac9a364SKalle Valo /* Default noise level to report when noise measurement is not available.
377ac9a364SKalle Valo * This may be because we're:
387ac9a364SKalle Valo * 1) Not associated (4965, no beacon stats being sent to driver)
397ac9a364SKalle Valo * 2) Scanning (noise measurement does not apply to associated channel)
407ac9a364SKalle Valo * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
417ac9a364SKalle Valo * Use default noise value of -127 ... this is below the range of measurable
427ac9a364SKalle Valo * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
437ac9a364SKalle Valo * Also, -127 works better than 0 when averaging frames with/without
447ac9a364SKalle Valo * noise info (e.g. averaging might be done in app); measured dBm values are
457ac9a364SKalle Valo * always negative ... using a negative value as the default keeps all
467ac9a364SKalle Valo * averages within an s8's (used in some apps) range of negative values. */
477ac9a364SKalle Valo #define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
487ac9a364SKalle Valo
497ac9a364SKalle Valo /* Module parameters accessible from iwl-*.c */
507ac9a364SKalle Valo extern struct il_mod_params il3945_mod_params;
517ac9a364SKalle Valo
527ac9a364SKalle Valo struct il3945_rate_scale_data {
537ac9a364SKalle Valo u64 data;
547ac9a364SKalle Valo s32 success_counter;
557ac9a364SKalle Valo s32 success_ratio;
567ac9a364SKalle Valo s32 counter;
577ac9a364SKalle Valo s32 average_tpt;
587ac9a364SKalle Valo unsigned long stamp;
597ac9a364SKalle Valo };
607ac9a364SKalle Valo
617ac9a364SKalle Valo struct il3945_rs_sta {
627ac9a364SKalle Valo spinlock_t lock;
637ac9a364SKalle Valo struct il_priv *il;
647ac9a364SKalle Valo s32 *expected_tpt;
657ac9a364SKalle Valo unsigned long last_partial_flush;
667ac9a364SKalle Valo unsigned long last_flush;
677ac9a364SKalle Valo u32 flush_time;
687ac9a364SKalle Valo u32 last_tx_packets;
697ac9a364SKalle Valo u32 tx_packets;
707ac9a364SKalle Valo u8 tgg;
717ac9a364SKalle Valo u8 flush_pending;
727ac9a364SKalle Valo u8 start_rate;
737ac9a364SKalle Valo struct timer_list rate_scale_flush;
747ac9a364SKalle Valo struct il3945_rate_scale_data win[RATE_COUNT_3945];
757ac9a364SKalle Valo
767ac9a364SKalle Valo /* used to be in sta_info */
777ac9a364SKalle Valo int last_txrate_idx;
787ac9a364SKalle Valo };
797ac9a364SKalle Valo
807ac9a364SKalle Valo /*
817ac9a364SKalle Valo * The common struct MUST be first because it is shared between
827ac9a364SKalle Valo * 3945 and 4965!
837ac9a364SKalle Valo */
847ac9a364SKalle Valo struct il3945_sta_priv {
857ac9a364SKalle Valo struct il_station_priv_common common;
867ac9a364SKalle Valo struct il3945_rs_sta rs_sta;
877ac9a364SKalle Valo };
887ac9a364SKalle Valo
897ac9a364SKalle Valo enum il3945_antenna {
907ac9a364SKalle Valo IL_ANTENNA_DIVERSITY,
917ac9a364SKalle Valo IL_ANTENNA_MAIN,
927ac9a364SKalle Valo IL_ANTENNA_AUX
937ac9a364SKalle Valo };
947ac9a364SKalle Valo
957ac9a364SKalle Valo /*
967ac9a364SKalle Valo * RTS threshold here is total size [2347] minus 4 FCS bytes
977ac9a364SKalle Valo * Per spec:
987ac9a364SKalle Valo * a value of 0 means RTS on all data/management packets
997ac9a364SKalle Valo * a value > max MSDU size means no RTS
1007ac9a364SKalle Valo * else RTS for data/management frames where MPDU is larger
1017ac9a364SKalle Valo * than RTS value.
1027ac9a364SKalle Valo */
1037ac9a364SKalle Valo #define DEFAULT_RTS_THRESHOLD 2347U
1047ac9a364SKalle Valo #define MIN_RTS_THRESHOLD 0U
1057ac9a364SKalle Valo #define MAX_RTS_THRESHOLD 2347U
1067ac9a364SKalle Valo #define MAX_MSDU_SIZE 2304U
1077ac9a364SKalle Valo #define MAX_MPDU_SIZE 2346U
1087ac9a364SKalle Valo #define DEFAULT_BEACON_INTERVAL 100U
1097ac9a364SKalle Valo #define DEFAULT_SHORT_RETRY_LIMIT 7U
1107ac9a364SKalle Valo #define DEFAULT_LONG_RETRY_LIMIT 4U
1117ac9a364SKalle Valo
1127ac9a364SKalle Valo #define IL_TX_FIFO_AC0 0
1137ac9a364SKalle Valo #define IL_TX_FIFO_AC1 1
1147ac9a364SKalle Valo #define IL_TX_FIFO_AC2 2
1157ac9a364SKalle Valo #define IL_TX_FIFO_AC3 3
1167ac9a364SKalle Valo #define IL_TX_FIFO_HCCA_1 5
1177ac9a364SKalle Valo #define IL_TX_FIFO_HCCA_2 6
1187ac9a364SKalle Valo #define IL_TX_FIFO_NONE 7
1197ac9a364SKalle Valo
1207ac9a364SKalle Valo #define IEEE80211_DATA_LEN 2304
1217ac9a364SKalle Valo #define IEEE80211_4ADDR_LEN 30
1227ac9a364SKalle Valo #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
1237ac9a364SKalle Valo #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
1247ac9a364SKalle Valo
1257ac9a364SKalle Valo struct il3945_frame {
1267ac9a364SKalle Valo union {
1277ac9a364SKalle Valo struct ieee80211_hdr frame;
1287ac9a364SKalle Valo struct il3945_tx_beacon_cmd beacon;
1297ac9a364SKalle Valo u8 raw[IEEE80211_FRAME_LEN];
1307ac9a364SKalle Valo u8 cmd[360];
1317ac9a364SKalle Valo } u;
1327ac9a364SKalle Valo struct list_head list;
1337ac9a364SKalle Valo };
1347ac9a364SKalle Valo
1357ac9a364SKalle Valo #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
1367ac9a364SKalle Valo #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
1377ac9a364SKalle Valo #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
1387ac9a364SKalle Valo
1397ac9a364SKalle Valo #define IL_SUPPORTED_RATES_IE_LEN 8
1407ac9a364SKalle Valo
1417ac9a364SKalle Valo #define SCAN_INTERVAL 100
1427ac9a364SKalle Valo
1437ac9a364SKalle Valo #define MAX_TID_COUNT 9
1447ac9a364SKalle Valo
1457ac9a364SKalle Valo #define IL_INVALID_RATE 0xFF
1467ac9a364SKalle Valo #define IL_INVALID_VALUE -1
1477ac9a364SKalle Valo
1487ac9a364SKalle Valo #define STA_PS_STATUS_WAKE 0
1497ac9a364SKalle Valo #define STA_PS_STATUS_SLEEP 1
1507ac9a364SKalle Valo
1517ac9a364SKalle Valo struct il3945_ibss_seq {
1527ac9a364SKalle Valo u8 mac[ETH_ALEN];
1537ac9a364SKalle Valo u16 seq_num;
1547ac9a364SKalle Valo u16 frag_num;
1557ac9a364SKalle Valo unsigned long packet_time;
1567ac9a364SKalle Valo struct list_head list;
1577ac9a364SKalle Valo };
1587ac9a364SKalle Valo
1597ac9a364SKalle Valo #define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\
1607ac9a364SKalle Valo x->u.rx_frame.stats.payload + \
1617ac9a364SKalle Valo x->u.rx_frame.stats.phy_count))
1627ac9a364SKalle Valo #define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\
1637ac9a364SKalle Valo IL_RX_HDR(x)->payload + \
1647ac9a364SKalle Valo le16_to_cpu(IL_RX_HDR(x)->len)))
1657ac9a364SKalle Valo #define IL_RX_STATS(x) (&x->u.rx_frame.stats)
1667ac9a364SKalle Valo #define IL_RX_DATA(x) (IL_RX_HDR(x)->payload)
1677ac9a364SKalle Valo
1687ac9a364SKalle Valo /******************************************************************************
1697ac9a364SKalle Valo *
1707ac9a364SKalle Valo * Functions implemented in iwl3945-base.c which are forward declared here
1717ac9a364SKalle Valo * for use by iwl-*.c
1727ac9a364SKalle Valo *
1737ac9a364SKalle Valo *****************************************************************************/
1747ac9a364SKalle Valo int il3945_calc_db_from_ratio(int sig_ratio);
1757ac9a364SKalle Valo void il3945_rx_replenish(void *data);
1767ac9a364SKalle Valo void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
1777ac9a364SKalle Valo unsigned int il3945_fill_beacon_frame(struct il_priv *il,
1787ac9a364SKalle Valo struct ieee80211_hdr *hdr, int left);
1797ac9a364SKalle Valo int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, char **buf,
1807ac9a364SKalle Valo bool display);
1817ac9a364SKalle Valo void il3945_dump_nic_error_log(struct il_priv *il);
1827ac9a364SKalle Valo
1837ac9a364SKalle Valo /******************************************************************************
1847ac9a364SKalle Valo *
1857ac9a364SKalle Valo * Functions implemented in iwl-[34]*.c which are forward declared here
1867ac9a364SKalle Valo * for use by iwl3945-base.c
1877ac9a364SKalle Valo *
1887ac9a364SKalle Valo * NOTE: The implementation of these functions are hardware specific
1897ac9a364SKalle Valo * which is why they are in the hardware specific files (vs. iwl-base.c)
1907ac9a364SKalle Valo *
1917ac9a364SKalle Valo * Naming convention --
1927ac9a364SKalle Valo * il3945_ <-- Its part of iwlwifi (should be changed to il3945_)
1937ac9a364SKalle Valo * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
1947ac9a364SKalle Valo * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
1957ac9a364SKalle Valo * il3945_bg_ <-- Called from work queue context
1967ac9a364SKalle Valo * il3945_mac_ <-- mac80211 callback
1977ac9a364SKalle Valo *
1987ac9a364SKalle Valo ****************************************************************************/
1997ac9a364SKalle Valo void il3945_hw_handler_setup(struct il_priv *il);
2007ac9a364SKalle Valo void il3945_hw_setup_deferred_work(struct il_priv *il);
2017ac9a364SKalle Valo void il3945_hw_cancel_deferred_work(struct il_priv *il);
2027ac9a364SKalle Valo int il3945_hw_rxq_stop(struct il_priv *il);
2037ac9a364SKalle Valo int il3945_hw_set_hw_params(struct il_priv *il);
2047ac9a364SKalle Valo int il3945_hw_nic_init(struct il_priv *il);
2057ac9a364SKalle Valo int il3945_hw_nic_stop_master(struct il_priv *il);
2067ac9a364SKalle Valo void il3945_hw_txq_ctx_free(struct il_priv *il);
2077ac9a364SKalle Valo void il3945_hw_txq_ctx_stop(struct il_priv *il);
2087ac9a364SKalle Valo int il3945_hw_nic_reset(struct il_priv *il);
2097ac9a364SKalle Valo int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
2107ac9a364SKalle Valo dma_addr_t addr, u16 len, u8 reset, u8 pad);
2117ac9a364SKalle Valo void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
2127ac9a364SKalle Valo int il3945_hw_get_temperature(struct il_priv *il);
2137ac9a364SKalle Valo int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
2147ac9a364SKalle Valo unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
2157ac9a364SKalle Valo struct il3945_frame *frame, u8 rate);
2167ac9a364SKalle Valo void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd,
2177ac9a364SKalle Valo struct ieee80211_tx_info *info,
2187ac9a364SKalle Valo struct ieee80211_hdr *hdr, int sta_id);
2197ac9a364SKalle Valo int il3945_hw_reg_send_txpower(struct il_priv *il);
2207ac9a364SKalle Valo int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power);
2217ac9a364SKalle Valo void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
2227ac9a364SKalle Valo void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
2237ac9a364SKalle Valo void il3945_disable_events(struct il_priv *il);
2247ac9a364SKalle Valo int il4965_get_temperature(const struct il_priv *il);
2257ac9a364SKalle Valo void il3945_post_associate(struct il_priv *il);
2267ac9a364SKalle Valo void il3945_config_ap(struct il_priv *il);
2277ac9a364SKalle Valo
2287ac9a364SKalle Valo int il3945_commit_rxon(struct il_priv *il);
2297ac9a364SKalle Valo
2307ac9a364SKalle Valo /**
2317ac9a364SKalle Valo * il3945_hw_find_station - Find station id for a given BSSID
2327ac9a364SKalle Valo * @bssid: MAC address of station ID to find
2337ac9a364SKalle Valo *
2347ac9a364SKalle Valo * NOTE: This should not be hardware specific but the code has
2357ac9a364SKalle Valo * not yet been merged into a single common layer for managing the
2367ac9a364SKalle Valo * station tables.
2377ac9a364SKalle Valo */
2387ac9a364SKalle Valo u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid);
2397ac9a364SKalle Valo
2407ac9a364SKalle Valo __le32 il3945_get_antenna_flags(const struct il_priv *il);
2417ac9a364SKalle Valo int il3945_init_hw_rate_table(struct il_priv *il);
2427ac9a364SKalle Valo void il3945_reg_txpower_periodic(struct il_priv *il);
2437ac9a364SKalle Valo int il3945_txpower_set_from_eeprom(struct il_priv *il);
2447ac9a364SKalle Valo
2457ac9a364SKalle Valo int il3945_rs_next_rate(struct il_priv *il, int rate);
2467ac9a364SKalle Valo
2477ac9a364SKalle Valo /* scanning */
2487ac9a364SKalle Valo int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
2497ac9a364SKalle Valo void il3945_post_scan(struct il_priv *il);
2507ac9a364SKalle Valo
2517ac9a364SKalle Valo /* rates */
2527ac9a364SKalle Valo extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945];
2537ac9a364SKalle Valo
2547ac9a364SKalle Valo /* RSSI to dBm */
2557ac9a364SKalle Valo #define IL39_RSSI_OFFSET 95
2567ac9a364SKalle Valo
2577ac9a364SKalle Valo /*
2587ac9a364SKalle Valo * EEPROM related constants, enums, and structures.
2597ac9a364SKalle Valo */
2607ac9a364SKalle Valo #define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
2617ac9a364SKalle Valo
2627ac9a364SKalle Valo /*
2637ac9a364SKalle Valo * Mapping of a Tx power level, at factory calibration temperature,
2647ac9a364SKalle Valo * to a radio/DSP gain table idx.
2657ac9a364SKalle Valo * One for each of 5 "sample" power levels in each band.
2667ac9a364SKalle Valo * v_det is measured at the factory, using the 3945's built-in power amplifier
2677ac9a364SKalle Valo * (PA) output voltage detector. This same detector is used during Tx of
2687ac9a364SKalle Valo * long packets in normal operation to provide feedback as to proper output
2697ac9a364SKalle Valo * level.
2707ac9a364SKalle Valo * Data copied from EEPROM.
2717ac9a364SKalle Valo * DO NOT ALTER THIS STRUCTURE!!!
2727ac9a364SKalle Valo */
2737ac9a364SKalle Valo struct il3945_eeprom_txpower_sample {
2747ac9a364SKalle Valo u8 gain_idx; /* idx into power (gain) setup table ... */
2757ac9a364SKalle Valo s8 power; /* ... for this pwr level for this chnl group */
2767ac9a364SKalle Valo u16 v_det; /* PA output voltage */
2777ac9a364SKalle Valo } __packed;
2787ac9a364SKalle Valo
2797ac9a364SKalle Valo /*
2807ac9a364SKalle Valo * Mappings of Tx power levels -> nominal radio/DSP gain table idxes.
2817ac9a364SKalle Valo * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
2827ac9a364SKalle Valo * Tx power setup code interpolates between the 5 "sample" power levels
2837ac9a364SKalle Valo * to determine the nominal setup for a requested power level.
2847ac9a364SKalle Valo * Data copied from EEPROM.
2857ac9a364SKalle Valo * DO NOT ALTER THIS STRUCTURE!!!
2867ac9a364SKalle Valo */
2877ac9a364SKalle Valo struct il3945_eeprom_txpower_group {
2887ac9a364SKalle Valo struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
2897ac9a364SKalle Valo s32 a, b, c, d, e; /* coefficients for voltage->power
2907ac9a364SKalle Valo * formula (signed) */
2917ac9a364SKalle Valo s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
2927ac9a364SKalle Valo * frequency (signed) */
2937ac9a364SKalle Valo s8 saturation_power; /* highest power possible by h/w in this
2947ac9a364SKalle Valo * band */
2957ac9a364SKalle Valo u8 group_channel; /* "representative" channel # in this band */
2967ac9a364SKalle Valo s16 temperature; /* h/w temperature at factory calib this band
2977ac9a364SKalle Valo * (signed) */
2987ac9a364SKalle Valo } __packed;
2997ac9a364SKalle Valo
3007ac9a364SKalle Valo /*
3017ac9a364SKalle Valo * Temperature-based Tx-power compensation data, not band-specific.
3027ac9a364SKalle Valo * These coefficients are use to modify a/b/c/d/e coeffs based on
3037ac9a364SKalle Valo * difference between current temperature and factory calib temperature.
3047ac9a364SKalle Valo * Data copied from EEPROM.
3057ac9a364SKalle Valo */
3067ac9a364SKalle Valo struct il3945_eeprom_temperature_corr {
3077ac9a364SKalle Valo u32 Ta;
3087ac9a364SKalle Valo u32 Tb;
3097ac9a364SKalle Valo u32 Tc;
3107ac9a364SKalle Valo u32 Td;
3117ac9a364SKalle Valo u32 Te;
3127ac9a364SKalle Valo } __packed;
3137ac9a364SKalle Valo
3147ac9a364SKalle Valo /*
3157ac9a364SKalle Valo * EEPROM map
3167ac9a364SKalle Valo */
3177ac9a364SKalle Valo struct il3945_eeprom {
3187ac9a364SKalle Valo u8 reserved0[16];
3197ac9a364SKalle Valo u16 device_id; /* abs.ofs: 16 */
3207ac9a364SKalle Valo u8 reserved1[2];
3217ac9a364SKalle Valo u16 pmc; /* abs.ofs: 20 */
3227ac9a364SKalle Valo u8 reserved2[20];
3237ac9a364SKalle Valo u8 mac_address[6]; /* abs.ofs: 42 */
3247ac9a364SKalle Valo u8 reserved3[58];
3257ac9a364SKalle Valo u16 board_revision; /* abs.ofs: 106 */
3267ac9a364SKalle Valo u8 reserved4[11];
3277ac9a364SKalle Valo u8 board_pba_number[9]; /* abs.ofs: 119 */
3287ac9a364SKalle Valo u8 reserved5[8];
3297ac9a364SKalle Valo u16 version; /* abs.ofs: 136 */
3307ac9a364SKalle Valo u8 sku_cap; /* abs.ofs: 138 */
3317ac9a364SKalle Valo u8 leds_mode; /* abs.ofs: 139 */
3327ac9a364SKalle Valo u16 oem_mode;
3337ac9a364SKalle Valo u16 wowlan_mode; /* abs.ofs: 142 */
3347ac9a364SKalle Valo u16 leds_time_interval; /* abs.ofs: 144 */
3357ac9a364SKalle Valo u8 leds_off_time; /* abs.ofs: 146 */
3367ac9a364SKalle Valo u8 leds_on_time; /* abs.ofs: 147 */
3377ac9a364SKalle Valo u8 almgor_m_version; /* abs.ofs: 148 */
3387ac9a364SKalle Valo u8 antenna_switch_type; /* abs.ofs: 149 */
3397ac9a364SKalle Valo u8 reserved6[42];
3407ac9a364SKalle Valo u8 sku_id[4]; /* abs.ofs: 192 */
3417ac9a364SKalle Valo
3427ac9a364SKalle Valo /*
3437ac9a364SKalle Valo * Per-channel regulatory data.
3447ac9a364SKalle Valo *
3457ac9a364SKalle Valo * Each channel that *might* be supported by 3945 has a fixed location
3467ac9a364SKalle Valo * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
3477ac9a364SKalle Valo * txpower (MSB).
3487ac9a364SKalle Valo *
3497ac9a364SKalle Valo * Entries immediately below are for 20 MHz channel width.
3507ac9a364SKalle Valo *
3517ac9a364SKalle Valo * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
3527ac9a364SKalle Valo */
3537ac9a364SKalle Valo u16 band_1_count; /* abs.ofs: 196 */
3547ac9a364SKalle Valo struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */
3557ac9a364SKalle Valo
3567ac9a364SKalle Valo /*
3577ac9a364SKalle Valo * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
3587ac9a364SKalle Valo * 5.0 GHz channels 7, 8, 11, 12, 16
3597ac9a364SKalle Valo * (4915-5080MHz) (none of these is ever supported)
3607ac9a364SKalle Valo */
3617ac9a364SKalle Valo u16 band_2_count; /* abs.ofs: 226 */
3627ac9a364SKalle Valo struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
3637ac9a364SKalle Valo
3647ac9a364SKalle Valo /*
3657ac9a364SKalle Valo * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
3667ac9a364SKalle Valo * (5170-5320MHz)
3677ac9a364SKalle Valo */
3687ac9a364SKalle Valo u16 band_3_count; /* abs.ofs: 254 */
3697ac9a364SKalle Valo struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
3707ac9a364SKalle Valo
3717ac9a364SKalle Valo /*
3727ac9a364SKalle Valo * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
3737ac9a364SKalle Valo * (5500-5700MHz)
3747ac9a364SKalle Valo */
3757ac9a364SKalle Valo u16 band_4_count; /* abs.ofs: 280 */
3767ac9a364SKalle Valo struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
3777ac9a364SKalle Valo
3787ac9a364SKalle Valo /*
3797ac9a364SKalle Valo * 5.7 GHz channels 145, 149, 153, 157, 161, 165
3807ac9a364SKalle Valo * (5725-5825MHz)
3817ac9a364SKalle Valo */
3827ac9a364SKalle Valo u16 band_5_count; /* abs.ofs: 304 */
3837ac9a364SKalle Valo struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
3847ac9a364SKalle Valo
3857ac9a364SKalle Valo u8 reserved9[194];
3867ac9a364SKalle Valo
3877ac9a364SKalle Valo /*
3887ac9a364SKalle Valo * 3945 Txpower calibration data.
3897ac9a364SKalle Valo */
3907ac9a364SKalle Valo #define IL_NUM_TX_CALIB_GROUPS 5
3917ac9a364SKalle Valo struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS];
3927ac9a364SKalle Valo /* abs.ofs: 512 */
3937ac9a364SKalle Valo struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
3947ac9a364SKalle Valo u8 reserved16[172]; /* fill out to full 1024 byte block */
3957ac9a364SKalle Valo } __packed;
3967ac9a364SKalle Valo
3977ac9a364SKalle Valo #define IL3945_EEPROM_IMG_SIZE 1024
3987ac9a364SKalle Valo
3997ac9a364SKalle Valo /* End of EEPROM */
4007ac9a364SKalle Valo
4017ac9a364SKalle Valo #define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
4027ac9a364SKalle Valo #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
4037ac9a364SKalle Valo
4047ac9a364SKalle Valo /* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
4057ac9a364SKalle Valo #define IL39_NUM_QUEUES 5
4067ac9a364SKalle Valo #define IL39_CMD_QUEUE_NUM 4
4077ac9a364SKalle Valo
4087ac9a364SKalle Valo #define IL_DEFAULT_TX_RETRY 15
4097ac9a364SKalle Valo
4107ac9a364SKalle Valo /*********************************************/
4117ac9a364SKalle Valo
4127ac9a364SKalle Valo #define RFD_SIZE 4
4137ac9a364SKalle Valo #define NUM_TFD_CHUNKS 4
4147ac9a364SKalle Valo
4157ac9a364SKalle Valo #define TFD_CTL_COUNT_SET(n) (n << 24)
4167ac9a364SKalle Valo #define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7)
4177ac9a364SKalle Valo #define TFD_CTL_PAD_SET(n) (n << 28)
4187ac9a364SKalle Valo #define TFD_CTL_PAD_GET(ctl) (ctl >> 28)
4197ac9a364SKalle Valo
4207ac9a364SKalle Valo /* Sizes and addresses for instruction and data memory (SRAM) in
4217ac9a364SKalle Valo * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
4227ac9a364SKalle Valo #define IL39_RTC_INST_LOWER_BOUND (0x000000)
4237ac9a364SKalle Valo #define IL39_RTC_INST_UPPER_BOUND (0x014000)
4247ac9a364SKalle Valo
4257ac9a364SKalle Valo #define IL39_RTC_DATA_LOWER_BOUND (0x800000)
4267ac9a364SKalle Valo #define IL39_RTC_DATA_UPPER_BOUND (0x808000)
4277ac9a364SKalle Valo
4287ac9a364SKalle Valo #define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \
4297ac9a364SKalle Valo IL39_RTC_INST_LOWER_BOUND)
4307ac9a364SKalle Valo #define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \
4317ac9a364SKalle Valo IL39_RTC_DATA_LOWER_BOUND)
4327ac9a364SKalle Valo
4337ac9a364SKalle Valo #define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE
4347ac9a364SKalle Valo #define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE
4357ac9a364SKalle Valo
4367ac9a364SKalle Valo /* Size of uCode instruction memory in bootstrap state machine */
4377ac9a364SKalle Valo #define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE
4387ac9a364SKalle Valo
4397ac9a364SKalle Valo static inline int
il3945_hw_valid_rtc_data_addr(u32 addr)4407ac9a364SKalle Valo il3945_hw_valid_rtc_data_addr(u32 addr)
4417ac9a364SKalle Valo {
4427ac9a364SKalle Valo return (addr >= IL39_RTC_DATA_LOWER_BOUND &&
4437ac9a364SKalle Valo addr < IL39_RTC_DATA_UPPER_BOUND);
4447ac9a364SKalle Valo }
4457ac9a364SKalle Valo
4467ac9a364SKalle Valo /* Base physical address of il3945_shared is provided to FH39_TSSR_CBB_BASE
4477ac9a364SKalle Valo * and &il3945_shared.rx_read_ptr[0] is provided to FH39_RCSR_RPTR_ADDR(0) */
4487ac9a364SKalle Valo struct il3945_shared {
4497ac9a364SKalle Valo __le32 tx_base_ptr[8];
4507ac9a364SKalle Valo } __packed;
4517ac9a364SKalle Valo
4527ac9a364SKalle Valo /************************************/
4537ac9a364SKalle Valo /* iwl3945 Flow Handler Definitions */
4547ac9a364SKalle Valo /************************************/
4557ac9a364SKalle Valo
4567ac9a364SKalle Valo /**
4577ac9a364SKalle Valo * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
4587ac9a364SKalle Valo * Addresses are offsets from device's PCI hardware base address.
4597ac9a364SKalle Valo */
4607ac9a364SKalle Valo #define FH39_MEM_LOWER_BOUND (0x0800)
4617ac9a364SKalle Valo #define FH39_MEM_UPPER_BOUND (0x1000)
4627ac9a364SKalle Valo
4637ac9a364SKalle Valo #define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140)
4647ac9a364SKalle Valo #define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180)
4657ac9a364SKalle Valo #define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400)
4667ac9a364SKalle Valo #define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0)
4677ac9a364SKalle Valo #define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500)
4687ac9a364SKalle Valo #define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680)
4697ac9a364SKalle Valo
4707ac9a364SKalle Valo /* TFDB (Transmit Frame Buffer Descriptor) */
4717ac9a364SKalle Valo #define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \
4727ac9a364SKalle Valo ((_ch) * 2 + (buf)) * 0x28)
4737ac9a364SKalle Valo #define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch))
4747ac9a364SKalle Valo
4757ac9a364SKalle Valo /* CBCC channel is [0,2] */
4767ac9a364SKalle Valo #define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8)
4777ac9a364SKalle Valo #define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00)
4787ac9a364SKalle Valo #define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04)
4797ac9a364SKalle Valo
4807ac9a364SKalle Valo /* RCSR channel is [0,2] */
4817ac9a364SKalle Valo #define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40)
4827ac9a364SKalle Valo #define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00)
4837ac9a364SKalle Valo #define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04)
4847ac9a364SKalle Valo #define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20)
4857ac9a364SKalle Valo #define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24)
4867ac9a364SKalle Valo
4877ac9a364SKalle Valo #define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0))
4887ac9a364SKalle Valo
4897ac9a364SKalle Valo /* RSSR */
4907ac9a364SKalle Valo #define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000)
4917ac9a364SKalle Valo #define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004)
4927ac9a364SKalle Valo
4937ac9a364SKalle Valo /* TCSR */
4947ac9a364SKalle Valo #define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20)
4957ac9a364SKalle Valo #define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00)
4967ac9a364SKalle Valo #define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04)
4977ac9a364SKalle Valo #define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08)
4987ac9a364SKalle Valo
4997ac9a364SKalle Valo /* TSSR */
5007ac9a364SKalle Valo #define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000)
5017ac9a364SKalle Valo #define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008)
5027ac9a364SKalle Valo #define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010)
5037ac9a364SKalle Valo
5047ac9a364SKalle Valo /* DBM */
5057ac9a364SKalle Valo
5067ac9a364SKalle Valo #define FH39_SRVC_CHNL (6)
5077ac9a364SKalle Valo
5087ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
5097ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
5107ac9a364SKalle Valo
5117ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
5127ac9a364SKalle Valo
5137ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
5147ac9a364SKalle Valo
5157ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
5167ac9a364SKalle Valo
5177ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
5187ac9a364SKalle Valo
5197ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
5207ac9a364SKalle Valo
5217ac9a364SKalle Valo #define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
5227ac9a364SKalle Valo
5237ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
5247ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
5257ac9a364SKalle Valo
5267ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
5277ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
5287ac9a364SKalle Valo
5297ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
5307ac9a364SKalle Valo
5317ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
5327ac9a364SKalle Valo
5337ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
5347ac9a364SKalle Valo #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
5357ac9a364SKalle Valo
5367ac9a364SKalle Valo #define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
5377ac9a364SKalle Valo
5387ac9a364SKalle Valo #define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
5397ac9a364SKalle Valo
5407ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
5417ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
5427ac9a364SKalle Valo
5437ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
5447ac9a364SKalle Valo
5457ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
5467ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
5477ac9a364SKalle Valo
5487ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
5497ac9a364SKalle Valo #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
5507ac9a364SKalle Valo
5517ac9a364SKalle Valo #define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24)
5527ac9a364SKalle Valo #define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16)
5537ac9a364SKalle Valo
5547ac9a364SKalle Valo #define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \
5557ac9a364SKalle Valo (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \
5567ac9a364SKalle Valo FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch))
5577ac9a364SKalle Valo
5587ac9a364SKalle Valo #define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
5597ac9a364SKalle Valo
5607ac9a364SKalle Valo struct il3945_tfd_tb {
5617ac9a364SKalle Valo __le32 addr;
5627ac9a364SKalle Valo __le32 len;
5637ac9a364SKalle Valo } __packed;
5647ac9a364SKalle Valo
5657ac9a364SKalle Valo struct il3945_tfd {
5667ac9a364SKalle Valo __le32 control_flags;
5677ac9a364SKalle Valo struct il3945_tfd_tb tbs[4];
5687ac9a364SKalle Valo u8 __pad[28];
5697ac9a364SKalle Valo } __packed;
5707ac9a364SKalle Valo
5717ac9a364SKalle Valo #ifdef CONFIG_IWLEGACY_DEBUGFS
5727ac9a364SKalle Valo extern const struct il_debugfs_ops il3945_debugfs_ops;
5737ac9a364SKalle Valo #endif
5747ac9a364SKalle Valo
5757ac9a364SKalle Valo #endif
576