Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Joe Perches | 516304b | 2012-03-18 17:30:52 -0700 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Alexey Dobriyan | b7f080c | 2011-06-16 11:01:34 +0000 | [diff] [blame] | 19 | #include <linux/dma-mapping.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 20 | #include <linux/slab.h> |
Felix Fietkau | 6fb1b1e | 2011-03-19 13:55:39 +0100 | [diff] [blame] | 21 | #include <linux/ath9k_platform.h> |
Paul Gortmaker | 9d9779e | 2011-07-03 15:21:01 -0400 | [diff] [blame] | 22 | #include <linux/module.h> |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 23 | #include <linux/relay.h> |
Oleksij Rempel | b0a1ae9 | 2013-05-24 20:30:59 +0200 | [diff] [blame] | 24 | #include <net/ieee80211_radiotap.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 26 | #include "ath9k.h" |
| 27 | |
Gabor Juhos | ab5c4f7 | 2012-12-10 15:30:28 +0100 | [diff] [blame] | 28 | struct ath9k_eeprom_ctx { |
| 29 | struct completion complete; |
| 30 | struct ath_hw *ah; |
| 31 | }; |
| 32 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 33 | static char *dev_info = "ath9k"; |
| 34 | |
| 35 | MODULE_AUTHOR("Atheros Communications"); |
| 36 | MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); |
| 37 | MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards"); |
| 38 | MODULE_LICENSE("Dual BSD/GPL"); |
| 39 | |
| 40 | static unsigned int ath9k_debug = ATH_DBG_DEFAULT; |
| 41 | module_param_named(debug, ath9k_debug, uint, 0); |
| 42 | MODULE_PARM_DESC(debug, "Debugging mask"); |
| 43 | |
John W. Linville | 3e6109c | 2011-01-05 09:39:17 -0500 | [diff] [blame] | 44 | int ath9k_modparam_nohwcrypt; |
| 45 | module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 46 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); |
| 47 | |
Hong Xu | 0c8a1e4 | 2015-01-24 03:34:03 -0800 | [diff] [blame] | 48 | int ath9k_led_blink; |
| 49 | module_param_named(blink, ath9k_led_blink, int, 0444); |
Vivek Natarajan | 9a75c2f | 2010-06-22 11:52:37 +0530 | [diff] [blame] | 50 | MODULE_PARM_DESC(blink, "Enable LED blink on activity"); |
| 51 | |
Vittorio Gambaletta (VittGam) | cd84042 | 2016-04-11 04:48:54 +0200 | [diff] [blame] | 52 | static int ath9k_led_active_high = -1; |
| 53 | module_param_named(led_active_high, ath9k_led_active_high, int, 0444); |
| 54 | MODULE_PARM_DESC(led_active_high, "Invert LED polarity"); |
| 55 | |
Vasanthakumar Thiagarajan | 8f5dcb1 | 2010-11-26 06:10:06 -0800 | [diff] [blame] | 56 | static int ath9k_btcoex_enable; |
| 57 | module_param_named(btcoex_enable, ath9k_btcoex_enable, int, 0444); |
| 58 | MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); |
| 59 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 60 | static int ath9k_bt_ant_diversity; |
| 61 | module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444); |
| 62 | MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity"); |
Sujith Manoharan | e09f2dc | 2012-09-16 08:06:56 +0530 | [diff] [blame] | 63 | |
Sujith Manoharan | 8298383 | 2014-02-04 08:37:53 +0530 | [diff] [blame] | 64 | static int ath9k_ps_enable; |
| 65 | module_param_named(ps_enable, ath9k_ps_enable, int, 0444); |
| 66 | MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave"); |
| 67 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 68 | #ifdef CONFIG_ATH9K_CHANNEL_CONTEXT |
| 69 | |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 70 | int ath9k_use_chanctx; |
Rajkumar Manoharan | 71a5f88 | 2014-05-29 15:11:09 +0530 | [diff] [blame] | 71 | module_param_named(use_chanctx, ath9k_use_chanctx, int, 0444); |
| 72 | MODULE_PARM_DESC(use_chanctx, "Enable channel context for concurrency"); |
| 73 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 74 | #endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ |
| 75 | |
Rajkumar Manoharan | d584747 | 2010-12-20 14:39:51 +0530 | [diff] [blame] | 76 | bool is_ath9k_unloaded; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 77 | |
Felix Fietkau | 0cf55c2 | 2011-02-27 22:26:40 +0100 | [diff] [blame] | 78 | #ifdef CONFIG_MAC80211_LEDS |
| 79 | static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = { |
| 80 | { .throughput = 0 * 1024, .blink_time = 334 }, |
| 81 | { .throughput = 1 * 1024, .blink_time = 260 }, |
| 82 | { .throughput = 5 * 1024, .blink_time = 220 }, |
| 83 | { .throughput = 10 * 1024, .blink_time = 190 }, |
| 84 | { .throughput = 20 * 1024, .blink_time = 170 }, |
| 85 | { .throughput = 50 * 1024, .blink_time = 150 }, |
| 86 | { .throughput = 70 * 1024, .blink_time = 130 }, |
| 87 | { .throughput = 100 * 1024, .blink_time = 110 }, |
| 88 | { .throughput = 200 * 1024, .blink_time = 80 }, |
| 89 | { .throughput = 300 * 1024, .blink_time = 50 }, |
| 90 | }; |
| 91 | #endif |
| 92 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 93 | static void ath9k_deinit_softc(struct ath_softc *sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 94 | |
kbuild test robot | d81f9a0 | 2014-11-12 06:19:48 +0800 | [diff] [blame] | 95 | static void ath9k_op_ps_wakeup(struct ath_common *common) |
Oleksij Rempel | 99d2217 | 2014-11-06 08:53:25 +0100 | [diff] [blame] | 96 | { |
| 97 | ath9k_ps_wakeup((struct ath_softc *) common->priv); |
| 98 | } |
| 99 | |
kbuild test robot | d81f9a0 | 2014-11-12 06:19:48 +0800 | [diff] [blame] | 100 | static void ath9k_op_ps_restore(struct ath_common *common) |
Oleksij Rempel | 99d2217 | 2014-11-06 08:53:25 +0100 | [diff] [blame] | 101 | { |
| 102 | ath9k_ps_restore((struct ath_softc *) common->priv); |
| 103 | } |
| 104 | |
kbuild test robot | d81f9a0 | 2014-11-12 06:19:48 +0800 | [diff] [blame] | 105 | static struct ath_ps_ops ath9k_ps_ops = { |
Oleksij Rempel | 99d2217 | 2014-11-06 08:53:25 +0100 | [diff] [blame] | 106 | .wakeup = ath9k_op_ps_wakeup, |
| 107 | .restore = ath9k_op_ps_restore, |
| 108 | }; |
| 109 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 110 | /* |
| 111 | * Read and write, they both share the same lock. We do this to serialize |
| 112 | * reads and writes on Atheros 802.11n PCI devices only. This is required |
| 113 | * as the FIFO on these devices can only accept sanely 2 requests. |
| 114 | */ |
| 115 | |
| 116 | static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) |
| 117 | { |
| 118 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
| 119 | struct ath_common *common = ath9k_hw_common(ah); |
| 120 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
| 121 | |
Felix Fietkau | f3eef64 | 2012-03-14 16:40:25 +0100 | [diff] [blame] | 122 | if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 123 | unsigned long flags; |
| 124 | spin_lock_irqsave(&sc->sc_serial_rw, flags); |
| 125 | iowrite32(val, sc->mem + reg_offset); |
| 126 | spin_unlock_irqrestore(&sc->sc_serial_rw, flags); |
| 127 | } else |
| 128 | iowrite32(val, sc->mem + reg_offset); |
| 129 | } |
| 130 | |
| 131 | static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) |
| 132 | { |
| 133 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
| 134 | struct ath_common *common = ath9k_hw_common(ah); |
| 135 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
| 136 | u32 val; |
| 137 | |
Felix Fietkau | f3eef64 | 2012-03-14 16:40:25 +0100 | [diff] [blame] | 138 | if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 139 | unsigned long flags; |
| 140 | spin_lock_irqsave(&sc->sc_serial_rw, flags); |
| 141 | val = ioread32(sc->mem + reg_offset); |
| 142 | spin_unlock_irqrestore(&sc->sc_serial_rw, flags); |
| 143 | } else |
| 144 | val = ioread32(sc->mem + reg_offset); |
| 145 | return val; |
| 146 | } |
| 147 | |
Oleksij Rempel | d55ce0a | 2015-03-22 19:29:50 +0100 | [diff] [blame] | 148 | static void ath9k_multi_ioread32(void *hw_priv, u32 *addr, |
| 149 | u32 *val, u16 count) |
| 150 | { |
| 151 | int i; |
| 152 | |
| 153 | for (i = 0; i < count; i++) |
| 154 | val[i] = ath9k_ioread32(hw_priv, addr[i]); |
| 155 | } |
| 156 | |
| 157 | |
Rajkumar Manoharan | 5479de6 | 2011-07-17 11:43:02 +0530 | [diff] [blame] | 158 | static unsigned int __ath9k_reg_rmw(struct ath_softc *sc, u32 reg_offset, |
| 159 | u32 set, u32 clr) |
| 160 | { |
| 161 | u32 val; |
| 162 | |
| 163 | val = ioread32(sc->mem + reg_offset); |
| 164 | val &= ~clr; |
| 165 | val |= set; |
| 166 | iowrite32(val, sc->mem + reg_offset); |
| 167 | |
| 168 | return val; |
| 169 | } |
| 170 | |
Felix Fietkau | 845e03c | 2011-03-23 20:57:25 +0100 | [diff] [blame] | 171 | static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 clr) |
| 172 | { |
| 173 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
| 174 | struct ath_common *common = ath9k_hw_common(ah); |
| 175 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
| 176 | unsigned long uninitialized_var(flags); |
| 177 | u32 val; |
| 178 | |
Felix Fietkau | f3eef64 | 2012-03-14 16:40:25 +0100 | [diff] [blame] | 179 | if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { |
Felix Fietkau | 845e03c | 2011-03-23 20:57:25 +0100 | [diff] [blame] | 180 | spin_lock_irqsave(&sc->sc_serial_rw, flags); |
Rajkumar Manoharan | 5479de6 | 2011-07-17 11:43:02 +0530 | [diff] [blame] | 181 | val = __ath9k_reg_rmw(sc, reg_offset, set, clr); |
Felix Fietkau | 845e03c | 2011-03-23 20:57:25 +0100 | [diff] [blame] | 182 | spin_unlock_irqrestore(&sc->sc_serial_rw, flags); |
Rajkumar Manoharan | 5479de6 | 2011-07-17 11:43:02 +0530 | [diff] [blame] | 183 | } else |
| 184 | val = __ath9k_reg_rmw(sc, reg_offset, set, clr); |
Felix Fietkau | 845e03c | 2011-03-23 20:57:25 +0100 | [diff] [blame] | 185 | |
| 186 | return val; |
| 187 | } |
| 188 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 189 | /**************************/ |
| 190 | /* Initialization */ |
| 191 | /**************************/ |
| 192 | |
Luis R. Rodriguez | 0c0280b | 2013-01-11 18:39:36 +0000 | [diff] [blame] | 193 | static void ath9k_reg_notifier(struct wiphy *wiphy, |
| 194 | struct regulatory_request *request) |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 195 | { |
| 196 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 197 | struct ath_softc *sc = hw->priv; |
Rajkumar Manoharan | 687f545 | 2011-12-08 23:59:25 +0530 | [diff] [blame] | 198 | struct ath_hw *ah = sc->sc_ah; |
| 199 | struct ath_regulatory *reg = ath9k_hw_regulatory(ah); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 200 | |
Luis R. Rodriguez | 0c0280b | 2013-01-11 18:39:36 +0000 | [diff] [blame] | 201 | ath_reg_notifier_apply(wiphy, request, reg); |
Rajkumar Manoharan | 687f545 | 2011-12-08 23:59:25 +0530 | [diff] [blame] | 202 | |
| 203 | /* Set tx power */ |
Felix Fietkau | d385c5c | 2014-11-04 16:56:57 +0100 | [diff] [blame] | 204 | if (!ah->curchan) |
| 205 | return; |
| 206 | |
| 207 | sc->cur_chan->txpower = 2 * ah->curchan->chan->max_power; |
| 208 | ath9k_ps_wakeup(sc); |
| 209 | ath9k_hw_set_txpowerlimit(ah, sc->cur_chan->txpower, false); |
| 210 | ath9k_cmn_update_txpow(ah, sc->cur_chan->cur_txpower, |
| 211 | sc->cur_chan->txpower, |
| 212 | &sc->cur_chan->cur_txpower); |
| 213 | /* synchronize DFS detector if regulatory domain changed */ |
| 214 | if (sc->dfs_detector != NULL) |
| 215 | sc->dfs_detector->set_dfs_domain(sc->dfs_detector, |
| 216 | request->dfs_region); |
| 217 | ath9k_ps_restore(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* |
| 221 | * This function will allocate both the DMA descriptor structure, and the |
| 222 | * buffers it contains. These are used to contain the descriptors used |
| 223 | * by the system. |
| 224 | */ |
| 225 | int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, |
| 226 | struct list_head *head, const char *name, |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 227 | int nbuf, int ndesc, bool is_tx) |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 228 | { |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 229 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 230 | u8 *ds; |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 231 | int i, bsize, desc_len; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 232 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 233 | ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n", |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 234 | name, nbuf, ndesc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 235 | |
| 236 | INIT_LIST_HEAD(head); |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 237 | |
| 238 | if (is_tx) |
| 239 | desc_len = sc->sc_ah->caps.tx_desc_len; |
| 240 | else |
| 241 | desc_len = sizeof(struct ath_desc); |
| 242 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 243 | /* ath_desc must be a multiple of DWORDs */ |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 244 | if ((desc_len % 4) != 0) { |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 245 | ath_err(common, "ath_desc not DWORD aligned\n"); |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 246 | BUG_ON((desc_len % 4) != 0); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 247 | return -ENOMEM; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 248 | } |
| 249 | |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 250 | dd->dd_desc_len = desc_len * nbuf * ndesc; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 251 | |
| 252 | /* |
| 253 | * Need additional DMA memory because we can't use |
| 254 | * descriptors that cross the 4K page boundary. Assume |
| 255 | * one skipped descriptor per 4K page. |
| 256 | */ |
| 257 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { |
| 258 | u32 ndesc_skipped = |
| 259 | ATH_DESC_4KB_BOUND_NUM_SKIPPED(dd->dd_desc_len); |
| 260 | u32 dma_len; |
| 261 | |
| 262 | while (ndesc_skipped) { |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 263 | dma_len = ndesc_skipped * desc_len; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 264 | dd->dd_desc_len += dma_len; |
| 265 | |
| 266 | ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len); |
Joe Perches | ee289b6 | 2010-05-17 22:47:34 -0700 | [diff] [blame] | 267 | } |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /* allocate descriptors */ |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 271 | dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len, |
| 272 | &dd->dd_desc_paddr, GFP_KERNEL); |
| 273 | if (!dd->dd_desc) |
| 274 | return -ENOMEM; |
| 275 | |
Vasanthakumar Thiagarajan | 4adfcde | 2010-04-15 17:39:33 -0400 | [diff] [blame] | 276 | ds = (u8 *) dd->dd_desc; |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 277 | ath_dbg(common, CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n", |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 278 | name, ds, (u32) dd->dd_desc_len, |
| 279 | ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 280 | |
| 281 | /* allocate buffers */ |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 282 | if (is_tx) { |
| 283 | struct ath_buf *bf; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 284 | |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 285 | bsize = sizeof(struct ath_buf) * nbuf; |
| 286 | bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); |
| 287 | if (!bf) |
| 288 | return -ENOMEM; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 289 | |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 290 | for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { |
| 291 | bf->bf_desc = ds; |
| 292 | bf->bf_daddr = DS2PHYS(dd, ds); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 293 | |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 294 | if (!(sc->sc_ah->caps.hw_caps & |
| 295 | ATH9K_HW_CAP_4KB_SPLITTRANS)) { |
| 296 | /* |
| 297 | * Skip descriptor addresses which can cause 4KB |
| 298 | * boundary crossing (addr + length) with a 32 dword |
| 299 | * descriptor fetch. |
| 300 | */ |
| 301 | while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { |
| 302 | BUG_ON((caddr_t) bf->bf_desc >= |
| 303 | ((caddr_t) dd->dd_desc + |
| 304 | dd->dd_desc_len)); |
| 305 | |
| 306 | ds += (desc_len * ndesc); |
| 307 | bf->bf_desc = ds; |
| 308 | bf->bf_daddr = DS2PHYS(dd, ds); |
| 309 | } |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 310 | } |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 311 | list_add_tail(&bf->list, head); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 312 | } |
Felix Fietkau | 1a04d59 | 2013-10-11 23:30:52 +0200 | [diff] [blame] | 313 | } else { |
| 314 | struct ath_rxbuf *bf; |
| 315 | |
| 316 | bsize = sizeof(struct ath_rxbuf) * nbuf; |
| 317 | bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL); |
| 318 | if (!bf) |
| 319 | return -ENOMEM; |
| 320 | |
| 321 | for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { |
| 322 | bf->bf_desc = ds; |
| 323 | bf->bf_daddr = DS2PHYS(dd, ds); |
| 324 | |
| 325 | if (!(sc->sc_ah->caps.hw_caps & |
| 326 | ATH9K_HW_CAP_4KB_SPLITTRANS)) { |
| 327 | /* |
| 328 | * Skip descriptor addresses which can cause 4KB |
| 329 | * boundary crossing (addr + length) with a 32 dword |
| 330 | * descriptor fetch. |
| 331 | */ |
| 332 | while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { |
| 333 | BUG_ON((caddr_t) bf->bf_desc >= |
| 334 | ((caddr_t) dd->dd_desc + |
| 335 | dd->dd_desc_len)); |
| 336 | |
| 337 | ds += (desc_len * ndesc); |
| 338 | bf->bf_desc = ds; |
| 339 | bf->bf_daddr = DS2PHYS(dd, ds); |
| 340 | } |
| 341 | } |
| 342 | list_add_tail(&bf->list, head); |
| 343 | } |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 344 | } |
| 345 | return 0; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 346 | } |
| 347 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 348 | static int ath9k_init_queues(struct ath_softc *sc) |
| 349 | { |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 350 | int i = 0; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 351 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 352 | sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 353 | sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 354 | ath_cabq_update(sc); |
| 355 | |
Felix Fietkau | f2c7a79 | 2013-06-07 18:12:00 +0200 | [diff] [blame] | 356 | sc->tx.uapsdq = ath_txq_setup(sc, ATH9K_TX_QUEUE_UAPSD, 0); |
| 357 | |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 358 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 359 | sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i); |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 360 | sc->tx.txq_map[i]->mac80211_qnum = i; |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 361 | sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH; |
Ben Greear | 60f2d1d | 2011-01-09 23:11:52 -0800 | [diff] [blame] | 362 | } |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 363 | return 0; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 364 | } |
| 365 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 366 | static void ath9k_init_misc(struct ath_softc *sc) |
| 367 | { |
| 368 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 369 | int i = 0; |
Sujith Manoharan | 3d4e20f | 2012-03-14 14:40:58 +0530 | [diff] [blame] | 370 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 371 | setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); |
| 372 | |
Oleksij Rempel | 32efb0c | 2014-02-04 10:27:39 +0100 | [diff] [blame] | 373 | common->last_rssi = ATH_RSSI_DUMMY_MARKER; |
Felix Fietkau | 364734f | 2010-09-14 20:22:44 +0200 | [diff] [blame] | 374 | memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 375 | sc->beacon.slottime = ATH9K_SLOT_TIME_9; |
| 376 | |
Felix Fietkau | 7545daf | 2011-01-24 19:23:16 +0100 | [diff] [blame] | 377 | for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 378 | sc->beacon.bslot[i] = NULL; |
Vasanthakumar Thiagarajan | 102885a | 2010-09-02 01:34:43 -0700 | [diff] [blame] | 379 | |
| 380 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) |
| 381 | sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 382 | |
Oleksij Rempel | dd7657b | 2014-11-06 08:53:22 +0100 | [diff] [blame] | 383 | sc->spec_priv.ah = sc->sc_ah; |
Oleksij Rempel | 21af25d | 2014-11-06 08:53:20 +0100 | [diff] [blame] | 384 | sc->spec_priv.spec_config.enabled = 0; |
| 385 | sc->spec_priv.spec_config.short_repeat = true; |
| 386 | sc->spec_priv.spec_config.count = 8; |
| 387 | sc->spec_priv.spec_config.endless = false; |
| 388 | sc->spec_priv.spec_config.period = 0xFF; |
| 389 | sc->spec_priv.spec_config.fft_period = 0xF; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 390 | } |
| 391 | |
Sujith Manoharan | 0f978bf | 2013-12-06 16:28:45 +0530 | [diff] [blame] | 392 | static void ath9k_init_pcoem_platform(struct ath_softc *sc) |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 393 | { |
| 394 | struct ath_hw *ah = sc->sc_ah; |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 395 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 396 | struct ath_common *common = ath9k_hw_common(ah); |
| 397 | |
Felix Fietkau | 935477e | 2014-10-25 17:19:26 +0200 | [diff] [blame] | 398 | if (!IS_ENABLED(CONFIG_ATH9K_PCOEM)) |
| 399 | return; |
| 400 | |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 401 | if (common->bus_ops->ath_bus_type != ATH_PCI) |
| 402 | return; |
| 403 | |
Sujith Manoharan | e861ef5 | 2013-06-18 10:13:43 +0530 | [diff] [blame] | 404 | if (sc->driver_data & (ATH9K_PCI_CUS198 | |
| 405 | ATH9K_PCI_CUS230)) { |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 406 | ah->config.xlna_gpio = 9; |
| 407 | ah->config.xatten_margin_cfg = true; |
Sujith Manoharan | e083a42 | 2013-08-19 11:04:01 +0530 | [diff] [blame] | 408 | ah->config.alt_mingainidx = true; |
Sujith Manoharan | 31fd216 | 2013-08-04 14:22:01 +0530 | [diff] [blame] | 409 | ah->config.ant_ctrl_comm2g_switch_enable = 0x000BBB88; |
Sujith Manoharan | 3afa6b4 | 2013-08-04 14:21:54 +0530 | [diff] [blame] | 410 | sc->ant_comb.low_rssi_thresh = 20; |
| 411 | sc->ant_comb.fast_div_bias = 3; |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 412 | |
Sujith Manoharan | e861ef5 | 2013-06-18 10:13:43 +0530 | [diff] [blame] | 413 | ath_info(common, "Set parameters for %s\n", |
| 414 | (sc->driver_data & ATH9K_PCI_CUS198) ? |
| 415 | "CUS198" : "CUS230"); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | if (sc->driver_data & ATH9K_PCI_CUS217) |
Sujith Manoharan | 12eea64 | 2013-06-18 15:42:36 +0530 | [diff] [blame] | 419 | ath_info(common, "CUS217 card detected\n"); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 420 | |
Sujith Manoharan | 1063133 | 2013-09-02 13:59:05 +0530 | [diff] [blame] | 421 | if (sc->driver_data & ATH9K_PCI_CUS252) |
| 422 | ath_info(common, "CUS252 card detected\n"); |
| 423 | |
Sujith Manoharan | 3fcdd0a | 2013-09-02 13:59:06 +0530 | [diff] [blame] | 424 | if (sc->driver_data & ATH9K_PCI_AR9565_1ANT) |
| 425 | ath_info(common, "WB335 1-ANT card detected\n"); |
| 426 | |
| 427 | if (sc->driver_data & ATH9K_PCI_AR9565_2ANT) |
| 428 | ath_info(common, "WB335 2-ANT card detected\n"); |
| 429 | |
Sujith Manoharan | 4dd3564 | 2013-10-23 14:26:04 +0530 | [diff] [blame] | 430 | if (sc->driver_data & ATH9K_PCI_KILLER) |
| 431 | ath_info(common, "Killer Wireless card detected\n"); |
| 432 | |
Sujith Manoharan | 3fcdd0a | 2013-09-02 13:59:06 +0530 | [diff] [blame] | 433 | /* |
| 434 | * Some WB335 cards do not support antenna diversity. Since |
| 435 | * we use a hardcoded value for AR9565 instead of using the |
| 436 | * EEPROM/OTP data, remove the combining feature from |
| 437 | * the HW capabilities bitmap. |
| 438 | */ |
| 439 | if (sc->driver_data & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { |
| 440 | if (!(sc->driver_data & ATH9K_PCI_BT_ANT_DIV)) |
| 441 | pCap->hw_caps &= ~ATH9K_HW_CAP_ANT_DIV_COMB; |
| 442 | } |
| 443 | |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 444 | if (sc->driver_data & ATH9K_PCI_BT_ANT_DIV) { |
| 445 | pCap->hw_caps |= ATH9K_HW_CAP_BT_ANT_DIV; |
| 446 | ath_info(common, "Set BT/WLAN RX diversity capability\n"); |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 447 | } |
Sujith Manoharan | d1ae25a | 2013-08-25 16:30:40 +0530 | [diff] [blame] | 448 | |
| 449 | if (sc->driver_data & ATH9K_PCI_D3_L1_WAR) { |
| 450 | ah->config.pcie_waen = 0x0040473b; |
| 451 | ath_info(common, "Enable WAR for ASPM D3/L1\n"); |
| 452 | } |
Sujith Manoharan | 2d22c7d | 2013-11-08 11:45:25 +0530 | [diff] [blame] | 453 | |
Sujith Manoharan | afa7e6d | 2015-03-09 14:20:07 +0530 | [diff] [blame] | 454 | /* |
| 455 | * The default value of pll_pwrsave is 1. |
| 456 | * For certain AR9485 cards, it is set to 0. |
Sujith Manoharan | 656cd75 | 2015-03-09 14:20:08 +0530 | [diff] [blame] | 457 | * For AR9462, AR9565 it's set to 7. |
Sujith Manoharan | afa7e6d | 2015-03-09 14:20:07 +0530 | [diff] [blame] | 458 | */ |
| 459 | ah->config.pll_pwrsave = 1; |
| 460 | |
Sujith Manoharan | 2d22c7d | 2013-11-08 11:45:25 +0530 | [diff] [blame] | 461 | if (sc->driver_data & ATH9K_PCI_NO_PLL_PWRSAVE) { |
Sujith Manoharan | afa7e6d | 2015-03-09 14:20:07 +0530 | [diff] [blame] | 462 | ah->config.pll_pwrsave = 0; |
Sujith Manoharan | 2d22c7d | 2013-11-08 11:45:25 +0530 | [diff] [blame] | 463 | ath_info(common, "Disable PLL PowerSave\n"); |
| 464 | } |
Sujith Manoharan | aeeb206 | 2014-11-16 06:11:02 +0530 | [diff] [blame] | 465 | |
| 466 | if (sc->driver_data & ATH9K_PCI_LED_ACT_HI) |
| 467 | ah->config.led_active_high = true; |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 468 | } |
| 469 | |
Gabor Juhos | ab5c4f7 | 2012-12-10 15:30:28 +0100 | [diff] [blame] | 470 | static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob, |
| 471 | void *ctx) |
| 472 | { |
| 473 | struct ath9k_eeprom_ctx *ec = ctx; |
| 474 | |
| 475 | if (eeprom_blob) |
| 476 | ec->ah->eeprom_blob = eeprom_blob; |
| 477 | |
| 478 | complete(&ec->complete); |
| 479 | } |
| 480 | |
| 481 | static int ath9k_eeprom_request(struct ath_softc *sc, const char *name) |
| 482 | { |
| 483 | struct ath9k_eeprom_ctx ec; |
Colin Ian King | 47f58b1 | 2016-04-10 12:25:31 +0100 | [diff] [blame] | 484 | struct ath_hw *ah = sc->sc_ah; |
Gabor Juhos | ab5c4f7 | 2012-12-10 15:30:28 +0100 | [diff] [blame] | 485 | int err; |
| 486 | |
| 487 | /* try to load the EEPROM content asynchronously */ |
| 488 | init_completion(&ec.complete); |
| 489 | ec.ah = sc->sc_ah; |
| 490 | |
| 491 | err = request_firmware_nowait(THIS_MODULE, 1, name, sc->dev, GFP_KERNEL, |
| 492 | &ec, ath9k_eeprom_request_cb); |
| 493 | if (err < 0) { |
| 494 | ath_err(ath9k_hw_common(ah), |
| 495 | "EEPROM request failed\n"); |
| 496 | return err; |
| 497 | } |
| 498 | |
| 499 | wait_for_completion(&ec.complete); |
| 500 | |
| 501 | if (!ah->eeprom_blob) { |
| 502 | ath_err(ath9k_hw_common(ah), |
| 503 | "Unable to load EEPROM file %s\n", name); |
| 504 | return -EINVAL; |
| 505 | } |
| 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | static void ath9k_eeprom_release(struct ath_softc *sc) |
| 511 | { |
| 512 | release_firmware(sc->sc_ah->eeprom_blob); |
| 513 | } |
| 514 | |
Sujith Manoharan | 0f978bf | 2013-12-06 16:28:45 +0530 | [diff] [blame] | 515 | static int ath9k_init_soc_platform(struct ath_softc *sc) |
| 516 | { |
| 517 | struct ath9k_platform_data *pdata = sc->dev->platform_data; |
| 518 | struct ath_hw *ah = sc->sc_ah; |
| 519 | int ret = 0; |
| 520 | |
| 521 | if (!pdata) |
| 522 | return 0; |
| 523 | |
| 524 | if (pdata->eeprom_name) { |
| 525 | ret = ath9k_eeprom_request(sc, pdata->eeprom_name); |
| 526 | if (ret) |
| 527 | return ret; |
| 528 | } |
| 529 | |
Martin Blumenstingl | 3467f0d | 2016-06-23 16:57:09 +0200 | [diff] [blame^] | 530 | if (pdata->led_active_high) |
| 531 | ah->config.led_active_high = true; |
| 532 | |
Sujith Manoharan | 0f978bf | 2013-12-06 16:28:45 +0530 | [diff] [blame] | 533 | if (pdata->tx_gain_buffalo) |
| 534 | ah->config.tx_gain_buffalo = true; |
| 535 | |
| 536 | return ret; |
| 537 | } |
| 538 | |
Pavel Roskin | eb93e89 | 2011-07-23 03:55:39 -0400 | [diff] [blame] | 539 | static int ath9k_init_softc(u16 devid, struct ath_softc *sc, |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 540 | const struct ath_bus_ops *bus_ops) |
| 541 | { |
Felix Fietkau | 6fb1b1e | 2011-03-19 13:55:39 +0100 | [diff] [blame] | 542 | struct ath9k_platform_data *pdata = sc->dev->platform_data; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 543 | struct ath_hw *ah = NULL; |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 544 | struct ath9k_hw_capabilities *pCap; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 545 | struct ath_common *common; |
| 546 | int ret = 0, i; |
| 547 | int csz = 0; |
| 548 | |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 549 | ah = devm_kzalloc(sc->dev, sizeof(struct ath_hw), GFP_KERNEL); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 550 | if (!ah) |
| 551 | return -ENOMEM; |
| 552 | |
Felix Fietkau | c1b976d | 2012-12-12 13:14:23 +0100 | [diff] [blame] | 553 | ah->dev = sc->dev; |
Ben Greear | 233536e | 2011-01-09 23:11:44 -0800 | [diff] [blame] | 554 | ah->hw = sc->hw; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 555 | ah->hw_version.devid = devid; |
Felix Fietkau | f9f84e9 | 2011-03-23 20:57:24 +0100 | [diff] [blame] | 556 | ah->reg_ops.read = ath9k_ioread32; |
Oleksij Rempel | d55ce0a | 2015-03-22 19:29:50 +0100 | [diff] [blame] | 557 | ah->reg_ops.multi_read = ath9k_multi_ioread32; |
Felix Fietkau | f9f84e9 | 2011-03-23 20:57:24 +0100 | [diff] [blame] | 558 | ah->reg_ops.write = ath9k_iowrite32; |
Felix Fietkau | 845e03c | 2011-03-23 20:57:25 +0100 | [diff] [blame] | 559 | ah->reg_ops.rmw = ath9k_reg_rmw; |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 560 | pCap = &ah->caps; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 561 | |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 562 | common = ath9k_hw_common(ah); |
Felix Fietkau | 56bdbe0 | 2014-11-30 21:58:30 +0100 | [diff] [blame] | 563 | |
| 564 | /* Will be cleared in ath9k_start() */ |
| 565 | set_bit(ATH_OP_INVALID, &common->op_flags); |
| 566 | |
| 567 | sc->sc_ah = ah; |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 568 | sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET); |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 569 | sc->tx99_power = MAX_RATE_POWER + 1; |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 570 | init_waitqueue_head(&sc->tx_wait); |
Rajkumar Manoharan | ca900ac | 2014-06-11 16:18:02 +0530 | [diff] [blame] | 571 | sc->cur_chan = &sc->chanctx[0]; |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 572 | if (!ath9k_is_chanctx_enabled()) |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 573 | sc->cur_chan->hw_queue_base = 0; |
Zefir Kurtisi | 8e92d3f | 2012-04-03 17:15:50 +0200 | [diff] [blame] | 574 | |
Helmut Schaa | 552a515 | 2014-05-07 09:28:31 +0200 | [diff] [blame] | 575 | if (!pdata || pdata->use_eeprom) { |
Felix Fietkau | a05b5d45 | 2010-11-17 04:25:33 +0100 | [diff] [blame] | 576 | ah->ah_flags |= AH_USE_EEPROM; |
Felix Fietkau | 6de66dd | 2011-03-19 13:55:40 +0100 | [diff] [blame] | 577 | sc->sc_ah->led_pin = -1; |
| 578 | } else { |
| 579 | sc->sc_ah->gpio_mask = pdata->gpio_mask; |
| 580 | sc->sc_ah->gpio_val = pdata->gpio_val; |
| 581 | sc->sc_ah->led_pin = pdata->led_pin; |
Vasanthakumar Thiagarajan | f2f5f2a | 2011-04-19 19:29:01 +0530 | [diff] [blame] | 582 | ah->is_clk_25mhz = pdata->is_clk_25mhz; |
Gabor Juhos | 3762561 | 2011-06-21 11:23:23 +0200 | [diff] [blame] | 583 | ah->get_mac_revision = pdata->get_mac_revision; |
Gabor Juhos | 7d95847c | 2011-06-21 11:23:51 +0200 | [diff] [blame] | 584 | ah->external_reset = pdata->external_reset; |
Felix Fietkau | 3468968 | 2014-10-25 17:19:34 +0200 | [diff] [blame] | 585 | ah->disable_2ghz = pdata->disable_2ghz; |
| 586 | ah->disable_5ghz = pdata->disable_5ghz; |
Felix Fietkau | a59dadb | 2014-10-25 17:19:33 +0200 | [diff] [blame] | 587 | if (!pdata->endian_check) |
| 588 | ah->ah_flags |= AH_NO_EEP_SWAP; |
Felix Fietkau | 6de66dd | 2011-03-19 13:55:40 +0100 | [diff] [blame] | 589 | } |
Felix Fietkau | a05b5d45 | 2010-11-17 04:25:33 +0100 | [diff] [blame] | 590 | |
Felix Fietkau | f9f84e9 | 2011-03-23 20:57:24 +0100 | [diff] [blame] | 591 | common->ops = &ah->reg_ops; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 592 | common->bus_ops = bus_ops; |
Oleksij Rempel | 99d2217 | 2014-11-06 08:53:25 +0100 | [diff] [blame] | 593 | common->ps_ops = &ath9k_ps_ops; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 594 | common->ah = ah; |
| 595 | common->hw = sc->hw; |
| 596 | common->priv = sc; |
| 597 | common->debug_mask = ath9k_debug; |
Vasanthakumar Thiagarajan | 8f5dcb1 | 2010-11-26 06:10:06 -0800 | [diff] [blame] | 598 | common->btcoex_enabled = ath9k_btcoex_enable == 1; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 599 | common->disable_ani = false; |
Sujith Manoharan | e09f2dc | 2012-09-16 08:06:56 +0530 | [diff] [blame] | 600 | |
| 601 | /* |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 602 | * Platform quirks. |
| 603 | */ |
Sujith Manoharan | 0f978bf | 2013-12-06 16:28:45 +0530 | [diff] [blame] | 604 | ath9k_init_pcoem_platform(sc); |
| 605 | |
| 606 | ret = ath9k_init_soc_platform(sc); |
| 607 | if (ret) |
| 608 | return ret; |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 609 | |
Vittorio Gambaletta (VittGam) | cd84042 | 2016-04-11 04:48:54 +0200 | [diff] [blame] | 610 | if (ath9k_led_active_high != -1) |
| 611 | ah->config.led_active_high = ath9k_led_active_high == 1; |
| 612 | |
Sujith Manoharan | 9b60b64 | 2013-06-13 22:51:26 +0530 | [diff] [blame] | 613 | /* |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 614 | * Enable WLAN/BT RX Antenna diversity only when: |
| 615 | * |
Sujith Manoharan | 7d84587 | 2013-08-07 12:29:27 +0530 | [diff] [blame] | 616 | * - BTCOEX is disabled. |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 617 | * - the user manually requests the feature. |
| 618 | * - the HW cap is set using the platform data. |
Sujith Manoharan | e09f2dc | 2012-09-16 08:06:56 +0530 | [diff] [blame] | 619 | */ |
Sujith Manoharan | 7d84587 | 2013-08-07 12:29:27 +0530 | [diff] [blame] | 620 | if (!common->btcoex_enabled && ath9k_bt_ant_diversity && |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 621 | (pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 622 | common->bt_ant_diversity = 1; |
Sujith Manoharan | e09f2dc | 2012-09-16 08:06:56 +0530 | [diff] [blame] | 623 | |
Ben Greear | 20b25744 | 2010-10-15 15:04:09 -0700 | [diff] [blame] | 624 | spin_lock_init(&common->cc_lock); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 625 | spin_lock_init(&sc->sc_serial_rw); |
| 626 | spin_lock_init(&sc->sc_pm_lock); |
Felix Fietkau | bff1176 | 2014-06-11 16:17:52 +0530 | [diff] [blame] | 627 | spin_lock_init(&sc->chan_lock); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 628 | mutex_init(&sc->mutex); |
| 629 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); |
Sujith Manoharan | fb6e252 | 2012-07-17 17:16:22 +0530 | [diff] [blame] | 630 | tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet, |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 631 | (unsigned long)sc); |
| 632 | |
Felix Fietkau | bf3dac5 | 2013-11-11 22:23:33 +0100 | [diff] [blame] | 633 | setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc); |
Sujith Manoharan | aaa1ec4 | 2012-06-04 16:27:08 +0530 | [diff] [blame] | 634 | INIT_WORK(&sc->hw_reset_work, ath_reset_work); |
Sujith Manoharan | aaa1ec4 | 2012-06-04 16:27:08 +0530 | [diff] [blame] | 635 | INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); |
| 636 | INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); |
Sujith Manoharan | 705d0bf | 2014-08-23 13:29:06 +0530 | [diff] [blame] | 637 | |
| 638 | ath9k_init_channel_context(sc); |
Sujith Manoharan | aaa1ec4 | 2012-06-04 16:27:08 +0530 | [diff] [blame] | 639 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 640 | /* |
| 641 | * Cache line size is used to size and align various |
| 642 | * structures used to communicate with the hardware. |
| 643 | */ |
| 644 | ath_read_cachesize(common, &csz); |
| 645 | common->cachelsz = csz << 2; /* convert to bytes */ |
| 646 | |
Luis R. Rodriguez | d70357d | 2010-04-15 17:38:06 -0400 | [diff] [blame] | 647 | /* Initializes the hardware for all supported chipsets */ |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 648 | ret = ath9k_hw_init(ah); |
Luis R. Rodriguez | d70357d | 2010-04-15 17:38:06 -0400 | [diff] [blame] | 649 | if (ret) |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 650 | goto err_hw; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 651 | |
Felix Fietkau | 6fb1b1e | 2011-03-19 13:55:39 +0100 | [diff] [blame] | 652 | if (pdata && pdata->macaddr) |
| 653 | memcpy(common->macaddr, pdata->macaddr, ETH_ALEN); |
| 654 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 655 | ret = ath9k_init_queues(sc); |
| 656 | if (ret) |
| 657 | goto err_queues; |
| 658 | |
| 659 | ret = ath9k_init_btcoex(sc); |
| 660 | if (ret) |
| 661 | goto err_btcoex; |
| 662 | |
Oleksij Rempel | 13f7105 | 2014-02-25 14:48:50 +0100 | [diff] [blame] | 663 | ret = ath9k_cmn_init_channels_rates(common); |
Felix Fietkau | f209f52 | 2010-10-01 01:06:53 +0200 | [diff] [blame] | 664 | if (ret) |
| 665 | goto err_btcoex; |
| 666 | |
Sujith Manoharan | c7dd40c | 2014-08-22 20:39:30 +0530 | [diff] [blame] | 667 | ret = ath9k_init_p2p(sc); |
| 668 | if (ret) |
Sujith Manoharan | 4f68169 | 2014-08-22 20:39:25 +0530 | [diff] [blame] | 669 | goto err_btcoex; |
Felix Fietkau | d463af4 | 2014-04-06 00:37:03 +0200 | [diff] [blame] | 670 | |
Rajkumar Manoharan | f82b4bd | 2011-08-13 10:28:15 +0530 | [diff] [blame] | 671 | ath9k_cmn_init_crypto(sc->sc_ah); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 672 | ath9k_init_misc(sc); |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 673 | ath_chanctx_init(sc); |
Sujith Manoharan | e90e302 | 2014-08-23 13:29:20 +0530 | [diff] [blame] | 674 | ath9k_offchannel_init(sc); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 675 | |
Sujith Manoharan | d09f5f4 | 2012-06-04 16:27:14 +0530 | [diff] [blame] | 676 | if (common->bus_ops->aspm_init) |
| 677 | common->bus_ops->aspm_init(common); |
| 678 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 679 | return 0; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 680 | |
| 681 | err_btcoex: |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 682 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) |
| 683 | if (ATH_TXQ_SETUP(sc, i)) |
| 684 | ath_tx_cleanupq(sc, &sc->tx.txq[i]); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 685 | err_queues: |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 686 | ath9k_hw_deinit(ah); |
| 687 | err_hw: |
Gabor Juhos | ab5c4f7 | 2012-12-10 15:30:28 +0100 | [diff] [blame] | 688 | ath9k_eeprom_release(sc); |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 689 | dev_kfree_skb_any(sc->tx99_skb); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 690 | return ret; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 691 | } |
| 692 | |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 693 | static void ath9k_init_band_txpower(struct ath_softc *sc, int band) |
| 694 | { |
| 695 | struct ieee80211_supported_band *sband; |
| 696 | struct ieee80211_channel *chan; |
| 697 | struct ath_hw *ah = sc->sc_ah; |
Oleksij Rempel | 13f7105 | 2014-02-25 14:48:50 +0100 | [diff] [blame] | 698 | struct ath_common *common = ath9k_hw_common(ah); |
Simon Wunderlich | 0671894 | 2013-08-16 10:46:04 +0200 | [diff] [blame] | 699 | struct cfg80211_chan_def chandef; |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 700 | int i; |
| 701 | |
Oleksij Rempel | 13f7105 | 2014-02-25 14:48:50 +0100 | [diff] [blame] | 702 | sband = &common->sbands[band]; |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 703 | for (i = 0; i < sband->n_channels; i++) { |
| 704 | chan = &sband->channels[i]; |
| 705 | ah->curchan = &ah->channels[chan->hw_value]; |
Simon Wunderlich | 0671894 | 2013-08-16 10:46:04 +0200 | [diff] [blame] | 706 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_HT20); |
Felix Fietkau | 2297f1c | 2013-10-11 23:30:57 +0200 | [diff] [blame] | 707 | ath9k_cmn_get_channel(sc->hw, ah, &chandef); |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 708 | ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true); |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 709 | } |
| 710 | } |
| 711 | |
| 712 | static void ath9k_init_txpower_limits(struct ath_softc *sc) |
| 713 | { |
| 714 | struct ath_hw *ah = sc->sc_ah; |
| 715 | struct ath9k_channel *curchan = ah->curchan; |
| 716 | |
| 717 | if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 718 | ath9k_init_band_txpower(sc, NL80211_BAND_2GHZ); |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 719 | if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 720 | ath9k_init_band_txpower(sc, NL80211_BAND_5GHZ); |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 721 | |
| 722 | ah->curchan = curchan; |
| 723 | } |
| 724 | |
Felix Fietkau | 20c8e8d | 2012-04-17 02:40:07 +0200 | [diff] [blame] | 725 | static const struct ieee80211_iface_limit if_limits[] = { |
Rajkumar Manoharan | 71a5f88 | 2014-05-29 15:11:09 +0530 | [diff] [blame] | 726 | { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) }, |
Felix Fietkau | 20c8e8d | 2012-04-17 02:40:07 +0200 | [diff] [blame] | 727 | { .max = 8, .types = |
| 728 | #ifdef CONFIG_MAC80211_MESH |
| 729 | BIT(NL80211_IFTYPE_MESH_POINT) | |
| 730 | #endif |
Felix Fietkau | 95ae481 | 2014-04-06 00:37:02 +0200 | [diff] [blame] | 731 | BIT(NL80211_IFTYPE_AP) }, |
| 732 | { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Felix Fietkau | 20c8e8d | 2012-04-17 02:40:07 +0200 | [diff] [blame] | 733 | BIT(NL80211_IFTYPE_P2P_GO) }, |
| 734 | }; |
| 735 | |
Rajkumar Manoharan | 71a5f88 | 2014-05-29 15:11:09 +0530 | [diff] [blame] | 736 | static const struct ieee80211_iface_limit wds_limits[] = { |
| 737 | { .max = 2048, .types = BIT(NL80211_IFTYPE_WDS) }, |
| 738 | }; |
| 739 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 740 | #ifdef CONFIG_ATH9K_CHANNEL_CONTEXT |
| 741 | |
Rajkumar Manoharan | a406832 | 2014-06-11 16:18:16 +0530 | [diff] [blame] | 742 | static const struct ieee80211_iface_limit if_limits_multi[] = { |
Sujith Manoharan | 86162d4 | 2014-08-24 21:16:12 +0530 | [diff] [blame] | 743 | { .max = 2, .types = BIT(NL80211_IFTYPE_STATION) | |
| 744 | BIT(NL80211_IFTYPE_AP) | |
| 745 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Rajkumar Manoharan | a406832 | 2014-06-11 16:18:16 +0530 | [diff] [blame] | 746 | BIT(NL80211_IFTYPE_P2P_GO) }, |
Sujith Manoharan | 86162d4 | 2014-08-24 21:16:12 +0530 | [diff] [blame] | 747 | { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, |
Janusz.Dziedzic@tieto.com | eb61f9f | 2015-07-21 11:11:40 +0200 | [diff] [blame] | 748 | { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) }, |
Rajkumar Manoharan | a406832 | 2014-06-11 16:18:16 +0530 | [diff] [blame] | 749 | }; |
| 750 | |
Rajkumar Manoharan | a406832 | 2014-06-11 16:18:16 +0530 | [diff] [blame] | 751 | static const struct ieee80211_iface_combination if_comb_multi[] = { |
| 752 | { |
| 753 | .limits = if_limits_multi, |
| 754 | .n_limits = ARRAY_SIZE(if_limits_multi), |
Janusz.Dziedzic@tieto.com | eb61f9f | 2015-07-21 11:11:40 +0200 | [diff] [blame] | 755 | .max_interfaces = 3, |
Rajkumar Manoharan | a406832 | 2014-06-11 16:18:16 +0530 | [diff] [blame] | 756 | .num_different_channels = 2, |
| 757 | .beacon_int_infra_match = true, |
| 758 | }, |
| 759 | }; |
| 760 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 761 | #endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ |
| 762 | |
Zefir Kurtisi | e9cdedf | 2013-04-03 18:31:29 +0200 | [diff] [blame] | 763 | static const struct ieee80211_iface_combination if_comb[] = { |
| 764 | { |
| 765 | .limits = if_limits, |
| 766 | .n_limits = ARRAY_SIZE(if_limits), |
| 767 | .max_interfaces = 2048, |
| 768 | .num_different_channels = 1, |
| 769 | .beacon_int_infra_match = true, |
Felix Fietkau | 1286558 | 2016-01-22 01:56:30 +0100 | [diff] [blame] | 770 | #ifdef CONFIG_ATH9K_DFS_CERTIFIED |
| 771 | .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | |
| 772 | BIT(NL80211_CHAN_WIDTH_20) | |
| 773 | BIT(NL80211_CHAN_WIDTH_40), |
| 774 | #endif |
Zefir Kurtisi | e9cdedf | 2013-04-03 18:31:29 +0200 | [diff] [blame] | 775 | }, |
Rajkumar Manoharan | 71a5f88 | 2014-05-29 15:11:09 +0530 | [diff] [blame] | 776 | { |
| 777 | .limits = wds_limits, |
| 778 | .n_limits = ARRAY_SIZE(wds_limits), |
| 779 | .max_interfaces = 2048, |
| 780 | .num_different_channels = 1, |
| 781 | .beacon_int_infra_match = true, |
| 782 | }, |
Felix Fietkau | 20c8e8d | 2012-04-17 02:40:07 +0200 | [diff] [blame] | 783 | }; |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 784 | |
Sujith Manoharan | 868caae | 2014-10-21 19:23:02 +0530 | [diff] [blame] | 785 | #ifdef CONFIG_ATH9K_CHANNEL_CONTEXT |
| 786 | static void ath9k_set_mcc_capab(struct ath_softc *sc, struct ieee80211_hw *hw) |
| 787 | { |
| 788 | struct ath_hw *ah = sc->sc_ah; |
| 789 | struct ath_common *common = ath9k_hw_common(ah); |
| 790 | |
| 791 | if (!ath9k_is_chanctx_enabled()) |
| 792 | return; |
| 793 | |
Johannes Berg | 30686bf | 2015-06-02 21:39:54 +0200 | [diff] [blame] | 794 | ieee80211_hw_set(hw, QUEUE_CONTROL); |
Sujith Manoharan | 868caae | 2014-10-21 19:23:02 +0530 | [diff] [blame] | 795 | hw->queues = ATH9K_NUM_TX_QUEUES; |
| 796 | hw->offchannel_tx_hw_queue = hw->queues - 1; |
| 797 | hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS); |
| 798 | hw->wiphy->iface_combinations = if_comb_multi; |
| 799 | hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi); |
| 800 | hw->wiphy->max_scan_ssids = 255; |
| 801 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; |
| 802 | hw->wiphy->max_remain_on_channel_duration = 10000; |
| 803 | hw->chanctx_data_size = sizeof(void *); |
| 804 | hw->extra_beacon_tailroom = |
| 805 | sizeof(struct ieee80211_p2p_noa_attr) + 9; |
| 806 | |
| 807 | ath_dbg(common, CHAN_CTX, "Use channel contexts\n"); |
| 808 | } |
| 809 | #endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ |
| 810 | |
Sujith Manoharan | 7b6ef99 | 2013-12-18 09:53:19 +0530 | [diff] [blame] | 811 | static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 812 | { |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 813 | struct ath_hw *ah = sc->sc_ah; |
| 814 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 815 | |
Johannes Berg | 30686bf | 2015-06-02 21:39:54 +0200 | [diff] [blame] | 816 | ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES); |
| 817 | ieee80211_hw_set(hw, SUPPORTS_RC_TABLE); |
| 818 | ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); |
| 819 | ieee80211_hw_set(hw, SPECTRUM_MGMT); |
| 820 | ieee80211_hw_set(hw, PS_NULLFUNC_STACK); |
| 821 | ieee80211_hw_set(hw, SIGNAL_DBM); |
| 822 | ieee80211_hw_set(hw, RX_INCLUDES_FCS); |
| 823 | ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING); |
Felix Fietkau | f419c5f | 2015-07-22 13:06:12 +0200 | [diff] [blame] | 824 | ieee80211_hw_set(hw, SUPPORT_FAST_XMIT); |
Pawel Kulakowski | 50e81e2 | 2015-12-18 10:48:57 +0100 | [diff] [blame] | 825 | ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 826 | |
Sujith Manoharan | 8298383 | 2014-02-04 08:37:53 +0530 | [diff] [blame] | 827 | if (ath9k_ps_enable) |
Johannes Berg | 30686bf | 2015-06-02 21:39:54 +0200 | [diff] [blame] | 828 | ieee80211_hw_set(hw, SUPPORTS_PS); |
Sujith Manoharan | 8298383 | 2014-02-04 08:37:53 +0530 | [diff] [blame] | 829 | |
Oleksij Rempel | b0a1ae9 | 2013-05-24 20:30:59 +0200 | [diff] [blame] | 830 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { |
Johannes Berg | 30686bf | 2015-06-02 21:39:54 +0200 | [diff] [blame] | 831 | ieee80211_hw_set(hw, AMPDU_AGGREGATION); |
Oleksij Rempel | b0a1ae9 | 2013-05-24 20:30:59 +0200 | [diff] [blame] | 832 | |
| 833 | if (AR_SREV_9280_20_OR_LATER(ah)) |
| 834 | hw->radiotap_mcs_details |= |
| 835 | IEEE80211_RADIOTAP_MCS_HAVE_STBC; |
| 836 | } |
Luis R. Rodriguez | 5ffaf8a | 2010-02-02 11:58:33 -0500 | [diff] [blame] | 837 | |
John W. Linville | 3e6109c | 2011-01-05 09:39:17 -0500 | [diff] [blame] | 838 | if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt) |
Johannes Berg | 30686bf | 2015-06-02 21:39:54 +0200 | [diff] [blame] | 839 | ieee80211_hw_set(hw, MFP_CAPABLE); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 840 | |
Sujith Manoharan | fdcf1bd | 2014-09-05 08:03:14 +0530 | [diff] [blame] | 841 | hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR | |
| 842 | NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | |
| 843 | NL80211_FEATURE_P2P_GO_CTWIN; |
Felix Fietkau | ec26bcc | 2013-05-28 13:01:54 +0200 | [diff] [blame] | 844 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 845 | if (!config_enabled(CONFIG_ATH9K_TX99)) { |
| 846 | hw->wiphy->interface_modes = |
| 847 | BIT(NL80211_IFTYPE_P2P_GO) | |
| 848 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 849 | BIT(NL80211_IFTYPE_AP) | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 850 | BIT(NL80211_IFTYPE_STATION) | |
| 851 | BIT(NL80211_IFTYPE_ADHOC) | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 852 | BIT(NL80211_IFTYPE_MESH_POINT) | |
Jan Kaisrlik | 862a336 | 2015-09-17 14:03:46 +0200 | [diff] [blame] | 853 | BIT(NL80211_IFTYPE_WDS) | |
| 854 | BIT(NL80211_IFTYPE_OCB); |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 855 | |
Janusz.Dziedzic@tieto.com | eb61f9f | 2015-07-21 11:11:40 +0200 | [diff] [blame] | 856 | if (ath9k_is_chanctx_enabled()) |
| 857 | hw->wiphy->interface_modes |= |
| 858 | BIT(NL80211_IFTYPE_P2P_DEVICE); |
| 859 | |
Arnd Bergmann | 362210e | 2016-03-14 15:18:37 +0100 | [diff] [blame] | 860 | hw->wiphy->iface_combinations = if_comb; |
| 861 | hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 862 | } |
Felix Fietkau | 20c8e8d | 2012-04-17 02:40:07 +0200 | [diff] [blame] | 863 | |
Sujith Manoharan | 531671c | 2013-06-01 07:08:09 +0530 | [diff] [blame] | 864 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 865 | |
Jouni Malinen | cfdc9a8 | 2011-03-23 14:52:19 +0200 | [diff] [blame] | 866 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
Jouni Malinen | fd65623 | 2011-10-27 17:31:50 +0300 | [diff] [blame] | 867 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; |
Johannes Berg | 81ddbb5 | 2012-03-26 18:47:18 +0200 | [diff] [blame] | 868 | hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Simon Wunderlich | 6fac8bb | 2013-08-14 08:01:34 +0200 | [diff] [blame] | 869 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ; |
Simon Wunderlich | d074e8d | 2013-08-14 08:01:38 +0200 | [diff] [blame] | 870 | hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
Jouni Malinen | 7b4f663 | 2014-02-18 20:41:08 +0200 | [diff] [blame] | 871 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
Jouni Malinen | cfdc9a8 | 2011-03-23 14:52:19 +0200 | [diff] [blame] | 872 | |
Sujith Manoharan | 868caae | 2014-10-21 19:23:02 +0530 | [diff] [blame] | 873 | hw->queues = 4; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 874 | hw->max_rates = 4; |
Rajkumar Manoharan | 5f2f9e4 | 2014-06-26 16:54:41 +0530 | [diff] [blame] | 875 | hw->max_listen_interval = 10; |
Felix Fietkau | 6589651 | 2010-01-24 03:26:11 +0100 | [diff] [blame] | 876 | hw->max_rate_tries = 10; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 877 | hw->sta_data_size = sizeof(struct ath_node); |
| 878 | hw->vif_data_size = sizeof(struct ath_vif); |
Felix Fietkau | 029cd03 | 2015-09-24 16:59:46 +0200 | [diff] [blame] | 879 | hw->extra_tx_headroom = 4; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 880 | |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 881 | hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; |
| 882 | hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; |
| 883 | |
| 884 | /* single chain devices with rx diversity */ |
| 885 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) |
| 886 | hw->wiphy->available_antennas_rx = BIT(0) | BIT(1); |
| 887 | |
| 888 | sc->ant_rx = hw->wiphy->available_antennas_rx; |
| 889 | sc->ant_tx = hw->wiphy->available_antennas_tx; |
| 890 | |
Felix Fietkau | d465991 | 2010-10-14 16:02:39 +0200 | [diff] [blame] | 891 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 892 | hw->wiphy->bands[NL80211_BAND_2GHZ] = |
| 893 | &common->sbands[NL80211_BAND_2GHZ]; |
Felix Fietkau | d465991 | 2010-10-14 16:02:39 +0200 | [diff] [blame] | 894 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 895 | hw->wiphy->bands[NL80211_BAND_5GHZ] = |
| 896 | &common->sbands[NL80211_BAND_5GHZ]; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 897 | |
Sujith Manoharan | 868caae | 2014-10-21 19:23:02 +0530 | [diff] [blame] | 898 | #ifdef CONFIG_ATH9K_CHANNEL_CONTEXT |
| 899 | ath9k_set_mcc_capab(sc, hw); |
| 900 | #endif |
Sujith Manoharan | babaa80 | 2013-10-28 13:01:28 +0530 | [diff] [blame] | 901 | ath9k_init_wow(hw); |
Oleksij Rempel | b57ba3b | 2014-02-25 14:48:55 +0100 | [diff] [blame] | 902 | ath9k_cmn_reload_chainmask(ah); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 903 | |
| 904 | SET_IEEE80211_PERM_ADDR(hw, common->macaddr); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 905 | } |
| 906 | |
Pavel Roskin | eb93e89 | 2011-07-23 03:55:39 -0400 | [diff] [blame] | 907 | int ath9k_init_device(u16 devid, struct ath_softc *sc, |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 908 | const struct ath_bus_ops *bus_ops) |
| 909 | { |
| 910 | struct ieee80211_hw *hw = sc->hw; |
| 911 | struct ath_common *common; |
| 912 | struct ath_hw *ah; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 913 | int error = 0; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 914 | struct ath_regulatory *reg; |
| 915 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 916 | /* Bring up device */ |
Pavel Roskin | eb93e89 | 2011-07-23 03:55:39 -0400 | [diff] [blame] | 917 | error = ath9k_init_softc(devid, sc, bus_ops); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 918 | if (error) |
| 919 | return error; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 920 | |
| 921 | ah = sc->sc_ah; |
| 922 | common = ath9k_hw_common(ah); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 923 | ath9k_set_hw_capab(sc, hw); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 924 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 925 | /* Initialize regulatory */ |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 926 | error = ath_regd_init(&common->regulatory, sc->hw->wiphy, |
| 927 | ath9k_reg_notifier); |
| 928 | if (error) |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 929 | goto deinit; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 930 | |
| 931 | reg = &common->regulatory; |
| 932 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 933 | /* Setup TX DMA */ |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 934 | error = ath_tx_init(sc, ATH_TXBUF); |
| 935 | if (error != 0) |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 936 | goto deinit; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 937 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 938 | /* Setup RX DMA */ |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 939 | error = ath_rx_init(sc, ATH_RXBUF); |
| 940 | if (error != 0) |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 941 | goto deinit; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 942 | |
Felix Fietkau | babcbc2 | 2010-10-20 02:09:46 +0200 | [diff] [blame] | 943 | ath9k_init_txpower_limits(sc); |
| 944 | |
Felix Fietkau | 0cf55c2 | 2011-02-27 22:26:40 +0100 | [diff] [blame] | 945 | #ifdef CONFIG_MAC80211_LEDS |
| 946 | /* must be initialized before ieee80211_register_hw */ |
| 947 | sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, |
| 948 | IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink, |
| 949 | ARRAY_SIZE(ath9k_tpt_blink)); |
| 950 | #endif |
| 951 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 952 | /* Register with mac80211 */ |
| 953 | error = ieee80211_register_hw(hw); |
| 954 | if (error) |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 955 | goto rx_cleanup; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 956 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 957 | error = ath9k_init_debug(ah); |
| 958 | if (error) { |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 959 | ath_err(common, "Unable to create debugfs files\n"); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 960 | goto unregister; |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 961 | } |
| 962 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 963 | /* Handle world regulatory */ |
| 964 | if (!ath_is_world_regd(reg)) { |
| 965 | error = regulatory_hint(hw->wiphy, reg->alpha2); |
| 966 | if (error) |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 967 | goto debug_cleanup; |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 968 | } |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 969 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 970 | ath_init_leds(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 971 | ath_start_rfkill_poll(sc); |
| 972 | |
| 973 | return 0; |
| 974 | |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 975 | debug_cleanup: |
| 976 | ath9k_deinit_debug(sc); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 977 | unregister: |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 978 | ieee80211_unregister_hw(hw); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 979 | rx_cleanup: |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 980 | ath_rx_cleanup(sc); |
Felix Fietkau | b81950b1 | 2012-12-12 13:14:22 +0100 | [diff] [blame] | 981 | deinit: |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 982 | ath9k_deinit_softc(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 983 | return error; |
| 984 | } |
| 985 | |
| 986 | /*****************************/ |
| 987 | /* De-Initialization */ |
| 988 | /*****************************/ |
| 989 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 990 | static void ath9k_deinit_softc(struct ath_softc *sc) |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 991 | { |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 992 | int i = 0; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 993 | |
Sujith Manoharan | c7dd40c | 2014-08-22 20:39:30 +0530 | [diff] [blame] | 994 | ath9k_deinit_p2p(sc); |
Sujith Manoharan | 5908120 | 2012-02-22 12:40:21 +0530 | [diff] [blame] | 995 | ath9k_deinit_btcoex(sc); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 996 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 997 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) |
| 998 | if (ATH_TXQ_SETUP(sc, i)) |
| 999 | ath_tx_cleanupq(sc, &sc->tx.txq[i]); |
| 1000 | |
Felix Fietkau | bf3dac5 | 2013-11-11 22:23:33 +0100 | [diff] [blame] | 1001 | del_timer_sync(&sc->sleep_timer); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 1002 | ath9k_hw_deinit(sc->sc_ah); |
Zefir Kurtisi | 8e92d3f | 2012-04-03 17:15:50 +0200 | [diff] [blame] | 1003 | if (sc->dfs_detector != NULL) |
| 1004 | sc->dfs_detector->exit(sc->dfs_detector); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 1005 | |
Gabor Juhos | ab5c4f7 | 2012-12-10 15:30:28 +0100 | [diff] [blame] | 1006 | ath9k_eeprom_release(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1007 | } |
| 1008 | |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 1009 | void ath9k_deinit_device(struct ath_softc *sc) |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1010 | { |
| 1011 | struct ieee80211_hw *hw = sc->hw; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1012 | |
| 1013 | ath9k_ps_wakeup(sc); |
| 1014 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1015 | wiphy_rfkill_stop_polling(sc->hw->wiphy); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 1016 | ath_deinit_leds(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1017 | |
Rajkumar Manoharan | c7c1806 | 2011-01-27 18:39:38 +0530 | [diff] [blame] | 1018 | ath9k_ps_restore(sc); |
| 1019 | |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1020 | ath9k_deinit_debug(sc); |
Sujith Manoharan | 661d258 | 2015-01-30 19:05:26 +0530 | [diff] [blame] | 1021 | ath9k_deinit_wow(hw); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1022 | ieee80211_unregister_hw(hw); |
| 1023 | ath_rx_cleanup(sc); |
Sujith | 285f2dd | 2010-01-08 10:36:07 +0530 | [diff] [blame] | 1024 | ath9k_deinit_softc(sc); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1025 | } |
| 1026 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1027 | /************************/ |
| 1028 | /* Module Hooks */ |
| 1029 | /************************/ |
| 1030 | |
| 1031 | static int __init ath9k_init(void) |
| 1032 | { |
| 1033 | int error; |
| 1034 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1035 | error = ath_pci_init(); |
| 1036 | if (error < 0) { |
Joe Perches | 516304b | 2012-03-18 17:30:52 -0700 | [diff] [blame] | 1037 | pr_err("No PCI devices found, driver not installed\n"); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1038 | error = -ENODEV; |
Sujith Manoharan | 9e495a2 | 2014-02-06 10:22:55 +0530 | [diff] [blame] | 1039 | goto err_out; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | error = ath_ahb_init(); |
| 1043 | if (error < 0) { |
| 1044 | error = -ENODEV; |
| 1045 | goto err_pci_exit; |
| 1046 | } |
| 1047 | |
| 1048 | return 0; |
| 1049 | |
| 1050 | err_pci_exit: |
| 1051 | ath_pci_exit(); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1052 | err_out: |
| 1053 | return error; |
| 1054 | } |
| 1055 | module_init(ath9k_init); |
| 1056 | |
| 1057 | static void __exit ath9k_exit(void) |
| 1058 | { |
Rajkumar Manoharan | d584747 | 2010-12-20 14:39:51 +0530 | [diff] [blame] | 1059 | is_ath9k_unloaded = true; |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1060 | ath_ahb_exit(); |
| 1061 | ath_pci_exit(); |
Joe Perches | 516304b | 2012-03-18 17:30:52 -0700 | [diff] [blame] | 1062 | pr_info("%s: Driver unloaded\n", dev_info); |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 1063 | } |
| 1064 | module_exit(ath9k_exit); |