aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/ahb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/ahb.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/ahb.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 1a984b02e9e5..5b49cd03bfdf 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2008-2009 Atheros Communications Inc. 2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org> 3 * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
4 * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org> 4 * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
5 * 5 *
@@ -21,6 +21,18 @@
21#include <linux/ath9k_platform.h> 21#include <linux/ath9k_platform.h>
22#include "ath9k.h" 22#include "ath9k.h"
23 23
24static const struct platform_device_id ath9k_platform_id_table[] = {
25 {
26 .name = "ath9k",
27 .driver_data = AR5416_AR9100_DEVID,
28 },
29 {
30 .name = "ar934x_wmac",
31 .driver_data = AR9300_DEVID_AR9340,
32 },
33 {},
34};
35
24/* return bus cachesize in 4B word units */ 36/* return bus cachesize in 4B word units */
25static void ath_ahb_read_cachesize(struct ath_common *common, int *csz) 37static void ath_ahb_read_cachesize(struct ath_common *common, int *csz)
26{ 38{
@@ -35,10 +47,9 @@ static bool ath_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
35 47
36 pdata = (struct ath9k_platform_data *) pdev->dev.platform_data; 48 pdata = (struct ath9k_platform_data *) pdev->dev.platform_data;
37 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) { 49 if (off >= (ARRAY_SIZE(pdata->eeprom_data))) {
38 ath_print(common, ATH_DBG_FATAL, 50 ath_err(common,
39 "%s: flash read failed, offset %08x " 51 "%s: flash read failed, offset %08x is out of range\n",
40 "is out of range\n", 52 __func__, off);
41 __func__, off);
42 return false; 53 return false;
43 } 54 }
44 55
@@ -55,10 +66,10 @@ static struct ath_bus_ops ath_ahb_bus_ops = {
55static int ath_ahb_probe(struct platform_device *pdev) 66static int ath_ahb_probe(struct platform_device *pdev)
56{ 67{
57 void __iomem *mem; 68 void __iomem *mem;
58 struct ath_wiphy *aphy;
59 struct ath_softc *sc; 69 struct ath_softc *sc;
60 struct ieee80211_hw *hw; 70 struct ieee80211_hw *hw;
61 struct resource *res; 71 struct resource *res;
72 const struct platform_device_id *id = platform_get_device_id(pdev);
62 int irq; 73 int irq;
63 int ret = 0; 74 int ret = 0;
64 struct ath_hw *ah; 75 struct ath_hw *ah;
@@ -77,7 +88,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
77 goto err_out; 88 goto err_out;
78 } 89 }
79 90
80 mem = ioremap_nocache(res->start, res->end - res->start + 1); 91 mem = ioremap_nocache(res->start, resource_size(res));
81 if (mem == NULL) { 92 if (mem == NULL) {
82 dev_err(&pdev->dev, "ioremap failed\n"); 93 dev_err(&pdev->dev, "ioremap failed\n");
83 ret = -ENOMEM; 94 ret = -ENOMEM;
@@ -93,8 +104,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
93 104
94 irq = res->start; 105 irq = res->start;
95 106
96 hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) + 107 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
97 sizeof(struct ath_softc), &ath9k_ops);
98 if (hw == NULL) { 108 if (hw == NULL) {
99 dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); 109 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
100 ret = -ENOMEM; 110 ret = -ENOMEM;
@@ -104,11 +114,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
104 SET_IEEE80211_DEV(hw, &pdev->dev); 114 SET_IEEE80211_DEV(hw, &pdev->dev);
105 platform_set_drvdata(pdev, hw); 115 platform_set_drvdata(pdev, hw);
106 116
107 aphy = hw->priv; 117 sc = hw->priv;
108 sc = (struct ath_softc *) (aphy + 1);
109 aphy->sc = sc;
110 aphy->hw = hw;
111 sc->pri_wiphy = aphy;
112 sc->hw = hw; 118 sc->hw = hw;
113 sc->dev = &pdev->dev; 119 sc->dev = &pdev->dev;
114 sc->mem = mem; 120 sc->mem = mem;
@@ -123,7 +129,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
123 goto err_free_hw; 129 goto err_free_hw;
124 } 130 }
125 131
126 ret = ath9k_init_device(AR5416_AR9100_DEVID, sc, 0x0, &ath_ahb_bus_ops); 132 ret = ath9k_init_device(id->driver_data, sc, 0x0, &ath_ahb_bus_ops);
127 if (ret) { 133 if (ret) {
128 dev_err(&pdev->dev, "failed to initialize device\n"); 134 dev_err(&pdev->dev, "failed to initialize device\n");
129 goto err_irq; 135 goto err_irq;
@@ -152,8 +158,7 @@ static int ath_ahb_remove(struct platform_device *pdev)
152 struct ieee80211_hw *hw = platform_get_drvdata(pdev); 158 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
153 159
154 if (hw) { 160 if (hw) {
155 struct ath_wiphy *aphy = hw->priv; 161 struct ath_softc *sc = hw->priv;
156 struct ath_softc *sc = aphy->sc;
157 void __iomem *mem = sc->mem; 162 void __iomem *mem = sc->mem;
158 163
159 ath9k_deinit_device(sc); 164 ath9k_deinit_device(sc);
@@ -173,8 +178,11 @@ static struct platform_driver ath_ahb_driver = {
173 .name = "ath9k", 178 .name = "ath9k",
174 .owner = THIS_MODULE, 179 .owner = THIS_MODULE,
175 }, 180 },
181 .id_table = ath9k_platform_id_table,
176}; 182};
177 183
184MODULE_DEVICE_TABLE(platform, ath9k_platform_id_table);
185
178int ath_ahb_init(void) 186int ath_ahb_init(void)
179{ 187{
180 return platform_driver_register(&ath_ahb_driver); 188 return platform_driver_register(&ath_ahb_driver);