Ignore:
Timestamp:
Dec 21, 1999, 2:27:52 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
db3e0108
Parents:
3ad7602e
Message:

Patch rtems-rc-19991203-5.diff from Ralf Corsepius <corsepiu@…>
which cleans up and merges some Hitachi SH-2 modifications from
John Mills <jmills@…>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/sh/sh7045/sci/sci.c

    r3ad7602e r8b91282  
    120120} /* sh_sci_outbyte_polled */
    121121
    122 /* Initial version calls polled output driver and blocks */
     122/*
     123 * Initial version calls polled output driver and blocks
     124 */
    123125void outbyte(
    124126  rtems_device_minor_number  minor,
     
    187189/*  sh_sci_initialize
    188190 *
    189  *  This routine initializes the sh_sci IO driver.
    190  *
    191  *  Input parameters: NONE
     191 *  This routine initializes (registers) the sh_sci IO drivers.
     192 *
     193 *  Input parameters: ignored
    192194 *
    193195 *  Output parameters:  NONE
    194196 *
    195  *  Return values:
     197 *  Return values: RTEMS_SUCCESSFUL
     198 *   if all sci[...] register, else calls
     199 *   rtems_fatal_error_occurred(status)
     200 *
    196201 */
    197202
     
    201206  void                      *arg )
    202207{
    203   int a;
    204   unsigned16 temp16;
    205208  rtems_device_driver status ;
    206 
    207   /* register devices */ 
    208   for ( a = 0 ; a < 2 ; a++ )
     209  rtems_device_minor_number     i;
     210 
     211  /*
     212   * register all possible devices.
     213   * the initialization of the hardware is done by sci_open
     214   */
     215
     216  for ( i = 0 ; i < SCI_MINOR_DEVICES ; i++ )
    209217  {
    210218    status = rtems_io_register_name(
    211       sci_device[a].name,
     219      sci_device[i].name,
    212220      major,
    213       sci_device[a].minor );
     221      sci_device[i].minor );
    214222    if (status != RTEMS_SUCCESSFUL)
    215223      rtems_fatal_error_occurred(status);
    216224  }
    217225
    218   /* default hardware setup */
    219 
    220   /* general setup */
    221   temp16 = read16(PFC_PECR1) | 0x0800;  /* General I/O except pin 13 (reset) */
    222   write16(temp16, PFC_PECR1);
    223   write16(0x00, PFC_PECR2);     /* All I/O lines bits 7-0 */
    224   temp16 = read16(PFC_PEIOR) | 0x0020;  /* P5 to out, all other pins in */
    225   write16(temp16, PFC_PEIOR);
    226 
    227   temp16 = read16(PFC_PACRL2) | 0x0145;  /* PFC - pins for Tx0-1, Rx0-1 */
    228   write16(temp16, PFC_PACRL2);
    229  
     226  /* non-default hardware setup occurs in sh_sci_open() */
     227
    230228  return RTEMS_SUCCESSFUL;
    231229}
     
    234232/*
    235233 *  Open entry point
     234 *   Sets up port and pins for selected sci.
     235 *   SCI0 setup is conditional on STANDALONE_EVB == 1
    236236 */
    237237
     
    242242{
    243243  unsigned8 temp8;
     244  unsigned16 temp16;
    244245  unsigned char smr ;
    245246  unsigned char brr ;
     
    247248  unsigned      a ;
    248249 
     250 /* check for valid minor number */
     251   if(( minor > ( SCI_MINOR_DEVICES -1 )) || ( minor < 0 ))
     252   {
     253     return RTEMS_INVALID_NUMBER;
     254   }
     255 
    249256  /* device already opened */
    250257  if ( sci_device[minor].opened > 0 )
    251258  {
    252259    sci_device[minor].opened++ ;
    253 
    254260    return RTEMS_SUCCESSFUL ;
    255261  }
    256262   
    257   /* retrieve brr and smr values */
    258   _sci_get_brparms( sci_device[minor].cflags, &smr, &brr );
    259  
    260   if (minor == 0) {
    261     write8(0x00, SCI_SCR0);     /* Clear SCR */
    262     write8(smr, SCI_SMR0);      /* Clear SMR */
    263     write8(brr, SCI_BRR0);      /* Default 9600 baud rate */
    264 #if 0
    265     write8(0x1F, SCI_BRR0);    /* 28800 baud */
    266 #endif
    267 /* FIXME: Will get optimized away */
    268     for(a=0;a<10000L;a++);      /* One bit delay */
    269     write8(0x30, SCI_SCR0);     /* Enable clock output */
    270     temp8 = read8(SCI_RDR0);      /* Clear out old input */
    271 
    272   } else {
    273     write8(0x00, SCI_SCR1);     /* Clear SCR */
    274     write8(smr, SCI_SMR1);      /* Clear SMR */
    275     write8(brr, SCI_BRR1);      /* Default 9600 baud rate */
    276 #if 0
    277     write8(0x1F, SCI_BRR1);    /* 28800 baud */
    278 #endif
    279 /* FIXME: Will get optimized away */
    280     for(a=0;a<10000L;a++);      /* One bit delay */
    281     write8(0x30, SCI_SCR1);     /* Enable clock output */
    282     temp8 = read8(SCI_RDR1);      /* Clear out old input */
    283   } 
     263  /* enable I/O pins */
     264
     265  if ((minor == 0) && (STANDALONE_EVB == 1)) {
     266    temp16 = read16(PFC_PACRL2) &          /* disable SCK0, Tx0, Rx0 */
     267      ~(PA2MD1 | PA2MD0 | PA1MD0 | PA0MD0);
     268    temp16 |= (PA_TXD0 | PA_RXD0);       /* assign pins for Tx0, Rx0 */
     269    write16(temp16, PFC_PACRL2);
     270   
     271  } else if (minor == 1) { 
     272    temp16 = read16(PFC_PACRL2) &           /* disable SCK1, Tx1, Rx1 */
     273      ~(PA5MD1 | PA5MD0 | PA4MD0 | PA3MD0);
     274    temp16 |= (PA_TXD1 | PA_RXD1);        /* assign pins for Tx1, Rx1 */
     275    write16(temp16, PFC_PACRL2);
     276
     277  } /* add other devices and pins as req'd. */
     278
     279  /* set up SCI registers */
     280  if ((minor != 0) || (STANDALONE_EVB == 1)) {
     281    write8(0x00, sci_device[minor].addr + SCI_SCR);      /* Clear SCR */
     282                                                   /* set SCR and BRR */
     283    _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags );
     284
     285    for(a=0; a < 10000L; a++) {                      /* One-bit delay */
     286      asm volatile ("nop");
     287    }
     288
     289    write8((SCI_RE | SCI_TE),              /* enable async. Tx and Rx */
     290           sci_device[minor].addr + SCI_SCR);
     291    temp8 = read8(sci_device[minor].addr + SCI_RDR);   /* flush input */
     292   
     293    /* add interrupt setup if required */
     294
     295  }
    284296
    285297  sci_device[minor].opened++ ;
Note: See TracChangeset for help on using the changeset viewer.