xref: /freebsd/sys/dev/rtwn/rtl8812a/r12a.h (revision 02e9120893770924227138ba49df1edb3896112a)
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 
64 /* r12a_calib.c */
65 void	r12a_save_bb_afe_vals(struct rtwn_softc *, uint32_t[],
66 	    const uint16_t[], int);
67 void	r12a_restore_bb_afe_vals(struct rtwn_softc *, uint32_t[],
68 	    const uint16_t[], int);
69 void	r12a_save_rf_vals(struct rtwn_softc *, uint32_t[],
70 	    const uint8_t[], int);
71 void	r12a_restore_rf_vals(struct rtwn_softc *, uint32_t[],
72 	    const uint8_t[], int);
73 void	r12a_lc_calib(struct rtwn_softc *);
74 #ifndef RTWN_WITHOUT_UCODE
75 int	r12a_iq_calib_fw_supported(struct rtwn_softc *);
76 #endif
77 void	r12a_iq_calib_sw(struct rtwn_softc *);
78 void	r12a_iq_calib(struct rtwn_softc *);
79 
80 /* r12a_caps.c */
81 int	r12a_ioctl_net(struct ieee80211com *, u_long, void *);
82 
83 /* r12a_chan.c */
84 void	r12a_fix_spur(struct rtwn_softc *, struct ieee80211_channel *);
85 void	r12a_set_chan(struct rtwn_softc *, struct ieee80211_channel *);
86 void	r12a_set_band_2ghz(struct rtwn_softc *, uint32_t);
87 void	r12a_set_band_5ghz(struct rtwn_softc *, uint32_t);
88 
89 /* r12a_fw.c */
90 #ifndef RTWN_WITHOUT_UCODE
91 void	r12a_fw_reset(struct rtwn_softc *, int);
92 void	r12a_fw_download_enable(struct rtwn_softc *, int);
93 void	r12a_set_media_status(struct rtwn_softc *, int);
94 int	r12a_set_pwrmode(struct rtwn_softc *, struct ieee80211vap *,
95 	    int);
96 void	r12a_iq_calib_fw(struct rtwn_softc *);
97 #endif
98 
99 /* r12a_init.c */
100 int	r12a_check_condition(struct rtwn_softc *, const uint8_t[]);
101 int	r12a_set_page_size(struct rtwn_softc *);
102 void	r12a_init_edca(struct rtwn_softc *);
103 void	r12a_init_bb(struct rtwn_softc *);
104 void	r12a_init_rf(struct rtwn_softc *);
105 void	r12a_crystalcap_write(struct rtwn_softc *);
106 int	r12a_power_on(struct rtwn_softc *);
107 void	r12a_power_off(struct rtwn_softc *);
108 void	r12a_init_intr(struct rtwn_softc *);
109 void	r12a_init_antsel(struct rtwn_softc *);
110 
111 /* r12a_led.c */
112 void	r12a_set_led(struct rtwn_softc *, int, int);
113 
114 /* r12a_rf.c */
115 uint32_t	r12a_rf_read(struct rtwn_softc *, int, uint8_t);
116 uint32_t	r12a_c_cut_rf_read(struct rtwn_softc *, int, uint8_t);
117 void		r12a_rf_write(struct rtwn_softc *, int, uint8_t, uint32_t);
118 
119 /* r12a_rom.c */
120 void	r12a_parse_rom_common(struct rtwn_softc *, uint8_t *);
121 void	r12a_parse_rom(struct rtwn_softc *, uint8_t *);
122 
123 /* r12a_rx.c */
124 void	r12a_ratectl_tx_complete(struct rtwn_softc *, uint8_t *, int);
125 void	r12a_handle_c2h_report(struct rtwn_softc *, uint8_t *, int);
126 int	r12a_check_frame_checksum(struct rtwn_softc *, struct mbuf *);
127 uint8_t	r12a_rx_radiotap_flags(const void *);
128 void	r12a_get_rx_stats(struct rtwn_softc *, struct ieee80211_rx_stats *,
129 	    const void *, const void *);
130 
131 /* r12a_tx.c */
132 void	r12a_fill_tx_desc(struct rtwn_softc *, struct ieee80211_node *,
133 	    struct mbuf *, void *, uint8_t, int);
134 void	r12a_fill_tx_desc_raw(struct rtwn_softc *, struct ieee80211_node *,
135 	    struct mbuf *, void *, const struct ieee80211_bpf_params *);
136 void	r12a_fill_tx_desc_null(struct rtwn_softc *, void *, int, int, int);
137 uint8_t	r12a_tx_radiotap_flags(const void *);
138 
139 #endif	/* RTL8812A_H */
140