1 | /* |
---|
2 | * Clock Tick Device Driver |
---|
3 | * |
---|
4 | * This routine initializes LEON timer 1 which used for the clock tick. |
---|
5 | * |
---|
6 | * The tick frequency is directly programmed to the configured number of |
---|
7 | * microseconds per tick. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-2006. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * Modified for LEON3 BSP. |
---|
13 | * COPYRIGHT (c) 2004. |
---|
14 | * Gaisler Research. |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.com/license/LICENSE. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <bspopts.h> |
---|
25 | |
---|
26 | #if SIMSPARC_FAST_IDLE==1 |
---|
27 | #define CLOCK_DRIVER_USE_FAST_IDLE |
---|
28 | #endif |
---|
29 | |
---|
30 | /* |
---|
31 | * The Real Time Clock Counter Timer uses this trap type. |
---|
32 | */ |
---|
33 | |
---|
34 | extern rtems_configuration_table Configuration; |
---|
35 | |
---|
36 | #define LEON3_CLOCK_INDEX \ |
---|
37 | (Configuration.User_multiprocessing_table ? LEON3_Cpu_Index : 0) |
---|
38 | |
---|
39 | volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0; |
---|
40 | static int clkirq; |
---|
41 | |
---|
42 | #define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq ) |
---|
43 | |
---|
44 | #define Clock_driver_support_at_tick() |
---|
45 | |
---|
46 | #define Clock_driver_support_find_timer() \ |
---|
47 | do { \ |
---|
48 | int i; \ |
---|
49 | unsigned int iobar, conf; \ |
---|
50 | \ |
---|
51 | /* Find GP Timer */ \ |
---|
52 | i = 0; \ |
---|
53 | while (i < amba_conf.apbslv.devnr) { \ |
---|
54 | conf = amba_get_confword(amba_conf.apbslv, i, 0); \ |
---|
55 | if ((amba_vendor(conf) == VENDOR_GAISLER) && \ |
---|
56 | (amba_device(conf) == GAISLER_GPTIMER)) { \ |
---|
57 | iobar = amba_apb_get_membar(amba_conf.apbslv, i); \ |
---|
58 | LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \ |
---|
59 | amba_iobar_start(amba_conf.apbmst, iobar); \ |
---|
60 | break; \ |
---|
61 | } \ |
---|
62 | i++; \ |
---|
63 | } \ |
---|
64 | \ |
---|
65 | clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \ |
---|
66 | \ |
---|
67 | /* MP */ \ |
---|
68 | if (Configuration.User_multiprocessing_table != NULL) { \ |
---|
69 | clkirq += LEON3_Cpu_Index; \ |
---|
70 | } \ |
---|
71 | } while (0) |
---|
72 | |
---|
73 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
74 | do { \ |
---|
75 | _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ |
---|
76 | } while(0) |
---|
77 | |
---|
78 | #define Clock_driver_support_initialize_hardware() \ |
---|
79 | do { \ |
---|
80 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \ |
---|
81 | BSP_Configuration.microseconds_per_tick - 1; \ |
---|
82 | \ |
---|
83 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = \ |
---|
84 | LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \ |
---|
85 | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \ |
---|
86 | } while (0) |
---|
87 | |
---|
88 | #define Clock_driver_support_shutdown_hardware() \ |
---|
89 | do { \ |
---|
90 | LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq)); \ |
---|
91 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0; \ |
---|
92 | } while (0) |
---|
93 | |
---|
94 | #include "../../../shared/clockdrv_shell.c" |
---|