Commit af03abec authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by John W. Linville
Browse files

ath9k: move hw specific btcoex info to ath_hw



Since we now access it via the ath_hw declare the ath_hw pointer
at the header of some routines and se it. ath9k.h no longer needs to
access btcoex.h and to adjust for this move ath_btcoex_set_weight()
into btcoex.h and instead give main.c a helper for setting initial
values upon drv_start()

Signed-off-by: default avatarLuis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2e20250a
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include "rc.h"
#include "debug.h"
#include "../ath.h"
#include "btcoex.h"

struct ath_node;

@@ -622,7 +621,6 @@ struct ath_softc {
	struct ath_bus_ops *bus_ops;
	struct ath_beacon_config cur_beacon_conf;
	struct delayed_work tx_complete_work;
	struct ath_btcoex_info btcoex_info;
	struct ath_btcoex btcoex;
};

+38 −19
Original line number Diff line number Diff line
@@ -43,14 +43,29 @@ bool ath_btcoex_supported(u16 subsysid)
	return false;
}

static void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
				  u32 bt_weight,
				  u32 wlan_weight)
{
	btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
				       SM(wlan_weight, AR_BTCOEX_WL_WGHT);
}

void ath9k_hw_btcoex_init_weight(struct ath_hw *ah)
{
	ath_btcoex_set_weight(&ah->btcoex_info, AR_BT_COEX_WGHT,
			      AR_STOMP_LOW_WLAN_WGHT);
}

/*
 * Detects if there is any priority bt traffic
 */
static void ath_detect_bt_priority(struct ath_softc *sc)
{
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_hw *ah = sc->sc_ah;

	if (ath9k_hw_gpio_get(sc->sc_ah, sc->btcoex_info.btpriority_gpio))
	if (ath9k_hw_gpio_get(sc->sc_ah, ah->btcoex_info.btpriority_gpio))
		btcoex->bt_priority_cnt++;

	if (time_after(jiffies, btcoex->bt_priority_time +
@@ -106,8 +121,9 @@ static void ath_btcoex_bt_stomp(struct ath_softc *sc,
static void ath_btcoex_period_timer(unsigned long data)
{
	struct ath_softc *sc = (struct ath_softc *) data;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_btcoex_info *btinfo = &sc->btcoex_info;
	struct ath_btcoex_info *btinfo = &ah->btcoex_info;

	ath_detect_bt_priority(sc);

@@ -119,9 +135,9 @@ static void ath_btcoex_period_timer(unsigned long data)

	if (btcoex->btcoex_period != btcoex->btcoex_no_stomp) {
		if (btcoex->hw_timer_enabled)
			ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer);
			ath_gen_timer_stop(ah, btinfo->no_stomp_timer);

		ath_gen_timer_start(sc->sc_ah,
		ath_gen_timer_start(ah,
			btinfo->no_stomp_timer,
			(ath9k_hw_gettsf32(sc->sc_ah) +
				btcoex->btcoex_no_stomp),
@@ -141,10 +157,11 @@ static void ath_btcoex_period_timer(unsigned long data)
static void ath_btcoex_no_stomp_timer(void *arg)
{
	struct ath_softc *sc = (struct ath_softc *)arg;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_btcoex_info *btinfo = &sc->btcoex_info;
	struct ath_btcoex_info *btinfo = &ah->btcoex_info;

	DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "no stomp timer running \n");
	DPRINTF(ah, ATH_DBG_BTCOEX, "no stomp timer running \n");

	spin_lock_bh(&btcoex->btcoex_lock);

@@ -156,14 +173,14 @@ static void ath_btcoex_no_stomp_timer(void *arg)
	spin_unlock_bh(&btcoex->btcoex_lock);
}

static int ath_init_btcoex_info(struct ath_hw *hw,
static int ath_init_btcoex_info(struct ath_hw *ah,
				struct ath_btcoex_info *btcoex_info)
{
	struct ath_btcoex *btcoex = &hw->ah_sc->btcoex;
	struct ath_btcoex *btcoex = &ah->ah_sc->btcoex;
	u32 i;
	int qnum;

	qnum = ath_tx_get_qnum(hw->ah_sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);
	qnum = ath_tx_get_qnum(ah->ah_sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);

	btcoex_info->bt_coex_mode =
		(btcoex_info->bt_coex_mode & AR_BT_QCU_THRESH) |
@@ -190,15 +207,15 @@ static int ath_init_btcoex_info(struct ath_hw *hw,
		btcoex->btcoex_period / 100;

	for (i = 0; i < 32; i++)
		hw->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i;
		ah->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i;

	setup_timer(&btcoex->period_timer, ath_btcoex_period_timer,
			(unsigned long) hw->ah_sc);
			(unsigned long) ah->ah_sc);

	btcoex_info->no_stomp_timer = ath_gen_timer_alloc(hw,
	btcoex_info->no_stomp_timer = ath_gen_timer_alloc(ah,
			ath_btcoex_no_stomp_timer,
			ath_btcoex_no_stomp_timer,
			(void *)hw->ah_sc, AR_FIRST_NDP_TIMER);
			(void *)ah->ah_sc, AR_FIRST_NDP_TIMER);

	if (btcoex_info->no_stomp_timer == NULL)
		return -ENOMEM;
@@ -210,7 +227,7 @@ static int ath_init_btcoex_info(struct ath_hw *hw,

int ath9k_hw_btcoex_init(struct ath_hw *ah)
{
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
	struct ath_btcoex_info *btcoex_info = &ah->btcoex_info;
	int ret = 0;

	if (btcoex_info->btcoex_scheme == ATH_BTCOEX_CFG_2WIRE) {
@@ -258,7 +275,7 @@ int ath9k_hw_btcoex_init(struct ath_hw *ah)

void ath9k_hw_btcoex_enable(struct ath_hw *ah)
{
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
	struct ath_btcoex_info *btcoex_info = &ah->btcoex_info;

	if (btcoex_info->btcoex_scheme == ATH_BTCOEX_CFG_2WIRE) {
		/* Configure the desired GPIO port for TX_FRAME output */
@@ -291,7 +308,7 @@ void ath9k_hw_btcoex_enable(struct ath_hw *ah)

void ath9k_hw_btcoex_disable(struct ath_hw *ah)
{
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
	struct ath_btcoex_info *btcoex_info = &ah->btcoex_info;

	ath9k_hw_set_gpio(ah, btcoex_info->wlanactive_gpio, 0);

@@ -313,11 +330,12 @@ void ath9k_hw_btcoex_disable(struct ath_hw *ah)
void ath_btcoex_timer_pause(struct ath_softc *sc)
{
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_hw *ah = sc->sc_ah;

	del_timer_sync(&btcoex->period_timer);

	if (btcoex->hw_timer_enabled)
		ath_gen_timer_stop(sc->sc_ah, sc->btcoex_info.no_stomp_timer);
		ath_gen_timer_stop(ah, ah->btcoex_info.no_stomp_timer);

	btcoex->hw_timer_enabled = false;
}
@@ -328,12 +346,13 @@ void ath_btcoex_timer_pause(struct ath_softc *sc)
void ath_btcoex_timer_resume(struct ath_softc *sc)
{
	struct ath_btcoex *btcoex = &sc->btcoex;
	struct ath_hw *ah = sc->sc_ah;

	DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "Starting btcoex timers");
	DPRINTF(ah, ATH_DBG_BTCOEX, "Starting btcoex timers");

	/* make sure duty cycle timer is also stopped when resuming */
	if (btcoex->hw_timer_enabled)
		ath_gen_timer_stop(sc->sc_ah, sc->btcoex_info.no_stomp_timer);
		ath_gen_timer_stop(sc->sc_ah, ah->btcoex_info.no_stomp_timer);

	btcoex->bt_priority_cnt = 0;
	btcoex->bt_priority_time = jiffies;
+3 −11
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef BTCOEX_H
#define BTCOEX_H

#include "hw.h"

#define ATH_WLANACTIVE_GPIO	5
#define ATH_BTACTIVE_GPIO	6
#define ATH_BTPRIORITY_GPIO	7
@@ -74,19 +76,9 @@ struct ath_btcoex_info {
};

bool ath_btcoex_supported(u16 subsysid);
void ath9k_hw_btcoex_init_weight(struct ath_hw *ah);
int ath9k_hw_btcoex_init(struct ath_hw *ah);
void ath9k_hw_btcoex_enable(struct ath_hw *ah);
void ath9k_hw_btcoex_disable(struct ath_hw *ah);

void ath_btcoex_timer_resume(struct ath_softc *sc);
void ath_btcoex_timer_pause(struct ath_softc *sc);

static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
					 u32 bt_weight,
					 u32 wlan_weight)
{
		btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
				       SM(wlan_weight, AR_BTCOEX_WL_WGHT);
}

#endif
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <asm/unaligned.h>
#include <linux/pci.h>

#include "hw.h"
#include "ath9k.h"
#include "initvals.h"

@@ -3558,7 +3559,7 @@ void ath9k_hw_fill_cap_info(struct ath_hw *ah)
{
	struct ath9k_hw_capabilities *pCap = &ah->caps;
	struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
	struct ath_btcoex_info *btcoex_info = &ah->ah_sc->btcoex_info;
	struct ath_btcoex_info *btcoex_info = &ah->btcoex_info;

	u16 capField = 0, eeval;

+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "calib.h"
#include "reg.h"
#include "phy.h"
#include "btcoex.h"

#include "../regd.h"

@@ -553,6 +554,9 @@ struct ath_hw {
	int firpwr[5];
	enum ath9k_ani_cmd ani_function;

	/* Bluetooth coexistance */
	struct ath_btcoex_info btcoex_info;

	u32 intr_txqs;
	enum ath9k_ht_extprotspacing extprotspacing;
	u8 txchainmask;
@@ -675,4 +679,7 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah);
#define ATH_PCIE_CAP_LINK_L1	2

void ath_pcie_aspm_disable(struct ath_softc *sc);

void ath_btcoex_timer_resume(struct ath_softc *sc);
void ath_btcoex_timer_pause(struct ath_softc *sc);
#endif
Loading