aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2009-01-14 14:17:08 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:00:33 -0500
commit9dbeb91a8b97e2892c04461e28d2bdd0198b719d (patch)
tree3ac42d298b739da86a991ed2bd53aa12377cb956 /drivers/net/wireless/ath9k
parent09329d371e57ff9fcb645b8e2cdee1ec8b9b539f (diff)
ath9k: get EEPROM contents from platform data on AHB bus
On the AR913x SOCs we have to provide EEPROM contents via platform_data, because accessing the flash via MMIO is not safe. Additionally different boards may store the radio calibration data at different locations. Changes-licensed-under: ISC Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Imre Kaloz <kaloz@openwrt.org> Tested-by: Pavel Roskin <proski@gnu.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k')
-rw-r--r--drivers/net/wireless/ath9k/ahb.c27
-rw-r--r--drivers/net/wireless/ath9k/core.h1
-rw-r--r--drivers/net/wireless/ath9k/eeprom.c51
-rw-r--r--drivers/net/wireless/ath9k/pci.c18
4 files changed, 49 insertions, 48 deletions
diff --git a/drivers/net/wireless/ath9k/ahb.c b/drivers/net/wireless/ath9k/ahb.c
index 8cbd4c2a7fa..7f2c3a09bca 100644
--- a/drivers/net/wireless/ath9k/ahb.c
+++ b/drivers/net/wireless/ath9k/ahb.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/nl80211.h> 19#include <linux/nl80211.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/ath9k_platform.h>
21#include "core.h" 22#include "core.h"
22#include "reg.h" 23#include "reg.h"
23#include "hw.h" 24#include "hw.h"
@@ -33,9 +34,29 @@ static void ath_ahb_cleanup(struct ath_softc *sc)
33 iounmap(sc->mem); 34 iounmap(sc->mem);
34} 35}
35 36
37static bool ath_ahb_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
38{
39 struct ath_softc *sc = ah->ah_sc;
40 struct platform_device *pdev = to_platform_device(sc->dev);
41 struct ath9k_platform_data *pdata;
42
43 pdata = (struct ath9k_platform_data *) pdev->dev.platform_data;
44 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
45 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
46 "%s: flash read failed, offset %08x is out of range\n",
47 __func__, off);
48 return false;
49 }
50
51 *data = pdata->eeprom_data[off];
52 return true;
53}
54
36static struct ath_bus_ops ath_ahb_bus_ops = { 55static struct ath_bus_ops ath_ahb_bus_ops = {
37 .read_cachesize = ath_ahb_read_cachesize, 56 .read_cachesize = ath_ahb_read_cachesize,
38 .cleanup = ath_ahb_cleanup, 57 .cleanup = ath_ahb_cleanup,
58
59 .eeprom_read = ath_ahb_eeprom_read,
39}; 60};
40 61
41static int ath_ahb_probe(struct platform_device *pdev) 62static int ath_ahb_probe(struct platform_device *pdev)
@@ -48,6 +69,12 @@ static int ath_ahb_probe(struct platform_device *pdev)
48 int ret = 0; 69 int ret = 0;
49 struct ath_hal *ah; 70 struct ath_hal *ah;
50 71
72 if (!pdev->dev.platform_data) {
73 dev_err(&pdev->dev, "no platform data specified\n");
74 ret = -EINVAL;
75 goto err_out;
76 }
77
51 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 78 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
52 if (res == NULL) { 79 if (res == NULL) {
53 dev_err(&pdev->dev, "no memory resource found\n"); 80 dev_err(&pdev->dev, "no memory resource found\n");
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index c5dae11d608..b687ae9c9e1 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -696,6 +696,7 @@ enum PROT_MODE {
696struct ath_bus_ops { 696struct ath_bus_ops {
697 void (*read_cachesize)(struct ath_softc *sc, int *csz); 697 void (*read_cachesize)(struct ath_softc *sc, int *csz);
698 void (*cleanup)(struct ath_softc *sc); 698 void (*cleanup)(struct ath_softc *sc);
699 bool (*eeprom_read)(struct ath_hal *ah, u32 off, u16 *data);
699}; 700};
700 701
701struct ath_softc { 702struct ath_softc {
diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c
index 1ef8b5a70e5..50cb3883416 100644
--- a/drivers/net/wireless/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath9k/eeprom.c
@@ -91,53 +91,11 @@ static inline bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList,
91 return false; 91 return false;
92} 92}
93 93
94static bool ath9k_hw_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
95{
96 (void)REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
97
98 if (!ath9k_hw_wait(ah,
99 AR_EEPROM_STATUS_DATA,
100 AR_EEPROM_STATUS_DATA_BUSY |
101 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) {
102 return false;
103 }
104
105 *data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
106 AR_EEPROM_STATUS_DATA_VAL);
107
108 return true;
109}
110
111static int ath9k_hw_flash_map(struct ath_hal *ah)
112{
113 struct ath_hal_5416 *ahp = AH5416(ah);
114
115 ahp->ah_cal_mem = ioremap(AR5416_EEPROM_START_ADDR, AR5416_EEPROM_MAX);
116
117 if (!ahp->ah_cal_mem) {
118 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
119 "cannot remap eeprom region \n");
120 return -EIO;
121 }
122
123 return 0;
124}
125
126static bool ath9k_hw_flash_read(struct ath_hal *ah, u32 off, u16 *data)
127{
128 struct ath_hal_5416 *ahp = AH5416(ah);
129
130 *data = ioread16(ahp->ah_cal_mem + off);
131
132 return true;
133}
134
135static inline bool ath9k_hw_nvram_read(struct ath_hal *ah, u32 off, u16 *data) 94static inline bool ath9k_hw_nvram_read(struct ath_hal *ah, u32 off, u16 *data)
136{ 95{
137 if (ath9k_hw_use_flash(ah)) 96 struct ath_softc *sc = ah->ah_sc;
138 return ath9k_hw_flash_read(ah, off, data); 97
139 else 98 return sc->bus_ops->eeprom_read(ah, off, data);
140 return ath9k_hw_eeprom_read(ah, off, data);
141} 99}
142 100
143static bool ath9k_hw_fill_4k_eeprom(struct ath_hal *ah) 101static bool ath9k_hw_fill_4k_eeprom(struct ath_hal *ah)
@@ -2825,9 +2783,6 @@ int ath9k_hw_eeprom_attach(struct ath_hal *ah)
2825 int status; 2783 int status;
2826 struct ath_hal_5416 *ahp = AH5416(ah); 2784 struct ath_hal_5416 *ahp = AH5416(ah);
2827 2785
2828 if (ath9k_hw_use_flash(ah))
2829 ath9k_hw_flash_map(ah);
2830
2831 if (AR_SREV_9285(ah)) 2786 if (AR_SREV_9285(ah))
2832 ahp->ah_eep_map = EEP_MAP_4KBITS; 2787 ahp->ah_eep_map = EEP_MAP_4KBITS;
2833 else 2788 else
diff --git a/drivers/net/wireless/ath9k/pci.c b/drivers/net/wireless/ath9k/pci.c
index 4ff1caa9ba9..05612bf2836 100644
--- a/drivers/net/wireless/ath9k/pci.c
+++ b/drivers/net/wireless/ath9k/pci.c
@@ -58,9 +58,27 @@ static void ath_pci_cleanup(struct ath_softc *sc)
58 pci_disable_device(pdev); 58 pci_disable_device(pdev);
59} 59}
60 60
61static bool ath_pci_eeprom_read(struct ath_hal *ah, u32 off, u16 *data)
62{
63 (void)REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
64
65 if (!ath9k_hw_wait(ah,
66 AR_EEPROM_STATUS_DATA,
67 AR_EEPROM_STATUS_DATA_BUSY |
68 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) {
69 return false;
70 }
71
72 *data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
73 AR_EEPROM_STATUS_DATA_VAL);
74
75 return true;
76}
77
61static struct ath_bus_ops ath_pci_bus_ops = { 78static struct ath_bus_ops ath_pci_bus_ops = {
62 .read_cachesize = ath_pci_read_cachesize, 79 .read_cachesize = ath_pci_read_cachesize,
63 .cleanup = ath_pci_cleanup, 80 .cleanup = ath_pci_cleanup,
81 .eeprom_read = ath_pci_eeprom_read,
64}; 82};
65 83
66static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 84static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)