1 commit 065e0b64f71632f5ad7f00c102fde09c534cfbf0
2 Author: Felix Fietkau <nbd@openwrt.org>
3 Date: Tue Sep 30 11:00:33 2014 +0200
5 ath9k: fix getting tx duration for dynack
7 On AR9003, tx control and tx status are in separate descriptor rings.
8 Tx duration is extracted from the tx control descriptor data, which
9 ar9003_hw_proc_txdesc cannot access.
11 Fix getting the duration by adding a separate callback for it.
13 Acked-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
14 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
16 commit fdf9a4517b60d847b9bc0a30249efd96559fa450
17 Author: Felix Fietkau <nbd@openwrt.org>
18 Date: Tue Sep 9 09:48:30 2014 +0200
20 ath9k_hw: fix PLL clock initialization for newer SoC
22 On AR934x and newer SoC devices, the layout of the AR_RTC_PLL_CONTROL
23 register changed. This currently breaks at least 5/10 MHz operation.
24 AR933x uses the old layout.
26 It might also have been causing other stability issues because of the
27 different location of the PLL_BYPASS bit which needs to be set during
28 PLL clock initialization.
30 This patch also removes more instances of hardcoded register values in
31 favor of properly computed ones with the PLL_BYPASS bit added.
33 Reported-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
34 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
36 commit b6d1f51cd8bdc9d952147a960fbf1f261d8e4188
37 Author: Felix Fietkau <nbd@openwrt.org>
38 Date: Mon Sep 8 18:35:08 2014 +0200
40 ath9k_hw: reduce ANI spur immunity setting on HT40 extension channel
42 The cycpwr_thr1 value needs to be lower on the extension channel than on
43 the control channel, similar to how the register settings are programmed
46 Also drop the unnecessary check for HT40 - this register can always be
47 written. This patch has been reported to improve HT40 stability and
48 throughput in some environments.
50 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
52 commit 5ad2dfbaa19aa45d29184d30c8c5dae0e110074a
53 Author: Felix Fietkau <nbd@openwrt.org>
54 Date: Mon Sep 8 18:31:26 2014 +0200
56 Revert "ath9k_hw: reduce ANI firstep range for older chips"
58 This reverts commit 09efc56345be4146ab9fc87a55c837ed5d6ea1ab
60 I've received reports that this change is decreasing throughput in some
61 rare conditions on an AR9280 based device
63 Cc: stable@vger.kernel.org
64 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
66 commit 4c82fc569cf2f29e6c66d98ef4a1b0f3b6a98e9d
67 Author: Felix Fietkau <nbd@openwrt.org>
68 Date: Sat Sep 27 22:39:27 2014 +0200
70 ath9k_hw: disable hardware ad-hoc flag on ar934x rev 3
72 On AR934x rev 3, settin the ad-hoc flag completely messes up hardware
73 state - beacons get stuck, almost no packets make it out, hardware is
76 When leaving out that flag and setting up the hw like in AP mode, TSF
77 timers won't be automatically synced, but at least the rest works.
79 AR934x rev 2 and older are not affected by this bug
81 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
83 commit ecfb4b3fff006372ac5c40871f9bb182fd00444f
84 Author: Felix Fietkau <nbd@openwrt.org>
85 Date: Sat Sep 27 22:15:43 2014 +0200
87 ath9k: use ah->get_mac_revision for all SoC devices if available
89 It is needed for AR934x as well
91 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
93 commit c11113bc25df22898fb995d3205bdc4f27c98073
94 Author: Felix Fietkau <nbd@openwrt.org>
95 Date: Sat Sep 27 18:04:58 2014 +0200
97 ath5k: add missing include for debug code
99 Needed for calling vmalloc()/vfree()
101 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
103 commit 83f76a9f9a42773c7eef90bb86b4b2c16b0b3755
104 Author: Felix Fietkau <nbd@openwrt.org>
105 Date: Sat Sep 27 15:58:51 2014 +0200
107 ath5k: fix AHB kconfig dependency
109 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
111 commit ddd67f2a5cfd73fad4b78190025402d419b9f0a9
112 Author: Felix Fietkau <nbd@openwrt.org>
113 Date: Sat Sep 27 15:57:09 2014 +0200
115 Revert "ath5k: Remove AHB bus support"
117 This reverts commit 093ec3c5337434f40d77c1af06c139da3e5ba6dc.
119 --- a/drivers/net/wireless/ath/ath5k/Kconfig
120 +++ b/drivers/net/wireless/ath/ath5k/Kconfig
121 @@ -2,12 +2,14 @@ config ATH5K
122 tristate "Atheros 5xxx wireless cards support"
124 depends on PCI && MAC80211
125 + depends on (PCI || ATHEROS_AR231X) && MAC80211
128 select BACKPORT_LEDS_CLASS
129 select BACKPORT_NEW_LEDS
130 select BACKPORT_AVERAGE
132 + select ATH5K_AHB if ATHEROS_AR231X
133 + select ATH5K_PCI if !ATHEROS_AR231X
135 This module adds support for wireless adapters based on
136 Atheros 5xxx chipset.
137 @@ -52,9 +54,16 @@ config ATH5K_TRACER
142 + bool "Atheros 5xxx AHB bus support"
143 + depends on ATHEROS_AR231X
145 + This adds support for WiSoC type chipsets of the 5xxx Atheros
149 bool "Atheros 5xxx PCI bus support"
151 + depends on !ATHEROS_AR231X
153 This adds support for PCI type chipsets of the 5xxx Atheros
156 +++ b/drivers/net/wireless/ath/ath5k/ahb.c
159 + * Copyright (c) 2008-2009 Atheros Communications Inc.
160 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
161 + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
163 + * Permission to use, copy, modify, and/or distribute this software for any
164 + * purpose with or without fee is hereby granted, provided that the above
165 + * copyright notice and this permission notice appear in all copies.
167 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
168 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
169 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
170 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
171 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
172 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
173 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
176 +#include <linux/nl80211.h>
177 +#include <linux/platform_device.h>
178 +#include <linux/etherdevice.h>
179 +#include <linux/export.h>
180 +#include <ar231x_platform.h>
186 +/* return bus cachesize in 4B word units */
187 +static void ath5k_ahb_read_cachesize(struct ath_common *common, int *csz)
189 + *csz = L1_CACHE_BYTES >> 2;
193 +ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
195 + struct ath5k_hw *ah = common->priv;
196 + struct platform_device *pdev = to_platform_device(ah->dev);
197 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
198 + u16 *eeprom, *eeprom_end;
200 + eeprom = (u16 *) bcfg->radio;
201 + eeprom_end = ((void *) bcfg->config) + BOARD_CONFIG_BUFSZ;
204 + if (eeprom > eeprom_end)
211 +int ath5k_hw_read_srev(struct ath5k_hw *ah)
213 + struct platform_device *pdev = to_platform_device(ah->dev);
214 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
215 + ah->ah_mac_srev = bcfg->devid;
219 +static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
221 + struct platform_device *pdev = to_platform_device(ah->dev);
222 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
225 + if (to_platform_device(ah->dev)->id == 0)
226 + cfg_mac = bcfg->config->wlan0_mac;
228 + cfg_mac = bcfg->config->wlan1_mac;
230 + memcpy(mac, cfg_mac, ETH_ALEN);
234 +static const struct ath_bus_ops ath_ahb_bus_ops = {
235 + .ath_bus_type = ATH_AHB,
236 + .read_cachesize = ath5k_ahb_read_cachesize,
237 + .eeprom_read = ath5k_ahb_eeprom_read,
238 + .eeprom_read_mac = ath5k_ahb_eeprom_read_mac,
242 +static int ath_ahb_probe(struct platform_device *pdev)
244 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
245 + struct ath5k_hw *ah;
246 + struct ieee80211_hw *hw;
247 + struct resource *res;
253 + if (!dev_get_platdata(&pdev->dev)) {
254 + dev_err(&pdev->dev, "no platform data specified\n");
259 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
261 + dev_err(&pdev->dev, "no memory resource found\n");
266 + mem = ioremap_nocache(res->start, resource_size(res));
268 + dev_err(&pdev->dev, "ioremap failed\n");
273 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
275 + dev_err(&pdev->dev, "no IRQ resource found\n");
282 + hw = ieee80211_alloc_hw(sizeof(struct ath5k_hw), &ath5k_hw_ops);
284 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
291 + ah->dev = &pdev->dev;
294 + ah->devid = bcfg->devid;
296 + if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
297 + /* Enable WMAC AHB arbitration */
298 + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
299 + reg |= AR5K_AR2315_AHB_ARB_CTL_WLAN;
300 + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
302 + /* Enable global WMAC swapping */
303 + reg = ioread32((void __iomem *) AR5K_AR2315_BYTESWAP);
304 + reg |= AR5K_AR2315_BYTESWAP_WMAC;
305 + iowrite32(reg, (void __iomem *) AR5K_AR2315_BYTESWAP);
307 + /* Enable WMAC DMA access (assuming 5312 or 231x*/
308 + /* TODO: check other platforms */
309 + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE);
310 + if (to_platform_device(ah->dev)->id == 0)
311 + reg |= AR5K_AR5312_ENABLE_WLAN0;
313 + reg |= AR5K_AR5312_ENABLE_WLAN1;
314 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
317 + * On a dual-band AR5312, the multiband radio is only
318 + * used as pass-through. Disable 2 GHz support in the
321 + if (to_platform_device(ah->dev)->id == 0 &&
322 + (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) ==
323 + (BD_WLAN1 | BD_WLAN0))
324 + ah->ah_capabilities.cap_needs_2GHz_ovr = true;
326 + ah->ah_capabilities.cap_needs_2GHz_ovr = false;
329 + ret = ath5k_init_ah(ah, &ath_ahb_bus_ops);
331 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
336 + platform_set_drvdata(pdev, hw);
341 + ieee80211_free_hw(hw);
348 +static int ath_ahb_remove(struct platform_device *pdev)
350 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
351 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
352 + struct ath5k_hw *ah;
360 + if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
361 + /* Disable WMAC AHB arbitration */
362 + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
363 + reg &= ~AR5K_AR2315_AHB_ARB_CTL_WLAN;
364 + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
366 + /*Stop DMA access */
367 + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE);
368 + if (to_platform_device(ah->dev)->id == 0)
369 + reg &= ~AR5K_AR5312_ENABLE_WLAN0;
371 + reg &= ~AR5K_AR5312_ENABLE_WLAN1;
372 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
375 + ath5k_deinit_ah(ah);
376 + iounmap(ah->iobase);
377 + ieee80211_free_hw(hw);
382 +static struct platform_driver ath_ahb_driver = {
383 + .probe = ath_ahb_probe,
384 + .remove = ath_ahb_remove,
386 + .name = "ar231x-wmac",
387 + .owner = THIS_MODULE,
391 +module_platform_driver(ath_ahb_driver);
392 --- a/drivers/net/wireless/ath/ath5k/ath5k.h
393 +++ b/drivers/net/wireless/ath/ath5k/ath5k.h
394 @@ -1647,6 +1647,32 @@ static inline struct ath_regulatory *ath
395 return &(ath5k_hw_common(ah)->regulatory);
398 +#ifdef CONFIG_ATHEROS_AR231X
399 +#define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000)
401 +static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
403 + /* On AR2315 and AR2317 the PCI clock domain registers
404 + * are outside of the WMAC register space */
405 + if (unlikely((reg >= 0x4000) && (reg < 0x5000) &&
406 + (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
407 + return AR5K_AR2315_PCI_BASE + reg;
409 + return ah->iobase + reg;
412 +static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
414 + return ioread32(ath5k_ahb_reg(ah, reg));
417 +static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
419 + iowrite32(val, ath5k_ahb_reg(ah, reg));
424 static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
426 return ioread32(ah->iobase + reg);
427 @@ -1657,6 +1683,8 @@ static inline void ath5k_hw_reg_write(st
428 iowrite32(val, ah->iobase + reg);
433 static inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah)
435 return ath5k_hw_common(ah)->bus_ops->ath_bus_type;
436 --- a/drivers/net/wireless/ath/ath5k/base.c
437 +++ b/drivers/net/wireless/ath/ath5k/base.c
438 @@ -99,6 +99,15 @@ static int ath5k_reset(struct ath5k_hw *
441 static const struct ath5k_srev_name srev_names[] = {
442 +#ifdef CONFIG_ATHEROS_AR231X
443 + { "5312", AR5K_VERSION_MAC, AR5K_SREV_AR5312_R2 },
444 + { "5312", AR5K_VERSION_MAC, AR5K_SREV_AR5312_R7 },
445 + { "2313", AR5K_VERSION_MAC, AR5K_SREV_AR2313_R8 },
446 + { "2315", AR5K_VERSION_MAC, AR5K_SREV_AR2315_R6 },
447 + { "2315", AR5K_VERSION_MAC, AR5K_SREV_AR2315_R7 },
448 + { "2317", AR5K_VERSION_MAC, AR5K_SREV_AR2317_R1 },
449 + { "2317", AR5K_VERSION_MAC, AR5K_SREV_AR2317_R2 },
451 { "5210", AR5K_VERSION_MAC, AR5K_SREV_AR5210 },
452 { "5311", AR5K_VERSION_MAC, AR5K_SREV_AR5311 },
453 { "5311A", AR5K_VERSION_MAC, AR5K_SREV_AR5311A },
454 @@ -117,6 +126,7 @@ static const struct ath5k_srev_name srev
455 { "5418", AR5K_VERSION_MAC, AR5K_SREV_AR5418 },
456 { "2425", AR5K_VERSION_MAC, AR5K_SREV_AR2425 },
457 { "2417", AR5K_VERSION_MAC, AR5K_SREV_AR2417 },
459 { "xxxxx", AR5K_VERSION_MAC, AR5K_SREV_UNKNOWN },
460 { "5110", AR5K_VERSION_RAD, AR5K_SREV_RAD_5110 },
461 { "5111", AR5K_VERSION_RAD, AR5K_SREV_RAD_5111 },
462 @@ -132,6 +142,10 @@ static const struct ath5k_srev_name srev
463 { "5413", AR5K_VERSION_RAD, AR5K_SREV_RAD_5413 },
464 { "5424", AR5K_VERSION_RAD, AR5K_SREV_RAD_5424 },
465 { "5133", AR5K_VERSION_RAD, AR5K_SREV_RAD_5133 },
466 +#ifdef CONFIG_ATHEROS_AR231X
467 + { "2316", AR5K_VERSION_RAD, AR5K_SREV_RAD_2316 },
468 + { "2317", AR5K_VERSION_RAD, AR5K_SREV_RAD_2317 },
470 { "xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN },
473 --- a/drivers/net/wireless/ath/ath5k/led.c
474 +++ b/drivers/net/wireless/ath/ath5k/led.c
475 @@ -163,14 +163,20 @@ int ath5k_init_leds(struct ath5k_hw *ah)
478 struct ieee80211_hw *hw = ah->hw;
479 +#ifndef CONFIG_ATHEROS_AR231X
480 struct pci_dev *pdev = ah->pdev;
482 char name[ATH5K_LED_MAX_NAME_LEN + 1];
483 const struct pci_device_id *match;
488 +#ifdef CONFIG_ATHEROS_AR231X
491 match = pci_match_id(&ath5k_led_devices[0], pdev);
494 __set_bit(ATH_STAT_LEDSOFT, ah->status);
495 ah->led_pin = ATH_PIN(match->driver_data);
496 --- a/drivers/net/wireless/ath/ath5k/debug.c
497 +++ b/drivers/net/wireless/ath/ath5k/debug.c
500 #include <linux/seq_file.h>
501 #include <linux/list.h>
502 +#include <linux/vmalloc.h>
506 --- a/drivers/net/wireless/ath/ath9k/hw.c
507 +++ b/drivers/net/wireless/ath/ath9k/hw.c
508 @@ -222,31 +222,28 @@ static void ath9k_hw_read_revisions(stru
512 + if (ah->get_mac_revision)
513 + ah->hw_version.macRev = ah->get_mac_revision();
515 switch (ah->hw_version.devid) {
516 case AR5416_AR9100_DEVID:
517 ah->hw_version.macVersion = AR_SREV_VERSION_9100;
519 case AR9300_DEVID_AR9330:
520 ah->hw_version.macVersion = AR_SREV_VERSION_9330;
521 - if (ah->get_mac_revision) {
522 - ah->hw_version.macRev = ah->get_mac_revision();
524 + if (!ah->get_mac_revision) {
525 val = REG_READ(ah, AR_SREV);
526 ah->hw_version.macRev = MS(val, AR_SREV_REVISION2);
529 case AR9300_DEVID_AR9340:
530 ah->hw_version.macVersion = AR_SREV_VERSION_9340;
531 - val = REG_READ(ah, AR_SREV);
532 - ah->hw_version.macRev = MS(val, AR_SREV_REVISION2);
534 case AR9300_DEVID_QCA955X:
535 ah->hw_version.macVersion = AR_SREV_VERSION_9550;
537 case AR9300_DEVID_AR953X:
538 ah->hw_version.macVersion = AR_SREV_VERSION_9531;
539 - if (ah->get_mac_revision)
540 - ah->hw_version.macRev = ah->get_mac_revision();
544 @@ -704,6 +701,8 @@ static void ath9k_hw_init_pll(struct ath
548 + pll = ath9k_hw_compute_pll_control(ah, chan);
550 if (AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
551 /* program BB PLL ki and kd value, ki=0x4, kd=0x40 */
552 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
553 @@ -754,7 +753,8 @@ static void ath9k_hw_init_pll(struct ath
554 REG_RMW_FIELD(ah, AR_CH0_DDR_DPLL3,
555 AR_CH0_DPLL3_PHASE_SHIFT, 0x1);
557 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
558 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
559 + pll | AR_RTC_9300_PLL_BYPASS);
562 /* program refdiv, nint, frac to RTC register */
563 @@ -770,7 +770,8 @@ static void ath9k_hw_init_pll(struct ath
564 } else if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
565 u32 regval, pll2_divint, pll2_divfrac, refdiv;
567 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
568 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
569 + pll | AR_RTC_9300_SOC_PLL_BYPASS);
572 REG_SET_BIT(ah, AR_PHY_PLL_MODE, 0x1 << 16);
573 @@ -843,7 +844,6 @@ static void ath9k_hw_init_pll(struct ath
577 - pll = ath9k_hw_compute_pll_control(ah, chan);
578 if (AR_SREV_9565(ah))
580 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
581 @@ -1192,9 +1192,12 @@ static void ath9k_hw_set_operating_mode(
584 case NL80211_IFTYPE_ADHOC:
585 - set |= AR_STA_ID1_ADHOC;
586 - REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
588 + if (!AR_SREV_9340_13(ah)) {
589 + set |= AR_STA_ID1_ADHOC;
590 + REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
594 case NL80211_IFTYPE_MESH_POINT:
595 case NL80211_IFTYPE_AP:
596 set |= AR_STA_ID1_STA_AP;
597 --- a/drivers/net/wireless/ath/ath9k/reg.h
598 +++ b/drivers/net/wireless/ath/ath9k/reg.h
600 #define AR_SREV_9340(_ah) \
601 (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9340))
603 +#define AR_SREV_9340_13(_ah) \
604 + (AR_SREV_9340((_ah)) && \
605 + ((_ah)->hw_version.macRev == AR_SREV_REVISION_9340_13))
607 #define AR_SREV_9340_13_OR_LATER(_ah) \
608 (AR_SREV_9340((_ah)) && \
609 ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9340_13))
610 @@ -1240,12 +1244,23 @@ enum {
611 #define AR_CH0_DPLL3_PHASE_SHIFT_S 23
612 #define AR_PHY_CCA_NOM_VAL_2GHZ -118
614 +#define AR_RTC_9300_SOC_PLL_DIV_INT 0x0000003f
615 +#define AR_RTC_9300_SOC_PLL_DIV_INT_S 0
616 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC 0x000fffc0
617 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC_S 6
618 +#define AR_RTC_9300_SOC_PLL_REFDIV 0x01f00000
619 +#define AR_RTC_9300_SOC_PLL_REFDIV_S 20
620 +#define AR_RTC_9300_SOC_PLL_CLKSEL 0x06000000
621 +#define AR_RTC_9300_SOC_PLL_CLKSEL_S 25
622 +#define AR_RTC_9300_SOC_PLL_BYPASS 0x08000000
624 #define AR_RTC_9300_PLL_DIV 0x000003ff
625 #define AR_RTC_9300_PLL_DIV_S 0
626 #define AR_RTC_9300_PLL_REFDIV 0x00003C00
627 #define AR_RTC_9300_PLL_REFDIV_S 10
628 #define AR_RTC_9300_PLL_CLKSEL 0x0000C000
629 #define AR_RTC_9300_PLL_CLKSEL_S 14
630 +#define AR_RTC_9300_PLL_BYPASS 0x00010000
632 #define AR_RTC_9160_PLL_DIV 0x000003ff
633 #define AR_RTC_9160_PLL_DIV_S 0
634 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
635 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
636 @@ -1004,9 +1004,11 @@ static bool ar5008_hw_ani_control_new(st
637 case ATH9K_ANI_FIRSTEP_LEVEL:{
642 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
643 AR_PHY_FIND_SIG_FIRSTEP, value);
644 + REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
645 + AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
647 if (level != aniState->firstepLevel) {
649 @@ -1040,9 +1042,8 @@ static bool ar5008_hw_ani_control_new(st
650 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
651 AR_PHY_TIMING5_CYCPWR_THR1, value);
653 - if (IS_CHAN_HT40(ah->curchan))
654 - REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
655 - AR_PHY_EXT_TIMING5_CYCPWR_THR1, value);
656 + REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
657 + AR_PHY_EXT_TIMING5_CYCPWR_THR1, value - 1);
659 if (level != aniState->spurImmunityLevel) {
661 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
662 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
663 @@ -517,6 +517,23 @@ static void ar9003_hw_spur_mitigate(stru
664 ar9003_hw_spur_mitigate_ofdm(ah, chan);
667 +static u32 ar9003_hw_compute_pll_control_soc(struct ath_hw *ah,
668 + struct ath9k_channel *chan)
672 + pll = SM(0x5, AR_RTC_9300_SOC_PLL_REFDIV);
674 + if (chan && IS_CHAN_HALF_RATE(chan))
675 + pll |= SM(0x1, AR_RTC_9300_SOC_PLL_CLKSEL);
676 + else if (chan && IS_CHAN_QUARTER_RATE(chan))
677 + pll |= SM(0x2, AR_RTC_9300_SOC_PLL_CLKSEL);
679 + pll |= SM(0x2c, AR_RTC_9300_SOC_PLL_DIV_INT);
684 static u32 ar9003_hw_compute_pll_control(struct ath_hw *ah,
685 struct ath9k_channel *chan)
687 @@ -1781,7 +1798,12 @@ void ar9003_hw_attach_phy_ops(struct ath
689 priv_ops->rf_set_freq = ar9003_hw_set_channel;
690 priv_ops->spur_mitigate_freq = ar9003_hw_spur_mitigate;
691 - priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
693 + if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah))
694 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control_soc;
696 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
698 priv_ops->set_channel_regs = ar9003_hw_set_channel_regs;
699 priv_ops->init_bb = ar9003_hw_init_bb;
700 priv_ops->process_ini = ar9003_hw_process_ini;
701 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
702 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
703 @@ -381,16 +381,27 @@ static int ar9002_hw_proc_txdesc(struct
704 ts->evm1 = ads->AR_TxEVM1;
705 ts->evm2 = ads->AR_TxEVM2;
707 - status = ACCESS_ONCE(ads->ds_ctl4);
708 - ts->duration[0] = MS(status, AR_PacketDur0);
709 - ts->duration[1] = MS(status, AR_PacketDur1);
710 - status = ACCESS_ONCE(ads->ds_ctl5);
711 - ts->duration[2] = MS(status, AR_PacketDur2);
712 - ts->duration[3] = MS(status, AR_PacketDur3);
717 +static int ar9002_hw_get_duration(struct ath_hw *ah, const void *ds, int index)
719 + struct ar5416_desc *ads = AR5416DESC(ds);
723 + return MS(ACCESS_ONCE(ads->ds_ctl4), AR_PacketDur0);
725 + return MS(ACCESS_ONCE(ads->ds_ctl4), AR_PacketDur1);
727 + return MS(ACCESS_ONCE(ads->ds_ctl5), AR_PacketDur2);
729 + return MS(ACCESS_ONCE(ads->ds_ctl5), AR_PacketDur3);
735 void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds,
738 @@ -413,4 +424,5 @@ void ar9002_hw_attach_mac_ops(struct ath
739 ops->get_isr = ar9002_hw_get_isr;
740 ops->set_txdesc = ar9002_set_txdesc;
741 ops->proc_txdesc = ar9002_hw_proc_txdesc;
742 + ops->get_duration = ar9002_hw_get_duration;
744 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
745 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
746 @@ -355,11 +355,9 @@ static int ar9003_hw_proc_txdesc(struct
747 struct ath_tx_status *ts)
749 struct ar9003_txs *ads;
750 - struct ar9003_txc *adc;
753 ads = &ah->ts_ring[ah->ts_tail];
754 - adc = (struct ar9003_txc *)ads;
756 status = ACCESS_ONCE(ads->status8);
757 if ((status & AR_TxDone) == 0)
758 @@ -428,18 +426,29 @@ static int ar9003_hw_proc_txdesc(struct
759 ts->ts_rssi_ext1 = MS(status, AR_TxRSSIAnt11);
760 ts->ts_rssi_ext2 = MS(status, AR_TxRSSIAnt12);
762 - status = ACCESS_ONCE(adc->ctl15);
763 - ts->duration[0] = MS(status, AR_PacketDur0);
764 - ts->duration[1] = MS(status, AR_PacketDur1);
765 - status = ACCESS_ONCE(adc->ctl16);
766 - ts->duration[2] = MS(status, AR_PacketDur2);
767 - ts->duration[3] = MS(status, AR_PacketDur3);
769 memset(ads, 0, sizeof(*ads));
774 +static int ar9003_hw_get_duration(struct ath_hw *ah, const void *ds, int index)
776 + const struct ar9003_txc *adc = ds;
780 + return MS(ACCESS_ONCE(adc->ctl15), AR_PacketDur0);
782 + return MS(ACCESS_ONCE(adc->ctl15), AR_PacketDur1);
784 + return MS(ACCESS_ONCE(adc->ctl16), AR_PacketDur2);
786 + return MS(ACCESS_ONCE(adc->ctl16), AR_PacketDur3);
792 void ar9003_hw_attach_mac_ops(struct ath_hw *hw)
794 struct ath_hw_ops *ops = ath9k_hw_ops(hw);
795 @@ -449,6 +458,7 @@ void ar9003_hw_attach_mac_ops(struct ath
796 ops->get_isr = ar9003_hw_get_isr;
797 ops->set_txdesc = ar9003_set_txdesc;
798 ops->proc_txdesc = ar9003_hw_proc_txdesc;
799 + ops->get_duration = ar9003_hw_get_duration;
802 void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
803 --- a/drivers/net/wireless/ath/ath9k/dynack.c
804 +++ b/drivers/net/wireless/ath/ath9k/dynack.c
805 @@ -202,7 +202,7 @@ void ath_dynack_sample_tx_ts(struct ath_
806 ridx = ts->ts_rateindex;
808 da->st_rbf.ts[da->st_rbf.t_rb].tstamp = ts->ts_tstamp;
809 - da->st_rbf.ts[da->st_rbf.t_rb].dur = ts->duration[ts->ts_rateindex];
810 + da->st_rbf.ts[da->st_rbf.t_rb].dur = ts->duration;
811 ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_dest, hdr->addr1);
812 ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_src, hdr->addr2);
814 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
815 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
816 @@ -67,6 +67,12 @@ static inline int ath9k_hw_txprocdesc(st
817 return ath9k_hw_ops(ah)->proc_txdesc(ah, ds, ts);
820 +static inline int ath9k_hw_get_duration(struct ath_hw *ah, const void *ds,
823 + return ath9k_hw_ops(ah)->get_duration(ah, ds, index);
826 static inline void ath9k_hw_antdiv_comb_conf_get(struct ath_hw *ah,
827 struct ath_hw_antcomb_conf *antconf)
829 --- a/drivers/net/wireless/ath/ath9k/hw.h
830 +++ b/drivers/net/wireless/ath/ath9k/hw.h
831 @@ -691,6 +691,7 @@ struct ath_hw_ops {
832 struct ath_tx_info *i);
833 int (*proc_txdesc)(struct ath_hw *ah, void *ds,
834 struct ath_tx_status *ts);
835 + int (*get_duration)(struct ath_hw *ah, const void *ds, int index);
836 void (*antdiv_comb_conf_get)(struct ath_hw *ah,
837 struct ath_hw_antcomb_conf *antconf);
838 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
839 --- a/drivers/net/wireless/ath/ath9k/mac.h
840 +++ b/drivers/net/wireless/ath/ath9k/mac.h
841 @@ -121,7 +121,7 @@ struct ath_tx_status {
849 struct ath_rx_status {
850 --- a/drivers/net/wireless/ath/ath9k/xmit.c
851 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
852 @@ -683,6 +683,8 @@ static void ath_tx_process_buffer(struct
853 if (bf_is_ampdu_not_probing(bf))
854 txq->axq_ampdu_depth--;
856 + ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc,
858 if (!bf_isampdu(bf)) {
860 info = IEEE80211_SKB_CB(bf->bf_mpdu);