[8a81e431] | 1 | /*
|
---|
| 2 | * Copyright (c) 2014 Jan Vesely
|
---|
[e0a5d4c] | 3 | * Copyright (c) 2018 Ondrej Hlavaty
|
---|
[8a81e431] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 | /** @addtogroup drvusbehci
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief EHCI driver USB transaction structure
|
---|
| 34 | */
|
---|
| 35 | #ifndef DRV_EHCI_BATCH_H
|
---|
| 36 | #define DRV_EHCI_BATCH_H
|
---|
| 37 |
|
---|
| 38 | #include <adt/list.h>
|
---|
| 39 | #include <assert.h>
|
---|
| 40 | #include <stdbool.h>
|
---|
| 41 | #include <usb/host/usb_transfer_batch.h>
|
---|
[3b60ea0] | 42 | #include <usb/dma_buffer.h>
|
---|
[8a81e431] | 43 |
|
---|
| 44 | #include "hw_struct/queue_head.h"
|
---|
| 45 | #include "hw_struct/transfer_descriptor.h"
|
---|
| 46 |
|
---|
| 47 | /** EHCI specific data required for USB transfer */
|
---|
| 48 | typedef struct ehci_transfer_batch {
|
---|
[5fd9c30] | 49 | usb_transfer_batch_t base;
|
---|
[35c37fc] | 50 | /** Number of TDs used by the transfer */
|
---|
| 51 | size_t td_count;
|
---|
[8a81e431] | 52 | /** Endpoint descriptor of the target endpoint. */
|
---|
| 53 | qh_t *qh;
|
---|
[c21e6a5] | 54 | /** Backend for TDs and setup data. */
|
---|
| 55 | dma_buffer_t ehci_dma_buffer;
|
---|
[35c37fc] | 56 | /** List of TDs needed for the transfer - backed by dma_buffer */
|
---|
| 57 | td_t *tds;
|
---|
| 58 | /** Data buffers - backed by dma_buffer */
|
---|
| 59 | void *setup_buffer;
|
---|
| 60 | void *data_buffer;
|
---|
[8a81e431] | 61 | /** Generic USB transfer structure */
|
---|
| 62 | usb_transfer_batch_t *usb_batch;
|
---|
| 63 | } ehci_transfer_batch_t;
|
---|
| 64 |
|
---|
[ae3a941] | 65 | ehci_transfer_batch_t *ehci_transfer_batch_create(endpoint_t *ep);
|
---|
[5fd9c30] | 66 | int ehci_transfer_batch_prepare(ehci_transfer_batch_t *batch);
|
---|
[8a81e431] | 67 | void ehci_transfer_batch_commit(const ehci_transfer_batch_t *batch);
|
---|
[5fd9c30] | 68 | bool ehci_transfer_batch_check_completed(ehci_transfer_batch_t *batch);
|
---|
| 69 | void ehci_transfer_batch_destroy(ehci_transfer_batch_t *batch);
|
---|
[8a81e431] | 70 |
|
---|
[ae3a941] | 71 | static inline ehci_transfer_batch_t *ehci_transfer_batch_get(
|
---|
| 72 | usb_transfer_batch_t *usb_batch)
|
---|
[5fd9c30] | 73 | {
|
---|
| 74 | assert(usb_batch);
|
---|
| 75 |
|
---|
| 76 | return (ehci_transfer_batch_t *) usb_batch;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[8a81e431] | 79 | #endif
|
---|
| 80 | /**
|
---|
| 81 | * @}
|
---|
| 82 | */
|
---|
| 83 |
|
---|