source: rtems/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c @ 5c89efa

4.104.114.84.95
Last change on this file since 5c89efa was 5c89efa, checked in by Joel Sherrill <joel.sherrill@…>, on 05/31/06 at 13:46:23

2006-05-31 Joel Sherrill <joel@…>

  • at91rm9200/clock/clock.c: Convert to using shared clock driver shell.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  AT91RM9200 clock specific using the System Timer
3 *
4 *  Copyright (c) 2003 by Cogent Computer Systems
5 *  Written by Mike Kelly <mike@cogcomp.com>
6 *         and Jay Monkman <jtm@lopingdog.com>
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *
14 *  $Id$
15 */
16#include <rtems.h>
17#include <rtems/clockdrv.h>
18#include <rtems/libio.h>
19
20#include <stdlib.h>
21#include <bsp.h>
22#include <irq.h>
23#include <at91rm9200.h>
24#include <at91rm9200_pmc.h>
25
26
27static unsigned long st_pimr_reload;
28
29/**
30 * Enables clock interrupt.
31 *
32 * If the interrupt is always on, this can be a NOP.
33 */
34static void clock_isr_on(const rtems_irq_connect_data *unused)
35{
36    /* enable timer interrupt */
37    ST_REG(ST_IER) = ST_SR_PITS;
38}
39
40/**
41 * Disables clock interrupts
42 *
43 * If the interrupt is always on, this can be a NOP.
44 */
45static void clock_isr_off(const rtems_irq_connect_data *unused)
46{
47    /* disable timer interrupt */
48    ST_REG(ST_IDR) = ST_SR_PITS;
49    return;
50}
51
52/**
53 * Tests to see if clock interrupt is enabled, and returns 1 if so.
54 * If interrupt is not enabled, returns 0.
55 *
56 * If the interrupt is always on, this always returns 1.
57 */
58static int clock_isr_is_on(const rtems_irq_connect_data *irq)
59{
60    /* check timer interrupt */
61    return ST_REG(ST_IMR) & ST_SR_PITS;
62}
63
64rtems_isr Clock_isr(rtems_vector_number vector);
65
66/* Replace the first value with the clock's interrupt name. */
67rtems_irq_connect_data clock_isr_data = {AT91RM9200_INT_SYSIRQ,   
68                                         (rtems_irq_hdl)Clock_isr,
69                                         clock_isr_on,
70                                         clock_isr_off,
71                                         clock_isr_is_on,
72                                         3,     /* unused for ARM cpus */
73                                         0 };   /* unused for ARM cpus */
74
75
76#define Clock_driver_support_install_isr( _new, _old ) \
77  BSP_install_rtems_irq_handler(&clock_isr_data)
78
79void Clock_driver_support_initialize_hardware(void)
80{
81  uint32_t st_str;
82  int slck;
83
84  /* the system timer is driven from SLCK */
85  slck = at91rm9200_get_slck();
86  st_pimr_reload =
87    (((BSP_Configuration.microseconds_per_tick * slck) + (1000000/2))/ 1000000);
88
89  /* read the status to clear the int */
90  st_str = ST_REG(ST_SR);
91   
92  /* set priority */
93  AIC_SMR_REG(AIC_SMR_SYSIRQ) = AIC_SMR_PRIOR(0x7);
94
95  /* set the timer value */
96  ST_REG(ST_PIMR) = st_pimr_reload;
97}
98
99
100#define CLOCK_VECTOR 0
101
102#define Clock_driver_support_at_tick() \
103  do { \
104    uint32_t st_str; \
105    \
106    /* read the status to clear the int */ \
107    st_str = ST_REG(ST_SR); \
108  } while (0)
109
110void Clock_driver_support_shutdown_hardware( void )
111{
112    BSP_remove_rtems_irq_handler(&clock_isr_data);
113}
114
115#include "../../../../libbsp/shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.