1 | /* |
---|
2 | * Cirrus EP7312 Clock driver |
---|
3 | * |
---|
4 | * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.org/license/LICENSE. |
---|
9 | */ |
---|
10 | |
---|
11 | #include <rtems.h> |
---|
12 | #include <ep7312.h> |
---|
13 | #include <bsp.h> |
---|
14 | #include <bsp/irq.h> |
---|
15 | #include <assert.h> |
---|
16 | |
---|
17 | #if ON_SKYEYE==1 |
---|
18 | #define CLOCK_DRIVER_USE_FAST_IDLE 1 |
---|
19 | #endif |
---|
20 | |
---|
21 | void Clock_isr(void * arg); |
---|
22 | |
---|
23 | #define Clock_driver_support_at_tick() \ |
---|
24 | do { \ |
---|
25 | *EP7312_TC1EOI = 0xffffffff; \ |
---|
26 | } while(0) |
---|
27 | |
---|
28 | #define Clock_driver_support_install_isr( _new ) \ |
---|
29 | do { \ |
---|
30 | rtems_status_code status = RTEMS_SUCCESSFUL; \ |
---|
31 | status = rtems_interrupt_handler_install( \ |
---|
32 | BSP_TC1OI, \ |
---|
33 | "Clock", \ |
---|
34 | RTEMS_INTERRUPT_UNIQUE, \ |
---|
35 | Clock_isr, \ |
---|
36 | NULL \ |
---|
37 | ); \ |
---|
38 | assert(status == RTEMS_SUCCESSFUL); \ |
---|
39 | } while(0) |
---|
40 | |
---|
41 | /* |
---|
42 | * Set up the clock hardware |
---|
43 | */ |
---|
44 | #if ON_SKYEYE |
---|
45 | #define TCD_VALUE \ |
---|
46 | (rtems_configuration_get_microseconds_per_tick() * 2000)/25000 |
---|
47 | #else |
---|
48 | #define TCD_VALUE \ |
---|
49 | (rtems_configuration_get_microseconds_per_tick() * 2000)/1000000 |
---|
50 | #endif |
---|
51 | |
---|
52 | #define Clock_driver_support_initialize_hardware() \ |
---|
53 | do { \ |
---|
54 | *EP7312_SYSCON1 |= EP7312_SYSCON1_TC1_PRESCALE; \ |
---|
55 | *EP7312_TC1D = TCD_VALUE; \ |
---|
56 | *EP7312_TC1EOI = 0xFFFFFFFF; \ |
---|
57 | } while (0) |
---|
58 | |
---|
59 | #define Clock_driver_support_shutdown_hardware() \ |
---|
60 | do { \ |
---|
61 | rtems_status_code status = RTEMS_SUCCESSFUL; \ |
---|
62 | status = rtems_interrupt_handler_remove( \ |
---|
63 | BSP_TC1OI, \ |
---|
64 | Clock_isr, \ |
---|
65 | NULL \ |
---|
66 | ); \ |
---|
67 | assert(status == RTEMS_SUCCESSFUL); \ |
---|
68 | } while (0) |
---|
69 | |
---|
70 | #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER |
---|
71 | |
---|
72 | #include "../../../shared/dev/clock/clockimpl.h" |
---|