Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:01

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * This file contains the TTY driver table. The implementation is
0005  * based on libchip/serial drivers, but it uses internal SHx SCI so
0006  * the implementation of the driver is placed in
0007  * lib/libcpu/sh/sh7045/sci instead of libchip/serial.
0008  *
0009  *  COPYRIGHT (c) 1989-2001.
0010  *  On-Line Applications Research Corporation (OAR).
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  *
0033  */
0034 
0035 #include <bsp.h>
0036 #include <libchip/serial.h>
0037 #include <libchip/sersupp.h>
0038 #include <sh/sci_termios.h>
0039 #include <rtems/score/sh_io.h>
0040 #include <rtems/score/ispsh7045.h>
0041 #include <rtems/score/iosh7045.h>
0042 #include <rtems/termiostypes.h>
0043 
0044 /*
0045  * Function set for interrupt enabled termios console
0046  */
0047 const console_fns sh_sci_fns =
0048 {
0049     libchip_serial_default_probe, /* deviceProbe */
0050     sh_sci_first_open,            /* deviceFirstOpen */
0051     NULL,                         /* deviceLastClose */
0052     NULL,                         /* deviceRead */
0053     sh_sci_write_support_int,     /* deviceWrite */
0054     sh_sci_initialize_interrupts, /* deviceInitialize */
0055     sh_sci_write_polled,          /* deviceWritePolled */
0056     sh_sci_set_attributes,        /* deviceSetAttributes */
0057     true                          /* deviceOutputUsesInterrupts */
0058 };
0059 
0060 /*
0061  * Function set for polled termios console
0062  */
0063 const console_fns sh_sci_fns_polled =
0064 {
0065     libchip_serial_default_probe, /* deviceProbe */
0066     sh_sci_first_open,            /* deviceFirstOpen */
0067     sh_sci_last_close,            /* deviceLastClose */
0068     sh_sci_inbyte_nonblocking_polled, /* deviceRead */
0069     sh_sci_write_support_polled,  /* deviceWrite */
0070     sh_sci_init,                  /* deviceInitialize */
0071     sh_sci_write_polled,          /* deviceWritePolled */
0072     sh_sci_set_attributes,        /* deviceSetAttributes */
0073     false                         /* deviceOutputUsesInterrupts */
0074 };
0075 
0076 #if 1 /* (CONSOLE_USE_INTERRUPTS) */
0077 #define SCI_FUNCTIONS &sh_sci_fns
0078 #else
0079 #define SCI_FUNCTIONS &sh_sci_fns_polled
0080 #endif
0081 
0082 static const struct termios term1 = {
0083     0,
0084     0,
0085     0,
0086     0,
0087     {0},
0088     B9600 | CS8,
0089     B9600 | CS8
0090 };
0091 
0092 static const struct termios term2 = {
0093     0,
0094     0,
0095     0,
0096     0,
0097     {0},
0098     B115200 | CS8,
0099     B115200 | CS8
0100 };
0101 
0102 console_tbl Console_Configuration_Ports[] = {
0103     {
0104         "/dev/sci0",            /* sDeviceName */
0105         SERIAL_CUSTOM,          /* deviceType */
0106         SCI_FUNCTIONS,          /* pDeviceFns */
0107         NULL,                   /* deviceProbe */
0108         NULL,                   /* pDeviceFlow */
0109         16,                     /* ulMargin */
0110         8,                      /* ulHysteresis */
0111         (void *)&term1,         /* baud rate */    /* pDeviceParams */
0112         SCI_SMR0,               /* ulCtrlPort1 */
0113         3,                      /* ulCtrlPort2 as IRQ priority level*/
0114         TXI0_ISP_V,             /* ulDataPort as TX end vector number*/
0115         NULL,                   /* unused */       /* getRegister */
0116         NULL,                   /* unused */       /* setRegister */
0117         NULL,                   /* unused */       /* getData */
0118         NULL,                   /* unused */       /* setData */
0119         0,                      /* ulClock */
0120         RXI0_ISP_V,             /* ulIntVector as RX end vector number*/
0121     },
0122     {
0123         "/dev/sci1",            /* sDeviceName */
0124         SERIAL_CUSTOM,          /* deviceType */
0125         SCI_FUNCTIONS,          /* pDeviceFns */
0126         NULL,                   /* deviceProbe */
0127         NULL,                   /* pDeviceFlow */
0128         16,                     /* ulMargin */
0129         8,                      /* ulHysteresis */
0130         (void *)&term2,         /* baud rate */    /* pDeviceParams */
0131         SCI_SMR1,               /* ulCtrlPort1 */
0132         3,                      /* ulCtrlPort2 as IRQ priority level*/
0133         TXI1_ISP_V,             /* ulDataPort as TX end vector number*/
0134         NULL,                   /* unused */       /* getRegister */
0135         NULL,                   /* unused */       /* setRegister */
0136         NULL,                   /* unused */       /* getData */
0137         NULL,                   /* unused */       /* setData */
0138         0,                      /* ulClock */
0139         RXI1_ISP_V,             /* ulIntVector as RX end vector number*/
0140     }
0141 };
0142 
0143 /*
0144  *  Declare some information used by the console driver
0145  */
0146 
0147 #define NUM_CONSOLE_PORTS (sizeof(Console_Configuration_Ports)/sizeof(console_tbl))
0148 
0149 unsigned long  Console_Configuration_Count =  NUM_CONSOLE_PORTS;