xref: /freebsd/sys/dev/rtwn/rtl8812a/r12a_var.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*-
2  * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef R12A_VAR_H
28 #define R12A_VAR_H
29 
30 #include <dev/rtwn/rtl8812a/r12a_rom_defs.h>
31 
32 struct r12a_softc {
33 	uint8_t			chip;
34 #define R12A_CHIP_C_CUT		0x01
35 
36 	uint8_t			rs_flags;
37 #define R12A_RXCKSUM_EN		0x01
38 #define R12A_RXCKSUM6_EN	0x02
39 #define R12A_IQK_RUNNING	0x04
40 #define R12A_RADAR_ENABLED	0x08
41 
42 	int			rs_radar;
43 	struct timeout_task	rs_chan_check;
44 
45 	/* ROM variables */
46 	int			ext_pa_2g:1,
47 				ext_pa_5g:1,
48 				ext_lna_2g:1,
49 				ext_lna_5g:1,
50 				type_pa_2g:4,
51 				type_pa_5g:4,
52 				type_lna_2g:4,
53 				type_lna_5g:4,
54 				bt_coex:1,
55 				bt_ant_num:1;
56 
57 	uint8_t			board_type;
58 	uint8_t			regulatory;
59 	uint8_t			crystalcap;
60 
61 	uint8_t			rfe_type;
62 	uint8_t			tx_bbswing_2g;
63 	uint8_t			tx_bbswing_5g;
64 
65 	uint8_t	cck_tx_pwr[R12A_MAX_RF_PATH][R12A_GROUP_2G];
66 	uint8_t	ht40_tx_pwr_2g[R12A_MAX_RF_PATH][R12A_GROUP_2G];
67 	uint8_t	ht40_tx_pwr_5g[R12A_MAX_RF_PATH][R12A_GROUP_5G];
68 
69 	int8_t	cck_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
70 	int8_t	ofdm_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
71 	int8_t	bw20_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
72 	int8_t	bw40_tx_pwr_diff_2g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
73 
74 	int8_t	ofdm_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
75 	int8_t	bw20_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
76 	int8_t	bw40_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
77 	int8_t	bw80_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
78 	int8_t	bw160_tx_pwr_diff_5g[R12A_MAX_RF_PATH][R12A_MAX_TX_COUNT];
79 
80 	int		sc_ant;
81 
82 	int		(*rs_newstate[RTWN_PORT_COUNT])(struct ieee80211vap *,
83 			    enum ieee80211_state, int);
84 	void		(*rs_scan_start)(struct ieee80211com *);
85 	void		(*rs_scan_end)(struct ieee80211com *);
86 
87 	void		(*rs_crystalcap_write)(struct rtwn_softc *);
88 	void		(*rs_fix_spur)(struct rtwn_softc *,
89 			    struct ieee80211_channel *);
90 	void		(*rs_set_band_2ghz)(struct rtwn_softc *, uint32_t);
91 	void		(*rs_set_band_5ghz)(struct rtwn_softc *, uint32_t);
92 	void		(*rs_init_burstlen)(struct rtwn_softc *);
93 	void		(*rs_init_ampdu_fwhw)(struct rtwn_softc *);
94 #ifndef RTWN_WITHOUT_UCODE
95 	int		(*rs_iq_calib_fw_supported)(struct rtwn_softc *);
96 #endif
97 	void		(*rs_iq_calib_sw)(struct rtwn_softc *);
98 
99 	int		ac_usb_dma_size;
100 	int		ac_usb_dma_time;
101 	int		ampdu_max_time;
102 };
103 #define	R12A_SOFTC(_sc)	((struct r12a_softc *)((_sc)->sc_priv))
104 
105 #define rtwn_r12a_fix_spur(_sc, _c) \
106 	((R12A_SOFTC(_sc)->rs_fix_spur)((_sc), (_c)))
107 #define rtwn_r12a_set_band_2ghz(_sc, _rates) \
108 	((R12A_SOFTC(_sc)->rs_set_band_2ghz)((_sc), (_rates)))
109 #define rtwn_r12a_set_band_5ghz(_sc, _rates) \
110 	((R12A_SOFTC(_sc)->rs_set_band_5ghz)((_sc), (_rates)))
111 #define rtwn_r12a_init_burstlen(_sc) \
112 	((R12A_SOFTC(_sc)->rs_init_burstlen)((_sc)))
113 #define rtwn_r12a_init_ampdu_fwhw(_sc) \
114 	((R12A_SOFTC(_sc)->rs_init_ampdu_fwhw)((_sc)))
115 #define rtwn_r12a_crystalcap_write(_sc) \
116 	((R12A_SOFTC(_sc)->rs_crystalcap_write)((_sc)))
117 #ifndef RTWN_WITHOUT_UCODE
118 #define rtwn_r12a_iq_calib_fw_supported(_sc) \
119 	((R12A_SOFTC(_sc)->rs_iq_calib_fw_supported)((_sc)))
120 #endif
121 #define rtwn_r12a_iq_calib_sw(_sc) \
122 	((R12A_SOFTC(_sc)->rs_iq_calib_sw)((_sc)))
123 
124 #endif	/* R12A_VAR_H */
125