| 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 libusb
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | * @brief USB driver (implementation).
|
|---|
| 34 | */
|
|---|
| 35 | #include <usb/usbdrv.h>
|
|---|
| 36 | #include <errno.h>
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 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 | {
|
|---|
| 47 | return ENOTSUP;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 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 | {
|
|---|
| 60 | return ENOTSUP;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | /** Connect to host controller the device is physically attached to.
|
|---|
| 64 | *
|
|---|
| 65 | * @param dev Device asking for connection.
|
|---|
| 66 | * @param flags Connection flags (blocking connection).
|
|---|
| 67 | * @return Phone to corresponding HC or error code.
|
|---|
| 68 | */
|
|---|
| 69 | int usb_drv_hc_connect_auto(device_t *dev, unsigned int flags)
|
|---|
| 70 | {
|
|---|
| 71 | return ENOTSUP;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 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 | {
|
|---|
| 82 | return ENOTSUP;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 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 | {
|
|---|
| 92 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 102 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 112 | return ENOTSUP;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 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 | {
|
|---|
| 125 | return ENOTSUP;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 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 | {
|
|---|
| 136 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 151 | return ENOTSUP;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | /** Send interrupt data to device. */
|
|---|
| 155 | int usb_drv_async_interrupt_out(int phone, usb_target_t target,
|
|---|
| 156 | void *buffer, size_t size,
|
|---|
| 157 | usb_handle_t *handle)
|
|---|
| 158 | {
|
|---|
| 159 | return ENOTSUP;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | /** Request interrupt data from device. */
|
|---|
| 163 | int usb_drv_async_interrupt_in(int phone, usb_target_t target,
|
|---|
| 164 | void *buffer, size_t size, size_t *actual_size,
|
|---|
| 165 | usb_handle_t *handle)
|
|---|
| 166 | {
|
|---|
| 167 | return ENOTSUP;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 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 | {
|
|---|
| 175 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 183 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 190 | return ENOTSUP;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 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 | {
|
|---|
| 199 | return ENOTSUP;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 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 | {
|
|---|
| 207 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 215 | return ENOTSUP;
|
|---|
| 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 | {
|
|---|
| 222 | return ENOTSUP;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 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 | {
|
|---|
| 231 | return ENOTSUP;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | /**
|
|---|
| 235 | * @}
|
|---|
| 236 | */
|
|---|