1 | /* |
---|
2 | * This file contains the TTY driver table for the EP1A |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <libchip/serial.h> |
---|
15 | #include "ns16550cfg.h" |
---|
16 | #include <bsp.h> |
---|
17 | #include <libcpu/io.h> |
---|
18 | #include "m68360.h" |
---|
19 | /* |
---|
20 | * Based on BSP configuration information decide whether to do polling IO |
---|
21 | * or interrupt driven IO. |
---|
22 | */ |
---|
23 | |
---|
24 | #define NS16550_FUNCTIONS &ns16550_fns_polled |
---|
25 | #define MC68360_SCC_FUNCTIONS &mc68360_scc_fns |
---|
26 | |
---|
27 | /* |
---|
28 | * Configuration specific probe routines |
---|
29 | */ |
---|
30 | static bool config_68360_scc_base_probe_1(int minor); |
---|
31 | static bool config_68360_scc_base_probe_2(int minor); |
---|
32 | static bool config_68360_scc_base_probe_3(int minor); |
---|
33 | static bool config_68360_scc_base_probe_4(int minor); |
---|
34 | static bool config_68360_scc_base_probe_5(int minor); |
---|
35 | static bool config_68360_scc_base_probe_6(int minor); |
---|
36 | static bool config_68360_scc_base_probe_7(int minor); |
---|
37 | static bool config_68360_scc_base_probe_8(int minor); |
---|
38 | static bool config_68360_scc_base_probe_9(int minor); |
---|
39 | static bool config_68360_scc_base_probe_10(int minor); |
---|
40 | static bool config_68360_scc_base_probe_11(int minor); |
---|
41 | static bool config_68360_scc_base_probe_12(int minor); |
---|
42 | |
---|
43 | extern console_fns mc68360_scc_fns; |
---|
44 | |
---|
45 | /* |
---|
46 | * The following table configures the console drivers used in this BSP. |
---|
47 | * |
---|
48 | * The first entry which, when probed, is available, will be named /dev/console, |
---|
49 | * all others being given the name indicated. |
---|
50 | * |
---|
51 | * Each field is interpreted thus: |
---|
52 | * |
---|
53 | * sDeviceName This is the name of the device. |
---|
54 | * pDeviceFns This is a pointer to the set of driver routines to use. |
---|
55 | * pDeviceFlow This is a pointer to the set of flow control routines to |
---|
56 | * use. Serial device drivers will typically supply RTSCTS |
---|
57 | * and DTRCTS handshake routines for DCE to DCE communication, |
---|
58 | * however for DCE to DTE communication, no such routines |
---|
59 | * should be necessary as RTS will be driven automatically |
---|
60 | * when the transmitter is active. |
---|
61 | * ulMargin The high water mark in the input buffer is set to the buffer |
---|
62 | * size less ulMargin. Once this level is reached, the driver's |
---|
63 | * flow control routine used to stop the remote transmitter will |
---|
64 | * be called. This figure should be greater than or equal to |
---|
65 | * the number of stages of FIFO between the transmitter and |
---|
66 | * receiver. |
---|
67 | * ulHysteresis After the high water mark specified by ulMargin has been |
---|
68 | * reached, the driver's routine to re-start the remote |
---|
69 | * transmitter will be called once the level in the input |
---|
70 | * buffer has fallen by ulHysteresis bytes. |
---|
71 | * pDeviceParams This contains either device specific data or a pointer to a |
---|
72 | * device specific structure containing additional information |
---|
73 | * not provided in this table. |
---|
74 | * ulCtrlPort1 This is the primary control port number for the device. This |
---|
75 | * may be used to specify different instances of the same device |
---|
76 | * type. |
---|
77 | * ulCtrlPort2 This is the secondary control port number, of use when a given |
---|
78 | * device has more than one available channel. |
---|
79 | * ulDataPort This is the port number for the data port of the device |
---|
80 | * ulIntVector This encodes the interrupt vector of the device. |
---|
81 | * |
---|
82 | */ |
---|
83 | console_tbl Console_Port_Tbl[] = { |
---|
84 | /* |
---|
85 | * NS16550 Chips provide first COM1 and COM2 Ports. |
---|
86 | */ |
---|
87 | { |
---|
88 | "/dev/com1", /* sDeviceName */ |
---|
89 | SERIAL_NS16550, /* deviceType */ |
---|
90 | NS16550_FUNCTIONS, /* pDeviceFns */ |
---|
91 | NULL, /* deviceProbe */ |
---|
92 | &ns16550_flow_RTSCTS, /* pDeviceFlow */ |
---|
93 | 16, /* ulMargin */ |
---|
94 | 8, /* ulHysteresis */ |
---|
95 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
96 | UART_BASE_COM1, /* ulCtrlPort1 */ |
---|
97 | 0, /* ulCtrlPort2 */ |
---|
98 | UART_BASE_COM1, /* ulDataPort */ |
---|
99 | Read_ns16550_register, /* getRegister */ |
---|
100 | Write_ns16550_register, /* setRegister */ |
---|
101 | NULL, /* getData */ |
---|
102 | NULL, /* setData */ |
---|
103 | 7372800, /* ulClock */ |
---|
104 | 0 /* ulIntVector */ |
---|
105 | }, |
---|
106 | { |
---|
107 | "/dev/com2", /* sDeviceName */ |
---|
108 | SERIAL_NS16550, /* deviceType */ |
---|
109 | NS16550_FUNCTIONS, /* pDeviceFns */ |
---|
110 | NULL, /* deviceProbe */ |
---|
111 | &ns16550_flow_RTSCTS, /* pDeviceFlow */ |
---|
112 | 16, /* ulMargin */ |
---|
113 | 8, /* ulHysteresis */ |
---|
114 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
115 | UART_BASE_COM2, /* ulCtrlPort1-Filled in at runtime */ |
---|
116 | 0, /* ulCtrlPort2 */ |
---|
117 | UART_BASE_COM2, /* ulDataPort-Filled in at runtime*/ |
---|
118 | Read_ns16550_register, /* getRegister */ |
---|
119 | Write_ns16550_register, /* setRegister */ |
---|
120 | NULL, /* getData */ |
---|
121 | NULL, /* setData */ |
---|
122 | 7372800, /* ulClock */ |
---|
123 | 0 /* ulIntVector */ |
---|
124 | }, |
---|
125 | /* |
---|
126 | * Up to 12 serial ports are provided by MC68360 SCC ports. |
---|
127 | * EP1A may have one MC68360 providing 4 ports (A,B,C,D). |
---|
128 | */ |
---|
129 | { |
---|
130 | "/dev/rs232_2", /* sDeviceName */ |
---|
131 | SERIAL_CUSTOM, /* deviceType */ |
---|
132 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
133 | config_68360_scc_base_probe_1, /* deviceProbe */ |
---|
134 | NULL, /* pDeviceFlow */ |
---|
135 | 16, /* ulMargin */ |
---|
136 | 8, /* ulHysteresis */ |
---|
137 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
138 | 0, /* ulCtrlPort1 */ |
---|
139 | 0, /* ulCtrlPort2 */ |
---|
140 | 0, /* ulDataPort */ |
---|
141 | NULL, /* getRegister */ |
---|
142 | NULL, /* setRegister */ |
---|
143 | NULL, /* getData */ |
---|
144 | NULL, /* setData */ |
---|
145 | 0, /* ulClock */ |
---|
146 | 0 /* ulIntVector */ |
---|
147 | }, |
---|
148 | { |
---|
149 | "/dev/rs422_1", /* sDeviceName */ |
---|
150 | SERIAL_CUSTOM, /* deviceType */ |
---|
151 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
152 | config_68360_scc_base_probe_2, /* deviceProbe */ |
---|
153 | NULL, /* pDeviceFlow */ |
---|
154 | 16, /* ulMargin */ |
---|
155 | 8, /* ulHysteresis */ |
---|
156 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
157 | 0, /* ulCtrlPort1 */ |
---|
158 | 0, /* ulCtrlPort2 */ |
---|
159 | 0, /* ulDataPort */ |
---|
160 | NULL, /* getRegister */ |
---|
161 | NULL, /* setRegister */ |
---|
162 | NULL, /* getData */ |
---|
163 | NULL, /* setData */ |
---|
164 | 0, /* ulClock */ |
---|
165 | 0 /* ulIntVector */ |
---|
166 | }, |
---|
167 | { |
---|
168 | "/dev/rs422_2", /* sDeviceName */ |
---|
169 | SERIAL_CUSTOM, /* deviceType */ |
---|
170 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
171 | config_68360_scc_base_probe_3, /* deviceProbe */ |
---|
172 | NULL, /* pDeviceFlow */ |
---|
173 | 16, /* ulMargin */ |
---|
174 | 8, /* ulHysteresis */ |
---|
175 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
176 | 0, /* ulCtrlPort1 */ |
---|
177 | 0, /* ulCtrlPort2 */ |
---|
178 | 0, /* ulDataPort */ |
---|
179 | NULL, /* getRegister */ |
---|
180 | NULL, /* setRegister */ |
---|
181 | NULL, /* getData */ |
---|
182 | NULL, /* setData */ |
---|
183 | 0, /* ulClock */ |
---|
184 | 0 /* ulIntVector */ |
---|
185 | }, |
---|
186 | { |
---|
187 | "/dev/ep1a_d", /* sDeviceName */ |
---|
188 | SERIAL_CUSTOM, /* deviceType */ |
---|
189 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
190 | config_68360_scc_base_probe_4, /* deviceProbe */ |
---|
191 | NULL, /* pDeviceFlow */ |
---|
192 | 16, /* ulMargin */ |
---|
193 | 8, /* ulHysteresis */ |
---|
194 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
195 | 0, /* ulCtrlPort1 */ |
---|
196 | 0, /* ulCtrlPort2 */ |
---|
197 | 0, /* ulDataPort */ |
---|
198 | NULL, /* getRegister */ |
---|
199 | NULL, /* setRegister */ |
---|
200 | NULL, /* getData */ |
---|
201 | NULL, /* setData */ |
---|
202 | 0, /* ulClock */ |
---|
203 | 0 /* ulIntVector */ |
---|
204 | }, |
---|
205 | /* |
---|
206 | * PMC1 may have one MC16550 providing 4 ports (A,B,C,D). |
---|
207 | */ |
---|
208 | { |
---|
209 | "/dev/rs422_3", /* sDeviceName */ |
---|
210 | SERIAL_CUSTOM, /* deviceType */ |
---|
211 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
212 | config_68360_scc_base_probe_5, /* deviceProbe */ |
---|
213 | NULL, /* pDeviceFlow */ |
---|
214 | 16, /* ulMargin */ |
---|
215 | 8, /* ulHysteresis */ |
---|
216 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
217 | 0, /* ulCtrlPort1 */ |
---|
218 | 0, /* ulCtrlPort2 */ |
---|
219 | 0, /* ulDataPort */ |
---|
220 | NULL, /* getRegister */ |
---|
221 | NULL, /* setRegister */ |
---|
222 | NULL, /* getData */ |
---|
223 | NULL, /* setData */ |
---|
224 | 0, /* ulClock */ |
---|
225 | 0 /* ulIntVector */ |
---|
226 | }, |
---|
227 | { |
---|
228 | "/dev/rs422_4", /* sDeviceName */ |
---|
229 | SERIAL_CUSTOM, /* deviceType */ |
---|
230 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
231 | config_68360_scc_base_probe_6, /* deviceProbe */ |
---|
232 | NULL, /* pDeviceFlow */ |
---|
233 | 16, /* ulMargin */ |
---|
234 | 8, /* ulHysteresis */ |
---|
235 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
236 | 0, /* ulCtrlPort1 */ |
---|
237 | 0, /* ulCtrlPort2 */ |
---|
238 | 0, /* ulDataPort */ |
---|
239 | NULL, /* getRegister */ |
---|
240 | NULL, /* setRegister */ |
---|
241 | NULL, /* getData */ |
---|
242 | NULL, /* setData */ |
---|
243 | 0, /* ulClock */ |
---|
244 | 0 /* ulIntVector */ |
---|
245 | }, |
---|
246 | { |
---|
247 | "/dev/rs422_5", /* sDeviceName */ |
---|
248 | SERIAL_CUSTOM, /* deviceType */ |
---|
249 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
250 | config_68360_scc_base_probe_7, /* deviceProbe */ |
---|
251 | NULL, /* pDeviceFlow */ |
---|
252 | 16, /* ulMargin */ |
---|
253 | 8, /* ulHysteresis */ |
---|
254 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
255 | 0, /* ulCtrlPort1 */ |
---|
256 | 0, /* ulCtrlPort2 */ |
---|
257 | 0, /* ulDataPort */ |
---|
258 | NULL, /* getRegister */ |
---|
259 | NULL, /* setRegister */ |
---|
260 | NULL, /* getData */ |
---|
261 | NULL, /* setData */ |
---|
262 | 0, /* ulClock */ |
---|
263 | 0 /* ulIntVector */ |
---|
264 | }, |
---|
265 | { |
---|
266 | "/dev/rs422_6", /* sDeviceName */ |
---|
267 | SERIAL_CUSTOM, /* deviceType */ |
---|
268 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
269 | config_68360_scc_base_probe_8, /* deviceProbe */ |
---|
270 | NULL, /* pDeviceFlow */ |
---|
271 | 16, /* ulMargin */ |
---|
272 | 8, /* ulHysteresis */ |
---|
273 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
274 | 0, /* ulCtrlPort1 */ |
---|
275 | 0, /* ulCtrlPort2 */ |
---|
276 | 0, /* ulDataPort */ |
---|
277 | NULL, /* getRegister */ |
---|
278 | NULL, /* setRegister */ |
---|
279 | NULL, /* getData */ |
---|
280 | NULL, /* setData */ |
---|
281 | 0, /* ulClock */ |
---|
282 | 0 /* ulIntVector */ |
---|
283 | }, |
---|
284 | /* |
---|
285 | * PMC2 may have one MC16550 providing 4 ports (A,B,C,D). |
---|
286 | */ |
---|
287 | { |
---|
288 | "/dev/rs232_3", /* sDeviceName */ |
---|
289 | SERIAL_CUSTOM, /* deviceType */ |
---|
290 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
291 | config_68360_scc_base_probe_9, /* deviceProbe */ |
---|
292 | NULL, /* pDeviceFlow */ |
---|
293 | 16, /* ulMargin */ |
---|
294 | 8, /* ulHysteresis */ |
---|
295 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
296 | 0, /* ulCtrlPort1 */ |
---|
297 | 0, /* ulCtrlPort2 */ |
---|
298 | 0, /* ulDataPort */ |
---|
299 | NULL, /* getRegister */ |
---|
300 | NULL, /* setRegister */ |
---|
301 | NULL, /* getData */ |
---|
302 | NULL, /* setData */ |
---|
303 | 0, /* ulClock */ |
---|
304 | 0 /* ulIntVector */ |
---|
305 | }, |
---|
306 | { |
---|
307 | "/dev/rs232_4", /* sDeviceName */ |
---|
308 | SERIAL_CUSTOM, /* deviceType */ |
---|
309 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
310 | config_68360_scc_base_probe_10, /* deviceProbe */ |
---|
311 | NULL, /* pDeviceFlow */ |
---|
312 | 16, /* ulMargin */ |
---|
313 | 8, /* ulHysteresis */ |
---|
314 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
315 | 0, /* ulCtrlPort1 */ |
---|
316 | 0, /* ulCtrlPort2 */ |
---|
317 | 0, /* ulDataPort */ |
---|
318 | NULL, /* getRegister */ |
---|
319 | NULL, /* setRegister */ |
---|
320 | NULL, /* getData */ |
---|
321 | NULL, /* setData */ |
---|
322 | 0, /* ulClock */ |
---|
323 | 0 /* ulIntVector */ |
---|
324 | }, |
---|
325 | { |
---|
326 | "/dev/rs232_5", /* sDeviceName */ |
---|
327 | SERIAL_CUSTOM, /* deviceType */ |
---|
328 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
329 | config_68360_scc_base_probe_11, /* deviceProbe */ |
---|
330 | NULL, /* pDeviceFlow */ |
---|
331 | 16, /* ulMargin */ |
---|
332 | 8, /* ulHysteresis */ |
---|
333 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
334 | 0, /* ulCtrlPort1 */ |
---|
335 | 0, /* ulCtrlPort2 */ |
---|
336 | 0, /* ulDataPort */ |
---|
337 | NULL, /* getRegister */ |
---|
338 | NULL, /* setRegister */ |
---|
339 | NULL, /* getData */ |
---|
340 | NULL, /* setData */ |
---|
341 | 0, /* ulClock */ |
---|
342 | 0 /* ulIntVector */ |
---|
343 | }, |
---|
344 | { |
---|
345 | "/dev/rs232_6", /* sDeviceName */ |
---|
346 | SERIAL_CUSTOM, /* deviceType */ |
---|
347 | MC68360_SCC_FUNCTIONS, /* pDeviceFns */ |
---|
348 | config_68360_scc_base_probe_12, /* deviceProbe */ |
---|
349 | NULL, /* pDeviceFlow */ |
---|
350 | 16, /* ulMargin */ |
---|
351 | 8, /* ulHysteresis */ |
---|
352 | (void *)9600, /* baud rate */ /* pDeviceParams */ |
---|
353 | 0, /* ulCtrlPort1 */ |
---|
354 | 0, /* ulCtrlPort2 */ |
---|
355 | 0, /* ulDataPort */ |
---|
356 | NULL, /* getRegister */ |
---|
357 | NULL, /* setRegister */ |
---|
358 | NULL, /* getData */ |
---|
359 | NULL, /* setData */ |
---|
360 | 0, /* ulClock */ |
---|
361 | 0 /* ulIntVector */ |
---|
362 | } |
---|
363 | }; |
---|
364 | |
---|
365 | static bool config_68360_scc_base_probe(int minor, unsigned long busNo, unsigned long slotNo, int channel) |
---|
366 | { |
---|
367 | M68360_t chip = M68360_chips; |
---|
368 | |
---|
369 | /* |
---|
370 | * Find out if the chip is installed. |
---|
371 | */ |
---|
372 | while (chip) { |
---|
373 | if ((chip->board_data->slotNo == slotNo) && (chip->board_data->busNo == busNo)) |
---|
374 | break; |
---|
375 | chip = chip->next; |
---|
376 | } |
---|
377 | |
---|
378 | if (!chip) |
---|
379 | return false; |
---|
380 | |
---|
381 | Console_Port_Tbl[minor].pDeviceParams = &chip->port[ channel-1 ]; |
---|
382 | chip->port[ channel-1 ].minor = minor; |
---|
383 | return true; |
---|
384 | } |
---|
385 | |
---|
386 | static bool config_68360_scc_base_probe_1( int minor ) { |
---|
387 | return config_68360_scc_base_probe(minor, 0, 11, 1); |
---|
388 | } |
---|
389 | |
---|
390 | static bool config_68360_scc_base_probe_2( int minor ) { |
---|
391 | return config_68360_scc_base_probe(minor, 0, 11, 2); |
---|
392 | } |
---|
393 | |
---|
394 | static bool config_68360_scc_base_probe_3( int minor ) { |
---|
395 | return config_68360_scc_base_probe( minor, 0, 11, 3); |
---|
396 | } |
---|
397 | |
---|
398 | static bool config_68360_scc_base_probe_4( int minor ) { |
---|
399 | return config_68360_scc_base_probe( minor, 0, 11, 4); |
---|
400 | } |
---|
401 | |
---|
402 | static bool config_68360_scc_base_probe_5( int minor ) { |
---|
403 | return config_68360_scc_base_probe( minor, 0, 16, 1); |
---|
404 | } |
---|
405 | |
---|
406 | static bool config_68360_scc_base_probe_6( int minor ) { |
---|
407 | return config_68360_scc_base_probe( minor, 0, 16, 2); |
---|
408 | } |
---|
409 | |
---|
410 | static bool config_68360_scc_base_probe_7( int minor ) { |
---|
411 | return config_68360_scc_base_probe( minor, 0, 16, 3); |
---|
412 | } |
---|
413 | |
---|
414 | static bool config_68360_scc_base_probe_8( int minor ) { |
---|
415 | return config_68360_scc_base_probe( minor, 0, 16, 4); |
---|
416 | } |
---|
417 | |
---|
418 | static bool config_68360_scc_base_probe_9( int minor ) { |
---|
419 | return config_68360_scc_base_probe( minor, 0, 15, 1); |
---|
420 | } |
---|
421 | |
---|
422 | static bool config_68360_scc_base_probe_10( int minor ) { |
---|
423 | return config_68360_scc_base_probe( minor, 0, 15, 2); |
---|
424 | } |
---|
425 | |
---|
426 | static bool config_68360_scc_base_probe_11( int minor ) { |
---|
427 | return config_68360_scc_base_probe( minor, 0, 15, 3); |
---|
428 | } |
---|
429 | |
---|
430 | static bool config_68360_scc_base_probe_12( int minor ) { |
---|
431 | return config_68360_scc_base_probe( minor, 0, 15, 4); |
---|
432 | } |
---|
433 | |
---|