Skip to contentSkip to conversation

ath9k_hw: ar93xx initial abstraction work

PATCH Superseded Luis R. Rodriguez 2 participants 26 messages Mar 17, 2010 – Mar 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover ath9k_hw: ar93xx initial abstraction work

Here's what I have so far, this is rebased on top of Senthil's patches for ath9k_htc posted today. Just tested it on my AR9280, it doesn't break anything.

Luis R. Rodriguez (20):
ath9k: start building an abstraction layer for hardware routines
ath9k: initial move of ar9002 specific code to its own file
ath9k: rename initvals.h to ar9002_initvals.h
ath9k_hw: rename getNoiseFloorThresh() to ath9k_hw_getnf_thres()
ath9k_hw: move < AR9002 specific calibration stuff to its own file
ath9k_hw: move calibration settings to ar9002_calib_settings.c
ath9k_hw: consolidate the pci express checks on __ath9k_hw_init()
ath9k_hw: move ar9002 bluetooth coexistence code to its own file
ath9k_hw: Use a helper for setting phy error masks
ath9k_hw: add helpers for writing phy errors counts
ath9k_hw: add a helper for phy error counter reads
ath9k_hw: add documentation for the TPC register
ath9k_hw: remove unused and buggy ath9k_hw_GetMibCycleCountsPct()
ath9k_hw: add a helper for retrieving the MIB cycle counters
ath9k_hw: provide a helper for clearing the MIB counters
ath9k_hw: simplify reseting of the MIB control register
ath9k_hw: provide a helper for managing the MIB control register
ath9k_hw: move common defines for ANI into ath/reg.h
ath9k_hw: move ar9002 ANI code to its own file
ath9k_hw: remove wrapper ath9k_hw_write_regs()

 drivers/net/wireless/ath/ath9k/Makefile            |    6 +-
 drivers/net/wireless/ath/ath9k/ani.c               |  403 +-
 drivers/net/wireless/ath/ath9k/ani.h               |   22 +-
 drivers/net/wireless/ath/ath9k/ar9002_ani.c        |  356 +
 drivers/net/wireless/ath/ath9k/ar9002_btcoex.c     |  239 +
 drivers/net/wireless/ath/ath9k/ar9002_calib.c      |  826 +++
 .../net/wireless/ath/ath9k/ar9002_calib_settings.c |  388 ++
 drivers/net/wireless/ath/ath9k/ar9002_hw.c         |  821 +++
 drivers/net/wireless/ath/ath9k/ar9002_initvals.h   | 7115 ++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/btcoex.c            |  227 -
 drivers/net/wireless/ath/ath9k/btcoex.h            |   10 -
 drivers/net/wireless/ath/ath9k/calib.c             | 1095 +---
 drivers/net/wireless/ath/ath9k/calib.h             |   15 +-
 drivers/net/wireless/ath/ath9k/common.h            |    1 +
 drivers/net/wireless/ath/ath9k/hw-ops.h            |  235 +
 drivers/net/wireless/ath/ath9k/hw.c                |  911 +---
 drivers/net/wireless/ath/ath9k/hw.h                |  149 +-
 drivers/net/wireless/ath/ath9k/init.c              |    9 +-
 drivers/net/wireless/ath/ath9k/initvals.h          | 7115 --------------------
 drivers/net/wireless/ath/ath9k/phy.c               |   15 -
 drivers/net/wireless/ath/ath9k/phy.h               |    3 -
 drivers/net/wireless/ath/ath9k/reg.h               |   17 +-
 drivers/net/wireless/ath/reg.h                     |    5 +
 23 files changed, 10382 insertions(+), 9601 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_ani.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_btcoex.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_calib.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_calib_settings.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_hw.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_initvals.h
 delete mode 100644 drivers/net/wireless/ath/ath9k/btcoex.c
 create mode 100644 drivers/net/wireless/ath/ath9k/hw-ops.h
 delete mode 100644 drivers/net/wireless/ath/ath9k/initvals.h
#1 lore raw

PATCH v2 1/20 ath9k: start building an abstraction layer for hardware routines

ath9k supports the AR5008, AR9001 and AR9002 family of Atheros chipsets, all 802.11n. The new breed of 802.11n chips, the AR9003 family will be supported as well but each register read and write uses a different register definition and and such to support it we need to build a hardware family abstraction layer.

This patch starts the abstraction layer through a set of callbacks. Our approach is to avoid as much duplicate code as is possible so where we can we will be re-using the same routines and only add callbacks for specific hardware functions which do direct hardware reads or writes. This starts off addressing hardware routines used during hardware initialization.

The benefit with this approach is the core of the driver won't need to be changed at all, except for areas where the hardware does require some changes like DMA, which is the case for AR9003.

---
 drivers/net/wireless/ath/ath9k/common.h |    1 +
 drivers/net/wireless/ath/ath9k/hw-ops.h |   36 ++++++++
 drivers/net/wireless/ath/ath9k/hw.c     |  144 ++++++++++++++++++++++---------
 drivers/net/wireless/ath/ath9k/hw.h     |   57 +++++++++++-
 drivers/net/wireless/ath/ath9k/init.c   |    7 +-
 5 files changed, 194 insertions(+), 51 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/hw-ops.h
drivers/net/wireless/ath/ath9k/common.h +1 -0
index bbcc57f..17ad34a 100644
@@ -20,6 +20,7 @@
 #include "../debug.h"
 
 #include "hw.h"
+#include "hw-ops.h"
 
 /* Common header for Atheros 802.11n base driver cores */
 
drivers/net/wireless/ath/ath9k/hw-ops.h new file +36 -0
new file mode 100644
index 0000000..0f9c29d
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010 Atheros Communications Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef ATH9K_HW_OPS_H
+#define ATH9K_HW_OPS_H
+
+#include "hw.h"
+
+/* Hardware core and driver accessible callbacks */
+
+static inline bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
+{
+	return ath9k_hw_ops(ah)->set_power(ah, mode);
+}
+
+static inline void ath9k_hw_configpcipowersave(struct ath_hw *ah,
+					       int restore,
+					       int power_off)
+{
+	ath9k_hw_ops(ah)->config_pci_powersave(ah, restore, power_off);
+}
+
+#endif /* ATH9K_HW_OPS_H */
drivers/net/wireless/ath/ath9k/hw.c +102 -42

259 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +53 -4

87 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/init.c +2 -5
index 6063f54..62682cc 100644
@@ -566,13 +566,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
 	ath_read_cachesize(common, &csz);
 	common->cachelsz = csz << 2; /* convert to bytes */
 
+	/* Initializes the hardware for all supported chipsets */
 	ret = ath9k_hw_init(ah);
-	if (ret) {
-		ath_print(common, ATH_DBG_FATAL,
-			  "Unable to initialize hardware; "
-			  "initialization status: %d\n", ret);
+	if (ret)
 		goto err_hw;
-	}
 
 	ret = ath9k_init_debug(ah);
 	if (ret) {
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v2 2/20 ath9k: initial move of ar9002 specific code to its own file

In reply to Luis R. Rodriguez

Move wardware code specific to ar9002 to its own file to make things easier to read and manage. This just shuffles code and adds three private hardware callbacks to allow us to move the
rest: init_pll, init_mode_gains and init_14_spread.

---
 drivers/net/wireless/ath/ath9k/Makefile    |    1 +
 drivers/net/wireless/ath/ath9k/ar9002_hw.c |  839 ++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw-ops.h    |   31 +-
 drivers/net/wireless/ath/ath9k/hw.c        |  821 +---------------------------
 drivers/net/wireless/ath/ath9k/hw.h        |    6 +
 5 files changed, 878 insertions(+), 820 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_hw.c
drivers/net/wireless/ath/ath9k/Makefile +1 -0
index 97133be..fe53595 100644
@@ -14,6 +14,7 @@ ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o
 obj-$(CONFIG_ATH9K) += ath9k.o
 
 ath9k_hw-y:=	hw.o \
+		ar9002_hw.o \
 		eeprom.o \
 		eeprom_def.o \
 		eeprom_4k.o \
drivers/net/wireless/ath/ath9k/ar9002_hw.c new file +839 -0

839 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw-ops.h +30 -1
index 0f9c29d..54bb57f 100644
@@ -19,7 +19,10 @@
 
 #include "hw.h"
 
-/* Hardware core and driver accessible callbacks */
+/*
+ * Hardware core and driver accessible callbacks. Both hardware code
+ * and the driver core is expected to make use of these calls.
+ */
 
 static inline bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
 {
@@ -33,4 +36,30 @@ static inline void ath9k_hw_configpcipowersave(struct ath_hw *ah,
 	ath9k_hw_ops(ah)->config_pci_powersave(ah, restore, power_off);
 }
 
+/*
+ * Private common hardware helpers. It is not expected that the core
+ * driver will use any of these calls
+ */
+
+static inline bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
+{
+	return ath9k_hw_private_ops(ah)->set_reset_reg(ah, type);
+}
+
+static inline void ath9k_hw_init_pll(struct ath_hw *ah,
+				     struct ath9k_channel *chan)
+{
+	ath9k_hw_private_ops(ah)->init_pll(ah, chan);
+}
+
+static inline void ath9k_hw_init_mode_gains(struct ath_hw *ah)
+{
+	ath9k_hw_private_ops(ah)->init_mode_gains(ah);
+}
+
+static inline void ath9k_hw_init_14_spread(struct ath_hw *ah)
+{
+	ath9k_hw_private_ops(ah)->init_14_spread(ah);
+}
+
 #endif /* ATH9K_HW_OPS_H */
drivers/net/wireless/ath/ath9k/hw.c +2 -819

889 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +6 -0
index 5a73d51..1b1b18d 100644
@@ -453,6 +453,9 @@ struct ath_gen_timer_table {
  * @macversion_supported: If this specific mac revision is supported
  * @set_reset_reg:
  * @disable_pcie:
+ * @init_pll:
+ * @init_mode_gains:
+ * @init_14_spread:
  */
 struct ath_hw_private_ops {
 	void (*init_cal_settings)(struct ath_hw *ah);
@@ -460,6 +463,9 @@ struct ath_hw_private_ops {
 	bool (*macversion_supported)(u32 macversion);
 	bool (*set_reset_reg)(struct ath_hw *ah, u32 type);
 	void (*disable_pcie)(struct ath_hw *ah);
+	void (*init_pll)(struct ath_hw *ah, struct ath9k_channel *chan);
+	void (*init_mode_gains)(struct ath_hw *ah);
+	void (*init_14_spread)(struct ath_hw *ah);
 };
 
 /**
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v2 3/20 ath9k: rename initvals.h to ar9002_initvals.h

In reply to Luis R. Rodriguez

The register initialization values we have so far are only for the AR5008, AR9002 and AR9002 hardware families and we've managed to get ar90002_hw.c to be its only user so clarify this by renaming the initvals.

---
 drivers/net/wireless/ath/ath9k/ar9002_hw.c       |    6 +-
 drivers/net/wireless/ath/ath9k/ar9002_initvals.h | 7115 ++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/initvals.h        | 7115 ----------------------
 3 files changed, 7118 insertions(+), 7118 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_initvals.h
 delete mode 100644 drivers/net/wireless/ath/ath9k/initvals.h
drivers/net/wireless/ath/ath9k/ar9002_hw.c +3 -3
index 76e49b4..154ca8d 100644
@@ -17,7 +17,7 @@
 #include "hw.h"
 #include "hw-ops.h"
 #include "rc.h"
-#include "initvals.h"
+#include "ar9002_initvals.h"
 
 static void ar9002_hw_disablepcie(struct ath_hw *ah)
 {
@@ -611,8 +611,8 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
 		if (AR_SREV_9280_20_OR_LATER(ah)) {
 			/*
 			 * AR9280 2.0 or later chips use SerDes values from the
-			 * initvals.h initialized depending on chipset during
-			 * __ath9k_hw_init()
+			 * ar9002_initvals.h initialized depending on chipset
+			 * during __ath9k_hw_init()
 			 */
 			for (i = 0; i < ah->iniPcieSerdes.ia_rows; i++) {
 				REG_WRITE(ah, INI_RA(&ah->iniPcieSerdes, i, 0),
drivers/net/wireless/ath/ath9k/ar9002_initvals.h new file +7115 -0

2,982 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/initvals.h deleted +0 -7115

7,115 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.6.3.3

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH v2 4/20 ath9k_hw: rename getNoiseFloorThresh() to ath9k_hw_getnf_thres()

In reply to Luis R. Rodriguez
---
 drivers/net/wireless/ath/ath9k/calib.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/calib.c +4 -4
index d5026e4..e4627da 100644
@@ -175,9 +175,9 @@ static void ath9k_hw_do_getnf(struct ath_hw *ah,
 	}
 }
 
-static bool getNoiseFloorThresh(struct ath_hw *ah,
-				enum ieee80211_band band,
-				int16_t *nft)
+static bool ath9k_hw_getnf_thres(struct ath_hw *ah,
+				 enum ieee80211_band band,
+				 int16_t *nft)
 {
 	switch (band) {
 	case IEEE80211_BAND_5GHZ:
@@ -698,7 +698,7 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah,
 	} else {
 		ath9k_hw_do_getnf(ah, nfarray);
 		nf = nfarray[0];
-		if (getNoiseFloorThresh(ah, c->band, &nfThresh)
+		if (ath9k_hw_getnf_thres(ah, c->band, &nfThresh)
 		    && nf > nfThresh) {
 			ath_print(common, ATH_DBG_CALIBRATE,
 				  "noise floor failed detected; "
Signature · 1 line
1.6.3.3
#5 lore raw

PATCH v2 5/20 ath9k_hw: move < AR9002 specific calibration stuff to its own file

In reply to Luis R. Rodriguez

This moves the calibration hardware code specific to AR5008, AR9001 and AR9002 to its own set of files. To make things easier to read and maintain we split the calibration hardware code into two files, one for generic calibration routines and another for the settings used for the three different types of calibration supported:

* IQ calibration
* ADC gain calibration
* ADC-DC calibration

Each of these have their own respective collection routine and calibration routines.

To get do all this we move power amplifier calibration code to its own helper, ath9k_hw_pa_cal(). I noticed that ath9k_hw_pa_cal() checks for a skip on calibration, but during ar9002_hw_init_cal(), which is called upon reset we don't check for a skip. We'll need to review that further.

---
 drivers/net/wireless/ath/ath9k/Makefile            |    2 +
 drivers/net/wireless/ath/ath9k/ar9002_calib.c      |  823 +++++++++++++++
 .../net/wireless/ath/ath9k/ar9002_calib_settings.c |  350 +++++++
 drivers/net/wireless/ath/ath9k/ar9002_hw.c         |    2 +
 drivers/net/wireless/ath/ath9k/calib.c             | 1095 +-------------------
 drivers/net/wireless/ath/ath9k/calib.h             |    7 +-
 drivers/net/wireless/ath/ath9k/hw-ops.h            |   50 +
 drivers/net/wireless/ath/ath9k/hw.h                |   25 +
 8 files changed, 1257 insertions(+), 1097 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_calib.c
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_calib_settings.c
drivers/net/wireless/ath/ath9k/Makefile +2 -0
index fe53595..6c1594b 100644
@@ -15,6 +15,8 @@ obj-$(CONFIG_ATH9K) += ath9k.o
 
 ath9k_hw-y:=	hw.o \
 		ar9002_hw.o \
+		ar9002_calib.o \
+		ar9002_calib_settings.o \
 		eeprom.o \
 		eeprom_def.o \
 		eeprom_4k.o \
drivers/net/wireless/ath/ath9k/ar9002_calib.c new file +823 -0

823 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ar9002_calib_settings.c new file +350 -0

350 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ar9002_hw.c +2 -0
index 154ca8d..5a8da22 100644
@@ -835,5 +835,7 @@ void ar9002_hw_attach_ops(struct ath_hw *ah)
 
 	ops->set_power = &ar9002_hw_setpower;
 	ops->config_pci_powersave = &ar9002_hw_configpcipowersave;
+
+	ar9002_hw_attach_calib_ops(ah);
 }
 EXPORT_SYMBOL(ar9002_hw_attach_ops);
drivers/net/wireless/ath/ath9k/calib.c +4 -1091

1,137 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/calib.h +1 -6
index b2c873e..039c247 100644
@@ -121,15 +121,10 @@ struct ath9k_pacal_info{
 };
 
 bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
-void ath9k_hw_start_nfcal(struct ath_hw *ah);
-void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
-int16_t ath9k_hw_getnf(struct ath_hw *ah,
-		       struct ath9k_channel *chan);
 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah);
 s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
 bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
 			u8 rxchainmask, bool longcal);
-bool ath9k_hw_init_cal(struct ath_hw *ah,
-		       struct ath9k_channel *chan);
+bool ath9k_hw_iscal_supported(struct ath_hw *ah, enum ath9k_cal_types calType);
 
 #endif /* CALIB_H */
drivers/net/wireless/ath/ath9k/hw-ops.h +50 -0

54 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +25 -0
index 1b1b18d..06d5c2a 100644
@@ -456,8 +456,18 @@ struct ath_gen_timer_table {
  * @init_pll:
  * @init_mode_gains:
  * @init_14_spread:
+ *
+ * @getnf: get the noise floor for the passed channel
+ * @reset_calibration:
+ * @per_calibration:
+ * @init_cal:
+ * @olc_temp_compensation:
+ * @loadnf:
+ * @start_nfcal: start noise floor calibration
+ * @pa_cal: Power amplifier calibration
  */
 struct ath_hw_private_ops {
+	/* General hardware ops */
 	void (*init_cal_settings)(struct ath_hw *ah);
 	void (*init_mode_regs)(struct ath_hw *ah);
 	bool (*macversion_supported)(u32 macversion);
@@ -466,6 +476,20 @@ struct ath_hw_private_ops {
 	void (*init_pll)(struct ath_hw *ah, struct ath9k_channel *chan);
 	void (*init_mode_gains)(struct ath_hw *ah);
 	void (*init_14_spread)(struct ath_hw *ah);
+
+	/* Calibration ops */
+	int16_t (*getnf)(struct ath_hw *ah, struct ath9k_channel *chan);
+	void (*reset_calibration)(struct ath_hw *ah,
+				  struct ath9k_cal_list *currCal);
+	bool (*per_calibration)(struct ath_hw *ah,
+				struct ath9k_channel *ichan,
+				u8 rxchainmask,
+				struct ath9k_cal_list *currCal);
+	bool (*init_cal)(struct ath_hw *ah, struct ath9k_channel *chan);
+	void (*olc_temp_compensation)(struct ath_hw *ah);
+	void (*loadnf)(struct ath_hw *ah, struct ath9k_channel *chan);
+	void (*start_nfcal)(struct ath_hw *ah);
+	void (*pa_cal)(struct ath_hw *ah);
 };
 
 /**
@@ -761,6 +785,7 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah);
 void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len);
 
 void ar9002_hw_attach_ops(struct ath_hw *ah);
+void ar9002_hw_attach_calib_ops(struct ath_hw *ah);
 
 /* HTC */
 void ath9k_hw_htc_resetinit(struct ath_hw *ah);
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH v2 6/20 ath9k_hw: move calibration settings to ar9002_calib_settings.c

In reply to Luis R. Rodriguez

Since we now have all the calibration functions and structures on ar9002_calib_settings.c we might as well move the function that sets these up there as well.

While at it, simplify it a little and also move the AR9100 calibration settings there too since they were just dangling on a random place on __ath9k_hw_init().

Doing this lets us remove the externs on the structures saving ourselves about 272 bytes mostly on the text area of ath9k_hw:

Before:
3746008 bytes ath9k_hw.ko
text data bss dec hex filename
221433 1088 1808 224329 36c49 ath9k_hw.ko

After:
3745736 bytes ath9k_hw.ko
text data bss dec hex filename
221417 1088 1808 224313 36c39 ath9k_hw.ko

---
 drivers/net/wireless/ath/ath9k/ar9002_calib.c      |    3 +
 .../net/wireless/ath/ath9k/ar9002_calib_settings.c |   52 +++++++++++++++++---
 drivers/net/wireless/ath/ath9k/ar9002_hw.c         |   25 ---------
 drivers/net/wireless/ath/ath9k/calib.h             |    8 ---
 drivers/net/wireless/ath/ath9k/hw.c                |    5 +--
 5 files changed, 49 insertions(+), 44 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_calib.c +3 -0
index bec0467..0313121 100644
@@ -22,6 +22,8 @@
  * the chipsets under the hardware families: AR5008, AR9001, and AR9002
  */
 
+extern void ar9002_hw_init_cal_settings(struct ath_hw *ah);
+
 static void ar9002_hw_do_getnf(struct ath_hw *ah,
 			      int16_t nfarray[NUM_NF_READINGS])
 {
@@ -820,4 +822,5 @@ void ar9002_hw_attach_calib_ops(struct ath_hw *ah)
 	priv_ops->loadnf = &ar9002_hw_loadnf;
 	priv_ops->start_nfcal = &ar9002_hw_start_nfcal;
 	priv_ops->pa_cal = &ar9002_hw_pa_cal;
+	priv_ops->init_cal_settings = &ar9002_hw_init_cal_settings;
 }
drivers/net/wireless/ath/ath9k/ar9002_calib_settings.c +45 -7

97 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ar9002_hw.c +0 -25
index 5a8da22..7c46c1e 100644
@@ -55,30 +55,6 @@ static bool ar9002_hw_macversion_supported(u32 macversion)
 	return false;
 }
 
-static void ar9002_hw_init_cal_settings(struct ath_hw *ah)
-{
-	if (AR_SREV_9160_10_OR_LATER(ah)) {
-		if (AR_SREV_9280_10_OR_LATER(ah)) {
-			ah->iq_caldata.calData = &iq_cal_single_sample;
-			ah->adcgain_caldata.calData =
-				&adc_gain_cal_single_sample;
-			ah->adcdc_caldata.calData =
-				&adc_dc_cal_single_sample;
-			ah->adcdc_calinitdata.calData =
-				&adc_init_dc_cal;
-		} else {
-			ah->iq_caldata.calData = &iq_cal_multi_sample;
-			ah->adcgain_caldata.calData =
-				&adc_gain_cal_multi_sample;
-			ah->adcdc_caldata.calData =
-				&adc_dc_cal_multi_sample;
-			ah->adcdc_calinitdata.calData =
-				&adc_init_dc_cal;
-		}
-		ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
-	}
-}
-
 static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
 {
 	if (AR_SREV_9271(ah)) {
@@ -824,7 +800,6 @@ void ar9002_hw_attach_ops(struct ath_hw *ah)
 	struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
 	struct ath_hw_ops *ops = ath9k_hw_ops(ah);
 
-	priv_ops->init_cal_settings = &ar9002_hw_init_cal_settings;
 	priv_ops->init_mode_regs = &ar9002_hw_init_mode_regs;
 	priv_ops->macversion_supported = &ar9002_hw_macversion_supported;
 	priv_ops->set_reset_reg = &ar9002_hw_set_reset_reg;
drivers/net/wireless/ath/ath9k/calib.h +0 -8
index 039c247..9d647db 100644
@@ -19,14 +19,6 @@
 
 #include "hw.h"
 
-extern const struct ath9k_percal_data iq_cal_multi_sample;
-extern const struct ath9k_percal_data iq_cal_single_sample;
-extern const struct ath9k_percal_data adc_gain_cal_multi_sample;
-extern const struct ath9k_percal_data adc_gain_cal_single_sample;
-extern const struct ath9k_percal_data adc_dc_cal_multi_sample;
-extern const struct ath9k_percal_data adc_dc_cal_single_sample;
-extern const struct ath9k_percal_data adc_init_dc_cal;
-
 #define AR_PHY_CCA_MAX_AR5416_GOOD_VALUE	-85
 #define AR_PHY_CCA_MAX_AR9280_GOOD_VALUE	-112
 #define AR_PHY_CCA_MAX_AR9285_GOOD_VALUE	-118
drivers/net/wireless/ath/ath9k/hw.c +1 -4
index 2a63b42..8d376ce 100644
@@ -535,11 +535,8 @@ int __ath9k_hw_init(struct ath_hw *ah)
 		return -EOPNOTSUPP;
 	}
 
-	if (AR_SREV_9100(ah)) {
-		ah->iq_caldata.calData = &iq_cal_multi_sample;
-		ah->supp_cals = IQ_MISMATCH_CAL;
+	if (AR_SREV_9100(ah))
 		ah->is_pciexpress = false;
-	}
 
 	if (AR_SREV_9271(ah))
 		ah->is_pciexpress = false;
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v2 7/20 ath9k_hw: consolidate the pci express checks on __ath9k_hw_init()

In reply to Luis R. Rodriguez
---
 drivers/net/wireless/ath/ath9k/hw.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +1 -4
index 8d376ce..9093235 100644
@@ -535,10 +535,7 @@ int __ath9k_hw_init(struct ath_hw *ah)
 		return -EOPNOTSUPP;
 	}
 
-	if (AR_SREV_9100(ah))
-		ah->is_pciexpress = false;
-
-	if (AR_SREV_9271(ah))
+	if (AR_SREV_9100(ah) || AR_SREV_9271(ah))
 		ah->is_pciexpress = false;
 
 	/* XXX: move this to its own hw op */
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v2 8/20 ath9k_hw: move ar9002 bluetooth coexistence code to its own file

In reply to Luis R. Rodriguez

It turns out all these routines do their own read/writes so just move the entire file. If btcoex is supported by the chipset the calls will be enabled and the driver core and hardware call will issue calls for btcoex.

---
 drivers/net/wireless/ath/ath9k/Makefile        |    2 +-
 drivers/net/wireless/ath/ath9k/ar9002_btcoex.c |  239 ++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/ar9002_hw.c     |    3 +
 drivers/net/wireless/ath/ath9k/btcoex.c        |  227 ----------------------
 drivers/net/wireless/ath/ath9k/btcoex.h        |   10 -
 drivers/net/wireless/ath/ath9k/hw-ops.h        |   51 +++++
 drivers/net/wireless/ath/ath9k/hw.h            |   26 +++
 drivers/net/wireless/ath/ath9k/init.c          |    2 +-
 8 files changed, 321 insertions(+), 239 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_btcoex.c
 delete mode 100644 drivers/net/wireless/ath/ath9k/btcoex.c
drivers/net/wireless/ath/ath9k/Makefile +1 -1
index 6c1594b..affbf84 100644
@@ -17,6 +17,7 @@ ath9k_hw-y:=	hw.o \
 		ar9002_hw.o \
 		ar9002_calib.o \
 		ar9002_calib_settings.o \
+		ar9002_btcoex.o \
 		eeprom.o \
 		eeprom_def.o \
 		eeprom_4k.o \
@@ -24,7 +25,6 @@ ath9k_hw-y:=	hw.o \
 		calib.o \
 		ani.o \
 		phy.o \
-		btcoex.o \
 		mac.o \
 
 obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o
drivers/net/wireless/ath/ath9k/ar9002_btcoex.c new file +239 -0

239 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ar9002_hw.c +3 -0
index 7c46c1e..8e5a07d 100644
@@ -19,6 +19,8 @@
 #include "rc.h"
 #include "ar9002_initvals.h"
 
+extern void ar9002_hw_attach_btcoex_ops(struct ath_hw *ah);
+
 static void ar9002_hw_disablepcie(struct ath_hw *ah)
 {
 	if (AR_SREV_9100(ah))
@@ -812,5 +814,6 @@ void ar9002_hw_attach_ops(struct ath_hw *ah)
 	ops->config_pci_powersave = &ar9002_hw_configpcipowersave;
 
 	ar9002_hw_attach_calib_ops(ah);
+	ar9002_hw_attach_btcoex_ops(ah);
 }
 EXPORT_SYMBOL(ar9002_hw_attach_ops);
drivers/net/wireless/ath/ath9k/btcoex.c deleted +0 -227

227 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/btcoex.h +0 -10
index 1ee5a15..0217df0 100644
@@ -49,14 +49,4 @@ struct ath_btcoex_hw {
 	u32 bt_coex_mode2; 	/* Register setting for AR_BT_COEX_MODE2 */
 };
 
-bool ath9k_hw_btcoex_supported(struct ath_hw *ah);
-void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah);
-void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah);
-void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum);
-void ath9k_hw_btcoex_set_weight(struct ath_hw *ah,
-				u32 bt_weight,
-				u32 wlan_weight);
-void ath9k_hw_btcoex_enable(struct ath_hw *ah);
-void ath9k_hw_btcoex_disable(struct ath_hw *ah);
-
 #endif
drivers/net/wireless/ath/ath9k/hw-ops.h +51 -0

55 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +26 -0
index 06d5c2a..ed137a8 100644
@@ -465,6 +465,10 @@ struct ath_gen_timer_table {
  * @loadnf:
  * @start_nfcal: start noise floor calibration
  * @pa_cal: Power amplifier calibration
+ *
+ * @btcoex_supported: whether or not bluetooth coexistence is supported
+ * @btcoex_enable_2wire:
+ * @btcoex_enable_3wire:
  */
 struct ath_hw_private_ops {
 	/* General hardware ops */
@@ -490,6 +494,11 @@ struct ath_hw_private_ops {
 	void (*loadnf)(struct ath_hw *ah, struct ath9k_channel *chan);
 	void (*start_nfcal)(struct ath_hw *ah);
 	void (*pa_cal)(struct ath_hw *ah);
+
+	/* Bluetooth coexistence ops */
+	bool (*btcoex_supported)(struct ath_hw *ah);
+	void (*btcoex_enable_2wire)(struct ath_hw *ah);
+	void (*btcoex_enable_3wire)(struct ath_hw *ah);
 };
 
 /**
@@ -500,12 +509,29 @@ struct ath_hw_private_ops {
  *
  * @set_power:
  * @config_pci_powersave:
+ *
+ * @btcoex_init:
+ * @btcoex_init_2wire:
+ * @btcoex_init_3wire:
+ * @btcoex_set_weight:
+ * @btcoex_enable:
+ * @btcoex_disable:
  */
 struct ath_hw_ops {
 	bool (*set_power)(struct ath_hw *ah, enum ath9k_power_mode mode);
 	void (*config_pci_powersave)(struct ath_hw *ah,
 				    int restore,
 				    int power_off);
+
+	/* Bluetooth coexistence ops */
+	void (*btcoex_init)(struct ath_hw *ah, int qnum);
+	void (*btcoex_init_2wire)(struct ath_hw *ah);
+	void (*btcoex_init_3wire)(struct ath_hw *ah);
+	void (*btcoex_set_weight)(struct ath_hw *ah,
+				  u32 bt_weight,
+				  u32 wlan_weight);
+	void (*btcoex_enable)(struct ath_hw *ah);
+	void (*btcoex_disable)(struct ath_hw *ah);
 };
 
 struct ath_hw {
drivers/net/wireless/ath/ath9k/init.c +1 -1
index 62682cc..b7fd491 100644
@@ -402,7 +402,7 @@ static int ath9k_init_btcoex(struct ath_softc *sc)
 		if (r)
 			return -1;
 		qnum = ath_tx_get_qnum(sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE);
-		ath9k_hw_init_btcoex_hw(sc->sc_ah, qnum);
+		ath9k_hw_btcoex_init(sc->sc_ah, qnum);
 		sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
 		break;
 	default:
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH v2 9/20 ath9k_hw: Use a helper for setting phy error masks

In reply to Luis R. Rodriguez

The phy error masks are used consistently on ani.c so define a common helper for this. We will later use this to further abstract direct hardware reads/writes depending on the chipset. While at it, add some sort of explanation as to what these masks are for.

---
 drivers/net/wireless/ath/ath9k/ani.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +15 -6
index 2a0cd64..08deda3 100644
@@ -231,6 +231,18 @@ static void ath9k_hw_update_mibstats(struct ath_hw *ah,
 	stats->beacons += REG_READ(ah, AR_BEACON_CNT);
 }
 
+/*
+ * These masks are used by the hardware to know which
+ * type of phy errors to include on their error counts.
+ * We use one counter for OFDM phy timing errors and the
+ * other for CCK phy timing errors only.
+ */
+static void ath9k_hw_update_phy_err_masks(struct ath_hw *ah)
+{
+	REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
+	REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
+}
+
 static void ath9k_ani_restart(struct ath_hw *ah)
 {
 	struct ar5416AniState *aniState;
@@ -264,8 +276,7 @@ static void ath9k_ani_restart(struct ath_hw *ah)
 		  aniState->cckPhyErrBase);
 	REG_WRITE(ah, AR_PHY_ERR_1, aniState->ofdmPhyErrBase);
 	REG_WRITE(ah, AR_PHY_ERR_2, aniState->cckPhyErrBase);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
+	ath9k_hw_update_phy_err_masks(ah);
 
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
 
@@ -540,8 +551,7 @@ void ath9k_ani_reset(struct ath_hw *ah)
 	ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) &
 			     ~ATH9K_RX_FILTER_PHYERR);
 	ath9k_ani_restart(ah);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
+	ath9k_hw_update_phy_err_masks(ah);
 }
 
 void ath9k_hw_ani_monitor(struct ath_hw *ah,
@@ -644,8 +654,7 @@ void ath9k_enable_mib_counters(struct ath_hw *ah)
 	REG_WRITE(ah, AR_MIBC,
 		  ~(AR_MIBC_COW | AR_MIBC_FMC | AR_MIBC_CMC | AR_MIBC_MCS)
 		  & 0x0f);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
-	REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
+	ath9k_hw_update_phy_err_masks(ah);
 }
 
 /* Freeze the MIB counters, get the stats and then clear them */
Signature · 1 line
1.6.3.3
#10 lore raw

PATCH v2 10/20 ath9k_hw: add helpers for writing phy errors counts

In reply to Luis R. Rodriguez

The hardware phy error counter are updated through the ANI code, provide a few helpers which make the access to hardware easier to abstract.

Extend the documentation of the phy error counts and masks.

---
 drivers/net/wireless/ath/ath9k/ani.c |  104 +++++++++++++++++++++++++++++-----
 1 files changed, 89 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +89 -15
index 08deda3..52852fc 100644
@@ -243,6 +243,79 @@ static void ath9k_hw_update_phy_err_masks(struct ath_hw *ah)
 	REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
 }
 
+static void ath9k_hw_update_phy_err1_count(struct ath_hw *ah,
+					   u32 err_count,
+					   bool reset_mask)
+{
+	REG_WRITE(ah, AR_PHY_ERR_1, err_count);
+
+	if (reset_mask)
+		REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
+}
+
+static void ath9k_hw_update_phy_err2_count(struct ath_hw *ah,
+					   u32 err_count,
+					   bool reset_mask)
+{
+	REG_WRITE(ah, AR_PHY_ERR_2, err_count);
+
+	if (reset_mask)
+		REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
+}
+
+/**
+ * ath9k_hw_update_phy_err_count - update phy error counts
+ *
+ * @ah: atheros hardware structure
+ * @phy_err_count1: number of OFDM PHY timing errors to set
+ * @phy_err_count2: number of CCK PHY timing errors to set
+ * @reset_masks: whether or not the masks for each counter
+ *	type should be reset to default values
+ *
+ * The hardware keeps track of different types of PHY errors
+ * depending on specific programmed mask for OFDM and CCK. The
+ * registers are used as follows:
+ *
+ *   - 0x8124 Filtered OFDM Frames Count
+ *   - 0x8128 Filtered CCK Frames Count
+ *   - 0x812C Phy Error1 Count
+ *   - 0x8130 Phy Error1 Count Mask
+ *   - 0x8134 Phy Error2 Count
+ *   - 0x8138 Phy Error2 Count Mask
+ *
+ *
+ * The Filtered OFDM Frames Count count OFDM data frames which
+ * were filtered.
+ *
+ * The Filtered CCK Frames Count count CCK data frames which
+ * were filtered.
+ *
+ * The Phy Error1 and Phy Error2 Count will count any phy error
+ * which matches the respective mask (Phy Error1 and Phy Error2
+ * Count Mask).  The bits of 32-bit masks correspond to the first
+ * 32 encoded values of the error.  Setting multiple bits in the
+ * mask will provide an ORing function to provide flexibility in
+ * counting.  For examples if we set the mask bits to 0xFF0000FF:
+ * then all phy errors from 0-7 and 24-31 will be counted.
+ *
+ * The 4 counters will use the PCI MIB control signals.  The PCI
+ * MIB freeze register will hold all the values of these registers.
+ * PCI MIB clear will zero out all the values of these registers.
+ * PCI MIB force will force increment of all the registers each
+ * cycle.  These 4 counters will saturate at the highest value and
+ * are writable.  If the upper two bits of these counters are 'b11
+ * then the pcu_mib_threshold will be asserted and an interrupt
+ * will be generated.
+ */
+static void ath9k_hw_update_phy_err_count(struct ath_hw *ah,
+					  u32 phy_err_count1,
+					  u32 phy_err_count2,
+					  bool reset_masks)
+{
+	ath9k_hw_update_phy_err1_count(ah, phy_err_count1, reset_masks);
+	ath9k_hw_update_phy_err2_count(ah, phy_err_count2, reset_masks);
+}
+
 static void ath9k_ani_restart(struct ath_hw *ah)
 {
 	struct ar5416AniState *aniState;
@@ -274,9 +347,11 @@ static void ath9k_ani_restart(struct ath_hw *ah)
 		  "Writing ofdmbase=%u   cckbase=%u\n",
 		  aniState->ofdmPhyErrBase,
 		  aniState->cckPhyErrBase);
-	REG_WRITE(ah, AR_PHY_ERR_1, aniState->ofdmPhyErrBase);
-	REG_WRITE(ah, AR_PHY_ERR_2, aniState->cckPhyErrBase);
-	ath9k_hw_update_phy_err_masks(ah);
+
+	ath9k_hw_update_phy_err_count(ah,
+				      aniState->ofdmPhyErrBase,
+				      aniState->cckPhyErrBase,
+				      true);
 
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
 
@@ -590,10 +665,9 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
 				  "counter value to 0x%x\n",
 				  phyCnt1,
 				  aniState->ofdmPhyErrBase);
-			REG_WRITE(ah, AR_PHY_ERR_1,
-				  aniState->ofdmPhyErrBase);
-			REG_WRITE(ah, AR_PHY_ERR_MASK_1,
-				  AR_PHY_ERR_OFDM_TIMING);
+			ath9k_hw_update_phy_err1_count(ah,
+						       aniState->ofdmPhyErrBase,
+						       true);
 		}
 		if (phyCnt2 < aniState->cckPhyErrBase) {
 			ath_print(common, ATH_DBG_ANI,
@@ -601,10 +675,9 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
 				  "counter value to 0x%x\n",
 				  phyCnt2,
 				  aniState->cckPhyErrBase);
-			REG_WRITE(ah, AR_PHY_ERR_2,
-				  aniState->cckPhyErrBase);
-			REG_WRITE(ah, AR_PHY_ERR_MASK_2,
-				  AR_PHY_ERR_CCK_TIMING);
+			ath9k_hw_update_phy_err2_count(ah,
+						       aniState->cckPhyErrBase,
+						       true);
 		}
 		return;
 	}
@@ -818,8 +891,10 @@ void ath9k_hw_ani_init(struct ath_hw *ah)
 	ath_print(common, ATH_DBG_ANI, "Setting cckErrBase = 0x%08x\n",
 		  ah->ani[0].cckPhyErrBase);
 
-	REG_WRITE(ah, AR_PHY_ERR_1, ah->ani[0].ofdmPhyErrBase);
-	REG_WRITE(ah, AR_PHY_ERR_2, ah->ani[0].cckPhyErrBase);
+	ath9k_hw_update_phy_err_count(ah,
+				      ah->ani[0].ofdmPhyErrBase,
+				      ah->ani[0].cckPhyErrBase,
+				      false);
 	ath9k_enable_mib_counters(ah);
 
 	ah->aniperiod = ATH9K_ANI_PERIOD;
@@ -832,6 +907,5 @@ void ath9k_hw_ani_disable(struct ath_hw *ah)
 	ath_print(ath9k_hw_common(ah), ATH_DBG_ANI, "Disabling ANI\n");
 
 	ath9k_hw_disable_mib_counters(ah);
-	REG_WRITE(ah, AR_PHY_ERR_1, 0);
-	REG_WRITE(ah, AR_PHY_ERR_2, 0);
+	ath9k_hw_update_phy_err_count(ah, 0, 0, false);
 }
Signature · 1 line
1.6.3.3
#11 lore raw

PATCH v2 11/20 ath9k_hw: add a helper for phy error counter reads

In reply to Luis R. Rodriguez

This lets us now share more ANI routines accross different chipsets.

---
 drivers/net/wireless/ath/ath9k/ani.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +11 -5
index 52852fc..7e87cf4 100644
@@ -316,6 +316,14 @@ static void ath9k_hw_update_phy_err_count(struct ath_hw *ah,
 	ath9k_hw_update_phy_err2_count(ah, phy_err_count2, reset_masks);
 }
 
+static void ath9k_hw_get_phy_err_count(struct ath_hw *ah,
+				       u32 *phy_err_count1,
+				       u32 *phy_err_count2)
+{
+	*phy_err_count1 = REG_READ(ah, AR_PHY_ERR_1);
+	*phy_err_count2 = REG_READ(ah, AR_PHY_ERR_2);
+}
+
 static void ath9k_ani_restart(struct ath_hw *ah)
 {
 	struct ar5416AniState *aniState;
@@ -653,9 +661,7 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
 	aniState->listenTime += listenTime;
 
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
-
-	phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
-	phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
+	ath9k_hw_get_phy_err_count(ah, &phyCnt1, &phyCnt2);
 
 	if (phyCnt1 < aniState->ofdmPhyErrBase ||
 	    phyCnt2 < aniState->cckPhyErrBase) {
@@ -807,8 +813,8 @@ void ath9k_hw_procmibevent(struct ath_hw *ah)
 		return;
 
 	/* NB: these are not reset-on-read */
-	phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
-	phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
+	ath9k_hw_get_phy_err_count(ah, &phyCnt1, &phyCnt2);
+
 	if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) ||
 	    ((phyCnt2 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK)) {
 		struct ar5416AniState *aniState = ah->curani;
Signature · 1 line
1.6.3.3
#12 lore raw

PATCH v2 12/20 ath9k_hw: add documentation for the TPC register

In reply to Luis R. Rodriguez
---
 drivers/net/wireless/ath/ath9k/reg.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/reg.h +14 -0
index 198e41d..ce94e99 100644
@@ -1435,6 +1435,20 @@ enum {
 #define AR_SLEEP2_BEACON_TIMEOUT    0xFFE00000
 #define AR_SLEEP2_BEACON_TIMEOUT_S  21
 
+/*
+ * 0x80e8   Transmit Power Control
+ * (Int Addr: 0x3A, Access: R/W, Clock: system clk)
+ * TPC             21:0    'h3F    bit 5:0:   ACK_PWR
+ *                                'h3F    bit 13:8:  CTS_PWR
+ *                                'h3F    bit 21:16: CHIRP_PWR
+ * Transmit Power Control Description:
+ *
+ * The 6 bit transmit power control sent from the MAC to the baseband
+ * is typically controlled by using the transmit descriptor field.  But
+ * self generated response frames such as ACK, CTS, and chirp which
+ * do not have a transmit descriptor use the values in the transmit power
+ * control register instead.
+ */
 #define AR_TPC                 0x80e8
 #define AR_TPC_ACK             0x0000003f
 #define AR_TPC_ACK_S           0x00
Signature · 1 line
1.6.3.3
#13 lore raw

PATCH v2 13/20 ath9k_hw: remove unused and buggy ath9k_hw_GetMibCycleCountsPct()

In reply to Luis R. Rodriguez

ath9k_hw_GetMibCycleCountsPct() is unused and in fact it would be buggy if used anyway. The right implementation is done throguh ath9k_hw_ani_get_listen_time() which is already present as well.

---
 drivers/net/wireless/ath/ath9k/ani.c |   41 ----------------------------------
 drivers/net/wireless/ath/ath9k/ani.h |    2 -
 2 files changed, 0 insertions(+), 43 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +0 -41
index 7e87cf4..71bf201 100644
@@ -750,47 +750,6 @@ void ath9k_hw_disable_mib_counters(struct ath_hw *ah)
 	REG_WRITE(ah, AR_FILT_CCK, 0);
 }
 
-u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hw *ah,
-				  u32 *rxc_pcnt,
-				  u32 *rxf_pcnt,
-				  u32 *txf_pcnt)
-{
-	struct ath_common *common = ath9k_hw_common(ah);
-	static u32 cycles, rx_clear, rx_frame, tx_frame;
-	u32 good = 1;
-
-	u32 rc = REG_READ(ah, AR_RCCNT);
-	u32 rf = REG_READ(ah, AR_RFCNT);
-	u32 tf = REG_READ(ah, AR_TFCNT);
-	u32 cc = REG_READ(ah, AR_CCCNT);
-
-	if (cycles == 0 || cycles > cc) {
-		ath_print(common, ATH_DBG_ANI,
-			  "cycle counter wrap. ExtBusy = 0\n");
-		good = 0;
-	} else {
-		u32 cc_d = cc - cycles;
-		u32 rc_d = rc - rx_clear;
-		u32 rf_d = rf - rx_frame;
-		u32 tf_d = tf - tx_frame;
-
-		if (cc_d != 0) {
-			*rxc_pcnt = rc_d * 100 / cc_d;
-			*rxf_pcnt = rf_d * 100 / cc_d;
-			*txf_pcnt = tf_d * 100 / cc_d;
-		} else {
-			good = 0;
-		}
-	}
-
-	cycles = cc;
-	rx_frame = rf;
-	rx_clear = rc;
-	tx_frame = tf;
-
-	return good;
-}
-
 /*
  * Process a MIB interrupt.  We may potentially be invoked because
  * any of the MIB counters overflow/trigger so don't assume we're
drivers/net/wireless/ath/ath9k/ani.h +0 -2
index 4e1ab94..01c07e2 100644
@@ -113,8 +113,6 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
 			  struct ath9k_channel *chan);
 void ath9k_enable_mib_counters(struct ath_hw *ah);
 void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
-u32 ath9k_hw_GetMibCycleCountsPct(struct ath_hw *ah, u32 *rxc_pcnt,
-				  u32 *rxf_pcnt, u32 *txf_pcnt);
 void ath9k_hw_procmibevent(struct ath_hw *ah);
 void ath9k_hw_ani_setup(struct ath_hw *ah);
 void ath9k_hw_ani_init(struct ath_hw *ah);
Signature · 1 line
1.6.3.3
#14 lore raw

PATCH v2 14/20 ath9k_hw: add a helper for retrieving the MIB cycle counters

In reply to Luis R. Rodriguez

This helper can be abstracted on each hardware family. While at it document the registers involved, used to profile the MAC baseband for Adaptive Noise Immunity (ANI).

---
 drivers/net/wireless/ath/ath9k/ani.c |   67 ++++++++++++++++++++++++++++++++--
 1 files changed, 64 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +64 -3
index 71bf201..02db5c5 100644
@@ -14,6 +14,13 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+/*
+ * Adaptive Noise Immunity
+ *
+ * Used to monitor your environment and adjust the MAC baseband accordingly to
+ * help with RX. ANI is extremely useful in environments with noise.
+ */
+
 #include "hw.h"
 
 static int ath9k_hw_get_ani_channel_idx(struct ath_hw *ah,
@@ -324,6 +331,18 @@ static void ath9k_hw_get_phy_err_count(struct ath_hw *ah,
 	*phy_err_count2 = REG_READ(ah, AR_PHY_ERR_2);
 }
 
+static void ath9k_hw_get_mib_cycle_counters(struct ath_hw *ah,
+					    u32 *rx_clear_count,
+					    u32 *rx_frame_count,
+					    u32 *tx_frame_count,
+					    u32 *cycle_count)
+{
+	*rx_clear_count = REG_READ(ah, AR_RCCNT);
+	*rx_frame_count = REG_READ(ah, AR_RFCNT);
+	*tx_frame_count = REG_READ(ah, AR_TFCNT);
+	*cycle_count = REG_READ(ah, AR_CCCNT);
+}
+
 static void ath9k_ani_restart(struct ath_hw *ah)
 {
 	struct ar5416AniState *aniState;
@@ -530,15 +549,57 @@ static void ath9k_hw_ani_lower_immunity(struct ath_hw *ah)
 	}
 }
 
+/**
+ * ath9k_hw_ani_get_listen_time - profile the MAC baseband for ANI
+ *
+ * @ah: atheros hardware structure
+ *
+ * This uses the Baseband Interface MIB Counters:
+ *
+ * 0x80ec - Transmit Frame Counter
+ * 0x80f0 - Receive Frame Counter
+ * 0x80f4 - Receive Clear Counter
+ * 0x80f8 - Cycle Counter
+ *
+ * for profiling of the MAC baseband and adjusting it accordingly.
+ *
+ * The baseband interface MIB counters are used to provide software a
+ * means of profiling the behavior at the MAC baseband interface for
+ * performance analysis.  These counters are based on the system clock
+ * domain which turns off during sleep.  The transmit frame counter
+ * counts the number of cycles the tx_frame signal is active.  The
+ * receive frame counter counts the number of cycles the rx_frame signal
+ * is active.  The receive clear counter counts the number of cycles the
+ * rx_clear signal is "NOT" active.  The cycle counter counts the number of
+ * clock cycles.  There are registers which controls the behaviour of
+ * these counters.  The PCI MIB freeze register will hold all the
+ * values of these registers.  PCI MIB clear will zero out all the
+ * values of these registers.  PCI MIB force will force increment of
+ * all the registers each cycle.  These register do not roll over or
+ * saturate but rather use a time weighted average to maintain the
+ * ratios of these MIB counter registers.  When the cycle counter
+ * register reaches 32'hFFFFFFFF, all the registers shift their
+ * values right by 1.  So the new cycle counter register will be
+ * 32'h7FFFFFFF.  Writes are allowed to verify correct averaging
+ * behaviour.
+ *
+ * The saturate cycle cnt bit if set in the DIAG_SW (0x8048) will
+ * cause the cycle counter register (0x80F8) to saturate instead
+ * of shifting to the right by 1 every time the count reaches
+ * 0xFFFFFFFF.
+ */
 static int32_t ath9k_hw_ani_get_listen_time(struct ath_hw *ah)
 {
 	struct ar5416AniState *aniState;
 	u32 txFrameCount, rxFrameCount, cycleCount;
+	u32 rx_clear_count; /* not actually used */
 	int32_t listenTime;
 
-	txFrameCount = REG_READ(ah, AR_TFCNT);
-	rxFrameCount = REG_READ(ah, AR_RFCNT);
-	cycleCount = REG_READ(ah, AR_CCCNT);
+	ath9k_hw_get_mib_cycle_counters(ah,
+					&rx_clear_count,
+					&rxFrameCount,
+					&txFrameCount,
+					&cycleCount);
 
 	aniState = ah->curani;
 	if (aniState->cycleCount == 0 || aniState->cycleCount > cycleCount) {
Signature · 1 line
1.6.3.3
#15 lore raw

PATCH v2 15/20 ath9k_hw: provide a helper for clearing the MIB counters

In reply to Luis R. Rodriguez

The MIB counters are cleared in a few places. Put that code into a helper so that each chipset supported can implement its own call later and we can share more code. While at it adds documentation for the MIB cycle counters and the sleep cycle counters.

---
 drivers/net/wireless/ath/ath9k/ani.c |   64 +++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +56 -8
index 02db5c5..a4e492d 100644
@@ -781,6 +781,58 @@ void ath9k_hw_ani_monitor(struct ath_hw *ah,
 }
 EXPORT_SYMBOL(ath9k_hw_ani_monitor);
 
+
+/**
+ * ath9k_hw_clear_mib_counters - clears all MIB counters
+ *
+ * @ah: atheros hardware structure
+ *
+ * Used to clear all MIB counters for the OFDM and CCK filtered
+ * frames and also the clock cycle counters and clock cycles we
+ * have spent sleeping. Refer to ath9k_hw_update_phy_err_count()
+ * for more documentation on the filtered frames, below we cover
+ * the clock cycle counters and sleep cycle counters.
+ *
+ * 0x8250           32KHz Sleep MIB Count
+ * (Int Addr: 0x94, Access, R/W, cold_reset, Clock: clk)
+ *       SLPMIB1                 31:0    'h0     bit 31:0   SLPMIB_SLEEP_CNT
+ *
+ * 0x8254           32KHz Cycle MIB Count
+ *        (Int Addr: 0x95, Access, R/W, cold_reset, Clock: clk)
+ *        SLPMIB2                 31:0    'h0     bit 31:0   SLPMIB_CYCLE_CNT
+ *
+ * 0x8258           32KHz Mode MIB Control Status
+ *        (Int Addr: 0x96, Access, R/W, cold_reset, Clock: clk)
+ *        SLPMIB3                  1:0    'h0     bit 0      SLPMIB_CLR_CNT
+ *                                        'h0    bit 1      SLPMIB_PEND
+ *
+ * The SLPMIB_SLEEP_CNT counts the number of 32KHz clock cycles that
+ * the MAC has been asleep.  The SLPMIB_CYCLE_CNT is the counts the
+ * absolute number of 32KHz clock cycles.  When the SLPMIB_CYCLE_CNT
+ * bit 31 is 1, the sleep MIB interrupt will be asserted.  The
+ * SLPMIB_SLEEP_CNT and SLPMIB_CYCLE_CNT are saturating counters when
+ * the value of SLPMIB_CYCLE_CNT reaches 0xFFFF_FFFF both counters
+ * will stop incrementing.  The SLPMIB_CLR_CNT will clear both the
+ * SLPMIB_SLEEP_CNT and SLPMIB_CYCLE_CNT.  During the time that the
+ * clearing of these register are pending the SLPMIB_CLR_PEND will
+ * be asserted.  SLPMIB_SLEEP_CNT, SLPMIB_CYCLE_CNT, and
+ * SLPMIB_CLR_CNT are writable for diagnostic purposes.  Before every
+ * read/write, the SLPMIB_PEND bit should be polled to verify any
+ * pending write has cleared.
+ */
+static void ath9k_hw_clear_mib_counters(struct ath_hw *ah,
+					bool check_clock_cycles)
+{
+	REG_WRITE(ah, AR_FILT_OFDM, 0);
+	REG_WRITE(ah, AR_FILT_CCK, 0);
+
+	if (!check_clock_cycles)
+		return;
+
+	if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
+		REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
+}
+
 void ath9k_enable_mib_counters(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
@@ -788,9 +840,8 @@ void ath9k_enable_mib_counters(struct ath_hw *ah)
 	ath_print(common, ATH_DBG_ANI, "Enable MIB counters\n");
 
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
+	ath9k_hw_clear_mib_counters(ah, false);
 
-	REG_WRITE(ah, AR_FILT_OFDM, 0);
-	REG_WRITE(ah, AR_FILT_CCK, 0);
 	REG_WRITE(ah, AR_MIBC,
 		  ~(AR_MIBC_COW | AR_MIBC_FMC | AR_MIBC_CMC | AR_MIBC_MCS)
 		  & 0x0f);
@@ -807,8 +858,8 @@ void ath9k_hw_disable_mib_counters(struct ath_hw *ah)
 	REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC);
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
 	REG_WRITE(ah, AR_MIBC, AR_MIBC_CMC);
-	REG_WRITE(ah, AR_FILT_OFDM, 0);
-	REG_WRITE(ah, AR_FILT_CCK, 0);
+
+	ath9k_hw_clear_mib_counters(ah, false);
 }
 
 /*
@@ -821,10 +872,7 @@ void ath9k_hw_procmibevent(struct ath_hw *ah)
 	u32 phyCnt1, phyCnt2;
 
 	/* Reset these counters regardless */
-	REG_WRITE(ah, AR_FILT_OFDM, 0);
-	REG_WRITE(ah, AR_FILT_CCK, 0);
-	if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
-		REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
+	ath9k_hw_clear_mib_counters(ah, true);
 
 	/* Clear the mib counters and save them in the stats */
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
Signature · 1 line
1.6.3.3
#16 lore raw

PATCH v2 16/20 ath9k_hw: simplify reseting of the MIB control register

In reply to Luis R. Rodriguez

This complex thing can more easily be expressed as 0.

---
 drivers/net/wireless/ath/ath9k/ani.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +1 -3
index a4e492d..efe0bb9 100644
@@ -842,9 +842,7 @@ void ath9k_enable_mib_counters(struct ath_hw *ah)
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
 	ath9k_hw_clear_mib_counters(ah, false);
 
-	REG_WRITE(ah, AR_MIBC,
-		  ~(AR_MIBC_COW | AR_MIBC_FMC | AR_MIBC_CMC | AR_MIBC_MCS)
-		  & 0x0f);
+	REG_WRITE(ah, AR_MIBC, 0);
 	ath9k_hw_update_phy_err_masks(ah);
 }
 
Signature · 1 line
1.6.3.3
#17 lore raw

PATCH v2 17/20 ath9k_hw: provide a helper for managing the MIB control register

In reply to Luis R. Rodriguez

This will help with the hardware family abstraction.

---
 drivers/net/wireless/ath/ath9k/ani.c |   49 +++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/ani.c +45 -4
index efe0bb9..024f8f6 100644
@@ -833,6 +833,48 @@ static void ath9k_hw_clear_mib_counters(struct ath_hw *ah,
 		REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
 }
 
+/**
+ * ath9k_hw_mibc_cmd - commands for the MIB control register (MIBC)
+ *
+ * @ATH9K_HW_MIBC_INIT: initializes the register
+ * @ATH9K_HW_MIBC_WARN_TEST: Warning test indicator
+ * @ATH9K_HW_MIBC_FREEZE: freeze all counters, useful prior to collecting
+ *	the MIB counters.
+ * @ATH9K_HW_MIBC_CLEAR: clear all counters, can be used after collecting
+ *	the MIB counters.
+ * @ATH9K_HW_MIBC_STROBE: MIB counter strobe, can increment every
+ *	counter by 1.
+ */
+enum ath9k_hw_mibc_cmd {
+	ATH9K_HW_MIBC_INIT = 0,
+	ATH9K_HW_MIBC_WARN_TEST,
+	ATH9K_HW_MIBC_FREEZE,
+	ATH9K_HW_MIBC_CLEAR,
+	ATH9K_HW_MIBC_STROBE,
+};
+
+static void ath9k_hw_send_mibc_cmd(struct ath_hw *ah,
+				   enum ath9k_hw_mibc_cmd cmd)
+{
+	switch (cmd) {
+	case ATH9K_HW_MIBC_INIT:
+		REG_WRITE(ah, AR_MIBC, 0);
+		break;
+	case ATH9K_HW_MIBC_WARN_TEST: /* unused */
+		REG_WRITE(ah, AR_MIBC, AR_MIBC_COW);
+		break;
+	case ATH9K_HW_MIBC_FREEZE:
+		REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC);
+		break;
+	case ATH9K_HW_MIBC_CLEAR:
+		REG_WRITE(ah, AR_MIBC, AR_MIBC_CMC);
+		break;
+	case ATH9K_HW_MIBC_STROBE: /* unused */
+		REG_WRITE(ah, AR_MIBC, AR_MIBC_MCS);
+		break;
+	}
+}
+
 void ath9k_enable_mib_counters(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
@@ -841,8 +883,7 @@ void ath9k_enable_mib_counters(struct ath_hw *ah)
 
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
 	ath9k_hw_clear_mib_counters(ah, false);
-
-	REG_WRITE(ah, AR_MIBC, 0);
+	ath9k_hw_send_mibc_cmd(ah, ATH9K_HW_MIBC_INIT);
 	ath9k_hw_update_phy_err_masks(ah);
 }
 
@@ -853,9 +894,9 @@ void ath9k_hw_disable_mib_counters(struct ath_hw *ah)
 
 	ath_print(common, ATH_DBG_ANI, "Disable MIB counters\n");
 
-	REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC);
+	ath9k_hw_send_mibc_cmd(ah, ATH9K_HW_MIBC_FREEZE);
 	ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
-	REG_WRITE(ah, AR_MIBC, AR_MIBC_CMC);
+	ath9k_hw_send_mibc_cmd(ah, ATH9K_HW_MIBC_CLEAR);
 
 	ath9k_hw_clear_mib_counters(ah, false);
 }
Signature · 1 line
1.6.3.3
#18 lore raw

PATCH v2 18/20 ath9k_hw: move common defines for ANI into ath/reg.h

In reply to Luis R. Rodriguez

This will allow us to share a common ath9k_ani_restart() and ath9k_hw_procmibevent() once we split the hardware specific stuff.

---
 drivers/net/wireless/ath/ath9k/reg.h |    3 ---
 drivers/net/wireless/ath/reg.h       |    5 +++++
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/reg.h +0 -3
index ce94e99..fa37e30 100644
@@ -1530,9 +1530,6 @@ enum {
 #define AR_PHY_ERR_2_COUNT     0x00FFFFFF
 #define AR_PHY_ERR_MASK_2      0x8138
 
-#define AR_PHY_COUNTMAX        (3 << 22)
-#define AR_MIBCNT_INTRMASK     (3 << 22)
-
 #define AR_TSFOOR_THRESHOLD       0x813c
 #define AR_TSFOOR_THRESHOLD_VAL   0x0000FFFF
 
drivers/net/wireless/ath/reg.h +5 -0
index dfe1fbe..dc8de1b 100644
@@ -24,4 +24,9 @@
 #define AR_BSSMSKL		0x80e0
 #define AR_BSSMSKU		0x80e4
 
+/* Max counted before intr */
+#define AR_PHY_COUNTMAX		(3 << 22)
+/* Mask top 2 bits of counters */
+#define AR_MIBCNT_INTRMASK	(3 << 22)
+
 #endif /* ATH_REGISTERS_H */
Signature · 1 line
1.6.3.3
#19 lore raw

PATCH v2 19/20 ath9k_hw: move ar9002 ANI code to its own file

In reply to Luis R. Rodriguez
---
 drivers/net/wireless/ath/ath9k/Makefile     |    1 +
 drivers/net/wireless/ath/ath9k/ani.c        |  341 +-------------------------
 drivers/net/wireless/ath/ath9k/ani.h        |   20 ++
 drivers/net/wireless/ath/ath9k/ar9002_ani.c |  356 +++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/ar9002_hw.c  |    2 +
 drivers/net/wireless/ath/ath9k/hw-ops.h     |   69 +++++
 drivers/net/wireless/ath/ath9k/hw.h         |   35 +++
 7 files changed, 484 insertions(+), 340 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/ar9002_ani.c
drivers/net/wireless/ath/ath9k/Makefile +1 -0
index affbf84..681fc4f 100644
@@ -18,6 +18,7 @@ ath9k_hw-y:=	hw.o \
 		ar9002_calib.o \
 		ar9002_calib_settings.o \
 		ar9002_btcoex.o \
+		ar9002_ani.o \
 		eeprom.o \
 		eeprom_def.o \
 		eeprom_4k.o \
drivers/net/wireless/ath/ath9k/ani.c +1 -340

365 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ani.h +20 -0
index 01c07e2..f9879e4 100644
@@ -40,6 +40,26 @@
 #define HAL_SPUR_IMMUNE_MAX               7
 #define HAL_FIRST_STEP_MAX                2
 
+/**
+ * ath9k_hw_mibc_cmd - commands for the MIB control register (MIBC)
+ *
+ * @ATH9K_HW_MIBC_INIT: initializes the register
+ * @ATH9K_HW_MIBC_WARN_TEST: Warning test indicator
+ * @ATH9K_HW_MIBC_FREEZE: freeze all counters, useful prior to collecting
+ *	the MIB counters.
+ * @ATH9K_HW_MIBC_CLEAR: clear all counters, can be used after collecting
+ *	the MIB counters.
+ * @ATH9K_HW_MIBC_STROBE: MIB counter strobe, can increment every
+ *	counter by 1.
+ */
+enum ath9k_hw_mibc_cmd {
+	ATH9K_HW_MIBC_INIT = 0,
+	ATH9K_HW_MIBC_WARN_TEST,
+	ATH9K_HW_MIBC_FREEZE,
+	ATH9K_HW_MIBC_CLEAR,
+	ATH9K_HW_MIBC_STROBE,
+};
+
 enum ath9k_ani_cmd {
 	ATH9K_ANI_PRESENT = 0x1,
 	ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
drivers/net/wireless/ath/ath9k/ar9002_ani.c new file +356 -0

356 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ar9002_hw.c +2 -0
index 8e5a07d..2356611 100644
@@ -20,6 +20,7 @@
 #include "ar9002_initvals.h"
 
 extern void ar9002_hw_attach_btcoex_ops(struct ath_hw *ah);
+extern void ar9002_hw_attach_ani_ops(struct ath_hw *ah);
 
 static void ar9002_hw_disablepcie(struct ath_hw *ah)
 {
@@ -815,5 +816,6 @@ void ar9002_hw_attach_ops(struct ath_hw *ah)
 
 	ar9002_hw_attach_calib_ops(ah);
 	ar9002_hw_attach_btcoex_ops(ah);
+	ar9002_hw_attach_ani_ops(ah);
 }
 EXPORT_SYMBOL(ar9002_hw_attach_ops);
drivers/net/wireless/ath/ath9k/hw-ops.h +69 -0

73 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +35 -0
index ed137a8..259761d 100644
@@ -469,6 +469,16 @@ struct ath_gen_timer_table {
  * @btcoex_supported: whether or not bluetooth coexistence is supported
  * @btcoex_enable_2wire:
  * @btcoex_enable_3wire:
+ *
+ * @ani_control:
+ * @update_mibstats:
+ * @update_phy_err_masks:
+ * @update_phy_err1_count:
+ * @update_phy_err2_count:
+ * @get_phy_err_count:
+ * @get_mib_cycle_counters:
+ * @clear_mib_counters:
+ * @send_mibc_cmd:
  */
 struct ath_hw_private_ops {
 	/* General hardware ops */
@@ -499,6 +509,31 @@ struct ath_hw_private_ops {
 	bool (*btcoex_supported)(struct ath_hw *ah);
 	void (*btcoex_enable_2wire)(struct ath_hw *ah);
 	void (*btcoex_enable_3wire)(struct ath_hw *ah);
+
+	/* ANI */
+	bool (*ani_control)(struct ath_hw *ah,
+			    enum ath9k_ani_cmd cmd, int param);
+	void (*update_mibstats)(struct ath_hw *ah,
+				struct ath9k_mib_stats *stats);
+	void (*update_phy_err_masks)(struct ath_hw *ah);
+	void (*update_phy_err1_count)(struct ath_hw *ah,
+				      u32 err_count,
+				      bool reset_mask);
+	void (*update_phy_err2_count)(struct ath_hw *ah,
+				      u32 err_count,
+				      bool reset_mask);
+	void (*get_phy_err_count)(struct ath_hw *ah,
+				  u32 *phy_err_count1,
+				  u32 *phy_err_count2);
+	void (*get_mib_cycle_counters)(struct ath_hw *ah,
+				       u32 *rx_clear_count,
+				       u32 *rx_frame_count,
+				       u32 *tx_frame_count,
+				       u32 *cycle_count);
+	void (*clear_mib_counters)(struct ath_hw *ah,
+				   bool check_clock_cycles);
+	void (*send_mibc_cmd)(struct ath_hw *ah,
+			      enum ath9k_hw_mibc_cmd cmd);
 };
 
 /**
Signature · 1 line
1.6.3.3
#20 lore raw

PATCH v2 20/20 ath9k_hw: remove wrapper ath9k_hw_write_regs()

In reply to Luis R. Rodriguez

This is used only once by ath9k_hw_process_ini() to write an array of phy registers through REG_WRITE_ARRAY(), but we already call REG_WRITE_ARRAY() multiple times on the same caller so just remove this pointless wrapper. We'll eventually just move the ath9k_hw_process_ini() caller as an callback to abstract away between different hardware families.

Although this change is subtle I should note that this does change the delay pattern on writing the next series of registers. REG_WRITE_ARRAY() uses a counter for each register write and does a udelay(1) every 64 writes. By removing this call it means that the counter is processed for all the iniBB_RfGain registers and is incremented on ath9k_hw_process_ini(), before this the after the call ath9k_hw_write_regs() was made the register counter was kept at the same index number prior to the call.

---
 drivers/net/wireless/ath/ath9k/hw.c  |    2 +-
 drivers/net/wireless/ath/ath9k/phy.c |   15 ---------------
 drivers/net/wireless/ath/ath9k/phy.h |    3 ---
 3 files changed, 1 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +1 -1
index 9093235..2013b7e 100644
@@ -1072,7 +1072,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 					modesIndex, regWrites);
 	}
 
-	ath9k_hw_write_regs(ah, freqIndex, regWrites);
+	REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites);
 
 	if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) {
 		REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex,
drivers/net/wireless/ath/ath9k/phy.c +0 -15
index c3b5939..02d40df 100644
@@ -42,21 +42,6 @@
 #include "hw.h"
 
 /**
- * ath9k_hw_write_regs - ??
- *
- * @ah: atheros hardware structure
- * @freqIndex:
- * @regWrites:
- *
- * Used for both the chipsets with an external AR2133/AR5133 radios and
- * single-chip devices.
- */
-void ath9k_hw_write_regs(struct ath_hw *ah, u32 freqIndex, int regWrites)
-{
-	REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites);
-}
-
-/**
  * ath9k_hw_ar9280_set_channel - set channel on single-chip device
  * @ah: atheros hardware structure
  * @chan:
drivers/net/wireless/ath/ath9k/phy.h +0 -3
index 0999a49..dc2b915 100644
@@ -17,9 +17,6 @@
 #ifndef PHY_H
 #define PHY_H
 
-/* Common between single chip and non single-chip solutions */
-void ath9k_hw_write_regs(struct ath_hw *ah, u32 freqIndex, int regWrites);
-
 /* Single chip radio settings */
 int ath9k_hw_ar9280_set_channel(struct ath_hw *ah, struct ath9k_channel *chan);
 void ath9k_hw_9280_spur_mitigate(struct ath_hw *ah, struct ath9k_channel *chan);
Signature · 1 line
1.6.3.3
#22 lore raw

v2 cover ath9k_hw: ar93xx initial abstraction work

Quoted 9 lines · Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

Here's what I have so far, this is rebased on top of Senthil's patches for ath9k_htc posted today. Just tested it on my AR9280, it doesn't break anything.

BTW the new ath9k_htc series + this series can be downloaded in one file from:

http://bombadil.infradead.org/~mcgrof/tmp/all-ar93xx-03-17-v3.patch

bleh, I did not use -M here... let me resend with that for the renames.

Luis

#23 lore raw

v2 cover ath9k_hw: ar93xx initial abstraction work

Quoted 8 lines · Luis R. Rodriguez
Quoted 6 lines · Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

Here's what I have so far, this is rebased on top of Senthil's patches for ath9k_htc posted today. Just tested it on my AR9280, it doesn't break anything.

Quoted 5 lines
Quoted 3 lines

BTW the new ath9k_htc series + this series can be downloaded in one file from:

http://bombadil.infradead.org/~mcgrof/tmp/all-ar93xx-03-17-v3.patch

bleh, I did not use -M here... let me resend with that for the renames.

On second thought John -- please hold off on merging these new ar93xx abstraction patches, we are trying to mathematically prove if ar9002 register definitions are the same as the ar9003 ones and if so well this is all pointless :D

Luis

#24 lore raw

v2 cover ath9k_hw: ar93xx initial abstraction work

Quoted 12 lines · Luis R. Rodriguez
Quoted 10 lines · Luis R. Rodriguez
Quoted 8 lines · Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

Here's what I have so far, this is rebased on top of Senthil's patches for ath9k_htc posted today. Just tested it on my AR9280, it doesn't break anything.

BTW the new ath9k_htc series + this series can be downloaded in one file from:

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

http://bombadil.infradead.org/~mcgrof/tmp/all-ar93xx-03-17-v3.patch

bleh, I did not use -M here... let me resend with that for the renames.

On second thought John -- please hold off on merging these new ar93xx abstraction patches, we are trying to mathematically prove if ar9002 register definitions are the same as the ar9003 ones and if so well this is all pointless :D

Did this get resolved?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
linville at tuxdriver.com			might be all we have.  Be ready.
#25 lore raw

v2 cover ath9k_hw: ar93xx initial abstraction work

Quoted 15 lines · John W. Linville
Quoted 14 lines · Luis R. Rodriguez
Quoted 12 lines · Luis R. Rodriguez
Quoted 9 lines · Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

Here's what I have so far, this is rebased on top of Senthil's patches for ath9k_htc posted today. Just tested it on my AR9280, it doesn't break anything.

BTW the new ath9k_htc series + this series can be downloaded in one file from:

http://bombadil.infradead.org/~mcgrof/tmp/all-ar93xx-03-17-v3.patch

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

bleh, I did not use -M here... let me resend with that for the renames.

On second thought John -- please hold off on merging these new ar93xx abstraction patches, we are trying to mathematically prove if ar9002 register definitions are the same as the ar9003 ones and if so well this is all pointless :D

Did this get resolved?

Yeah but we're just holding off on them for now, we'll send patch bombs next week I think. But please do take the ath9k_htc stuff.

Luis