blob: 014383af1a7b4da4aa620fcae80928bd3fe64140 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2015 Brian Swetland
3 * Copyright (c) 2008 Google, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files
7 * (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef __PRIVATE_UDC_H__
26#define __PRIVATE_UDC_H__
27
28#define GET_STATUS 0
29#define CLEAR_FEATURE 1
30#define SET_FEATURE 3
31#define SET_ADDRESS 5
32#define GET_DESCRIPTOR 6
33#define SET_DESCRIPTOR 7
34#define GET_CONFIGURATION 8
35#define SET_CONFIGURATION 9
36#define GET_INTERFACE 10
37#define SET_INTERFACE 11
38#define SYNCH_FRAME 12
39#define SET_SEL 48
40
41#define TYPE_DEVICE 1
42#define TYPE_CONFIGURATION 2
43#define TYPE_STRING 3
44#define TYPE_INTERFACE 4
45#define TYPE_ENDPOINT 5
46#define TYPE_BOS 15
47#define TYPE_DEVICE_CAP 16
48#define TYPE_SS_EP_COMP 48
49
50#define DEVICE_READ 0x80
51#define DEVICE_WRITE 0x00
52#define INTERFACE_READ 0x81
53#define INTERFACE_WRITE 0x01
54#define ENDPOINT_READ 0x82
55#define ENDPOINT_WRITE 0x02
56
57typedef struct udc_descriptor udc_descriptor_t;
58
59union setup_packet {
60 struct {
61 uint8_t type;
62 uint8_t request;
63 uint16_t value;
64 uint16_t index;
65 uint16_t length;
66 };
67 struct {
68 uint32_t w0;
69 uint32_t w1;
70 };
71} __attribute__ ((packed));
72
73struct udc_descriptor {
74 udc_descriptor_t *next;
75 uint16_t tag; /* ((TYPE << 8) | NUM) */
76 uint16_t len; /* total length */
77 uint8_t data[4];
78};
79
80// driver calls this to build descriptors from device and gadgets
81void udc_create_descriptors(udc_device_t *device, udc_gadget_t *gadget);
82
83// driver uses this to obtain descriptors
84udc_descriptor_t *udc_descriptor_find(unsigned tag);
85
86// driver provides this
87void udc_ept_desc_fill(udc_endpoint_t *ept, unsigned char *data);
88
89#endif