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 cnt; \ |
---|
49 | amba_apb_device dev; \ |
---|
50 | \ |
---|
51 | /* Find LEON3 Interrupt controler */ \ |
---|
52 | cnt = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev); \ |
---|
53 | if ( cnt > 0 ){ \ |
---|
54 | /* Found APB IRQ_MP Interrupt Controller */ \ |
---|
55 | LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start; \ |
---|
56 | clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \ |
---|
57 | \ |
---|
58 | if (Configuration.User_multiprocessing_table != NULL) { \ |
---|
59 | clkirq += LEON3_Cpu_Index; \ |
---|
60 | } \ |
---|
61 | } \ |
---|
62 | } while (0) |
---|
63 | |
---|
64 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
65 | do { \ |
---|
66 | _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ |
---|
67 | } while(0) |
---|
68 | |
---|
69 | #define Clock_driver_support_initialize_hardware() \ |
---|
70 | do { \ |
---|
71 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \ |
---|
72 | BSP_Configuration.microseconds_per_tick - 1; \ |
---|
73 | \ |
---|
74 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = \ |
---|
75 | LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \ |
---|
76 | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \ |
---|
77 | } while (0) |
---|
78 | |
---|
79 | #define Clock_driver_support_shutdown_hardware() \ |
---|
80 | do { \ |
---|
81 | LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq)); \ |
---|
82 | LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0; \ |
---|
83 | } while (0) |
---|
84 | |
---|
85 | #include "../../../shared/clockdrv_shell.c" |
---|