Linux Audio

Check our new training course

Loading...
v3.5.6
 1/*****************************************************************************
 2* Copyright 2003 - 2008 Broadcom Corporation.  All rights reserved.
 3*
 4* Unless you and Broadcom execute a separate written software license
 5* agreement governing use of this software, this software is licensed to you
 6* under the terms of the GNU General Public License version 2, available at
 7* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
 8*
 9* Notwithstanding the above, under no circumstances may you combine this
10* software in any way with any other Broadcom software provided under a
11* license other than the GPL, without Broadcom's express prior written
12* consent.
13*****************************************************************************/
14
 
15#include <linux/types.h>
16#include <linux/module.h>
17#include <csp/tmrHw.h>
18
19#include <mach/timer.h>
20/* The core.c file initializes timers 1 and 3 as a linux clocksource. */
21/* The real time clock should probably be the real linux clocksource. */
22/* In the meantime, this file should agree with core.c as to the */
23/* profiling timer. If the clocksource is moved to rtc later, then */
24/* we can init the profiling timer here instead. */
25
26/* Timer 1 provides 25MHz resolution syncrhonized to scheduling and APM timing */
27/* Timer 3 provides bus freqeuncy sychronized to ACLK, but spread spectrum will */
28/* affect synchronization with scheduling and APM timing. */
29
30#define PROF_TIMER 1
31
32timer_tick_rate_t timer_get_tick_rate(void)
33{
34	return tmrHw_getCountRate(PROF_TIMER);
35}
36
37timer_tick_count_t timer_get_tick_count(void)
38{
39	return tmrHw_GetCurrentCount(PROF_TIMER);	/* change downcounter to upcounter */
40}
41
42timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks)
43{
44	static int tickRateMsec;
45
46	if (tickRateMsec == 0) {
47		tickRateMsec = timer_get_tick_rate() / 1000;
48	}
49
50	return ticks / tickRateMsec;
51}
52
53timer_msec_t timer_get_msec(void)
54{
55	return timer_ticks_to_msec(timer_get_tick_count());
56}
57
58EXPORT_SYMBOL(timer_get_tick_count);
59EXPORT_SYMBOL(timer_ticks_to_msec);
60EXPORT_SYMBOL(timer_get_tick_rate);
61EXPORT_SYMBOL(timer_get_msec);
v3.1
 1/*****************************************************************************
 2* Copyright 2003 - 2008 Broadcom Corporation.  All rights reserved.
 3*
 4* Unless you and Broadcom execute a separate written software license
 5* agreement governing use of this software, this software is licensed to you
 6* under the terms of the GNU General Public License version 2, available at
 7* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
 8*
 9* Notwithstanding the above, under no circumstances may you combine this
10* software in any way with any other Broadcom software provided under a
11* license other than the GPL, without Broadcom's express prior written
12* consent.
13*****************************************************************************/
14
15#include <linux/version.h>
16#include <linux/types.h>
17#include <linux/module.h>
18#include <csp/tmrHw.h>
19
20#include <mach/timer.h>
21/* The core.c file initializes timers 1 and 3 as a linux clocksource. */
22/* The real time clock should probably be the real linux clocksource. */
23/* In the meantime, this file should agree with core.c as to the */
24/* profiling timer. If the clocksource is moved to rtc later, then */
25/* we can init the profiling timer here instead. */
26
27/* Timer 1 provides 25MHz resolution syncrhonized to scheduling and APM timing */
28/* Timer 3 provides bus freqeuncy sychronized to ACLK, but spread spectrum will */
29/* affect synchronization with scheduling and APM timing. */
30
31#define PROF_TIMER 1
32
33timer_tick_rate_t timer_get_tick_rate(void)
34{
35	return tmrHw_getCountRate(PROF_TIMER);
36}
37
38timer_tick_count_t timer_get_tick_count(void)
39{
40	return tmrHw_GetCurrentCount(PROF_TIMER);	/* change downcounter to upcounter */
41}
42
43timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks)
44{
45	static int tickRateMsec;
46
47	if (tickRateMsec == 0) {
48		tickRateMsec = timer_get_tick_rate() / 1000;
49	}
50
51	return ticks / tickRateMsec;
52}
53
54timer_msec_t timer_get_msec(void)
55{
56	return timer_ticks_to_msec(timer_get_tick_count());
57}
58
59EXPORT_SYMBOL(timer_get_tick_count);
60EXPORT_SYMBOL(timer_ticks_to_msec);
61EXPORT_SYMBOL(timer_get_tick_rate);
62EXPORT_SYMBOL(timer_get_msec);