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