1 /* drivers/char/ser_a2232.h */ 2 3 /* $Id: ser_a2232.h,v 0.4 2000/01/25 12:00:00 ehaase Exp $ */ 4 5 /* Linux serial driver for the Amiga A2232 board */ 6 7 /* This driver is MAINTAINED. Before applying any changes, please contact 8 * the author. 9 */ 10 11 /* Copyright (c) 2000-2001 Enver Haase <ehaase@inf.fu-berlin.de> 12 * alias The A2232 driver project <A2232@gmx.net> 13 * All rights reserved. 14 * 15 * This program is free software; you can redistribute it and/or modify 16 * it under the terms of the GNU General Public License as published by 17 * the Free Software Foundation; either version 2 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * You should have received a copy of the GNU General Public License 26 * along with this program; if not, write to the Free Software 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 29 */ 30 31 #ifndef _SER_A2232_H_ 32 #define _SER_A2232_H_ 33 34 /* 35 How many boards are to be supported at maximum; 36 "up to five A2232 Multiport Serial Cards may be installed in a 37 single Amiga 2000" states the A2232 User's Guide. If you have 38 more slots available, you might want to change the value below. 39 */ 40 #define MAX_A2232_BOARDS 5 41 42 #ifndef A2232_NORMAL_MAJOR 43 /* This allows overriding on the compiler commandline, or in a "major.h" 44 include or something like that */ 45 #define A2232_NORMAL_MAJOR 224 /* /dev/ttyY* */ 46 #define A2232_CALLOUT_MAJOR 225 /* /dev/cuy* */ 47 #endif 48 49 /* Some magic is always good - Who knows :) */ 50 #define A2232_MAGIC 0x000a2232 51 52 /* for the tty_struct subtype field */ 53 #define A2232_TTY_SUBTYPE_NORMAL 1 54 #define A2232_TTY_SUBTYPE_CALLOUT 2 55 56 /* A2232 port structure to keep track of the 57 status of every single line used */ 58 struct a2232_port{ 59 struct gs_port gs; 60 unsigned int which_a2232; 61 unsigned int which_port_on_a2232; 62 short disable_rx; 63 short throttle_input; 64 short cd_status; 65 }; 66 67 #define NUMLINES 7 /* number of lines per board */ 68 #define A2232_IOBUFLEN 256 /* number of bytes per buffer */ 69 #define A2232_IOBUFLENMASK 0xff /* mask for maximum number of bytes */ 70 71 72 #define A2232_UNKNOWN 0 /* crystal not known */ 73 #define A2232_NORMAL 1 /* normal A2232 (1.8432 MHz oscillator) */ 74 #define A2232_TURBO 2 /* turbo A2232 (3.6864 MHz oscillator) */ 75 76 77 struct a2232common { 78 char Crystal; /* normal (1) or turbo (2) board? */ 79 u_char Pad_a; 80 u_char TimerH; /* timer value after speed check */ 81 u_char TimerL; 82 u_char CDHead; /* head pointer for CD message queue */ 83 u_char CDTail; /* tail pointer for CD message queue */ 84 u_char CDStatus; 85 u_char Pad_b; 86 }; 87 88 struct a2232status { 89 u_char InHead; /* input queue head */ 90 u_char InTail; /* input queue tail */ 91 u_char OutDisable; /* disables output */ 92 u_char OutHead; /* output queue head */ 93 u_char OutTail; /* output queue tail */ 94 u_char OutCtrl; /* soft flow control character to send */ 95 u_char OutFlush; /* flushes output buffer */ 96 u_char Setup; /* causes reconfiguration */ 97 u_char Param; /* parameter byte - see A2232PARAM */ 98 u_char Command; /* command byte - see A2232CMD */ 99 u_char SoftFlow; /* enables xon/xoff flow control */ 100 /* private 65EC02 fields: */ 101 u_char XonOff; /* stores XON/XOFF enable/disable */ 102 }; 103 104 #define A2232_MEMPAD1 \ 105 (0x0200 - NUMLINES * sizeof(struct a2232status) - \ 106 sizeof(struct a2232common)) 107 #define A2232_MEMPAD2 (0x2000 - NUMLINES * A2232_IOBUFLEN - A2232_IOBUFLEN) 108 109 struct a2232memory { 110 struct a2232status Status[NUMLINES]; /* 0x0000-0x006f status areas */ 111 struct a2232common Common; /* 0x0070-0x0077 common flags */ 112 u_char Dummy1[A2232_MEMPAD1]; /* 0x00XX-0x01ff */ 113 u_char OutBuf[NUMLINES][A2232_IOBUFLEN];/* 0x0200-0x08ff output bufs */ 114 u_char InBuf[NUMLINES][A2232_IOBUFLEN]; /* 0x0900-0x0fff input bufs */ 115 u_char InCtl[NUMLINES][A2232_IOBUFLEN]; /* 0x1000-0x16ff control data */ 116 u_char CDBuf[A2232_IOBUFLEN]; /* 0x1700-0x17ff CD event buffer */ 117 u_char Dummy2[A2232_MEMPAD2]; /* 0x1800-0x2fff */ 118 u_char Code[0x1000]; /* 0x3000-0x3fff code area */ 119 u_short InterruptAck; /* 0x4000 intr ack */ 120 u_char Dummy3[0x3ffe]; /* 0x4002-0x7fff */ 121 u_short Enable6502Reset; /* 0x8000 Stop board, */ 122 /* 6502 RESET line held low */ 123 u_char Dummy4[0x3ffe]; /* 0x8002-0xbfff */ 124 u_short ResetBoard; /* 0xc000 reset board & run, */ 125 /* 6502 RESET line held high */ 126 }; 127 128 #undef A2232_MEMPAD1 129 #undef A2232_MEMPAD2 130 131 #define A2232INCTL_CHAR 0 /* corresponding byte in InBuf is a character */ 132 #define A2232INCTL_EVENT 1 /* corresponding byte in InBuf is an event */ 133 134 #define A2232EVENT_Break 1 /* break set */ 135 #define A2232EVENT_CarrierOn 2 /* carrier raised */ 136 #define A2232EVENT_CarrierOff 3 /* carrier dropped */ 137 #define A2232EVENT_Sync 4 /* don't know, defined in 2232.ax */ 138 139 #define A2232CMD_Enable 0x1 /* enable/DTR bit */ 140 #define A2232CMD_Close 0x2 /* close the device */ 141 #define A2232CMD_Open 0xb /* open the device */ 142 #define A2232CMD_CMask 0xf /* command mask */ 143 #define A2232CMD_RTSOff 0x0 /* turn off RTS */ 144 #define A2232CMD_RTSOn 0x8 /* turn on RTS */ 145 #define A2232CMD_Break 0xd /* transmit a break */ 146 #define A2232CMD_RTSMask 0xc /* mask for RTS stuff */ 147 #define A2232CMD_NoParity 0x00 /* don't use parity */ 148 #define A2232CMD_OddParity 0x20 /* odd parity */ 149 #define A2232CMD_EvenParity 0x60 /* even parity */ 150 #define A2232CMD_ParityMask 0xe0 /* parity mask */ 151 152 #define A2232PARAM_B115200 0x0 /* baud rates */ 153 #define A2232PARAM_B50 0x1 154 #define A2232PARAM_B75 0x2 155 #define A2232PARAM_B110 0x3 156 #define A2232PARAM_B134 0x4 157 #define A2232PARAM_B150 0x5 158 #define A2232PARAM_B300 0x6 159 #define A2232PARAM_B600 0x7 160 #define A2232PARAM_B1200 0x8 161 #define A2232PARAM_B1800 0x9 162 #define A2232PARAM_B2400 0xa 163 #define A2232PARAM_B3600 0xb 164 #define A2232PARAM_B4800 0xc 165 #define A2232PARAM_B7200 0xd 166 #define A2232PARAM_B9600 0xe 167 #define A2232PARAM_B19200 0xf 168 #define A2232PARAM_BaudMask 0xf /* baud rate mask */ 169 #define A2232PARAM_RcvBaud 0x10 /* enable receive baud rate */ 170 #define A2232PARAM_8Bit 0x00 /* numbers of bits */ 171 #define A2232PARAM_7Bit 0x20 172 #define A2232PARAM_6Bit 0x40 173 #define A2232PARAM_5Bit 0x60 174 #define A2232PARAM_BitMask 0x60 /* numbers of bits mask */ 175 176 177 /* Standard speeds tables, -1 means unavailable, -2 means 0 baud: switch off line */ 178 #define A2232_BAUD_TABLE_NOAVAIL -1 179 #define A2232_BAUD_TABLE_NUM_RATES (18) 180 static int a2232_baud_table[A2232_BAUD_TABLE_NUM_RATES*3] = { 181 //Baud //Normal //Turbo 182 50, A2232PARAM_B50, A2232_BAUD_TABLE_NOAVAIL, 183 75, A2232PARAM_B75, A2232_BAUD_TABLE_NOAVAIL, 184 110, A2232PARAM_B110, A2232_BAUD_TABLE_NOAVAIL, 185 134, A2232PARAM_B134, A2232_BAUD_TABLE_NOAVAIL, 186 150, A2232PARAM_B150, A2232PARAM_B75, 187 200, A2232_BAUD_TABLE_NOAVAIL, A2232_BAUD_TABLE_NOAVAIL, 188 300, A2232PARAM_B300, A2232PARAM_B150, 189 600, A2232PARAM_B600, A2232PARAM_B300, 190 1200, A2232PARAM_B1200, A2232PARAM_B600, 191 1800, A2232PARAM_B1800, A2232_BAUD_TABLE_NOAVAIL, 192 2400, A2232PARAM_B2400, A2232PARAM_B1200, 193 4800, A2232PARAM_B4800, A2232PARAM_B2400, 194 9600, A2232PARAM_B9600, A2232PARAM_B4800, 195 19200, A2232PARAM_B19200, A2232PARAM_B9600, 196 38400, A2232_BAUD_TABLE_NOAVAIL, A2232PARAM_B19200, 197 57600, A2232_BAUD_TABLE_NOAVAIL, A2232_BAUD_TABLE_NOAVAIL, 198 #ifdef A2232_SPEEDHACK 199 115200, A2232PARAM_B115200, A2232_BAUD_TABLE_NOAVAIL, 200 230400, A2232_BAUD_TABLE_NOAVAIL, A2232PARAM_B115200 201 #else 202 115200, A2232_BAUD_TABLE_NOAVAIL, A2232_BAUD_TABLE_NOAVAIL, 203 230400, A2232_BAUD_TABLE_NOAVAIL, A2232_BAUD_TABLE_NOAVAIL 204 #endif 205 }; 206 #endif 207