162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef B43_TABLES_NPHY_H_
362306a36Sopenharmony_ci#define B43_TABLES_NPHY_H_
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/types.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_cistruct b43_phy_n_sfo_cfg {
862306a36Sopenharmony_ci	u16 phy_bw1a;
962306a36Sopenharmony_ci	u16 phy_bw2;
1062306a36Sopenharmony_ci	u16 phy_bw3;
1162306a36Sopenharmony_ci	u16 phy_bw4;
1262306a36Sopenharmony_ci	u16 phy_bw5;
1362306a36Sopenharmony_ci	u16 phy_bw6;
1462306a36Sopenharmony_ci};
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistruct b43_wldev;
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistruct nphy_txiqcal_ladder {
1962306a36Sopenharmony_ci	u8 percent;
2062306a36Sopenharmony_ci	u8 g_env;
2162306a36Sopenharmony_ci};
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistruct nphy_rf_control_override_rev2 {
2462306a36Sopenharmony_ci	u8 addr0;
2562306a36Sopenharmony_ci	u8 addr1;
2662306a36Sopenharmony_ci	u16 bmask;
2762306a36Sopenharmony_ci	u8 shift;
2862306a36Sopenharmony_ci};
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_cistruct nphy_rf_control_override_rev3 {
3162306a36Sopenharmony_ci	u16 val_mask;
3262306a36Sopenharmony_ci	u8 val_shift;
3362306a36Sopenharmony_ci	u8 en_addr0;
3462306a36Sopenharmony_ci	u8 val_addr0;
3562306a36Sopenharmony_ci	u8 en_addr1;
3662306a36Sopenharmony_ci	u8 val_addr1;
3762306a36Sopenharmony_ci};
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_cistruct nphy_rf_control_override_rev7 {
4062306a36Sopenharmony_ci	u16 field;
4162306a36Sopenharmony_ci	u16 val_addr_core0;
4262306a36Sopenharmony_ci	u16 val_addr_core1;
4362306a36Sopenharmony_ci	u16 val_mask;
4462306a36Sopenharmony_ci	u8 val_shift;
4562306a36Sopenharmony_ci};
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cistruct nphy_gain_ctl_workaround_entry {
4862306a36Sopenharmony_ci	s8 lna1_gain[4];
4962306a36Sopenharmony_ci	s8 lna2_gain[4];
5062306a36Sopenharmony_ci	u8 gain_db[10];
5162306a36Sopenharmony_ci	u8 gain_bits[10];
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci	u16 init_gain;
5462306a36Sopenharmony_ci	u16 rfseq_init[4];
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci	u16 cliphi_gain;
5762306a36Sopenharmony_ci	u16 clipmd_gain;
5862306a36Sopenharmony_ci	u16 cliplo_gain;
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci	u16 crsmin;
6162306a36Sopenharmony_ci	u16 crsminl;
6262306a36Sopenharmony_ci	u16 crsminu;
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci	u16 nbclip;
6562306a36Sopenharmony_ci	u16 wlclip;
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/* Get entry with workaround values for gain ctl. Does not return NULL. */
6962306a36Sopenharmony_cistruct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
7062306a36Sopenharmony_ci	struct b43_wldev *dev, bool ghz5, bool ext_lna);
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci/* The N-PHY tables. */
7462306a36Sopenharmony_ci#define B43_NTAB_TYPEMASK		0xF0000000
7562306a36Sopenharmony_ci#define B43_NTAB_8BIT			0x10000000
7662306a36Sopenharmony_ci#define B43_NTAB_16BIT			0x20000000
7762306a36Sopenharmony_ci#define B43_NTAB_32BIT			0x30000000
7862306a36Sopenharmony_ci#define B43_NTAB8(table, offset)	(((table) << 10) | (offset) | B43_NTAB_8BIT)
7962306a36Sopenharmony_ci#define B43_NTAB16(table, offset)	(((table) << 10) | (offset) | B43_NTAB_16BIT)
8062306a36Sopenharmony_ci#define B43_NTAB32(table, offset)	(((table) << 10) | (offset) | B43_NTAB_32BIT)
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci/* Static N-PHY tables */
8362306a36Sopenharmony_ci#define B43_NTAB_FRAMESTRUCT		B43_NTAB32(0x0A, 0x000) /* Frame Struct Table */
8462306a36Sopenharmony_ci#define B43_NTAB_FRAMESTRUCT_SIZE	832
8562306a36Sopenharmony_ci#define B43_NTAB_FRAMELT		B43_NTAB8 (0x18, 0x000) /* Frame Lookup Table */
8662306a36Sopenharmony_ci#define B43_NTAB_FRAMELT_SIZE		32
8762306a36Sopenharmony_ci#define B43_NTAB_TMAP			B43_NTAB32(0x0C, 0x000) /* T Map Table */
8862306a36Sopenharmony_ci#define B43_NTAB_TMAP_SIZE		448
8962306a36Sopenharmony_ci#define B43_NTAB_TDTRN			B43_NTAB32(0x0E, 0x000) /* TDTRN Table */
9062306a36Sopenharmony_ci#define B43_NTAB_TDTRN_SIZE		704
9162306a36Sopenharmony_ci#define B43_NTAB_INTLEVEL		B43_NTAB32(0x0D, 0x000) /* Int Level Table */
9262306a36Sopenharmony_ci#define B43_NTAB_INTLEVEL_SIZE		7
9362306a36Sopenharmony_ci#define B43_NTAB_PILOT			B43_NTAB16(0x0B, 0x000) /* Pilot Table */
9462306a36Sopenharmony_ci#define B43_NTAB_PILOT_SIZE		88
9562306a36Sopenharmony_ci#define B43_NTAB_PILOTLT		B43_NTAB32(0x14, 0x000) /* Pilot Lookup Table */
9662306a36Sopenharmony_ci#define B43_NTAB_PILOTLT_SIZE		6
9762306a36Sopenharmony_ci#define B43_NTAB_TDI20A0		B43_NTAB32(0x13, 0x080) /* TDI Table 20 Antenna 0 */
9862306a36Sopenharmony_ci#define B43_NTAB_TDI20A0_SIZE		55
9962306a36Sopenharmony_ci#define B43_NTAB_TDI20A1		B43_NTAB32(0x13, 0x100) /* TDI Table 20 Antenna 1 */
10062306a36Sopenharmony_ci#define B43_NTAB_TDI20A1_SIZE		55
10162306a36Sopenharmony_ci#define B43_NTAB_TDI40A0		B43_NTAB32(0x13, 0x280) /* TDI Table 40 Antenna 0 */
10262306a36Sopenharmony_ci#define B43_NTAB_TDI40A0_SIZE		110
10362306a36Sopenharmony_ci#define B43_NTAB_TDI40A1		B43_NTAB32(0x13, 0x300) /* TDI Table 40 Antenna 1 */
10462306a36Sopenharmony_ci#define B43_NTAB_TDI40A1_SIZE		110
10562306a36Sopenharmony_ci#define B43_NTAB_BDI			B43_NTAB16(0x15, 0x000) /* BDI Table */
10662306a36Sopenharmony_ci#define B43_NTAB_BDI_SIZE		6
10762306a36Sopenharmony_ci#define B43_NTAB_CHANEST		B43_NTAB32(0x16, 0x000) /* Channel Estimate Table */
10862306a36Sopenharmony_ci#define B43_NTAB_CHANEST_SIZE		96
10962306a36Sopenharmony_ci#define B43_NTAB_MCS			B43_NTAB8 (0x12, 0x000) /* MCS Table */
11062306a36Sopenharmony_ci#define B43_NTAB_MCS_SIZE		128
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/* Volatile N-PHY tables */
11362306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR10		B43_NTAB32(0x10, 0x000) /* Noise Var Table 10 */
11462306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR10_SIZE	256
11562306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR11		B43_NTAB32(0x10, 0x080) /* Noise Var Table 11 */
11662306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR11_SIZE	256
11762306a36Sopenharmony_ci#define B43_NTAB_C0_ESTPLT		B43_NTAB8 (0x1A, 0x000) /* Estimate Power Lookup Table Core 0 */
11862306a36Sopenharmony_ci#define B43_NTAB_C0_ESTPLT_SIZE		64
11962306a36Sopenharmony_ci#define B43_NTAB_C0_ADJPLT		B43_NTAB8 (0x1A, 0x040) /* Adjust Power Lookup Table Core 0 */
12062306a36Sopenharmony_ci#define B43_NTAB_C0_ADJPLT_SIZE		128
12162306a36Sopenharmony_ci#define B43_NTAB_C0_GAINCTL		B43_NTAB32(0x1A, 0x0C0) /* Gain Control Lookup Table Core 0 */
12262306a36Sopenharmony_ci#define B43_NTAB_C0_GAINCTL_SIZE	128
12362306a36Sopenharmony_ci#define B43_NTAB_C0_IQLT		B43_NTAB32(0x1A, 0x140) /* IQ Lookup Table Core 0 */
12462306a36Sopenharmony_ci#define B43_NTAB_C0_IQLT_SIZE		128
12562306a36Sopenharmony_ci#define B43_NTAB_C0_LOFEEDTH		B43_NTAB16(0x1A, 0x1C0) /* Local Oscillator Feed Through Lookup Table Core 0 */
12662306a36Sopenharmony_ci#define B43_NTAB_C0_LOFEEDTH_SIZE	128
12762306a36Sopenharmony_ci#define B43_NTAB_C1_ESTPLT		B43_NTAB8 (0x1B, 0x000) /* Estimate Power Lookup Table Core 1 */
12862306a36Sopenharmony_ci#define B43_NTAB_C1_ESTPLT_SIZE		64
12962306a36Sopenharmony_ci#define B43_NTAB_C1_ADJPLT		B43_NTAB8 (0x1B, 0x040) /* Adjust Power Lookup Table Core 1 */
13062306a36Sopenharmony_ci#define B43_NTAB_C1_ADJPLT_SIZE		128
13162306a36Sopenharmony_ci#define B43_NTAB_C1_GAINCTL		B43_NTAB32(0x1B, 0x0C0) /* Gain Control Lookup Table Core 1 */
13262306a36Sopenharmony_ci#define B43_NTAB_C1_GAINCTL_SIZE	128
13362306a36Sopenharmony_ci#define B43_NTAB_C1_IQLT		B43_NTAB32(0x1B, 0x140) /* IQ Lookup Table Core 1 */
13462306a36Sopenharmony_ci#define B43_NTAB_C1_IQLT_SIZE		128
13562306a36Sopenharmony_ci#define B43_NTAB_C1_LOFEEDTH		B43_NTAB16(0x1B, 0x1C0) /* Local Oscillator Feed Through Lookup Table Core 1 */
13662306a36Sopenharmony_ci#define B43_NTAB_C1_LOFEEDTH_SIZE	128
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/* Volatile N-PHY tables, PHY revision >= 3 */
13962306a36Sopenharmony_ci#define B43_NTAB_ANT_SW_CTL_R3		B43_NTAB16( 9,   0) /* antenna software control */
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci/* Static N-PHY tables, PHY revision >= 3 */
14262306a36Sopenharmony_ci#define B43_NTAB_FRAMESTRUCT_R3		B43_NTAB32(10,   0) /* frame struct  */
14362306a36Sopenharmony_ci#define B43_NTAB_PILOT_R3		B43_NTAB16(11,   0) /* pilot  */
14462306a36Sopenharmony_ci#define B43_NTAB_TMAP_R3		B43_NTAB32(12,   0) /* TM AP  */
14562306a36Sopenharmony_ci#define B43_NTAB_INTLEVEL_R3		B43_NTAB32(13,   0) /* INT LV  */
14662306a36Sopenharmony_ci#define B43_NTAB_TDTRN_R3		B43_NTAB32(14,   0) /* TD TRN  */
14762306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR_R3		B43_NTAB32(16,   0) /* noise variance */
14862306a36Sopenharmony_ci#define B43_NTAB_MCS_R3			B43_NTAB16(18,   0) /* MCS  */
14962306a36Sopenharmony_ci#define B43_NTAB_TDI20A0_R3		B43_NTAB32(19, 128) /* TDI 20/0  */
15062306a36Sopenharmony_ci#define B43_NTAB_TDI20A1_R3		B43_NTAB32(19, 256) /* TDI 20/1  */
15162306a36Sopenharmony_ci#define B43_NTAB_TDI40A0_R3		B43_NTAB32(19, 640) /* TDI 40/0  */
15262306a36Sopenharmony_ci#define B43_NTAB_TDI40A1_R3		B43_NTAB32(19, 768) /* TDI 40/1  */
15362306a36Sopenharmony_ci#define B43_NTAB_PILOTLT_R3		B43_NTAB32(20,   0) /* PLT lookup  */
15462306a36Sopenharmony_ci#define B43_NTAB_CHANEST_R3		B43_NTAB32(22,   0) /* channel estimate  */
15562306a36Sopenharmony_ci#define B43_NTAB_FRAMELT_R3		 B43_NTAB8(24,   0) /* frame lookup  */
15662306a36Sopenharmony_ci#define B43_NTAB_C0_ESTPLT_R3		 B43_NTAB8(26,   0) /* estimated power lookup 0  */
15762306a36Sopenharmony_ci#define B43_NTAB_C0_ADJPLT_R3		 B43_NTAB8(26,  64) /* adjusted power lookup 0  */
15862306a36Sopenharmony_ci#define B43_NTAB_C0_GAINCTL_R3		B43_NTAB32(26, 192) /* gain control lookup 0  */
15962306a36Sopenharmony_ci#define B43_NTAB_C0_IQLT_R3		B43_NTAB32(26, 320) /* I/Q lookup 0  */
16062306a36Sopenharmony_ci#define B43_NTAB_C0_LOFEEDTH_R3		B43_NTAB16(26, 448) /* Local Oscillator Feed Through lookup 0  */
16162306a36Sopenharmony_ci#define B43_NTAB_C0_PAPD_COMP_R3	B43_NTAB16(26, 576)
16262306a36Sopenharmony_ci#define B43_NTAB_C1_ESTPLT_R3		 B43_NTAB8(27,   0) /* estimated power lookup 1  */
16362306a36Sopenharmony_ci#define B43_NTAB_C1_ADJPLT_R3		 B43_NTAB8(27,  64) /* adjusted power lookup 1  */
16462306a36Sopenharmony_ci#define B43_NTAB_C1_GAINCTL_R3		B43_NTAB32(27, 192) /* gain control lookup 1  */
16562306a36Sopenharmony_ci#define B43_NTAB_C1_IQLT_R3		B43_NTAB32(27, 320) /* I/Q lookup 1  */
16662306a36Sopenharmony_ci#define B43_NTAB_C1_LOFEEDTH_R3		B43_NTAB16(27, 448) /* Local Oscillator Feed Through lookup 1 */
16762306a36Sopenharmony_ci#define B43_NTAB_C1_PAPD_COMP_R3	B43_NTAB16(27, 576)
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci/* Static N-PHY tables, PHY revision >= 7 */
17062306a36Sopenharmony_ci#define B43_NTAB_TMAP_R7		B43_NTAB32(12,   0) /* TM AP */
17162306a36Sopenharmony_ci#define B43_NTAB_NOISEVAR_R7		B43_NTAB32(16,   0) /* noise variance */
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_LOFT_LADDER_40_SIZE	18
17462306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_LOFT_LADDER_20_SIZE	18
17562306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_IQIMB_LADDER_40_SIZE	18
17662306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_IQIMB_LADDER_20_SIZE	18
17762306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_STARTCOEFS_REV3		11
17862306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_STARTCOEFS			9
17962306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_CMDS_RECAL_REV3		12
18062306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_CMDS_RECAL			10
18162306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL		10
18262306a36Sopenharmony_ci#define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV3		12
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ciu32 b43_ntab_read(struct b43_wldev *dev, u32 offset);
18562306a36Sopenharmony_civoid b43_ntab_read_bulk(struct b43_wldev *dev, u32 offset,
18662306a36Sopenharmony_ci			 unsigned int nr_elements, void *_data);
18762306a36Sopenharmony_civoid b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value);
18862306a36Sopenharmony_civoid b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
18962306a36Sopenharmony_ci			  unsigned int nr_elements, const void *_data);
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_civoid b43_nphy_tables_init(struct b43_wldev *dev);
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ciconst u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ciconst s16 *b43_ntab_get_rf_pwr_offset_table(struct b43_wldev *dev);
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ciextern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[];
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ciextern const u16 tbl_iqcal_gainparams[2][9][8];
20062306a36Sopenharmony_ciextern const struct nphy_txiqcal_ladder ladder_lo[];
20162306a36Sopenharmony_ciextern const struct nphy_txiqcal_ladder ladder_iq[];
20262306a36Sopenharmony_ciextern const u16 loscale[];
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_loft_ladder_40[];
20562306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_loft_ladder_20[];
20662306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[];
20762306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[];
20862306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[];
20962306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_startcoefs[];
21062306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[];
21162306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_cmds_recal[];
21262306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_cmds_fullcal[];
21362306a36Sopenharmony_ciextern const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[];
21462306a36Sopenharmony_ciextern const s16 tbl_tx_filter_coef_rev4[7][15];
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ciextern const struct nphy_rf_control_override_rev2
21762306a36Sopenharmony_ci	tbl_rf_control_override_rev2[];
21862306a36Sopenharmony_ciextern const struct nphy_rf_control_override_rev3
21962306a36Sopenharmony_ci	tbl_rf_control_override_rev3[];
22062306a36Sopenharmony_ciconst struct nphy_rf_control_override_rev7 *b43_nphy_get_rf_ctl_over_rev7(
22162306a36Sopenharmony_ci	struct b43_wldev *dev, u16 field, u8 override);
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci#endif /* B43_TABLES_NPHY_H_ */
224