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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d8b275d was 46e078a, checked in by Vojtech Horky <vojtechhorky@…>, 15 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
RevLine 
[91db50ac]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
[3b77628]29/** @addtogroup libdrv
30 * @addtogroup usb
[91db50ac]31 * @{
32 */
33/** @file
[6edd494]34 * @brief USB host controller interface definition.
[91db50ac]35 */
36
[cb59f787]37#ifndef LIBDRV_USBHC_IFACE_H_
38#define LIBDRV_USBHC_IFACE_H_
[91db50ac]39
[eb1a2f4]40#include "ddf/driver.h"
[91db50ac]41#include <usb/usb.h>
[6427cf67]42#include <bool.h>
[91db50ac]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)
[cb59f787]50 * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
[91db50ac]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
[228f251]55 * - argument #3 is max packet size of the endpoint
[91db50ac]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)
[cb59f787]63 * - e.g. IPC_M_USBHC_INTERRUPT_IN -
[91db50ac]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
[1e64b250]68 * - this call is immediately followed by IPC data read (async version)
[91db50ac]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.
[1e64b250]75 **
[91db50ac]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 {
[6f04905]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
[4689d40]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
[6f04905]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
[91db50ac]117 /** Send interrupt data to device.
[1b22bd4]118 * See explanation at usb_iface_funcs_t (OUT transaction).
[91db50ac]119 */
[cb59f787]120 IPC_M_USBHC_INTERRUPT_OUT,
[91db50ac]121
122 /** Get interrupt data from device.
[1b22bd4]123 * See explanation at usb_iface_funcs_t (IN transaction).
[91db50ac]124 */
[cb59f787]125 IPC_M_USBHC_INTERRUPT_IN,
[91db50ac]126
[0a46c41e]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
[9753220]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
[228f251]145 /** Issue control READ transfer.
[9753220]146 * See explanation at usb_iface_funcs_t (IN transaction) for
147 * call parameters.
[228f251]148 * This call is immediately followed by IPC data write from the caller
149 * (setup packet) and IPC data read (buffer that was read).
[9753220]150 */
151 IPC_M_USBHC_CONTROL_READ,
[91db50ac]152
[b7d8fd9]153 /** Register endpoint attributes at host controller.
154 * This is used to reserve portion of USB bandwidth.
[1998bcd]155 * When speed is invalid, speed of the device is used.
[b7d8fd9]156 * Parameters:
[1998bcd]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
[b7d8fd9]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
[cb59f787]179} usbhc_iface_funcs_t;
[91db50ac]180
181/** Callback for outgoing transfer. */
[eb1a2f4]182typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *,
[daec5e04]183 int, void *);
[91db50ac]184
185/** Callback for incoming transfer. */
[eb1a2f4]186typedef void (*usbhc_iface_transfer_in_callback_t)(ddf_fun_t *,
[daec5e04]187 int, size_t, void *);
[91db50ac]188
[fb1dca09]189
190/** Out transfer processing function prototype. */
[7dfc06fa]191typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t,
[fb1dca09]192 void *, size_t,
193 usbhc_iface_transfer_out_callback_t, void *);
194
[ec59693]195/** Setup transfer processing function prototype. @deprecated */
[fb1dca09]196typedef usbhc_iface_transfer_out_t usbhc_iface_transfer_setup_t;
197
198/** In transfer processing function prototype. */
[7dfc06fa]199typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t,
[fb1dca09]200 void *, size_t,
201 usbhc_iface_transfer_in_callback_t, void *);
202
[6edd494]203/** USB host controller communication interface. */
[91db50ac]204typedef struct {
[eb1a2f4]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);
[6f04905]210
[1998bcd]211 int (*register_endpoint)(ddf_fun_t *,
212 usb_address_t, usb_speed_t, usb_endpoint_t,
[b7d8fd9]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
[fb1dca09]217 usbhc_iface_transfer_out_t interrupt_out;
218 usbhc_iface_transfer_in_t interrupt_in;
[a3dfb2e]219
[0a46c41e]220 usbhc_iface_transfer_out_t bulk_out;
221 usbhc_iface_transfer_in_t bulk_in;
222
[eb1a2f4]223 int (*control_write)(ddf_fun_t *, usb_target_t,
[9753220]224 void *, size_t, void *, size_t,
225 usbhc_iface_transfer_out_callback_t, void *);
226
[eb1a2f4]227 int (*control_read)(ddf_fun_t *, usb_target_t,
[9753220]228 void *, size_t, void *, size_t,
229 usbhc_iface_transfer_in_callback_t, void *);
[cb59f787]230} usbhc_iface_t;
[91db50ac]231
232
233#endif
234/**
235 * @}
236 */
Note: See TracBrowser for help on using the repository browser.