[c7137738] | 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 libusb
|
---|
[c7137738] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief USB driver (implementation).
|
---|
| 34 | */
|
---|
[4b4c797] | 35 | #include <usb/usbdrv.h>
|
---|
[c7137738] | 36 | #include <errno.h>
|
---|
| 37 |
|
---|
[91db50ac] | 38 |
|
---|
[56fb3732] | 39 | /** Find handle of host controller the device is physically attached to.
|
---|
| 40 | *
|
---|
| 41 | * @param[in] dev Device looking for its host controller.
|
---|
| 42 | * @param[out] handle Host controller devman handle.
|
---|
| 43 | * @return Error code.
|
---|
| 44 | */
|
---|
| 45 | int usb_drv_find_hc(device_t *dev, devman_handle_t *handle)
|
---|
| 46 | {
|
---|
[72363a1] | 47 | return ENOTSUP;
|
---|
[56fb3732] | 48 | }
|
---|
| 49 |
|
---|
[71ed4849] | 50 | /** Connect to host controller the device is physically attached to.
|
---|
| 51 | *
|
---|
| 52 | * @param dev Device asking for connection.
|
---|
| 53 | * @param hc_handle Devman handle of the host controller.
|
---|
| 54 | * @param flags Connection flags (blocking connection).
|
---|
| 55 | * @return Phone to the HC or error code.
|
---|
| 56 | */
|
---|
| 57 | int usb_drv_hc_connect(device_t *dev, devman_handle_t hc_handle,
|
---|
| 58 | unsigned int flags)
|
---|
| 59 | {
|
---|
[72363a1] | 60 | return ENOTSUP;
|
---|
[71ed4849] | 61 | }
|
---|
| 62 |
|
---|
[c7137738] | 63 | /** Connect to host controller the device is physically attached to.
|
---|
| 64 | *
|
---|
[62c9661] | 65 | * @param dev Device asking for connection.
|
---|
[c7137738] | 66 | * @param flags Connection flags (blocking connection).
|
---|
[91db50ac] | 67 | * @return Phone to corresponding HC or error code.
|
---|
[c7137738] | 68 | */
|
---|
[71ed4849] | 69 | int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags)
|
---|
[c7137738] | 70 | {
|
---|
[72363a1] | 71 | return ENOTSUP;
|
---|
[c7137738] | 72 | }
|
---|
| 73 |
|
---|
[0e126be7] | 74 | /** Tell USB address assigned to given device.
|
---|
| 75 | *
|
---|
| 76 | * @param phone Phone to my HC.
|
---|
| 77 | * @param dev Device in question.
|
---|
| 78 | * @return USB address or error code.
|
---|
| 79 | */
|
---|
| 80 | usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
|
---|
| 81 | {
|
---|
[72363a1] | 82 | return ENOTSUP;
|
---|
[0e126be7] | 83 | }
|
---|
| 84 |
|
---|
[6f04905] | 85 | /** Tell HC to reserve default address.
|
---|
| 86 | *
|
---|
| 87 | * @param phone Open phone to host controller driver.
|
---|
| 88 | * @return Error code.
|
---|
| 89 | */
|
---|
| 90 | int usb_drv_reserve_default_address(int phone)
|
---|
| 91 | {
|
---|
[72363a1] | 92 | return ENOTSUP;
|
---|
[6f04905] | 93 | }
|
---|
| 94 |
|
---|
| 95 | /** Tell HC to release default address.
|
---|
| 96 | *
|
---|
| 97 | * @param phone Open phone to host controller driver.
|
---|
| 98 | * @return Error code.
|
---|
| 99 | */
|
---|
| 100 | int usb_drv_release_default_address(int phone)
|
---|
| 101 | {
|
---|
[72363a1] | 102 | return ENOTSUP;
|
---|
[6f04905] | 103 | }
|
---|
| 104 |
|
---|
| 105 | /** Ask HC for free address assignment.
|
---|
| 106 | *
|
---|
| 107 | * @param phone Open phone to host controller driver.
|
---|
| 108 | * @return Assigned USB address or negative error code.
|
---|
| 109 | */
|
---|
| 110 | usb_address_t usb_drv_request_address(int phone)
|
---|
| 111 | {
|
---|
[72363a1] | 112 | return ENOTSUP;
|
---|
[6f04905] | 113 | }
|
---|
| 114 |
|
---|
[4689d40] | 115 | /** Inform HC about binding address with devman handle.
|
---|
| 116 | *
|
---|
| 117 | * @param phone Open phone to host controller driver.
|
---|
| 118 | * @param address Address to be binded.
|
---|
| 119 | * @param handle Devman handle of the device.
|
---|
| 120 | * @return Error code.
|
---|
| 121 | */
|
---|
| 122 | int usb_drv_bind_address(int phone, usb_address_t address,
|
---|
| 123 | devman_handle_t handle)
|
---|
| 124 | {
|
---|
[72363a1] | 125 | return ENOTSUP;
|
---|
[4689d40] | 126 | }
|
---|
| 127 |
|
---|
[6f04905] | 128 | /** Inform HC about address release.
|
---|
| 129 | *
|
---|
| 130 | * @param phone Open phone to host controller driver.
|
---|
| 131 | * @param address Address to be released.
|
---|
| 132 | * @return Error code.
|
---|
| 133 | */
|
---|
| 134 | int usb_drv_release_address(int phone, usb_address_t address)
|
---|
| 135 | {
|
---|
[72363a1] | 136 | return ENOTSUP;
|
---|
[91db50ac] | 137 | }
|
---|
| 138 |
|
---|
| 139 | /** Blocks caller until given USB transaction is finished.
|
---|
| 140 | * After the transaction is finished, the user can access all output data
|
---|
| 141 | * given to initial call function.
|
---|
| 142 | *
|
---|
| 143 | * @param handle Transaction handle.
|
---|
| 144 | * @return Error status.
|
---|
| 145 | * @retval EOK No error.
|
---|
| 146 | * @retval EBADMEM Invalid handle.
|
---|
| 147 | * @retval ENOENT Data buffer associated with transaction does not exist.
|
---|
| 148 | */
|
---|
| 149 | int usb_drv_async_wait_for(usb_handle_t handle)
|
---|
| 150 | {
|
---|
[72363a1] | 151 | return ENOTSUP;
|
---|
[91db50ac] | 152 | }
|
---|
| 153 |
|
---|
| 154 | /** Send interrupt data to device. */
|
---|
[0e126be7] | 155 | int usb_drv_async_interrupt_out(int phone, usb_target_t target,
|
---|
[91db50ac] | 156 | void *buffer, size_t size,
|
---|
| 157 | usb_handle_t *handle)
|
---|
| 158 | {
|
---|
[72363a1] | 159 | return ENOTSUP;
|
---|
[91db50ac] | 160 | }
|
---|
| 161 |
|
---|
| 162 | /** Request interrupt data from device. */
|
---|
[0e126be7] | 163 | int usb_drv_async_interrupt_in(int phone, usb_target_t target,
|
---|
[91db50ac] | 164 | void *buffer, size_t size, size_t *actual_size,
|
---|
| 165 | usb_handle_t *handle)
|
---|
| 166 | {
|
---|
[72363a1] | 167 | return ENOTSUP;
|
---|
[91db50ac] | 168 | }
|
---|
[c7137738] | 169 |
|
---|
[6c8ada21] | 170 | /** Start control write transfer. */
|
---|
| 171 | int usb_drv_async_control_write_setup(int phone, usb_target_t target,
|
---|
| 172 | void *buffer, size_t size,
|
---|
| 173 | usb_handle_t *handle)
|
---|
| 174 | {
|
---|
[72363a1] | 175 | return ENOTSUP;
|
---|
[6c8ada21] | 176 | }
|
---|
| 177 |
|
---|
| 178 | /** Send data during control write transfer. */
|
---|
| 179 | int usb_drv_async_control_write_data(int phone, usb_target_t target,
|
---|
| 180 | void *buffer, size_t size,
|
---|
| 181 | usb_handle_t *handle)
|
---|
| 182 | {
|
---|
[72363a1] | 183 | return ENOTSUP;
|
---|
[6c8ada21] | 184 | }
|
---|
| 185 |
|
---|
| 186 | /** Finalize control write transfer. */
|
---|
| 187 | int usb_drv_async_control_write_status(int phone, usb_target_t target,
|
---|
| 188 | usb_handle_t *handle)
|
---|
| 189 | {
|
---|
[72363a1] | 190 | return ENOTSUP;
|
---|
[6c8ada21] | 191 | }
|
---|
| 192 |
|
---|
[fe4dd14] | 193 | /** Issue whole control write transfer. */
|
---|
| 194 | int usb_drv_async_control_write(int phone, usb_target_t target,
|
---|
| 195 | void *setup_packet, size_t setup_packet_size,
|
---|
| 196 | void *buffer, size_t buffer_size,
|
---|
| 197 | usb_handle_t *handle)
|
---|
| 198 | {
|
---|
[72363a1] | 199 | return ENOTSUP;
|
---|
[fe4dd14] | 200 | }
|
---|
| 201 |
|
---|
[6c8ada21] | 202 | /** Start control read transfer. */
|
---|
| 203 | int usb_drv_async_control_read_setup(int phone, usb_target_t target,
|
---|
| 204 | void *buffer, size_t size,
|
---|
| 205 | usb_handle_t *handle)
|
---|
| 206 | {
|
---|
[72363a1] | 207 | return ENOTSUP;
|
---|
[6c8ada21] | 208 | }
|
---|
| 209 |
|
---|
| 210 | /** Read data during control read transfer. */
|
---|
| 211 | int usb_drv_async_control_read_data(int phone, usb_target_t target,
|
---|
| 212 | void *buffer, size_t size, size_t *actual_size,
|
---|
| 213 | usb_handle_t *handle)
|
---|
| 214 | {
|
---|
[72363a1] | 215 | return ENOTSUP;
|
---|
[6c8ada21] | 216 | }
|
---|
| 217 |
|
---|
| 218 | /** Finalize control read transfer. */
|
---|
| 219 | int usb_drv_async_control_read_status(int phone, usb_target_t target,
|
---|
| 220 | usb_handle_t *handle)
|
---|
| 221 | {
|
---|
[72363a1] | 222 | return ENOTSUP;
|
---|
[6c8ada21] | 223 | }
|
---|
| 224 |
|
---|
[fe4dd14] | 225 | /** Issue whole control read transfer. */
|
---|
| 226 | int usb_drv_async_control_read(int phone, usb_target_t target,
|
---|
| 227 | void *setup_packet, size_t setup_packet_size,
|
---|
| 228 | void *buffer, size_t buffer_size, size_t *actual_size,
|
---|
| 229 | usb_handle_t *handle)
|
---|
| 230 | {
|
---|
[72363a1] | 231 | return ENOTSUP;
|
---|
[fe4dd14] | 232 | }
|
---|
| 233 |
|
---|
[c7137738] | 234 | /**
|
---|
| 235 | * @}
|
---|
| 236 | */
|
---|