diff options
-rw-r--r-- | drivers/net/wireless/ath/ath.h | 6 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 13 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 32 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.h | 17 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 42 |
5 files changed, 63 insertions, 47 deletions
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 7589b2aa030b..38be4279affc 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h | |||
@@ -39,6 +39,11 @@ struct ath_regulatory { | |||
39 | struct reg_dmn_pair_mapping *regpair; | 39 | struct reg_dmn_pair_mapping *regpair; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | struct ath_ops { | ||
43 | unsigned int (*read)(void *, u32 reg_offset); | ||
44 | void (*write)(void *, u32 val, u32 reg_offset); | ||
45 | }; | ||
46 | |||
42 | struct ath_common { | 47 | struct ath_common { |
43 | u16 cachelsz; | 48 | u16 cachelsz; |
44 | u16 curaid; | 49 | u16 curaid; |
@@ -46,6 +51,7 @@ struct ath_common { | |||
46 | u8 curbssid[ETH_ALEN]; | 51 | u8 curbssid[ETH_ALEN]; |
47 | u8 bssidmask[ETH_ALEN]; | 52 | u8 bssidmask[ETH_ALEN]; |
48 | struct ath_regulatory regulatory; | 53 | struct ath_regulatory regulatory; |
54 | struct ath_ops *ops; | ||
49 | }; | 55 | }; |
50 | 56 | ||
51 | struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, | 57 | struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, |
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 0962505430e2..7c740cf50f7c 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -646,16 +646,6 @@ int ath_get_hal_qnum(u16 queue, struct ath_softc *sc); | |||
646 | int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc); | 646 | int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc); |
647 | int ath_cabq_update(struct ath_softc *); | 647 | int ath_cabq_update(struct ath_softc *); |
648 | 648 | ||
649 | static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) | ||
650 | { | ||
651 | return &ah->common; | ||
652 | } | ||
653 | |||
654 | static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah) | ||
655 | { | ||
656 | return &(ath9k_hw_common(ah)->regulatory); | ||
657 | } | ||
658 | |||
659 | static inline void ath_read_cachesize(struct ath_softc *sc, int *csz) | 649 | static inline void ath_read_cachesize(struct ath_softc *sc, int *csz) |
660 | { | 650 | { |
661 | sc->bus_ops->read_cachesize(sc, csz); | 651 | sc->bus_ops->read_cachesize(sc, csz); |
@@ -718,8 +708,5 @@ bool ath9k_wiphy_scanning(struct ath_softc *sc); | |||
718 | void ath9k_wiphy_work(struct work_struct *work); | 708 | void ath9k_wiphy_work(struct work_struct *work); |
719 | bool ath9k_all_wiphys_idle(struct ath_softc *sc); | 709 | bool ath9k_all_wiphys_idle(struct ath_softc *sc); |
720 | 710 | ||
721 | void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val); | ||
722 | unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset); | ||
723 | |||
724 | int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype); | 711 | int ath_tx_get_qnum(struct ath_softc *sc, int qtype, int haltype); |
725 | #endif /* ATH9K_H */ | 712 | #endif /* ATH9K_H */ |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index a3b1ce32cfcb..0ad25987d85c 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -81,38 +81,6 @@ static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs) | |||
81 | return ath9k_hw_mac_clks(ah, usecs); | 81 | return ath9k_hw_mac_clks(ah, usecs); |
82 | } | 82 | } |
83 | 83 | ||
84 | /* | ||
85 | * Read and write, they both share the same lock. We do this to serialize | ||
86 | * reads and writes on Atheros 802.11n PCI devices only. This is required | ||
87 | * as the FIFO on these devices can only accept sanely 2 requests. After | ||
88 | * that the device goes bananas. Serializing the reads/writes prevents this | ||
89 | * from happening. | ||
90 | */ | ||
91 | |||
92 | void ath9k_iowrite32(struct ath_hw *ah, u32 reg_offset, u32 val) | ||
93 | { | ||
94 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { | ||
95 | unsigned long flags; | ||
96 | spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); | ||
97 | iowrite32(val, ah->ah_sc->mem + reg_offset); | ||
98 | spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); | ||
99 | } else | ||
100 | iowrite32(val, ah->ah_sc->mem + reg_offset); | ||
101 | } | ||
102 | |||
103 | unsigned int ath9k_ioread32(struct ath_hw *ah, u32 reg_offset) | ||
104 | { | ||
105 | u32 val; | ||
106 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { | ||
107 | unsigned long flags; | ||
108 | spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); | ||
109 | val = ioread32(ah->ah_sc->mem + reg_offset); | ||
110 | spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); | ||
111 | } else | ||
112 | val = ioread32(ah->ah_sc->mem + reg_offset); | ||
113 | return val; | ||
114 | } | ||
115 | |||
116 | bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) | 84 | bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) |
117 | { | 85 | { |
118 | int i; | 86 | int i; |
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index f460a06b86ac..ae351a183416 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h | |||
@@ -51,8 +51,11 @@ | |||
51 | #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab | 51 | #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab |
52 | 52 | ||
53 | /* Register read/write primitives */ | 53 | /* Register read/write primitives */ |
54 | #define REG_WRITE(_ah, _reg, _val) ath9k_iowrite32((_ah), (_reg), (_val)) | 54 | #define REG_WRITE(_ah, _reg, _val) \ |
55 | #define REG_READ(_ah, _reg) ath9k_ioread32((_ah), (_reg)) | 55 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
56 | |||
57 | #define REG_READ(_ah, _reg) \ | ||
58 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) | ||
56 | 59 | ||
57 | #define SM(_v, _f) (((_v) << _f##_S) & _f) | 60 | #define SM(_v, _f) (((_v) << _f##_S) & _f) |
58 | #define MS(_v, _f) (((_v) & _f) >> _f##_S) | 61 | #define MS(_v, _f) (((_v) & _f) >> _f##_S) |
@@ -588,6 +591,16 @@ struct ath_hw { | |||
588 | struct ath_gen_timer_table hw_gen_timers; | 591 | struct ath_gen_timer_table hw_gen_timers; |
589 | }; | 592 | }; |
590 | 593 | ||
594 | static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) | ||
595 | { | ||
596 | return &ah->common; | ||
597 | } | ||
598 | |||
599 | static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah) | ||
600 | { | ||
601 | return &(ath9k_hw_common(ah)->regulatory); | ||
602 | } | ||
603 | |||
591 | /* Initialization, Detach, Reset */ | 604 | /* Initialization, Detach, Reset */ |
592 | const char *ath9k_hw_probe(u16 vendorid, u16 devid); | 605 | const char *ath9k_hw_probe(u16 vendorid, u16 devid); |
593 | void ath9k_hw_detach(struct ath_hw *ah); | 606 | void ath9k_hw_detach(struct ath_hw *ah); |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 27ab378ae535..4a85f6ccb509 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -1490,6 +1490,47 @@ static int ath_init_btcoex_timer(struct ath_softc *sc) | |||
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | /* | 1492 | /* |
1493 | * Read and write, they both share the same lock. We do this to serialize | ||
1494 | * reads and writes on Atheros 802.11n PCI devices only. This is required | ||
1495 | * as the FIFO on these devices can only accept sanely 2 requests. After | ||
1496 | * that the device goes bananas. Serializing the reads/writes prevents this | ||
1497 | * from happening. | ||
1498 | */ | ||
1499 | |||
1500 | static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) | ||
1501 | { | ||
1502 | struct ath_hw *ah = (struct ath_hw *) hw_priv; | ||
1503 | |||
1504 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { | ||
1505 | unsigned long flags; | ||
1506 | spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); | ||
1507 | iowrite32(val, ah->ah_sc->mem + reg_offset); | ||
1508 | spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); | ||
1509 | } else | ||
1510 | iowrite32(val, ah->ah_sc->mem + reg_offset); | ||
1511 | } | ||
1512 | |||
1513 | static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) | ||
1514 | { | ||
1515 | struct ath_hw *ah = (struct ath_hw *) hw_priv; | ||
1516 | u32 val; | ||
1517 | |||
1518 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { | ||
1519 | unsigned long flags; | ||
1520 | spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); | ||
1521 | val = ioread32(ah->ah_sc->mem + reg_offset); | ||
1522 | spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); | ||
1523 | } else | ||
1524 | val = ioread32(ah->ah_sc->mem + reg_offset); | ||
1525 | return val; | ||
1526 | } | ||
1527 | |||
1528 | static struct ath_ops ath9k_common_ops = { | ||
1529 | .read = ath9k_ioread32, | ||
1530 | .write = ath9k_iowrite32, | ||
1531 | }; | ||
1532 | |||
1533 | /* | ||
1493 | * Initialize and fill ath_softc, ath_sofct is the | 1534 | * Initialize and fill ath_softc, ath_sofct is the |
1494 | * "Software Carrier" struct. Historically it has existed | 1535 | * "Software Carrier" struct. Historically it has existed |
1495 | * to allow the separation between hardware specific | 1536 | * to allow the separation between hardware specific |
@@ -1528,6 +1569,7 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid) | |||
1528 | sc->sc_ah = ah; | 1569 | sc->sc_ah = ah; |
1529 | 1570 | ||
1530 | common = ath9k_hw_common(ah); | 1571 | common = ath9k_hw_common(ah); |
1572 | common->ops = &ath9k_common_ops; | ||
1531 | 1573 | ||
1532 | /* | 1574 | /* |
1533 | * Cache line size is used to size and align various | 1575 | * Cache line size is used to size and align various |