[f51594fa] | 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) \
|
---|
[c4fb5ecd] | 47 | usb_log_debug("Client called unsupported interface method " \
|
---|
| 48 | "`%s()' in %s:%d.\n", \
|
---|
[f51594fa] | 49 | methodname, __FILE__, __LINE__)
|
---|
| 50 |
|
---|
[a763eb4] | 51 | /** Found free USB address.
|
---|
| 52 | *
|
---|
| 53 | * @param[in] fun Device function the action was invoked on.
|
---|
| 54 | * @param[in] speed Speed of the device that will get this address.
|
---|
| 55 | * @param[out] address Non-null pointer where to store the free address.
|
---|
| 56 | * @return Error code.
|
---|
| 57 | */
|
---|
[67f55e7b] | 58 | static int request_address(ddf_fun_t *fun, usb_address_t *address, bool strict,
|
---|
| 59 | usb_speed_t speed)
|
---|
[f51594fa] | 60 | {
|
---|
| 61 | UNSUPPORTED("request_address");
|
---|
| 62 |
|
---|
| 63 | return ENOTSUP;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[a763eb4] | 66 | /** Bind USB address with device devman handle.
|
---|
| 67 | *
|
---|
| 68 | * @param[in] fun Device function the action was invoked on.
|
---|
| 69 | * @param[in] address USB address of the device.
|
---|
| 70 | * @param[in] handle Devman handle of the device.
|
---|
| 71 | * @return Error code.
|
---|
| 72 | */
|
---|
| 73 | static int bind_address(ddf_fun_t *fun,
|
---|
| 74 | usb_address_t address, devman_handle_t handle)
|
---|
[f51594fa] | 75 | {
|
---|
| 76 | UNSUPPORTED("bind_address");
|
---|
| 77 |
|
---|
| 78 | return ENOTSUP;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[df25ab6] | 81 | /** Find device handle by USB address.
|
---|
| 82 | *
|
---|
| 83 | * @param[in] fun DDF function that was called.
|
---|
| 84 | * @param[in] address Address in question.
|
---|
| 85 | * @param[out] handle Where to store device handle if found.
|
---|
| 86 | * @return Error code.
|
---|
| 87 | */
|
---|
| 88 | static int find_by_address(ddf_fun_t *fun, usb_address_t address,
|
---|
| 89 | devman_handle_t *handle)
|
---|
| 90 | {
|
---|
| 91 | UNSUPPORTED("find_by_address");
|
---|
| 92 |
|
---|
| 93 | return ENOTSUP;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[a763eb4] | 96 | /** Release previously requested address.
|
---|
| 97 | *
|
---|
| 98 | * @param[in] fun Device function the action was invoked on.
|
---|
| 99 | * @param[in] address USB address to be released.
|
---|
| 100 | * @return Error code.
|
---|
| 101 | */
|
---|
[f51594fa] | 102 | static int release_address(ddf_fun_t *fun, usb_address_t address)
|
---|
| 103 | {
|
---|
| 104 | UNSUPPORTED("release_address");
|
---|
| 105 |
|
---|
| 106 | return ENOTSUP;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[a763eb4] | 109 | /** Register endpoint for bandwidth reservation.
|
---|
| 110 | *
|
---|
| 111 | * @param[in] fun Device function the action was invoked on.
|
---|
| 112 | * @param[in] address USB address of the device.
|
---|
[1998bcd] | 113 | * @param[in] speed Endpoint speed (invalid means to use device one).
|
---|
[a763eb4] | 114 | * @param[in] endpoint Endpoint number.
|
---|
| 115 | * @param[in] transfer_type USB transfer type.
|
---|
| 116 | * @param[in] direction Endpoint data direction.
|
---|
| 117 | * @param[in] max_packet_size Max packet size of the endpoint.
|
---|
| 118 | * @param[in] interval Polling interval.
|
---|
| 119 | * @return Error code.
|
---|
| 120 | */
|
---|
| 121 | static int register_endpoint(ddf_fun_t *fun,
|
---|
[27736cf] | 122 | usb_address_t address, usb_endpoint_t endpoint,
|
---|
[f51594fa] | 123 | usb_transfer_type_t transfer_type, usb_direction_t direction,
|
---|
| 124 | size_t max_packet_size, unsigned int interval)
|
---|
| 125 | {
|
---|
| 126 | UNSUPPORTED("register_endpoint");
|
---|
| 127 |
|
---|
| 128 | return ENOTSUP;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[a763eb4] | 131 | /** Unregister endpoint (free some bandwidth reservation).
|
---|
| 132 | *
|
---|
| 133 | * @param[in] fun Device function the action was invoked on.
|
---|
| 134 | * @param[in] address USB address of the device.
|
---|
| 135 | * @param[in] endpoint Endpoint number.
|
---|
| 136 | * @param[in] direction Endpoint data direction.
|
---|
| 137 | * @return Error code.
|
---|
| 138 | */
|
---|
| 139 | static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
|
---|
| 140 | usb_endpoint_t endpoint, usb_direction_t direction)
|
---|
[f51594fa] | 141 | {
|
---|
| 142 | UNSUPPORTED("unregister_endpoint");
|
---|
| 143 |
|
---|
| 144 | return ENOTSUP;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
[a763eb4] | 147 | /** Host controller interface implementation for EHCI. */
|
---|
[f51594fa] | 148 | usbhc_iface_t ehci_hc_iface = {
|
---|
| 149 | .request_address = request_address,
|
---|
| 150 | .bind_address = bind_address,
|
---|
[df25ab6] | 151 | .find_by_address = find_by_address,
|
---|
[f51594fa] | 152 | .release_address = release_address,
|
---|
| 153 |
|
---|
| 154 | .register_endpoint = register_endpoint,
|
---|
| 155 | .unregister_endpoint = unregister_endpoint,
|
---|
| 156 | };
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * @}
|
---|
| 160 | */
|
---|