source: rtems/c/src/libchip/serial/mc68681.c @ 4778c6e0

4.115
Last change on this file since 4778c6e0 was 4778c6e0, checked in by Joel Sherrill <joel.sherrill@…>, on 10/28/11 at 13:58:22

2011-10-28 Joel Sherrill <joel.sherrill@…>

PR 1944/misc

  • libchip/serial/mc68681.c: Remove #if 0.
  • Property mode set to 100644
File size: 18.9 KB
Line 
1/*
2 *  This file contains the termios TTY driver for the Motorola MC68681.
3 *
4 *  This part is available from a number of secondary sources.
5 *  In particular, we know about the following:
6 *
7 *     + Exar 88c681 and 68c681
8 *
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <rtems.h>
20#include <rtems/libio.h>
21#include <stdlib.h>
22
23#include <libchip/serial.h>
24#include <libchip/mc68681.h>
25#include <libchip/sersupp.h>
26#include "mc68681_p.h"
27
28/*
29 * Flow control is only supported when using interrupts
30 */
31
32console_fns mc68681_fns =
33{
34  libchip_serial_default_probe,   /* deviceProbe */
35  mc68681_open,                   /* deviceFirstOpen */
36  NULL,                           /* deviceLastClose */
37  NULL,                           /* deviceRead */
38  mc68681_write_support_int,      /* deviceWrite */
39  mc68681_initialize_interrupts,  /* deviceInitialize */
40  mc68681_write_polled,           /* deviceWritePolled */
41  mc68681_set_attributes,         /* deviceSetAttributes */
42  true                            /* deviceOutputUsesInterrupts */
43};
44
45console_fns mc68681_fns_polled =
46{
47  libchip_serial_default_probe,        /* deviceProbe */
48  mc68681_open,                        /* deviceFirstOpen */
49  mc68681_close,                       /* deviceLastClose */
50  mc68681_inbyte_nonblocking_polled,   /* deviceRead */
51  mc68681_write_support_polled,        /* deviceWrite */
52  mc68681_init,                        /* deviceInitialize */
53  mc68681_write_polled,                /* deviceWritePolled */
54  mc68681_set_attributes,              /* deviceSetAttributes */
55  false,                               /* deviceOutputUsesInterrupts */
56};
57
58extern void set_vector( rtems_isr_entry, rtems_vector_number, int );
59
60/*
61 *  Console Device Driver Entry Points
62 */
63
64/*
65 *  mc68681_baud_rate
66 *
67 *  This routine returns the proper ACR bit and baud rate field values
68 *  based on the requested baud rate.  The baud rate set to be used
69 *  must be configured by the user.
70 */
71
72MC68681_STATIC int mc68681_baud_rate(
73  int           minor,
74  int           baud,
75  unsigned int *baud_mask_p,
76  unsigned int *acr_bit_p,
77  unsigned int *command
78);
79
80/*
81 *  mc68681_set_attributes
82 *
83 *  This function sets the DUART channel to reflect the requested termios
84 *  port settings.
85 */
86
87MC68681_STATIC int mc68681_set_attributes(
88  int minor,
89  const struct termios *t
90)
91{
92  uint32_t               pMC68681_port;
93  uint32_t               pMC68681;
94  unsigned int           mode1;
95  unsigned int           mode2;
96  unsigned int           baud_mask;
97  unsigned int           acr_bit;
98  unsigned int           cmd = 0;
99  setRegister_f          setReg;
100  rtems_interrupt_level  Irql;
101
102  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
103  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
104  setReg        = Console_Port_Tbl[minor]->setRegister;
105
106  /*
107   *  Set the baud rate
108   */
109
110  if (mc68681_baud_rate( minor, t->c_cflag, &baud_mask, &acr_bit, &cmd ) == -1)
111    return -1;
112
113  baud_mask |=  baud_mask << 4;
114  acr_bit   <<= 7;
115
116  /*
117   *  Parity
118   */
119
120  mode1 = 0;
121  mode2 = 0;
122
123  if (t->c_cflag & PARENB) {
124    if (t->c_cflag & PARODD)
125      mode1 |= 0x04;
126    /* else
127                mode1 |= 0x04; */
128  } else {
129   mode1 |= 0x10;
130  }
131
132  /*
133   *  Character Size
134   */
135
136  if (t->c_cflag & CSIZE) {
137    switch (t->c_cflag & CSIZE) {
138      case CS5:  break;
139      case CS6:  mode1 |= 0x01;  break;
140      case CS7:  mode1 |= 0x02;  break;
141      case CS8:  mode1 |= 0x03;  break;
142    }
143  } else {
144    mode1 |= 0x03;       /* default to 9600,8,N,1 */
145  }
146
147  /*
148   *  Stop Bits
149   */
150
151  if (t->c_cflag & CSTOPB) {
152    mode2 |= 0x0F;                      /* 2 stop bits */
153  } else {
154    if ((t->c_cflag & CSIZE) == CS5)    /* CS5 and 1 stop bits not supported */
155      return -1;
156    mode2 |= 0x07;                      /* 1 stop bit */
157  }
158
159 /*
160  *   Hardware Flow Control
161  */
162
163  if(t->c_cflag & CRTSCTS) {
164          mode1 |= 0x80; /* Enable Rx RTS Control */
165          mode2 |= 0x10; /* Enable CTS Enable Tx */
166  }
167
168
169  rtems_interrupt_disable(Irql);
170    (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit );
171    (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud_mask );
172    if ( cmd ) {
173      (*setReg)( pMC68681_port, MC68681_COMMAND, cmd );         /* RX */
174      (*setReg)( pMC68681_port, MC68681_COMMAND, cmd | 0x20 );  /* TX */
175    }
176    (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
177    (*setReg)( pMC68681_port, MC68681_MODE, mode1 );
178    (*setReg)( pMC68681_port, MC68681_MODE, mode2 );
179  rtems_interrupt_enable(Irql);
180  return 0;
181}
182
183/*
184 *  mc68681_initialize_context
185 *
186 *  This function sets the default values of the per port context structure.
187 */
188
189MC68681_STATIC void mc68681_initialize_context(
190  int               minor,
191  mc68681_context  *pmc68681Context
192)
193{
194  int          port;
195  unsigned int pMC68681;
196  unsigned int pMC68681_port;
197
198  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
199  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
200
201  pmc68681Context->mate = -1;
202
203  for (port=0 ; port<Console_Port_Count ; port++ ) {
204    if ( Console_Port_Tbl[port]->ulCtrlPort1 == pMC68681 &&
205         Console_Port_Tbl[port]->ulCtrlPort2 != pMC68681_port ) {
206      pmc68681Context->mate = port;
207      pmc68681Context->imr  = 0;
208      break;
209    }
210  }
211
212}
213
214/*
215 *  mc68681_init
216 *
217 *  This function initializes the DUART to a quiecsent state.
218 */
219
220MC68681_STATIC void mc68681_init(int minor)
221{
222  uint32_t                pMC68681_port;
223  uint32_t                pMC68681;
224  mc68681_context        *pmc68681Context;
225  setRegister_f           setReg;
226
227  pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context));
228
229  Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context;
230
231  mc68681_initialize_context( minor, pmc68681Context );
232
233  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
234  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
235  setReg        = Console_Port_Tbl[minor]->setRegister;
236
237  /*
238   *  Reset everything and leave this port disabled.
239   */
240
241  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_RX );
242  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_TX );
243  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
244  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_BREAK );
245  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_STOP_BREAK );
246  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
247  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
248
249
250  (*setReg)( pMC68681_port, MC68681_MODE_REG_1A, 0x00 );
251  (*setReg)( pMC68681_port, MC68681_MODE_REG_2A, 0x02 );
252
253  /*
254   *  Disable interrupts on RX and TX for this port
255   */
256
257  mc68681_enable_interrupts( minor, MC68681_IMR_DISABLE_ALL );
258}
259
260/*
261 *  mc68681_open
262 *
263 *  This function opens a port for communication.
264 *
265 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
266 */
267
268MC68681_STATIC int mc68681_open(
269  int      major,
270  int      minor,
271  void    *arg
272)
273{
274  uint32_t               pMC68681;
275  uint32_t               pMC68681_port;
276  unsigned int           baud;
277  unsigned int           acr_bit;
278  unsigned int           vector;
279  unsigned int           command = 0;
280  rtems_interrupt_level  Irql;
281  setRegister_f          setReg;
282  unsigned int                   status;
283
284
285  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
286  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
287  setReg        = Console_Port_Tbl[minor]->setRegister;
288  vector        = Console_Port_Tbl[minor]->ulIntVector;
289
290  /* XXX default baud rate should be from configuration table */
291
292  status = mc68681_baud_rate( minor, B9600, &baud, &acr_bit, &command );
293  if (status < 0) rtems_fatal_error_occurred (RTEMS_NOT_DEFINED);
294
295  /*
296   *  Set the DUART channel to a default useable state
297   */
298
299  rtems_interrupt_disable(Irql);
300    (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit << 7 );
301    (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud );
302    if ( command ) {
303      (*setReg)( pMC68681_port, MC68681_COMMAND, command );         /* RX */
304      (*setReg)( pMC68681_port, MC68681_COMMAND, command | 0x20 );  /* TX */
305    }
306    (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
307    (*setReg)( pMC68681_port, MC68681_MODE, 0x13 );
308    (*setReg)( pMC68681_port, MC68681_MODE, 0x07 );
309  rtems_interrupt_enable(Irql);
310
311  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX );
312  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX );
313
314  (*setReg)( pMC68681, MC68681_INTERRUPT_VECTOR_REG, vector );
315
316  return RTEMS_SUCCESSFUL;
317}
318
319/*
320 *  mc68681_close
321 *
322 *  This function shuts down the requested port.
323 */
324
325MC68681_STATIC int mc68681_close(
326  int      major,
327  int      minor,
328  void    *arg
329)
330{
331  uint32_t        pMC68681;
332  uint32_t        pMC68681_port;
333  setRegister_f   setReg;
334
335  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
336  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
337  setReg        = Console_Port_Tbl[minor]->setRegister;
338
339  /*
340   *  Disable interrupts from this channel and then disable it totally.
341   */
342  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
343  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
344
345  return(RTEMS_SUCCESSFUL);
346}
347
348/*
349 *  mc68681_write_polled
350 *
351 *  This routine polls out the requested character.
352 */
353
354MC68681_STATIC void mc68681_write_polled(
355  int   minor,
356  char  cChar
357)
358{
359  uint32_t                pMC68681_port;
360  unsigned char           ucLineStatus;
361  int                     iTimeout;
362  getRegister_f           getReg;
363  setRegister_f           setReg;
364
365  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
366  getReg        = Console_Port_Tbl[minor]->getRegister;
367  setReg        = Console_Port_Tbl[minor]->setRegister;
368
369  /*
370   * wait for transmitter holding register to be empty
371   */
372  iTimeout = 1000;
373  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
374  while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) {
375
376    if ((ucLineStatus & 0xF0))
377      (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
378
379    /*
380     * Yield while we wait
381     */
382
383#if 0
384     if(_System_state_Is_up(_System_state_Get())) {
385       rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
386     }
387#endif
388     ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
389     if(!--iTimeout) {
390       break;
391     }
392  }
393
394  /*
395   * transmit character
396   */
397
398  (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar);
399}
400
401/*
402 *  mc68681_isr
403 *
404 *  This is the single interrupt entry point which parcels interrupts
405 *  out to the various ports.
406 */
407
408MC68681_STATIC rtems_isr mc68681_isr(
409  rtems_vector_number vector
410)
411{
412  int     minor;
413
414  for(minor=0 ; minor<Console_Port_Count ; minor++) {
415    if(Console_Port_Tbl[minor]->ulIntVector == vector &&
416       Console_Port_Tbl[minor]->deviceType == SERIAL_MC68681 ) {
417      mc68681_process(minor);
418    }
419  }
420}
421
422/*
423 *  mc68681_initialize_interrupts
424 *
425 *  This routine initializes the console's receive and transmit
426 *  ring buffers and loads the appropriate vectors to handle the interrupts.
427 */
428
429MC68681_STATIC void mc68681_initialize_interrupts(int minor)
430{
431  mc68681_init(minor);
432
433  Console_Port_Data[minor].bActive = FALSE;
434
435  set_vector(mc68681_isr, Console_Port_Tbl[minor]->ulIntVector, 1);
436
437  mc68681_enable_interrupts(minor,MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
438}
439
440/*
441 *  mc68681_write_support_int
442 *
443 *  Console Termios output entry point when using interrupt driven output.
444 */
445
446MC68681_STATIC ssize_t mc68681_write_support_int(
447  int         minor,
448  const char *buf,
449  size_t      len
450)
451{
452  uint32_t        Irql;
453  uint32_t        pMC68681_port;
454  setRegister_f   setReg;
455
456  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
457  setReg        = Console_Port_Tbl[minor]->setRegister;
458
459  /*
460   *  We are using interrupt driven output and termios only sends us
461   *  one character at a time.
462   */
463
464  if ( !len )
465    return 0;
466
467  /*
468   *  Put the character out and enable interrupts if necessary.
469   */
470
471  rtems_interrupt_disable(Irql);
472    if ( Console_Port_Data[minor].bActive == FALSE ) {
473      Console_Port_Data[minor].bActive = TRUE;
474      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL);
475    }
476    (*setReg)(pMC68681_port, MC68681_TX_BUFFER, *buf);
477  rtems_interrupt_enable(Irql);
478
479  return 0;
480}
481
482/*
483 *  mc68681_write_support_polled
484 *
485 *  Console Termios output entry point when using polled output.
486 *
487 */
488
489MC68681_STATIC ssize_t mc68681_write_support_polled(
490  int         minor,
491  const char *buf,
492  size_t      len
493)
494{
495  int nwrite = 0;
496
497  /*
498   * poll each byte in the string out of the port.
499   */
500  while (nwrite < len) {
501    /*
502     * transmit character
503     */
504    mc68681_write_polled(minor, *buf++);
505    nwrite++;
506  }
507
508  /*
509   * return the number of bytes written.
510   */
511  return nwrite;
512}
513
514/*
515 *  mc68681_inbyte_nonblocking_polled
516 *
517 *  Console Termios polling input entry point.
518 */
519
520MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
521  int minor
522)
523{
524  uint32_t             pMC68681_port;
525  unsigned char        ucLineStatus;
526  unsigned char        cChar;
527  getRegister_f        getReg;
528
529  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
530  getReg        = Console_Port_Tbl[minor]->getRegister;
531
532  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
533  if(ucLineStatus & MC68681_RX_READY) {
534    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
535    return (int)cChar;
536  } else {
537    return -1;
538  }
539}
540
541/*
542 *  mc68681_baud_rate
543 */
544
545MC68681_STATIC int mc68681_baud_rate(
546  int           minor,
547  int           baud,
548  unsigned int *baud_mask_p,
549  unsigned int *acr_bit_p,
550  unsigned int *command
551)
552{
553  unsigned int           baud_mask;
554  unsigned int           acr_bit;
555  int                    status;
556  int                    is_extended;
557  int                    baud_requested;
558  mc68681_baud_table_t  *baud_tbl;
559
560  baud_mask = 0;
561  acr_bit = 0;
562  status = 0;
563
564  if (Console_Port_Tbl[minor]->ulDataPort & MC68681_DATA_BAUD_RATE_SET_2)
565  {
566    acr_bit = 1;
567  }
568
569  is_extended = 0;
570
571  switch (Console_Port_Tbl[minor]->ulDataPort & MC68681_XBRG_MASK) {
572    case MC68681_XBRG_IGNORED:
573      *command = 0x00;
574      break;
575    case MC68681_XBRG_ENABLED:
576      *command = 0x80;
577      is_extended = 1;
578      break;
579    case MC68681_XBRG_DISABLED:
580      *command = 0x90;
581      break;
582  }
583
584  baud_requested = baud & CBAUD;
585  if (!baud_requested)
586    baud_requested = B9600;              /* default to 9600 baud */
587
588  baud_requested = rtems_termios_baud_to_index( baud_requested );
589
590  baud_tbl = (mc68681_baud_table_t *)
591     ((uintptr_t)Console_Port_Tbl[minor]->ulClock);
592  if (!baud_tbl)
593    rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS);
594
595  if ( is_extended )
596    baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ];
597  else
598    baud_mask = baud_tbl[ acr_bit ][ baud_requested ];
599
600  if ( baud_mask == MC68681_BAUD_NOT_VALID )
601    status = -1;
602
603  /*
604   *  upper nibble is receiver and lower nibble is transmitter
605   */
606
607  *baud_mask_p = (baud_mask << 4) | baud_mask;
608  *acr_bit_p   = acr_bit;
609  return status;
610}
611
612/*
613 *  mc68681_process
614 *
615 *  This routine is the per port console interrupt handler.
616 */
617
618MC68681_STATIC void mc68681_process(
619  int  minor
620)
621{
622  uint32_t                pMC68681;
623  uint32_t                pMC68681_port;
624  volatile uint8_t        ucLineStatus;
625  volatile uint8_t        ucISRStatus;
626  char                    cChar;
627  getRegister_f           getReg;
628  setRegister_f           setReg;
629
630  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
631  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
632  getReg        = Console_Port_Tbl[minor]->getRegister;
633  setReg        = Console_Port_Tbl[minor]->setRegister;
634
635  /* Get ISR at the beginning of the IT routine */
636  ucISRStatus = (*getReg)(pMC68681, MC68681_INTERRUPT_STATUS_REG);
637
638  /* Get good ISR a or b channel */
639  if (pMC68681 != pMC68681_port){
640    ucISRStatus >>= 4;
641  }
642
643  /* See if is usefull to call rtems_termios_dequeue */
644  if(Console_Port_Data[minor].bActive == FALSE) {
645                ucISRStatus = ucISRStatus & ~MC68681_IR_TX_READY;
646  }
647
648  /*
649   * Deal with any received characters
650   */
651  while(true) {
652    ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
653    if(!(ucLineStatus & MC68681_RX_READY)) {
654      break;
655    }
656    /*
657     *  If there is a RX error, then dump all the data.
658     */
659    if ( ucLineStatus & MC68681_RX_ERRORS ) {
660      do {
661        cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
662        ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
663      } while ( ucLineStatus & MC68681_RX_READY );
664      continue;
665    }
666    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
667    rtems_termios_enqueue_raw_characters(
668      Console_Port_Data[minor].termios_data,
669      &cChar,
670      1
671    );
672  }
673
674  /*
675   *  Deal with the transmitter
676   */
677
678  if (ucISRStatus & MC68681_IR_TX_READY) {
679    if (!rtems_termios_dequeue_characters(
680          Console_Port_Data[minor].termios_data, 1)) {
681          /* If no more char to send, disable TX interrupt */
682      Console_Port_Data[minor].bActive = FALSE;
683      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
684    }
685  }
686}
687
688/*
689 *  mc68681_build_imr
690 *
691 *  This function returns the value for the interrupt mask register for this
692 *  DUART.  Since this is a shared register, we must look at the other port
693 *  on this chip to determine whether or not it is using interrupts.
694 */
695
696MC68681_STATIC unsigned int mc68681_build_imr(
697  int  minor,
698  int  enable_flag
699)
700{
701  int              mate;
702  int              is_a;
703  unsigned int     mask;
704  unsigned int     mate_mask;
705  unsigned int     pMC68681;
706  unsigned int     pMC68681_port;
707  mc68681_context *pmc68681Context;
708  mc68681_context *mateContext;
709
710  pMC68681        = Console_Port_Tbl[minor]->ulCtrlPort1;
711  pMC68681_port   = Console_Port_Tbl[minor]->ulCtrlPort2;
712  pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
713  mate            = pmc68681Context->mate;
714
715  mask = 0;
716  mate_mask = 0;
717
718  is_a = (pMC68681 == pMC68681_port);
719
720  /*
721   *  If there is a mate for this port, get its IMR mask.
722   */
723
724  if ( mate != -1 ) {
725    mateContext = Console_Port_Data[mate].pDeviceContext;
726
727    if (mateContext)
728      mate_mask = mateContext->imr;
729  }
730
731  /*
732   *  Calculate this port's IMR mask and save it in the context area.
733   */
734
735  if ( Console_Port_Tbl[minor]->pDeviceFns->deviceOutputUsesInterrupts )
736    mask = enable_flag;
737
738  pmc68681Context->imr = mask;
739
740  /*
741   *  Now return the full IMR value
742   */
743
744  if (is_a)
745    return (mate_mask << 4) | mask;
746
747  return (mask << 4) | mate_mask;
748}
749
750/*
751 *  mc68681_enable_interrupts
752 *
753 *  This function enables specific interrupt sources on the DUART.
754 */
755
756MC68681_STATIC void mc68681_enable_interrupts(
757  int minor,
758  int imr_mask
759)
760{
761  uint32_t              pMC68681;
762  setRegister_f         setReg;
763
764  pMC68681 = Console_Port_Tbl[minor]->ulCtrlPort1;
765  setReg   = Console_Port_Tbl[minor]->setRegister;
766
767  /*
768   *  Enable interrupts on RX and TX -- not break
769   */
770
771  (*setReg)(
772     pMC68681,
773     MC68681_INTERRUPT_MASK_REG,
774     mc68681_build_imr(minor, imr_mask)
775  );
776}
Note: See TracBrowser for help on using the repository browser.