Skip to content

Commit

Permalink
ARM: 5649/1: bcmring: add bcmring timer function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Leo Chen authored and Russell King committed Aug 15, 2009
1 parent 859277f commit 3455912
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
77 changes: 77 additions & 0 deletions arch/arm/mach-bcmring/include/mach/timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*****************************************************************************
* Copyright 2004 - 2008 Broadcom Corporation. All rights reserved.
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2, available at
* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
*
* Notwithstanding the above, under no circumstances may you combine this
* software in any way with any other Broadcom software provided under a
* license other than the GPL, without Broadcom's express prior written
* consent.
*****************************************************************************/

/*
*
*****************************************************************************
*
* timer.h
*
* PURPOSE:
*
*
*
* NOTES:
*
*****************************************************************************/

#if !defined(BCM_LINUX_TIMER_H)
#define BCM_LINUX_TIMER_H

#if defined(__KERNEL__)

/* ---- Include Files ---------------------------------------------------- */
/* ---- Constants and Types ---------------------------------------------- */

typedef unsigned int timer_tick_count_t;
typedef unsigned int timer_tick_rate_t;
typedef unsigned int timer_msec_t;

/* ---- Variable Externs ------------------------------------------------- */
/* ---- Function Prototypes ---------------------------------------------- */

/****************************************************************************
*
* timer_get_tick_count
*
*
***************************************************************************/
timer_tick_count_t timer_get_tick_count(void);

/****************************************************************************
*
* timer_get_tick_rate
*
*
***************************************************************************/
timer_tick_rate_t timer_get_tick_rate(void);

/****************************************************************************
*
* timer_get_msec
*
*
***************************************************************************/
timer_msec_t timer_get_msec(void);

/****************************************************************************
*
* timer_ticks_to_msec
*
*
***************************************************************************/
timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks);

#endif /* __KERNEL__ */
#endif /* BCM_LINUX_TIMER_H */
25 changes: 25 additions & 0 deletions arch/arm/mach-bcmring/include/mach/timex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
*
* Integrator architecture timex specifications
*
* Copyright (C) 1999 ARM Limited
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/*
* Specifies the number of ticks per second
*/
#define CLOCK_TICK_RATE 100000 /* REG_SMT_TICKS_PER_SEC */
62 changes: 62 additions & 0 deletions arch/arm/mach-bcmring/timer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*****************************************************************************
* Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2, available at
* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
*
* Notwithstanding the above, under no circumstances may you combine this
* software in any way with any other Broadcom software provided under a
* license other than the GPL, without Broadcom's express prior written
* consent.
*****************************************************************************/

#include <linux/version.h>
#include <linux/types.h>
#include <linux/module.h>
#include <csp/tmrHw.h>

#include <mach/timer.h>
/* The core.c file initializes timers 1 and 3 as a linux clocksource. */
/* The real time clock should probably be the real linux clocksource. */
/* In the meantime, this file should agree with core.c as to the */
/* profiling timer. If the clocksource is moved to rtc later, then */
/* we can init the profiling timer here instead. */

/* Timer 1 provides 25MHz resolution syncrhonized to scheduling and APM timing */
/* Timer 3 provides bus freqeuncy sychronized to ACLK, but spread spectrum will */
/* affect synchronization with scheduling and APM timing. */

#define PROF_TIMER 1

timer_tick_rate_t timer_get_tick_rate(void)
{
return tmrHw_getCountRate(PROF_TIMER);
}

timer_tick_count_t timer_get_tick_count(void)
{
return tmrHw_GetCurrentCount(PROF_TIMER); /* change downcounter to upcounter */
}

timer_msec_t timer_ticks_to_msec(timer_tick_count_t ticks)
{
static int tickRateMsec;

if (tickRateMsec == 0) {
tickRateMsec = timer_get_tick_rate() / 1000;
}

return ticks / tickRateMsec;
}

timer_msec_t timer_get_msec(void)
{
return timer_ticks_to_msec(timer_get_tick_count());
}

EXPORT_SYMBOL(timer_get_tick_count);
EXPORT_SYMBOL(timer_ticks_to_msec);
EXPORT_SYMBOL(timer_get_tick_rate);
EXPORT_SYMBOL(timer_get_msec);

0 comments on commit 3455912

Please sign in to comment.