1 | /* |
---|
2 | * C4X IO Information |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #ifndef _RTEMS_TIC4X_C4XIO_H |
---|
15 | #define _RTEMS_TIC4X_C4XIO_H |
---|
16 | |
---|
17 | /* |
---|
18 | * Address defines |
---|
19 | */ |
---|
20 | |
---|
21 | #ifdef _TMS320C40 |
---|
22 | #define C4X_TIMER_0 ((struct c4x_timer*)0x100020) |
---|
23 | #else |
---|
24 | #define C4X_TIMER_0 ((struct c4x_timer*)0x808020) |
---|
25 | #define C4X_TIMER_1 ((struct c4x_timer*)0x808030) |
---|
26 | #endif |
---|
27 | |
---|
28 | /* XXX how portable */ |
---|
29 | |
---|
30 | /* C32 Internal Control Registers */ |
---|
31 | #define C4X_STRB0_REG 0x808064 |
---|
32 | #define C4X_STRB1_REG 0x808068 |
---|
33 | #define C4X_IOSTRB_REG 0x808060 |
---|
34 | |
---|
35 | /* C32 Internal RAM Locations */ |
---|
36 | /* XXX how long */ |
---|
37 | #define C4X_RAM_BLK_0 0x87fe00 |
---|
38 | #define C4X_RAM_BLK_1 0x87ff00 |
---|
39 | |
---|
40 | /* |
---|
41 | * Data Structures to Overlay the Peripherals on the CPU |
---|
42 | */ |
---|
43 | |
---|
44 | struct c4x_timer { |
---|
45 | volatile int tcontrol; |
---|
46 | volatile int r1[3]; |
---|
47 | volatile int tcounter; |
---|
48 | volatile int r2[3]; |
---|
49 | volatile int tperiod; |
---|
50 | }; |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | /* |
---|
56 | * Timer Support Routines |
---|
57 | * |
---|
58 | * The following section of C4x timer code is based on C40 specific |
---|
59 | * timer code from Ran Cabell <rcabell@norfolk.infi.net>. The |
---|
60 | * only C3x/C4x difference spotted was the address of the timer. |
---|
61 | * The names have been changed to be more RTEMS like. |
---|
62 | */ |
---|
63 | |
---|
64 | #define c4x_timer_get_control( _timer ) (volatile int)(_timer->tcontrol) |
---|
65 | |
---|
66 | #define c4x_timer_set_control( _timer, _value ) \ |
---|
67 | do { \ |
---|
68 | (volatile int)(_timer->tcontrol) = _value; \ |
---|
69 | } while (0); |
---|
70 | |
---|
71 | #define c4x_timer_start( _timer ) \ |
---|
72 | c4x_timer_set_control(_timer, 0x02c1 ) |
---|
73 | |
---|
74 | #define c4x_timer_stop( _timer ) _timer->tcontrol = 0 |
---|
75 | |
---|
76 | #define c4x_timer_get_counter( _timer ) (volatile int)(_timer->tcounter) |
---|
77 | |
---|
78 | #define c4x_timer_set_counter( _timer, _value ) \ |
---|
79 | do { \ |
---|
80 | (volatile int)(_timer->tcounter) = _value; \ |
---|
81 | } while (0); |
---|
82 | |
---|
83 | #define c4x_timer_get_period( _timer ) (volatile int)(_timer->tperiod) |
---|
84 | |
---|
85 | #define c4x_timer_set_period( _timer, _value ) \ |
---|
86 | do { \ |
---|
87 | (volatile int)(_timer->tperiod) = _value; \ |
---|
88 | } while (0); |
---|
89 | |
---|
90 | /* |
---|
91 | * IO Flags |
---|
92 | * |
---|
93 | * NOTE: iof on c3x, iiof on c4x |
---|
94 | */ |
---|
95 | |
---|
96 | #ifdef _TMS320C40 |
---|
97 | |
---|
98 | #else |
---|
99 | |
---|
100 | static inline uint32_t c3x_get_iof( void ) |
---|
101 | { |
---|
102 | register uint32_t iof_value; |
---|
103 | |
---|
104 | __asm__ volatile ("ldi iof, %0" : "=r" (iof_value)); |
---|
105 | return iof_value; |
---|
106 | } |
---|
107 | |
---|
108 | static inline void c3x_set_iof( uint32_t value ) |
---|
109 | { |
---|
110 | __asm__ volatile ("ldi %0,iof" : : "g" (value) : "iof", "cc"); |
---|
111 | } |
---|
112 | |
---|
113 | #endif |
---|
114 | |
---|
115 | |
---|
116 | #endif |
---|
117 | /* end if include file */ |
---|