ser_a2232.h 7.4 KB

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