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