blob: f987bf89da1a7c52cc44f33cc3cb5944fa8f04d5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Martin Bachemd6c59c12007-08-21 14:26:21 +02002 * hfc_usb.h
3 *
4 * $Id: hfc_usb.h,v 1.1.2.5 2007/08/20 14:36:03 mbachem Exp $
5 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7#ifndef __HFC_USB_H__
8#define __HFC_USB_H__
9
10#define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)"
11#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver"
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Martin Bachemd6c59c12007-08-21 14:26:21 +020014#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Martin Bachemd6c59c12007-08-21 14:26:21 +020018#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */
19#define HFCUSB_L1_DRX 1 /* D-frame received */
20#define HFCUSB_L1_ERX 2 /* E-frame received */
21#define HFCUSB_L1_DTX 4 /* D-frames completed */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Martin Bachemd6c59c12007-08-21 14:26:21 +020023#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Martin Bachemd6c59c12007-08-21 14:26:21 +020025#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
26#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
29#define HFCUSB_CIRM 0x00 /* cirm register index */
30#define HFCUSB_USB_SIZE 0x07 /* int length register */
31#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */
32#define HFCUSB_F_CROSS 0x0b /* bit order register */
33#define HFCUSB_CLKDEL 0x37 /* bit delay register */
34#define HFCUSB_CON_HDLC 0xfa /* channel connect register */
35#define HFCUSB_HDLC_PAR 0xfb
36#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */
37#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */
38#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */
39#define HFCUSB_F_THRES 0x0c /* threshold register */
40#define HFCUSB_FIFO 0x0f /* fifo select register */
41#define HFCUSB_F_USAGE 0x1a /* fifo usage register */
42#define HFCUSB_MST_MODE0 0x14
43#define HFCUSB_MST_MODE1 0x15
44#define HFCUSB_P_DATA 0x1f
45#define HFCUSB_INC_RES_F 0x0e
46#define HFCUSB_STATES 0x30
47
48#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
49
Martin Bachemd6c59c12007-08-21 14:26:21 +020050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051/* fifo registers */
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
53#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
54#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
55#define HFCUSB_B2_TX 2
56#define HFCUSB_B2_RX 3
57#define HFCUSB_D_TX 4
58#define HFCUSB_D_RX 5
59#define HFCUSB_PCM_TX 6
60#define HFCUSB_PCM_RX 7
61
62/*
Martin Bachemd6c59c12007-08-21 14:26:21 +020063 * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just
64 * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out
65 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#define USB_INT 0
67#define USB_BULK 1
68#define USB_ISOC 2
69
70#define ISOC_PACKETS_D 8
71#define ISOC_PACKETS_B 8
72#define ISO_BUFFER_SIZE 128
73
Martin Bachemd6c59c12007-08-21 14:26:21 +020074/* Fifo flow Control for TX ISO */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define SINK_MAX 68
76#define SINK_MIN 48
77#define SINK_DMIN 12
78#define SINK_DMAX 18
Joe Perches475be4d2012-02-19 19:52:38 -080079#define BITLINE_INF (-64 * 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Martin Bachemd6c59c12007-08-21 14:26:21 +020081/* HFC-S USB register access by Control-URSs */
Joe Perches475be4d2012-02-19 19:52:38 -080082#define write_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), NULL, 0, HFC_CTRL_TIMEOUT)
83#define read_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), 1, HFC_CTRL_TIMEOUT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#define HFC_CTRL_BUFSIZE 32
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086/* entry and size of output/input control buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087typedef struct {
88 __u8 hfc_reg; /* register number */
89 __u8 reg_val; /* value to be written (or read) */
90 int action; /* data for action handler */
91} ctrl_buft;
92
Martin Bachemd6c59c12007-08-21 14:26:21 +020093/* Debugging Flags */
94#define HFCUSB_DBG_INIT 0x0001
95#define HFCUSB_DBG_STATES 0x0002
96#define HFCUSB_DBG_DCHANNEL 0x0080
97#define HFCUSB_DBG_FIFO_ERR 0x4000
98#define HFCUSB_DBG_VERBOSE_USB 0x8000
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Martin Bachemd6c59c12007-08-21 14:26:21 +0200100/*
101 * URB error codes:
102 * Used to represent a list of values and their respective symbolic names
103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104struct hfcusb_symbolic_list {
105 const int num;
106 const char *name;
107};
108
109static struct hfcusb_symbolic_list urb_errlist[] = {
110 {-ENOMEM, "No memory for allocation of internal structures"},
111 {-ENOSPC, "The host controller's bandwidth is already consumed"},
112 {-ENOENT, "URB was canceled by unlink_urb"},
113 {-EXDEV, "ISO transfer only partially completed"},
114 {-EAGAIN, "Too match scheduled for the future"},
115 {-ENXIO, "URB already queued"},
116 {-EFBIG, "Too much ISO frames requested"},
117 {-ENOSR, "Buffer error (overrun)"},
Martin Bachemd6c59c12007-08-21 14:26:21 +0200118 {-EPIPE, "Specified endpoint is stalled (device not responding)"},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 {-EOVERFLOW, "Babble (bad cable?)"},
120 {-EPROTO, "Bit-stuff error (bad cable?)"},
Martin Bachemd6c59c12007-08-21 14:26:21 +0200121 {-EILSEQ, "CRC/Timeout"},
122 {-ETIMEDOUT, "NAK (device does not respond)"},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 {-ESHUTDOWN, "Device unplugged"},
124 {-1, NULL}
125};
126
127
Martin Bachemd6c59c12007-08-21 14:26:21 +0200128/*
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300129 * device dependent information to support different
Martin Bachemd6c59c12007-08-21 14:26:21 +0200130 * ISDN Ta's using the HFC-S USB chip
131 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133/* USB descriptor need to contain one of the following EndPoint combination: */
134#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT
135#define CNF_3INT3ISO 2 // 3 INT IN, 3 ISO OUT
136#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT
137#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT
138
Martin Bachemd6c59c12007-08-21 14:26:21 +0200139#define EP_NUL 1 // Endpoint at this position not allowed
140#define EP_NOP 2 // all type of endpoints allowed at this position
141#define EP_ISO 3 // Isochron endpoint mandatory at this position
142#define EP_BLK 4 // Bulk endpoint mandatory at this position
143#define EP_INT 5 // Interrupt endpoint mandatory at this position
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Martin Bachemd6c59c12007-08-21 14:26:21 +0200145/*
146 * List of all supported endpoint configuration sets, used to find the
147 * best matching endpoint configuration within a devices' USB descriptor.
148 * We need at least 3 RX endpoints, and 3 TX endpoints, either
149 * INT-in and ISO-out, or ISO-in and ISO-out)
150 * with 4 RX endpoints even E-Channel logging is possible
151 */
Adrian Bunk672c3fd2005-06-25 14:59:18 -0700152static int validconf[][19] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 // INT in, ISO out config
154 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
155 EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
156 CNF_4INT3ISO, 2, 1},
157 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL,
158 EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
159 CNF_3INT3ISO, 2, 0},
160 // ISO in, ISO out config
161 {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
162 EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO,
163 CNF_4ISO3ISO, 2, 1},
164 {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
165 EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL,
166 CNF_3ISO3ISO, 2, 0},
167 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} // EOL element
168};
169
Martin Bachem597a1072005-11-07 01:00:20 -0800170#ifdef CONFIG_HISAX_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171// string description of chosen config
Adrian Bunk672c3fd2005-06-25 14:59:18 -0700172static char *conf_str[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 "4 Interrupt IN + 3 Isochron OUT",
174 "3 Interrupt IN + 3 Isochron OUT",
175 "4 Isochron IN + 3 Isochron OUT",
176 "3 Isochron IN + 3 Isochron OUT"
177};
Martin Bachem597a1072005-11-07 01:00:20 -0800178#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180typedef struct {
181 int vendor; // vendor id
182 int prod_id; // product id
183 char *vend_name; // vendor string
184 __u8 led_scheme; // led display scheme
185 signed short led_bits[8]; // array of 8 possible LED bitmask settings
186} vendor_data;
187
Martin Bachemd6c59c12007-08-21 14:26:21 +0200188#define LED_OFF 0 // no LED support
189#define LED_SCHEME1 1 // LED standard scheme
190#define LED_SCHEME2 2 // not used yet...
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192#define LED_POWER_ON 1
193#define LED_POWER_OFF 2
194#define LED_S0_ON 3
195#define LED_S0_OFF 4
196#define LED_B1_ON 5
197#define LED_B1_OFF 6
198#define LED_B1_DATA 7
199#define LED_B2_ON 8
200#define LED_B2_OFF 9
201#define LED_B2_DATA 10
202
Joe Perches475be4d2012-02-19 19:52:38 -0800203#define LED_NORMAL 0 // LEDs are normal
204#define LED_INVERTED 1 // LEDs are inverted
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206
Martin Bachemd6c59c12007-08-21 14:26:21 +0200207#endif // __HFC_USB_H__