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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparclite/] [sleb/] [current/] [include/] [hal_hwio.h] - Blame information for rev 817

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_HAL_HWIO_H
2
#define CYGONCE_HAL_HAL_HWIO_H
3
 
4
/*=============================================================================
5
//
6
//      hal_hwio.h
7
//
8
//      HAL Support for IO to platform-specific devices
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):   hmt
46
// Contributors:        hmt
47
// Date:        1999-01-11
48
// Purpose:     HAL Support for IO to platform-specific devices
49
// Description: Macros to access the 86940 SPARClite companion chip
50
// Usage:       #include <cyg/hal/hal_hwio.h>
51
//
52
//####DESCRIPTIONEND####
53
//
54
//===========================================================================*/
55
 
56
#include <pkgconf/system.h>
57
#include <pkgconf/hal.h>
58
#include <pkgconf/hal_sparclite.h>
59
#include <pkgconf/hal_sparclite_sleb.h>
60
 
61
#include <cyg/infra/cyg_type.h>
62
 
63
/*---------------------------------------------------------------------------*/
64
/* MB86940 flags and the like                                                */
65
 
66
/* Interrupt trigger modes. */
67
#define HAL_SPARC_86940_TRIG_LEVEL_H   0   /* trigger on high level   */
68
#define HAL_SPARC_86940_TRIG_LEVEL_L   1   /* trigger on low level    */
69
#define HAL_SPARC_86940_TRIG_EDGE_H    2   /* trigger on rising edge  */
70
#define HAL_SPARC_86940_TRIG_EDGE_L    3   /* trigger on falling edge */
71
 
72
/* Timer prescaler register values */
73
#define HAL_SPARC_86940_PRS_EXTCLK    0x8000
74
#define HAL_SPARC_86940_PRS_ODIV1     (0<<8)
75
#define HAL_SPARC_86940_PRS_ODIV2     (1<<8)
76
#define HAL_SPARC_86940_PRS_ODIV4     (2<<8)
77
#define HAL_SPARC_86940_PRS_ODIV8     (3<<8)
78
#define HAL_SPARC_86940_PRS_ODIV16    (4<<8)
79
#define HAL_SPARC_86940_PRS_ODIV32    (5<<8)
80
#define HAL_SPARC_86940_PRS_ODIV64    (6<<8)
81
#define HAL_SPARC_86940_PRS_ODIV128   (7<<8)
82
 
83
/* Timer control register values */
84
#define HAL_SPARC_86940_TCR_CE          (1<<11)
85
#define HAL_SPARC_86940_TCR_CLKINT      (0<<9)
86
#define HAL_SPARC_86940_TCR_CLKEXT      (1<<9)
87
#define HAL_SPARC_86940_TCR_CLKPRS      (2<<9)
88
#define HAL_SPARC_86940_TCR_CLKRSVD     (3<<9)
89
#define HAL_SPARC_86940_TCR_OUTSAME     (0<<7)
90
#define HAL_SPARC_86940_TCR_OUTHIGH     (1<<7)
91
#define HAL_SPARC_86940_TCR_OUTLOW      (2<<7)
92
#define HAL_SPARC_86940_TCR_OUTC3       (3<<7)
93
#define HAL_SPARC_86940_TCR_INV         (1<<6)
94
#define HAL_SPARC_86940_TCR_PER_INT     (0<<3)
95
#define HAL_SPARC_86940_TCR_TO_INT      (1<<3)
96
#define HAL_SPARC_86940_TCR_SQWAVE      (2<<3)
97
#define HAL_SPARC_86940_TCR_SW_WATCH    (3<<3)
98
#define HAL_SPARC_86940_TCR_HW_WATCH    (4<<3)
99
#define HAL_SPARC_86940_TCR_LEVEL_L     0
100
#define HAL_SPARC_86940_TCR_LEVEL_H     1
101
#define HAL_SPARC_86940_TCR_EDGE_H      2
102
#define HAL_SPARC_86940_TCR_EDGE_L      3
103
#define HAL_SPARC_86940_TCR_EDGE        4
104
 
105
/* serial mode register values */
106
#define HAL_SPARC_86940_SER_STOP0       (0<<6)
107
#define HAL_SPARC_86940_SER_STOP1       (1<<6)
108
#define HAL_SPARC_86940_SER_STOP1_5     (2<<6)
109
#define HAL_SPARC_86940_SER_STOP2       (3<<6)
110
#define HAL_SPARC_86940_SER_NO_PARITY   (0<<4)
111
#define HAL_SPARC_86940_SER_ODD_PARITY  (1<<4)
112
#define HAL_SPARC_86940_SER_EVEN_PARITY (3<<4)
113
#define HAL_SPARC_86940_SER_5BITS       (0<<2)
114
#define HAL_SPARC_86940_SER_6BITS       (1<<2)
115
#define HAL_SPARC_86940_SER_7BITS       (2<<2)
116
#define HAL_SPARC_86940_SER_8BITS       (3<<2)
117
#define HAL_SPARC_86940_SER_MODE_SYNCH  0
118
#define HAL_SPARC_86940_SER_DIV1_CLK    1
119
#define HAL_SPARC_86940_SER_DIV16_CLK   2
120
#define HAL_SPARC_86940_SER_DIV64_CLK   3
121
 
122
/* serial command register (asynch) */
123
#define HAL_SPARC_86940_SER_CMD_EHM     (1<<7)
124
#define HAL_SPARC_86940_SER_CMD_IRST    (1<<6)
125
#define HAL_SPARC_86940_SER_CMD_RTS     (1<<5)
126
#define HAL_SPARC_86940_SER_CMD_EFR     (1<<4)
127
#define HAL_SPARC_86940_SER_CMD_BREAK   (1<<3)
128
#define HAL_SPARC_86940_SER_CMD_RXEN    (1<<2)
129
#define HAL_SPARC_86940_SER_CMD_DTR     (1<<1)
130
#define HAL_SPARC_86940_SER_CMD_TXEN    (1<<0)
131
 
132
/* serial status register */
133
#define HAL_SPARC_86940_SER_STAT_DSR    (1<<7)
134
#define HAL_SPARC_86940_SER_STAT_BREAK  (1<<6)
135
#define HAL_SPARC_86940_SER_STAT_FERR   (1<<5)
136
#define HAL_SPARC_86940_SER_STAT_OERR   (1<<4)
137
#define HAL_SPARC_86940_SER_STAT_PERR   (1<<3)
138
#define HAL_SPARC_86940_SER_STAT_TXEMP  (1<<2)
139
#define HAL_SPARC_86940_SER_STAT_RXRDY  (1<<1)
140
#define HAL_SPARC_86940_SER_STAT_TXRDY  (1<<0)
141
 
142
#define HAL_SPARC_86940_CHIP_ASI        4
143
#define HAL_SPARC_86940_CHIP_BASE       0x10000000
144
#define HAL_SPARC_86940_REGADDR_SHIFT   2
145
#define HAL_SPARC_86940_REGVAL_SHIFT    16
146
 
147
/*---------------------------------------------------------------------------*/
148
/* Register addresses                                                        */
149
 
150
// The "interesting" IO parts are in Address Space Four:
151
#define HAL_SPARC_ASI_4_READ( addr, res )                                   \
152
    asm volatile(                                                           \
153
        "lda [ %1 ] 4, %0"                                                  \
154
        : "=r"(res)                                                         \
155
        : "r"(addr)                                                         \
156
    );
157
 
158
#define HAL_SPARC_ASI_4_WRITE( addr, val )                                  \
159
    asm volatile(                                                           \
160
        "sta %0, [ %1 ] 4"                                                  \
161
        :                                                                   \
162
        : "r"(val),"r"(addr)                                                \
163
    );
164
 
165
#define HAL_SPARC_86940_BASE (0x10000000)  // in ASI 4
166
 
167
// The 86940 is connected to the upper 16 bits!
168
#define HAL_SPARC_86940_READ( reg, result ) CYG_MACRO_START                 \
169
        cyg_uint32 hires;                                                   \
170
        HAL_SPARC_ASI_4_READ( reg + HAL_SPARC_86940_BASE, hires );          \
171
        hires >>= 16;                                                       \
172
        result = hires;                                                     \
173
CYG_MACRO_END
174
 
175
// THIS IS ONLY HERE FOR DEBUGGING:
176
// The 86940 is connected to the upper 16 bits!
177
// And seems to be an unreliable deprecated thing...
178
// so read it 3 times and believe the majority.
179
#define HAL_SPARC_86940_READ3( reg, result ) CYG_MACRO_START                \
180
        cyg_uint32 hires1;                                                  \
181
        cyg_uint32 hires2;                                                  \
182
        cyg_uint32 hires3;                                                  \
183
        HAL_SPARC_ASI_4_READ( reg + HAL_SPARC_86940_BASE, hires1 );         \
184
        HAL_SPARC_ASI_4_READ( reg + HAL_SPARC_86940_BASE, hires2 );         \
185
        HAL_SPARC_ASI_4_READ( reg + HAL_SPARC_86940_BASE, hires3 );         \
186
        result = ((hires1&hires2)|(hires1&hires3)|(hires2&hires3)) >> 16;   \
187
CYG_MACRO_END
188
 
189
#define HAL_SPARC_86940_WRITE( reg, value ) CYG_MACRO_START                 \
190
        cyg_uint32 hival = (value) << 16;                                   \
191
        HAL_SPARC_ASI_4_WRITE( reg + HAL_SPARC_86940_BASE, hival );         \
192
CYG_MACRO_END
193
 
194
// Registers are at word offsets
195
#define HAL_SPARC_86940_REG_SDTR0_TXDATA ( 0x08 * 4 )
196
#define HAL_SPARC_86940_REG_SDTR0_RXDATA ( 0x08 * 4 )
197
#define HAL_SPARC_86940_REG_SDTR0_STAT   ( 0x09 * 4 )
198
#define HAL_SPARC_86940_REG_SDTR0_CTRL   ( 0x09 * 4 )
199
#define HAL_SPARC_86940_REG_SDTR1_TXDATA ( 0x0c * 4 )
200
#define HAL_SPARC_86940_REG_SDTR1_RXDATA ( 0x0c * 4 )
201
#define HAL_SPARC_86940_REG_SDTR1_STAT   ( 0x0d * 4 )
202
#define HAL_SPARC_86940_REG_SDTR1_CTRL   ( 0x0d * 4 )
203
 
204
#define HAL_SPARC_86940_REG_PRS0         ( 0x10 * 4 )
205
#define HAL_SPARC_86940_REG_TCR0         ( 0x11 * 4 )
206
#define HAL_SPARC_86940_REG_RELOAD0      ( 0x12 * 4 )
207
#define HAL_SPARC_86940_REG_CNT0         ( 0x13 * 4 )
208
#define HAL_SPARC_86940_REG_PRS1         ( 0x14 * 4 )
209
#define HAL_SPARC_86940_REG_TCR1         ( 0x15 * 4 )
210
#define HAL_SPARC_86940_REG_RELOAD1      ( 0x16 * 4 )
211
#define HAL_SPARC_86940_REG_CNT1         ( 0x17 * 4 )
212
#define HAL_SPARC_86940_REG_TCR2         ( 0x19 * 4 )
213
#define HAL_SPARC_86940_REG_RELOAD2      ( 0x1A * 4 )
214
#define HAL_SPARC_86940_REG_CNT2         ( 0x1B * 4 )
215
#define HAL_SPARC_86940_REG_TCR3         ( 0x1D * 4 )
216
#define HAL_SPARC_86940_REG_RELOAD3      ( 0x1E * 4 )
217
#define HAL_SPARC_86940_REG_CNT3         ( 0x1F * 4 )
218
 
219
// Glue together to access them neatly
220
#define HAL_SPARC_86940_SDTR0_TXDATA_WRITE( v ) \
221
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_SDTR0_TXDATA, v )
222
#define HAL_SPARC_86940_SDTR0_RXDATA_READ( r ) \
223
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_SDTR0_RXDATA, r )
224
 
225
#define HAL_SPARC_86940_SDTR0_STAT_READ( r ) \
226
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_SDTR0_STAT, r )
227
#define HAL_SPARC_86940_SDTR0_CTRL_WRITE( v ) \
228
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_SDTR0_CTRL, v )
229
 
230
#define HAL_SPARC_86940_SDTR1_TXDATA_WRITE( v ) \
231
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_SDTR1_TXDATA, v )
232
#define HAL_SPARC_86940_SDTR1_RXDATA_READ( r ) \
233
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_SDTR1_RXDATA, r )
234
 
235
#define HAL_SPARC_86940_SDTR1_STAT_READ( r ) \
236
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_SDTR1_STAT, r )
237
#define HAL_SPARC_86940_SDTR1_CTRL_WRITE( v ) \
238
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_SDTR1_CTRL, v )
239
 
240
#define HAL_SPARC_86940_PRS0_READ( r ) \
241
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_PRS0, r )
242
#define HAL_SPARC_86940_PRS0_WRITE( v ) \
243
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_PRS0, v )
244
 
245
#define HAL_SPARC_86940_TCR0_READ( r ) \
246
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TCR0, r )
247
#define HAL_SPARC_86940_TCR0_WRITE( v ) \
248
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TCR0, v )
249
 
250
#define HAL_SPARC_86940_RELOAD0_READ( r ) \
251
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_RELOAD0, r )
252
#define HAL_SPARC_86940_RELOAD0_WRITE( v ) \
253
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_RELOAD0, v )
254
 
255
#define HAL_SPARC_86940_CNT0_READ( r ) \
256
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_CNT0, r )
257
#define HAL_SPARC_86940_CNT0_WRITE( v ) \
258
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_CNT0, v )
259
 
260
#define HAL_SPARC_86940_PRS1_READ( r ) \
261
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_PRS1, r )
262
#define HAL_SPARC_86940_PRS1_WRITE( v ) \
263
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_PRS1, v )
264
 
265
#define HAL_SPARC_86940_TCR1_READ( r ) \
266
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TCR1, r )
267
#define HAL_SPARC_86940_TCR1_WRITE( v ) \
268
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TCR1, v )
269
 
270
#define HAL_SPARC_86940_RELOAD1_READ( r ) \
271
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_RELOAD1, r )
272
#define HAL_SPARC_86940_RELOAD1_WRITE( v ) \
273
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_RELOAD1, v )
274
 
275
#define HAL_SPARC_86940_CNT1_READ( r ) \
276
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_CNT1, r )
277
#define HAL_SPARC_86940_CNT1_WRITE( v ) \
278
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_CNT1, v )
279
 
280
#define HAL_SPARC_86940_TCR2_READ( r ) \
281
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TCR2, r )
282
#define HAL_SPARC_86940_TCR2_WRITE( v ) \
283
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TCR2, v )
284
 
285
#define HAL_SPARC_86940_RELOAD2_READ( r ) \
286
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_RELOAD2, r )
287
#define HAL_SPARC_86940_RELOAD2_WRITE( v ) \
288
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_RELOAD2, v )
289
 
290
#define HAL_SPARC_86940_CNT2_READ( r ) \
291
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_CNT2, r )
292
#define HAL_SPARC_86940_CNT2_WRITE( v ) \
293
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_CNT2, v )
294
 
295
#define HAL_SPARC_86940_TCR3_READ( r ) \
296
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TCR3, r )
297
#define HAL_SPARC_86940_TCR3_WRITE( v ) \
298
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TCR3, v )
299
 
300
#define HAL_SPARC_86940_RELOAD3_READ( r ) \
301
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_RELOAD3, r )
302
#define HAL_SPARC_86940_RELOAD3_WRITE( v ) \
303
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_RELOAD3, v )
304
 
305
#define HAL_SPARC_86940_CNT3_READ( r ) \
306
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_CNT3, r )
307
#define HAL_SPARC_86940_CNT3_WRITE( v ) \
308
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_CNT3, v )
309
 
310
/*---------------------------------------------------------------------------*/
311
/* end of hal_hwio.h                                                         */
312
#endif /* CYGONCE_HAL_HAL_HWIO_H */

powered by: WebSVN 2.1.0

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