xref: /openbmc/linux/drivers/net/wireless/intel/iwlegacy/4965.h (revision 7ac9a364c1721a863ecc6cc9aba66e10114908db)
1*7ac9a364SKalle Valo /******************************************************************************
2*7ac9a364SKalle Valo  *
3*7ac9a364SKalle Valo  * GPL LICENSE SUMMARY
4*7ac9a364SKalle Valo  *
5*7ac9a364SKalle Valo  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6*7ac9a364SKalle Valo  *
7*7ac9a364SKalle Valo  * This program is free software; you can redistribute it and/or modify
8*7ac9a364SKalle Valo  * it under the terms of version 2 of the GNU General Public License as
9*7ac9a364SKalle Valo  * published by the Free Software Foundation.
10*7ac9a364SKalle Valo  *
11*7ac9a364SKalle Valo  * This program is distributed in the hope that it will be useful, but
12*7ac9a364SKalle Valo  * WITHOUT ANY WARRANTY; without even the implied warranty of
13*7ac9a364SKalle Valo  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*7ac9a364SKalle Valo  * General Public License for more details.
15*7ac9a364SKalle Valo  *
16*7ac9a364SKalle Valo  * You should have received a copy of the GNU General Public License
17*7ac9a364SKalle Valo  * along with this program; if not, write to the Free Software
18*7ac9a364SKalle Valo  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19*7ac9a364SKalle Valo  * USA
20*7ac9a364SKalle Valo  *
21*7ac9a364SKalle Valo  * The full GNU General Public License is included in this distribution
22*7ac9a364SKalle Valo  * in the file called LICENSE.GPL.
23*7ac9a364SKalle Valo  *
24*7ac9a364SKalle Valo  * Contact Information:
25*7ac9a364SKalle Valo  *  Intel Linux Wireless <ilw@linux.intel.com>
26*7ac9a364SKalle Valo  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27*7ac9a364SKalle Valo  *
28*7ac9a364SKalle Valo  *****************************************************************************/
29*7ac9a364SKalle Valo 
30*7ac9a364SKalle Valo #ifndef __il_4965_h__
31*7ac9a364SKalle Valo #define __il_4965_h__
32*7ac9a364SKalle Valo 
33*7ac9a364SKalle Valo struct il_rx_queue;
34*7ac9a364SKalle Valo struct il_rx_buf;
35*7ac9a364SKalle Valo struct il_rx_pkt;
36*7ac9a364SKalle Valo struct il_tx_queue;
37*7ac9a364SKalle Valo struct il_rxon_context;
38*7ac9a364SKalle Valo 
39*7ac9a364SKalle Valo /* configuration for the _4965 devices */
40*7ac9a364SKalle Valo extern struct il_cfg il4965_cfg;
41*7ac9a364SKalle Valo extern const struct il_ops il4965_ops;
42*7ac9a364SKalle Valo 
43*7ac9a364SKalle Valo extern struct il_mod_params il4965_mod_params;
44*7ac9a364SKalle Valo 
45*7ac9a364SKalle Valo /* tx queue */
46*7ac9a364SKalle Valo void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid,
47*7ac9a364SKalle Valo 			       int freed);
48*7ac9a364SKalle Valo 
49*7ac9a364SKalle Valo /* RXON */
50*7ac9a364SKalle Valo void il4965_set_rxon_chain(struct il_priv *il);
51*7ac9a364SKalle Valo 
52*7ac9a364SKalle Valo /* uCode */
53*7ac9a364SKalle Valo int il4965_verify_ucode(struct il_priv *il);
54*7ac9a364SKalle Valo 
55*7ac9a364SKalle Valo /* lib */
56*7ac9a364SKalle Valo void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status);
57*7ac9a364SKalle Valo 
58*7ac9a364SKalle Valo void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
59*7ac9a364SKalle Valo int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq);
60*7ac9a364SKalle Valo int il4965_hw_nic_init(struct il_priv *il);
61*7ac9a364SKalle Valo int il4965_dump_fh(struct il_priv *il, char **buf, bool display);
62*7ac9a364SKalle Valo 
63*7ac9a364SKalle Valo void il4965_nic_config(struct il_priv *il);
64*7ac9a364SKalle Valo 
65*7ac9a364SKalle Valo /* rx */
66*7ac9a364SKalle Valo void il4965_rx_queue_restock(struct il_priv *il);
67*7ac9a364SKalle Valo void il4965_rx_replenish(struct il_priv *il);
68*7ac9a364SKalle Valo void il4965_rx_replenish_now(struct il_priv *il);
69*7ac9a364SKalle Valo void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq);
70*7ac9a364SKalle Valo int il4965_rxq_stop(struct il_priv *il);
71*7ac9a364SKalle Valo int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
72*7ac9a364SKalle Valo void il4965_rx_handle(struct il_priv *il);
73*7ac9a364SKalle Valo 
74*7ac9a364SKalle Valo /* tx */
75*7ac9a364SKalle Valo void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
76*7ac9a364SKalle Valo int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
77*7ac9a364SKalle Valo 				    dma_addr_t addr, u16 len, u8 reset, u8 pad);
78*7ac9a364SKalle Valo int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
79*7ac9a364SKalle Valo void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
80*7ac9a364SKalle Valo 				 struct ieee80211_tx_info *info);
81*7ac9a364SKalle Valo int il4965_tx_skb(struct il_priv *il,
82*7ac9a364SKalle Valo 		  struct ieee80211_sta *sta,
83*7ac9a364SKalle Valo 		  struct sk_buff *skb);
84*7ac9a364SKalle Valo int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
85*7ac9a364SKalle Valo 			struct ieee80211_sta *sta, u16 tid, u16 * ssn);
86*7ac9a364SKalle Valo int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
87*7ac9a364SKalle Valo 		       struct ieee80211_sta *sta, u16 tid);
88*7ac9a364SKalle Valo int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id);
89*7ac9a364SKalle Valo int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx);
90*7ac9a364SKalle Valo void il4965_hw_txq_ctx_free(struct il_priv *il);
91*7ac9a364SKalle Valo int il4965_txq_ctx_alloc(struct il_priv *il);
92*7ac9a364SKalle Valo void il4965_txq_ctx_reset(struct il_priv *il);
93*7ac9a364SKalle Valo void il4965_txq_ctx_stop(struct il_priv *il);
94*7ac9a364SKalle Valo void il4965_txq_set_sched(struct il_priv *il, u32 mask);
95*7ac9a364SKalle Valo 
96*7ac9a364SKalle Valo /*
97*7ac9a364SKalle Valo  * Acquire il->lock before calling this function !
98*7ac9a364SKalle Valo  */
99*7ac9a364SKalle Valo void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx);
100*7ac9a364SKalle Valo /**
101*7ac9a364SKalle Valo  * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue
102*7ac9a364SKalle Valo  * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed
103*7ac9a364SKalle Valo  * @scd_retry: (1) Indicates queue will be used in aggregation mode
104*7ac9a364SKalle Valo  *
105*7ac9a364SKalle Valo  * NOTE:  Acquire il->lock before calling this function !
106*7ac9a364SKalle Valo  */
107*7ac9a364SKalle Valo void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
108*7ac9a364SKalle Valo 				int tx_fifo_id, int scd_retry);
109*7ac9a364SKalle Valo 
110*7ac9a364SKalle Valo /* scan */
111*7ac9a364SKalle Valo int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
112*7ac9a364SKalle Valo 
113*7ac9a364SKalle Valo /* station mgmt */
114*7ac9a364SKalle Valo int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
115*7ac9a364SKalle Valo 			       bool add);
116*7ac9a364SKalle Valo 
117*7ac9a364SKalle Valo /* hcmd */
118*7ac9a364SKalle Valo int il4965_send_beacon_cmd(struct il_priv *il);
119*7ac9a364SKalle Valo 
120*7ac9a364SKalle Valo #ifdef CONFIG_IWLEGACY_DEBUG
121*7ac9a364SKalle Valo const char *il4965_get_tx_fail_reason(u32 status);
122*7ac9a364SKalle Valo #else
123*7ac9a364SKalle Valo static inline const char *
124*7ac9a364SKalle Valo il4965_get_tx_fail_reason(u32 status)
125*7ac9a364SKalle Valo {
126*7ac9a364SKalle Valo 	return "";
127*7ac9a364SKalle Valo }
128*7ac9a364SKalle Valo #endif
129*7ac9a364SKalle Valo 
130*7ac9a364SKalle Valo /* station management */
131*7ac9a364SKalle Valo int il4965_alloc_bcast_station(struct il_priv *il);
132*7ac9a364SKalle Valo int il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r);
133*7ac9a364SKalle Valo int il4965_remove_default_wep_key(struct il_priv *il,
134*7ac9a364SKalle Valo 				  struct ieee80211_key_conf *key);
135*7ac9a364SKalle Valo int il4965_set_default_wep_key(struct il_priv *il,
136*7ac9a364SKalle Valo 			       struct ieee80211_key_conf *key);
137*7ac9a364SKalle Valo int il4965_restore_default_wep_keys(struct il_priv *il);
138*7ac9a364SKalle Valo int il4965_set_dynamic_key(struct il_priv *il,
139*7ac9a364SKalle Valo 			   struct ieee80211_key_conf *key, u8 sta_id);
140*7ac9a364SKalle Valo int il4965_remove_dynamic_key(struct il_priv *il,
141*7ac9a364SKalle Valo 			      struct ieee80211_key_conf *key, u8 sta_id);
142*7ac9a364SKalle Valo void il4965_update_tkip_key(struct il_priv *il,
143*7ac9a364SKalle Valo 			    struct ieee80211_key_conf *keyconf,
144*7ac9a364SKalle Valo 			    struct ieee80211_sta *sta, u32 iv32,
145*7ac9a364SKalle Valo 			    u16 *phase1key);
146*7ac9a364SKalle Valo int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid);
147*7ac9a364SKalle Valo int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
148*7ac9a364SKalle Valo 			    int tid, u16 ssn);
149*7ac9a364SKalle Valo int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
150*7ac9a364SKalle Valo 			   int tid);
151*7ac9a364SKalle Valo void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt);
152*7ac9a364SKalle Valo int il4965_update_bcast_stations(struct il_priv *il);
153*7ac9a364SKalle Valo 
154*7ac9a364SKalle Valo /* rate */
155*7ac9a364SKalle Valo static inline u8
156*7ac9a364SKalle Valo il4965_hw_get_rate(__le32 rate_n_flags)
157*7ac9a364SKalle Valo {
158*7ac9a364SKalle Valo 	return le32_to_cpu(rate_n_flags) & 0xFF;
159*7ac9a364SKalle Valo }
160*7ac9a364SKalle Valo 
161*7ac9a364SKalle Valo /* eeprom */
162*7ac9a364SKalle Valo void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac);
163*7ac9a364SKalle Valo int il4965_eeprom_acquire_semaphore(struct il_priv *il);
164*7ac9a364SKalle Valo void il4965_eeprom_release_semaphore(struct il_priv *il);
165*7ac9a364SKalle Valo int il4965_eeprom_check_version(struct il_priv *il);
166*7ac9a364SKalle Valo 
167*7ac9a364SKalle Valo /* mac80211 handlers (for 4965) */
168*7ac9a364SKalle Valo void il4965_mac_tx(struct ieee80211_hw *hw,
169*7ac9a364SKalle Valo 		   struct ieee80211_tx_control *control,
170*7ac9a364SKalle Valo 		   struct sk_buff *skb);
171*7ac9a364SKalle Valo int il4965_mac_start(struct ieee80211_hw *hw);
172*7ac9a364SKalle Valo void il4965_mac_stop(struct ieee80211_hw *hw);
173*7ac9a364SKalle Valo void il4965_configure_filter(struct ieee80211_hw *hw,
174*7ac9a364SKalle Valo 			     unsigned int changed_flags,
175*7ac9a364SKalle Valo 			     unsigned int *total_flags, u64 multicast);
176*7ac9a364SKalle Valo int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
177*7ac9a364SKalle Valo 		       struct ieee80211_vif *vif, struct ieee80211_sta *sta,
178*7ac9a364SKalle Valo 		       struct ieee80211_key_conf *key);
179*7ac9a364SKalle Valo void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
180*7ac9a364SKalle Valo 				struct ieee80211_vif *vif,
181*7ac9a364SKalle Valo 				struct ieee80211_key_conf *keyconf,
182*7ac9a364SKalle Valo 				struct ieee80211_sta *sta, u32 iv32,
183*7ac9a364SKalle Valo 				u16 *phase1key);
184*7ac9a364SKalle Valo int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
185*7ac9a364SKalle Valo 			    enum ieee80211_ampdu_mlme_action action,
186*7ac9a364SKalle Valo 			    struct ieee80211_sta *sta, u16 tid, u16 * ssn,
187*7ac9a364SKalle Valo 			    u8 buf_size, bool amsdu);
188*7ac9a364SKalle Valo int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
189*7ac9a364SKalle Valo 		       struct ieee80211_sta *sta);
190*7ac9a364SKalle Valo void
191*7ac9a364SKalle Valo il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
192*7ac9a364SKalle Valo 			  struct ieee80211_channel_switch *ch_switch);
193*7ac9a364SKalle Valo 
194*7ac9a364SKalle Valo void il4965_led_enable(struct il_priv *il);
195*7ac9a364SKalle Valo 
196*7ac9a364SKalle Valo /* EEPROM */
197*7ac9a364SKalle Valo #define IL4965_EEPROM_IMG_SIZE			1024
198*7ac9a364SKalle Valo 
199*7ac9a364SKalle Valo /*
200*7ac9a364SKalle Valo  * uCode queue management definitions ...
201*7ac9a364SKalle Valo  * The first queue used for block-ack aggregation is #7 (4965 only).
202*7ac9a364SKalle Valo  * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
203*7ac9a364SKalle Valo  */
204*7ac9a364SKalle Valo #define IL49_FIRST_AMPDU_QUEUE	7
205*7ac9a364SKalle Valo 
206*7ac9a364SKalle Valo /* Sizes and addresses for instruction and data memory (SRAM) in
207*7ac9a364SKalle Valo  * 4965's embedded processor.  Driver access is via HBUS_TARG_MEM_* regs. */
208*7ac9a364SKalle Valo #define IL49_RTC_INST_LOWER_BOUND		(0x000000)
209*7ac9a364SKalle Valo #define IL49_RTC_INST_UPPER_BOUND		(0x018000)
210*7ac9a364SKalle Valo 
211*7ac9a364SKalle Valo #define IL49_RTC_DATA_LOWER_BOUND		(0x800000)
212*7ac9a364SKalle Valo #define IL49_RTC_DATA_UPPER_BOUND		(0x80A000)
213*7ac9a364SKalle Valo 
214*7ac9a364SKalle Valo #define IL49_RTC_INST_SIZE  (IL49_RTC_INST_UPPER_BOUND - \
215*7ac9a364SKalle Valo 				IL49_RTC_INST_LOWER_BOUND)
216*7ac9a364SKalle Valo #define IL49_RTC_DATA_SIZE  (IL49_RTC_DATA_UPPER_BOUND - \
217*7ac9a364SKalle Valo 				IL49_RTC_DATA_LOWER_BOUND)
218*7ac9a364SKalle Valo 
219*7ac9a364SKalle Valo #define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE
220*7ac9a364SKalle Valo #define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE
221*7ac9a364SKalle Valo 
222*7ac9a364SKalle Valo /* Size of uCode instruction memory in bootstrap state machine */
223*7ac9a364SKalle Valo #define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE
224*7ac9a364SKalle Valo 
225*7ac9a364SKalle Valo static inline int
226*7ac9a364SKalle Valo il4965_hw_valid_rtc_data_addr(u32 addr)
227*7ac9a364SKalle Valo {
228*7ac9a364SKalle Valo 	return (addr >= IL49_RTC_DATA_LOWER_BOUND &&
229*7ac9a364SKalle Valo 		addr < IL49_RTC_DATA_UPPER_BOUND);
230*7ac9a364SKalle Valo }
231*7ac9a364SKalle Valo 
232*7ac9a364SKalle Valo /********************* START TEMPERATURE *************************************/
233*7ac9a364SKalle Valo 
234*7ac9a364SKalle Valo /**
235*7ac9a364SKalle Valo  * 4965 temperature calculation.
236*7ac9a364SKalle Valo  *
237*7ac9a364SKalle Valo  * The driver must calculate the device temperature before calculating
238*7ac9a364SKalle Valo  * a txpower setting (amplifier gain is temperature dependent).  The
239*7ac9a364SKalle Valo  * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
240*7ac9a364SKalle Valo  * values used for the life of the driver, and one of which (R4) is the
241*7ac9a364SKalle Valo  * real-time temperature indicator.
242*7ac9a364SKalle Valo  *
243*7ac9a364SKalle Valo  * uCode provides all 4 values to the driver via the "initialize alive"
244*7ac9a364SKalle Valo  * notification (see struct il4965_init_alive_resp).  After the runtime uCode
245*7ac9a364SKalle Valo  * image loads, uCode updates the R4 value via stats notifications
246*7ac9a364SKalle Valo  * (see N_STATS), which occur after each received beacon
247*7ac9a364SKalle Valo  * when associated, or can be requested via C_STATS.
248*7ac9a364SKalle Valo  *
249*7ac9a364SKalle Valo  * NOTE:  uCode provides the R4 value as a 23-bit signed value.  Driver
250*7ac9a364SKalle Valo  *        must sign-extend to 32 bits before applying formula below.
251*7ac9a364SKalle Valo  *
252*7ac9a364SKalle Valo  * Formula:
253*7ac9a364SKalle Valo  *
254*7ac9a364SKalle Valo  * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
255*7ac9a364SKalle Valo  *
256*7ac9a364SKalle Valo  * NOTE:  The basic formula is 259 * (R4-R2) / (R3-R1).  The 97/100 is
257*7ac9a364SKalle Valo  * an additional correction, which should be centered around 0 degrees
258*7ac9a364SKalle Valo  * Celsius (273 degrees Kelvin).  The 8 (3 percent of 273) compensates for
259*7ac9a364SKalle Valo  * centering the 97/100 correction around 0 degrees K.
260*7ac9a364SKalle Valo  *
261*7ac9a364SKalle Valo  * Add 273 to Kelvin value to find degrees Celsius, for comparing current
262*7ac9a364SKalle Valo  * temperature with factory-measured temperatures when calculating txpower
263*7ac9a364SKalle Valo  * settings.
264*7ac9a364SKalle Valo  */
265*7ac9a364SKalle Valo #define TEMPERATURE_CALIB_KELVIN_OFFSET 8
266*7ac9a364SKalle Valo #define TEMPERATURE_CALIB_A_VAL 259
267*7ac9a364SKalle Valo 
268*7ac9a364SKalle Valo /* Limit range of calculated temperature to be between these Kelvin values */
269*7ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_MIN  (263)
270*7ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_MAX  (410)
271*7ac9a364SKalle Valo 
272*7ac9a364SKalle Valo #define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
273*7ac9a364SKalle Valo 	((t) < IL_TX_POWER_TEMPERATURE_MIN || \
274*7ac9a364SKalle Valo 	 (t) > IL_TX_POWER_TEMPERATURE_MAX)
275*7ac9a364SKalle Valo 
276*7ac9a364SKalle Valo void il4965_temperature_calib(struct il_priv *il);
277*7ac9a364SKalle Valo /********************* END TEMPERATURE ***************************************/
278*7ac9a364SKalle Valo 
279*7ac9a364SKalle Valo /********************* START TXPOWER *****************************************/
280*7ac9a364SKalle Valo 
281*7ac9a364SKalle Valo /**
282*7ac9a364SKalle Valo  * 4965 txpower calculations rely on information from three sources:
283*7ac9a364SKalle Valo  *
284*7ac9a364SKalle Valo  *     1) EEPROM
285*7ac9a364SKalle Valo  *     2) "initialize" alive notification
286*7ac9a364SKalle Valo  *     3) stats notifications
287*7ac9a364SKalle Valo  *
288*7ac9a364SKalle Valo  * EEPROM data consists of:
289*7ac9a364SKalle Valo  *
290*7ac9a364SKalle Valo  * 1)  Regulatory information (max txpower and channel usage flags) is provided
291*7ac9a364SKalle Valo  *     separately for each channel that can possibly supported by 4965.
292*7ac9a364SKalle Valo  *     40 MHz wide (.11n HT40) channels are listed separately from 20 MHz
293*7ac9a364SKalle Valo  *     (legacy) channels.
294*7ac9a364SKalle Valo  *
295*7ac9a364SKalle Valo  *     See struct il4965_eeprom_channel for format, and struct il4965_eeprom
296*7ac9a364SKalle Valo  *     for locations in EEPROM.
297*7ac9a364SKalle Valo  *
298*7ac9a364SKalle Valo  * 2)  Factory txpower calibration information is provided separately for
299*7ac9a364SKalle Valo  *     sub-bands of contiguous channels.  2.4GHz has just one sub-band,
300*7ac9a364SKalle Valo  *     but 5 GHz has several sub-bands.
301*7ac9a364SKalle Valo  *
302*7ac9a364SKalle Valo  *     In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
303*7ac9a364SKalle Valo  *
304*7ac9a364SKalle Valo  *     See struct il4965_eeprom_calib_info (and the tree of structures
305*7ac9a364SKalle Valo  *     contained within it) for format, and struct il4965_eeprom for
306*7ac9a364SKalle Valo  *     locations in EEPROM.
307*7ac9a364SKalle Valo  *
308*7ac9a364SKalle Valo  * "Initialization alive" notification (see struct il4965_init_alive_resp)
309*7ac9a364SKalle Valo  * consists of:
310*7ac9a364SKalle Valo  *
311*7ac9a364SKalle Valo  * 1)  Temperature calculation parameters.
312*7ac9a364SKalle Valo  *
313*7ac9a364SKalle Valo  * 2)  Power supply voltage measurement.
314*7ac9a364SKalle Valo  *
315*7ac9a364SKalle Valo  * 3)  Tx gain compensation to balance 2 transmitters for MIMO use.
316*7ac9a364SKalle Valo  *
317*7ac9a364SKalle Valo  * Statistics notifications deliver:
318*7ac9a364SKalle Valo  *
319*7ac9a364SKalle Valo  * 1)  Current values for temperature param R4.
320*7ac9a364SKalle Valo  */
321*7ac9a364SKalle Valo 
322*7ac9a364SKalle Valo /**
323*7ac9a364SKalle Valo  * To calculate a txpower setting for a given desired target txpower, channel,
324*7ac9a364SKalle Valo  * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
325*7ac9a364SKalle Valo  * support MIMO and transmit diversity), driver must do the following:
326*7ac9a364SKalle Valo  *
327*7ac9a364SKalle Valo  * 1)  Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
328*7ac9a364SKalle Valo  *     Do not exceed regulatory limit; reduce target txpower if necessary.
329*7ac9a364SKalle Valo  *
330*7ac9a364SKalle Valo  *     If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
331*7ac9a364SKalle Valo  *     2 transmitters will be used simultaneously; driver must reduce the
332*7ac9a364SKalle Valo  *     regulatory limit by 3 dB (half-power) for each transmitter, so the
333*7ac9a364SKalle Valo  *     combined total output of the 2 transmitters is within regulatory limits.
334*7ac9a364SKalle Valo  *
335*7ac9a364SKalle Valo  *
336*7ac9a364SKalle Valo  * 2)  Compare target txpower vs. (EEPROM) saturation txpower *reduced by
337*7ac9a364SKalle Valo  *     backoff for this bit rate*.  Do not exceed (saturation - backoff[rate]);
338*7ac9a364SKalle Valo  *     reduce target txpower if necessary.
339*7ac9a364SKalle Valo  *
340*7ac9a364SKalle Valo  *     Backoff values below are in 1/2 dB units (equivalent to steps in
341*7ac9a364SKalle Valo  *     txpower gain tables):
342*7ac9a364SKalle Valo  *
343*7ac9a364SKalle Valo  *     OFDM 6 - 36 MBit:  10 steps (5 dB)
344*7ac9a364SKalle Valo  *     OFDM 48 MBit:      15 steps (7.5 dB)
345*7ac9a364SKalle Valo  *     OFDM 54 MBit:      17 steps (8.5 dB)
346*7ac9a364SKalle Valo  *     OFDM 60 MBit:      20 steps (10 dB)
347*7ac9a364SKalle Valo  *     CCK all rates:     10 steps (5 dB)
348*7ac9a364SKalle Valo  *
349*7ac9a364SKalle Valo  *     Backoff values apply to saturation txpower on a per-transmitter basis;
350*7ac9a364SKalle Valo  *     when using MIMO (2 transmitters), each transmitter uses the same
351*7ac9a364SKalle Valo  *     saturation level provided in EEPROM, and the same backoff values;
352*7ac9a364SKalle Valo  *     no reduction (such as with regulatory txpower limits) is required.
353*7ac9a364SKalle Valo  *
354*7ac9a364SKalle Valo  *     Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
355*7ac9a364SKalle Valo  *     widths and 40 Mhz (.11n HT40) channel widths; there is no separate
356*7ac9a364SKalle Valo  *     factory measurement for ht40 channels.
357*7ac9a364SKalle Valo  *
358*7ac9a364SKalle Valo  *     The result of this step is the final target txpower.  The rest of
359*7ac9a364SKalle Valo  *     the steps figure out the proper settings for the device to achieve
360*7ac9a364SKalle Valo  *     that target txpower.
361*7ac9a364SKalle Valo  *
362*7ac9a364SKalle Valo  *
363*7ac9a364SKalle Valo  * 3)  Determine (EEPROM) calibration sub band for the target channel, by
364*7ac9a364SKalle Valo  *     comparing against first and last channels in each sub band
365*7ac9a364SKalle Valo  *     (see struct il4965_eeprom_calib_subband_info).
366*7ac9a364SKalle Valo  *
367*7ac9a364SKalle Valo  *
368*7ac9a364SKalle Valo  * 4)  Linearly interpolate (EEPROM) factory calibration measurement sets,
369*7ac9a364SKalle Valo  *     referencing the 2 factory-measured (sample) channels within the sub band.
370*7ac9a364SKalle Valo  *
371*7ac9a364SKalle Valo  *     Interpolation is based on difference between target channel's frequency
372*7ac9a364SKalle Valo  *     and the sample channels' frequencies.  Since channel numbers are based
373*7ac9a364SKalle Valo  *     on frequency (5 MHz between each channel number), this is equivalent
374*7ac9a364SKalle Valo  *     to interpolating based on channel number differences.
375*7ac9a364SKalle Valo  *
376*7ac9a364SKalle Valo  *     Note that the sample channels may or may not be the channels at the
377*7ac9a364SKalle Valo  *     edges of the sub band.  The target channel may be "outside" of the
378*7ac9a364SKalle Valo  *     span of the sampled channels.
379*7ac9a364SKalle Valo  *
380*7ac9a364SKalle Valo  *     Driver may choose the pair (for 2 Tx chains) of measurements (see
381*7ac9a364SKalle Valo  *     struct il4965_eeprom_calib_ch_info) for which the actual measured
382*7ac9a364SKalle Valo  *     txpower comes closest to the desired txpower.  Usually, though,
383*7ac9a364SKalle Valo  *     the middle set of measurements is closest to the regulatory limits,
384*7ac9a364SKalle Valo  *     and is therefore a good choice for all txpower calculations (this
385*7ac9a364SKalle Valo  *     assumes that high accuracy is needed for maximizing legal txpower,
386*7ac9a364SKalle Valo  *     while lower txpower configurations do not need as much accuracy).
387*7ac9a364SKalle Valo  *
388*7ac9a364SKalle Valo  *     Driver should interpolate both members of the chosen measurement pair,
389*7ac9a364SKalle Valo  *     i.e. for both Tx chains (radio transmitters), unless the driver knows
390*7ac9a364SKalle Valo  *     that only one of the chains will be used (e.g. only one tx antenna
391*7ac9a364SKalle Valo  *     connected, but this should be unusual).  The rate scaling algorithm
392*7ac9a364SKalle Valo  *     switches antennas to find best performance, so both Tx chains will
393*7ac9a364SKalle Valo  *     be used (although only one at a time) even for non-MIMO transmissions.
394*7ac9a364SKalle Valo  *
395*7ac9a364SKalle Valo  *     Driver should interpolate factory values for temperature, gain table
396*7ac9a364SKalle Valo  *     idx, and actual power.  The power amplifier detector values are
397*7ac9a364SKalle Valo  *     not used by the driver.
398*7ac9a364SKalle Valo  *
399*7ac9a364SKalle Valo  *     Sanity check:  If the target channel happens to be one of the sample
400*7ac9a364SKalle Valo  *     channels, the results should agree with the sample channel's
401*7ac9a364SKalle Valo  *     measurements!
402*7ac9a364SKalle Valo  *
403*7ac9a364SKalle Valo  *
404*7ac9a364SKalle Valo  * 5)  Find difference between desired txpower and (interpolated)
405*7ac9a364SKalle Valo  *     factory-measured txpower.  Using (interpolated) factory gain table idx
406*7ac9a364SKalle Valo  *     (shown elsewhere) as a starting point, adjust this idx lower to
407*7ac9a364SKalle Valo  *     increase txpower, or higher to decrease txpower, until the target
408*7ac9a364SKalle Valo  *     txpower is reached.  Each step in the gain table is 1/2 dB.
409*7ac9a364SKalle Valo  *
410*7ac9a364SKalle Valo  *     For example, if factory measured txpower is 16 dBm, and target txpower
411*7ac9a364SKalle Valo  *     is 13 dBm, add 6 steps to the factory gain idx to reduce txpower
412*7ac9a364SKalle Valo  *     by 3 dB.
413*7ac9a364SKalle Valo  *
414*7ac9a364SKalle Valo  *
415*7ac9a364SKalle Valo  * 6)  Find difference between current device temperature and (interpolated)
416*7ac9a364SKalle Valo  *     factory-measured temperature for sub-band.  Factory values are in
417*7ac9a364SKalle Valo  *     degrees Celsius.  To calculate current temperature, see comments for
418*7ac9a364SKalle Valo  *     "4965 temperature calculation".
419*7ac9a364SKalle Valo  *
420*7ac9a364SKalle Valo  *     If current temperature is higher than factory temperature, driver must
421*7ac9a364SKalle Valo  *     increase gain (lower gain table idx), and vice verse.
422*7ac9a364SKalle Valo  *
423*7ac9a364SKalle Valo  *     Temperature affects gain differently for different channels:
424*7ac9a364SKalle Valo  *
425*7ac9a364SKalle Valo  *     2.4 GHz all channels:  3.5 degrees per half-dB step
426*7ac9a364SKalle Valo  *     5 GHz channels 34-43:  4.5 degrees per half-dB step
427*7ac9a364SKalle Valo  *     5 GHz channels >= 44:  4.0 degrees per half-dB step
428*7ac9a364SKalle Valo  *
429*7ac9a364SKalle Valo  *     NOTE:  Temperature can increase rapidly when transmitting, especially
430*7ac9a364SKalle Valo  *            with heavy traffic at high txpowers.  Driver should update
431*7ac9a364SKalle Valo  *            temperature calculations often under these conditions to
432*7ac9a364SKalle Valo  *            maintain strong txpower in the face of rising temperature.
433*7ac9a364SKalle Valo  *
434*7ac9a364SKalle Valo  *
435*7ac9a364SKalle Valo  * 7)  Find difference between current power supply voltage indicator
436*7ac9a364SKalle Valo  *     (from "initialize alive") and factory-measured power supply voltage
437*7ac9a364SKalle Valo  *     indicator (EEPROM).
438*7ac9a364SKalle Valo  *
439*7ac9a364SKalle Valo  *     If the current voltage is higher (indicator is lower) than factory
440*7ac9a364SKalle Valo  *     voltage, gain should be reduced (gain table idx increased) by:
441*7ac9a364SKalle Valo  *
442*7ac9a364SKalle Valo  *     (eeprom - current) / 7
443*7ac9a364SKalle Valo  *
444*7ac9a364SKalle Valo  *     If the current voltage is lower (indicator is higher) than factory
445*7ac9a364SKalle Valo  *     voltage, gain should be increased (gain table idx decreased) by:
446*7ac9a364SKalle Valo  *
447*7ac9a364SKalle Valo  *     2 * (current - eeprom) / 7
448*7ac9a364SKalle Valo  *
449*7ac9a364SKalle Valo  *     If number of idx steps in either direction turns out to be > 2,
450*7ac9a364SKalle Valo  *     something is wrong ... just use 0.
451*7ac9a364SKalle Valo  *
452*7ac9a364SKalle Valo  *     NOTE:  Voltage compensation is independent of band/channel.
453*7ac9a364SKalle Valo  *
454*7ac9a364SKalle Valo  *     NOTE:  "Initialize" uCode measures current voltage, which is assumed
455*7ac9a364SKalle Valo  *            to be constant after this initial measurement.  Voltage
456*7ac9a364SKalle Valo  *            compensation for txpower (number of steps in gain table)
457*7ac9a364SKalle Valo  *            may be calculated once and used until the next uCode bootload.
458*7ac9a364SKalle Valo  *
459*7ac9a364SKalle Valo  *
460*7ac9a364SKalle Valo  * 8)  If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
461*7ac9a364SKalle Valo  *     adjust txpower for each transmitter chain, so txpower is balanced
462*7ac9a364SKalle Valo  *     between the two chains.  There are 5 pairs of tx_atten[group][chain]
463*7ac9a364SKalle Valo  *     values in "initialize alive", one pair for each of 5 channel ranges:
464*7ac9a364SKalle Valo  *
465*7ac9a364SKalle Valo  *     Group 0:  5 GHz channel 34-43
466*7ac9a364SKalle Valo  *     Group 1:  5 GHz channel 44-70
467*7ac9a364SKalle Valo  *     Group 2:  5 GHz channel 71-124
468*7ac9a364SKalle Valo  *     Group 3:  5 GHz channel 125-200
469*7ac9a364SKalle Valo  *     Group 4:  2.4 GHz all channels
470*7ac9a364SKalle Valo  *
471*7ac9a364SKalle Valo  *     Add the tx_atten[group][chain] value to the idx for the target chain.
472*7ac9a364SKalle Valo  *     The values are signed, but are in pairs of 0 and a non-negative number,
473*7ac9a364SKalle Valo  *     so as to reduce gain (if necessary) of the "hotter" channel.  This
474*7ac9a364SKalle Valo  *     avoids any need to double-check for regulatory compliance after
475*7ac9a364SKalle Valo  *     this step.
476*7ac9a364SKalle Valo  *
477*7ac9a364SKalle Valo  *
478*7ac9a364SKalle Valo  * 9)  If setting up for a CCK rate, lower the gain by adding a CCK compensation
479*7ac9a364SKalle Valo  *     value to the idx:
480*7ac9a364SKalle Valo  *
481*7ac9a364SKalle Valo  *     Hardware rev B:  9 steps (4.5 dB)
482*7ac9a364SKalle Valo  *     Hardware rev C:  5 steps (2.5 dB)
483*7ac9a364SKalle Valo  *
484*7ac9a364SKalle Valo  *     Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
485*7ac9a364SKalle Valo  *     bits [3:2], 1 = B, 2 = C.
486*7ac9a364SKalle Valo  *
487*7ac9a364SKalle Valo  *     NOTE:  This compensation is in addition to any saturation backoff that
488*7ac9a364SKalle Valo  *            might have been applied in an earlier step.
489*7ac9a364SKalle Valo  *
490*7ac9a364SKalle Valo  *
491*7ac9a364SKalle Valo  * 10) Select the gain table, based on band (2.4 vs 5 GHz).
492*7ac9a364SKalle Valo  *
493*7ac9a364SKalle Valo  *     Limit the adjusted idx to stay within the table!
494*7ac9a364SKalle Valo  *
495*7ac9a364SKalle Valo  *
496*7ac9a364SKalle Valo  * 11) Read gain table entries for DSP and radio gain, place into appropriate
497*7ac9a364SKalle Valo  *     location(s) in command (struct il4965_txpowertable_cmd).
498*7ac9a364SKalle Valo  */
499*7ac9a364SKalle Valo 
500*7ac9a364SKalle Valo /**
501*7ac9a364SKalle Valo  * When MIMO is used (2 transmitters operating simultaneously), driver should
502*7ac9a364SKalle Valo  * limit each transmitter to deliver a max of 3 dB below the regulatory limit
503*7ac9a364SKalle Valo  * for the device.  That is, use half power for each transmitter, so total
504*7ac9a364SKalle Valo  * txpower is within regulatory limits.
505*7ac9a364SKalle Valo  *
506*7ac9a364SKalle Valo  * The value "6" represents number of steps in gain table to reduce power 3 dB.
507*7ac9a364SKalle Valo  * Each step is 1/2 dB.
508*7ac9a364SKalle Valo  */
509*7ac9a364SKalle Valo #define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
510*7ac9a364SKalle Valo 
511*7ac9a364SKalle Valo /**
512*7ac9a364SKalle Valo  * CCK gain compensation.
513*7ac9a364SKalle Valo  *
514*7ac9a364SKalle Valo  * When calculating txpowers for CCK, after making sure that the target power
515*7ac9a364SKalle Valo  * is within regulatory and saturation limits, driver must additionally
516*7ac9a364SKalle Valo  * back off gain by adding these values to the gain table idx.
517*7ac9a364SKalle Valo  *
518*7ac9a364SKalle Valo  * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
519*7ac9a364SKalle Valo  * bits [3:2], 1 = B, 2 = C.
520*7ac9a364SKalle Valo  */
521*7ac9a364SKalle Valo #define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
522*7ac9a364SKalle Valo #define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
523*7ac9a364SKalle Valo 
524*7ac9a364SKalle Valo /*
525*7ac9a364SKalle Valo  * 4965 power supply voltage compensation for txpower
526*7ac9a364SKalle Valo  */
527*7ac9a364SKalle Valo #define TX_POWER_IL_VOLTAGE_CODES_PER_03V   (7)
528*7ac9a364SKalle Valo 
529*7ac9a364SKalle Valo /**
530*7ac9a364SKalle Valo  * Gain tables.
531*7ac9a364SKalle Valo  *
532*7ac9a364SKalle Valo  * The following tables contain pair of values for setting txpower, i.e.
533*7ac9a364SKalle Valo  * gain settings for the output of the device's digital signal processor (DSP),
534*7ac9a364SKalle Valo  * and for the analog gain structure of the transmitter.
535*7ac9a364SKalle Valo  *
536*7ac9a364SKalle Valo  * Each entry in the gain tables represents a step of 1/2 dB.  Note that these
537*7ac9a364SKalle Valo  * are *relative* steps, not indications of absolute output power.  Output
538*7ac9a364SKalle Valo  * power varies with temperature, voltage, and channel frequency, and also
539*7ac9a364SKalle Valo  * requires consideration of average power (to satisfy regulatory constraints),
540*7ac9a364SKalle Valo  * and peak power (to avoid distortion of the output signal).
541*7ac9a364SKalle Valo  *
542*7ac9a364SKalle Valo  * Each entry contains two values:
543*7ac9a364SKalle Valo  * 1)  DSP gain (or sometimes called DSP attenuation).  This is a fine-grained
544*7ac9a364SKalle Valo  *     linear value that multiplies the output of the digital signal processor,
545*7ac9a364SKalle Valo  *     before being sent to the analog radio.
546*7ac9a364SKalle Valo  * 2)  Radio gain.  This sets the analog gain of the radio Tx path.
547*7ac9a364SKalle Valo  *     It is a coarser setting, and behaves in a logarithmic (dB) fashion.
548*7ac9a364SKalle Valo  *
549*7ac9a364SKalle Valo  * EEPROM contains factory calibration data for txpower.  This maps actual
550*7ac9a364SKalle Valo  * measured txpower levels to gain settings in the "well known" tables
551*7ac9a364SKalle Valo  * below ("well-known" means here that both factory calibration *and* the
552*7ac9a364SKalle Valo  * driver work with the same table).
553*7ac9a364SKalle Valo  *
554*7ac9a364SKalle Valo  * There are separate tables for 2.4 GHz and 5 GHz bands.  The 5 GHz table
555*7ac9a364SKalle Valo  * has an extension (into negative idxes), in case the driver needs to
556*7ac9a364SKalle Valo  * boost power setting for high device temperatures (higher than would be
557*7ac9a364SKalle Valo  * present during factory calibration).  A 5 Ghz EEPROM idx of "40"
558*7ac9a364SKalle Valo  * corresponds to the 49th entry in the table used by the driver.
559*7ac9a364SKalle Valo  */
560*7ac9a364SKalle Valo #define MIN_TX_GAIN_IDX		(0)	/* highest gain, lowest idx, 2.4 */
561*7ac9a364SKalle Valo #define MIN_TX_GAIN_IDX_52GHZ_EXT	(-9)	/* highest gain, lowest idx, 5 */
562*7ac9a364SKalle Valo 
563*7ac9a364SKalle Valo /**
564*7ac9a364SKalle Valo  * 2.4 GHz gain table
565*7ac9a364SKalle Valo  *
566*7ac9a364SKalle Valo  * Index    Dsp gain   Radio gain
567*7ac9a364SKalle Valo  *   0        110         0x3f      (highest gain)
568*7ac9a364SKalle Valo  *   1        104         0x3f
569*7ac9a364SKalle Valo  *   2         98         0x3f
570*7ac9a364SKalle Valo  *   3        110         0x3e
571*7ac9a364SKalle Valo  *   4        104         0x3e
572*7ac9a364SKalle Valo  *   5         98         0x3e
573*7ac9a364SKalle Valo  *   6        110         0x3d
574*7ac9a364SKalle Valo  *   7        104         0x3d
575*7ac9a364SKalle Valo  *   8         98         0x3d
576*7ac9a364SKalle Valo  *   9        110         0x3c
577*7ac9a364SKalle Valo  *  10        104         0x3c
578*7ac9a364SKalle Valo  *  11         98         0x3c
579*7ac9a364SKalle Valo  *  12        110         0x3b
580*7ac9a364SKalle Valo  *  13        104         0x3b
581*7ac9a364SKalle Valo  *  14         98         0x3b
582*7ac9a364SKalle Valo  *  15        110         0x3a
583*7ac9a364SKalle Valo  *  16        104         0x3a
584*7ac9a364SKalle Valo  *  17         98         0x3a
585*7ac9a364SKalle Valo  *  18        110         0x39
586*7ac9a364SKalle Valo  *  19        104         0x39
587*7ac9a364SKalle Valo  *  20         98         0x39
588*7ac9a364SKalle Valo  *  21        110         0x38
589*7ac9a364SKalle Valo  *  22        104         0x38
590*7ac9a364SKalle Valo  *  23         98         0x38
591*7ac9a364SKalle Valo  *  24        110         0x37
592*7ac9a364SKalle Valo  *  25        104         0x37
593*7ac9a364SKalle Valo  *  26         98         0x37
594*7ac9a364SKalle Valo  *  27        110         0x36
595*7ac9a364SKalle Valo  *  28        104         0x36
596*7ac9a364SKalle Valo  *  29         98         0x36
597*7ac9a364SKalle Valo  *  30        110         0x35
598*7ac9a364SKalle Valo  *  31        104         0x35
599*7ac9a364SKalle Valo  *  32         98         0x35
600*7ac9a364SKalle Valo  *  33        110         0x34
601*7ac9a364SKalle Valo  *  34        104         0x34
602*7ac9a364SKalle Valo  *  35         98         0x34
603*7ac9a364SKalle Valo  *  36        110         0x33
604*7ac9a364SKalle Valo  *  37        104         0x33
605*7ac9a364SKalle Valo  *  38         98         0x33
606*7ac9a364SKalle Valo  *  39        110         0x32
607*7ac9a364SKalle Valo  *  40        104         0x32
608*7ac9a364SKalle Valo  *  41         98         0x32
609*7ac9a364SKalle Valo  *  42        110         0x31
610*7ac9a364SKalle Valo  *  43        104         0x31
611*7ac9a364SKalle Valo  *  44         98         0x31
612*7ac9a364SKalle Valo  *  45        110         0x30
613*7ac9a364SKalle Valo  *  46        104         0x30
614*7ac9a364SKalle Valo  *  47         98         0x30
615*7ac9a364SKalle Valo  *  48        110          0x6
616*7ac9a364SKalle Valo  *  49        104          0x6
617*7ac9a364SKalle Valo  *  50         98          0x6
618*7ac9a364SKalle Valo  *  51        110          0x5
619*7ac9a364SKalle Valo  *  52        104          0x5
620*7ac9a364SKalle Valo  *  53         98          0x5
621*7ac9a364SKalle Valo  *  54        110          0x4
622*7ac9a364SKalle Valo  *  55        104          0x4
623*7ac9a364SKalle Valo  *  56         98          0x4
624*7ac9a364SKalle Valo  *  57        110          0x3
625*7ac9a364SKalle Valo  *  58        104          0x3
626*7ac9a364SKalle Valo  *  59         98          0x3
627*7ac9a364SKalle Valo  *  60        110          0x2
628*7ac9a364SKalle Valo  *  61        104          0x2
629*7ac9a364SKalle Valo  *  62         98          0x2
630*7ac9a364SKalle Valo  *  63        110          0x1
631*7ac9a364SKalle Valo  *  64        104          0x1
632*7ac9a364SKalle Valo  *  65         98          0x1
633*7ac9a364SKalle Valo  *  66        110          0x0
634*7ac9a364SKalle Valo  *  67        104          0x0
635*7ac9a364SKalle Valo  *  68         98          0x0
636*7ac9a364SKalle Valo  *  69         97            0
637*7ac9a364SKalle Valo  *  70         96            0
638*7ac9a364SKalle Valo  *  71         95            0
639*7ac9a364SKalle Valo  *  72         94            0
640*7ac9a364SKalle Valo  *  73         93            0
641*7ac9a364SKalle Valo  *  74         92            0
642*7ac9a364SKalle Valo  *  75         91            0
643*7ac9a364SKalle Valo  *  76         90            0
644*7ac9a364SKalle Valo  *  77         89            0
645*7ac9a364SKalle Valo  *  78         88            0
646*7ac9a364SKalle Valo  *  79         87            0
647*7ac9a364SKalle Valo  *  80         86            0
648*7ac9a364SKalle Valo  *  81         85            0
649*7ac9a364SKalle Valo  *  82         84            0
650*7ac9a364SKalle Valo  *  83         83            0
651*7ac9a364SKalle Valo  *  84         82            0
652*7ac9a364SKalle Valo  *  85         81            0
653*7ac9a364SKalle Valo  *  86         80            0
654*7ac9a364SKalle Valo  *  87         79            0
655*7ac9a364SKalle Valo  *  88         78            0
656*7ac9a364SKalle Valo  *  89         77            0
657*7ac9a364SKalle Valo  *  90         76            0
658*7ac9a364SKalle Valo  *  91         75            0
659*7ac9a364SKalle Valo  *  92         74            0
660*7ac9a364SKalle Valo  *  93         73            0
661*7ac9a364SKalle Valo  *  94         72            0
662*7ac9a364SKalle Valo  *  95         71            0
663*7ac9a364SKalle Valo  *  96         70            0
664*7ac9a364SKalle Valo  *  97         69            0
665*7ac9a364SKalle Valo  *  98         68            0
666*7ac9a364SKalle Valo  */
667*7ac9a364SKalle Valo 
668*7ac9a364SKalle Valo /**
669*7ac9a364SKalle Valo  * 5 GHz gain table
670*7ac9a364SKalle Valo  *
671*7ac9a364SKalle Valo  * Index    Dsp gain   Radio gain
672*7ac9a364SKalle Valo  *  -9 	      123         0x3F      (highest gain)
673*7ac9a364SKalle Valo  *  -8 	      117         0x3F
674*7ac9a364SKalle Valo  *  -7        110         0x3F
675*7ac9a364SKalle Valo  *  -6        104         0x3F
676*7ac9a364SKalle Valo  *  -5         98         0x3F
677*7ac9a364SKalle Valo  *  -4        110         0x3E
678*7ac9a364SKalle Valo  *  -3        104         0x3E
679*7ac9a364SKalle Valo  *  -2         98         0x3E
680*7ac9a364SKalle Valo  *  -1        110         0x3D
681*7ac9a364SKalle Valo  *   0        104         0x3D
682*7ac9a364SKalle Valo  *   1         98         0x3D
683*7ac9a364SKalle Valo  *   2        110         0x3C
684*7ac9a364SKalle Valo  *   3        104         0x3C
685*7ac9a364SKalle Valo  *   4         98         0x3C
686*7ac9a364SKalle Valo  *   5        110         0x3B
687*7ac9a364SKalle Valo  *   6        104         0x3B
688*7ac9a364SKalle Valo  *   7         98         0x3B
689*7ac9a364SKalle Valo  *   8        110         0x3A
690*7ac9a364SKalle Valo  *   9        104         0x3A
691*7ac9a364SKalle Valo  *  10         98         0x3A
692*7ac9a364SKalle Valo  *  11        110         0x39
693*7ac9a364SKalle Valo  *  12        104         0x39
694*7ac9a364SKalle Valo  *  13         98         0x39
695*7ac9a364SKalle Valo  *  14        110         0x38
696*7ac9a364SKalle Valo  *  15        104         0x38
697*7ac9a364SKalle Valo  *  16         98         0x38
698*7ac9a364SKalle Valo  *  17        110         0x37
699*7ac9a364SKalle Valo  *  18        104         0x37
700*7ac9a364SKalle Valo  *  19         98         0x37
701*7ac9a364SKalle Valo  *  20        110         0x36
702*7ac9a364SKalle Valo  *  21        104         0x36
703*7ac9a364SKalle Valo  *  22         98         0x36
704*7ac9a364SKalle Valo  *  23        110         0x35
705*7ac9a364SKalle Valo  *  24        104         0x35
706*7ac9a364SKalle Valo  *  25         98         0x35
707*7ac9a364SKalle Valo  *  26        110         0x34
708*7ac9a364SKalle Valo  *  27        104         0x34
709*7ac9a364SKalle Valo  *  28         98         0x34
710*7ac9a364SKalle Valo  *  29        110         0x33
711*7ac9a364SKalle Valo  *  30        104         0x33
712*7ac9a364SKalle Valo  *  31         98         0x33
713*7ac9a364SKalle Valo  *  32        110         0x32
714*7ac9a364SKalle Valo  *  33        104         0x32
715*7ac9a364SKalle Valo  *  34         98         0x32
716*7ac9a364SKalle Valo  *  35        110         0x31
717*7ac9a364SKalle Valo  *  36        104         0x31
718*7ac9a364SKalle Valo  *  37         98         0x31
719*7ac9a364SKalle Valo  *  38        110         0x30
720*7ac9a364SKalle Valo  *  39        104         0x30
721*7ac9a364SKalle Valo  *  40         98         0x30
722*7ac9a364SKalle Valo  *  41        110         0x25
723*7ac9a364SKalle Valo  *  42        104         0x25
724*7ac9a364SKalle Valo  *  43         98         0x25
725*7ac9a364SKalle Valo  *  44        110         0x24
726*7ac9a364SKalle Valo  *  45        104         0x24
727*7ac9a364SKalle Valo  *  46         98         0x24
728*7ac9a364SKalle Valo  *  47        110         0x23
729*7ac9a364SKalle Valo  *  48        104         0x23
730*7ac9a364SKalle Valo  *  49         98         0x23
731*7ac9a364SKalle Valo  *  50        110         0x22
732*7ac9a364SKalle Valo  *  51        104         0x18
733*7ac9a364SKalle Valo  *  52         98         0x18
734*7ac9a364SKalle Valo  *  53        110         0x17
735*7ac9a364SKalle Valo  *  54        104         0x17
736*7ac9a364SKalle Valo  *  55         98         0x17
737*7ac9a364SKalle Valo  *  56        110         0x16
738*7ac9a364SKalle Valo  *  57        104         0x16
739*7ac9a364SKalle Valo  *  58         98         0x16
740*7ac9a364SKalle Valo  *  59        110         0x15
741*7ac9a364SKalle Valo  *  60        104         0x15
742*7ac9a364SKalle Valo  *  61         98         0x15
743*7ac9a364SKalle Valo  *  62        110         0x14
744*7ac9a364SKalle Valo  *  63        104         0x14
745*7ac9a364SKalle Valo  *  64         98         0x14
746*7ac9a364SKalle Valo  *  65        110         0x13
747*7ac9a364SKalle Valo  *  66        104         0x13
748*7ac9a364SKalle Valo  *  67         98         0x13
749*7ac9a364SKalle Valo  *  68        110         0x12
750*7ac9a364SKalle Valo  *  69        104         0x08
751*7ac9a364SKalle Valo  *  70         98         0x08
752*7ac9a364SKalle Valo  *  71        110         0x07
753*7ac9a364SKalle Valo  *  72        104         0x07
754*7ac9a364SKalle Valo  *  73         98         0x07
755*7ac9a364SKalle Valo  *  74        110         0x06
756*7ac9a364SKalle Valo  *  75        104         0x06
757*7ac9a364SKalle Valo  *  76         98         0x06
758*7ac9a364SKalle Valo  *  77        110         0x05
759*7ac9a364SKalle Valo  *  78        104         0x05
760*7ac9a364SKalle Valo  *  79         98         0x05
761*7ac9a364SKalle Valo  *  80        110         0x04
762*7ac9a364SKalle Valo  *  81        104         0x04
763*7ac9a364SKalle Valo  *  82         98         0x04
764*7ac9a364SKalle Valo  *  83        110         0x03
765*7ac9a364SKalle Valo  *  84        104         0x03
766*7ac9a364SKalle Valo  *  85         98         0x03
767*7ac9a364SKalle Valo  *  86        110         0x02
768*7ac9a364SKalle Valo  *  87        104         0x02
769*7ac9a364SKalle Valo  *  88         98         0x02
770*7ac9a364SKalle Valo  *  89        110         0x01
771*7ac9a364SKalle Valo  *  90        104         0x01
772*7ac9a364SKalle Valo  *  91         98         0x01
773*7ac9a364SKalle Valo  *  92        110         0x00
774*7ac9a364SKalle Valo  *  93        104         0x00
775*7ac9a364SKalle Valo  *  94         98         0x00
776*7ac9a364SKalle Valo  *  95         93         0x00
777*7ac9a364SKalle Valo  *  96         88         0x00
778*7ac9a364SKalle Valo  *  97         83         0x00
779*7ac9a364SKalle Valo  *  98         78         0x00
780*7ac9a364SKalle Valo  */
781*7ac9a364SKalle Valo 
782*7ac9a364SKalle Valo /**
783*7ac9a364SKalle Valo  * Sanity checks and default values for EEPROM regulatory levels.
784*7ac9a364SKalle Valo  * If EEPROM values fall outside MIN/MAX range, use default values.
785*7ac9a364SKalle Valo  *
786*7ac9a364SKalle Valo  * Regulatory limits refer to the maximum average txpower allowed by
787*7ac9a364SKalle Valo  * regulatory agencies in the geographies in which the device is meant
788*7ac9a364SKalle Valo  * to be operated.  These limits are SKU-specific (i.e. geography-specific),
789*7ac9a364SKalle Valo  * and channel-specific; each channel has an individual regulatory limit
790*7ac9a364SKalle Valo  * listed in the EEPROM.
791*7ac9a364SKalle Valo  *
792*7ac9a364SKalle Valo  * Units are in half-dBm (i.e. "34" means 17 dBm).
793*7ac9a364SKalle Valo  */
794*7ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_REGULATORY_24   (34)
795*7ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_REGULATORY_52   (34)
796*7ac9a364SKalle Valo #define IL_TX_POWER_REGULATORY_MIN          (0)
797*7ac9a364SKalle Valo #define IL_TX_POWER_REGULATORY_MAX          (34)
798*7ac9a364SKalle Valo 
799*7ac9a364SKalle Valo /**
800*7ac9a364SKalle Valo  * Sanity checks and default values for EEPROM saturation levels.
801*7ac9a364SKalle Valo  * If EEPROM values fall outside MIN/MAX range, use default values.
802*7ac9a364SKalle Valo  *
803*7ac9a364SKalle Valo  * Saturation is the highest level that the output power amplifier can produce
804*7ac9a364SKalle Valo  * without significant clipping distortion.  This is a "peak" power level.
805*7ac9a364SKalle Valo  * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
806*7ac9a364SKalle Valo  * require differing amounts of backoff, relative to their average power output,
807*7ac9a364SKalle Valo  * in order to avoid clipping distortion.
808*7ac9a364SKalle Valo  *
809*7ac9a364SKalle Valo  * Driver must make sure that it is violating neither the saturation limit,
810*7ac9a364SKalle Valo  * nor the regulatory limit, when calculating Tx power settings for various
811*7ac9a364SKalle Valo  * rates.
812*7ac9a364SKalle Valo  *
813*7ac9a364SKalle Valo  * Units are in half-dBm (i.e. "38" means 19 dBm).
814*7ac9a364SKalle Valo  */
815*7ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_SATURATION_24   (38)
816*7ac9a364SKalle Valo #define IL_TX_POWER_DEFAULT_SATURATION_52   (38)
817*7ac9a364SKalle Valo #define IL_TX_POWER_SATURATION_MIN          (20)
818*7ac9a364SKalle Valo #define IL_TX_POWER_SATURATION_MAX          (50)
819*7ac9a364SKalle Valo 
820*7ac9a364SKalle Valo /**
821*7ac9a364SKalle Valo  * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
822*7ac9a364SKalle Valo  * and thermal Txpower calibration.
823*7ac9a364SKalle Valo  *
824*7ac9a364SKalle Valo  * When calculating txpower, driver must compensate for current device
825*7ac9a364SKalle Valo  * temperature; higher temperature requires higher gain.  Driver must calculate
826*7ac9a364SKalle Valo  * current temperature (see "4965 temperature calculation"), then compare vs.
827*7ac9a364SKalle Valo  * factory calibration temperature in EEPROM; if current temperature is higher
828*7ac9a364SKalle Valo  * than factory temperature, driver must *increase* gain by proportions shown
829*7ac9a364SKalle Valo  * in table below.  If current temperature is lower than factory, driver must
830*7ac9a364SKalle Valo  * *decrease* gain.
831*7ac9a364SKalle Valo  *
832*7ac9a364SKalle Valo  * Different frequency ranges require different compensation, as shown below.
833*7ac9a364SKalle Valo  */
834*7ac9a364SKalle Valo /* Group 0, 5.2 GHz ch 34-43:  4.5 degrees per 1/2 dB. */
835*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR1_FCH 34
836*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR1_LCH 43
837*7ac9a364SKalle Valo 
838*7ac9a364SKalle Valo /* Group 1, 5.3 GHz ch 44-70:  4.0 degrees per 1/2 dB. */
839*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR2_FCH 44
840*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR2_LCH 70
841*7ac9a364SKalle Valo 
842*7ac9a364SKalle Valo /* Group 2, 5.5 GHz ch 71-124:  4.0 degrees per 1/2 dB. */
843*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR3_FCH 71
844*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR3_LCH 124
845*7ac9a364SKalle Valo 
846*7ac9a364SKalle Valo /* Group 3, 5.7 GHz ch 125-200:  4.0 degrees per 1/2 dB. */
847*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR4_FCH 125
848*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR4_LCH 200
849*7ac9a364SKalle Valo 
850*7ac9a364SKalle Valo /* Group 4, 2.4 GHz all channels:  3.5 degrees per 1/2 dB. */
851*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR5_FCH 1
852*7ac9a364SKalle Valo #define CALIB_IL_TX_ATTEN_GR5_LCH 20
853*7ac9a364SKalle Valo 
854*7ac9a364SKalle Valo enum {
855*7ac9a364SKalle Valo 	CALIB_CH_GROUP_1 = 0,
856*7ac9a364SKalle Valo 	CALIB_CH_GROUP_2 = 1,
857*7ac9a364SKalle Valo 	CALIB_CH_GROUP_3 = 2,
858*7ac9a364SKalle Valo 	CALIB_CH_GROUP_4 = 3,
859*7ac9a364SKalle Valo 	CALIB_CH_GROUP_5 = 4,
860*7ac9a364SKalle Valo 	CALIB_CH_GROUP_MAX
861*7ac9a364SKalle Valo };
862*7ac9a364SKalle Valo 
863*7ac9a364SKalle Valo /********************* END TXPOWER *****************************************/
864*7ac9a364SKalle Valo 
865*7ac9a364SKalle Valo /**
866*7ac9a364SKalle Valo  * Tx/Rx Queues
867*7ac9a364SKalle Valo  *
868*7ac9a364SKalle Valo  * Most communication between driver and 4965 is via queues of data buffers.
869*7ac9a364SKalle Valo  * For example, all commands that the driver issues to device's embedded
870*7ac9a364SKalle Valo  * controller (uCode) are via the command queue (one of the Tx queues).  All
871*7ac9a364SKalle Valo  * uCode command responses/replies/notifications, including Rx frames, are
872*7ac9a364SKalle Valo  * conveyed from uCode to driver via the Rx queue.
873*7ac9a364SKalle Valo  *
874*7ac9a364SKalle Valo  * Most support for these queues, including handshake support, resides in
875*7ac9a364SKalle Valo  * structures in host DRAM, shared between the driver and the device.  When
876*7ac9a364SKalle Valo  * allocating this memory, the driver must make sure that data written by
877*7ac9a364SKalle Valo  * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
878*7ac9a364SKalle Valo  * cache memory), so DRAM and cache are consistent, and the device can
879*7ac9a364SKalle Valo  * immediately see changes made by the driver.
880*7ac9a364SKalle Valo  *
881*7ac9a364SKalle Valo  * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via
882*7ac9a364SKalle Valo  * up to 7 DMA channels (FIFOs).  Each Tx queue is supported by a circular array
883*7ac9a364SKalle Valo  * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
884*7ac9a364SKalle Valo  */
885*7ac9a364SKalle Valo #define IL49_NUM_FIFOS	7
886*7ac9a364SKalle Valo #define IL49_CMD_FIFO_NUM	4
887*7ac9a364SKalle Valo #define IL49_NUM_QUEUES	16
888*7ac9a364SKalle Valo #define IL49_NUM_AMPDU_QUEUES	8
889*7ac9a364SKalle Valo 
890*7ac9a364SKalle Valo /**
891*7ac9a364SKalle Valo  * struct il4965_schedq_bc_tbl
892*7ac9a364SKalle Valo  *
893*7ac9a364SKalle Valo  * Byte Count table
894*7ac9a364SKalle Valo  *
895*7ac9a364SKalle Valo  * Each Tx queue uses a byte-count table containing 320 entries:
896*7ac9a364SKalle Valo  * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
897*7ac9a364SKalle Valo  * duplicate the first 64 entries (to avoid wrap-around within a Tx win;
898*7ac9a364SKalle Valo  * max Tx win is 64 TFDs).
899*7ac9a364SKalle Valo  *
900*7ac9a364SKalle Valo  * When driver sets up a new TFD, it must also enter the total byte count
901*7ac9a364SKalle Valo  * of the frame to be transmitted into the corresponding entry in the byte
902*7ac9a364SKalle Valo  * count table for the chosen Tx queue.  If the TFD idx is 0-63, the driver
903*7ac9a364SKalle Valo  * must duplicate the byte count entry in corresponding idx 256-319.
904*7ac9a364SKalle Valo  *
905*7ac9a364SKalle Valo  * padding puts each byte count table on a 1024-byte boundary;
906*7ac9a364SKalle Valo  * 4965 assumes tables are separated by 1024 bytes.
907*7ac9a364SKalle Valo  */
908*7ac9a364SKalle Valo struct il4965_scd_bc_tbl {
909*7ac9a364SKalle Valo 	__le16 tfd_offset[TFD_QUEUE_BC_SIZE];
910*7ac9a364SKalle Valo 	u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
911*7ac9a364SKalle Valo } __packed;
912*7ac9a364SKalle Valo 
913*7ac9a364SKalle Valo #define IL4965_RTC_INST_LOWER_BOUND		(0x000000)
914*7ac9a364SKalle Valo 
915*7ac9a364SKalle Valo /* RSSI to dBm */
916*7ac9a364SKalle Valo #define IL4965_RSSI_OFFSET	44
917*7ac9a364SKalle Valo 
918*7ac9a364SKalle Valo /* PCI registers */
919*7ac9a364SKalle Valo #define PCI_CFG_RETRY_TIMEOUT	0x041
920*7ac9a364SKalle Valo 
921*7ac9a364SKalle Valo #define IL4965_DEFAULT_TX_RETRY  15
922*7ac9a364SKalle Valo 
923*7ac9a364SKalle Valo /* EEPROM */
924*7ac9a364SKalle Valo #define IL4965_FIRST_AMPDU_QUEUE	10
925*7ac9a364SKalle Valo 
926*7ac9a364SKalle Valo /* Calibration */
927*7ac9a364SKalle Valo void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
928*7ac9a364SKalle Valo void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
929*7ac9a364SKalle Valo void il4965_init_sensitivity(struct il_priv *il);
930*7ac9a364SKalle Valo void il4965_reset_run_time_calib(struct il_priv *il);
931*7ac9a364SKalle Valo 
932*7ac9a364SKalle Valo /* Debug */
933*7ac9a364SKalle Valo #ifdef CONFIG_IWLEGACY_DEBUGFS
934*7ac9a364SKalle Valo extern const struct il_debugfs_ops il4965_debugfs_ops;
935*7ac9a364SKalle Valo #endif
936*7ac9a364SKalle Valo 
937*7ac9a364SKalle Valo /****************************/
938*7ac9a364SKalle Valo /* Flow Handler Definitions */
939*7ac9a364SKalle Valo /****************************/
940*7ac9a364SKalle Valo 
941*7ac9a364SKalle Valo /**
942*7ac9a364SKalle Valo  * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
943*7ac9a364SKalle Valo  * Addresses are offsets from device's PCI hardware base address.
944*7ac9a364SKalle Valo  */
945*7ac9a364SKalle Valo #define FH49_MEM_LOWER_BOUND                   (0x1000)
946*7ac9a364SKalle Valo #define FH49_MEM_UPPER_BOUND                   (0x2000)
947*7ac9a364SKalle Valo 
948*7ac9a364SKalle Valo /**
949*7ac9a364SKalle Valo  * Keep-Warm (KW) buffer base address.
950*7ac9a364SKalle Valo  *
951*7ac9a364SKalle Valo  * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
952*7ac9a364SKalle Valo  * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
953*7ac9a364SKalle Valo  * DRAM access when 4965 is Txing or Rxing.  The dummy accesses prevent host
954*7ac9a364SKalle Valo  * from going into a power-savings mode that would cause higher DRAM latency,
955*7ac9a364SKalle Valo  * and possible data over/under-runs, before all Tx/Rx is complete.
956*7ac9a364SKalle Valo  *
957*7ac9a364SKalle Valo  * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4)
958*7ac9a364SKalle Valo  * of the buffer, which must be 4K aligned.  Once this is set up, the 4965
959*7ac9a364SKalle Valo  * automatically invokes keep-warm accesses when normal accesses might not
960*7ac9a364SKalle Valo  * be sufficient to maintain fast DRAM response.
961*7ac9a364SKalle Valo  *
962*7ac9a364SKalle Valo  * Bit fields:
963*7ac9a364SKalle Valo  *  31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
964*7ac9a364SKalle Valo  */
965*7ac9a364SKalle Valo #define FH49_KW_MEM_ADDR_REG		     (FH49_MEM_LOWER_BOUND + 0x97C)
966*7ac9a364SKalle Valo 
967*7ac9a364SKalle Valo /**
968*7ac9a364SKalle Valo  * TFD Circular Buffers Base (CBBC) addresses
969*7ac9a364SKalle Valo  *
970*7ac9a364SKalle Valo  * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
971*7ac9a364SKalle Valo  * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
972*7ac9a364SKalle Valo  * (see struct il_tfd_frame).  These 16 pointer registers are offset by 0x04
973*7ac9a364SKalle Valo  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
974*7ac9a364SKalle Valo  * aligned (address bits 0-7 must be 0).
975*7ac9a364SKalle Valo  *
976*7ac9a364SKalle Valo  * Bit fields in each pointer register:
977*7ac9a364SKalle Valo  *  27-0: TFD CB physical base address [35:8], must be 256-byte aligned
978*7ac9a364SKalle Valo  */
979*7ac9a364SKalle Valo #define FH49_MEM_CBBC_LOWER_BOUND          (FH49_MEM_LOWER_BOUND + 0x9D0)
980*7ac9a364SKalle Valo #define FH49_MEM_CBBC_UPPER_BOUND          (FH49_MEM_LOWER_BOUND + 0xA10)
981*7ac9a364SKalle Valo 
982*7ac9a364SKalle Valo /* Find TFD CB base pointer for given queue (range 0-15). */
983*7ac9a364SKalle Valo #define FH49_MEM_CBBC_QUEUE(x)  (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
984*7ac9a364SKalle Valo 
985*7ac9a364SKalle Valo /**
986*7ac9a364SKalle Valo  * Rx SRAM Control and Status Registers (RSCSR)
987*7ac9a364SKalle Valo  *
988*7ac9a364SKalle Valo  * These registers provide handshake between driver and 4965 for the Rx queue
989*7ac9a364SKalle Valo  * (this queue handles *all* command responses, notifications, Rx data, etc.
990*7ac9a364SKalle Valo  * sent from 4965 uCode to host driver).  Unlike Tx, there is only one Rx
991*7ac9a364SKalle Valo  * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
992*7ac9a364SKalle Valo  * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
993*7ac9a364SKalle Valo  * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
994*7ac9a364SKalle Valo  * mapping between RBDs and RBs.
995*7ac9a364SKalle Valo  *
996*7ac9a364SKalle Valo  * Driver must allocate host DRAM memory for the following, and set the
997*7ac9a364SKalle Valo  * physical address of each into 4965 registers:
998*7ac9a364SKalle Valo  *
999*7ac9a364SKalle Valo  * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1000*7ac9a364SKalle Valo  *     entries (although any power of 2, up to 4096, is selectable by driver).
1001*7ac9a364SKalle Valo  *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
1002*7ac9a364SKalle Valo  *     (typically 4K, although 8K or 16K are also selectable by driver).
1003*7ac9a364SKalle Valo  *     Driver sets up RB size and number of RBDs in the CB via Rx config
1004*7ac9a364SKalle Valo  *     register FH49_MEM_RCSR_CHNL0_CONFIG_REG.
1005*7ac9a364SKalle Valo  *
1006*7ac9a364SKalle Valo  *     Bit fields within one RBD:
1007*7ac9a364SKalle Valo  *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned
1008*7ac9a364SKalle Valo  *
1009*7ac9a364SKalle Valo  *     Driver sets physical address [35:8] of base of RBD circular buffer
1010*7ac9a364SKalle Valo  *     into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1011*7ac9a364SKalle Valo  *
1012*7ac9a364SKalle Valo  * 2)  Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
1013*7ac9a364SKalle Valo  *     (RBs) have been filled, via a "write pointer", actually the idx of
1014*7ac9a364SKalle Valo  *     the RB's corresponding RBD within the circular buffer.  Driver sets
1015*7ac9a364SKalle Valo  *     physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1016*7ac9a364SKalle Valo  *
1017*7ac9a364SKalle Valo  *     Bit fields in lower dword of Rx status buffer (upper dword not used
1018*7ac9a364SKalle Valo  *     by driver; see struct il4965_shared, val0):
1019*7ac9a364SKalle Valo  *     31-12:  Not used by driver
1020*7ac9a364SKalle Valo  *     11- 0:  Index of last filled Rx buffer descriptor
1021*7ac9a364SKalle Valo  *             (4965 writes, driver reads this value)
1022*7ac9a364SKalle Valo  *
1023*7ac9a364SKalle Valo  * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
1024*7ac9a364SKalle Valo  * enter pointers to these RBs into contiguous RBD circular buffer entries,
1025*7ac9a364SKalle Valo  * and update the 4965's "write" idx register,
1026*7ac9a364SKalle Valo  * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG.
1027*7ac9a364SKalle Valo  *
1028*7ac9a364SKalle Valo  * This "write" idx corresponds to the *next* RBD that the driver will make
1029*7ac9a364SKalle Valo  * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1030*7ac9a364SKalle Valo  * the circular buffer.  This value should initially be 0 (before preparing any
1031*7ac9a364SKalle Valo  * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1032*7ac9a364SKalle Valo  * wrap back to 0 at the end of the circular buffer (but don't wrap before
1033*7ac9a364SKalle Valo  * "read" idx has advanced past 1!  See below).
1034*7ac9a364SKalle Valo  * NOTE:  4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8.
1035*7ac9a364SKalle Valo  *
1036*7ac9a364SKalle Valo  * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
1037*7ac9a364SKalle Valo  * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1038*7ac9a364SKalle Valo  * to tell the driver the idx of the latest filled RBD.  The driver must
1039*7ac9a364SKalle Valo  * read this "read" idx from DRAM after receiving an Rx interrupt from 4965.
1040*7ac9a364SKalle Valo  *
1041*7ac9a364SKalle Valo  * The driver must also internally keep track of a third idx, which is the
1042*7ac9a364SKalle Valo  * next RBD to process.  When receiving an Rx interrupt, driver should process
1043*7ac9a364SKalle Valo  * all filled but unprocessed RBs up to, but not including, the RB
1044*7ac9a364SKalle Valo  * corresponding to the "read" idx.  For example, if "read" idx becomes "1",
1045*7ac9a364SKalle Valo  * driver may process the RB pointed to by RBD 0.  Depending on volume of
1046*7ac9a364SKalle Valo  * traffic, there may be many RBs to process.
1047*7ac9a364SKalle Valo  *
1048*7ac9a364SKalle Valo  * If read idx == write idx, 4965 thinks there is no room to put new data.
1049*7ac9a364SKalle Valo  * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
1050*7ac9a364SKalle Valo  * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1051*7ac9a364SKalle Valo  * and "read" idxes; that is, make sure that there are no more than 254
1052*7ac9a364SKalle Valo  * buffers waiting to be filled.
1053*7ac9a364SKalle Valo  */
1054*7ac9a364SKalle Valo #define FH49_MEM_RSCSR_LOWER_BOUND	(FH49_MEM_LOWER_BOUND + 0xBC0)
1055*7ac9a364SKalle Valo #define FH49_MEM_RSCSR_UPPER_BOUND	(FH49_MEM_LOWER_BOUND + 0xC00)
1056*7ac9a364SKalle Valo #define FH49_MEM_RSCSR_CHNL0		(FH49_MEM_RSCSR_LOWER_BOUND)
1057*7ac9a364SKalle Valo 
1058*7ac9a364SKalle Valo /**
1059*7ac9a364SKalle Valo  * Physical base address of 8-byte Rx Status buffer.
1060*7ac9a364SKalle Valo  * Bit fields:
1061*7ac9a364SKalle Valo  *  31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1062*7ac9a364SKalle Valo  */
1063*7ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_STTS_WPTR_REG	(FH49_MEM_RSCSR_CHNL0)
1064*7ac9a364SKalle Valo 
1065*7ac9a364SKalle Valo /**
1066*7ac9a364SKalle Valo  * Physical base address of Rx Buffer Descriptor Circular Buffer.
1067*7ac9a364SKalle Valo  * Bit fields:
1068*7ac9a364SKalle Valo  *  27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
1069*7ac9a364SKalle Valo  */
1070*7ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_RBDCB_BASE_REG	(FH49_MEM_RSCSR_CHNL0 + 0x004)
1071*7ac9a364SKalle Valo 
1072*7ac9a364SKalle Valo /**
1073*7ac9a364SKalle Valo  * Rx write pointer (idx, really!).
1074*7ac9a364SKalle Valo  * Bit fields:
1075*7ac9a364SKalle Valo  *  11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
1076*7ac9a364SKalle Valo  *         NOTE:  For 256-entry circular buffer, use only bits [7:0].
1077*7ac9a364SKalle Valo  */
1078*7ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG	(FH49_MEM_RSCSR_CHNL0 + 0x008)
1079*7ac9a364SKalle Valo #define FH49_RSCSR_CHNL0_WPTR        (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG)
1080*7ac9a364SKalle Valo 
1081*7ac9a364SKalle Valo /**
1082*7ac9a364SKalle Valo  * Rx Config/Status Registers (RCSR)
1083*7ac9a364SKalle Valo  * Rx Config Reg for channel 0 (only channel used)
1084*7ac9a364SKalle Valo  *
1085*7ac9a364SKalle Valo  * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1086*7ac9a364SKalle Valo  * normal operation (see bit fields).
1087*7ac9a364SKalle Valo  *
1088*7ac9a364SKalle Valo  * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1089*7ac9a364SKalle Valo  * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG	for
1090*7ac9a364SKalle Valo  * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1091*7ac9a364SKalle Valo  *
1092*7ac9a364SKalle Valo  * Bit fields:
1093*7ac9a364SKalle Valo  * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1094*7ac9a364SKalle Valo  *        '10' operate normally
1095*7ac9a364SKalle Valo  * 29-24: reserved
1096*7ac9a364SKalle Valo  * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1097*7ac9a364SKalle Valo  *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
1098*7ac9a364SKalle Valo  * 19-18: reserved
1099*7ac9a364SKalle Valo  * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1100*7ac9a364SKalle Valo  *        '10' 12K, '11' 16K.
1101*7ac9a364SKalle Valo  * 15-14: reserved
1102*7ac9a364SKalle Valo  * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1103*7ac9a364SKalle Valo  * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1104*7ac9a364SKalle Valo  *        typical value 0x10 (about 1/2 msec)
1105*7ac9a364SKalle Valo  *  3- 0: reserved
1106*7ac9a364SKalle Valo  */
1107*7ac9a364SKalle Valo #define FH49_MEM_RCSR_LOWER_BOUND      (FH49_MEM_LOWER_BOUND + 0xC00)
1108*7ac9a364SKalle Valo #define FH49_MEM_RCSR_UPPER_BOUND      (FH49_MEM_LOWER_BOUND + 0xCC0)
1109*7ac9a364SKalle Valo #define FH49_MEM_RCSR_CHNL0            (FH49_MEM_RCSR_LOWER_BOUND)
1110*7ac9a364SKalle Valo 
1111*7ac9a364SKalle Valo #define FH49_MEM_RCSR_CHNL0_CONFIG_REG	(FH49_MEM_RCSR_CHNL0)
1112*7ac9a364SKalle Valo 
1113*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0)	/* bits 4-11 */
1114*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK   (0x00001000)	/* bits 12 */
1115*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000)	/* bit 15 */
1116*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK   (0x00030000)	/* bits 16-17 */
1117*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000)	/* bits 20-23 */
1118*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000)	/* bits 30-31 */
1119*7ac9a364SKalle Valo 
1120*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS	(20)
1121*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS	(4)
1122*7ac9a364SKalle Valo #define RX_RB_TIMEOUT	(0x10)
1123*7ac9a364SKalle Valo 
1124*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL         (0x00000000)
1125*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL     (0x40000000)
1126*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL        (0x80000000)
1127*7ac9a364SKalle Valo 
1128*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K    (0x00000000)
1129*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K    (0x00010000)
1130*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K   (0x00020000)
1131*7ac9a364SKalle Valo #define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K   (0x00030000)
1132*7ac9a364SKalle Valo 
1133*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY              (0x00000004)
1134*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL    (0x00000000)
1135*7ac9a364SKalle Valo #define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL  (0x00001000)
1136*7ac9a364SKalle Valo 
1137*7ac9a364SKalle Valo /**
1138*7ac9a364SKalle Valo  * Rx Shared Status Registers (RSSR)
1139*7ac9a364SKalle Valo  *
1140*7ac9a364SKalle Valo  * After stopping Rx DMA channel (writing 0 to
1141*7ac9a364SKalle Valo  * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1142*7ac9a364SKalle Valo  * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1143*7ac9a364SKalle Valo  *
1144*7ac9a364SKalle Valo  * Bit fields:
1145*7ac9a364SKalle Valo  *  24:  1 = Channel 0 is idle
1146*7ac9a364SKalle Valo  *
1147*7ac9a364SKalle Valo  * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1148*7ac9a364SKalle Valo  * contain default values that should not be altered by the driver.
1149*7ac9a364SKalle Valo  */
1150*7ac9a364SKalle Valo #define FH49_MEM_RSSR_LOWER_BOUND           (FH49_MEM_LOWER_BOUND + 0xC40)
1151*7ac9a364SKalle Valo #define FH49_MEM_RSSR_UPPER_BOUND           (FH49_MEM_LOWER_BOUND + 0xD00)
1152*7ac9a364SKalle Valo 
1153*7ac9a364SKalle Valo #define FH49_MEM_RSSR_SHARED_CTRL_REG       (FH49_MEM_RSSR_LOWER_BOUND)
1154*7ac9a364SKalle Valo #define FH49_MEM_RSSR_RX_STATUS_REG	(FH49_MEM_RSSR_LOWER_BOUND + 0x004)
1155*7ac9a364SKalle Valo #define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1156*7ac9a364SKalle Valo 					(FH49_MEM_RSSR_LOWER_BOUND + 0x008)
1157*7ac9a364SKalle Valo 
1158*7ac9a364SKalle Valo #define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE	(0x01000000)
1159*7ac9a364SKalle Valo 
1160*7ac9a364SKalle Valo #define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT	28
1161*7ac9a364SKalle Valo 
1162*7ac9a364SKalle Valo /* TFDB  Area - TFDs buffer table */
1163*7ac9a364SKalle Valo #define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK      (0xFFFFFFFF)
1164*7ac9a364SKalle Valo #define FH49_TFDIB_LOWER_BOUND       (FH49_MEM_LOWER_BOUND + 0x900)
1165*7ac9a364SKalle Valo #define FH49_TFDIB_UPPER_BOUND       (FH49_MEM_LOWER_BOUND + 0x958)
1166*7ac9a364SKalle Valo #define FH49_TFDIB_CTRL0_REG(_chnl)  (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1167*7ac9a364SKalle Valo #define FH49_TFDIB_CTRL1_REG(_chnl)  (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1168*7ac9a364SKalle Valo 
1169*7ac9a364SKalle Valo /**
1170*7ac9a364SKalle Valo  * Transmit DMA Channel Control/Status Registers (TCSR)
1171*7ac9a364SKalle Valo  *
1172*7ac9a364SKalle Valo  * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
1173*7ac9a364SKalle Valo  * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1174*7ac9a364SKalle Valo  * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1175*7ac9a364SKalle Valo  *
1176*7ac9a364SKalle Valo  * To use a Tx DMA channel, driver must initialize its
1177*7ac9a364SKalle Valo  * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1178*7ac9a364SKalle Valo  *
1179*7ac9a364SKalle Valo  * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1180*7ac9a364SKalle Valo  * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1181*7ac9a364SKalle Valo  *
1182*7ac9a364SKalle Valo  * All other bits should be 0.
1183*7ac9a364SKalle Valo  *
1184*7ac9a364SKalle Valo  * Bit fields:
1185*7ac9a364SKalle Valo  * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1186*7ac9a364SKalle Valo  *        '10' operate normally
1187*7ac9a364SKalle Valo  * 29- 4: Reserved, set to "0"
1188*7ac9a364SKalle Valo  *     3: Enable internal DMA requests (1, normal operation), disable (0)
1189*7ac9a364SKalle Valo  *  2- 0: Reserved, set to "0"
1190*7ac9a364SKalle Valo  */
1191*7ac9a364SKalle Valo #define FH49_TCSR_LOWER_BOUND  (FH49_MEM_LOWER_BOUND + 0xD00)
1192*7ac9a364SKalle Valo #define FH49_TCSR_UPPER_BOUND  (FH49_MEM_LOWER_BOUND + 0xE60)
1193*7ac9a364SKalle Valo 
1194*7ac9a364SKalle Valo /* Find Control/Status reg for given Tx DMA/FIFO channel */
1195*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_NUM                            (7)
1196*7ac9a364SKalle Valo #define FH50_TCSR_CHNL_NUM                            (8)
1197*7ac9a364SKalle Valo 
1198*7ac9a364SKalle Valo /* TCSR: tx_config register values */
1199*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl)	\
1200*7ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1201*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl)	\
1202*7ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1203*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl)	\
1204*7ac9a364SKalle Valo 		(FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1205*7ac9a364SKalle Valo 
1206*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF		(0x00000000)
1207*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV		(0x00000001)
1208*7ac9a364SKalle Valo 
1209*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE	(0x00000000)
1210*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE	(0x00000008)
1211*7ac9a364SKalle Valo 
1212*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
1213*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD	(0x00100000)
1214*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
1215*7ac9a364SKalle Valo 
1216*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT	(0x00000000)
1217*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
1218*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD	(0x00800000)
1219*7ac9a364SKalle Valo 
1220*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE	(0x00000000)
1221*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF	(0x40000000)
1222*7ac9a364SKalle Valo #define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE	(0x80000000)
1223*7ac9a364SKalle Valo 
1224*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
1225*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
1226*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
1227*7ac9a364SKalle Valo 
1228*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM		(20)
1229*7ac9a364SKalle Valo #define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX		(12)
1230*7ac9a364SKalle Valo 
1231*7ac9a364SKalle Valo /**
1232*7ac9a364SKalle Valo  * Tx Shared Status Registers (TSSR)
1233*7ac9a364SKalle Valo  *
1234*7ac9a364SKalle Valo  * After stopping Tx DMA channel (writing 0 to
1235*7ac9a364SKalle Valo  * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1236*7ac9a364SKalle Valo  * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle
1237*7ac9a364SKalle Valo  * (channel's buffers empty | no pending requests).
1238*7ac9a364SKalle Valo  *
1239*7ac9a364SKalle Valo  * Bit fields:
1240*7ac9a364SKalle Valo  * 31-24:  1 = Channel buffers empty (channel 7:0)
1241*7ac9a364SKalle Valo  * 23-16:  1 = No pending requests (channel 7:0)
1242*7ac9a364SKalle Valo  */
1243*7ac9a364SKalle Valo #define FH49_TSSR_LOWER_BOUND		(FH49_MEM_LOWER_BOUND + 0xEA0)
1244*7ac9a364SKalle Valo #define FH49_TSSR_UPPER_BOUND		(FH49_MEM_LOWER_BOUND + 0xEC0)
1245*7ac9a364SKalle Valo 
1246*7ac9a364SKalle Valo #define FH49_TSSR_TX_STATUS_REG		(FH49_TSSR_LOWER_BOUND + 0x010)
1247*7ac9a364SKalle Valo 
1248*7ac9a364SKalle Valo /**
1249*7ac9a364SKalle Valo  * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1250*7ac9a364SKalle Valo  * 31:  Indicates an address error when accessed to internal memory
1251*7ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
1252*7ac9a364SKalle Valo  * 30:  Indicates that Host did not send the expected number of dwords to FH
1253*7ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
1254*7ac9a364SKalle Valo  * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1255*7ac9a364SKalle Valo  *	command was received from the scheduler while the TRB was already full
1256*7ac9a364SKalle Valo  *	with previous command
1257*7ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
1258*7ac9a364SKalle Valo  * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1259*7ac9a364SKalle Valo  *	bit is set, it indicates that the FH has received a full indication
1260*7ac9a364SKalle Valo  *	from the RTC TxFIFO and the current value of the TxCredit counter was
1261*7ac9a364SKalle Valo  *	not equal to zero. This mean that the credit mechanism was not
1262*7ac9a364SKalle Valo  *	synchronized to the TxFIFO status
1263*7ac9a364SKalle Valo  *	uCode/driver must write "1" in order to clear this flag
1264*7ac9a364SKalle Valo  */
1265*7ac9a364SKalle Valo #define FH49_TSSR_TX_ERROR_REG		(FH49_TSSR_LOWER_BOUND + 0x018)
1266*7ac9a364SKalle Valo 
1267*7ac9a364SKalle Valo #define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1268*7ac9a364SKalle Valo 
1269*7ac9a364SKalle Valo /* Tx service channels */
1270*7ac9a364SKalle Valo #define FH49_SRVC_CHNL		(9)
1271*7ac9a364SKalle Valo #define FH49_SRVC_LOWER_BOUND	(FH49_MEM_LOWER_BOUND + 0x9C8)
1272*7ac9a364SKalle Valo #define FH49_SRVC_UPPER_BOUND	(FH49_MEM_LOWER_BOUND + 0x9D0)
1273*7ac9a364SKalle Valo #define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1274*7ac9a364SKalle Valo 		(FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1275*7ac9a364SKalle Valo 
1276*7ac9a364SKalle Valo #define FH49_TX_CHICKEN_BITS_REG	(FH49_MEM_LOWER_BOUND + 0xE98)
1277*7ac9a364SKalle Valo /* Instruct FH to increment the retry count of a packet when
1278*7ac9a364SKalle Valo  * it is brought from the memory to TX-FIFO
1279*7ac9a364SKalle Valo  */
1280*7ac9a364SKalle Valo #define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN	(0x00000002)
1281*7ac9a364SKalle Valo 
1282*7ac9a364SKalle Valo /* Keep Warm Size */
1283*7ac9a364SKalle Valo #define IL_KW_SIZE 0x1000	/* 4k */
1284*7ac9a364SKalle Valo 
1285*7ac9a364SKalle Valo #endif /* __il_4965_h__ */
1286