1 /** |
|
2 * rt_com |
|
3 * ====== |
|
4 * |
|
5 * RT-Linux kernel module for communication across serial lines. |
|
6 * |
|
7 * Copyright (C) 1997 Jens Michaelsen |
|
8 * Copyright (C) 1997-2000 Jochen Kupper |
|
9 * Copyright (C) 1999 Hua Mao <hmao@nmt.edu> |
|
10 * |
|
11 * This program is free software; you can redistribute it and/or |
|
12 * modify it under the terms of the GNU General Public License as |
|
13 * published by the Free Software Foundation; either version 2 of the |
|
14 * License, or (at your option) any later version. |
|
15 * |
|
16 * This program is distributed in the hope that it will be useful, but |
|
17 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 * General Public License for more details. |
|
20 * |
|
21 * You should have received a copy of the GNU General Public License |
|
22 * along with this program; see the file License. if not, write to the |
|
23 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
24 * MA 02111-1307, USA. |
|
25 */ |
|
26 |
|
27 |
|
28 |
|
29 #ifndef AIP_COM_P_H |
|
30 #define AIP_COM_P_H |
|
31 |
|
32 |
|
33 #define RT_COM_NAME "rt_com(aip)" //Hm, IgH |
|
34 |
|
35 /* input/ouput buffer (FIFO) sizes */ |
|
36 #define RT_COM_BUF_SIZ 2048 //256 // MUST BE ONLY POWER OF 2 !! |
|
37 /* amount of free space on input buffer for RTS reset */ |
|
38 #define RT_COM_BUF_LOW (RT_COM_BUF_SIZ / 3) |
|
39 /* amount of free space on input buffer for RTS set */ |
|
40 #define RT_COM_BUF_HI (RT_COM_BUF_SIZ * 2 / 3) |
|
41 /* limit of free space on input buffer for buffer full error */ |
|
42 #define RT_COM_BUF_FULL 20 |
|
43 |
|
44 |
|
45 /* usage flags */ |
|
46 #define RT_COM_PORT_FREE 0x00 |
|
47 #define RT_COM_PORT_INUSE 0x01 |
|
48 #define RT_COM_PORT_SETUP 0x02 |
|
49 |
|
50 |
|
51 /* Some hardware description */ |
|
52 #define RT_COM_BASE_BAUD 115200 |
|
53 |
|
54 /** Interrupt Service Routines |
|
55 * These are private functions */ |
|
56 static void rt_com0_isr( void ); |
|
57 static void rt_com1_isr( void ); |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 /** Interrupt handling |
|
63 * |
|
64 * Define internal convinience macros for interrupt handling, so we |
|
65 * get rid of the system dependencies. |
|
66 */ |
|
67 //#define rt_com_irq_off( state ) do{}while(0) //rt_global_save_flags( &state ); rt_global_cli() schreiben und lesen sowieso in IRQ Hm |
|
68 //#define rt_com_irq_on(state) do{}while(0) //rt_global_restore_flags( state ) |
|
69 #define rt_com_irq_off( state ) rt_global_save_flags( &state ); rt_global_cli() |
|
70 #define rt_com_irq_on(state) rt_global_restore_flags( state ) |
|
71 #define rt_com_request_irq( irq, isr ) rt_request_global_irq( irq, isr ); rt_enable_irq( irq ); |
|
72 #define rt_com_free_irq( irq ) rt_free_global_irq( irq ) |
|
73 |
|
74 |
|
75 /* port register offsets */ |
|
76 #define RT_COM_RXB 0x00 |
|
77 #define RT_COM_TXB 0x00 |
|
78 #define RT_COM_IER 0x01 |
|
79 #define RT_COM_IIR 0x02 |
|
80 #define RT_COM_FCR 0x02 |
|
81 #define RT_COM_LCR 0x03 |
|
82 #define RT_COM_MCR 0x04 |
|
83 #define RT_COM_LSR 0x05 |
|
84 #define RT_COM_MSR 0x06 |
|
85 #define RT_COM_DLL 0x00 |
|
86 #define RT_COM_DLM 0x01 |
|
87 |
|
88 /** MCR Modem Control Register masks */ |
|
89 #define MCR_DTR 0x01 // Data Terminal Ready |
|
90 #define MCR_RTS 0x02 // Request To Send |
|
91 #define MCR_OUT1 0x04 |
|
92 #define MCR_OUT2 0x08 |
|
93 #define MCR_LOOP 0x10 |
|
94 #define MCR_AFE 0x20 // AutoFlow Enable |
|
95 |
|
96 /** IER Interrupt Enable Register masks */ |
|
97 #define IER_ERBI 0x01 // Enable Received Data Available Interrupt |
|
98 #define IER_ETBEI 0x02 // Enable Transmitter Holding Register |
|
99 // Empty Interrupt |
|
100 #define IER_ELSI 0x04 // Enable Receiver Line Status Interrupt |
|
101 #define IER_EDSSI 0x08 // Enable Modem Status Interrupt |
|
102 |
|
103 /** MSR Modem Status Register masks */ |
|
104 #define MSR_DELTA_CTS 0x01 |
|
105 #define MSR_DELTA_DSR 0x02 |
|
106 #define MSR_TERI 0x04 |
|
107 #define MSR_DELTA_DCD 0x08 |
|
108 #define MSR_CTS 0x10 |
|
109 #define MSR_DSR 0x20 |
|
110 #define MSR_RI 0x40 |
|
111 #define MSR_DCD 0x80 |
|
112 |
|
113 /** LSR Line Status Register masks */ |
|
114 #define LSR_DATA_READY 0x01 |
|
115 #define LSR_OVERRUN_ERR 0x02 |
|
116 #define LSR_PARITY_ERR 0x04 |
|
117 #define LSR_FRAMING_ERR 0x08 |
|
118 #define LSR_BREAK 0x10 |
|
119 #define LSR_THRE 0x20 // Transmitter Holding Register |
|
120 #define LSR_TEMT 0x40 // Transmitter Empty |
|
121 |
|
122 /** FCR FIFO Control Register masks */ |
|
123 #define FCR_FIFO_ENABLE 0x01 |
|
124 #define FCR_INPUT_FIFO_RESET 0x02 |
|
125 #define FCR_OUTPUT_FIFO_RESET 0x04 |
|
126 |
|
127 /** data buffer |
|
128 * |
|
129 * Used for buffering of input and output data. Two buffers per port |
|
130 * (one for input, one for output). Organized as a FIFO */ |
|
131 struct rt_buf_struct{ |
|
132 unsigned int head; |
|
133 unsigned int tail; |
|
134 char buf[ RT_COM_BUF_SIZ ]; |
|
135 }; |
|
136 |
|
137 |
|
138 |
|
139 /** Port data |
|
140 * |
|
141 * Internal information structure containing all data for a port. One |
|
142 * structure for every port. |
|
143 * |
|
144 * Contains all current setup parameters and all data currently |
|
145 * buffered by rt_com. |
|
146 * |
|
147 * mode (functioning mode) |
|
148 * possible values: |
|
149 * - RT_COM_DSR_ON_TX - for standard functioning mode (DSR needed on TX) |
|
150 * - RT_COM_NO_HAND_SHAKE - for comunication without hand shake signals |
|
151 * (only RXD-TXD-GND) |
|
152 * - RT_COM_HW_FLOW - for hardware flow control (RTS-CTS) |
|
153 * Of course RT_COM_DSR_ON_TX and RT_COM_NO_HAND_SHAKE cannot be |
|
154 * sppecified at the same time. |
|
155 * |
|
156 * NOTE: When you select a mode that uses hand shake signals pay |
|
157 * attention that no input signals (CTS,DSR,RI,DCD) must be |
|
158 * floating. |
|
159 * |
|
160 * used (usage flag) |
|
161 * possible values: |
|
162 * - RT_COM_PORT_INUSE - port region requested by init_module |
|
163 * - RT_COM_PORT_FREE - port region requested by rt_com_set_param |
|
164 * - RT_COM_PORT_SETUP - port parameters are setup, |
|
165 * don't specify at compile time ! |
|
166 * |
|
167 * error |
|
168 * last error detected |
|
169 * |
|
170 * ier (interrupt enable register) |
|
171 * copy of IER chip register, last value set by rt_com. |
|
172 * |
|
173 * mcr (modem control register) |
|
174 * copy of the MCR internal register |
|
175 */ |
|
176 struct rt_com_struct{ |
|
177 int baud_base; |
|
178 int port; |
|
179 int irq; |
|
180 void (*isr)(void); |
|
181 int baud; |
|
182 unsigned int wordlength; |
|
183 unsigned int parity; |
|
184 unsigned int stopbits; |
|
185 int mode; |
|
186 int fifotrig; |
|
187 int used; |
|
188 int error; |
|
189 int type; |
|
190 int ier; |
|
191 int mcr; |
|
192 struct rt_buf_struct ibuf; |
|
193 struct rt_buf_struct obuf; |
|
194 }; |
|
195 |
|
196 |
|
197 #endif /* RT_COM_P_H */ |
|
198 |
|
199 |
|
200 |
|
201 /** |
|
202 * Local Variables: |
|
203 * mode: C |
|
204 * c-file-style: "Stroustrup" |
|
205 * End: |
|
206 */ |
|