source: rtems/c/src/lib/libcpu/arm/pxa255/clock/clock.c @ f3b29236

Last change on this file since f3b29236 was f3b29236, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 18, 2017 at 6:22:38 AM

bsps: Clock_driver_support_install_isr()

Remove old ISR parameter since is not used by the clock driver shell.
Make an implementation optional.

Update #3139.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  PXA255 clock specific using the System Timer
3 *
4 *  RTEMS uses IRQ 26 as Clock Source
5 */
6
7/*
8 *  By Yang Xi <hiyangxi@gmail.com>
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.org/license/LICENSE.
13 */
14
15#include <rtems.h>
16#include <rtems/clockdrv.h>
17#include <rtems/libio.h>
18
19#include <stdlib.h>
20#include <bsp.h>
21#include <bspopts.h>
22#include <bsp/irq.h>
23#include <pxa255.h>
24
25#if ON_SKYEYE==1
26  #define CLOCK_DRIVER_USE_FAST_IDLE 1
27#endif
28
29static unsigned long period_num;
30
31/**
32 * Enables clock interrupt.
33 *
34 * If the interrupt is always on, this can be a NOP.
35 */
36static void clock_isr_on(const rtems_irq_connect_data *unused)
37{
38  /*Clear the interrupt bit */
39  XSCALE_OS_TIMER_TSR = 0x1;
40
41  /* enable timer interrupt */
42  XSCALE_OS_TIMER_IER |= 0x1;
43
44#if ON_SKYEYE==1
45  period_num = (TIMER_RATE* rtems_configuration_get_microseconds_per_tick())/100000;
46#else
47  period_num = (TIMER_RATE* rtems_configuration_get_microseconds_per_tick())/10000;
48#endif
49
50  XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;
51}
52
53/**
54 * Disables clock interrupts
55 *
56 * If the interrupt is always on, this can be a NOP.
57 */
58static void clock_isr_off(const rtems_irq_connect_data *unused)
59{
60  /*Clear the interrupt bit */
61  XSCALE_OS_TIMER_TSR = 0x1;
62  /* disable timer interrupt*/
63  XSCALE_OS_TIMER_IER &= ~0x1;
64}
65
66/**
67 * Tests to see if clock interrupt is enabled, and returns 1 if so.
68 * If interrupt is not enabled, returns 0.
69 *
70 * If the interrupt is always on, this always returns 1.
71 */
72static int clock_isr_is_on(const rtems_irq_connect_data *irq)
73{
74  /* check timer interrupt */
75  return XSCALE_OS_TIMER_IER & 0x1;
76}
77
78void Clock_isr(rtems_irq_hdl_param arg);
79
80rtems_irq_connect_data clock_isr_data = {
81  .name   = XSCALE_IRQ_OS_TIMER,
82  .hdl    = Clock_isr,
83  .handle = NULL,
84  .on     = clock_isr_on,
85  .off    = clock_isr_off,
86  .isOn   = clock_isr_is_on,
87};
88
89#define Clock_driver_support_install_isr( _new ) \
90  BSP_install_rtems_irq_handler(&clock_isr_data)
91
92static void Clock_driver_support_initialize_hardware(void)
93{
94  period_num = TIMER_RATE* rtems_configuration_get_microseconds_per_tick();
95#if ON_SKYEYE==1
96  period_num /= 100000;
97#else
98  period_num /= 10000;
99#endif
100}
101
102#define Clock_driver_support_at_tick() \
103  do { \
104    /* read the status to clear the int */ \
105    XSCALE_OS_TIMER_TSR = 0x1; \
106    \
107    /*Add the match register*/ \
108    XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num; \
109  } while (0)
110
111#define Clock_driver_support_shutdown_hardware() \
112  do { \
113    BSP_remove_rtems_irq_handler(&clock_isr_data); \
114  } while (0)
115
116#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
117
118#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.