diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2009-01-14 14:17:08 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:00:33 -0500 |
commit | 9dbeb91a8b97e2892c04461e28d2bdd0198b719d (patch) | |
tree | 3ac42d298b739da86a991ed2bd53aa12377cb956 /drivers/net/wireless/ath9k/ahb.c | |
parent | 09329d371e57ff9fcb645b8e2cdee1ec8b9b539f (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/ahb.c')
-rw-r--r-- | drivers/net/wireless/ath9k/ahb.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath9k/ahb.c b/drivers/net/wireless/ath9k/ahb.c index 8cbd4c2a7fa0..7f2c3a09bcac 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 | ||
37 | static 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 | |||
36 | static struct ath_bus_ops ath_ahb_bus_ops = { | 55 | static 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 | ||
41 | static int ath_ahb_probe(struct platform_device *pdev) | 62 | static 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"); |