source: mainline/uspace/lib/drv/include/usbhc_iface.h@ ec59693

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ec59693 was ec59693, checked in by Vojtech Horky <vojtechhorky@…>, 14 years ago

USB HC interface has max packet size

Currently, it is only a hack to extend the interface as the values
are hard coded inside the remote part of the interface.

Sending of real values will be added once the old drivers API is
completely removed (no sense in changing the same thing twice).

  • Property mode set to 100644
File size: 8.7 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libdrv
30 * @addtogroup usb
31 * @{
32 */
33/** @file
34 * @brief USB host controller interface definition.
35 */
36
37#ifndef LIBDRV_USBHC_IFACE_H_
38#define LIBDRV_USBHC_IFACE_H_
39
40#include "driver.h"
41#include <usb/usb.h>
42
43
44/** IPC methods for communication with HC through DDF interface.
45 *
46 * Notes for async methods:
47 *
48 * Methods for sending data to device (OUT transactions)
49 * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
50 * always use the same semantics:
51 * - first, IPC call with given method is made
52 * - argument #1 is target address
53 * - argument #2 is target endpoint
54 * - argument #3 is buffer size
55 * - this call is immediately followed by IPC data write (from caller)
56 * - the initial call (and the whole transaction) is answer after the
57 * transaction is scheduled by the HC and acknowledged by the device
58 * or immediately after error is detected
59 * - the answer carries only the error code
60 *
61 * Methods for retrieving data from device (IN transactions)
62 * - e.g. IPC_M_USBHC_INTERRUPT_IN -
63 * also use the same semantics:
64 * - first, IPC call with given method is made
65 * - argument #1 is target address
66 * - argument #2 is target endpoint
67 * - argument #3 is buffer size
68 * - this call is immediately followed by IPC data read (async version)
69 * - the call is not answered until the device returns some data (or until
70 * error occurs)
71 *
72 * Some special methods (NO-DATA transactions) do not send any data. These
73 * might behave as both OUT or IN transactions because communication parts
74 * where actual buffers are exchanged are omitted.
75 **
76 * For all these methods, wrap functions exists. Important rule: functions
77 * for IN transactions have (as parameters) buffers where retrieved data
78 * will be stored. These buffers must be already allocated and shall not be
79 * touch until the transaction is completed
80 * (e.g. not before calling usb_wait_for() with appropriate handle).
81 * OUT transactions buffers can be freed immediately after call is dispatched
82 * (i.e. after return from wrapping function).
83 *
84 */
85typedef enum {
86 /** Tell USB address assigned to device.
87 * Parameters:
88 * - devman handle id
89 * Answer:
90 * - EINVAL - unknown handle or handle not managed by this driver
91 * - ENOTSUP - operation not supported by HC (shall not happen)
92 * - arbitrary error code if returned by remote implementation
93 * - EOK - handle found, first parameter contains the USB address
94 */
95 IPC_M_USBHC_GET_ADDRESS,
96
97
98 /** Reserve usage of default address.
99 * This call informs the host controller that the caller will be
100 * using default USB address. It is duty of the HC driver to ensure
101 * that only single entity will have it reserved.
102 * The address is returned via IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS.
103 * The caller can start using the address after receiving EOK
104 * answer.
105 */
106 IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS,
107
108 /** Release usage of default address.
109 * @see IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS
110 */
111 IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS,
112
113 /** Asks for address assignment by host controller.
114 * Answer:
115 * - ELIMIT - host controller run out of address
116 * - EOK - address assigned
117 * Answer arguments:
118 * - assigned address
119 *
120 * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
121 */
122 IPC_M_USBHC_REQUEST_ADDRESS,
123
124 /** Bind USB address with devman handle.
125 * Parameters:
126 * - USB address
127 * - devman handle
128 * Answer:
129 * - EOK - address binded
130 * - ENOENT - address is not in use
131 */
132 IPC_M_USBHC_BIND_ADDRESS,
133
134 /** Release address in use.
135 * Arguments:
136 * - address to be released
137 * Answer:
138 * - ENOENT - address not in use
139 * - EPERM - trying to release default USB address
140 */
141 IPC_M_USBHC_RELEASE_ADDRESS,
142
143
144 /** Send interrupt data to device.
145 * See explanation at usb_iface_funcs_t (OUT transaction).
146 */
147 IPC_M_USBHC_INTERRUPT_OUT,
148
149 /** Get interrupt data from device.
150 * See explanation at usb_iface_funcs_t (IN transaction).
151 */
152 IPC_M_USBHC_INTERRUPT_IN,
153
154
155 /** Start WRITE control transfer.
156 * See explanation at usb_iface_funcs_t (OUT transaction).
157 */
158 IPC_M_USBHC_CONTROL_WRITE_SETUP,
159
160 /** Send control-transfer data to device.
161 * See explanation at usb_iface_funcs_t (OUT transaction).
162 */
163 IPC_M_USBHC_CONTROL_WRITE_DATA,
164
165 /** Terminate WRITE control transfer.
166 * See explanation at usb_iface_funcs_t (NO-DATA transaction).
167 */
168 IPC_M_USBHC_CONTROL_WRITE_STATUS,
169
170
171
172 /** Start READ control transfer.
173 * See explanation at usb_iface_funcs_t (OUT transaction).
174 */
175 IPC_M_USBHC_CONTROL_READ_SETUP,
176
177 /** Get control-transfer data from device.
178 * See explanation at usb_iface_funcs_t (IN transaction).
179 */
180 IPC_M_USBHC_CONTROL_READ_DATA,
181
182 /** Terminate READ control transfer.
183 * See explanation at usb_iface_funcs_t (NO-DATA transaction).
184 */
185 IPC_M_USBHC_CONTROL_READ_STATUS,
186
187 /** Issue control WRITE transfer.
188 * See explanation at usb_iface_funcs_t (OUT transaction) for
189 * call parameters.
190 * This call is immediately followed by two IPC data writes
191 * from the caller (setup packet and actual data).
192 */
193 IPC_M_USBHC_CONTROL_WRITE,
194
195 /** Issue control WRITE transfer.
196 * See explanation at usb_iface_funcs_t (IN transaction) for
197 * call parameters.
198 * This call is immediately followed by IPC data read from the caller
199 * (setup packet).
200 * Actual data are retrieved through IPC_M_USBHC_GET_BUFFER.
201 */
202 IPC_M_USBHC_CONTROL_READ,
203
204 /* IPC_M_USB_ */
205} usbhc_iface_funcs_t;
206
207/** Callback for outgoing transfer. */
208typedef void (*usbhc_iface_transfer_out_callback_t)(device_t *,
209 int, void *);
210
211/** Callback for incoming transfer. */
212typedef void (*usbhc_iface_transfer_in_callback_t)(device_t *,
213 int, size_t, void *);
214
215
216/** Out transfer processing function prototype. */
217typedef int (*usbhc_iface_transfer_out_t)(device_t *, usb_target_t, size_t,
218 void *, size_t,
219 usbhc_iface_transfer_out_callback_t, void *);
220
221/** Setup transfer processing function prototype. @deprecated */
222typedef usbhc_iface_transfer_out_t usbhc_iface_transfer_setup_t;
223
224/** In transfer processing function prototype. */
225typedef int (*usbhc_iface_transfer_in_t)(device_t *, usb_target_t, size_t,
226 void *, size_t,
227 usbhc_iface_transfer_in_callback_t, void *);
228
229/** USB host controller communication interface. */
230typedef struct {
231 int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);
232
233 int (*reserve_default_address)(device_t *);
234 int (*release_default_address)(device_t *);
235 int (*request_address)(device_t *, usb_address_t *);
236 int (*bind_address)(device_t *, usb_address_t, devman_handle_t);
237 int (*release_address)(device_t *, usb_address_t);
238
239 usbhc_iface_transfer_out_t interrupt_out;
240 usbhc_iface_transfer_in_t interrupt_in;
241
242 usbhc_iface_transfer_setup_t control_write_setup;
243 usbhc_iface_transfer_out_t control_write_data;
244 int (*control_write_status)(device_t *, usb_target_t,
245 usbhc_iface_transfer_in_callback_t, void *);
246
247 usbhc_iface_transfer_setup_t control_read_setup;
248 usbhc_iface_transfer_in_t control_read_data;
249 int (*control_read_status)(device_t *, usb_target_t,
250 usbhc_iface_transfer_out_callback_t, void *);
251
252 int (*control_write)(device_t *, usb_target_t,
253 size_t,
254 void *, size_t, void *, size_t,
255 usbhc_iface_transfer_out_callback_t, void *);
256
257 int (*control_read)(device_t *, usb_target_t,
258 size_t,
259 void *, size_t, void *, size_t,
260 usbhc_iface_transfer_in_callback_t, void *);
261} usbhc_iface_t;
262
263
264#endif
265/**
266 * @}
267 */
Note: See TracBrowser for help on using the repository browser.