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