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

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

USBHC iface: remove default address reservation

This functionality is now handled via endpoint registration.

Also removed references to this function from hub driver. Either they
were unreachable or would break things anyway.

  • Property mode set to 100644
File size: 7.8 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 "ddf/driver.h"
41#include <usb/usb.h>
42#include <bool.h>
43
44
45/** IPC methods for communication with HC through DDF interface.
46 *
47 * Notes for async methods:
48 *
49 * Methods for sending data to device (OUT transactions)
50 * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
51 * always use the same semantics:
52 * - first, IPC call with given method is made
53 * - argument #1 is target address
54 * - argument #2 is target endpoint
55 * - argument #3 is max packet size of the endpoint
56 * - this call is immediately followed by IPC data write (from caller)
57 * - the initial call (and the whole transaction) is answer after the
58 * transaction is scheduled by the HC and acknowledged by the device
59 * or immediately after error is detected
60 * - the answer carries only the error code
61 *
62 * Methods for retrieving data from device (IN transactions)
63 * - e.g. IPC_M_USBHC_INTERRUPT_IN -
64 * also use the same semantics:
65 * - first, IPC call with given method is made
66 * - argument #1 is target address
67 * - argument #2 is target endpoint
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 /** Asks for address assignment by host controller.
87 * Answer:
88 * - ELIMIT - host controller run out of address
89 * - EOK - address assigned
90 * Answer arguments:
91 * - assigned address
92 *
93 * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
94 */
95 IPC_M_USBHC_REQUEST_ADDRESS,
96
97 /** Bind USB address with devman handle.
98 * Parameters:
99 * - USB address
100 * - devman handle
101 * Answer:
102 * - EOK - address binded
103 * - ENOENT - address is not in use
104 */
105 IPC_M_USBHC_BIND_ADDRESS,
106
107 /** Release address in use.
108 * Arguments:
109 * - address to be released
110 * Answer:
111 * - ENOENT - address not in use
112 * - EPERM - trying to release default USB address
113 */
114 IPC_M_USBHC_RELEASE_ADDRESS,
115
116
117 /** Send interrupt data to device.
118 * See explanation at usb_iface_funcs_t (OUT transaction).
119 */
120 IPC_M_USBHC_INTERRUPT_OUT,
121
122 /** Get interrupt data from device.
123 * See explanation at usb_iface_funcs_t (IN transaction).
124 */
125 IPC_M_USBHC_INTERRUPT_IN,
126
127 /** Send bulk data to device.
128 * See explanation at usb_iface_funcs_t (OUT transaction).
129 */
130 IPC_M_USBHC_BULK_OUT,
131
132 /** Get bulk data from device.
133 * See explanation at usb_iface_funcs_t (IN transaction).
134 */
135 IPC_M_USBHC_BULK_IN,
136
137 /** Issue control WRITE transfer.
138 * See explanation at usb_iface_funcs_t (OUT transaction) for
139 * call parameters.
140 * This call is immediately followed by two IPC data writes
141 * from the caller (setup packet and actual data).
142 */
143 IPC_M_USBHC_CONTROL_WRITE,
144
145 /** Issue control READ transfer.
146 * See explanation at usb_iface_funcs_t (IN transaction) for
147 * call parameters.
148 * This call is immediately followed by IPC data write from the caller
149 * (setup packet) and IPC data read (buffer that was read).
150 */
151 IPC_M_USBHC_CONTROL_READ,
152
153 /** Register endpoint attributes at host controller.
154 * This is used to reserve portion of USB bandwidth.
155 * When speed is invalid, speed of the device is used.
156 * Parameters:
157 * - USB address + endpoint number
158 * - packed as ADDR << 16 + EP
159 * - speed + transfer type + direction
160 * - packed as ( SPEED << 8 + TYPE ) << 8 + DIR
161 * - maximum packet size + interval (in milliseconds)
162 * - packed as MPS << 16 + INT
163 * Answer:
164 * - EOK - reservation successful
165 * - ELIMIT - not enough bandwidth to satisfy the request
166 */
167 IPC_M_USBHC_REGISTER_ENDPOINT,
168
169 /** Revert endpoint registration.
170 * Parameters:
171 * - USB address
172 * - endpoint number
173 * - data direction
174 * Answer:
175 * - EOK - endpoint unregistered
176 * - ENOENT - unknown endpoint
177 */
178 IPC_M_USBHC_UNREGISTER_ENDPOINT
179} usbhc_iface_funcs_t;
180
181/** Callback for outgoing transfer. */
182typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *,
183 int, void *);
184
185/** Callback for incoming transfer. */
186typedef void (*usbhc_iface_transfer_in_callback_t)(ddf_fun_t *,
187 int, size_t, void *);
188
189
190/** Out transfer processing function prototype. */
191typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t,
192 void *, size_t,
193 usbhc_iface_transfer_out_callback_t, void *);
194
195/** Setup transfer processing function prototype. @deprecated */
196typedef usbhc_iface_transfer_out_t usbhc_iface_transfer_setup_t;
197
198/** In transfer processing function prototype. */
199typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t,
200 void *, size_t,
201 usbhc_iface_transfer_in_callback_t, void *);
202
203/** USB host controller communication interface. */
204typedef struct {
205 int (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
206 int (*release_default_address)(ddf_fun_t *);
207 int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
208 int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
209 int (*release_address)(ddf_fun_t *, usb_address_t);
210
211 int (*register_endpoint)(ddf_fun_t *,
212 usb_address_t, usb_speed_t, usb_endpoint_t,
213 usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
214 int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
215 usb_direction_t);
216
217 usbhc_iface_transfer_out_t interrupt_out;
218 usbhc_iface_transfer_in_t interrupt_in;
219
220 usbhc_iface_transfer_out_t bulk_out;
221 usbhc_iface_transfer_in_t bulk_in;
222
223 int (*control_write)(ddf_fun_t *, usb_target_t,
224 void *, size_t, void *, size_t,
225 usbhc_iface_transfer_out_callback_t, void *);
226
227 int (*control_read)(ddf_fun_t *, usb_target_t,
228 void *, size_t, void *, size_t,
229 usbhc_iface_transfer_in_callback_t, void *);
230} usbhc_iface_t;
231
232
233#endif
234/**
235 * @}
236 */
Note: See TracBrowser for help on using the repository browser.