aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-14 19:41:11 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-14 19:41:11 -0400
commita3fbedf98fe9909cb2e406e2018ec437d64806f6 (patch)
tree701e2060053a2e9ac3052d6aec8a5334061fa123 /include/linux/usb
parente6bbe1d05353a29628a4ca72d88bac0bdcec5f38 (diff)
parent2f3cc24f07b8bfe8302a46ceb1ed58cde62cbd09 (diff)
Merge tag 'usb-for-v4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
Felipe writes: usb: patches for v4.3 merge window New support for Allwinne SoC on the MUSB driver has been added to the list of glue layers. MUSB also got support for building all DMA engines in one binary; this will be great for distros. DWC3 now has no trace of dev_dbg()/dev_vdbg() usage. We will rely solely on tracing to debug DWC3. There was also a fix for memory corruption with EP0 when maxpacket size transfers are > 512 bytes. Robert's EP capabilities flags is making EP selection a lot simpler. UDCs are now required to set these flags up when adding endpoints to the framework. Other than these, we have the usual set of miscelaneous cleanups and minor fixes. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/chipidea.h1
-rw-r--r--include/linux/usb/composite.h2
-rw-r--r--include/linux/usb/gadget.h198
-rw-r--r--include/linux/usb/msm_hsusb.h9
-rw-r--r--include/linux/usb/of.h7
-rw-r--r--include/linux/usb/otg.h15
6 files changed, 224 insertions, 8 deletions
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ab94f78c4dd1..e10cefc721ad 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {
34#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 34#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
35 void (*notify_event) (struct ci_hdrc *ci, unsigned event); 35 void (*notify_event) (struct ci_hdrc *ci, unsigned event);
36 struct regulator *reg_vbus; 36 struct regulator *reg_vbus;
37 struct usb_otg_caps ci_otg_caps;
37 bool tpl_support; 38 bool tpl_support;
38}; 39};
39 40
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 2511469a9904..1074b8921a5d 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -228,6 +228,8 @@ struct usb_function {
228 struct list_head list; 228 struct list_head list;
229 DECLARE_BITMAP(endpoints, 32); 229 DECLARE_BITMAP(endpoints, 32);
230 const struct usb_function_instance *fi; 230 const struct usb_function_instance *fi;
231
232 unsigned int bind_deactivated:1;
231}; 233};
232 234
233int usb_add_function(struct usb_configuration *, struct usb_function *); 235int usb_add_function(struct usb_configuration *, struct usb_function *);
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 4f3dfb7d0654..c14a69b36d27 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -141,10 +141,49 @@ struct usb_ep_ops {
141}; 141};
142 142
143/** 143/**
144 * struct usb_ep_caps - endpoint capabilities description
145 * @type_control:Endpoint supports control type (reserved for ep0).
146 * @type_iso:Endpoint supports isochronous transfers.
147 * @type_bulk:Endpoint supports bulk transfers.
148 * @type_int:Endpoint supports interrupt transfers.
149 * @dir_in:Endpoint supports IN direction.
150 * @dir_out:Endpoint supports OUT direction.
151 */
152struct usb_ep_caps {
153 unsigned type_control:1;
154 unsigned type_iso:1;
155 unsigned type_bulk:1;
156 unsigned type_int:1;
157 unsigned dir_in:1;
158 unsigned dir_out:1;
159};
160
161#define USB_EP_CAPS_TYPE_CONTROL 0x01
162#define USB_EP_CAPS_TYPE_ISO 0x02
163#define USB_EP_CAPS_TYPE_BULK 0x04
164#define USB_EP_CAPS_TYPE_INT 0x08
165#define USB_EP_CAPS_TYPE_ALL \
166 (USB_EP_CAPS_TYPE_ISO | USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT)
167#define USB_EP_CAPS_DIR_IN 0x01
168#define USB_EP_CAPS_DIR_OUT 0x02
169#define USB_EP_CAPS_DIR_ALL (USB_EP_CAPS_DIR_IN | USB_EP_CAPS_DIR_OUT)
170
171#define USB_EP_CAPS(_type, _dir) \
172 { \
173 .type_control = !!(_type & USB_EP_CAPS_TYPE_CONTROL), \
174 .type_iso = !!(_type & USB_EP_CAPS_TYPE_ISO), \
175 .type_bulk = !!(_type & USB_EP_CAPS_TYPE_BULK), \
176 .type_int = !!(_type & USB_EP_CAPS_TYPE_INT), \
177 .dir_in = !!(_dir & USB_EP_CAPS_DIR_IN), \
178 .dir_out = !!(_dir & USB_EP_CAPS_DIR_OUT), \
179 }
180
181/**
144 * struct usb_ep - device side representation of USB endpoint 182 * struct usb_ep - device side representation of USB endpoint
145 * @name:identifier for the endpoint, such as "ep-a" or "ep9in-bulk" 183 * @name:identifier for the endpoint, such as "ep-a" or "ep9in-bulk"
146 * @ops: Function pointers used to access hardware-specific operations. 184 * @ops: Function pointers used to access hardware-specific operations.
147 * @ep_list:the gadget's ep_list holds all of its endpoints 185 * @ep_list:the gadget's ep_list holds all of its endpoints
186 * @caps:The structure describing types and directions supported by endoint.
148 * @maxpacket:The maximum packet size used on this endpoint. The initial 187 * @maxpacket:The maximum packet size used on this endpoint. The initial
149 * value can sometimes be reduced (hardware allowing), according to 188 * value can sometimes be reduced (hardware allowing), according to
150 * the endpoint descriptor used to configure the endpoint. 189 * the endpoint descriptor used to configure the endpoint.
@@ -167,12 +206,15 @@ struct usb_ep_ops {
167 * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list, 206 * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
168 * and is accessed only in response to a driver setup() callback. 207 * and is accessed only in response to a driver setup() callback.
169 */ 208 */
209
170struct usb_ep { 210struct usb_ep {
171 void *driver_data; 211 void *driver_data;
172 212
173 const char *name; 213 const char *name;
174 const struct usb_ep_ops *ops; 214 const struct usb_ep_ops *ops;
175 struct list_head ep_list; 215 struct list_head ep_list;
216 struct usb_ep_caps caps;
217 bool claimed;
176 unsigned maxpacket:16; 218 unsigned maxpacket:16;
177 unsigned maxpacket_limit:16; 219 unsigned maxpacket_limit:16;
178 unsigned max_streams:16; 220 unsigned max_streams:16;
@@ -492,6 +534,9 @@ struct usb_gadget_ops {
492 int (*udc_start)(struct usb_gadget *, 534 int (*udc_start)(struct usb_gadget *,
493 struct usb_gadget_driver *); 535 struct usb_gadget_driver *);
494 int (*udc_stop)(struct usb_gadget *); 536 int (*udc_stop)(struct usb_gadget *);
537 struct usb_ep *(*match_ep)(struct usb_gadget *,
538 struct usb_endpoint_descriptor *,
539 struct usb_ss_ep_comp_descriptor *);
495}; 540};
496 541
497/** 542/**
@@ -511,6 +556,7 @@ struct usb_gadget_ops {
511 * @dev: Driver model state for this abstract device. 556 * @dev: Driver model state for this abstract device.
512 * @out_epnum: last used out ep number 557 * @out_epnum: last used out ep number
513 * @in_epnum: last used in ep number 558 * @in_epnum: last used in ep number
559 * @otg_caps: OTG capabilities of this gadget.
514 * @sg_supported: true if we can handle scatter-gather 560 * @sg_supported: true if we can handle scatter-gather
515 * @is_otg: True if the USB device port uses a Mini-AB jack, so that the 561 * @is_otg: True if the USB device port uses a Mini-AB jack, so that the
516 * gadget driver must provide a USB OTG descriptor. 562 * gadget driver must provide a USB OTG descriptor.
@@ -526,6 +572,9 @@ struct usb_gadget_ops {
526 * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to 572 * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to
527 * MaxPacketSize. 573 * MaxPacketSize.
528 * @is_selfpowered: if the gadget is self-powered. 574 * @is_selfpowered: if the gadget is self-powered.
575 * @deactivated: True if gadget is deactivated - in deactivated state it cannot
576 * be connected.
577 * @connected: True if gadget is connected.
529 * 578 *
530 * Gadgets have a mostly-portable "gadget driver" implementing device 579 * Gadgets have a mostly-portable "gadget driver" implementing device
531 * functions, handling all usb configurations and interfaces. Gadget 580 * functions, handling all usb configurations and interfaces. Gadget
@@ -559,6 +608,7 @@ struct usb_gadget {
559 struct device dev; 608 struct device dev;
560 unsigned out_epnum; 609 unsigned out_epnum;
561 unsigned in_epnum; 610 unsigned in_epnum;
611 struct usb_otg_caps *otg_caps;
562 612
563 unsigned sg_supported:1; 613 unsigned sg_supported:1;
564 unsigned is_otg:1; 614 unsigned is_otg:1;
@@ -567,7 +617,12 @@ struct usb_gadget {
567 unsigned a_hnp_support:1; 617 unsigned a_hnp_support:1;
568 unsigned a_alt_hnp_support:1; 618 unsigned a_alt_hnp_support:1;
569 unsigned quirk_ep_out_aligned_size:1; 619 unsigned quirk_ep_out_aligned_size:1;
620 unsigned quirk_altset_not_supp:1;
621 unsigned quirk_stall_not_supp:1;
622 unsigned quirk_zlp_not_supp:1;
570 unsigned is_selfpowered:1; 623 unsigned is_selfpowered:1;
624 unsigned deactivated:1;
625 unsigned connected:1;
571}; 626};
572#define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) 627#define work_to_gadget(w) (container_of((w), struct usb_gadget, work))
573 628
@@ -584,7 +639,6 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
584#define gadget_for_each_ep(tmp, gadget) \ 639#define gadget_for_each_ep(tmp, gadget) \
585 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) 640 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
586 641
587
588/** 642/**
589 * usb_ep_align_maybe - returns @len aligned to ep's maxpacketsize if gadget 643 * usb_ep_align_maybe - returns @len aligned to ep's maxpacketsize if gadget
590 * requires quirk_ep_out_aligned_size, otherwise reguens len. 644 * requires quirk_ep_out_aligned_size, otherwise reguens len.
@@ -603,6 +657,34 @@ usb_ep_align_maybe(struct usb_gadget *g, struct usb_ep *ep, size_t len)
603} 657}
604 658
605/** 659/**
660 * gadget_is_altset_supported - return true iff the hardware supports
661 * altsettings
662 * @g: controller to check for quirk
663 */
664static inline int gadget_is_altset_supported(struct usb_gadget *g)
665{
666 return !g->quirk_altset_not_supp;
667}
668
669/**
670 * gadget_is_stall_supported - return true iff the hardware supports stalling
671 * @g: controller to check for quirk
672 */
673static inline int gadget_is_stall_supported(struct usb_gadget *g)
674{
675 return !g->quirk_stall_not_supp;
676}
677
678/**
679 * gadget_is_zlp_supported - return true iff the hardware supports zlp
680 * @g: controller to check for quirk
681 */
682static inline int gadget_is_zlp_supported(struct usb_gadget *g)
683{
684 return !g->quirk_zlp_not_supp;
685}
686
687/**
606 * gadget_is_dualspeed - return true iff the hardware handles high speed 688 * gadget_is_dualspeed - return true iff the hardware handles high speed
607 * @g: controller that might support both high and full speeds 689 * @g: controller that might support both high and full speeds
608 */ 690 */
@@ -771,9 +853,24 @@ static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
771 */ 853 */
772static inline int usb_gadget_connect(struct usb_gadget *gadget) 854static inline int usb_gadget_connect(struct usb_gadget *gadget)
773{ 855{
856 int ret;
857
774 if (!gadget->ops->pullup) 858 if (!gadget->ops->pullup)
775 return -EOPNOTSUPP; 859 return -EOPNOTSUPP;
776 return gadget->ops->pullup(gadget, 1); 860
861 if (gadget->deactivated) {
862 /*
863 * If gadget is deactivated we only save new state.
864 * Gadget will be connected automatically after activation.
865 */
866 gadget->connected = true;
867 return 0;
868 }
869
870 ret = gadget->ops->pullup(gadget, 1);
871 if (!ret)
872 gadget->connected = 1;
873 return ret;
777} 874}
778 875
779/** 876/**
@@ -784,20 +881,88 @@ static inline int usb_gadget_connect(struct usb_gadget *gadget)
784 * as a disconnect (when a VBUS session is active). Not all systems 881 * as a disconnect (when a VBUS session is active). Not all systems
785 * support software pullup controls. 882 * support software pullup controls.
786 * 883 *
884 * Returns zero on success, else negative errno.
885 */
886static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
887{
888 int ret;
889
890 if (!gadget->ops->pullup)
891 return -EOPNOTSUPP;
892
893 if (gadget->deactivated) {
894 /*
895 * If gadget is deactivated we only save new state.
896 * Gadget will stay disconnected after activation.
897 */
898 gadget->connected = false;
899 return 0;
900 }
901
902 ret = gadget->ops->pullup(gadget, 0);
903 if (!ret)
904 gadget->connected = 0;
905 return ret;
906}
907
908/**
909 * usb_gadget_deactivate - deactivate function which is not ready to work
910 * @gadget: the peripheral being deactivated
911 *
787 * This routine may be used during the gadget driver bind() call to prevent 912 * This routine may be used during the gadget driver bind() call to prevent
788 * the peripheral from ever being visible to the USB host, unless later 913 * the peripheral from ever being visible to the USB host, unless later
789 * usb_gadget_connect() is called. For example, user mode components may 914 * usb_gadget_activate() is called. For example, user mode components may
790 * need to be activated before the system can talk to hosts. 915 * need to be activated before the system can talk to hosts.
791 * 916 *
792 * Returns zero on success, else negative errno. 917 * Returns zero on success, else negative errno.
793 */ 918 */
794static inline int usb_gadget_disconnect(struct usb_gadget *gadget) 919static inline int usb_gadget_deactivate(struct usb_gadget *gadget)
795{ 920{
796 if (!gadget->ops->pullup) 921 int ret;
797 return -EOPNOTSUPP; 922
798 return gadget->ops->pullup(gadget, 0); 923 if (gadget->deactivated)
924 return 0;
925
926 if (gadget->connected) {
927 ret = usb_gadget_disconnect(gadget);
928 if (ret)
929 return ret;
930 /*
931 * If gadget was being connected before deactivation, we want
932 * to reconnect it in usb_gadget_activate().
933 */
934 gadget->connected = true;
935 }
936 gadget->deactivated = true;
937
938 return 0;
799} 939}
800 940
941/**
942 * usb_gadget_activate - activate function which is not ready to work
943 * @gadget: the peripheral being activated
944 *
945 * This routine activates gadget which was previously deactivated with
946 * usb_gadget_deactivate() call. It calls usb_gadget_connect() if needed.
947 *
948 * Returns zero on success, else negative errno.
949 */
950static inline int usb_gadget_activate(struct usb_gadget *gadget)
951{
952 if (!gadget->deactivated)
953 return 0;
954
955 gadget->deactivated = false;
956
957 /*
958 * If gadget has been connected before deactivation, or became connected
959 * while it was being deactivated, we call usb_gadget_connect().
960 */
961 if (gadget->connected)
962 return usb_gadget_connect(gadget);
963
964 return 0;
965}
801 966
802/*-------------------------------------------------------------------------*/ 967/*-------------------------------------------------------------------------*/
803 968
@@ -1002,6 +1167,10 @@ int usb_assign_descriptors(struct usb_function *f,
1002 struct usb_descriptor_header **ss); 1167 struct usb_descriptor_header **ss);
1003void usb_free_all_descriptors(struct usb_function *f); 1168void usb_free_all_descriptors(struct usb_function *f);
1004 1169
1170struct usb_descriptor_header *usb_otg_descriptor_alloc(
1171 struct usb_gadget *gadget);
1172int usb_otg_descriptor_init(struct usb_gadget *gadget,
1173 struct usb_descriptor_header *otg_desc);
1005/*-------------------------------------------------------------------------*/ 1174/*-------------------------------------------------------------------------*/
1006 1175
1007/* utility to simplify map/unmap of usb_requests to/from DMA */ 1176/* utility to simplify map/unmap of usb_requests to/from DMA */
@@ -1034,6 +1203,21 @@ extern void usb_gadget_giveback_request(struct usb_ep *ep,
1034 1203
1035/*-------------------------------------------------------------------------*/ 1204/*-------------------------------------------------------------------------*/
1036 1205
1206/* utility to find endpoint by name */
1207
1208extern struct usb_ep *gadget_find_ep_by_name(struct usb_gadget *g,
1209 const char *name);
1210
1211/*-------------------------------------------------------------------------*/
1212
1213/* utility to check if endpoint caps match descriptor needs */
1214
1215extern int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
1216 struct usb_ep *ep, struct usb_endpoint_descriptor *desc,
1217 struct usb_ss_ep_comp_descriptor *ep_comp);
1218
1219/*-------------------------------------------------------------------------*/
1220
1037/* utility to update vbus status for udc core, it may be scheduled */ 1221/* utility to update vbus status for udc core, it may be scheduled */
1038extern void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status); 1222extern void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status);
1039 1223
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index e55a1504266e..8c8f6854c993 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -128,7 +128,7 @@ struct msm_otg_platform_data {
128 */ 128 */
129struct msm_usb_cable { 129struct msm_usb_cable {
130 struct notifier_block nb; 130 struct notifier_block nb;
131 struct extcon_specific_cable_nb conn; 131 struct extcon_dev *extcon;
132}; 132};
133 133
134/** 134/**
@@ -155,6 +155,10 @@ struct msm_usb_cable {
155 * starting controller using usbcmd run/stop bit. 155 * starting controller using usbcmd run/stop bit.
156 * @vbus: VBUS signal state trakining, using extcon framework 156 * @vbus: VBUS signal state trakining, using extcon framework
157 * @id: ID signal state trakining, using extcon framework 157 * @id: ID signal state trakining, using extcon framework
158 * @switch_gpio: Descriptor for GPIO used to control external Dual
159 * SPDT USB Switch.
160 * @reboot: Used to inform the driver to route USB D+/D- line to Device
161 * connector
158 */ 162 */
159struct msm_otg { 163struct msm_otg {
160 struct usb_phy phy; 164 struct usb_phy phy;
@@ -188,6 +192,9 @@ struct msm_otg {
188 192
189 struct msm_usb_cable vbus; 193 struct msm_usb_cable vbus;
190 struct msm_usb_cable id; 194 struct msm_usb_cable id;
195
196 struct gpio_desc *switch_gpio;
197 struct notifier_block reboot;
191}; 198};
192 199
193#endif 200#endif
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
index cfe0528cdbb1..8c5a818ec244 100644
--- a/include/linux/usb/of.h
+++ b/include/linux/usb/of.h
@@ -15,6 +15,8 @@
15enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); 15enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
16enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); 16enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
17bool of_usb_host_tpl_support(struct device_node *np); 17bool of_usb_host_tpl_support(struct device_node *np);
18int of_usb_update_otg_caps(struct device_node *np,
19 struct usb_otg_caps *otg_caps);
18#else 20#else
19static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) 21static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
20{ 22{
@@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct device_node *np)
30{ 32{
31 return false; 33 return false;
32} 34}
35static inline int of_usb_update_otg_caps(struct device_node *np,
36 struct usb_otg_caps *otg_caps)
37{
38 return 0;
39}
33#endif 40#endif
34 41
35#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) 42#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 52661c5da690..bd1dcf816100 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -41,6 +41,21 @@ struct usb_otg {
41 41
42}; 42};
43 43
44/**
45 * struct usb_otg_caps - describes the otg capabilities of the device
46 * @otg_rev: The OTG revision number the device is compliant with, it's
47 * in binary-coded decimal (i.e. 2.0 is 0200H).
48 * @hnp_support: Indicates if the device supports HNP.
49 * @srp_support: Indicates if the device supports SRP.
50 * @adp_support: Indicates if the device supports ADP.
51 */
52struct usb_otg_caps {
53 u16 otg_rev;
54 bool hnp_support;
55 bool srp_support;
56 bool adp_support;
57};
58
44extern const char *usb_otg_state_string(enum usb_otg_state state); 59extern const char *usb_otg_state_string(enum usb_otg_state state);
45 60
46/* Context: can sleep */ 61/* Context: can sleep */