aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/gadget.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb/gadget.h')
-rw-r--r--include/linux/usb/gadget.h88
1 files changed, 73 insertions, 15 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index dd1571db55e7..087f4b931833 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -15,7 +15,13 @@
15#ifndef __LINUX_USB_GADGET_H 15#ifndef __LINUX_USB_GADGET_H
16#define __LINUX_USB_GADGET_H 16#define __LINUX_USB_GADGET_H
17 17
18#include <linux/device.h>
19#include <linux/errno.h>
20#include <linux/init.h>
21#include <linux/list.h>
18#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/types.h>
24#include <linux/usb/ch9.h>
19 25
20struct usb_ep; 26struct usb_ep;
21 27
@@ -27,6 +33,7 @@ struct usb_ep;
27 * field, and the usb controller needs one, it is responsible 33 * field, and the usb controller needs one, it is responsible
28 * for mapping and unmapping the buffer. 34 * for mapping and unmapping the buffer.
29 * @length: Length of that data 35 * @length: Length of that data
36 * @stream_id: The stream id, when USB3.0 bulk streams are being used
30 * @no_interrupt: If true, hints that no completion irq is needed. 37 * @no_interrupt: If true, hints that no completion irq is needed.
31 * Helpful sometimes with deep request queues that are handled 38 * Helpful sometimes with deep request queues that are handled
32 * directly by DMA controllers. 39 * directly by DMA controllers.
@@ -81,6 +88,7 @@ struct usb_request {
81 unsigned length; 88 unsigned length;
82 dma_addr_t dma; 89 dma_addr_t dma;
83 90
91 unsigned stream_id:16;
84 unsigned no_interrupt:1; 92 unsigned no_interrupt:1;
85 unsigned zero:1; 93 unsigned zero:1;
86 unsigned short_not_ok:1; 94 unsigned short_not_ok:1;
@@ -131,8 +139,17 @@ struct usb_ep_ops {
131 * @maxpacket:The maximum packet size used on this endpoint. The initial 139 * @maxpacket:The maximum packet size used on this endpoint. The initial
132 * value can sometimes be reduced (hardware allowing), according to 140 * value can sometimes be reduced (hardware allowing), according to
133 * the endpoint descriptor used to configure the endpoint. 141 * the endpoint descriptor used to configure the endpoint.
134 * @driver_data:for use by the gadget driver. all other fields are 142 * @max_streams: The maximum number of streams supported
135 * read-only to gadget drivers. 143 * by this EP (0 - 16, actual number is 2^n)
144 * @mult: multiplier, 'mult' value for SS Isoc EPs
145 * @maxburst: the maximum number of bursts supported by this EP (for usb3)
146 * @driver_data:for use by the gadget driver.
147 * @address: used to identify the endpoint when finding descriptor that
148 * matches connection speed
149 * @desc: endpoint descriptor. This pointer is set before the endpoint is
150 * enabled and remains valid until the endpoint is disabled.
151 * @comp_desc: In case of SuperSpeed support, this is the endpoint companion
152 * descriptor that is used to configure the endpoint
136 * 153 *
137 * the bus controller driver lists all the general purpose endpoints in 154 * the bus controller driver lists all the general purpose endpoints in
138 * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list, 155 * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
@@ -145,6 +162,12 @@ struct usb_ep {
145 const struct usb_ep_ops *ops; 162 const struct usb_ep_ops *ops;
146 struct list_head ep_list; 163 struct list_head ep_list;
147 unsigned maxpacket:16; 164 unsigned maxpacket:16;
165 unsigned max_streams:16;
166 unsigned mult:2;
167 unsigned maxburst:4;
168 u8 address;
169 const struct usb_endpoint_descriptor *desc;
170 const struct usb_ss_ep_comp_descriptor *comp_desc;
148}; 171};
149 172
150/*-------------------------------------------------------------------------*/ 173/*-------------------------------------------------------------------------*/
@@ -153,11 +176,8 @@ struct usb_ep {
153 * usb_ep_enable - configure endpoint, making it usable 176 * usb_ep_enable - configure endpoint, making it usable
154 * @ep:the endpoint being configured. may not be the endpoint named "ep0". 177 * @ep:the endpoint being configured. may not be the endpoint named "ep0".
155 * drivers discover endpoints through the ep_list of a usb_gadget. 178 * drivers discover endpoints through the ep_list of a usb_gadget.
156 * @desc:descriptor for desired behavior. caller guarantees this pointer
157 * remains valid until the endpoint is disabled; the data byte order
158 * is little-endian (usb-standard).
159 * 179 *
160 * when configurations are set, or when interface settings change, the driver 180 * When configurations are set, or when interface settings change, the driver
161 * will enable or disable the relevant endpoints. while it is enabled, an 181 * will enable or disable the relevant endpoints. while it is enabled, an
162 * endpoint may be used for i/o until the driver receives a disconnect() from 182 * endpoint may be used for i/o until the driver receives a disconnect() from
163 * the host or until the endpoint is disabled. 183 * the host or until the endpoint is disabled.
@@ -172,10 +192,9 @@ struct usb_ep {
172 * 192 *
173 * returns zero, or a negative error code. 193 * returns zero, or a negative error code.
174 */ 194 */
175static inline int usb_ep_enable(struct usb_ep *ep, 195static inline int usb_ep_enable(struct usb_ep *ep)
176 const struct usb_endpoint_descriptor *desc)
177{ 196{
178 return ep->ops->enable(ep, desc); 197 return ep->ops->enable(ep, ep->desc);
179} 198}
180 199
181/** 200/**
@@ -416,7 +435,16 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)
416 435
417/*-------------------------------------------------------------------------*/ 436/*-------------------------------------------------------------------------*/
418 437
438struct usb_dcd_config_params {
439 __u8 bU1devExitLat; /* U1 Device exit Latency */
440#define USB_DEFULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */
441 __le16 bU2DevExitLat; /* U2 Device exit Latency */
442#define USB_DEFULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */
443};
444
445
419struct usb_gadget; 446struct usb_gadget;
447struct usb_gadget_driver;
420 448
421/* the rest of the api to the controller hardware: device operations, 449/* the rest of the api to the controller hardware: device operations,
422 * which don't involve endpoints (or i/o). 450 * which don't involve endpoints (or i/o).
@@ -430,6 +458,16 @@ struct usb_gadget_ops {
430 int (*pullup) (struct usb_gadget *, int is_on); 458 int (*pullup) (struct usb_gadget *, int is_on);
431 int (*ioctl)(struct usb_gadget *, 459 int (*ioctl)(struct usb_gadget *,
432 unsigned code, unsigned long param); 460 unsigned code, unsigned long param);
461 void (*get_config_params)(struct usb_dcd_config_params *);
462 int (*udc_start)(struct usb_gadget *,
463 struct usb_gadget_driver *);
464 int (*udc_stop)(struct usb_gadget *,
465 struct usb_gadget_driver *);
466
467 /* Those two are deprecated */
468 int (*start)(struct usb_gadget_driver *,
469 int (*bind)(struct usb_gadget *));
470 int (*stop)(struct usb_gadget_driver *);
433}; 471};
434 472
435/** 473/**
@@ -521,6 +559,24 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g)
521} 559}
522 560
523/** 561/**
562 * gadget_is_superspeed() - return true if the hardware handles
563 * supperspeed
564 * @g: controller that might support supper speed
565 */
566static inline int gadget_is_superspeed(struct usb_gadget *g)
567{
568#ifdef CONFIG_USB_GADGET_SUPERSPEED
569 /*
570 * runtime test would check "g->is_superspeed" ... that might be
571 * useful to work around hardware bugs, but is mostly pointless
572 */
573 return 1;
574#else
575 return 0;
576#endif
577}
578
579/**
524 * gadget_is_otg - return true iff the hardware is OTG-ready 580 * gadget_is_otg - return true iff the hardware is OTG-ready
525 * @g: controller that might have a Mini-AB connector 581 * @g: controller that might have a Mini-AB connector
526 * 582 *
@@ -821,6 +877,9 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
821 */ 877 */
822int usb_gadget_unregister_driver(struct usb_gadget_driver *driver); 878int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
823 879
880extern int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget);
881extern void usb_del_gadget_udc(struct usb_gadget *gadget);
882
824/*-------------------------------------------------------------------------*/ 883/*-------------------------------------------------------------------------*/
825 884
826/* utility to simplify dealing with string descriptors */ 885/* utility to simplify dealing with string descriptors */
@@ -870,12 +929,6 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
870struct usb_descriptor_header **usb_copy_descriptors( 929struct usb_descriptor_header **usb_copy_descriptors(
871 struct usb_descriptor_header **); 930 struct usb_descriptor_header **);
872 931
873/* return copy of endpoint descriptor given original descriptor set */
874struct usb_endpoint_descriptor *usb_find_endpoint(
875 struct usb_descriptor_header **src,
876 struct usb_descriptor_header **copy,
877 struct usb_endpoint_descriptor *match);
878
879/** 932/**
880 * usb_free_descriptors - free descriptors returned by usb_copy_descriptors() 933 * usb_free_descriptors - free descriptors returned by usb_copy_descriptors()
881 * @v: vector of descriptors 934 * @v: vector of descriptors
@@ -892,6 +945,11 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v)
892extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, 945extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
893 struct usb_endpoint_descriptor *); 946 struct usb_endpoint_descriptor *);
894 947
948
949extern struct usb_ep *usb_ep_autoconfig_ss(struct usb_gadget *,
950 struct usb_endpoint_descriptor *,
951 struct usb_ss_ep_comp_descriptor *);
952
895extern void usb_ep_autoconfig_reset(struct usb_gadget *); 953extern void usb_ep_autoconfig_reset(struct usb_gadget *);
896 954
897#endif /* __LINUX_USB_GADGET_H */ 955#endif /* __LINUX_USB_GADGET_H */