source: mainline/uspace/drv/ehci_hcd/hc_iface.c@ 99e846f0

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 99e846f0 was 8d6c1f1, checked in by Jakub Jermar <jakub@…>, 14 years ago

Merge USB support.

Changes from bzr://helenos-usb.bzr.sourceforge.net/bzrroot/helenos-usb/mainline:

  • replaced '-' with '_' in new driver names
  • USB libs are built for each architecture
  • devman starts early
  • sys_thread_udelay() uses generic delay()
  • sys_as_create_area() now creates cacheable areas by default
  • Property mode set to 100644
File size: 11.0 KB
Line 
1/*
2 * Copyright (c) 2011 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/** @addtogroup drvusbehci
29 * @{
30 */
31/** @file
32 * USB-HC interface implementation.
33 */
34#include <ddf/driver.h>
35#include <ddf/interrupt.h>
36#include <device/hw_res.h>
37#include <errno.h>
38#include <str_error.h>
39
40#include <usb_iface.h>
41#include <usb/ddfiface.h>
42#include <usb/debug.h>
43
44#include "ehci.h"
45
46#define UNSUPPORTED(methodname) \
47 usb_log_warning("Unsupported interface method `%s()' in %s:%d.\n", \
48 methodname, __FILE__, __LINE__)
49
50/** Found free USB address.
51 *
52 * @param[in] fun Device function the action was invoked on.
53 * @param[in] speed Speed of the device that will get this address.
54 * @param[out] address Non-null pointer where to store the free address.
55 * @return Error code.
56 */
57static int request_address(ddf_fun_t *fun, usb_speed_t speed,
58 usb_address_t *address)
59{
60 UNSUPPORTED("request_address");
61
62 return ENOTSUP;
63}
64
65/** Bind USB address with device devman handle.
66 *
67 * @param[in] fun Device function the action was invoked on.
68 * @param[in] address USB address of the device.
69 * @param[in] handle Devman handle of the device.
70 * @return Error code.
71 */
72static int bind_address(ddf_fun_t *fun,
73 usb_address_t address, devman_handle_t handle)
74{
75 UNSUPPORTED("bind_address");
76
77 return ENOTSUP;
78}
79
80/** Find device handle by USB address.
81 *
82 * @param[in] fun DDF function that was called.
83 * @param[in] address Address in question.
84 * @param[out] handle Where to store device handle if found.
85 * @return Error code.
86 */
87static int find_by_address(ddf_fun_t *fun, usb_address_t address,
88 devman_handle_t *handle)
89{
90 UNSUPPORTED("find_by_address");
91
92 return ENOTSUP;
93}
94
95/** Release previously requested address.
96 *
97 * @param[in] fun Device function the action was invoked on.
98 * @param[in] address USB address to be released.
99 * @return Error code.
100 */
101static int release_address(ddf_fun_t *fun, usb_address_t address)
102{
103 UNSUPPORTED("release_address");
104
105 return ENOTSUP;
106}
107
108/** Register endpoint for bandwidth reservation.
109 *
110 * @param[in] fun Device function the action was invoked on.
111 * @param[in] address USB address of the device.
112 * @param[in] speed Endpoint speed (invalid means to use device one).
113 * @param[in] endpoint Endpoint number.
114 * @param[in] transfer_type USB transfer type.
115 * @param[in] direction Endpoint data direction.
116 * @param[in] max_packet_size Max packet size of the endpoint.
117 * @param[in] interval Polling interval.
118 * @return Error code.
119 */
120static int register_endpoint(ddf_fun_t *fun,
121 usb_address_t address, usb_speed_t speed, usb_endpoint_t endpoint,
122 usb_transfer_type_t transfer_type, usb_direction_t direction,
123 size_t max_packet_size, unsigned int interval)
124{
125 UNSUPPORTED("register_endpoint");
126
127 return ENOTSUP;
128}
129
130/** Unregister endpoint (free some bandwidth reservation).
131 *
132 * @param[in] fun Device function the action was invoked on.
133 * @param[in] address USB address of the device.
134 * @param[in] endpoint Endpoint number.
135 * @param[in] direction Endpoint data direction.
136 * @return Error code.
137 */
138static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
139 usb_endpoint_t endpoint, usb_direction_t direction)
140{
141 UNSUPPORTED("unregister_endpoint");
142
143 return ENOTSUP;
144}
145
146/** Schedule interrupt out transfer.
147 *
148 * The callback is supposed to be called once the transfer (on the wire) is
149 * complete regardless of the outcome.
150 * However, the callback could be called only when this function returns
151 * with success status (i.e. returns EOK).
152 *
153 * @param[in] fun Device function the action was invoked on.
154 * @param[in] target Target pipe (address and endpoint number) specification.
155 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
156 * by the caller).
157 * @param[in] size Size of the @p data buffer in bytes.
158 * @param[in] callback Callback to be issued once the transfer is complete.
159 * @param[in] arg Pass-through argument to the callback.
160 * @return Error code.
161 */
162static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
163 void *data, size_t size,
164 usbhc_iface_transfer_out_callback_t callback, void *arg)
165{
166 UNSUPPORTED("interrupt_out");
167
168 return ENOTSUP;
169}
170
171/** Schedule interrupt in transfer.
172 *
173 * The callback is supposed to be called once the transfer (on the wire) is
174 * complete regardless of the outcome.
175 * However, the callback could be called only when this function returns
176 * with success status (i.e. returns EOK).
177 *
178 * @param[in] fun Device function the action was invoked on.
179 * @param[in] target Target pipe (address and endpoint number) specification.
180 * @param[in] data Buffer where to store the data (in USB endianess,
181 * allocated and deallocated by the caller).
182 * @param[in] size Size of the @p data buffer in bytes.
183 * @param[in] callback Callback to be issued once the transfer is complete.
184 * @param[in] arg Pass-through argument to the callback.
185 * @return Error code.
186 */
187static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
188 void *data, size_t size,
189 usbhc_iface_transfer_in_callback_t callback, void *arg)
190{
191 UNSUPPORTED("interrupt_in");
192
193 return ENOTSUP;
194}
195
196/** Schedule bulk out transfer.
197 *
198 * The callback is supposed to be called once the transfer (on the wire) is
199 * complete regardless of the outcome.
200 * However, the callback could be called only when this function returns
201 * with success status (i.e. returns EOK).
202 *
203 * @param[in] fun Device function the action was invoked on.
204 * @param[in] target Target pipe (address and endpoint number) specification.
205 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
206 * by the caller).
207 * @param[in] size Size of the @p data buffer in bytes.
208 * @param[in] callback Callback to be issued once the transfer is complete.
209 * @param[in] arg Pass-through argument to the callback.
210 * @return Error code.
211 */
212static int bulk_out(ddf_fun_t *fun, usb_target_t target,
213 void *data, size_t size,
214 usbhc_iface_transfer_out_callback_t callback, void *arg)
215{
216 UNSUPPORTED("bulk_out");
217
218 return ENOTSUP;
219}
220
221/** Schedule bulk in transfer.
222 *
223 * The callback is supposed to be called once the transfer (on the wire) is
224 * complete regardless of the outcome.
225 * However, the callback could be called only when this function returns
226 * with success status (i.e. returns EOK).
227 *
228 * @param[in] fun Device function the action was invoked on.
229 * @param[in] target Target pipe (address and endpoint number) specification.
230 * @param[in] data Buffer where to store the data (in USB endianess,
231 * allocated and deallocated by the caller).
232 * @param[in] size Size of the @p data buffer in bytes.
233 * @param[in] callback Callback to be issued once the transfer is complete.
234 * @param[in] arg Pass-through argument to the callback.
235 * @return Error code.
236 */
237static int bulk_in(ddf_fun_t *fun, usb_target_t target,
238 void *data, size_t size,
239 usbhc_iface_transfer_in_callback_t callback, void *arg)
240{
241 UNSUPPORTED("bulk_in");
242
243 return ENOTSUP;
244}
245
246/** Schedule control write transfer.
247 *
248 * The callback is supposed to be called once the transfer (on the wire) is
249 * complete regardless of the outcome.
250 * However, the callback could be called only when this function returns
251 * with success status (i.e. returns EOK).
252 *
253 * @param[in] fun Device function the action was invoked on.
254 * @param[in] target Target pipe (address and endpoint number) specification.
255 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
256 * and deallocated by the caller).
257 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
258 * @param[in] data_buffer Data buffer (in USB endianess, allocated and
259 * deallocated by the caller).
260 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
261 * @param[in] callback Callback to be issued once the transfer is complete.
262 * @param[in] arg Pass-through argument to the callback.
263 * @return Error code.
264 */
265static int control_write(ddf_fun_t *fun, usb_target_t target,
266 void *setup_packet, size_t setup_packet_size,
267 void *data_buffer, size_t data_buffer_size,
268 usbhc_iface_transfer_out_callback_t callback, void *arg)
269{
270 UNSUPPORTED("control_write");
271
272 return ENOTSUP;
273}
274
275/** Schedule control read transfer.
276 *
277 * The callback is supposed to be called once the transfer (on the wire) is
278 * complete regardless of the outcome.
279 * However, the callback could be called only when this function returns
280 * with success status (i.e. returns EOK).
281 *
282 * @param[in] fun Device function the action was invoked on.
283 * @param[in] target Target pipe (address and endpoint number) specification.
284 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
285 * and deallocated by the caller).
286 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
287 * @param[in] data_buffer Buffer where to store the data (in USB endianess,
288 * allocated and deallocated by the caller).
289 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
290 * @param[in] callback Callback to be issued once the transfer is complete.
291 * @param[in] arg Pass-through argument to the callback.
292 * @return Error code.
293 */
294static int control_read(ddf_fun_t *fun, usb_target_t target,
295 void *setup_packet, size_t setup_packet_size,
296 void *data_buffer, size_t data_buffer_size,
297 usbhc_iface_transfer_in_callback_t callback, void *arg)
298{
299 UNSUPPORTED("control_read");
300
301 return ENOTSUP;
302}
303
304/** Host controller interface implementation for EHCI. */
305usbhc_iface_t ehci_hc_iface = {
306 .request_address = request_address,
307 .bind_address = bind_address,
308 .find_by_address = find_by_address,
309 .release_address = release_address,
310
311 .register_endpoint = register_endpoint,
312 .unregister_endpoint = unregister_endpoint,
313
314 .interrupt_out = interrupt_out,
315 .interrupt_in = interrupt_in,
316
317 .bulk_out = bulk_out,
318 .bulk_in = bulk_in,
319
320 .control_write = control_write,
321 .control_read = control_read
322};
323
324/**
325 * @}
326 */
Note: See TracBrowser for help on using the repository browser.