blob: 273bb9645e30b114993b6bcf354054cf042e1e7b [file] [log] [blame]
Amol Jadif3d5a892013-07-23 16:09:44 -07001/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28#ifndef _USB30_UDC_H
29#define _USB30_UDC_H
30
31#include <bits.h>
32#include <usb30_dwc.h>
33#include <usb30_wrapper.h>
34
35#define UDC_DESC_SIZE_CONFIGURATION 9
36#define UDC_DESC_SIZE_INTERFACE 9
37#define UDC_DESC_SIZE_ENDPOINT 7
38#define UDC_DESC_SIZE_ENDPOINT_COMP 6
39
40typedef enum
41{
42 UDC_DESC_SPEC_20 = BIT(0),
43 UDC_DESC_SPEC_30 = BIT(1),
44} udc_desc_spec_t;
45
46typedef enum
47{
48 UDC_SPEED_LS,
49 UDC_SPEED_FS,
50 UDC_SPEED_HS,
51 UDC_SPEED_SS
52} udc_device_speed_t;
53
54typedef struct
55{
56 usb_wrapper_dev_t *wrapper_dev; /* store the wrapper device ptr */
57 dwc_dev_t *dwc; /* store the dwc device ptr */
58
59 struct udc_gadget *gadget; /* store the registered gadget. */
60 struct udc_descriptor *desc_list; /* linked list of all descriptors: device, config, string, language table, bos etc. */
61 struct udc_endpoint *ept_list; /* linked list of all eps */
62 uint32_t ept_alloc_table; /* keep track of which usb EPs are allocated. Initialized to assume EP0 In/OUT are already allocated.*/
63 uint32_t next_string_id; /* keeps track of string id for string descriptor */
64 void *ctrl_rx_buf; /* buffer pointer to receive ctrl data. */
65 void *ctrl_tx_buf; /* buffer pointer to send ctrl data. */
66
67
68 udc_device_speed_t speed; /* keeps track of usb connection speed. */
69 uint8_t config_selected; /* keeps track of the selected configuration */
70
71 struct udc_request *queued_req; /* pointer to the currently queued request. NULL indicates no request is queued. */
72
73} udc_t;
74
75
76struct udc_descriptor {
77 struct udc_descriptor *next;
78 uint16_t tag; /* ((TYPE << 8) | NUM) */
79 uint16_t len; /* total length */
80 udc_desc_spec_t spec; /* bit map of spec that this desc complies with. */
81 uint8_t data[0]; /* descriptor contents. */
82};
83
84struct udc_endpoint {
85 struct udc_endpoint *next;
86 uint8_t num;
87 uint8_t in;
88 uint16_t maxpkt;
89 uint32_t maxburst; /* max pkts that this ep can transfer before waiting for ack. */
90
91 dwc_trb_t *trb; /* pointer to buffer used for TRB chain */
92 uint32_t trb_count; /* size of TRB chain. */
93};
94
95#endif