On Thu, Mar 26, 2015 at 11:21:43AM +0800, Macpaul Lin wrote:
> Introduce kernel feature CONFIG_USB_OTG20 and related
> gadget_is_otg20() API for supporting OTG20 compliant
> drivers.
> This patch also updated usb_otg_descritpor.
>
> Signed-off-by: Macpaul Lin <[email protected]>
> ---
> drivers/usb/core/Kconfig | 9 +++++++++
> include/linux/usb/gadget.h | 24 ++++++++++++++++++++++++
> include/uapi/linux/usb/ch9.h | 4 ++++
> 3 files changed, 37 insertions(+)
>
> changes for v2:
> - Add USB_OTG_ADP definition in ch9.h
>
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index cc0ced0..7fdda5f 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/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index e2f00fd..e598677 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -512,6 +512,8 @@ struct usb_gadget_ops {
> * @sg_supported: true if we can handle scatter-gather
> * @is_otg: True if the USB device port uses a Mini-AB jack, so that the
> * gadget driver must provide a USB OTG descriptor.
> + * @is_otg20: True if the USB hardware supports OTG 2.0 specification.
> + * The gadget driver must provide USB OTG 2.0 descriptor.
> * @is_a_peripheral: False unless is_otg, the "A" end of a USB cable
> * is in the Mini-AB jack, and HNP has been used to switch roles
> * so that the "A" device currently acts as A-Peripheral, not A-Host.
> @@ -559,6 +561,7 @@ struct usb_gadget {
>
> unsigned sg_supported:1;
> unsigned is_otg:1;
> + unsigned is_otg20:1;
> unsigned is_a_peripheral:1;
> unsigned b_hnp_enable:1;
> unsigned a_hnp_support:1;
> @@ -634,6 +637,23 @@ static inline int gadget_is_otg(struct usb_gadget *g)
> }
>
> /**
> + * gadget_is_otg20 - return true iff the hardware is OTG 2.0-ready
> + * @g: controller that might supports OTG 2.0 specification.
> + *
> + * This is a runtime test, since kernels with a USB-OTG stack sometimes
> + * run on boards which only supports OTG 1.3,
%s/1.3/2.0
> + */
> +static inline int gadget_is_otg20(struct usb_gadget *g)
> +{
> +#ifdef CONFIG_USB_OTG20
> + return g->is_otg20;
> +#else
> + return 0;
> +#endif
> +}
> +
> +
> +/**
> * usb_gadget_frame_number - returns the current frame number
> * @gadget: controller that reports the frame number
> *
> @@ -832,6 +852,10 @@ static inline int usb_gadget_disconnect(struct
> usb_gadget *gadget)
> * having called usb_gadget_disconnect(), and the USB host stack has
> * initialized.
> *
> + * If gadget->is_otg20 is true, the gadget driver must provide an OTG 2.0
> + * descriptor during enumeration, and related behavior must compliant with
> + * OTG 2.0 specificaiton.
> + *
> * Drivers use hardware-specific knowledge to configure the usb hardware.
> * endpoint addressing is only one of several hardware characteristics that
> * are in descriptors the ep0 implementation returns from setup() calls.
> diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
> index aa33fd1..aaabdca 100644
> --- a/include/uapi/linux/usb/ch9.h
> +++ b/include/uapi/linux/usb/ch9.h
> @@ -672,11 +672,15 @@ struct usb_otg_descriptor {
> __u8 bDescriptorType;
>
> __u8 bmAttributes; /* support for HNP, SRP, etc */
> +#ifdef CONFIG_USB_OTG20
> + __le16 bcdOTG; /* Support OTG 2.0 */
> +#endif
Why you use tab instead of space for this define?
For above, you use space.
> } __attribute__ ((packed));
>
> /* from usb_otg_descriptor.bmAttributes */
> #define USB_OTG_SRP (1 << 0)
> #define USB_OTG_HNP (1 << 1) /* swap host/device roles */
> +#define USB_OTG_ADP (1 << 2) /* support ADP */
>
> /*-------------------------------------------------------------------------*/
>
> --
> 1.8.3.2
>
--
Best Regards,
Peter Chen
--
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