hfc_usb.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * hfc_usb.h
  3. *
  4. * $Id: hfc_usb.h,v 4.2 2005/04/07 15:27:17 martinb1 Exp $
  5. */
  6. #ifndef __HFC_USB_H__
  7. #define __HFC_USB_H__
  8. #define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)"
  9. #define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver"
  10. #define VERBOSE_USB_DEBUG
  11. /***********/
  12. /* defines */
  13. /***********/
  14. #define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */
  15. #define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */
  16. #define HFC_TIMER_T4 500 /* time for state change interval */
  17. #define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */
  18. #define HFCUSB_L1_DRX 1 /* D-frame received */
  19. #define HFCUSB_L1_ERX 2 /* E-frame received */
  20. #define HFCUSB_L1_DTX 4 /* D-frames completed */
  21. #define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
  22. #define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
  23. #define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
  24. #define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
  25. #define HFCUSB_CIRM 0x00 /* cirm register index */
  26. #define HFCUSB_USB_SIZE 0x07 /* int length register */
  27. #define HFCUSB_USB_SIZE_I 0x06 /* iso length register */
  28. #define HFCUSB_F_CROSS 0x0b /* bit order register */
  29. #define HFCUSB_CLKDEL 0x37 /* bit delay register */
  30. #define HFCUSB_CON_HDLC 0xfa /* channel connect register */
  31. #define HFCUSB_HDLC_PAR 0xfb
  32. #define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */
  33. #define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */
  34. #define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */
  35. #define HFCUSB_F_THRES 0x0c /* threshold register */
  36. #define HFCUSB_FIFO 0x0f /* fifo select register */
  37. #define HFCUSB_F_USAGE 0x1a /* fifo usage register */
  38. #define HFCUSB_MST_MODE0 0x14
  39. #define HFCUSB_MST_MODE1 0x15
  40. #define HFCUSB_P_DATA 0x1f
  41. #define HFCUSB_INC_RES_F 0x0e
  42. #define HFCUSB_STATES 0x30
  43. #define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
  44. /******************/
  45. /* fifo registers */
  46. /******************/
  47. #define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
  48. #define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
  49. #define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
  50. #define HFCUSB_B2_TX 2
  51. #define HFCUSB_B2_RX 3
  52. #define HFCUSB_D_TX 4
  53. #define HFCUSB_D_RX 5
  54. #define HFCUSB_PCM_TX 6
  55. #define HFCUSB_PCM_RX 7
  56. /*
  57. * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just
  58. * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out
  59. */
  60. #define USB_INT 0
  61. #define USB_BULK 1
  62. #define USB_ISOC 2
  63. #define ISOC_PACKETS_D 8
  64. #define ISOC_PACKETS_B 8
  65. #define ISO_BUFFER_SIZE 128
  66. // ISO send definitions
  67. #define SINK_MAX 68
  68. #define SINK_MIN 48
  69. #define SINK_DMIN 12
  70. #define SINK_DMAX 18
  71. #define BITLINE_INF (-64*8)
  72. /**********/
  73. /* macros */
  74. /**********/
  75. #define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT)
  76. #define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT)
  77. /*******************/
  78. /* Debugging Flags */
  79. /*******************/
  80. #define USB_DBG 1
  81. #define ISDN_DBG 2
  82. /* *********************/
  83. /* USB related defines */
  84. /***********************/
  85. #define HFC_CTRL_BUFSIZE 32
  86. /*************************************************/
  87. /* entry and size of output/input control buffer */
  88. /*************************************************/
  89. typedef struct {
  90. __u8 hfc_reg; /* register number */
  91. __u8 reg_val; /* value to be written (or read) */
  92. int action; /* data for action handler */
  93. } ctrl_buft;
  94. /********************/
  95. /* URB error codes: */
  96. /********************/
  97. /* Used to represent a list of values and their respective symbolic names */
  98. struct hfcusb_symbolic_list {
  99. const int num;
  100. const char *name;
  101. };
  102. static struct hfcusb_symbolic_list urb_errlist[] = {
  103. {-ENOMEM, "No memory for allocation of internal structures"},
  104. {-ENOSPC, "The host controller's bandwidth is already consumed"},
  105. {-ENOENT, "URB was canceled by unlink_urb"},
  106. {-EXDEV, "ISO transfer only partially completed"},
  107. {-EAGAIN, "Too match scheduled for the future"},
  108. {-ENXIO, "URB already queued"},
  109. {-EFBIG, "Too much ISO frames requested"},
  110. {-ENOSR, "Buffer error (overrun)"},
  111. {-EPIPE, "Specified endpoint is stalled"},
  112. {-EOVERFLOW, "Babble (bad cable?)"},
  113. {-EPROTO, "Bit-stuff error (bad cable?)"},
  114. {-EILSEQ, "CRC or missing token"},
  115. {-ETIME, "Device did not respond"},
  116. {-ESHUTDOWN, "Device unplugged"},
  117. {-1, NULL}
  118. };
  119. /*****************************************************/
  120. /* device dependant information to support different */
  121. /* ISDN Ta's using the HFC-S USB chip */
  122. /*****************************************************/
  123. /* USB descriptor need to contain one of the following EndPoint combination: */
  124. #define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT
  125. #define CNF_3INT3ISO 2 // 3 INT IN, 3 ISO OUT
  126. #define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT
  127. #define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT
  128. #define EP_NUL 1 // Endpoint at this position not allowed
  129. #define EP_NOP 2 // all type of endpoints allowed at this position
  130. #define EP_ISO 3 // Isochron endpoint mandatory at this position
  131. #define EP_BLK 4 // Bulk endpoint mandatory at this position
  132. #define EP_INT 5 // Interrupt endpoint mandatory at this position
  133. /* this array represents all endpoints possible in the HCF-USB the last
  134. * 3 entries are the configuration number, the minimum interval for
  135. * Interrupt endpoints & boolean if E-channel logging possible
  136. */
  137. static int validconf[][19] = {
  138. // INT in, ISO out config
  139. {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
  140. EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
  141. CNF_4INT3ISO, 2, 1},
  142. {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL,
  143. EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
  144. CNF_3INT3ISO, 2, 0},
  145. // ISO in, ISO out config
  146. {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
  147. EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO,
  148. CNF_4ISO3ISO, 2, 1},
  149. {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
  150. EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL,
  151. CNF_3ISO3ISO, 2, 0},
  152. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // EOL element
  153. };
  154. #ifdef CONFIG_HISAX_DEBUG
  155. // string description of chosen config
  156. static char *conf_str[] = {
  157. "4 Interrupt IN + 3 Isochron OUT",
  158. "3 Interrupt IN + 3 Isochron OUT",
  159. "4 Isochron IN + 3 Isochron OUT",
  160. "3 Isochron IN + 3 Isochron OUT"
  161. };
  162. #endif
  163. typedef struct {
  164. int vendor; // vendor id
  165. int prod_id; // product id
  166. char *vend_name; // vendor string
  167. __u8 led_scheme; // led display scheme
  168. signed short led_bits[8]; // array of 8 possible LED bitmask settings
  169. } vendor_data;
  170. #define LED_OFF 0 // no LED support
  171. #define LED_SCHEME1 1 // LED standard scheme
  172. #define LED_SCHEME2 2 // not used yet...
  173. #define LED_POWER_ON 1
  174. #define LED_POWER_OFF 2
  175. #define LED_S0_ON 3
  176. #define LED_S0_OFF 4
  177. #define LED_B1_ON 5
  178. #define LED_B1_OFF 6
  179. #define LED_B1_DATA 7
  180. #define LED_B2_ON 8
  181. #define LED_B2_OFF 9
  182. #define LED_B2_DATA 10
  183. #define LED_NORMAL 0 // LEDs are normal
  184. #define LED_INVERTED 1 // LEDs are inverted
  185. /* time in ms to perform a Flashing LED when B-Channel has traffic */
  186. #define LED_TIME 250
  187. #endif // __HFC_USB_H__