xref: /openbmc/linux/drivers/net/wireless/intel/iwlegacy/4965.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*ad306d68SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27ac9a364SKalle Valo /******************************************************************************
37ac9a364SKalle Valo  *
47ac9a364SKalle Valo  * Copyright(c) 2008 - 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_4965_h__
137ac9a364SKalle Valo #define __il_4965_h__
147ac9a364SKalle Valo 
157ac9a364SKalle Valo struct il_rx_queue;
167ac9a364SKalle Valo struct il_rx_buf;
177ac9a364SKalle Valo struct il_rx_pkt;
187ac9a364SKalle Valo struct il_tx_queue;
197ac9a364SKalle Valo struct il_rxon_context;
207ac9a364SKalle Valo 
217ac9a364SKalle Valo /* configuration for the _4965 devices */
227ac9a364SKalle Valo extern struct il_cfg il4965_cfg;
237ac9a364SKalle Valo extern const struct il_ops il4965_ops;
247ac9a364SKalle Valo 
257ac9a364SKalle Valo extern struct il_mod_params il4965_mod_params;
267ac9a364SKalle Valo 
277ac9a364SKalle Valo /* tx queue */
287ac9a364SKalle Valo void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid,
297ac9a364SKalle Valo 			       int freed);
307ac9a364SKalle Valo 
317ac9a364SKalle Valo /* RXON */
327ac9a364SKalle Valo void il4965_set_rxon_chain(struct il_priv *il);
337ac9a364SKalle Valo 
347ac9a364SKalle Valo /* uCode */
357ac9a364SKalle Valo int il4965_verify_ucode(struct il_priv *il);
367ac9a364SKalle Valo 
377ac9a364SKalle Valo /* lib */
387ac9a364SKalle Valo void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status);
397ac9a364SKalle Valo 
407ac9a364SKalle Valo void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
417ac9a364SKalle Valo int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq);
427ac9a364SKalle Valo int il4965_hw_nic_init(struct il_priv *il);
437ac9a364SKalle Valo int il4965_dump_fh(struct il_priv *il, char **buf, bool display);
447ac9a364SKalle Valo 
457ac9a364SKalle Valo void il4965_nic_config(struct il_priv *il);
467ac9a364SKalle Valo 
477ac9a364SKalle Valo /* rx */
487ac9a364SKalle Valo void il4965_rx_queue_restock(struct il_priv *il);
497ac9a364SKalle Valo void il4965_rx_replenish(struct il_priv *il);
507ac9a364SKalle Valo void il4965_rx_replenish_now(struct il_priv *il);
517ac9a364SKalle Valo void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq);
527ac9a364SKalle Valo int il4965_rxq_stop(struct il_priv *il);
5357fbcce3SJohannes Berg int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum nl80211_band band);
547ac9a364SKalle Valo void il4965_rx_handle(struct il_priv *il);
557ac9a364SKalle Valo 
567ac9a364SKalle Valo /* tx */
577ac9a364SKalle Valo void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
587ac9a364SKalle Valo int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
597ac9a364SKalle Valo 				    dma_addr_t addr, u16 len, u8 reset, u8 pad);
607ac9a364SKalle Valo int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
617ac9a364SKalle Valo void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
627ac9a364SKalle Valo 				 struct ieee80211_tx_info *info);
637ac9a364SKalle Valo int il4965_tx_skb(struct il_priv *il,
647ac9a364SKalle Valo 		  struct ieee80211_sta *sta,
657ac9a364SKalle Valo 		  struct sk_buff *skb);
667ac9a364SKalle Valo int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
677ac9a364SKalle Valo 			struct ieee80211_sta *sta, u16 tid, u16 * ssn);
687ac9a364SKalle Valo int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
697ac9a364SKalle Valo 		       struct ieee80211_sta *sta, u16 tid);
707ac9a364SKalle Valo int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id);
717ac9a364SKalle Valo int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx);
727ac9a364SKalle Valo void il4965_hw_txq_ctx_free(struct il_priv *il);
737ac9a364SKalle Valo int il4965_txq_ctx_alloc(struct il_priv *il);
747ac9a364SKalle Valo void il4965_txq_ctx_reset(struct il_priv *il);
757ac9a364SKalle Valo void il4965_txq_ctx_stop(struct il_priv *il);
767ac9a364SKalle Valo void il4965_txq_set_sched(struct il_priv *il, u32 mask);
777ac9a364SKalle Valo 
787ac9a364SKalle Valo /*
797ac9a364SKalle Valo  * Acquire il->lock before calling this function !
807ac9a364SKalle Valo  */
817ac9a364SKalle Valo void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx);
827ac9a364SKalle Valo /**
837ac9a364SKalle Valo  * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue
847ac9a364SKalle Valo  * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed
857ac9a364SKalle Valo  * @scd_retry: (1) Indicates queue will be used in aggregation mode
867ac9a364SKalle Valo  *
877ac9a364SKalle Valo  * NOTE:  Acquire il->lock before calling this function !
887ac9a364SKalle Valo  */
897ac9a364SKalle Valo void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
907ac9a364SKalle Valo 				int tx_fifo_id, int scd_retry);
917ac9a364SKalle Valo 
927ac9a364SKalle Valo /* scan */
937ac9a364SKalle Valo int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
947ac9a364SKalle Valo 
957ac9a364SKalle Valo /* station mgmt */
967ac9a364SKalle Valo int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
977ac9a364SKalle Valo 			       bool add);
987ac9a364SKalle Valo 
997ac9a364SKalle Valo /* hcmd */
1007ac9a364SKalle Valo int il4965_send_beacon_cmd(struct il_priv *il);
1017ac9a364SKalle Valo 
1027ac9a364SKalle Valo #ifdef CONFIG_IWLEGACY_DEBUG
1037ac9a364SKalle Valo const char *il4965_get_tx_fail_reason(u32 status);
1047ac9a364SKalle Valo #else
1057ac9a364SKalle Valo static inline const char *
il4965_get_tx_fail_reason(u32 status)1067ac9a364SKalle Valo il4965_get_tx_fail_reason(u32 status)
1077ac9a364SKalle Valo {
1087ac9a364SKalle Valo 	return "";
1097ac9a364SKalle Valo }
1107ac9a364SKalle Valo #endif
1117ac9a364SKalle Valo 
1127ac9a364SKalle Valo /* station management */
1137ac9a364SKalle Valo int il4965_alloc_bcast_station(struct il_priv *il);
1147ac9a364SKalle Valo int il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r);
1157ac9a364SKalle Valo int il4965_remove_default_wep_key(struct il_priv *il,
1167ac9a364SKalle Valo 				  struct ieee80211_key_conf *key);
1177ac9a364SKalle Valo int il4965_set_default_wep_key(struct il_priv *il,
1187ac9a364SKalle Valo 			       struct ieee80211_key_conf *key);
1197ac9a364SKalle Valo int il4965_restore_default_wep_keys(struct il_priv *il);
1207ac9a364SKalle Valo int il4965_set_dynamic_key(struct il_priv *il,
1217ac9a364SKalle Valo 			   struct ieee80211_key_conf *key, u8 sta_id);
1227ac9a364SKalle Valo int il4965_remove_dynamic_key(struct il_priv *il,
1237ac9a364SKalle Valo 			      struct ieee80211_key_conf *key, u8 sta_id);
1247ac9a364SKalle Valo void il4965_update_tkip_key(struct il_priv *il,
1257ac9a364SKalle Valo 			    struct ieee80211_key_conf *keyconf,
1267ac9a364SKalle Valo 			    struct ieee80211_sta *sta, u32 iv32,
1277ac9a364SKalle Valo 			    u16 *phase1key);
1287ac9a364SKalle Valo int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid);
1297ac9a364SKalle Valo int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
1307ac9a364SKalle Valo 			    int tid, u16 ssn);
1317ac9a364SKalle Valo int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
1327ac9a364SKalle Valo 			   int tid);
1337ac9a364SKalle Valo void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt);
1347ac9a364SKalle Valo int il4965_update_bcast_stations(struct il_priv *il);
1357ac9a364SKalle Valo 
1367ac9a364SKalle Valo /* rate */
1377ac9a364SKalle Valo static inline u8
il4965_hw_get_rate(__le32 rate_n_flags)1387ac9a364SKalle Valo il4965_hw_get_rate(__le32 rate_n_flags)
1397ac9a364SKalle Valo {
1407ac9a364SKalle Valo 	return le32_to_cpu(rate_n_flags) & 0xFF;
1417ac9a364SKalle Valo }
1427ac9a364SKalle Valo 
1437ac9a364SKalle Valo /* eeprom */
1447ac9a364SKalle Valo void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac);
1457ac9a364SKalle Valo int il4965_eeprom_acquire_semaphore(struct il_priv *il);
1467ac9a364SKalle Valo void il4965_eeprom_release_semaphore(struct il_priv *il);
1477ac9a364SKalle Valo int il4965_eeprom_check_version(struct il_priv *il);
1487ac9a364SKalle Valo 
1497ac9a364SKalle Valo /* mac80211 handlers (for 4965) */
1507ac9a364SKalle Valo void il4965_mac_tx(struct ieee80211_hw *hw,
1517ac9a364SKalle Valo 		   struct ieee80211_tx_control *control,
1527ac9a364SKalle Valo 		   struct sk_buff *skb);
1537ac9a364SKalle Valo int il4965_mac_start(struct ieee80211_hw *hw);
1547ac9a364SKalle Valo void il4965_mac_stop(struct ieee80211_hw *hw);
1557ac9a364SKalle Valo void il4965_configure_filter(struct ieee80211_hw *hw,
1567ac9a364SKalle Valo 			     unsigned int changed_flags,
1577ac9a364SKalle Valo 			     unsigned int *total_flags, u64 multicast);
1587ac9a364SKalle Valo int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1597ac9a364SKalle Valo 		       struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1607ac9a364SKalle Valo 		       struct ieee80211_key_conf *key);
1617ac9a364SKalle Valo void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
1627ac9a364SKalle Valo 				struct ieee80211_vif *vif,
1637ac9a364SKalle Valo 				struct ieee80211_key_conf *keyconf,
1647ac9a364SKalle Valo 				struct ieee80211_sta *sta, u32 iv32,
1657ac9a364SKalle Valo 				u16 *phase1key);
1667ac9a364SKalle Valo int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
16750ea05efSSara Sharon 			    struct ieee80211_ampdu_params *params);
1687ac9a364SKalle Valo int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1697ac9a364SKalle Valo 		       struct ieee80211_sta *sta);
1707ac9a364SKalle Valo void
1717ac9a364SKalle Valo il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1727ac9a364SKalle Valo 			  struct ieee80211_channel_switch *ch_switch);
1737ac9a364SKalle Valo 
1747ac9a364SKalle Valo void il4965_led_enable(struct il_priv *il);
1757ac9a364SKalle Valo 
1767ac9a364SKalle Valo /* EEPROM */
1777ac9a364SKalle Valo #define IL4965_EEPROM_IMG_SIZE			1024
1787ac9a364SKalle Valo 
1797ac9a364SKalle Valo /*
1807ac9a364SKalle Valo  * uCode queue management definitions ...
1817ac9a364SKalle Valo  * The first queue used for block-ack aggregation is #7 (4965 only).
1827ac9a364SKalle Valo  * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
1837ac9a364SKalle Valo  */
1847ac9a364SKalle Valo #define IL49_FIRST_AMPDU_QUEUE	7
1857ac9a364SKalle Valo 
1867ac9a364SKalle Valo /* Sizes and addresses for instruction and data memory (SRAM) in
1877ac9a364SKalle Valo  * 4965's embedded processor.  Driver access is via HBUS_TARG_MEM_* regs. */
1887ac9a364SKalle Valo #define IL49_RTC_INST_LOWER_BOUND		(0x000000)
1897ac9a364SKalle Valo #define IL49_RTC_INST_UPPER_BOUND		(0x018000)
1907ac9a364SKalle Valo 
1917ac9a364SKalle Valo #define IL49_RTC_DATA_LOWER_BOUND		(0x800000)
1927ac9a364SKalle Valo #define IL49_RTC_DATA_UPPER_BOUND		(0x80A000)
1937ac9a364SKalle Valo 
1947ac9a364SKalle Valo #define IL49_RTC_INST_SIZE  (IL49_RTC_INST_UPPER_BOUND - \
1957ac9a364SKalle Valo 				IL49_RTC_INST_LOWER_BOUND)
1967ac9a364SKalle Valo #define IL49_RTC_DATA_SIZE  (IL49_RTC_DATA_UPPER_BOUND - \
1977ac9a364SKalle Valo 				IL49_RTC_DATA_LOWER_BOUND)
1987ac9a364SKalle Valo 
1997ac9a364SKalle Valo #define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE
2007ac9a364SKalle Valo #define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE
2017ac9a364SKalle Valo 
2027ac9a364SKalle Valo /* Size of uCode instruction memory in bootstrap state machine */
2037ac9a364SKalle Valo #define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE
2047ac9a364SKalle Valo 
2057ac9a364SKalle Valo static inline int
il4965_hw_valid_rtc_data_addr(u32 addr)2067ac9a364SKalle Valo il4965_hw_valid_rtc_data_addr(u32 addr)
2077ac9a364SKalle Valo {
2087ac9a364SKalle Valo 	return (addr >= IL49_RTC_DATA_LOWER_BOUND &&
2097ac9a364SKalle Valo 		addr < IL49_RTC_DATA_UPPER_BOUND);
2107ac9a364SKalle Valo }
2117ac9a364SKalle Valo 
2127ac9a364SKalle Valo /********************* START TEMPERATURE *************************************/
2137ac9a364SKalle Valo 
2147ac9a364SKalle Valo /**
2157ac9a364SKalle Valo  * 4965 temperature calculation.
2167ac9a364SKalle Valo  *
2177ac9a364SKalle Valo  * The driver must calculate the device temperature before calculating
2187ac9a364SKalle Valo  * a txpower setting (amplifier gain is temperature dependent).  The
2197ac9a364SKalle Valo  * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
2207ac9a364SKalle Valo  * values used for the life of the driver, and one of which (R4) is the
2217ac9a364SKalle Valo  * real-time temperature indicator.
2227ac9a364SKalle Valo  *
2237ac9a364SKalle Valo  * uCode provides all 4 values to the driver via the "initialize alive"
2247ac9a364SKalle Valo  * notification (see struct il4965_init_alive_resp).  After the runtime uCode
2257ac9a364SKalle Valo  * image loads, uCode updates the R4 value via stats notifications
2267ac9a364SKalle Valo  * (see N_STATS), which occur after each received beacon
2277ac9a364SKalle Valo  * when associated, or can be requested via C_STATS.
2287ac9a364SKalle Valo  *
2297ac9a364SKalle Valo  * NOTE:  uCode provides the R4 value as a 23-bit signed value.  Driver
2307ac9a364SKalle Valo  *        must sign-extend to 32 bits before applying formula below.
2317ac9a364SKalle Valo  *
2327ac9a364SKalle Valo  * Formula:
2337ac9a364SKalle Valo  *
2347ac9a364SKalle Valo  * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
2357ac9a364SKalle Valo  *
2367ac9a364SKalle Valo  * NOTE:  The basic formula is 259 * (R4-R2) / (R3-R1).  The 97/100 is
2377ac9a364SKalle Valo  * an additional correction, which should be centered around 0 degrees
2387ac9a364SKalle Valo  * Celsius (273 degrees Kelvin).  The 8 (3 percent of 273) compensates for
2397ac9a364SKalle Valo  * centering the 97/100 correction around 0 degrees K.
2407ac9a364SKalle Valo  *
2417ac9a364SKalle Valo  * Add 273 to Kelvin value to find degrees Celsius, for comparing current
2427ac9a364SKalle Valo  * temperature with factory-measured temperatures when calculating txpower
2437ac9a364SKalle Valo  * settings.
2447ac9a364SKalle Valo  */
2457ac9a364SKalle Valo #define TEMPERATURE_CALIB_KELVIN_OFFSET 8
2467ac9a364SKalle Valo #define TEMPERATURE_CALIB_A_VAL 259
2477ac9a364SKalle Valo 
2487ac9a364SKalle Valo /* Limit range of calculated temperature to be between these Kelvin values */
2497ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_MIN  (263)
2507ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_MAX  (410)
2517ac9a364SKalle Valo 
2527ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
2537ac9a364SKalle Valo 	((t) < IL_TX_POWER_TEMPERATURE_MIN || \
2547ac9a364SKalle Valo 	 (t) > IL_TX_POWER_TEMPERATURE_MAX)
2557ac9a364SKalle Valo 
2567ac9a364SKalle Valo void il4965_temperature_calib(struct il_priv *il);
2577ac9a364SKalle Valo /********************* END TEMPERATURE ***************************************/
2587ac9a364SKalle Valo 
2597ac9a364SKalle Valo /********************* START TXPOWER *****************************************/
2607ac9a364SKalle Valo 
2617ac9a364SKalle Valo /**
2627ac9a364SKalle Valo  * 4965 txpower calculations rely on information from three sources:
2637ac9a364SKalle Valo  *
2647ac9a364SKalle Valo  *     1) EEPROM
2657ac9a364SKalle Valo  *     2) "initialize" alive notification
2667ac9a364SKalle Valo  *     3) stats notifications
2677ac9a364SKalle Valo  *
2687ac9a364SKalle Valo  * EEPROM data consists of:
2697ac9a364SKalle Valo  *
2707ac9a364SKalle Valo  * 1)  Regulatory information (max txpower and channel usage flags) is provided
2717ac9a364SKalle Valo  *     separately for each channel that can possibly supported by 4965.
2727ac9a364SKalle Valo  *     40 MHz wide (.11n HT40) channels are listed separately from 20 MHz
2737ac9a364SKalle Valo  *     (legacy) channels.
2747ac9a364SKalle Valo  *
2757ac9a364SKalle Valo  *     See struct il4965_eeprom_channel for format, and struct il4965_eeprom
2767ac9a364SKalle Valo  *     for locations in EEPROM.
2777ac9a364SKalle Valo  *
2787ac9a364SKalle Valo  * 2)  Factory txpower calibration information is provided separately for
2797ac9a364SKalle Valo  *     sub-bands of contiguous channels.  2.4GHz has just one sub-band,
2807ac9a364SKalle Valo  *     but 5 GHz has several sub-bands.
2817ac9a364SKalle Valo  *
2827ac9a364SKalle Valo  *     In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
2837ac9a364SKalle Valo  *
2847ac9a364SKalle Valo  *     See struct il4965_eeprom_calib_info (and the tree of structures
2857ac9a364SKalle Valo  *     contained within it) for format, and struct il4965_eeprom for
2867ac9a364SKalle Valo  *     locations in EEPROM.
2877ac9a364SKalle Valo  *
2887ac9a364SKalle Valo  * "Initialization alive" notification (see struct il4965_init_alive_resp)
2897ac9a364SKalle Valo  * consists of:
2907ac9a364SKalle Valo  *
2917ac9a364SKalle Valo  * 1)  Temperature calculation parameters.
2927ac9a364SKalle Valo  *
2937ac9a364SKalle Valo  * 2)  Power supply voltage measurement.
2947ac9a364SKalle Valo  *
2957ac9a364SKalle Valo  * 3)  Tx gain compensation to balance 2 transmitters for MIMO use.
2967ac9a364SKalle Valo  *
2977ac9a364SKalle Valo  * Statistics notifications deliver:
2987ac9a364SKalle Valo  *
2997ac9a364SKalle Valo  * 1)  Current values for temperature param R4.
3007ac9a364SKalle Valo  */
3017ac9a364SKalle Valo 
3027ac9a364SKalle Valo /**
3037ac9a364SKalle Valo  * To calculate a txpower setting for a given desired target txpower, channel,
3047ac9a364SKalle Valo  * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
3057ac9a364SKalle Valo  * support MIMO and transmit diversity), driver must do the following:
3067ac9a364SKalle Valo  *
3077ac9a364SKalle Valo  * 1)  Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
3087ac9a364SKalle Valo  *     Do not exceed regulatory limit; reduce target txpower if necessary.
3097ac9a364SKalle Valo  *
3107ac9a364SKalle Valo  *     If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
3117ac9a364SKalle Valo  *     2 transmitters will be used simultaneously; driver must reduce the
3127ac9a364SKalle Valo  *     regulatory limit by 3 dB (half-power) for each transmitter, so the
3137ac9a364SKalle Valo  *     combined total output of the 2 transmitters is within regulatory limits.
3147ac9a364SKalle Valo  *
3157ac9a364SKalle Valo  *
3167ac9a364SKalle Valo  * 2)  Compare target txpower vs. (EEPROM) saturation txpower *reduced by
3177ac9a364SKalle Valo  *     backoff for this bit rate*.  Do not exceed (saturation - backoff[rate]);
3187ac9a364SKalle Valo  *     reduce target txpower if necessary.
3197ac9a364SKalle Valo  *
3207ac9a364SKalle Valo  *     Backoff values below are in 1/2 dB units (equivalent to steps in
3217ac9a364SKalle Valo  *     txpower gain tables):
3227ac9a364SKalle Valo  *
3237ac9a364SKalle Valo  *     OFDM 6 - 36 MBit:  10 steps (5 dB)
3247ac9a364SKalle Valo  *     OFDM 48 MBit:      15 steps (7.5 dB)
3257ac9a364SKalle Valo  *     OFDM 54 MBit:      17 steps (8.5 dB)
3267ac9a364SKalle Valo  *     OFDM 60 MBit:      20 steps (10 dB)
3277ac9a364SKalle Valo  *     CCK all rates:     10 steps (5 dB)
3287ac9a364SKalle Valo  *
3297ac9a364SKalle Valo  *     Backoff values apply to saturation txpower on a per-transmitter basis;
3307ac9a364SKalle Valo  *     when using MIMO (2 transmitters), each transmitter uses the same
3317ac9a364SKalle Valo  *     saturation level provided in EEPROM, and the same backoff values;
3327ac9a364SKalle Valo  *     no reduction (such as with regulatory txpower limits) is required.
3337ac9a364SKalle Valo  *
3347ac9a364SKalle Valo  *     Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
3357ac9a364SKalle Valo  *     widths and 40 Mhz (.11n HT40) channel widths; there is no separate
3367ac9a364SKalle Valo  *     factory measurement for ht40 channels.
3377ac9a364SKalle Valo  *
3387ac9a364SKalle Valo  *     The result of this step is the final target txpower.  The rest of
3397ac9a364SKalle Valo  *     the steps figure out the proper settings for the device to achieve
3407ac9a364SKalle Valo  *     that target txpower.
3417ac9a364SKalle Valo  *
3427ac9a364SKalle Valo  *
3437ac9a364SKalle Valo  * 3)  Determine (EEPROM) calibration sub band for the target channel, by
3447ac9a364SKalle Valo  *     comparing against first and last channels in each sub band
3457ac9a364SKalle Valo  *     (see struct il4965_eeprom_calib_subband_info).
3467ac9a364SKalle Valo  *
3477ac9a364SKalle Valo  *
3487ac9a364SKalle Valo  * 4)  Linearly interpolate (EEPROM) factory calibration measurement sets,
3497ac9a364SKalle Valo  *     referencing the 2 factory-measured (sample) channels within the sub band.
3507ac9a364SKalle Valo  *
3517ac9a364SKalle Valo  *     Interpolation is based on difference between target channel's frequency
3527ac9a364SKalle Valo  *     and the sample channels' frequencies.  Since channel numbers are based
3537ac9a364SKalle Valo  *     on frequency (5 MHz between each channel number), this is equivalent
3547ac9a364SKalle Valo  *     to interpolating based on channel number differences.
3557ac9a364SKalle Valo  *
3567ac9a364SKalle Valo  *     Note that the sample channels may or may not be the channels at the
3577ac9a364SKalle Valo  *     edges of the sub band.  The target channel may be "outside" of the
3587ac9a364SKalle Valo  *     span of the sampled channels.
3597ac9a364SKalle Valo  *
3607ac9a364SKalle Valo  *     Driver may choose the pair (for 2 Tx chains) of measurements (see
3617ac9a364SKalle Valo  *     struct il4965_eeprom_calib_ch_info) for which the actual measured
3627ac9a364SKalle Valo  *     txpower comes closest to the desired txpower.  Usually, though,
3637ac9a364SKalle Valo  *     the middle set of measurements is closest to the regulatory limits,
3647ac9a364SKalle Valo  *     and is therefore a good choice for all txpower calculations (this
3657ac9a364SKalle Valo  *     assumes that high accuracy is needed for maximizing legal txpower,
3667ac9a364SKalle Valo  *     while lower txpower configurations do not need as much accuracy).
3677ac9a364SKalle Valo  *
3687ac9a364SKalle Valo  *     Driver should interpolate both members of the chosen measurement pair,
3697ac9a364SKalle Valo  *     i.e. for both Tx chains (radio transmitters), unless the driver knows
3707ac9a364SKalle Valo  *     that only one of the chains will be used (e.g. only one tx antenna
3717ac9a364SKalle Valo  *     connected, but this should be unusual).  The rate scaling algorithm
3727ac9a364SKalle Valo  *     switches antennas to find best performance, so both Tx chains will
3737ac9a364SKalle Valo  *     be used (although only one at a time) even for non-MIMO transmissions.
3747ac9a364SKalle Valo  *
3757ac9a364SKalle Valo  *     Driver should interpolate factory values for temperature, gain table
3767ac9a364SKalle Valo  *     idx, and actual power.  The power amplifier detector values are
3777ac9a364SKalle Valo  *     not used by the driver.
3787ac9a364SKalle Valo  *
3797ac9a364SKalle Valo  *     Sanity check:  If the target channel happens to be one of the sample
3807ac9a364SKalle Valo  *     channels, the results should agree with the sample channel's
3817ac9a364SKalle Valo  *     measurements!
3827ac9a364SKalle Valo  *
3837ac9a364SKalle Valo  *
3847ac9a364SKalle Valo  * 5)  Find difference between desired txpower and (interpolated)
3857ac9a364SKalle Valo  *     factory-measured txpower.  Using (interpolated) factory gain table idx
3867ac9a364SKalle Valo  *     (shown elsewhere) as a starting point, adjust this idx lower to
3877ac9a364SKalle Valo  *     increase txpower, or higher to decrease txpower, until the target
3887ac9a364SKalle Valo  *     txpower is reached.  Each step in the gain table is 1/2 dB.
3897ac9a364SKalle Valo  *
3907ac9a364SKalle Valo  *     For example, if factory measured txpower is 16 dBm, and target txpower
3917ac9a364SKalle Valo  *     is 13 dBm, add 6 steps to the factory gain idx to reduce txpower
3927ac9a364SKalle Valo  *     by 3 dB.
3937ac9a364SKalle Valo  *
3947ac9a364SKalle Valo  *
3957ac9a364SKalle Valo  * 6)  Find difference between current device temperature and (interpolated)
3967ac9a364SKalle Valo  *     factory-measured temperature for sub-band.  Factory values are in
3977ac9a364SKalle Valo  *     degrees Celsius.  To calculate current temperature, see comments for
3987ac9a364SKalle Valo  *     "4965 temperature calculation".
3997ac9a364SKalle Valo  *
4007ac9a364SKalle Valo  *     If current temperature is higher than factory temperature, driver must
4017ac9a364SKalle Valo  *     increase gain (lower gain table idx), and vice verse.
4027ac9a364SKalle Valo  *
4037ac9a364SKalle Valo  *     Temperature affects gain differently for different channels:
4047ac9a364SKalle Valo  *
4057ac9a364SKalle Valo  *     2.4 GHz all channels:  3.5 degrees per half-dB step
4067ac9a364SKalle Valo  *     5 GHz channels 34-43:  4.5 degrees per half-dB step
4077ac9a364SKalle Valo  *     5 GHz channels >= 44:  4.0 degrees per half-dB step
4087ac9a364SKalle Valo  *
4097ac9a364SKalle Valo  *     NOTE:  Temperature can increase rapidly when transmitting, especially
4107ac9a364SKalle Valo  *            with heavy traffic at high txpowers.  Driver should update
4117ac9a364SKalle Valo  *            temperature calculations often under these conditions to
4127ac9a364SKalle Valo  *            maintain strong txpower in the face of rising temperature.
4137ac9a364SKalle Valo  *
4147ac9a364SKalle Valo  *
4157ac9a364SKalle Valo  * 7)  Find difference between current power supply voltage indicator
4167ac9a364SKalle Valo  *     (from "initialize alive") and factory-measured power supply voltage
4177ac9a364SKalle Valo  *     indicator (EEPROM).
4187ac9a364SKalle Valo  *
4197ac9a364SKalle Valo  *     If the current voltage is higher (indicator is lower) than factory
4207ac9a364SKalle Valo  *     voltage, gain should be reduced (gain table idx increased) by:
4217ac9a364SKalle Valo  *
4227ac9a364SKalle Valo  *     (eeprom - current) / 7
4237ac9a364SKalle Valo  *
4247ac9a364SKalle Valo  *     If the current voltage is lower (indicator is higher) than factory
4257ac9a364SKalle Valo  *     voltage, gain should be increased (gain table idx decreased) by:
4267ac9a364SKalle Valo  *
4277ac9a364SKalle Valo  *     2 * (current - eeprom) / 7
4287ac9a364SKalle Valo  *
4297ac9a364SKalle Valo  *     If number of idx steps in either direction turns out to be > 2,
4307ac9a364SKalle Valo  *     something is wrong ... just use 0.
4317ac9a364SKalle Valo  *
4327ac9a364SKalle Valo  *     NOTE:  Voltage compensation is independent of band/channel.
4337ac9a364SKalle Valo  *
4347ac9a364SKalle Valo  *     NOTE:  "Initialize" uCode measures current voltage, which is assumed
4357ac9a364SKalle Valo  *            to be constant after this initial measurement.  Voltage
4367ac9a364SKalle Valo  *            compensation for txpower (number of steps in gain table)
4377ac9a364SKalle Valo  *            may be calculated once and used until the next uCode bootload.
4387ac9a364SKalle Valo  *
4397ac9a364SKalle Valo  *
4407ac9a364SKalle Valo  * 8)  If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
4417ac9a364SKalle Valo  *     adjust txpower for each transmitter chain, so txpower is balanced
4427ac9a364SKalle Valo  *     between the two chains.  There are 5 pairs of tx_atten[group][chain]
4437ac9a364SKalle Valo  *     values in "initialize alive", one pair for each of 5 channel ranges:
4447ac9a364SKalle Valo  *
4457ac9a364SKalle Valo  *     Group 0:  5 GHz channel 34-43
4467ac9a364SKalle Valo  *     Group 1:  5 GHz channel 44-70
4477ac9a364SKalle Valo  *     Group 2:  5 GHz channel 71-124
4487ac9a364SKalle Valo  *     Group 3:  5 GHz channel 125-200
4497ac9a364SKalle Valo  *     Group 4:  2.4 GHz all channels
4507ac9a364SKalle Valo  *
4517ac9a364SKalle Valo  *     Add the tx_atten[group][chain] value to the idx for the target chain.
4527ac9a364SKalle Valo  *     The values are signed, but are in pairs of 0 and a non-negative number,
4537ac9a364SKalle Valo  *     so as to reduce gain (if necessary) of the "hotter" channel.  This
4547ac9a364SKalle Valo  *     avoids any need to double-check for regulatory compliance after
4557ac9a364SKalle Valo  *     this step.
4567ac9a364SKalle Valo  *
4577ac9a364SKalle Valo  *
4587ac9a364SKalle Valo  * 9)  If setting up for a CCK rate, lower the gain by adding a CCK compensation
4597ac9a364SKalle Valo  *     value to the idx:
4607ac9a364SKalle Valo  *
4617ac9a364SKalle Valo  *     Hardware rev B:  9 steps (4.5 dB)
4627ac9a364SKalle Valo  *     Hardware rev C:  5 steps (2.5 dB)
4637ac9a364SKalle Valo  *
4647ac9a364SKalle Valo  *     Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
4657ac9a364SKalle Valo  *     bits [3:2], 1 = B, 2 = C.
4667ac9a364SKalle Valo  *
4677ac9a364SKalle Valo  *     NOTE:  This compensation is in addition to any saturation backoff that
4687ac9a364SKalle Valo  *            might have been applied in an earlier step.
4697ac9a364SKalle Valo  *
4707ac9a364SKalle Valo  *
4717ac9a364SKalle Valo  * 10) Select the gain table, based on band (2.4 vs 5 GHz).
4727ac9a364SKalle Valo  *
4737ac9a364SKalle Valo  *     Limit the adjusted idx to stay within the table!
4747ac9a364SKalle Valo  *
4757ac9a364SKalle Valo  *
4767ac9a364SKalle Valo  * 11) Read gain table entries for DSP and radio gain, place into appropriate
4777ac9a364SKalle Valo  *     location(s) in command (struct il4965_txpowertable_cmd).
4787ac9a364SKalle Valo  */
4797ac9a364SKalle Valo 
4807ac9a364SKalle Valo /**
4817ac9a364SKalle Valo  * When MIMO is used (2 transmitters operating simultaneously), driver should
4827ac9a364SKalle Valo  * limit each transmitter to deliver a max of 3 dB below the regulatory limit
4837ac9a364SKalle Valo  * for the device.  That is, use half power for each transmitter, so total
4847ac9a364SKalle Valo  * txpower is within regulatory limits.
4857ac9a364SKalle Valo  *
4867ac9a364SKalle Valo  * The value "6" represents number of steps in gain table to reduce power 3 dB.
4877ac9a364SKalle Valo  * Each step is 1/2 dB.
4887ac9a364SKalle Valo  */
4897ac9a364SKalle Valo #define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
4907ac9a364SKalle Valo 
4917ac9a364SKalle Valo /**
4927ac9a364SKalle Valo  * CCK gain compensation.
4937ac9a364SKalle Valo  *
4947ac9a364SKalle Valo  * When calculating txpowers for CCK, after making sure that the target power
4957ac9a364SKalle Valo  * is within regulatory and saturation limits, driver must additionally
4967ac9a364SKalle Valo  * back off gain by adding these values to the gain table idx.
4977ac9a364SKalle Valo  *
4987ac9a364SKalle Valo  * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
4997ac9a364SKalle Valo  * bits [3:2], 1 = B, 2 = C.
5007ac9a364SKalle Valo  */
5017ac9a364SKalle Valo #define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
5027ac9a364SKalle Valo #define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
5037ac9a364SKalle Valo 
5047ac9a364SKalle Valo /*
5057ac9a364SKalle Valo  * 4965 power supply voltage compensation for txpower
5067ac9a364SKalle Valo  */
5077ac9a364SKalle Valo #define TX_POWER_IL_VOLTAGE_CODES_PER_03V   (7)
5087ac9a364SKalle Valo 
5097ac9a364SKalle Valo /**
5107ac9a364SKalle Valo  * Gain tables.
5117ac9a364SKalle Valo  *
5127ac9a364SKalle Valo  * The following tables contain pair of values for setting txpower, i.e.
5137ac9a364SKalle Valo  * gain settings for the output of the device's digital signal processor (DSP),
5147ac9a364SKalle Valo  * and for the analog gain structure of the transmitter.
5157ac9a364SKalle Valo  *
5167ac9a364SKalle Valo  * Each entry in the gain tables represents a step of 1/2 dB.  Note that these
5177ac9a364SKalle Valo  * are *relative* steps, not indications of absolute output power.  Output
5187ac9a364SKalle Valo  * power varies with temperature, voltage, and channel frequency, and also
5197ac9a364SKalle Valo  * requires consideration of average power (to satisfy regulatory constraints),
5207ac9a364SKalle Valo  * and peak power (to avoid distortion of the output signal).
5217ac9a364SKalle Valo  *
5227ac9a364SKalle Valo  * Each entry contains two values:
5237ac9a364SKalle Valo  * 1)  DSP gain (or sometimes called DSP attenuation).  This is a fine-grained
5247ac9a364SKalle Valo  *     linear value that multiplies the output of the digital signal processor,
5257ac9a364SKalle Valo  *     before being sent to the analog radio.
5267ac9a364SKalle Valo  * 2)  Radio gain.  This sets the analog gain of the radio Tx path.
5277ac9a364SKalle Valo  *     It is a coarser setting, and behaves in a logarithmic (dB) fashion.
5287ac9a364SKalle Valo  *
5297ac9a364SKalle Valo  * EEPROM contains factory calibration data for txpower.  This maps actual
5307ac9a364SKalle Valo  * measured txpower levels to gain settings in the "well known" tables
5317ac9a364SKalle Valo  * below ("well-known" means here that both factory calibration *and* the
5327ac9a364SKalle Valo  * driver work with the same table).
5337ac9a364SKalle Valo  *
5347ac9a364SKalle Valo  * There are separate tables for 2.4 GHz and 5 GHz bands.  The 5 GHz table
5357ac9a364SKalle Valo  * has an extension (into negative idxes), in case the driver needs to
5367ac9a364SKalle Valo  * boost power setting for high device temperatures (higher than would be
5377ac9a364SKalle Valo  * present during factory calibration).  A 5 Ghz EEPROM idx of "40"
5387ac9a364SKalle Valo  * corresponds to the 49th entry in the table used by the driver.
5397ac9a364SKalle Valo  */
5407ac9a364SKalle Valo #define MIN_TX_GAIN_IDX		(0)	/* highest gain, lowest idx, 2.4 */
5417ac9a364SKalle Valo #define MIN_TX_GAIN_IDX_52GHZ_EXT	(-9)	/* highest gain, lowest idx, 5 */
5427ac9a364SKalle Valo 
5437ac9a364SKalle Valo /**
5447ac9a364SKalle Valo  * 2.4 GHz gain table
5457ac9a364SKalle Valo  *
5467ac9a364SKalle Valo  * Index    Dsp gain   Radio gain
5477ac9a364SKalle Valo  *   0        110         0x3f      (highest gain)
5487ac9a364SKalle Valo  *   1        104         0x3f
5497ac9a364SKalle Valo  *   2         98         0x3f
5507ac9a364SKalle Valo  *   3        110         0x3e
5517ac9a364SKalle Valo  *   4        104         0x3e
5527ac9a364SKalle Valo  *   5         98         0x3e
5537ac9a364SKalle Valo  *   6        110         0x3d
5547ac9a364SKalle Valo  *   7        104         0x3d
5557ac9a364SKalle Valo  *   8         98         0x3d
5567ac9a364SKalle Valo  *   9        110         0x3c
5577ac9a364SKalle Valo  *  10        104         0x3c
5587ac9a364SKalle Valo  *  11         98         0x3c
5597ac9a364SKalle Valo  *  12        110         0x3b
5607ac9a364SKalle Valo  *  13        104         0x3b
5617ac9a364SKalle Valo  *  14         98         0x3b
5627ac9a364SKalle Valo  *  15        110         0x3a
5637ac9a364SKalle Valo  *  16        104         0x3a
5647ac9a364SKalle Valo  *  17         98         0x3a
5657ac9a364SKalle Valo  *  18        110         0x39
5667ac9a364SKalle Valo  *  19        104         0x39
5677ac9a364SKalle Valo  *  20         98         0x39
5687ac9a364SKalle Valo  *  21        110         0x38
5697ac9a364SKalle Valo  *  22        104         0x38
5707ac9a364SKalle Valo  *  23         98         0x38
5717ac9a364SKalle Valo  *  24        110         0x37
5727ac9a364SKalle Valo  *  25        104         0x37
5737ac9a364SKalle Valo  *  26         98         0x37
5747ac9a364SKalle Valo  *  27        110         0x36
5757ac9a364SKalle Valo  *  28        104         0x36
5767ac9a364SKalle Valo  *  29         98         0x36
5777ac9a364SKalle Valo  *  30        110         0x35
5787ac9a364SKalle Valo  *  31        104         0x35
5797ac9a364SKalle Valo  *  32         98         0x35
5807ac9a364SKalle Valo  *  33        110         0x34
5817ac9a364SKalle Valo  *  34        104         0x34
5827ac9a364SKalle Valo  *  35         98         0x34
5837ac9a364SKalle Valo  *  36        110         0x33
5847ac9a364SKalle Valo  *  37        104         0x33
5857ac9a364SKalle Valo  *  38         98         0x33
5867ac9a364SKalle Valo  *  39        110         0x32
5877ac9a364SKalle Valo  *  40        104         0x32
5887ac9a364SKalle Valo  *  41         98         0x32
5897ac9a364SKalle Valo  *  42        110         0x31
5907ac9a364SKalle Valo  *  43        104         0x31
5917ac9a364SKalle Valo  *  44         98         0x31
5927ac9a364SKalle Valo  *  45        110         0x30
5937ac9a364SKalle Valo  *  46        104         0x30
5947ac9a364SKalle Valo  *  47         98         0x30
5957ac9a364SKalle Valo  *  48        110          0x6
5967ac9a364SKalle Valo  *  49        104          0x6
5977ac9a364SKalle Valo  *  50         98          0x6
5987ac9a364SKalle Valo  *  51        110          0x5
5997ac9a364SKalle Valo  *  52        104          0x5
6007ac9a364SKalle Valo  *  53         98          0x5
6017ac9a364SKalle Valo  *  54        110          0x4
6027ac9a364SKalle Valo  *  55        104          0x4
6037ac9a364SKalle Valo  *  56         98          0x4
6047ac9a364SKalle Valo  *  57        110          0x3
6057ac9a364SKalle Valo  *  58        104          0x3
6067ac9a364SKalle Valo  *  59         98          0x3
6077ac9a364SKalle Valo  *  60        110          0x2
6087ac9a364SKalle Valo  *  61        104          0x2
6097ac9a364SKalle Valo  *  62         98          0x2
6107ac9a364SKalle Valo  *  63        110          0x1
6117ac9a364SKalle Valo  *  64        104          0x1
6127ac9a364SKalle Valo  *  65         98          0x1
6137ac9a364SKalle Valo  *  66        110          0x0
6147ac9a364SKalle Valo  *  67        104          0x0
6157ac9a364SKalle Valo  *  68         98          0x0
6167ac9a364SKalle Valo  *  69         97            0
6177ac9a364SKalle Valo  *  70         96            0
6187ac9a364SKalle Valo  *  71         95            0
6197ac9a364SKalle Valo  *  72         94            0
6207ac9a364SKalle Valo  *  73         93            0
6217ac9a364SKalle Valo  *  74         92            0
6227ac9a364SKalle Valo  *  75         91            0
6237ac9a364SKalle Valo  *  76         90            0
6247ac9a364SKalle Valo  *  77         89            0
6257ac9a364SKalle Valo  *  78         88            0
6267ac9a364SKalle Valo  *  79         87            0
6277ac9a364SKalle Valo  *  80         86            0
6287ac9a364SKalle Valo  *  81         85            0
6297ac9a364SKalle Valo  *  82         84            0
6307ac9a364SKalle Valo  *  83         83            0
6317ac9a364SKalle Valo  *  84         82            0
6327ac9a364SKalle Valo  *  85         81            0
6337ac9a364SKalle Valo  *  86         80            0
6347ac9a364SKalle Valo  *  87         79            0
6357ac9a364SKalle Valo  *  88         78            0
6367ac9a364SKalle Valo  *  89         77            0
6377ac9a364SKalle Valo  *  90         76            0
6387ac9a364SKalle Valo  *  91         75            0
6397ac9a364SKalle Valo  *  92         74            0
6407ac9a364SKalle Valo  *  93         73            0
6417ac9a364SKalle Valo  *  94         72            0
6427ac9a364SKalle Valo  *  95         71            0
6437ac9a364SKalle Valo  *  96         70            0
6447ac9a364SKalle Valo  *  97         69            0
6457ac9a364SKalle Valo  *  98         68            0
6467ac9a364SKalle Valo  */
6477ac9a364SKalle Valo 
6487ac9a364SKalle Valo /**
6497ac9a364SKalle Valo  * 5 GHz gain table
6507ac9a364SKalle Valo  *
6517ac9a364SKalle Valo  * Index    Dsp gain   Radio gain
6527ac9a364SKalle Valo  *  -9 	      123         0x3F      (highest gain)
6537ac9a364SKalle Valo  *  -8 	      117         0x3F
6547ac9a364SKalle Valo  *  -7        110         0x3F
6557ac9a364SKalle Valo  *  -6        104         0x3F
6567ac9a364SKalle Valo  *  -5         98         0x3F
6577ac9a364SKalle Valo  *  -4        110         0x3E
6587ac9a364SKalle Valo  *  -3        104         0x3E
6597ac9a364SKalle Valo  *  -2         98         0x3E
6607ac9a364SKalle Valo  *  -1        110         0x3D
6617ac9a364SKalle Valo  *   0        104         0x3D
6627ac9a364SKalle Valo  *   1         98         0x3D
6637ac9a364SKalle Valo  *   2        110         0x3C
6647ac9a364SKalle Valo  *   3        104         0x3C
6657ac9a364SKalle Valo  *   4         98         0x3C
6667ac9a364SKalle Valo  *   5        110         0x3B
6677ac9a364SKalle Valo  *   6        104         0x3B
6687ac9a364SKalle Valo  *   7         98         0x3B
6697ac9a364SKalle Valo  *   8        110         0x3A
6707ac9a364SKalle Valo  *   9        104         0x3A
6717ac9a364SKalle Valo  *  10         98         0x3A
6727ac9a364SKalle Valo  *  11        110         0x39
6737ac9a364SKalle Valo  *  12        104         0x39
6747ac9a364SKalle Valo  *  13         98         0x39
6757ac9a364SKalle Valo  *  14        110         0x38
6767ac9a364SKalle Valo  *  15        104         0x38
6777ac9a364SKalle Valo  *  16         98         0x38
6787ac9a364SKalle Valo  *  17        110         0x37
6797ac9a364SKalle Valo  *  18        104         0x37
6807ac9a364SKalle Valo  *  19         98         0x37
6817ac9a364SKalle Valo  *  20        110         0x36
6827ac9a364SKalle Valo  *  21        104         0x36
6837ac9a364SKalle Valo  *  22         98         0x36
6847ac9a364SKalle Valo  *  23        110         0x35
6857ac9a364SKalle Valo  *  24        104         0x35
6867ac9a364SKalle Valo  *  25         98         0x35
6877ac9a364SKalle Valo  *  26        110         0x34
6887ac9a364SKalle Valo  *  27        104         0x34
6897ac9a364SKalle Valo  *  28         98         0x34
6907ac9a364SKalle Valo  *  29        110         0x33
6917ac9a364SKalle Valo  *  30        104         0x33
6927ac9a364SKalle Valo  *  31         98         0x33
6937ac9a364SKalle Valo  *  32        110         0x32
6947ac9a364SKalle Valo  *  33        104         0x32
6957ac9a364SKalle Valo  *  34         98         0x32
6967ac9a364SKalle Valo  *  35        110         0x31
6977ac9a364SKalle Valo  *  36        104         0x31
6987ac9a364SKalle Valo  *  37         98         0x31
6997ac9a364SKalle Valo  *  38        110         0x30
7007ac9a364SKalle Valo  *  39        104         0x30
7017ac9a364SKalle Valo  *  40         98         0x30
7027ac9a364SKalle Valo  *  41        110         0x25
7037ac9a364SKalle Valo  *  42        104         0x25
7047ac9a364SKalle Valo  *  43         98         0x25
7057ac9a364SKalle Valo  *  44        110         0x24
7067ac9a364SKalle Valo  *  45        104         0x24
7077ac9a364SKalle Valo  *  46         98         0x24
7087ac9a364SKalle Valo  *  47        110         0x23
7097ac9a364SKalle Valo  *  48        104         0x23
7107ac9a364SKalle Valo  *  49         98         0x23
7117ac9a364SKalle Valo  *  50        110         0x22
7127ac9a364SKalle Valo  *  51        104         0x18
7137ac9a364SKalle Valo  *  52         98         0x18
7147ac9a364SKalle Valo  *  53        110         0x17
7157ac9a364SKalle Valo  *  54        104         0x17
7167ac9a364SKalle Valo  *  55         98         0x17
7177ac9a364SKalle Valo  *  56        110         0x16
7187ac9a364SKalle Valo  *  57        104         0x16
7197ac9a364SKalle Valo  *  58         98         0x16
7207ac9a364SKalle Valo  *  59        110         0x15
7217ac9a364SKalle Valo  *  60        104         0x15
7227ac9a364SKalle Valo  *  61         98         0x15
7237ac9a364SKalle Valo  *  62        110         0x14
7247ac9a364SKalle Valo  *  63        104         0x14
7257ac9a364SKalle Valo  *  64         98         0x14
7267ac9a364SKalle Valo  *  65        110         0x13
7277ac9a364SKalle Valo  *  66        104         0x13
7287ac9a364SKalle Valo  *  67         98         0x13
7297ac9a364SKalle Valo  *  68        110         0x12
7307ac9a364SKalle Valo  *  69        104         0x08
7317ac9a364SKalle Valo  *  70         98         0x08
7327ac9a364SKalle Valo  *  71        110         0x07
7337ac9a364SKalle Valo  *  72        104         0x07
7347ac9a364SKalle Valo  *  73         98         0x07
7357ac9a364SKalle Valo  *  74        110         0x06
7367ac9a364SKalle Valo  *  75        104         0x06
7377ac9a364SKalle Valo  *  76         98         0x06
7387ac9a364SKalle Valo  *  77        110         0x05
7397ac9a364SKalle Valo  *  78        104         0x05
7407ac9a364SKalle Valo  *  79         98         0x05
7417ac9a364SKalle Valo  *  80        110         0x04
7427ac9a364SKalle Valo  *  81        104         0x04
7437ac9a364SKalle Valo  *  82         98         0x04
7447ac9a364SKalle Valo  *  83        110         0x03
7457ac9a364SKalle Valo  *  84        104         0x03
7467ac9a364SKalle Valo  *  85         98         0x03
7477ac9a364SKalle Valo  *  86        110         0x02
7487ac9a364SKalle Valo  *  87        104         0x02
7497ac9a364SKalle Valo  *  88         98         0x02
7507ac9a364SKalle Valo  *  89        110         0x01
7517ac9a364SKalle Valo  *  90        104         0x01
7527ac9a364SKalle Valo  *  91         98         0x01
7537ac9a364SKalle Valo  *  92        110         0x00
7547ac9a364SKalle Valo  *  93        104         0x00
7557ac9a364SKalle Valo  *  94         98         0x00
7567ac9a364SKalle Valo  *  95         93         0x00
7577ac9a364SKalle Valo  *  96         88         0x00
7587ac9a364SKalle Valo  *  97         83         0x00
7597ac9a364SKalle Valo  *  98         78         0x00
7607ac9a364SKalle Valo  */
7617ac9a364SKalle Valo 
7627ac9a364SKalle Valo /**
7637ac9a364SKalle Valo  * Sanity checks and default values for EEPROM regulatory levels.
7647ac9a364SKalle Valo  * If EEPROM values fall outside MIN/MAX range, use default values.
7657ac9a364SKalle Valo  *
7667ac9a364SKalle Valo  * Regulatory limits refer to the maximum average txpower allowed by
7677ac9a364SKalle Valo  * regulatory agencies in the geographies in which the device is meant
7687ac9a364SKalle Valo  * to be operated.  These limits are SKU-specific (i.e. geography-specific),
7697ac9a364SKalle Valo  * and channel-specific; each channel has an individual regulatory limit
7707ac9a364SKalle Valo  * listed in the EEPROM.
7717ac9a364SKalle Valo  *
7727ac9a364SKalle Valo  * Units are in half-dBm (i.e. "34" means 17 dBm).
7737ac9a364SKalle Valo  */
7747ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_REGULATORY_24   (34)
7757ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_REGULATORY_52   (34)
7767ac9a364SKalle Valo #define IL_TX_POWER_REGULATORY_MIN          (0)
7777ac9a364SKalle Valo #define IL_TX_POWER_REGULATORY_MAX          (34)
7787ac9a364SKalle Valo 
7797ac9a364SKalle Valo /**
7807ac9a364SKalle Valo  * Sanity checks and default values for EEPROM saturation levels.
7817ac9a364SKalle Valo  * If EEPROM values fall outside MIN/MAX range, use default values.
7827ac9a364SKalle Valo  *
7837ac9a364SKalle Valo  * Saturation is the highest level that the output power amplifier can produce
7847ac9a364SKalle Valo  * without significant clipping distortion.  This is a "peak" power level.
7857ac9a364SKalle Valo  * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
7867ac9a364SKalle Valo  * require differing amounts of backoff, relative to their average power output,
7877ac9a364SKalle Valo  * in order to avoid clipping distortion.
7887ac9a364SKalle Valo  *
7897ac9a364SKalle Valo  * Driver must make sure that it is violating neither the saturation limit,
7907ac9a364SKalle Valo  * nor the regulatory limit, when calculating Tx power settings for various
7917ac9a364SKalle Valo  * rates.
7927ac9a364SKalle Valo  *
7937ac9a364SKalle Valo  * Units are in half-dBm (i.e. "38" means 19 dBm).
7947ac9a364SKalle Valo  */
7957ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_SATURATION_24   (38)
7967ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_SATURATION_52   (38)
7977ac9a364SKalle Valo #define IL_TX_POWER_SATURATION_MIN          (20)
7987ac9a364SKalle Valo #define IL_TX_POWER_SATURATION_MAX          (50)
7997ac9a364SKalle Valo 
8007ac9a364SKalle Valo /**
8017ac9a364SKalle Valo  * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
8027ac9a364SKalle Valo  * and thermal Txpower calibration.
8037ac9a364SKalle Valo  *
8047ac9a364SKalle Valo  * When calculating txpower, driver must compensate for current device
8057ac9a364SKalle Valo  * temperature; higher temperature requires higher gain.  Driver must calculate
8067ac9a364SKalle Valo  * current temperature (see "4965 temperature calculation"), then compare vs.
8077ac9a364SKalle Valo  * factory calibration temperature in EEPROM; if current temperature is higher
8087ac9a364SKalle Valo  * than factory temperature, driver must *increase* gain by proportions shown
8097ac9a364SKalle Valo  * in table below.  If current temperature is lower than factory, driver must
8107ac9a364SKalle Valo  * *decrease* gain.
8117ac9a364SKalle Valo  *
8127ac9a364SKalle Valo  * Different frequency ranges require different compensation, as shown below.
8137ac9a364SKalle Valo  */
8147ac9a364SKalle Valo /* Group 0, 5.2 GHz ch 34-43:  4.5 degrees per 1/2 dB. */
8157ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR1_FCH 34
8167ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR1_LCH 43
8177ac9a364SKalle Valo 
8187ac9a364SKalle Valo /* Group 1, 5.3 GHz ch 44-70:  4.0 degrees per 1/2 dB. */
8197ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR2_FCH 44
8207ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR2_LCH 70
8217ac9a364SKalle Valo 
8227ac9a364SKalle Valo /* Group 2, 5.5 GHz ch 71-124:  4.0 degrees per 1/2 dB. */
8237ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR3_FCH 71
8247ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR3_LCH 124
8257ac9a364SKalle Valo 
8267ac9a364SKalle Valo /* Group 3, 5.7 GHz ch 125-200:  4.0 degrees per 1/2 dB. */
8277ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR4_FCH 125
8287ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR4_LCH 200
8297ac9a364SKalle Valo 
8307ac9a364SKalle Valo /* Group 4, 2.4 GHz all channels:  3.5 degrees per 1/2 dB. */
8317ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR5_FCH 1
8327ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR5_LCH 20
8337ac9a364SKalle Valo 
8347ac9a364SKalle Valo enum {
8357ac9a364SKalle Valo 	CALIB_CH_GROUP_1 = 0,
8367ac9a364SKalle Valo 	CALIB_CH_GROUP_2 = 1,
8377ac9a364SKalle Valo 	CALIB_CH_GROUP_3 = 2,
8387ac9a364SKalle Valo 	CALIB_CH_GROUP_4 = 3,
8397ac9a364SKalle Valo 	CALIB_CH_GROUP_5 = 4,
8407ac9a364SKalle Valo 	CALIB_CH_GROUP_MAX
8417ac9a364SKalle Valo };
8427ac9a364SKalle Valo 
8437ac9a364SKalle Valo /********************* END TXPOWER *****************************************/
8447ac9a364SKalle Valo 
8457ac9a364SKalle Valo /**
8467ac9a364SKalle Valo  * Tx/Rx Queues
8477ac9a364SKalle Valo  *
8487ac9a364SKalle Valo  * Most communication between driver and 4965 is via queues of data buffers.
8497ac9a364SKalle Valo  * For example, all commands that the driver issues to device's embedded
8507ac9a364SKalle Valo  * controller (uCode) are via the command queue (one of the Tx queues).  All
8517ac9a364SKalle Valo  * uCode command responses/replies/notifications, including Rx frames, are
8527ac9a364SKalle Valo  * conveyed from uCode to driver via the Rx queue.
8537ac9a364SKalle Valo  *
8547ac9a364SKalle Valo  * Most support for these queues, including handshake support, resides in
8557ac9a364SKalle Valo  * structures in host DRAM, shared between the driver and the device.  When
8567ac9a364SKalle Valo  * allocating this memory, the driver must make sure that data written by
8577ac9a364SKalle Valo  * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
8587ac9a364SKalle Valo  * cache memory), so DRAM and cache are consistent, and the device can
8597ac9a364SKalle Valo  * immediately see changes made by the driver.
8607ac9a364SKalle Valo  *
8617ac9a364SKalle Valo  * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via
8627ac9a364SKalle Valo  * up to 7 DMA channels (FIFOs).  Each Tx queue is supported by a circular array
8637ac9a364SKalle Valo  * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
8647ac9a364SKalle Valo  */
8657ac9a364SKalle Valo #define IL49_NUM_FIFOS	7
8667ac9a364SKalle Valo #define IL49_CMD_FIFO_NUM	4
8677ac9a364SKalle Valo #define IL49_NUM_QUEUES	16
8687ac9a364SKalle Valo #define IL49_NUM_AMPDU_QUEUES	8
8697ac9a364SKalle Valo 
8707ac9a364SKalle Valo /**
8717ac9a364SKalle Valo  * struct il4965_schedq_bc_tbl
8727ac9a364SKalle Valo  *
8737ac9a364SKalle Valo  * Byte Count table
8747ac9a364SKalle Valo  *
8757ac9a364SKalle Valo  * Each Tx queue uses a byte-count table containing 320 entries:
8767ac9a364SKalle Valo  * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
8777ac9a364SKalle Valo  * duplicate the first 64 entries (to avoid wrap-around within a Tx win;
8787ac9a364SKalle Valo  * max Tx win is 64 TFDs).
8797ac9a364SKalle Valo  *
8807ac9a364SKalle Valo  * When driver sets up a new TFD, it must also enter the total byte count
8817ac9a364SKalle Valo  * of the frame to be transmitted into the corresponding entry in the byte
8827ac9a364SKalle Valo  * count table for the chosen Tx queue.  If the TFD idx is 0-63, the driver
8837ac9a364SKalle Valo  * must duplicate the byte count entry in corresponding idx 256-319.
8847ac9a364SKalle Valo  *
8857ac9a364SKalle Valo  * padding puts each byte count table on a 1024-byte boundary;
8867ac9a364SKalle Valo  * 4965 assumes tables are separated by 1024 bytes.
8877ac9a364SKalle Valo  */
8887ac9a364SKalle Valo struct il4965_scd_bc_tbl {
8897ac9a364SKalle Valo 	__le16 tfd_offset[TFD_QUEUE_BC_SIZE];
8907ac9a364SKalle Valo 	u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
8917ac9a364SKalle Valo } __packed;
8927ac9a364SKalle Valo 
8937ac9a364SKalle Valo #define IL4965_RTC_INST_LOWER_BOUND		(0x000000)
8947ac9a364SKalle Valo 
8957ac9a364SKalle Valo /* RSSI to dBm */
8967ac9a364SKalle Valo #define IL4965_RSSI_OFFSET	44
8977ac9a364SKalle Valo 
8987ac9a364SKalle Valo /* PCI registers */
8997ac9a364SKalle Valo #define PCI_CFG_RETRY_TIMEOUT	0x041
9007ac9a364SKalle Valo 
9017ac9a364SKalle Valo #define IL4965_DEFAULT_TX_RETRY  15
9027ac9a364SKalle Valo 
9037ac9a364SKalle Valo /* EEPROM */
9047ac9a364SKalle Valo #define IL4965_FIRST_AMPDU_QUEUE	10
9057ac9a364SKalle Valo 
9067ac9a364SKalle Valo /* Calibration */
9077ac9a364SKalle Valo void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
9087ac9a364SKalle Valo void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
9097ac9a364SKalle Valo void il4965_init_sensitivity(struct il_priv *il);
9107ac9a364SKalle Valo void il4965_reset_run_time_calib(struct il_priv *il);
9117ac9a364SKalle Valo 
9127ac9a364SKalle Valo /* Debug */
9137ac9a364SKalle Valo #ifdef CONFIG_IWLEGACY_DEBUGFS
9147ac9a364SKalle Valo extern const struct il_debugfs_ops il4965_debugfs_ops;
9157ac9a364SKalle Valo #endif
9167ac9a364SKalle Valo 
9177ac9a364SKalle Valo /****************************/
9187ac9a364SKalle Valo /* Flow Handler Definitions */
9197ac9a364SKalle Valo /****************************/
9207ac9a364SKalle Valo 
9217ac9a364SKalle Valo /**
9227ac9a364SKalle Valo  * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
9237ac9a364SKalle Valo  * Addresses are offsets from device's PCI hardware base address.
9247ac9a364SKalle Valo  */
9257ac9a364SKalle Valo #define FH49_MEM_LOWER_BOUND                   (0x1000)
9267ac9a364SKalle Valo #define FH49_MEM_UPPER_BOUND                   (0x2000)
9277ac9a364SKalle Valo 
9287ac9a364SKalle Valo /**
9297ac9a364SKalle Valo  * Keep-Warm (KW) buffer base address.
9307ac9a364SKalle Valo  *
9317ac9a364SKalle Valo  * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
9327ac9a364SKalle Valo  * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
9337ac9a364SKalle Valo  * DRAM access when 4965 is Txing or Rxing.  The dummy accesses prevent host
9347ac9a364SKalle Valo  * from going into a power-savings mode that would cause higher DRAM latency,
9357ac9a364SKalle Valo  * and possible data over/under-runs, before all Tx/Rx is complete.
9367ac9a364SKalle Valo  *
9377ac9a364SKalle Valo  * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4)
9387ac9a364SKalle Valo  * of the buffer, which must be 4K aligned.  Once this is set up, the 4965
9397ac9a364SKalle Valo  * automatically invokes keep-warm accesses when normal accesses might not
9407ac9a364SKalle Valo  * be sufficient to maintain fast DRAM response.
9417ac9a364SKalle Valo  *
9427ac9a364SKalle Valo  * Bit fields:
9437ac9a364SKalle Valo  *  31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
9447ac9a364SKalle Valo  */
9457ac9a364SKalle Valo #define FH49_KW_MEM_ADDR_REG		     (FH49_MEM_LOWER_BOUND + 0x97C)
9467ac9a364SKalle Valo 
9477ac9a364SKalle Valo /**
9487ac9a364SKalle Valo  * TFD Circular Buffers Base (CBBC) addresses
9497ac9a364SKalle Valo  *
9507ac9a364SKalle Valo  * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
9517ac9a364SKalle Valo  * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
9527ac9a364SKalle Valo  * (see struct il_tfd_frame).  These 16 pointer registers are offset by 0x04
9537ac9a364SKalle Valo  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
9547ac9a364SKalle Valo  * aligned (address bits 0-7 must be 0).
9557ac9a364SKalle Valo  *
9567ac9a364SKalle Valo  * Bit fields in each pointer register:
9577ac9a364SKalle Valo  *  27-0: TFD CB physical base address [35:8], must be 256-byte aligned
9587ac9a364SKalle Valo  */
9597ac9a364SKalle Valo #define FH49_MEM_CBBC_LOWER_BOUND          (FH49_MEM_LOWER_BOUND + 0x9D0)
9607ac9a364SKalle Valo #define FH49_MEM_CBBC_UPPER_BOUND          (FH49_MEM_LOWER_BOUND + 0xA10)
9617ac9a364SKalle Valo 
9627ac9a364SKalle Valo /* Find TFD CB base pointer for given queue (range 0-15). */
9637ac9a364SKalle Valo #define FH49_MEM_CBBC_QUEUE(x)  (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
9647ac9a364SKalle Valo 
9657ac9a364SKalle Valo /**
9667ac9a364SKalle Valo  * Rx SRAM Control and Status Registers (RSCSR)
9677ac9a364SKalle Valo  *
9687ac9a364SKalle Valo  * These registers provide handshake between driver and 4965 for the Rx queue
9697ac9a364SKalle Valo  * (this queue handles *all* command responses, notifications, Rx data, etc.
9707ac9a364SKalle Valo  * sent from 4965 uCode to host driver).  Unlike Tx, there is only one Rx
9717ac9a364SKalle Valo  * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
9727ac9a364SKalle Valo  * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
9737ac9a364SKalle Valo  * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
9747ac9a364SKalle Valo  * mapping between RBDs and RBs.
9757ac9a364SKalle Valo  *
9767ac9a364SKalle Valo  * Driver must allocate host DRAM memory for the following, and set the
9777ac9a364SKalle Valo  * physical address of each into 4965 registers:
9787ac9a364SKalle Valo  *
9797ac9a364SKalle Valo  * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
9807ac9a364SKalle Valo  *     entries (although any power of 2, up to 4096, is selectable by driver).
9817ac9a364SKalle Valo  *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
9827ac9a364SKalle Valo  *     (typically 4K, although 8K or 16K are also selectable by driver).
9837ac9a364SKalle Valo  *     Driver sets up RB size and number of RBDs in the CB via Rx config
9847ac9a364SKalle Valo  *     register FH49_MEM_RCSR_CHNL0_CONFIG_REG.
9857ac9a364SKalle Valo  *
9867ac9a364SKalle Valo  *     Bit fields within one RBD:
9877ac9a364SKalle Valo  *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned
9887ac9a364SKalle Valo  *
9897ac9a364SKalle Valo  *     Driver sets physical address [35:8] of base of RBD circular buffer
9907ac9a364SKalle Valo  *     into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
9917ac9a364SKalle Valo  *
9927ac9a364SKalle Valo  * 2)  Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
9937ac9a364SKalle Valo  *     (RBs) have been filled, via a "write pointer", actually the idx of
9947ac9a364SKalle Valo  *     the RB's corresponding RBD within the circular buffer.  Driver sets
9957ac9a364SKalle Valo  *     physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
9967ac9a364SKalle Valo  *
9977ac9a364SKalle Valo  *     Bit fields in lower dword of Rx status buffer (upper dword not used
9987ac9a364SKalle Valo  *     by driver; see struct il4965_shared, val0):
9997ac9a364SKalle Valo  *     31-12:  Not used by driver
10007ac9a364SKalle Valo  *     11- 0:  Index of last filled Rx buffer descriptor
10017ac9a364SKalle Valo  *             (4965 writes, driver reads this value)
10027ac9a364SKalle Valo  *
10037ac9a364SKalle Valo  * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
10047ac9a364SKalle Valo  * enter pointers to these RBs into contiguous RBD circular buffer entries,
10057ac9a364SKalle Valo  * and update the 4965's "write" idx register,
10067ac9a364SKalle Valo  * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG.
10077ac9a364SKalle Valo  *
10087ac9a364SKalle Valo  * This "write" idx corresponds to the *next* RBD that the driver will make
10097ac9a364SKalle Valo  * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
10107ac9a364SKalle Valo  * the circular buffer.  This value should initially be 0 (before preparing any
10117ac9a364SKalle Valo  * RBs), should be 8 after preparing the first 8 RBs (for example), and must
10127ac9a364SKalle Valo  * wrap back to 0 at the end of the circular buffer (but don't wrap before
10137ac9a364SKalle Valo  * "read" idx has advanced past 1!  See below).
10147ac9a364SKalle Valo  * NOTE:  4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8.
10157ac9a364SKalle Valo  *
10167ac9a364SKalle Valo  * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
10177ac9a364SKalle Valo  * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
10187ac9a364SKalle Valo  * to tell the driver the idx of the latest filled RBD.  The driver must
10197ac9a364SKalle Valo  * read this "read" idx from DRAM after receiving an Rx interrupt from 4965.
10207ac9a364SKalle Valo  *
10217ac9a364SKalle Valo  * The driver must also internally keep track of a third idx, which is the
10227ac9a364SKalle Valo  * next RBD to process.  When receiving an Rx interrupt, driver should process
10237ac9a364SKalle Valo  * all filled but unprocessed RBs up to, but not including, the RB
10247ac9a364SKalle Valo  * corresponding to the "read" idx.  For example, if "read" idx becomes "1",
10257ac9a364SKalle Valo  * driver may process the RB pointed to by RBD 0.  Depending on volume of
10267ac9a364SKalle Valo  * traffic, there may be many RBs to process.
10277ac9a364SKalle Valo  *
10287ac9a364SKalle Valo  * If read idx == write idx, 4965 thinks there is no room to put new data.
10297ac9a364SKalle Valo  * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
10307ac9a364SKalle Valo  * be safe, make sure that there is a gap of at least 2 RBDs between "write"
10317ac9a364SKalle Valo  * and "read" idxes; that is, make sure that there are no more than 254
10327ac9a364SKalle Valo  * buffers waiting to be filled.
10337ac9a364SKalle Valo  */
10347ac9a364SKalle Valo #define FH49_MEM_RSCSR_LOWER_BOUND	(FH49_MEM_LOWER_BOUND + 0xBC0)
10357ac9a364SKalle Valo #define FH49_MEM_RSCSR_UPPER_BOUND	(FH49_MEM_LOWER_BOUND + 0xC00)
10367ac9a364SKalle Valo #define FH49_MEM_RSCSR_CHNL0		(FH49_MEM_RSCSR_LOWER_BOUND)
10377ac9a364SKalle Valo 
10387ac9a364SKalle Valo /**
10397ac9a364SKalle Valo  * Physical base address of 8-byte Rx Status buffer.
10407ac9a364SKalle Valo  * Bit fields:
10417ac9a364SKalle Valo  *  31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
10427ac9a364SKalle Valo  */
10437ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_STTS_WPTR_REG	(FH49_MEM_RSCSR_CHNL0)
10447ac9a364SKalle Valo 
10457ac9a364SKalle Valo /**
10467ac9a364SKalle Valo  * Physical base address of Rx Buffer Descriptor Circular Buffer.
10477ac9a364SKalle Valo  * Bit fields:
10487ac9a364SKalle Valo  *  27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
10497ac9a364SKalle Valo  */
10507ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_RBDCB_BASE_REG	(FH49_MEM_RSCSR_CHNL0 + 0x004)
10517ac9a364SKalle Valo 
10527ac9a364SKalle Valo /**
10537ac9a364SKalle Valo  * Rx write pointer (idx, really!).
10547ac9a364SKalle Valo  * Bit fields:
10557ac9a364SKalle Valo  *  11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
10567ac9a364SKalle Valo  *         NOTE:  For 256-entry circular buffer, use only bits [7:0].
10577ac9a364SKalle Valo  */
10587ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG	(FH49_MEM_RSCSR_CHNL0 + 0x008)
10597ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_WPTR        (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG)
10607ac9a364SKalle Valo 
10617ac9a364SKalle Valo /**
10627ac9a364SKalle Valo  * Rx Config/Status Registers (RCSR)
10637ac9a364SKalle Valo  * Rx Config Reg for channel 0 (only channel used)
10647ac9a364SKalle Valo  *
10657ac9a364SKalle Valo  * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for
10667ac9a364SKalle Valo  * normal operation (see bit fields).
10677ac9a364SKalle Valo  *
10687ac9a364SKalle Valo  * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
10697ac9a364SKalle Valo  * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG	for
10707ac9a364SKalle Valo  * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
10717ac9a364SKalle Valo  *
10727ac9a364SKalle Valo  * Bit fields:
10737ac9a364SKalle Valo  * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
10747ac9a364SKalle Valo  *        '10' operate normally
10757ac9a364SKalle Valo  * 29-24: reserved
10767ac9a364SKalle Valo  * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
10777ac9a364SKalle Valo  *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
10787ac9a364SKalle Valo  * 19-18: reserved
10797ac9a364SKalle Valo  * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
10807ac9a364SKalle Valo  *        '10' 12K, '11' 16K.
10817ac9a364SKalle Valo  * 15-14: reserved
10827ac9a364SKalle Valo  * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
10837ac9a364SKalle Valo  * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
10847ac9a364SKalle Valo  *        typical value 0x10 (about 1/2 msec)
10857ac9a364SKalle Valo  *  3- 0: reserved
10867ac9a364SKalle Valo  */
10877ac9a364SKalle Valo #define FH49_MEM_RCSR_LOWER_BOUND      (FH49_MEM_LOWER_BOUND + 0xC00)
10887ac9a364SKalle Valo #define FH49_MEM_RCSR_UPPER_BOUND      (FH49_MEM_LOWER_BOUND + 0xCC0)
10897ac9a364SKalle Valo #define FH49_MEM_RCSR_CHNL0            (FH49_MEM_RCSR_LOWER_BOUND)
10907ac9a364SKalle Valo 
10917ac9a364SKalle Valo #define FH49_MEM_RCSR_CHNL0_CONFIG_REG	(FH49_MEM_RCSR_CHNL0)
10927ac9a364SKalle Valo 
10937ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0)	/* bits 4-11 */
10947ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK   (0x00001000)	/* bits 12 */
10957ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000)	/* bit 15 */
10967ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK   (0x00030000)	/* bits 16-17 */
10977ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000)	/* bits 20-23 */
10987ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000)	/* bits 30-31 */
10997ac9a364SKalle Valo 
11007ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS	(20)
11017ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS	(4)
11027ac9a364SKalle Valo #define RX_RB_TIMEOUT	(0x10)
11037ac9a364SKalle Valo 
11047ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL         (0x00000000)
11057ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL     (0x40000000)
11067ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL        (0x80000000)
11077ac9a364SKalle Valo 
11087ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K    (0x00000000)
11097ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K    (0x00010000)
11107ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K   (0x00020000)
11117ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K   (0x00030000)
11127ac9a364SKalle Valo 
11137ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY              (0x00000004)
11147ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL    (0x00000000)
11157ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL  (0x00001000)
11167ac9a364SKalle Valo 
11177ac9a364SKalle Valo /**
11187ac9a364SKalle Valo  * Rx Shared Status Registers (RSSR)
11197ac9a364SKalle Valo  *
11207ac9a364SKalle Valo  * After stopping Rx DMA channel (writing 0 to
11217ac9a364SKalle Valo  * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
11227ac9a364SKalle Valo  * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
11237ac9a364SKalle Valo  *
11247ac9a364SKalle Valo  * Bit fields:
11257ac9a364SKalle Valo  *  24:  1 = Channel 0 is idle
11267ac9a364SKalle Valo  *
11277ac9a364SKalle Valo  * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
11287ac9a364SKalle Valo  * contain default values that should not be altered by the driver.
11297ac9a364SKalle Valo  */
11307ac9a364SKalle Valo #define FH49_MEM_RSSR_LOWER_BOUND           (FH49_MEM_LOWER_BOUND + 0xC40)
11317ac9a364SKalle Valo #define FH49_MEM_RSSR_UPPER_BOUND           (FH49_MEM_LOWER_BOUND + 0xD00)
11327ac9a364SKalle Valo 
11337ac9a364SKalle Valo #define FH49_MEM_RSSR_SHARED_CTRL_REG       (FH49_MEM_RSSR_LOWER_BOUND)
11347ac9a364SKalle Valo #define FH49_MEM_RSSR_RX_STATUS_REG	(FH49_MEM_RSSR_LOWER_BOUND + 0x004)
11357ac9a364SKalle Valo #define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
11367ac9a364SKalle Valo 					(FH49_MEM_RSSR_LOWER_BOUND + 0x008)
11377ac9a364SKalle Valo 
11387ac9a364SKalle Valo #define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE	(0x01000000)
11397ac9a364SKalle Valo 
11407ac9a364SKalle Valo #define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT	28
11417ac9a364SKalle Valo 
11427ac9a364SKalle Valo /* TFDB  Area - TFDs buffer table */
11437ac9a364SKalle Valo #define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK      (0xFFFFFFFF)
11447ac9a364SKalle Valo #define FH49_TFDIB_LOWER_BOUND       (FH49_MEM_LOWER_BOUND + 0x900)
11457ac9a364SKalle Valo #define FH49_TFDIB_UPPER_BOUND       (FH49_MEM_LOWER_BOUND + 0x958)
11467ac9a364SKalle Valo #define FH49_TFDIB_CTRL0_REG(_chnl)  (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
11477ac9a364SKalle Valo #define FH49_TFDIB_CTRL1_REG(_chnl)  (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
11487ac9a364SKalle Valo 
11497ac9a364SKalle Valo /**
11507ac9a364SKalle Valo  * Transmit DMA Channel Control/Status Registers (TCSR)
11517ac9a364SKalle Valo  *
11527ac9a364SKalle Valo  * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
11537ac9a364SKalle Valo  * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
11547ac9a364SKalle Valo  * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
11557ac9a364SKalle Valo  *
11567ac9a364SKalle Valo  * To use a Tx DMA channel, driver must initialize its
11577ac9a364SKalle Valo  * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
11587ac9a364SKalle Valo  *
11597ac9a364SKalle Valo  * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
11607ac9a364SKalle Valo  * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
11617ac9a364SKalle Valo  *
11627ac9a364SKalle Valo  * All other bits should be 0.
11637ac9a364SKalle Valo  *
11647ac9a364SKalle Valo  * Bit fields:
11657ac9a364SKalle Valo  * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
11667ac9a364SKalle Valo  *        '10' operate normally
11677ac9a364SKalle Valo  * 29- 4: Reserved, set to "0"
11687ac9a364SKalle Valo  *     3: Enable internal DMA requests (1, normal operation), disable (0)
11697ac9a364SKalle Valo  *  2- 0: Reserved, set to "0"
11707ac9a364SKalle Valo  */
11717ac9a364SKalle Valo #define FH49_TCSR_LOWER_BOUND  (FH49_MEM_LOWER_BOUND + 0xD00)
11727ac9a364SKalle Valo #define FH49_TCSR_UPPER_BOUND  (FH49_MEM_LOWER_BOUND + 0xE60)
11737ac9a364SKalle Valo 
11747ac9a364SKalle Valo /* Find Control/Status reg for given Tx DMA/FIFO channel */
11757ac9a364SKalle Valo #define FH49_TCSR_CHNL_NUM                            (7)
11767ac9a364SKalle Valo #define FH50_TCSR_CHNL_NUM                            (8)
11777ac9a364SKalle Valo 
11787ac9a364SKalle Valo /* TCSR: tx_config register values */
11797ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl)	\
11807ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl))
11817ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl)	\
11827ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
11837ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl)	\
11847ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
11857ac9a364SKalle Valo 
11867ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF		(0x00000000)
11877ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV		(0x00000001)
11887ac9a364SKalle Valo 
11897ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE	(0x00000000)
11907ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE	(0x00000008)
11917ac9a364SKalle Valo 
11927ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
11937ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD	(0x00100000)
11947ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
11957ac9a364SKalle Valo 
11967ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT	(0x00000000)
11977ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
11987ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD	(0x00800000)
11997ac9a364SKalle Valo 
12007ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE	(0x00000000)
12017ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF	(0x40000000)
12027ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE	(0x80000000)
12037ac9a364SKalle Valo 
12047ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
12057ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
12067ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
12077ac9a364SKalle Valo 
12087ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM		(20)
12097ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX		(12)
12107ac9a364SKalle Valo 
12117ac9a364SKalle Valo /**
12127ac9a364SKalle Valo  * Tx Shared Status Registers (TSSR)
12137ac9a364SKalle Valo  *
12147ac9a364SKalle Valo  * After stopping Tx DMA channel (writing 0 to
12157ac9a364SKalle Valo  * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
12167ac9a364SKalle Valo  * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle
12177ac9a364SKalle Valo  * (channel's buffers empty | no pending requests).
12187ac9a364SKalle Valo  *
12197ac9a364SKalle Valo  * Bit fields:
12207ac9a364SKalle Valo  * 31-24:  1 = Channel buffers empty (channel 7:0)
12217ac9a364SKalle Valo  * 23-16:  1 = No pending requests (channel 7:0)
12227ac9a364SKalle Valo  */
12237ac9a364SKalle Valo #define FH49_TSSR_LOWER_BOUND		(FH49_MEM_LOWER_BOUND + 0xEA0)
12247ac9a364SKalle Valo #define FH49_TSSR_UPPER_BOUND		(FH49_MEM_LOWER_BOUND + 0xEC0)
12257ac9a364SKalle Valo 
12267ac9a364SKalle Valo #define FH49_TSSR_TX_STATUS_REG		(FH49_TSSR_LOWER_BOUND + 0x010)
12277ac9a364SKalle Valo 
12287ac9a364SKalle Valo /**
12297ac9a364SKalle Valo  * Bit fields for TSSR(Tx Shared Status & Control) error status register:
12307ac9a364SKalle Valo  * 31:  Indicates an address error when accessed to internal memory
12317ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
12327ac9a364SKalle Valo  * 30:  Indicates that Host did not send the expected number of dwords to FH
12337ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
12347ac9a364SKalle Valo  * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
12357ac9a364SKalle Valo  *	command was received from the scheduler while the TRB was already full
12367ac9a364SKalle Valo  *	with previous command
12377ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
12387ac9a364SKalle Valo  * 7-0: Each status bit indicates a channel's TxCredit error. When an error
12397ac9a364SKalle Valo  *	bit is set, it indicates that the FH has received a full indication
12407ac9a364SKalle Valo  *	from the RTC TxFIFO and the current value of the TxCredit counter was
12417ac9a364SKalle Valo  *	not equal to zero. This mean that the credit mechanism was not
12427ac9a364SKalle Valo  *	synchronized to the TxFIFO status
12437ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
12447ac9a364SKalle Valo  */
12457ac9a364SKalle Valo #define FH49_TSSR_TX_ERROR_REG		(FH49_TSSR_LOWER_BOUND + 0x018)
12467ac9a364SKalle Valo 
12477ac9a364SKalle Valo #define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
12487ac9a364SKalle Valo 
12497ac9a364SKalle Valo /* Tx service channels */
12507ac9a364SKalle Valo #define FH49_SRVC_CHNL		(9)
12517ac9a364SKalle Valo #define FH49_SRVC_LOWER_BOUND	(FH49_MEM_LOWER_BOUND + 0x9C8)
12527ac9a364SKalle Valo #define FH49_SRVC_UPPER_BOUND	(FH49_MEM_LOWER_BOUND + 0x9D0)
12537ac9a364SKalle Valo #define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
12547ac9a364SKalle Valo 		(FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
12557ac9a364SKalle Valo 
12567ac9a364SKalle Valo #define FH49_TX_CHICKEN_BITS_REG	(FH49_MEM_LOWER_BOUND + 0xE98)
12577ac9a364SKalle Valo /* Instruct FH to increment the retry count of a packet when
12587ac9a364SKalle Valo  * it is brought from the memory to TX-FIFO
12597ac9a364SKalle Valo  */
12607ac9a364SKalle Valo #define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN	(0x00000002)
12617ac9a364SKalle Valo 
12627ac9a364SKalle Valo /* Keep Warm Size */
12637ac9a364SKalle Valo #define IL_KW_SIZE 0x1000	/* 4k */
12647ac9a364SKalle Valo 
12657ac9a364SKalle Valo #endif /* __il_4965_h__ */
1266