hfc_usb.h 7.1 KB

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