scc.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* $Id: scc.h,v 1.29 1997/04/02 14:56:45 jreuter Exp jreuter $ */
  2. #ifndef _SCC_H
  3. #define _SCC_H
  4. #include <linux/config.h>
  5. /* selection of hardware types */
  6. #define PA0HZP 0x00 /* hardware type for PA0HZP SCC card and compatible */
  7. #define EAGLE 0x01 /* hardware type for EAGLE card */
  8. #define PC100 0x02 /* hardware type for PC100 card */
  9. #define PRIMUS 0x04 /* hardware type for PRIMUS-PC (DG9BL) card */
  10. #define DRSI 0x08 /* hardware type for DRSI PC*Packet card */
  11. #define BAYCOM 0x10 /* hardware type for BayCom (U)SCC */
  12. /* DEV ioctl() commands */
  13. enum SCC_ioctl_cmds {
  14. SIOCSCCRESERVED = SIOCDEVPRIVATE,
  15. SIOCSCCCFG,
  16. SIOCSCCINI,
  17. SIOCSCCCHANINI,
  18. SIOCSCCSMEM,
  19. SIOCSCCGKISS,
  20. SIOCSCCSKISS,
  21. SIOCSCCGSTAT,
  22. SIOCSCCCAL
  23. };
  24. /* Device parameter control (from WAMPES) */
  25. enum L1_params {
  26. PARAM_DATA,
  27. PARAM_TXDELAY,
  28. PARAM_PERSIST,
  29. PARAM_SLOTTIME,
  30. PARAM_TXTAIL,
  31. PARAM_FULLDUP,
  32. PARAM_SOFTDCD, /* was: PARAM_HW */
  33. PARAM_MUTE, /* ??? */
  34. PARAM_DTR,
  35. PARAM_RTS,
  36. PARAM_SPEED,
  37. PARAM_ENDDELAY, /* ??? */
  38. PARAM_GROUP,
  39. PARAM_IDLE,
  40. PARAM_MIN,
  41. PARAM_MAXKEY,
  42. PARAM_WAIT,
  43. PARAM_MAXDEFER,
  44. PARAM_TX,
  45. PARAM_HWEVENT = 31,
  46. PARAM_RETURN = 255 /* reset kiss mode */
  47. };
  48. /* fulldup parameter */
  49. enum FULLDUP_modes {
  50. KISS_DUPLEX_HALF, /* normal CSMA operation */
  51. KISS_DUPLEX_FULL, /* fullduplex, key down trx after transmission */
  52. KISS_DUPLEX_LINK, /* fullduplex, key down trx after 'idletime' sec */
  53. KISS_DUPLEX_OPTIMA /* fullduplex, let the protocol layer control the hw */
  54. };
  55. /* misc. parameters */
  56. #define TIMER_OFF 65535U /* to switch off timers */
  57. #define NO_SUCH_PARAM 65534U /* param not implemented */
  58. /* HWEVENT parameter */
  59. enum HWEVENT_opts {
  60. HWEV_DCD_ON,
  61. HWEV_DCD_OFF,
  62. HWEV_ALL_SENT
  63. };
  64. /* channel grouping */
  65. #define RXGROUP 0100 /* if set, only tx when all channels clear */
  66. #define TXGROUP 0200 /* if set, don't transmit simultaneously */
  67. /* Tx/Rx clock sources */
  68. enum CLOCK_sources {
  69. CLK_DPLL, /* normal halfduplex operation */
  70. CLK_EXTERNAL, /* external clocking (G3RUH/DF9IC modems) */
  71. CLK_DIVIDER, /* Rx = DPLL, Tx = divider (fullduplex with */
  72. /* modems without clock regeneration */
  73. CLK_BRG /* experimental fullduplex mode with DPLL/BRG for */
  74. /* MODEMs without clock recovery */
  75. };
  76. /* Tx state */
  77. enum TX_state {
  78. TXS_IDLE, /* Transmitter off, no data pending */
  79. TXS_BUSY, /* waiting for permission to send / tailtime */
  80. TXS_ACTIVE, /* Transmitter on, sending data */
  81. TXS_NEWFRAME, /* reset CRC and send (next) frame */
  82. TXS_IDLE2, /* Transmitter on, no data pending */
  83. TXS_WAIT, /* Waiting for Mintime to expire */
  84. TXS_TIMEOUT /* We had a transmission timeout */
  85. };
  86. typedef unsigned long io_port; /* type definition for an 'io port address' */
  87. /* SCC statistical information */
  88. struct scc_stat {
  89. long rxints; /* Receiver interrupts */
  90. long txints; /* Transmitter interrupts */
  91. long exints; /* External/status interrupts */
  92. long spints; /* Special receiver interrupts */
  93. long txframes; /* Packets sent */
  94. long rxframes; /* Number of Frames Actually Received */
  95. long rxerrs; /* CRC Errors */
  96. long txerrs; /* KISS errors */
  97. unsigned int nospace; /* "Out of buffers" */
  98. unsigned int rx_over; /* Receiver Overruns */
  99. unsigned int tx_under; /* Transmitter Underruns */
  100. unsigned int tx_state; /* Transmitter state */
  101. int tx_queued; /* tx frames enqueued */
  102. unsigned int maxqueue; /* allocated tx_buffers */
  103. unsigned int bufsize; /* used buffersize */
  104. };
  105. struct scc_modem {
  106. long speed; /* Line speed, bps */
  107. char clocksrc; /* 0 = DPLL, 1 = external, 2 = divider */
  108. char nrz; /* NRZ instead of NRZI */
  109. };
  110. struct scc_kiss_cmd {
  111. int command; /* one of the KISS-Commands defined above */
  112. unsigned param; /* KISS-Param */
  113. };
  114. struct scc_hw_config {
  115. io_port data_a; /* data port channel A */
  116. io_port ctrl_a; /* control port channel A */
  117. io_port data_b; /* data port channel B */
  118. io_port ctrl_b; /* control port channel B */
  119. io_port vector_latch; /* INTACK-Latch (#) */
  120. io_port special; /* special function port */
  121. int irq; /* irq */
  122. long clock; /* clock */
  123. char option; /* command for function port */
  124. char brand; /* hardware type */
  125. char escc; /* use ext. features of a 8580/85180/85280 */
  126. };
  127. /* (#) only one INTACK latch allowed. */
  128. struct scc_mem_config {
  129. unsigned int dummy;
  130. unsigned int bufsize;
  131. };
  132. struct scc_calibrate {
  133. unsigned int time;
  134. unsigned char pattern;
  135. };
  136. #ifdef __KERNEL__
  137. enum {TX_OFF, TX_ON}; /* command for scc_key_trx() */
  138. /* Vector masks in RR2B */
  139. #define VECTOR_MASK 0x06
  140. #define TXINT 0x00
  141. #define EXINT 0x02
  142. #define RXINT 0x04
  143. #define SPINT 0x06
  144. #ifdef CONFIG_SCC_DELAY
  145. #define Inb(port) inb_p(port)
  146. #define Outb(port, val) outb_p(val, port)
  147. #else
  148. #define Inb(port) inb(port)
  149. #define Outb(port, val) outb(val, port)
  150. #endif
  151. /* SCC channel control structure for KISS */
  152. struct scc_kiss {
  153. unsigned char txdelay; /* Transmit Delay 10 ms/cnt */
  154. unsigned char persist; /* Persistence (0-255) as a % */
  155. unsigned char slottime; /* Delay to wait on persistence hit */
  156. unsigned char tailtime; /* Delay after last byte written */
  157. unsigned char fulldup; /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
  158. unsigned char waittime; /* Waittime before any transmit attempt */
  159. unsigned int maxkeyup; /* Maximum time to transmit (seconds) */
  160. unsigned int mintime; /* Minimal offtime after MAXKEYUP timeout (seconds) */
  161. unsigned int idletime; /* Maximum idle time in ALWAYS KEYED mode (seconds) */
  162. unsigned int maxdefer; /* Timer for CSMA channel busy limit */
  163. unsigned char tx_inhibit; /* Transmit is not allowed when set */
  164. unsigned char group; /* Group ID for AX.25 TX interlocking */
  165. unsigned char mode; /* 'normal' or 'hwctrl' mode (unused) */
  166. unsigned char softdcd; /* Use DPLL instead of DCD pin for carrier detect */
  167. };
  168. /* SCC channel structure */
  169. struct scc_channel {
  170. int init; /* channel exists? */
  171. struct net_device *dev; /* link to device control structure */
  172. struct net_device_stats dev_stat;/* device statistics */
  173. char brand; /* manufacturer of the board */
  174. long clock; /* used clock */
  175. io_port ctrl; /* I/O address of CONTROL register */
  176. io_port data; /* I/O address of DATA register */
  177. io_port special; /* I/O address of special function port */
  178. int irq; /* Number of Interrupt */
  179. char option;
  180. char enhanced; /* Enhanced SCC support */
  181. unsigned char wreg[16]; /* Copy of last written value in WRx */
  182. unsigned char status; /* Copy of R0 at last external interrupt */
  183. unsigned char dcd; /* DCD status */
  184. struct scc_kiss kiss; /* control structure for KISS params */
  185. struct scc_stat stat; /* statistical information */
  186. struct scc_modem modem; /* modem information */
  187. struct sk_buff_head tx_queue; /* next tx buffer */
  188. struct sk_buff *rx_buff; /* pointer to frame currently received */
  189. struct sk_buff *tx_buff; /* pointer to frame currently transmitted */
  190. /* Timer */
  191. struct timer_list tx_t; /* tx timer for this channel */
  192. struct timer_list tx_wdog; /* tx watchdogs */
  193. /* Channel lock */
  194. spinlock_t lock; /* Channel guard lock */
  195. };
  196. #endif /* defined(__KERNEL__) */
  197. #endif /* defined(_SCC_H) */