1 |
27 |
unneback |
#ifndef CYGONCE_HAL_IMP_INTR_H
|
2 |
|
|
#define CYGONCE_HAL_IMP_INTR_H
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// imp_intr.h
|
7 |
|
|
//
|
8 |
|
|
// TX39 Interrupt and clock support
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
21 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License along
|
26 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
30 |
|
|
// or inline functions from this file, or you compile this file and link it
|
31 |
|
|
// with other works to produce a work based on this file, this file does not
|
32 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
33 |
|
|
// License. However the source code for this file must still be made available
|
34 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
37 |
|
|
// this file might be covered by the GNU General Public License.
|
38 |
|
|
//
|
39 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
40 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
43 |
|
|
//==========================================================================
|
44 |
|
|
//#####DESCRIPTIONBEGIN####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): nickg
|
47 |
|
|
// Contributors: nickg, jskov,
|
48 |
|
|
// gthomas, jlarmour
|
49 |
|
|
// Date: 1999-02-16
|
50 |
|
|
// Purpose: TX39 Interrupt support
|
51 |
|
|
// Description: The macros defined here provide the HAL APIs for handling
|
52 |
|
|
// interrupts and the clock for variants of the TX39 MIPS
|
53 |
|
|
// architecture.
|
54 |
|
|
//
|
55 |
|
|
// Usage:
|
56 |
|
|
// #include <cyg/hal/imp_intr.h>
|
57 |
|
|
// ...
|
58 |
|
|
//
|
59 |
|
|
//
|
60 |
|
|
//####DESCRIPTIONEND####
|
61 |
|
|
//
|
62 |
|
|
//==========================================================================
|
63 |
|
|
|
64 |
|
|
#include <pkgconf/hal.h>
|
65 |
|
|
|
66 |
|
|
#include <cyg/infra/cyg_type.h>
|
67 |
|
|
|
68 |
|
|
#include <cyg/hal/plf_intr.h>
|
69 |
|
|
|
70 |
|
|
//--------------------------------------------------------------------------
|
71 |
|
|
// Interrupt vectors.
|
72 |
|
|
|
73 |
|
|
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
|
74 |
|
|
|
75 |
|
|
// These are decoded via the IP bits of the cause
|
76 |
|
|
// register when an external interrupt is delivered.
|
77 |
|
|
|
78 |
|
|
#define CYGNUM_HAL_INTERRUPT_1 0
|
79 |
|
|
#define CYGNUM_HAL_INTERRUPT_2 1
|
80 |
|
|
#define CYGNUM_HAL_INTERRUPT_3 2
|
81 |
|
|
#define CYGNUM_HAL_INTERRUPT_4 3
|
82 |
|
|
#define CYGNUM_HAL_INTERRUPT_5 4
|
83 |
|
|
#define CYGNUM_HAL_INTERRUPT_6 5
|
84 |
|
|
#define CYGNUM_HAL_INTERRUPT_7 6
|
85 |
|
|
#define CYGNUM_HAL_INTERRUPT_DMAC1_CH3 7
|
86 |
|
|
#define CYGNUM_HAL_INTERRUPT_DMAC1_CH2 8
|
87 |
|
|
#define CYGNUM_HAL_INTERRUPT_DMAC0_CH1 9
|
88 |
|
|
#define CYGNUM_HAL_INTERRUPT_DMAC0_CH0 10
|
89 |
|
|
#define CYGNUM_HAL_INTERRUPT_SIO_0 11
|
90 |
|
|
#define CYGNUM_HAL_INTERRUPT_SIO_1 12
|
91 |
|
|
#define CYGNUM_HAL_INTERRUPT_TMR_0 13
|
92 |
|
|
#define CYGNUM_HAL_INTERRUPT_TMR_1 14
|
93 |
|
|
#define CYGNUM_HAL_INTERRUPT_TMR_2 15
|
94 |
|
|
#define CYGNUM_HAL_INTERRUPT_0 16
|
95 |
|
|
|
96 |
|
|
// Min/Max ISR numbers and how many there are
|
97 |
|
|
#define CYGNUM_HAL_ISR_MIN 0
|
98 |
|
|
#define CYGNUM_HAL_ISR_MAX 16
|
99 |
|
|
#define CYGNUM_HAL_ISR_COUNT 17
|
100 |
|
|
|
101 |
|
|
// The vector used by the Real time clock
|
102 |
|
|
#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_TMR_0
|
103 |
|
|
|
104 |
|
|
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
|
105 |
|
|
|
106 |
|
|
#endif
|
107 |
|
|
|
108 |
|
|
//--------------------------------------------------------------------------
|
109 |
|
|
// Interrupt controller access.
|
110 |
|
|
|
111 |
|
|
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
|
112 |
|
|
|
113 |
|
|
#if defined(CYGPKG_HAL_MIPS_TX3904)
|
114 |
|
|
|
115 |
|
|
#define CYG_HAL_MIPS_TX3904_ILR0 0xFFFFC010
|
116 |
|
|
#define CYG_HAL_MIPS_TX3904_CConR 0xFFFFE000
|
117 |
|
|
|
118 |
|
|
// Array which stores the configured priority levels for the configured
|
119 |
|
|
// interrupts.
|
120 |
|
|
externC volatile CYG_BYTE hal_interrupt_level[CYGNUM_HAL_ISR_COUNT];
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
#define HAL_INTERRUPT_MASK( _vector_ ) \
|
124 |
|
|
{ \
|
125 |
|
|
HAL_IO_REGISTER _reg_ = CYG_HAL_MIPS_TX3904_ILR0; \
|
126 |
|
|
CYG_WORD32 _ilr_; \
|
127 |
|
|
_reg_ += (_vector_)&0xC; \
|
128 |
|
|
HAL_READ_UINT32( _reg_, _ilr_ ); \
|
129 |
|
|
_ilr_ &= ~(7 << (((_vector_)&0x3)<<3)); \
|
130 |
|
|
HAL_WRITE_UINT32( _reg_, _ilr_ ); \
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
#define HAL_INTERRUPT_UNMASK( _vector_ ) \
|
134 |
|
|
{ \
|
135 |
|
|
HAL_IO_REGISTER _reg_ = CYG_HAL_MIPS_TX3904_ILR0; \
|
136 |
|
|
CYG_WORD32 _ilr_; \
|
137 |
|
|
_reg_ += (_vector_)&0xC; \
|
138 |
|
|
HAL_READ_UINT32( _reg_, _ilr_ ); \
|
139 |
|
|
_ilr_ |= hal_interrupt_level[_vector_] << (((_vector_)&0x3)<<3); \
|
140 |
|
|
HAL_WRITE_UINT32( _reg_, _ilr_ ); \
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) \
|
144 |
|
|
{ \
|
145 |
|
|
if( _vector_ <= CYGNUM_HAL_INTERRUPT_7 || \
|
146 |
|
|
_vector_ == CYGNUM_HAL_INTERRUPT_0 ) \
|
147 |
|
|
{ \
|
148 |
|
|
cyg_uint32 _v_ = _vector_ + 1; \
|
149 |
|
|
cyg_uint8 _reg_; \
|
150 |
|
|
\
|
151 |
|
|
/* adjust vector to bit offset in CConR */ \
|
152 |
|
|
if( _v_ == CYGNUM_HAL_INTERRUPT_0 + 1 ) _v_ = 0; \
|
153 |
|
|
\
|
154 |
|
|
/* get CConR */ \
|
155 |
|
|
HAL_READ_UINT8( CYG_HAL_MIPS_TX3904_CConR+1, _reg_ ); \
|
156 |
|
|
\
|
157 |
|
|
/* clear old value and set new */ \
|
158 |
|
|
_reg_ &= ~(7 << 5); \
|
159 |
|
|
_reg_ |= _v_ << 5; \
|
160 |
|
|
HAL_WRITE_UINT8( CYG_HAL_MIPS_TX3904_CConR+1, _reg_); \
|
161 |
|
|
} \
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ ) \
|
165 |
|
|
{ \
|
166 |
|
|
if( _vector_ <= CYGNUM_HAL_INTERRUPT_7 || \
|
167 |
|
|
_vector_ == CYGNUM_HAL_INTERRUPT_0 ) \
|
168 |
|
|
{ \
|
169 |
|
|
cyg_uint32 _v_ = _vector_ + 1; \
|
170 |
|
|
cyg_uint32 _val_ = 0; \
|
171 |
|
|
cyg_uint16 _reg_; \
|
172 |
|
|
\
|
173 |
|
|
/* adjust vector to bit offset in CConR */ \
|
174 |
|
|
if( _v_ == CYGNUM_HAL_INTERRUPT_0 + 1 ) _v_ = 0; \
|
175 |
|
|
_v_ <<= 1; \
|
176 |
|
|
\
|
177 |
|
|
/* set bits according to requirements */ \
|
178 |
|
|
if( _up_ ) _val_ |= 1; \
|
179 |
|
|
if( !(_level_) ) _val_ |= 2; \
|
180 |
|
|
\
|
181 |
|
|
/* get CConR */ \
|
182 |
|
|
HAL_READ_UINT16( CYG_HAL_MIPS_TX3904_CConR+2, _reg_ ); \
|
183 |
|
|
\
|
184 |
|
|
/* clear old value and set new */ \
|
185 |
|
|
_reg_ &= ~(3 << _v_); \
|
186 |
|
|
_reg_ |= _val_ << _v_; \
|
187 |
|
|
HAL_WRITE_UINT16( CYG_HAL_MIPS_TX3904_CConR+2, _reg_ ); \
|
188 |
|
|
} \
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ ) \
|
192 |
|
|
{ \
|
193 |
|
|
HAL_IO_REGISTER _reg_ = CYG_HAL_MIPS_TX3904_ILR0; \
|
194 |
|
|
CYG_WORD32 _ilr_; \
|
195 |
|
|
_reg_ += (_vector_)&0xC; \
|
196 |
|
|
HAL_READ_UINT32( _reg_, _ilr_ ); \
|
197 |
|
|
_ilr_ |= (_level_) << (((_vector_)&0x3)<<3); \
|
198 |
|
|
HAL_WRITE_UINT32( _reg_, _ilr_ ); \
|
199 |
|
|
hal_interrupt_level[_vector_] = _level_; \
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
|
203 |
|
|
|
204 |
|
|
#else
|
205 |
|
|
|
206 |
|
|
#error Unspecified TX39 variant
|
207 |
|
|
|
208 |
|
|
#endif
|
209 |
|
|
|
210 |
|
|
#endif
|
211 |
|
|
|
212 |
|
|
//--------------------------------------------------------------------------
|
213 |
|
|
// Clock control
|
214 |
|
|
|
215 |
|
|
#ifndef CYGHWR_HAL_CLOCK_CONTROL_DEFINED
|
216 |
|
|
|
217 |
|
|
#if defined(CYGPKG_HAL_MIPS_TX3904)
|
218 |
|
|
|
219 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_BASE 0xFFFFF000
|
220 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_CR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0x00)
|
221 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_SR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0x04)
|
222 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_CPR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0x08)
|
223 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_IMR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0x10)
|
224 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_DR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0x20)
|
225 |
|
|
#define CYG_HAL_MIPS_TX3904_TIMER_RR (CYG_HAL_MIPS_TX3904_TIMER_BASE + 0xF0)
|
226 |
|
|
|
227 |
|
|
#define HAL_CLOCK_INITIALIZE( _period_ ) \
|
228 |
|
|
{ \
|
229 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_DR, 0x00000003 ); \
|
230 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_CPR, _period_ ); \
|
231 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_SR, 0x00000000 ); \
|
232 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_IMR, 0x00008001 ); \
|
233 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_CR, 0x000000C0 ); \
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
#define HAL_CLOCK_RESET( _vector_, _period_ ) \
|
237 |
|
|
{ \
|
238 |
|
|
HAL_WRITE_UINT32( CYG_HAL_MIPS_TX3904_TIMER_SR, 0x00000000 ); \
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
#if defined(CYGHWR_HAL_MIPS_TX3904_TRR_REQUIRES_SYNC) && \
|
242 |
|
|
!defined(CYGPKG_HAL_MIPS_SIM)
|
243 |
|
|
|
244 |
|
|
// We need to sync and check the coprocessor 0 condition - this
|
245 |
|
|
// indicates whether data is present in the write buffer. We need to
|
246 |
|
|
// wait until the data to be written is flushed out. This works
|
247 |
|
|
// around a tx39 bug. gcc will insert a NOP after the asm insns.
|
248 |
|
|
|
249 |
|
|
# define HAL_CLOCK_READ( _pvalue_ ) \
|
250 |
|
|
CYG_MACRO_START \
|
251 |
|
|
asm volatile ( \
|
252 |
|
|
"sync; nop; 1: ; bc0f 1b" \
|
253 |
|
|
: \
|
254 |
|
|
: \
|
255 |
|
|
: "$0" \
|
256 |
|
|
); \
|
257 |
|
|
HAL_READ_UINT32( CYG_HAL_MIPS_TX3904_TIMER_RR, *(_pvalue_) ); \
|
258 |
|
|
CYG_MACRO_END
|
259 |
|
|
|
260 |
|
|
#else
|
261 |
|
|
|
262 |
|
|
# define HAL_CLOCK_READ( _pvalue_ ) \
|
263 |
|
|
CYG_MACRO_START \
|
264 |
|
|
HAL_READ_UINT32( CYG_HAL_MIPS_TX3904_TIMER_RR, *(_pvalue_) ); \
|
265 |
|
|
CYG_MACRO_END
|
266 |
|
|
|
267 |
|
|
#endif
|
268 |
|
|
|
269 |
|
|
#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && \
|
270 |
|
|
!defined(HAL_CLOCK_LATENCY)
|
271 |
|
|
#define HAL_CLOCK_LATENCY( _pvalue_ ) HAL_CLOCK_READ(_pvalue_)
|
272 |
|
|
#endif
|
273 |
|
|
|
274 |
|
|
#define CYGHWR_HAL_CLOCK_CONTROL_DEFINED
|
275 |
|
|
|
276 |
|
|
#else
|
277 |
|
|
|
278 |
|
|
#error Unspecified TX39 variant
|
279 |
|
|
|
280 |
|
|
#endif
|
281 |
|
|
|
282 |
|
|
#endif
|
283 |
|
|
|
284 |
|
|
//--------------------------------------------------------------------------
|
285 |
|
|
// Timeout exception support. This is TX39 specific.
|
286 |
|
|
|
287 |
|
|
#if defined(CYGPKG_HAL_MIPS_TX3904)
|
288 |
|
|
|
289 |
|
|
#define HAL_TX39_DEBUG_TOE_ENABLE() \
|
290 |
|
|
{ \
|
291 |
|
|
HAL_IO_REGISTER _reg_ = CYG_HAL_MIPS_TX3904_CConR; \
|
292 |
|
|
CYG_WORD32 _cconr_; \
|
293 |
|
|
HAL_READ_UINT32( _reg_, _cconr_); \
|
294 |
|
|
_cconr_ |= 0x04000000; \
|
295 |
|
|
HAL_WRITE_UINT32( _reg_, _cconr_); \
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
#define HAL_TX39_DEBUG_TOE_DISABLE() \
|
299 |
|
|
{ \
|
300 |
|
|
HAL_IO_REGISTER _reg_ = CYG_HAL_MIPS_TX3904_CConR; \
|
301 |
|
|
CYG_WORD32 _cconr_; \
|
302 |
|
|
HAL_READ_UINT32( _reg_, _cconr_); \
|
303 |
|
|
_cconr_ &= 0xFBFFFFFF; \
|
304 |
|
|
HAL_WRITE_UINT32( _reg_, _cconr_); \
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
#else
|
308 |
|
|
|
309 |
|
|
#define HAL_TX39_DEBUG_TOE_ENABLE()
|
310 |
|
|
|
311 |
|
|
#define HAL_TX39_DEBUG_TOE_DISABLE()
|
312 |
|
|
|
313 |
|
|
#endif
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
//--------------------------------------------------------------------------
|
317 |
|
|
#endif // ifndef CYGONCE_HAL_IMP_INTR_H
|
318 |
|
|
// End of imp_intr.h
|