[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"
|
---|
| 33 |
|
---|
| 34 | static int get_address(device_t *dev, devman_handle_t handle,
|
---|
| 35 | usb_address_t *address)
|
---|
| 36 | {
|
---|
| 37 | return ENOTSUP;
|
---|
| 38 | }
|
---|
[3515533] | 39 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 40 | static int interrupt_out(device_t *dev, usb_target_t target,
|
---|
| 41 | void *data, size_t size,
|
---|
| 42 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 43 | {
|
---|
[d93ff502] | 44 | return uhci_transfer(dev, target, USB_TRANSFER_INTERRUPT, 0, USB_PID_OUT,
|
---|
| 45 | data, size, callback, NULL, arg);
|
---|
[4317827] | 46 | }
|
---|
[3515533] | 47 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 48 | static int interrupt_in(device_t *dev, usb_target_t target,
|
---|
| 49 | void *data, size_t size,
|
---|
| 50 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 51 | {
|
---|
[d93ff502] | 52 | return uhci_transfer(dev, target, USB_TRANSFER_INTERRUPT, 0, USB_PID_IN,
|
---|
| 53 | data, size, NULL, callback, arg);
|
---|
[4317827] | 54 | }
|
---|
[3515533] | 55 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 56 | static int control_write_setup(device_t *dev, usb_target_t target,
|
---|
| 57 | void *data, size_t size,
|
---|
| 58 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 59 | {
|
---|
[d93ff502] | 60 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 0, USB_PID_SETUP,
|
---|
| 61 | data, size, callback, NULL, arg);
|
---|
[4317827] | 62 | }
|
---|
[3515533] | 63 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 64 | static int control_write_data(device_t *dev, usb_target_t target,
|
---|
| 65 | void *data, size_t size,
|
---|
| 66 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 67 | {
|
---|
[d93ff502] | 68 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 1, USB_PID_OUT,
|
---|
| 69 | data, size, callback, NULL, arg);
|
---|
[4317827] | 70 | }
|
---|
[3515533] | 71 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 72 | static int control_write_status(device_t *dev, usb_target_t target,
|
---|
| 73 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 74 | {
|
---|
[d93ff502] | 75 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 0, USB_PID_IN,
|
---|
| 76 | NULL, 0, NULL, callback, arg);
|
---|
[4317827] | 77 | }
|
---|
[3515533] | 78 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 79 | static int control_read_setup(device_t *dev, usb_target_t target,
|
---|
| 80 | void *data, size_t size,
|
---|
| 81 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 82 | {
|
---|
[d93ff502] | 83 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 0, USB_PID_SETUP,
|
---|
| 84 | data, size, callback, NULL, arg);
|
---|
[4317827] | 85 | }
|
---|
[3515533] | 86 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 87 | static int control_read_data(device_t *dev, usb_target_t target,
|
---|
| 88 | void *data, size_t size,
|
---|
| 89 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
| 90 | {
|
---|
[d93ff502] | 91 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 1, USB_PID_IN,
|
---|
| 92 | data, size, NULL, callback, arg);
|
---|
[4317827] | 93 | }
|
---|
[3515533] | 94 | /*----------------------------------------------------------------------------*/
|
---|
[4317827] | 95 | static int control_read_status(device_t *dev, usb_target_t target,
|
---|
| 96 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
| 97 | {
|
---|
[d93ff502] | 98 | return uhci_transfer(dev, target, USB_TRANSFER_CONTROL, 0, USB_PID_OUT,
|
---|
| 99 | NULL, 0, callback, NULL, arg);
|
---|
[4317827] | 100 | }
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | usbhc_iface_t uhci_iface = {
|
---|
| 104 | .tell_address = get_address,
|
---|
[3515533] | 105 |
|
---|
| 106 | .reserve_default_address = NULL,
|
---|
| 107 | .release_default_address = NULL,
|
---|
| 108 | .request_address = NULL,
|
---|
| 109 | .bind_address = NULL,
|
---|
| 110 | .release_address = NULL,
|
---|
| 111 |
|
---|
[4317827] | 112 | .interrupt_out = interrupt_out,
|
---|
| 113 | .interrupt_in = interrupt_in,
|
---|
[3515533] | 114 |
|
---|
[4317827] | 115 | .control_write_setup = control_write_setup,
|
---|
| 116 | .control_write_data = control_write_data,
|
---|
| 117 | .control_write_status = control_write_status,
|
---|
[3515533] | 118 |
|
---|
[4317827] | 119 | .control_read_setup = control_read_setup,
|
---|
| 120 | .control_read_data = control_read_data,
|
---|
| 121 | .control_read_status = control_read_status
|
---|
| 122 | };
|
---|