hfc_usb.h 6.8 KB

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