123c21068SFiona Klute /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 223c21068SFiona Klute /* Copyright Fiona Klute <fiona.klute@gmx.de> */ 323c21068SFiona Klute 423c21068SFiona Klute #ifndef __RTW8703B_H__ 523c21068SFiona Klute #define __RTW8703B_H__ 623c21068SFiona Klute 723c21068SFiona Klute #include "rtw8723x.h" 823c21068SFiona Klute 923c21068SFiona Klute extern const struct rtw_chip_info rtw8703b_hw_spec; 1023c21068SFiona Klute 1123c21068SFiona Klute /* phy status parsing */ 1223c21068SFiona Klute #define VGA_BITS GENMASK(4, 0) 1323c21068SFiona Klute #define LNA_L_BITS GENMASK(7, 5) 1423c21068SFiona Klute #define LNA_H_BIT BIT(7) 1523c21068SFiona Klute /* masks for assembling LNA index from high and low bits */ 1623c21068SFiona Klute #define BIT_LNA_H_MASK BIT(3) 1723c21068SFiona Klute #define BIT_LNA_L_MASK GENMASK(2, 0) 1823c21068SFiona Klute 1923c21068SFiona Klute struct phy_rx_agc_info { 2023c21068SFiona Klute #ifdef __LITTLE_ENDIAN 2123c21068SFiona Klute u8 gain: 7; 2223c21068SFiona Klute u8 trsw: 1; 2323c21068SFiona Klute #else 2423c21068SFiona Klute u8 trsw: 1; 2523c21068SFiona Klute u8 gain: 7; 2623c21068SFiona Klute #endif 2723c21068SFiona Klute } __packed; 2823c21068SFiona Klute 2923c21068SFiona Klute /* This struct is called phy_status_rpt_8192cd in the vendor driver, 3023c21068SFiona Klute * there might be potential to share it with drivers for other chips 3123c21068SFiona Klute * of the same generation. 3223c21068SFiona Klute */ 3323c21068SFiona Klute struct phy_status_8703b { 3423c21068SFiona Klute struct phy_rx_agc_info path_agc[2]; 3523c21068SFiona Klute u8 ch_corr[2]; 3623c21068SFiona Klute u8 cck_sig_qual_ofdm_pwdb_all; 3723c21068SFiona Klute /* for CCK: bits 0:4: VGA index, bits 5:7: LNA index (low) */ 3823c21068SFiona Klute u8 cck_agc_rpt_ofdm_cfosho_a; 3923c21068SFiona Klute /* for CCK: bit 7 is high bit of LNA index if long report type */ 4023c21068SFiona Klute u8 cck_rpt_b_ofdm_cfosho_b; 4123c21068SFiona Klute u8 reserved_1; 4223c21068SFiona Klute u8 noise_power_db_msb; 4323c21068SFiona Klute s8 path_cfotail[2]; 4423c21068SFiona Klute u8 pcts_mask[2]; 4523c21068SFiona Klute s8 stream_rxevm[2]; 4623c21068SFiona Klute u8 path_rxsnr[2]; 4723c21068SFiona Klute u8 noise_power_db_lsb; 4823c21068SFiona Klute u8 reserved_2[3]; 4923c21068SFiona Klute u8 stream_csi[2]; 5023c21068SFiona Klute u8 stream_target_csi[2]; 5123c21068SFiona Klute s8 sig_evm; 5223c21068SFiona Klute u8 reserved_3; 5323c21068SFiona Klute 5423c21068SFiona Klute #ifdef __LITTLE_ENDIAN 5523c21068SFiona Klute u8 antsel_rx_keep_2: 1; 5623c21068SFiona Klute u8 sgi_en: 1; 5723c21068SFiona Klute u8 rxsc: 2; 5823c21068SFiona Klute u8 idle_long: 1; 5923c21068SFiona Klute u8 r_ant_train_en: 1; 6023c21068SFiona Klute u8 ant_sel_b: 1; 6123c21068SFiona Klute u8 ant_sel: 1; 6223c21068SFiona Klute #else /* __BIG_ENDIAN */ 6323c21068SFiona Klute u8 ant_sel: 1; 6423c21068SFiona Klute u8 ant_sel_b: 1; 6523c21068SFiona Klute u8 r_ant_train_en: 1; 6623c21068SFiona Klute u8 idle_long: 1; 6723c21068SFiona Klute u8 rxsc: 2; 6823c21068SFiona Klute u8 sgi_en: 1; 6923c21068SFiona Klute u8 antsel_rx_keep_2: 1; 7023c21068SFiona Klute #endif 7123c21068SFiona Klute } __packed; 7223c21068SFiona Klute 7323c21068SFiona Klute /* Baseband registers */ 7423c21068SFiona Klute #define REG_BB_PWR_SAV5_11N 0x0818 7523c21068SFiona Klute /* BIT(11) should be 1 for 8703B *and* 8723D, which means LNA uses 4 7623c21068SFiona Klute * bit for CCK rates in report, not 3. Vendor driver logs a warning if 7723c21068SFiona Klute * it's 0, but handles the case. 7823c21068SFiona Klute * 7923c21068SFiona Klute * Purpose of other parts of this register is unknown, 8723cs driver 8023c21068SFiona Klute * code indicates some other chips use certain bits for antenna 8123c21068SFiona Klute * diversity. 8223c21068SFiona Klute */ 8323c21068SFiona Klute #define REG_BB_AMP 0x0950 8423c21068SFiona Klute #define BIT_MASK_RX_LNA (BIT(11)) 8523c21068SFiona Klute 8623c21068SFiona Klute /* 0xaXX: 40MHz channel settings */ 8723c21068SFiona Klute #define REG_CCK_TXSF2 0x0a24 /* CCK TX filter 2 */ 8823c21068SFiona Klute #define REG_CCK_DBG 0x0a28 /* debug port */ 8923c21068SFiona Klute #define REG_OFDM0_A_TX_AFE 0x0c84 9023c21068SFiona Klute #define REG_TXIQK_MATRIXB_LSB2_11N 0x0c9c 9123c21068SFiona Klute #define REG_OFDM0_TX_PSD_NOISE 0x0ce4 /* TX pseudo noise weighting */ 9223c21068SFiona Klute #define REG_IQK_RDY 0x0e90 /* is != 0 when IQK is done */ 9323c21068SFiona Klute 9423c21068SFiona Klute /* RF registers */ 9523c21068SFiona Klute #define RF_RCK1 0x1E 9623c21068SFiona Klute 9723c21068SFiona Klute #define AGG_BURST_NUM 3 9823c21068SFiona Klute #define AGG_BURST_SIZE 0 /* 1K */ 9923c21068SFiona Klute #define BIT_MASK_AGG_BURST_NUM (GENMASK(3, 2)) 10023c21068SFiona Klute #define BIT_MASK_AGG_BURST_SIZE (GENMASK(5, 4)) 10123c21068SFiona Klute 10223c21068SFiona Klute #endif /* __RTW8703B_H__ */ 103