1 /*-------------------------------------------------------------------------*/
2 /* list of all controllers using this driver
5 static LIST_HEAD (hci_hcd_list);
7 /* URB states (urb_state) */
8 /* isoc, interrupt single state */
10 /* bulk transfer main state and 0-length packet */
13 /* three setup states */
14 #define US_CTRL_SETUP 2
15 #define US_CTRL_DATA 1
18 /*-------------------------------------------------------------------------*/
19 /* HC private part of a device descriptor
25 struct urb *pipe_head;
26 struct list_head urb_queue;
28 struct timer_list timeout;
29 int last_iso; /* timestamp of last queued ISOC transfer */
37 /*-------------------------------------------------------------------------*/
41 #define usb_to_hci(usb) ((struct hci_device *)(usb)->hcpriv)
43 struct virt_root_hub {
44 int devnum; /* Address of Root Hub endpoint */
45 void *urb; /* interrupt URB of root hub */
46 int send; /* active flag */
47 int interval; /* interval of roothub interrupt transfers */
48 struct timer_list rh_int_timer; /* interval timer for rh interrupt EP */
52 /* USB HUB CONSTANTS (not OHCI-specific; see hub.h and USB spec) */
54 /* destination of request */
55 #define RH_INTERFACE 0x01
56 #define RH_ENDPOINT 0x02
60 #define RH_VENDOR 0x40
62 /* Requests: bRequest << 8 | bmRequestType */
63 #define RH_GET_STATUS 0x0080
64 #define RH_CLEAR_FEATURE 0x0100
65 #define RH_SET_FEATURE 0x0300
66 #define RH_SET_ADDRESS 0x0500
67 #define RH_GET_DESCRIPTOR 0x0680
68 #define RH_SET_DESCRIPTOR 0x0700
69 #define RH_GET_CONFIGURATION 0x0880
70 #define RH_SET_CONFIGURATION 0x0900
71 #define RH_GET_STATE 0x0280
72 #define RH_GET_INTERFACE 0x0A80
73 #define RH_SET_INTERFACE 0x0B00
74 #define RH_SYNC_FRAME 0x0C80
75 /* Our Vendor Specific Request */
76 #define RH_SET_EP 0x2000
78 /* Hub port features */
79 #define RH_PORT_CONNECTION 0x00
80 #define RH_PORT_ENABLE 0x01
81 #define RH_PORT_SUSPEND 0x02
82 #define RH_PORT_OVER_CURRENT 0x03
83 #define RH_PORT_RESET 0x04
84 #define RH_PORT_POWER 0x08
85 #define RH_PORT_LOW_SPEED 0x09
87 #define RH_C_PORT_CONNECTION 0x10
88 #define RH_C_PORT_ENABLE 0x11
89 #define RH_C_PORT_SUSPEND 0x12
90 #define RH_C_PORT_OVER_CURRENT 0x13
91 #define RH_C_PORT_RESET 0x14
94 #define RH_C_HUB_LOCAL_POWER 0x00
95 #define RH_C_HUB_OVER_CURRENT 0x01
97 #define RH_DEVICE_REMOTE_WAKEUP 0x00
98 #define RH_ENDPOINT_STALL 0x01
102 /*-------------------------------------------------------------------------*/
103 /* struct for each HC
114 typedef struct td_array {
120 struct virt_root_hub rh; /* roothub */
121 wait_queue_head_t waitq; /* deletion of URBs and devices needs a waitqueue */
122 int active; /* HC is operating */
124 struct list_head ctrl_list; /* set of ctrl endpoints */
125 struct list_head bulk_list; /* set of bulk endpoints */
126 struct list_head iso_list; /* set of isoc endpoints */
127 struct list_head intr_list; /* ordered (tree) set of int endpoints */
128 struct list_head del_list; /* set of entpoints to be deleted */
130 td_array_t *td_array;
131 td_array_t a_td_array;
132 td_array_t i_td_array[2];
134 struct list_head hci_hcd_list; /* list of all hci_hcd */
135 struct usb_bus *bus; /* our bus */
137 // int trans; /* number of transactions pending */
140 int frame_number; /* frame number */
141 hcipriv_t hp; /* individual part of hc type */
147 /*-------------------------------------------------------------------------*/
148 /* condition (error) CC codes and mapping OHCI like
151 #define TD_CC_NOERROR 0x00
152 #define TD_CC_CRC 0x01
153 #define TD_CC_BITSTUFFING 0x02
154 #define TD_CC_DATATOGGLEM 0x03
155 #define TD_CC_STALL 0x04
156 #define TD_DEVNOTRESP 0x05
157 #define TD_PIDCHECKFAIL 0x06
158 #define TD_UNEXPECTEDPID 0x07
159 #define TD_DATAOVERRUN 0x08
160 #define TD_DATAUNDERRUN 0x09
161 #define TD_BUFFEROVERRUN 0x0C
162 #define TD_BUFFERUNDERRUN 0x0D
163 #define TD_NOTACCESSED 0x0F
166 /* urb interface functions */
167 static int hci_get_current_frame_number (struct usb_device *usb_dev);
168 static int hci_unlink_urb (struct urb * urb);
170 static int qu_queue_urb (hci_t * hci, struct urb * urb);
173 static int rh_init_int_timer (struct urb * urb);
174 static int rh_submit_urb (struct urb * urb);
175 static int rh_unlink_urb (struct urb * urb);
177 /* schedule functions */
178 static int sh_add_packet (hci_t * hci, struct urb * urb);
180 /* hc specific functions */
181 static inline void hc_flush_data_cache (hci_t * hci, void *data, int len);
182 static inline int hc_parse_trans (hci_t * hci, int *actbytes, __u8 * data,
183 int *cc, int *toggle, int length, int pid,
185 static inline int hc_add_trans (hci_t * hci, int len, void *data, int toggle,
186 int maxps, int slow, int endpoint, int address,
187 int pid, int format, int urb_state);
189 static void hc_start_int (hci_t * hci);
190 static void hc_stop_int (hci_t * hci);
191 static void SL811Write (hci_t * hci, char offset, char data);
193 /* debug| print the main components of an URB
194 * small: 0) header + data packets 1) just header */
196 static void urb_print (struct urb * urb, char *str, int small)
198 unsigned int pipe = urb->pipe;
201 if (!urb->dev || !urb->dev->bus) {
202 dbg ("%s URB: no dev", str);
206 printk ("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,flags:%4x,len:%d/%d,stat:%d(%x)\n",
207 str, hci_get_current_frame_number (urb->dev),
208 usb_pipedevice (pipe), usb_pipeendpoint (pipe),
209 usb_pipeout (pipe) ? 'O' : 'I',
210 usb_pipetype (pipe) < 2 ? (usb_pipeint (pipe) ? "INTR" : "ISOC")
211 : (usb_pipecontrol (pipe) ? "CTRL" : "BULK"), urb->transfer_flags,
212 urb->actual_length, urb->transfer_buffer_length, urb->status,
215 if (usb_pipecontrol (pipe)) {
216 printk (__FILE__ ": cmd(8):");
217 for (i = 0; i < 8; i++)
218 printk (" %02x", ((__u8 *) urb->setup_packet)[i]);
221 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
222 printk (__FILE__ ": data(%d/%d):", urb->actual_length,
223 urb->transfer_buffer_length);
224 len = usb_pipeout (pipe) ? urb-> transfer_buffer_length : urb->actual_length;
225 for (i = 0; i < 2096 && i < len; i++)
226 printk (" %02x", ((__u8 *) urb->transfer_buffer)[i]);
227 printk ("%s stat:%d\n", i < len ? "..." : "",