OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [fr30/] [mb91301/] [current/] [include/] [var_intr.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_IMP_INTR_H
2
#define CYGONCE_HAL_IMP_INTR_H
3
 
4
//==========================================================================
5
//
6
//      var_intr.h
7
//
8
//      MB91301 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 Free Software Foundation, 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      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    larsi
46
// Contributors: larsi
47
// Date:         2006-07-14
48
// Purpose:      MB91301 Interrupt support
49
// Description:  The macros defined here provide the HAL APIs for handling
50
//               interrupts and the clock for variants of the MB91301
51
//               architecture.
52
//              
53
// Usage:
54
//              #include <cyg/hal/imp_intr.h>
55
//              ...
56
//              
57
//
58
//####DESCRIPTIONEND####
59
//
60
//==========================================================================
61
 
62
#include <pkgconf/hal.h>
63
 
64
#include <cyg/infra/cyg_type.h>
65
 
66
#include <cyg/hal/hal_io.h>
67
 
68
#include <cyg/hal/plf_intr.h>
69
 
70
//--------------------------------------------------------------------------
71
// Interrupt vectors.
72
 
73
#ifndef CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
74
 
75
#define CYGNUM_HAL_INTERRUPT_0                     16
76
#define CYGNUM_HAL_INTERRUPT_1                     17
77
#define CYGNUM_HAL_INTERRUPT_2                     18
78
#define CYGNUM_HAL_INTERRUPT_3                     19
79
#define CYGNUM_HAL_INTERRUPT_4                     20
80
#define CYGNUM_HAL_INTERRUPT_5                     21
81
#define CYGNUM_HAL_INTERRUPT_6                     22
82
#define CYGNUM_HAL_INTERRUPT_7                     23
83
#define CYGNUM_HAL_INTERRUPT_RELOAD_TIMER0         24
84
#define CYGNUM_HAL_INTERRUPT_RELOAD_TIMER1         25
85
#define CYGNUM_HAL_INTERRUPT_RELOAD_TIMER2         26
86
#define CYGNUM_HAL_INTERRUPT_UART0_RX              27
87
#define CYGNUM_HAL_INTERRUPT_UART1_RX              28
88
#define CYGNUM_HAL_INTERRUPT_UART2_RX              29
89
#define CYGNUM_HAL_INTERRUPT_UART0_TX              30
90
#define CYGNUM_HAL_INTERRUPT_UART1_TX              31
91
#define CYGNUM_HAL_INTERRUPT_UART2_TX              32
92
#define CYGNUM_HAL_INTERRUPT_DMAC0                 33
93
#define CYGNUM_HAL_INTERRUPT_DMAC1                 34
94
#define CYGNUM_HAL_INTERRUPT_DMAC2                 35
95
#define CYGNUM_HAL_INTERRUPT_DMAC3                 36
96
#define CYGNUM_HAL_INTERRUPT_DMAC4                 37
97
#define CYGNUM_HAL_INTERRUPT_AD                    38
98
#define CYGNUM_HAL_INTERRUPT_PPG0                  39
99
#define CYGNUM_HAL_INTERRUPT_PPG1                  40
100
#define CYGNUM_HAL_INTERRUPT_PPG2                  41
101
#define CYGNUM_HAL_INTERRUPT_PPG3                  42
102
// system reserved #define CYGNUM_HAL_INTERRUPT_                43
103
#define CYGNUM_HAL_INTERRUPT_UTIMER0               44
104
#define CYGNUM_HAL_INTERRUPT_UTIMER1               45
105
#define CYGNUM_HAL_INTERRUPT_UTIMER2               46
106
#define CYGNUM_HAL_INTERRUPT_TIMEBASE_OVERFLOW     47
107
#define CYGNUM_HAL_INTERRUPT_I2C0                  48
108
#define CYGNUM_HAL_INTERRUPT_I2C1                  49
109
// system reserved #define CYGNUM_HAL_INTERRUPT_                 50
110
// system reserved #define CYGNUM_HAL_INTERRUPT_                 51
111
#define CYGNUM_HAL_INTERRUPT_FREERUN_TIMER         52
112
#define CYGNUM_HAL_INTERRUPT_ICU0                  53
113
#define CYGNUM_HAL_INTERRUPT_ICU1                  54
114
#define CYGNUM_HAL_INTERRUPT_ICU2                  55
115
#define CYGNUM_HAL_INTERRUPT_ICU3                  56
116
// system reserved #define CYGNUM_HAL_INTERRUPT_             57
117
// system reserved #define CYGNUM_HAL_INTERRUPT_             58
118
// system reserved #define CYGNUM_HAL_INTERRUPT_             59
119
// system reserved #define CYGNUM_HAL_INTERRUPT_             60
120
// system reserved #define CYGNUM_HAL_INTERRUPT_             61
121
// system reserved #define CYGNUM_HAL_INTERRUPT_             62
122
#define CYGNUM_HAL_INTERRUPT_DELAYED_IRQ           63
123
 
124
// The interrupt vector used by the RTC, aka tick timer
125
#define CYGNUM_HAL_INTERRUPT_RTC            CYGNUM_HAL_INTERRUPT_RELOAD_TIMER1
126
 
127
#define CYGHWR_HAL_INTERRUPT_VECTORS_DEFINED
128
 
129
#endif
130
 
131
//--------------------------------------------------------------------------
132
// Interrupt controller access.
133
 
134
// currently only external interrupts are masked using the external
135
// interrupt controller. This means only vectors 16 to 23 are valid.
136
// Other interrupts may be masked in the future
137
// using the mask mechanism for interrupt levels, if needed.
138
 
139
#ifndef CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
140
 
141
#define CYG_HAL_FR30_MB91301_ENIR     0x41
142
#define CYG_HAL_FR30_MB91301_EIRR     0x40
143
#define CYG_HAL_FR30_MB91301_ELVR     0x42
144
#define CYG_HAL_FR30_MB91301_ICR00    0x440
145
 
146
// Array which stores the configured priority levels for the configured
147
// interrupts.
148
// this will be useful, if we implement masking of non external interrupts
149
// externC volatile CYG_BYTE hal_interrupt_level[CYGNUM_HAL_ISR_COUNT];
150
 
151
 
152
#define HAL_INTERRUPT_MASK( _vector_ )                       \
153
{                                                            \
154
    CYG_WORD32 _ilr_;                                        \
155
    if ((_vector_ >= CYGNUM_HAL_INTERRUPT_7) &&              \
156
          (_vector_ <= CYGNUM_HAL_INTERRUPT_0)){             \
157
        HAL_READ_UINT8( CYG_HAL_FR30_MB91301_ENIR, _ilr_ );  \
158
        _ilr_ &= ~(1<<((_vector_)>>4));                      \
159
        HAL_WRITE_UINT8( CYG_HAL_FR30_MB91301_ENIR, _ilr_ ); \
160
    }                                                        \
161
    /* Handle RTC masking special */                         \
162
    if (_vector_ == CYGNUM_HAL_INTERRUPT_RTC)                \
163
        asm volatile("ldi:8     #0x57,  r0;\n"               \
164
                     "bandl     #0x7,   @r0;\n"              \
165
                      : : :"r0");                            \
166
}
167
 
168
#define HAL_INTERRUPT_UNMASK( _vector_ )                     \
169
{                                                            \
170
    CYG_WORD32 _ilr_;                                        \
171
    if ((_vector_ >= CYGNUM_HAL_INTERRUPT_7) &&              \
172
          (_vector_ <= CYGNUM_HAL_INTERRUPT_0)){             \
173
        HAL_READ_UINT8( CYG_HAL_FR30_MB91301_ENIR, _ilr_ );  \
174
        _ilr_ |= (1<<((_vector_)>>4));                       \
175
        HAL_WRITE_UINT8( CYG_HAL_FR30_MB91301_ENIR, _ilr_ ); \
176
    }                                                        \
177
    /* Handle RTC unmasking special */                       \
178
    if (_vector_ == CYGNUM_HAL_INTERRUPT_RTC)                \
179
        asm volatile("ldi:8     #0x57,  r0;\n"               \
180
                     "borl      #0x8,   @r0;\n"              \
181
                      : : :"r0");                            \
182
}
183
 
184
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )                \
185
{                                                            \
186
    CYG_WORD32 _ilr_;                                        \
187
    if ((_vector_ >= CYGNUM_HAL_INTERRUPT_7) &&              \
188
          (_vector_ <= CYGNUM_HAL_INTERRUPT_0)){             \
189
        HAL_READ_UINT8( CYG_HAL_FR30_MB91301_EIRR, _ilr_ );  \
190
        _ilr_ &= ~(1<<((_vector_)>>4));                      \
191
        HAL_WRITE_UINT8( CYG_HAL_FR30_MB91301_EIRR, _ilr_ ); \
192
    }                                                        \
193
    /* Handle RTC acknowledging special */                   \
194
    if (_vector_ == CYGNUM_HAL_INTERRUPT_RTC)                \
195
        asm volatile("ldi:8     #0x57,  r0;\n"               \
196
                     "bandl     #0xb,   @r0;\n"              \
197
                      : : :"r0");                            \
198
}
199
 
200
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )              \
201
{                                                                       \
202
        /* subtract 15 from vector */                                   \
203
        cyg_uint32 _v_ = _vector_ >> 4;                                 \
204
        cyg_uint16 _val_ = 0;                                           \
205
        cyg_uint16 _reg_;                                               \
206
                                                                        \
207
            if ((_vector_ >= CYGNUM_HAL_INTERRUPT_7) &&                 \
208
                (_vector_ <= CYGNUM_HAL_INTERRUPT_0)){                  \
209
                                                                        \
210
        /* set bits according to requirements */                        \
211
        if( _up_ ) _val_ |= 1;                                          \
212
        if( !(_level_) ) _val_ |= 2;                                    \
213
                                                                        \
214
        /* get old ELVR */                                              \
215
        HAL_READ_UINT16( CYG_HAL_FR30_MB91301_ELVR, _reg_ );            \
216
                                                                        \
217
        /* clear old value and set new */                               \
218
        _reg_ &= ~(3 << _v_);                                           \
219
        _reg_ |= _val_ << _v_;                                          \
220
        HAL_WRITE_UINT16( CYG_HAL_FR30_MB91301_ELVR, _reg_ );           \
221
    }                                                                   \
222
}
223
 
224
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )                    \
225
{                                                                       \
226
    /* subtract 15 from vector */                                       \
227
    cyg_uint32 _v_ = _vector_ >> 4;                                     \
228
    CYG_WORD32 _ilr_;                                                   \
229
/*    HAL_READ_UINT8( CYG_HAL_FR30_MB91301_ICR00 + _vector_, _ilr_ );*/ \
230
/* reading before writing is only needed, if UINT8 writing is not */    \
231
/* possible to IO 0x440   */                                              \
232
    _ilr_ = (_level_);                                                  \
233
    HAL_WRITE_UINT8( CYG_HAL_FR30_MB91301_ICR00 + _vector_, _ilr_ );    \
234
/*  for later use:  */                                                    \
235
/*    hal_interrupt_level[_vector_] = _level_;      */                    \
236
}
237
 
238
#define CYGHWR_HAL_INTERRUPT_CONTROLLER_ACCESS_DEFINED
239
 
240
#endif
241
 
242
//--------------------------------------------------------------------------
243
// Clock control registers
244
 
245
// MB91301 series has 3 built-in timer channels.
246
// Timer 2 is used for delay and timer 1 for RTC/*delay*/.
247
// Timer 0 and 1 can activate DMA and this feature is propably needed by
248
// the application. Timer 0 is free to use by the application.
249
 
250
#define CYG_HAL_FR30_DLY_TMCSR          0x5e
251
#define CYG_HAL_FR30_DLY_TMR            0x5a
252
#define CYG_HAL_FR30_DLY_TMRLR          0x58
253
#define CYG_HAL_FR30_RTC_TMCSR          0x56
254
#define CYG_HAL_FR30_RTC_TMR            0x52
255
#define CYG_HAL_FR30_RTC_TMRLR          0x50
256
 
257
 
258
 
259
//--------------------------------------------------------------------------
260
// Control-C support.
261
 
262
#if defined(CYGDBG_HAL_FR30_DEBUG_GDB_CTRLC_SUPPORT)
263
 
264
#define CYGHWR_HAL_GDB_PORT_VECTOR CYGNUM_HAL_INTERRUPT_DUART
265
 
266
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
267
 
268
#define HAL_CTRLC_ISR hal_ctrlc_isr
269
 
270
#endif
271
 
272
//--------------------------------------------------------------------------
273
#endif // ifndef CYGONCE_HAL_IMP_INTR_H
274
// End of imp_intr.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.