drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
Extension
.c
Size
12688 bytes
Lines
482
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct brcmf_btcoex_info {
	struct brcmf_cfg80211_vif *vif;
	struct timer_list timer;
	u16 timeout;
	bool timer_on;
	bool dhcp_done;
	enum brcmf_btcoex_state bt_state;
	struct work_struct work;
	struct brcmf_cfg80211_info *cfg;
	u32 reg66;
	u32 reg41;
	u32 reg68;
	bool saved_regs_part1;
	u32 reg50;
	u32 reg51;
	u32 reg64;
	u32 reg65;
	u32 reg71;
	bool saved_regs_part2;
};

/**
 * brcmf_btcoex_params_write() - write btc_params firmware variable
 * @ifp: interface
 * @addr: btc_params register number
 * @data: data to write
 */
static s32 brcmf_btcoex_params_write(struct brcmf_if *ifp, u32 addr, u32 data)
{
	struct {
		__le32 addr;
		__le32 data;
	} reg_write;

	reg_write.addr = cpu_to_le32(addr);
	reg_write.data = cpu_to_le32(data);
	return brcmf_fil_iovar_data_set(ifp, "btc_params",
					&reg_write, sizeof(reg_write));
}

/**
 * brcmf_btcoex_params_read() - read btc_params firmware variable
 * @ifp: interface
 * @addr: btc_params register number
 * @data: read data
 */
static s32 brcmf_btcoex_params_read(struct brcmf_if *ifp, u32 addr, u32 *data)
{
	*data = addr;

	return brcmf_fil_iovar_int_query(ifp, "btc_params", data);
}

/**
 * brcmf_btcoex_boost_wifi() - control BT SCO/eSCO parameters
 * @btci: BT coex info
 * @trump_sco:
 *	true - set SCO/eSCO parameters for compatibility
 *		during DHCP window
 *	false - restore saved parameter values
 *
 * Enhanced BT COEX settings for eSCO compatibility during DHCP window
 */
static void brcmf_btcoex_boost_wifi(struct brcmf_btcoex_info *btci,
				    bool trump_sco)
{
	struct brcmf_if *ifp = brcmf_get_ifp(btci->cfg->pub, 0);

	if (trump_sco && !btci->saved_regs_part2) {
		/* this should reduce eSCO agressive
		 * retransmit w/o breaking it
		 */

		/* save current */
		brcmf_dbg(INFO, "new SCO/eSCO coex algo {save & override}\n");
		brcmf_btcoex_params_read(ifp, 50, &btci->reg50);
		brcmf_btcoex_params_read(ifp, 51, &btci->reg51);
		brcmf_btcoex_params_read(ifp, 64, &btci->reg64);
		brcmf_btcoex_params_read(ifp, 65, &btci->reg65);
		brcmf_btcoex_params_read(ifp, 71, &btci->reg71);

		btci->saved_regs_part2 = true;
		brcmf_dbg(INFO,
			  "saved bt_params[50,51,64,65,71]: 0x%x 0x%x 0x%x 0x%x 0x%x\n",
			  btci->reg50, btci->reg51, btci->reg64,
			  btci->reg65, btci->reg71);

		/* pacify the eSco   */
		brcmf_btcoex_params_write(ifp, 50, BRCMF_BT_DHCP_REG50);
		brcmf_btcoex_params_write(ifp, 51, BRCMF_BT_DHCP_REG51);

Annotation

Implementation Notes