Timer
From OMAPpedia
Welcome to the General Purpose Timers webpage.
[edit] Introduction
This webpage describes the GP Timers driver design, features, and details of development activities.
[edit] List of Features Supported
- Functions for reserving and freeing timers
- Functions for programming various registers of the timer.
- Functions for getting information about the timers such as the functional clock, interrupt etc associated with them.
[edit] Design
[edit] Hardware Capabilities
Here are some of the key hardware capabilities of the GP Timer module.
- Interrupts generated on overflow, compare, and capture
- Free-running 32-bit upward counter
- Compare and capture modes
- Compare mode generates an interrupt when the timer value matches the value in the respective match register.
- Capture mode allows capturing of the timer value in a separate register based on an input signal.
- Autoreload mode
- Start/stop mode
- Programmable divider clock source (2^n where n = [0:8])
- Dedicated input trigger for capture mode and dedicated output trigger/PWM signal
- On-the-fly read/write register (while counting)
[edit] Software Design
This driver is merely a small library providing some functions for the clients of GP timers to reserve and program the timers. The library does not provide high-level abstractions.
So, the clients have to manage all the low-level programming(through the functions provided)and interrupt handling themselves.
This keeps the driver simple and flexible considering that GP Timer is not used by many. Following section describes the API provided by this library:
[edit] APIs
- struct omap_dm_timer *omap_dm_timer_request(void)
- Request a timer
- struct omap_dm_timer *omap_dm_timer_request_specific(int id)
- Request a specific timer
- void omap_dm_timer_free(struct omap_dm_timer *timer)
- Free allocated timer
- void omap_dm_timer_enable(struct omap_dm_timer *timer)
- Enable the timer
- void omap_dm_timer_disable(struct omap_dm_timer *timer)
- Disable the timer
- int omap_dm_timer_get_irq(struct omap_dm_timer *timer)
- Get the IRQ for a given timer
- __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask)
- TODO
- struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer)
- Get the functional clocks supported by the timer
- void omap_dm_timer_trigger(struct omap_dm_timer *timer)
- Trigger a reload of the timer
- void omap_dm_timer_start(struct omap_dm_timer *timer
- Start running the timer
- void omap_dm_timer_stop(struct omap_dm_timer *timer)
- Stop the timer
- int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
- Set the source functional clock frequency
- void omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int load)
- Set the load register
- void omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int load)
- Set the load register and start
- void omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match)
- Set the match register
- void omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger)
- Set the pwm register - TODO: Add details
- void omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
- Set the prescaler
- void omap_dm_timer_set_int_enable(struct omap_dm_timer *timer, unsigned int value)
- Enable interrupt for the timer
- unsigned int omap_dm_timer_read_status(struct omap_dm_timer *timer)
- Read the interrupt status of the timer
- void omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value)
- Write the status register - typically to clear it.
- unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer)
- Read the timer counter value.
- void omap_dm_timer_write_counter(struct omap_dm_timer *timer, unsigned int value)
- On the fly writing of counter register
- int omap_dm_timers_active(void)
- See if any of the timers is active.
[edit] Feature Status Summary
Here is the summary of completed, ongoing and planned features in the GP Timer driver.
GP Timer Driver
| ID | Title | Target Week | Upstream Status | Link to Patches | Priority | Owner | Dev Status | Comments & Link to Details |
[edit] Defect Status Summary
Here is the summary of completed, ongoing and planned defect fixes in the GP Timer driver.
GP Timer Driver
| ID | Title | Target Week | Upstream Status | Link to Patches | Features Impacted | Priority | Owner | Dev Status | Comments & Link to Details |
| Nothing to Report | NA | NA | NA | NA | NA | NA | NA | NA | NA |
[edit] FAQ
[edit] How do I use a GP timer to benchmark kernel functions?
1). Include dmtimer header in source file of functions you wish to benchmark:
#include <mach/dmtimer.h>
2). Initialise a gptimer to run at SYS_CLK freq. For an OMAP3 device, the SYS_CLK frequency will be the frequency of the main external clock connected to the sys_xtalin pad on the device divided by 1 or 2 depending on the configuration of the bit field PRM_CLKSRC_CTRL.SYSCLKDIV. Hence, the SYS_CLK is board dependent.
struct omap_dm_timer *gptimer; gptimer = omap_dm_timer_request(); omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK); omap_dm_timer_set_load_start(gptimer, 0, 0);
3). Use the following function to read timer at desired intervals:
u32 time_start, time_end; time_start = omap_dm_timer_read_counter(gptimer); // code to be benchmarked time_end = omap_dm_timer_read_counter(gptimer); printk(KERN_INFO "Total timer ticks = %d\n", (time_end-time_start));
[edit] Feature Status Details
[edit] Defect Status Details
None reported so far
[edit] Future Development Plan
None at present
[edit] Information on Testing Procedures
[edit] Submit Your Ideas Here
Please list them as separate subsections (use ==title==). Please include your name, email ID and date for easy processing.
[edit] Owner
Aneesh V <aneesh@ti.com>
[edit] Contributors
Juha Yrjola
Santosh Shilimkar <santosh.shilimkar@ti.com>
[edit] Patches Merged in kernel.org
TBD
[edit] Recent Submissions to Open Source
TBD
[edit] Current Status of Patches in Omapzoom Tree
None