[ee3b242b] | 1 | /* |
---|
| 2 | * This file contains the TTY driver table definition |
---|
| 3 | * |
---|
| 4 | * This driver uses the termios pseudo driver. |
---|
| 5 | * |
---|
| 6 | * COPYRIGHT (c) 1998 by Radstone Technology |
---|
| 7 | * |
---|
| 8 | * |
---|
| 9 | * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY |
---|
| 10 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 11 | * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK |
---|
| 12 | * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU. |
---|
| 13 | * |
---|
| 14 | * You are hereby granted permission to use, copy, modify, and distribute |
---|
| 15 | * this file, provided that this notice, plus the above copyright notice |
---|
| 16 | * and disclaimer, appears in all copies. Radstone Technology will provide |
---|
| 17 | * no support for this code. |
---|
| 18 | * |
---|
| 19 | * $Id$ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef __LIBCHIP_SERIAL_h |
---|
| 23 | #define __LIBCHIP_SERIAL_h |
---|
| 24 | |
---|
[5ae415b] | 25 | #include <termios.h> |
---|
[ee3b242b] | 26 | #include <ringbuf.h> |
---|
| 27 | |
---|
[36152b0e] | 28 | /* |
---|
| 29 | * Types for get and set register routines |
---|
| 30 | */ |
---|
| 31 | |
---|
| 32 | typedef unsigned8 (*getRegister_f)(unsigned32 port, unsigned8 register); |
---|
| 33 | typedef void (*setRegister_f)( |
---|
| 34 | unsigned32 port, unsigned8 reg, unsigned8 value); |
---|
| 35 | typedef unsigned8 (*getData_f)(unsigned32 port); |
---|
| 36 | typedef void (*setData_f)(unsigned32 port, unsigned8 value); |
---|
| 37 | |
---|
[ee3b242b] | 38 | typedef struct _console_fns { |
---|
[424e23ee] | 39 | boolean (*deviceProbe)(int minor); |
---|
[58b1e95] | 40 | int (*deviceFirstOpen)(int major, int minor, void *arg); |
---|
| 41 | int (*deviceLastClose)(int major, int minor, void *arg); |
---|
| 42 | int (*deviceRead)(int minor); |
---|
| 43 | int (*deviceWrite)(int minor, const char *buf, int len); |
---|
| 44 | void (*deviceInitialize)(int minor); |
---|
| 45 | void (*deviceWritePolled)(int minor, char cChar); |
---|
[8a2d4f2b] | 46 | int (*deviceSetAttributes)(int minor, const struct termios *t); |
---|
[58b1e95] | 47 | int deviceOutputUsesInterrupts; |
---|
[ee3b242b] | 48 | } console_fns; |
---|
| 49 | |
---|
| 50 | typedef struct _console_flow { |
---|
[424e23ee] | 51 | int (*deviceStopRemoteTx)(int minor); |
---|
| 52 | int (*deviceStartRemoteTx)(int minor); |
---|
[ee3b242b] | 53 | } console_flow; |
---|
| 54 | |
---|
[c0573d7] | 55 | typedef enum { |
---|
| 56 | SERIAL_MC68681, /* Motorola MC68681 or Exar 88681 */ |
---|
| 57 | SERIAL_NS16550, /* National Semiconductor NS16550 */ |
---|
| 58 | SERIAL_Z85C30, /* Zilog Z85C30 */ |
---|
| 59 | SERIAL_CUSTOM /* BSP specific driver */ |
---|
| 60 | |
---|
| 61 | } console_devs; |
---|
| 62 | |
---|
[5ae415b] | 63 | /* |
---|
| 64 | * Each field is interpreted thus: |
---|
| 65 | * |
---|
| 66 | * sDeviceName This is the name of the device. |
---|
| 67 | * |
---|
[c0573d7] | 68 | * deviceType This indicates the chip type. It is especially important when |
---|
| 69 | * multiple devices share the same interrupt vector and must be |
---|
| 70 | * distinguished. |
---|
| 71 | * |
---|
[5ae415b] | 72 | * pDeviceFns This is a pointer to the set of driver routines to use. |
---|
| 73 | * |
---|
| 74 | * pDeviceFlow This is a pointer to the set of flow control routines to |
---|
| 75 | * use. Serial device drivers will typically supply RTSCTS |
---|
| 76 | * and DTRCTS handshake routines for DCE to DCE communication, |
---|
| 77 | * however for DCE to DTE communication, no such routines |
---|
| 78 | * should be necessary as RTS will be driven automatically |
---|
| 79 | * when the transmitter is active. |
---|
| 80 | * |
---|
| 81 | * ulMargin The high water mark in the input buffer is set to the buffer |
---|
| 82 | * size less ulMargin. Once this level is reached, the driver's |
---|
| 83 | * flow control routine used to stop the remote transmitter will |
---|
| 84 | * be called. This figure should be greater than or equal to |
---|
| 85 | * the number of stages of FIFO between the transmitter and |
---|
| 86 | * receiver. |
---|
| 87 | * |
---|
| 88 | * NOTE: At the current time, this parameter is hard coded |
---|
| 89 | * in termios and this number is ignored. |
---|
| 90 | * |
---|
| 91 | * ulHysteresis After the high water mark specified by ulMargin has been |
---|
| 92 | * reached, the driver's routine to re-start the remote |
---|
| 93 | * transmitter will be called once the level in the input |
---|
| 94 | * buffer has fallen by ulHysteresis bytes. |
---|
| 95 | * |
---|
| 96 | * NOTE: At the current time, this parameter is hard coded |
---|
| 97 | * in termios and this number is ignored. |
---|
| 98 | * |
---|
| 99 | * pDeviceParams This contains either device specific data or a pointer to a |
---|
| 100 | * device specific structure containing additional information |
---|
| 101 | * not provided in this table. |
---|
| 102 | * |
---|
| 103 | * ulCtrlPort1 This is the primary control port number for the device. This |
---|
| 104 | * may be used to specify different instances of the same device |
---|
| 105 | * type. |
---|
| 106 | * |
---|
| 107 | * ulCtrlPort2 This is the secondary control port number, of use when a given |
---|
| 108 | * device has more than one available channel. |
---|
| 109 | * |
---|
| 110 | * ulDataPort This is the port number for the data port of the device |
---|
| 111 | * |
---|
| 112 | * getRegister This is the routine used to read register values. |
---|
| 113 | * |
---|
| 114 | * setRegister This is the routine used to write register values. |
---|
| 115 | * |
---|
| 116 | * getData This is the routine used to read the data register (RX). |
---|
| 117 | * |
---|
| 118 | * setData This is the routine used to write the data register (TX). |
---|
| 119 | * |
---|
| 120 | * ulClock This is the baud rate clock speed. |
---|
| 121 | * |
---|
| 122 | * ulIntVector This encodes the interrupt vector of the device. |
---|
| 123 | */ |
---|
| 124 | |
---|
[ee3b242b] | 125 | typedef struct _console_tbl { |
---|
[58b1e95] | 126 | char *sDeviceName; |
---|
[c0573d7] | 127 | console_devs deviceType; |
---|
[58b1e95] | 128 | console_fns *pDeviceFns; |
---|
| 129 | boolean (*deviceProbe)(int minor); |
---|
[424e23ee] | 130 | console_flow *pDeviceFlow; |
---|
[58b1e95] | 131 | unsigned32 ulMargin; |
---|
| 132 | unsigned32 ulHysteresis; |
---|
| 133 | void *pDeviceParams; |
---|
| 134 | unsigned32 ulCtrlPort1; |
---|
| 135 | unsigned32 ulCtrlPort2; |
---|
| 136 | unsigned32 ulDataPort; |
---|
[36152b0e] | 137 | getRegister_f getRegister; |
---|
| 138 | setRegister_f setRegister; |
---|
| 139 | getData_f getData; |
---|
| 140 | setData_f setData; |
---|
[58b1e95] | 141 | unsigned32 ulClock; |
---|
| 142 | unsigned int ulIntVector; |
---|
[ee3b242b] | 143 | } console_tbl; |
---|
| 144 | |
---|
| 145 | typedef struct _console_data { |
---|
[58b1e95] | 146 | void *termios_data; |
---|
| 147 | volatile boolean bActive; |
---|
[c1da250] | 148 | volatile Ring_buffer_t TxBuffer; /* XXX remove usage from drivers */ |
---|
| 149 | /* XXX only the ns16550 uses this now */ |
---|
[424e23ee] | 150 | /* |
---|
| 151 | * This field may be used for any purpose required by the driver |
---|
| 152 | */ |
---|
[58b1e95] | 153 | void *pDeviceContext; |
---|
[ee3b242b] | 154 | } console_data; |
---|
| 155 | |
---|
[424e23ee] | 156 | extern console_tbl Console_Port_Tbl[]; |
---|
| 157 | extern console_data Console_Port_Data[]; |
---|
| 158 | extern unsigned long Console_Port_Count; |
---|
[ee3b242b] | 159 | |
---|
| 160 | #endif |
---|
| 161 | /* end of include file */ |
---|