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