linux/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_hal.h

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2010 Broadcom Corporation
 */

/*
 * phy_hal.h:  functionality exported from the phy to higher layers
 */

#ifndef _BRCM_PHY_HAL_H_
#define _BRCM_PHY_HAL_H_

#include <brcmu_utils.h>
#include <brcmu_wifi.h>
#include <phy_shim.h>

#define IDCODE_VER_MASK
#define IDCODE_VER_SHIFT
#define IDCODE_MFG_MASK
#define IDCODE_MFG_SHIFT
#define IDCODE_ID_MASK
#define IDCODE_ID_SHIFT
#define IDCODE_REV_MASK
#define IDCODE_REV_SHIFT

#define NORADIO_ID
#define NORADIO_IDCODE

#define BCM2055_ID
#define BCM2055_IDCODE
#define BCM2055A0_IDCODE

#define BCM2056_ID
#define BCM2056_IDCODE
#define BCM2056A0_IDCODE

#define BCM2057_ID
#define BCM2057_IDCODE
#define BCM2057A0_IDCODE

#define BCM2064_ID
#define BCM2064_IDCODE
#define BCM2064A0_IDCODE

#define PHY_TPC_HW_OFF
#define PHY_TPC_HW_ON

#define PHY_PERICAL_DRIVERUP
#define PHY_PERICAL_WATCHDOG
#define PHY_PERICAL_PHYINIT
#define PHY_PERICAL_JOIN_BSS
#define PHY_PERICAL_START_IBSS
#define PHY_PERICAL_UP_BSS
#define PHY_PERICAL_CHAN
#define PHY_FULLCAL

#define PHY_PERICAL_DISABLE
#define PHY_PERICAL_SPHASE
#define PHY_PERICAL_MPHASE
#define PHY_PERICAL_MANUAL

#define PHY_HOLD_FOR_ASSOC
#define PHY_HOLD_FOR_SCAN
#define PHY_HOLD_FOR_RM
#define PHY_HOLD_FOR_PLT
#define PHY_HOLD_FOR_MUTE
#define PHY_HOLD_FOR_NOT_ASSOC

#define PHY_MUTE_FOR_PREISM
#define PHY_MUTE_ALL

#define PHY_NOISE_FIXED_VAL
#define PHY_NOISE_FIXED_VAL_NPHY
#define PHY_NOISE_FIXED_VAL_LCNPHY

#define PHY_MODE_CAL
#define PHY_MODE_NOISEM

#define BRCMS_TXPWR_DB_FACTOR

/* a large TX Power as an init value to factor out of min() calculations,
 * keep low enough to fit in an s8, units are .25 dBm
 */
#define BRCMS_TXPWR_MAX

#define BRCMS_NUM_RATES_CCK
#define BRCMS_NUM_RATES_OFDM
#define BRCMS_NUM_RATES_MCS_1_STREAM
#define BRCMS_NUM_RATES_MCS_2_STREAM
#define BRCMS_NUM_RATES_MCS_3_STREAM
#define BRCMS_NUM_RATES_MCS_4_STREAM

#define BRCMS_RSSI_INVALID

struct d11regs;
struct phy_shim_info;

struct txpwr_limits {};

struct tx_power {};

struct brcms_chanvec {};

struct shared_phy_params {};


struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp);
struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh,
				     struct bcma_device *d11core, int bandtype,
				     struct wiphy *wiphy);
void wlc_phy_detach(struct brcms_phy_pub *ppi);

bool wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype,
			    u16 *phyrev, u16 *radioid, u16 *radiover);
bool wlc_phy_get_encore(struct brcms_phy_pub *pih);
u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih);

void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *ppi, bool newstate);
void wlc_phy_hw_state_upd(struct brcms_phy_pub *ppi, bool newstate);
void wlc_phy_init(struct brcms_phy_pub *ppi, u16 chanspec);
void wlc_phy_watchdog(struct brcms_phy_pub *ppi);
int wlc_phy_down(struct brcms_phy_pub *ppi);
u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih);
void wlc_phy_cal_init(struct brcms_phy_pub *ppi);
void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init);

void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec);
u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi);
void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch);
u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi);
void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw);

int wlc_phy_rssi_compute(struct brcms_phy_pub *pih, struct d11rxhdr *rxh);
void wlc_phy_por_inform(struct brcms_phy_pub *ppi);
void wlc_phy_noise_sample_intr(struct brcms_phy_pub *ppi);
bool wlc_phy_bist_check_phy(struct brcms_phy_pub *ppi);

void wlc_phy_set_deaf(struct brcms_phy_pub *ppi, bool user_flag);

void wlc_phy_switch_radio(struct brcms_phy_pub *ppi, bool on);
void wlc_phy_anacore(struct brcms_phy_pub *ppi, bool on);


void wlc_phy_BSSinit(struct brcms_phy_pub *ppi, bool bonlyap, int rssi);

void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
					  bool wide_filter);
void wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
				   struct brcms_chanvec *channels);
u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band);

void wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint chan, u8 *_min_,
			       u8 *_max_, int rate);
void wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan,
				       u8 *_max_, u8 *_min_);
void wlc_phy_txpower_boardlimit_band(struct brcms_phy_pub *ppi, uint band,
				     s32 *, s32 *, u32 *);
void wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *,
			       u16 chanspec);
int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override);
int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override);
void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi,
				struct txpwr_limits *);
bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi);
void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl);
u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi);
u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi);
bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *pih);

void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain);
void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain);
u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih);
s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec);
void wlc_phy_ldpc_override_set(struct brcms_phy_pub *ppi, bool val);

void wlc_phy_cal_perical(struct brcms_phy_pub *ppi, u8 reason);
void wlc_phy_noise_sample_request_external(struct brcms_phy_pub *ppi);
void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock);
void wlc_phy_cal_papd_recal(struct brcms_phy_pub *ppi);

void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val);
void wlc_phy_clear_tssi(struct brcms_phy_pub *ppi);
void wlc_phy_hold_upd(struct brcms_phy_pub *ppi, u32 id, bool val);
void wlc_phy_mute_upd(struct brcms_phy_pub *ppi, bool val, u32 flags);

void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type);

void wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi,
				 struct tx_power *power, uint channel);

void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal);
bool wlc_phy_test_ison(struct brcms_phy_pub *ppi);
void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, u8 txpwr_percent);
void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);
void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt);
void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap);

void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end);

void wlc_phy_freqtrack_start(struct brcms_phy_pub *ppi);
void wlc_phy_freqtrack_end(struct brcms_phy_pub *ppi);

const u8 *wlc_phy_get_ofdm_rate_lookup(void);

s8 wlc_phy_get_tx_power_offset_by_mcs(struct brcms_phy_pub *ppi,
				      u8 mcs_offset);
s8 wlc_phy_get_tx_power_offset(struct brcms_phy_pub *ppi, u8 tbl_offset);
#endif                          /* _BRCM_PHY_HAL_H_ */