File indexing completed on 2025-05-11 08:23:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include <bsp.h>
0038 #include <termios.h>
0039 #include <stdio.h>
0040 #include <stdlib.h>
0041
0042 #include <rtems/termiostypes.h>
0043 #include <libchip/serial.h>
0044 #include <libchip/z85c30.h>
0045 #include <rtems/bspIo.h>
0046 #include <bsp/rtd316.h>
0047 #include <rtems/score/i386.h>
0048 #include "../../shared/dev/serial/legacy-console.h"
0049
0050 #define RTD_CLOCK_RATE (460800 * 32)
0051
0052 uint8_t rtd316_com_get_register(uintptr_t addr, uint8_t reg)
0053 {
0054 register uint8_t val = 0;
0055
0056 outport_byte( addr, reg );
0057
0058 inport_byte( addr, val );
0059
0060 return val;
0061 }
0062
0063 void rtd316_com_set_register(uintptr_t addr, uint8_t reg, uint8_t val)
0064 {
0065 outport_byte( addr, reg );
0066
0067 outport_byte( addr, val );
0068 }
0069
0070 rtems_device_driver rtd316_initialize(
0071 rtems_device_major_number major,
0072 rtems_device_minor_number minor_arg,
0073 void *arg
0074 )
0075 {
0076 int p;
0077 console_tbl *ports;
0078 console_tbl *port_p;
0079
0080
0081
0082
0083 ports = calloc( 2, sizeof( console_tbl ) );
0084 port_p = ports;
0085
0086 for ( p=0 ; p<2 ; p++ ) {
0087 char name[32];
0088 sprintf( name, "/dev/rtd316_1_%d", p );
0089 printk("Found %s\n", name );
0090 port_p->sDeviceName = strdup( name );
0091 port_p->deviceType = SERIAL_Z85C30;
0092 #if 0
0093 port_p->pDeviceFns = &z85c30_fns_polled;
0094 #else
0095 port_p->pDeviceFns = &z85c30_fns;
0096 #endif
0097
0098 port_p->deviceProbe = NULL;
0099 port_p->pDeviceFlow = NULL;
0100 port_p->ulMargin = 16;
0101 port_p->ulHysteresis = 8;
0102 port_p->pDeviceParams = (void *) 9600;
0103 port_p->getRegister = rtd316_com_get_register;
0104 port_p->setRegister = rtd316_com_set_register;
0105 port_p->getData = NULL;
0106 port_p->setData = NULL;
0107 port_p->ulClock = RTD_CLOCK_RATE;
0108 port_p->ulIntVector = 9;
0109
0110 if ( p==0 ) {
0111 port_p->ulDataPort = 0;
0112 port_p->ulCtrlPort1 = 0x340;
0113 port_p->ulCtrlPort2 = 0x341;
0114 } else {
0115 port_p->ulDataPort = 1;
0116 port_p->ulCtrlPort1 = 0x342;
0117 port_p->ulCtrlPort2 = 0x343;
0118 }
0119 port_p++;
0120 }
0121
0122
0123
0124
0125 console_register_devices( ports, 2 );
0126
0127 return RTEMS_SUCCESSFUL;
0128 }