zd1211rw: Implement get_tsf()
authorAlina Friedrichsen <x-alina@gmx.net>
Tue, 24 Feb 2009 23:49:18 +0000 (00:49 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 5 Mar 2009 19:39:30 +0000 (14:39 -0500)
This patch implements get_tsf() of ieee80211_ops in the zd1211rw driver.

Signed-off-by: Alina Friedrichsen <x-alina@gmx.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_chip.h
drivers/net/wireless/zd1211rw/zd_mac.c

index f1519143f8a65e80fca00501be81e5fd456cec73..2c813d87092c0b1c60846f12af4433bd6a03da68 100644 (file)
@@ -1616,3 +1616,24 @@ int zd_chip_set_multicast_hash(struct zd_chip *chip,
 
        return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs));
 }
+
+u64 zd_chip_get_tsf(struct zd_chip *chip)
+{
+       int r;
+       static const zd_addr_t aw_pt_bi_addr[] =
+               { CR_TSF_LOW_PART, CR_TSF_HIGH_PART };
+       u32 values[2];
+       u64 tsf;
+
+       mutex_lock(&chip->mutex);
+       r = zd_ioread32v_locked(chip, values, (const zd_addr_t *)aw_pt_bi_addr,
+                               ARRAY_SIZE(aw_pt_bi_addr));
+       mutex_unlock(&chip->mutex);
+       if (r)
+               return 0;
+
+       tsf = values[1];
+       tsf = (tsf << 32) | values[0];
+
+       return tsf;
+}
index f8c061a9b6ecd2f181b938ee7f14a5deaa45956b..ee42751d5cb02039e3b226e97556288fa625b243 100644 (file)
@@ -950,4 +950,6 @@ static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
 int zd_chip_set_multicast_hash(struct zd_chip *chip,
                               struct zd_mc_hash *hash);
 
+u64 zd_chip_get_tsf(struct zd_chip *chip);
+
 #endif /* _ZD_CHIP_H */
index da9214e33a5fbb9f59548880aac58aa28f256c26..0b01ff036aacf06a40c51731a7e6e6bf3e79355a 100644 (file)
@@ -935,6 +935,12 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw,
        }
 }
 
+static u64 zd_op_get_tsf(struct ieee80211_hw *hw)
+{
+       struct zd_mac *mac = zd_hw_mac(hw);
+       return zd_chip_get_tsf(&mac->chip);
+}
+
 static const struct ieee80211_ops zd_ops = {
        .tx                     = zd_op_tx,
        .start                  = zd_op_start,
@@ -945,6 +951,7 @@ static const struct ieee80211_ops zd_ops = {
        .config_interface       = zd_op_config_interface,
        .configure_filter       = zd_op_configure_filter,
        .bss_info_changed       = zd_op_bss_info_changed,
+       .get_tsf                = zd_op_get_tsf,
 };
 
 struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)