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