hfc_usb.h 6.8 KB

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