source: rtems/c/src/libchip/serial/mc68681.c @ 64a1529

4.104.115
Last change on this file since 64a1529 was 64a1529, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/30/09 at 04:02:40

2009-09-30 Ralf Corsépius <ralf.corsepius@…>

  • libchip/serial/z85c30.c, libchip/serial/ns16550.c, libchip/serial/mc68681.c: Reflect termios_baud_to_number having been renamed to rtems_termios_baud_to_number.
  • Property mode set to 100644
File size: 19.0 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  getRegister_f           getReg;
227
228  pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context));
229
230  Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context;
231
232  mc68681_initialize_context( minor, pmc68681Context );
233
234  pMC68681      = Console_Port_Tbl[minor].ulCtrlPort1;
235  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
236  setReg        = Console_Port_Tbl[minor].setRegister;
237  getReg        = Console_Port_Tbl[minor].getRegister;
238
239  /*
240   *  Reset everything and leave this port disabled.
241   */
242
243  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_RX );
244  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_TX );
245  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
246  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_BREAK );
247  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_STOP_BREAK );
248  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
249  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
250
251
252  (*setReg)( pMC68681_port, MC68681_MODE_REG_1A, 0x00 );
253  (*setReg)( pMC68681_port, MC68681_MODE_REG_2A, 0x02 );
254
255  /*
256   *  Disable interrupts on RX and TX for this port
257   */
258
259  mc68681_enable_interrupts( minor, MC68681_IMR_DISABLE_ALL );
260}
261
262/*
263 *  mc68681_open
264 *
265 *  This function opens a port for communication.
266 *
267 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
268 */
269
270MC68681_STATIC int mc68681_open(
271  int      major,
272  int      minor,
273  void    *arg
274)
275{
276  uint32_t               pMC68681;
277  uint32_t               pMC68681_port;
278  unsigned int           baud;
279  unsigned int           acr_bit;
280  unsigned int           vector;
281  unsigned int           command = 0;
282  rtems_interrupt_level  Irql;
283  setRegister_f          setReg;
284  unsigned int                   status;
285
286
287  pMC68681      = Console_Port_Tbl[minor].ulCtrlPort1;
288  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
289  setReg        = Console_Port_Tbl[minor].setRegister;
290  vector        = Console_Port_Tbl[minor].ulIntVector;
291
292  /* XXX default baud rate should be from configuration table */
293
294  status = mc68681_baud_rate( minor, B9600, &baud, &acr_bit, &command );
295  if (status < 0) rtems_fatal_error_occurred (RTEMS_NOT_DEFINED);
296
297  /*
298   *  Set the DUART channel to a default useable state
299   */
300
301  rtems_interrupt_disable(Irql);
302    (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit << 7 );
303    (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud );
304    if ( command ) {
305      (*setReg)( pMC68681_port, MC68681_COMMAND, command );         /* RX */
306      (*setReg)( pMC68681_port, MC68681_COMMAND, command | 0x20 );  /* TX */
307    }
308    (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
309    (*setReg)( pMC68681_port, MC68681_MODE, 0x13 );
310    (*setReg)( pMC68681_port, MC68681_MODE, 0x07 );
311  rtems_interrupt_enable(Irql);
312
313  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX );
314  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX );
315
316  (*setReg)( pMC68681, MC68681_INTERRUPT_VECTOR_REG, vector );
317
318  return RTEMS_SUCCESSFUL;
319}
320
321/*
322 *  mc68681_close
323 *
324 *  This function shuts down the requested port.
325 */
326
327MC68681_STATIC int mc68681_close(
328  int      major,
329  int      minor,
330  void    *arg
331)
332{
333  uint32_t        pMC68681;
334  uint32_t        pMC68681_port;
335  setRegister_f   setReg;
336
337  pMC68681      = Console_Port_Tbl[minor].ulCtrlPort1;
338  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
339  setReg        = Console_Port_Tbl[minor].setRegister;
340
341  /*
342   *  Disable interrupts from this channel and then disable it totally.
343   */
344
345#if 0
346  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
347  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
348#endif
349
350  return(RTEMS_SUCCESSFUL);
351}
352
353/*
354 *  mc68681_write_polled
355 *
356 *  This routine polls out the requested character.
357 */
358
359MC68681_STATIC void mc68681_write_polled(
360  int   minor,
361  char  cChar
362)
363{
364  uint32_t                pMC68681_port;
365  unsigned char           ucLineStatus;
366  int                     iTimeout;
367  getRegister_f           getReg;
368  setRegister_f           setReg;
369
370  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
371  getReg        = Console_Port_Tbl[minor].getRegister;
372  setReg        = Console_Port_Tbl[minor].setRegister;
373
374  /*
375   * wait for transmitter holding register to be empty
376   */
377  iTimeout = 1000;
378  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
379  while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) {
380
381    if ((ucLineStatus & 0xF0))
382      (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
383
384    /*
385     * Yield while we wait
386     */
387
388#if 0
389     if(_System_state_Is_up(_System_state_Get())) {
390       rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
391     }
392#endif
393     ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
394     if(!--iTimeout) {
395       break;
396     }
397  }
398
399  /*
400   * transmit character
401   */
402
403  (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar);
404}
405
406/*
407 *  mc68681_isr
408 *
409 *  This is the single interrupt entry point which parcels interrupts
410 *  out to the various ports.
411 */
412
413MC68681_STATIC rtems_isr mc68681_isr(
414  rtems_vector_number vector
415)
416{
417  int     minor;
418
419  for(minor=0 ; minor<Console_Port_Count ; minor++) {
420    if(Console_Port_Tbl[minor].ulIntVector == vector &&
421       Console_Port_Tbl[minor].deviceType == SERIAL_MC68681 ) {
422      mc68681_process(minor);
423    }
424  }
425}
426
427/*
428 *  mc68681_initialize_interrupts
429 *
430 *  This routine initializes the console's receive and transmit
431 *  ring buffers and loads the appropriate vectors to handle the interrupts.
432 */
433
434MC68681_STATIC void mc68681_initialize_interrupts(int minor)
435{
436  mc68681_init(minor);
437
438  Console_Port_Data[minor].bActive = FALSE;
439
440  set_vector(mc68681_isr, Console_Port_Tbl[minor].ulIntVector, 1);
441
442  mc68681_enable_interrupts(minor,MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
443}
444
445/*
446 *  mc68681_write_support_int
447 *
448 *  Console Termios output entry point when using interrupt driven output.
449 */
450
451MC68681_STATIC int mc68681_write_support_int(
452  int         minor,
453  const char *buf,
454  int         len
455)
456{
457  uint32_t        Irql;
458  uint32_t        pMC68681_port;
459  setRegister_f   setReg;
460
461  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
462  setReg        = Console_Port_Tbl[minor].setRegister;
463
464  /*
465   *  We are using interrupt driven output and termios only sends us
466   *  one character at a time.
467   */
468
469  if ( !len )
470    return 0;
471
472  /*
473   *  Put the character out and enable interrupts if necessary.
474   */
475
476  rtems_interrupt_disable(Irql);
477    if ( Console_Port_Data[minor].bActive == FALSE ) {
478      Console_Port_Data[minor].bActive = TRUE;
479      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL);
480    }
481    (*setReg)(pMC68681_port, MC68681_TX_BUFFER, *buf);
482  rtems_interrupt_enable(Irql);
483
484  return 1;
485}
486
487/*
488 *  mc68681_write_support_polled
489 *
490 *  Console Termios output entry point when using polled output.
491 *
492 */
493
494MC68681_STATIC int mc68681_write_support_polled(
495  int         minor,
496  const char *buf,
497  int         len
498)
499{
500  int nwrite = 0;
501
502  /*
503   * poll each byte in the string out of the port.
504   */
505  while (nwrite < len) {
506    /*
507     * transmit character
508     */
509    mc68681_write_polled(minor, *buf++);
510    nwrite++;
511  }
512
513  /*
514   * return the number of bytes written.
515   */
516  return nwrite;
517}
518
519/*
520 *  mc68681_inbyte_nonblocking_polled
521 *
522 *  Console Termios polling input entry point.
523 */
524
525MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
526  int minor
527)
528{
529  uint32_t             pMC68681_port;
530  unsigned char        ucLineStatus;
531  unsigned char        cChar;
532  getRegister_f        getReg;
533
534  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
535  getReg        = Console_Port_Tbl[minor].getRegister;
536
537  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
538  if(ucLineStatus & MC68681_RX_READY) {
539    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
540    return (int)cChar;
541  } else {
542    return -1;
543  }
544}
545
546/*
547 *  mc68681_baud_rate
548 */
549
550MC68681_STATIC int mc68681_baud_rate(
551  int           minor,
552  int           baud,
553  unsigned int *baud_mask_p,
554  unsigned int *acr_bit_p,
555  unsigned int *command
556)
557{
558  unsigned int           baud_mask;
559  unsigned int           acr_bit;
560  int                    status;
561  int                    is_extended;
562  int                    baud_requested;
563  mc68681_baud_table_t  *baud_tbl;
564
565  baud_mask = 0;
566  acr_bit = 0;
567  status = 0;
568
569  if (Console_Port_Tbl[minor].ulDataPort & MC68681_DATA_BAUD_RATE_SET_2)
570  {
571    acr_bit = 1;
572  }
573
574  is_extended = 0;
575
576  switch (Console_Port_Tbl[minor].ulDataPort & MC68681_XBRG_MASK) {
577    case MC68681_XBRG_IGNORED:
578      *command = 0x00;
579      break;
580    case MC68681_XBRG_ENABLED:
581      *command = 0x80;
582      is_extended = 1;
583      break;
584    case MC68681_XBRG_DISABLED:
585      *command = 0x90;
586      break;
587  }
588
589  baud_requested = baud & CBAUD;
590  if (!baud_requested)
591    baud_requested = B9600;              /* default to 9600 baud */
592
593  baud_requested = rtems_termios_baud_to_index( baud_requested );
594
595  baud_tbl = (mc68681_baud_table_t *) Console_Port_Tbl[minor].ulClock;
596  if (!baud_tbl)
597    rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS);
598
599  if ( is_extended )
600    baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ];
601  else
602    baud_mask = baud_tbl[ acr_bit ][ baud_requested ];
603
604  if ( baud_mask == MC68681_BAUD_NOT_VALID )
605    status = -1;
606
607  /*
608   *  upper nibble is receiver and lower nibble is transmitter
609   */
610
611  *baud_mask_p = (baud_mask << 4) | baud_mask;
612  *acr_bit_p   = acr_bit;
613  return status;
614}
615
616/*
617 *  mc68681_process
618 *
619 *  This routine is the per port console interrupt handler.
620 */
621
622MC68681_STATIC void mc68681_process(
623  int  minor
624)
625{
626  uint32_t                pMC68681;
627  uint32_t                pMC68681_port;
628  volatile uint8_t        ucLineStatus;
629  volatile uint8_t        ucISRStatus;
630  char                    cChar;
631  getRegister_f           getReg;
632  setRegister_f           setReg;
633
634  pMC68681      = Console_Port_Tbl[minor].ulCtrlPort1;
635  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
636  getReg        = Console_Port_Tbl[minor].getRegister;
637  setReg        = Console_Port_Tbl[minor].setRegister;
638
639  /* Get ISR at the beginning of the IT routine */
640  ucISRStatus = (*getReg)(pMC68681, MC68681_INTERRUPT_STATUS_REG);
641
642  /* Get good ISR a or b channel */
643  if (pMC68681 != pMC68681_port){
644    ucISRStatus >>= 4;
645  }
646
647  /* See if is usefull to call rtems_termios_dequeue */
648  if(Console_Port_Data[minor].bActive == FALSE) {
649                ucISRStatus = ucISRStatus & ~MC68681_IR_TX_READY;
650  }
651
652  /*
653   * Deal with any received characters
654   */
655  while(true) {
656    ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
657    if(!(ucLineStatus & MC68681_RX_READY)) {
658      break;
659    }
660    /*
661     *  If there is a RX error, then dump all the data.
662     */
663    if ( ucLineStatus & MC68681_RX_ERRORS ) {
664      do {
665        cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
666        ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
667      } while ( ucLineStatus & MC68681_RX_READY );
668      continue;
669    }
670    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
671    rtems_termios_enqueue_raw_characters(
672      Console_Port_Data[minor].termios_data,
673      &cChar,
674      1
675    );
676  }
677
678  /*
679   *  Deal with the transmitter
680   */
681
682  if (ucISRStatus & MC68681_IR_TX_READY) {
683    if (!rtems_termios_dequeue_characters(
684          Console_Port_Data[minor].termios_data, 1)) {
685          /* If no more char to send, disable TX interrupt */
686      Console_Port_Data[minor].bActive = FALSE;
687      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
688    }
689  }
690}
691
692/*
693 *  mc68681_build_imr
694 *
695 *  This function returns the value for the interrupt mask register for this
696 *  DUART.  Since this is a shared register, we must look at the other port
697 *  on this chip to determine whether or not it is using interrupts.
698 */
699
700MC68681_STATIC unsigned int mc68681_build_imr(
701  int  minor,
702  int  enable_flag
703)
704{
705  int              mate;
706  int              is_a;
707  unsigned int     mask;
708  unsigned int     mate_mask;
709  unsigned int     pMC68681;
710  unsigned int     pMC68681_port;
711  mc68681_context *pmc68681Context;
712  mc68681_context *mateContext;
713
714  pMC68681        = Console_Port_Tbl[minor].ulCtrlPort1;
715  pMC68681_port   = Console_Port_Tbl[minor].ulCtrlPort2;
716  pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
717  mate            = pmc68681Context->mate;
718
719  mask = 0;
720  mate_mask = 0;
721
722  is_a = (pMC68681 == pMC68681_port);
723
724  /*
725   *  If there is a mate for this port, get its IMR mask.
726   */
727
728  if ( mate != -1 ) {
729    mateContext = Console_Port_Data[mate].pDeviceContext;
730
731    if (mateContext)
732      mate_mask = mateContext->imr;
733  }
734
735  /*
736   *  Calculate this port's IMR mask and save it in the context area.
737   */
738
739  if ( Console_Port_Tbl[minor].pDeviceFns->deviceOutputUsesInterrupts )
740    mask = enable_flag;
741
742  pmc68681Context->imr = mask;
743
744  /*
745   *  Now return the full IMR value
746   */
747
748  if (is_a)
749    return (mate_mask << 4) | mask;
750
751  return (mask << 4) | mate_mask;
752}
753
754/*
755 *  mc68681_enable_interrupts
756 *
757 *  This function enables specific interrupt sources on the DUART.
758 */
759
760MC68681_STATIC void mc68681_enable_interrupts(
761  int minor,
762  int imr_mask
763)
764{
765  uint32_t              pMC68681;
766  setRegister_f         setReg;
767
768  pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
769  setReg   = Console_Port_Tbl[minor].setRegister;
770
771  /*
772   *  Enable interrupts on RX and TX -- not break
773   */
774
775  (*setReg)(
776     pMC68681,
777     MC68681_INTERRUPT_MASK_REG,
778     mc68681_build_imr(minor, imr_mask)
779  );
780}
Note: See TracBrowser for help on using the repository browser.