aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch
diff options
context:
space:
mode:
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>2016-11-26 01:01:13 +0100
committerMathias Kresin <dev@kresin.me>2016-11-29 21:40:16 +0100
commit3f889418a504b9c5d5781c2248bc3b3dc515ff03 (patch)
tree29af20d775cb4717ac325764fd70def3d3cfd2ce /package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch
parent1847248fc1560d10cb49c88b343598c9cb673f38 (diff)
downloadupstream-3f889418a504b9c5d5781c2248bc3b3dc515ff03.tar.gz
upstream-3f889418a504b9c5d5781c2248bc3b3dc515ff03.tar.bz2
upstream-3f889418a504b9c5d5781c2248bc3b3dc515ff03.zip
kernel: mac80211: add pending ath9k EEPROM swapping patches
There are two types of swapping the EEPROM data in the ath9k driver. Before this series one type of swapping could not be used without the other. The first type of swapping looks at the "magic bytes" at the start of the EEPROM data and performs swab16 on the EEPROM contents if needed. The second type of swapping is EEPROM format specific and swaps specific fields within the EEPROM itself (swab16, swab32 - depends on the EEPROM format). With this series the second part now looks at the EEPMISC register inside the EEPROM, which uses a bit to indicate if the EEPROM data is Big Endian (this is also done by the FreeBSD kernel). This has a nice advantage: currently there are some out-of-tree hacks (in OpenWrt and LEDE) where the EEPROM has a Big Endian header on a Big Endian system (= no swab16 is performed) but the EEPROM itself indicates that it's data is Little Endian. Until now the out-of-tree code simply did a swab16 before passing the data to ath9k, so ath9k first did the swab16 - this also enabled the format specific swapping. These out-of-tree hacks are still working with the new logic, but it is recommended to remove them. This implementation is based on a discussion with Arnd Bergmann who raised concerns about the robustness and portability of the swapping logic in the original OF support patch review, see [0]. After a second round of patches (= v1 of this series) neither Arnd Bergmann nor I were really happy with the complexity of the EEPROM swapping logic. Based on a discussion (see [1] and [2]) we decided that ath9k should use a defined format (specifying the endianness of the data - I went with __le16 and __le32) when accessing the EEPROM fields. A benefit of this is that we enable the EEPMISC based swapping logic by default, just like the FreeBSD driver, see [3]. On the devices which I have tested (see below) ath9k now works without having to specify the "endian_check" field in ath9k_platform_data (or a similar logic which could provide this via devicetree) as ath9k now detects the endianness automatically. Only EEPROMs which are mangled by some out-of-tree code still need the endian_check flag (or one can simply remove that mangling from the out-of-tree code). [0] http://www.spinics.net/lists/linux-wireless/msg152634.html [1] https://marc.info/?l=linux-wireless&m=147250597503174&w=2 [2] https://marc.info/?l=linux-wireless&m=147254388611344&w=2 [3] https://github.com/freebsd/freebsd/blob/50719b56d9ce8d7d4beb53b16e9edb2e9a4a7a18/sys/dev/ath/ath_hal/ah_eeprom_9287.c#L351 Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Diffstat (limited to 'package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch')
-rw-r--r--package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch b/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch
new file mode 100644
index 0000000000..a4a3595531
--- /dev/null
+++ b/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch
@@ -0,0 +1,78 @@
+From e88ab4a2649d0fbf675193fb2c176f65375bdd2d Mon Sep 17 00:00:00 2001
+From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Date: Mon, 3 Oct 2016 00:29:08 +0200
+Subject: [v2 PATCH 2/7] ath9k: indicate that the AR9003 EEPROM template values
+ are little endian
+
+The eepMisc field was not set explicitly. The default value of 0 means
+that the values in the EEPROM (template) should be interpreted as little
+endian. However, this is not clear until comparing the AR9003 code with
+the other EEPROM formats.
+To make the code easier to understand we explicitly state that the values
+are little endian - there are no functional changes with this patch.
+
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+---
+ drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 10 +++++-----
+ drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | 3 +++
+ 2 files changed, 8 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+@@ -53,7 +53,7 @@ static const struct ar9300_eeprom ar9300
+ .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
+ .opCapFlags = {
+ .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
+- .eepMisc = 0,
++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
+ },
+ .rfSilent = 0,
+ .blueToothOptions = 0,
+@@ -631,7 +631,7 @@ static const struct ar9300_eeprom ar9300
+ .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
+ .opCapFlags = {
+ .opFlags = AR5416_OPFLAGS_11A,
+- .eepMisc = 0,
++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
+ },
+ .rfSilent = 0,
+ .blueToothOptions = 0,
+@@ -1210,7 +1210,7 @@ static const struct ar9300_eeprom ar9300
+ .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
+ .opCapFlags = {
+ .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
+- .eepMisc = 0,
++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
+ },
+ .rfSilent = 0,
+ .blueToothOptions = 0,
+@@ -1789,7 +1789,7 @@ static const struct ar9300_eeprom ar9300
+ .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
+ .opCapFlags = {
+ .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
+- .eepMisc = 0,
++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
+ },
+ .rfSilent = 0,
+ .blueToothOptions = 0,
+@@ -2367,7 +2367,7 @@ static const struct ar9300_eeprom ar9300
+ .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
+ .opCapFlags = {
+ .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
+- .eepMisc = 0,
++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN,
+ },
+ .rfSilent = 0,
+ .blueToothOptions = 0,
+--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+@@ -69,6 +69,9 @@
+ #define AR9300_BASE_ADDR 0x3ff
+ #define AR9300_BASE_ADDR_512 0x1ff
+
++/* AR5416_EEPMISC_BIG_ENDIAN not set indicates little endian */
++#define AR9300_EEPMISC_LITTLE_ENDIAN 0
++
+ #define AR9300_OTP_BASE \
+ ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x30000 : 0x14000)
+ #define AR9300_OTP_STATUS \