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 |
---|
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 static |
---|
31 | |
---|
32 | #define NS16550_RECEIVE_BUFFER 0 |
---|
33 | #define NS16550_TRANSMIT_BUFFER 0 |
---|
34 | #define NS16550_INTERRUPT_ENABLE 1 |
---|
35 | #define NS16550_INTERRUPT_ID 2 |
---|
36 | #define NS16550_FIFO_CONTROL 2 |
---|
37 | #define NS16550_LINE_CONTROL 3 |
---|
38 | #define NS16550_MODEM_CONTROL 4 |
---|
39 | #define NS16550_LINE_STATUS 5 |
---|
40 | #define NS16550_MODEM_STATUS 6 |
---|
41 | #define NS16550_SCRATCH_PAD 7 |
---|
42 | |
---|
43 | /* |
---|
44 | * Define serial port interrupt enable register structure. |
---|
45 | */ |
---|
46 | |
---|
47 | #define SP_INT_RX_ENABLE 0x01 |
---|
48 | #define SP_INT_TX_ENABLE 0x02 |
---|
49 | #define SP_INT_LS_ENABLE 0x04 |
---|
50 | #define SP_INT_MS_ENABLE 0x08 |
---|
51 | |
---|
52 | #define NS16550_ENABLE_ALL_INTR (SP_INT_RX_ENABLE | SP_INT_TX_ENABLE) |
---|
53 | #define NS16550_DISABLE_ALL_INTR 0x00 |
---|
54 | #define NS16550_ENABLE_ALL_INTR_EXCEPT_TX (SP_INT_RX_ENABLE) |
---|
55 | |
---|
56 | /* |
---|
57 | * Define serial port interrupt ID register structure. |
---|
58 | */ |
---|
59 | |
---|
60 | #define SP_IID_0 0x01 |
---|
61 | #define SP_IID_1 0x02 |
---|
62 | #define SP_IID_2 0x04 |
---|
63 | #define SP_IID_3 0x08 |
---|
64 | |
---|
65 | /* |
---|
66 | * Define serial port fifo control register structure. |
---|
67 | */ |
---|
68 | |
---|
69 | #define SP_FIFO_ENABLE 0x01 |
---|
70 | #define SP_FIFO_RXRST 0x02 |
---|
71 | #define SP_FIFO_TXRST 0x04 |
---|
72 | #define SP_FIFO_DMA 0x08 |
---|
73 | #define SP_FIFO_RXLEVEL 0xc0 |
---|
74 | |
---|
75 | #define SP_FIFO_SIZE 16 |
---|
76 | |
---|
77 | /* |
---|
78 | * Define serial port line control register structure. |
---|
79 | */ |
---|
80 | |
---|
81 | #define SP_LINE_SIZE 0x03 |
---|
82 | #define SP_LINE_STOP 0x04 |
---|
83 | #define SP_LINE_PAR 0x08 |
---|
84 | #define SP_LINE_ODD 0x10 |
---|
85 | #define SP_LINE_STICK 0x20 |
---|
86 | #define SP_LINE_BREAK 0x40 |
---|
87 | #define SP_LINE_DLAB 0x80 |
---|
88 | |
---|
89 | /* |
---|
90 | * Line status register character size definitions. |
---|
91 | */ |
---|
92 | |
---|
93 | #define FIVE_BITS 0x0 /* five bits per character */ |
---|
94 | #define SIX_BITS 0x1 /* six bits per character */ |
---|
95 | #define SEVEN_BITS 0x2 /* seven bits per character */ |
---|
96 | #define EIGHT_BITS 0x3 /* eight bits per character */ |
---|
97 | |
---|
98 | /* |
---|
99 | * Line speed divisor definition. |
---|
100 | */ |
---|
101 | |
---|
102 | #define NS16550_Baud(_clock, _baud_rate) \ |
---|
103 | ((((_clock) == 0) ? 115200 : (_clock))/(_baud_rate*16)) |
---|
104 | |
---|
105 | /* |
---|
106 | * Define serial port modem control register structure. |
---|
107 | */ |
---|
108 | |
---|
109 | #define SP_MODEM_DTR 0x01 |
---|
110 | #define SP_MODEM_RTS 0x02 |
---|
111 | #define SP_MODEM_IRQ 0x08 |
---|
112 | #define SP_MODEM_LOOP 0x10 |
---|
113 | #define SP_MODEM_DIV4 0x80 |
---|
114 | |
---|
115 | /* |
---|
116 | * Define serial port line status register structure. |
---|
117 | */ |
---|
118 | |
---|
119 | #define SP_LSR_RDY 0x01 |
---|
120 | #define SP_LSR_EOVRUN 0x02 |
---|
121 | #define SP_LSR_EPAR 0x04 |
---|
122 | #define SP_LSR_EFRAME 0x08 |
---|
123 | #define SP_LSR_BREAK 0x10 |
---|
124 | #define SP_LSR_THOLD 0x20 |
---|
125 | #define SP_LSR_TX 0x40 |
---|
126 | #define SP_LSR_EFIFO 0x80 |
---|
127 | |
---|
128 | typedef struct { |
---|
129 | uint8_t ucModemCtrl; |
---|
130 | int transmitFifoChars; |
---|
131 | } ns16550_context; |
---|
132 | |
---|
133 | /* |
---|
134 | * Driver functions |
---|
135 | */ |
---|
136 | |
---|
137 | NS16550_STATIC void ns16550_init(int minor); |
---|
138 | |
---|
139 | NS16550_STATIC int ns16550_open( |
---|
140 | int major, |
---|
141 | int minor, |
---|
142 | void * arg |
---|
143 | ); |
---|
144 | |
---|
145 | NS16550_STATIC int ns16550_close( |
---|
146 | int major, |
---|
147 | int minor, |
---|
148 | void * arg |
---|
149 | ); |
---|
150 | |
---|
151 | NS16550_STATIC void ns16550_write_polled( |
---|
152 | int minor, |
---|
153 | char cChar |
---|
154 | ); |
---|
155 | |
---|
156 | NS16550_STATIC int ns16550_assert_RTS( |
---|
157 | int minor |
---|
158 | ); |
---|
159 | |
---|
160 | NS16550_STATIC int ns16550_negate_RTS( |
---|
161 | int minor |
---|
162 | ); |
---|
163 | |
---|
164 | NS16550_STATIC int ns16550_assert_DTR( |
---|
165 | int minor |
---|
166 | ); |
---|
167 | |
---|
168 | NS16550_STATIC int ns16550_negate_DTR( |
---|
169 | int minor |
---|
170 | ); |
---|
171 | |
---|
172 | NS16550_STATIC void ns16550_initialize_interrupts(int minor); |
---|
173 | |
---|
174 | NS16550_STATIC ssize_t ns16550_write_support_int( |
---|
175 | int minor, |
---|
176 | const char *buf, |
---|
177 | size_t len |
---|
178 | ); |
---|
179 | |
---|
180 | NS16550_STATIC ssize_t ns16550_write_support_polled( |
---|
181 | int minor, |
---|
182 | const char *buf, |
---|
183 | size_t len |
---|
184 | ); |
---|
185 | |
---|
186 | NS16550_STATIC int ns16550_inbyte_nonblocking_polled( |
---|
187 | int minor |
---|
188 | ); |
---|
189 | |
---|
190 | NS16550_STATIC void ns16550_enable_interrupts( |
---|
191 | int minor, |
---|
192 | int mask |
---|
193 | ); |
---|
194 | |
---|
195 | NS16550_STATIC int ns16550_set_attributes( |
---|
196 | int minor, |
---|
197 | const struct termios *t |
---|
198 | ); |
---|
199 | |
---|
200 | #ifdef __cplusplus |
---|
201 | } |
---|
202 | #endif |
---|
203 | |
---|
204 | #endif /* _NS16550_P_H_ */ |
---|