ath: process regulatory notifiers with CONFIG_ATH_USER_REGD set
[oweals/openwrt.git] / package / kernel / mac80211 / patches / 333-ath9k-add-support-for-endian-swap-of-eeprom-from-pla.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sat, 18 Oct 2014 18:24:15 +0200
3 Subject: [PATCH] ath9k: add support for endian swap of eeprom from
4  platform data
5
6 On some devices (especially little-endian ones), the flash EEPROM data
7 has a different endian, which needs to be detected.
8 Add a flag to the platform data to allow overriding that behavior
9
10 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 ---
12
13 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
14 +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
15 @@ -262,7 +262,7 @@ static int ath9k_hw_def_check_eeprom(str
16  {
17         struct ar5416_eeprom_def *eep = &ah->eeprom.def;
18         struct ath_common *common = ath9k_hw_common(ah);
19 -       u16 *eepdata, temp, magic, magic2;
20 +       u16 *eepdata, temp, magic;
21         u32 sum = 0, el;
22         bool need_swap = false;
23         int i, addr, size;
24 @@ -272,27 +272,16 @@ static int ath9k_hw_def_check_eeprom(str
25                 return false;
26         }
27  
28 -       if (!ath9k_hw_use_flash(ah)) {
29 -               ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
30 -
31 -               if (magic != AR5416_EEPROM_MAGIC) {
32 -                       magic2 = swab16(magic);
33 -
34 -                       if (magic2 == AR5416_EEPROM_MAGIC) {
35 -                               size = sizeof(struct ar5416_eeprom_def);
36 -                               need_swap = true;
37 -                               eepdata = (u16 *) (&ah->eeprom);
38 -
39 -                               for (addr = 0; addr < size / sizeof(u16); addr++) {
40 -                                       temp = swab16(*eepdata);
41 -                                       *eepdata = temp;
42 -                                       eepdata++;
43 -                               }
44 -                       } else {
45 -                               ath_err(common,
46 -                                       "Invalid EEPROM Magic. Endianness mismatch.\n");
47 -                               return -EINVAL;
48 -                       }
49 +       if (swab16(magic) == AR5416_EEPROM_MAGIC &&
50 +           !(ah->ah_flags & AH_NO_EEP_SWAP)) {
51 +               size = sizeof(struct ar5416_eeprom_def);
52 +               need_swap = true;
53 +               eepdata = (u16 *) (&ah->eeprom);
54 +
55 +               for (addr = 0; addr < size / sizeof(u16); addr++) {
56 +                       temp = swab16(*eepdata);
57 +                       *eepdata = temp;
58 +                       eepdata++;
59                 }
60         }
61  
62 --- a/drivers/net/wireless/ath/ath9k/hw.h
63 +++ b/drivers/net/wireless/ath/ath9k/hw.h
64 @@ -731,6 +731,7 @@ enum ath_cal_list {
65  #define AH_USE_EEPROM   0x1
66  #define AH_UNPLUGGED    0x2 /* The card has been physically removed. */
67  #define AH_FASTCC       0x4
68 +#define AH_NO_EEP_SWAP  0x8 /* Do not swap EEPROM data */
69  
70  struct ath_hw {
71         struct ath_ops reg_ops;
72 --- a/drivers/net/wireless/ath/ath9k/init.c
73 +++ b/drivers/net/wireless/ath/ath9k/init.c
74 @@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, s
75                 ah->is_clk_25mhz = pdata->is_clk_25mhz;
76                 ah->get_mac_revision = pdata->get_mac_revision;
77                 ah->external_reset = pdata->external_reset;
78 +               if (!pdata->endian_check)
79 +                       ah->ah_flags |= AH_NO_EEP_SWAP;
80         }
81  
82         common->ops = &ah->reg_ops;
83 --- a/include/linux/ath9k_platform.h
84 +++ b/include/linux/ath9k_platform.h
85 @@ -31,6 +31,7 @@ struct ath9k_platform_data {
86         u32 gpio_mask;
87         u32 gpio_val;
88  
89 +       bool endian_check;
90         bool is_clk_25mhz;
91         bool tx_gain_buffalo;
92