xref: /freebsd/sys/contrib/dev/broadcom/brcm80211/brcmsmac/phy_shim.h (revision b4c3e9b5b09c829b4135aff738bd2893ed052377)
1*b4c3e9b5SBjoern A. Zeeb /*
2*b4c3e9b5SBjoern A. Zeeb  * Copyright (c) 2010 Broadcom Corporation
3*b4c3e9b5SBjoern A. Zeeb  *
4*b4c3e9b5SBjoern A. Zeeb  * Permission to use, copy, modify, and/or distribute this software for any
5*b4c3e9b5SBjoern A. Zeeb  * purpose with or without fee is hereby granted, provided that the above
6*b4c3e9b5SBjoern A. Zeeb  * copyright notice and this permission notice appear in all copies.
7*b4c3e9b5SBjoern A. Zeeb  *
8*b4c3e9b5SBjoern A. Zeeb  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*b4c3e9b5SBjoern A. Zeeb  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*b4c3e9b5SBjoern A. Zeeb  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11*b4c3e9b5SBjoern A. Zeeb  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*b4c3e9b5SBjoern A. Zeeb  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13*b4c3e9b5SBjoern A. Zeeb  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14*b4c3e9b5SBjoern A. Zeeb  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*b4c3e9b5SBjoern A. Zeeb  */
16*b4c3e9b5SBjoern A. Zeeb 
17*b4c3e9b5SBjoern A. Zeeb /*
18*b4c3e9b5SBjoern A. Zeeb  * phy_shim.h: stuff defined in phy_shim.c and included only by the phy
19*b4c3e9b5SBjoern A. Zeeb  */
20*b4c3e9b5SBjoern A. Zeeb 
21*b4c3e9b5SBjoern A. Zeeb #ifndef _BRCM_PHY_SHIM_H_
22*b4c3e9b5SBjoern A. Zeeb #define _BRCM_PHY_SHIM_H_
23*b4c3e9b5SBjoern A. Zeeb 
24*b4c3e9b5SBjoern A. Zeeb #include "types.h"
25*b4c3e9b5SBjoern A. Zeeb 
26*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_NONE		0	/* Radar type None */
27*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_ETSI_1	1	/* ETSI 1 Radar type */
28*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_ETSI_2	2	/* ETSI 2 Radar type */
29*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_ETSI_3	3	/* ETSI 3 Radar type */
30*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_ITU_E	4	/* ITU E Radar type */
31*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_ITU_K	5	/* ITU K Radar type */
32*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_UNCLASSIFIED	6	/* Unclassified Radar type  */
33*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_BIN5		7	/* long pulse radar type */
34*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_STG2		8	/* staggered-2 radar */
35*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_STG3		9	/* staggered-3 radar */
36*b4c3e9b5SBjoern A. Zeeb #define RADAR_TYPE_FRA		10	/* French radar */
37*b4c3e9b5SBjoern A. Zeeb 
38*b4c3e9b5SBjoern A. Zeeb /* French radar pulse widths */
39*b4c3e9b5SBjoern A. Zeeb #define FRA_T1_20MHZ	52770
40*b4c3e9b5SBjoern A. Zeeb #define FRA_T2_20MHZ	61538
41*b4c3e9b5SBjoern A. Zeeb #define FRA_T3_20MHZ	66002
42*b4c3e9b5SBjoern A. Zeeb #define FRA_T1_40MHZ	105541
43*b4c3e9b5SBjoern A. Zeeb #define FRA_T2_40MHZ	123077
44*b4c3e9b5SBjoern A. Zeeb #define FRA_T3_40MHZ	132004
45*b4c3e9b5SBjoern A. Zeeb #define FRA_ERR_20MHZ	60
46*b4c3e9b5SBjoern A. Zeeb #define FRA_ERR_40MHZ	120
47*b4c3e9b5SBjoern A. Zeeb 
48*b4c3e9b5SBjoern A. Zeeb #define ANTSEL_NA		0 /* No boardlevel selection available */
49*b4c3e9b5SBjoern A. Zeeb #define ANTSEL_2x4		1 /* 2x4 boardlevel selection available */
50*b4c3e9b5SBjoern A. Zeeb #define ANTSEL_2x3		2 /* 2x3 CB2 boardlevel selection available */
51*b4c3e9b5SBjoern A. Zeeb 
52*b4c3e9b5SBjoern A. Zeeb /* Rx Antenna diversity control values */
53*b4c3e9b5SBjoern A. Zeeb #define	ANT_RX_DIV_FORCE_0	0	/* Use antenna 0 */
54*b4c3e9b5SBjoern A. Zeeb #define	ANT_RX_DIV_FORCE_1	1	/* Use antenna 1 */
55*b4c3e9b5SBjoern A. Zeeb #define	ANT_RX_DIV_START_1	2	/* Choose starting with 1 */
56*b4c3e9b5SBjoern A. Zeeb #define	ANT_RX_DIV_START_0	3	/* Choose starting with 0 */
57*b4c3e9b5SBjoern A. Zeeb #define	ANT_RX_DIV_ENABLE	3	/* APHY bbConfig Enable RX Diversity */
58*b4c3e9b5SBjoern A. Zeeb #define ANT_RX_DIV_DEF		ANT_RX_DIV_START_0 /* default antdiv setting */
59*b4c3e9b5SBjoern A. Zeeb 
60*b4c3e9b5SBjoern A. Zeeb #define WL_ANT_RX_MAX		2	/* max 2 receive antennas */
61*b4c3e9b5SBjoern A. Zeeb #define WL_ANT_HT_RX_MAX	3	/* max 3 receive antennas/cores */
62*b4c3e9b5SBjoern A. Zeeb #define WL_ANT_IDX_1		0	/* antenna index 1 */
63*b4c3e9b5SBjoern A. Zeeb #define WL_ANT_IDX_2		1	/* antenna index 2 */
64*b4c3e9b5SBjoern A. Zeeb 
65*b4c3e9b5SBjoern A. Zeeb /* values for n_preamble_type */
66*b4c3e9b5SBjoern A. Zeeb #define BRCMS_N_PREAMBLE_MIXEDMODE	0
67*b4c3e9b5SBjoern A. Zeeb #define BRCMS_N_PREAMBLE_GF		1
68*b4c3e9b5SBjoern A. Zeeb #define BRCMS_N_PREAMBLE_GF_BRCM          2
69*b4c3e9b5SBjoern A. Zeeb 
70*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_RATES_LEGACY	45
71*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_FIRST	        12
72*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_NUM	        16
73*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_FIRST	        28
74*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_NUM	        17
75*b4c3e9b5SBjoern A. Zeeb 
76*b4c3e9b5SBjoern A. Zeeb 
77*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_RATES	       101
78*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_CCK_FIRST	       0
79*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_CCK_NUM	       4
80*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz OFDM SISO rate */
81*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_OFDM_FIRST	       4
82*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz OFDM CDD rate */
83*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_OFDM20_CDD_FIRST   12
84*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz OFDM SISO rate */
85*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_OFDM40_SISO_FIRST  52
86*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz OFDM CDD rate */
87*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_OFDM40_CDD_FIRST   60
88*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_OFDM_NUM	       8
89*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz MCS SISO rate */
90*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_SISO_FIRST   20
91*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz MCS CDD rate */
92*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_CDD_FIRST    28
93*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz MCS STBC rate */
94*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_STBC_FIRST   36
95*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz MCS SDM rate */
96*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_SDM_FIRST    44
97*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz MCS SISO rate */
98*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_SISO_FIRST   68
99*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz MCS CDD rate */
100*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_CDD_FIRST    76
101*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz MCS STBC rate */
102*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_STBC_FIRST   84
103*b4c3e9b5SBjoern A. Zeeb /* Index for first 40MHz MCS SDM rate */
104*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS40_SDM_FIRST    92
105*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS_1_STREAM_NUM   8
106*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS_2_STREAM_NUM   8
107*b4c3e9b5SBjoern A. Zeeb /* Index for 40MHz rate MCS 32 */
108*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS_32	       100
109*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS_32_NUM	       1
110*b4c3e9b5SBjoern A. Zeeb 
111*b4c3e9b5SBjoern A. Zeeb /* sslpnphy specifics */
112*b4c3e9b5SBjoern A. Zeeb /* Index for first 20MHz MCS SISO rate */
113*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_MCS20_SISO_FIRST_SSN   12
114*b4c3e9b5SBjoern A. Zeeb 
115*b4c3e9b5SBjoern A. Zeeb /* struct tx_power::flags bits */
116*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_F_ENABLED	1
117*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_F_HW	2
118*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_F_MIMO	4
119*b4c3e9b5SBjoern A. Zeeb #define WL_TX_POWER_F_SISO	8
120*b4c3e9b5SBjoern A. Zeeb 
121*b4c3e9b5SBjoern A. Zeeb /* values to force tx/rx chain */
122*b4c3e9b5SBjoern A. Zeeb #define BRCMS_N_TXRX_CHAIN0		0
123*b4c3e9b5SBjoern A. Zeeb #define BRCMS_N_TXRX_CHAIN1		1
124*b4c3e9b5SBjoern A. Zeeb 
125*b4c3e9b5SBjoern A. Zeeb struct brcms_phy;
126*b4c3e9b5SBjoern A. Zeeb 
127*b4c3e9b5SBjoern A. Zeeb struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
128*b4c3e9b5SBjoern A. Zeeb 					  struct brcms_info *wl,
129*b4c3e9b5SBjoern A. Zeeb 					  struct brcms_c_info *wlc);
130*b4c3e9b5SBjoern A. Zeeb void wlc_phy_shim_detach(struct phy_shim_info *physhim);
131*b4c3e9b5SBjoern A. Zeeb 
132*b4c3e9b5SBjoern A. Zeeb /* PHY to WL utility functions */
133*b4c3e9b5SBjoern A. Zeeb struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
134*b4c3e9b5SBjoern A. Zeeb 				     void (*fn)(void *pi),
135*b4c3e9b5SBjoern A. Zeeb 				     void *arg, const char *name);
136*b4c3e9b5SBjoern A. Zeeb void wlapi_free_timer(struct wlapi_timer *t);
137*b4c3e9b5SBjoern A. Zeeb void wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic);
138*b4c3e9b5SBjoern A. Zeeb bool wlapi_del_timer(struct wlapi_timer *t);
139*b4c3e9b5SBjoern A. Zeeb void wlapi_intrson(struct phy_shim_info *physhim);
140*b4c3e9b5SBjoern A. Zeeb u32 wlapi_intrsoff(struct phy_shim_info *physhim);
141*b4c3e9b5SBjoern A. Zeeb void wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask);
142*b4c3e9b5SBjoern A. Zeeb 
143*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v);
144*b4c3e9b5SBjoern A. Zeeb u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset);
145*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask, u16 val,
146*b4c3e9b5SBjoern A. Zeeb 		    int bands);
147*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags);
148*b4c3e9b5SBjoern A. Zeeb void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim);
149*b4c3e9b5SBjoern A. Zeeb void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode);
150*b4c3e9b5SBjoern A. Zeeb void wlapi_enable_mac(struct phy_shim_info *physhim);
151*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val);
152*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_phy_reset(struct phy_shim_info *physhim);
153*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw);
154*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk);
155*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk);
156*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on);
157*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim);
158*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim);
159*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim);
160*b4c3e9b5SBjoern A. Zeeb void wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int o,
161*b4c3e9b5SBjoern A. Zeeb 				   int len, void *buf);
162*b4c3e9b5SBjoern A. Zeeb u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate);
163*b4c3e9b5SBjoern A. Zeeb void wlapi_ucode_sample_init(struct phy_shim_info *physhim);
164*b4c3e9b5SBjoern A. Zeeb void wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint, void *buf,
165*b4c3e9b5SBjoern A. Zeeb 			   int, u32 sel);
166*b4c3e9b5SBjoern A. Zeeb void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, const void *buf,
167*b4c3e9b5SBjoern A. Zeeb 			 int, u32);
168*b4c3e9b5SBjoern A. Zeeb 
169*b4c3e9b5SBjoern A. Zeeb void wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode);
170*b4c3e9b5SBjoern A. Zeeb u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
171*b4c3e9b5SBjoern A. Zeeb 
172*b4c3e9b5SBjoern A. Zeeb #endif				/* _BRCM_PHY_SHIM_H_ */
173