aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/cdc.h51
-rw-r--r--include/linux/usb/ch9.h11
-rw-r--r--include/linux/usb/chipidea.h24
-rw-r--r--include/linux/usb/gadget.h29
-rw-r--r--include/linux/usb/gadget_configfs.h19
-rw-r--r--include/linux/usb/hcd.h26
-rw-r--r--include/linux/usb/musb.h2
-rw-r--r--include/linux/usb/of.h12
-rw-r--r--include/linux/usb/otg.h9
-rw-r--r--include/linux/usb/phy.h8
-rw-r--r--include/linux/usb/renesas_usbhs.h2
11 files changed, 151 insertions, 42 deletions
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
new file mode 100644
index 000000000000..b5706f94ee9e
--- /dev/null
+++ b/include/linux/usb/cdc.h
@@ -0,0 +1,51 @@
1/*
2 * USB CDC common helpers
3 *
4 * Copyright (c) 2015 Oliver Neukum <oneukum@suse.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 */
10#ifndef __LINUX_USB_CDC_H
11#define __LINUX_USB_CDC_H
12
13#include <uapi/linux/usb/cdc.h>
14
15/*
16 * inofficial magic numbers
17 */
18
19#define CDC_PHONET_MAGIC_NUMBER 0xAB
20
21/*
22 * parsing CDC headers
23 */
24
25struct usb_cdc_parsed_header {
26 struct usb_cdc_union_desc *usb_cdc_union_desc;
27 struct usb_cdc_header_desc *usb_cdc_header_desc;
28
29 struct usb_cdc_call_mgmt_descriptor *usb_cdc_call_mgmt_descriptor;
30 struct usb_cdc_acm_descriptor *usb_cdc_acm_descriptor;
31 struct usb_cdc_country_functional_desc *usb_cdc_country_functional_desc;
32 struct usb_cdc_network_terminal_desc *usb_cdc_network_terminal_desc;
33 struct usb_cdc_ether_desc *usb_cdc_ether_desc;
34 struct usb_cdc_dmm_desc *usb_cdc_dmm_desc;
35 struct usb_cdc_mdlm_desc *usb_cdc_mdlm_desc;
36 struct usb_cdc_mdlm_detail_desc *usb_cdc_mdlm_detail_desc;
37 struct usb_cdc_obex_desc *usb_cdc_obex_desc;
38 struct usb_cdc_ncm_desc *usb_cdc_ncm_desc;
39 struct usb_cdc_mbim_desc *usb_cdc_mbim_desc;
40 struct usb_cdc_mbim_extended_desc *usb_cdc_mbim_extended_desc;
41
42 bool phonet_magic_present;
43};
44
45struct usb_interface;
46int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
47 struct usb_interface *intf,
48 u8 *buffer,
49 int buflen);
50
51#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 27603bcbb9b9..6cc96bb12ddc 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -32,9 +32,9 @@
32#ifndef __LINUX_USB_CH9_H 32#ifndef __LINUX_USB_CH9_H
33#define __LINUX_USB_CH9_H 33#define __LINUX_USB_CH9_H
34 34
35#include <linux/device.h>
35#include <uapi/linux/usb/ch9.h> 36#include <uapi/linux/usb/ch9.h>
36 37
37
38/** 38/**
39 * usb_speed_string() - Returns human readable-name of the speed. 39 * usb_speed_string() - Returns human readable-name of the speed.
40 * @speed: The speed to return human-readable name for. If it's not 40 * @speed: The speed to return human-readable name for. If it's not
@@ -43,6 +43,15 @@
43 */ 43 */
44extern const char *usb_speed_string(enum usb_device_speed speed); 44extern const char *usb_speed_string(enum usb_device_speed speed);
45 45
46/**
47 * usb_get_maximum_speed - Get maximum requested speed for a given USB
48 * controller.
49 * @dev: Pointer to the given USB controller device
50 *
51 * The function gets the maximum speed string from property "maximum-speed",
52 * and returns the corresponding enum usb_device_speed.
53 */
54extern enum usb_device_speed usb_get_maximum_speed(struct device *dev);
46 55
47/** 56/**
48 * usb_state_string - Returns human readable name for the state. 57 * usb_state_string - Returns human readable name for the state.
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index a41833cd184c..5dd75fa47dd8 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -5,9 +5,28 @@
5#ifndef __LINUX_USB_CHIPIDEA_H 5#ifndef __LINUX_USB_CHIPIDEA_H
6#define __LINUX_USB_CHIPIDEA_H 6#define __LINUX_USB_CHIPIDEA_H
7 7
8#include <linux/extcon.h>
8#include <linux/usb/otg.h> 9#include <linux/usb/otg.h>
9 10
10struct ci_hdrc; 11struct ci_hdrc;
12
13/**
14 * struct ci_hdrc_cable - structure for external connector cable state tracking
15 * @state: current state of the line
16 * @changed: set to true when extcon event happen
17 * @edev: device which generate events
18 * @ci: driver state of the chipidea device
19 * @nb: hold event notification callback
20 * @conn: used for notification registration
21 */
22struct ci_hdrc_cable {
23 bool state;
24 bool changed;
25 struct extcon_dev *edev;
26 struct ci_hdrc *ci;
27 struct notifier_block nb;
28};
29
11struct ci_hdrc_platform_data { 30struct ci_hdrc_platform_data {
12 const char *name; 31 const char *name;
13 /* offset of the capability registers */ 32 /* offset of the capability registers */
@@ -48,6 +67,11 @@ struct ci_hdrc_platform_data {
48 u32 ahb_burst_config; 67 u32 ahb_burst_config;
49 u32 tx_burst_size; 68 u32 tx_burst_size;
50 u32 rx_burst_size; 69 u32 rx_burst_size;
70
71 /* VBUS and ID signal state tracking, using extcon framework */
72 struct ci_hdrc_cable vbus_extcon;
73 struct ci_hdrc_cable id_extcon;
74 u32 phy_clkgate_delay_us;
51}; 75};
52 76
53/* Default offset of capability registers */ 77/* Default offset of capability registers */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c14a69b36d27..3d583a10b926 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -215,6 +215,7 @@ struct usb_ep {
215 struct list_head ep_list; 215 struct list_head ep_list;
216 struct usb_ep_caps caps; 216 struct usb_ep_caps caps;
217 bool claimed; 217 bool claimed;
218 bool enabled;
218 unsigned maxpacket:16; 219 unsigned maxpacket:16;
219 unsigned maxpacket_limit:16; 220 unsigned maxpacket_limit:16;
220 unsigned max_streams:16; 221 unsigned max_streams:16;
@@ -264,7 +265,18 @@ static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
264 */ 265 */
265static inline int usb_ep_enable(struct usb_ep *ep) 266static inline int usb_ep_enable(struct usb_ep *ep)
266{ 267{
267 return ep->ops->enable(ep, ep->desc); 268 int ret;
269
270 if (ep->enabled)
271 return 0;
272
273 ret = ep->ops->enable(ep, ep->desc);
274 if (ret)
275 return ret;
276
277 ep->enabled = true;
278
279 return 0;
268} 280}
269 281
270/** 282/**
@@ -281,7 +293,18 @@ static inline int usb_ep_enable(struct usb_ep *ep)
281 */ 293 */
282static inline int usb_ep_disable(struct usb_ep *ep) 294static inline int usb_ep_disable(struct usb_ep *ep)
283{ 295{
284 return ep->ops->disable(ep); 296 int ret;
297
298 if (!ep->enabled)
299 return 0;
300
301 ret = ep->ops->disable(ep);
302 if (ret)
303 return ret;
304
305 ep->enabled = false;
306
307 return 0;
285} 308}
286 309
287/** 310/**
@@ -1233,6 +1256,8 @@ extern struct usb_ep *usb_ep_autoconfig_ss(struct usb_gadget *,
1233 struct usb_endpoint_descriptor *, 1256 struct usb_endpoint_descriptor *,
1234 struct usb_ss_ep_comp_descriptor *); 1257 struct usb_ss_ep_comp_descriptor *);
1235 1258
1259extern void usb_ep_autoconfig_release(struct usb_ep *);
1260
1236extern void usb_ep_autoconfig_reset(struct usb_gadget *); 1261extern void usb_ep_autoconfig_reset(struct usb_gadget *);
1237 1262
1238#endif /* __LINUX_USB_GADGET_H */ 1263#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb/gadget_configfs.h b/include/linux/usb/gadget_configfs.h
index d74c0ae989d5..c36e95730de1 100644
--- a/include/linux/usb/gadget_configfs.h
+++ b/include/linux/usb/gadget_configfs.h
@@ -7,9 +7,10 @@ int check_user_usb_string(const char *name,
7 struct usb_gadget_strings *stringtab_dev); 7 struct usb_gadget_strings *stringtab_dev);
8 8
9#define GS_STRINGS_W(__struct, __name) \ 9#define GS_STRINGS_W(__struct, __name) \
10 static ssize_t __struct##_##__name##_store(struct __struct *gs, \ 10static ssize_t __struct##_##__name##_store(struct config_item *item, \
11 const char *page, size_t len) \ 11 const char *page, size_t len) \
12{ \ 12{ \
13 struct __struct *gs = to_##__struct(item); \
13 int ret; \ 14 int ret; \
14 \ 15 \
15 ret = usb_string_copy(page, &gs->__name); \ 16 ret = usb_string_copy(page, &gs->__name); \
@@ -19,30 +20,20 @@ int check_user_usb_string(const char *name,
19} 20}
20 21
21#define GS_STRINGS_R(__struct, __name) \ 22#define GS_STRINGS_R(__struct, __name) \
22 static ssize_t __struct##_##__name##_show(struct __struct *gs, \ 23static ssize_t __struct##_##__name##_show(struct config_item *item, char *page) \
23 char *page) \
24{ \ 24{ \
25 struct __struct *gs = to_##__struct(item); \
25 return sprintf(page, "%s\n", gs->__name ?: ""); \ 26 return sprintf(page, "%s\n", gs->__name ?: ""); \
26} 27}
27 28
28#define GS_STRING_ITEM_ATTR(struct_name, name) \
29 static struct struct_name##_attribute struct_name##_##name = \
30 __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
31 struct_name##_##name##_show, \
32 struct_name##_##name##_store)
33
34#define GS_STRINGS_RW(struct_name, _name) \ 29#define GS_STRINGS_RW(struct_name, _name) \
35 GS_STRINGS_R(struct_name, _name) \ 30 GS_STRINGS_R(struct_name, _name) \
36 GS_STRINGS_W(struct_name, _name) \ 31 GS_STRINGS_W(struct_name, _name) \
37 GS_STRING_ITEM_ATTR(struct_name, _name) 32 CONFIGFS_ATTR(struct_name##_, _name)
38 33
39#define USB_CONFIG_STRING_RW_OPS(struct_in) \ 34#define USB_CONFIG_STRING_RW_OPS(struct_in) \
40 CONFIGFS_ATTR_OPS(struct_in); \
41 \
42static struct configfs_item_operations struct_in##_langid_item_ops = { \ 35static struct configfs_item_operations struct_in##_langid_item_ops = { \
43 .release = struct_in##_attr_release, \ 36 .release = struct_in##_attr_release, \
44 .show_attribute = struct_in##_attr_show, \
45 .store_attribute = struct_in##_attr_store, \
46}; \ 37}; \
47 \ 38 \
48static struct config_item_type struct_in##_langid_type = { \ 39static struct config_item_type struct_in##_langid_type = { \
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index d2784c10bfe2..f89c24bd53a4 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -58,12 +58,6 @@
58 * 58 *
59 * Since "struct usb_bus" is so thin, you can't share much code in it. 59 * Since "struct usb_bus" is so thin, you can't share much code in it.
60 * This framework is a layer over that, and should be more sharable. 60 * This framework is a layer over that, and should be more sharable.
61 *
62 * @authorized_default: Specifies if new devices are authorized to
63 * connect by default or they require explicit
64 * user space authorization; this bit is settable
65 * through /sys/class/usb_host/X/authorized_default.
66 * For the rest is RO, so we don't lock to r/w it.
67 */ 61 */
68 62
69/*-------------------------------------------------------------------------*/ 63/*-------------------------------------------------------------------------*/
@@ -120,6 +114,8 @@ struct usb_hcd {
120#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */ 114#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */
121#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ 115#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
122#define HCD_FLAG_DEAD 6 /* controller has died? */ 116#define HCD_FLAG_DEAD 6 /* controller has died? */
117#define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */
118#define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */
123 119
124 /* The flags can be tested using these macros; they are likely to 120 /* The flags can be tested using these macros; they are likely to
125 * be slightly faster than test_bit(). 121 * be slightly faster than test_bit().
@@ -131,6 +127,22 @@ struct usb_hcd {
131#define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING)) 127#define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
132#define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD)) 128#define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD))
133 129
130 /*
131 * Specifies if interfaces are authorized by default
132 * or they require explicit user space authorization; this bit is
133 * settable through /sys/class/usb_host/X/interface_authorized_default
134 */
135#define HCD_INTF_AUTHORIZED(hcd) \
136 ((hcd)->flags & (1U << HCD_FLAG_INTF_AUTHORIZED))
137
138 /*
139 * Specifies if devices are authorized by default
140 * or they require explicit user space authorization; this bit is
141 * settable through /sys/class/usb_host/X/authorized_default
142 */
143#define HCD_DEV_AUTHORIZED(hcd) \
144 ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED))
145
134 /* Flags that get set only during HCD registration or removal. */ 146 /* Flags that get set only during HCD registration or removal. */
135 unsigned rh_registered:1;/* is root hub registered? */ 147 unsigned rh_registered:1;/* is root hub registered? */
136 unsigned rh_pollable:1; /* may we poll the root hub? */ 148 unsigned rh_pollable:1; /* may we poll the root hub? */
@@ -141,7 +153,6 @@ struct usb_hcd {
141 * support the new root-hub polling mechanism. */ 153 * support the new root-hub polling mechanism. */
142 unsigned uses_new_polling:1; 154 unsigned uses_new_polling:1;
143 unsigned wireless:1; /* Wireless USB HCD */ 155 unsigned wireless:1; /* Wireless USB HCD */
144 unsigned authorized_default:1;
145 unsigned has_tt:1; /* Integrated TT in root hub */ 156 unsigned has_tt:1; /* Integrated TT in root hub */
146 unsigned amd_resume_bug:1; /* AMD remote wakeup quirk */ 157 unsigned amd_resume_bug:1; /* AMD remote wakeup quirk */
147 unsigned can_do_streams:1; /* HC supports streams */ 158 unsigned can_do_streams:1; /* HC supports streams */
@@ -239,6 +250,7 @@ struct hc_driver {
239#define HCD_USB2 0x0020 /* USB 2.0 */ 250#define HCD_USB2 0x0020 /* USB 2.0 */
240#define HCD_USB25 0x0030 /* Wireless USB 1.0 (USB 2.5)*/ 251#define HCD_USB25 0x0030 /* Wireless USB 1.0 (USB 2.5)*/
241#define HCD_USB3 0x0040 /* USB 3.0 */ 252#define HCD_USB3 0x0040 /* USB 3.0 */
253#define HCD_USB31 0x0050 /* USB 3.1 */
242#define HCD_MASK 0x0070 254#define HCD_MASK 0x0070
243#define HCD_BH 0x0100 /* URB complete in BH context */ 255#define HCD_BH 0x0100 /* URB complete in BH context */
244 256
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index a4ee1b582183..fa6dc132bd1b 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -95,7 +95,7 @@ struct musb_hdrc_config {
95 /* musb CLKIN in Blackfin in MHZ */ 95 /* musb CLKIN in Blackfin in MHZ */
96 unsigned char clkin; 96 unsigned char clkin;
97#endif 97#endif
98 98 u32 maximum_speed;
99}; 99};
100 100
101struct musb_hdrc_platform_data { 101struct musb_hdrc_platform_data {
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
index 8c5a818ec244..c3fe9e48ce27 100644
--- a/include/linux/usb/of.h
+++ b/include/linux/usb/of.h
@@ -12,22 +12,10 @@
12#include <linux/usb/phy.h> 12#include <linux/usb/phy.h>
13 13
14#if IS_ENABLED(CONFIG_OF) 14#if IS_ENABLED(CONFIG_OF)
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);
17bool of_usb_host_tpl_support(struct device_node *np); 15bool of_usb_host_tpl_support(struct device_node *np);
18int of_usb_update_otg_caps(struct device_node *np, 16int of_usb_update_otg_caps(struct device_node *np,
19 struct usb_otg_caps *otg_caps); 17 struct usb_otg_caps *otg_caps);
20#else 18#else
21static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
22{
23 return USB_DR_MODE_UNKNOWN;
24}
25
26static inline enum usb_device_speed
27of_usb_get_maximum_speed(struct device_node *np)
28{
29 return USB_SPEED_UNKNOWN;
30}
31static inline bool of_usb_host_tpl_support(struct device_node *np) 19static inline bool of_usb_host_tpl_support(struct device_node *np)
32{ 20{
33 return false; 21 return false;
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index bd1dcf816100..67929df86df5 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -119,4 +119,13 @@ enum usb_dr_mode {
119 USB_DR_MODE_OTG, 119 USB_DR_MODE_OTG,
120}; 120};
121 121
122/**
123 * usb_get_dr_mode - Get dual role mode for given device
124 * @dev: Pointer to the given device
125 *
126 * The function gets phy interface string from property 'dr_mode',
127 * and returns the correspondig enum usb_dr_mode
128 */
129extern enum usb_dr_mode usb_get_dr_mode(struct device *dev);
130
122#endif /* __LINUX_USB_OTG_H */ 131#endif /* __LINUX_USB_OTG_H */
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index e39f251cf861..31a8068c42a5 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -63,7 +63,7 @@ enum usb_otg_state {
63struct usb_phy; 63struct usb_phy;
64struct usb_otg; 64struct usb_otg;
65 65
66/* for transceivers connected thru an ULPI interface, the user must 66/* for phys connected thru an ULPI interface, the user must
67 * provide access ops 67 * provide access ops
68 */ 68 */
69struct usb_phy_io_ops { 69struct usb_phy_io_ops {
@@ -92,10 +92,10 @@ struct usb_phy {
92 u16 port_status; 92 u16 port_status;
93 u16 port_change; 93 u16 port_change;
94 94
95 /* to support controllers that have multiple transceivers */ 95 /* to support controllers that have multiple phys */
96 struct list_head head; 96 struct list_head head;
97 97
98 /* initialize/shutdown the OTG controller */ 98 /* initialize/shutdown the phy */
99 int (*init)(struct usb_phy *x); 99 int (*init)(struct usb_phy *x);
100 void (*shutdown)(struct usb_phy *x); 100 void (*shutdown)(struct usb_phy *x);
101 101
@@ -106,7 +106,7 @@ struct usb_phy {
106 int (*set_power)(struct usb_phy *x, 106 int (*set_power)(struct usb_phy *x,
107 unsigned mA); 107 unsigned mA);
108 108
109 /* Set transceiver into suspend mode */ 109 /* Set phy into suspend mode */
110 int (*set_suspend)(struct usb_phy *x, 110 int (*set_suspend)(struct usb_phy *x,
111 int suspend); 111 int suspend);
112 112
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index 3dd5a781da99..bfb74723f151 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -157,7 +157,7 @@ struct renesas_usbhs_driver_param {
157 */ 157 */
158 int pio_dma_border; /* default is 64byte */ 158 int pio_dma_border; /* default is 64byte */
159 159
160 u32 type; 160 uintptr_t type;
161 u32 enable_gpio; 161 u32 enable_gpio;
162 162
163 /* 163 /*