Changeset a5d0c7c in rtems for c/src/libchip/serial/mc68681.c


Ignore:
Timestamp:
Jun 23, 1998, 3:54:33 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
beaaf49f
Parents:
b7ebcea
Message:

Added concept of "mate" -- the other port on the same DUART. This is
needed to properly handle the interrupt mask register since it is
shared.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/serial/mc68681.c

    rb7ebcea ra5d0c7c  
    167167}
    168168
    169 #define MC68681_PORT_MASK( _port, _bits ) \
    170   ((_port) ? ((_bits) << 4) : (_bits))
    171 
    172169static int mc68681_set_attributes(
    173170  int minor,
     
    251248}
    252249
     250static void mc68681_initialize_context(
     251  int               minor,
     252  mc68681_context  *pmc68681Context
     253)
     254{
     255  int          port;
     256  unsigned int pMC68681;
     257 
     258  pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
     259
     260  pmc68681Context->mate = -1;
     261
     262  for (port=0 ; port<Console_Port_Count ; port++ ) {
     263    if ( Console_Port_Tbl[port].ulCtrlPort1 == pMC68681 ) {
     264      pmc68681Context->mate = port;
     265      break;
     266    }
     267  }
     268
     269  pmc68681Context->ucModemCtrl = 0x00;   /* XXX */
     270}
     271
     272static unsigned int mc68681_build_imr(
     273  int minor
     274)
     275{
     276  int              mate;
     277  unsigned int     mask;
     278  unsigned int     mate_mask;
     279  unsigned int     pMC68681;
     280  unsigned int     pMC68681_port;
     281  mc68681_context *pmc68681Context;
     282 
     283  pMC68681       = Console_Port_Tbl[minor].ulCtrlPort1;
     284  pMC68681_port  = Console_Port_Tbl[minor].ulCtrlPort2;
     285  pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
     286  mate            = pmc68681Context->mate;
     287
     288  mate_mask = 0;
     289
     290  /*
     291   *  Decide if the other port on this DUART is using interrupts
     292   */
     293
     294  if ( mate != -1 ) {
     295    if ( Console_Port_Tbl[mate].pDeviceFns->deviceOutputUsesInterrupts )
     296      mate_mask = 0x03;
     297
     298    /*
     299     *  If equal, then minor is A so the mate must be B
     300     */
     301
     302    if ( pMC68681 == pMC68681_port )
     303      mate_mask <<= 4;
     304  }
     305
     306
     307  /*
     308   *  Add in minor's mask
     309   */
     310
     311  mask = 0;
     312  if ( Console_Port_Tbl[minor].pDeviceFns->deviceOutputUsesInterrupts ) {
     313    if ( pMC68681 == pMC68681_port )
     314       mask = 0x03;
     315    else
     316       mask = 0x30;
     317  }
     318
     319  return mask | mate_mask;
     320}
     321
    253322static void mc68681_init(int minor)
    254323{
    255 /* XXX */
    256324  unsigned32              pMC68681_port;
    257325  unsigned32              pMC68681;
     
    259327  setRegister_f           setReg;
    260328  getRegister_f           getReg;
    261   unsigned int            port;
    262329
    263330  pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context));
    264331
    265332  Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context;
    266 #if 0
    267   pmc68681Context->ucModemCtrl = SP_MODEM_IRQ;
    268 #endif
     333
     334  mc68681_initialize_context( minor, pmc68681Context );
    269335
    270336  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort1;
     
    272338  setReg        = Console_Port_Tbl[minor].setRegister;
    273339  getReg        = Console_Port_Tbl[minor].getRegister;
    274   port          = Console_Port_Tbl[minor].ulDataPort;
    275340
    276341  /*
     
    305370  unsigned int           baud;
    306371  unsigned int           acr;
    307   unsigned int           port;
    308372  unsigned int           vector;
    309373  rtems_interrupt_level  Irql;
     
    313377  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
    314378  setReg        = Console_Port_Tbl[minor].setRegister;
    315   port          = Console_Port_Tbl[minor].ulDataPort;
    316379  vector        = Console_Port_Tbl[minor].ulIntVector;
    317380
     
    330393  rtems_interrupt_enable(Irql);
    331394
    332   (*setReg)(
    333      pMC68681,
    334      MC68681_INTERRUPT_MASK_REG,
    335      MC68681_PORT_MASK( port, 0x03 )  /* intr on RX and TX -- not break */
    336   );
    337 
    338395  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX );
    339396  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX );
     
    360417  unsigned32      pMC68681;
    361418  unsigned32      pMC68681_port;
    362   unsigned int    port;
    363419  setRegister_f   setReg;
    364420
     
    366422  pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
    367423  setReg        = Console_Port_Tbl[minor].setRegister;
    368   port          = Console_Port_Tbl[minor].ulDataPort;
    369424
    370425  /*
    371426   *  Disable interrupts from this channel and then disable it totally.
    372427   */
    373 
    374   (*setReg)(
    375      pMC68681,
    376      MC68681_INTERRUPT_MASK_REG,
    377      MC68681_PORT_MASK( port, 0x03 )  /* intr on RX and TX -- not break */
    378   );
    379428
    380429  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
     
    688737 *  This routine initializes the console's receive and transmit
    689738 *  ring buffers and loads the appropriate vectors to handle the interrupts.
    690  *
    691  *  Input parameters:  NONE
    692  *
    693  *  Output parameters: NONE
    694  *
    695  *  Return values:     NONE
    696739 */
    697740
     
    700743)
    701744{
    702 /* XXX */
    703745  unsigned32            pMC68681;
    704   unsigned8             ucDataByte;
    705746  setRegister_f         setReg;
    706747
    707 #if 1
    708 ucDataByte = 0;
    709 #endif
    710748  pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
    711749  setReg   = Console_Port_Tbl[minor].setRegister;
    712750
    713 #if 0
    714   /*
    715    * Enable interrupts
    716    */
    717   ucDataByte = SP_INT_RX_ENABLE | SP_INT_TX_ENABLE;
    718   (*setReg)(pMC68681, MC68681_INTERRUPT_ENABLE, ucDataByte);
    719 #endif
     751  /*
     752   *  Enable interrupts on RX and TX -- not break
     753   */
     754
     755  (*setReg)( pMC68681, MC68681_INTERRUPT_MASK_REG, mc68681_build_imr( minor ));
    720756}
    721757
Note: See TracChangeset for help on using the changeset viewer.