diff options
author | Leo Chen <leochen@broadcom.com> | 2009-08-07 15:01:47 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-08-15 11:01:41 -0400 |
commit | 34559125742645843bc7639900c7b4737ec12b72 (patch) | |
tree | 671f6a7fcd53e82bb29d620edf5739f4e8c5d0f7 /arch/arm/mach-bcmring | |
parent | 859277f7dbf8b48016d55ea2171d04eed074d858 (diff) |
ARM: 5649/1: bcmring: add bcmring timer function
bcmring timer helper function, hardware register headers
Signed-off-by: Leo Chen <leochen@broadcom.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-bcmring')
-rw-r--r-- | arch/arm/mach-bcmring/include/mach/timer.h | 77 | ||||
-rw-r--r-- | arch/arm/mach-bcmring/include/mach/timex.h | 25 | ||||
-rw-r--r-- | arch/arm/mach-bcmring/timer.c | 62 |
3 files changed, 164 insertions, 0 deletions
diff --git a/arch/arm/mach-bcmring/include/mach/timer.h b/arch/arm/mach-bcmring/include/mach/timer.h new file mode 100644 index 000000000000..5a94bbb032b6 --- /dev/null +++ b/arch/arm/mach-bcmring/include/mach/timer.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright 2004 - 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 | /* | ||
16 | * | ||
17 | ***************************************************************************** | ||
18 | * | ||
19 | * timer.h | ||
20 | * | ||
21 | * PURPOSE: | ||
22 | * | ||
23 | * | ||
24 | * | ||
25 | * NOTES: | ||
26 | * | ||
27 | *****************************************************************************/ | ||
28 | |||
29 | #if !defined(BCM_LINUX_TIMER_H) | ||
30 | #define BCM_LINUX_TIMER_H | ||
31 | |||
32 | #if defined(__KERNEL__) | ||
33 | |||
34 | /* ---- Include Files ---------------------------------------------------- */ | ||
35 | /* ---- Constants and Types ---------------------------------------------- */ | ||
36 | |||
37 | typedef unsigned int timer_tick_count_t; | ||
38 | typedef unsigned int timer_tick_rate_t; | ||
39 | typedef unsigned int timer_msec_t; | ||
40 | |||
41 | /* ---- Variable Externs ------------------------------------------------- */ | ||
42 | /* ---- Function Prototypes ---------------------------------------------- */ | ||
43 | |||
44 | /**************************************************************************** | ||
45 | * | ||
46 | * timer_get_tick_count | ||
47 | * | ||
48 | * | ||
49 | ***************************************************************************/ | ||
50 | timer_tick_count_t timer_get_tick_count(void); | ||
51 | |||
52 | /**************************************************************************** | ||
53 | * | ||
54 | * timer_get_tick_rate | ||
55 | * | ||
56 | * | ||
57 | ***************************************************************************/ | ||
58 | timer_tick_rate_t timer_get_tick_rate(void); | ||
59 | |||
60 | /**************************************************************************** | ||
61 | * | ||
62 | * timer_get_msec | ||
63 | * | ||
64 | * | ||
65 | ***************************************************************************/ | ||
66 | timer_msec_t timer_get_msec(void); | ||
67 | |||
68 | /**************************************************************************** | ||
69 | * | ||
70 | * timer_ticks_to_msec | ||
71 | * | ||
72 | * | ||
73 | ***************************************************************************/ | ||
74 | timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks); | ||
75 | |||
76 | #endif /* __KERNEL__ */ | ||
77 | #endif /* BCM_LINUX_TIMER_H */ | ||
diff --git a/arch/arm/mach-bcmring/include/mach/timex.h b/arch/arm/mach-bcmring/include/mach/timex.h new file mode 100644 index 000000000000..40d033ec5892 --- /dev/null +++ b/arch/arm/mach-bcmring/include/mach/timex.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Integrator architecture timex specifications | ||
4 | * | ||
5 | * Copyright (C) 1999 ARM Limited | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * Specifies the number of ticks per second | ||
24 | */ | ||
25 | #define CLOCK_TICK_RATE 100000 /* REG_SMT_TICKS_PER_SEC */ | ||
diff --git a/arch/arm/mach-bcmring/timer.c b/arch/arm/mach-bcmring/timer.c new file mode 100644 index 000000000000..2d415d2a8e68 --- /dev/null +++ b/arch/arm/mach-bcmring/timer.c | |||
@@ -0,0 +1,62 @@ | |||
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 | |||
33 | timer_tick_rate_t timer_get_tick_rate(void) | ||
34 | { | ||
35 | return tmrHw_getCountRate(PROF_TIMER); | ||
36 | } | ||
37 | |||
38 | timer_tick_count_t timer_get_tick_count(void) | ||
39 | { | ||
40 | return tmrHw_GetCurrentCount(PROF_TIMER); /* change downcounter to upcounter */ | ||
41 | } | ||
42 | |||
43 | timer_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 | |||
54 | timer_msec_t timer_get_msec(void) | ||
55 | { | ||
56 | return timer_ticks_to_msec(timer_get_tick_count()); | ||
57 | } | ||
58 | |||
59 | EXPORT_SYMBOL(timer_get_tick_count); | ||
60 | EXPORT_SYMBOL(timer_ticks_to_msec); | ||
61 | EXPORT_SYMBOL(timer_get_tick_rate); | ||
62 | EXPORT_SYMBOL(timer_get_msec); | ||