aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/main.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-09-10 19:11:21 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-07 16:39:27 -0400
commit9e4bffd233f27fe83fc48efb01935aee7d0685bf (patch)
tree9c7444e68bda2774284dcff2eddacbdef8890932 /drivers/net/wireless/ath/ath9k/main.c
parent867633f026456ff71d4c4890f502c7a61b2adac0 (diff)
atheros/ath9k: add common read/write ops and port ath9k to use it
In an effort to make hw code driver core agnostic read and write operations are defined on the ath_common structure. This patch adds that and makes ath9k use it. This allows drivers like ath9k_htc to define its own read/write ops and still rely on the same hw code. This also paves the way for sharing code between ath9k/ath5k/ath9k_htc. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/main.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c42
1 files changed, 42 insertions, 0 deletions
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
1500static 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
1513static 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
1528static 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