Re: [PATCH 1/9] usb: introduce OTG version number config

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 28, 2015 at 10:00:52AM +0800, Li Jun wrote:
> On Thu, May 28, 2015 at 09:15:05AM +0800, Peter Chen wrote:
> > On Wed, May 27, 2015 at 07:50:01PM +0800, Li Jun wrote:
> > > From: Macpaul Lin <macpaul@xxxxxxxxx>
> > > 
> > > Add CONFIG_USB_OTG_VERSION to identify the OTG and EH supplement release number
> > > with which the OTG device is compliant, also update the usb_otg_descriptor for
> > > OTG 2.0 and later release to include this OTG version number.
> > > 
> > > Signed-off-by: Macpaul Lin <macpaul@xxxxxxxxx>
> > > Signed-off-by: Li Jun <jun.li@xxxxxxxxxxxxx>
> > > ---
> > >  drivers/usb/core/Kconfig     | 11 +++++++++++
> > >  include/uapi/linux/usb/ch9.h |  7 ++++++-
> > >  2 files changed, 17 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> > > index cc0ced0..566a6c6 100644
> > > --- a/drivers/usb/core/Kconfig
> > > +++ b/drivers/usb/core/Kconfig
> > > @@ -55,6 +55,17 @@ config USB_OTG
> > >  	  Select this only if your board has Mini-AB/Micro-AB
> > >  	  connector.
> > >  
> > > +config USB_OTG_VERSION
> > > +	int "OTG and EH supplement release version number"
> > > +	depends on USB_OTG
> > > +	default 13
> > > +	range 0 30
> > > +	help
> > > +	  OTG and EH supplement release number(e.g. 13 is for OTG 1.3, 20 is
> > > +	  for OTG 2.0). This field will be converted to be bcdOTG in binary-coded
> > > +	  decimal of otg descriptor and identifies the release of the OTG and EH
> > > +	  supplement with which the device and its descriptors are compliant.
> > > +
> > 
> > Hi Jun,
> > 
> > Per previous discussion, in order to support multi-platform, we should 
> > not use Kconfig entry for different otg versions, instead we
> > need to define several otg descriptor definitions, and choose one of
> > them according to platform parameters.
> 
> I know there was discussion about it, but that will make the things some
> complicated, the fact is we have static otg descriptor definition in many
> gadget drivers, then we have to remove all of them and allocate&set it at
> runtime. I am wondering how much that target makes sense, there are cases
> multi-platform which have one same kernel image but some are OTG 1.3, and
> some are OTG 2.0?
> 

We do need to support multi-platform, maybe it is time we move otg
descriptor from each gadget drivers to common header file. For
struct usb_otg_descriptor, we can add zero-length variable structure.

diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index aa33fd1..40a4490 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -666,12 +666,17 @@ struct usb_qualifier_descriptor {
 
 /*-------------------------------------------------------------------------*/
 
+struct bcdOTG {
+	__le16 bcdOTG;
+};
+
 /* USB_DT_OTG (from OTG 1.0a supplement) */
 struct usb_otg_descriptor {
 	__u8  bLength;
 	__u8  bDescriptorType;
 
 	__u8  bmAttributes;	/* support for HNP, SRP, etc */
+	struct bcdOTG otg_rev[0];
 } __attribute__ ((packed));
 
 /* from usb_otg_descriptor.bmAttributes */

For gadget driver, you may need to allocate/free at runtime, of cos,
you can have some common APIs for doing that.

diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
index 5ee9515..7c955a6 100644
--- a/drivers/usb/gadget/legacy/zero.c
+++ b/drivers/usb/gadget/legacy/zero.c
@@ -341,6 +341,9 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
 
 	/* support OTG systems */
 	if (gadget_is_otg(cdev->gadget)) {
+		otg_descriptor = devm_kzalloc(sizeof(struct usb_otg_descriptor) +
+			     bcdotg_is_needed ? sizeof (struct bcdOTG):
+			     0);
 		sourcesink_driver.descriptors = otg_desc;
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 		loopback_driver.descriptors = otg_desc;
@@ -397,6 +400,7 @@ static int zero_unbind(struct usb_composite_dev *cdev)
 	if (!IS_ERR_OR_NULL(func_lb))
 		usb_put_function(func_lb);
 	usb_put_function_instance(func_inst_lb);
+	devm_kfree(otg_descriptor);
 	return 0;
 }


-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux