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