aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-11-16 22:25:33 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-11-18 14:22:23 -0500
commita05b5d45049d60a06a1b12976150572304a51928 (patch)
treeb19006fab0ef546fcd40a1d3e30906348084f64c
parent458fafdd579dcb58c8288c55c9cd92d6816ba094 (diff)
ath9k: add support for reading eeprom from platform data on PCI devices
Some embedded boards store platform data for connected PCIe AR92xx chips in the system flash instead of a separate EEPROM chip. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c42
3 files changed, 32 insertions, 17 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 75e23632b968..5a13a761c30c 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -419,10 +419,6 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
419 ah->hw_version.magic = AR5416_MAGIC; 419 ah->hw_version.magic = AR5416_MAGIC;
420 ah->hw_version.subvendorid = 0; 420 ah->hw_version.subvendorid = 0;
421 421
422 ah->ah_flags = 0;
423 if (!AR_SREV_9100(ah))
424 ah->ah_flags = AH_USE_EEPROM;
425
426 ah->atim_window = 0; 422 ah->atim_window = 0;
427 ah->sta_id1_defaults = 423 ah->sta_id1_defaults =
428 AR_STA_ID1_CRPT_MIC_ENABLE | 424 AR_STA_ID1_CRPT_MIC_ENABLE |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 498f62180f1c..e7764ce881df 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -530,6 +530,9 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
530 ah->hw_version.subsysid = subsysid; 530 ah->hw_version.subsysid = subsysid;
531 sc->sc_ah = ah; 531 sc->sc_ah = ah;
532 532
533 if (!sc->dev->platform_data)
534 ah->ah_flags |= AH_USE_EEPROM;
535
533 common = ath9k_hw_common(ah); 536 common = ath9k_hw_common(ah);
534 common->ops = &ath9k_common_ops; 537 common->ops = &ath9k_common_ops;
535 common->bus_ops = bus_ops; 538 common->bus_ops = bus_ops;
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 6605bc2c2036..09f69a9617f4 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/nl80211.h> 17#include <linux/nl80211.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/ath9k_platform.h>
19#include "ath9k.h" 20#include "ath9k.h"
20 21
21static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { 22static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
@@ -53,21 +54,36 @@ static void ath_pci_read_cachesize(struct ath_common *common, int *csz)
53 54
54static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data) 55static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
55{ 56{
56 struct ath_hw *ah = (struct ath_hw *) common->ah; 57 struct ath_softc *sc = (struct ath_softc *) common->priv;
57 58 struct ath9k_platform_data *pdata = sc->dev->platform_data;
58 common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S)); 59
59 60 if (pdata) {
60 if (!ath9k_hw_wait(ah, 61 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
61 AR_EEPROM_STATUS_DATA, 62 ath_print(common, ATH_DBG_FATAL,
62 AR_EEPROM_STATUS_DATA_BUSY | 63 "%s: eeprom read failed, offset %08x "
63 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0, 64 "is out of range\n",
64 AH_WAIT_TIMEOUT)) { 65 __func__, off);
65 return false; 66 }
67
68 *data = pdata->eeprom_data[off];
69 } else {
70 struct ath_hw *ah = (struct ath_hw *) common->ah;
71
72 common->ops->read(ah, AR5416_EEPROM_OFFSET +
73 (off << AR5416_EEPROM_S));
74
75 if (!ath9k_hw_wait(ah,
76 AR_EEPROM_STATUS_DATA,
77 AR_EEPROM_STATUS_DATA_BUSY |
78 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
79 AH_WAIT_TIMEOUT)) {
80 return false;
81 }
82
83 *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
84 AR_EEPROM_STATUS_DATA_VAL);
66 } 85 }
67 86
68 *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA),
69 AR_EEPROM_STATUS_DATA_VAL);
70
71 return true; 87 return true;
72} 88}
73 89