xref: /freebsd/sys/dev/rtwn/rtl8812a/r12a.h (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
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 RTL8812A_H
28 #define RTL8812A_H
29 
30 /*
31  * Global definitions.
32  */
33 #define R12A_PUBQ_NPAGES	219
34 #define R12A_TXPKTBUF_COUNT	255
35 #define R12A_TX_PAGE_COUNT	248
36 
37 #define R12A_TX_PAGE_SIZE	512
38 #define R12A_RX_DMA_BUFFER_SIZE	0x3e80
39 
40 #define R12A_MAX_FW_SIZE	0x8000
41 #define R12A_MACID_MAX		127
42 #define R12A_CAM_ENTRY_COUNT	64
43 
44 #define	R12A_INTR_MSG_LEN	60
45 
46 static const uint8_t r12a_chan_5ghz_0[] =
47 	{ 36, 40, 44, 48, 52, 56, 60, 64 };
48 static const uint8_t r12a_chan_5ghz_1[] =
49 	{ 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144 };
50 static const uint8_t r12a_chan_5ghz_2[] =
51 	{ 149, 153, 157, 161, 165, 169, 173, 177 };
52 
53 /*
54  * Function declarations.
55  */
56 /* r12a_attach.c */
57 void	r12a_vap_preattach(struct rtwn_softc *, struct ieee80211vap *);
58 void	r12a_detach_private(struct rtwn_softc *);
59 
60 /* r12a_beacon.c */
61 void	r12a_beacon_init(struct rtwn_softc *, void *, int);
62 void	r12a_beacon_set_rate(void *, int);
63 void	r12a_sta_beacon_enable(struct rtwn_softc *, int, bool);
64 
65 /* r12a_calib.c */
66 void	r12a_save_bb_afe_vals(struct rtwn_softc *, uint32_t[],
67 	    const uint16_t[], int);
68 void	r12a_restore_bb_afe_vals(struct rtwn_softc *, uint32_t[],
69 	    const uint16_t[], int);
70 void	r12a_save_rf_vals(struct rtwn_softc *, uint32_t[],
71 	    const uint8_t[], int);
72 void	r12a_restore_rf_vals(struct rtwn_softc *, uint32_t[],
73 	    const uint8_t[], int);
74 void	r12a_lc_calib(struct rtwn_softc *);
75 #ifndef RTWN_WITHOUT_UCODE
76 int	r12a_iq_calib_fw_supported(struct rtwn_softc *);
77 #endif
78 void	r12a_iq_calib_sw(struct rtwn_softc *);
79 void	r12a_iq_calib(struct rtwn_softc *);
80 
81 /* r12a_caps.c */
82 int	r12a_ioctl_net(struct ieee80211com *, u_long, void *);
83 
84 /* r12a_chan.c */
85 void	r12a_fix_spur(struct rtwn_softc *, struct ieee80211_channel *);
86 void	r12a_set_chan(struct rtwn_softc *, struct ieee80211_channel *);
87 void	r12a_set_band_2ghz(struct rtwn_softc *, uint32_t);
88 void	r12a_set_band_5ghz(struct rtwn_softc *, uint32_t);
89 
90 /* r12a_fw.c */
91 #ifndef RTWN_WITHOUT_UCODE
92 void	r12a_fw_reset(struct rtwn_softc *, int);
93 void	r12a_fw_download_enable(struct rtwn_softc *, int);
94 void	r12a_set_media_status(struct rtwn_softc *, int);
95 int	r12a_set_pwrmode(struct rtwn_softc *, struct ieee80211vap *,
96 	    int);
97 void	r12a_iq_calib_fw(struct rtwn_softc *);
98 #endif
99 
100 /* r12a_init.c */
101 int	r12a_check_condition(struct rtwn_softc *, const uint8_t[]);
102 int	r12a_set_page_size(struct rtwn_softc *);
103 void	r12a_init_edca(struct rtwn_softc *);
104 void	r12a_init_bb(struct rtwn_softc *);
105 void	r12a_init_rf(struct rtwn_softc *);
106 void	r12a_crystalcap_write(struct rtwn_softc *);
107 int	r12a_power_on(struct rtwn_softc *);
108 void	r12a_power_off(struct rtwn_softc *);
109 void	r12a_init_intr(struct rtwn_softc *);
110 void	r12a_init_antsel(struct rtwn_softc *);
111 
112 /* r12a_led.c */
113 void	r12a_set_led(struct rtwn_softc *, int, int);
114 
115 /* r12a_rf.c */
116 uint32_t	r12a_rf_read(struct rtwn_softc *, int, uint8_t);
117 uint32_t	r12a_c_cut_rf_read(struct rtwn_softc *, int, uint8_t);
118 void		r12a_rf_write(struct rtwn_softc *, int, uint8_t, uint32_t);
119 
120 /* r12a_rom.c */
121 void	r12a_parse_rom_common(struct rtwn_softc *, uint8_t *);
122 void	r12a_parse_rom(struct rtwn_softc *, uint8_t *);
123 
124 /* r12a_rx.c */
125 void	r12a_ratectl_tx_complete(struct rtwn_softc *, uint8_t *, int);
126 void	r12a_handle_c2h_report(struct rtwn_softc *, uint8_t *, int);
127 int	r12a_check_frame_checksum(struct rtwn_softc *, struct mbuf *);
128 uint8_t	r12a_rx_radiotap_flags(const void *);
129 void	r12a_get_rx_stats(struct rtwn_softc *, struct ieee80211_rx_stats *,
130 	    const void *, const void *);
131 
132 /* r12a_tx.c */
133 void	r12a_fill_tx_desc(struct rtwn_softc *, struct ieee80211_node *,
134 	    struct mbuf *, void *, uint8_t, bool, int);
135 void	r12a_fill_tx_desc_raw(struct rtwn_softc *, struct ieee80211_node *,
136 	    struct mbuf *, void *, const struct ieee80211_bpf_params *);
137 void	r12a_fill_tx_desc_null(struct rtwn_softc *, void *, int, int, int);
138 uint8_t	r12a_tx_radiotap_flags(const void *);
139 
140 #endif	/* RTL8812A_H */
141