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>
This commit is contained in:
Hamad Kadmany 2013-01-31 14:53:32 +02:00 committed by Iliyan Malchev
parent d1003a1d4c
commit c29c79bb54
2 changed files with 29 additions and 2 deletions

View file

@ -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 @@ void tsif_stop(void *cookie)
}
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;

View file

@ -3,7 +3,7 @@
*
* Kernel API
*
* Copyright (c) 2009-2010, 2012, The Linux Foundation. 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
@ -255,6 +255,17 @@ int tsif_start(void *cookie);
*/
void tsif_stop(void *cookie);
/**
* tsif_get_ref_clk_counter - return the TSIF clock reference (TCR) counter.
* @cookie: TSIF cookie previously obtained with tsif_attach()
* @tcr_counter: the value of TCR counter
*
* Return error code
*
* TCR increments at a rate equal to 27 MHz/256 = 105.47 kHz.
*/
int tsif_get_ref_clk_counter(void *cookie, u32 *tcr_counter);
/**
* tsif_reclaim_packets - inform that buffer space may be reclaimed
* @cookie: TSIF cookie previously obtained with tsif_attach()