diff options
113 files changed, 3438 insertions, 1079 deletions
diff --git a/Documentation/ABI/testing/configfs-usb-gadget-loopback b/Documentation/ABI/testing/configfs-usb-gadget-loopback index 9aae5bfb9908..06beefbcf061 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-loopback +++ b/Documentation/ABI/testing/configfs-usb-gadget-loopback | |||
@@ -5,4 +5,4 @@ Description: | |||
5 | The attributes: | 5 | The attributes: |
6 | 6 | ||
7 | qlen - depth of loopback queue | 7 | qlen - depth of loopback queue |
8 | bulk_buflen - buffer length | 8 | buflen - buffer length |
diff --git a/Documentation/ABI/testing/configfs-usb-gadget-sourcesink b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink index 29477c319f61..bc7ff731aa0c 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-sourcesink +++ b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink | |||
@@ -9,4 +9,4 @@ Description: | |||
9 | isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) | 9 | isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) |
10 | isoc_mult - 0..2 (hs/ss only) | 10 | isoc_mult - 0..2 (hs/ss only) |
11 | isoc_maxburst - 0..15 (ss only) | 11 | isoc_maxburst - 0..15 (ss only) |
12 | qlen - buffer length | 12 | buflen - buffer length |
diff --git a/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt new file mode 100644 index 000000000000..862cd7c79805 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | Allwinner sun4i A10 musb DRC/OTG controller | ||
2 | ------------------------------------------- | ||
3 | |||
4 | Required properties: | ||
5 | - compatible : "allwinner,sun4i-a10-musb", "allwinner,sun6i-a31-musb" | ||
6 | or "allwinner,sun8i-a33-musb" | ||
7 | - reg : mmio address range of the musb controller | ||
8 | - clocks : clock specifier for the musb controller ahb gate clock | ||
9 | - reset : reset specifier for the ahb reset (A31 and newer only) | ||
10 | - interrupts : interrupt to which the musb controller is connected | ||
11 | - interrupt-names : must be "mc" | ||
12 | - phys : phy specifier for the otg phy | ||
13 | - phy-names : must be "usb" | ||
14 | - dr_mode : Dual-Role mode must be "host" or "otg" | ||
15 | - extcon : extcon specifier for the otg phy | ||
16 | |||
17 | Example: | ||
18 | |||
19 | usb_otg: usb@01c13000 { | ||
20 | compatible = "allwinner,sun4i-a10-musb"; | ||
21 | reg = <0x01c13000 0x0400>; | ||
22 | clocks = <&ahb_gates 0>; | ||
23 | interrupts = <38>; | ||
24 | interrupt-names = "mc"; | ||
25 | phys = <&usbphy 0>; | ||
26 | phy-names = "usb"; | ||
27 | extcon = <&usbphy 0>; | ||
28 | status = "disabled"; | ||
29 | }; | ||
diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index 477d5bb5e51c..bba825711873 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt | |||
@@ -11,6 +11,19 @@ Optional properties: | |||
11 | "peripheral" and "otg". In case this attribute isn't | 11 | "peripheral" and "otg". In case this attribute isn't |
12 | passed via DT, USB DRD controllers should default to | 12 | passed via DT, USB DRD controllers should default to |
13 | OTG. | 13 | OTG. |
14 | - otg-rev: tells usb driver the release number of the OTG and EH supplement | ||
15 | with which the device and its descriptors are compliant, | ||
16 | in binary-coded decimal (i.e. 2.0 is 0200H). This | ||
17 | property is used if any real OTG features(HNP/SRP/ADP) | ||
18 | is enabled, if ADP is required, otg-rev should be | ||
19 | 0x0200 or above. | ||
20 | - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP | ||
21 | is the basic function of real OTG except you want it | ||
22 | to be a srp-capable only B device. | ||
23 | - srp-disable: tells OTG controllers we want to disable OTG SRP, SRP is | ||
24 | optional for OTG device. | ||
25 | - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is | ||
26 | optional for OTG device. | ||
14 | 27 | ||
15 | This is an attribute to a USB controller such as: | 28 | This is an attribute to a USB controller such as: |
16 | 29 | ||
@@ -21,4 +34,6 @@ dwc3@4a030000 { | |||
21 | usb-phy = <&usb2_phy>, <&usb3,phy>; | 34 | usb-phy = <&usb2_phy>, <&usb3,phy>; |
22 | maximum-speed = "super-speed"; | 35 | maximum-speed = "super-speed"; |
23 | dr_mode = "otg"; | 36 | dr_mode = "otg"; |
37 | otg-rev = <0x0200>; | ||
38 | adp-disable; | ||
24 | }; | 39 | }; |
diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt index bd8d9e753029..8654a3ec23e4 100644 --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt | |||
@@ -52,6 +52,10 @@ Required properties: | |||
52 | Optional properties: | 52 | Optional properties: |
53 | - dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" | 53 | - dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" |
54 | 54 | ||
55 | - switch-gpio: A phandle + gpio-specifier pair. Some boards are using Dual | ||
56 | SPDT USB Switch, witch is cotrolled by GPIO to de/multiplex | ||
57 | D+/D- USB lines between connectors. | ||
58 | |||
55 | - qcom,phy-init-sequence: PHY configuration sequence values. This is related to Device | 59 | - qcom,phy-init-sequence: PHY configuration sequence values. This is related to Device |
56 | Mode Eye Diagram test. Start address at which these values will be | 60 | Mode Eye Diagram test. Start address at which these values will be |
57 | written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as | 61 | written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as |
diff --git a/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt b/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt new file mode 100644 index 000000000000..2cb2168cef41 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/qcom,usb-8x16-phy.txt | |||
@@ -0,0 +1,76 @@ | |||
1 | Qualcomm's APQ8016/MSM8916 USB transceiver controller | ||
2 | |||
3 | - compatible: | ||
4 | Usage: required | ||
5 | Value type: <string> | ||
6 | Definition: Should contain "qcom,usb-8x16-phy". | ||
7 | |||
8 | - reg: | ||
9 | Usage: required | ||
10 | Value type: <prop-encoded-array> | ||
11 | Definition: USB PHY base address and length of the register map | ||
12 | |||
13 | - clocks: | ||
14 | Usage: required | ||
15 | Value type: <prop-encoded-array> | ||
16 | Definition: See clock-bindings.txt section "consumers". List of | ||
17 | two clock specifiers for interface and core controller | ||
18 | clocks. | ||
19 | |||
20 | - clock-names: | ||
21 | Usage: required | ||
22 | Value type: <string> | ||
23 | Definition: Must contain "iface" and "core" strings. | ||
24 | |||
25 | - vddcx-supply: | ||
26 | Usage: required | ||
27 | Value type: <phandle> | ||
28 | Definition: phandle to the regulator VDCCX supply node. | ||
29 | |||
30 | - v1p8-supply: | ||
31 | Usage: required | ||
32 | Value type: <phandle> | ||
33 | Definition: phandle to the regulator 1.8V supply node. | ||
34 | |||
35 | - v3p3-supply: | ||
36 | Usage: required | ||
37 | Value type: <phandle> | ||
38 | Definition: phandle to the regulator 3.3V supply node. | ||
39 | |||
40 | - resets: | ||
41 | Usage: required | ||
42 | Value type: <prop-encoded-array> | ||
43 | Definition: See reset.txt section "consumers". PHY reset specifier. | ||
44 | |||
45 | - reset-names: | ||
46 | Usage: required | ||
47 | Value type: <string> | ||
48 | Definition: Must contain "phy" string. | ||
49 | |||
50 | - switch-gpio: | ||
51 | Usage: optional | ||
52 | Value type: <prop-encoded-array> | ||
53 | Definition: Some boards are using Dual SPDT USB Switch, witch is | ||
54 | controlled by GPIO to de/multiplex D+/D- USB lines | ||
55 | between connectors. | ||
56 | |||
57 | Example: | ||
58 | usb_phy: phy@78d9000 { | ||
59 | compatible = "qcom,usb-8x16-phy"; | ||
60 | reg = <0x78d9000 0x400>; | ||
61 | |||
62 | vddcx-supply = <&pm8916_s1_corner>; | ||
63 | v1p8-supply = <&pm8916_l7>; | ||
64 | v3p3-supply = <&pm8916_l13>; | ||
65 | |||
66 | clocks = <&gcc GCC_USB_HS_AHB_CLK>, | ||
67 | <&gcc GCC_USB_HS_SYSTEM_CLK>; | ||
68 | clock-names = "iface", "core"; | ||
69 | |||
70 | resets = <&gcc GCC_USB2A_PHY_BCR>; | ||
71 | reset-names = "phy"; | ||
72 | |||
73 | // D+/D- lines: 1 - Routed to HUB, 0 - Device connector | ||
74 | switch-gpio = <&pm8916_gpios 4 GPIO_ACTIVE_HIGH>; | ||
75 | }; | ||
76 | |||
diff --git a/Documentation/usb/gadget-testing.txt b/Documentation/usb/gadget-testing.txt index 592678009c15..b24d3ef89166 100644 --- a/Documentation/usb/gadget-testing.txt +++ b/Documentation/usb/gadget-testing.txt | |||
@@ -237,9 +237,7 @@ Testing the LOOPBACK function | |||
237 | ----------------------------- | 237 | ----------------------------- |
238 | 238 | ||
239 | device: run the gadget | 239 | device: run the gadget |
240 | host: test-usb | 240 | host: test-usb (tools/usb/testusb.c) |
241 | |||
242 | http://www.linux-usb.org/usbtest/testusb.c | ||
243 | 241 | ||
244 | 8. MASS STORAGE function | 242 | 8. MASS STORAGE function |
245 | ======================== | 243 | ======================== |
@@ -586,9 +584,8 @@ Testing the SOURCESINK function | |||
586 | ------------------------------- | 584 | ------------------------------- |
587 | 585 | ||
588 | device: run the gadget | 586 | device: run the gadget |
589 | host: test-usb | 587 | host: test-usb (tools/usb/testusb.c) |
590 | 588 | ||
591 | http://www.linux-usb.org/usbtest/testusb.c | ||
592 | 589 | ||
593 | 16. UAC1 function | 590 | 16. UAC1 function |
594 | ================= | 591 | ================= |
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 4178d96f94cf..b6b76ff09657 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c | |||
@@ -3153,36 +3153,46 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops = { | |||
3153 | .ioctl = nbu2ss_gad_ioctl, | 3153 | .ioctl = nbu2ss_gad_ioctl, |
3154 | }; | 3154 | }; |
3155 | 3155 | ||
3156 | static const char g_ep0_name[] = "ep0"; | 3156 | static const struct { |
3157 | static const char g_ep1_name[] = "ep1-bulk"; | 3157 | const char *name; |
3158 | static const char g_ep2_name[] = "ep2-bulk"; | 3158 | const struct usb_ep_caps caps; |
3159 | static const char g_ep3_name[] = "ep3in-int"; | 3159 | } ep_info[NUM_ENDPOINTS] = { |
3160 | static const char g_ep4_name[] = "ep4-iso"; | 3160 | #define EP_INFO(_name, _caps) \ |
3161 | static const char g_ep5_name[] = "ep5-iso"; | 3161 | { \ |
3162 | static const char g_ep6_name[] = "ep6-bulk"; | 3162 | .name = _name, \ |
3163 | static const char g_ep7_name[] = "ep7-bulk"; | 3163 | .caps = _caps, \ |
3164 | static const char g_ep8_name[] = "ep8in-int"; | 3164 | } |
3165 | static const char g_ep9_name[] = "ep9-iso"; | 3165 | |
3166 | static const char g_epa_name[] = "epa-iso"; | 3166 | EP_INFO("ep0", |
3167 | static const char g_epb_name[] = "epb-bulk"; | 3167 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), |
3168 | static const char g_epc_name[] = "epc-nulk"; | 3168 | EP_INFO("ep1-bulk", |
3169 | static const char g_epd_name[] = "epdin-int"; | 3169 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), |
3170 | 3170 | EP_INFO("ep2-bulk", | |
3171 | static const char *gp_ep_name[NUM_ENDPOINTS] = { | 3171 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), |
3172 | g_ep0_name, | 3172 | EP_INFO("ep3in-int", |
3173 | g_ep1_name, | 3173 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), |
3174 | g_ep2_name, | 3174 | EP_INFO("ep4-iso", |
3175 | g_ep3_name, | 3175 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), |
3176 | g_ep4_name, | 3176 | EP_INFO("ep5-iso", |
3177 | g_ep5_name, | 3177 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), |
3178 | g_ep6_name, | 3178 | EP_INFO("ep6-bulk", |
3179 | g_ep7_name, | 3179 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), |
3180 | g_ep8_name, | 3180 | EP_INFO("ep7-bulk", |
3181 | g_ep9_name, | 3181 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), |
3182 | g_epa_name, | 3182 | EP_INFO("ep8in-int", |
3183 | g_epb_name, | 3183 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), |
3184 | g_epc_name, | 3184 | EP_INFO("ep9-iso", |
3185 | g_epd_name, | 3185 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), |
3186 | EP_INFO("epa-iso", | ||
3187 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), | ||
3188 | EP_INFO("epb-bulk", | ||
3189 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), | ||
3190 | EP_INFO("epc-bulk", | ||
3191 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), | ||
3192 | EP_INFO("epdin-int", | ||
3193 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), | ||
3194 | |||
3195 | #undef EP_INFO | ||
3186 | }; | 3196 | }; |
3187 | 3197 | ||
3188 | /*-------------------------------------------------------------------------*/ | 3198 | /*-------------------------------------------------------------------------*/ |
@@ -3200,10 +3210,12 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) | |||
3200 | ep->desc = NULL; | 3210 | ep->desc = NULL; |
3201 | 3211 | ||
3202 | ep->ep.driver_data = NULL; | 3212 | ep->ep.driver_data = NULL; |
3203 | ep->ep.name = gp_ep_name[i]; | 3213 | ep->ep.name = ep_info[i].name; |
3214 | ep->ep.caps = ep_info[i].caps; | ||
3204 | ep->ep.ops = &nbu2ss_ep_ops; | 3215 | ep->ep.ops = &nbu2ss_ep_ops; |
3205 | 3216 | ||
3206 | ep->ep.maxpacket = (i == 0 ? EP0_PACKETSIZE : EP_PACKETSIZE); | 3217 | usb_ep_set_maxpacket_limit(&ep->ep, |
3218 | i == 0 ? EP0_PACKETSIZE : EP_PACKETSIZE); | ||
3207 | 3219 | ||
3208 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | 3220 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); |
3209 | INIT_LIST_HEAD(&ep->queue); | 3221 | INIT_LIST_HEAD(&ep->queue); |
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 62f2a7be0697..41d7cf6d63ba 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h | |||
@@ -408,8 +408,11 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg, | |||
408 | static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci) | 408 | static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci) |
409 | { | 409 | { |
410 | #ifdef CONFIG_USB_OTG_FSM | 410 | #ifdef CONFIG_USB_OTG_FSM |
411 | struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; | ||
412 | |||
411 | return ci->is_otg && ci->roles[CI_ROLE_HOST] && | 413 | return ci->is_otg && ci->roles[CI_ROLE_HOST] && |
412 | ci->roles[CI_ROLE_GADGET]; | 414 | ci->roles[CI_ROLE_GADGET] && (otg_caps->srp_support || |
415 | otg_caps->hnp_support || otg_caps->adp_support); | ||
413 | #else | 416 | #else |
414 | return false; | 417 | return false; |
415 | #endif | 418 | #endif |
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 50cd23b3b7f1..3feebf7f31f0 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -635,6 +635,19 @@ static int ci_get_platdata(struct device *dev, | |||
635 | of_usb_host_tpl_support(dev->of_node); | 635 | of_usb_host_tpl_support(dev->of_node); |
636 | } | 636 | } |
637 | 637 | ||
638 | if (platdata->dr_mode == USB_DR_MODE_OTG) { | ||
639 | /* We can support HNP and SRP of OTG 2.0 */ | ||
640 | platdata->ci_otg_caps.otg_rev = 0x0200; | ||
641 | platdata->ci_otg_caps.hnp_support = true; | ||
642 | platdata->ci_otg_caps.srp_support = true; | ||
643 | |||
644 | /* Update otg capabilities by DT properties */ | ||
645 | ret = of_usb_update_otg_caps(dev->of_node, | ||
646 | &platdata->ci_otg_caps); | ||
647 | if (ret) | ||
648 | return ret; | ||
649 | } | ||
650 | |||
638 | if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) | 651 | if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) |
639 | platdata->flags |= CI_HDRC_FORCE_FULLSPEED; | 652 | platdata->flags |= CI_HDRC_FORCE_FULLSPEED; |
640 | 653 | ||
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 64b6a4735876..080b7be3daf0 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/usb/phy.h> | 10 | #include <linux/usb/phy.h> |
11 | #include <linux/usb/otg.h> | 11 | #include <linux/usb/otg.h> |
12 | #include <linux/usb/otg-fsm.h> | 12 | #include <linux/usb/otg-fsm.h> |
13 | #include <linux/usb/chipidea.h> | ||
13 | 14 | ||
14 | #include "ci.h" | 15 | #include "ci.h" |
15 | #include "udc.h" | 16 | #include "udc.h" |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index aca7a97ee5ff..a637da25dda0 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -1631,6 +1631,20 @@ static int init_eps(struct ci_hdrc *ci) | |||
1631 | 1631 | ||
1632 | hwep->ep.name = hwep->name; | 1632 | hwep->ep.name = hwep->name; |
1633 | hwep->ep.ops = &usb_ep_ops; | 1633 | hwep->ep.ops = &usb_ep_ops; |
1634 | |||
1635 | if (i == 0) { | ||
1636 | hwep->ep.caps.type_control = true; | ||
1637 | } else { | ||
1638 | hwep->ep.caps.type_iso = true; | ||
1639 | hwep->ep.caps.type_bulk = true; | ||
1640 | hwep->ep.caps.type_int = true; | ||
1641 | } | ||
1642 | |||
1643 | if (j == TX) | ||
1644 | hwep->ep.caps.dir_in = true; | ||
1645 | else | ||
1646 | hwep->ep.caps.dir_out = true; | ||
1647 | |||
1634 | /* | 1648 | /* |
1635 | * for ep0: maxP defined in desc, for other | 1649 | * for ep0: maxP defined in desc, for other |
1636 | * eps, maxP is set by epautoconfig() called | 1650 | * eps, maxP is set by epautoconfig() called |
@@ -1834,6 +1848,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) | |||
1834 | static int udc_start(struct ci_hdrc *ci) | 1848 | static int udc_start(struct ci_hdrc *ci) |
1835 | { | 1849 | { |
1836 | struct device *dev = ci->dev; | 1850 | struct device *dev = ci->dev; |
1851 | struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; | ||
1837 | int retval = 0; | 1852 | int retval = 0; |
1838 | 1853 | ||
1839 | spin_lock_init(&ci->lock); | 1854 | spin_lock_init(&ci->lock); |
@@ -1841,8 +1856,12 @@ static int udc_start(struct ci_hdrc *ci) | |||
1841 | ci->gadget.ops = &usb_gadget_ops; | 1856 | ci->gadget.ops = &usb_gadget_ops; |
1842 | ci->gadget.speed = USB_SPEED_UNKNOWN; | 1857 | ci->gadget.speed = USB_SPEED_UNKNOWN; |
1843 | ci->gadget.max_speed = USB_SPEED_HIGH; | 1858 | ci->gadget.max_speed = USB_SPEED_HIGH; |
1844 | ci->gadget.is_otg = ci->is_otg ? 1 : 0; | ||
1845 | ci->gadget.name = ci->platdata->name; | 1859 | ci->gadget.name = ci->platdata->name; |
1860 | ci->gadget.otg_caps = otg_caps; | ||
1861 | |||
1862 | if (ci->is_otg && (otg_caps->hnp_support || otg_caps->srp_support || | ||
1863 | otg_caps->adp_support)) | ||
1864 | ci->gadget.is_otg = 1; | ||
1846 | 1865 | ||
1847 | INIT_LIST_HEAD(&ci->gadget.ep_list); | 1866 | INIT_LIST_HEAD(&ci->gadget.ep_list); |
1848 | 1867 | ||
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index b530fd403ffb..9e39286a4e5a 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c | |||
@@ -154,6 +154,62 @@ bool of_usb_host_tpl_support(struct device_node *np) | |||
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); | 156 | EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); |
157 | |||
158 | /** | ||
159 | * of_usb_update_otg_caps - to update usb otg capabilities according to | ||
160 | * the passed properties in DT. | ||
161 | * @np: Pointer to the given device_node | ||
162 | * @otg_caps: Pointer to the target usb_otg_caps to be set | ||
163 | * | ||
164 | * The function updates the otg capabilities | ||
165 | */ | ||
166 | int of_usb_update_otg_caps(struct device_node *np, | ||
167 | struct usb_otg_caps *otg_caps) | ||
168 | { | ||
169 | u32 otg_rev; | ||
170 | |||
171 | if (!otg_caps) | ||
172 | return -EINVAL; | ||
173 | |||
174 | if (!of_property_read_u32(np, "otg-rev", &otg_rev)) { | ||
175 | switch (otg_rev) { | ||
176 | case 0x0100: | ||
177 | case 0x0120: | ||
178 | case 0x0130: | ||
179 | case 0x0200: | ||
180 | /* Choose the lesser one if it's already been set */ | ||
181 | if (otg_caps->otg_rev) | ||
182 | otg_caps->otg_rev = min_t(u16, otg_rev, | ||
183 | otg_caps->otg_rev); | ||
184 | else | ||
185 | otg_caps->otg_rev = otg_rev; | ||
186 | break; | ||
187 | default: | ||
188 | pr_err("%s: unsupported otg-rev: 0x%x\n", | ||
189 | np->full_name, otg_rev); | ||
190 | return -EINVAL; | ||
191 | } | ||
192 | } else { | ||
193 | /* | ||
194 | * otg-rev is mandatory for otg properties, if not passed | ||
195 | * we set it to be 0 and assume it's a legacy otg device. | ||
196 | * Non-dt platform can set it afterwards. | ||
197 | */ | ||
198 | otg_caps->otg_rev = 0; | ||
199 | } | ||
200 | |||
201 | if (of_find_property(np, "hnp-disable", NULL)) | ||
202 | otg_caps->hnp_support = false; | ||
203 | if (of_find_property(np, "srp-disable", NULL)) | ||
204 | otg_caps->srp_support = false; | ||
205 | if (of_find_property(np, "adp-disable", NULL) || | ||
206 | (otg_caps->otg_rev < 0x0200)) | ||
207 | otg_caps->adp_support = false; | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); | ||
212 | |||
157 | #endif | 213 | #endif |
158 | 214 | ||
159 | MODULE_LICENSE("GPL"); | 215 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c09238..3ee5b4c77a1f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c | |||
@@ -2880,7 +2880,7 @@ static int s3c_hsotg_ep_sethalt(struct usb_ep *ep, int value) | |||
2880 | epctl = readl(hs->regs + epreg); | 2880 | epctl = readl(hs->regs + epreg); |
2881 | 2881 | ||
2882 | if (value) { | 2882 | if (value) { |
2883 | epctl |= DXEPCTL_STALL + DXEPCTL_SNAK; | 2883 | epctl |= DXEPCTL_STALL | DXEPCTL_SNAK; |
2884 | if (epctl & DXEPCTL_EPENA) | 2884 | if (epctl & DXEPCTL_EPENA) |
2885 | epctl |= DXEPCTL_EPDIS; | 2885 | epctl |= DXEPCTL_EPDIS; |
2886 | } else { | 2886 | } else { |
@@ -3289,6 +3289,19 @@ static void s3c_hsotg_initep(struct dwc2_hsotg *hsotg, | |||
3289 | usb_ep_set_maxpacket_limit(&hs_ep->ep, epnum ? 1024 : EP0_MPS_LIMIT); | 3289 | usb_ep_set_maxpacket_limit(&hs_ep->ep, epnum ? 1024 : EP0_MPS_LIMIT); |
3290 | hs_ep->ep.ops = &s3c_hsotg_ep_ops; | 3290 | hs_ep->ep.ops = &s3c_hsotg_ep_ops; |
3291 | 3291 | ||
3292 | if (epnum == 0) { | ||
3293 | hs_ep->ep.caps.type_control = true; | ||
3294 | } else { | ||
3295 | hs_ep->ep.caps.type_iso = true; | ||
3296 | hs_ep->ep.caps.type_bulk = true; | ||
3297 | hs_ep->ep.caps.type_int = true; | ||
3298 | } | ||
3299 | |||
3300 | if (dir_in) | ||
3301 | hs_ep->ep.caps.dir_in = true; | ||
3302 | else | ||
3303 | hs_ep->ep.caps.dir_out = true; | ||
3304 | |||
3292 | /* | 3305 | /* |
3293 | * if we're using dma, we need to set the next-endpoint pointer | 3306 | * if we're using dma, we need to set the next-endpoint pointer |
3294 | * to be something valid. | 3307 | * to be something valid. |
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index dede32e809b6..5a42c4590402 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig | |||
@@ -104,11 +104,4 @@ config USB_DWC3_QCOM | |||
104 | Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, | 104 | Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, |
105 | say 'Y' or 'M' if you have one such device. | 105 | say 'Y' or 'M' if you have one such device. |
106 | 106 | ||
107 | comment "Debugging features" | ||
108 | |||
109 | config USB_DWC3_DEBUG | ||
110 | bool "Enable Debugging Messages" | ||
111 | help | ||
112 | Say Y here to enable debugging messages on DWC3 Driver. | ||
113 | |||
114 | endif | 107 | endif |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index c7076e37c4ed..acc951d46c27 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -1,8 +1,6 @@ | |||
1 | # define_trace.h needs to know how to find our header | 1 | # define_trace.h needs to know how to find our header |
2 | CFLAGS_trace.o := -I$(src) | 2 | CFLAGS_trace.o := -I$(src) |
3 | 3 | ||
4 | ccflags-$(CONFIG_USB_DWC3_DEBUG) := -DDEBUG | ||
5 | |||
6 | obj-$(CONFIG_USB_DWC3) += dwc3.o | 4 | obj-$(CONFIG_USB_DWC3) += dwc3.o |
7 | 5 | ||
8 | dwc3-y := core.o debug.o trace.o | 6 | dwc3-y := core.o debug.o trace.o |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index ff5773c66b84..064123e44566 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -455,8 +455,6 @@ static int dwc3_phy_setup(struct dwc3 *dwc) | |||
455 | reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; | 455 | reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; |
456 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | 456 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); |
457 | } else { | 457 | } else { |
458 | dev_warn(dwc->dev, "HSPHY Interface not defined\n"); | ||
459 | |||
460 | /* Relying on default value. */ | 458 | /* Relying on default value. */ |
461 | if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI)) | 459 | if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI)) |
462 | break; | 460 | break; |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 7bd0a95b2815..dd5cb5577dca 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -145,7 +145,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev) | |||
145 | 145 | ||
146 | exynos->susp_clk = devm_clk_get(dev, "usbdrd30_susp_clk"); | 146 | exynos->susp_clk = devm_clk_get(dev, "usbdrd30_susp_clk"); |
147 | if (IS_ERR(exynos->susp_clk)) { | 147 | if (IS_ERR(exynos->susp_clk)) { |
148 | dev_dbg(dev, "no suspend clk specified\n"); | 148 | dev_info(dev, "no suspend clk specified\n"); |
149 | exynos->susp_clk = NULL; | 149 | exynos->susp_clk = NULL; |
150 | } | 150 | } |
151 | clk_prepare_enable(exynos->susp_clk); | 151 | clk_prepare_enable(exynos->susp_clk); |
diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index fe3b9335a74e..2be268d2423d 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c | |||
@@ -115,7 +115,7 @@ static int kdwc3_probe(struct platform_device *pdev) | |||
115 | 115 | ||
116 | error = clk_prepare_enable(kdwc->clk); | 116 | error = clk_prepare_enable(kdwc->clk); |
117 | if (error < 0) { | 117 | if (error < 0) { |
118 | dev_dbg(kdwc->dev, "unable to enable usb clock, err %d\n", | 118 | dev_err(kdwc->dev, "unable to enable usb clock, error %d\n", |
119 | error); | 119 | error); |
120 | return error; | 120 | return error; |
121 | } | 121 | } |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 6b486a36863c..a5a1b7c45743 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -128,8 +128,7 @@ struct dwc3_omap { | |||
128 | 128 | ||
129 | u32 dma_status:1; | 129 | u32 dma_status:1; |
130 | 130 | ||
131 | struct extcon_specific_cable_nb extcon_vbus_dev; | 131 | struct extcon_dev *edev; |
132 | struct extcon_specific_cable_nb extcon_id_dev; | ||
133 | struct notifier_block vbus_nb; | 132 | struct notifier_block vbus_nb; |
134 | struct notifier_block id_nb; | 133 | struct notifier_block id_nb; |
135 | 134 | ||
@@ -225,12 +224,10 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, | |||
225 | 224 | ||
226 | switch (status) { | 225 | switch (status) { |
227 | case OMAP_DWC3_ID_GROUND: | 226 | case OMAP_DWC3_ID_GROUND: |
228 | dev_dbg(omap->dev, "ID GND\n"); | ||
229 | |||
230 | if (omap->vbus_reg) { | 227 | if (omap->vbus_reg) { |
231 | ret = regulator_enable(omap->vbus_reg); | 228 | ret = regulator_enable(omap->vbus_reg); |
232 | if (ret) { | 229 | if (ret) { |
233 | dev_dbg(omap->dev, "regulator enable failed\n"); | 230 | dev_err(omap->dev, "regulator enable failed\n"); |
234 | return; | 231 | return; |
235 | } | 232 | } |
236 | } | 233 | } |
@@ -245,8 +242,6 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, | |||
245 | break; | 242 | break; |
246 | 243 | ||
247 | case OMAP_DWC3_VBUS_VALID: | 244 | case OMAP_DWC3_VBUS_VALID: |
248 | dev_dbg(omap->dev, "VBUS Connect\n"); | ||
249 | |||
250 | val = dwc3_omap_read_utmi_ctrl(omap); | 245 | val = dwc3_omap_read_utmi_ctrl(omap); |
251 | val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND; | 246 | val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND; |
252 | val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG | 247 | val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG |
@@ -261,8 +256,6 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, | |||
261 | regulator_disable(omap->vbus_reg); | 256 | regulator_disable(omap->vbus_reg); |
262 | 257 | ||
263 | case OMAP_DWC3_VBUS_OFF: | 258 | case OMAP_DWC3_VBUS_OFF: |
264 | dev_dbg(omap->dev, "VBUS Disconnect\n"); | ||
265 | |||
266 | val = dwc3_omap_read_utmi_ctrl(omap); | 259 | val = dwc3_omap_read_utmi_ctrl(omap); |
267 | val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID | 260 | val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID |
268 | | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID | 261 | | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID |
@@ -273,7 +266,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, | |||
273 | break; | 266 | break; |
274 | 267 | ||
275 | default: | 268 | default: |
276 | dev_dbg(omap->dev, "invalid state\n"); | 269 | dev_WARN(omap->dev, "invalid state\n"); |
277 | } | 270 | } |
278 | } | 271 | } |
279 | 272 | ||
@@ -284,37 +277,8 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | |||
284 | 277 | ||
285 | reg = dwc3_omap_read_irqmisc_status(omap); | 278 | reg = dwc3_omap_read_irqmisc_status(omap); |
286 | 279 | ||
287 | if (reg & USBOTGSS_IRQMISC_DMADISABLECLR) { | 280 | if (reg & USBOTGSS_IRQMISC_DMADISABLECLR) |
288 | dev_dbg(omap->dev, "DMA Disable was Cleared\n"); | ||
289 | omap->dma_status = false; | 281 | omap->dma_status = false; |
290 | } | ||
291 | |||
292 | if (reg & USBOTGSS_IRQMISC_OEVT) | ||
293 | dev_dbg(omap->dev, "OTG Event\n"); | ||
294 | |||
295 | if (reg & USBOTGSS_IRQMISC_DRVVBUS_RISE) | ||
296 | dev_dbg(omap->dev, "DRVVBUS Rise\n"); | ||
297 | |||
298 | if (reg & USBOTGSS_IRQMISC_CHRGVBUS_RISE) | ||
299 | dev_dbg(omap->dev, "CHRGVBUS Rise\n"); | ||
300 | |||
301 | if (reg & USBOTGSS_IRQMISC_DISCHRGVBUS_RISE) | ||
302 | dev_dbg(omap->dev, "DISCHRGVBUS Rise\n"); | ||
303 | |||
304 | if (reg & USBOTGSS_IRQMISC_IDPULLUP_RISE) | ||
305 | dev_dbg(omap->dev, "IDPULLUP Rise\n"); | ||
306 | |||
307 | if (reg & USBOTGSS_IRQMISC_DRVVBUS_FALL) | ||
308 | dev_dbg(omap->dev, "DRVVBUS Fall\n"); | ||
309 | |||
310 | if (reg & USBOTGSS_IRQMISC_CHRGVBUS_FALL) | ||
311 | dev_dbg(omap->dev, "CHRGVBUS Fall\n"); | ||
312 | |||
313 | if (reg & USBOTGSS_IRQMISC_DISCHRGVBUS_FALL) | ||
314 | dev_dbg(omap->dev, "DISCHRGVBUS Fall\n"); | ||
315 | |||
316 | if (reg & USBOTGSS_IRQMISC_IDPULLUP_FALL) | ||
317 | dev_dbg(omap->dev, "IDPULLUP Fall\n"); | ||
318 | 282 | ||
319 | dwc3_omap_write_irqmisc_status(omap, reg); | 283 | dwc3_omap_write_irqmisc_status(omap, reg); |
320 | 284 | ||
@@ -434,7 +398,7 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap) | |||
434 | reg &= ~USBOTGSS_UTMI_OTG_CTRL_SW_MODE; | 398 | reg &= ~USBOTGSS_UTMI_OTG_CTRL_SW_MODE; |
435 | break; | 399 | break; |
436 | default: | 400 | default: |
437 | dev_dbg(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode); | 401 | dev_WARN(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode); |
438 | } | 402 | } |
439 | 403 | ||
440 | dwc3_omap_write_utmi_ctrl(omap, reg); | 404 | dwc3_omap_write_utmi_ctrl(omap, reg); |
@@ -454,23 +418,23 @@ static int dwc3_omap_extcon_register(struct dwc3_omap *omap) | |||
454 | } | 418 | } |
455 | 419 | ||
456 | omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier; | 420 | omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier; |
457 | ret = extcon_register_interest(&omap->extcon_vbus_dev, | 421 | ret = extcon_register_notifier(edev, EXTCON_USB, |
458 | edev->name, "USB", | 422 | &omap->vbus_nb); |
459 | &omap->vbus_nb); | ||
460 | if (ret < 0) | 423 | if (ret < 0) |
461 | dev_vdbg(omap->dev, "failed to register notifier for USB\n"); | 424 | dev_vdbg(omap->dev, "failed to register notifier for USB\n"); |
462 | 425 | ||
463 | omap->id_nb.notifier_call = dwc3_omap_id_notifier; | 426 | omap->id_nb.notifier_call = dwc3_omap_id_notifier; |
464 | ret = extcon_register_interest(&omap->extcon_id_dev, | 427 | ret = extcon_register_notifier(edev, EXTCON_USB_HOST, |
465 | edev->name, "USB-HOST", | 428 | &omap->id_nb); |
466 | &omap->id_nb); | ||
467 | if (ret < 0) | 429 | if (ret < 0) |
468 | dev_vdbg(omap->dev, "failed to register notifier for USB-HOST\n"); | 430 | dev_vdbg(omap->dev, "failed to register notifier for USB-HOST\n"); |
469 | 431 | ||
470 | if (extcon_get_cable_state(edev, "USB") == true) | 432 | if (extcon_get_cable_state_(edev, EXTCON_USB) == true) |
471 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); | 433 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); |
472 | if (extcon_get_cable_state(edev, "USB-HOST") == true) | 434 | if (extcon_get_cable_state_(edev, EXTCON_USB_HOST) == true) |
473 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); | 435 | dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); |
436 | |||
437 | omap->edev = edev; | ||
474 | } | 438 | } |
475 | 439 | ||
476 | return 0; | 440 | return 0; |
@@ -565,11 +529,8 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
565 | return 0; | 529 | return 0; |
566 | 530 | ||
567 | err3: | 531 | err3: |
568 | if (omap->extcon_vbus_dev.edev) | 532 | extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); |
569 | extcon_unregister_interest(&omap->extcon_vbus_dev); | 533 | extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); |
570 | if (omap->extcon_id_dev.edev) | ||
571 | extcon_unregister_interest(&omap->extcon_id_dev); | ||
572 | |||
573 | err2: | 534 | err2: |
574 | dwc3_omap_disable_irqs(omap); | 535 | dwc3_omap_disable_irqs(omap); |
575 | 536 | ||
@@ -586,10 +547,8 @@ static int dwc3_omap_remove(struct platform_device *pdev) | |||
586 | { | 547 | { |
587 | struct dwc3_omap *omap = platform_get_drvdata(pdev); | 548 | struct dwc3_omap *omap = platform_get_drvdata(pdev); |
588 | 549 | ||
589 | if (omap->extcon_vbus_dev.edev) | 550 | extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); |
590 | extcon_unregister_interest(&omap->extcon_vbus_dev); | 551 | extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); |
591 | if (omap->extcon_id_dev.edev) | ||
592 | extcon_unregister_interest(&omap->extcon_id_dev); | ||
593 | dwc3_omap_disable_irqs(omap); | 552 | dwc3_omap_disable_irqs(omap); |
594 | of_platform_depopulate(omap->dev); | 553 | of_platform_depopulate(omap->dev); |
595 | pm_runtime_put_sync(&pdev->dev); | 554 | pm_runtime_put_sync(&pdev->dev); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 27e4fc896e9d..f62617999f3c 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -83,17 +83,23 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) | |||
83 | acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), | 83 | acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), |
84 | acpi_dwc3_byt_gpios); | 84 | acpi_dwc3_byt_gpios); |
85 | 85 | ||
86 | /* These GPIOs will turn on the USB2 PHY */ | 86 | /* |
87 | gpio = gpiod_get(&pdev->dev, "cs"); | 87 | * These GPIOs will turn on the USB2 PHY. Note that we have to |
88 | if (!IS_ERR(gpio)) { | 88 | * put the gpio descriptors again here because the phy driver |
89 | gpiod_direction_output(gpio, 0); | 89 | * might want to grab them, too. |
90 | gpiod_set_value_cansleep(gpio, 1); | 90 | */ |
91 | gpiod_put(gpio); | 91 | gpio = gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW); |
92 | } | 92 | if (IS_ERR(gpio)) |
93 | return PTR_ERR(gpio); | ||
94 | |||
95 | gpiod_set_value_cansleep(gpio, 1); | ||
96 | gpiod_put(gpio); | ||
97 | |||
98 | gpio = gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); | ||
99 | if (IS_ERR(gpio)) | ||
100 | return PTR_ERR(gpio); | ||
93 | 101 | ||
94 | gpio = gpiod_get(&pdev->dev, "reset"); | 102 | if (gpio) { |
95 | if (!IS_ERR(gpio)) { | ||
96 | gpiod_direction_output(gpio, 0); | ||
97 | gpiod_set_value_cansleep(gpio, 1); | 103 | gpiod_set_value_cansleep(gpio, 1); |
98 | gpiod_put(gpio); | 104 | gpiod_put(gpio); |
99 | usleep_range(10000, 11000); | 105 | usleep_range(10000, 11000); |
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 8c2e8eec80c2..088026048f49 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c | |||
@@ -48,13 +48,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev) | |||
48 | 48 | ||
49 | qdwc->iface_clk = devm_clk_get(qdwc->dev, "iface"); | 49 | qdwc->iface_clk = devm_clk_get(qdwc->dev, "iface"); |
50 | if (IS_ERR(qdwc->iface_clk)) { | 50 | if (IS_ERR(qdwc->iface_clk)) { |
51 | dev_dbg(qdwc->dev, "failed to get optional iface clock\n"); | 51 | dev_info(qdwc->dev, "failed to get optional iface clock\n"); |
52 | qdwc->iface_clk = NULL; | 52 | qdwc->iface_clk = NULL; |
53 | } | 53 | } |
54 | 54 | ||
55 | qdwc->sleep_clk = devm_clk_get(qdwc->dev, "sleep"); | 55 | qdwc->sleep_clk = devm_clk_get(qdwc->dev, "sleep"); |
56 | if (IS_ERR(qdwc->sleep_clk)) { | 56 | if (IS_ERR(qdwc->sleep_clk)) { |
57 | dev_dbg(qdwc->dev, "failed to get optional sleep clock\n"); | 57 | dev_info(qdwc->dev, "failed to get optional sleep clock\n"); |
58 | qdwc->sleep_clk = NULL; | 58 | qdwc->sleep_clk = NULL; |
59 | } | 59 | } |
60 | 60 | ||
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c index 4a1a543deeda..de4d52f62517 100644 --- a/drivers/usb/dwc3/dwc3-st.c +++ b/drivers/usb/dwc3/dwc3-st.c | |||
@@ -135,8 +135,6 @@ static int st_dwc3_drd_init(struct st_dwc3 *dwc3_data) | |||
135 | | USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2); | 135 | | USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2); |
136 | 136 | ||
137 | val |= USB3_DEVICE_NOT_HOST; | 137 | val |= USB3_DEVICE_NOT_HOST; |
138 | |||
139 | dev_dbg(dwc3_data->dev, "Configuring as Device\n"); | ||
140 | break; | 138 | break; |
141 | 139 | ||
142 | case USB_DR_MODE_HOST: | 140 | case USB_DR_MODE_HOST: |
@@ -154,8 +152,6 @@ static int st_dwc3_drd_init(struct st_dwc3 *dwc3_data) | |||
154 | */ | 152 | */ |
155 | 153 | ||
156 | val |= USB3_DELAY_VBUSVALID; | 154 | val |= USB3_DELAY_VBUSVALID; |
157 | |||
158 | dev_dbg(dwc3_data->dev, "Configuring as Host\n"); | ||
159 | break; | 155 | break; |
160 | 156 | ||
161 | default: | 157 | default: |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 69e769c35cf5..5320e939e090 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -56,7 +56,7 @@ static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | 58 | static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, |
59 | u32 len, u32 type) | 59 | u32 len, u32 type, bool chain) |
60 | { | 60 | { |
61 | struct dwc3_gadget_ep_cmd_params params; | 61 | struct dwc3_gadget_ep_cmd_params params; |
62 | struct dwc3_trb *trb; | 62 | struct dwc3_trb *trb; |
@@ -70,7 +70,10 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | trb = dwc->ep0_trb; | 73 | trb = &dwc->ep0_trb[dep->free_slot]; |
74 | |||
75 | if (chain) | ||
76 | dep->free_slot++; | ||
74 | 77 | ||
75 | trb->bpl = lower_32_bits(buf_dma); | 78 | trb->bpl = lower_32_bits(buf_dma); |
76 | trb->bph = upper_32_bits(buf_dma); | 79 | trb->bph = upper_32_bits(buf_dma); |
@@ -78,10 +81,17 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
78 | trb->ctrl = type; | 81 | trb->ctrl = type; |
79 | 82 | ||
80 | trb->ctrl |= (DWC3_TRB_CTRL_HWO | 83 | trb->ctrl |= (DWC3_TRB_CTRL_HWO |
81 | | DWC3_TRB_CTRL_LST | ||
82 | | DWC3_TRB_CTRL_IOC | ||
83 | | DWC3_TRB_CTRL_ISP_IMI); | 84 | | DWC3_TRB_CTRL_ISP_IMI); |
84 | 85 | ||
86 | if (chain) | ||
87 | trb->ctrl |= DWC3_TRB_CTRL_CHN; | ||
88 | else | ||
89 | trb->ctrl |= (DWC3_TRB_CTRL_IOC | ||
90 | | DWC3_TRB_CTRL_LST); | ||
91 | |||
92 | if (chain) | ||
93 | return 0; | ||
94 | |||
85 | memset(¶ms, 0, sizeof(params)); | 95 | memset(¶ms, 0, sizeof(params)); |
86 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); | 96 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); |
87 | params.param1 = lower_32_bits(dwc->ep0_trb_addr); | 97 | params.param1 = lower_32_bits(dwc->ep0_trb_addr); |
@@ -302,7 +312,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) | |||
302 | int ret; | 312 | int ret; |
303 | 313 | ||
304 | ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, | 314 | ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, |
305 | DWC3_TRBCTL_CONTROL_SETUP); | 315 | DWC3_TRBCTL_CONTROL_SETUP, false); |
306 | WARN_ON(ret < 0); | 316 | WARN_ON(ret < 0); |
307 | } | 317 | } |
308 | 318 | ||
@@ -783,7 +793,11 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
783 | struct usb_request *ur; | 793 | struct usb_request *ur; |
784 | struct dwc3_trb *trb; | 794 | struct dwc3_trb *trb; |
785 | struct dwc3_ep *ep0; | 795 | struct dwc3_ep *ep0; |
786 | u32 transferred; | 796 | unsigned transfer_size = 0; |
797 | unsigned maxp; | ||
798 | unsigned remaining_ur_length; | ||
799 | void *buf; | ||
800 | u32 transferred = 0; | ||
787 | u32 status; | 801 | u32 status; |
788 | u32 length; | 802 | u32 length; |
789 | u8 epnum; | 803 | u8 epnum; |
@@ -812,17 +826,37 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
812 | } | 826 | } |
813 | 827 | ||
814 | ur = &r->request; | 828 | ur = &r->request; |
829 | buf = ur->buf; | ||
830 | remaining_ur_length = ur->length; | ||
815 | 831 | ||
816 | length = trb->size & DWC3_TRB_SIZE_MASK; | 832 | length = trb->size & DWC3_TRB_SIZE_MASK; |
817 | 833 | ||
834 | maxp = ep0->endpoint.maxpacket; | ||
835 | |||
818 | if (dwc->ep0_bounced) { | 836 | if (dwc->ep0_bounced) { |
819 | unsigned transfer_size = ur->length; | 837 | /* |
820 | unsigned maxp = ep0->endpoint.maxpacket; | 838 | * Handle the first TRB before handling the bounce buffer if |
839 | * the request length is greater than the bounce buffer size | ||
840 | */ | ||
841 | if (ur->length > DWC3_EP0_BOUNCE_SIZE) { | ||
842 | transfer_size = ALIGN(ur->length - maxp, maxp); | ||
843 | transferred = transfer_size - length; | ||
844 | buf = (u8 *)buf + transferred; | ||
845 | ur->actual += transferred; | ||
846 | remaining_ur_length -= transferred; | ||
847 | |||
848 | trb++; | ||
849 | length = trb->size & DWC3_TRB_SIZE_MASK; | ||
821 | 850 | ||
822 | transfer_size += (maxp - (transfer_size % maxp)); | 851 | ep0->free_slot = 0; |
823 | transferred = min_t(u32, ur->length, | 852 | } |
824 | transfer_size - length); | 853 | |
825 | memcpy(ur->buf, dwc->ep0_bounce, transferred); | 854 | transfer_size = roundup((ur->length - transfer_size), |
855 | maxp); | ||
856 | |||
857 | transferred = min_t(u32, remaining_ur_length, | ||
858 | transfer_size - length); | ||
859 | memcpy(buf, dwc->ep0_bounce, transferred); | ||
826 | } else { | 860 | } else { |
827 | transferred = ur->length - length; | 861 | transferred = ur->length - length; |
828 | } | 862 | } |
@@ -844,7 +878,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
844 | 878 | ||
845 | ret = dwc3_ep0_start_trans(dwc, epnum, | 879 | ret = dwc3_ep0_start_trans(dwc, epnum, |
846 | dwc->ctrl_req_addr, 0, | 880 | dwc->ctrl_req_addr, 0, |
847 | DWC3_TRBCTL_CONTROL_DATA); | 881 | DWC3_TRBCTL_CONTROL_DATA, false); |
848 | WARN_ON(ret < 0); | 882 | WARN_ON(ret < 0); |
849 | } | 883 | } |
850 | } | 884 | } |
@@ -928,10 +962,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
928 | if (req->request.length == 0) { | 962 | if (req->request.length == 0) { |
929 | ret = dwc3_ep0_start_trans(dwc, dep->number, | 963 | ret = dwc3_ep0_start_trans(dwc, dep->number, |
930 | dwc->ctrl_req_addr, 0, | 964 | dwc->ctrl_req_addr, 0, |
931 | DWC3_TRBCTL_CONTROL_DATA); | 965 | DWC3_TRBCTL_CONTROL_DATA, false); |
932 | } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) | 966 | } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) |
933 | && (dep->number == 0)) { | 967 | && (dep->number == 0)) { |
934 | u32 transfer_size; | 968 | u32 transfer_size = 0; |
935 | u32 maxpacket; | 969 | u32 maxpacket; |
936 | 970 | ||
937 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, | 971 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, |
@@ -941,21 +975,26 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
941 | return; | 975 | return; |
942 | } | 976 | } |
943 | 977 | ||
944 | WARN_ON(req->request.length > DWC3_EP0_BOUNCE_SIZE); | ||
945 | |||
946 | maxpacket = dep->endpoint.maxpacket; | 978 | maxpacket = dep->endpoint.maxpacket; |
947 | transfer_size = roundup(req->request.length, maxpacket); | 979 | |
980 | if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { | ||
981 | transfer_size = ALIGN(req->request.length - maxpacket, | ||
982 | maxpacket); | ||
983 | ret = dwc3_ep0_start_trans(dwc, dep->number, | ||
984 | req->request.dma, | ||
985 | transfer_size, | ||
986 | DWC3_TRBCTL_CONTROL_DATA, | ||
987 | true); | ||
988 | } | ||
989 | |||
990 | transfer_size = roundup((req->request.length - transfer_size), | ||
991 | maxpacket); | ||
948 | 992 | ||
949 | dwc->ep0_bounced = true; | 993 | dwc->ep0_bounced = true; |
950 | 994 | ||
951 | /* | ||
952 | * REVISIT in case request length is bigger than | ||
953 | * DWC3_EP0_BOUNCE_SIZE we will need two chained | ||
954 | * TRBs to handle the transfer. | ||
955 | */ | ||
956 | ret = dwc3_ep0_start_trans(dwc, dep->number, | 995 | ret = dwc3_ep0_start_trans(dwc, dep->number, |
957 | dwc->ep0_bounce_addr, transfer_size, | 996 | dwc->ep0_bounce_addr, transfer_size, |
958 | DWC3_TRBCTL_CONTROL_DATA); | 997 | DWC3_TRBCTL_CONTROL_DATA, false); |
959 | } else { | 998 | } else { |
960 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, | 999 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, |
961 | dep->number); | 1000 | dep->number); |
@@ -965,7 +1004,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
965 | } | 1004 | } |
966 | 1005 | ||
967 | ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, | 1006 | ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, |
968 | req->request.length, DWC3_TRBCTL_CONTROL_DATA); | 1007 | req->request.length, DWC3_TRBCTL_CONTROL_DATA, |
1008 | false); | ||
969 | } | 1009 | } |
970 | 1010 | ||
971 | WARN_ON(ret < 0); | 1011 | WARN_ON(ret < 0); |
@@ -980,7 +1020,7 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) | |||
980 | : DWC3_TRBCTL_CONTROL_STATUS2; | 1020 | : DWC3_TRBCTL_CONTROL_STATUS2; |
981 | 1021 | ||
982 | return dwc3_ep0_start_trans(dwc, dep->number, | 1022 | return dwc3_ep0_start_trans(dwc, dep->number, |
983 | dwc->ctrl_req_addr, 0, type); | 1023 | dwc->ctrl_req_addr, 0, type, false); |
984 | } | 1024 | } |
985 | 1025 | ||
986 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) | 1026 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 333a7c0078fc..0c25704dcb6b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -547,6 +547,23 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
547 | trb_link->ctrl |= DWC3_TRB_CTRL_HWO; | 547 | trb_link->ctrl |= DWC3_TRB_CTRL_HWO; |
548 | } | 548 | } |
549 | 549 | ||
550 | switch (usb_endpoint_type(desc)) { | ||
551 | case USB_ENDPOINT_XFER_CONTROL: | ||
552 | strlcat(dep->name, "-control", sizeof(dep->name)); | ||
553 | break; | ||
554 | case USB_ENDPOINT_XFER_ISOC: | ||
555 | strlcat(dep->name, "-isoc", sizeof(dep->name)); | ||
556 | break; | ||
557 | case USB_ENDPOINT_XFER_BULK: | ||
558 | strlcat(dep->name, "-bulk", sizeof(dep->name)); | ||
559 | break; | ||
560 | case USB_ENDPOINT_XFER_INT: | ||
561 | strlcat(dep->name, "-int", sizeof(dep->name)); | ||
562 | break; | ||
563 | default: | ||
564 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | ||
565 | } | ||
566 | |||
550 | return 0; | 567 | return 0; |
551 | } | 568 | } |
552 | 569 | ||
@@ -586,6 +603,8 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) | |||
586 | struct dwc3 *dwc = dep->dwc; | 603 | struct dwc3 *dwc = dep->dwc; |
587 | u32 reg; | 604 | u32 reg; |
588 | 605 | ||
606 | dwc3_trace(trace_dwc3_gadget, "Disabling %s", dep->name); | ||
607 | |||
589 | dwc3_remove_requests(dwc, dep); | 608 | dwc3_remove_requests(dwc, dep); |
590 | 609 | ||
591 | /* make sure HW endpoint isn't stalled */ | 610 | /* make sure HW endpoint isn't stalled */ |
@@ -602,6 +621,10 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) | |||
602 | dep->type = 0; | 621 | dep->type = 0; |
603 | dep->flags = 0; | 622 | dep->flags = 0; |
604 | 623 | ||
624 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", | ||
625 | dep->number >> 1, | ||
626 | (dep->number & 1) ? "in" : "out"); | ||
627 | |||
605 | return 0; | 628 | return 0; |
606 | } | 629 | } |
607 | 630 | ||
@@ -647,23 +670,6 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
647 | return 0; | 670 | return 0; |
648 | } | 671 | } |
649 | 672 | ||
650 | switch (usb_endpoint_type(desc)) { | ||
651 | case USB_ENDPOINT_XFER_CONTROL: | ||
652 | strlcat(dep->name, "-control", sizeof(dep->name)); | ||
653 | break; | ||
654 | case USB_ENDPOINT_XFER_ISOC: | ||
655 | strlcat(dep->name, "-isoc", sizeof(dep->name)); | ||
656 | break; | ||
657 | case USB_ENDPOINT_XFER_BULK: | ||
658 | strlcat(dep->name, "-bulk", sizeof(dep->name)); | ||
659 | break; | ||
660 | case USB_ENDPOINT_XFER_INT: | ||
661 | strlcat(dep->name, "-int", sizeof(dep->name)); | ||
662 | break; | ||
663 | default: | ||
664 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | ||
665 | } | ||
666 | |||
667 | spin_lock_irqsave(&dwc->lock, flags); | 673 | spin_lock_irqsave(&dwc->lock, flags); |
668 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false); | 674 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false); |
669 | spin_unlock_irqrestore(&dwc->lock, flags); | 675 | spin_unlock_irqrestore(&dwc->lock, flags); |
@@ -692,10 +698,6 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep) | |||
692 | return 0; | 698 | return 0; |
693 | } | 699 | } |
694 | 700 | ||
695 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", | ||
696 | dep->number >> 1, | ||
697 | (dep->number & 1) ? "in" : "out"); | ||
698 | |||
699 | spin_lock_irqsave(&dwc->lock, flags); | 701 | spin_lock_irqsave(&dwc->lock, flags); |
700 | ret = __dwc3_gadget_ep_disable(dep); | 702 | ret = __dwc3_gadget_ep_disable(dep); |
701 | spin_unlock_irqrestore(&dwc->lock, flags); | 703 | spin_unlock_irqrestore(&dwc->lock, flags); |
@@ -1713,6 +1715,17 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, | |||
1713 | return ret; | 1715 | return ret; |
1714 | } | 1716 | } |
1715 | 1717 | ||
1718 | if (epnum == 0 || epnum == 1) { | ||
1719 | dep->endpoint.caps.type_control = true; | ||
1720 | } else { | ||
1721 | dep->endpoint.caps.type_iso = true; | ||
1722 | dep->endpoint.caps.type_bulk = true; | ||
1723 | dep->endpoint.caps.type_int = true; | ||
1724 | } | ||
1725 | |||
1726 | dep->endpoint.caps.dir_in = !!direction; | ||
1727 | dep->endpoint.caps.dir_out = !direction; | ||
1728 | |||
1716 | INIT_LIST_HEAD(&dep->request_list); | 1729 | INIT_LIST_HEAD(&dep->request_list); |
1717 | INIT_LIST_HEAD(&dep->req_queued); | 1730 | INIT_LIST_HEAD(&dep->req_queued); |
1718 | } | 1731 | } |
@@ -2685,7 +2698,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) | |||
2685 | goto err0; | 2698 | goto err0; |
2686 | } | 2699 | } |
2687 | 2700 | ||
2688 | dwc->ep0_trb = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ep0_trb), | 2701 | dwc->ep0_trb = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ep0_trb) * 2, |
2689 | &dwc->ep0_trb_addr, GFP_KERNEL); | 2702 | &dwc->ep0_trb_addr, GFP_KERNEL); |
2690 | if (!dwc->ep0_trb) { | 2703 | if (!dwc->ep0_trb) { |
2691 | dev_err(dwc->dev, "failed to allocate ep0 trb\n"); | 2704 | dev_err(dwc->dev, "failed to allocate ep0 trb\n"); |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 58b4657fc721..b474499839d3 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/utsname.h> | 19 | #include <linux/utsname.h> |
20 | 20 | ||
21 | #include <linux/usb/composite.h> | 21 | #include <linux/usb/composite.h> |
22 | #include <linux/usb/otg.h> | ||
22 | #include <asm/unaligned.h> | 23 | #include <asm/unaligned.h> |
23 | 24 | ||
24 | #include "u_os_desc.h" | 25 | #include "u_os_desc.h" |
@@ -209,6 +210,12 @@ int usb_add_function(struct usb_configuration *config, | |||
209 | function->config = config; | 210 | function->config = config; |
210 | list_add_tail(&function->list, &config->functions); | 211 | list_add_tail(&function->list, &config->functions); |
211 | 212 | ||
213 | if (function->bind_deactivated) { | ||
214 | value = usb_function_deactivate(function); | ||
215 | if (value) | ||
216 | goto done; | ||
217 | } | ||
218 | |||
212 | /* REVISIT *require* function->bind? */ | 219 | /* REVISIT *require* function->bind? */ |
213 | if (function->bind) { | 220 | if (function->bind) { |
214 | value = function->bind(config, function); | 221 | value = function->bind(config, function); |
@@ -279,7 +286,7 @@ int usb_function_deactivate(struct usb_function *function) | |||
279 | spin_lock_irqsave(&cdev->lock, flags); | 286 | spin_lock_irqsave(&cdev->lock, flags); |
280 | 287 | ||
281 | if (cdev->deactivations == 0) | 288 | if (cdev->deactivations == 0) |
282 | status = usb_gadget_disconnect(cdev->gadget); | 289 | status = usb_gadget_deactivate(cdev->gadget); |
283 | if (status == 0) | 290 | if (status == 0) |
284 | cdev->deactivations++; | 291 | cdev->deactivations++; |
285 | 292 | ||
@@ -311,7 +318,7 @@ int usb_function_activate(struct usb_function *function) | |||
311 | else { | 318 | else { |
312 | cdev->deactivations--; | 319 | cdev->deactivations--; |
313 | if (cdev->deactivations == 0) | 320 | if (cdev->deactivations == 0) |
314 | status = usb_gadget_connect(cdev->gadget); | 321 | status = usb_gadget_activate(cdev->gadget); |
315 | } | 322 | } |
316 | 323 | ||
317 | spin_unlock_irqrestore(&cdev->lock, flags); | 324 | spin_unlock_irqrestore(&cdev->lock, flags); |
@@ -896,7 +903,7 @@ void usb_remove_config(struct usb_composite_dev *cdev, | |||
896 | 903 | ||
897 | /* We support strings in multiple languages ... string descriptor zero | 904 | /* We support strings in multiple languages ... string descriptor zero |
898 | * says which languages are supported. The typical case will be that | 905 | * says which languages are supported. The typical case will be that |
899 | * only one language (probably English) is used, with I18N handled on | 906 | * only one language (probably English) is used, with i18n handled on |
900 | * the host side. | 907 | * the host side. |
901 | */ | 908 | */ |
902 | 909 | ||
@@ -949,7 +956,7 @@ static int get_string(struct usb_composite_dev *cdev, | |||
949 | struct usb_function *f; | 956 | struct usb_function *f; |
950 | int len; | 957 | int len; |
951 | 958 | ||
952 | /* Yes, not only is USB's I18N support probably more than most | 959 | /* Yes, not only is USB's i18n support probably more than most |
953 | * folk will ever care about ... also, it's all supported here. | 960 | * folk will ever care about ... also, it's all supported here. |
954 | * (Except for UTF8 support for Unicode's "Astral Planes".) | 961 | * (Except for UTF8 support for Unicode's "Astral Planes".) |
955 | */ | 962 | */ |
@@ -1534,6 +1541,32 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1534 | value = min(w_length, (u16) value); | 1541 | value = min(w_length, (u16) value); |
1535 | } | 1542 | } |
1536 | break; | 1543 | break; |
1544 | case USB_DT_OTG: | ||
1545 | if (gadget_is_otg(gadget)) { | ||
1546 | struct usb_configuration *config; | ||
1547 | int otg_desc_len = 0; | ||
1548 | |||
1549 | if (cdev->config) | ||
1550 | config = cdev->config; | ||
1551 | else | ||
1552 | config = list_first_entry( | ||
1553 | &cdev->configs, | ||
1554 | struct usb_configuration, list); | ||
1555 | if (!config) | ||
1556 | goto done; | ||
1557 | |||
1558 | if (gadget->otg_caps && | ||
1559 | (gadget->otg_caps->otg_rev >= 0x0200)) | ||
1560 | otg_desc_len += sizeof( | ||
1561 | struct usb_otg20_descriptor); | ||
1562 | else | ||
1563 | otg_desc_len += sizeof( | ||
1564 | struct usb_otg_descriptor); | ||
1565 | |||
1566 | value = min_t(int, w_length, otg_desc_len); | ||
1567 | memcpy(req->buf, config->descriptors[0], value); | ||
1568 | } | ||
1569 | break; | ||
1537 | } | 1570 | } |
1538 | break; | 1571 | break; |
1539 | 1572 | ||
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 34e12fc52c23..0fafa7a1b6f6 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/usb/ch9.h> | 20 | #include <linux/usb/ch9.h> |
21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
22 | #include <linux/usb/composite.h> | 22 | #include <linux/usb/composite.h> |
23 | #include <linux/usb/otg.h> | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * usb_descriptor_fillbuf - fill buffer with descriptors | 26 | * usb_descriptor_fillbuf - fill buffer with descriptors |
@@ -195,3 +196,58 @@ void usb_free_all_descriptors(struct usb_function *f) | |||
195 | usb_free_descriptors(f->ss_descriptors); | 196 | usb_free_descriptors(f->ss_descriptors); |
196 | } | 197 | } |
197 | EXPORT_SYMBOL_GPL(usb_free_all_descriptors); | 198 | EXPORT_SYMBOL_GPL(usb_free_all_descriptors); |
199 | |||
200 | struct usb_descriptor_header *usb_otg_descriptor_alloc( | ||
201 | struct usb_gadget *gadget) | ||
202 | { | ||
203 | struct usb_descriptor_header *otg_desc; | ||
204 | unsigned length = 0; | ||
205 | |||
206 | if (gadget->otg_caps && (gadget->otg_caps->otg_rev >= 0x0200)) | ||
207 | length = sizeof(struct usb_otg20_descriptor); | ||
208 | else | ||
209 | length = sizeof(struct usb_otg_descriptor); | ||
210 | |||
211 | otg_desc = kzalloc(length, GFP_KERNEL); | ||
212 | return otg_desc; | ||
213 | } | ||
214 | EXPORT_SYMBOL_GPL(usb_otg_descriptor_alloc); | ||
215 | |||
216 | int usb_otg_descriptor_init(struct usb_gadget *gadget, | ||
217 | struct usb_descriptor_header *otg_desc) | ||
218 | { | ||
219 | struct usb_otg_descriptor *otg1x_desc; | ||
220 | struct usb_otg20_descriptor *otg20_desc; | ||
221 | struct usb_otg_caps *otg_caps = gadget->otg_caps; | ||
222 | u8 otg_attributes = 0; | ||
223 | |||
224 | if (!otg_desc) | ||
225 | return -EINVAL; | ||
226 | |||
227 | if (otg_caps && otg_caps->otg_rev) { | ||
228 | if (otg_caps->hnp_support) | ||
229 | otg_attributes |= USB_OTG_HNP; | ||
230 | if (otg_caps->srp_support) | ||
231 | otg_attributes |= USB_OTG_SRP; | ||
232 | if (otg_caps->adp_support && (otg_caps->otg_rev >= 0x0200)) | ||
233 | otg_attributes |= USB_OTG_ADP; | ||
234 | } else { | ||
235 | otg_attributes = USB_OTG_SRP | USB_OTG_HNP; | ||
236 | } | ||
237 | |||
238 | if (otg_caps && (otg_caps->otg_rev >= 0x0200)) { | ||
239 | otg20_desc = (struct usb_otg20_descriptor *)otg_desc; | ||
240 | otg20_desc->bLength = sizeof(struct usb_otg20_descriptor); | ||
241 | otg20_desc->bDescriptorType = USB_DT_OTG; | ||
242 | otg20_desc->bmAttributes = otg_attributes; | ||
243 | otg20_desc->bcdOTG = cpu_to_le16(otg_caps->otg_rev); | ||
244 | } else { | ||
245 | otg1x_desc = (struct usb_otg_descriptor *)otg_desc; | ||
246 | otg1x_desc->bLength = sizeof(struct usb_otg_descriptor); | ||
247 | otg1x_desc->bDescriptorType = USB_DT_OTG; | ||
248 | otg1x_desc->bmAttributes = otg_attributes; | ||
249 | } | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | EXPORT_SYMBOL_GPL(usb_otg_descriptor_init); | ||
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 289e20119fea..294eb74fb078 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c | |||
@@ -41,6 +41,8 @@ int check_user_usb_string(const char *name, | |||
41 | #define MAX_NAME_LEN 40 | 41 | #define MAX_NAME_LEN 40 |
42 | #define MAX_USB_STRING_LANGS 2 | 42 | #define MAX_USB_STRING_LANGS 2 |
43 | 43 | ||
44 | static const struct usb_descriptor_header *otg_desc[2]; | ||
45 | |||
44 | struct gadget_info { | 46 | struct gadget_info { |
45 | struct config_group group; | 47 | struct config_group group; |
46 | struct config_group functions_group; | 48 | struct config_group functions_group; |
@@ -55,9 +57,6 @@ struct gadget_info { | |||
55 | struct list_head available_func; | 57 | struct list_head available_func; |
56 | 58 | ||
57 | const char *udc_name; | 59 | const char *udc_name; |
58 | #ifdef CONFIG_USB_OTG | ||
59 | struct usb_otg_descriptor otg; | ||
60 | #endif | ||
61 | struct usb_composite_driver composite; | 60 | struct usb_composite_driver composite; |
62 | struct usb_composite_dev cdev; | 61 | struct usb_composite_dev cdev; |
63 | bool use_os_desc; | 62 | bool use_os_desc; |
@@ -1376,6 +1375,19 @@ static int configfs_composite_bind(struct usb_gadget *gadget, | |||
1376 | memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); | 1375 | memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); |
1377 | } | 1376 | } |
1378 | 1377 | ||
1378 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
1379 | struct usb_descriptor_header *usb_desc; | ||
1380 | |||
1381 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
1382 | if (!usb_desc) { | ||
1383 | ret = -ENOMEM; | ||
1384 | goto err_comp_cleanup; | ||
1385 | } | ||
1386 | usb_otg_descriptor_init(gadget, usb_desc); | ||
1387 | otg_desc[0] = usb_desc; | ||
1388 | otg_desc[1] = NULL; | ||
1389 | } | ||
1390 | |||
1379 | /* Go through all configs, attach all functions */ | 1391 | /* Go through all configs, attach all functions */ |
1380 | list_for_each_entry(c, &gi->cdev.configs, list) { | 1392 | list_for_each_entry(c, &gi->cdev.configs, list) { |
1381 | struct config_usb_cfg *cfg; | 1393 | struct config_usb_cfg *cfg; |
@@ -1383,6 +1395,9 @@ static int configfs_composite_bind(struct usb_gadget *gadget, | |||
1383 | struct usb_function *tmp; | 1395 | struct usb_function *tmp; |
1384 | struct gadget_config_name *cn; | 1396 | struct gadget_config_name *cn; |
1385 | 1397 | ||
1398 | if (gadget_is_otg(gadget)) | ||
1399 | c->descriptors = otg_desc; | ||
1400 | |||
1386 | cfg = container_of(c, struct config_usb_cfg, c); | 1401 | cfg = container_of(c, struct config_usb_cfg, c); |
1387 | if (!list_empty(&cfg->string_list)) { | 1402 | if (!list_empty(&cfg->string_list)) { |
1388 | i = 0; | 1403 | i = 0; |
@@ -1437,6 +1452,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) | |||
1437 | cdev = get_gadget_data(gadget); | 1452 | cdev = get_gadget_data(gadget); |
1438 | gi = container_of(cdev, struct gadget_info, cdev); | 1453 | gi = container_of(cdev, struct gadget_info, cdev); |
1439 | 1454 | ||
1455 | kfree(otg_desc[0]); | ||
1456 | otg_desc[0] = NULL; | ||
1440 | purge_configs_funcs(gi); | 1457 | purge_configs_funcs(gi); |
1441 | composite_dev_cleanup(cdev); | 1458 | composite_dev_cleanup(cdev); |
1442 | usb_ep_autoconfig_reset(cdev->gadget); | 1459 | usb_ep_autoconfig_reset(cdev->gadget); |
@@ -1510,12 +1527,6 @@ static struct config_group *gadgets_make( | |||
1510 | if (!gi->composite.gadget_driver.function) | 1527 | if (!gi->composite.gadget_driver.function) |
1511 | goto err; | 1528 | goto err; |
1512 | 1529 | ||
1513 | #ifdef CONFIG_USB_OTG | ||
1514 | gi->otg.bLength = sizeof(struct usb_otg_descriptor); | ||
1515 | gi->otg.bDescriptorType = USB_DT_OTG; | ||
1516 | gi->otg.bmAttributes = USB_OTG_SRP | USB_OTG_HNP; | ||
1517 | #endif | ||
1518 | |||
1519 | config_group_init_type_name(&gi->group, name, | 1530 | config_group_init_type_name(&gi->group, name, |
1520 | &gadget_root_type); | 1531 | &gadget_root_type); |
1521 | return &gi->group; | 1532 | return &gi->group; |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 919cdfdda78b..978435a51038 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -20,186 +20,6 @@ | |||
20 | #include <linux/usb/ch9.h> | 20 | #include <linux/usb/ch9.h> |
21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
22 | 22 | ||
23 | #include "gadget_chips.h" | ||
24 | |||
25 | /* | ||
26 | * This should work with endpoints from controller drivers sharing the | ||
27 | * same endpoint naming convention. By example: | ||
28 | * | ||
29 | * - ep1, ep2, ... address is fixed, not direction or type | ||
30 | * - ep1in, ep2out, ... address and direction are fixed, not type | ||
31 | * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction | ||
32 | * - ep1in-bulk, ep2out-iso, ... all three are fixed | ||
33 | * - ep-* ... no functionality restrictions | ||
34 | * | ||
35 | * Type suffixes are "-bulk", "-iso", or "-int". Numbers are decimal. | ||
36 | * Less common restrictions are implied by gadget_is_*(). | ||
37 | * | ||
38 | * NOTE: each endpoint is unidirectional, as specified by its USB | ||
39 | * descriptor; and isn't specific to a configuration or altsetting. | ||
40 | */ | ||
41 | static int | ||
42 | ep_matches ( | ||
43 | struct usb_gadget *gadget, | ||
44 | struct usb_ep *ep, | ||
45 | struct usb_endpoint_descriptor *desc, | ||
46 | struct usb_ss_ep_comp_descriptor *ep_comp | ||
47 | ) | ||
48 | { | ||
49 | u8 type; | ||
50 | const char *tmp; | ||
51 | u16 max; | ||
52 | |||
53 | int num_req_streams = 0; | ||
54 | |||
55 | /* endpoint already claimed? */ | ||
56 | if (NULL != ep->driver_data) | ||
57 | return 0; | ||
58 | |||
59 | /* only support ep0 for portable CONTROL traffic */ | ||
60 | type = usb_endpoint_type(desc); | ||
61 | if (USB_ENDPOINT_XFER_CONTROL == type) | ||
62 | return 0; | ||
63 | |||
64 | /* some other naming convention */ | ||
65 | if ('e' != ep->name[0]) | ||
66 | return 0; | ||
67 | |||
68 | /* type-restriction: "-iso", "-bulk", or "-int". | ||
69 | * direction-restriction: "in", "out". | ||
70 | */ | ||
71 | if ('-' != ep->name[2]) { | ||
72 | tmp = strrchr (ep->name, '-'); | ||
73 | if (tmp) { | ||
74 | switch (type) { | ||
75 | case USB_ENDPOINT_XFER_INT: | ||
76 | /* bulk endpoints handle interrupt transfers, | ||
77 | * except the toggle-quirky iso-synch kind | ||
78 | */ | ||
79 | if ('s' == tmp[2]) // == "-iso" | ||
80 | return 0; | ||
81 | /* for now, avoid PXA "interrupt-in"; | ||
82 | * it's documented as never using DATA1. | ||
83 | */ | ||
84 | if (gadget_is_pxa (gadget) | ||
85 | && 'i' == tmp [1]) | ||
86 | return 0; | ||
87 | break; | ||
88 | case USB_ENDPOINT_XFER_BULK: | ||
89 | if ('b' != tmp[1]) // != "-bulk" | ||
90 | return 0; | ||
91 | break; | ||
92 | case USB_ENDPOINT_XFER_ISOC: | ||
93 | if ('s' != tmp[2]) // != "-iso" | ||
94 | return 0; | ||
95 | } | ||
96 | } else { | ||
97 | tmp = ep->name + strlen (ep->name); | ||
98 | } | ||
99 | |||
100 | /* direction-restriction: "..in-..", "out-.." */ | ||
101 | tmp--; | ||
102 | if (!isdigit (*tmp)) { | ||
103 | if (desc->bEndpointAddress & USB_DIR_IN) { | ||
104 | if ('n' != *tmp) | ||
105 | return 0; | ||
106 | } else { | ||
107 | if ('t' != *tmp) | ||
108 | return 0; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /* | ||
114 | * Get the number of required streams from the EP companion | ||
115 | * descriptor and see if the EP matches it | ||
116 | */ | ||
117 | if (usb_endpoint_xfer_bulk(desc)) { | ||
118 | if (ep_comp && gadget->max_speed >= USB_SPEED_SUPER) { | ||
119 | num_req_streams = ep_comp->bmAttributes & 0x1f; | ||
120 | if (num_req_streams > ep->max_streams) | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | } | ||
125 | |||
126 | /* | ||
127 | * If the protocol driver hasn't yet decided on wMaxPacketSize | ||
128 | * and wants to know the maximum possible, provide the info. | ||
129 | */ | ||
130 | if (desc->wMaxPacketSize == 0) | ||
131 | desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit); | ||
132 | |||
133 | /* endpoint maxpacket size is an input parameter, except for bulk | ||
134 | * where it's an output parameter representing the full speed limit. | ||
135 | * the usb spec fixes high speed bulk maxpacket at 512 bytes. | ||
136 | */ | ||
137 | max = 0x7ff & usb_endpoint_maxp(desc); | ||
138 | switch (type) { | ||
139 | case USB_ENDPOINT_XFER_INT: | ||
140 | /* INT: limit 64 bytes full speed, 1024 high/super speed */ | ||
141 | if (!gadget_is_dualspeed(gadget) && max > 64) | ||
142 | return 0; | ||
143 | /* FALLTHROUGH */ | ||
144 | |||
145 | case USB_ENDPOINT_XFER_ISOC: | ||
146 | /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ | ||
147 | if (ep->maxpacket_limit < max) | ||
148 | return 0; | ||
149 | if (!gadget_is_dualspeed(gadget) && max > 1023) | ||
150 | return 0; | ||
151 | |||
152 | /* BOTH: "high bandwidth" works only at high speed */ | ||
153 | if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) { | ||
154 | if (!gadget_is_dualspeed(gadget)) | ||
155 | return 0; | ||
156 | /* configure your hardware with enough buffering!! */ | ||
157 | } | ||
158 | break; | ||
159 | } | ||
160 | |||
161 | /* MATCH!! */ | ||
162 | |||
163 | /* report address */ | ||
164 | desc->bEndpointAddress &= USB_DIR_IN; | ||
165 | if (isdigit (ep->name [2])) { | ||
166 | u8 num = simple_strtoul (&ep->name [2], NULL, 10); | ||
167 | desc->bEndpointAddress |= num; | ||
168 | } else if (desc->bEndpointAddress & USB_DIR_IN) { | ||
169 | if (++gadget->in_epnum > 15) | ||
170 | return 0; | ||
171 | desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; | ||
172 | } else { | ||
173 | if (++gadget->out_epnum > 15) | ||
174 | return 0; | ||
175 | desc->bEndpointAddress |= gadget->out_epnum; | ||
176 | } | ||
177 | |||
178 | /* report (variable) full speed bulk maxpacket */ | ||
179 | if ((USB_ENDPOINT_XFER_BULK == type) && !ep_comp) { | ||
180 | int size = ep->maxpacket_limit; | ||
181 | |||
182 | /* min() doesn't work on bitfields with gcc-3.5 */ | ||
183 | if (size > 64) | ||
184 | size = 64; | ||
185 | desc->wMaxPacketSize = cpu_to_le16(size); | ||
186 | } | ||
187 | ep->address = desc->bEndpointAddress; | ||
188 | return 1; | ||
189 | } | ||
190 | |||
191 | static struct usb_ep * | ||
192 | find_ep (struct usb_gadget *gadget, const char *name) | ||
193 | { | ||
194 | struct usb_ep *ep; | ||
195 | |||
196 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | ||
197 | if (0 == strcmp (ep->name, name)) | ||
198 | return ep; | ||
199 | } | ||
200 | return NULL; | ||
201 | } | ||
202 | |||
203 | /** | 23 | /** |
204 | * usb_ep_autoconfig_ss() - choose an endpoint matching the ep | 24 | * usb_ep_autoconfig_ss() - choose an endpoint matching the ep |
205 | * descriptor and ep companion descriptor | 25 | * descriptor and ep companion descriptor |
@@ -240,7 +60,7 @@ find_ep (struct usb_gadget *gadget, const char *name) | |||
240 | * updated with the assigned number of streams if it is | 60 | * updated with the assigned number of streams if it is |
241 | * different from the original value. To prevent the endpoint | 61 | * different from the original value. To prevent the endpoint |
242 | * from being returned by a later autoconfig call, claim it by | 62 | * from being returned by a later autoconfig call, claim it by |
243 | * assigning ep->driver_data to some non-null value. | 63 | * assigning ep->claimed to true. |
244 | * | 64 | * |
245 | * On failure, this returns a null endpoint descriptor. | 65 | * On failure, this returns a null endpoint descriptor. |
246 | */ | 66 | */ |
@@ -255,74 +75,58 @@ struct usb_ep *usb_ep_autoconfig_ss( | |||
255 | 75 | ||
256 | type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | 76 | type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; |
257 | 77 | ||
258 | /* First, apply chip-specific "best usage" knowledge. | 78 | if (gadget->ops->match_ep) { |
259 | * This might make a good usb_gadget_ops hook ... | 79 | ep = gadget->ops->match_ep(gadget, desc, ep_comp); |
260 | */ | 80 | if (ep) |
261 | if (gadget_is_net2280(gadget)) { | ||
262 | char name[8]; | ||
263 | |||
264 | if (type == USB_ENDPOINT_XFER_INT) { | ||
265 | /* ep-e, ep-f are PIO with only 64 byte fifos */ | ||
266 | ep = find_ep(gadget, "ep-e"); | ||
267 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | ||
268 | goto found_ep; | ||
269 | ep = find_ep(gadget, "ep-f"); | ||
270 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | ||
271 | goto found_ep; | ||
272 | } | ||
273 | |||
274 | /* USB3380: use same address for usb and hardware endpoints */ | ||
275 | snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc), | ||
276 | usb_endpoint_dir_in(desc) ? "in" : "out"); | ||
277 | ep = find_ep(gadget, name); | ||
278 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | ||
279 | goto found_ep; | 81 | goto found_ep; |
280 | } else if (gadget_is_goku (gadget)) { | ||
281 | if (USB_ENDPOINT_XFER_INT == type) { | ||
282 | /* single buffering is enough */ | ||
283 | ep = find_ep(gadget, "ep3-bulk"); | ||
284 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | ||
285 | goto found_ep; | ||
286 | } else if (USB_ENDPOINT_XFER_BULK == type | ||
287 | && (USB_DIR_IN & desc->bEndpointAddress)) { | ||
288 | /* DMA may be available */ | ||
289 | ep = find_ep(gadget, "ep2-bulk"); | ||
290 | if (ep && ep_matches(gadget, ep, desc, | ||
291 | ep_comp)) | ||
292 | goto found_ep; | ||
293 | } | ||
294 | |||
295 | #ifdef CONFIG_BLACKFIN | ||
296 | } else if (gadget_is_musbhdrc(gadget)) { | ||
297 | if ((USB_ENDPOINT_XFER_BULK == type) || | ||
298 | (USB_ENDPOINT_XFER_ISOC == type)) { | ||
299 | if (USB_DIR_IN & desc->bEndpointAddress) | ||
300 | ep = find_ep (gadget, "ep5in"); | ||
301 | else | ||
302 | ep = find_ep (gadget, "ep6out"); | ||
303 | } else if (USB_ENDPOINT_XFER_INT == type) { | ||
304 | if (USB_DIR_IN & desc->bEndpointAddress) | ||
305 | ep = find_ep(gadget, "ep1in"); | ||
306 | else | ||
307 | ep = find_ep(gadget, "ep2out"); | ||
308 | } else | ||
309 | ep = NULL; | ||
310 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | ||
311 | goto found_ep; | ||
312 | #endif | ||
313 | } | 82 | } |
314 | 83 | ||
315 | /* Second, look at endpoints until an unclaimed one looks usable */ | 84 | /* Second, look at endpoints until an unclaimed one looks usable */ |
316 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | 85 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { |
317 | if (ep_matches(gadget, ep, desc, ep_comp)) | 86 | if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) |
318 | goto found_ep; | 87 | goto found_ep; |
319 | } | 88 | } |
320 | 89 | ||
321 | /* Fail */ | 90 | /* Fail */ |
322 | return NULL; | 91 | return NULL; |
323 | found_ep: | 92 | found_ep: |
93 | |||
94 | /* | ||
95 | * If the protocol driver hasn't yet decided on wMaxPacketSize | ||
96 | * and wants to know the maximum possible, provide the info. | ||
97 | */ | ||
98 | if (desc->wMaxPacketSize == 0) | ||
99 | desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit); | ||
100 | |||
101 | /* report address */ | ||
102 | desc->bEndpointAddress &= USB_DIR_IN; | ||
103 | if (isdigit(ep->name[2])) { | ||
104 | u8 num = simple_strtoul(&ep->name[2], NULL, 10); | ||
105 | desc->bEndpointAddress |= num; | ||
106 | } else if (desc->bEndpointAddress & USB_DIR_IN) { | ||
107 | if (++gadget->in_epnum > 15) | ||
108 | return NULL; | ||
109 | desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; | ||
110 | } else { | ||
111 | if (++gadget->out_epnum > 15) | ||
112 | return NULL; | ||
113 | desc->bEndpointAddress |= gadget->out_epnum; | ||
114 | } | ||
115 | |||
116 | /* report (variable) full speed bulk maxpacket */ | ||
117 | if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) { | ||
118 | int size = ep->maxpacket_limit; | ||
119 | |||
120 | /* min() doesn't work on bitfields with gcc-3.5 */ | ||
121 | if (size > 64) | ||
122 | size = 64; | ||
123 | desc->wMaxPacketSize = cpu_to_le16(size); | ||
124 | } | ||
125 | |||
126 | ep->address = desc->bEndpointAddress; | ||
324 | ep->desc = NULL; | 127 | ep->desc = NULL; |
325 | ep->comp_desc = NULL; | 128 | ep->comp_desc = NULL; |
129 | ep->claimed = true; | ||
326 | return ep; | 130 | return ep; |
327 | } | 131 | } |
328 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); | 132 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); |
@@ -354,7 +158,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); | |||
354 | * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value | 158 | * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value |
355 | * is initialized as if the endpoint were used at full speed. To prevent | 159 | * is initialized as if the endpoint were used at full speed. To prevent |
356 | * the endpoint from being returned by a later autoconfig call, claim it | 160 | * the endpoint from being returned by a later autoconfig call, claim it |
357 | * by assigning ep->driver_data to some non-null value. | 161 | * by assigning ep->claimed to true. |
358 | * | 162 | * |
359 | * On failure, this returns a null endpoint descriptor. | 163 | * On failure, this returns a null endpoint descriptor. |
360 | */ | 164 | */ |
@@ -373,7 +177,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig); | |||
373 | * | 177 | * |
374 | * Use this for devices where one configuration may need to assign | 178 | * Use this for devices where one configuration may need to assign |
375 | * endpoint resources very differently from the next one. It clears | 179 | * endpoint resources very differently from the next one. It clears |
376 | * state such as ep->driver_data and the record of assigned endpoints | 180 | * state such as ep->claimed and the record of assigned endpoints |
377 | * used by usb_ep_autoconfig(). | 181 | * used by usb_ep_autoconfig(). |
378 | */ | 182 | */ |
379 | void usb_ep_autoconfig_reset (struct usb_gadget *gadget) | 183 | void usb_ep_autoconfig_reset (struct usb_gadget *gadget) |
@@ -381,7 +185,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) | |||
381 | struct usb_ep *ep; | 185 | struct usb_ep *ep; |
382 | 186 | ||
383 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | 187 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { |
384 | ep->driver_data = NULL; | 188 | ep->claimed = false; |
385 | } | 189 | } |
386 | gadget->in_epnum = 0; | 190 | gadget->in_epnum = 0; |
387 | gadget->out_epnum = 0; | 191 | gadget->out_epnum = 0; |
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index aad8165e98ef..be9df09fde26 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | 22 | ||
23 | #include "u_serial.h" | 23 | #include "u_serial.h" |
24 | #include "gadget_chips.h" | ||
25 | 24 | ||
26 | 25 | ||
27 | /* | 26 | /* |
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 798760fa7e70..7b7424f10ddd 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c | |||
@@ -585,8 +585,8 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
585 | /* Enable zlps by default for ECM conformance; | 585 | /* Enable zlps by default for ECM conformance; |
586 | * override for musb_hdrc (avoids txdma ovhead). | 586 | * override for musb_hdrc (avoids txdma ovhead). |
587 | */ | 587 | */ |
588 | ecm->port.is_zlp_ok = !(gadget_is_musbhdrc(cdev->gadget) | 588 | ecm->port.is_zlp_ok = |
589 | ); | 589 | gadget_is_zlp_supported(cdev->gadget); |
590 | ecm->port.cdc_filter = DEFAULT_FILTER; | 590 | ecm->port.cdc_filter = DEFAULT_FILTER; |
591 | DBG(cdev, "activate ecm\n"); | 591 | DBG(cdev, "activate ecm\n"); |
592 | net = gether_connect(&ecm->port); | 592 | net = gether_connect(&ecm->port); |
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 6e7be91e6097..adc6d52efa46 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -2897,11 +2897,17 @@ static int ffs_func_bind(struct usb_configuration *c, | |||
2897 | struct usb_function *f) | 2897 | struct usb_function *f) |
2898 | { | 2898 | { |
2899 | struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c); | 2899 | struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c); |
2900 | struct ffs_function *func = ffs_func_from_usb(f); | ||
2901 | int ret; | ||
2900 | 2902 | ||
2901 | if (IS_ERR(ffs_opts)) | 2903 | if (IS_ERR(ffs_opts)) |
2902 | return PTR_ERR(ffs_opts); | 2904 | return PTR_ERR(ffs_opts); |
2903 | 2905 | ||
2904 | return _ffs_func_bind(c, f); | 2906 | ret = _ffs_func_bind(c, f); |
2907 | if (ret && !--ffs_opts->refcnt) | ||
2908 | functionfs_unbind(func->ffs); | ||
2909 | |||
2910 | return ret; | ||
2905 | } | 2911 | } |
2906 | 2912 | ||
2907 | 2913 | ||
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c index 39f49f1ad22f..6e2fe63b9267 100644 --- a/drivers/usb/gadget/function/f_loopback.c +++ b/drivers/usb/gadget/function/f_loopback.c | |||
@@ -28,11 +28,6 @@ | |||
28 | * This takes messages of various sizes written OUT to a device, and loops | 28 | * This takes messages of various sizes written OUT to a device, and loops |
29 | * them back so they can be read IN from it. It has been used by certain | 29 | * them back so they can be read IN from it. It has been used by certain |
30 | * test applications. It supports limited testing of data queueing logic. | 30 | * test applications. It supports limited testing of data queueing logic. |
31 | * | ||
32 | * | ||
33 | * This is currently packaged as a configuration driver, which can't be | ||
34 | * combined with other functions to make composite devices. However, it | ||
35 | * can be combined with other independent configurations. | ||
36 | */ | 31 | */ |
37 | struct f_loopback { | 32 | struct f_loopback { |
38 | struct usb_function function; | 33 | struct usb_function function; |
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index f936268d26c6..a6eb537d7768 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c | |||
@@ -54,7 +54,7 @@ | |||
54 | * following fields: | 54 | * following fields: |
55 | * | 55 | * |
56 | * nluns Number of LUNs function have (anywhere from 1 | 56 | * nluns Number of LUNs function have (anywhere from 1 |
57 | * to FSG_MAX_LUNS which is 8). | 57 | * to FSG_MAX_LUNS). |
58 | * luns An array of LUN configuration values. This | 58 | * luns An array of LUN configuration values. This |
59 | * should be filled for each LUN that | 59 | * should be filled for each LUN that |
60 | * function will include (ie. for "nluns" | 60 | * function will include (ie. for "nluns" |
@@ -214,12 +214,12 @@ | |||
214 | #include <linux/string.h> | 214 | #include <linux/string.h> |
215 | #include <linux/freezer.h> | 215 | #include <linux/freezer.h> |
216 | #include <linux/module.h> | 216 | #include <linux/module.h> |
217 | #include <linux/uaccess.h> | ||
217 | 218 | ||
218 | #include <linux/usb/ch9.h> | 219 | #include <linux/usb/ch9.h> |
219 | #include <linux/usb/gadget.h> | 220 | #include <linux/usb/gadget.h> |
220 | #include <linux/usb/composite.h> | 221 | #include <linux/usb/composite.h> |
221 | 222 | ||
222 | #include "gadget_chips.h" | ||
223 | #include "configfs.h" | 223 | #include "configfs.h" |
224 | 224 | ||
225 | 225 | ||
@@ -279,9 +279,8 @@ struct fsg_common { | |||
279 | int cmnd_size; | 279 | int cmnd_size; |
280 | u8 cmnd[MAX_COMMAND_SIZE]; | 280 | u8 cmnd[MAX_COMMAND_SIZE]; |
281 | 281 | ||
282 | unsigned int nluns; | ||
283 | unsigned int lun; | 282 | unsigned int lun; |
284 | struct fsg_lun **luns; | 283 | struct fsg_lun *luns[FSG_MAX_LUNS]; |
285 | struct fsg_lun *curlun; | 284 | struct fsg_lun *curlun; |
286 | 285 | ||
287 | unsigned int bulk_out_maxpacket; | 286 | unsigned int bulk_out_maxpacket; |
@@ -490,6 +489,16 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | |||
490 | spin_unlock(&common->lock); | 489 | spin_unlock(&common->lock); |
491 | } | 490 | } |
492 | 491 | ||
492 | static int _fsg_common_get_max_lun(struct fsg_common *common) | ||
493 | { | ||
494 | int i = ARRAY_SIZE(common->luns) - 1; | ||
495 | |||
496 | while (i >= 0 && !common->luns[i]) | ||
497 | --i; | ||
498 | |||
499 | return i; | ||
500 | } | ||
501 | |||
493 | static int fsg_setup(struct usb_function *f, | 502 | static int fsg_setup(struct usb_function *f, |
494 | const struct usb_ctrlrequest *ctrl) | 503 | const struct usb_ctrlrequest *ctrl) |
495 | { | 504 | { |
@@ -533,7 +542,7 @@ static int fsg_setup(struct usb_function *f, | |||
533 | w_length != 1) | 542 | w_length != 1) |
534 | return -EDOM; | 543 | return -EDOM; |
535 | VDBG(fsg, "get max LUN\n"); | 544 | VDBG(fsg, "get max LUN\n"); |
536 | *(u8 *)req->buf = fsg->common->nluns - 1; | 545 | *(u8 *)req->buf = _fsg_common_get_max_lun(fsg->common); |
537 | 546 | ||
538 | /* Respond with data/status */ | 547 | /* Respond with data/status */ |
539 | req->length = min((u16)1, w_length); | 548 | req->length = min((u16)1, w_length); |
@@ -2131,8 +2140,9 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2131 | } | 2140 | } |
2132 | 2141 | ||
2133 | /* Is the CBW meaningful? */ | 2142 | /* Is the CBW meaningful? */ |
2134 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || | 2143 | if (cbw->Lun >= ARRAY_SIZE(common->luns) || |
2135 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | 2144 | cbw->Flags & ~US_BULK_FLAG_IN || cbw->Length <= 0 || |
2145 | cbw->Length > MAX_COMMAND_SIZE) { | ||
2136 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | 2146 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " |
2137 | "cmdlen %u\n", | 2147 | "cmdlen %u\n", |
2138 | cbw->Lun, cbw->Flags, cbw->Length); | 2148 | cbw->Lun, cbw->Flags, cbw->Length); |
@@ -2159,7 +2169,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2159 | if (common->data_size == 0) | 2169 | if (common->data_size == 0) |
2160 | common->data_dir = DATA_DIR_NONE; | 2170 | common->data_dir = DATA_DIR_NONE; |
2161 | common->lun = cbw->Lun; | 2171 | common->lun = cbw->Lun; |
2162 | if (common->lun < common->nluns) | 2172 | if (common->lun < ARRAY_SIZE(common->luns)) |
2163 | common->curlun = common->luns[common->lun]; | 2173 | common->curlun = common->luns[common->lun]; |
2164 | else | 2174 | else |
2165 | common->curlun = NULL; | 2175 | common->curlun = NULL; |
@@ -2307,7 +2317,7 @@ reset: | |||
2307 | } | 2317 | } |
2308 | 2318 | ||
2309 | common->running = 1; | 2319 | common->running = 1; |
2310 | for (i = 0; i < common->nluns; ++i) | 2320 | for (i = 0; i < ARRAY_SIZE(common->luns); ++i) |
2311 | if (common->luns[i]) | 2321 | if (common->luns[i]) |
2312 | common->luns[i]->unit_attention_data = | 2322 | common->luns[i]->unit_attention_data = |
2313 | SS_RESET_OCCURRED; | 2323 | SS_RESET_OCCURRED; |
@@ -2409,7 +2419,7 @@ static void handle_exception(struct fsg_common *common) | |||
2409 | if (old_state == FSG_STATE_ABORT_BULK_OUT) | 2419 | if (old_state == FSG_STATE_ABORT_BULK_OUT) |
2410 | common->state = FSG_STATE_STATUS_PHASE; | 2420 | common->state = FSG_STATE_STATUS_PHASE; |
2411 | else { | 2421 | else { |
2412 | for (i = 0; i < common->nluns; ++i) { | 2422 | for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { |
2413 | curlun = common->luns[i]; | 2423 | curlun = common->luns[i]; |
2414 | if (!curlun) | 2424 | if (!curlun) |
2415 | continue; | 2425 | continue; |
@@ -2453,7 +2463,7 @@ static void handle_exception(struct fsg_common *common) | |||
2453 | * a waste of time. Ditto for the INTERFACE_CHANGE and | 2463 | * a waste of time. Ditto for the INTERFACE_CHANGE and |
2454 | * CONFIG_CHANGE cases. | 2464 | * CONFIG_CHANGE cases. |
2455 | */ | 2465 | */ |
2456 | /* for (i = 0; i < common->nluns; ++i) */ | 2466 | /* for (i = 0; i < common->ARRAY_SIZE(common->luns); ++i) */ |
2457 | /* if (common->luns[i]) */ | 2467 | /* if (common->luns[i]) */ |
2458 | /* common->luns[i]->unit_attention_data = */ | 2468 | /* common->luns[i]->unit_attention_data = */ |
2459 | /* SS_RESET_OCCURRED; */ | 2469 | /* SS_RESET_OCCURRED; */ |
@@ -2552,12 +2562,11 @@ static int fsg_main_thread(void *common_) | |||
2552 | 2562 | ||
2553 | if (!common->ops || !common->ops->thread_exits | 2563 | if (!common->ops || !common->ops->thread_exits |
2554 | || common->ops->thread_exits(common) < 0) { | 2564 | || common->ops->thread_exits(common) < 0) { |
2555 | struct fsg_lun **curlun_it = common->luns; | 2565 | int i; |
2556 | unsigned i = common->nluns; | ||
2557 | 2566 | ||
2558 | down_write(&common->filesem); | 2567 | down_write(&common->filesem); |
2559 | for (; i--; ++curlun_it) { | 2568 | for (i = 0; i < ARRAY_SIZE(common->luns); --i) { |
2560 | struct fsg_lun *curlun = *curlun_it; | 2569 | struct fsg_lun *curlun = common->luns[i]; |
2561 | if (!curlun || !fsg_lun_is_open(curlun)) | 2570 | if (!curlun || !fsg_lun_is_open(curlun)) |
2562 | continue; | 2571 | continue; |
2563 | 2572 | ||
@@ -2676,6 +2685,7 @@ static struct fsg_common *fsg_common_setup(struct fsg_common *common) | |||
2676 | init_completion(&common->thread_notifier); | 2685 | init_completion(&common->thread_notifier); |
2677 | init_waitqueue_head(&common->fsg_wait); | 2686 | init_waitqueue_head(&common->fsg_wait); |
2678 | common->state = FSG_STATE_TERMINATED; | 2687 | common->state = FSG_STATE_TERMINATED; |
2688 | memset(common->luns, 0, sizeof(common->luns)); | ||
2679 | 2689 | ||
2680 | return common; | 2690 | return common; |
2681 | } | 2691 | } |
@@ -2742,9 +2752,9 @@ error_release: | |||
2742 | } | 2752 | } |
2743 | EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers); | 2753 | EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers); |
2744 | 2754 | ||
2745 | void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) | 2755 | void fsg_common_remove_lun(struct fsg_lun *lun) |
2746 | { | 2756 | { |
2747 | if (sysfs) | 2757 | if (device_is_registered(&lun->dev)) |
2748 | device_unregister(&lun->dev); | 2758 | device_unregister(&lun->dev); |
2749 | fsg_lun_close(lun); | 2759 | fsg_lun_close(lun); |
2750 | kfree(lun); | 2760 | kfree(lun); |
@@ -2757,48 +2767,16 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n) | |||
2757 | 2767 | ||
2758 | for (i = 0; i < n; ++i) | 2768 | for (i = 0; i < n; ++i) |
2759 | if (common->luns[i]) { | 2769 | if (common->luns[i]) { |
2760 | fsg_common_remove_lun(common->luns[i], common->sysfs); | 2770 | fsg_common_remove_lun(common->luns[i]); |
2761 | common->luns[i] = NULL; | 2771 | common->luns[i] = NULL; |
2762 | } | 2772 | } |
2763 | } | 2773 | } |
2764 | EXPORT_SYMBOL_GPL(fsg_common_remove_luns); | ||
2765 | 2774 | ||
2766 | void fsg_common_remove_luns(struct fsg_common *common) | 2775 | void fsg_common_remove_luns(struct fsg_common *common) |
2767 | { | 2776 | { |
2768 | _fsg_common_remove_luns(common, common->nluns); | 2777 | _fsg_common_remove_luns(common, ARRAY_SIZE(common->luns)); |
2769 | } | ||
2770 | |||
2771 | void fsg_common_free_luns(struct fsg_common *common) | ||
2772 | { | ||
2773 | fsg_common_remove_luns(common); | ||
2774 | kfree(common->luns); | ||
2775 | common->luns = NULL; | ||
2776 | } | ||
2777 | EXPORT_SYMBOL_GPL(fsg_common_free_luns); | ||
2778 | |||
2779 | int fsg_common_set_nluns(struct fsg_common *common, int nluns) | ||
2780 | { | ||
2781 | struct fsg_lun **curlun; | ||
2782 | |||
2783 | /* Find out how many LUNs there should be */ | ||
2784 | if (nluns < 1 || nluns > FSG_MAX_LUNS) { | ||
2785 | pr_err("invalid number of LUNs: %u\n", nluns); | ||
2786 | return -EINVAL; | ||
2787 | } | ||
2788 | |||
2789 | curlun = kcalloc(FSG_MAX_LUNS, sizeof(*curlun), GFP_KERNEL); | ||
2790 | if (unlikely(!curlun)) | ||
2791 | return -ENOMEM; | ||
2792 | |||
2793 | if (common->luns) | ||
2794 | fsg_common_free_luns(common); | ||
2795 | |||
2796 | common->luns = curlun; | ||
2797 | common->nluns = nluns; | ||
2798 | |||
2799 | return 0; | ||
2800 | } | 2778 | } |
2801 | EXPORT_SYMBOL_GPL(fsg_common_set_nluns); | 2779 | EXPORT_SYMBOL_GPL(fsg_common_remove_luns); |
2802 | 2780 | ||
2803 | void fsg_common_set_ops(struct fsg_common *common, | 2781 | void fsg_common_set_ops(struct fsg_common *common, |
2804 | const struct fsg_operations *ops) | 2782 | const struct fsg_operations *ops) |
@@ -2836,7 +2814,8 @@ int fsg_common_set_cdev(struct fsg_common *common, | |||
2836 | * halt bulk endpoints correctly. If one of them is present, | 2814 | * halt bulk endpoints correctly. If one of them is present, |
2837 | * disable stalls. | 2815 | * disable stalls. |
2838 | */ | 2816 | */ |
2839 | common->can_stall = can_stall && !(gadget_is_at91(common->gadget)); | 2817 | common->can_stall = can_stall && |
2818 | gadget_is_stall_supported(common->gadget); | ||
2840 | 2819 | ||
2841 | return 0; | 2820 | return 0; |
2842 | } | 2821 | } |
@@ -2880,7 +2859,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, | |||
2880 | char *pathbuf, *p; | 2859 | char *pathbuf, *p; |
2881 | int rc = -ENOMEM; | 2860 | int rc = -ENOMEM; |
2882 | 2861 | ||
2883 | if (!common->nluns || !common->luns) | 2862 | if (id >= ARRAY_SIZE(common->luns)) |
2884 | return -ENODEV; | 2863 | return -ENODEV; |
2885 | 2864 | ||
2886 | if (common->luns[id]) | 2865 | if (common->luns[id]) |
@@ -2949,7 +2928,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, | |||
2949 | return 0; | 2928 | return 0; |
2950 | 2929 | ||
2951 | error_lun: | 2930 | error_lun: |
2952 | if (common->sysfs) | 2931 | if (device_is_registered(&lun->dev)) |
2953 | device_unregister(&lun->dev); | 2932 | device_unregister(&lun->dev); |
2954 | fsg_lun_close(lun); | 2933 | fsg_lun_close(lun); |
2955 | common->luns[id] = NULL; | 2934 | common->luns[id] = NULL; |
@@ -2964,14 +2943,16 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) | |||
2964 | char buf[8]; /* enough for 100000000 different numbers, decimal */ | 2943 | char buf[8]; /* enough for 100000000 different numbers, decimal */ |
2965 | int i, rc; | 2944 | int i, rc; |
2966 | 2945 | ||
2967 | for (i = 0; i < common->nluns; ++i) { | 2946 | fsg_common_remove_luns(common); |
2947 | |||
2948 | for (i = 0; i < cfg->nluns; ++i) { | ||
2968 | snprintf(buf, sizeof(buf), "lun%d", i); | 2949 | snprintf(buf, sizeof(buf), "lun%d", i); |
2969 | rc = fsg_common_create_lun(common, &cfg->luns[i], i, buf, NULL); | 2950 | rc = fsg_common_create_lun(common, &cfg->luns[i], i, buf, NULL); |
2970 | if (rc) | 2951 | if (rc) |
2971 | goto fail; | 2952 | goto fail; |
2972 | } | 2953 | } |
2973 | 2954 | ||
2974 | pr_info("Number of LUNs=%d\n", common->nluns); | 2955 | pr_info("Number of LUNs=%d\n", cfg->nluns); |
2975 | 2956 | ||
2976 | return 0; | 2957 | return 0; |
2977 | 2958 | ||
@@ -3020,6 +3001,7 @@ EXPORT_SYMBOL_GPL(fsg_common_run_thread); | |||
3020 | static void fsg_common_release(struct kref *ref) | 3001 | static void fsg_common_release(struct kref *ref) |
3021 | { | 3002 | { |
3022 | struct fsg_common *common = container_of(ref, struct fsg_common, ref); | 3003 | struct fsg_common *common = container_of(ref, struct fsg_common, ref); |
3004 | int i; | ||
3023 | 3005 | ||
3024 | /* If the thread isn't already dead, tell it to exit now */ | 3006 | /* If the thread isn't already dead, tell it to exit now */ |
3025 | if (common->state != FSG_STATE_TERMINATED) { | 3007 | if (common->state != FSG_STATE_TERMINATED) { |
@@ -3027,22 +3009,14 @@ static void fsg_common_release(struct kref *ref) | |||
3027 | wait_for_completion(&common->thread_notifier); | 3009 | wait_for_completion(&common->thread_notifier); |
3028 | } | 3010 | } |
3029 | 3011 | ||
3030 | if (likely(common->luns)) { | 3012 | for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { |
3031 | struct fsg_lun **lun_it = common->luns; | 3013 | struct fsg_lun *lun = common->luns[i]; |
3032 | unsigned i = common->nluns; | 3014 | if (!lun) |
3033 | 3015 | continue; | |
3034 | /* In error recovery common->nluns may be zero. */ | 3016 | fsg_lun_close(lun); |
3035 | for (; i; --i, ++lun_it) { | 3017 | if (device_is_registered(&lun->dev)) |
3036 | struct fsg_lun *lun = *lun_it; | 3018 | device_unregister(&lun->dev); |
3037 | if (!lun) | 3019 | kfree(lun); |
3038 | continue; | ||
3039 | fsg_lun_close(lun); | ||
3040 | if (common->sysfs) | ||
3041 | device_unregister(&lun->dev); | ||
3042 | kfree(lun); | ||
3043 | } | ||
3044 | |||
3045 | kfree(common->luns); | ||
3046 | } | 3020 | } |
3047 | 3021 | ||
3048 | _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); | 3022 | _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); |
@@ -3056,6 +3030,7 @@ static void fsg_common_release(struct kref *ref) | |||
3056 | static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | 3030 | static int fsg_bind(struct usb_configuration *c, struct usb_function *f) |
3057 | { | 3031 | { |
3058 | struct fsg_dev *fsg = fsg_from_func(f); | 3032 | struct fsg_dev *fsg = fsg_from_func(f); |
3033 | struct fsg_common *common = fsg->common; | ||
3059 | struct usb_gadget *gadget = c->cdev->gadget; | 3034 | struct usb_gadget *gadget = c->cdev->gadget; |
3060 | int i; | 3035 | int i; |
3061 | struct usb_ep *ep; | 3036 | struct usb_ep *ep; |
@@ -3063,6 +3038,13 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
3063 | int ret; | 3038 | int ret; |
3064 | struct fsg_opts *opts; | 3039 | struct fsg_opts *opts; |
3065 | 3040 | ||
3041 | /* Don't allow to bind if we don't have at least one LUN */ | ||
3042 | ret = _fsg_common_get_max_lun(common); | ||
3043 | if (ret < 0) { | ||
3044 | pr_err("There should be at least one LUN.\n"); | ||
3045 | return -EINVAL; | ||
3046 | } | ||
3047 | |||
3066 | opts = fsg_opts_from_func_inst(f->fi); | 3048 | opts = fsg_opts_from_func_inst(f->fi); |
3067 | if (!opts->no_configfs) { | 3049 | if (!opts->no_configfs) { |
3068 | ret = fsg_common_set_cdev(fsg->common, c->cdev, | 3050 | ret = fsg_common_set_cdev(fsg->common, c->cdev, |
@@ -3080,7 +3062,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
3080 | /* New interface */ | 3062 | /* New interface */ |
3081 | i = usb_interface_id(c, f); | 3063 | i = usb_interface_id(c, f); |
3082 | if (i < 0) | 3064 | if (i < 0) |
3083 | return i; | 3065 | goto fail; |
3084 | fsg_intf_desc.bInterfaceNumber = i; | 3066 | fsg_intf_desc.bInterfaceNumber = i; |
3085 | fsg->interface_number = i; | 3067 | fsg->interface_number = i; |
3086 | 3068 | ||
@@ -3123,7 +3105,14 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
3123 | 3105 | ||
3124 | autoconf_fail: | 3106 | autoconf_fail: |
3125 | ERROR(fsg, "unable to autoconfigure all endpoints\n"); | 3107 | ERROR(fsg, "unable to autoconfigure all endpoints\n"); |
3126 | return -ENOTSUPP; | 3108 | i = -ENOTSUPP; |
3109 | fail: | ||
3110 | /* terminate the thread */ | ||
3111 | if (fsg->common->state != FSG_STATE_TERMINATED) { | ||
3112 | raise_exception(fsg->common, FSG_STATE_EXIT); | ||
3113 | wait_for_completion(&fsg->common->thread_notifier); | ||
3114 | } | ||
3115 | return i; | ||
3127 | } | 3116 | } |
3128 | 3117 | ||
3129 | /****************************** ALLOCATE FUNCTION *************************/ | 3118 | /****************************** ALLOCATE FUNCTION *************************/ |
@@ -3355,7 +3344,7 @@ static void fsg_lun_drop(struct config_group *group, struct config_item *item) | |||
3355 | unregister_gadget_item(gadget); | 3344 | unregister_gadget_item(gadget); |
3356 | } | 3345 | } |
3357 | 3346 | ||
3358 | fsg_common_remove_lun(lun_opts->lun, fsg_opts->common->sysfs); | 3347 | fsg_common_remove_lun(lun_opts->lun); |
3359 | fsg_opts->common->luns[lun_opts->lun_id] = NULL; | 3348 | fsg_opts->common->luns[lun_opts->lun_id] = NULL; |
3360 | lun_opts->lun_id = 0; | 3349 | lun_opts->lun_id = 0; |
3361 | mutex_unlock(&fsg_opts->lock); | 3350 | mutex_unlock(&fsg_opts->lock); |
@@ -3509,14 +3498,11 @@ static struct usb_function_instance *fsg_alloc_inst(void) | |||
3509 | rc = PTR_ERR(opts->common); | 3498 | rc = PTR_ERR(opts->common); |
3510 | goto release_opts; | 3499 | goto release_opts; |
3511 | } | 3500 | } |
3512 | rc = fsg_common_set_nluns(opts->common, FSG_MAX_LUNS); | ||
3513 | if (rc) | ||
3514 | goto release_opts; | ||
3515 | 3501 | ||
3516 | rc = fsg_common_set_num_buffers(opts->common, | 3502 | rc = fsg_common_set_num_buffers(opts->common, |
3517 | CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS); | 3503 | CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS); |
3518 | if (rc) | 3504 | if (rc) |
3519 | goto release_luns; | 3505 | goto release_opts; |
3520 | 3506 | ||
3521 | pr_info(FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); | 3507 | pr_info(FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); |
3522 | 3508 | ||
@@ -3524,6 +3510,9 @@ static struct usb_function_instance *fsg_alloc_inst(void) | |||
3524 | config.removable = true; | 3510 | config.removable = true; |
3525 | rc = fsg_common_create_lun(opts->common, &config, 0, "lun.0", | 3511 | rc = fsg_common_create_lun(opts->common, &config, 0, "lun.0", |
3526 | (const char **)&opts->func_inst.group.cg_item.ci_name); | 3512 | (const char **)&opts->func_inst.group.cg_item.ci_name); |
3513 | if (rc) | ||
3514 | goto release_buffers; | ||
3515 | |||
3527 | opts->lun0.lun = opts->common->luns[0]; | 3516 | opts->lun0.lun = opts->common->luns[0]; |
3528 | opts->lun0.lun_id = 0; | 3517 | opts->lun0.lun_id = 0; |
3529 | config_group_init_type_name(&opts->lun0.group, "lun.0", &fsg_lun_type); | 3518 | config_group_init_type_name(&opts->lun0.group, "lun.0", &fsg_lun_type); |
@@ -3534,8 +3523,8 @@ static struct usb_function_instance *fsg_alloc_inst(void) | |||
3534 | 3523 | ||
3535 | return &opts->func_inst; | 3524 | return &opts->func_inst; |
3536 | 3525 | ||
3537 | release_luns: | 3526 | release_buffers: |
3538 | kfree(opts->common->luns); | 3527 | fsg_common_free_buffers(opts->common); |
3539 | release_opts: | 3528 | release_opts: |
3540 | kfree(opts); | 3529 | kfree(opts); |
3541 | return ERR_PTR(rc); | 3530 | return ERR_PTR(rc); |
@@ -3561,23 +3550,12 @@ static struct usb_function *fsg_alloc(struct usb_function_instance *fi) | |||
3561 | struct fsg_opts *opts = fsg_opts_from_func_inst(fi); | 3550 | struct fsg_opts *opts = fsg_opts_from_func_inst(fi); |
3562 | struct fsg_common *common = opts->common; | 3551 | struct fsg_common *common = opts->common; |
3563 | struct fsg_dev *fsg; | 3552 | struct fsg_dev *fsg; |
3564 | unsigned nluns, i; | ||
3565 | 3553 | ||
3566 | fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); | 3554 | fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); |
3567 | if (unlikely(!fsg)) | 3555 | if (unlikely(!fsg)) |
3568 | return ERR_PTR(-ENOMEM); | 3556 | return ERR_PTR(-ENOMEM); |
3569 | 3557 | ||
3570 | mutex_lock(&opts->lock); | 3558 | mutex_lock(&opts->lock); |
3571 | if (!opts->refcnt) { | ||
3572 | for (nluns = i = 0; i < FSG_MAX_LUNS; ++i) | ||
3573 | if (common->luns[i]) | ||
3574 | nluns = i + 1; | ||
3575 | if (!nluns) | ||
3576 | pr_warn("No LUNS defined, continuing anyway\n"); | ||
3577 | else | ||
3578 | common->nluns = nluns; | ||
3579 | pr_info("Number of LUNs=%u\n", common->nluns); | ||
3580 | } | ||
3581 | opts->refcnt++; | 3559 | opts->refcnt++; |
3582 | mutex_unlock(&opts->lock); | 3560 | mutex_unlock(&opts->lock); |
3583 | 3561 | ||
diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h index b4866fcef30b..445df6775609 100644 --- a/drivers/usb/gadget/function/f_mass_storage.h +++ b/drivers/usb/gadget/function/f_mass_storage.h | |||
@@ -137,14 +137,10 @@ void fsg_common_free_buffers(struct fsg_common *common); | |||
137 | int fsg_common_set_cdev(struct fsg_common *common, | 137 | int fsg_common_set_cdev(struct fsg_common *common, |
138 | struct usb_composite_dev *cdev, bool can_stall); | 138 | struct usb_composite_dev *cdev, bool can_stall); |
139 | 139 | ||
140 | void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); | 140 | void fsg_common_remove_lun(struct fsg_lun *lun); |
141 | 141 | ||
142 | void fsg_common_remove_luns(struct fsg_common *common); | 142 | void fsg_common_remove_luns(struct fsg_common *common); |
143 | 143 | ||
144 | void fsg_common_free_luns(struct fsg_common *common); | ||
145 | |||
146 | int fsg_common_set_nluns(struct fsg_common *common, int nluns); | ||
147 | |||
148 | void fsg_common_set_ops(struct fsg_common *common, | 144 | void fsg_common_set_ops(struct fsg_common *common, |
149 | const struct fsg_operations *ops); | 145 | const struct fsg_operations *ops); |
150 | 146 | ||
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index ad50a67c1465..a287a4829273 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c | |||
@@ -329,6 +329,10 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
329 | unsigned i; | 329 | unsigned i; |
330 | int err; | 330 | int err; |
331 | 331 | ||
332 | /* For Control Device interface we do nothing */ | ||
333 | if (intf == 0) | ||
334 | return 0; | ||
335 | |||
332 | err = f_midi_start_ep(midi, f, midi->in_ep); | 336 | err = f_midi_start_ep(midi, f, midi->in_ep); |
333 | if (err) | 337 | if (err) |
334 | return err; | 338 | return err; |
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index bdcda9f5148e..3f05c6bd57f0 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c | |||
@@ -853,9 +853,8 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
853 | /* Enable zlps by default for NCM conformance; | 853 | /* Enable zlps by default for NCM conformance; |
854 | * override for musb_hdrc (avoids txdma ovhead) | 854 | * override for musb_hdrc (avoids txdma ovhead) |
855 | */ | 855 | */ |
856 | ncm->port.is_zlp_ok = !( | 856 | ncm->port.is_zlp_ok = |
857 | gadget_is_musbhdrc(cdev->gadget) | 857 | gadget_is_zlp_supported(cdev->gadget); |
858 | ); | ||
859 | ncm->port.cdc_filter = DEFAULT_FILTER; | 858 | ncm->port.cdc_filter = DEFAULT_FILTER; |
860 | DBG(cdev, "activate ncm\n"); | 859 | DBG(cdev, "activate ncm\n"); |
861 | net = gether_connect(&ncm->port); | 860 | net = gether_connect(&ncm->port); |
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index a1b79c53499c..5460426057eb 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | 21 | ||
22 | #include "u_serial.h" | 22 | #include "u_serial.h" |
23 | #include "gadget_chips.h" | ||
24 | 23 | ||
25 | 24 | ||
26 | /* | 25 | /* |
@@ -37,7 +36,6 @@ struct f_obex { | |||
37 | u8 data_id; | 36 | u8 data_id; |
38 | u8 cur_alt; | 37 | u8 cur_alt; |
39 | u8 port_num; | 38 | u8 port_num; |
40 | u8 can_activate; | ||
41 | }; | 39 | }; |
42 | 40 | ||
43 | static inline struct f_obex *func_to_obex(struct usb_function *f) | 41 | static inline struct f_obex *func_to_obex(struct usb_function *f) |
@@ -268,9 +266,6 @@ static void obex_connect(struct gserial *g) | |||
268 | struct usb_composite_dev *cdev = g->func.config->cdev; | 266 | struct usb_composite_dev *cdev = g->func.config->cdev; |
269 | int status; | 267 | int status; |
270 | 268 | ||
271 | if (!obex->can_activate) | ||
272 | return; | ||
273 | |||
274 | status = usb_function_activate(&g->func); | 269 | status = usb_function_activate(&g->func); |
275 | if (status) | 270 | if (status) |
276 | dev_dbg(&cdev->gadget->dev, | 271 | dev_dbg(&cdev->gadget->dev, |
@@ -284,9 +279,6 @@ static void obex_disconnect(struct gserial *g) | |||
284 | struct usb_composite_dev *cdev = g->func.config->cdev; | 279 | struct usb_composite_dev *cdev = g->func.config->cdev; |
285 | int status; | 280 | int status; |
286 | 281 | ||
287 | if (!obex->can_activate) | ||
288 | return; | ||
289 | |||
290 | status = usb_function_deactivate(&g->func); | 282 | status = usb_function_deactivate(&g->func); |
291 | if (status) | 283 | if (status) |
292 | dev_dbg(&cdev->gadget->dev, | 284 | dev_dbg(&cdev->gadget->dev, |
@@ -304,7 +296,7 @@ static inline bool can_support_obex(struct usb_configuration *c) | |||
304 | * | 296 | * |
305 | * Altsettings are mandatory, however... | 297 | * Altsettings are mandatory, however... |
306 | */ | 298 | */ |
307 | if (!gadget_supports_altsettings(c->cdev->gadget)) | 299 | if (!gadget_is_altset_supported(c->cdev->gadget)) |
308 | return false; | 300 | return false; |
309 | 301 | ||
310 | /* everything else is *probably* fine ... */ | 302 | /* everything else is *probably* fine ... */ |
@@ -378,17 +370,6 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
378 | if (status) | 370 | if (status) |
379 | goto fail; | 371 | goto fail; |
380 | 372 | ||
381 | /* Avoid letting this gadget enumerate until the userspace | ||
382 | * OBEX server is active. | ||
383 | */ | ||
384 | status = usb_function_deactivate(f); | ||
385 | if (status < 0) | ||
386 | WARNING(cdev, "obex ttyGS%d: can't prevent enumeration, %d\n", | ||
387 | obex->port_num, status); | ||
388 | else | ||
389 | obex->can_activate = true; | ||
390 | |||
391 | |||
392 | dev_dbg(&cdev->gadget->dev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", | 373 | dev_dbg(&cdev->gadget->dev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", |
393 | obex->port_num, | 374 | obex->port_num, |
394 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", | 375 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", |
@@ -529,6 +510,7 @@ static struct usb_function *obex_alloc(struct usb_function_instance *fi) | |||
529 | obex->port.func.get_alt = obex_get_alt; | 510 | obex->port.func.get_alt = obex_get_alt; |
530 | obex->port.func.disable = obex_disable; | 511 | obex->port.func.disable = obex_disable; |
531 | obex->port.func.free_func = obex_free; | 512 | obex->port.func.free_func = obex_free; |
513 | obex->port.func.bind_deactivated = true; | ||
532 | 514 | ||
533 | return &obex->port.func; | 515 | return &obex->port.func; |
534 | } | 516 | } |
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 357f63f47b42..8e2b6bea07bc 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c | |||
@@ -804,6 +804,8 @@ done: | |||
804 | 804 | ||
805 | static void printer_reset_interface(struct printer_dev *dev) | 805 | static void printer_reset_interface(struct printer_dev *dev) |
806 | { | 806 | { |
807 | unsigned long flags; | ||
808 | |||
807 | if (dev->interface < 0) | 809 | if (dev->interface < 0) |
808 | return; | 810 | return; |
809 | 811 | ||
@@ -815,9 +817,11 @@ static void printer_reset_interface(struct printer_dev *dev) | |||
815 | if (dev->out_ep->desc) | 817 | if (dev->out_ep->desc) |
816 | usb_ep_disable(dev->out_ep); | 818 | usb_ep_disable(dev->out_ep); |
817 | 819 | ||
820 | spin_lock_irqsave(&dev->lock, flags); | ||
818 | dev->in_ep->desc = NULL; | 821 | dev->in_ep->desc = NULL; |
819 | dev->out_ep->desc = NULL; | 822 | dev->out_ep->desc = NULL; |
820 | dev->interface = -1; | 823 | dev->interface = -1; |
824 | spin_unlock_irqrestore(&dev->lock, flags); | ||
821 | } | 825 | } |
822 | 826 | ||
823 | /* Change our operational Interface. */ | 827 | /* Change our operational Interface. */ |
@@ -1131,13 +1135,10 @@ static int printer_func_set_alt(struct usb_function *f, | |||
1131 | static void printer_func_disable(struct usb_function *f) | 1135 | static void printer_func_disable(struct usb_function *f) |
1132 | { | 1136 | { |
1133 | struct printer_dev *dev = func_to_printer(f); | 1137 | struct printer_dev *dev = func_to_printer(f); |
1134 | unsigned long flags; | ||
1135 | 1138 | ||
1136 | DBG(dev, "%s\n", __func__); | 1139 | DBG(dev, "%s\n", __func__); |
1137 | 1140 | ||
1138 | spin_lock_irqsave(&dev->lock, flags); | ||
1139 | printer_reset_interface(dev); | 1141 | printer_reset_interface(dev); |
1140 | spin_unlock_irqrestore(&dev->lock, flags); | ||
1141 | } | 1142 | } |
1142 | 1143 | ||
1143 | static inline struct f_printer_opts | 1144 | static inline struct f_printer_opts |
diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c index 2e02dfabc7ae..1d162e200e83 100644 --- a/drivers/usb/gadget/function/f_serial.c +++ b/drivers/usb/gadget/function/f_serial.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
17 | 17 | ||
18 | #include "u_serial.h" | 18 | #include "u_serial.h" |
19 | #include "gadget_chips.h" | ||
20 | 19 | ||
21 | 20 | ||
22 | /* | 21 | /* |
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c index 3a5ae9900b1e..cbfaf86fe456 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | 21 | ||
22 | #include "g_zero.h" | 22 | #include "g_zero.h" |
23 | #include "gadget_chips.h" | ||
24 | #include "u_f.h" | 23 | #include "u_f.h" |
25 | 24 | ||
26 | /* | 25 | /* |
@@ -42,11 +41,6 @@ | |||
42 | * queues are relatively independent, will receive a range of packet sizes, | 41 | * queues are relatively independent, will receive a range of packet sizes, |
43 | * and can often be made to run out completely. Those issues are important | 42 | * and can often be made to run out completely. Those issues are important |
44 | * when stress testing peripheral controller drivers. | 43 | * when stress testing peripheral controller drivers. |
45 | * | ||
46 | * | ||
47 | * This is currently packaged as a configuration driver, which can't be | ||
48 | * combined with other functions to make composite devices. However, it | ||
49 | * can be combined with other independent configurations. | ||
50 | */ | 44 | */ |
51 | struct f_sourcesink { | 45 | struct f_sourcesink { |
52 | struct usb_function function; | 46 | struct usb_function function; |
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 531861547253..f8de7ea2a0c1 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
@@ -975,6 +975,29 @@ free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep) | |||
975 | "%s:%d Error!\n", __func__, __LINE__); | 975 | "%s:%d Error!\n", __func__, __LINE__); |
976 | } | 976 | } |
977 | 977 | ||
978 | static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts, | ||
979 | struct usb_endpoint_descriptor *ep_desc, | ||
980 | unsigned int factor, bool is_playback) | ||
981 | { | ||
982 | int chmask, srate, ssize; | ||
983 | u16 max_packet_size; | ||
984 | |||
985 | if (is_playback) { | ||
986 | chmask = uac2_opts->p_chmask; | ||
987 | srate = uac2_opts->p_srate; | ||
988 | ssize = uac2_opts->p_ssize; | ||
989 | } else { | ||
990 | chmask = uac2_opts->c_chmask; | ||
991 | srate = uac2_opts->c_srate; | ||
992 | ssize = uac2_opts->c_ssize; | ||
993 | } | ||
994 | |||
995 | max_packet_size = num_channels(chmask) * ssize * | ||
996 | DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))); | ||
997 | ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_packet_size, | ||
998 | le16_to_cpu(ep_desc->wMaxPacketSize))); | ||
999 | } | ||
1000 | |||
978 | static int | 1001 | static int |
979 | afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | 1002 | afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) |
980 | { | 1003 | { |
@@ -1070,10 +1093,14 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1070 | uac2->p_prm.uac2 = uac2; | 1093 | uac2->p_prm.uac2 = uac2; |
1071 | uac2->c_prm.uac2 = uac2; | 1094 | uac2->c_prm.uac2 = uac2; |
1072 | 1095 | ||
1096 | /* Calculate wMaxPacketSize according to audio bandwidth */ | ||
1097 | set_ep_max_packet_size(uac2_opts, &fs_epin_desc, 1000, true); | ||
1098 | set_ep_max_packet_size(uac2_opts, &fs_epout_desc, 1000, false); | ||
1099 | set_ep_max_packet_size(uac2_opts, &hs_epin_desc, 8000, true); | ||
1100 | set_ep_max_packet_size(uac2_opts, &hs_epout_desc, 8000, false); | ||
1101 | |||
1073 | hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; | 1102 | hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; |
1074 | hs_epout_desc.wMaxPacketSize = fs_epout_desc.wMaxPacketSize; | ||
1075 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; | 1103 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; |
1076 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; | ||
1077 | 1104 | ||
1078 | ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL); | 1105 | ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL); |
1079 | if (ret) | 1106 | if (ret) |
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index cf0df8fbba89..743be34605dc 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c | |||
@@ -733,12 +733,6 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) | |||
733 | uvc->control_req->complete = uvc_function_ep0_complete; | 733 | uvc->control_req->complete = uvc_function_ep0_complete; |
734 | uvc->control_req->context = uvc; | 734 | uvc->control_req->context = uvc; |
735 | 735 | ||
736 | /* Avoid letting this gadget enumerate until the userspace server is | ||
737 | * active. | ||
738 | */ | ||
739 | if ((ret = usb_function_deactivate(f)) < 0) | ||
740 | goto error; | ||
741 | |||
742 | if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { | 736 | if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { |
743 | printk(KERN_INFO "v4l2_device_register failed\n"); | 737 | printk(KERN_INFO "v4l2_device_register failed\n"); |
744 | goto error; | 738 | goto error; |
@@ -949,6 +943,7 @@ static struct usb_function *uvc_alloc(struct usb_function_instance *fi) | |||
949 | uvc->func.disable = uvc_function_disable; | 943 | uvc->func.disable = uvc_function_disable; |
950 | uvc->func.setup = uvc_function_setup; | 944 | uvc->func.setup = uvc_function_setup; |
951 | uvc->func.free_func = uvc_free; | 945 | uvc->func.free_func = uvc_free; |
946 | uvc->func.bind_deactivated = true; | ||
952 | 947 | ||
953 | return &uvc->func; | 948 | return &uvc->func; |
954 | } | 949 | } |
diff --git a/drivers/usb/gadget/function/storage_common.h b/drivers/usb/gadget/function/storage_common.h index 70c891469f57..c3544e61da66 100644 --- a/drivers/usb/gadget/function/storage_common.h +++ b/drivers/usb/gadget/function/storage_common.h | |||
@@ -123,7 +123,7 @@ static inline bool fsg_lun_is_open(struct fsg_lun *curlun) | |||
123 | #define FSG_BUFLEN ((u32)16384) | 123 | #define FSG_BUFLEN ((u32)16384) |
124 | 124 | ||
125 | /* Maximal number of LUNs supported in mass storage function */ | 125 | /* Maximal number of LUNs supported in mass storage function */ |
126 | #define FSG_MAX_LUNS 8 | 126 | #define FSG_MAX_LUNS 16 |
127 | 127 | ||
128 | enum fsg_buffer_state { | 128 | enum fsg_buffer_state { |
129 | BUF_STATE_EMPTY = 0, | 129 | BUF_STATE_EMPTY = 0, |
diff --git a/drivers/usb/gadget/function/u_ether.h b/drivers/usb/gadget/function/u_ether.h index 334b38947916..c77145bd6b5b 100644 --- a/drivers/usb/gadget/function/u_ether.h +++ b/drivers/usb/gadget/function/u_ether.h | |||
@@ -20,8 +20,6 @@ | |||
20 | #include <linux/usb/cdc.h> | 20 | #include <linux/usb/cdc.h> |
21 | #include <linux/netdevice.h> | 21 | #include <linux/netdevice.h> |
22 | 22 | ||
23 | #include "gadget_chips.h" | ||
24 | |||
25 | #define QMULT_DEFAULT 5 | 23 | #define QMULT_DEFAULT 5 |
26 | 24 | ||
27 | /* | 25 | /* |
@@ -259,7 +257,7 @@ void gether_disconnect(struct gether *); | |||
259 | /* Some controllers can't support CDC Ethernet (ECM) ... */ | 257 | /* Some controllers can't support CDC Ethernet (ECM) ... */ |
260 | static inline bool can_support_ecm(struct usb_gadget *gadget) | 258 | static inline bool can_support_ecm(struct usb_gadget *gadget) |
261 | { | 259 | { |
262 | if (!gadget_supports_altsettings(gadget)) | 260 | if (!gadget_is_altset_supported(gadget)) |
263 | return false; | 261 | return false; |
264 | 262 | ||
265 | /* Everything else is *presumably* fine ... but this is a bit | 263 | /* Everything else is *presumably* fine ... but this is a bit |
diff --git a/drivers/usb/gadget/function/u_uac1.h b/drivers/usb/gadget/function/u_uac1.h index fe386df6dd3e..5c2ac8e8456d 100644 --- a/drivers/usb/gadget/function/u_uac1.h +++ b/drivers/usb/gadget/function/u_uac1.h | |||
@@ -21,8 +21,6 @@ | |||
21 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
22 | #include <sound/pcm_params.h> | 22 | #include <sound/pcm_params.h> |
23 | 23 | ||
24 | #include "gadget_chips.h" | ||
25 | |||
26 | #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p" | 24 | #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p" |
27 | #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c" | 25 | #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c" |
28 | #define FILE_CONTROL "/dev/snd/controlC0" | 26 | #define FILE_CONTROL "/dev/snd/controlC0" |
diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig index d5a7102de696..4d682ad7bf23 100644 --- a/drivers/usb/gadget/legacy/Kconfig +++ b/drivers/usb/gadget/legacy/Kconfig | |||
@@ -339,6 +339,7 @@ config USB_CDC_COMPOSITE | |||
339 | config USB_G_NOKIA | 339 | config USB_G_NOKIA |
340 | tristate "Nokia composite gadget" | 340 | tristate "Nokia composite gadget" |
341 | depends on PHONET | 341 | depends on PHONET |
342 | depends on BLOCK | ||
342 | select USB_LIBCOMPOSITE | 343 | select USB_LIBCOMPOSITE |
343 | select USB_U_SERIAL | 344 | select USB_U_SERIAL |
344 | select USB_U_ETHER | 345 | select USB_U_ETHER |
@@ -346,6 +347,7 @@ config USB_G_NOKIA | |||
346 | select USB_F_OBEX | 347 | select USB_F_OBEX |
347 | select USB_F_PHONET | 348 | select USB_F_PHONET |
348 | select USB_F_ECM | 349 | select USB_F_ECM |
350 | select USB_F_MASS_STORAGE | ||
349 | help | 351 | help |
350 | The Nokia composite gadget provides support for acm, obex | 352 | The Nokia composite gadget provides support for acm, obex |
351 | and phonet in only one composite gadget driver. | 353 | and phonet in only one composite gadget driver. |
diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c index 1194b09ae746..4b158e2d1e57 100644 --- a/drivers/usb/gadget/legacy/acm_ms.c +++ b/drivers/usb/gadget/legacy/acm_ms.c | |||
@@ -58,21 +58,7 @@ static struct usb_device_descriptor device_desc = { | |||
58 | /*.bNumConfigurations = DYNAMIC*/ | 58 | /*.bNumConfigurations = DYNAMIC*/ |
59 | }; | 59 | }; |
60 | 60 | ||
61 | static struct usb_otg_descriptor otg_descriptor = { | 61 | static const struct usb_descriptor_header *otg_desc[2]; |
62 | .bLength = sizeof otg_descriptor, | ||
63 | .bDescriptorType = USB_DT_OTG, | ||
64 | |||
65 | /* | ||
66 | * REVISIT SRP-only hardware is possible, although | ||
67 | * it would not be called "OTG" ... | ||
68 | */ | ||
69 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
70 | }; | ||
71 | |||
72 | static const struct usb_descriptor_header *otg_desc[] = { | ||
73 | (struct usb_descriptor_header *) &otg_descriptor, | ||
74 | NULL, | ||
75 | }; | ||
76 | 62 | ||
77 | /* string IDs are assigned dynamically */ | 63 | /* string IDs are assigned dynamically */ |
78 | static struct usb_string strings_dev[] = { | 64 | static struct usb_string strings_dev[] = { |
@@ -200,10 +186,6 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) | |||
200 | if (status) | 186 | if (status) |
201 | goto fail; | 187 | goto fail; |
202 | 188 | ||
203 | status = fsg_common_set_nluns(opts->common, config.nluns); | ||
204 | if (status) | ||
205 | goto fail_set_nluns; | ||
206 | |||
207 | status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); | 189 | status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); |
208 | if (status) | 190 | if (status) |
209 | goto fail_set_cdev; | 191 | goto fail_set_cdev; |
@@ -225,10 +207,21 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) | |||
225 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 207 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
226 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 208 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
227 | 209 | ||
210 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
211 | struct usb_descriptor_header *usb_desc; | ||
212 | |||
213 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
214 | if (!usb_desc) | ||
215 | goto fail_string_ids; | ||
216 | usb_otg_descriptor_init(gadget, usb_desc); | ||
217 | otg_desc[0] = usb_desc; | ||
218 | otg_desc[1] = NULL; | ||
219 | } | ||
220 | |||
228 | /* register our configuration */ | 221 | /* register our configuration */ |
229 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); | 222 | status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); |
230 | if (status < 0) | 223 | if (status < 0) |
231 | goto fail_string_ids; | 224 | goto fail_otg_desc; |
232 | 225 | ||
233 | usb_composite_overwrite_options(cdev, &coverwrite); | 226 | usb_composite_overwrite_options(cdev, &coverwrite); |
234 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 227 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
@@ -236,11 +229,12 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) | |||
236 | return 0; | 229 | return 0; |
237 | 230 | ||
238 | /* error recovery */ | 231 | /* error recovery */ |
232 | fail_otg_desc: | ||
233 | kfree(otg_desc[0]); | ||
234 | otg_desc[0] = NULL; | ||
239 | fail_string_ids: | 235 | fail_string_ids: |
240 | fsg_common_remove_luns(opts->common); | 236 | fsg_common_remove_luns(opts->common); |
241 | fail_set_cdev: | 237 | fail_set_cdev: |
242 | fsg_common_free_luns(opts->common); | ||
243 | fail_set_nluns: | ||
244 | fsg_common_free_buffers(opts->common); | 238 | fsg_common_free_buffers(opts->common); |
245 | fail: | 239 | fail: |
246 | usb_put_function_instance(fi_msg); | 240 | usb_put_function_instance(fi_msg); |
@@ -255,6 +249,9 @@ static int acm_ms_unbind(struct usb_composite_dev *cdev) | |||
255 | usb_put_function_instance(fi_msg); | 249 | usb_put_function_instance(fi_msg); |
256 | usb_put_function(f_acm); | 250 | usb_put_function(f_acm); |
257 | usb_put_function_instance(f_acm_inst); | 251 | usb_put_function_instance(f_acm_inst); |
252 | kfree(otg_desc[0]); | ||
253 | otg_desc[0] = NULL; | ||
254 | |||
258 | return 0; | 255 | return 0; |
259 | } | 256 | } |
260 | 257 | ||
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c index f289caf18a45..685cf3b4b78f 100644 --- a/drivers/usb/gadget/legacy/audio.c +++ b/drivers/usb/gadget/legacy/audio.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/usb/composite.h> | 16 | #include <linux/usb/composite.h> |
17 | 17 | ||
18 | #include "gadget_chips.h" | ||
19 | #define DRIVER_DESC "Linux USB Audio Gadget" | 18 | #define DRIVER_DESC "Linux USB Audio Gadget" |
20 | #define DRIVER_VERSION "Feb 2, 2012" | 19 | #define DRIVER_VERSION "Feb 2, 2012" |
21 | 20 | ||
@@ -124,7 +123,7 @@ static struct usb_device_descriptor device_desc = { | |||
124 | .bLength = sizeof device_desc, | 123 | .bLength = sizeof device_desc, |
125 | .bDescriptorType = USB_DT_DEVICE, | 124 | .bDescriptorType = USB_DT_DEVICE, |
126 | 125 | ||
127 | .bcdUSB = __constant_cpu_to_le16(0x200), | 126 | .bcdUSB = cpu_to_le16(0x200), |
128 | 127 | ||
129 | #ifdef CONFIG_GADGET_UAC1 | 128 | #ifdef CONFIG_GADGET_UAC1 |
130 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | 129 | .bDeviceClass = USB_CLASS_PER_INTERFACE, |
@@ -141,8 +140,8 @@ static struct usb_device_descriptor device_desc = { | |||
141 | * we support. (As does bNumConfigurations.) These values can | 140 | * we support. (As does bNumConfigurations.) These values can |
142 | * also be overridden by module parameters. | 141 | * also be overridden by module parameters. |
143 | */ | 142 | */ |
144 | .idVendor = __constant_cpu_to_le16(AUDIO_VENDOR_NUM), | 143 | .idVendor = cpu_to_le16(AUDIO_VENDOR_NUM), |
145 | .idProduct = __constant_cpu_to_le16(AUDIO_PRODUCT_NUM), | 144 | .idProduct = cpu_to_le16(AUDIO_PRODUCT_NUM), |
146 | /* .bcdDevice = f(hardware) */ | 145 | /* .bcdDevice = f(hardware) */ |
147 | /* .iManufacturer = DYNAMIC */ | 146 | /* .iManufacturer = DYNAMIC */ |
148 | /* .iProduct = DYNAMIC */ | 147 | /* .iProduct = DYNAMIC */ |
@@ -150,20 +149,7 @@ static struct usb_device_descriptor device_desc = { | |||
150 | .bNumConfigurations = 1, | 149 | .bNumConfigurations = 1, |
151 | }; | 150 | }; |
152 | 151 | ||
153 | static struct usb_otg_descriptor otg_descriptor = { | 152 | static const struct usb_descriptor_header *otg_desc[2]; |
154 | .bLength = sizeof otg_descriptor, | ||
155 | .bDescriptorType = USB_DT_OTG, | ||
156 | |||
157 | /* REVISIT SRP-only hardware is possible, although | ||
158 | * it would not be called "OTG" ... | ||
159 | */ | ||
160 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
161 | }; | ||
162 | |||
163 | static const struct usb_descriptor_header *otg_desc[] = { | ||
164 | (struct usb_descriptor_header *) &otg_descriptor, | ||
165 | NULL, | ||
166 | }; | ||
167 | 153 | ||
168 | /*-------------------------------------------------------------------------*/ | 154 | /*-------------------------------------------------------------------------*/ |
169 | 155 | ||
@@ -259,14 +245,28 @@ static int audio_bind(struct usb_composite_dev *cdev) | |||
259 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 245 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
260 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 246 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
261 | 247 | ||
248 | if (gadget_is_otg(cdev->gadget) && !otg_desc[0]) { | ||
249 | struct usb_descriptor_header *usb_desc; | ||
250 | |||
251 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); | ||
252 | if (!usb_desc) | ||
253 | goto fail; | ||
254 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
255 | otg_desc[0] = usb_desc; | ||
256 | otg_desc[1] = NULL; | ||
257 | } | ||
258 | |||
262 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); | 259 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); |
263 | if (status < 0) | 260 | if (status < 0) |
264 | goto fail; | 261 | goto fail_otg_desc; |
265 | usb_composite_overwrite_options(cdev, &coverwrite); | 262 | usb_composite_overwrite_options(cdev, &coverwrite); |
266 | 263 | ||
267 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); | 264 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); |
268 | return 0; | 265 | return 0; |
269 | 266 | ||
267 | fail_otg_desc: | ||
268 | kfree(otg_desc[0]); | ||
269 | otg_desc[0] = NULL; | ||
270 | fail: | 270 | fail: |
271 | #ifndef CONFIG_GADGET_UAC1 | 271 | #ifndef CONFIG_GADGET_UAC1 |
272 | usb_put_function_instance(fi_uac2); | 272 | usb_put_function_instance(fi_uac2); |
@@ -289,6 +289,9 @@ static int audio_unbind(struct usb_composite_dev *cdev) | |||
289 | if (!IS_ERR_OR_NULL(fi_uac2)) | 289 | if (!IS_ERR_OR_NULL(fi_uac2)) |
290 | usb_put_function_instance(fi_uac2); | 290 | usb_put_function_instance(fi_uac2); |
291 | #endif | 291 | #endif |
292 | kfree(otg_desc[0]); | ||
293 | otg_desc[0] = NULL; | ||
294 | |||
292 | return 0; | 295 | return 0; |
293 | } | 296 | } |
294 | 297 | ||
diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c index afd3e37921a7..ecd8c8d62f2e 100644 --- a/drivers/usb/gadget/legacy/cdc2.c +++ b/drivers/usb/gadget/legacy/cdc2.c | |||
@@ -60,21 +60,7 @@ static struct usb_device_descriptor device_desc = { | |||
60 | .bNumConfigurations = 1, | 60 | .bNumConfigurations = 1, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static struct usb_otg_descriptor otg_descriptor = { | 63 | static const struct usb_descriptor_header *otg_desc[2]; |
64 | .bLength = sizeof otg_descriptor, | ||
65 | .bDescriptorType = USB_DT_OTG, | ||
66 | |||
67 | /* REVISIT SRP-only hardware is possible, although | ||
68 | * it would not be called "OTG" ... | ||
69 | */ | ||
70 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
71 | }; | ||
72 | |||
73 | static const struct usb_descriptor_header *otg_desc[] = { | ||
74 | (struct usb_descriptor_header *) &otg_descriptor, | ||
75 | NULL, | ||
76 | }; | ||
77 | |||
78 | 64 | ||
79 | /* string IDs are assigned dynamically */ | 65 | /* string IDs are assigned dynamically */ |
80 | static struct usb_string strings_dev[] = { | 66 | static struct usb_string strings_dev[] = { |
@@ -193,10 +179,21 @@ static int cdc_bind(struct usb_composite_dev *cdev) | |||
193 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 179 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
194 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 180 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
195 | 181 | ||
182 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
183 | struct usb_descriptor_header *usb_desc; | ||
184 | |||
185 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
186 | if (!usb_desc) | ||
187 | goto fail1; | ||
188 | usb_otg_descriptor_init(gadget, usb_desc); | ||
189 | otg_desc[0] = usb_desc; | ||
190 | otg_desc[1] = NULL; | ||
191 | } | ||
192 | |||
196 | /* register our configuration */ | 193 | /* register our configuration */ |
197 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); | 194 | status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); |
198 | if (status < 0) | 195 | if (status < 0) |
199 | goto fail1; | 196 | goto fail2; |
200 | 197 | ||
201 | usb_composite_overwrite_options(cdev, &coverwrite); | 198 | usb_composite_overwrite_options(cdev, &coverwrite); |
202 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 199 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
@@ -204,6 +201,9 @@ static int cdc_bind(struct usb_composite_dev *cdev) | |||
204 | 201 | ||
205 | return 0; | 202 | return 0; |
206 | 203 | ||
204 | fail2: | ||
205 | kfree(otg_desc[0]); | ||
206 | otg_desc[0] = NULL; | ||
207 | fail1: | 207 | fail1: |
208 | usb_put_function_instance(fi_serial); | 208 | usb_put_function_instance(fi_serial); |
209 | fail: | 209 | fail: |
@@ -219,6 +219,9 @@ static int cdc_unbind(struct usb_composite_dev *cdev) | |||
219 | usb_put_function(f_ecm); | 219 | usb_put_function(f_ecm); |
220 | if (!IS_ERR_OR_NULL(fi_ecm)) | 220 | if (!IS_ERR_OR_NULL(fi_ecm)) |
221 | usb_put_function_instance(fi_ecm); | 221 | usb_put_function_instance(fi_ecm); |
222 | kfree(otg_desc[0]); | ||
223 | otg_desc[0] = NULL; | ||
224 | |||
222 | return 0; | 225 | return 0; |
223 | } | 226 | } |
224 | 227 | ||
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c index 204b10b1a7e7..5231a32aef55 100644 --- a/drivers/usb/gadget/legacy/dbgp.c +++ b/drivers/usb/gadget/legacy/dbgp.c | |||
@@ -35,10 +35,10 @@ static struct dbgp { | |||
35 | static struct usb_device_descriptor device_desc = { | 35 | static struct usb_device_descriptor device_desc = { |
36 | .bLength = sizeof device_desc, | 36 | .bLength = sizeof device_desc, |
37 | .bDescriptorType = USB_DT_DEVICE, | 37 | .bDescriptorType = USB_DT_DEVICE, |
38 | .bcdUSB = __constant_cpu_to_le16(0x0200), | 38 | .bcdUSB = cpu_to_le16(0x0200), |
39 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, | 39 | .bDeviceClass = USB_CLASS_VENDOR_SPEC, |
40 | .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_ID), | 40 | .idVendor = cpu_to_le16(DRIVER_VENDOR_ID), |
41 | .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_ID), | 41 | .idProduct = cpu_to_le16(DRIVER_PRODUCT_ID), |
42 | .bNumConfigurations = 1, | 42 | .bNumConfigurations = 1, |
43 | }; | 43 | }; |
44 | 44 | ||
@@ -251,7 +251,7 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget) | |||
251 | 251 | ||
252 | dbgp.i_ep->driver_data = gadget; | 252 | dbgp.i_ep->driver_data = gadget; |
253 | i_desc.wMaxPacketSize = | 253 | i_desc.wMaxPacketSize = |
254 | __constant_cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); | 254 | cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); |
255 | 255 | ||
256 | dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc); | 256 | dbgp.o_ep = usb_ep_autoconfig(gadget, &o_desc); |
257 | if (!dbgp.o_ep) { | 257 | if (!dbgp.o_ep) { |
@@ -262,7 +262,7 @@ static int dbgp_configure_endpoints(struct usb_gadget *gadget) | |||
262 | 262 | ||
263 | dbgp.o_ep->driver_data = gadget; | 263 | dbgp.o_ep->driver_data = gadget; |
264 | o_desc.wMaxPacketSize = | 264 | o_desc.wMaxPacketSize = |
265 | __constant_cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); | 265 | cpu_to_le16(USB_DEBUG_MAX_PACKET_SIZE); |
266 | 266 | ||
267 | dbg_desc.bDebugInEndpoint = i_desc.bEndpointAddress; | 267 | dbg_desc.bDebugInEndpoint = i_desc.bEndpointAddress; |
268 | dbg_desc.bDebugOutEndpoint = o_desc.bEndpointAddress; | 268 | dbg_desc.bDebugOutEndpoint = o_desc.bEndpointAddress; |
diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c index a3323dca218f..31e9160223e9 100644 --- a/drivers/usb/gadget/legacy/ether.c +++ b/drivers/usb/gadget/legacy/ether.c | |||
@@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { | |||
171 | .bNumConfigurations = 1, | 171 | .bNumConfigurations = 1, |
172 | }; | 172 | }; |
173 | 173 | ||
174 | static struct usb_otg_descriptor otg_descriptor = { | 174 | static const struct usb_descriptor_header *otg_desc[2]; |
175 | .bLength = sizeof otg_descriptor, | ||
176 | .bDescriptorType = USB_DT_OTG, | ||
177 | |||
178 | /* REVISIT SRP-only hardware is possible, although | ||
179 | * it would not be called "OTG" ... | ||
180 | */ | ||
181 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
182 | }; | ||
183 | |||
184 | static const struct usb_descriptor_header *otg_desc[] = { | ||
185 | (struct usb_descriptor_header *) &otg_descriptor, | ||
186 | NULL, | ||
187 | }; | ||
188 | 175 | ||
189 | static struct usb_string strings_dev[] = { | 176 | static struct usb_string strings_dev[] = { |
190 | [USB_GADGET_MANUFACTURER_IDX].s = "", | 177 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
@@ -416,17 +403,28 @@ static int eth_bind(struct usb_composite_dev *cdev) | |||
416 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 403 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
417 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 404 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
418 | 405 | ||
406 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
407 | struct usb_descriptor_header *usb_desc; | ||
408 | |||
409 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
410 | if (!usb_desc) | ||
411 | goto fail1; | ||
412 | usb_otg_descriptor_init(gadget, usb_desc); | ||
413 | otg_desc[0] = usb_desc; | ||
414 | otg_desc[1] = NULL; | ||
415 | } | ||
416 | |||
419 | /* register our configuration(s); RNDIS first, if it's used */ | 417 | /* register our configuration(s); RNDIS first, if it's used */ |
420 | if (has_rndis()) { | 418 | if (has_rndis()) { |
421 | status = usb_add_config(cdev, &rndis_config_driver, | 419 | status = usb_add_config(cdev, &rndis_config_driver, |
422 | rndis_do_config); | 420 | rndis_do_config); |
423 | if (status < 0) | 421 | if (status < 0) |
424 | goto fail1; | 422 | goto fail2; |
425 | } | 423 | } |
426 | 424 | ||
427 | status = usb_add_config(cdev, ð_config_driver, eth_do_config); | 425 | status = usb_add_config(cdev, ð_config_driver, eth_do_config); |
428 | if (status < 0) | 426 | if (status < 0) |
429 | goto fail1; | 427 | goto fail2; |
430 | 428 | ||
431 | usb_composite_overwrite_options(cdev, &coverwrite); | 429 | usb_composite_overwrite_options(cdev, &coverwrite); |
432 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | 430 | dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", |
@@ -434,6 +432,9 @@ static int eth_bind(struct usb_composite_dev *cdev) | |||
434 | 432 | ||
435 | return 0; | 433 | return 0; |
436 | 434 | ||
435 | fail2: | ||
436 | kfree(otg_desc[0]); | ||
437 | otg_desc[0] = NULL; | ||
437 | fail1: | 438 | fail1: |
438 | if (has_rndis()) | 439 | if (has_rndis()) |
439 | usb_put_function_instance(fi_rndis); | 440 | usb_put_function_instance(fi_rndis); |
@@ -463,6 +464,9 @@ static int eth_unbind(struct usb_composite_dev *cdev) | |||
463 | usb_put_function(f_geth); | 464 | usb_put_function(f_geth); |
464 | usb_put_function_instance(fi_geth); | 465 | usb_put_function_instance(fi_geth); |
465 | } | 466 | } |
467 | kfree(otg_desc[0]); | ||
468 | otg_desc[0] = NULL; | ||
469 | |||
466 | return 0; | 470 | return 0; |
467 | } | 471 | } |
468 | 472 | ||
diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c index e821931c965c..320a81b2baa6 100644 --- a/drivers/usb/gadget/legacy/g_ffs.c +++ b/drivers/usb/gadget/legacy/g_ffs.c | |||
@@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol"); | |||
88 | module_param_array_named(functions, func_names, charp, &func_num, 0); | 88 | module_param_array_named(functions, func_names, charp, &func_num, 0); |
89 | MODULE_PARM_DESC(functions, "USB Functions list"); | 89 | MODULE_PARM_DESC(functions, "USB Functions list"); |
90 | 90 | ||
91 | static const struct usb_descriptor_header *gfs_otg_desc[] = { | 91 | static const struct usb_descriptor_header *gfs_otg_desc[2]; |
92 | (const struct usb_descriptor_header *) | ||
93 | &(const struct usb_otg_descriptor) { | ||
94 | .bLength = sizeof(struct usb_otg_descriptor), | ||
95 | .bDescriptorType = USB_DT_OTG, | ||
96 | |||
97 | /* | ||
98 | * REVISIT SRP-only hardware is possible, although | ||
99 | * it would not be called "OTG" ... | ||
100 | */ | ||
101 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
102 | }, | ||
103 | |||
104 | NULL | ||
105 | }; | ||
106 | 92 | ||
107 | /* String IDs are assigned dynamically */ | 93 | /* String IDs are assigned dynamically */ |
108 | static struct usb_string gfs_strings[] = { | 94 | static struct usb_string gfs_strings[] = { |
@@ -412,6 +398,17 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
412 | goto error_rndis; | 398 | goto error_rndis; |
413 | gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; | 399 | gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; |
414 | 400 | ||
401 | if (gadget_is_otg(cdev->gadget) && !gfs_otg_desc[0]) { | ||
402 | struct usb_descriptor_header *usb_desc; | ||
403 | |||
404 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); | ||
405 | if (!usb_desc) | ||
406 | goto error_rndis; | ||
407 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
408 | gfs_otg_desc[0] = usb_desc; | ||
409 | gfs_otg_desc[1] = NULL; | ||
410 | } | ||
411 | |||
415 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { | 412 | for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { |
416 | struct gfs_configuration *c = gfs_configurations + i; | 413 | struct gfs_configuration *c = gfs_configurations + i; |
417 | int sid = USB_GADGET_FIRST_AVAIL_IDX + i; | 414 | int sid = USB_GADGET_FIRST_AVAIL_IDX + i; |
@@ -432,6 +429,8 @@ static int gfs_bind(struct usb_composite_dev *cdev) | |||
432 | 429 | ||
433 | /* TODO */ | 430 | /* TODO */ |
434 | error_unbind: | 431 | error_unbind: |
432 | kfree(gfs_otg_desc[0]); | ||
433 | gfs_otg_desc[0] = NULL; | ||
435 | error_rndis: | 434 | error_rndis: |
436 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS | 435 | #ifdef CONFIG_USB_FUNCTIONFS_RNDIS |
437 | usb_put_function_instance(fi_rndis); | 436 | usb_put_function_instance(fi_rndis); |
@@ -473,6 +472,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev) | |||
473 | for (i = 0; i < N_CONF * func_num; ++i) | 472 | for (i = 0; i < N_CONF * func_num; ++i) |
474 | usb_put_function(*(f_ffs[0] + i)); | 473 | usb_put_function(*(f_ffs[0] + i)); |
475 | 474 | ||
475 | kfree(gfs_otg_desc[0]); | ||
476 | gfs_otg_desc[0] = NULL; | ||
477 | |||
476 | return 0; | 478 | return 0; |
477 | } | 479 | } |
478 | 480 | ||
diff --git a/drivers/usb/gadget/legacy/gmidi.c b/drivers/usb/gadget/legacy/gmidi.c index da19c486b61e..8a18348ae86e 100644 --- a/drivers/usb/gadget/legacy/gmidi.c +++ b/drivers/usb/gadget/legacy/gmidi.c | |||
@@ -35,8 +35,6 @@ | |||
35 | #include <linux/usb/audio.h> | 35 | #include <linux/usb/audio.h> |
36 | #include <linux/usb/midi.h> | 36 | #include <linux/usb/midi.h> |
37 | 37 | ||
38 | #include "gadget_chips.h" | ||
39 | |||
40 | #include "u_midi.h" | 38 | #include "u_midi.h" |
41 | 39 | ||
42 | /*-------------------------------------------------------------------------*/ | 40 | /*-------------------------------------------------------------------------*/ |
@@ -88,10 +86,10 @@ MODULE_PARM_DESC(out_ports, "Number of MIDI output ports"); | |||
88 | static struct usb_device_descriptor device_desc = { | 86 | static struct usb_device_descriptor device_desc = { |
89 | .bLength = USB_DT_DEVICE_SIZE, | 87 | .bLength = USB_DT_DEVICE_SIZE, |
90 | .bDescriptorType = USB_DT_DEVICE, | 88 | .bDescriptorType = USB_DT_DEVICE, |
91 | .bcdUSB = __constant_cpu_to_le16(0x0200), | 89 | .bcdUSB = cpu_to_le16(0x0200), |
92 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | 90 | .bDeviceClass = USB_CLASS_PER_INTERFACE, |
93 | .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), | 91 | .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM), |
94 | .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), | 92 | .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM), |
95 | /* .iManufacturer = DYNAMIC */ | 93 | /* .iManufacturer = DYNAMIC */ |
96 | /* .iProduct = DYNAMIC */ | 94 | /* .iProduct = DYNAMIC */ |
97 | .bNumConfigurations = 1, | 95 | .bNumConfigurations = 1, |
diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c index 2baa572686c6..7e5d2c48476e 100644 --- a/drivers/usb/gadget/legacy/hid.c +++ b/drivers/usb/gadget/legacy/hid.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/usb/composite.h> | 19 | #include <linux/usb/composite.h> |
20 | #include <linux/usb/g_hid.h> | 20 | #include <linux/usb/g_hid.h> |
21 | 21 | ||
22 | #include "gadget_chips.h" | ||
23 | #define DRIVER_DESC "HID Gadget" | 22 | #define DRIVER_DESC "HID Gadget" |
24 | #define DRIVER_VERSION "2010/03/16" | 23 | #define DRIVER_VERSION "2010/03/16" |
25 | 24 | ||
@@ -68,21 +67,7 @@ static struct usb_device_descriptor device_desc = { | |||
68 | .bNumConfigurations = 1, | 67 | .bNumConfigurations = 1, |
69 | }; | 68 | }; |
70 | 69 | ||
71 | static struct usb_otg_descriptor otg_descriptor = { | 70 | static const struct usb_descriptor_header *otg_desc[2]; |
72 | .bLength = sizeof otg_descriptor, | ||
73 | .bDescriptorType = USB_DT_OTG, | ||
74 | |||
75 | /* REVISIT SRP-only hardware is possible, although | ||
76 | * it would not be called "OTG" ... | ||
77 | */ | ||
78 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
79 | }; | ||
80 | |||
81 | static const struct usb_descriptor_header *otg_desc[] = { | ||
82 | (struct usb_descriptor_header *) &otg_descriptor, | ||
83 | NULL, | ||
84 | }; | ||
85 | |||
86 | 71 | ||
87 | /* string IDs are assigned dynamically */ | 72 | /* string IDs are assigned dynamically */ |
88 | static struct usb_string strings_dev[] = { | 73 | static struct usb_string strings_dev[] = { |
@@ -186,16 +171,30 @@ static int hid_bind(struct usb_composite_dev *cdev) | |||
186 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 171 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
187 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 172 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
188 | 173 | ||
174 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
175 | struct usb_descriptor_header *usb_desc; | ||
176 | |||
177 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
178 | if (!usb_desc) | ||
179 | goto put; | ||
180 | usb_otg_descriptor_init(gadget, usb_desc); | ||
181 | otg_desc[0] = usb_desc; | ||
182 | otg_desc[1] = NULL; | ||
183 | } | ||
184 | |||
189 | /* register our configuration */ | 185 | /* register our configuration */ |
190 | status = usb_add_config(cdev, &config_driver, do_config); | 186 | status = usb_add_config(cdev, &config_driver, do_config); |
191 | if (status < 0) | 187 | if (status < 0) |
192 | goto put; | 188 | goto free_otg_desc; |
193 | 189 | ||
194 | usb_composite_overwrite_options(cdev, &coverwrite); | 190 | usb_composite_overwrite_options(cdev, &coverwrite); |
195 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 191 | dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
196 | 192 | ||
197 | return 0; | 193 | return 0; |
198 | 194 | ||
195 | free_otg_desc: | ||
196 | kfree(otg_desc[0]); | ||
197 | otg_desc[0] = NULL; | ||
199 | put: | 198 | put: |
200 | list_for_each_entry(m, &hidg_func_list, node) { | 199 | list_for_each_entry(m, &hidg_func_list, node) { |
201 | if (m == n) | 200 | if (m == n) |
@@ -213,6 +212,10 @@ static int hid_unbind(struct usb_composite_dev *cdev) | |||
213 | usb_put_function(n->f); | 212 | usb_put_function(n->f); |
214 | usb_put_function_instance(n->fi); | 213 | usb_put_function_instance(n->fi); |
215 | } | 214 | } |
215 | |||
216 | kfree(otg_desc[0]); | ||
217 | otg_desc[0] = NULL; | ||
218 | |||
216 | return 0; | 219 | return 0; |
217 | } | 220 | } |
218 | 221 | ||
diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c index e7bfb081f111..bda3c519110f 100644 --- a/drivers/usb/gadget/legacy/mass_storage.c +++ b/drivers/usb/gadget/legacy/mass_storage.c | |||
@@ -64,21 +64,7 @@ static struct usb_device_descriptor msg_device_desc = { | |||
64 | .bNumConfigurations = 1, | 64 | .bNumConfigurations = 1, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static struct usb_otg_descriptor otg_descriptor = { | 67 | static const struct usb_descriptor_header *otg_desc[2]; |
68 | .bLength = sizeof otg_descriptor, | ||
69 | .bDescriptorType = USB_DT_OTG, | ||
70 | |||
71 | /* | ||
72 | * REVISIT SRP-only hardware is possible, although | ||
73 | * it would not be called "OTG" ... | ||
74 | */ | ||
75 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
76 | }; | ||
77 | |||
78 | static const struct usb_descriptor_header *otg_desc[] = { | ||
79 | (struct usb_descriptor_header *) &otg_descriptor, | ||
80 | NULL, | ||
81 | }; | ||
82 | 68 | ||
83 | static struct usb_string strings_dev[] = { | 69 | static struct usb_string strings_dev[] = { |
84 | [USB_GADGET_MANUFACTURER_IDX].s = "", | 70 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
@@ -191,10 +177,6 @@ static int msg_bind(struct usb_composite_dev *cdev) | |||
191 | if (status) | 177 | if (status) |
192 | goto fail; | 178 | goto fail; |
193 | 179 | ||
194 | status = fsg_common_set_nluns(opts->common, config.nluns); | ||
195 | if (status) | ||
196 | goto fail_set_nluns; | ||
197 | |||
198 | fsg_common_set_ops(opts->common, &ops); | 180 | fsg_common_set_ops(opts->common, &ops); |
199 | 181 | ||
200 | status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); | 182 | status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); |
@@ -214,9 +196,20 @@ static int msg_bind(struct usb_composite_dev *cdev) | |||
214 | goto fail_string_ids; | 196 | goto fail_string_ids; |
215 | msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 197 | msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
216 | 198 | ||
199 | if (gadget_is_otg(cdev->gadget) && !otg_desc[0]) { | ||
200 | struct usb_descriptor_header *usb_desc; | ||
201 | |||
202 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); | ||
203 | if (!usb_desc) | ||
204 | goto fail_string_ids; | ||
205 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
206 | otg_desc[0] = usb_desc; | ||
207 | otg_desc[1] = NULL; | ||
208 | } | ||
209 | |||
217 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); | 210 | status = usb_add_config(cdev, &msg_config_driver, msg_do_config); |
218 | if (status < 0) | 211 | if (status < 0) |
219 | goto fail_string_ids; | 212 | goto fail_otg_desc; |
220 | 213 | ||
221 | usb_composite_overwrite_options(cdev, &coverwrite); | 214 | usb_composite_overwrite_options(cdev, &coverwrite); |
222 | dev_info(&cdev->gadget->dev, | 215 | dev_info(&cdev->gadget->dev, |
@@ -224,11 +217,12 @@ static int msg_bind(struct usb_composite_dev *cdev) | |||
224 | set_bit(0, &msg_registered); | 217 | set_bit(0, &msg_registered); |
225 | return 0; | 218 | return 0; |
226 | 219 | ||
220 | fail_otg_desc: | ||
221 | kfree(otg_desc[0]); | ||
222 | otg_desc[0] = NULL; | ||
227 | fail_string_ids: | 223 | fail_string_ids: |
228 | fsg_common_remove_luns(opts->common); | 224 | fsg_common_remove_luns(opts->common); |
229 | fail_set_cdev: | 225 | fail_set_cdev: |
230 | fsg_common_free_luns(opts->common); | ||
231 | fail_set_nluns: | ||
232 | fsg_common_free_buffers(opts->common); | 226 | fsg_common_free_buffers(opts->common); |
233 | fail: | 227 | fail: |
234 | usb_put_function_instance(fi_msg); | 228 | usb_put_function_instance(fi_msg); |
@@ -243,6 +237,9 @@ static int msg_unbind(struct usb_composite_dev *cdev) | |||
243 | if (!IS_ERR(fi_msg)) | 237 | if (!IS_ERR(fi_msg)) |
244 | usb_put_function_instance(fi_msg); | 238 | usb_put_function_instance(fi_msg); |
245 | 239 | ||
240 | kfree(otg_desc[0]); | ||
241 | otg_desc[0] = NULL; | ||
242 | |||
246 | return 0; | 243 | return 0; |
247 | } | 244 | } |
248 | 245 | ||
diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c index b21b51f0c9fa..4fe794ddcd49 100644 --- a/drivers/usb/gadget/legacy/multi.c +++ b/drivers/usb/gadget/legacy/multi.c | |||
@@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = { | |||
78 | .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), | 78 | .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), |
79 | }; | 79 | }; |
80 | 80 | ||
81 | 81 | static const struct usb_descriptor_header *otg_desc[2]; | |
82 | static const struct usb_descriptor_header *otg_desc[] = { | ||
83 | (struct usb_descriptor_header *) &(struct usb_otg_descriptor){ | ||
84 | .bLength = sizeof(struct usb_otg_descriptor), | ||
85 | .bDescriptorType = USB_DT_OTG, | ||
86 | |||
87 | /* | ||
88 | * REVISIT SRP-only hardware is possible, although | ||
89 | * it would not be called "OTG" ... | ||
90 | */ | ||
91 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
92 | }, | ||
93 | NULL, | ||
94 | }; | ||
95 | |||
96 | 82 | ||
97 | enum { | 83 | enum { |
98 | MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, | 84 | MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, |
@@ -407,10 +393,6 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
407 | if (status) | 393 | if (status) |
408 | goto fail2; | 394 | goto fail2; |
409 | 395 | ||
410 | status = fsg_common_set_nluns(fsg_opts->common, config.nluns); | ||
411 | if (status) | ||
412 | goto fail_set_nluns; | ||
413 | |||
414 | status = fsg_common_set_cdev(fsg_opts->common, cdev, config.can_stall); | 396 | status = fsg_common_set_cdev(fsg_opts->common, cdev, config.can_stall); |
415 | if (status) | 397 | if (status) |
416 | goto fail_set_cdev; | 398 | goto fail_set_cdev; |
@@ -429,14 +411,25 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
429 | goto fail_string_ids; | 411 | goto fail_string_ids; |
430 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 412 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
431 | 413 | ||
414 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
415 | struct usb_descriptor_header *usb_desc; | ||
416 | |||
417 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
418 | if (!usb_desc) | ||
419 | goto fail_string_ids; | ||
420 | usb_otg_descriptor_init(gadget, usb_desc); | ||
421 | otg_desc[0] = usb_desc; | ||
422 | otg_desc[1] = NULL; | ||
423 | } | ||
424 | |||
432 | /* register configurations */ | 425 | /* register configurations */ |
433 | status = rndis_config_register(cdev); | 426 | status = rndis_config_register(cdev); |
434 | if (unlikely(status < 0)) | 427 | if (unlikely(status < 0)) |
435 | goto fail_string_ids; | 428 | goto fail_otg_desc; |
436 | 429 | ||
437 | status = cdc_config_register(cdev); | 430 | status = cdc_config_register(cdev); |
438 | if (unlikely(status < 0)) | 431 | if (unlikely(status < 0)) |
439 | goto fail_string_ids; | 432 | goto fail_otg_desc; |
440 | usb_composite_overwrite_options(cdev, &coverwrite); | 433 | usb_composite_overwrite_options(cdev, &coverwrite); |
441 | 434 | ||
442 | /* we're done */ | 435 | /* we're done */ |
@@ -445,11 +438,12 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) | |||
445 | 438 | ||
446 | 439 | ||
447 | /* error recovery */ | 440 | /* error recovery */ |
441 | fail_otg_desc: | ||
442 | kfree(otg_desc[0]); | ||
443 | otg_desc[0] = NULL; | ||
448 | fail_string_ids: | 444 | fail_string_ids: |
449 | fsg_common_remove_luns(fsg_opts->common); | 445 | fsg_common_remove_luns(fsg_opts->common); |
450 | fail_set_cdev: | 446 | fail_set_cdev: |
451 | fsg_common_free_luns(fsg_opts->common); | ||
452 | fail_set_nluns: | ||
453 | fsg_common_free_buffers(fsg_opts->common); | 447 | fsg_common_free_buffers(fsg_opts->common); |
454 | fail2: | 448 | fail2: |
455 | usb_put_function_instance(fi_msg); | 449 | usb_put_function_instance(fi_msg); |
@@ -490,6 +484,9 @@ static int multi_unbind(struct usb_composite_dev *cdev) | |||
490 | usb_put_function(f_ecm); | 484 | usb_put_function(f_ecm); |
491 | usb_put_function_instance(fi_ecm); | 485 | usb_put_function_instance(fi_ecm); |
492 | #endif | 486 | #endif |
487 | kfree(otg_desc[0]); | ||
488 | otg_desc[0] = NULL; | ||
489 | |||
493 | return 0; | 490 | return 0; |
494 | } | 491 | } |
495 | 492 | ||
diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c index 6ce7421412e9..2bae4381332d 100644 --- a/drivers/usb/gadget/legacy/ncm.c +++ b/drivers/usb/gadget/legacy/ncm.c | |||
@@ -69,20 +69,7 @@ static struct usb_device_descriptor device_desc = { | |||
69 | .bNumConfigurations = 1, | 69 | .bNumConfigurations = 1, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static struct usb_otg_descriptor otg_descriptor = { | 72 | static const struct usb_descriptor_header *otg_desc[2]; |
73 | .bLength = sizeof otg_descriptor, | ||
74 | .bDescriptorType = USB_DT_OTG, | ||
75 | |||
76 | /* REVISIT SRP-only hardware is possible, although | ||
77 | * it would not be called "OTG" ... | ||
78 | */ | ||
79 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
80 | }; | ||
81 | |||
82 | static const struct usb_descriptor_header *otg_desc[] = { | ||
83 | (struct usb_descriptor_header *) &otg_descriptor, | ||
84 | NULL, | ||
85 | }; | ||
86 | 73 | ||
87 | /* string IDs are assigned dynamically */ | 74 | /* string IDs are assigned dynamically */ |
88 | static struct usb_string strings_dev[] = { | 75 | static struct usb_string strings_dev[] = { |
@@ -171,16 +158,30 @@ static int gncm_bind(struct usb_composite_dev *cdev) | |||
171 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 158 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
172 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 159 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
173 | 160 | ||
161 | if (gadget_is_otg(gadget) && !otg_desc[0]) { | ||
162 | struct usb_descriptor_header *usb_desc; | ||
163 | |||
164 | usb_desc = usb_otg_descriptor_alloc(gadget); | ||
165 | if (!usb_desc) | ||
166 | goto fail; | ||
167 | usb_otg_descriptor_init(gadget, usb_desc); | ||
168 | otg_desc[0] = usb_desc; | ||
169 | otg_desc[1] = NULL; | ||
170 | } | ||
171 | |||
174 | status = usb_add_config(cdev, &ncm_config_driver, | 172 | status = usb_add_config(cdev, &ncm_config_driver, |
175 | ncm_do_config); | 173 | ncm_do_config); |
176 | if (status < 0) | 174 | if (status < 0) |
177 | goto fail; | 175 | goto fail1; |
178 | 176 | ||
179 | usb_composite_overwrite_options(cdev, &coverwrite); | 177 | usb_composite_overwrite_options(cdev, &coverwrite); |
180 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); | 178 | dev_info(&gadget->dev, "%s\n", DRIVER_DESC); |
181 | 179 | ||
182 | return 0; | 180 | return 0; |
183 | 181 | ||
182 | fail1: | ||
183 | kfree(otg_desc[0]); | ||
184 | otg_desc[0] = NULL; | ||
184 | fail: | 185 | fail: |
185 | usb_put_function_instance(f_ncm_inst); | 186 | usb_put_function_instance(f_ncm_inst); |
186 | return status; | 187 | return status; |
@@ -192,6 +193,9 @@ static int gncm_unbind(struct usb_composite_dev *cdev) | |||
192 | usb_put_function(f_ncm); | 193 | usb_put_function(f_ncm); |
193 | if (!IS_ERR_OR_NULL(f_ncm_inst)) | 194 | if (!IS_ERR_OR_NULL(f_ncm_inst)) |
194 | usb_put_function_instance(f_ncm_inst); | 195 | usb_put_function_instance(f_ncm_inst); |
196 | kfree(otg_desc[0]); | ||
197 | otg_desc[0] = NULL; | ||
198 | |||
195 | return 0; | 199 | return 0; |
196 | } | 200 | } |
197 | 201 | ||
diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c index 4bb498a38a1c..8b3f6fb1825d 100644 --- a/drivers/usb/gadget/legacy/nokia.c +++ b/drivers/usb/gadget/legacy/nokia.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "u_ether.h" | 23 | #include "u_ether.h" |
24 | #include "u_phonet.h" | 24 | #include "u_phonet.h" |
25 | #include "u_ecm.h" | 25 | #include "u_ecm.h" |
26 | #include "gadget_chips.h" | 26 | #include "f_mass_storage.h" |
27 | 27 | ||
28 | /* Defines */ | 28 | /* Defines */ |
29 | 29 | ||
@@ -34,6 +34,29 @@ USB_GADGET_COMPOSITE_OPTIONS(); | |||
34 | 34 | ||
35 | USB_ETHERNET_MODULE_PARAMETERS(); | 35 | USB_ETHERNET_MODULE_PARAMETERS(); |
36 | 36 | ||
37 | static struct fsg_module_parameters fsg_mod_data = { | ||
38 | .stall = 0, | ||
39 | .luns = 2, | ||
40 | .removable_count = 2, | ||
41 | .removable = { 1, 1, }, | ||
42 | }; | ||
43 | |||
44 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | ||
45 | |||
46 | static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; | ||
47 | |||
48 | #else | ||
49 | |||
50 | /* | ||
51 | * Number of buffers we will use. | ||
52 | * 2 is usually enough for good buffering pipeline | ||
53 | */ | ||
54 | #define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS | ||
55 | |||
56 | #endif /* CONFIG_USB_DEBUG */ | ||
57 | |||
58 | FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); | ||
59 | |||
37 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ | 60 | #define NOKIA_VENDOR_ID 0x0421 /* Nokia */ |
38 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ | 61 | #define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ |
39 | 62 | ||
@@ -66,10 +89,10 @@ static struct usb_gadget_strings *dev_strings[] = { | |||
66 | static struct usb_device_descriptor device_desc = { | 89 | static struct usb_device_descriptor device_desc = { |
67 | .bLength = USB_DT_DEVICE_SIZE, | 90 | .bLength = USB_DT_DEVICE_SIZE, |
68 | .bDescriptorType = USB_DT_DEVICE, | 91 | .bDescriptorType = USB_DT_DEVICE, |
69 | .bcdUSB = __constant_cpu_to_le16(0x0200), | 92 | .bcdUSB = cpu_to_le16(0x0200), |
70 | .bDeviceClass = USB_CLASS_COMM, | 93 | .bDeviceClass = USB_CLASS_COMM, |
71 | .idVendor = __constant_cpu_to_le16(NOKIA_VENDOR_ID), | 94 | .idVendor = cpu_to_le16(NOKIA_VENDOR_ID), |
72 | .idProduct = __constant_cpu_to_le16(NOKIA_PRODUCT_ID), | 95 | .idProduct = cpu_to_le16(NOKIA_PRODUCT_ID), |
73 | .bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM), | 96 | .bcdDevice = cpu_to_le16(NOKIA_VERSION_NUM), |
74 | /* .iManufacturer = DYNAMIC */ | 97 | /* .iManufacturer = DYNAMIC */ |
75 | /* .iProduct = DYNAMIC */ | 98 | /* .iProduct = DYNAMIC */ |
@@ -94,6 +117,8 @@ static struct usb_function *f_obex1_cfg2; | |||
94 | static struct usb_function *f_obex2_cfg2; | 117 | static struct usb_function *f_obex2_cfg2; |
95 | static struct usb_function *f_phonet_cfg1; | 118 | static struct usb_function *f_phonet_cfg1; |
96 | static struct usb_function *f_phonet_cfg2; | 119 | static struct usb_function *f_phonet_cfg2; |
120 | static struct usb_function *f_msg_cfg1; | ||
121 | static struct usb_function *f_msg_cfg2; | ||
97 | 122 | ||
98 | 123 | ||
99 | static struct usb_configuration nokia_config_500ma_driver = { | 124 | static struct usb_configuration nokia_config_500ma_driver = { |
@@ -117,6 +142,7 @@ static struct usb_function_instance *fi_ecm; | |||
117 | static struct usb_function_instance *fi_obex1; | 142 | static struct usb_function_instance *fi_obex1; |
118 | static struct usb_function_instance *fi_obex2; | 143 | static struct usb_function_instance *fi_obex2; |
119 | static struct usb_function_instance *fi_phonet; | 144 | static struct usb_function_instance *fi_phonet; |
145 | static struct usb_function_instance *fi_msg; | ||
120 | 146 | ||
121 | static int nokia_bind_config(struct usb_configuration *c) | 147 | static int nokia_bind_config(struct usb_configuration *c) |
122 | { | 148 | { |
@@ -125,6 +151,8 @@ static int nokia_bind_config(struct usb_configuration *c) | |||
125 | struct usb_function *f_obex1 = NULL; | 151 | struct usb_function *f_obex1 = NULL; |
126 | struct usb_function *f_ecm; | 152 | struct usb_function *f_ecm; |
127 | struct usb_function *f_obex2 = NULL; | 153 | struct usb_function *f_obex2 = NULL; |
154 | struct usb_function *f_msg; | ||
155 | struct fsg_opts *fsg_opts; | ||
128 | int status = 0; | 156 | int status = 0; |
129 | int obex1_stat = -1; | 157 | int obex1_stat = -1; |
130 | int obex2_stat = -1; | 158 | int obex2_stat = -1; |
@@ -160,6 +188,12 @@ static int nokia_bind_config(struct usb_configuration *c) | |||
160 | goto err_get_ecm; | 188 | goto err_get_ecm; |
161 | } | 189 | } |
162 | 190 | ||
191 | f_msg = usb_get_function(fi_msg); | ||
192 | if (IS_ERR(f_msg)) { | ||
193 | status = PTR_ERR(f_msg); | ||
194 | goto err_get_msg; | ||
195 | } | ||
196 | |||
163 | if (!IS_ERR_OR_NULL(f_phonet)) { | 197 | if (!IS_ERR_OR_NULL(f_phonet)) { |
164 | phonet_stat = usb_add_function(c, f_phonet); | 198 | phonet_stat = usb_add_function(c, f_phonet); |
165 | if (phonet_stat) | 199 | if (phonet_stat) |
@@ -187,21 +221,36 @@ static int nokia_bind_config(struct usb_configuration *c) | |||
187 | pr_debug("could not bind ecm config %d\n", status); | 221 | pr_debug("could not bind ecm config %d\n", status); |
188 | goto err_ecm; | 222 | goto err_ecm; |
189 | } | 223 | } |
224 | |||
225 | fsg_opts = fsg_opts_from_func_inst(fi_msg); | ||
226 | |||
227 | status = fsg_common_run_thread(fsg_opts->common); | ||
228 | if (status) | ||
229 | goto err_msg; | ||
230 | |||
231 | status = usb_add_function(c, f_msg); | ||
232 | if (status) | ||
233 | goto err_msg; | ||
234 | |||
190 | if (c == &nokia_config_500ma_driver) { | 235 | if (c == &nokia_config_500ma_driver) { |
191 | f_acm_cfg1 = f_acm; | 236 | f_acm_cfg1 = f_acm; |
192 | f_ecm_cfg1 = f_ecm; | 237 | f_ecm_cfg1 = f_ecm; |
193 | f_phonet_cfg1 = f_phonet; | 238 | f_phonet_cfg1 = f_phonet; |
194 | f_obex1_cfg1 = f_obex1; | 239 | f_obex1_cfg1 = f_obex1; |
195 | f_obex2_cfg1 = f_obex2; | 240 | f_obex2_cfg1 = f_obex2; |
241 | f_msg_cfg1 = f_msg; | ||
196 | } else { | 242 | } else { |
197 | f_acm_cfg2 = f_acm; | 243 | f_acm_cfg2 = f_acm; |
198 | f_ecm_cfg2 = f_ecm; | 244 | f_ecm_cfg2 = f_ecm; |
199 | f_phonet_cfg2 = f_phonet; | 245 | f_phonet_cfg2 = f_phonet; |
200 | f_obex1_cfg2 = f_obex1; | 246 | f_obex1_cfg2 = f_obex1; |
201 | f_obex2_cfg2 = f_obex2; | 247 | f_obex2_cfg2 = f_obex2; |
248 | f_msg_cfg2 = f_msg; | ||
202 | } | 249 | } |
203 | 250 | ||
204 | return status; | 251 | return status; |
252 | err_msg: | ||
253 | usb_remove_function(c, f_ecm); | ||
205 | err_ecm: | 254 | err_ecm: |
206 | usb_remove_function(c, f_acm); | 255 | usb_remove_function(c, f_acm); |
207 | err_conf: | 256 | err_conf: |
@@ -211,6 +260,8 @@ err_conf: | |||
211 | usb_remove_function(c, f_obex1); | 260 | usb_remove_function(c, f_obex1); |
212 | if (!phonet_stat) | 261 | if (!phonet_stat) |
213 | usb_remove_function(c, f_phonet); | 262 | usb_remove_function(c, f_phonet); |
263 | usb_put_function(f_msg); | ||
264 | err_get_msg: | ||
214 | usb_put_function(f_ecm); | 265 | usb_put_function(f_ecm); |
215 | err_get_ecm: | 266 | err_get_ecm: |
216 | usb_put_function(f_acm); | 267 | usb_put_function(f_acm); |
@@ -227,6 +278,8 @@ err_get_acm: | |||
227 | static int nokia_bind(struct usb_composite_dev *cdev) | 278 | static int nokia_bind(struct usb_composite_dev *cdev) |
228 | { | 279 | { |
229 | struct usb_gadget *gadget = cdev->gadget; | 280 | struct usb_gadget *gadget = cdev->gadget; |
281 | struct fsg_opts *fsg_opts; | ||
282 | struct fsg_config fsg_config; | ||
230 | int status; | 283 | int status; |
231 | 284 | ||
232 | status = usb_string_ids_tab(cdev, strings_dev); | 285 | status = usb_string_ids_tab(cdev, strings_dev); |
@@ -238,7 +291,7 @@ static int nokia_bind(struct usb_composite_dev *cdev) | |||
238 | nokia_config_500ma_driver.iConfiguration = status; | 291 | nokia_config_500ma_driver.iConfiguration = status; |
239 | nokia_config_100ma_driver.iConfiguration = status; | 292 | nokia_config_100ma_driver.iConfiguration = status; |
240 | 293 | ||
241 | if (!gadget_supports_altsettings(gadget)) { | 294 | if (!gadget_is_altset_supported(gadget)) { |
242 | status = -ENODEV; | 295 | status = -ENODEV; |
243 | goto err_usb; | 296 | goto err_usb; |
244 | } | 297 | } |
@@ -267,11 +320,42 @@ static int nokia_bind(struct usb_composite_dev *cdev) | |||
267 | goto err_acm_inst; | 320 | goto err_acm_inst; |
268 | } | 321 | } |
269 | 322 | ||
323 | fi_msg = usb_get_function_instance("mass_storage"); | ||
324 | if (IS_ERR(fi_msg)) { | ||
325 | status = PTR_ERR(fi_msg); | ||
326 | goto err_ecm_inst; | ||
327 | } | ||
328 | |||
329 | /* set up mass storage function */ | ||
330 | fsg_config_from_params(&fsg_config, &fsg_mod_data, fsg_num_buffers); | ||
331 | fsg_config.vendor_name = "Nokia"; | ||
332 | fsg_config.product_name = "N900"; | ||
333 | |||
334 | fsg_opts = fsg_opts_from_func_inst(fi_msg); | ||
335 | fsg_opts->no_configfs = true; | ||
336 | |||
337 | status = fsg_common_set_num_buffers(fsg_opts->common, fsg_num_buffers); | ||
338 | if (status) | ||
339 | goto err_msg_inst; | ||
340 | |||
341 | status = fsg_common_set_cdev(fsg_opts->common, cdev, fsg_config.can_stall); | ||
342 | if (status) | ||
343 | goto err_msg_buf; | ||
344 | |||
345 | fsg_common_set_sysfs(fsg_opts->common, true); | ||
346 | |||
347 | status = fsg_common_create_luns(fsg_opts->common, &fsg_config); | ||
348 | if (status) | ||
349 | goto err_msg_buf; | ||
350 | |||
351 | fsg_common_set_inquiry_string(fsg_opts->common, fsg_config.vendor_name, | ||
352 | fsg_config.product_name); | ||
353 | |||
270 | /* finally register the configuration */ | 354 | /* finally register the configuration */ |
271 | status = usb_add_config(cdev, &nokia_config_500ma_driver, | 355 | status = usb_add_config(cdev, &nokia_config_500ma_driver, |
272 | nokia_bind_config); | 356 | nokia_bind_config); |
273 | if (status < 0) | 357 | if (status < 0) |
274 | goto err_ecm_inst; | 358 | goto err_msg_luns; |
275 | 359 | ||
276 | status = usb_add_config(cdev, &nokia_config_100ma_driver, | 360 | status = usb_add_config(cdev, &nokia_config_100ma_driver, |
277 | nokia_bind_config); | 361 | nokia_bind_config); |
@@ -292,6 +376,12 @@ err_put_cfg1: | |||
292 | if (!IS_ERR_OR_NULL(f_phonet_cfg1)) | 376 | if (!IS_ERR_OR_NULL(f_phonet_cfg1)) |
293 | usb_put_function(f_phonet_cfg1); | 377 | usb_put_function(f_phonet_cfg1); |
294 | usb_put_function(f_ecm_cfg1); | 378 | usb_put_function(f_ecm_cfg1); |
379 | err_msg_luns: | ||
380 | fsg_common_remove_luns(fsg_opts->common); | ||
381 | err_msg_buf: | ||
382 | fsg_common_free_buffers(fsg_opts->common); | ||
383 | err_msg_inst: | ||
384 | usb_put_function_instance(fi_msg); | ||
295 | err_ecm_inst: | 385 | err_ecm_inst: |
296 | usb_put_function_instance(fi_ecm); | 386 | usb_put_function_instance(fi_ecm); |
297 | err_acm_inst: | 387 | err_acm_inst: |
@@ -325,7 +415,10 @@ static int nokia_unbind(struct usb_composite_dev *cdev) | |||
325 | usb_put_function(f_acm_cfg2); | 415 | usb_put_function(f_acm_cfg2); |
326 | usb_put_function(f_ecm_cfg1); | 416 | usb_put_function(f_ecm_cfg1); |
327 | usb_put_function(f_ecm_cfg2); | 417 | usb_put_function(f_ecm_cfg2); |
418 | usb_put_function(f_msg_cfg1); | ||
419 | usb_put_function(f_msg_cfg2); | ||
328 | 420 | ||
421 | usb_put_function_instance(fi_msg); | ||
329 | usb_put_function_instance(fi_ecm); | 422 | usb_put_function_instance(fi_ecm); |
330 | if (!IS_ERR(fi_obex2)) | 423 | if (!IS_ERR(fi_obex2)) |
331 | usb_put_function_instance(fi_obex2); | 424 | usb_put_function_instance(fi_obex2); |
diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 1ce7df1060a5..a22d30a4def1 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include <linux/usb/gadget.h> | 19 | #include <linux/usb/gadget.h> |
20 | #include <linux/usb/g_printer.h> | 20 | #include <linux/usb/g_printer.h> |
21 | 21 | ||
22 | #include "gadget_chips.h" | ||
23 | |||
24 | USB_GADGET_COMPOSITE_OPTIONS(); | 22 | USB_GADGET_COMPOSITE_OPTIONS(); |
25 | 23 | ||
26 | #define DRIVER_DESC "Printer Gadget" | 24 | #define DRIVER_DESC "Printer Gadget" |
@@ -82,16 +80,7 @@ static struct usb_device_descriptor device_desc = { | |||
82 | .bNumConfigurations = 1 | 80 | .bNumConfigurations = 1 |
83 | }; | 81 | }; |
84 | 82 | ||
85 | static struct usb_otg_descriptor otg_descriptor = { | 83 | static const struct usb_descriptor_header *otg_desc[2]; |
86 | .bLength = sizeof otg_descriptor, | ||
87 | .bDescriptorType = USB_DT_OTG, | ||
88 | .bmAttributes = USB_OTG_SRP, | ||
89 | }; | ||
90 | |||
91 | static const struct usb_descriptor_header *otg_desc[] = { | ||
92 | (struct usb_descriptor_header *) &otg_descriptor, | ||
93 | NULL, | ||
94 | }; | ||
95 | 84 | ||
96 | /*-------------------------------------------------------------------------*/ | 85 | /*-------------------------------------------------------------------------*/ |
97 | 86 | ||
@@ -136,7 +125,6 @@ static int printer_do_config(struct usb_configuration *c) | |||
136 | usb_gadget_set_selfpowered(gadget); | 125 | usb_gadget_set_selfpowered(gadget); |
137 | 126 | ||
138 | if (gadget_is_otg(gadget)) { | 127 | if (gadget_is_otg(gadget)) { |
139 | otg_descriptor.bmAttributes |= USB_OTG_HNP; | ||
140 | printer_cfg_driver.descriptors = otg_desc; | 128 | printer_cfg_driver.descriptors = otg_desc; |
141 | printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 129 | printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
142 | } | 130 | } |
@@ -174,21 +162,39 @@ static int printer_bind(struct usb_composite_dev *cdev) | |||
174 | opts->q_len = QLEN; | 162 | opts->q_len = QLEN; |
175 | 163 | ||
176 | ret = usb_string_ids_tab(cdev, strings); | 164 | ret = usb_string_ids_tab(cdev, strings); |
177 | if (ret < 0) { | 165 | if (ret < 0) |
178 | usb_put_function_instance(fi_printer); | 166 | goto fail_put_func_inst; |
179 | return ret; | 167 | |
180 | } | ||
181 | device_desc.iManufacturer = strings[USB_GADGET_MANUFACTURER_IDX].id; | 168 | device_desc.iManufacturer = strings[USB_GADGET_MANUFACTURER_IDX].id; |
182 | device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; | 169 | device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; |
183 | device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; | 170 | device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; |
184 | 171 | ||
185 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_do_config); | 172 | if (gadget_is_otg(cdev->gadget) && !otg_desc[0]) { |
186 | if (ret) { | 173 | struct usb_descriptor_header *usb_desc; |
187 | usb_put_function_instance(fi_printer); | 174 | |
188 | return ret; | 175 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); |
176 | if (!usb_desc) { | ||
177 | ret = -ENOMEM; | ||
178 | goto fail_put_func_inst; | ||
179 | } | ||
180 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
181 | otg_desc[0] = usb_desc; | ||
182 | otg_desc[1] = NULL; | ||
189 | } | 183 | } |
184 | |||
185 | ret = usb_add_config(cdev, &printer_cfg_driver, printer_do_config); | ||
186 | if (ret) | ||
187 | goto fail_free_otg_desc; | ||
188 | |||
190 | usb_composite_overwrite_options(cdev, &coverwrite); | 189 | usb_composite_overwrite_options(cdev, &coverwrite); |
191 | return ret; | 190 | return ret; |
191 | |||
192 | fail_free_otg_desc: | ||
193 | kfree(otg_desc[0]); | ||
194 | otg_desc[0] = NULL; | ||
195 | fail_put_func_inst: | ||
196 | usb_put_function_instance(fi_printer); | ||
197 | return ret; | ||
192 | } | 198 | } |
193 | 199 | ||
194 | static int printer_unbind(struct usb_composite_dev *cdev) | 200 | static int printer_unbind(struct usb_composite_dev *cdev) |
@@ -196,6 +202,9 @@ static int printer_unbind(struct usb_composite_dev *cdev) | |||
196 | usb_put_function(f_printer); | 202 | usb_put_function(f_printer); |
197 | usb_put_function_instance(fi_printer); | 203 | usb_put_function_instance(fi_printer); |
198 | 204 | ||
205 | kfree(otg_desc[0]); | ||
206 | otg_desc[0] = NULL; | ||
207 | |||
199 | return 0; | 208 | return 0; |
200 | } | 209 | } |
201 | 210 | ||
diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c index 8b7528f9b78e..c5d42e0347a9 100644 --- a/drivers/usb/gadget/legacy/serial.c +++ b/drivers/usb/gadget/legacy/serial.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/tty_flip.h> | 17 | #include <linux/tty_flip.h> |
18 | 18 | ||
19 | #include "u_serial.h" | 19 | #include "u_serial.h" |
20 | #include "gadget_chips.h" | ||
21 | 20 | ||
22 | 21 | ||
23 | /* Defines */ | 22 | /* Defines */ |
@@ -79,20 +78,7 @@ static struct usb_device_descriptor device_desc = { | |||
79 | .bNumConfigurations = 1, | 78 | .bNumConfigurations = 1, |
80 | }; | 79 | }; |
81 | 80 | ||
82 | static struct usb_otg_descriptor otg_descriptor = { | 81 | static const struct usb_descriptor_header *otg_desc[2]; |
83 | .bLength = sizeof otg_descriptor, | ||
84 | .bDescriptorType = USB_DT_OTG, | ||
85 | |||
86 | /* REVISIT SRP-only hardware is possible, although | ||
87 | * it would not be called "OTG" ... | ||
88 | */ | ||
89 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
90 | }; | ||
91 | |||
92 | static const struct usb_descriptor_header *otg_desc[] = { | ||
93 | (struct usb_descriptor_header *) &otg_descriptor, | ||
94 | NULL, | ||
95 | }; | ||
96 | 82 | ||
97 | /*-------------------------------------------------------------------------*/ | 83 | /*-------------------------------------------------------------------------*/ |
98 | 84 | ||
@@ -191,6 +177,18 @@ static int gs_bind(struct usb_composite_dev *cdev) | |||
191 | serial_config_driver.iConfiguration = status; | 177 | serial_config_driver.iConfiguration = status; |
192 | 178 | ||
193 | if (gadget_is_otg(cdev->gadget)) { | 179 | if (gadget_is_otg(cdev->gadget)) { |
180 | if (!otg_desc[0]) { | ||
181 | struct usb_descriptor_header *usb_desc; | ||
182 | |||
183 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); | ||
184 | if (!usb_desc) { | ||
185 | status = -ENOMEM; | ||
186 | goto fail; | ||
187 | } | ||
188 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
189 | otg_desc[0] = usb_desc; | ||
190 | otg_desc[1] = NULL; | ||
191 | } | ||
194 | serial_config_driver.descriptors = otg_desc; | 192 | serial_config_driver.descriptors = otg_desc; |
195 | serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 193 | serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
196 | } | 194 | } |
@@ -208,13 +206,15 @@ static int gs_bind(struct usb_composite_dev *cdev) | |||
208 | "gser"); | 206 | "gser"); |
209 | } | 207 | } |
210 | if (status < 0) | 208 | if (status < 0) |
211 | goto fail; | 209 | goto fail1; |
212 | 210 | ||
213 | usb_composite_overwrite_options(cdev, &coverwrite); | 211 | usb_composite_overwrite_options(cdev, &coverwrite); |
214 | INFO(cdev, "%s\n", GS_VERSION_NAME); | 212 | INFO(cdev, "%s\n", GS_VERSION_NAME); |
215 | 213 | ||
216 | return 0; | 214 | return 0; |
217 | 215 | fail1: | |
216 | kfree(otg_desc[0]); | ||
217 | otg_desc[0] = NULL; | ||
218 | fail: | 218 | fail: |
219 | return status; | 219 | return status; |
220 | } | 220 | } |
@@ -227,6 +227,10 @@ static int gs_unbind(struct usb_composite_dev *cdev) | |||
227 | usb_put_function(f_serial[i]); | 227 | usb_put_function(f_serial[i]); |
228 | usb_put_function_instance(fi_serial[i]); | 228 | usb_put_function_instance(fi_serial[i]); |
229 | } | 229 | } |
230 | |||
231 | kfree(otg_desc[0]); | ||
232 | otg_desc[0] = NULL; | ||
233 | |||
230 | return 0; | 234 | return 0; |
231 | } | 235 | } |
232 | 236 | ||
diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c index c986e8addb90..37a410056fed 100644 --- a/drivers/usb/gadget/legacy/zero.c +++ b/drivers/usb/gadget/legacy/zero.c | |||
@@ -121,24 +121,7 @@ static struct usb_device_descriptor device_desc = { | |||
121 | .bNumConfigurations = 2, | 121 | .bNumConfigurations = 2, |
122 | }; | 122 | }; |
123 | 123 | ||
124 | #ifdef CONFIG_USB_OTG | 124 | static const struct usb_descriptor_header *otg_desc[2]; |
125 | static struct usb_otg_descriptor otg_descriptor = { | ||
126 | .bLength = sizeof otg_descriptor, | ||
127 | .bDescriptorType = USB_DT_OTG, | ||
128 | |||
129 | /* REVISIT SRP-only hardware is possible, although | ||
130 | * it would not be called "OTG" ... | ||
131 | */ | ||
132 | .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, | ||
133 | }; | ||
134 | |||
135 | static const struct usb_descriptor_header *otg_desc[] = { | ||
136 | (struct usb_descriptor_header *) &otg_descriptor, | ||
137 | NULL, | ||
138 | }; | ||
139 | #else | ||
140 | #define otg_desc NULL | ||
141 | #endif | ||
142 | 125 | ||
143 | /* string IDs are assigned dynamically */ | 126 | /* string IDs are assigned dynamically */ |
144 | /* default serial number takes at least two packets */ | 127 | /* default serial number takes at least two packets */ |
@@ -341,6 +324,18 @@ static int zero_bind(struct usb_composite_dev *cdev) | |||
341 | 324 | ||
342 | /* support OTG systems */ | 325 | /* support OTG systems */ |
343 | if (gadget_is_otg(cdev->gadget)) { | 326 | if (gadget_is_otg(cdev->gadget)) { |
327 | if (!otg_desc[0]) { | ||
328 | struct usb_descriptor_header *usb_desc; | ||
329 | |||
330 | usb_desc = usb_otg_descriptor_alloc(cdev->gadget); | ||
331 | if (!usb_desc) { | ||
332 | status = -ENOMEM; | ||
333 | goto err_conf_flb; | ||
334 | } | ||
335 | usb_otg_descriptor_init(cdev->gadget, usb_desc); | ||
336 | otg_desc[0] = usb_desc; | ||
337 | otg_desc[1] = NULL; | ||
338 | } | ||
344 | sourcesink_driver.descriptors = otg_desc; | 339 | sourcesink_driver.descriptors = otg_desc; |
345 | sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 340 | sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
346 | loopback_driver.descriptors = otg_desc; | 341 | loopback_driver.descriptors = otg_desc; |
@@ -359,12 +354,12 @@ static int zero_bind(struct usb_composite_dev *cdev) | |||
359 | } | 354 | } |
360 | status = usb_add_function(&sourcesink_driver, func_ss); | 355 | status = usb_add_function(&sourcesink_driver, func_ss); |
361 | if (status) | 356 | if (status) |
362 | goto err_conf_flb; | 357 | goto err_free_otg_desc; |
363 | 358 | ||
364 | usb_ep_autoconfig_reset(cdev->gadget); | 359 | usb_ep_autoconfig_reset(cdev->gadget); |
365 | status = usb_add_function(&loopback_driver, func_lb); | 360 | status = usb_add_function(&loopback_driver, func_lb); |
366 | if (status) | 361 | if (status) |
367 | goto err_conf_flb; | 362 | goto err_free_otg_desc; |
368 | 363 | ||
369 | usb_ep_autoconfig_reset(cdev->gadget); | 364 | usb_ep_autoconfig_reset(cdev->gadget); |
370 | usb_composite_overwrite_options(cdev, &coverwrite); | 365 | usb_composite_overwrite_options(cdev, &coverwrite); |
@@ -373,6 +368,9 @@ static int zero_bind(struct usb_composite_dev *cdev) | |||
373 | 368 | ||
374 | return 0; | 369 | return 0; |
375 | 370 | ||
371 | err_free_otg_desc: | ||
372 | kfree(otg_desc[0]); | ||
373 | otg_desc[0] = NULL; | ||
376 | err_conf_flb: | 374 | err_conf_flb: |
377 | usb_put_function(func_lb); | 375 | usb_put_function(func_lb); |
378 | func_lb = NULL; | 376 | func_lb = NULL; |
@@ -397,6 +395,9 @@ static int zero_unbind(struct usb_composite_dev *cdev) | |||
397 | if (!IS_ERR_OR_NULL(func_lb)) | 395 | if (!IS_ERR_OR_NULL(func_lb)) |
398 | usb_put_function(func_lb); | 396 | usb_put_function(func_lb); |
399 | usb_put_function_instance(func_inst_lb); | 397 | usb_put_function_instance(func_inst_lb); |
398 | kfree(otg_desc[0]); | ||
399 | otg_desc[0] = NULL; | ||
400 | |||
400 | return 0; | 401 | return 0; |
401 | } | 402 | } |
402 | 403 | ||
diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index de7e5e2ccf1c..fdacddb18c00 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c | |||
@@ -138,15 +138,82 @@ static DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, | |||
138 | 138 | ||
139 | /* endpoint names used for print */ | 139 | /* endpoint names used for print */ |
140 | static const char ep0_string[] = "ep0in"; | 140 | static const char ep0_string[] = "ep0in"; |
141 | static const char *const ep_string[] = { | 141 | static const struct { |
142 | ep0_string, | 142 | const char *name; |
143 | "ep1in-int", "ep2in-bulk", "ep3in-bulk", "ep4in-bulk", "ep5in-bulk", | 143 | const struct usb_ep_caps caps; |
144 | "ep6in-bulk", "ep7in-bulk", "ep8in-bulk", "ep9in-bulk", "ep10in-bulk", | 144 | } ep_info[] = { |
145 | "ep11in-bulk", "ep12in-bulk", "ep13in-bulk", "ep14in-bulk", | 145 | #define EP_INFO(_name, _caps) \ |
146 | "ep15in-bulk", "ep0out", "ep1out-bulk", "ep2out-bulk", "ep3out-bulk", | 146 | { \ |
147 | "ep4out-bulk", "ep5out-bulk", "ep6out-bulk", "ep7out-bulk", | 147 | .name = _name, \ |
148 | "ep8out-bulk", "ep9out-bulk", "ep10out-bulk", "ep11out-bulk", | 148 | .caps = _caps, \ |
149 | "ep12out-bulk", "ep13out-bulk", "ep14out-bulk", "ep15out-bulk" | 149 | } |
150 | |||
151 | EP_INFO(ep0_string, | ||
152 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_IN)), | ||
153 | EP_INFO("ep1in-int", | ||
154 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
155 | EP_INFO("ep2in-bulk", | ||
156 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
157 | EP_INFO("ep3in-bulk", | ||
158 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
159 | EP_INFO("ep4in-bulk", | ||
160 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
161 | EP_INFO("ep5in-bulk", | ||
162 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
163 | EP_INFO("ep6in-bulk", | ||
164 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
165 | EP_INFO("ep7in-bulk", | ||
166 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
167 | EP_INFO("ep8in-bulk", | ||
168 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
169 | EP_INFO("ep9in-bulk", | ||
170 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
171 | EP_INFO("ep10in-bulk", | ||
172 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
173 | EP_INFO("ep11in-bulk", | ||
174 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
175 | EP_INFO("ep12in-bulk", | ||
176 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
177 | EP_INFO("ep13in-bulk", | ||
178 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
179 | EP_INFO("ep14in-bulk", | ||
180 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
181 | EP_INFO("ep15in-bulk", | ||
182 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
183 | EP_INFO("ep0out", | ||
184 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_OUT)), | ||
185 | EP_INFO("ep1out-bulk", | ||
186 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
187 | EP_INFO("ep2out-bulk", | ||
188 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
189 | EP_INFO("ep3out-bulk", | ||
190 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
191 | EP_INFO("ep4out-bulk", | ||
192 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
193 | EP_INFO("ep5out-bulk", | ||
194 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
195 | EP_INFO("ep6out-bulk", | ||
196 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
197 | EP_INFO("ep7out-bulk", | ||
198 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
199 | EP_INFO("ep8out-bulk", | ||
200 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
201 | EP_INFO("ep9out-bulk", | ||
202 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
203 | EP_INFO("ep10out-bulk", | ||
204 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
205 | EP_INFO("ep11out-bulk", | ||
206 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
207 | EP_INFO("ep12out-bulk", | ||
208 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
209 | EP_INFO("ep13out-bulk", | ||
210 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
211 | EP_INFO("ep14out-bulk", | ||
212 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
213 | EP_INFO("ep15out-bulk", | ||
214 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
215 | |||
216 | #undef EP_INFO | ||
150 | }; | 217 | }; |
151 | 218 | ||
152 | /* DMA usage flag */ | 219 | /* DMA usage flag */ |
@@ -1517,7 +1584,8 @@ static void udc_setup_endpoints(struct udc *dev) | |||
1517 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) { | 1584 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) { |
1518 | ep = &dev->ep[tmp]; | 1585 | ep = &dev->ep[tmp]; |
1519 | ep->dev = dev; | 1586 | ep->dev = dev; |
1520 | ep->ep.name = ep_string[tmp]; | 1587 | ep->ep.name = ep_info[tmp].name; |
1588 | ep->ep.caps = ep_info[tmp].caps; | ||
1521 | ep->num = tmp; | 1589 | ep->num = tmp; |
1522 | /* txfifo size is calculated at enable time */ | 1590 | /* txfifo size is calculated at enable time */ |
1523 | ep->txfifo = dev->txfifo; | 1591 | ep->txfifo = dev->txfifo; |
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c index fc4226462f8f..d0d18947f58b 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c | |||
@@ -59,15 +59,34 @@ | |||
59 | #define DRIVER_VERSION "3 May 2006" | 59 | #define DRIVER_VERSION "3 May 2006" |
60 | 60 | ||
61 | static const char driver_name [] = "at91_udc"; | 61 | static const char driver_name [] = "at91_udc"; |
62 | static const char * const ep_names[] = { | 62 | |
63 | "ep0", | 63 | static const struct { |
64 | "ep1", | 64 | const char *name; |
65 | "ep2", | 65 | const struct usb_ep_caps caps; |
66 | "ep3-int", | 66 | } ep_info[] = { |
67 | "ep4", | 67 | #define EP_INFO(_name, _caps) \ |
68 | "ep5", | 68 | { \ |
69 | .name = _name, \ | ||
70 | .caps = _caps, \ | ||
71 | } | ||
72 | |||
73 | EP_INFO("ep0", | ||
74 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), | ||
75 | EP_INFO("ep1", | ||
76 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
77 | EP_INFO("ep2", | ||
78 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
79 | EP_INFO("ep3-int", | ||
80 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_ALL)), | ||
81 | EP_INFO("ep4", | ||
82 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
83 | EP_INFO("ep5", | ||
84 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
85 | |||
86 | #undef EP_INFO | ||
69 | }; | 87 | }; |
70 | #define ep0name ep_names[0] | 88 | |
89 | #define ep0name ep_info[0].name | ||
71 | 90 | ||
72 | #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) | 91 | #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) |
73 | 92 | ||
@@ -825,6 +844,7 @@ static void udc_reinit(struct at91_udc *udc) | |||
825 | 844 | ||
826 | INIT_LIST_HEAD(&udc->gadget.ep_list); | 845 | INIT_LIST_HEAD(&udc->gadget.ep_list); |
827 | INIT_LIST_HEAD(&udc->gadget.ep0->ep_list); | 846 | INIT_LIST_HEAD(&udc->gadget.ep0->ep_list); |
847 | udc->gadget.quirk_stall_not_supp = 1; | ||
828 | 848 | ||
829 | for (i = 0; i < NUM_ENDPOINTS; i++) { | 849 | for (i = 0; i < NUM_ENDPOINTS; i++) { |
830 | struct at91_ep *ep = &udc->ep[i]; | 850 | struct at91_ep *ep = &udc->ep[i]; |
@@ -1830,7 +1850,8 @@ static int at91udc_probe(struct platform_device *pdev) | |||
1830 | 1850 | ||
1831 | for (i = 0; i < NUM_ENDPOINTS; i++) { | 1851 | for (i = 0; i < NUM_ENDPOINTS; i++) { |
1832 | ep = &udc->ep[i]; | 1852 | ep = &udc->ep[i]; |
1833 | ep->ep.name = ep_names[i]; | 1853 | ep->ep.name = ep_info[i].name; |
1854 | ep->ep.caps = ep_info[i].caps; | ||
1834 | ep->ep.ops = &at91_ep_ops; | 1855 | ep->ep.ops = &at91_ep_ops; |
1835 | ep->udc = udc; | 1856 | ep->udc = udc; |
1836 | ep->int_mask = BIT(i); | 1857 | ep->int_mask = BIT(i); |
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 4095cce05e6a..267d84f838e1 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c | |||
@@ -1989,6 +1989,10 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | |||
1989 | ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc"); | 1989 | ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc"); |
1990 | 1990 | ||
1991 | ret = of_property_read_string(pp, "name", &name); | 1991 | ret = of_property_read_string(pp, "name", &name); |
1992 | if (ret) { | ||
1993 | dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); | ||
1994 | goto err; | ||
1995 | } | ||
1992 | ep->ep.name = name; | 1996 | ep->ep.name = name; |
1993 | 1997 | ||
1994 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); | 1998 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); |
@@ -2063,6 +2067,17 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, | |||
2063 | ep->can_dma = pdata->ep[i].can_dma; | 2067 | ep->can_dma = pdata->ep[i].can_dma; |
2064 | ep->can_isoc = pdata->ep[i].can_isoc; | 2068 | ep->can_isoc = pdata->ep[i].can_isoc; |
2065 | 2069 | ||
2070 | if (i == 0) { | ||
2071 | ep->ep.caps.type_control = true; | ||
2072 | } else { | ||
2073 | ep->ep.caps.type_iso = ep->can_isoc; | ||
2074 | ep->ep.caps.type_bulk = true; | ||
2075 | ep->ep.caps.type_int = true; | ||
2076 | } | ||
2077 | |||
2078 | ep->ep.caps.dir_in = true; | ||
2079 | ep->ep.caps.dir_out = true; | ||
2080 | |||
2066 | if (i) | 2081 | if (i) |
2067 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | 2082 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); |
2068 | } | 2083 | } |
diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 9db968ba39f5..8cbb00325824 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c | |||
@@ -44,9 +44,29 @@ | |||
44 | #define DRV_MODULE_NAME "bcm63xx_udc" | 44 | #define DRV_MODULE_NAME "bcm63xx_udc" |
45 | 45 | ||
46 | static const char bcm63xx_ep0name[] = "ep0"; | 46 | static const char bcm63xx_ep0name[] = "ep0"; |
47 | static const char *const bcm63xx_ep_name[] = { | 47 | |
48 | bcm63xx_ep0name, | 48 | static const struct { |
49 | "ep1in-bulk", "ep2out-bulk", "ep3in-int", "ep4out-int", | 49 | const char *name; |
50 | const struct usb_ep_caps caps; | ||
51 | } bcm63xx_ep_info[] = { | ||
52 | #define EP_INFO(_name, _caps) \ | ||
53 | { \ | ||
54 | .name = _name, \ | ||
55 | .caps = _caps, \ | ||
56 | } | ||
57 | |||
58 | EP_INFO(bcm63xx_ep0name, | ||
59 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), | ||
60 | EP_INFO("ep1in-bulk", | ||
61 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
62 | EP_INFO("ep2out-bulk", | ||
63 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
64 | EP_INFO("ep3in-int", | ||
65 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), | ||
66 | EP_INFO("ep4out-int", | ||
67 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_OUT)), | ||
68 | |||
69 | #undef EP_INFO | ||
50 | }; | 70 | }; |
51 | 71 | ||
52 | static bool use_fullspeed; | 72 | static bool use_fullspeed; |
@@ -943,7 +963,8 @@ static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc) | |||
943 | for (i = 0; i < BCM63XX_NUM_EP; i++) { | 963 | for (i = 0; i < BCM63XX_NUM_EP; i++) { |
944 | struct bcm63xx_ep *bep = &udc->bep[i]; | 964 | struct bcm63xx_ep *bep = &udc->bep[i]; |
945 | 965 | ||
946 | bep->ep.name = bcm63xx_ep_name[i]; | 966 | bep->ep.name = bcm63xx_ep_info[i].name; |
967 | bep->ep.caps = bcm63xx_ep_info[i].caps; | ||
947 | bep->ep_num = i; | 968 | bep->ep_num = i; |
948 | bep->ep.ops = &bcm63xx_udc_ep_ops; | 969 | bep->ep.ops = &bcm63xx_udc_ep_ops; |
949 | list_add_tail(&bep->ep.ep_list, &udc->gadget.ep_list); | 970 | list_add_tail(&bep->ep.ep_list, &udc->gadget.ep_list); |
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index 1efa61265d8d..d1b81539d632 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c | |||
@@ -1952,12 +1952,18 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) | |||
1952 | ep->bdc = bdc; | 1952 | ep->bdc = bdc; |
1953 | ep->dir = dir; | 1953 | ep->dir = dir; |
1954 | 1954 | ||
1955 | if (dir) | ||
1956 | ep->usb_ep.caps.dir_in = true; | ||
1957 | else | ||
1958 | ep->usb_ep.caps.dir_out = true; | ||
1959 | |||
1955 | /* ep->ep_num is the index inside bdc_ep */ | 1960 | /* ep->ep_num is the index inside bdc_ep */ |
1956 | if (epnum == 1) { | 1961 | if (epnum == 1) { |
1957 | ep->ep_num = 1; | 1962 | ep->ep_num = 1; |
1958 | bdc->bdc_ep_array[ep->ep_num] = ep; | 1963 | bdc->bdc_ep_array[ep->ep_num] = ep; |
1959 | snprintf(ep->name, sizeof(ep->name), "ep%d", epnum - 1); | 1964 | snprintf(ep->name, sizeof(ep->name), "ep%d", epnum - 1); |
1960 | usb_ep_set_maxpacket_limit(&ep->usb_ep, EP0_MAX_PKT_SIZE); | 1965 | usb_ep_set_maxpacket_limit(&ep->usb_ep, EP0_MAX_PKT_SIZE); |
1966 | ep->usb_ep.caps.type_control = true; | ||
1961 | ep->comp_desc = NULL; | 1967 | ep->comp_desc = NULL; |
1962 | bdc->gadget.ep0 = &ep->usb_ep; | 1968 | bdc->gadget.ep0 = &ep->usb_ep; |
1963 | } else { | 1969 | } else { |
@@ -1971,6 +1977,9 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) | |||
1971 | dir & 1 ? "in" : "out"); | 1977 | dir & 1 ? "in" : "out"); |
1972 | 1978 | ||
1973 | usb_ep_set_maxpacket_limit(&ep->usb_ep, 1024); | 1979 | usb_ep_set_maxpacket_limit(&ep->usb_ep, 1024); |
1980 | ep->usb_ep.caps.type_iso = true; | ||
1981 | ep->usb_ep.caps.type_bulk = true; | ||
1982 | ep->usb_ep.caps.type_int = true; | ||
1974 | ep->usb_ep.max_streams = 0; | 1983 | ep->usb_ep.max_streams = 0; |
1975 | list_add_tail(&ep->usb_ep.ep_list, &bdc->gadget.ep_list); | 1984 | list_add_tail(&ep->usb_ep.ep_list, &bdc->gadget.ep_list); |
1976 | } | 1985 | } |
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 181112c88f43..1379ad40d864 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c | |||
@@ -127,23 +127,87 @@ static inline struct dummy_request *usb_request_to_dummy_request | |||
127 | 127 | ||
128 | static const char ep0name[] = "ep0"; | 128 | static const char ep0name[] = "ep0"; |
129 | 129 | ||
130 | static const char *const ep_name[] = { | 130 | static const struct { |
131 | ep0name, /* everyone has ep0 */ | 131 | const char *name; |
132 | const struct usb_ep_caps caps; | ||
133 | } ep_info[] = { | ||
134 | #define EP_INFO(_name, _caps) \ | ||
135 | { \ | ||
136 | .name = _name, \ | ||
137 | .caps = _caps, \ | ||
138 | } | ||
132 | 139 | ||
140 | /* everyone has ep0 */ | ||
141 | EP_INFO(ep0name, | ||
142 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), | ||
133 | /* act like a pxa250: fifteen fixed function endpoints */ | 143 | /* act like a pxa250: fifteen fixed function endpoints */ |
134 | "ep1in-bulk", "ep2out-bulk", "ep3in-iso", "ep4out-iso", "ep5in-int", | 144 | EP_INFO("ep1in-bulk", |
135 | "ep6in-bulk", "ep7out-bulk", "ep8in-iso", "ep9out-iso", "ep10in-int", | 145 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), |
136 | "ep11in-bulk", "ep12out-bulk", "ep13in-iso", "ep14out-iso", | 146 | EP_INFO("ep2out-bulk", |
137 | "ep15in-int", | 147 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), |
138 | 148 | EP_INFO("ep3in-iso", | |
149 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), | ||
150 | EP_INFO("ep4out-iso", | ||
151 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), | ||
152 | EP_INFO("ep5in-int", | ||
153 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), | ||
154 | EP_INFO("ep6in-bulk", | ||
155 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
156 | EP_INFO("ep7out-bulk", | ||
157 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
158 | EP_INFO("ep8in-iso", | ||
159 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), | ||
160 | EP_INFO("ep9out-iso", | ||
161 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), | ||
162 | EP_INFO("ep10in-int", | ||
163 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), | ||
164 | EP_INFO("ep11in-bulk", | ||
165 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
166 | EP_INFO("ep12out-bulk", | ||
167 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | ||
168 | EP_INFO("ep13in-iso", | ||
169 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), | ||
170 | EP_INFO("ep14out-iso", | ||
171 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), | ||
172 | EP_INFO("ep15in-int", | ||
173 | USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), | ||
139 | /* or like sa1100: two fixed function endpoints */ | 174 | /* or like sa1100: two fixed function endpoints */ |
140 | "ep1out-bulk", "ep2in-bulk", | 175 | EP_INFO("ep1out-bulk", |
141 | 176 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), | |
177 | EP_INFO("ep2in-bulk", | ||
178 | USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), | ||
142 | /* and now some generic EPs so we have enough in multi config */ | 179 | /* and now some generic EPs so we have enough in multi config */ |
143 | "ep3out", "ep4in", "ep5out", "ep6out", "ep7in", "ep8out", "ep9in", | 180 | EP_INFO("ep3out", |
144 | "ep10out", "ep11out", "ep12in", "ep13out", "ep14in", "ep15out", | 181 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), |
182 | EP_INFO("ep4in", | ||
183 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
184 | EP_INFO("ep5out", | ||
185 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
186 | EP_INFO("ep6out", | ||
187 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
188 | EP_INFO("ep7in", | ||
189 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
190 | EP_INFO("ep8out", | ||
191 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
192 | EP_INFO("ep9in", | ||
193 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
194 | EP_INFO("ep10out", | ||
195 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
196 | EP_INFO("ep11out", | ||
197 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
198 | EP_INFO("ep12in", | ||
199 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
200 | EP_INFO("ep13out", | ||
201 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
202 | EP_INFO("ep14in", | ||
203 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
204 | EP_INFO("ep15out", | ||
205 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
206 | |||
207 | #undef EP_INFO | ||
145 | }; | 208 | }; |
146 | #define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name) | 209 | |
210 | #define DUMMY_ENDPOINTS ARRAY_SIZE(ep_info) | ||
147 | 211 | ||
148 | /*-------------------------------------------------------------------------*/ | 212 | /*-------------------------------------------------------------------------*/ |
149 | 213 | ||
@@ -938,9 +1002,10 @@ static void init_dummy_udc_hw(struct dummy *dum) | |||
938 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { | 1002 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { |
939 | struct dummy_ep *ep = &dum->ep[i]; | 1003 | struct dummy_ep *ep = &dum->ep[i]; |
940 | 1004 | ||
941 | if (!ep_name[i]) | 1005 | if (!ep_info[i].name) |
942 | break; | 1006 | break; |
943 | ep->ep.name = ep_name[i]; | 1007 | ep->ep.name = ep_info[i].name; |
1008 | ep->ep.caps = ep_info[i].caps; | ||
944 | ep->ep.ops = &dummy_ep_ops; | 1009 | ep->ep.ops = &dummy_ep_ops; |
945 | list_add_tail(&ep->ep.ep_list, &dum->gadget.ep_list); | 1010 | list_add_tail(&ep->ep.ep_list, &dum->gadget.ep_list); |
946 | ep->halted = ep->wedged = ep->already_seen = | 1011 | ep->halted = ep->wedged = ep->already_seen = |
@@ -1684,7 +1749,7 @@ static void dummy_timer(unsigned long _dum_hcd) | |||
1684 | } | 1749 | } |
1685 | 1750 | ||
1686 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { | 1751 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { |
1687 | if (!ep_name[i]) | 1752 | if (!ep_info[i].name) |
1688 | break; | 1753 | break; |
1689 | dum->ep[i].already_seen = 0; | 1754 | dum->ep[i].already_seen = 0; |
1690 | } | 1755 | } |
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 1137e3384218..6ba122cc7490 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c | |||
@@ -384,25 +384,15 @@ static void fotg210_ep0_queue(struct fotg210_ep *ep, | |||
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | if (ep->dir_in) { /* if IN */ | 386 | if (ep->dir_in) { /* if IN */ |
387 | if (req->req.length) { | 387 | fotg210_start_dma(ep, req); |
388 | fotg210_start_dma(ep, req); | ||
389 | } else { | ||
390 | pr_err("%s : req->req.length = 0x%x\n", | ||
391 | __func__, req->req.length); | ||
392 | } | ||
393 | if ((req->req.length == req->req.actual) || | 388 | if ((req->req.length == req->req.actual) || |
394 | (req->req.actual < ep->ep.maxpacket)) | 389 | (req->req.actual < ep->ep.maxpacket)) |
395 | fotg210_done(ep, req, 0); | 390 | fotg210_done(ep, req, 0); |
396 | } else { /* OUT */ | 391 | } else { /* OUT */ |
397 | if (!req->req.length) { | 392 | u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0); |
398 | fotg210_done(ep, req, 0); | ||
399 | } else { | ||
400 | u32 value = ioread32(ep->fotg210->reg + | ||
401 | FOTG210_DMISGR0); | ||
402 | 393 | ||
403 | value &= ~DMISGR0_MCX_OUT_INT; | 394 | value &= ~DMISGR0_MCX_OUT_INT; |
404 | iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0); | 395 | iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0); |
405 | } | ||
406 | } | 396 | } |
407 | } | 397 | } |
408 | 398 | ||
@@ -1153,6 +1143,17 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
1153 | ep->ep.name = fotg210_ep_name[i]; | 1143 | ep->ep.name = fotg210_ep_name[i]; |
1154 | ep->ep.ops = &fotg210_ep_ops; | 1144 | ep->ep.ops = &fotg210_ep_ops; |
1155 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); | 1145 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); |
1146 | |||
1147 | if (i == 0) { | ||
1148 | ep->ep.caps.type_control = true; | ||
1149 | } else { | ||
1150 | ep->ep.caps.type_iso = true; | ||
1151 | ep->ep.caps.type_bulk = true; | ||
1152 | ep->ep.caps.type_int = true; | ||
1153 | } | ||
1154 | |||
1155 | ep->ep.caps.dir_in = true; | ||
1156 | ep->ep.caps.dir_out = true; | ||
1156 | } | 1157 | } |
1157 | usb_ep_set_maxpacket_limit(&fotg210->ep[0]->ep, 0x40); | 1158 | usb_ep_set_maxpacket_limit(&fotg210->ep[0]->ep, 0x40); |
1158 | fotg210->gadget.ep0 = &fotg210->ep[0]->ep; | 1159 | fotg210->gadget.ep0 = &fotg210->ep[0]->ep; |
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index e0822f1b6639..5fb6f8b4f0b4 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c | |||
@@ -2417,6 +2417,17 @@ static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) | |||
2417 | strcpy(ep->name, ep_name[pipe_num]); | 2417 | strcpy(ep->name, ep_name[pipe_num]); |
2418 | ep->ep.name = ep_name[pipe_num]; | 2418 | ep->ep.name = ep_name[pipe_num]; |
2419 | 2419 | ||
2420 | if (pipe_num == 0) { | ||
2421 | ep->ep.caps.type_control = true; | ||
2422 | } else { | ||
2423 | ep->ep.caps.type_iso = true; | ||
2424 | ep->ep.caps.type_bulk = true; | ||
2425 | ep->ep.caps.type_int = true; | ||
2426 | } | ||
2427 | |||
2428 | ep->ep.caps.dir_in = true; | ||
2429 | ep->ep.caps.dir_out = true; | ||
2430 | |||
2420 | ep->ep.ops = &qe_ep_ops; | 2431 | ep->ep.ops = &qe_ep_ops; |
2421 | ep->stopped = 1; | 2432 | ep->stopped = 1; |
2422 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); | 2433 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); |
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index c60022b46a48..aab5221d6c2e 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c | |||
@@ -2313,6 +2313,19 @@ static int struct_ep_setup(struct fsl_udc *udc, unsigned char index, | |||
2313 | ep->ep.ops = &fsl_ep_ops; | 2313 | ep->ep.ops = &fsl_ep_ops; |
2314 | ep->stopped = 0; | 2314 | ep->stopped = 0; |
2315 | 2315 | ||
2316 | if (index == 0) { | ||
2317 | ep->ep.caps.type_control = true; | ||
2318 | } else { | ||
2319 | ep->ep.caps.type_iso = true; | ||
2320 | ep->ep.caps.type_bulk = true; | ||
2321 | ep->ep.caps.type_int = true; | ||
2322 | } | ||
2323 | |||
2324 | if (index & 1) | ||
2325 | ep->ep.caps.dir_in = true; | ||
2326 | else | ||
2327 | ep->ep.caps.dir_out = true; | ||
2328 | |||
2316 | /* for ep0: maxP defined in desc | 2329 | /* for ep0: maxP defined in desc |
2317 | * for other eps, maxP is set by epautoconfig() called by gadget layer | 2330 | * for other eps, maxP is set by epautoconfig() called by gadget layer |
2318 | */ | 2331 | */ |
diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index 3970f453de49..948845c90e47 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c | |||
@@ -1450,6 +1450,17 @@ static int fusb300_probe(struct platform_device *pdev) | |||
1450 | ep->ep.name = fusb300_ep_name[i]; | 1450 | ep->ep.name = fusb300_ep_name[i]; |
1451 | ep->ep.ops = &fusb300_ep_ops; | 1451 | ep->ep.ops = &fusb300_ep_ops; |
1452 | usb_ep_set_maxpacket_limit(&ep->ep, HS_BULK_MAX_PACKET_SIZE); | 1452 | usb_ep_set_maxpacket_limit(&ep->ep, HS_BULK_MAX_PACKET_SIZE); |
1453 | |||
1454 | if (i == 0) { | ||
1455 | ep->ep.caps.type_control = true; | ||
1456 | } else { | ||
1457 | ep->ep.caps.type_iso = true; | ||
1458 | ep->ep.caps.type_bulk = true; | ||
1459 | ep->ep.caps.type_int = true; | ||
1460 | } | ||
1461 | |||
1462 | ep->ep.caps.dir_in = true; | ||
1463 | ep->ep.caps.dir_out = true; | ||
1453 | } | 1464 | } |
1454 | usb_ep_set_maxpacket_limit(&fusb300->ep[0]->ep, HS_CTL_MAX_PACKET_SIZE); | 1465 | usb_ep_set_maxpacket_limit(&fusb300->ep[0]->ep, HS_CTL_MAX_PACKET_SIZE); |
1455 | fusb300->ep[0]->epnum = 0; | 1466 | fusb300->ep[0]->epnum = 0; |
diff --git a/drivers/usb/gadget/udc/gadget_chips.h b/drivers/usb/gadget/udc/gadget_chips.h deleted file mode 100644 index bcd04bc66b98..000000000000 --- a/drivers/usb/gadget/udc/gadget_chips.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* | ||
2 | * USB device controllers have lots of quirks. Use these macros in | ||
3 | * gadget drivers or other code that needs to deal with them, and which | ||
4 | * autoconfigures instead of using early binding to the hardware. | ||
5 | * | ||
6 | * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by | ||
7 | * some config file that gets updated as new hardware is supported. | ||
8 | * (And avoiding all runtime comparisons in typical one-choice configs!) | ||
9 | * | ||
10 | * NOTE: some of these controller drivers may not be available yet. | ||
11 | * Some are available on 2.4 kernels; several are available, but not | ||
12 | * yet pushed in the 2.6 mainline tree. | ||
13 | */ | ||
14 | |||
15 | #ifndef __GADGET_CHIPS_H | ||
16 | #define __GADGET_CHIPS_H | ||
17 | |||
18 | #include <linux/usb/gadget.h> | ||
19 | |||
20 | /* | ||
21 | * NOTICE: the entries below are alphabetical and should be kept | ||
22 | * that way. | ||
23 | * | ||
24 | * Always be sure to add new entries to the correct position or | ||
25 | * accept the bashing later. | ||
26 | * | ||
27 | * If you have forgotten the alphabetical order let VIM/EMACS | ||
28 | * do that for you. | ||
29 | */ | ||
30 | #define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name)) | ||
31 | #define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name)) | ||
32 | #define gadget_is_musbhdrc(g) (!strcmp("musb-hdrc", (g)->name)) | ||
33 | #define gadget_is_net2280(g) (!strcmp("net2280", (g)->name)) | ||
34 | #define gadget_is_pxa(g) (!strcmp("pxa25x_udc", (g)->name)) | ||
35 | #define gadget_is_pxa27x(g) (!strcmp("pxa27x_udc", (g)->name)) | ||
36 | |||
37 | /** | ||
38 | * gadget_supports_altsettings - return true if altsettings work | ||
39 | * @gadget: the gadget in question | ||
40 | */ | ||
41 | static inline bool gadget_supports_altsettings(struct usb_gadget *gadget) | ||
42 | { | ||
43 | /* PXA 21x/25x/26x has no altsettings at all */ | ||
44 | if (gadget_is_pxa(gadget)) | ||
45 | return false; | ||
46 | |||
47 | /* PXA 27x and 3xx have *broken* altsetting support */ | ||
48 | if (gadget_is_pxa27x(gadget)) | ||
49 | return false; | ||
50 | |||
51 | /* Everything else is *presumably* fine ... */ | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | #endif /* __GADGET_CHIPS_H */ | ||
diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 9e8d842e8c08..1fdfec14a3ba 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c | |||
@@ -990,6 +990,35 @@ static int goku_get_frame(struct usb_gadget *_gadget) | |||
990 | return -EOPNOTSUPP; | 990 | return -EOPNOTSUPP; |
991 | } | 991 | } |
992 | 992 | ||
993 | static struct usb_ep *goku_match_ep(struct usb_gadget *g, | ||
994 | struct usb_endpoint_descriptor *desc, | ||
995 | struct usb_ss_ep_comp_descriptor *ep_comp) | ||
996 | { | ||
997 | struct goku_udc *dev = to_goku_udc(g); | ||
998 | struct usb_ep *ep; | ||
999 | |||
1000 | switch (usb_endpoint_type(desc)) { | ||
1001 | case USB_ENDPOINT_XFER_INT: | ||
1002 | /* single buffering is enough */ | ||
1003 | ep = &dev->ep[3].ep; | ||
1004 | if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) | ||
1005 | return ep; | ||
1006 | break; | ||
1007 | case USB_ENDPOINT_XFER_BULK: | ||
1008 | if (usb_endpoint_dir_in(desc)) { | ||
1009 | /* DMA may be available */ | ||
1010 | ep = &dev->ep[2].ep; | ||
1011 | if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) | ||
1012 | return ep; | ||
1013 | } | ||
1014 | break; | ||
1015 | default: | ||
1016 | /* nothing */ ; | ||
1017 | } | ||
1018 | |||
1019 | return NULL; | ||
1020 | } | ||
1021 | |||
993 | static int goku_udc_start(struct usb_gadget *g, | 1022 | static int goku_udc_start(struct usb_gadget *g, |
994 | struct usb_gadget_driver *driver); | 1023 | struct usb_gadget_driver *driver); |
995 | static int goku_udc_stop(struct usb_gadget *g); | 1024 | static int goku_udc_stop(struct usb_gadget *g); |
@@ -998,6 +1027,7 @@ static const struct usb_gadget_ops goku_ops = { | |||
998 | .get_frame = goku_get_frame, | 1027 | .get_frame = goku_get_frame, |
999 | .udc_start = goku_udc_start, | 1028 | .udc_start = goku_udc_start, |
1000 | .udc_stop = goku_udc_stop, | 1029 | .udc_stop = goku_udc_stop, |
1030 | .match_ep = goku_match_ep, | ||
1001 | // no remote wakeup | 1031 | // no remote wakeup |
1002 | // not selfpowered | 1032 | // not selfpowered |
1003 | }; | 1033 | }; |
@@ -1257,6 +1287,14 @@ static void udc_reinit (struct goku_udc *dev) | |||
1257 | INIT_LIST_HEAD (&ep->queue); | 1287 | INIT_LIST_HEAD (&ep->queue); |
1258 | 1288 | ||
1259 | ep_reset(NULL, ep); | 1289 | ep_reset(NULL, ep); |
1290 | |||
1291 | if (i == 0) | ||
1292 | ep->ep.caps.type_control = true; | ||
1293 | else | ||
1294 | ep->ep.caps.type_bulk = true; | ||
1295 | |||
1296 | ep->ep.caps.dir_in = true; | ||
1297 | ep->ep.caps.dir_out = true; | ||
1260 | } | 1298 | } |
1261 | 1299 | ||
1262 | dev->ep[0].reg_mode = NULL; | 1300 | dev->ep[0].reg_mode = NULL; |
diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index c8868870e217..8aa2593c2c36 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c | |||
@@ -2018,12 +2018,23 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) | |||
2018 | 2018 | ||
2019 | usb_ep_set_maxpacket_limit(&ep->ep, MAX_CTRL_PL_SIZE); | 2019 | usb_ep_set_maxpacket_limit(&ep->ep, MAX_CTRL_PL_SIZE); |
2020 | ep->bytes_per_buffer = MAX_CTRL_PL_SIZE; | 2020 | ep->bytes_per_buffer = MAX_CTRL_PL_SIZE; |
2021 | |||
2022 | ep->ep.caps.type_control = true; | ||
2021 | } else { | 2023 | } else { |
2022 | usb_ep_set_maxpacket_limit(&ep->ep, (u16)maxplimit); | 2024 | usb_ep_set_maxpacket_limit(&ep->ep, (u16)maxplimit); |
2023 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); | 2025 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); |
2026 | |||
2027 | ep->ep.caps.type_iso = true; | ||
2028 | ep->ep.caps.type_bulk = true; | ||
2029 | ep->ep.caps.type_int = true; | ||
2024 | } | 2030 | } |
2025 | list_add_tail(&ep->ep_list, &dev->ep_list); | 2031 | list_add_tail(&ep->ep_list, &dev->ep_list); |
2026 | 2032 | ||
2033 | if (is_in) | ||
2034 | ep->ep.caps.dir_in = true; | ||
2035 | else | ||
2036 | ep->ep.caps.dir_out = true; | ||
2037 | |||
2027 | ep->tailbuf = dma_alloc_coherent(dev->dev, ep->ep.maxpacket_limit, | 2038 | ep->tailbuf = dma_alloc_coherent(dev->dev, ep->ep.maxpacket_limit, |
2028 | &ep->tailbuf_paddr, GFP_ATOMIC); | 2039 | &ep->tailbuf_paddr, GFP_ATOMIC); |
2029 | if (!ep->tailbuf) | 2040 | if (!ep->tailbuf) |
diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 3b6a7852822d..00b5006baf15 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c | |||
@@ -2575,6 +2575,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2575 | .ep = { | 2575 | .ep = { |
2576 | .name = "ep0", | 2576 | .name = "ep0", |
2577 | .ops = &lpc32xx_ep_ops, | 2577 | .ops = &lpc32xx_ep_ops, |
2578 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, | ||
2579 | USB_EP_CAPS_DIR_ALL), | ||
2578 | }, | 2580 | }, |
2579 | .maxpacket = 64, | 2581 | .maxpacket = 64, |
2580 | .hwep_num_base = 0, | 2582 | .hwep_num_base = 0, |
@@ -2586,6 +2588,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2586 | .ep = { | 2588 | .ep = { |
2587 | .name = "ep1-int", | 2589 | .name = "ep1-int", |
2588 | .ops = &lpc32xx_ep_ops, | 2590 | .ops = &lpc32xx_ep_ops, |
2591 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, | ||
2592 | USB_EP_CAPS_DIR_ALL), | ||
2589 | }, | 2593 | }, |
2590 | .maxpacket = 64, | 2594 | .maxpacket = 64, |
2591 | .hwep_num_base = 2, | 2595 | .hwep_num_base = 2, |
@@ -2597,6 +2601,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2597 | .ep = { | 2601 | .ep = { |
2598 | .name = "ep2-bulk", | 2602 | .name = "ep2-bulk", |
2599 | .ops = &lpc32xx_ep_ops, | 2603 | .ops = &lpc32xx_ep_ops, |
2604 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2605 | USB_EP_CAPS_DIR_ALL), | ||
2600 | }, | 2606 | }, |
2601 | .maxpacket = 64, | 2607 | .maxpacket = 64, |
2602 | .hwep_num_base = 4, | 2608 | .hwep_num_base = 4, |
@@ -2608,6 +2614,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2608 | .ep = { | 2614 | .ep = { |
2609 | .name = "ep3-iso", | 2615 | .name = "ep3-iso", |
2610 | .ops = &lpc32xx_ep_ops, | 2616 | .ops = &lpc32xx_ep_ops, |
2617 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2618 | USB_EP_CAPS_DIR_ALL), | ||
2611 | }, | 2619 | }, |
2612 | .maxpacket = 1023, | 2620 | .maxpacket = 1023, |
2613 | .hwep_num_base = 6, | 2621 | .hwep_num_base = 6, |
@@ -2619,6 +2627,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2619 | .ep = { | 2627 | .ep = { |
2620 | .name = "ep4-int", | 2628 | .name = "ep4-int", |
2621 | .ops = &lpc32xx_ep_ops, | 2629 | .ops = &lpc32xx_ep_ops, |
2630 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, | ||
2631 | USB_EP_CAPS_DIR_ALL), | ||
2622 | }, | 2632 | }, |
2623 | .maxpacket = 64, | 2633 | .maxpacket = 64, |
2624 | .hwep_num_base = 8, | 2634 | .hwep_num_base = 8, |
@@ -2630,6 +2640,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2630 | .ep = { | 2640 | .ep = { |
2631 | .name = "ep5-bulk", | 2641 | .name = "ep5-bulk", |
2632 | .ops = &lpc32xx_ep_ops, | 2642 | .ops = &lpc32xx_ep_ops, |
2643 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2644 | USB_EP_CAPS_DIR_ALL), | ||
2633 | }, | 2645 | }, |
2634 | .maxpacket = 64, | 2646 | .maxpacket = 64, |
2635 | .hwep_num_base = 10, | 2647 | .hwep_num_base = 10, |
@@ -2641,6 +2653,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2641 | .ep = { | 2653 | .ep = { |
2642 | .name = "ep6-iso", | 2654 | .name = "ep6-iso", |
2643 | .ops = &lpc32xx_ep_ops, | 2655 | .ops = &lpc32xx_ep_ops, |
2656 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2657 | USB_EP_CAPS_DIR_ALL), | ||
2644 | }, | 2658 | }, |
2645 | .maxpacket = 1023, | 2659 | .maxpacket = 1023, |
2646 | .hwep_num_base = 12, | 2660 | .hwep_num_base = 12, |
@@ -2652,6 +2666,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2652 | .ep = { | 2666 | .ep = { |
2653 | .name = "ep7-int", | 2667 | .name = "ep7-int", |
2654 | .ops = &lpc32xx_ep_ops, | 2668 | .ops = &lpc32xx_ep_ops, |
2669 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, | ||
2670 | USB_EP_CAPS_DIR_ALL), | ||
2655 | }, | 2671 | }, |
2656 | .maxpacket = 64, | 2672 | .maxpacket = 64, |
2657 | .hwep_num_base = 14, | 2673 | .hwep_num_base = 14, |
@@ -2663,6 +2679,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2663 | .ep = { | 2679 | .ep = { |
2664 | .name = "ep8-bulk", | 2680 | .name = "ep8-bulk", |
2665 | .ops = &lpc32xx_ep_ops, | 2681 | .ops = &lpc32xx_ep_ops, |
2682 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2683 | USB_EP_CAPS_DIR_ALL), | ||
2666 | }, | 2684 | }, |
2667 | .maxpacket = 64, | 2685 | .maxpacket = 64, |
2668 | .hwep_num_base = 16, | 2686 | .hwep_num_base = 16, |
@@ -2674,6 +2692,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2674 | .ep = { | 2692 | .ep = { |
2675 | .name = "ep9-iso", | 2693 | .name = "ep9-iso", |
2676 | .ops = &lpc32xx_ep_ops, | 2694 | .ops = &lpc32xx_ep_ops, |
2695 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2696 | USB_EP_CAPS_DIR_ALL), | ||
2677 | }, | 2697 | }, |
2678 | .maxpacket = 1023, | 2698 | .maxpacket = 1023, |
2679 | .hwep_num_base = 18, | 2699 | .hwep_num_base = 18, |
@@ -2685,6 +2705,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2685 | .ep = { | 2705 | .ep = { |
2686 | .name = "ep10-int", | 2706 | .name = "ep10-int", |
2687 | .ops = &lpc32xx_ep_ops, | 2707 | .ops = &lpc32xx_ep_ops, |
2708 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, | ||
2709 | USB_EP_CAPS_DIR_ALL), | ||
2688 | }, | 2710 | }, |
2689 | .maxpacket = 64, | 2711 | .maxpacket = 64, |
2690 | .hwep_num_base = 20, | 2712 | .hwep_num_base = 20, |
@@ -2696,6 +2718,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2696 | .ep = { | 2718 | .ep = { |
2697 | .name = "ep11-bulk", | 2719 | .name = "ep11-bulk", |
2698 | .ops = &lpc32xx_ep_ops, | 2720 | .ops = &lpc32xx_ep_ops, |
2721 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2722 | USB_EP_CAPS_DIR_ALL), | ||
2699 | }, | 2723 | }, |
2700 | .maxpacket = 64, | 2724 | .maxpacket = 64, |
2701 | .hwep_num_base = 22, | 2725 | .hwep_num_base = 22, |
@@ -2707,6 +2731,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2707 | .ep = { | 2731 | .ep = { |
2708 | .name = "ep12-iso", | 2732 | .name = "ep12-iso", |
2709 | .ops = &lpc32xx_ep_ops, | 2733 | .ops = &lpc32xx_ep_ops, |
2734 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2735 | USB_EP_CAPS_DIR_ALL), | ||
2710 | }, | 2736 | }, |
2711 | .maxpacket = 1023, | 2737 | .maxpacket = 1023, |
2712 | .hwep_num_base = 24, | 2738 | .hwep_num_base = 24, |
@@ -2718,6 +2744,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2718 | .ep = { | 2744 | .ep = { |
2719 | .name = "ep13-int", | 2745 | .name = "ep13-int", |
2720 | .ops = &lpc32xx_ep_ops, | 2746 | .ops = &lpc32xx_ep_ops, |
2747 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, | ||
2748 | USB_EP_CAPS_DIR_ALL), | ||
2721 | }, | 2749 | }, |
2722 | .maxpacket = 64, | 2750 | .maxpacket = 64, |
2723 | .hwep_num_base = 26, | 2751 | .hwep_num_base = 26, |
@@ -2729,6 +2757,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2729 | .ep = { | 2757 | .ep = { |
2730 | .name = "ep14-bulk", | 2758 | .name = "ep14-bulk", |
2731 | .ops = &lpc32xx_ep_ops, | 2759 | .ops = &lpc32xx_ep_ops, |
2760 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2761 | USB_EP_CAPS_DIR_ALL), | ||
2732 | }, | 2762 | }, |
2733 | .maxpacket = 64, | 2763 | .maxpacket = 64, |
2734 | .hwep_num_base = 28, | 2764 | .hwep_num_base = 28, |
@@ -2740,6 +2770,8 @@ static const struct lpc32xx_udc controller_template = { | |||
2740 | .ep = { | 2770 | .ep = { |
2741 | .name = "ep15-bulk", | 2771 | .name = "ep15-bulk", |
2742 | .ops = &lpc32xx_ep_ops, | 2772 | .ops = &lpc32xx_ep_ops, |
2773 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2774 | USB_EP_CAPS_DIR_ALL), | ||
2743 | }, | 2775 | }, |
2744 | .maxpacket = 1023, | 2776 | .maxpacket = 1023, |
2745 | .hwep_num_base = 30, | 2777 | .hwep_num_base = 30, |
diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index 309706fe4bf0..b1cfa96cc88f 100644 --- a/drivers/usb/gadget/udc/m66592-udc.c +++ b/drivers/usb/gadget/udc/m66592-udc.c | |||
@@ -1052,7 +1052,7 @@ static void set_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl) | |||
1052 | tmp = m66592_read(m66592, M66592_INTSTS0) & | 1052 | tmp = m66592_read(m66592, M66592_INTSTS0) & |
1053 | M66592_CTSQ; | 1053 | M66592_CTSQ; |
1054 | udelay(1); | 1054 | udelay(1); |
1055 | } while (tmp != M66592_CS_IDST || timeout-- > 0); | 1055 | } while (tmp != M66592_CS_IDST && timeout-- > 0); |
1056 | 1056 | ||
1057 | if (tmp == M66592_CS_IDST) | 1057 | if (tmp == M66592_CS_IDST) |
1058 | m66592_bset(m66592, | 1058 | m66592_bset(m66592, |
@@ -1644,6 +1644,17 @@ static int m66592_probe(struct platform_device *pdev) | |||
1644 | ep->ep.name = m66592_ep_name[i]; | 1644 | ep->ep.name = m66592_ep_name[i]; |
1645 | ep->ep.ops = &m66592_ep_ops; | 1645 | ep->ep.ops = &m66592_ep_ops; |
1646 | usb_ep_set_maxpacket_limit(&ep->ep, 512); | 1646 | usb_ep_set_maxpacket_limit(&ep->ep, 512); |
1647 | |||
1648 | if (i == 0) { | ||
1649 | ep->ep.caps.type_control = true; | ||
1650 | } else { | ||
1651 | ep->ep.caps.type_iso = true; | ||
1652 | ep->ep.caps.type_bulk = true; | ||
1653 | ep->ep.caps.type_int = true; | ||
1654 | } | ||
1655 | |||
1656 | ep->ep.caps.dir_in = true; | ||
1657 | ep->ep.caps.dir_out = true; | ||
1647 | } | 1658 | } |
1648 | usb_ep_set_maxpacket_limit(&m66592->ep[0].ep, 64); | 1659 | usb_ep_set_maxpacket_limit(&m66592->ep[0].ep, 64); |
1649 | m66592->ep[0].pipenum = 0; | 1660 | m66592->ep[0].pipenum = 0; |
diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index ea35a248c898..4c489692745e 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c | |||
@@ -1324,6 +1324,9 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) | |||
1324 | ep->ep.ops = &mv_u3d_ep_ops; | 1324 | ep->ep.ops = &mv_u3d_ep_ops; |
1325 | ep->wedge = 0; | 1325 | ep->wedge = 0; |
1326 | usb_ep_set_maxpacket_limit(&ep->ep, MV_U3D_EP0_MAX_PKT_SIZE); | 1326 | usb_ep_set_maxpacket_limit(&ep->ep, MV_U3D_EP0_MAX_PKT_SIZE); |
1327 | ep->ep.caps.type_control = true; | ||
1328 | ep->ep.caps.dir_in = true; | ||
1329 | ep->ep.caps.dir_out = true; | ||
1327 | ep->ep_num = 0; | 1330 | ep->ep_num = 0; |
1328 | ep->ep.desc = &mv_u3d_ep0_desc; | 1331 | ep->ep.desc = &mv_u3d_ep0_desc; |
1329 | INIT_LIST_HEAD(&ep->queue); | 1332 | INIT_LIST_HEAD(&ep->queue); |
@@ -1339,14 +1342,20 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) | |||
1339 | if (i & 1) { | 1342 | if (i & 1) { |
1340 | snprintf(name, sizeof(name), "ep%din", i >> 1); | 1343 | snprintf(name, sizeof(name), "ep%din", i >> 1); |
1341 | ep->direction = MV_U3D_EP_DIR_IN; | 1344 | ep->direction = MV_U3D_EP_DIR_IN; |
1345 | ep->ep.caps.dir_in = true; | ||
1342 | } else { | 1346 | } else { |
1343 | snprintf(name, sizeof(name), "ep%dout", i >> 1); | 1347 | snprintf(name, sizeof(name), "ep%dout", i >> 1); |
1344 | ep->direction = MV_U3D_EP_DIR_OUT; | 1348 | ep->direction = MV_U3D_EP_DIR_OUT; |
1349 | ep->ep.caps.dir_out = true; | ||
1345 | } | 1350 | } |
1346 | ep->u3d = u3d; | 1351 | ep->u3d = u3d; |
1347 | strncpy(ep->name, name, sizeof(ep->name)); | 1352 | strncpy(ep->name, name, sizeof(ep->name)); |
1348 | ep->ep.name = ep->name; | 1353 | ep->ep.name = ep->name; |
1349 | 1354 | ||
1355 | ep->ep.caps.type_iso = true; | ||
1356 | ep->ep.caps.type_bulk = true; | ||
1357 | ep->ep.caps.type_int = true; | ||
1358 | |||
1350 | ep->ep.ops = &mv_u3d_ep_ops; | 1359 | ep->ep.ops = &mv_u3d_ep_ops; |
1351 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); | 1360 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); |
1352 | ep->ep_num = i / 2; | 1361 | ep->ep_num = i / 2; |
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index 5da37c957b53..339af51df57d 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c | |||
@@ -1257,6 +1257,9 @@ static int eps_init(struct mv_udc *udc) | |||
1257 | ep->wedge = 0; | 1257 | ep->wedge = 0; |
1258 | ep->stopped = 0; | 1258 | ep->stopped = 0; |
1259 | usb_ep_set_maxpacket_limit(&ep->ep, EP0_MAX_PKT_SIZE); | 1259 | usb_ep_set_maxpacket_limit(&ep->ep, EP0_MAX_PKT_SIZE); |
1260 | ep->ep.caps.type_control = true; | ||
1261 | ep->ep.caps.dir_in = true; | ||
1262 | ep->ep.caps.dir_out = true; | ||
1260 | ep->ep_num = 0; | 1263 | ep->ep_num = 0; |
1261 | ep->ep.desc = &mv_ep0_desc; | 1264 | ep->ep.desc = &mv_ep0_desc; |
1262 | INIT_LIST_HEAD(&ep->queue); | 1265 | INIT_LIST_HEAD(&ep->queue); |
@@ -1269,14 +1272,20 @@ static int eps_init(struct mv_udc *udc) | |||
1269 | if (i % 2) { | 1272 | if (i % 2) { |
1270 | snprintf(name, sizeof(name), "ep%din", i / 2); | 1273 | snprintf(name, sizeof(name), "ep%din", i / 2); |
1271 | ep->direction = EP_DIR_IN; | 1274 | ep->direction = EP_DIR_IN; |
1275 | ep->ep.caps.dir_in = true; | ||
1272 | } else { | 1276 | } else { |
1273 | snprintf(name, sizeof(name), "ep%dout", i / 2); | 1277 | snprintf(name, sizeof(name), "ep%dout", i / 2); |
1274 | ep->direction = EP_DIR_OUT; | 1278 | ep->direction = EP_DIR_OUT; |
1279 | ep->ep.caps.dir_out = true; | ||
1275 | } | 1280 | } |
1276 | ep->udc = udc; | 1281 | ep->udc = udc; |
1277 | strncpy(ep->name, name, sizeof(ep->name)); | 1282 | strncpy(ep->name, name, sizeof(ep->name)); |
1278 | ep->ep.name = ep->name; | 1283 | ep->ep.name = ep->name; |
1279 | 1284 | ||
1285 | ep->ep.caps.type_iso = true; | ||
1286 | ep->ep.caps.type_bulk = true; | ||
1287 | ep->ep.caps.type_int = true; | ||
1288 | |||
1280 | ep->ep.ops = &mv_ep_ops; | 1289 | ep->ep.ops = &mv_ep_ops; |
1281 | ep->stopped = 0; | 1290 | ep->stopped = 0; |
1282 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); | 1291 | usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); |
diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index 195baf3e1fcd..18f5ebd447b8 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c | |||
@@ -1404,6 +1404,17 @@ net2272_usb_reinit(struct net2272 *dev) | |||
1404 | else | 1404 | else |
1405 | ep->fifo_size = 64; | 1405 | ep->fifo_size = 64; |
1406 | net2272_ep_reset(ep); | 1406 | net2272_ep_reset(ep); |
1407 | |||
1408 | if (i == 0) { | ||
1409 | ep->ep.caps.type_control = true; | ||
1410 | } else { | ||
1411 | ep->ep.caps.type_iso = true; | ||
1412 | ep->ep.caps.type_bulk = true; | ||
1413 | ep->ep.caps.type_int = true; | ||
1414 | } | ||
1415 | |||
1416 | ep->ep.caps.dir_in = true; | ||
1417 | ep->ep.caps.dir_out = true; | ||
1407 | } | 1418 | } |
1408 | usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 64); | 1419 | usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 64); |
1409 | 1420 | ||
@@ -1826,9 +1837,9 @@ net2272_handle_stat0_irqs(struct net2272 *dev, u8 stat) | |||
1826 | if (!e || u.r.wLength > 2) | 1837 | if (!e || u.r.wLength > 2) |
1827 | goto do_stall; | 1838 | goto do_stall; |
1828 | if (net2272_ep_read(e, EP_RSPSET) & (1 << ENDPOINT_HALT)) | 1839 | if (net2272_ep_read(e, EP_RSPSET) & (1 << ENDPOINT_HALT)) |
1829 | status = __constant_cpu_to_le16(1); | 1840 | status = cpu_to_le16(1); |
1830 | else | 1841 | else |
1831 | status = __constant_cpu_to_le16(0); | 1842 | status = cpu_to_le16(0); |
1832 | 1843 | ||
1833 | /* don't bother with a request object! */ | 1844 | /* don't bother with a request object! */ |
1834 | net2272_ep_write(&dev->ep[0], EP_IRQENB, 0); | 1845 | net2272_ep_write(&dev->ep[0], EP_IRQENB, 0); |
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 2bee912ca65b..cf0ed42f5591 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c | |||
@@ -74,19 +74,58 @@ static const char driver_desc[] = DRIVER_DESC; | |||
74 | 74 | ||
75 | static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 }; | 75 | static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 }; |
76 | static const char ep0name[] = "ep0"; | 76 | static const char ep0name[] = "ep0"; |
77 | static const char *const ep_name[] = { | ||
78 | ep0name, | ||
79 | "ep-a", "ep-b", "ep-c", "ep-d", | ||
80 | "ep-e", "ep-f", "ep-g", "ep-h", | ||
81 | }; | ||
82 | 77 | ||
83 | /* Endpoint names for usb3380 advance mode */ | 78 | #define EP_INFO(_name, _caps) \ |
84 | static const char *const ep_name_adv[] = { | 79 | { \ |
85 | ep0name, | 80 | .name = _name, \ |
86 | "ep1in", "ep2out", "ep3in", "ep4out", | 81 | .caps = _caps, \ |
87 | "ep1out", "ep2in", "ep3out", "ep4in", | 82 | } |
83 | |||
84 | static const struct { | ||
85 | const char *name; | ||
86 | const struct usb_ep_caps caps; | ||
87 | } ep_info_dft[] = { /* Default endpoint configuration */ | ||
88 | EP_INFO(ep0name, | ||
89 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), | ||
90 | EP_INFO("ep-a", | ||
91 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
92 | EP_INFO("ep-b", | ||
93 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
94 | EP_INFO("ep-c", | ||
95 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
96 | EP_INFO("ep-d", | ||
97 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
98 | EP_INFO("ep-e", | ||
99 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
100 | EP_INFO("ep-f", | ||
101 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
102 | EP_INFO("ep-g", | ||
103 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
104 | EP_INFO("ep-h", | ||
105 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), | ||
106 | }, ep_info_adv[] = { /* Endpoints for usb3380 advance mode */ | ||
107 | EP_INFO(ep0name, | ||
108 | USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), | ||
109 | EP_INFO("ep1in", | ||
110 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
111 | EP_INFO("ep2out", | ||
112 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
113 | EP_INFO("ep3in", | ||
114 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
115 | EP_INFO("ep4out", | ||
116 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
117 | EP_INFO("ep1out", | ||
118 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
119 | EP_INFO("ep2in", | ||
120 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
121 | EP_INFO("ep3out", | ||
122 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), | ||
123 | EP_INFO("ep4in", | ||
124 | USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), | ||
88 | }; | 125 | }; |
89 | 126 | ||
127 | #undef EP_INFO | ||
128 | |||
90 | /* mode 0 == ep-{a,b,c,d} 1K fifo each | 129 | /* mode 0 == ep-{a,b,c,d} 1K fifo each |
91 | * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable | 130 | * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable |
92 | * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable | 131 | * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable |
@@ -1511,6 +1550,33 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on) | |||
1511 | return 0; | 1550 | return 0; |
1512 | } | 1551 | } |
1513 | 1552 | ||
1553 | static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget, | ||
1554 | struct usb_endpoint_descriptor *desc, | ||
1555 | struct usb_ss_ep_comp_descriptor *ep_comp) | ||
1556 | { | ||
1557 | char name[8]; | ||
1558 | struct usb_ep *ep; | ||
1559 | |||
1560 | if (usb_endpoint_type(desc) == USB_ENDPOINT_XFER_INT) { | ||
1561 | /* ep-e, ep-f are PIO with only 64 byte fifos */ | ||
1562 | ep = gadget_find_ep_by_name(_gadget, "ep-e"); | ||
1563 | if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) | ||
1564 | return ep; | ||
1565 | ep = gadget_find_ep_by_name(_gadget, "ep-f"); | ||
1566 | if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) | ||
1567 | return ep; | ||
1568 | } | ||
1569 | |||
1570 | /* USB3380: use same address for usb and hardware endpoints */ | ||
1571 | snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc), | ||
1572 | usb_endpoint_dir_in(desc) ? "in" : "out"); | ||
1573 | ep = gadget_find_ep_by_name(_gadget, name); | ||
1574 | if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) | ||
1575 | return ep; | ||
1576 | |||
1577 | return NULL; | ||
1578 | } | ||
1579 | |||
1514 | static int net2280_start(struct usb_gadget *_gadget, | 1580 | static int net2280_start(struct usb_gadget *_gadget, |
1515 | struct usb_gadget_driver *driver); | 1581 | struct usb_gadget_driver *driver); |
1516 | static int net2280_stop(struct usb_gadget *_gadget); | 1582 | static int net2280_stop(struct usb_gadget *_gadget); |
@@ -1522,6 +1588,7 @@ static const struct usb_gadget_ops net2280_ops = { | |||
1522 | .pullup = net2280_pullup, | 1588 | .pullup = net2280_pullup, |
1523 | .udc_start = net2280_start, | 1589 | .udc_start = net2280_start, |
1524 | .udc_stop = net2280_stop, | 1590 | .udc_stop = net2280_stop, |
1591 | .match_ep = net2280_match_ep, | ||
1525 | }; | 1592 | }; |
1526 | 1593 | ||
1527 | /*-------------------------------------------------------------------------*/ | 1594 | /*-------------------------------------------------------------------------*/ |
@@ -2055,7 +2122,8 @@ static void usb_reinit_228x(struct net2280 *dev) | |||
2055 | for (tmp = 0; tmp < 7; tmp++) { | 2122 | for (tmp = 0; tmp < 7; tmp++) { |
2056 | struct net2280_ep *ep = &dev->ep[tmp]; | 2123 | struct net2280_ep *ep = &dev->ep[tmp]; |
2057 | 2124 | ||
2058 | ep->ep.name = ep_name[tmp]; | 2125 | ep->ep.name = ep_info_dft[tmp].name; |
2126 | ep->ep.caps = ep_info_dft[tmp].caps; | ||
2059 | ep->dev = dev; | 2127 | ep->dev = dev; |
2060 | ep->num = tmp; | 2128 | ep->num = tmp; |
2061 | 2129 | ||
@@ -2095,7 +2163,10 @@ static void usb_reinit_338x(struct net2280 *dev) | |||
2095 | for (i = 0; i < dev->n_ep; i++) { | 2163 | for (i = 0; i < dev->n_ep; i++) { |
2096 | struct net2280_ep *ep = &dev->ep[i]; | 2164 | struct net2280_ep *ep = &dev->ep[i]; |
2097 | 2165 | ||
2098 | ep->ep.name = dev->enhanced_mode ? ep_name_adv[i] : ep_name[i]; | 2166 | ep->ep.name = dev->enhanced_mode ? ep_info_adv[i].name : |
2167 | ep_info_dft[i].name; | ||
2168 | ep->ep.caps = dev->enhanced_mode ? ep_info_adv[i].caps : | ||
2169 | ep_info_dft[i].caps; | ||
2099 | ep->dev = dev; | 2170 | ep->dev = dev; |
2100 | ep->num = i; | 2171 | ep->num = i; |
2101 | 2172 | ||
diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index e2fcdb8e5596..9b7d39484ed3 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c | |||
@@ -2579,6 +2579,28 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2579 | ep->double_buf = dbuf; | 2579 | ep->double_buf = dbuf; |
2580 | ep->udc = udc; | 2580 | ep->udc = udc; |
2581 | 2581 | ||
2582 | switch (type) { | ||
2583 | case USB_ENDPOINT_XFER_CONTROL: | ||
2584 | ep->ep.caps.type_control = true; | ||
2585 | ep->ep.caps.dir_in = true; | ||
2586 | ep->ep.caps.dir_out = true; | ||
2587 | break; | ||
2588 | case USB_ENDPOINT_XFER_ISOC: | ||
2589 | ep->ep.caps.type_iso = true; | ||
2590 | break; | ||
2591 | case USB_ENDPOINT_XFER_BULK: | ||
2592 | ep->ep.caps.type_bulk = true; | ||
2593 | break; | ||
2594 | case USB_ENDPOINT_XFER_INT: | ||
2595 | ep->ep.caps.type_int = true; | ||
2596 | break; | ||
2597 | }; | ||
2598 | |||
2599 | if (addr & USB_DIR_IN) | ||
2600 | ep->ep.caps.dir_in = true; | ||
2601 | else | ||
2602 | ep->ep.caps.dir_out = true; | ||
2603 | |||
2582 | ep->ep.name = ep->name; | 2604 | ep->ep.name = ep->name; |
2583 | ep->ep.ops = &omap_ep_ops; | 2605 | ep->ep.ops = &omap_ep_ops; |
2584 | ep->maxpacket = maxp; | 2606 | ep->maxpacket = maxp; |
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index 613547f07828..e5f4c5274298 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c | |||
@@ -620,9 +620,9 @@ static inline void pch_udc_vbus_session(struct pch_udc_dev *dev, | |||
620 | dev->vbus_session = 1; | 620 | dev->vbus_session = 1; |
621 | } else { | 621 | } else { |
622 | if (dev->driver && dev->driver->disconnect) { | 622 | if (dev->driver && dev->driver->disconnect) { |
623 | spin_unlock(&dev->lock); | ||
624 | dev->driver->disconnect(&dev->gadget); | ||
625 | spin_lock(&dev->lock); | 623 | spin_lock(&dev->lock); |
624 | dev->driver->disconnect(&dev->gadget); | ||
625 | spin_unlock(&dev->lock); | ||
626 | } | 626 | } |
627 | pch_udc_set_disconnect(dev); | 627 | pch_udc_set_disconnect(dev); |
628 | dev->vbus_session = 0; | 628 | dev->vbus_session = 0; |
@@ -1191,9 +1191,9 @@ static int pch_udc_pcd_pullup(struct usb_gadget *gadget, int is_on) | |||
1191 | pch_udc_reconnect(dev); | 1191 | pch_udc_reconnect(dev); |
1192 | } else { | 1192 | } else { |
1193 | if (dev->driver && dev->driver->disconnect) { | 1193 | if (dev->driver && dev->driver->disconnect) { |
1194 | spin_unlock(&dev->lock); | ||
1195 | dev->driver->disconnect(&dev->gadget); | ||
1196 | spin_lock(&dev->lock); | 1194 | spin_lock(&dev->lock); |
1195 | dev->driver->disconnect(&dev->gadget); | ||
1196 | spin_unlock(&dev->lock); | ||
1197 | } | 1197 | } |
1198 | pch_udc_set_disconnect(dev); | 1198 | pch_udc_set_disconnect(dev); |
1199 | } | 1199 | } |
@@ -1488,11 +1488,11 @@ static void complete_req(struct pch_udc_ep *ep, struct pch_udc_request *req, | |||
1488 | req->dma_mapped = 0; | 1488 | req->dma_mapped = 0; |
1489 | } | 1489 | } |
1490 | ep->halted = 1; | 1490 | ep->halted = 1; |
1491 | spin_unlock(&dev->lock); | 1491 | spin_lock(&dev->lock); |
1492 | if (!ep->in) | 1492 | if (!ep->in) |
1493 | pch_udc_ep_clear_rrdy(ep); | 1493 | pch_udc_ep_clear_rrdy(ep); |
1494 | usb_gadget_giveback_request(&ep->ep, &req->req); | 1494 | usb_gadget_giveback_request(&ep->ep, &req->req); |
1495 | spin_lock(&dev->lock); | 1495 | spin_unlock(&dev->lock); |
1496 | ep->halted = halted; | 1496 | ep->halted = halted; |
1497 | } | 1497 | } |
1498 | 1498 | ||
@@ -1793,7 +1793,7 @@ static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep, | |||
1793 | } | 1793 | } |
1794 | /* prevent from using desc. - set HOST BUSY */ | 1794 | /* prevent from using desc. - set HOST BUSY */ |
1795 | dma_desc->status |= PCH_UDC_BS_HST_BSY; | 1795 | dma_desc->status |= PCH_UDC_BS_HST_BSY; |
1796 | dma_desc->dataptr = __constant_cpu_to_le32(DMA_ADDR_INVALID); | 1796 | dma_desc->dataptr = cpu_to_le32(DMA_ADDR_INVALID); |
1797 | req->td_data = dma_desc; | 1797 | req->td_data = dma_desc; |
1798 | req->td_data_last = dma_desc; | 1798 | req->td_data_last = dma_desc; |
1799 | req->chain_len = 1; | 1799 | req->chain_len = 1; |
@@ -2414,7 +2414,7 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev) | |||
2414 | dev->gadget.ep0 = &dev->ep[UDC_EP0IN_IDX].ep; | 2414 | dev->gadget.ep0 = &dev->ep[UDC_EP0IN_IDX].ep; |
2415 | else /* OUT */ | 2415 | else /* OUT */ |
2416 | dev->gadget.ep0 = &ep->ep; | 2416 | dev->gadget.ep0 = &ep->ep; |
2417 | spin_unlock(&dev->lock); | 2417 | spin_lock(&dev->lock); |
2418 | /* If Mass storage Reset */ | 2418 | /* If Mass storage Reset */ |
2419 | if ((dev->setup_data.bRequestType == 0x21) && | 2419 | if ((dev->setup_data.bRequestType == 0x21) && |
2420 | (dev->setup_data.bRequest == 0xFF)) | 2420 | (dev->setup_data.bRequest == 0xFF)) |
@@ -2422,7 +2422,7 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev) | |||
2422 | /* call gadget with setup data received */ | 2422 | /* call gadget with setup data received */ |
2423 | setup_supported = dev->driver->setup(&dev->gadget, | 2423 | setup_supported = dev->driver->setup(&dev->gadget, |
2424 | &dev->setup_data); | 2424 | &dev->setup_data); |
2425 | spin_lock(&dev->lock); | 2425 | spin_unlock(&dev->lock); |
2426 | 2426 | ||
2427 | if (dev->setup_data.bRequestType & USB_DIR_IN) { | 2427 | if (dev->setup_data.bRequestType & USB_DIR_IN) { |
2428 | ep->td_data->status = (ep->td_data->status & | 2428 | ep->td_data->status = (ep->td_data->status & |
@@ -2594,9 +2594,9 @@ static void pch_udc_svc_ur_interrupt(struct pch_udc_dev *dev) | |||
2594 | empty_req_queue(ep); | 2594 | empty_req_queue(ep); |
2595 | } | 2595 | } |
2596 | if (dev->driver) { | 2596 | if (dev->driver) { |
2597 | spin_unlock(&dev->lock); | ||
2598 | usb_gadget_udc_reset(&dev->gadget, dev->driver); | ||
2599 | spin_lock(&dev->lock); | 2597 | spin_lock(&dev->lock); |
2598 | usb_gadget_udc_reset(&dev->gadget, dev->driver); | ||
2599 | spin_unlock(&dev->lock); | ||
2600 | } | 2600 | } |
2601 | } | 2601 | } |
2602 | 2602 | ||
@@ -2675,9 +2675,9 @@ static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev) | |||
2675 | dev->ep[i].halted = 0; | 2675 | dev->ep[i].halted = 0; |
2676 | } | 2676 | } |
2677 | dev->stall = 0; | 2677 | dev->stall = 0; |
2678 | spin_unlock(&dev->lock); | ||
2679 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | ||
2680 | spin_lock(&dev->lock); | 2678 | spin_lock(&dev->lock); |
2679 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | ||
2680 | spin_unlock(&dev->lock); | ||
2681 | } | 2681 | } |
2682 | 2682 | ||
2683 | /** | 2683 | /** |
@@ -2712,9 +2712,9 @@ static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev) | |||
2712 | dev->stall = 0; | 2712 | dev->stall = 0; |
2713 | 2713 | ||
2714 | /* call gadget zero with setup data received */ | 2714 | /* call gadget zero with setup data received */ |
2715 | spin_unlock(&dev->lock); | ||
2716 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | ||
2717 | spin_lock(&dev->lock); | 2715 | spin_lock(&dev->lock); |
2716 | ret = dev->driver->setup(&dev->gadget, &dev->setup_data); | ||
2717 | spin_unlock(&dev->lock); | ||
2718 | } | 2718 | } |
2719 | 2719 | ||
2720 | /** | 2720 | /** |
@@ -2747,18 +2747,18 @@ static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr) | |||
2747 | if (dev_intr & UDC_DEVINT_US) { | 2747 | if (dev_intr & UDC_DEVINT_US) { |
2748 | if (dev->driver | 2748 | if (dev->driver |
2749 | && dev->driver->suspend) { | 2749 | && dev->driver->suspend) { |
2750 | spin_unlock(&dev->lock); | ||
2751 | dev->driver->suspend(&dev->gadget); | ||
2752 | spin_lock(&dev->lock); | 2750 | spin_lock(&dev->lock); |
2751 | dev->driver->suspend(&dev->gadget); | ||
2752 | spin_unlock(&dev->lock); | ||
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | vbus = pch_vbus_gpio_get_value(dev); | 2755 | vbus = pch_vbus_gpio_get_value(dev); |
2756 | if ((dev->vbus_session == 0) | 2756 | if ((dev->vbus_session == 0) |
2757 | && (vbus != 1)) { | 2757 | && (vbus != 1)) { |
2758 | if (dev->driver && dev->driver->disconnect) { | 2758 | if (dev->driver && dev->driver->disconnect) { |
2759 | spin_unlock(&dev->lock); | ||
2760 | dev->driver->disconnect(&dev->gadget); | ||
2761 | spin_lock(&dev->lock); | 2759 | spin_lock(&dev->lock); |
2760 | dev->driver->disconnect(&dev->gadget); | ||
2761 | spin_unlock(&dev->lock); | ||
2762 | } | 2762 | } |
2763 | pch_udc_reconnect(dev); | 2763 | pch_udc_reconnect(dev); |
2764 | } else if ((dev->vbus_session == 0) | 2764 | } else if ((dev->vbus_session == 0) |
@@ -2895,11 +2895,21 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev) | |||
2895 | ep->in = ~i & 1; | 2895 | ep->in = ~i & 1; |
2896 | ep->ep.name = ep_string[i]; | 2896 | ep->ep.name = ep_string[i]; |
2897 | ep->ep.ops = &pch_udc_ep_ops; | 2897 | ep->ep.ops = &pch_udc_ep_ops; |
2898 | if (ep->in) | 2898 | if (ep->in) { |
2899 | ep->offset_addr = ep->num * UDC_EP_REG_SHIFT; | 2899 | ep->offset_addr = ep->num * UDC_EP_REG_SHIFT; |
2900 | else | 2900 | ep->ep.caps.dir_in = true; |
2901 | } else { | ||
2901 | ep->offset_addr = (UDC_EPINT_OUT_SHIFT + ep->num) * | 2902 | ep->offset_addr = (UDC_EPINT_OUT_SHIFT + ep->num) * |
2902 | UDC_EP_REG_SHIFT; | 2903 | UDC_EP_REG_SHIFT; |
2904 | ep->ep.caps.dir_out = true; | ||
2905 | } | ||
2906 | if (i == UDC_EP0IN_IDX || i == UDC_EP0OUT_IDX) { | ||
2907 | ep->ep.caps.type_control = true; | ||
2908 | } else { | ||
2909 | ep->ep.caps.type_iso = true; | ||
2910 | ep->ep.caps.type_bulk = true; | ||
2911 | ep->ep.caps.type_int = true; | ||
2912 | } | ||
2903 | /* need to set ep->ep.maxpacket and set Default Configuration?*/ | 2913 | /* need to set ep->ep.maxpacket and set Default Configuration?*/ |
2904 | usb_ep_set_maxpacket_limit(&ep->ep, UDC_BULK_MAX_PKT_SIZE); | 2914 | usb_ep_set_maxpacket_limit(&ep->ep, UDC_BULK_MAX_PKT_SIZE); |
2905 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); | 2915 | list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list); |
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index f6cbe667ce39..b82cb14850b6 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c | |||
@@ -1176,6 +1176,7 @@ static void udc_reinit(struct pxa25x_udc *dev) | |||
1176 | INIT_LIST_HEAD (&dev->gadget.ep_list); | 1176 | INIT_LIST_HEAD (&dev->gadget.ep_list); |
1177 | INIT_LIST_HEAD (&dev->gadget.ep0->ep_list); | 1177 | INIT_LIST_HEAD (&dev->gadget.ep0->ep_list); |
1178 | dev->ep0state = EP0_IDLE; | 1178 | dev->ep0state = EP0_IDLE; |
1179 | dev->gadget.quirk_altset_not_supp = 1; | ||
1179 | 1180 | ||
1180 | /* basic endpoint records init */ | 1181 | /* basic endpoint records init */ |
1181 | for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { | 1182 | for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { |
@@ -1821,6 +1822,8 @@ static struct pxa25x_udc memory = { | |||
1821 | .name = ep0name, | 1822 | .name = ep0name, |
1822 | .ops = &pxa25x_ep_ops, | 1823 | .ops = &pxa25x_ep_ops, |
1823 | .maxpacket = EP0_FIFO_SIZE, | 1824 | .maxpacket = EP0_FIFO_SIZE, |
1825 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, | ||
1826 | USB_EP_CAPS_DIR_ALL), | ||
1824 | }, | 1827 | }, |
1825 | .dev = &memory, | 1828 | .dev = &memory, |
1826 | .reg_udccs = &UDCCS0, | 1829 | .reg_udccs = &UDCCS0, |
@@ -1833,6 +1836,8 @@ static struct pxa25x_udc memory = { | |||
1833 | .name = "ep1in-bulk", | 1836 | .name = "ep1in-bulk", |
1834 | .ops = &pxa25x_ep_ops, | 1837 | .ops = &pxa25x_ep_ops, |
1835 | .maxpacket = BULK_FIFO_SIZE, | 1838 | .maxpacket = BULK_FIFO_SIZE, |
1839 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1840 | USB_EP_CAPS_DIR_IN), | ||
1836 | }, | 1841 | }, |
1837 | .dev = &memory, | 1842 | .dev = &memory, |
1838 | .fifo_size = BULK_FIFO_SIZE, | 1843 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1846,6 +1851,8 @@ static struct pxa25x_udc memory = { | |||
1846 | .name = "ep2out-bulk", | 1851 | .name = "ep2out-bulk", |
1847 | .ops = &pxa25x_ep_ops, | 1852 | .ops = &pxa25x_ep_ops, |
1848 | .maxpacket = BULK_FIFO_SIZE, | 1853 | .maxpacket = BULK_FIFO_SIZE, |
1854 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1855 | USB_EP_CAPS_DIR_OUT), | ||
1849 | }, | 1856 | }, |
1850 | .dev = &memory, | 1857 | .dev = &memory, |
1851 | .fifo_size = BULK_FIFO_SIZE, | 1858 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1861,6 +1868,8 @@ static struct pxa25x_udc memory = { | |||
1861 | .name = "ep3in-iso", | 1868 | .name = "ep3in-iso", |
1862 | .ops = &pxa25x_ep_ops, | 1869 | .ops = &pxa25x_ep_ops, |
1863 | .maxpacket = ISO_FIFO_SIZE, | 1870 | .maxpacket = ISO_FIFO_SIZE, |
1871 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
1872 | USB_EP_CAPS_DIR_IN), | ||
1864 | }, | 1873 | }, |
1865 | .dev = &memory, | 1874 | .dev = &memory, |
1866 | .fifo_size = ISO_FIFO_SIZE, | 1875 | .fifo_size = ISO_FIFO_SIZE, |
@@ -1874,6 +1883,8 @@ static struct pxa25x_udc memory = { | |||
1874 | .name = "ep4out-iso", | 1883 | .name = "ep4out-iso", |
1875 | .ops = &pxa25x_ep_ops, | 1884 | .ops = &pxa25x_ep_ops, |
1876 | .maxpacket = ISO_FIFO_SIZE, | 1885 | .maxpacket = ISO_FIFO_SIZE, |
1886 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
1887 | USB_EP_CAPS_DIR_OUT), | ||
1877 | }, | 1888 | }, |
1878 | .dev = &memory, | 1889 | .dev = &memory, |
1879 | .fifo_size = ISO_FIFO_SIZE, | 1890 | .fifo_size = ISO_FIFO_SIZE, |
@@ -1888,6 +1899,7 @@ static struct pxa25x_udc memory = { | |||
1888 | .name = "ep5in-int", | 1899 | .name = "ep5in-int", |
1889 | .ops = &pxa25x_ep_ops, | 1900 | .ops = &pxa25x_ep_ops, |
1890 | .maxpacket = INT_FIFO_SIZE, | 1901 | .maxpacket = INT_FIFO_SIZE, |
1902 | .caps = USB_EP_CAPS(0, 0), | ||
1891 | }, | 1903 | }, |
1892 | .dev = &memory, | 1904 | .dev = &memory, |
1893 | .fifo_size = INT_FIFO_SIZE, | 1905 | .fifo_size = INT_FIFO_SIZE, |
@@ -1903,6 +1915,8 @@ static struct pxa25x_udc memory = { | |||
1903 | .name = "ep6in-bulk", | 1915 | .name = "ep6in-bulk", |
1904 | .ops = &pxa25x_ep_ops, | 1916 | .ops = &pxa25x_ep_ops, |
1905 | .maxpacket = BULK_FIFO_SIZE, | 1917 | .maxpacket = BULK_FIFO_SIZE, |
1918 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1919 | USB_EP_CAPS_DIR_IN), | ||
1906 | }, | 1920 | }, |
1907 | .dev = &memory, | 1921 | .dev = &memory, |
1908 | .fifo_size = BULK_FIFO_SIZE, | 1922 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1916,6 +1930,8 @@ static struct pxa25x_udc memory = { | |||
1916 | .name = "ep7out-bulk", | 1930 | .name = "ep7out-bulk", |
1917 | .ops = &pxa25x_ep_ops, | 1931 | .ops = &pxa25x_ep_ops, |
1918 | .maxpacket = BULK_FIFO_SIZE, | 1932 | .maxpacket = BULK_FIFO_SIZE, |
1933 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1934 | USB_EP_CAPS_DIR_OUT), | ||
1919 | }, | 1935 | }, |
1920 | .dev = &memory, | 1936 | .dev = &memory, |
1921 | .fifo_size = BULK_FIFO_SIZE, | 1937 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1930,6 +1946,8 @@ static struct pxa25x_udc memory = { | |||
1930 | .name = "ep8in-iso", | 1946 | .name = "ep8in-iso", |
1931 | .ops = &pxa25x_ep_ops, | 1947 | .ops = &pxa25x_ep_ops, |
1932 | .maxpacket = ISO_FIFO_SIZE, | 1948 | .maxpacket = ISO_FIFO_SIZE, |
1949 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
1950 | USB_EP_CAPS_DIR_IN), | ||
1933 | }, | 1951 | }, |
1934 | .dev = &memory, | 1952 | .dev = &memory, |
1935 | .fifo_size = ISO_FIFO_SIZE, | 1953 | .fifo_size = ISO_FIFO_SIZE, |
@@ -1943,6 +1961,8 @@ static struct pxa25x_udc memory = { | |||
1943 | .name = "ep9out-iso", | 1961 | .name = "ep9out-iso", |
1944 | .ops = &pxa25x_ep_ops, | 1962 | .ops = &pxa25x_ep_ops, |
1945 | .maxpacket = ISO_FIFO_SIZE, | 1963 | .maxpacket = ISO_FIFO_SIZE, |
1964 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
1965 | USB_EP_CAPS_DIR_OUT), | ||
1946 | }, | 1966 | }, |
1947 | .dev = &memory, | 1967 | .dev = &memory, |
1948 | .fifo_size = ISO_FIFO_SIZE, | 1968 | .fifo_size = ISO_FIFO_SIZE, |
@@ -1957,6 +1977,7 @@ static struct pxa25x_udc memory = { | |||
1957 | .name = "ep10in-int", | 1977 | .name = "ep10in-int", |
1958 | .ops = &pxa25x_ep_ops, | 1978 | .ops = &pxa25x_ep_ops, |
1959 | .maxpacket = INT_FIFO_SIZE, | 1979 | .maxpacket = INT_FIFO_SIZE, |
1980 | .caps = USB_EP_CAPS(0, 0), | ||
1960 | }, | 1981 | }, |
1961 | .dev = &memory, | 1982 | .dev = &memory, |
1962 | .fifo_size = INT_FIFO_SIZE, | 1983 | .fifo_size = INT_FIFO_SIZE, |
@@ -1972,6 +1993,8 @@ static struct pxa25x_udc memory = { | |||
1972 | .name = "ep11in-bulk", | 1993 | .name = "ep11in-bulk", |
1973 | .ops = &pxa25x_ep_ops, | 1994 | .ops = &pxa25x_ep_ops, |
1974 | .maxpacket = BULK_FIFO_SIZE, | 1995 | .maxpacket = BULK_FIFO_SIZE, |
1996 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1997 | USB_EP_CAPS_DIR_IN), | ||
1975 | }, | 1998 | }, |
1976 | .dev = &memory, | 1999 | .dev = &memory, |
1977 | .fifo_size = BULK_FIFO_SIZE, | 2000 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1985,6 +2008,8 @@ static struct pxa25x_udc memory = { | |||
1985 | .name = "ep12out-bulk", | 2008 | .name = "ep12out-bulk", |
1986 | .ops = &pxa25x_ep_ops, | 2009 | .ops = &pxa25x_ep_ops, |
1987 | .maxpacket = BULK_FIFO_SIZE, | 2010 | .maxpacket = BULK_FIFO_SIZE, |
2011 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
2012 | USB_EP_CAPS_DIR_OUT), | ||
1988 | }, | 2013 | }, |
1989 | .dev = &memory, | 2014 | .dev = &memory, |
1990 | .fifo_size = BULK_FIFO_SIZE, | 2015 | .fifo_size = BULK_FIFO_SIZE, |
@@ -1999,6 +2024,8 @@ static struct pxa25x_udc memory = { | |||
1999 | .name = "ep13in-iso", | 2024 | .name = "ep13in-iso", |
2000 | .ops = &pxa25x_ep_ops, | 2025 | .ops = &pxa25x_ep_ops, |
2001 | .maxpacket = ISO_FIFO_SIZE, | 2026 | .maxpacket = ISO_FIFO_SIZE, |
2027 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2028 | USB_EP_CAPS_DIR_IN), | ||
2002 | }, | 2029 | }, |
2003 | .dev = &memory, | 2030 | .dev = &memory, |
2004 | .fifo_size = ISO_FIFO_SIZE, | 2031 | .fifo_size = ISO_FIFO_SIZE, |
@@ -2012,6 +2039,8 @@ static struct pxa25x_udc memory = { | |||
2012 | .name = "ep14out-iso", | 2039 | .name = "ep14out-iso", |
2013 | .ops = &pxa25x_ep_ops, | 2040 | .ops = &pxa25x_ep_ops, |
2014 | .maxpacket = ISO_FIFO_SIZE, | 2041 | .maxpacket = ISO_FIFO_SIZE, |
2042 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, | ||
2043 | USB_EP_CAPS_DIR_OUT), | ||
2015 | }, | 2044 | }, |
2016 | .dev = &memory, | 2045 | .dev = &memory, |
2017 | .fifo_size = ISO_FIFO_SIZE, | 2046 | .fifo_size = ISO_FIFO_SIZE, |
@@ -2026,6 +2055,7 @@ static struct pxa25x_udc memory = { | |||
2026 | .name = "ep15in-int", | 2055 | .name = "ep15in-int", |
2027 | .ops = &pxa25x_ep_ops, | 2056 | .ops = &pxa25x_ep_ops, |
2028 | .maxpacket = INT_FIFO_SIZE, | 2057 | .maxpacket = INT_FIFO_SIZE, |
2058 | .caps = USB_EP_CAPS(0, 0), | ||
2029 | }, | 2059 | }, |
2030 | .dev = &memory, | 2060 | .dev = &memory, |
2031 | .fifo_size = INT_FIFO_SIZE, | 2061 | .fifo_size = INT_FIFO_SIZE, |
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index b51226abade6..670ac0b12f00 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c | |||
@@ -1710,6 +1710,7 @@ static void udc_init_data(struct pxa_udc *dev) | |||
1710 | INIT_LIST_HEAD(&dev->gadget.ep_list); | 1710 | INIT_LIST_HEAD(&dev->gadget.ep_list); |
1711 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); | 1711 | INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); |
1712 | dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; | 1712 | dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; |
1713 | dev->gadget.quirk_altset_not_supp = 1; | ||
1713 | ep0_idle(dev); | 1714 | ep0_idle(dev); |
1714 | 1715 | ||
1715 | /* PXA endpoints init */ | 1716 | /* PXA endpoints init */ |
@@ -2422,7 +2423,7 @@ static int pxa_udc_probe(struct platform_device *pdev) | |||
2422 | } | 2423 | } |
2423 | udc->udc_command = mach->udc_command; | 2424 | udc->udc_command = mach->udc_command; |
2424 | } else { | 2425 | } else { |
2425 | udc->gpiod = devm_gpiod_get(&pdev->dev, NULL); | 2426 | udc->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); |
2426 | } | 2427 | } |
2427 | 2428 | ||
2428 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2429 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h index 11e14232794b..cea2cb79b30c 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.h +++ b/drivers/usb/gadget/udc/pxa27x_udc.h | |||
@@ -234,25 +234,35 @@ | |||
234 | /* | 234 | /* |
235 | * Endpoint definition helpers | 235 | * Endpoint definition helpers |
236 | */ | 236 | */ |
237 | #define USB_EP_DEF(addr, bname, dir, type, maxpkt) \ | 237 | #define USB_EP_DEF(addr, bname, dir, type, maxpkt, ctype, cdir) \ |
238 | { .usb_ep = { .name = bname, .ops = &pxa_ep_ops, .maxpacket = maxpkt, }, \ | 238 | { .usb_ep = { .name = bname, .ops = &pxa_ep_ops, .maxpacket = maxpkt, \ |
239 | .caps = USB_EP_CAPS(ctype, cdir), }, \ | ||
239 | .desc = { .bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ | 240 | .desc = { .bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ |
240 | .bmAttributes = type, \ | 241 | .bmAttributes = USB_ENDPOINT_XFER_ ## type, \ |
241 | .wMaxPacketSize = maxpkt, }, \ | 242 | .wMaxPacketSize = maxpkt, }, \ |
242 | .dev = &memory \ | 243 | .dev = &memory \ |
243 | } | 244 | } |
244 | #define USB_EP_BULK(addr, bname, dir) \ | 245 | #define USB_EP_BULK(addr, bname, dir, cdir) \ |
245 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE) | 246 | USB_EP_DEF(addr, bname, dir, BULK, BULK_FIFO_SIZE, \ |
246 | #define USB_EP_ISO(addr, bname, dir) \ | 247 | USB_EP_CAPS_TYPE_BULK, cdir) |
247 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE) | 248 | #define USB_EP_ISO(addr, bname, dir, cdir) \ |
248 | #define USB_EP_INT(addr, bname, dir) \ | 249 | USB_EP_DEF(addr, bname, dir, ISOC, ISO_FIFO_SIZE, \ |
249 | USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE) | 250 | USB_EP_CAPS_TYPE_ISO, cdir) |
250 | #define USB_EP_IN_BULK(n) USB_EP_BULK(n, "ep" #n "in-bulk", 1) | 251 | #define USB_EP_INT(addr, bname, dir, cdir) \ |
251 | #define USB_EP_OUT_BULK(n) USB_EP_BULK(n, "ep" #n "out-bulk", 0) | 252 | USB_EP_DEF(addr, bname, dir, INT, INT_FIFO_SIZE, \ |
252 | #define USB_EP_IN_ISO(n) USB_EP_ISO(n, "ep" #n "in-iso", 1) | 253 | USB_EP_CAPS_TYPE_INT, cdir) |
253 | #define USB_EP_OUT_ISO(n) USB_EP_ISO(n, "ep" #n "out-iso", 0) | 254 | #define USB_EP_IN_BULK(n) USB_EP_BULK(n, "ep" #n "in-bulk", 1, \ |
254 | #define USB_EP_IN_INT(n) USB_EP_INT(n, "ep" #n "in-int", 1) | 255 | USB_EP_CAPS_DIR_IN) |
255 | #define USB_EP_CTRL USB_EP_DEF(0, "ep0", 0, 0, EP0_FIFO_SIZE) | 256 | #define USB_EP_OUT_BULK(n) USB_EP_BULK(n, "ep" #n "out-bulk", 0, \ |
257 | USB_EP_CAPS_DIR_OUT) | ||
258 | #define USB_EP_IN_ISO(n) USB_EP_ISO(n, "ep" #n "in-iso", 1, \ | ||
259 | USB_EP_CAPS_DIR_IN) | ||
260 | #define USB_EP_OUT_ISO(n) USB_EP_ISO(n, "ep" #n "out-iso", 0, \ | ||
261 | USB_EP_CAPS_DIR_OUT) | ||
262 | #define USB_EP_IN_INT(n) USB_EP_INT(n, "ep" #n "in-int", 1, \ | ||
263 | USB_EP_CAPS_DIR_IN) | ||
264 | #define USB_EP_CTRL USB_EP_DEF(0, "ep0", 0, CONTROL, EP0_FIFO_SIZE, \ | ||
265 | USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL) | ||
256 | 266 | ||
257 | #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ | 267 | #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ |
258 | { \ | 268 | { \ |
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 0293f7169dee..baa0609a429d 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c | |||
@@ -1935,6 +1935,16 @@ static int r8a66597_probe(struct platform_device *pdev) | |||
1935 | ep->ep.name = r8a66597_ep_name[i]; | 1935 | ep->ep.name = r8a66597_ep_name[i]; |
1936 | ep->ep.ops = &r8a66597_ep_ops; | 1936 | ep->ep.ops = &r8a66597_ep_ops; |
1937 | usb_ep_set_maxpacket_limit(&ep->ep, 512); | 1937 | usb_ep_set_maxpacket_limit(&ep->ep, 512); |
1938 | |||
1939 | if (i == 0) { | ||
1940 | ep->ep.caps.type_control = true; | ||
1941 | } else { | ||
1942 | ep->ep.caps.type_iso = true; | ||
1943 | ep->ep.caps.type_bulk = true; | ||
1944 | ep->ep.caps.type_int = true; | ||
1945 | } | ||
1946 | ep->ep.caps.dir_in = true; | ||
1947 | ep->ep.caps.dir_out = true; | ||
1938 | } | 1948 | } |
1939 | usb_ep_set_maxpacket_limit(&r8a66597->ep[0].ep, 64); | 1949 | usb_ep_set_maxpacket_limit(&r8a66597->ep[0].ep, 64); |
1940 | r8a66597->ep[0].pipenum = 0; | 1950 | r8a66597->ep[0].pipenum = 0; |
diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c index 85a712a03343..e9def42ce50d 100644 --- a/drivers/usb/gadget/udc/s3c-hsudc.c +++ b/drivers/usb/gadget/udc/s3c-hsudc.c | |||
@@ -1005,6 +1005,21 @@ static void s3c_hsudc_initep(struct s3c_hsudc *hsudc, | |||
1005 | hsep->stopped = 0; | 1005 | hsep->stopped = 0; |
1006 | hsep->wedge = 0; | 1006 | hsep->wedge = 0; |
1007 | 1007 | ||
1008 | if (epnum == 0) { | ||
1009 | hsep->ep.caps.type_control = true; | ||
1010 | hsep->ep.caps.dir_in = true; | ||
1011 | hsep->ep.caps.dir_out = true; | ||
1012 | } else { | ||
1013 | hsep->ep.caps.type_iso = true; | ||
1014 | hsep->ep.caps.type_bulk = true; | ||
1015 | hsep->ep.caps.type_int = true; | ||
1016 | } | ||
1017 | |||
1018 | if (epnum & 1) | ||
1019 | hsep->ep.caps.dir_in = true; | ||
1020 | else | ||
1021 | hsep->ep.caps.dir_out = true; | ||
1022 | |||
1008 | set_index(hsudc, epnum); | 1023 | set_index(hsudc, epnum); |
1009 | writel(hsep->ep.maxpacket, hsudc->regs + S3C_MPR); | 1024 | writel(hsep->ep.maxpacket, hsudc->regs + S3C_MPR); |
1010 | } | 1025 | } |
diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c index 5d9aa81969b4..eb3571ee59e3 100644 --- a/drivers/usb/gadget/udc/s3c2410_udc.c +++ b/drivers/usb/gadget/udc/s3c2410_udc.c | |||
@@ -1691,6 +1691,8 @@ static struct s3c2410_udc memory = { | |||
1691 | .name = ep0name, | 1691 | .name = ep0name, |
1692 | .ops = &s3c2410_ep_ops, | 1692 | .ops = &s3c2410_ep_ops, |
1693 | .maxpacket = EP0_FIFO_SIZE, | 1693 | .maxpacket = EP0_FIFO_SIZE, |
1694 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, | ||
1695 | USB_EP_CAPS_DIR_ALL), | ||
1694 | }, | 1696 | }, |
1695 | .dev = &memory, | 1697 | .dev = &memory, |
1696 | }, | 1698 | }, |
@@ -1702,6 +1704,8 @@ static struct s3c2410_udc memory = { | |||
1702 | .name = "ep1-bulk", | 1704 | .name = "ep1-bulk", |
1703 | .ops = &s3c2410_ep_ops, | 1705 | .ops = &s3c2410_ep_ops, |
1704 | .maxpacket = EP_FIFO_SIZE, | 1706 | .maxpacket = EP_FIFO_SIZE, |
1707 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1708 | USB_EP_CAPS_DIR_ALL), | ||
1705 | }, | 1709 | }, |
1706 | .dev = &memory, | 1710 | .dev = &memory, |
1707 | .fifo_size = EP_FIFO_SIZE, | 1711 | .fifo_size = EP_FIFO_SIZE, |
@@ -1714,6 +1718,8 @@ static struct s3c2410_udc memory = { | |||
1714 | .name = "ep2-bulk", | 1718 | .name = "ep2-bulk", |
1715 | .ops = &s3c2410_ep_ops, | 1719 | .ops = &s3c2410_ep_ops, |
1716 | .maxpacket = EP_FIFO_SIZE, | 1720 | .maxpacket = EP_FIFO_SIZE, |
1721 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1722 | USB_EP_CAPS_DIR_ALL), | ||
1717 | }, | 1723 | }, |
1718 | .dev = &memory, | 1724 | .dev = &memory, |
1719 | .fifo_size = EP_FIFO_SIZE, | 1725 | .fifo_size = EP_FIFO_SIZE, |
@@ -1726,6 +1732,8 @@ static struct s3c2410_udc memory = { | |||
1726 | .name = "ep3-bulk", | 1732 | .name = "ep3-bulk", |
1727 | .ops = &s3c2410_ep_ops, | 1733 | .ops = &s3c2410_ep_ops, |
1728 | .maxpacket = EP_FIFO_SIZE, | 1734 | .maxpacket = EP_FIFO_SIZE, |
1735 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1736 | USB_EP_CAPS_DIR_ALL), | ||
1729 | }, | 1737 | }, |
1730 | .dev = &memory, | 1738 | .dev = &memory, |
1731 | .fifo_size = EP_FIFO_SIZE, | 1739 | .fifo_size = EP_FIFO_SIZE, |
@@ -1738,6 +1746,8 @@ static struct s3c2410_udc memory = { | |||
1738 | .name = "ep4-bulk", | 1746 | .name = "ep4-bulk", |
1739 | .ops = &s3c2410_ep_ops, | 1747 | .ops = &s3c2410_ep_ops, |
1740 | .maxpacket = EP_FIFO_SIZE, | 1748 | .maxpacket = EP_FIFO_SIZE, |
1749 | .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, | ||
1750 | USB_EP_CAPS_DIR_ALL), | ||
1741 | }, | 1751 | }, |
1742 | .dev = &memory, | 1752 | .dev = &memory, |
1743 | .fifo_size = EP_FIFO_SIZE, | 1753 | .fifo_size = EP_FIFO_SIZE, |
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 89ed5e71a199..f660afba715d 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c | |||
@@ -131,6 +131,96 @@ EXPORT_SYMBOL_GPL(usb_gadget_giveback_request); | |||
131 | 131 | ||
132 | /* ------------------------------------------------------------------------- */ | 132 | /* ------------------------------------------------------------------------- */ |
133 | 133 | ||
134 | /** | ||
135 | * gadget_find_ep_by_name - returns ep whose name is the same as sting passed | ||
136 | * in second parameter or NULL if searched endpoint not found | ||
137 | * @g: controller to check for quirk | ||
138 | * @name: name of searched endpoint | ||
139 | */ | ||
140 | struct usb_ep *gadget_find_ep_by_name(struct usb_gadget *g, const char *name) | ||
141 | { | ||
142 | struct usb_ep *ep; | ||
143 | |||
144 | gadget_for_each_ep(ep, g) { | ||
145 | if (!strcmp(ep->name, name)) | ||
146 | return ep; | ||
147 | } | ||
148 | |||
149 | return NULL; | ||
150 | } | ||
151 | EXPORT_SYMBOL_GPL(gadget_find_ep_by_name); | ||
152 | |||
153 | /* ------------------------------------------------------------------------- */ | ||
154 | |||
155 | int usb_gadget_ep_match_desc(struct usb_gadget *gadget, | ||
156 | struct usb_ep *ep, struct usb_endpoint_descriptor *desc, | ||
157 | struct usb_ss_ep_comp_descriptor *ep_comp) | ||
158 | { | ||
159 | u8 type; | ||
160 | u16 max; | ||
161 | int num_req_streams = 0; | ||
162 | |||
163 | /* endpoint already claimed? */ | ||
164 | if (ep->claimed) | ||
165 | return 0; | ||
166 | |||
167 | type = usb_endpoint_type(desc); | ||
168 | max = 0x7ff & usb_endpoint_maxp(desc); | ||
169 | |||
170 | if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in) | ||
171 | return 0; | ||
172 | if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out) | ||
173 | return 0; | ||
174 | |||
175 | if (max > ep->maxpacket_limit) | ||
176 | return 0; | ||
177 | |||
178 | /* "high bandwidth" works only at high speed */ | ||
179 | if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp(desc) & (3<<11)) | ||
180 | return 0; | ||
181 | |||
182 | switch (type) { | ||
183 | case USB_ENDPOINT_XFER_CONTROL: | ||
184 | /* only support ep0 for portable CONTROL traffic */ | ||
185 | return 0; | ||
186 | case USB_ENDPOINT_XFER_ISOC: | ||
187 | if (!ep->caps.type_iso) | ||
188 | return 0; | ||
189 | /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ | ||
190 | if (!gadget_is_dualspeed(gadget) && max > 1023) | ||
191 | return 0; | ||
192 | break; | ||
193 | case USB_ENDPOINT_XFER_BULK: | ||
194 | if (!ep->caps.type_bulk) | ||
195 | return 0; | ||
196 | if (ep_comp && gadget_is_superspeed(gadget)) { | ||
197 | /* Get the number of required streams from the | ||
198 | * EP companion descriptor and see if the EP | ||
199 | * matches it | ||
200 | */ | ||
201 | num_req_streams = ep_comp->bmAttributes & 0x1f; | ||
202 | if (num_req_streams > ep->max_streams) | ||
203 | return 0; | ||
204 | } | ||
205 | break; | ||
206 | case USB_ENDPOINT_XFER_INT: | ||
207 | /* Bulk endpoints handle interrupt transfers, | ||
208 | * except the toggle-quirky iso-synch kind | ||
209 | */ | ||
210 | if (!ep->caps.type_int && !ep->caps.type_bulk) | ||
211 | return 0; | ||
212 | /* INT: limit 64 bytes full speed, 1024 high/super speed */ | ||
213 | if (!gadget_is_dualspeed(gadget) && max > 64) | ||
214 | return 0; | ||
215 | break; | ||
216 | } | ||
217 | |||
218 | return 1; | ||
219 | } | ||
220 | EXPORT_SYMBOL_GPL(usb_gadget_ep_match_desc); | ||
221 | |||
222 | /* ------------------------------------------------------------------------- */ | ||
223 | |||
134 | static void usb_gadget_state_work(struct work_struct *work) | 224 | static void usb_gadget_state_work(struct work_struct *work) |
135 | { | 225 | { |
136 | struct usb_gadget *gadget = work_to_gadget(work); | 226 | struct usb_gadget *gadget = work_to_gadget(work); |
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 1f24274477ab..1cbb0ac6b182 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c | |||
@@ -1317,12 +1317,21 @@ static void xudc_eps_init(struct xusb_udc *udc) | |||
1317 | snprintf(ep->name, EPNAME_SIZE, "ep%d", ep_number); | 1317 | snprintf(ep->name, EPNAME_SIZE, "ep%d", ep_number); |
1318 | ep->ep_usb.name = ep->name; | 1318 | ep->ep_usb.name = ep->name; |
1319 | ep->ep_usb.ops = &xusb_ep_ops; | 1319 | ep->ep_usb.ops = &xusb_ep_ops; |
1320 | |||
1321 | ep->ep_usb.caps.type_iso = true; | ||
1322 | ep->ep_usb.caps.type_bulk = true; | ||
1323 | ep->ep_usb.caps.type_int = true; | ||
1320 | } else { | 1324 | } else { |
1321 | ep->ep_usb.name = ep0name; | 1325 | ep->ep_usb.name = ep0name; |
1322 | usb_ep_set_maxpacket_limit(&ep->ep_usb, EP0_MAX_PACKET); | 1326 | usb_ep_set_maxpacket_limit(&ep->ep_usb, EP0_MAX_PACKET); |
1323 | ep->ep_usb.ops = &xusb_ep0_ops; | 1327 | ep->ep_usb.ops = &xusb_ep0_ops; |
1328 | |||
1329 | ep->ep_usb.caps.type_control = true; | ||
1324 | } | 1330 | } |
1325 | 1331 | ||
1332 | ep->ep_usb.caps.dir_in = true; | ||
1333 | ep->ep_usb.caps.dir_out = true; | ||
1334 | |||
1326 | ep->udc = udc; | 1335 | ep->udc = udc; |
1327 | ep->epnumber = ep_number; | 1336 | ep->epnumber = ep_number; |
1328 | ep->desc = NULL; | 1337 | ep->desc = NULL; |
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 18ebf5b1f256..1c3d0fd658fa 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c | |||
@@ -1382,14 +1382,25 @@ static void isp1760_udc_init_eps(struct isp1760_udc *udc) | |||
1382 | * This fits in the 8kB FIFO without double-buffering. | 1382 | * This fits in the 8kB FIFO without double-buffering. |
1383 | */ | 1383 | */ |
1384 | if (ep_num == 0) { | 1384 | if (ep_num == 0) { |
1385 | ep->ep.maxpacket = 64; | 1385 | usb_ep_set_maxpacket_limit(&ep->ep, 64); |
1386 | ep->ep.caps.type_control = true; | ||
1387 | ep->ep.caps.dir_in = true; | ||
1388 | ep->ep.caps.dir_out = true; | ||
1386 | ep->maxpacket = 64; | 1389 | ep->maxpacket = 64; |
1387 | udc->gadget.ep0 = &ep->ep; | 1390 | udc->gadget.ep0 = &ep->ep; |
1388 | } else { | 1391 | } else { |
1389 | ep->ep.maxpacket = 512; | 1392 | usb_ep_set_maxpacket_limit(&ep->ep, 512); |
1393 | ep->ep.caps.type_iso = true; | ||
1394 | ep->ep.caps.type_bulk = true; | ||
1395 | ep->ep.caps.type_int = true; | ||
1390 | ep->maxpacket = 0; | 1396 | ep->maxpacket = 0; |
1391 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | 1397 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); |
1392 | } | 1398 | } |
1399 | |||
1400 | if (is_in) | ||
1401 | ep->ep.caps.dir_in = true; | ||
1402 | else | ||
1403 | ep->ep.caps.dir_out = true; | ||
1393 | } | 1404 | } |
1394 | } | 1405 | } |
1395 | 1406 | ||
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 39db8b603627..1f2037bbeb0d 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller | 6 | # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller |
7 | config USB_MUSB_HDRC | 7 | config USB_MUSB_HDRC |
8 | tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' | 8 | tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)' |
9 | depends on (USB || USB_GADGET) | 9 | depends on (USB || USB_GADGET) |
10 | help | 10 | help |
11 | Say Y here if your system has a dual role high speed USB | 11 | Say Y here if your system has a dual role high speed USB |
@@ -20,6 +20,8 @@ config USB_MUSB_HDRC | |||
20 | Analog Devices parts using this IP include Blackfin BF54x, | 20 | Analog Devices parts using this IP include Blackfin BF54x, |
21 | BF525 and BF527. | 21 | BF525 and BF527. |
22 | 22 | ||
23 | Allwinner SoCs using this IP include A10, A13, A20, ... | ||
24 | |||
23 | If you do not know what this is, please say N. | 25 | If you do not know what this is, please say N. |
24 | 26 | ||
25 | To compile this driver as a module, choose M here; the | 27 | To compile this driver as a module, choose M here; the |
@@ -60,6 +62,15 @@ endchoice | |||
60 | 62 | ||
61 | comment "Platform Glue Layer" | 63 | comment "Platform Glue Layer" |
62 | 64 | ||
65 | config USB_MUSB_SUNXI | ||
66 | tristate "Allwinner (sunxi)" | ||
67 | depends on ARCH_SUNXI | ||
68 | depends on NOP_USB_XCEIV | ||
69 | depends on PHY_SUN4I_USB | ||
70 | depends on EXTCON | ||
71 | depends on GENERIC_PHY | ||
72 | select SUNXI_SRAM | ||
73 | |||
63 | config USB_MUSB_DAVINCI | 74 | config USB_MUSB_DAVINCI |
64 | tristate "DaVinci" | 75 | tristate "DaVinci" |
65 | depends on ARCH_DAVINCI_DMx | 76 | depends on ARCH_DAVINCI_DMx |
@@ -113,19 +124,20 @@ config USB_MUSB_JZ4740 | |||
113 | config USB_MUSB_AM335X_CHILD | 124 | config USB_MUSB_AM335X_CHILD |
114 | tristate | 125 | tristate |
115 | 126 | ||
116 | choice | 127 | comment "MUSB DMA mode" |
117 | prompt 'MUSB DMA mode' | 128 | |
118 | default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM || USB_MUSB_JZ4740 | 129 | config MUSB_PIO_ONLY |
119 | default USB_UX500_DMA if USB_MUSB_UX500 | 130 | bool 'Disable DMA (always use PIO)' |
120 | default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN | ||
121 | default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI | ||
122 | default USB_TUSB_OMAP_DMA if USB_MUSB_TUSB6010 | ||
123 | default MUSB_PIO_ONLY if USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X \ | ||
124 | || USB_MUSB_DSPS | ||
125 | help | 131 | help |
126 | Unfortunately, only one option can be enabled here. Ideally one | 132 | All data is copied between memory and FIFO by the CPU. |
127 | should be able to build all these drivers into one kernel to | 133 | DMA controllers are ignored. |
128 | allow using DMA on multiplatform kernels. | 134 | |
135 | Do not choose this unless DMA support for your SOC or board | ||
136 | is unavailable (or unstable). When DMA is enabled at compile time, | ||
137 | you can still disable it at run time using the "use_dma=n" module | ||
138 | parameter. | ||
139 | |||
140 | if !MUSB_PIO_ONLY | ||
129 | 141 | ||
130 | config USB_UX500_DMA | 142 | config USB_UX500_DMA |
131 | bool 'ST Ericsson Ux500' | 143 | bool 'ST Ericsson Ux500' |
@@ -157,17 +169,6 @@ config USB_TUSB_OMAP_DMA | |||
157 | help | 169 | help |
158 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. | 170 | Enable DMA transfers on TUSB 6010 when OMAP DMA is available. |
159 | 171 | ||
160 | config MUSB_PIO_ONLY | 172 | endif # !MUSB_PIO_ONLY |
161 | bool 'Disable DMA (always use PIO)' | ||
162 | help | ||
163 | All data is copied between memory and FIFO by the CPU. | ||
164 | DMA controllers are ignored. | ||
165 | |||
166 | Do not choose this unless DMA support for your SOC or board | ||
167 | is unavailable (or unstable). When DMA is enabled at compile time, | ||
168 | you can still disable it at run time using the "use_dma=n" module | ||
169 | parameter. | ||
170 | |||
171 | endchoice | ||
172 | 173 | ||
173 | endif # USB_MUSB_HDRC | 174 | endif # USB_MUSB_HDRC |
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index ba495018b416..f95befe18cc1 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile | |||
@@ -20,6 +20,7 @@ obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o | |||
20 | obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o | 20 | obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o |
21 | obj-$(CONFIG_USB_MUSB_UX500) += ux500.o | 21 | obj-$(CONFIG_USB_MUSB_UX500) += ux500.o |
22 | obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o | 22 | obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o |
23 | obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o | ||
23 | 24 | ||
24 | 25 | ||
25 | obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o | 26 | obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o |
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 4d1b44c232ee..d07cafb7d5f5 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c | |||
@@ -614,7 +614,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) | |||
614 | { | 614 | { |
615 | struct musb *musb = controller->musb; | 615 | struct musb *musb = controller->musb; |
616 | struct device *dev = musb->controller; | 616 | struct device *dev = musb->controller; |
617 | struct device_node *np = dev->of_node; | 617 | struct device_node *np = dev->parent->of_node; |
618 | struct cppi41_dma_channel *cppi41_channel; | 618 | struct cppi41_dma_channel *cppi41_channel; |
619 | int count; | 619 | int count; |
620 | int i; | 620 | int i; |
@@ -664,7 +664,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) | |||
664 | musb_dma->status = MUSB_DMA_STATUS_FREE; | 664 | musb_dma->status = MUSB_DMA_STATUS_FREE; |
665 | musb_dma->max_len = SZ_4M; | 665 | musb_dma->max_len = SZ_4M; |
666 | 666 | ||
667 | dc = dma_request_slave_channel(dev, str); | 667 | dc = dma_request_slave_channel(dev->parent, str); |
668 | if (!dc) { | 668 | if (!dc) { |
669 | dev_err(dev, "Failed to request %s.\n", str); | 669 | dev_err(dev, "Failed to request %s.\n", str); |
670 | ret = -EPROBE_DEFER; | 670 | ret = -EPROBE_DEFER; |
@@ -695,7 +695,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) | |||
695 | struct cppi41_dma_controller *controller; | 695 | struct cppi41_dma_controller *controller; |
696 | int ret = 0; | 696 | int ret = 0; |
697 | 697 | ||
698 | if (!musb->controller->of_node) { | 698 | if (!musb->controller->parent->of_node) { |
699 | dev_err(musb->controller, "Need DT for the DMA engine.\n"); | 699 | dev_err(musb->controller, "Need DT for the DMA engine.\n"); |
700 | return NULL; | 700 | return NULL; |
701 | } | 701 | } |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 625d482f1a97..67ad630c86c9 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -313,8 +313,7 @@ static void txstate(struct musb *musb, struct musb_request *req) | |||
313 | 313 | ||
314 | /* MUSB_TXCSR_P_ISO is still set correctly */ | 314 | /* MUSB_TXCSR_P_ISO is still set correctly */ |
315 | 315 | ||
316 | #if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) | 316 | if (musb_dma_inventra(musb) || musb_dma_ux500(musb)) { |
317 | { | ||
318 | if (request_size < musb_ep->packet_sz) | 317 | if (request_size < musb_ep->packet_sz) |
319 | musb_ep->dma->desired_mode = 0; | 318 | musb_ep->dma->desired_mode = 0; |
320 | else | 319 | else |
@@ -365,7 +364,6 @@ static void txstate(struct musb *musb, struct musb_request *req) | |||
365 | } | 364 | } |
366 | } | 365 | } |
367 | 366 | ||
368 | #endif | ||
369 | if (is_cppi_enabled(musb)) { | 367 | if (is_cppi_enabled(musb)) { |
370 | /* program endpoint CSR first, then setup DMA */ | 368 | /* program endpoint CSR first, then setup DMA */ |
371 | csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); | 369 | csr &= ~(MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); |
@@ -641,8 +639,10 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
641 | use_mode_1 = 0; | 639 | use_mode_1 = 0; |
642 | 640 | ||
643 | if (request->actual < request->length) { | 641 | if (request->actual < request->length) { |
644 | #ifdef CONFIG_USB_INVENTRA_DMA | 642 | if (!is_buffer_mapped(req)) |
645 | if (is_buffer_mapped(req)) { | 643 | goto buffer_aint_mapped; |
644 | |||
645 | if (musb_dma_inventra(musb)) { | ||
646 | struct dma_controller *c; | 646 | struct dma_controller *c; |
647 | struct dma_channel *channel; | 647 | struct dma_channel *channel; |
648 | int use_dma = 0; | 648 | int use_dma = 0; |
@@ -716,8 +716,8 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
716 | if (use_dma) | 716 | if (use_dma) |
717 | return; | 717 | return; |
718 | } | 718 | } |
719 | #elif defined(CONFIG_USB_UX500_DMA) | 719 | |
720 | if ((is_buffer_mapped(req)) && | 720 | if ((musb_dma_ux500(musb)) && |
721 | (request->actual < request->length)) { | 721 | (request->actual < request->length)) { |
722 | 722 | ||
723 | struct dma_controller *c; | 723 | struct dma_controller *c; |
@@ -765,7 +765,6 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
765 | 765 | ||
766 | return; | 766 | return; |
767 | } | 767 | } |
768 | #endif /* Mentor's DMA */ | ||
769 | 768 | ||
770 | len = request->length - request->actual; | 769 | len = request->length - request->actual; |
771 | dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", | 770 | dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", |
@@ -775,8 +774,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
775 | 774 | ||
776 | fifo_count = min_t(unsigned, len, fifo_count); | 775 | fifo_count = min_t(unsigned, len, fifo_count); |
777 | 776 | ||
778 | #ifdef CONFIG_USB_TUSB_OMAP_DMA | 777 | if (tusb_dma_omap(musb)) { |
779 | if (tusb_dma_omap(musb) && is_buffer_mapped(req)) { | ||
780 | struct dma_controller *c = musb->dma_controller; | 778 | struct dma_controller *c = musb->dma_controller; |
781 | struct dma_channel *channel = musb_ep->dma; | 779 | struct dma_channel *channel = musb_ep->dma; |
782 | u32 dma_addr = request->dma + request->actual; | 780 | u32 dma_addr = request->dma + request->actual; |
@@ -790,23 +788,22 @@ static void rxstate(struct musb *musb, struct musb_request *req) | |||
790 | if (ret) | 788 | if (ret) |
791 | return; | 789 | return; |
792 | } | 790 | } |
793 | #endif | 791 | |
794 | /* | 792 | /* |
795 | * Unmap the dma buffer back to cpu if dma channel | 793 | * Unmap the dma buffer back to cpu if dma channel |
796 | * programming fails. This buffer is mapped if the | 794 | * programming fails. This buffer is mapped if the |
797 | * channel allocation is successful | 795 | * channel allocation is successful |
798 | */ | 796 | */ |
799 | if (is_buffer_mapped(req)) { | 797 | unmap_dma_buffer(req, musb); |
800 | unmap_dma_buffer(req, musb); | ||
801 | |||
802 | /* | ||
803 | * Clear DMAENAB and AUTOCLEAR for the | ||
804 | * PIO mode transfer | ||
805 | */ | ||
806 | csr &= ~(MUSB_RXCSR_DMAENAB | MUSB_RXCSR_AUTOCLEAR); | ||
807 | musb_writew(epio, MUSB_RXCSR, csr); | ||
808 | } | ||
809 | 798 | ||
799 | /* | ||
800 | * Clear DMAENAB and AUTOCLEAR for the | ||
801 | * PIO mode transfer | ||
802 | */ | ||
803 | csr &= ~(MUSB_RXCSR_DMAENAB | MUSB_RXCSR_AUTOCLEAR); | ||
804 | musb_writew(epio, MUSB_RXCSR, csr); | ||
805 | |||
806 | buffer_aint_mapped: | ||
810 | musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *) | 807 | musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *) |
811 | (request->buf + request->actual)); | 808 | (request->buf + request->actual)); |
812 | request->actual += fifo_count; | 809 | request->actual += fifo_count; |
@@ -1684,6 +1681,40 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) | |||
1684 | return 0; | 1681 | return 0; |
1685 | } | 1682 | } |
1686 | 1683 | ||
1684 | #ifdef CONFIG_BLACKFIN | ||
1685 | static struct usb_ep *musb_match_ep(struct usb_gadget *g, | ||
1686 | struct usb_endpoint_descriptor *desc, | ||
1687 | struct usb_ss_ep_comp_descriptor *ep_comp) | ||
1688 | { | ||
1689 | struct usb_ep *ep = NULL; | ||
1690 | |||
1691 | switch (usb_endpoint_type(desc)) { | ||
1692 | case USB_ENDPOINT_XFER_ISOC: | ||
1693 | case USB_ENDPOINT_XFER_BULK: | ||
1694 | if (usb_endpoint_dir_in(desc)) | ||
1695 | ep = gadget_find_ep_by_name(g, "ep5in"); | ||
1696 | else | ||
1697 | ep = gadget_find_ep_by_name(g, "ep6out"); | ||
1698 | break; | ||
1699 | case USB_ENDPOINT_XFER_INT: | ||
1700 | if (usb_endpoint_dir_in(desc)) | ||
1701 | ep = gadget_find_ep_by_name(g, "ep1in"); | ||
1702 | else | ||
1703 | ep = gadget_find_ep_by_name(g, "ep2out"); | ||
1704 | break; | ||
1705 | default: | ||
1706 | break; | ||
1707 | } | ||
1708 | |||
1709 | if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) | ||
1710 | return ep; | ||
1711 | |||
1712 | return NULL; | ||
1713 | } | ||
1714 | #else | ||
1715 | #define musb_match_ep NULL | ||
1716 | #endif | ||
1717 | |||
1687 | static int musb_gadget_start(struct usb_gadget *g, | 1718 | static int musb_gadget_start(struct usb_gadget *g, |
1688 | struct usb_gadget_driver *driver); | 1719 | struct usb_gadget_driver *driver); |
1689 | static int musb_gadget_stop(struct usb_gadget *g); | 1720 | static int musb_gadget_stop(struct usb_gadget *g); |
@@ -1697,6 +1728,7 @@ static const struct usb_gadget_ops musb_gadget_operations = { | |||
1697 | .pullup = musb_gadget_pullup, | 1728 | .pullup = musb_gadget_pullup, |
1698 | .udc_start = musb_gadget_start, | 1729 | .udc_start = musb_gadget_start, |
1699 | .udc_stop = musb_gadget_stop, | 1730 | .udc_stop = musb_gadget_stop, |
1731 | .match_ep = musb_match_ep, | ||
1700 | }; | 1732 | }; |
1701 | 1733 | ||
1702 | /* ----------------------------------------------------------------------- */ | 1734 | /* ----------------------------------------------------------------------- */ |
@@ -1729,6 +1761,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | |||
1729 | INIT_LIST_HEAD(&ep->end_point.ep_list); | 1761 | INIT_LIST_HEAD(&ep->end_point.ep_list); |
1730 | if (!epnum) { | 1762 | if (!epnum) { |
1731 | usb_ep_set_maxpacket_limit(&ep->end_point, 64); | 1763 | usb_ep_set_maxpacket_limit(&ep->end_point, 64); |
1764 | ep->end_point.caps.type_control = true; | ||
1732 | ep->end_point.ops = &musb_g_ep0_ops; | 1765 | ep->end_point.ops = &musb_g_ep0_ops; |
1733 | musb->g.ep0 = &ep->end_point; | 1766 | musb->g.ep0 = &ep->end_point; |
1734 | } else { | 1767 | } else { |
@@ -1736,9 +1769,20 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | |||
1736 | usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_tx); | 1769 | usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_tx); |
1737 | else | 1770 | else |
1738 | usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_rx); | 1771 | usb_ep_set_maxpacket_limit(&ep->end_point, hw_ep->max_packet_sz_rx); |
1772 | ep->end_point.caps.type_iso = true; | ||
1773 | ep->end_point.caps.type_bulk = true; | ||
1774 | ep->end_point.caps.type_int = true; | ||
1739 | ep->end_point.ops = &musb_ep_ops; | 1775 | ep->end_point.ops = &musb_ep_ops; |
1740 | list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list); | 1776 | list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list); |
1741 | } | 1777 | } |
1778 | |||
1779 | if (!epnum || hw_ep->is_shared_fifo) { | ||
1780 | ep->end_point.caps.dir_in = true; | ||
1781 | ep->end_point.caps.dir_out = true; | ||
1782 | } else if (is_in) | ||
1783 | ep->end_point.caps.dir_in = true; | ||
1784 | else | ||
1785 | ep->end_point.caps.dir_out = true; | ||
1742 | } | 1786 | } |
1743 | 1787 | ||
1744 | /* | 1788 | /* |
@@ -2075,6 +2119,7 @@ __acquires(musb->lock) | |||
2075 | musb->g.b_hnp_enable = 0; | 2119 | musb->g.b_hnp_enable = 0; |
2076 | musb->g.a_alt_hnp_support = 0; | 2120 | musb->g.a_alt_hnp_support = 0; |
2077 | musb->g.a_hnp_support = 0; | 2121 | musb->g.a_hnp_support = 0; |
2122 | musb->g.quirk_zlp_not_supp = 1; | ||
2078 | 2123 | ||
2079 | /* Normal reset, as B-Device; | 2124 | /* Normal reset, as B-Device; |
2080 | * or else after HNP, as A-Device | 2125 | * or else after HNP, as A-Device |
diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c new file mode 100644 index 000000000000..f9f6304ad854 --- /dev/null +++ b/drivers/usb/musb/sunxi.c | |||
@@ -0,0 +1,756 @@ | |||
1 | /* | ||
2 | * Allwinner sun4i MUSB Glue Layer | ||
3 | * | ||
4 | * Copyright (C) 2015 Hans de Goede <hdegoede@redhat.com> | ||
5 | * | ||
6 | * Based on code from | ||
7 | * Allwinner Technology Co., Ltd. <www.allwinnertech.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | #include <linux/clk.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <linux/extcon.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/phy/phy-sun4i-usb.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/reset.h> | ||
30 | #include <linux/soc/sunxi/sunxi_sram.h> | ||
31 | #include <linux/usb/musb.h> | ||
32 | #include <linux/usb/of.h> | ||
33 | #include <linux/usb/usb_phy_generic.h> | ||
34 | #include <linux/workqueue.h> | ||
35 | #include "musb_core.h" | ||
36 | |||
37 | /* | ||
38 | * Register offsets, note sunxi musb has a different layout then most | ||
39 | * musb implementations, we translate the layout in musb_readb & friends. | ||
40 | */ | ||
41 | #define SUNXI_MUSB_POWER 0x0040 | ||
42 | #define SUNXI_MUSB_DEVCTL 0x0041 | ||
43 | #define SUNXI_MUSB_INDEX 0x0042 | ||
44 | #define SUNXI_MUSB_VEND0 0x0043 | ||
45 | #define SUNXI_MUSB_INTRTX 0x0044 | ||
46 | #define SUNXI_MUSB_INTRRX 0x0046 | ||
47 | #define SUNXI_MUSB_INTRTXE 0x0048 | ||
48 | #define SUNXI_MUSB_INTRRXE 0x004a | ||
49 | #define SUNXI_MUSB_INTRUSB 0x004c | ||
50 | #define SUNXI_MUSB_INTRUSBE 0x0050 | ||
51 | #define SUNXI_MUSB_FRAME 0x0054 | ||
52 | #define SUNXI_MUSB_TXFIFOSZ 0x0090 | ||
53 | #define SUNXI_MUSB_TXFIFOADD 0x0092 | ||
54 | #define SUNXI_MUSB_RXFIFOSZ 0x0094 | ||
55 | #define SUNXI_MUSB_RXFIFOADD 0x0096 | ||
56 | #define SUNXI_MUSB_FADDR 0x0098 | ||
57 | #define SUNXI_MUSB_TXFUNCADDR 0x0098 | ||
58 | #define SUNXI_MUSB_TXHUBADDR 0x009a | ||
59 | #define SUNXI_MUSB_TXHUBPORT 0x009b | ||
60 | #define SUNXI_MUSB_RXFUNCADDR 0x009c | ||
61 | #define SUNXI_MUSB_RXHUBADDR 0x009e | ||
62 | #define SUNXI_MUSB_RXHUBPORT 0x009f | ||
63 | #define SUNXI_MUSB_CONFIGDATA 0x00c0 | ||
64 | |||
65 | /* VEND0 bits */ | ||
66 | #define SUNXI_MUSB_VEND0_PIO_MODE 0 | ||
67 | |||
68 | /* flags */ | ||
69 | #define SUNXI_MUSB_FL_ENABLED 0 | ||
70 | #define SUNXI_MUSB_FL_HOSTMODE 1 | ||
71 | #define SUNXI_MUSB_FL_HOSTMODE_PEND 2 | ||
72 | #define SUNXI_MUSB_FL_VBUS_ON 3 | ||
73 | #define SUNXI_MUSB_FL_PHY_ON 4 | ||
74 | #define SUNXI_MUSB_FL_HAS_SRAM 5 | ||
75 | #define SUNXI_MUSB_FL_HAS_RESET 6 | ||
76 | #define SUNXI_MUSB_FL_NO_CONFIGDATA 7 | ||
77 | |||
78 | /* Our read/write methods need access and do not get passed in a musb ref :| */ | ||
79 | static struct musb *sunxi_musb; | ||
80 | |||
81 | struct sunxi_glue { | ||
82 | struct device *dev; | ||
83 | struct platform_device *musb; | ||
84 | struct clk *clk; | ||
85 | struct reset_control *rst; | ||
86 | struct phy *phy; | ||
87 | struct platform_device *usb_phy; | ||
88 | struct usb_phy *xceiv; | ||
89 | unsigned long flags; | ||
90 | struct work_struct work; | ||
91 | struct extcon_dev *extcon; | ||
92 | struct notifier_block host_nb; | ||
93 | }; | ||
94 | |||
95 | /* phy_power_on / off may sleep, so we use a workqueue */ | ||
96 | static void sunxi_musb_work(struct work_struct *work) | ||
97 | { | ||
98 | struct sunxi_glue *glue = container_of(work, struct sunxi_glue, work); | ||
99 | bool vbus_on, phy_on; | ||
100 | |||
101 | if (!test_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags)) | ||
102 | return; | ||
103 | |||
104 | if (test_and_clear_bit(SUNXI_MUSB_FL_HOSTMODE_PEND, &glue->flags)) { | ||
105 | struct musb *musb = platform_get_drvdata(glue->musb); | ||
106 | unsigned long flags; | ||
107 | u8 devctl; | ||
108 | |||
109 | spin_lock_irqsave(&musb->lock, flags); | ||
110 | |||
111 | devctl = readb(musb->mregs + SUNXI_MUSB_DEVCTL); | ||
112 | if (test_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags)) { | ||
113 | set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
114 | musb->xceiv->otg->default_a = 1; | ||
115 | musb->xceiv->otg->state = OTG_STATE_A_IDLE; | ||
116 | MUSB_HST_MODE(musb); | ||
117 | devctl |= MUSB_DEVCTL_SESSION; | ||
118 | } else { | ||
119 | clear_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
120 | musb->xceiv->otg->default_a = 0; | ||
121 | musb->xceiv->otg->state = OTG_STATE_B_IDLE; | ||
122 | MUSB_DEV_MODE(musb); | ||
123 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
124 | } | ||
125 | writeb(devctl, musb->mregs + SUNXI_MUSB_DEVCTL); | ||
126 | |||
127 | spin_unlock_irqrestore(&musb->lock, flags); | ||
128 | } | ||
129 | |||
130 | vbus_on = test_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
131 | phy_on = test_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); | ||
132 | |||
133 | if (phy_on != vbus_on) { | ||
134 | if (vbus_on) { | ||
135 | phy_power_on(glue->phy); | ||
136 | set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); | ||
137 | } else { | ||
138 | phy_power_off(glue->phy); | ||
139 | clear_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | static void sunxi_musb_set_vbus(struct musb *musb, int is_on) | ||
145 | { | ||
146 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
147 | |||
148 | if (is_on) | ||
149 | set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
150 | else | ||
151 | clear_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
152 | |||
153 | schedule_work(&glue->work); | ||
154 | } | ||
155 | |||
156 | static void sunxi_musb_pre_root_reset_end(struct musb *musb) | ||
157 | { | ||
158 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
159 | |||
160 | sun4i_usb_phy_set_squelch_detect(glue->phy, false); | ||
161 | } | ||
162 | |||
163 | static void sunxi_musb_post_root_reset_end(struct musb *musb) | ||
164 | { | ||
165 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
166 | |||
167 | sun4i_usb_phy_set_squelch_detect(glue->phy, true); | ||
168 | } | ||
169 | |||
170 | static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci) | ||
171 | { | ||
172 | struct musb *musb = __hci; | ||
173 | unsigned long flags; | ||
174 | |||
175 | spin_lock_irqsave(&musb->lock, flags); | ||
176 | |||
177 | musb->int_usb = readb(musb->mregs + SUNXI_MUSB_INTRUSB); | ||
178 | if (musb->int_usb) | ||
179 | writeb(musb->int_usb, musb->mregs + SUNXI_MUSB_INTRUSB); | ||
180 | |||
181 | /* | ||
182 | * sunxi musb often signals babble on low / full speed device | ||
183 | * disconnect, without ever raising MUSB_INTR_DISCONNECT, since | ||
184 | * normally babble never happens treat it as disconnect. | ||
185 | */ | ||
186 | if ((musb->int_usb & MUSB_INTR_BABBLE) && is_host_active(musb)) { | ||
187 | musb->int_usb &= ~MUSB_INTR_BABBLE; | ||
188 | musb->int_usb |= MUSB_INTR_DISCONNECT; | ||
189 | } | ||
190 | |||
191 | if ((musb->int_usb & MUSB_INTR_RESET) && !is_host_active(musb)) { | ||
192 | /* ep0 FADDR must be 0 when (re)entering peripheral mode */ | ||
193 | musb_ep_select(musb->mregs, 0); | ||
194 | musb_writeb(musb->mregs, MUSB_FADDR, 0); | ||
195 | } | ||
196 | |||
197 | musb->int_tx = readw(musb->mregs + SUNXI_MUSB_INTRTX); | ||
198 | if (musb->int_tx) | ||
199 | writew(musb->int_tx, musb->mregs + SUNXI_MUSB_INTRTX); | ||
200 | |||
201 | musb->int_rx = readw(musb->mregs + SUNXI_MUSB_INTRRX); | ||
202 | if (musb->int_rx) | ||
203 | writew(musb->int_rx, musb->mregs + SUNXI_MUSB_INTRRX); | ||
204 | |||
205 | musb_interrupt(musb); | ||
206 | |||
207 | spin_unlock_irqrestore(&musb->lock, flags); | ||
208 | |||
209 | return IRQ_HANDLED; | ||
210 | } | ||
211 | |||
212 | static int sunxi_musb_host_notifier(struct notifier_block *nb, | ||
213 | unsigned long event, void *ptr) | ||
214 | { | ||
215 | struct sunxi_glue *glue = container_of(nb, struct sunxi_glue, host_nb); | ||
216 | |||
217 | if (event) | ||
218 | set_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags); | ||
219 | else | ||
220 | clear_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags); | ||
221 | |||
222 | set_bit(SUNXI_MUSB_FL_HOSTMODE_PEND, &glue->flags); | ||
223 | schedule_work(&glue->work); | ||
224 | |||
225 | return NOTIFY_DONE; | ||
226 | } | ||
227 | |||
228 | static int sunxi_musb_init(struct musb *musb) | ||
229 | { | ||
230 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
231 | int ret; | ||
232 | |||
233 | sunxi_musb = musb; | ||
234 | musb->phy = glue->phy; | ||
235 | musb->xceiv = glue->xceiv; | ||
236 | |||
237 | if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) { | ||
238 | ret = sunxi_sram_claim(musb->controller->parent); | ||
239 | if (ret) | ||
240 | return ret; | ||
241 | } | ||
242 | |||
243 | ret = clk_prepare_enable(glue->clk); | ||
244 | if (ret) | ||
245 | goto error_sram_release; | ||
246 | |||
247 | if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) { | ||
248 | ret = reset_control_deassert(glue->rst); | ||
249 | if (ret) | ||
250 | goto error_clk_disable; | ||
251 | } | ||
252 | |||
253 | writeb(SUNXI_MUSB_VEND0_PIO_MODE, musb->mregs + SUNXI_MUSB_VEND0); | ||
254 | |||
255 | /* Register notifier before calling phy_init() */ | ||
256 | if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) { | ||
257 | ret = extcon_register_notifier(glue->extcon, EXTCON_USB_HOST, | ||
258 | &glue->host_nb); | ||
259 | if (ret) | ||
260 | goto error_reset_assert; | ||
261 | } | ||
262 | |||
263 | ret = phy_init(glue->phy); | ||
264 | if (ret) | ||
265 | goto error_unregister_notifier; | ||
266 | |||
267 | if (musb->port_mode == MUSB_PORT_MODE_HOST) { | ||
268 | ret = phy_power_on(glue->phy); | ||
269 | if (ret) | ||
270 | goto error_phy_exit; | ||
271 | set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); | ||
272 | /* Stop musb work from turning vbus off again */ | ||
273 | set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); | ||
274 | } | ||
275 | |||
276 | musb->isr = sunxi_musb_interrupt; | ||
277 | |||
278 | /* Stop the musb-core from doing runtime pm (not supported on sunxi) */ | ||
279 | pm_runtime_get(musb->controller); | ||
280 | |||
281 | return 0; | ||
282 | |||
283 | error_phy_exit: | ||
284 | phy_exit(glue->phy); | ||
285 | error_unregister_notifier: | ||
286 | if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) | ||
287 | extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, | ||
288 | &glue->host_nb); | ||
289 | error_reset_assert: | ||
290 | if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) | ||
291 | reset_control_assert(glue->rst); | ||
292 | error_clk_disable: | ||
293 | clk_disable_unprepare(glue->clk); | ||
294 | error_sram_release: | ||
295 | if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) | ||
296 | sunxi_sram_release(musb->controller->parent); | ||
297 | return ret; | ||
298 | } | ||
299 | |||
300 | static int sunxi_musb_exit(struct musb *musb) | ||
301 | { | ||
302 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
303 | |||
304 | pm_runtime_put(musb->controller); | ||
305 | |||
306 | cancel_work_sync(&glue->work); | ||
307 | if (test_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags)) | ||
308 | phy_power_off(glue->phy); | ||
309 | |||
310 | phy_exit(glue->phy); | ||
311 | |||
312 | if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) | ||
313 | extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, | ||
314 | &glue->host_nb); | ||
315 | |||
316 | if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) | ||
317 | reset_control_assert(glue->rst); | ||
318 | |||
319 | clk_disable_unprepare(glue->clk); | ||
320 | if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) | ||
321 | sunxi_sram_release(musb->controller->parent); | ||
322 | |||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static void sunxi_musb_enable(struct musb *musb) | ||
327 | { | ||
328 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
329 | |||
330 | /* musb_core does not call us in a balanced manner */ | ||
331 | if (test_and_set_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags)) | ||
332 | return; | ||
333 | |||
334 | schedule_work(&glue->work); | ||
335 | } | ||
336 | |||
337 | static void sunxi_musb_disable(struct musb *musb) | ||
338 | { | ||
339 | struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); | ||
340 | |||
341 | clear_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags); | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * sunxi musb register layout | ||
346 | * 0x00 - 0x17 fifo regs, 1 long per fifo | ||
347 | * 0x40 - 0x57 generic control regs (power - frame) | ||
348 | * 0x80 - 0x8f ep control regs (addressed through hw_ep->regs, indexed) | ||
349 | * 0x90 - 0x97 fifo control regs (indexed) | ||
350 | * 0x98 - 0x9f multipoint / busctl regs (indexed) | ||
351 | * 0xc0 configdata reg | ||
352 | */ | ||
353 | |||
354 | static u32 sunxi_musb_fifo_offset(u8 epnum) | ||
355 | { | ||
356 | return (epnum * 4); | ||
357 | } | ||
358 | |||
359 | static u32 sunxi_musb_ep_offset(u8 epnum, u16 offset) | ||
360 | { | ||
361 | WARN_ONCE(offset != 0, | ||
362 | "sunxi_musb_ep_offset called with non 0 offset\n"); | ||
363 | |||
364 | return 0x80; /* indexed, so ignore epnum */ | ||
365 | } | ||
366 | |||
367 | static u32 sunxi_musb_busctl_offset(u8 epnum, u16 offset) | ||
368 | { | ||
369 | return SUNXI_MUSB_TXFUNCADDR + offset; | ||
370 | } | ||
371 | |||
372 | static u8 sunxi_musb_readb(const void __iomem *addr, unsigned offset) | ||
373 | { | ||
374 | struct sunxi_glue *glue; | ||
375 | |||
376 | if (addr == sunxi_musb->mregs) { | ||
377 | /* generic control or fifo control reg access */ | ||
378 | switch (offset) { | ||
379 | case MUSB_FADDR: | ||
380 | return readb(addr + SUNXI_MUSB_FADDR); | ||
381 | case MUSB_POWER: | ||
382 | return readb(addr + SUNXI_MUSB_POWER); | ||
383 | case MUSB_INTRUSB: | ||
384 | return readb(addr + SUNXI_MUSB_INTRUSB); | ||
385 | case MUSB_INTRUSBE: | ||
386 | return readb(addr + SUNXI_MUSB_INTRUSBE); | ||
387 | case MUSB_INDEX: | ||
388 | return readb(addr + SUNXI_MUSB_INDEX); | ||
389 | case MUSB_TESTMODE: | ||
390 | return 0; /* No testmode on sunxi */ | ||
391 | case MUSB_DEVCTL: | ||
392 | return readb(addr + SUNXI_MUSB_DEVCTL); | ||
393 | case MUSB_TXFIFOSZ: | ||
394 | return readb(addr + SUNXI_MUSB_TXFIFOSZ); | ||
395 | case MUSB_RXFIFOSZ: | ||
396 | return readb(addr + SUNXI_MUSB_RXFIFOSZ); | ||
397 | case MUSB_CONFIGDATA + 0x10: /* See musb_read_configdata() */ | ||
398 | glue = dev_get_drvdata(sunxi_musb->controller->parent); | ||
399 | /* A33 saves a reg, and we get to hardcode this */ | ||
400 | if (test_bit(SUNXI_MUSB_FL_NO_CONFIGDATA, | ||
401 | &glue->flags)) | ||
402 | return 0xde; | ||
403 | |||
404 | return readb(addr + SUNXI_MUSB_CONFIGDATA); | ||
405 | /* Offset for these is fixed by sunxi_musb_busctl_offset() */ | ||
406 | case SUNXI_MUSB_TXFUNCADDR: | ||
407 | case SUNXI_MUSB_TXHUBADDR: | ||
408 | case SUNXI_MUSB_TXHUBPORT: | ||
409 | case SUNXI_MUSB_RXFUNCADDR: | ||
410 | case SUNXI_MUSB_RXHUBADDR: | ||
411 | case SUNXI_MUSB_RXHUBPORT: | ||
412 | /* multipoint / busctl reg access */ | ||
413 | return readb(addr + offset); | ||
414 | default: | ||
415 | dev_err(sunxi_musb->controller->parent, | ||
416 | "Error unknown readb offset %u\n", offset); | ||
417 | return 0; | ||
418 | } | ||
419 | } else if (addr == (sunxi_musb->mregs + 0x80)) { | ||
420 | /* ep control reg access */ | ||
421 | /* sunxi has a 2 byte hole before the txtype register */ | ||
422 | if (offset >= MUSB_TXTYPE) | ||
423 | offset += 2; | ||
424 | return readb(addr + offset); | ||
425 | } | ||
426 | |||
427 | dev_err(sunxi_musb->controller->parent, | ||
428 | "Error unknown readb at 0x%x bytes offset\n", | ||
429 | (int)(addr - sunxi_musb->mregs)); | ||
430 | return 0; | ||
431 | } | ||
432 | |||
433 | static void sunxi_musb_writeb(void __iomem *addr, unsigned offset, u8 data) | ||
434 | { | ||
435 | if (addr == sunxi_musb->mregs) { | ||
436 | /* generic control or fifo control reg access */ | ||
437 | switch (offset) { | ||
438 | case MUSB_FADDR: | ||
439 | return writeb(data, addr + SUNXI_MUSB_FADDR); | ||
440 | case MUSB_POWER: | ||
441 | return writeb(data, addr + SUNXI_MUSB_POWER); | ||
442 | case MUSB_INTRUSB: | ||
443 | return writeb(data, addr + SUNXI_MUSB_INTRUSB); | ||
444 | case MUSB_INTRUSBE: | ||
445 | return writeb(data, addr + SUNXI_MUSB_INTRUSBE); | ||
446 | case MUSB_INDEX: | ||
447 | return writeb(data, addr + SUNXI_MUSB_INDEX); | ||
448 | case MUSB_TESTMODE: | ||
449 | if (data) | ||
450 | dev_warn(sunxi_musb->controller->parent, | ||
451 | "sunxi-musb does not have testmode\n"); | ||
452 | return; | ||
453 | case MUSB_DEVCTL: | ||
454 | return writeb(data, addr + SUNXI_MUSB_DEVCTL); | ||
455 | case MUSB_TXFIFOSZ: | ||
456 | return writeb(data, addr + SUNXI_MUSB_TXFIFOSZ); | ||
457 | case MUSB_RXFIFOSZ: | ||
458 | return writeb(data, addr + SUNXI_MUSB_RXFIFOSZ); | ||
459 | /* Offset for these is fixed by sunxi_musb_busctl_offset() */ | ||
460 | case SUNXI_MUSB_TXFUNCADDR: | ||
461 | case SUNXI_MUSB_TXHUBADDR: | ||
462 | case SUNXI_MUSB_TXHUBPORT: | ||
463 | case SUNXI_MUSB_RXFUNCADDR: | ||
464 | case SUNXI_MUSB_RXHUBADDR: | ||
465 | case SUNXI_MUSB_RXHUBPORT: | ||
466 | /* multipoint / busctl reg access */ | ||
467 | return writeb(data, addr + offset); | ||
468 | default: | ||
469 | dev_err(sunxi_musb->controller->parent, | ||
470 | "Error unknown writeb offset %u\n", offset); | ||
471 | return; | ||
472 | } | ||
473 | } else if (addr == (sunxi_musb->mregs + 0x80)) { | ||
474 | /* ep control reg access */ | ||
475 | if (offset >= MUSB_TXTYPE) | ||
476 | offset += 2; | ||
477 | return writeb(data, addr + offset); | ||
478 | } | ||
479 | |||
480 | dev_err(sunxi_musb->controller->parent, | ||
481 | "Error unknown writeb at 0x%x bytes offset\n", | ||
482 | (int)(addr - sunxi_musb->mregs)); | ||
483 | } | ||
484 | |||
485 | static u16 sunxi_musb_readw(const void __iomem *addr, unsigned offset) | ||
486 | { | ||
487 | if (addr == sunxi_musb->mregs) { | ||
488 | /* generic control or fifo control reg access */ | ||
489 | switch (offset) { | ||
490 | case MUSB_INTRTX: | ||
491 | return readw(addr + SUNXI_MUSB_INTRTX); | ||
492 | case MUSB_INTRRX: | ||
493 | return readw(addr + SUNXI_MUSB_INTRRX); | ||
494 | case MUSB_INTRTXE: | ||
495 | return readw(addr + SUNXI_MUSB_INTRTXE); | ||
496 | case MUSB_INTRRXE: | ||
497 | return readw(addr + SUNXI_MUSB_INTRRXE); | ||
498 | case MUSB_FRAME: | ||
499 | return readw(addr + SUNXI_MUSB_FRAME); | ||
500 | case MUSB_TXFIFOADD: | ||
501 | return readw(addr + SUNXI_MUSB_TXFIFOADD); | ||
502 | case MUSB_RXFIFOADD: | ||
503 | return readw(addr + SUNXI_MUSB_RXFIFOADD); | ||
504 | case MUSB_HWVERS: | ||
505 | return 0; /* sunxi musb version is not known */ | ||
506 | default: | ||
507 | dev_err(sunxi_musb->controller->parent, | ||
508 | "Error unknown readw offset %u\n", offset); | ||
509 | return 0; | ||
510 | } | ||
511 | } else if (addr == (sunxi_musb->mregs + 0x80)) { | ||
512 | /* ep control reg access */ | ||
513 | return readw(addr + offset); | ||
514 | } | ||
515 | |||
516 | dev_err(sunxi_musb->controller->parent, | ||
517 | "Error unknown readw at 0x%x bytes offset\n", | ||
518 | (int)(addr - sunxi_musb->mregs)); | ||
519 | return 0; | ||
520 | } | ||
521 | |||
522 | static void sunxi_musb_writew(void __iomem *addr, unsigned offset, u16 data) | ||
523 | { | ||
524 | if (addr == sunxi_musb->mregs) { | ||
525 | /* generic control or fifo control reg access */ | ||
526 | switch (offset) { | ||
527 | case MUSB_INTRTX: | ||
528 | return writew(data, addr + SUNXI_MUSB_INTRTX); | ||
529 | case MUSB_INTRRX: | ||
530 | return writew(data, addr + SUNXI_MUSB_INTRRX); | ||
531 | case MUSB_INTRTXE: | ||
532 | return writew(data, addr + SUNXI_MUSB_INTRTXE); | ||
533 | case MUSB_INTRRXE: | ||
534 | return writew(data, addr + SUNXI_MUSB_INTRRXE); | ||
535 | case MUSB_FRAME: | ||
536 | return writew(data, addr + SUNXI_MUSB_FRAME); | ||
537 | case MUSB_TXFIFOADD: | ||
538 | return writew(data, addr + SUNXI_MUSB_TXFIFOADD); | ||
539 | case MUSB_RXFIFOADD: | ||
540 | return writew(data, addr + SUNXI_MUSB_RXFIFOADD); | ||
541 | default: | ||
542 | dev_err(sunxi_musb->controller->parent, | ||
543 | "Error unknown writew offset %u\n", offset); | ||
544 | return; | ||
545 | } | ||
546 | } else if (addr == (sunxi_musb->mregs + 0x80)) { | ||
547 | /* ep control reg access */ | ||
548 | return writew(data, addr + offset); | ||
549 | } | ||
550 | |||
551 | dev_err(sunxi_musb->controller->parent, | ||
552 | "Error unknown writew at 0x%x bytes offset\n", | ||
553 | (int)(addr - sunxi_musb->mregs)); | ||
554 | } | ||
555 | |||
556 | static const struct musb_platform_ops sunxi_musb_ops = { | ||
557 | .quirks = MUSB_INDEXED_EP, | ||
558 | .init = sunxi_musb_init, | ||
559 | .exit = sunxi_musb_exit, | ||
560 | .enable = sunxi_musb_enable, | ||
561 | .disable = sunxi_musb_disable, | ||
562 | .fifo_offset = sunxi_musb_fifo_offset, | ||
563 | .ep_offset = sunxi_musb_ep_offset, | ||
564 | .busctl_offset = sunxi_musb_busctl_offset, | ||
565 | .readb = sunxi_musb_readb, | ||
566 | .writeb = sunxi_musb_writeb, | ||
567 | .readw = sunxi_musb_readw, | ||
568 | .writew = sunxi_musb_writew, | ||
569 | .set_vbus = sunxi_musb_set_vbus, | ||
570 | .pre_root_reset_end = sunxi_musb_pre_root_reset_end, | ||
571 | .post_root_reset_end = sunxi_musb_post_root_reset_end, | ||
572 | }; | ||
573 | |||
574 | /* Allwinner OTG supports up to 5 endpoints */ | ||
575 | #define SUNXI_MUSB_MAX_EP_NUM 6 | ||
576 | #define SUNXI_MUSB_RAM_BITS 11 | ||
577 | |||
578 | static struct musb_fifo_cfg sunxi_musb_mode_cfg[] = { | ||
579 | MUSB_EP_FIFO_SINGLE(1, FIFO_TX, 512), | ||
580 | MUSB_EP_FIFO_SINGLE(1, FIFO_RX, 512), | ||
581 | MUSB_EP_FIFO_SINGLE(2, FIFO_TX, 512), | ||
582 | MUSB_EP_FIFO_SINGLE(2, FIFO_RX, 512), | ||
583 | MUSB_EP_FIFO_SINGLE(3, FIFO_TX, 512), | ||
584 | MUSB_EP_FIFO_SINGLE(3, FIFO_RX, 512), | ||
585 | MUSB_EP_FIFO_SINGLE(4, FIFO_TX, 512), | ||
586 | MUSB_EP_FIFO_SINGLE(4, FIFO_RX, 512), | ||
587 | MUSB_EP_FIFO_SINGLE(5, FIFO_TX, 512), | ||
588 | MUSB_EP_FIFO_SINGLE(5, FIFO_RX, 512), | ||
589 | }; | ||
590 | |||
591 | static struct musb_hdrc_config sunxi_musb_hdrc_config = { | ||
592 | .fifo_cfg = sunxi_musb_mode_cfg, | ||
593 | .fifo_cfg_size = ARRAY_SIZE(sunxi_musb_mode_cfg), | ||
594 | .multipoint = true, | ||
595 | .dyn_fifo = true, | ||
596 | .soft_con = true, | ||
597 | .num_eps = SUNXI_MUSB_MAX_EP_NUM, | ||
598 | .ram_bits = SUNXI_MUSB_RAM_BITS, | ||
599 | .dma = 0, | ||
600 | }; | ||
601 | |||
602 | static int sunxi_musb_probe(struct platform_device *pdev) | ||
603 | { | ||
604 | struct musb_hdrc_platform_data pdata; | ||
605 | struct platform_device_info pinfo; | ||
606 | struct sunxi_glue *glue; | ||
607 | struct device_node *np = pdev->dev.of_node; | ||
608 | int ret; | ||
609 | |||
610 | if (!np) { | ||
611 | dev_err(&pdev->dev, "Error no device tree node found\n"); | ||
612 | return -EINVAL; | ||
613 | } | ||
614 | |||
615 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); | ||
616 | if (!glue) | ||
617 | return -ENOMEM; | ||
618 | |||
619 | memset(&pdata, 0, sizeof(pdata)); | ||
620 | switch (of_usb_get_dr_mode(np)) { | ||
621 | #if defined CONFIG_USB_MUSB_DUAL_ROLE || defined CONFIG_USB_MUSB_HOST | ||
622 | case USB_DR_MODE_HOST: | ||
623 | pdata.mode = MUSB_PORT_MODE_HOST; | ||
624 | break; | ||
625 | #endif | ||
626 | #ifdef CONFIG_USB_MUSB_DUAL_ROLE | ||
627 | case USB_DR_MODE_OTG: | ||
628 | glue->extcon = extcon_get_edev_by_phandle(&pdev->dev, 0); | ||
629 | if (IS_ERR(glue->extcon)) { | ||
630 | if (PTR_ERR(glue->extcon) == -EPROBE_DEFER) | ||
631 | return -EPROBE_DEFER; | ||
632 | dev_err(&pdev->dev, "Invalid or missing extcon\n"); | ||
633 | return PTR_ERR(glue->extcon); | ||
634 | } | ||
635 | pdata.mode = MUSB_PORT_MODE_DUAL_ROLE; | ||
636 | break; | ||
637 | #endif | ||
638 | default: | ||
639 | dev_err(&pdev->dev, "Invalid or missing 'dr_mode' property\n"); | ||
640 | return -EINVAL; | ||
641 | } | ||
642 | pdata.platform_ops = &sunxi_musb_ops; | ||
643 | pdata.config = &sunxi_musb_hdrc_config; | ||
644 | |||
645 | glue->dev = &pdev->dev; | ||
646 | INIT_WORK(&glue->work, sunxi_musb_work); | ||
647 | glue->host_nb.notifier_call = sunxi_musb_host_notifier; | ||
648 | |||
649 | if (of_device_is_compatible(np, "allwinner,sun4i-a10-musb")) | ||
650 | set_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags); | ||
651 | |||
652 | if (of_device_is_compatible(np, "allwinner,sun6i-a31-musb")) | ||
653 | set_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags); | ||
654 | |||
655 | if (of_device_is_compatible(np, "allwinner,sun8i-a33-musb")) { | ||
656 | set_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags); | ||
657 | set_bit(SUNXI_MUSB_FL_NO_CONFIGDATA, &glue->flags); | ||
658 | } | ||
659 | |||
660 | glue->clk = devm_clk_get(&pdev->dev, NULL); | ||
661 | if (IS_ERR(glue->clk)) { | ||
662 | dev_err(&pdev->dev, "Error getting clock: %ld\n", | ||
663 | PTR_ERR(glue->clk)); | ||
664 | return PTR_ERR(glue->clk); | ||
665 | } | ||
666 | |||
667 | if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) { | ||
668 | glue->rst = devm_reset_control_get(&pdev->dev, NULL); | ||
669 | if (IS_ERR(glue->rst)) { | ||
670 | if (PTR_ERR(glue->rst) == -EPROBE_DEFER) | ||
671 | return -EPROBE_DEFER; | ||
672 | dev_err(&pdev->dev, "Error getting reset %ld\n", | ||
673 | PTR_ERR(glue->rst)); | ||
674 | return PTR_ERR(glue->rst); | ||
675 | } | ||
676 | } | ||
677 | |||
678 | glue->phy = devm_phy_get(&pdev->dev, "usb"); | ||
679 | if (IS_ERR(glue->phy)) { | ||
680 | if (PTR_ERR(glue->phy) == -EPROBE_DEFER) | ||
681 | return -EPROBE_DEFER; | ||
682 | dev_err(&pdev->dev, "Error getting phy %ld\n", | ||
683 | PTR_ERR(glue->phy)); | ||
684 | return PTR_ERR(glue->phy); | ||
685 | } | ||
686 | |||
687 | glue->usb_phy = usb_phy_generic_register(); | ||
688 | if (IS_ERR(glue->usb_phy)) { | ||
689 | dev_err(&pdev->dev, "Error registering usb-phy %ld\n", | ||
690 | PTR_ERR(glue->usb_phy)); | ||
691 | return PTR_ERR(glue->usb_phy); | ||
692 | } | ||
693 | |||
694 | glue->xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); | ||
695 | if (IS_ERR(glue->xceiv)) { | ||
696 | ret = PTR_ERR(glue->xceiv); | ||
697 | dev_err(&pdev->dev, "Error getting usb-phy %d\n", ret); | ||
698 | goto err_unregister_usb_phy; | ||
699 | } | ||
700 | |||
701 | platform_set_drvdata(pdev, glue); | ||
702 | |||
703 | memset(&pinfo, 0, sizeof(pinfo)); | ||
704 | pinfo.name = "musb-hdrc"; | ||
705 | pinfo.id = PLATFORM_DEVID_AUTO; | ||
706 | pinfo.parent = &pdev->dev; | ||
707 | pinfo.res = pdev->resource; | ||
708 | pinfo.num_res = pdev->num_resources; | ||
709 | pinfo.data = &pdata; | ||
710 | pinfo.size_data = sizeof(pdata); | ||
711 | |||
712 | glue->musb = platform_device_register_full(&pinfo); | ||
713 | if (IS_ERR(glue->musb)) { | ||
714 | ret = PTR_ERR(glue->musb); | ||
715 | dev_err(&pdev->dev, "Error registering musb dev: %d\n", ret); | ||
716 | goto err_unregister_usb_phy; | ||
717 | } | ||
718 | |||
719 | return 0; | ||
720 | |||
721 | err_unregister_usb_phy: | ||
722 | usb_phy_generic_unregister(glue->usb_phy); | ||
723 | return ret; | ||
724 | } | ||
725 | |||
726 | static int sunxi_musb_remove(struct platform_device *pdev) | ||
727 | { | ||
728 | struct sunxi_glue *glue = platform_get_drvdata(pdev); | ||
729 | struct platform_device *usb_phy = glue->usb_phy; | ||
730 | |||
731 | platform_device_unregister(glue->musb); /* Frees glue ! */ | ||
732 | usb_phy_generic_unregister(usb_phy); | ||
733 | |||
734 | return 0; | ||
735 | } | ||
736 | |||
737 | static const struct of_device_id sunxi_musb_match[] = { | ||
738 | { .compatible = "allwinner,sun4i-a10-musb", }, | ||
739 | { .compatible = "allwinner,sun6i-a31-musb", }, | ||
740 | { .compatible = "allwinner,sun8i-a33-musb", }, | ||
741 | {} | ||
742 | }; | ||
743 | |||
744 | static struct platform_driver sunxi_musb_driver = { | ||
745 | .probe = sunxi_musb_probe, | ||
746 | .remove = sunxi_musb_remove, | ||
747 | .driver = { | ||
748 | .name = "musb-sunxi", | ||
749 | .of_match_table = sunxi_musb_match, | ||
750 | }, | ||
751 | }; | ||
752 | module_platform_driver(sunxi_musb_driver); | ||
753 | |||
754 | MODULE_DESCRIPTION("Allwinner sunxi MUSB Glue Layer"); | ||
755 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | ||
756 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 869c0cfcad98..7d3beee2a587 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
@@ -152,6 +152,20 @@ config USB_MSM_OTG | |||
152 | This driver is not supported on boards like trout which | 152 | This driver is not supported on boards like trout which |
153 | has an external PHY. | 153 | has an external PHY. |
154 | 154 | ||
155 | config USB_QCOM_8X16_PHY | ||
156 | tristate "Qualcomm APQ8016/MSM8916 on-chip USB PHY controller support" | ||
157 | depends on ARCH_QCOM || COMPILE_TEST | ||
158 | depends on RESET_CONTROLLER | ||
159 | select USB_PHY | ||
160 | select USB_ULPI_VIEWPORT | ||
161 | help | ||
162 | Enable this to support the USB transceiver on Qualcomm 8x16 chipsets. | ||
163 | It handles PHY initialization, clock management, power management, | ||
164 | and workarounds required after resetting the hardware. | ||
165 | |||
166 | To compile this driver as a module, choose M here: the | ||
167 | module will be called phy-qcom-8x16-usb. | ||
168 | |||
155 | config USB_MV_OTG | 169 | config USB_MV_OTG |
156 | tristate "Marvell USB OTG support" | 170 | tristate "Marvell USB OTG support" |
157 | depends on USB_EHCI_MV && USB_MV_UDC && PM | 171 | depends on USB_EHCI_MV && USB_MV_UDC && PM |
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index e36ab1d46d8b..19c0dccbb116 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile | |||
@@ -20,6 +20,7 @@ obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o | |||
20 | obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o | 20 | obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o |
21 | obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o | 21 | obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o |
22 | obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o | 22 | obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o |
23 | obj-$(CONFIG_USB_QCOM_8X16_PHY) += phy-qcom-8x16-usb.o | ||
23 | obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o | 24 | obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o |
24 | obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o | 25 | obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o |
25 | obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o | 26 | obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o |
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index deee68eafb72..ec6ecd03269c 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c | |||
@@ -218,11 +218,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop, | |||
218 | clk_rate = 0; | 218 | clk_rate = 0; |
219 | 219 | ||
220 | needs_vcc = of_property_read_bool(node, "vcc-supply"); | 220 | needs_vcc = of_property_read_bool(node, "vcc-supply"); |
221 | nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset"); | 221 | nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset", |
222 | GPIOD_ASIS); | ||
222 | err = PTR_ERR_OR_ZERO(nop->gpiod_reset); | 223 | err = PTR_ERR_OR_ZERO(nop->gpiod_reset); |
223 | if (!err) { | 224 | if (!err) { |
224 | nop->gpiod_vbus = devm_gpiod_get_optional(dev, | 225 | nop->gpiod_vbus = devm_gpiod_get_optional(dev, |
225 | "vbus-detect"); | 226 | "vbus-detect", |
227 | GPIOD_ASIS); | ||
226 | err = PTR_ERR_OR_ZERO(nop->gpiod_vbus); | 228 | err = PTR_ERR_OR_ZERO(nop->gpiod_vbus); |
227 | } | 229 | } |
228 | } else if (pdata) { | 230 | } else if (pdata) { |
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 00c49bb1bd29..c58c3c0dbe35 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/gpio/consumer.h> | ||
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <linux/clk.h> | 23 | #include <linux/clk.h> |
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -32,6 +33,7 @@ | |||
32 | #include <linux/pm_runtime.h> | 33 | #include <linux/pm_runtime.h> |
33 | #include <linux/of.h> | 34 | #include <linux/of.h> |
34 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
36 | #include <linux/reboot.h> | ||
35 | #include <linux/reset.h> | 37 | #include <linux/reset.h> |
36 | 38 | ||
37 | #include <linux/usb.h> | 39 | #include <linux/usb.h> |
@@ -1471,6 +1473,14 @@ static int msm_otg_vbus_notifier(struct notifier_block *nb, unsigned long event, | |||
1471 | else | 1473 | else |
1472 | clear_bit(B_SESS_VLD, &motg->inputs); | 1474 | clear_bit(B_SESS_VLD, &motg->inputs); |
1473 | 1475 | ||
1476 | if (test_bit(B_SESS_VLD, &motg->inputs)) { | ||
1477 | /* Switch D+/D- lines to Device connector */ | ||
1478 | gpiod_set_value_cansleep(motg->switch_gpio, 0); | ||
1479 | } else { | ||
1480 | /* Switch D+/D- lines to Hub */ | ||
1481 | gpiod_set_value_cansleep(motg->switch_gpio, 1); | ||
1482 | } | ||
1483 | |||
1474 | schedule_work(&motg->sm_work); | 1484 | schedule_work(&motg->sm_work); |
1475 | 1485 | ||
1476 | return NOTIFY_DONE; | 1486 | return NOTIFY_DONE; |
@@ -1546,6 +1556,11 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1546 | 1556 | ||
1547 | motg->manual_pullup = of_property_read_bool(node, "qcom,manual-pullup"); | 1557 | motg->manual_pullup = of_property_read_bool(node, "qcom,manual-pullup"); |
1548 | 1558 | ||
1559 | motg->switch_gpio = devm_gpiod_get_optional(&pdev->dev, "switch", | ||
1560 | GPIOD_OUT_LOW); | ||
1561 | if (IS_ERR(motg->switch_gpio)) | ||
1562 | return PTR_ERR(motg->switch_gpio); | ||
1563 | |||
1549 | ext_id = ERR_PTR(-ENODEV); | 1564 | ext_id = ERR_PTR(-ENODEV); |
1550 | ext_vbus = ERR_PTR(-ENODEV); | 1565 | ext_vbus = ERR_PTR(-ENODEV); |
1551 | if (of_property_read_bool(node, "extcon")) { | 1566 | if (of_property_read_bool(node, "extcon")) { |
@@ -1561,15 +1576,16 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1561 | } | 1576 | } |
1562 | 1577 | ||
1563 | if (!IS_ERR(ext_vbus)) { | 1578 | if (!IS_ERR(ext_vbus)) { |
1579 | motg->vbus.extcon = ext_vbus; | ||
1564 | motg->vbus.nb.notifier_call = msm_otg_vbus_notifier; | 1580 | motg->vbus.nb.notifier_call = msm_otg_vbus_notifier; |
1565 | ret = extcon_register_interest(&motg->vbus.conn, ext_vbus->name, | 1581 | ret = extcon_register_notifier(ext_vbus, EXTCON_USB, |
1566 | "USB", &motg->vbus.nb); | 1582 | &motg->vbus.nb); |
1567 | if (ret < 0) { | 1583 | if (ret < 0) { |
1568 | dev_err(&pdev->dev, "register VBUS notifier failed\n"); | 1584 | dev_err(&pdev->dev, "register VBUS notifier failed\n"); |
1569 | return ret; | 1585 | return ret; |
1570 | } | 1586 | } |
1571 | 1587 | ||
1572 | ret = extcon_get_cable_state(ext_vbus, "USB"); | 1588 | ret = extcon_get_cable_state_(ext_vbus, EXTCON_USB); |
1573 | if (ret) | 1589 | if (ret) |
1574 | set_bit(B_SESS_VLD, &motg->inputs); | 1590 | set_bit(B_SESS_VLD, &motg->inputs); |
1575 | else | 1591 | else |
@@ -1577,15 +1593,16 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1577 | } | 1593 | } |
1578 | 1594 | ||
1579 | if (!IS_ERR(ext_id)) { | 1595 | if (!IS_ERR(ext_id)) { |
1596 | motg->id.extcon = ext_id; | ||
1580 | motg->id.nb.notifier_call = msm_otg_id_notifier; | 1597 | motg->id.nb.notifier_call = msm_otg_id_notifier; |
1581 | ret = extcon_register_interest(&motg->id.conn, ext_id->name, | 1598 | ret = extcon_register_notifier(ext_id, EXTCON_USB_HOST, |
1582 | "USB-HOST", &motg->id.nb); | 1599 | &motg->id.nb); |
1583 | if (ret < 0) { | 1600 | if (ret < 0) { |
1584 | dev_err(&pdev->dev, "register ID notifier failed\n"); | 1601 | dev_err(&pdev->dev, "register ID notifier failed\n"); |
1585 | return ret; | 1602 | return ret; |
1586 | } | 1603 | } |
1587 | 1604 | ||
1588 | ret = extcon_get_cable_state(ext_id, "USB-HOST"); | 1605 | ret = extcon_get_cable_state_(ext_id, EXTCON_USB_HOST); |
1589 | if (ret) | 1606 | if (ret) |
1590 | clear_bit(ID, &motg->inputs); | 1607 | clear_bit(ID, &motg->inputs); |
1591 | else | 1608 | else |
@@ -1615,6 +1632,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1615 | return 0; | 1632 | return 0; |
1616 | } | 1633 | } |
1617 | 1634 | ||
1635 | static int msm_otg_reboot_notify(struct notifier_block *this, | ||
1636 | unsigned long code, void *unused) | ||
1637 | { | ||
1638 | struct msm_otg *motg = container_of(this, struct msm_otg, reboot); | ||
1639 | |||
1640 | /* | ||
1641 | * Ensure that D+/D- lines are routed to uB connector, so | ||
1642 | * we could load bootloader/kernel at next reboot | ||
1643 | */ | ||
1644 | gpiod_set_value_cansleep(motg->switch_gpio, 0); | ||
1645 | return NOTIFY_DONE; | ||
1646 | } | ||
1647 | |||
1618 | static int msm_otg_probe(struct platform_device *pdev) | 1648 | static int msm_otg_probe(struct platform_device *pdev) |
1619 | { | 1649 | { |
1620 | struct regulator_bulk_data regs[3]; | 1650 | struct regulator_bulk_data regs[3]; |
@@ -1779,6 +1809,17 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1779 | dev_dbg(&pdev->dev, "Can not create mode change file\n"); | 1809 | dev_dbg(&pdev->dev, "Can not create mode change file\n"); |
1780 | } | 1810 | } |
1781 | 1811 | ||
1812 | if (test_bit(B_SESS_VLD, &motg->inputs)) { | ||
1813 | /* Switch D+/D- lines to Device connector */ | ||
1814 | gpiod_set_value_cansleep(motg->switch_gpio, 0); | ||
1815 | } else { | ||
1816 | /* Switch D+/D- lines to Hub */ | ||
1817 | gpiod_set_value_cansleep(motg->switch_gpio, 1); | ||
1818 | } | ||
1819 | |||
1820 | motg->reboot.notifier_call = msm_otg_reboot_notify; | ||
1821 | register_reboot_notifier(&motg->reboot); | ||
1822 | |||
1782 | pm_runtime_set_active(&pdev->dev); | 1823 | pm_runtime_set_active(&pdev->dev); |
1783 | pm_runtime_enable(&pdev->dev); | 1824 | pm_runtime_enable(&pdev->dev); |
1784 | 1825 | ||
@@ -1805,10 +1846,16 @@ static int msm_otg_remove(struct platform_device *pdev) | |||
1805 | if (phy->otg->host || phy->otg->gadget) | 1846 | if (phy->otg->host || phy->otg->gadget) |
1806 | return -EBUSY; | 1847 | return -EBUSY; |
1807 | 1848 | ||
1808 | if (motg->id.conn.edev) | 1849 | unregister_reboot_notifier(&motg->reboot); |
1809 | extcon_unregister_interest(&motg->id.conn); | 1850 | |
1810 | if (motg->vbus.conn.edev) | 1851 | /* |
1811 | extcon_unregister_interest(&motg->vbus.conn); | 1852 | * Ensure that D+/D- lines are routed to uB connector, so |
1853 | * we could load bootloader/kernel at next reboot | ||
1854 | */ | ||
1855 | gpiod_set_value_cansleep(motg->switch_gpio, 0); | ||
1856 | |||
1857 | extcon_unregister_notifier(motg->id.extcon, EXTCON_USB_HOST, &motg->id.nb); | ||
1858 | extcon_unregister_notifier(motg->vbus.extcon, EXTCON_USB, &motg->vbus.nb); | ||
1812 | 1859 | ||
1813 | msm_otg_debugfs_cleanup(); | 1860 | msm_otg_debugfs_cleanup(); |
1814 | cancel_delayed_work_sync(&motg->chg_work); | 1861 | cancel_delayed_work_sync(&motg->chg_work); |
diff --git a/drivers/usb/phy/phy-omap-otg.c b/drivers/usb/phy/phy-omap-otg.c index 56ee7603034b..1270906ccb95 100644 --- a/drivers/usb/phy/phy-omap-otg.c +++ b/drivers/usb/phy/phy-omap-otg.c | |||
@@ -30,8 +30,7 @@ struct otg_device { | |||
30 | void __iomem *base; | 30 | void __iomem *base; |
31 | bool id; | 31 | bool id; |
32 | bool vbus; | 32 | bool vbus; |
33 | struct extcon_specific_cable_nb vbus_dev; | 33 | struct extcon_dev *extcon; |
34 | struct extcon_specific_cable_nb id_dev; | ||
35 | struct notifier_block vbus_nb; | 34 | struct notifier_block vbus_nb; |
36 | struct notifier_block id_nb; | 35 | struct notifier_block id_nb; |
37 | }; | 36 | }; |
@@ -106,6 +105,7 @@ static int omap_otg_probe(struct platform_device *pdev) | |||
106 | extcon = extcon_get_extcon_dev(config->extcon); | 105 | extcon = extcon_get_extcon_dev(config->extcon); |
107 | if (!extcon) | 106 | if (!extcon) |
108 | return -EPROBE_DEFER; | 107 | return -EPROBE_DEFER; |
108 | otg_dev->extcon = extcon; | ||
109 | 109 | ||
110 | otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL); | 110 | otg_dev = devm_kzalloc(&pdev->dev, sizeof(*otg_dev), GFP_KERNEL); |
111 | if (!otg_dev) | 111 | if (!otg_dev) |
@@ -118,20 +118,19 @@ static int omap_otg_probe(struct platform_device *pdev) | |||
118 | otg_dev->id_nb.notifier_call = omap_otg_id_notifier; | 118 | otg_dev->id_nb.notifier_call = omap_otg_id_notifier; |
119 | otg_dev->vbus_nb.notifier_call = omap_otg_vbus_notifier; | 119 | otg_dev->vbus_nb.notifier_call = omap_otg_vbus_notifier; |
120 | 120 | ||
121 | ret = extcon_register_interest(&otg_dev->id_dev, config->extcon, | 121 | ret = extcon_register_notifier(extcon, EXTCON_USB_HOST, &otg_dev->id_nb); |
122 | "USB-HOST", &otg_dev->id_nb); | ||
123 | if (ret) | 122 | if (ret) |
124 | return ret; | 123 | return ret; |
125 | 124 | ||
126 | ret = extcon_register_interest(&otg_dev->vbus_dev, config->extcon, | 125 | ret = extcon_register_notifier(extcon, EXTCON_USB, &otg_dev->vbus_nb); |
127 | "USB", &otg_dev->vbus_nb); | ||
128 | if (ret) { | 126 | if (ret) { |
129 | extcon_unregister_interest(&otg_dev->id_dev); | 127 | extcon_unregister_notifier(extcon, EXTCON_USB_HOST, |
128 | &otg_dev->id_nb); | ||
130 | return ret; | 129 | return ret; |
131 | } | 130 | } |
132 | 131 | ||
133 | otg_dev->id = extcon_get_cable_state(extcon, "USB-HOST"); | 132 | otg_dev->id = extcon_get_cable_state_(extcon, EXTCON_USB_HOST); |
134 | otg_dev->vbus = extcon_get_cable_state(extcon, "USB"); | 133 | otg_dev->vbus = extcon_get_cable_state_(extcon, EXTCON_USB); |
135 | omap_otg_set_mode(otg_dev); | 134 | omap_otg_set_mode(otg_dev); |
136 | 135 | ||
137 | rev = readl(otg_dev->base); | 136 | rev = readl(otg_dev->base); |
@@ -147,9 +146,10 @@ static int omap_otg_probe(struct platform_device *pdev) | |||
147 | static int omap_otg_remove(struct platform_device *pdev) | 146 | static int omap_otg_remove(struct platform_device *pdev) |
148 | { | 147 | { |
149 | struct otg_device *otg_dev = platform_get_drvdata(pdev); | 148 | struct otg_device *otg_dev = platform_get_drvdata(pdev); |
149 | struct extcon_dev *edev = otg_dev->extcon; | ||
150 | 150 | ||
151 | extcon_unregister_interest(&otg_dev->id_dev); | 151 | extcon_unregister_notifier(edev, EXTCON_USB_HOST,&otg_dev->id_nb); |
152 | extcon_unregister_interest(&otg_dev->vbus_dev); | 152 | extcon_unregister_notifier(edev, EXTCON_USB, &otg_dev->vbus_nb); |
153 | 153 | ||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c b/drivers/usb/phy/phy-qcom-8x16-usb.c new file mode 100644 index 000000000000..5d357a94599e --- /dev/null +++ b/drivers/usb/phy/phy-qcom-8x16-usb.c | |||
@@ -0,0 +1,436 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2015, Linaro Limited | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 and | ||
6 | * only version 2 as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/clk.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/extcon.h> | ||
19 | #include <linux/gpio/consumer.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/of.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/reboot.h> | ||
25 | #include <linux/regulator/consumer.h> | ||
26 | #include <linux/reset.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/usb.h> | ||
29 | #include <linux/usb/ulpi.h> | ||
30 | |||
31 | #define HSPHY_AHBBURST 0x0090 | ||
32 | #define HSPHY_AHBMODE 0x0098 | ||
33 | #define HSPHY_GENCONFIG 0x009c | ||
34 | #define HSPHY_GENCONFIG_2 0x00a0 | ||
35 | |||
36 | #define HSPHY_USBCMD 0x0140 | ||
37 | #define HSPHY_ULPI_VIEWPORT 0x0170 | ||
38 | #define HSPHY_CTRL 0x0240 | ||
39 | |||
40 | #define HSPHY_TXFIFO_IDLE_FORCE_DIS BIT(4) | ||
41 | #define HSPHY_SESS_VLD_CTRL_EN BIT(7) | ||
42 | #define HSPHY_POR_ASSERT BIT(0) | ||
43 | #define HSPHY_RETEN BIT(1) | ||
44 | |||
45 | #define HSPHY_SESS_VLD_CTRL BIT(25) | ||
46 | |||
47 | #define ULPI_PWR_CLK_MNG_REG 0x88 | ||
48 | #define ULPI_PWR_OTG_COMP_DISABLE BIT(0) | ||
49 | |||
50 | #define ULPI_MISC_A 0x96 | ||
51 | #define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1) | ||
52 | #define ULPI_MISC_A_VBUSVLDEXT BIT(0) | ||
53 | |||
54 | #define HSPHY_3P3_MIN 3050000 /* uV */ | ||
55 | #define HSPHY_3P3_MAX 3300000 /* uV */ | ||
56 | |||
57 | #define HSPHY_1P8_MIN 1800000 /* uV */ | ||
58 | #define HSPHY_1P8_MAX 1800000 /* uV */ | ||
59 | |||
60 | #define HSPHY_VDD_MIN 5 | ||
61 | #define HSPHY_VDD_MAX 7 | ||
62 | |||
63 | struct phy_8x16 { | ||
64 | struct usb_phy phy; | ||
65 | void __iomem *regs; | ||
66 | struct clk *core_clk; | ||
67 | struct clk *iface_clk; | ||
68 | struct regulator *v3p3; | ||
69 | struct regulator *v1p8; | ||
70 | struct regulator *vdd; | ||
71 | |||
72 | struct reset_control *phy_reset; | ||
73 | |||
74 | struct extcon_specific_cable_nb vbus_cable; | ||
75 | struct notifier_block vbus_notify; | ||
76 | |||
77 | struct gpio_desc *switch_gpio; | ||
78 | struct notifier_block reboot_notify; | ||
79 | }; | ||
80 | |||
81 | static int phy_8x16_regulators_enable(struct phy_8x16 *qphy) | ||
82 | { | ||
83 | int ret; | ||
84 | |||
85 | ret = regulator_set_voltage(qphy->vdd, HSPHY_VDD_MIN, HSPHY_VDD_MAX); | ||
86 | if (ret) | ||
87 | return ret; | ||
88 | |||
89 | ret = regulator_enable(qphy->vdd); | ||
90 | if (ret) | ||
91 | return ret; | ||
92 | |||
93 | ret = regulator_set_voltage(qphy->v3p3, HSPHY_3P3_MIN, HSPHY_3P3_MAX); | ||
94 | if (ret) | ||
95 | goto off_vdd; | ||
96 | |||
97 | ret = regulator_enable(qphy->v3p3); | ||
98 | if (ret) | ||
99 | goto off_vdd; | ||
100 | |||
101 | ret = regulator_set_voltage(qphy->v1p8, HSPHY_1P8_MIN, HSPHY_1P8_MAX); | ||
102 | if (ret) | ||
103 | goto off_3p3; | ||
104 | |||
105 | ret = regulator_enable(qphy->v1p8); | ||
106 | if (ret) | ||
107 | goto off_3p3; | ||
108 | |||
109 | return 0; | ||
110 | |||
111 | off_3p3: | ||
112 | regulator_disable(qphy->v3p3); | ||
113 | off_vdd: | ||
114 | regulator_disable(qphy->vdd); | ||
115 | |||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | static void phy_8x16_regulators_disable(struct phy_8x16 *qphy) | ||
120 | { | ||
121 | regulator_disable(qphy->v1p8); | ||
122 | regulator_disable(qphy->v3p3); | ||
123 | regulator_disable(qphy->vdd); | ||
124 | } | ||
125 | |||
126 | static int phy_8x16_notify_connect(struct usb_phy *phy, | ||
127 | enum usb_device_speed speed) | ||
128 | { | ||
129 | struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); | ||
130 | u32 val; | ||
131 | |||
132 | val = ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT; | ||
133 | usb_phy_io_write(&qphy->phy, val, ULPI_SET(ULPI_MISC_A)); | ||
134 | |||
135 | val = readl(qphy->regs + HSPHY_USBCMD); | ||
136 | val |= HSPHY_SESS_VLD_CTRL; | ||
137 | writel(val, qphy->regs + HSPHY_USBCMD); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static int phy_8x16_notify_disconnect(struct usb_phy *phy, | ||
143 | enum usb_device_speed speed) | ||
144 | { | ||
145 | struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); | ||
146 | u32 val; | ||
147 | |||
148 | val = ULPI_MISC_A_VBUSVLDEXT | ULPI_MISC_A_VBUSVLDEXTSEL; | ||
149 | usb_phy_io_write(&qphy->phy, val, ULPI_CLR(ULPI_MISC_A)); | ||
150 | |||
151 | val = readl(qphy->regs + HSPHY_USBCMD); | ||
152 | val &= ~HSPHY_SESS_VLD_CTRL; | ||
153 | writel(val, qphy->regs + HSPHY_USBCMD); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static int phy_8x16_vbus_on(struct phy_8x16 *qphy) | ||
159 | { | ||
160 | phy_8x16_notify_connect(&qphy->phy, USB_SPEED_UNKNOWN); | ||
161 | |||
162 | /* Switch D+/D- lines to Device connector */ | ||
163 | gpiod_set_value_cansleep(qphy->switch_gpio, 0); | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | static int phy_8x16_vbus_off(struct phy_8x16 *qphy) | ||
169 | { | ||
170 | phy_8x16_notify_disconnect(&qphy->phy, USB_SPEED_UNKNOWN); | ||
171 | |||
172 | /* Switch D+/D- lines to USB HUB */ | ||
173 | gpiod_set_value_cansleep(qphy->switch_gpio, 1); | ||
174 | |||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | static int phy_8x16_vbus_notify(struct notifier_block *nb, unsigned long event, | ||
179 | void *ptr) | ||
180 | { | ||
181 | struct phy_8x16 *qphy = container_of(nb, struct phy_8x16, vbus_notify); | ||
182 | |||
183 | if (event) | ||
184 | phy_8x16_vbus_on(qphy); | ||
185 | else | ||
186 | phy_8x16_vbus_off(qphy); | ||
187 | |||
188 | return NOTIFY_DONE; | ||
189 | } | ||
190 | |||
191 | static int phy_8x16_init(struct usb_phy *phy) | ||
192 | { | ||
193 | struct phy_8x16 *qphy = container_of(phy, struct phy_8x16, phy); | ||
194 | u32 val, init[] = {0x44, 0x6B, 0x24, 0x13}; | ||
195 | u32 addr = ULPI_EXT_VENDOR_SPECIFIC; | ||
196 | int idx, state; | ||
197 | |||
198 | for (idx = 0; idx < ARRAY_SIZE(init); idx++) | ||
199 | usb_phy_io_write(phy, init[idx], addr + idx); | ||
200 | |||
201 | reset_control_reset(qphy->phy_reset); | ||
202 | |||
203 | /* Assert USB HSPHY_POR */ | ||
204 | val = readl(qphy->regs + HSPHY_CTRL); | ||
205 | val |= HSPHY_POR_ASSERT; | ||
206 | writel(val, qphy->regs + HSPHY_CTRL); | ||
207 | |||
208 | /* | ||
209 | * wait for minimum 10 microseconds as suggested in HPG. | ||
210 | * Use a slightly larger value since the exact value didn't | ||
211 | * work 100% of the time. | ||
212 | */ | ||
213 | usleep_range(12, 15); | ||
214 | |||
215 | /* Deassert USB HSPHY_POR */ | ||
216 | val = readl(qphy->regs + HSPHY_CTRL); | ||
217 | val &= ~HSPHY_POR_ASSERT; | ||
218 | writel(val, qphy->regs + HSPHY_CTRL); | ||
219 | |||
220 | usleep_range(10, 15); | ||
221 | |||
222 | writel(0x00, qphy->regs + HSPHY_AHBBURST); | ||
223 | writel(0x08, qphy->regs + HSPHY_AHBMODE); | ||
224 | |||
225 | /* workaround for rx buffer collision issue */ | ||
226 | val = readl(qphy->regs + HSPHY_GENCONFIG); | ||
227 | val &= ~HSPHY_TXFIFO_IDLE_FORCE_DIS; | ||
228 | writel(val, qphy->regs + HSPHY_GENCONFIG); | ||
229 | |||
230 | val = readl(qphy->regs + HSPHY_GENCONFIG_2); | ||
231 | val |= HSPHY_SESS_VLD_CTRL_EN; | ||
232 | writel(val, qphy->regs + HSPHY_GENCONFIG_2); | ||
233 | |||
234 | val = ULPI_PWR_OTG_COMP_DISABLE; | ||
235 | usb_phy_io_write(phy, val, ULPI_SET(ULPI_PWR_CLK_MNG_REG)); | ||
236 | |||
237 | state = extcon_get_cable_state(qphy->vbus_cable.edev, "USB"); | ||
238 | if (state) | ||
239 | phy_8x16_vbus_on(qphy); | ||
240 | else | ||
241 | phy_8x16_vbus_off(qphy); | ||
242 | |||
243 | val = usb_phy_io_read(&qphy->phy, ULPI_FUNC_CTRL); | ||
244 | val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; | ||
245 | val |= ULPI_FUNC_CTRL_OPMODE_NORMAL; | ||
246 | usb_phy_io_write(&qphy->phy, val, ULPI_FUNC_CTRL); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | static void phy_8x16_shutdown(struct usb_phy *phy) | ||
252 | { | ||
253 | u32 val; | ||
254 | |||
255 | /* Put the controller in non-driving mode */ | ||
256 | val = usb_phy_io_read(phy, ULPI_FUNC_CTRL); | ||
257 | val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; | ||
258 | val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | ||
259 | usb_phy_io_write(phy, val, ULPI_FUNC_CTRL); | ||
260 | } | ||
261 | |||
262 | static int phy_8x16_read_devicetree(struct phy_8x16 *qphy) | ||
263 | { | ||
264 | struct regulator_bulk_data regs[3]; | ||
265 | struct device *dev = qphy->phy.dev; | ||
266 | int ret; | ||
267 | |||
268 | qphy->core_clk = devm_clk_get(dev, "core"); | ||
269 | if (IS_ERR(qphy->core_clk)) | ||
270 | return PTR_ERR(qphy->core_clk); | ||
271 | |||
272 | qphy->iface_clk = devm_clk_get(dev, "iface"); | ||
273 | if (IS_ERR(qphy->iface_clk)) | ||
274 | return PTR_ERR(qphy->iface_clk); | ||
275 | |||
276 | regs[0].supply = "v3p3"; | ||
277 | regs[1].supply = "v1p8"; | ||
278 | regs[2].supply = "vddcx"; | ||
279 | |||
280 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(regs), regs); | ||
281 | if (ret) | ||
282 | return ret; | ||
283 | |||
284 | qphy->v3p3 = regs[0].consumer; | ||
285 | qphy->v1p8 = regs[1].consumer; | ||
286 | qphy->vdd = regs[2].consumer; | ||
287 | |||
288 | qphy->phy_reset = devm_reset_control_get(dev, "phy"); | ||
289 | if (IS_ERR(qphy->phy_reset)) | ||
290 | return PTR_ERR(qphy->phy_reset); | ||
291 | |||
292 | qphy->switch_gpio = devm_gpiod_get_optional(dev, "switch", | ||
293 | GPIOD_OUT_LOW); | ||
294 | if (IS_ERR(qphy->switch_gpio)) | ||
295 | return PTR_ERR(qphy->switch_gpio); | ||
296 | |||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static int phy_8x16_reboot_notify(struct notifier_block *this, | ||
301 | unsigned long code, void *unused) | ||
302 | { | ||
303 | struct phy_8x16 *qphy; | ||
304 | |||
305 | qphy = container_of(this, struct phy_8x16, reboot_notify); | ||
306 | |||
307 | /* | ||
308 | * Ensure that D+/D- lines are routed to uB connector, so | ||
309 | * we could load bootloader/kernel at next reboot_notify | ||
310 | */ | ||
311 | gpiod_set_value_cansleep(qphy->switch_gpio, 0); | ||
312 | return NOTIFY_DONE; | ||
313 | } | ||
314 | |||
315 | static int phy_8x16_probe(struct platform_device *pdev) | ||
316 | { | ||
317 | struct extcon_dev *edev; | ||
318 | struct phy_8x16 *qphy; | ||
319 | struct resource *res; | ||
320 | struct usb_phy *phy; | ||
321 | int ret; | ||
322 | |||
323 | qphy = devm_kzalloc(&pdev->dev, sizeof(*qphy), GFP_KERNEL); | ||
324 | if (!qphy) | ||
325 | return -ENOMEM; | ||
326 | |||
327 | platform_set_drvdata(pdev, qphy); | ||
328 | |||
329 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
330 | if (!res) | ||
331 | return -EINVAL; | ||
332 | |||
333 | qphy->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); | ||
334 | if (!qphy->regs) | ||
335 | return -ENOMEM; | ||
336 | |||
337 | phy = &qphy->phy; | ||
338 | phy->dev = &pdev->dev; | ||
339 | phy->label = dev_name(&pdev->dev); | ||
340 | phy->init = phy_8x16_init; | ||
341 | phy->shutdown = phy_8x16_shutdown; | ||
342 | phy->notify_connect = phy_8x16_notify_connect; | ||
343 | phy->notify_disconnect = phy_8x16_notify_disconnect; | ||
344 | phy->io_priv = qphy->regs + HSPHY_ULPI_VIEWPORT; | ||
345 | phy->io_ops = &ulpi_viewport_access_ops; | ||
346 | phy->type = USB_PHY_TYPE_USB2; | ||
347 | |||
348 | ret = phy_8x16_read_devicetree(qphy); | ||
349 | if (ret < 0) | ||
350 | return ret; | ||
351 | |||
352 | edev = extcon_get_edev_by_phandle(phy->dev, 0); | ||
353 | if (IS_ERR(edev)) | ||
354 | return PTR_ERR(edev); | ||
355 | |||
356 | ret = clk_set_rate(qphy->core_clk, INT_MAX); | ||
357 | if (ret < 0) | ||
358 | dev_dbg(phy->dev, "Can't boost core clock\n"); | ||
359 | |||
360 | ret = clk_prepare_enable(qphy->core_clk); | ||
361 | if (ret < 0) | ||
362 | return ret; | ||
363 | |||
364 | ret = clk_prepare_enable(qphy->iface_clk); | ||
365 | if (ret < 0) | ||
366 | goto off_core; | ||
367 | |||
368 | ret = phy_8x16_regulators_enable(qphy); | ||
369 | if (0 && ret) | ||
370 | goto off_clks; | ||
371 | |||
372 | qphy->vbus_notify.notifier_call = phy_8x16_vbus_notify; | ||
373 | ret = extcon_register_interest(&qphy->vbus_cable, edev->name, | ||
374 | "USB", &qphy->vbus_notify); | ||
375 | if (ret < 0) | ||
376 | goto off_power; | ||
377 | |||
378 | ret = usb_add_phy_dev(&qphy->phy); | ||
379 | if (ret) | ||
380 | goto off_extcon; | ||
381 | |||
382 | qphy->reboot_notify.notifier_call = phy_8x16_reboot_notify; | ||
383 | register_reboot_notifier(&qphy->reboot_notify); | ||
384 | |||
385 | return 0; | ||
386 | |||
387 | off_extcon: | ||
388 | extcon_unregister_interest(&qphy->vbus_cable); | ||
389 | off_power: | ||
390 | phy_8x16_regulators_disable(qphy); | ||
391 | off_clks: | ||
392 | clk_disable_unprepare(qphy->iface_clk); | ||
393 | off_core: | ||
394 | clk_disable_unprepare(qphy->core_clk); | ||
395 | return ret; | ||
396 | } | ||
397 | |||
398 | static int phy_8x16_remove(struct platform_device *pdev) | ||
399 | { | ||
400 | struct phy_8x16 *qphy = platform_get_drvdata(pdev); | ||
401 | |||
402 | unregister_reboot_notifier(&qphy->reboot_notify); | ||
403 | extcon_unregister_interest(&qphy->vbus_cable); | ||
404 | |||
405 | /* | ||
406 | * Ensure that D+/D- lines are routed to uB connector, so | ||
407 | * we could load bootloader/kernel at next reboot_notify | ||
408 | */ | ||
409 | gpiod_set_value_cansleep(qphy->switch_gpio, 0); | ||
410 | |||
411 | usb_remove_phy(&qphy->phy); | ||
412 | |||
413 | clk_disable_unprepare(qphy->iface_clk); | ||
414 | clk_disable_unprepare(qphy->core_clk); | ||
415 | phy_8x16_regulators_disable(qphy); | ||
416 | return 0; | ||
417 | } | ||
418 | |||
419 | static const struct of_device_id phy_8x16_dt_match[] = { | ||
420 | { .compatible = "qcom,usb-8x16-phy" }, | ||
421 | { } | ||
422 | }; | ||
423 | MODULE_DEVICE_TABLE(of, phy_8x16_dt_match); | ||
424 | |||
425 | static struct platform_driver phy_8x16_driver = { | ||
426 | .probe = phy_8x16_probe, | ||
427 | .remove = phy_8x16_remove, | ||
428 | .driver = { | ||
429 | .name = "phy-qcom-8x16-usb", | ||
430 | .of_match_table = phy_8x16_dt_match, | ||
431 | }, | ||
432 | }; | ||
433 | module_platform_driver(phy_8x16_driver); | ||
434 | |||
435 | MODULE_LICENSE("GPL v2"); | ||
436 | MODULE_DESCRIPTION("Qualcomm APQ8016/MSM8916 chipsets USB transceiver driver"); | ||
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c index b40d6a87d694..ab5d364f6e8c 100644 --- a/drivers/usb/phy/phy-tahvo.c +++ b/drivers/usb/phy/phy-tahvo.c | |||
@@ -57,7 +57,7 @@ struct tahvo_usb { | |||
57 | struct clk *ick; | 57 | struct clk *ick; |
58 | int irq; | 58 | int irq; |
59 | int tahvo_mode; | 59 | int tahvo_mode; |
60 | struct extcon_dev extcon; | 60 | struct extcon_dev *extcon; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static const unsigned int tahvo_cable[] = { | 63 | static const unsigned int tahvo_cable[] = { |
@@ -121,7 +121,7 @@ static void check_vbus_state(struct tahvo_usb *tu) | |||
121 | prev_state = tu->vbus_state; | 121 | prev_state = tu->vbus_state; |
122 | tu->vbus_state = reg & TAHVO_STAT_VBUS; | 122 | tu->vbus_state = reg & TAHVO_STAT_VBUS; |
123 | if (prev_state != tu->vbus_state) { | 123 | if (prev_state != tu->vbus_state) { |
124 | extcon_set_cable_state(&tu->extcon, "USB", tu->vbus_state); | 124 | extcon_set_cable_state_(tu->extcon, EXTCON_USB, tu->vbus_state); |
125 | sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state"); | 125 | sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state"); |
126 | } | 126 | } |
127 | } | 127 | } |
@@ -130,7 +130,7 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu) | |||
130 | { | 130 | { |
131 | struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); | 131 | struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); |
132 | 132 | ||
133 | extcon_set_cable_state(&tu->extcon, "USB-HOST", true); | 133 | extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST, true); |
134 | 134 | ||
135 | /* Power up the transceiver in USB host mode */ | 135 | /* Power up the transceiver in USB host mode */ |
136 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | | 136 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | |
@@ -149,7 +149,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) | |||
149 | { | 149 | { |
150 | struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); | 150 | struct retu_dev *rdev = dev_get_drvdata(tu->pt_dev->dev.parent); |
151 | 151 | ||
152 | extcon_set_cable_state(&tu->extcon, "USB-HOST", false); | 152 | extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST, false); |
153 | 153 | ||
154 | /* Power up transceiver and set it in USB peripheral mode */ | 154 | /* Power up transceiver and set it in USB peripheral mode */ |
155 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | | 155 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | |
@@ -365,11 +365,13 @@ static int tahvo_usb_probe(struct platform_device *pdev) | |||
365 | */ | 365 | */ |
366 | tu->vbus_state = retu_read(rdev, TAHVO_REG_IDSR) & TAHVO_STAT_VBUS; | 366 | tu->vbus_state = retu_read(rdev, TAHVO_REG_IDSR) & TAHVO_STAT_VBUS; |
367 | 367 | ||
368 | tu->extcon.name = DRIVER_NAME; | 368 | tu->extcon = devm_extcon_dev_allocate(&pdev->dev, tahvo_cable); |
369 | tu->extcon.supported_cable = tahvo_cable; | 369 | if (IS_ERR(tu->extcon)) { |
370 | tu->extcon.dev.parent = &pdev->dev; | 370 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
371 | return -ENOMEM; | ||
372 | } | ||
371 | 373 | ||
372 | ret = extcon_dev_register(&tu->extcon); | 374 | ret = devm_extcon_dev_register(&pdev->dev, tu->extcon); |
373 | if (ret) { | 375 | if (ret) { |
374 | dev_err(&pdev->dev, "could not register extcon device: %d\n", | 376 | dev_err(&pdev->dev, "could not register extcon device: %d\n", |
375 | ret); | 377 | ret); |
@@ -377,9 +379,9 @@ static int tahvo_usb_probe(struct platform_device *pdev) | |||
377 | } | 379 | } |
378 | 380 | ||
379 | /* Set the initial cable state. */ | 381 | /* Set the initial cable state. */ |
380 | extcon_set_cable_state(&tu->extcon, "USB-HOST", | 382 | extcon_set_cable_state_(tu->extcon, EXTCON_USB_HOST, |
381 | tu->tahvo_mode == TAHVO_MODE_HOST); | 383 | tu->tahvo_mode == TAHVO_MODE_HOST); |
382 | extcon_set_cable_state(&tu->extcon, "USB", tu->vbus_state); | 384 | extcon_set_cable_state_(tu->extcon, EXTCON_USB, tu->vbus_state); |
383 | 385 | ||
384 | /* Create OTG interface */ | 386 | /* Create OTG interface */ |
385 | tahvo_usb_power_off(tu); | 387 | tahvo_usb_power_off(tu); |
@@ -396,7 +398,7 @@ static int tahvo_usb_probe(struct platform_device *pdev) | |||
396 | if (ret < 0) { | 398 | if (ret < 0) { |
397 | dev_err(&pdev->dev, "cannot register USB transceiver: %d\n", | 399 | dev_err(&pdev->dev, "cannot register USB transceiver: %d\n", |
398 | ret); | 400 | ret); |
399 | goto err_extcon_unreg; | 401 | goto err_disable_clk; |
400 | } | 402 | } |
401 | 403 | ||
402 | dev_set_drvdata(&pdev->dev, tu); | 404 | dev_set_drvdata(&pdev->dev, tu); |
@@ -424,8 +426,6 @@ err_free_irq: | |||
424 | free_irq(tu->irq, tu); | 426 | free_irq(tu->irq, tu); |
425 | err_remove_phy: | 427 | err_remove_phy: |
426 | usb_remove_phy(&tu->phy); | 428 | usb_remove_phy(&tu->phy); |
427 | err_extcon_unreg: | ||
428 | extcon_dev_unregister(&tu->extcon); | ||
429 | err_disable_clk: | 429 | err_disable_clk: |
430 | if (!IS_ERR(tu->ick)) | 430 | if (!IS_ERR(tu->ick)) |
431 | clk_disable(tu->ick); | 431 | clk_disable(tu->ick); |
@@ -440,7 +440,6 @@ static int tahvo_usb_remove(struct platform_device *pdev) | |||
440 | sysfs_remove_group(&pdev->dev.kobj, &tahvo_attr_group); | 440 | sysfs_remove_group(&pdev->dev.kobj, &tahvo_attr_group); |
441 | free_irq(tu->irq, tu); | 441 | free_irq(tu->irq, tu); |
442 | usb_remove_phy(&tu->phy); | 442 | usb_remove_phy(&tu->phy); |
443 | extcon_dev_unregister(&tu->extcon); | ||
444 | if (!IS_ERR(tu->ick)) | 443 | if (!IS_ERR(tu->ick)) |
445 | clk_disable(tu->ick); | 444 | clk_disable(tu->ick); |
446 | 445 | ||
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index e8bf40808b39..7b98e1d9194c 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -388,7 +388,7 @@ static void usbhsc_hotplug(struct usbhs_priv *priv) | |||
388 | 388 | ||
389 | if (enable && !mod) { | 389 | if (enable && !mod) { |
390 | if (priv->edev) { | 390 | if (priv->edev) { |
391 | cable = extcon_get_cable_state(priv->edev, "USB-HOST"); | 391 | cable = extcon_get_cable_state_(priv->edev, EXTCON_USB_HOST); |
392 | if ((cable > 0 && id != USBHS_HOST) || | 392 | if ((cable > 0 && id != USBHS_HOST) || |
393 | (!cable && id != USBHS_GADGET)) { | 393 | (!cable && id != USBHS_GADGET)) { |
394 | dev_info(&pdev->dev, | 394 | dev_info(&pdev->dev, |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 54f916fa238d..de4f97d84a82 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -52,7 +52,7 @@ struct usbhsg_gpriv { | |||
52 | 52 | ||
53 | struct usb_gadget_driver *driver; | 53 | struct usb_gadget_driver *driver; |
54 | struct usb_phy *transceiver; | 54 | struct usb_phy *transceiver; |
55 | bool vbus_active; | 55 | bool vbus_active; |
56 | 56 | ||
57 | u32 status; | 57 | u32 status; |
58 | #define USBHSG_STATUS_STARTED (1 << 0) | 58 | #define USBHSG_STATUS_STARTED (1 << 0) |
@@ -1103,12 +1103,18 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
1103 | if (usbhsg_is_dcp(uep)) { | 1103 | if (usbhsg_is_dcp(uep)) { |
1104 | gpriv->gadget.ep0 = &uep->ep; | 1104 | gpriv->gadget.ep0 = &uep->ep; |
1105 | usb_ep_set_maxpacket_limit(&uep->ep, 64); | 1105 | usb_ep_set_maxpacket_limit(&uep->ep, 64); |
1106 | uep->ep.caps.type_control = true; | ||
1106 | } | 1107 | } |
1107 | /* init normal pipe */ | 1108 | /* init normal pipe */ |
1108 | else { | 1109 | else { |
1109 | usb_ep_set_maxpacket_limit(&uep->ep, 512); | 1110 | usb_ep_set_maxpacket_limit(&uep->ep, 512); |
1111 | uep->ep.caps.type_iso = true; | ||
1112 | uep->ep.caps.type_bulk = true; | ||
1113 | uep->ep.caps.type_int = true; | ||
1110 | list_add_tail(&uep->ep.ep_list, &gpriv->gadget.ep_list); | 1114 | list_add_tail(&uep->ep.ep_list, &gpriv->gadget.ep_list); |
1111 | } | 1115 | } |
1116 | uep->ep.caps.dir_in = true; | ||
1117 | uep->ep.caps.dir_out = true; | ||
1112 | } | 1118 | } |
1113 | 1119 | ||
1114 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); | 1120 | ret = usb_add_gadget_udc(dev, &gpriv->gadget); |
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 575eaf0ebac1..a41833cd184c 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h | |||
@@ -41,6 +41,7 @@ struct ci_hdrc_platform_data { | |||
41 | #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 | 41 | #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 |
42 | void (*notify_event) (struct ci_hdrc *ci, unsigned event); | 42 | void (*notify_event) (struct ci_hdrc *ci, unsigned event); |
43 | struct regulator *reg_vbus; | 43 | struct regulator *reg_vbus; |
44 | struct usb_otg_caps ci_otg_caps; | ||
44 | bool tpl_support; | 45 | bool tpl_support; |
45 | /* interrupt threshold setting */ | 46 | /* interrupt threshold setting */ |
46 | u32 itc_setting; | 47 | u32 itc_setting; |
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 | ||
233 | int usb_add_function(struct usb_configuration *, struct usb_function *); | 235 | int 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 | */ | ||
152 | struct 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 | |||
170 | struct usb_ep { | 210 | struct 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 | */ | ||
664 | static 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 | */ | ||
673 | static 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 | */ | ||
682 | static 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 | */ |
772 | static inline int usb_gadget_connect(struct usb_gadget *gadget) | 854 | static 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 | */ | ||
886 | static 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 | */ |
794 | static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | 919 | static 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 | */ | ||
950 | static 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); |
1003 | void usb_free_all_descriptors(struct usb_function *f); | 1168 | void usb_free_all_descriptors(struct usb_function *f); |
1004 | 1169 | ||
1170 | struct usb_descriptor_header *usb_otg_descriptor_alloc( | ||
1171 | struct usb_gadget *gadget); | ||
1172 | int 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 | |||
1208 | extern 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 | |||
1215 | extern 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 */ |
1038 | extern void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status); | 1222 | extern 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 | */ |
129 | struct msm_usb_cable { | 129 | struct 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 | */ |
159 | struct msm_otg { | 163 | struct 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 @@ | |||
15 | enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); | 15 | enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); |
16 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); | 16 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); |
17 | bool of_usb_host_tpl_support(struct device_node *np); | 17 | bool of_usb_host_tpl_support(struct device_node *np); |
18 | int of_usb_update_otg_caps(struct device_node *np, | ||
19 | struct usb_otg_caps *otg_caps); | ||
18 | #else | 20 | #else |
19 | static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) | 21 | static 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 | } |
35 | static 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 | */ | ||
52 | struct usb_otg_caps { | ||
53 | u16 otg_rev; | ||
54 | bool hnp_support; | ||
55 | bool srp_support; | ||
56 | bool adp_support; | ||
57 | }; | ||
58 | |||
44 | extern const char *usb_otg_state_string(enum usb_otg_state state); | 59 | extern const char *usb_otg_state_string(enum usb_otg_state state); |
45 | 60 | ||
46 | /* Context: can sleep */ | 61 | /* Context: can sleep */ |
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index aa33fd1b2d4f..f7adc6e01f9e 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h | |||
@@ -674,9 +674,21 @@ struct usb_otg_descriptor { | |||
674 | __u8 bmAttributes; /* support for HNP, SRP, etc */ | 674 | __u8 bmAttributes; /* support for HNP, SRP, etc */ |
675 | } __attribute__ ((packed)); | 675 | } __attribute__ ((packed)); |
676 | 676 | ||
677 | /* USB_DT_OTG (from OTG 2.0 supplement) */ | ||
678 | struct usb_otg20_descriptor { | ||
679 | __u8 bLength; | ||
680 | __u8 bDescriptorType; | ||
681 | |||
682 | __u8 bmAttributes; /* support for HNP, SRP and ADP, etc */ | ||
683 | __le16 bcdOTG; /* OTG and EH supplement release number | ||
684 | * in binary-coded decimal(i.e. 2.0 is 0200H) | ||
685 | */ | ||
686 | } __attribute__ ((packed)); | ||
687 | |||
677 | /* from usb_otg_descriptor.bmAttributes */ | 688 | /* from usb_otg_descriptor.bmAttributes */ |
678 | #define USB_OTG_SRP (1 << 0) | 689 | #define USB_OTG_SRP (1 << 0) |
679 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | 690 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ |
691 | #define USB_OTG_ADP (1 << 2) /* support ADP */ | ||
680 | 692 | ||
681 | /*-------------------------------------------------------------------------*/ | 693 | /*-------------------------------------------------------------------------*/ |
682 | 694 | ||