OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [linux-headers/] [include/] [linux/] [usb/] [functionfs.h] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
#ifndef __LINUX_FUNCTIONFS_H__
2
#define __LINUX_FUNCTIONFS_H__
3
 
4
 
5
#include <linux/types.h>
6
#include <linux/ioctl.h>
7
 
8
#include <linux/usb/ch9.h>
9
 
10
 
11
enum {
12
        FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13
        FUNCTIONFS_STRINGS_MAGIC     = 2
14
};
15
 
16
 
17
 
18
/* Descriptor of an non-audio endpoint */
19
struct usb_endpoint_descriptor_no_audio {
20
        __u8  bLength;
21
        __u8  bDescriptorType;
22
 
23
        __u8  bEndpointAddress;
24
        __u8  bmAttributes;
25
        __le16 wMaxPacketSize;
26
        __u8  bInterval;
27
} __attribute__((packed));
28
 
29
 
30
/*
31
 * All numbers must be in little endian order.
32
 */
33
 
34
/* Legacy format, deprecated as of 3.14. */
35
struct usb_functionfs_descs_head {
36
        __le32 magic;
37
        __le32 length;
38
        __le32 fs_count;
39
        __le32 hs_count;
40
} __attribute__((packed, deprecated));
41
 
42
/*
43
 * Descriptors format:
44
 *
45
 * | off | name      | type         | description                          |
46
 * |-----+-----------+--------------+--------------------------------------|
47
 * |   0 | magic     | LE32         | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48
 * |   4 | length    | LE32         | length of the whole data chunk       |
49
 * |   8 | fs_count  | LE32         | number of full-speed descriptors     |
50
 * |  12 | hs_count  | LE32         | number of high-speed descriptors     |
51
 * |  16 | fs_descrs | Descriptor[] | list of full-speed descriptors       |
52
 * |     | hs_descrs | Descriptor[] | list of high-speed descriptors       |
53
 *
54
 * descs are just valid USB descriptors and have the following format:
55
 *
56
 * | off | name            | type | description              |
57
 * |-----+-----------------+------+--------------------------|
58
 * |   0 | bLength         | U8   | length of the descriptor |
59
 * |   1 | bDescriptorType | U8   | descriptor type          |
60
 * |   2 | payload         |      | descriptor's payload     |
61
 */
62
 
63
struct usb_functionfs_strings_head {
64
        __le32 magic;
65
        __le32 length;
66
        __le32 str_count;
67
        __le32 lang_count;
68
} __attribute__((packed));
69
 
70
/*
71
 * Strings format:
72
 *
73
 * | off | name       | type                  | description                |
74
 * |-----+------------+-----------------------+----------------------------|
75
 * |   0 | magic      | LE32                  | FUNCTIONFS_STRINGS_MAGIC   |
76
 * |   4 | length     | LE32                  | length of the data chunk   |
77
 * |   8 | str_count  | LE32                  | number of strings          |
78
 * |  12 | lang_count | LE32                  | number of languages        |
79
 * |  16 | stringtab  | StringTab[lang_count] | table of strings per lang  |
80
 *
81
 * For each language there is one stringtab entry (ie. there are lang_count
82
 * stringtab entires).  Each StringTab has following format:
83
 *
84
 * | off | name    | type              | description                        |
85
 * |-----+---------+-------------------+------------------------------------|
86
 * |   0 | lang    | LE16              | language code                      |
87
 * |   2 | strings | String[str_count] | array of strings in given language |
88
 *
89
 * For each string there is one strings entry (ie. there are str_count
90
 * string entries).  Each String is a NUL terminated string encoded in
91
 * UTF-8.
92
 */
93
 
94
 
95
 
96
/*
97
 * Events are delivered on the ep0 file descriptor, when the user mode driver
98
 * reads from this file descriptor after writing the descriptors.  Don't
99
 * stop polling this descriptor.
100
 */
101
 
102
enum usb_functionfs_event_type {
103
        FUNCTIONFS_BIND,
104
        FUNCTIONFS_UNBIND,
105
 
106
        FUNCTIONFS_ENABLE,
107
        FUNCTIONFS_DISABLE,
108
 
109
        FUNCTIONFS_SETUP,
110
 
111
        FUNCTIONFS_SUSPEND,
112
        FUNCTIONFS_RESUME
113
};
114
 
115
/* NOTE:  this structure must stay the same size and layout on
116
 * both 32-bit and 64-bit kernels.
117
 */
118
struct usb_functionfs_event {
119
        union {
120
                /* SETUP: packet; DATA phase i/o precedes next event
121
                 *(setup.bmRequestType & USB_DIR_IN) flags direction */
122
                struct usb_ctrlrequest  setup;
123
        } __attribute__((packed)) u;
124
 
125
        /* enum usb_functionfs_event_type */
126
        __u8                            type;
127
        __u8                            _pad[3];
128
} __attribute__((packed));
129
 
130
 
131
/* Endpoint ioctls */
132
/* The same as in gadgetfs */
133
 
134
/* IN transfers may be reported to the gadget driver as complete
135
 *      when the fifo is loaded, before the host reads the data;
136
 * OUT transfers may be reported to the host's "client" driver as
137
 *      complete when they're sitting in the FIFO unread.
138
 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
139
 * (needed for precise fault handling, when the hardware allows it)
140
 */
141
#define FUNCTIONFS_FIFO_STATUS  _IO('g', 1)
142
 
143
/* discards any unclaimed data in the fifo. */
144
#define FUNCTIONFS_FIFO_FLUSH   _IO('g', 2)
145
 
146
/* resets endpoint halt+toggle; used to implement set_interface.
147
 * some hardware (like pxa2xx) can't support this.
148
 */
149
#define FUNCTIONFS_CLEAR_HALT   _IO('g', 3)
150
 
151
/* Specific for functionfs */
152
 
153
/*
154
 * Returns reverse mapping of an interface.  Called on EP0.  If there
155
 * is no such interface returns -EDOM.  If function is not active
156
 * returns -ENODEV.
157
 */
158
#define FUNCTIONFS_INTERFACE_REVMAP     _IO('g', 128)
159
 
160
/*
161
 * Returns real bEndpointAddress of an endpoint.  If function is not
162
 * active returns -ENODEV.
163
 */
164
#define FUNCTIONFS_ENDPOINT_REVMAP      _IO('g', 129)
165
 
166
 
167
 
168
#endif /* __LINUX_FUNCTIONFS_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.