tsif: Add option to read TSIF clock reference counter
Reading the current value of TSIF clock reference counter
is required by some application.
Change-Id: I5ca2a280f864fbb9c4a69518ce9672538f9c8489
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
diff --git a/drivers/misc/tsif.c b/drivers/misc/tsif.c
index b7b1203..05f6c86 100644
--- a/drivers/misc/tsif.c
+++ b/drivers/misc/tsif.c
@@ -1,7 +1,7 @@
/*
* TSIF Driver
*
- * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1770,6 +1770,22 @@
}
EXPORT_SYMBOL(tsif_stop);
+int tsif_get_ref_clk_counter(void *cookie, u32 *tcr_counter)
+{
+ struct msm_tsif_device *tsif_device = cookie;
+
+ if (!tsif_device || !tcr_counter)
+ return -EINVAL;
+
+ if (tsif_device->state == tsif_state_running)
+ *tcr_counter = ioread32(tsif_device->base + TSIF_CLK_REF_OFF);
+ else
+ *tcr_counter = 0;
+
+ return 0;
+}
+EXPORT_SYMBOL(tsif_get_ref_clk_counter);
+
void tsif_reclaim_packets(void *cookie, int read_index)
{
struct msm_tsif_device *tsif_device = cookie;