[4317827] | 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 | #include <usb/hcdhubd.h>
|
---|
| 29 | #include <errno.h>
|
---|
| 30 |
|
---|
[3515533] | 31 | #include "iface.h"
|
---|
[4317827] | 32 | #include "uhci.h"
|
---|
[3515533] | 33 | /*
|
---|
[4317827] | 34 | static int enqueue_transfer_out(device_t *dev,
|
---|
| 35 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
| 36 | void *buffer, size_t size,
|
---|
| 37 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 38 | {
|
---|
[b9eb93f] | 39 | printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
|
---|
[4317827] | 40 | target.address, target.endpoint,
|
---|
| 41 | usb_str_transfer_type(transfer_type),
|
---|
| 42 | size);
|
---|
| 43 |
|
---|
| 44 | return ENOTSUP;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | static int enqueue_transfer_setup(device_t *dev,
|
---|
| 48 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
| 49 | void *buffer, size_t size,
|
---|
| 50 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 51 | {
|
---|
[b9eb93f] | 52 | printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
|
---|
[4317827] | 53 | target.address, target.endpoint,
|
---|
| 54 | usb_str_transfer_type(transfer_type),
|
---|
| 55 | size);
|
---|
| 56 |
|
---|
| 57 | return ENOTSUP;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | static int enqueue_transfer_in(device_t *dev,
|
---|
| 61 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
| 62 | void *buffer, size_t size,
|
---|
| 63 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 64 | {
|
---|
[b9eb93f] | 65 | printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
|
---|
[4317827] | 66 | target.address, target.endpoint,
|
---|
| 67 | usb_str_transfer_type(transfer_type),
|
---|
| 68 | size);
|
---|
| 69 |
|
---|
| 70 | return ENOTSUP;
|
---|
| 71 | }
|
---|
[3515533] | 72 | */
|
---|
[4317827] | 73 |
|
---|
| 74 | static int get_address(device_t *dev, devman_handle_t handle,
|
---|
| 75 | usb_address_t *address)
|
---|
| 76 | {
|
---|
| 77 | return ENOTSUP;
|
---|
| 78 | }
|
---|
[3515533] | 79 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 80 | static int interrupt_out(device_t *dev, usb_target_t target,
|
---|
| 81 | void *data, size_t size,
|
---|
| 82 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 83 | {
|
---|
[3515533] | 84 | return uhci_out(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
| 85 | data, size, callback, arg);
|
---|
[4317827] | 86 | }
|
---|
[3515533] | 87 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 88 | static int interrupt_in(device_t *dev, usb_target_t target,
|
---|
| 89 | void *data, size_t size,
|
---|
| 90 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 91 | {
|
---|
[3515533] | 92 | return uhci_in(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
| 93 | data, size, callback, arg);
|
---|
[4317827] | 94 | }
|
---|
[3515533] | 95 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 96 | static int control_write_setup(device_t *dev, usb_target_t target,
|
---|
| 97 | void *data, size_t size,
|
---|
| 98 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 99 | {
|
---|
[3515533] | 100 | return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 101 | data, size, callback, arg);
|
---|
[4317827] | 102 | }
|
---|
[3515533] | 103 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 104 | static int control_write_data(device_t *dev, usb_target_t target,
|
---|
| 105 | void *data, size_t size,
|
---|
| 106 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 107 | {
|
---|
[3515533] | 108 | return uhci_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 109 | data, size, callback, arg);
|
---|
[4317827] | 110 | }
|
---|
[3515533] | 111 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 112 | static int control_write_status(device_t *dev, usb_target_t target,
|
---|
| 113 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 114 | {
|
---|
[3515533] | 115 | return uhci_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 116 | NULL, 0, callback, arg);
|
---|
[4317827] | 117 | }
|
---|
[3515533] | 118 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 119 | static int control_read_setup(device_t *dev, usb_target_t target,
|
---|
| 120 | void *data, size_t size,
|
---|
| 121 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 122 | {
|
---|
[3515533] | 123 | return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 124 | data, size, callback, arg);
|
---|
[4317827] | 125 | }
|
---|
[3515533] | 126 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 127 | static int control_read_data(device_t *dev, usb_target_t target,
|
---|
| 128 | void *data, size_t size,
|
---|
| 129 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 130 | {
|
---|
[3515533] | 131 | return uhci_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 132 | data, size, callback, arg);
|
---|
[4317827] | 133 | }
|
---|
[3515533] | 134 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 135 | static int control_read_status(device_t *dev, usb_target_t target,
|
---|
| 136 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 137 | {
|
---|
[3515533] | 138 | return uhci_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
| 139 | NULL, 0, callback, arg);
|
---|
[4317827] | 140 | }
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | usbhc_iface_t uhci_iface = {
|
---|
| 144 | .tell_address = get_address,
|
---|
[3515533] | 145 |
|
---|
| 146 | .reserve_default_address = NULL,
|
---|
| 147 | .release_default_address = NULL,
|
---|
| 148 | .request_address = NULL,
|
---|
| 149 | .bind_address = NULL,
|
---|
| 150 | .release_address = NULL,
|
---|
| 151 |
|
---|
[4317827] | 152 | .interrupt_out = interrupt_out,
|
---|
| 153 | .interrupt_in = interrupt_in,
|
---|
[3515533] | 154 |
|
---|
[4317827] | 155 | .control_write_setup = control_write_setup,
|
---|
| 156 | .control_write_data = control_write_data,
|
---|
| 157 | .control_write_status = control_write_status,
|
---|
[3515533] | 158 |
|
---|
[4317827] | 159 | .control_read_setup = control_read_setup,
|
---|
| 160 | .control_read_data = control_read_data,
|
---|
| 161 | .control_read_status = control_read_status
|
---|
| 162 | };
|
---|