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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libchip/] [serial/] [ns16550_p.h] - Blame information for rev 609

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *  COPYRIGHT (c) 1998 by Radstone Technology
3
 *
4
 *
5
 * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
6
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
7
 * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
8
 * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
9
 *
10
 * You are hereby granted permission to use, copy, modify, and distribute
11
 * this file, provided that this notice, plus the above copyright notice
12
 * and disclaimer, appears in all copies. Radstone Technology will provide
13
 * no support for this code.
14
 *
15
 *  $Id: ns16550_p.h,v 1.2 2001-09-27 12:01:42 chris Exp $
16
 */
17
 
18
#ifndef _NS16550_P_H_
19
#define _NS16550_P_H_
20
 
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
 
25
/*
26
 *  Define NS16550_STATIC to nothing while debugging so the entry points
27
 *  will show up in the symbol table.
28
 */
29
 
30
#define NS16550_STATIC
31
 
32
/* #define NS16550_STATIC static */
33
 
34
/*
35
 * Define serial port read registers structure.
36
 */
37
 
38
typedef volatile struct _SP_READ_REGISTERS {
39
    unsigned char ReceiveBuffer;
40
    unsigned char InterruptEnable;
41
    unsigned char InterruptId;
42
    unsigned char LineControl;
43
    unsigned char ModemControl;
44
    unsigned char LineStatus;
45
    unsigned char ModemStatus;
46
    unsigned char ScratchPad;
47
} SP_READ_REGISTERS, *PSP_READ_REGISTERS;
48
 
49
#define NS16550_RECEIVE_BUFFER   0
50
#define NS16550_INTERRUPT_ENABLE 1
51
#define NS16550_INTERRUPT_ID     2
52
#define NS16550_LINE_CONTROL     3
53
#define NS16550_MODEM_CONTROL    4
54
#define NS16550_LINE_STATUS      5
55
#define NS16550_MODEM_STATUS     6
56
#define NS16550_SCRATCH_PAD      7
57
 
58
/*
59
 * Define serial port write registers structure.
60
 */
61
 
62
typedef volatile struct _SP_WRITE_REGISTERS {
63
    unsigned char TransmitBuffer;
64
    unsigned char InterruptEnable;
65
    unsigned char FifoControl;
66
    unsigned char LineControl;
67
    unsigned char ModemControl;
68
    unsigned char Reserved1;
69
    unsigned char ModemStatus;
70
    unsigned char ScratchPad;
71
} SP_WRITE_REGISTERS, *PSP_WRITE_REGISTERS;
72
 
73
#define NS16550_TRANSMIT_BUFFER  0
74
#define NS16550_FIFO_CONTROL     2
75
 
76
/*
77
 * Define serial port interrupt enable register structure.
78
 */
79
 
80
#define SP_INT_RX_ENABLE  0x01
81
#define SP_INT_TX_ENABLE  0x02
82
#define SP_INT_LS_ENABLE  0x04
83
#define SP_INT_MS_ENABLE  0x08
84
 
85
#define NS16550_ENABLE_ALL_INTR           (SP_INT_RX_ENABLE | SP_INT_TX_ENABLE)
86
#define NS16550_DISABLE_ALL_INTR          0x00
87
#define NS16550_ENABLE_ALL_INTR_EXCEPT_TX (SP_INT_RX_ENABLE)
88
 
89
/*
90
 * Define serial port interrupt id register structure.
91
 */
92
 
93
typedef struct _SP_INTERRUPT_ID {
94
    unsigned char InterruptPending : 1;
95
    unsigned char Identification : 3;
96
    unsigned char Reserved1 : 2;
97
    unsigned char FifoEnabled : 2;
98
} SP_INTERRUPT_ID, *PSP_INTERRUPT_ID;
99
 
100
/*
101
 * Define serial port fifo control register structure.
102
 */
103
 
104
#define SP_FIFO_ENABLE  0x01
105
#define SP_FIFO_RXRST 0x02
106
#define SP_FIFO_TXRST 0x04
107
#define SP_FIFO_DMA   0x08
108
#define SP_FIFO_RXLEVEL 0xc0
109
 
110
/*
111
 * Define serial port line control register structure.
112
 */
113
 
114
#define SP_LINE_SIZE  0x03
115
#define SP_LINE_STOP  0x04
116
#define SP_LINE_PAR   0x08
117
#define SP_LINE_ODD   0x10
118
#define SP_LINE_STICK 0x20
119
#define SP_LINE_BREAK 0x40
120
#define SP_LINE_DLAB  0x80
121
 
122
/*
123
 * Line status register character size definitions.
124
 */
125
 
126
#define FIVE_BITS 0x0                   /* five bits per character */
127
#define SIX_BITS 0x1                    /* six bits per character */
128
#define SEVEN_BITS 0x2                  /* seven bits per character */
129
#define EIGHT_BITS 0x3                  /* eight bits per character */
130
 
131
/*
132
 * Line speed divisor definition.
133
 */
134
 
135
#define NS16550_Baud(_clock, _baud_rate) \
136
  ((((_clock) == 0) ? 115200 : (_clock))/(_baud_rate))
137
 
138
/*
139
 * Define serial port modem control register structure.
140
 */
141
 
142
#define SP_MODEM_DTR  0x01
143
#define SP_MODEM_RTS  0x02
144
#define SP_MODEM_IRQ  0x08
145
#define SP_MODEM_LOOP 0x10
146
#define SP_MODEM_DIV4 0x80
147
 
148
/*
149
 * Define serial port line status register structure.
150
 */
151
 
152
#define SP_LSR_RDY    0x01
153
#define SP_LSR_EOVRUN 0x02
154
#define SP_LSR_EPAR   0x04
155
#define SP_LSR_EFRAME 0x08
156
#define SP_LSR_BREAK  0x10
157
#define SP_LSR_THOLD  0x20
158
#define SP_LSR_TX   0x40
159
#define SP_LSR_EFIFO  0x80
160
 
161
typedef struct _ns16550_context
162
{
163
        unsigned8       ucModemCtrl;
164
} ns16550_context;
165
 
166
/*
167
 * Driver functions
168
 */
169
 
170
NS16550_STATIC boolean ns16550_probe(int minor);
171
 
172
NS16550_STATIC void ns16550_init(int minor);
173
 
174
NS16550_STATIC int ns16550_open(
175
  int major,
176
  int minor,
177
  void  * arg
178
);
179
 
180
NS16550_STATIC int ns16550_close(
181
  int major,
182
  int minor,
183
  void  * arg
184
);
185
 
186
NS16550_STATIC void ns16550_write_polled(
187
  int   minor,
188
  char  cChar
189
);
190
 
191
NS16550_STATIC int ns16550_assert_RTS(
192
  int minor
193
);
194
 
195
NS16550_STATIC int ns16550_negate_RTS(
196
  int minor
197
);
198
 
199
NS16550_STATIC int ns16550_assert_DTR(
200
  int minor
201
);
202
 
203
NS16550_STATIC int ns16550_negate_DTR(
204
  int minor
205
);
206
 
207
NS16550_STATIC void ns16550_initialize_interrupts(int minor);
208
 
209
NS16550_STATIC int ns16550_write_support_int(
210
  int   minor,
211
  const char *buf,
212
  int   len
213
);
214
 
215
NS16550_STATIC int ns16550_write_support_polled(
216
  int   minor,
217
  const char *buf,
218
  int   len
219
  );
220
 
221
NS16550_STATIC int ns16550_inbyte_nonblocking_polled(
222
  int minor
223
);
224
 
225
NS16550_STATIC void ns16550_enable_interrupts(
226
  int minor,
227
  int mask
228
);
229
 
230
NS16550_STATIC int ns16550_set_attributes(
231
  int                   minor,
232
  const struct termios *t
233
);
234
 
235
#ifdef __cplusplus
236
}
237
#endif
238
 
239
#endif /* _NS16550_P_H_ */

powered by: WebSVN 2.1.0

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