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