On Wed, Mar 25, 2015 at 06:04:17PM +0800, Macpaul Lin wrote:
> Add OTG 2.0 descriptors and enable the gadget function.
> This change has been tested with USB-IF Compliance
> PET TEST: OTG-B VBUS.mpet testing item.
>
> Signed-off-by: Macpaul Lin <[email protected]>
> ---
> drivers/usb/core/Kconfig | 9 +++++++++
> drivers/usb/gadget/composite.c | 12 ++++++++++++
> drivers/usb/gadget/legacy/multi.c | 3 +++
> include/uapi/linux/usb/ch9.h | 3 +++
> 4 files changed, 27 insertions(+)
>
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index cc0ced0..434ce19 100644
> --- a/drivers/usb/core/Kconfig
> +++ b/drivers/usb/core/Kconfig
> @@ -55,6 +55,15 @@ config USB_OTG
> Select this only if your board has Mini-AB/Micro-AB
> connector.
>
> +config USB_OTG20
> + bool "OTG20 support (EXPERIMENTAL)"
> + depends on USB_OTG
> + default n
> + help
> + This feature is still under developing.
> +
> + Select this only if your board support OTG 20's hardware requirements.
> +
> config USB_OTG_WHITELIST
> bool "Rely on OTG and EH Targeted Peripherals List"
> depends on USB
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 13adfd1..2f3d347 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1461,6 +1461,7 @@ composite_setup(struct usb_gadget *gadget, const struct
> usb_ctrlrequest *ctrl)
> u16 w_length = le16_to_cpu(ctrl->wLength);
> struct usb_function *f = NULL;
> u8 endp;
> + struct usb_otg_descriptor *otg_desc = NULL;
>
> /* partial re-init of the response message; the function or the
> * gadget might need to intercept e.g. a control-OUT completion
> @@ -1480,6 +1481,17 @@ composite_setup(struct usb_gadget *gadget, const
> struct usb_ctrlrequest *ctrl)
> goto unknown;
> switch (w_value >> 8) {
>
> +#ifdef CONFIG_USB_OTG20
> + case USB_DT_OTG:
> + otg_desc = (struct usb_otg_descriptor *)req->buf;
> + otg_desc->bLength = sizeof(*otg_desc);
> + otg_desc->bDescriptorType = USB_DT_OTG;
> + otg_desc->bmAttributes = USB_OTG_SRP | USB_OTG_HNP;
Response with both HNP and SRP enabled anyway if OTG 2.0? Actually these
capabilities depend on controller.
Li Jun
> + otg_desc->bcdOTG = cpu_to_le16(0x0200);
> + value = min_t(int, w_length,
> + sizeof(struct usb_otg_descriptor));
> + break;
> +#endif
> case USB_DT_DEVICE:
> cdev->desc.bNumConfigurations =
> count_configs(cdev, USB_DT_DEVICE);
> diff --git a/drivers/usb/gadget/legacy/multi.c
> b/drivers/usb/gadget/legacy/multi.c
> index 39d27bb..0f4005e 100644
> --- a/drivers/usb/gadget/legacy/multi.c
> +++ b/drivers/usb/gadget/legacy/multi.c
> @@ -89,6 +89,9 @@ static const struct usb_descriptor_header *otg_desc[] = {
> * it would not be called "OTG" ...
> */
> .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
> +#ifdef CONFIG_USB_OTG20
> + .bcdOTG = cpu_to_le16(0x0200),
> +#endif
> },
> NULL,
> };
> diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
> index aa33fd1..29e079b 100644
> --- a/include/uapi/linux/usb/ch9.h
> +++ b/include/uapi/linux/usb/ch9.h
> @@ -672,6 +672,9 @@ struct usb_otg_descriptor {
> __u8 bDescriptorType;
>
> __u8 bmAttributes; /* support for HNP, SRP, etc */
> +#ifdef CONFIG_USB_OTG20
> + __le16 bcdOTG; /* Support OTG 2.0 */
> +#endif
> } __attribute__ ((packed));
>
> /* from usb_otg_descriptor.bmAttributes */
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html