Merge tag 'JH7110_515_SDK_v4.0.0-rc1' into vf2-515-devel
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / hal_desc.h
1 /**
2  ******************************************************************************
3  *
4  * @file hal_desc.h
5  *
6  * @brief File containing the definition of HW descriptors.
7  *
8  * Contains the definition and structures used by HW
9  *
10  * Copyright (C) ESWIN 2015-2020
11  *
12  ******************************************************************************
13  */
14
15 #ifndef _HAL_DESC_H_
16 #define _HAL_DESC_H_
17
18 #include "lmac_types.h"
19
20 #define ECRNX_MACHW_NX 1
21 #define ECRNX_MACHW_HE 2
22 /* Rate and policy table */
23
24 #define N_CCK  8
25 #define N_OFDM 8
26 #define N_HT   (8 * 2 * 2 * 4)
27 #define N_VHT  (10 * 4 * 2 * 8)
28 #define N_HE_SU (12 * 4 * 3 * 8)
29 #define N_HE_MU (12 * 6 * 3 * 8)
30
31 /* conversion table from NL80211 to MACHW enum */
32 extern const int chnl2bw[];
33
34 /* conversion table from MACHW to NL80211 enum */
35 extern const int bw2chnl[];
36
37 struct ecrnx_legrate {
38     s16 idx;
39     u16 rate;  // in 100Kbps
40 };
41 extern const struct ecrnx_legrate legrates_lut[];
42 /* Values for formatModTx */
43 #define FORMATMOD_NON_HT          0
44 #define FORMATMOD_NON_HT_DUP_OFDM 1
45 #define FORMATMOD_HT_MF           2
46 #define FORMATMOD_HT_GF           3
47 #define FORMATMOD_VHT             4
48 #define FORMATMOD_HE_SU           5
49 #define FORMATMOD_HE_MU           6
50 #define FORMATMOD_HE_ER           7
51 #define FORMATMOD_HE_TB           8
52
53 /* Values for navProtFrmEx */
54 #define NAV_PROT_NO_PROT_BIT                 0
55 #define NAV_PROT_SELF_CTS_BIT                1
56 #define NAV_PROT_RTS_CTS_BIT                 2
57 #define NAV_PROT_RTS_CTS_WITH_QAP_BIT        3
58 #define NAV_PROT_STBC_BIT                    4
59
60 /* THD MACCTRLINFO2 fields, used in  struct umacdesc umac.flags */
61 /// WhichDescriptor definition - contains aMPDU bit and position value
62 /// Offset of WhichDescriptor field in the MAC CONTROL INFO 2 word
63 #define WHICHDESC_OFT                     19
64 /// Mask of the WhichDescriptor field
65 #define WHICHDESC_MSK                     (0x07 << WHICHDESC_OFT)
66 /// Only 1 THD possible, describing an unfragmented MSDU
67 #define WHICHDESC_UNFRAGMENTED_MSDU       (0x00 << WHICHDESC_OFT)
68 /// THD describing the first MPDU of a fragmented MSDU
69 #define WHICHDESC_FRAGMENTED_MSDU_FIRST   (0x01 << WHICHDESC_OFT)
70 /// THD describing intermediate MPDUs of a fragmented MSDU
71 #define WHICHDESC_FRAGMENTED_MSDU_INT     (0x02 << WHICHDESC_OFT)
72 /// THD describing the last MPDU of a fragmented MSDU
73 #define WHICHDESC_FRAGMENTED_MSDU_LAST    (0x03 << WHICHDESC_OFT)
74 /// THD for extra descriptor starting an AMPDU
75 #define WHICHDESC_AMPDU_EXTRA             (0x04 << WHICHDESC_OFT)
76 /// THD describing the first MPDU of an A-MPDU
77 #define WHICHDESC_AMPDU_FIRST             (0x05 << WHICHDESC_OFT)
78 /// THD describing intermediate MPDUs of an A-MPDU
79 #define WHICHDESC_AMPDU_INT               (0x06 << WHICHDESC_OFT)
80 /// THD describing the last MPDU of an A-MPDU
81 #define WHICHDESC_AMPDU_LAST              (0x07 << WHICHDESC_OFT)
82
83 /// aMPDU bit offset
84 #define AMPDU_OFT                         21
85 /// aMPDU bit
86 #define AMPDU_BIT                         CO_BIT(AMPDU_OFT)
87
88 union ecrnx_mcs_index {
89     struct {
90         u32 mcs : 3;
91         u32 nss : 2;
92     } ht;
93     struct {
94         u32 mcs : 4;
95         u32 nss : 3;
96     } vht;
97     struct {
98         u32 mcs : 4;
99         u32 nss : 3;
100     } he;
101     u32 legacy : 7;
102 };
103
104 union ecrnx_rate_ctrl_info {
105     struct {
106         u32 mcsIndexTx      : 7;
107         u32 bwTx            : 2;
108         u32 giAndPreTypeTx  : 2;
109         u32 formatModTx     : 3;
110         #ifdef CONFIG_ECRNX_FULLMAC
111         u32 dcmTx           : 1;
112         #else
113         u32 navProtFrmEx    : 3;
114         u32 mcsIndexProtTx  : 7;
115         u32 bwProtTx        : 2;
116         u32 formatModProtTx : 3;
117         u32 nRetry          : 3;
118         #endif
119     };
120     u32 value;
121 };
122
123 struct ecrnx_power_ctrl_info {
124     u32 txPwrLevelPT          : 8;
125     u32 txPwrLevelProtPT      : 8;
126     u32 reserved              :16;
127 };
128
129 union ecrnx_pol_phy_ctrl_info_1 {
130     struct {
131         u32 rsvd1     : 3;
132         u32 bfFrmEx   : 1;
133         u32 numExtnSS : 2;
134         u32 fecCoding : 1;
135         u32 stbc      : 2;
136         u32 rsvd2     : 5;
137         u32 nTx       : 3;
138         u32 nTxProt   : 3;
139     };
140     u32 value;
141 };
142
143 union ecrnx_pol_phy_ctrl_info_2 {
144     struct {
145         u32 antennaSet : 8;
146         u32 smmIndex   : 8;
147         u32 beamFormed : 1;
148     };
149     u32 value;
150 };
151
152 union ecrnx_pol_mac_ctrl_info_1 {
153     struct {
154         u32 keySRamIndex   : 10;
155         u32 keySRamIndexRA : 10;
156     };
157     u32 value;
158 };
159
160 union ecrnx_pol_mac_ctrl_info_2 {
161     struct {
162         u32 longRetryLimit  : 8;
163         u32 shortRetryLimit : 8;
164         u32 rtsThreshold    : 12;
165     };
166     u32 value;
167 };
168
169 #define POLICY_TABLE_PATTERN    0xBADCAB1E
170
171 struct tx_policy_tbl {
172     /* Unique Pattern at the start of Policy Table */
173     u32 upatterntx;
174     /* PHY Control 1 Information used by MAC HW */
175     union ecrnx_pol_phy_ctrl_info_1 phyctrlinfo_1;
176     /* PHY Control 2 Information used by MAC HW */
177     union ecrnx_pol_phy_ctrl_info_2 phyctrlinfo_2;
178     /* MAC Control 1 Information used by MAC HW */
179     union ecrnx_pol_mac_ctrl_info_1 macctrlinfo_1;
180     /* MAC Control 2 Information used by MAC HW */
181     union ecrnx_pol_mac_ctrl_info_2 macctrlinfo_2;
182
183     union ecrnx_rate_ctrl_info  ratectrlinfos[NX_TX_MAX_RATES];
184     struct ecrnx_power_ctrl_info powerctrlinfos[NX_TX_MAX_RATES];
185 };
186
187 #ifdef CONFIG_ECRNX_SOFTMAC
188
189 union ecrnx_hw_txstatus {
190     struct {
191         u32 num_rts_retries      : 8;
192         u32 num_mpdu_retries     : 8;
193         u32 retry_limit_reached  : 1;
194         u32 lifetime_expired     : 1;
195         u32 baFrameReceived      : 1;
196         u32 reserved2            : 4;
197         u32 frm_successful_tx    : 1;
198         u32 transmission_bw      : 2;
199         u32 which_descriptor_sw  : 4;
200         u32 descriptor_done_swtx : 1;
201         u32 descriptor_done_hwtx : 1;
202     };
203     u32 value;
204 };
205
206 // WhichDescriptor for AMPDUs (_under BA Policy_)
207 #define __WD_AMPDU_BAPOL                     0xC
208 #define __WD_AMPDU_EXTRA                     0xC
209 #define __WD_AMPDU_FIRST                     0xD
210 #define __WD_AMPDU_INT                       0xE
211 #define __WD_AMPDU_LAST                      0xF
212
213 #define ECRNX_WD_IS_AMPDU(whichdesc) \
214     (((whichdesc) & __WD_AMPDU_BAPOL) == __WD_AMPDU_BAPOL)
215 #define ECRNX_WD_IS_FIRST(whichdesc) \
216     ((whichdesc) == __WD_AMPDU_FIRST)
217 #define ECRNX_WD_IS_LAST(whichdesc) \
218     ((whichdesc) == __WD_AMPDU_LAST)
219
220 union ecrnx_thd_phy_ctrl_info {
221     struct {
222         u32 soundingTx       : 1;
223         u32 smoothingTx      : 1;
224         u32 smoothingProtTx  : 1;
225         u32 useBWSignalingTx : 1;
226         u32 dynBWTx          : 1;
227         u32 dozeNotAllowedTx : 1;
228         u32 continuousTx     : 1;
229         u32 rsvd             : 1;
230         u32 PTITx            : 4;
231         u32 userPositionTx   : 2;
232         u32 useRIFSTx        : 1;
233         u32 muMIMOTx         : 1;
234         u32 groupIDTx        : 6;
235         u32 partialAIDTx     : 9;
236     };
237     u32 value;
238 };
239
240 #define EXPECTED_ACK_NO_ACK               0
241 #define EXPECTED_ACK_NORMAL_ACK           1
242 #define EXPECTED_ACK_BLOCK_ACK            2
243 #define EXPECTED_ACK_COMPRESSED_BLOCK_ACK 3
244
245 union ecrnx_thd_mac_ctrl_info_1 {
246     struct {
247         u32 rsvd1        : 9;
248         u32 expectedAck  : 2;
249         u32 lstp         : 1;
250         u32 lstpProt     : 1;
251         u32 lowRateRetry : 1;
252         u32 writeACK     : 1;
253         u32 rsvd2        : 1;
254         u32 protFrmDur   : 16;
255     };
256     u32 value;
257 };
258
259 /**
260  * struct ecrnx_hw_txhdr - Hardware part of tx header
261  *
262  * @policy: Policy table to use for transmission
263  * @mac_ctrl_info: MAC configuration to use for transmission
264  * @phy_ctrl_info: PHY configuration to use for transmission
265  *
266  * @status: Status updated by fw/hardware after transmission
267  */
268 struct ecrnx_hw_txhdr {
269     struct tx_policy_tbl policy;
270     union ecrnx_thd_mac_ctrl_info_1 mac_ctrl_info;
271     union ecrnx_thd_phy_ctrl_info phy_ctrl_info;
272     union ecrnx_hw_txstatus status;
273 };
274
275 #else /* !CONFIG_ECRNX_SOFTMAC */
276
277 /**
278  * struct ecrnx_hw_txstatus - Bitfield of confirmation status
279  *
280  * @tx_done: packet has been processed by the firmware.
281  * @retry_required: packet has been transmitted but not acknoledged.
282  * Driver must repush it.
283  * @sw_retry_required: packet has not been transmitted (FW wasn't able to push
284  * it when it received it: not active channel ...). Driver must repush it.
285  * @acknowledged: packet has been acknowledged by peer
286  */
287 union ecrnx_hw_txstatus {
288     struct {
289         u32 tx_done            : 1;
290         u32 retry_required     : 1;
291         u32 sw_retry_required  : 1;
292         u32 acknowledged       : 1;
293         u32 reserved           :28;
294     };
295     u32 value;
296 };
297
298 /**
299  * struct tx_cfm_tag - Structure indicating the status and other
300  * information about the transmission
301  *
302  * @pn: PN that was used for the transmission
303  * @sn: Sequence number of the packet
304  * @timestamp: Timestamp of first transmission of this MPDU
305  * @credits: Number of credits to be reallocated for the txq that push this
306  * buffer (can be 0 or 1)
307  * @ampdu_size: Size of the ampdu in which the frame has been transmitted if
308  * this was the last frame of the a-mpdu, and 0 if the frame is not the last
309  * frame on a a-mdpu.
310  * 1 means that the frame has been transmitted as a singleton.
311  * @amsdu_size: Size, in bytes, allowed to create a-msdu.
312  * @status: transmission status
313  */
314 struct tx_cfm_tag
315 {
316     u16_l pn[4];
317     u16_l sn;
318     u16_l timestamp;
319     s8_l credits;
320     u8_l ampdu_size;
321 #ifdef CONFIG_ECRNX_SPLIT_TX_BUF
322     u16_l amsdu_size;
323 #endif
324
325 #ifdef CONFIG_ECRNX_ESWIN
326     uint32_t  hostid[2];
327 #endif
328
329     union ecrnx_hw_txstatus status;
330 };
331
332 /**
333  * struct ecrnx_hw_txhdr - Hardware part of tx header
334  *
335  * @cfm: Information updated by fw/hardware after sending a frame
336  */
337 struct ecrnx_hw_txhdr {
338     struct tx_cfm_tag cfm;
339 };
340
341 #endif /* CONFIG_ECRNX_SOFTMAC */
342
343 #define ECRNX_RX_HD_NX_DECR_UNENC           0 // Frame unencrypted
344 #define ECRNX_RX_HD_NX_DECR_ICVFAIL         1 // WEP/TKIP ICV failure
345 #define ECRNX_RX_HD_NX_DECR_CCMPFAIL        2 // CCMP failure
346 #define ECRNX_RX_HD_NX_DECR_AMSDUDISCARD    3 // A-MSDU discarded at HW
347 #define ECRNX_RX_HD_NX_DECR_NULLKEY         4 // NULL key found
348 #define ECRNX_RX_HD_NX_DECR_WEPSUCCESS      5 // Security type WEP
349 #define ECRNX_RX_HD_NX_DECR_TKIPSUCCESS     6 // Security type TKIP
350 #define ECRNX_RX_HD_NX_DECR_CCMPSUCCESS     7 // Security type CCMP (or WPI)
351 #define ECRNX_RX_HD_DECR_UNENC     0 // Frame unencrypted
352 #define ECRNX_RX_HD_DECR_WEP       1 // Security type WEP
353 #define ECRNX_RX_HD_DECR_TKIP      2 // Security type TKIP
354 #define ECRNX_RX_HD_DECR_CCMP128   3 // Security type CCMP (128 bits)
355 #define ECRNX_RX_HD_DECR_CCMP256   4 // Security type CCMP (256 bits)
356 #define ECRNX_RX_HD_DECR_GCMP128   5 // Security type GCMP (128 bits)
357 #define ECRNX_RX_HD_DECR_GCMP256   6 // Security type GCMP (256 bits)
358 #define ECRNX_RX_HD_DECR_WAPI      7 // Security type WAPI
359 #define ECRNX_RX_HD_DECR_NULLKEY  15 // NULL key found
360 struct rx_vector_1_nx {
361     u32    leg_length         :12;
362     u32    leg_rate           : 4;
363     u32    ht_length          :16;
364     u32    _ht_length         : 4; // FIXME
365     u32    short_gi           : 1;
366     u32    stbc               : 2;
367     u32    smoothing          : 1;
368     u32    mcs                : 7;
369     u32    pre_type           : 1;
370     u32    format_mod         : 3;
371     u32    ch_bw              : 2;
372     u32    n_sts              : 3;
373     u32    lsig_valid         : 1;
374     u32    sounding           : 1;
375     u32    num_extn_ss        : 2;
376     u32    aggregation        : 1;
377     u32    fec_coding         : 1;
378     u32    dyn_bw             : 1;
379     u32    doze_not_allowed   : 1;
380     u32    antenna_set        : 8;
381     u32    partial_aid        : 9;
382     u32    group_id           : 6;
383     u32    first_user         : 1;
384     s32    rssi1              : 8;
385     s32    rssi2              : 8;
386     s32    rssi3              : 8;
387     s32    rssi4              : 8;
388     u32    reserved_1d        : 8;
389 };
390 struct rx_vector_2_nx {
391     u32    rcpi               : 8;
392     u32    evm1               : 8;
393     u32    evm2               : 8;
394     u32    evm3               : 8;
395     u32    evm4               : 8;
396     u32    reserved2b_1       : 8;
397     u32    reserved2b_2       : 8;
398     u32    reserved2b_3       : 8;
399 };
400 struct mpdu_status_nx {
401     u32    rx_vect2_valid     : 1;
402     u32    resp_frame         : 1;
403     u32    decr_status        : 3;
404     u32    rx_fifo_oflow      : 1;
405     u32    undef_err          : 1;
406     u32    phy_err            : 1;
407     u32    fcs_err            : 1;
408     u32    addr_mismatch      : 1;
409     u32    ga_frame           : 1;
410     u32    current_ac         : 2;
411     u32    frm_successful_rx  : 1;
412     u32    desc_done_rx       : 1;
413     u32    key_sram_index     : 10;
414     u32    key_sram_valid     : 1;
415     u32    type               : 2;
416     u32    subtype            : 4;
417 };
418 struct rx_leg_vect
419 {
420     u8    dyn_bw_in_non_ht     : 1;
421     u8    chn_bw_in_non_ht     : 2;
422     u8    rsvd_nht             : 4;
423     u8    lsig_valid           : 1;
424 } __packed;
425 struct rx_ht_vect
426 {
427     u16   sounding             : 1;
428     u16   smoothing            : 1;
429     u16   short_gi             : 1;
430     u16   aggregation          : 1;
431     u16   stbc                 : 1;
432     u16   num_extn_ss          : 2;
433     u16   lsig_valid           : 1;
434     u16   mcs                  : 7;
435     u16   fec                  : 1;
436     u16   length               :16;
437 } __packed;
438 struct rx_vht_vect
439 {
440     u8   sounding              : 1;
441     u8   beamformed            : 1;
442     u8   short_gi              : 1;
443     u8   rsvd_vht1             : 1;
444     u8   stbc                  : 1;
445     u8   doze_not_allowed      : 1;
446     u8   first_user            : 1;
447     u8   rsvd_vht2             : 1;
448     u16  partial_aid           : 9;
449     u16  group_id              : 6;
450     u16  rsvd_vht3             : 1;
451     u32  mcs                   : 4;
452     u32  nss                   : 3;
453     u32  fec                   : 1;
454     u32  length                :20;
455     u32  rsvd_vht4             : 4;
456 } __packed;
457 struct rx_he_vect
458 {
459     u8   sounding              : 1;
460     u8   beamformed            : 1;
461     u8   gi_type               : 2;
462     u8   stbc                  : 1;
463     u8   rsvd_he1              : 3;
464     u8   uplink_flag           : 1;
465     u8   beam_change           : 1;
466     u8   dcm                   : 1;
467     u8   he_ltf_type           : 2;
468     u8   doppler               : 1;
469     u8   rsvd_he2              : 2;
470     u8   bss_color             : 6;
471     u8   rsvd_he3              : 2;
472     u8   txop_duration         : 7;
473     u8   rsvd_he4              : 1;
474     u8   pe_duration           : 4;
475     u8   spatial_reuse         : 4;
476     u8   sig_b_comp_mode       : 1;
477     u8   dcm_sig_b             : 1;
478     u8   mcs_sig_b             : 3;
479     u8   ru_size               : 3;
480     u32  mcs                   : 4;
481     u32  nss                   : 3;
482     u32  fec                   : 1;
483     u32  length                :20;
484     u32  rsvd_he6              : 4;
485 } __packed;
486 struct rx_vector_1 {
487     u8     format_mod         : 4;
488     u8     ch_bw              : 3;
489     u8     pre_type           : 1;
490     u8     antenna_set        : 8;
491     s32    rssi_leg           : 8;
492     u32    leg_length         :12;
493     u32    leg_rate           : 4;
494     s32    rssi1              : 8;
495     union
496     {
497         struct rx_leg_vect leg;
498         struct rx_ht_vect ht;
499         struct rx_vht_vect vht;
500         struct rx_he_vect he;
501     };
502 } __packed;
503 struct rx_vector_2 {
504     u32    rcpi1              : 8;
505     u32    rcpi2              : 8;
506     u32    rcpi3              : 8;
507     u32    rcpi4              : 8;
508     u32    evm1               : 8;
509     u32    evm2               : 8;
510     u32    evm3               : 8;
511     u32    evm4               : 8;
512 };
513 struct mpdu_status {
514     u32    rx_vect2_valid     : 1;
515     u32    resp_frame         : 1;
516     u32    decr_type          : 4;
517     u32    decr_err           : 1;
518     u32    undef_err          : 1;
519     u32    fcs_err            : 1;
520     u32    addr_mismatch      : 1;
521     u32    ga_frame           : 1;
522     u32    current_ac         : 2;
523     u32    frm_successful_rx  : 1;
524     u32    desc_done_rx       : 1;
525     u32    key_sram_index     : 10;
526     u32    key_sram_v         : 1;
527     u32    type               : 2;
528     u32    subtype            : 4;
529 };
530 struct hw_vect {
531     u32 len                   :16;
532     u32 reserved              : 8;
533     u32 mpdu_cnt              : 6;
534     u32 ampdu_cnt             : 2;
535     __le32 tsf_lo;
536     /** TSF High */
537     __le32 tsf_hi;
538
539     /** Receive Vector 1 */
540     struct rx_vector_1 rx_vect1;
541     /** Receive Vector 2 */
542     struct rx_vector_2 rx_vect2;
543
544     /** MPDU status information */
545     struct mpdu_status status;
546 };
547
548 struct phy_channel_info_desc {
549     /** PHY channel information 1 */
550     u32    phy_band           : 8;
551     u32    phy_channel_type   : 8;
552     u32    phy_prim20_freq    : 16;
553
554     /** PHY channel information 2 */
555     u32    phy_center1_freq   : 16;
556     u32    phy_center2_freq   : 16;
557 };
558
559 int ecrnx_machw_type(uint32_t machw_version_2);
560 void ecrnx_rx_vector_convert(int machw_type, struct rx_vector_1 *rx_vect1,
561                             struct rx_vector_2 *rx_vect2);
562 void ecrnx_rx_status_convert(int machw_type, struct mpdu_status *status);
563
564 /******************************************************************************
565  * Modem
566  ******************************************************************************/
567 #define MDM_PHY_CONFIG_TRIDENT     0
568 #define MDM_PHY_CONFIG_CATAXIA     1
569 #define MDM_PHY_CONFIG_KARST       2
570
571 // MODEM features (from reg_mdm_stat.h)
572 /// MUMIMOTX field bit
573 #define MDM_MUMIMOTX_BIT    ((u32)0x80000000)
574 /// MUMIMOTX field position
575 #define MDM_MUMIMOTX_POS    31
576 /// MUMIMORX field bit
577 #define MDM_MUMIMORX_BIT    ((u32)0x40000000)
578 /// MUMIMORX field position
579 #define MDM_MUMIMORX_POS    30
580 /// BFMER field bit
581 #define MDM_BFMER_BIT       ((u32)0x20000000)
582 /// BFMER field position
583 #define MDM_BFMER_POS       29
584 /// BFMEE field bit
585 #define MDM_BFMEE_BIT       ((u32)0x10000000)
586 /// BFMEE field position
587 #define MDM_BFMEE_POS       28
588 /// LDPCDEC field bit
589 #define MDM_LDPCDEC_BIT     ((u32)0x08000000)
590 /// LDPCDEC field position
591 #define MDM_LDPCDEC_POS     27
592 /// LDPCENC field bit
593 #define MDM_LDPCENC_BIT     ((u32)0x04000000)
594 /// LDPCENC field position
595 #define MDM_LDPCENC_POS     26
596 /// CHBW field mask
597 #define MDM_CHBW_MASK       ((u32)0x03000000)
598 /// CHBW field LSB position
599 #define MDM_CHBW_LSB        24
600 /// CHBW field width
601 #define MDM_CHBW_WIDTH      ((u32)0x00000002)
602 /// DSSSCCK field bit
603 #define MDM_DSSSCCK_BIT     ((u32)0x00800000)
604 /// DSSSCCK field position
605 #define MDM_DSSSCCK_POS     23
606 /// VHT field bit
607 #define MDM_VHT_BIT         ((u32)0x00400000)
608 /// VHT field position
609 #define MDM_VHT_POS         22
610 /// HE field bit
611 #define MDM_HE_BIT          ((u32)0x00200000)
612 /// HE field position
613 #define MDM_HE_POS          21
614 /// ESS field bit
615 #define MDM_ESS_BIT         ((u32)0x00100000)
616 /// ESS field position
617 #define MDM_ESS_POS         20
618 /// RFMODE field mask
619 #define MDM_RFMODE_MASK     ((u32)0x000F0000)
620 /// RFMODE field LSB position
621 #define MDM_RFMODE_LSB      16
622 /// RFMODE field width
623 #define MDM_RFMODE_WIDTH    ((u32)0x00000004)
624 /// NSTS field mask
625 #define MDM_NSTS_MASK       ((u32)0x0000F000)
626 /// NSTS field LSB position
627 #define MDM_NSTS_LSB        12
628 /// NSTS field width
629 #define MDM_NSTS_WIDTH      ((u32)0x00000004)
630 /// NSS field mask
631 #define MDM_NSS_MASK        ((u32)0x00000F00)
632 /// NSS field LSB position
633 #define MDM_NSS_LSB         8
634 /// NSS field width
635 #define MDM_NSS_WIDTH       ((u32)0x00000004)
636 /// NTX field mask
637 #define MDM_NTX_MASK        ((u32)0x000000F0)
638 /// NTX field LSB position
639 #define MDM_NTX_LSB         4
640 /// NTX field width
641 #define MDM_NTX_WIDTH       ((u32)0x00000004)
642 /// NRX field mask
643 #define MDM_NRX_MASK        ((u32)0x0000000F)
644 /// NRX field LSB position
645 #define MDM_NRX_LSB         0
646 /// NRX field width
647 #define MDM_NRX_WIDTH       ((u32)0x00000004)
648
649 #define __MDM_PHYCFG_FROM_VERS(v)  (((v) & MDM_RFMODE_MASK) >> MDM_RFMODE_LSB)
650
651 #define RIU_FCU_PRESENT_MASK       ((u32)0xFF000000)
652 #define RIU_FCU_PRESENT_LSB        24
653
654 #define __RIU_FCU_PRESENT(v)  (((v) & RIU_FCU_PRESENT_MASK) >> RIU_FCU_PRESENT_LSB == 5)
655
656 /// AGC load version field mask
657 #define RIU_AGC_LOAD_MASK          ((u32)0x00C00000)
658 /// AGC load version field LSB position
659 #define RIU_AGC_LOAD_LSB           22
660
661 #define __RIU_AGCLOAD_FROM_VERS(v) (((v) & RIU_AGC_LOAD_MASK) >> RIU_AGC_LOAD_LSB)
662
663 #define __FPGA_TYPE(v)             (((v) & 0xFFFF0000) >> 16)
664
665 #define __MDM_MAJOR_VERSION(v)     (((v) & 0xFF000000) >> 24)
666 #define __MDM_MINOR_VERSION(v)     (((v) & 0x00FF0000) >> 16)
667 #define __MDM_VERSION(v)       ((__MDM_MAJOR_VERSION(v) + 2) * 10 + __MDM_MINOR_VERSION(v))
668
669
670 #endif // _HAL_DESC_H_