1 | /*===============================================================*\ |
---|
2 | | Project: RTEMS generic mcf548x BSP | |
---|
3 | +-----------------------------------------------------------------+ |
---|
4 | | File: clock.c | |
---|
5 | +-----------------------------------------------------------------+ |
---|
6 | | The file contains the clock driver code of generic MCF548x BSP. | |
---|
7 | +-----------------------------------------------------------------+ |
---|
8 | | Copyright (c) 2007 | |
---|
9 | | Embedded Brains GmbH | |
---|
10 | | Obere Lagerstr. 30 | |
---|
11 | | D-82178 Puchheim | |
---|
12 | | Germany | |
---|
13 | | rtems@embedded-brains.de | |
---|
14 | +-----------------------------------------------------------------+ |
---|
15 | | | |
---|
16 | | Parts of the code has been derived from the "dBUG source code" | |
---|
17 | | package Freescale is providing for M548X EVBs. The usage of | |
---|
18 | | the modified or unmodified code and it's integration into the | |
---|
19 | | generic mcf548x BSP has been done according to the Freescale | |
---|
20 | | license terms. | |
---|
21 | | | |
---|
22 | | The Freescale license terms can be reviewed in the file | |
---|
23 | | | |
---|
24 | | Freescale_license.txt | |
---|
25 | | | |
---|
26 | +-----------------------------------------------------------------+ |
---|
27 | | | |
---|
28 | | The generic mcf548x BSP has been developed on the basic | |
---|
29 | | structures and modules of the av5282 BSP. | |
---|
30 | | | |
---|
31 | +-----------------------------------------------------------------+ |
---|
32 | | | |
---|
33 | | The license and distribution terms for this file may be | |
---|
34 | | found in the file LICENSE in this distribution or at | |
---|
35 | | | |
---|
36 | | http://www.rtems.org/license/LICENSE. | |
---|
37 | | | |
---|
38 | +-----------------------------------------------------------------+ |
---|
39 | | | |
---|
40 | | date history ID | |
---|
41 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
---|
42 | | 12.11.07 1.0 ras | |
---|
43 | | | |
---|
44 | \*===============================================================*/ |
---|
45 | |
---|
46 | /* |
---|
47 | * Use first slice timer (SLT0) as the system clock. |
---|
48 | * |
---|
49 | */ |
---|
50 | |
---|
51 | #include <rtems.h> |
---|
52 | #include <bsp.h> |
---|
53 | #include <bsp/irq-generic.h> |
---|
54 | #include <mcf548x/mcf548x.h> |
---|
55 | |
---|
56 | /* |
---|
57 | * Use SLT 0 |
---|
58 | */ |
---|
59 | #define CLOCK_IRQ MCF548X_IRQ_SLT0 |
---|
60 | |
---|
61 | /* |
---|
62 | * Periodic interval timer interrupt handler |
---|
63 | */ |
---|
64 | #define Clock_driver_support_at_tick() \ |
---|
65 | do { \ |
---|
66 | MCF548X_SLT_SSR0 = MCF548X_SLT_SSR_ST; \ |
---|
67 | } while (0) \ |
---|
68 | |
---|
69 | /* |
---|
70 | * Attach clock interrupt handler |
---|
71 | */ |
---|
72 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
73 | do { \ |
---|
74 | _old = (rtems_isr_entry)set_vector(_new, CLOCK_IRQ + 64, 1); \ |
---|
75 | } while(0) |
---|
76 | |
---|
77 | /* |
---|
78 | * Turn off the clock |
---|
79 | */ |
---|
80 | #define Clock_driver_support_shutdown_hardware() \ |
---|
81 | do { \ |
---|
82 | MCF548X_SLT_SCR0 &= ~(MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN | MCF548X_SLT_SCR_IEN); \ |
---|
83 | } while(0) |
---|
84 | |
---|
85 | /* |
---|
86 | * Set up the clock hardware |
---|
87 | * |
---|
88 | * We need to have 1 interrupt every 10,000 microseconds |
---|
89 | * XLB clock 100 MHz / MCF548X_SLT_SLTCNT0 = XLB clock/100 |
---|
90 | */ |
---|
91 | #define Clock_driver_support_initialize_hardware() \ |
---|
92 | do { \ |
---|
93 | bsp_interrupt_vector_enable(CLOCK_IRQ); \ |
---|
94 | MCF548X_SLT_SLTCNT0 = get_CPU_clock_speed() \ |
---|
95 | / 1000 \ |
---|
96 | * rtems_configuration_get_microseconds_per_tick() \ |
---|
97 | / 1000; \ |
---|
98 | MCF548X_SLT_SCR0 |= (MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN | MCF548X_SLT_SCR_IEN); \ |
---|
99 | } while (0) |
---|
100 | |
---|
101 | #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER |
---|
102 | |
---|
103 | #include "../../../shared/clockdrv_shell.h" |
---|
104 | |
---|