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);
7 +static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
10 + struct ath_common *common = ath9k_hw_common(ah);
11 + u16 *data = (u16 *) mptr;
14 + for (i = 0; i < mdata_size / 2; i++, data++)
15 + ath9k_hw_nvram_read(common, i, data);
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);
26 + if (ath9k_hw_use_flash(ah))
27 + return ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
29 word = kzalloc(2048, GFP_KERNEL);
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;
39 - if (!AR_SREV_9100(ah))
40 - ah->ah_flags = AH_USE_EEPROM;
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;
51 + if (!sc->dev->platform_data)
52 + ah->ah_flags |= AH_USE_EEPROM;
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
61 #include <linux/nl80211.h>
62 #include <linux/pci.h>
63 +#include <linux/ath9k_platform.h>
66 static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
67 @@ -53,21 +54,36 @@ static void ath_pci_read_cachesize(struc
69 static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
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;
75 - common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
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",
84 + *data = pdata->eeprom_data[off];
86 + struct ath_hw *ah = (struct ath_hw *) common->ah;
88 + common->ops->read(ah, AR5416_EEPROM_OFFSET +
89 + (off << AR5416_EEPROM_S));
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,
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)) {
105 + *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
106 + AR_EEPROM_STATUS_DATA_VAL);
109 - *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
110 - AR_EEPROM_STATUS_DATA_VAL);