source: rtems/c/src/libchip/serial/ns16550_p.h @ e97e0e0

4.104.11
Last change on this file since e97e0e0 was e97e0e0, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Sep 22, 2008 at 11:46:15 AM

Include required header files. Removed support for old PowerPC exception handling. Various fixes for interrupt related routines. Added support for BSPs with IRQ extension API.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
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$
16 */
17
18#ifndef _NS16550_P_H_
19#define _NS16550_P_H_
20
21#ifdef __cplusplus
22extern "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 static
31
32/*
33 * Define serial port read registers structure.
34 */
35
36typedef volatile struct _SP_READ_REGISTERS {
37    unsigned char ReceiveBuffer;
38    unsigned char InterruptEnable;
39    unsigned char InterruptId;
40    unsigned char LineControl;
41    unsigned char ModemControl;
42    unsigned char LineStatus;
43    unsigned char ModemStatus;
44    unsigned char ScratchPad;
45} SP_READ_REGISTERS, *PSP_READ_REGISTERS;
46
47#define NS16550_RECEIVE_BUFFER   0
48#define NS16550_INTERRUPT_ENABLE 1
49#define NS16550_INTERRUPT_ID     2
50#define NS16550_LINE_CONTROL     3
51#define NS16550_MODEM_CONTROL    4
52#define NS16550_LINE_STATUS      5
53#define NS16550_MODEM_STATUS     6
54#define NS16550_SCRATCH_PAD      7
55
56/*
57 * Define serial port write registers structure.
58 */
59
60typedef volatile struct _SP_WRITE_REGISTERS {
61    unsigned char TransmitBuffer;
62    unsigned char InterruptEnable;
63    unsigned char FifoControl;
64    unsigned char LineControl;
65    unsigned char ModemControl;
66    unsigned char Reserved1;
67    unsigned char ModemStatus;
68    unsigned char ScratchPad;
69} SP_WRITE_REGISTERS, *PSP_WRITE_REGISTERS;
70
71#define NS16550_TRANSMIT_BUFFER  0
72#define NS16550_FIFO_CONTROL     2
73
74/*
75 * Define serial port interrupt enable register structure.
76 */
77
78#define SP_INT_RX_ENABLE  0x01
79#define SP_INT_TX_ENABLE  0x02
80#define SP_INT_LS_ENABLE  0x04
81#define SP_INT_MS_ENABLE  0x08
82
83#define NS16550_ENABLE_ALL_INTR           (SP_INT_RX_ENABLE | SP_INT_TX_ENABLE)
84#define NS16550_DISABLE_ALL_INTR          0x00
85#define NS16550_ENABLE_ALL_INTR_EXCEPT_TX (SP_INT_RX_ENABLE)
86
87/*
88 * Define serial port interrupt id register structure.
89 */
90
91typedef struct _SP_INTERRUPT_ID {
92    unsigned char InterruptPending : 1;
93    unsigned char Identification : 3;
94    unsigned char Reserved1 : 2;
95    unsigned char FifoEnabled : 2;
96} SP_INTERRUPT_ID, *PSP_INTERRUPT_ID;
97
98/*
99 * Define serial port fifo control register structure.
100 */
101
102#define SP_FIFO_ENABLE  0x01
103#define SP_FIFO_RXRST 0x02
104#define SP_FIFO_TXRST 0x04
105#define SP_FIFO_DMA   0x08
106#define SP_FIFO_RXLEVEL 0xc0
107
108/*
109 * Define serial port line control register structure.
110 */
111
112#define SP_LINE_SIZE  0x03
113#define SP_LINE_STOP  0x04
114#define SP_LINE_PAR   0x08
115#define SP_LINE_ODD   0x10
116#define SP_LINE_STICK 0x20
117#define SP_LINE_BREAK 0x40
118#define SP_LINE_DLAB  0x80
119
120/*
121 * Line status register character size definitions.
122 */
123
124#define FIVE_BITS 0x0                   /* five bits per character */
125#define SIX_BITS 0x1                    /* six bits per character */
126#define SEVEN_BITS 0x2                  /* seven bits per character */
127#define EIGHT_BITS 0x3                  /* eight bits per character */
128
129/*
130 * Line speed divisor definition.
131 */
132
133#define NS16550_Baud(_clock, _baud_rate) \
134  ((((_clock) == 0) ? 115200 : (_clock))/(_baud_rate*16))
135
136/*
137 * Define serial port modem control register structure.
138 */
139
140#define SP_MODEM_DTR  0x01
141#define SP_MODEM_RTS  0x02
142#define SP_MODEM_IRQ  0x08
143#define SP_MODEM_LOOP 0x10
144#define SP_MODEM_DIV4 0x80
145
146/*
147 * Define serial port line status register structure.
148 */
149
150#define SP_LSR_RDY    0x01
151#define SP_LSR_EOVRUN 0x02
152#define SP_LSR_EPAR   0x04
153#define SP_LSR_EFRAME 0x08
154#define SP_LSR_BREAK  0x10
155#define SP_LSR_THOLD  0x20
156#define SP_LSR_TX   0x40
157#define SP_LSR_EFIFO  0x80
158
159typedef struct _ns16550_context
160{
161        uint8_t         ucModemCtrl;
162} ns16550_context;
163
164/*
165 * Driver functions
166 */
167
168NS16550_STATIC bool ns16550_probe(int minor);
169
170NS16550_STATIC void ns16550_init(int minor);
171
172NS16550_STATIC int ns16550_open(
173  int major,
174  int minor,
175  void  * arg
176);
177
178NS16550_STATIC int ns16550_close(
179  int major,
180  int minor,
181  void  * arg
182);
183
184NS16550_STATIC void ns16550_write_polled(
185  int   minor,
186  char  cChar
187);
188
189NS16550_STATIC int ns16550_assert_RTS(
190  int minor
191);
192
193NS16550_STATIC int ns16550_negate_RTS(
194  int minor
195);
196
197NS16550_STATIC int ns16550_assert_DTR(
198  int minor
199);
200
201NS16550_STATIC int ns16550_negate_DTR(
202  int minor
203);
204
205NS16550_STATIC void ns16550_initialize_interrupts(int minor);
206
207NS16550_STATIC int ns16550_write_support_int(
208  int   minor,
209  const char *buf,
210  int   len
211);
212
213NS16550_STATIC int ns16550_write_support_polled(
214  int   minor,
215  const char *buf,
216  int   len
217  );
218
219NS16550_STATIC int ns16550_inbyte_nonblocking_polled(
220  int minor
221);
222
223NS16550_STATIC void ns16550_enable_interrupts(
224  int minor,
225  int mask
226);
227
228NS16550_STATIC int ns16550_set_attributes(
229  int                   minor,
230  const struct termios *t
231);
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* _NS16550_P_H_ */
Note: See TracBrowser for help on using the repository browser.