b693b0a6dd4f59d29fd2699571ec4897a9102dfa
[openwrt.git] / package / mac80211 / patches / 310-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
3 @@ -3271,6 +3271,18 @@ static bool ar9300_check_eeprom_header(s
4 return ar9300_check_header(header);
5 }
6
7 +static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
8 + int mdata_size)
9 +{
10 + struct ath_common *common = ath9k_hw_common(ah);
11 + u16 *data = (u16 *) mptr;
12 + int i;
13 +
14 + for (i = 0; i < mdata_size / 2; i++, data++)
15 + ath9k_hw_nvram_read(common, i, data);
16 +
17 + return 0;
18 +}
19 /*
20 * Read the configuration data from the eeprom.
21 * The data can be put in any specified memory buffer.
22 @@ -3293,6 +3305,9 @@ static int ar9300_eeprom_restore_interna
23 struct ath_common *common = ath9k_hw_common(ah);
24 eeprom_read_op read;
25
26 + if (ath9k_hw_use_flash(ah))
27 + return ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
28 +
29 word = kzalloc(2048, GFP_KERNEL);
30 if (!word)
31 return -1;
32 --- a/drivers/net/wireless/ath/ath9k/hw.c
33 +++ b/drivers/net/wireless/ath/ath9k/hw.c
34 @@ -419,10 +419,6 @@ static void ath9k_hw_init_defaults(struc
35 ah->hw_version.magic = AR5416_MAGIC;
36 ah->hw_version.subvendorid = 0;
37
38 - ah->ah_flags = 0;
39 - if (!AR_SREV_9100(ah))
40 - ah->ah_flags = AH_USE_EEPROM;
41 -
42 ah->atim_window = 0;
43 ah->sta_id1_defaults =
44 AR_STA_ID1_CRPT_MIC_ENABLE |
45 --- a/drivers/net/wireless/ath/ath9k/init.c
46 +++ b/drivers/net/wireless/ath/ath9k/init.c
47 @@ -533,6 +533,9 @@ static int ath9k_init_softc(u16 devid, s
48 ah->hw_version.subsysid = subsysid;
49 sc->sc_ah = ah;
50
51 + if (!sc->dev->platform_data)
52 + ah->ah_flags |= AH_USE_EEPROM;
53 +
54 common = ath9k_hw_common(ah);
55 common->ops = &ath9k_common_ops;
56 common->bus_ops = bus_ops;
57 --- a/drivers/net/wireless/ath/ath9k/pci.c
58 +++ b/drivers/net/wireless/ath/ath9k/pci.c
59 @@ -16,6 +16,7 @@
60
61 #include <linux/nl80211.h>
62 #include <linux/pci.h>
63 +#include <linux/ath9k_platform.h>
64 #include "ath9k.h"
65
66 static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
67 @@ -53,21 +54,36 @@ static void ath_pci_read_cachesize(struc
68
69 static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
70 {
71 - struct ath_hw *ah = (struct ath_hw *) common->ah;
72 + struct ath_softc *sc = (struct ath_softc *) common->priv;
73 + struct ath9k_platform_data *pdata = sc->dev->platform_data;
74
75 - common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
76 + if (pdata) {
77 + if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
78 + ath_print(common, ATH_DBG_FATAL,
79 + "%s: eeprom read failed, offset %08x "
80 + "is out of range\n",
81 + __func__, off);
82 + }
83 +
84 + *data = pdata->eeprom_data[off];
85 + } else {
86 + struct ath_hw *ah = (struct ath_hw *) common->ah;
87 +
88 + common->ops->read(ah, AR5416_EEPROM_OFFSET +
89 + (off << AR5416_EEPROM_S));
90 +
91 + if (!ath9k_hw_wait(ah,
92 + AR_EEPROM_STATUS_DATA,
93 + AR_EEPROM_STATUS_DATA_BUSY |
94 + AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
95 + AH_WAIT_TIMEOUT)) {
96 + return false;
97 + }
98
99 - if (!ath9k_hw_wait(ah,
100 - AR_EEPROM_STATUS_DATA,
101 - AR_EEPROM_STATUS_DATA_BUSY |
102 - AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
103 - AH_WAIT_TIMEOUT)) {
104 - return false;
105 + *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
106 + AR_EEPROM_STATUS_DATA_VAL);
107 }
108
109 - *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
110 - AR_EEPROM_STATUS_DATA_VAL);
111 -
112 return true;
113 }
114
This page took 0.046706 seconds and 3 git commands to generate.