xref: /linux/drivers/net/wireless/realtek/rtw88/rtw8703b.h (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
1*23c21068SFiona Klute /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2*23c21068SFiona Klute /* Copyright Fiona Klute <fiona.klute@gmx.de> */
3*23c21068SFiona Klute 
4*23c21068SFiona Klute #ifndef __RTW8703B_H__
5*23c21068SFiona Klute #define __RTW8703B_H__
6*23c21068SFiona Klute 
7*23c21068SFiona Klute #include "rtw8723x.h"
8*23c21068SFiona Klute 
9*23c21068SFiona Klute extern const struct rtw_chip_info rtw8703b_hw_spec;
10*23c21068SFiona Klute 
11*23c21068SFiona Klute /* phy status parsing */
12*23c21068SFiona Klute #define VGA_BITS GENMASK(4, 0)
13*23c21068SFiona Klute #define LNA_L_BITS GENMASK(7, 5)
14*23c21068SFiona Klute #define LNA_H_BIT BIT(7)
15*23c21068SFiona Klute /* masks for assembling LNA index from high and low bits */
16*23c21068SFiona Klute #define BIT_LNA_H_MASK BIT(3)
17*23c21068SFiona Klute #define BIT_LNA_L_MASK GENMASK(2, 0)
18*23c21068SFiona Klute 
19*23c21068SFiona Klute struct phy_rx_agc_info {
20*23c21068SFiona Klute #ifdef __LITTLE_ENDIAN
21*23c21068SFiona Klute 	u8 gain: 7;
22*23c21068SFiona Klute 	u8 trsw: 1;
23*23c21068SFiona Klute #else
24*23c21068SFiona Klute 	u8 trsw: 1;
25*23c21068SFiona Klute 	u8 gain: 7;
26*23c21068SFiona Klute #endif
27*23c21068SFiona Klute } __packed;
28*23c21068SFiona Klute 
29*23c21068SFiona Klute /* This struct is called phy_status_rpt_8192cd in the vendor driver,
30*23c21068SFiona Klute  * there might be potential to share it with drivers for other chips
31*23c21068SFiona Klute  * of the same generation.
32*23c21068SFiona Klute  */
33*23c21068SFiona Klute struct phy_status_8703b {
34*23c21068SFiona Klute 	struct phy_rx_agc_info path_agc[2];
35*23c21068SFiona Klute 	u8 ch_corr[2];
36*23c21068SFiona Klute 	u8 cck_sig_qual_ofdm_pwdb_all;
37*23c21068SFiona Klute 	/* for CCK: bits 0:4: VGA index, bits 5:7: LNA index (low) */
38*23c21068SFiona Klute 	u8 cck_agc_rpt_ofdm_cfosho_a;
39*23c21068SFiona Klute 	/* for CCK: bit 7 is high bit of LNA index if long report type */
40*23c21068SFiona Klute 	u8 cck_rpt_b_ofdm_cfosho_b;
41*23c21068SFiona Klute 	u8 reserved_1;
42*23c21068SFiona Klute 	u8 noise_power_db_msb;
43*23c21068SFiona Klute 	s8 path_cfotail[2];
44*23c21068SFiona Klute 	u8 pcts_mask[2];
45*23c21068SFiona Klute 	s8 stream_rxevm[2];
46*23c21068SFiona Klute 	u8 path_rxsnr[2];
47*23c21068SFiona Klute 	u8 noise_power_db_lsb;
48*23c21068SFiona Klute 	u8 reserved_2[3];
49*23c21068SFiona Klute 	u8 stream_csi[2];
50*23c21068SFiona Klute 	u8 stream_target_csi[2];
51*23c21068SFiona Klute 	s8 sig_evm;
52*23c21068SFiona Klute 	u8 reserved_3;
53*23c21068SFiona Klute 
54*23c21068SFiona Klute #ifdef __LITTLE_ENDIAN
55*23c21068SFiona Klute 	u8 antsel_rx_keep_2: 1;
56*23c21068SFiona Klute 	u8 sgi_en: 1;
57*23c21068SFiona Klute 	u8 rxsc: 2;
58*23c21068SFiona Klute 	u8 idle_long: 1;
59*23c21068SFiona Klute 	u8 r_ant_train_en: 1;
60*23c21068SFiona Klute 	u8 ant_sel_b: 1;
61*23c21068SFiona Klute 	u8 ant_sel: 1;
62*23c21068SFiona Klute #else /* __BIG_ENDIAN */
63*23c21068SFiona Klute 	u8 ant_sel: 1;
64*23c21068SFiona Klute 	u8 ant_sel_b: 1;
65*23c21068SFiona Klute 	u8 r_ant_train_en: 1;
66*23c21068SFiona Klute 	u8 idle_long: 1;
67*23c21068SFiona Klute 	u8 rxsc: 2;
68*23c21068SFiona Klute 	u8 sgi_en: 1;
69*23c21068SFiona Klute 	u8 antsel_rx_keep_2: 1;
70*23c21068SFiona Klute #endif
71*23c21068SFiona Klute } __packed;
72*23c21068SFiona Klute 
73*23c21068SFiona Klute /* Baseband registers */
74*23c21068SFiona Klute #define REG_BB_PWR_SAV5_11N 0x0818
75*23c21068SFiona Klute /* BIT(11) should be 1 for 8703B *and* 8723D, which means LNA uses 4
76*23c21068SFiona Klute  * bit for CCK rates in report, not 3. Vendor driver logs a warning if
77*23c21068SFiona Klute  * it's 0, but handles the case.
78*23c21068SFiona Klute  *
79*23c21068SFiona Klute  * Purpose of other parts of this register is unknown, 8723cs driver
80*23c21068SFiona Klute  * code indicates some other chips use certain bits for antenna
81*23c21068SFiona Klute  * diversity.
82*23c21068SFiona Klute  */
83*23c21068SFiona Klute #define REG_BB_AMP 0x0950
84*23c21068SFiona Klute #define BIT_MASK_RX_LNA (BIT(11))
85*23c21068SFiona Klute 
86*23c21068SFiona Klute /* 0xaXX: 40MHz channel settings */
87*23c21068SFiona Klute #define REG_CCK_TXSF2 0x0a24  /* CCK TX filter 2 */
88*23c21068SFiona Klute #define REG_CCK_DBG 0x0a28  /* debug port */
89*23c21068SFiona Klute #define REG_OFDM0_A_TX_AFE 0x0c84
90*23c21068SFiona Klute #define REG_TXIQK_MATRIXB_LSB2_11N 0x0c9c
91*23c21068SFiona Klute #define REG_OFDM0_TX_PSD_NOISE 0x0ce4  /* TX pseudo noise weighting */
92*23c21068SFiona Klute #define REG_IQK_RDY 0x0e90  /* is != 0 when IQK is done */
93*23c21068SFiona Klute 
94*23c21068SFiona Klute /* RF registers */
95*23c21068SFiona Klute #define RF_RCK1 0x1E
96*23c21068SFiona Klute 
97*23c21068SFiona Klute #define AGG_BURST_NUM 3
98*23c21068SFiona Klute #define AGG_BURST_SIZE 0 /* 1K */
99*23c21068SFiona Klute #define BIT_MASK_AGG_BURST_NUM (GENMASK(3, 2))
100*23c21068SFiona Klute #define BIT_MASK_AGG_BURST_SIZE (GENMASK(5, 4))
101*23c21068SFiona Klute 
102*23c21068SFiona Klute #endif /* __RTW8703B_H__ */
103