source: rtems/c/src/libchip/serial/mc68681.c @ 229bcca8

4.115
Last change on this file since 229bcca8 was 229bcca8, checked in by Jennifer Averett <Jennifer.Averett@…>, on 10/18/11 at 18:40:27

2011-10-18 Jennifer Averett <Jennifer.Averett@…>

PR 1917/bsps

  • libchip/serial/mc68681.c, libchip/serial/ns16550.c, libchip/serial/serial.h, libchip/serial/z85c30.c: Modifications to add dynamic tables for libchip serial drivers.
  • 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
343#if 0
344  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
345  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
346#endif
347
348  return(RTEMS_SUCCESSFUL);
349}
350
351/*
352 *  mc68681_write_polled
353 *
354 *  This routine polls out the requested character.
355 */
356
357MC68681_STATIC void mc68681_write_polled(
358  int   minor,
359  char  cChar
360)
361{
362  uint32_t                pMC68681_port;
363  unsigned char           ucLineStatus;
364  int                     iTimeout;
365  getRegister_f           getReg;
366  setRegister_f           setReg;
367
368  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
369  getReg        = Console_Port_Tbl[minor]->getRegister;
370  setReg        = Console_Port_Tbl[minor]->setRegister;
371
372  /*
373   * wait for transmitter holding register to be empty
374   */
375  iTimeout = 1000;
376  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
377  while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) {
378
379    if ((ucLineStatus & 0xF0))
380      (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
381
382    /*
383     * Yield while we wait
384     */
385
386#if 0
387     if(_System_state_Is_up(_System_state_Get())) {
388       rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
389     }
390#endif
391     ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
392     if(!--iTimeout) {
393       break;
394     }
395  }
396
397  /*
398   * transmit character
399   */
400
401  (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar);
402}
403
404/*
405 *  mc68681_isr
406 *
407 *  This is the single interrupt entry point which parcels interrupts
408 *  out to the various ports.
409 */
410
411MC68681_STATIC rtems_isr mc68681_isr(
412  rtems_vector_number vector
413)
414{
415  int     minor;
416
417  for(minor=0 ; minor<Console_Port_Count ; minor++) {
418    if(Console_Port_Tbl[minor]->ulIntVector == vector &&
419       Console_Port_Tbl[minor]->deviceType == SERIAL_MC68681 ) {
420      mc68681_process(minor);
421    }
422  }
423}
424
425/*
426 *  mc68681_initialize_interrupts
427 *
428 *  This routine initializes the console's receive and transmit
429 *  ring buffers and loads the appropriate vectors to handle the interrupts.
430 */
431
432MC68681_STATIC void mc68681_initialize_interrupts(int minor)
433{
434  mc68681_init(minor);
435
436  Console_Port_Data[minor].bActive = FALSE;
437
438  set_vector(mc68681_isr, Console_Port_Tbl[minor]->ulIntVector, 1);
439
440  mc68681_enable_interrupts(minor,MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
441}
442
443/*
444 *  mc68681_write_support_int
445 *
446 *  Console Termios output entry point when using interrupt driven output.
447 */
448
449MC68681_STATIC ssize_t mc68681_write_support_int(
450  int         minor,
451  const char *buf,
452  size_t      len
453)
454{
455  uint32_t        Irql;
456  uint32_t        pMC68681_port;
457  setRegister_f   setReg;
458
459  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
460  setReg        = Console_Port_Tbl[minor]->setRegister;
461
462  /*
463   *  We are using interrupt driven output and termios only sends us
464   *  one character at a time.
465   */
466
467  if ( !len )
468    return 0;
469
470  /*
471   *  Put the character out and enable interrupts if necessary.
472   */
473
474  rtems_interrupt_disable(Irql);
475    if ( Console_Port_Data[minor].bActive == FALSE ) {
476      Console_Port_Data[minor].bActive = TRUE;
477      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL);
478    }
479    (*setReg)(pMC68681_port, MC68681_TX_BUFFER, *buf);
480  rtems_interrupt_enable(Irql);
481
482  return 0;
483}
484
485/*
486 *  mc68681_write_support_polled
487 *
488 *  Console Termios output entry point when using polled output.
489 *
490 */
491
492MC68681_STATIC ssize_t mc68681_write_support_polled(
493  int         minor,
494  const char *buf,
495  size_t      len
496)
497{
498  int nwrite = 0;
499
500  /*
501   * poll each byte in the string out of the port.
502   */
503  while (nwrite < len) {
504    /*
505     * transmit character
506     */
507    mc68681_write_polled(minor, *buf++);
508    nwrite++;
509  }
510
511  /*
512   * return the number of bytes written.
513   */
514  return nwrite;
515}
516
517/*
518 *  mc68681_inbyte_nonblocking_polled
519 *
520 *  Console Termios polling input entry point.
521 */
522
523MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
524  int minor
525)
526{
527  uint32_t             pMC68681_port;
528  unsigned char        ucLineStatus;
529  unsigned char        cChar;
530  getRegister_f        getReg;
531
532  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
533  getReg        = Console_Port_Tbl[minor]->getRegister;
534
535  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
536  if(ucLineStatus & MC68681_RX_READY) {
537    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
538    return (int)cChar;
539  } else {
540    return -1;
541  }
542}
543
544/*
545 *  mc68681_baud_rate
546 */
547
548MC68681_STATIC int mc68681_baud_rate(
549  int           minor,
550  int           baud,
551  unsigned int *baud_mask_p,
552  unsigned int *acr_bit_p,
553  unsigned int *command
554)
555{
556  unsigned int           baud_mask;
557  unsigned int           acr_bit;
558  int                    status;
559  int                    is_extended;
560  int                    baud_requested;
561  mc68681_baud_table_t  *baud_tbl;
562
563  baud_mask = 0;
564  acr_bit = 0;
565  status = 0;
566
567  if (Console_Port_Tbl[minor]->ulDataPort & MC68681_DATA_BAUD_RATE_SET_2)
568  {
569    acr_bit = 1;
570  }
571
572  is_extended = 0;
573
574  switch (Console_Port_Tbl[minor]->ulDataPort & MC68681_XBRG_MASK) {
575    case MC68681_XBRG_IGNORED:
576      *command = 0x00;
577      break;
578    case MC68681_XBRG_ENABLED:
579      *command = 0x80;
580      is_extended = 1;
581      break;
582    case MC68681_XBRG_DISABLED:
583      *command = 0x90;
584      break;
585  }
586
587  baud_requested = baud & CBAUD;
588  if (!baud_requested)
589    baud_requested = B9600;              /* default to 9600 baud */
590
591  baud_requested = rtems_termios_baud_to_index( baud_requested );
592
593  baud_tbl = (mc68681_baud_table_t *)
594     ((uintptr_t)Console_Port_Tbl[minor]->ulClock);
595  if (!baud_tbl)
596    rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS);
597
598  if ( is_extended )
599    baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ];
600  else
601    baud_mask = baud_tbl[ acr_bit ][ baud_requested ];
602
603  if ( baud_mask == MC68681_BAUD_NOT_VALID )
604    status = -1;
605
606  /*
607   *  upper nibble is receiver and lower nibble is transmitter
608   */
609
610  *baud_mask_p = (baud_mask << 4) | baud_mask;
611  *acr_bit_p   = acr_bit;
612  return status;
613}
614
615/*
616 *  mc68681_process
617 *
618 *  This routine is the per port console interrupt handler.
619 */
620
621MC68681_STATIC void mc68681_process(
622  int  minor
623)
624{
625  uint32_t                pMC68681;
626  uint32_t                pMC68681_port;
627  volatile uint8_t        ucLineStatus;
628  volatile uint8_t        ucISRStatus;
629  char                    cChar;
630  getRegister_f           getReg;
631  setRegister_f           setReg;
632
633  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
634  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
635  getReg        = Console_Port_Tbl[minor]->getRegister;
636  setReg        = Console_Port_Tbl[minor]->setRegister;
637
638  /* Get ISR at the beginning of the IT routine */
639  ucISRStatus = (*getReg)(pMC68681, MC68681_INTERRUPT_STATUS_REG);
640
641  /* Get good ISR a or b channel */
642  if (pMC68681 != pMC68681_port){
643    ucISRStatus >>= 4;
644  }
645
646  /* See if is usefull to call rtems_termios_dequeue */
647  if(Console_Port_Data[minor].bActive == FALSE) {
648                ucISRStatus = ucISRStatus & ~MC68681_IR_TX_READY;
649  }
650
651  /*
652   * Deal with any received characters
653   */
654  while(true) {
655    ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
656    if(!(ucLineStatus & MC68681_RX_READY)) {
657      break;
658    }
659    /*
660     *  If there is a RX error, then dump all the data.
661     */
662    if ( ucLineStatus & MC68681_RX_ERRORS ) {
663      do {
664        cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
665        ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
666      } while ( ucLineStatus & MC68681_RX_READY );
667      continue;
668    }
669    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
670    rtems_termios_enqueue_raw_characters(
671      Console_Port_Data[minor].termios_data,
672      &cChar,
673      1
674    );
675  }
676
677  /*
678   *  Deal with the transmitter
679   */
680
681  if (ucISRStatus & MC68681_IR_TX_READY) {
682    if (!rtems_termios_dequeue_characters(
683          Console_Port_Data[minor].termios_data, 1)) {
684          /* If no more char to send, disable TX interrupt */
685      Console_Port_Data[minor].bActive = FALSE;
686      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
687    }
688  }
689}
690
691/*
692 *  mc68681_build_imr
693 *
694 *  This function returns the value for the interrupt mask register for this
695 *  DUART.  Since this is a shared register, we must look at the other port
696 *  on this chip to determine whether or not it is using interrupts.
697 */
698
699MC68681_STATIC unsigned int mc68681_build_imr(
700  int  minor,
701  int  enable_flag
702)
703{
704  int              mate;
705  int              is_a;
706  unsigned int     mask;
707  unsigned int     mate_mask;
708  unsigned int     pMC68681;
709  unsigned int     pMC68681_port;
710  mc68681_context *pmc68681Context;
711  mc68681_context *mateContext;
712
713  pMC68681        = Console_Port_Tbl[minor]->ulCtrlPort1;
714  pMC68681_port   = Console_Port_Tbl[minor]->ulCtrlPort2;
715  pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
716  mate            = pmc68681Context->mate;
717
718  mask = 0;
719  mate_mask = 0;
720
721  is_a = (pMC68681 == pMC68681_port);
722
723  /*
724   *  If there is a mate for this port, get its IMR mask.
725   */
726
727  if ( mate != -1 ) {
728    mateContext = Console_Port_Data[mate].pDeviceContext;
729
730    if (mateContext)
731      mate_mask = mateContext->imr;
732  }
733
734  /*
735   *  Calculate this port's IMR mask and save it in the context area.
736   */
737
738  if ( Console_Port_Tbl[minor]->pDeviceFns->deviceOutputUsesInterrupts )
739    mask = enable_flag;
740
741  pmc68681Context->imr = mask;
742
743  /*
744   *  Now return the full IMR value
745   */
746
747  if (is_a)
748    return (mate_mask << 4) | mask;
749
750  return (mask << 4) | mate_mask;
751}
752
753/*
754 *  mc68681_enable_interrupts
755 *
756 *  This function enables specific interrupt sources on the DUART.
757 */
758
759MC68681_STATIC void mc68681_enable_interrupts(
760  int minor,
761  int imr_mask
762)
763{
764  uint32_t              pMC68681;
765  setRegister_f         setReg;
766
767  pMC68681 = Console_Port_Tbl[minor]->ulCtrlPort1;
768  setReg   = Console_Port_Tbl[minor]->setRegister;
769
770  /*
771   *  Enable interrupts on RX and TX -- not break
772   */
773
774  (*setReg)(
775     pMC68681,
776     MC68681_INTERRUPT_MASK_REG,
777     mc68681_build_imr(minor, imr_mask)
778  );
779}
Note: See TracBrowser for help on using the repository browser.