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