Re: [PATCH] usb: xhci: make USB_XHCI_PLATFORM selectable

2015-06-18 Thread Mathias Nyman
On 17.06.2015 18:19, Rafał Miłecki wrote:
> On 17 June 2015 at 17:11, Mathias Nyman  wrote:
>> On 16.06.2015 23:01, Rafał Miłecki wrote:
>>> On 16 June 2015 at 21:56, Greg Kroah-Hartman  
>>> wrote:
 On Tue, Jun 16, 2015 at 09:18:05PM +0200, Rafał Miłecki wrote:
> Right now xhci-plat-hcd can be built when using one of platform specific
> drivers only (mvebu/rcar). There shouldn't be such limitation as some
> platforms may not require any quirks and may want to just use a generic
> driver ("generic-xhci" / "xhci-hcd").

 Don't you still need some kind of xhci platform driver?  On its own,
 xhci-hcd doesn't provide what you need.
>>>
>>> First, I can just "generic-xhci" if the controller doesn't need any
>>> extra setup. See even the example in
>>> Documentation/devicetree/bindings/usb/usb-xhci.txt, there is that:
>>> compatible = "generic-xhci";
>>> example entry for DT.
>>>
>>> And about "xhci-hcd": if there appears (one day) some platform driver
>>> (e.g. non-DT) registering "xhci-hcd" platform device, it'll most
>>> likely handle initialization on its own, before calling the
>>> platform_device_add.
>>
>> True that there is no way to just select the xhci platform driver if all you
>> need is a driver for a "generic-xhci" platform device with only interrupt 
>> and mem
>> resources set in the platform device.
>>
>> Is this fixing some real life issue?
>>
>> I don't have strong opinions about this, for me adding this option is fine, 
>> or
>> then wait until it's really needed by someone.
> 
> I am/was trying to use "generic-xhci" for Broadcom's devices,
> unfortunately I'm still experiencing some stability problems. Not sure
> if there are related to the controller initialization or some more
> low-level stuff.
> 
> Anyway, since "generic-xhci" support is there and not all dts files
> are part of kernel, it would be nice if you could accept this patch.
> Please note that there are many dts files living out of kernel source.
> Also some bootloaders support DT natively (it's not dtb appended to
> the kernel binary), so there may be ppl interested in using
> "generic-xhci" even if there isn't any in-kernel dts using that.
> 

I'll add to my queue and send it forward to Greg once 4.2-rc1 is out.

-Mathias 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Roger Quadros
Lin,

You can use --in-reply-to "message id of v5 of this path" so that it appears 
together
with the other patches in peoples mailboxes.

On Thu, 18 Jun 2015 09:18:22 +0800
Li Jun  wrote:

> Change for v6:
> UPdate otg caps by disable flags even if otg_rev is not passed, this is
> needed in case user wants to disable whole OTG(or just want to ID pin
> detect).
> 
> Check property of usb hardware to get otg version and if SRP, HNP and ADP
> are disabled.
> 
> Signed-off-by: Li Jun 
> ---
>  drivers/usb/common/common.c | 27 +++
>  include/linux/usb/of.h  |  7 +++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index b530fd4..12f5d28 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -154,6 +154,33 @@ bool of_usb_host_tpl_support(struct device_node *np)
>   return false;
>  }
>  EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
> +
> +/**
> + * of_usb_get_set_caps - to set usb otg capabilities according to

get or set?
how about update instead?

> + * the passed properties in DT.
> + * @np: Pointer to the given device_node
> + * @otg_caps: Pointer to the target usb_otg_caps to be set
> + *
> + * The function gets and sets the otg capabilities
> + */
> +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> *otg_caps)
> +{
> + u32 otg_rev;
> +
> + if (!otg_caps)
> + return;
> +
> + if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> + otg_caps->otg_rev = otg_rev;

should we check if otg_rev is in correct format?
anything non BCD and greater than 0x is invalid.

Also if otg-rev is not passed then we need to treat it as legacy
platform right? How is this taken care of?

> + if (of_find_property(np, "hnp-disable", NULL))
> + otg_caps->hnp_support = false;
> + if (of_find_property(np, "srp-disable", NULL))
> + otg_caps->srp_support = false;
> + if (of_find_property(np, "adp-disable", NULL))
> + otg_caps->adp_support = false;

Don't we expect it to do basic sanity checks?
e.g. if otg_rev < 0x200 then adp_support can't be true?

> +}
> +EXPORT_SYMBOL_GPL(of_usb_set_otg_caps);
> +
>  #endif
>  
>  MODULE_LICENSE("GPL");
> diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> index cfe0528..6339799 100644
> --- a/include/linux/usb/of.h
> +++ b/include/linux/usb/of.h
> @@ -15,6 +15,8 @@
>  enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
>  enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
>  bool of_usb_host_tpl_support(struct device_node *np);
> +void of_usb_set_otg_caps(struct device_node *np,
> + struct usb_otg_caps *otg_caps);
>  #else
>  static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
>  {
> @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct 
> device_node *np)
>  {
>   return false;
>  }
> +static inline void of_usb_set_otg_caps(struct device_node *np,
> + struct usb_otg_caps *otg_caps)
> +{
> +
> +}
>  #endif
>  
>  #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
> -- 
> 1.9.1
> 

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


Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities

2015-06-18 Thread Roger Quadros
Typo in subject
gadeget's -> gadget's

On Wed, 17 Jun 2015 19:40:15 +0800
Li Jun  wrote:

> Set gadget's otg capabilities according to controller's capability and otg
> properties in device tree.
> 
> Signed-off-by: Li Jun 
> ---
>  drivers/usb/chipidea/core.c  | 8 
>  drivers/usb/chipidea/udc.c   | 7 ++-
>  include/linux/usb/chipidea.h | 1 +
>  3 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 74fea4f..2abecbc 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,
>   of_usb_host_tpl_support(dev->of_node);
>   }
>  
> + if (platdata->dr_mode == USB_DR_MODE_OTG) {
> + /* We can support HNP and SRP */
> + platdata->ci_otg_caps.hnp_support = true;
> + platdata->ci_otg_caps.srp_support = true;
> + /* Update otg capabilities by DT properties */
> + of_usb_set_otg_caps(dev->of_node, &platdata->ci_otg_caps);

we're not tackling the legacy platform case.
i.e. when otg-rev is not present in DT.

one way could be that of_usb_set_otg_caps sets otg-rev to 0 if
it is not present in DT.

> + }
> +
>   if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
>   platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
>  
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 764f668..858bd21 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
>  static int udc_start(struct ci_hdrc *ci)
>  {
>   struct device *dev = ci->dev;
> + struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
>   int retval = 0;
>  
>   spin_lock_init(&ci->lock);
> @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci)
>   ci->gadget.ops  = &usb_gadget_ops;
>   ci->gadget.speed= USB_SPEED_UNKNOWN;
>   ci->gadget.max_speed= USB_SPEED_HIGH;
> - ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
>   ci->gadget.name = ci->platdata->name;
> + ci->gadget.otg_caps = otg_caps;
> +
> + if (otg_caps->otg_rev && (otg_caps->hnp_support ||
> + otg_caps->srp_support || otg_caps->adp_support))
> + ci->gadget.is_otg = 1;
>  
>   INIT_LIST_HEAD(&ci->gadget.ep_list);
>  
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index ab94f78..e10cefc 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
>   void(*notify_event) (struct ci_hdrc *ci, unsigned event);
>   struct regulator*reg_vbus;
> + struct usb_otg_caps ci_otg_caps;
>   booltpl_support;
>  };
>  
> -- 
> 1.9.1
> 

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


Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities

2015-06-18 Thread Roger Quadros
On Wed, 17 Jun 2015 19:40:19 +0800
Li Jun  wrote:

> Allocate and initialize usb otg descriptor according to gadget otg
> capabilities, add it for each usb configurations, free it while
> ether unbind. If otg capability is not defined, keep its otg
> descriptor unchanged.
> 
> Signed-off-by: Li Jun 
> ---
>  drivers/usb/gadget/legacy/ether.c | 52 
> +++
>  1 file changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/gadget/legacy/ether.c 
> b/drivers/usb/gadget/legacy/ether.c
> index a3323dc..2595288 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 = {
>   .bNumConfigurations =   1,
>  };
>  
> -static struct usb_otg_descriptor otg_descriptor = {
> - .bLength =  sizeof otg_descriptor,
> - .bDescriptorType =  USB_DT_OTG,
> -
> - /* REVISIT SRP-only hardware is possible, although
> -  * it would not be called "OTG" ...
> -  */
> - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
> -};
> -
> -static const struct usb_descriptor_header *otg_desc[] = {
> - (struct usb_descriptor_header *) &otg_descriptor,
> - NULL,
> -};
> +static const struct usb_descriptor_header *otg_desc[2];
>  
>  static struct usb_string strings_dev[] = {
>   [USB_GADGET_MANUFACTURER_IDX].s = "",
> @@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)
>  
>   /* FIXME alloc iConfiguration string, set it in c->strings */
>  
> - if (gadget_is_otg(c->cdev->gadget)) {
> - c->descriptors = otg_desc;

If you remove this who is setting c->descriptors to otg_desc?

> - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

Why are you removing this? won't it change gadget behaviour?

> - }
> -
>   f_rndis = usb_get_function(fi_rndis);
>   if (IS_ERR(f_rndis))
>   return PTR_ERR(f_rndis);
> @@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c)
>  
>   /* FIXME alloc iConfiguration string, set it in c->strings */
>  
> - if (gadget_is_otg(c->cdev->gadget)) {
> - c->descriptors = otg_desc;
> - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

same here

> - }
> -
>   if (use_eem) {
>   f_eem = usb_get_function(fi_eem);
>   if (IS_ERR(f_eem))
> @@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev)
>   device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
>   device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
>  
> + if (gadget_is_otg(gadget)) {
> + if (!otg_desc[0]) {
> + struct usb_descriptor_header *usb_desc;
> +
> + usb_desc = usb_otg_descriptor_alloc(gadget);
> + if (!usb_desc)
> + goto fail1;
> + usb_otg_descriptor_init(gadget, usb_desc);
> + otg_desc[0] = usb_desc;
> + otg_desc[1] = NULL;
> + }
> + rndis_config_driver.descriptors = otg_desc;
> + rndis_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> + eth_config_driver.descriptors = otg_desc;
> + eth_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> + }
> +
>   /* register our configuration(s); RNDIS first, if it's used */
>   if (has_rndis()) {
>   status = usb_add_config(cdev, &rndis_config_driver,
>   rndis_do_config);
>   if (status < 0)
> - goto fail1;
> + goto fail2;
>   }
>  
>   status = usb_add_config(cdev, ð_config_driver, eth_do_config);
>   if (status < 0)
> - goto fail1;
> + goto fail2;
>  
>   usb_composite_overwrite_options(cdev, &coverwrite);
>   dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
> @@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev)
>  
>   return 0;
>  
> +fail2:
> + kfree(otg_desc[0]);
> + otg_desc[0] = NULL;
>  fail1:
>   if (has_rndis())
>   usb_put_function_instance(fi_rndis);
> @@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev)
>   usb_put_function(f_geth);
>   usb_put_function_instance(fi_geth);
>   }
> + kfree(otg_desc[0]);
> + otg_desc[0] = NULL;
> +
>   return 0;
>  }
>  
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities

2015-06-18 Thread Roger Quadros
On Thu, 18 Jun 2015 10:43:02 +0300
Roger Quadros  wrote:

> On Wed, 17 Jun 2015 19:40:19 +0800
> Li Jun  wrote:
> 
> > Allocate and initialize usb otg descriptor according to gadget otg
> > capabilities, add it for each usb configurations, free it while
> > ether unbind. If otg capability is not defined, keep its otg
> > descriptor unchanged.
> > 
> > Signed-off-by: Li Jun 
> > ---
> >  drivers/usb/gadget/legacy/ether.c | 52 
> > +++
> >  1 file changed, 26 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/legacy/ether.c 
> > b/drivers/usb/gadget/legacy/ether.c
> > index a3323dc..2595288 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 = {
> > .bNumConfigurations =   1,
> >  };
> >  
> > -static struct usb_otg_descriptor otg_descriptor = {
> > -   .bLength =  sizeof otg_descriptor,
> > -   .bDescriptorType =  USB_DT_OTG,
> > -
> > -   /* REVISIT SRP-only hardware is possible, although
> > -* it would not be called "OTG" ...
> > -*/
> > -   .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
> > -};
> > -
> > -static const struct usb_descriptor_header *otg_desc[] = {
> > -   (struct usb_descriptor_header *) &otg_descriptor,
> > -   NULL,
> > -};
> > +static const struct usb_descriptor_header *otg_desc[2];
> >  
> >  static struct usb_string strings_dev[] = {
> > [USB_GADGET_MANUFACTURER_IDX].s = "",
> > @@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)
> >  
> > /* FIXME alloc iConfiguration string, set it in c->strings */
> >  
> > -   if (gadget_is_otg(c->cdev->gadget)) {
> > -   c->descriptors = otg_desc;
> 
> If you remove this who is setting c->descriptors to otg_desc?
> 
> > -   c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> 
> Why are you removing this? won't it change gadget behaviour?

OK. I see that you moved this bit to eth_bind. So it should be fine
I guess. But this change was not necessary.

cheers,
-roger

> 
> > -   }
> > -
> > f_rndis = usb_get_function(fi_rndis);
> > if (IS_ERR(f_rndis))
> > return PTR_ERR(f_rndis);
> > @@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c)
> >  
> > /* FIXME alloc iConfiguration string, set it in c->strings */
> >  
> > -   if (gadget_is_otg(c->cdev->gadget)) {
> > -   c->descriptors = otg_desc;
> > -   c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> 
> same here
> 
> > -   }
> > -
> > if (use_eem) {
> > f_eem = usb_get_function(fi_eem);
> > if (IS_ERR(f_eem))
> > @@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev)
> > device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
> > device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
> >  
> > +   if (gadget_is_otg(gadget)) {
> > +   if (!otg_desc[0]) {
> > +   struct usb_descriptor_header *usb_desc;
> > +
> > +   usb_desc = usb_otg_descriptor_alloc(gadget);
> > +   if (!usb_desc)
> > +   goto fail1;
> > +   usb_otg_descriptor_init(gadget, usb_desc);
> > +   otg_desc[0] = usb_desc;
> > +   otg_desc[1] = NULL;
> > +   }
> > +   rndis_config_driver.descriptors = otg_desc;
> > +   rndis_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> > +   eth_config_driver.descriptors = otg_desc;
> > +   eth_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> > +   }
> > +
> > /* register our configuration(s); RNDIS first, if it's used */
> > if (has_rndis()) {
> > status = usb_add_config(cdev, &rndis_config_driver,
> > rndis_do_config);
> > if (status < 0)
> > -   goto fail1;
> > +   goto fail2;
> > }
> >  
> > status = usb_add_config(cdev, ð_config_driver, eth_do_config);
> > if (status < 0)
> > -   goto fail1;
> > +   goto fail2;
> >  
> > usb_composite_overwrite_options(cdev, &coverwrite);
> > dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
> > @@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev)
> >  
> > return 0;
> >  
> > +fail2:
> > +   kfree(otg_desc[0]);
> > +   otg_desc[0] = NULL;
> >  fail1:
> > if (has_rndis())
> > usb_put_function_instance(fi_rndis);
> > @@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev)
> > usb_put_function(f_geth);
> > usb_put_function_instance(fi_geth);
> > }
> > +   kfree(otg_desc[0]);
> > +   otg_desc[0] = NULL;
> > +
> > return 0;
> >  }
> >  
> > -- 
> > 1.9.1
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> Mor

Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> Lin,
> 
> You can use --in-reply-to "message id of v5 of this path" so that it appears 
> together
> with the other patches in peoples mailboxes.
> 
okay, I will try that next time, thanks.

Li Jun
> On Thu, 18 Jun 2015 09:18:22 +0800
> Li Jun  wrote:
> 
> > Change for v6:
> > UPdate otg caps by disable flags even if otg_rev is not passed, this is
> > needed in case user wants to disable whole OTG(or just want to ID pin
> > detect).
> > 
> > Check property of usb hardware to get otg version and if SRP, HNP and ADP
> > are disabled.
> > 
> > Signed-off-by: Li Jun 
> > ---
> >  drivers/usb/common/common.c | 27 +++
> >  include/linux/usb/of.h  |  7 +++
> >  2 files changed, 34 insertions(+)
> > 
> > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> > index b530fd4..12f5d28 100644
> > --- a/drivers/usb/common/common.c
> > +++ b/drivers/usb/common/common.c
> > @@ -154,6 +154,33 @@ bool of_usb_host_tpl_support(struct device_node *np)
> > return false;
> >  }
> >  EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
> > +
> > +/**
> > + * of_usb_get_set_caps - to set usb otg capabilities according to
> 
> get or set?
> how about update instead?
> 
Should be set, update? okay.

Li Jun
> > + * the passed properties in DT.
> > + * @np: Pointer to the given device_node
> > + * @otg_caps: Pointer to the target usb_otg_caps to be set
> > + *
> > + * The function gets and sets the otg capabilities
> > + */
> > +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> > *otg_caps)
> > +{
> > +   u32 otg_rev;
> > +
> > +   if (!otg_caps)
> > +   return;
> > +
> > +   if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> > +   otg_caps->otg_rev = otg_rev;
> 
> should we check if otg_rev is in correct format?
> anything non BCD and greater than 0x is invalid.
> 
Then that's not so simple, every number should be checked,
if ((otg_caps->otg_rev % 10) > 9) ||
((otg_caps->otg_rev >> 4) % 10) > 9) ||
((otg_caps->otg_rev >> 8) % 10) > 9) ||
((otg_caps->otg_rev >> 12) % 10) > 9))
return error;
We really need this kind of format check? seems no this check
for bcdUSB.

> Also if otg-rev is not passed then we need to treat it as legacy
> platform right? How is this taken care of?
> 
> > +   if (of_find_property(np, "hnp-disable", NULL))
> > +   otg_caps->hnp_support = false;
> > +   if (of_find_property(np, "srp-disable", NULL))
> > +   otg_caps->srp_support = false;
> > +   if (of_find_property(np, "adp-disable", NULL))
> > +   otg_caps->adp_support = false;
> 
> Don't we expect it to do basic sanity checks?
> e.g. if otg_rev < 0x200 then adp_support can't be true?
> 
Okay, it's better we add a sanity check here.

> > +}
> > +EXPORT_SYMBOL_GPL(of_usb_set_otg_caps);
> > +
> >  #endif
> >  
> >  MODULE_LICENSE("GPL");
> > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> > index cfe0528..6339799 100644
> > --- a/include/linux/usb/of.h
> > +++ b/include/linux/usb/of.h
> > @@ -15,6 +15,8 @@
> >  enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
> >  enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
> >  bool of_usb_host_tpl_support(struct device_node *np);
> > +void of_usb_set_otg_caps(struct device_node *np,
> > +   struct usb_otg_caps *otg_caps);
> >  #else
> >  static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> >  {
> > @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct 
> > device_node *np)
> >  {
> > return false;
> >  }
> > +static inline void of_usb_set_otg_caps(struct device_node *np,
> > +   struct usb_otg_caps *otg_caps)
> > +{
> > +
> > +}
> >  #endif
> >  
> >  #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
> > -- 
> > 1.9.1
> > 
> 
> cheers,
> -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 10:39:35AM +0300, Roger Quadros wrote:
> Typo in subject
> gadeget's -> gadget's
> 
> On Wed, 17 Jun 2015 19:40:15 +0800
> Li Jun  wrote:
> 
> > Set gadget's otg capabilities according to controller's capability and otg
> > properties in device tree.
> > 
> > Signed-off-by: Li Jun 
> > ---
> >  drivers/usb/chipidea/core.c  | 8 
> >  drivers/usb/chipidea/udc.c   | 7 ++-
> >  include/linux/usb/chipidea.h | 1 +
> >  3 files changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 74fea4f..2abecbc 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,
> > of_usb_host_tpl_support(dev->of_node);
> > }
> >  
> > +   if (platdata->dr_mode == USB_DR_MODE_OTG) {
> > +   /* We can support HNP and SRP */
> > +   platdata->ci_otg_caps.hnp_support = true;
> > +   platdata->ci_otg_caps.srp_support = true;
> > +   /* Update otg capabilities by DT properties */
> > +   of_usb_set_otg_caps(dev->of_node, &platdata->ci_otg_caps);
> 
> we're not tackling the legacy platform case.
> i.e. when otg-rev is not present in DT.
> 
Legacy platforms with chipidea controller can use otg HNP and SRP
without any otg properties passed, so I keep hnp and srp to be true.

> one way could be that of_usb_set_otg_caps sets otg-rev to 0 if
> it is not present in DT.
> 
otg-rev should be 0 as initial value if it's not present in DT, isn't it?

> > +   }
> > +
> > if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
> > platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
> >  
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index 764f668..858bd21 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
> >  static int udc_start(struct ci_hdrc *ci)
> >  {
> > struct device *dev = ci->dev;
> > +   struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
> > int retval = 0;
> >  
> > spin_lock_init(&ci->lock);
> > @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci)
> > ci->gadget.ops  = &usb_gadget_ops;
> > ci->gadget.speed= USB_SPEED_UNKNOWN;
> > ci->gadget.max_speed= USB_SPEED_HIGH;
> > -   ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
> > ci->gadget.name = ci->platdata->name;
> > +   ci->gadget.otg_caps = otg_caps;
> > +
> > +   if (otg_caps->otg_rev && (otg_caps->hnp_support ||
> > +   otg_caps->srp_support || otg_caps->adp_support))
> > +   ci->gadget.is_otg = 1;
> >  
> > INIT_LIST_HEAD(&ci->gadget.ep_list);
> >  
> > diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> > index ab94f78..e10cefc 100644
> > --- a/include/linux/usb/chipidea.h
> > +++ b/include/linux/usb/chipidea.h
> > @@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {
> >  #define CI_HDRC_CONTROLLER_STOPPED_EVENT   1
> > void(*notify_event) (struct ci_hdrc *ci, unsigned event);
> > struct regulator*reg_vbus;
> > +   struct usb_otg_caps ci_otg_caps;
> > booltpl_support;
> >  };
> >  
> > -- 
> > 1.9.1
> > 
> 
> cheers,
> -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 10:51:48AM +0300, Roger Quadros wrote:
> On Thu, 18 Jun 2015 10:43:02 +0300
> Roger Quadros  wrote:
> 
> > On Wed, 17 Jun 2015 19:40:19 +0800
> > Li Jun  wrote:
> > 
> > > @@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration 
> > > *c)
> > >  
> > >   /* FIXME alloc iConfiguration string, set it in c->strings */
> > >  
> > > - if (gadget_is_otg(c->cdev->gadget)) {
> > > - c->descriptors = otg_desc;
> > 
> > If you remove this who is setting c->descriptors to otg_desc?
> > 
> > > - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
> > 
> > Why are you removing this? won't it change gadget behaviour?
> 
> OK. I see that you moved this bit to eth_bind. So it should be fine
> I guess. But this change was not necessary.
> 
right, I will revert this change.

Li Jun
> cheers,
> -roger
> 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> Lin,
> 
> You can use --in-reply-to "message id of v5 of this path" so that it appears 
> together
> with the other patches in peoples mailboxes.
> 
> > + * the passed properties in DT.
> > + * @np: Pointer to the given device_node
> > + * @otg_caps: Pointer to the target usb_otg_caps to be set
> > + *
> > + * The function gets and sets the otg capabilities
> > + */
> > +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> > *otg_caps)
> > +{
> > +   u32 otg_rev;
> > +
> > +   if (!otg_caps)
> > +   return;
> > +
> > +   if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> > +   otg_caps->otg_rev = otg_rev;
> 
> should we check if otg_rev is in correct format?
> anything non BCD and greater than 0x is invalid.
> 
> Also if otg-rev is not passed then we need to treat it as legacy
> platform right? How is this taken care of?
> 
Missed this comment
This handling rely on controller driver, cannot decided here.
There are several cases we need take care:
1) otg-rev is not passed, but all 3 disable flags passed, this is
  valid, means user want to disable whole OTG, so only "otg-rev"
  not passed, cannot treat as legacy platform.
2) Legacy platform means: none of 4 properties is present.
3) Some controller drivers already support OTG HNP/SRP, then change
  to utilize those new flags, still should support OTG HNP/SRP w/o
  any dt change, so OTG caps should be enabled for legacy platforms.
4) Some controller drivers does not support any OTG, after add OTG
  functions and utilize those new flags, should keep OTG disabled
  for legacy platforms.

Li Jun 
> > -- 
> > 1.9.1
> > 
> 
> cheers,
> -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] USB SERIAL: option.c: add 2020:4000 IDs

2015-06-18 Thread Claudio Cappelli
On Wednesday 17 June 2015 11:55:37 Johan Hovold wrote:
> On Fri, Jun 12, 2015 at 09:32:31AM +0200, Claudio Cappelli wrote:
> >
> > Was this second version in the right format?
> > Since it was my first patch submit, I'd be
> > grateful if you could confirm.
>
> Looks good. I've added the usb-devices output from your earlier mail to
> the commit message and queued it up for 4.2-rc2.
>
> Thanks,
> Johan
>

Thanks to you!
Glad to have been helpful!

See you.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 02/10] USB: io_ti: Add timeout parameter to ti_vsend_sync()

2015-06-18 Thread Peter Berger
On Wed, 2015-06-17 at 11:21 +0200, Johan Hovold wrote:
> On Mon, Jun 15, 2015 at 10:47:25AM -0500, Peter E. Berger wrote:
> > From: "Peter E. Berger" 
> > 
> > Instead of having ti_vsend_sync() decide when to use non-default timeouts,
> > make "timeout" a parameter and leave the decision to the caller.
> > 
> > Signed-off-by: Peter E. Berger 
> > ---
> >  drivers/usb/serial/io_ti.c | 28 +---
> >  1 file changed, 17 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
> > index 3206a6f..75f08c3 100644
> > --- a/drivers/usb/serial/io_ti.c
> > +++ b/drivers/usb/serial/io_ti.c
> > @@ -210,6 +210,10 @@ static int edge_create_sysfs_attrs(struct 
> > usb_serial_port *port);
> >  static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
> >  
> >  
> > +/* Timeouts in msecs: firmware downloads take longer */
> > +#define TI_VSEND_TIMEOUT_DEFAULT 1000
> > +#define TI_VSEND_TIMEOUT_FW_DOWNLOAD 1
> > +
> >  static int ti_vread_sync(struct usb_device *dev, __u8 request,
> > __u16 value, __u16 index, u8 *data, int size)
> >  {
> > @@ -228,14 +232,11 @@ static int ti_vread_sync(struct usb_device *dev, __u8 
> > request,
> > return 0;
> >  }
> >  
> > -static int ti_vsend_sync(struct usb_device *dev, __u8 request,
> > +static int ti_vsend_sync(struct usb_device *dev, __u8 request, int timeout,
> > __u16 value, __u16 index, u8 *data, int size)
> 
> So merge this one with the first patch. Also add the timeout argument
> at the end of the argument list to match the USB API.

OK.  A v6 patchset with these changes (and your other suggestions for
squashing the v5 patchset into three patches) is just about ready to
send.  Thanks for your guidance and patience.
 --Peter
> 
> Thanks,
> Johan

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


[PATCH v6 1/3] USB: io_ti: Increase insufficient timeout for firmware downloads

2015-06-18 Thread Peter E. Berger
From: "Peter E. Berger" 

The io_ti driver fails to download firmware to Edgeport devices such as
the EP/416.  One of the problems is that the default 1 second timeout
in ti_vsend_sync() is insufficient for download operations.  This patch
increases the download timeout to 10 seconds.

Signed-off-by: Peter E. Berger 
---
 drivers/usb/serial/io_ti.c | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index ddbb8fe..69378a7 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -210,6 +210,10 @@ static int edge_create_sysfs_attrs(struct usb_serial_port 
*port);
 static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
 
 
+/* Timeouts in msecs: firmware downloads take longer */
+#define TI_VSEND_TIMEOUT_DEFAULT 1000
+#define TI_VSEND_TIMEOUT_FW_DOWNLOAD 1
+
 static int ti_vread_sync(struct usb_device *dev, __u8 request,
__u16 value, __u16 index, u8 *data, int size)
 {
@@ -228,14 +232,14 @@ static int ti_vread_sync(struct usb_device *dev, __u8 
request,
return 0;
 }
 
-static int ti_vsend_sync(struct usb_device *dev, __u8 request,
-   __u16 value, __u16 index, u8 *data, int size)
+static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value,
+   u16 index, u8 *data, int size, int timeout)
 {
int status;
 
status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
-   value, index, data, size, 1000);
+   value, index, data, size, timeout);
if (status < 0)
return status;
if (status != size) {
@@ -250,7 +254,8 @@ static int send_cmd(struct usb_device *dev, __u8 command,
__u8 moduleid, __u16 value, u8 *data,
int size)
 {
-   return ti_vsend_sync(dev, command, value, moduleid, data, size);
+   return ti_vsend_sync(dev, command, value, moduleid, data, size,
+   TI_VSEND_TIMEOUT_DEFAULT);
 }
 
 /* clear tx/rx buffers and fifo in TI UMP */
@@ -378,9 +383,9 @@ static int write_boot_mem(struct edgeport_serial *serial,
}
 
for (i = 0; i < length; ++i) {
-   status = ti_vsend_sync(serial->serial->dev,
-   UMPC_MEMORY_WRITE, buffer[i],
-   (__u16)(i + start_address), NULL, 0);
+   status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
+   buffer[i], (u16)(i + start_address), NULL,
+   0, TI_VSEND_TIMEOUT_DEFAULT);
if (status)
return status;
}
@@ -421,10 +426,9 @@ static int write_i2c_mem(struct edgeport_serial *serial,
 *   regardless of host byte order.
 */
be_start_address = swab16((u16)start_address);
-   status = ti_vsend_sync(serial->serial->dev,
-   UMPC_MEMORY_WRITE, (__u16)address_type,
-   be_start_address,
-   buffer, write_length);
+   status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
+   (u16)address_type, be_start_address,
+   buffer, write_length, TI_VSEND_TIMEOUT_DEFAULT);
if (status) {
dev_dbg(dev, "%s - ERROR %d\n", __func__, status);
return status;
@@ -454,9 +458,8 @@ static int write_i2c_mem(struct edgeport_serial *serial,
 */
be_start_address = swab16((u16)start_address);
status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
-   (__u16)address_type,
-   be_start_address,
-   buffer, write_length);
+   (u16)address_type, be_start_address, buffer,
+   write_length, TI_VSEND_TIMEOUT_DEFAULT);
if (status) {
dev_err(dev, "%s - ERROR %d\n", __func__, status);
return status;
@@ -1129,7 +1132,8 @@ static int download_fw(struct edgeport_serial *serial)
/* Reset UMP -- Back to BOOT MODE */
status = ti_vsend_sync(serial->serial->dev,
UMPC_HARDWARE_RESET,
-   0, 0, NULL, 0);
+   0, 0, NULL, 0,
+   TI_VSEND_TIMEOUT_DEFAULT);
 
dev_dbg(dev, "%s - HARDWARE RESET return %d\n", 
__func__, status);
 
@@ -1229,7 +1233,9 @@ static int download_fw(struct edgeport_serial *serial)

[PATCH v6 3/3] USB: io_ti: Add heartbeat to keep idle Edgeport ports from disconnecting

2015-06-18 Thread Peter E. Berger
From: "Peter E. Berger" 

When using newer Edgeport devices such as the EP/416, idle ports are
automatically bounced (disconnected and then reconnected) approximately
every 60 seconds.  This breaks programs (e.g: minicom) where idle periods
are common, normal and expected.

I confirmed with the manufacturer (Digi International) that some Edgeports
now ship from the factory with firmware that expects periodic "heartbeat"
queries from the driver to keep idle ports alive.  This patch implements
heartbeat support using the mechanism Digi suggested (periodically
requesting an I2C descriptor address) that appears effective on Edgeports
running the newer firmware (that require it) and benign on Edgeport
devices running older firmware.  Since we know that Edgeport firmware
version 4.80 (the version distributed in /lib/firmware/down3.bin and used
for Edgeports that are either running still older versions or have no
onboard non-volatile firmware image) does not require heartbeat support,
this patch schedules heartbeats only on devices running firmware versions
newer than 4.80.

Signed-off-by: Peter E. Berger 
---
 drivers/usb/serial/io_ti.c | 78 +-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index c76820b..b7c1ea1 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -101,6 +101,7 @@ struct edgeport_serial {
struct mutex es_lock;
int num_ports_open;
struct usb_serial *serial;
+   struct delayed_work heartbeat_work;
int fw_version;
 };
 
@@ -206,6 +207,18 @@ static void edge_send(struct usb_serial_port *port, struct 
tty_struct *tty);
 static int edge_create_sysfs_attrs(struct usb_serial_port *port);
 static int edge_remove_sysfs_attrs(struct usb_serial_port *port);
 
+/*
+ * Some release of Edgeport firmware "down3.bin" after version 4.80
+ * introduced code to automatically disconnect idle devices after periods
+ * of inactivity, typically ~60 seconds.  This occurs without regard to
+ * whether ports on the device are open or not.  Digi International Tech
+ * Support suggested adding driver "heartbeat" code to reset the firmware
+ * timer by requesting a descriptor record every 15 seconds, which should be
+ * effective with newer firmware versions that require it, and benign with
+ * older versions that do not. In practice 40 seconds seems often enough.
+ */
+#define FW_HEARTBEAT_VERSION_CUTOFF ((4 << 8) + 80)
+#define FW_HEARTBEAT_SECS 40
 
 /* Timeouts in msecs: firmware downloads take longer */
 #define TI_VSEND_TIMEOUT_DEFAULT 1000
@@ -2354,6 +2367,36 @@ static void edge_break(struct tty_struct *tty, int 
break_state)
__func__, status);
 }
 
+static void edge_heartbeat_work(struct work_struct *work)
+{
+   struct edgeport_serial *serial;
+   struct ti_i2c_desc *rom_desc;
+
+   serial = container_of(work, struct edgeport_serial,
+   heartbeat_work.work);
+
+   rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
+
+   /* Descriptor address request is enough to reset the firmware timer */
+   if (!rom_desc || !get_descriptor_addr(serial, I2C_DESC_TYPE_ION,
+   rom_desc)) {
+   dev_err(&serial->serial->interface->dev,
+   "%s - Incomplete heartbeat\n", __func__);
+   }
+   kfree(rom_desc);
+
+   schedule_delayed_work(&serial->heartbeat_work, FW_HEARTBEAT_SECS * HZ);
+}
+
+static inline void edge_heartbeat_reschedule(struct edgeport_serial
+   *edge_serial)
+{
+   if (edge_serial->fw_version > FW_HEARTBEAT_VERSION_CUTOFF) {
+   schedule_delayed_work(&edge_serial->heartbeat_work,
+   FW_HEARTBEAT_SECS * HZ);
+   }
+}
+
 static int edge_startup(struct usb_serial *serial)
 {
struct edgeport_serial *edge_serial;
@@ -2401,6 +2444,9 @@ static int edge_startup(struct usb_serial *serial)
return status;
}
 
+   INIT_DELAYED_WORK(&edge_serial->heartbeat_work, edge_heartbeat_work);
+   edge_heartbeat_reschedule(edge_serial);
+
return 0;
 }
 
@@ -2410,7 +2456,10 @@ static void edge_disconnect(struct usb_serial *serial)
 
 static void edge_release(struct usb_serial *serial)
 {
-   kfree(usb_get_serial_data(serial));
+   struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
+
+   cancel_delayed_work_sync(&edge_serial->heartbeat_work);
+   kfree(edge_serial);
 }
 
 static int edge_port_probe(struct usb_serial_port *port)
@@ -2514,6 +2563,25 @@ static int edge_remove_sysfs_attrs(struct 
usb_serial_port *port)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int edge_suspend(struct usb_serial *serial, pm_message_t message)
+{
+   struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
+
+   cancel_delayed_work_sync(&edge_serial->heartbeat_work);
+
+   return 0;
+}
+

[PATCH v6 0/3] Fix idle port disconnects and firmware downloading

2015-06-18 Thread Peter E. Berger
From: "Peter E. Berger" 

I found that when using newer Edgeport devices such as the EP/416,
idle ports are regularly bounced (disconnected and then reconnected).
I discussed this with the manufacturer (Digi International) and learned
that some newer Edgeport devices now ship from the factory running
firmware that requires periodic heartbeat messages from the driver, so
I enclose a proposed patch to implement their suggested mechanism (which
works both with old and new Edgeport devices).

While developing my heartbeat patch, I discovered that the firmware
download code was not working properly, so I also include two proposed
patches to fix this.

I welcome any comments or suggestions.

Thanks.
 --Peter

Changes since v5 [1]
Addressing Johan's review comments.  Thanks Johan!

 - Merge the ten v5 patches into three.
 - Move the ti_vsend_sync() "timeout" argument to the end of the
   argument list.


[1]: v5: http://marc.info/?l=linux-usb&m=143439219222811&w=2

Peter E. Berger (3):
  USB: io_ti: Increase insufficient timeout for firmware downloads
  USB: io_ti: Move request_firmware() calls out of download_fw()
  USB: io_ti: Add heartbeat to keep idle Edgeport ports from
disconnecting

 drivers/usb/serial/io_ti.c | 216 +++--
 1 file changed, 150 insertions(+), 66 deletions(-)

-- 
1.8.3.1

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


[PATCH v6 2/3] USB: io_ti: Move request_firmware() calls out of download_fw()

2015-06-18 Thread Peter E. Berger
From: "Peter E. Berger" 

The io_ti driver fails to download firmware to Edgeport
devices such as the EP/416, even when the on-disk firmware image
(/lib/firmware/edgeport/down3.bin) is more current than the version
on the EP/416.  The current download code is broken in a few ways.
Notably it mis-uses global variables OperationalMajorVersion and
OperationalMinorVersion (reading their values before they've been
properly initialized and subsequently initializing them multiple times
without synchronization).  This patch drops the global variables and
replaces the redundant calls to request_firmware()/release_firmware()
in download_fw() with a single call pair in edge_startup(); the firmware
image pointer is then passed to download_fw() and build_i2c_fw_hdr().

Also, the firmware has a "build_number" field, though it apparently is
unused (according to observations of the three firmware images I have
seen and confirmed by Digi Tech Support).  This comment describes its
structure, in case it is populated in a future release.

Signed-off-by: Peter E. Berger 
---
 drivers/usb/serial/io_ti.c | 100 +++--
 1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 69378a7..c76820b 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -101,6 +101,7 @@ struct edgeport_serial {
struct mutex es_lock;
int num_ports_open;
struct usb_serial *serial;
+   int fw_version;
 };
 
 
@@ -187,10 +188,6 @@ static const struct usb_device_id id_table_combined[] = {
 
 MODULE_DEVICE_TABLE(usb, id_table_combined);
 
-static unsigned char OperationalMajorVersion;
-static unsigned char OperationalMinorVersion;
-static unsigned short OperationalBuildNumber;
-
 static int closing_wait = EDGE_CLOSING_WAIT;
 static bool ignore_cpu_rev;
 static int default_uart_mode;  /* RS232 */
@@ -751,18 +748,18 @@ exit:
 }
 
 /* Build firmware header used for firmware update */
-static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
+static int build_i2c_fw_hdr(u8 *header, struct device *dev,
+   const struct firmware *fw)
 {
__u8 *buffer;
int buffer_size;
int i;
-   int err;
__u8 cs = 0;
struct ti_i2c_desc *i2c_header;
struct ti_i2c_image_header *img_header;
struct ti_i2c_firmware_rec *firmware_rec;
-   const struct firmware *fw;
-   const char *fw_name = "edgeport/down3.bin";
+   u8 fw_major_version = fw->data[0];
+   u8 fw_minor_version = fw->data[1];
 
/* In order to update the I2C firmware we must change the type 2 record
 * to type 0xF2.  This will force the UMP to come up in Boot Mode.
@@ -785,24 +782,11 @@ static int build_i2c_fw_hdr(__u8 *header, struct device 
*dev)
// Set entire image of 0xffs
memset(buffer, 0xff, buffer_size);
 
-   err = request_firmware(&fw, fw_name, dev);
-   if (err) {
-   dev_err(dev, "Failed to load image \"%s\" err %d\n",
-   fw_name, err);
-   kfree(buffer);
-   return err;
-   }
-
-   /* Save Download Version Number */
-   OperationalMajorVersion = fw->data[0];
-   OperationalMinorVersion = fw->data[1];
-   OperationalBuildNumber = fw->data[2] | (fw->data[3] << 8);
-
/* Copy version number into firmware record */
firmware_rec = (struct ti_i2c_firmware_rec *)buffer;
 
-   firmware_rec->Ver_Major = OperationalMajorVersion;
-   firmware_rec->Ver_Minor = OperationalMinorVersion;
+   firmware_rec->Ver_Major = fw_major_version;
+   firmware_rec->Ver_Minor = fw_minor_version;
 
/* Pointer to fw_down memory image */
img_header = (struct ti_i2c_image_header *)&fw->data[4];
@@ -811,8 +795,6 @@ static int build_i2c_fw_hdr(__u8 *header, struct device 
*dev)
&fw->data[4 + sizeof(struct ti_i2c_image_header)],
le16_to_cpu(img_header->Length));
 
-   release_firmware(fw);
-
for (i=0; i < buffer_size; i++) {
cs = (__u8)(cs + buffer[i]);
}
@@ -826,8 +808,8 @@ static int build_i2c_fw_hdr(__u8 *header, struct device 
*dev)
i2c_header->Type= I2C_DESC_TYPE_FIRMWARE_BLANK;
i2c_header->Size= cpu_to_le16(buffer_size);
i2c_header->CheckSum= cs;
-   firmware_rec->Ver_Major = OperationalMajorVersion;
-   firmware_rec->Ver_Minor = OperationalMinorVersion;
+   firmware_rec->Ver_Major = fw_major_version;
+   firmware_rec->Ver_Minor = fw_minor_version;
 
return 0;
 }
@@ -934,7 +916,8 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc)
  * This routine downloads the main operating code into the TI5052, using the
  * boot code already burned into E2PROM or ROM.
  */
-static int download_fw(struct edgeport_serial *serial)
+static int download_fw(struct edgeport_serial *serial,
+   

Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities

2015-06-18 Thread Roger Quadros
On Thu, 18 Jun 2015 16:20:30 +0800
Li Jun  wrote:

> On Thu, Jun 18, 2015 at 10:39:35AM +0300, Roger Quadros wrote:
> > Typo in subject
> > gadeget's -> gadget's
> > 
> > On Wed, 17 Jun 2015 19:40:15 +0800
> > Li Jun  wrote:
> > 
> > > Set gadget's otg capabilities according to controller's capability and otg
> > > properties in device tree.
> > > 
> > > Signed-off-by: Li Jun 
> > > ---
> > >  drivers/usb/chipidea/core.c  | 8 
> > >  drivers/usb/chipidea/udc.c   | 7 ++-
> > >  include/linux/usb/chipidea.h | 1 +
> > >  3 files changed, 15 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > > index 74fea4f..2abecbc 100644
> > > --- a/drivers/usb/chipidea/core.c
> > > +++ b/drivers/usb/chipidea/core.c
> > > @@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,
> > >   of_usb_host_tpl_support(dev->of_node);
> > >   }
> > >  
> > > + if (platdata->dr_mode == USB_DR_MODE_OTG) {
> > > + /* We can support HNP and SRP */
> > > + platdata->ci_otg_caps.hnp_support = true;
> > > + platdata->ci_otg_caps.srp_support = true;
> > > + /* Update otg capabilities by DT properties */
> > > + of_usb_set_otg_caps(dev->of_node, &platdata->ci_otg_caps);
> > 
> > we're not tackling the legacy platform case.
> > i.e. when otg-rev is not present in DT.
> > 
> Legacy platforms with chipidea controller can use otg HNP and SRP
> without any otg properties passed, so I keep hnp and srp to be true.

I was thinking that controller should set whatever it supports regardless of
legacy platforms.
e.g. if chipidea controller supports ADP then it should set it to true here
before calling of_usb_update_otg_caps().

And it should also set the best OTG version it supports and not leave it to 0.

of_usb_update_otg_caps() should then take the decision based on
controller otg_caps and DT otg flags as to what must be done.

> 
> > one way could be that of_usb_set_otg_caps sets otg-rev to 0 if
> > it is not present in DT.
> > 
> otg-rev should be 0 as initial value if it's not present in DT, isn't it?

That's because you didn't set the otg-rev that chipidea controller supports.

This will break for example if DT passes otg-rev 3.0 and controller supports
only otg-rev 2.0 but we didn't bother to check :)

Let's do whatever common functionality we can in of_usb_update_otg_caps()
rather than depending on controller drivers and inviting more errors.

cheers,
-roger

> 
> > > + }
> > > +
> > >   if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
> > >   platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
> > >  
> > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > > index 764f668..858bd21 100644
> > > --- a/drivers/usb/chipidea/udc.c
> > > +++ b/drivers/usb/chipidea/udc.c
> > > @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
> > >  static int udc_start(struct ci_hdrc *ci)
> > >  {
> > >   struct device *dev = ci->dev;
> > > + struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
> > >   int retval = 0;
> > >  
> > >   spin_lock_init(&ci->lock);
> > > @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci)
> > >   ci->gadget.ops  = &usb_gadget_ops;
> > >   ci->gadget.speed= USB_SPEED_UNKNOWN;
> > >   ci->gadget.max_speed= USB_SPEED_HIGH;
> > > - ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
> > >   ci->gadget.name = ci->platdata->name;
> > > + ci->gadget.otg_caps = otg_caps;
> > > +
> > > + if (otg_caps->otg_rev && (otg_caps->hnp_support ||
> > > + otg_caps->srp_support || otg_caps->adp_support))
> > > + ci->gadget.is_otg = 1;
> > >  
> > >   INIT_LIST_HEAD(&ci->gadget.ep_list);
> > >  
> > > diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> > > index ab94f78..e10cefc 100644
> > > --- a/include/linux/usb/chipidea.h
> > > +++ b/include/linux/usb/chipidea.h
> > > @@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {
> > >  #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
> > >   void(*notify_event) (struct ci_hdrc *ci, unsigned event);
> > >   struct regulator*reg_vbus;
> > > + struct usb_otg_caps ci_otg_caps;
> > >   booltpl_support;
> > >  };
> > >  
> > > -- 
> > > 1.9.1
> > > 
> > 
> > cheers,
> > -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Roger Quadros
On Thu, 18 Jun 2015 16:47:48 +0800
Li Jun  wrote:

> On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> > Lin,
> > 
> > You can use --in-reply-to "message id of v5 of this path" so that it 
> > appears together
> > with the other patches in peoples mailboxes.
> > 
> > > + * the passed properties in DT.
> > > + * @np: Pointer to the given device_node
> > > + * @otg_caps: Pointer to the target usb_otg_caps to be set
> > > + *
> > > + * The function gets and sets the otg capabilities
> > > + */
> > > +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> > > *otg_caps)
> > > +{
> > > + u32 otg_rev;
> > > +
> > > + if (!otg_caps)
> > > + return;
> > > +
> > > + if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> > > + otg_caps->otg_rev = otg_rev;
> > 
> > should we check if otg_rev is in correct format?
> > anything non BCD and greater than 0x is invalid.
> > 
> > Also if otg-rev is not passed then we need to treat it as legacy
> > platform right? How is this taken care of?
> > 
> Missed this comment
> This handling rely on controller driver, cannot decided here.
> There are several cases we need take care:
> 1) otg-rev is not passed, but all 3 disable flags passed, this is
>   valid, means user want to disable whole OTG, so only "otg-rev"
>   not passed, cannot treat as legacy platform.
> 2) Legacy platform means: none of 4 properties is present.

Right. Plus controller drivers that are not updated to use these otg_caps
are also legacy.

> 3) Some controller drivers already support OTG HNP/SRP, then change
>   to utilize those new flags, still should support OTG HNP/SRP w/o
>   any dt change, so OTG caps should be enabled for legacy platforms.

I didn't understand this point. If a controller driver is not updated
to use otg_caps it is legacy and gadget->otg_caps will be NULL.

> 4) Some controller drivers does not support any OTG, after add OTG
>   functions and utilize those new flags, should keep OTG disabled
>   for legacy platforms.

If controller drivers don't support OTG. gadget->is_otg and
gadget->otg_caps will not be set by them and they don't have to use
of_usb_set_otg_caps().

So I didn't understand why the decision can't be taken here
for non-legacy controller drivers with legacy DT.
They will set gadget->otg_caps and gadget->is_otg.

If none of the 4 DT flags are passed then we know it is legacy DT
and we can limit to legacy behaviour.

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


[PATCH v2 5/7] samples: kdbus: disable for mn10300

2015-06-18 Thread Sudip Mukherjee
While building it failed with:
In function 'prime_new':
error: '__NR_memfd_create' undeclared (first use in this function)

memfd_create syscall has not yet been implemented for mn10300.
so disable compilation of samples/kdbus for now with mn10300.

Signed-off-by: Sudip Mukherjee 
---
 samples/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/Kconfig b/samples/Kconfig
index a4c6b2f..20c55af 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -57,7 +57,7 @@ config SAMPLE_KDB
 
 config SAMPLE_KDBUS
bool "Build kdbus API example"
-   depends on KDBUS
+   depends on KDBUS && !MN10300
help
  Build an example of how the kdbus API can be used from
  userspace.
-- 
1.8.1.2

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


[PATCH v2 4/7] USB: mos7720: rename DCR

2015-06-18 Thread Sudip Mukherjee
While building with mn10300 it failed with:
error: expected identifier before '(' token
 #define __SYSREG(ADDR, TYPE) (*(volatile TYPE *)(ADDR))
note: in expansion of macro '__SYSREG'
 #define DCR   __SYSREG(0xc030, u16) /* Debug control register */

mn10300 has a register named as DCR, so when this driver used an enum
named as DCR, build failed.
Just rename the DCR in the driver to parport_DCR.

Signed-off-by: Sudip Mukherjee 
---
 drivers/usb/serial/mos7720.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 4f70df3..3263125 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -135,7 +135,7 @@ enum mos_regs {
DLM,
DPR,  /* parallel port regs */
DSR,
-   DCR,
+   parport_DCR,
ECR,
SP1_REG,  /* device control regs */
SP2_REG,  /* serial port 2 (7720 only) */
@@ -164,7 +164,7 @@ static inline __u16 get_reg_index(enum mos_regs reg)
0x01,   /* DLM */
0x00,   /* DPR */
0x01,   /* DSR */
-   0x02,   /* DCR */
+   0x02,   /* parport_DCR */
0x0a,   /* ECR */
0x01,   /* SP1_REG */
0x02,   /* SP2_REG (7720 only) */
@@ -510,7 +510,7 @@ static void parport_mos7715_write_control(struct parport 
*pp, unsigned char d)
if (parport_prologue(pp) < 0)
return;
data = ((__u8)d & 0x0f) | (mos_parport->shadowDCR & 0xf0);
-   write_mos_reg(mos_parport->serial, dummy, DCR, data);
+   write_mos_reg(mos_parport->serial, dummy, parport_DCR, data);
mos_parport->shadowDCR = data;
parport_epilogue(pp);
 }
@@ -543,7 +543,7 @@ static unsigned char parport_mos7715_frob_control(struct 
parport *pp,
if (parport_prologue(pp) < 0)
return 0;
mos_parport->shadowDCR = (mos_parport->shadowDCR & (~mask)) ^ val;
-   write_mos_reg(mos_parport->serial, dummy, DCR, mos_parport->shadowDCR);
+   write_mos_reg(mos_parport->serial, dummy, parport_DCR, 
mos_parport->shadowDCR);
dcr = mos_parport->shadowDCR & 0x0f;
parport_epilogue(pp);
return dcr;
@@ -581,7 +581,7 @@ static void parport_mos7715_data_forward(struct parport *pp)
return;
mos7715_change_mode(mos_parport, PS2);
mos_parport->shadowDCR &=  ~0x20;
-   write_mos_reg(mos_parport->serial, dummy, DCR, mos_parport->shadowDCR);
+   write_mos_reg(mos_parport->serial, dummy, parport_DCR, 
mos_parport->shadowDCR);
parport_epilogue(pp);
 }
 
@@ -593,7 +593,7 @@ static void parport_mos7715_data_reverse(struct parport *pp)
return;
mos7715_change_mode(mos_parport, PS2);
mos_parport->shadowDCR |= 0x20;
-   write_mos_reg(mos_parport->serial, dummy, DCR, mos_parport->shadowDCR);
+   write_mos_reg(mos_parport->serial, dummy, parport_DCR, 
mos_parport->shadowDCR);
parport_epilogue(pp);
 }
 
@@ -633,7 +633,7 @@ static void parport_mos7715_restore_state(struct parport 
*pp,
spin_unlock(&release_lock);
return;
}
-   write_parport_reg_nonblock(mos_parport, DCR, mos_parport->shadowDCR);
+   write_parport_reg_nonblock(mos_parport, parport_DCR, 
mos_parport->shadowDCR);
write_parport_reg_nonblock(mos_parport, ECR, mos_parport->shadowECR);
spin_unlock(&release_lock);
 }
@@ -719,7 +719,7 @@ static int mos7715_parport_init(struct usb_serial *serial)
 
/* initialize device registers */
mos_parport->shadowDCR = DCR_INIT_VAL;
-   write_mos_reg(mos_parport->serial, dummy, DCR, mos_parport->shadowDCR);
+   write_mos_reg(mos_parport->serial, dummy, parport_DCR, 
mos_parport->shadowDCR);
mos_parport->shadowECR = ECR_INIT_VAL;
write_mos_reg(mos_parport->serial, dummy, ECR, mos_parport->shadowECR);
 
-- 
1.8.1.2

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


[PATCH v2 3/7] mmc: mediatek: build as module

2015-06-18 Thread Sudip Mukherjee
while building as module with mn10300 it failed with:

warning: data definition has no type or storage class
module_init(__driver##_init);

Signed-off-by: Sudip Mukherjee 
---
 drivers/mmc/host/mtk-sd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 7c20f28..ea6ae36 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_BD_NUM  1024
 
-- 
1.8.1.2

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


[PATCH v2 7/7] mn10300: add early_init_dt_*

2015-06-18 Thread Sudip Mukherjee
While building it failed with:
undefined reference to `early_init_dt_alloc_memory_arch'
undefined reference to `early_init_dt_add_memory_arch'

Added the function after seeing them in x86.

Signed-off-by: Sudip Mukherjee 
---
 arch/mn10300/kernel/setup.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/mn10300/kernel/setup.c b/arch/mn10300/kernel/setup.c
index 2ad7f32..f0e08b0 100644
--- a/arch/mn10300/kernel/setup.c
+++ b/arch/mn10300/kernel/setup.c
@@ -87,6 +87,21 @@ static int __init early_mem(char *p)
 early_param("mem", early_mem);
 
 /*
+ * early_init_dt_add_memory_arch() and early_init_dt_alloc_memory_arch()
+ * borrowed from arch/x86/kernel/devicetree.c
+ */
+
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+   BUG();
+}
+
+void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+   return __alloc_bootmem(size, align, 0);
+}
+
+/*
  * architecture specific setup
  */
 void __init setup_arch(char **cmdline_p)
-- 
1.8.1.2

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


[PATCH v2 6/7] mn10300: kgdb_arch_set_pc

2015-06-18 Thread Sudip Mukherjee
While building it failed with:
undefined reference to `kgdb_arch_set_pc'

Signed-off-by: Sudip Mukherjee 
---
 arch/mn10300/kernel/kgdb.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/mn10300/kernel/kgdb.c b/arch/mn10300/kernel/kgdb.c
index 9977082..8a0ae2b 100644
--- a/arch/mn10300/kernel/kgdb.c
+++ b/arch/mn10300/kernel/kgdb.c
@@ -499,3 +499,8 @@ void kgdb_roundup_cpus(unsigned long flags)
smp_jump_to_debugger();
 }
 #endif
+
+void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
+{
+   regs->pc = ip;
+}
-- 
1.8.1.2

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


Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Roger Quadros
On Thu, 18 Jun 2015 15:55:28 +0800
Li Jun  wrote:

> On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> > Lin,
> > 
> > You can use --in-reply-to "message id of v5 of this path" so that it 
> > appears together
> > with the other patches in peoples mailboxes.
> > 
> okay, I will try that next time, thanks.
> 
> Li Jun
> > On Thu, 18 Jun 2015 09:18:22 +0800
> > Li Jun  wrote:
> > 
> > > Change for v6:
> > > UPdate otg caps by disable flags even if otg_rev is not passed, this is
> > > needed in case user wants to disable whole OTG(or just want to ID pin
> > > detect).
> > > 
> > > Check property of usb hardware to get otg version and if SRP, HNP and ADP
> > > are disabled.
> > > 
> > > Signed-off-by: Li Jun 
> > > ---
> > >  drivers/usb/common/common.c | 27 +++
> > >  include/linux/usb/of.h  |  7 +++
> > >  2 files changed, 34 insertions(+)
> > > 
> > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> > > index b530fd4..12f5d28 100644
> > > --- a/drivers/usb/common/common.c
> > > +++ b/drivers/usb/common/common.c
> > > @@ -154,6 +154,33 @@ bool of_usb_host_tpl_support(struct device_node *np)
> > >   return false;
> > >  }
> > >  EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
> > > +
> > > +/**
> > > + * of_usb_get_set_caps - to set usb otg capabilities according to
> > 
> > get or set?
> > how about update instead?
> > 
> Should be set, update? okay.
> 
> Li Jun
> > > + * the passed properties in DT.
> > > + * @np: Pointer to the given device_node
> > > + * @otg_caps: Pointer to the target usb_otg_caps to be set
> > > + *
> > > + * The function gets and sets the otg capabilities
> > > + */
> > > +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> > > *otg_caps)
> > > +{
> > > + u32 otg_rev;
> > > +
> > > + if (!otg_caps)
> > > + return;
> > > +
> > > + if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> > > + otg_caps->otg_rev = otg_rev;
> > 
> > should we check if otg_rev is in correct format?
> > anything non BCD and greater than 0x is invalid.
> > 
> Then that's not so simple, every number should be checked,
> if ((otg_caps->otg_rev % 10) > 9) ||
>   ((otg_caps->otg_rev >> 4) % 10) > 9) ||
>   ((otg_caps->otg_rev >> 8) % 10) > 9) ||
>   ((otg_caps->otg_rev >> 12) % 10) > 9))
>   return error;
> We really need this kind of format check? seems no this check
> for bcdUSB.

How about checking for released spec versions instead?

switch (otg_rev) {
case 0x0100:
case 0x0110:
case 0x0200:
case 0x0300:
break;
default:
dev_err(dev, "unsupported otg-rev: 0x%x\n", otg_rev);
return error;
}

cheers,
-roger

>   
> > Also if otg-rev is not passed then we need to treat it as legacy
> > platform right? How is this taken care of?
> > 
> > > + if (of_find_property(np, "hnp-disable", NULL))
> > > + otg_caps->hnp_support = false;
> > > + if (of_find_property(np, "srp-disable", NULL))
> > > + otg_caps->srp_support = false;
> > > + if (of_find_property(np, "adp-disable", NULL))
> > > + otg_caps->adp_support = false;
> > 
> > Don't we expect it to do basic sanity checks?
> > e.g. if otg_rev < 0x200 then adp_support can't be true?
> > 
> Okay, it's better we add a sanity check here.
> 
> > > +}
> > > +EXPORT_SYMBOL_GPL(of_usb_set_otg_caps);
> > > +
> > >  #endif
> > >  
> > >  MODULE_LICENSE("GPL");
> > > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> > > index cfe0528..6339799 100644
> > > --- a/include/linux/usb/of.h
> > > +++ b/include/linux/usb/of.h
> > > @@ -15,6 +15,8 @@
> > >  enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
> > >  enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
> > >  bool of_usb_host_tpl_support(struct device_node *np);
> > > +void of_usb_set_otg_caps(struct device_node *np,
> > > + struct usb_otg_caps *otg_caps);
> > >  #else
> > >  static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> > >  {
> > > @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct 
> > > device_node *np)
> > >  {
> > >   return false;
> > >  }
> > > +static inline void of_usb_set_otg_caps(struct device_node *np,
> > > + struct usb_otg_caps *otg_caps)
> > > +{
> > > +
> > > +}
> > >  #endif
> > >  
> > >  #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
> > > -- 
> > > 1.9.1
> > > 
> > 
> > cheers,
> > -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/7] fix build failure of mn10300

2015-06-18 Thread Sudip Mukherjee
Hi,
This is an attempt to fix the build failures when building mn10300 with
allmodconfig. As I have never worked with arch files so I hope you will
point me to right direction to correct my mistakes in this attempt.

regards
sudip

Sudip Mukherjee (7):
  mn10300: fix build failure
  mn10300: Provide dummy dma_alloc_attrs() and dma_free_attrs()
  mmc: mediatek: build as module
  USB: mos7720: rename DCR
  samples: kdbus: disable for mn10300
  mn10300: kgdb_arch_set_pc
  mn10300: add early_init_dt_*

 arch/mn10300/include/asm/dma-mapping.h | 13 +
 arch/mn10300/include/asm/kprobes.h | 12 
 arch/mn10300/kernel/kgdb.c |  5 +
 arch/mn10300/kernel/setup.c| 15 +++
 drivers/mmc/host/mtk-sd.c  |  1 +
 drivers/usb/serial/mos7720.c   | 16 
 samples/Kconfig|  2 +-
 7 files changed, 55 insertions(+), 9 deletions(-)

-- 
1.8.1.2

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


[PATCH v2 2/7] mn10300: Provide dummy dma_alloc_attrs() and dma_free_attrs()

2015-06-18 Thread Sudip Mukherjee
allmodconfig fails to build with following errors.

drivers/media/platform/sti/bdisp/bdisp-hw.c:
In function 'bdisp_hw_free_nodes':
drivers/media/platform/sti/bdisp/bdisp-hw.c:132:3: error:
implicit declaration of function 'dma_free_attrs'

drivers/media/platform/sti/bdisp/bdisp-hw.c:
In function 'bdisp_hw_alloc_nodes':
drivers/media/platform/sti/bdisp/bdisp-hw.c:157:2: error:
implicit declaration of function 'dma_alloc_attrs'

mn10300 does not provide those functions at this time.
Provide dummy implementations to avoid build errors.

Signed-off-by: Sudip Mukherjee 
---

copied from https://lkml.org/lkml/2015/4/22/346

 arch/mn10300/include/asm/dma-mapping.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/mn10300/include/asm/dma-mapping.h 
b/arch/mn10300/include/asm/dma-mapping.h
index a18abfc..d589c5e 100644
--- a/arch/mn10300/include/asm/dma-mapping.h
+++ b/arch/mn10300/include/asm/dma-mapping.h
@@ -183,4 +183,17 @@ static inline int dma_get_sgtable(struct device *dev, 
struct sg_table *sgt,
return -EINVAL;
 }
 
+static inline void *dma_alloc_attrs(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t flag,
+   struct dma_attrs *attrs)
+{
+   return NULL;
+}
+
+static inline void dma_free_attrs(struct device *dev, size_t size,
+ void *vaddr, dma_addr_t dma_handle,
+ struct dma_attrs *attrs)
+{
+}
+
 #endif
-- 
1.8.1.2

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


[PATCH v2 1/7] mn10300: fix build failure

2015-06-18 Thread Sudip Mukherjee
allmodconfig build fails with the error:
invalid use of undefined type 'struct kprobe_ctlblk'

just declared the two basic structures after checking the struct in other
architectures.

Signed-off-by: Sudip Mukherjee 
---
 arch/mn10300/include/asm/kprobes.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/mn10300/include/asm/kprobes.h 
b/arch/mn10300/include/asm/kprobes.h
index c800b59..c90d2b1 100644
--- a/arch/mn10300/include/asm/kprobes.h
+++ b/arch/mn10300/include/asm/kprobes.h
@@ -47,4 +47,16 @@ extern int kprobe_exceptions_notify(struct notifier_block 
*self,
 
 extern void arch_remove_kprobe(struct kprobe *p);
 
+struct prev_kprobe {
+   struct kprobe *kp;
+   unsigned long status;
+};
+
+struct kprobe_ctlblk {
+   unsigned int kprobe_status;
+   struct pt_regs jprobe_saved_regs;
+   char jprobes_stack[MAX_STACK_SIZE];
+   struct prev_kprobe prev_kprobe;
+};
+
 #endif /* _ASM_KPROBES_H */
-- 
1.8.1.2

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


Re: [PATCH v2 3/7] mmc: mediatek: build as module

2015-06-18 Thread Ulf Hansson
On 18 June 2015 at 14:17, Sudip Mukherjee  wrote:
> while building as module with mn10300 it failed with:
>
> warning: data definition has no type or storage class
> module_init(__driver##_init);
>
> Signed-off-by: Sudip Mukherjee 

Thanks for the patch. It's although already been fixed on my next branch.

Kind regards
Uffe

> ---
>  drivers/mmc/host/mtk-sd.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 7c20f28..ea6ae36 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -33,6 +33,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define MAX_BD_NUM  1024
>
> --
> 1.8.1.2
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 03:06:27PM +0300, Roger Quadros wrote:
> On Thu, 18 Jun 2015 16:20:30 +0800
> Li Jun  wrote:
> 
> > On Thu, Jun 18, 2015 at 10:39:35AM +0300, Roger Quadros wrote:
> > > Typo in subject
> > > gadeget's -> gadget's
> > > 
> > > On Wed, 17 Jun 2015 19:40:15 +0800
> > > Li Jun  wrote:
> > > 
> > > > Set gadget's otg capabilities according to controller's capability and 
> > > > otg
> > > > properties in device tree.
> > > > 
> > > > Signed-off-by: Li Jun 
> > > > ---
> > > >  drivers/usb/chipidea/core.c  | 8 
> > > >  drivers/usb/chipidea/udc.c   | 7 ++-
> > > >  include/linux/usb/chipidea.h | 1 +
> > > >  3 files changed, 15 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > > > index 74fea4f..2abecbc 100644
> > > > --- a/drivers/usb/chipidea/core.c
> > > > +++ b/drivers/usb/chipidea/core.c
> > > > @@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,
> > > > of_usb_host_tpl_support(dev->of_node);
> > > > }
> > > >  
> > > > +   if (platdata->dr_mode == USB_DR_MODE_OTG) {
> > > > +   /* We can support HNP and SRP */
> > > > +   platdata->ci_otg_caps.hnp_support = true;
> > > > +   platdata->ci_otg_caps.srp_support = true;
> > > > +   /* Update otg capabilities by DT properties */
> > > > +   of_usb_set_otg_caps(dev->of_node, 
> > > > &platdata->ci_otg_caps);
> > > 
> > > we're not tackling the legacy platform case.
> > > i.e. when otg-rev is not present in DT.
> > > 
> > Legacy platforms with chipidea controller can use otg HNP and SRP
> > without any otg properties passed, so I keep hnp and srp to be true.
> 
> I was thinking that controller should set whatever it supports regardless of
> legacy platforms.
> e.g. if chipidea controller supports ADP then it should set it to true here
> before calling of_usb_update_otg_caps().
> 
Now chipidea only support HNP and SRP, that's the best capability.

> And it should also set the best OTG version it supports and not leave it to 0.
> 
Best version is 2.0 for chipidea.
But I cannot find the real case to use the best version(as initial setting) by
controller in the end, anyway for a OTG device, the otg-rev should be passed
and the dt value should be used.
 
> of_usb_update_otg_caps() should then take the decision based on
> controller otg_caps and DT otg flags as to what must be done.
>
The decision some how depends on controller drivers. Can not be fixed.
 
> > 
> > > one way could be that of_usb_set_otg_caps sets otg-rev to 0 if
> > > it is not present in DT.
> > > 
> > otg-rev should be 0 as initial value if it's not present in DT, isn't it?
> 
> That's because you didn't set the otg-rev that chipidea controller supports.
> 
> This will break for example if DT passes otg-rev 3.0 and controller supports
> only otg-rev 2.0 but we didn't bother to check :)
> 
okay, another crazy dt user, I see the usage of initial setting of otg-rev
here, we can use it to decide the final version if a wrong value is passed.

> Let's do whatever common functionality we can in of_usb_update_otg_caps()
> rather than depending on controller drivers and inviting more errors.
> 
The only question is: if none of 4 flags passed, we should set what kind of
otg capability in of_usb_update_otg_caps?
there are 2 kind legacy platforms, one is some really can support HNP.
the other one is it cannot support any real OTG.

Li Jun
> cheers,
> -roger
> 
> > 
> > > > +   }
> > > > +
> > > > if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
> > > > platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
> > > >  
> > > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > > > index 764f668..858bd21 100644
> > > > --- a/drivers/usb/chipidea/udc.c
> > > > +++ b/drivers/usb/chipidea/udc.c
> > > > @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
> > > >  static int udc_start(struct ci_hdrc *ci)
> > > >  {
> > > > struct device *dev = ci->dev;
> > > > +   struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
> > > > int retval = 0;
> > > >  
> > > > spin_lock_init(&ci->lock);
> > > > @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci)
> > > > ci->gadget.ops  = &usb_gadget_ops;
> > > > ci->gadget.speed= USB_SPEED_UNKNOWN;
> > > > ci->gadget.max_speed= USB_SPEED_HIGH;
> > > > -   ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
> > > > ci->gadget.name = ci->platdata->name;
> > > > +   ci->gadget.otg_caps = otg_caps;
> > > > +
> > > > +   if (otg_caps->otg_rev && (otg_caps->hnp_support ||
> > > > +   otg_caps->srp_support || otg_caps->adp_support))
> > > > +   ci->gadget.is_otg = 1;
> > > >  
> > > > INIT_LIST_HEAD(&ci->gadget.ep_list);
> > > >  
> > > > diff --git a/include/l

Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 03:07:48PM +0300, Roger Quadros wrote:
> On Thu, 18 Jun 2015 16:47:48 +0800
> Li Jun  wrote:
> 
> > On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> > > Lin,
> > > 
> > > You can use --in-reply-to "message id of v5 of this path" so that it 
> > > appears together
> > > with the other patches in peoples mailboxes.
> > > 
> > > > + * the passed properties in DT.
> > > > + * @np: Pointer to the given device_node
> > > > + * @otg_caps: Pointer to the target usb_otg_caps to be set
> > > > + *
> > > > + * The function gets and sets the otg capabilities
> > > > + */
> > > > +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps 
> > > > *otg_caps)
> > > > +{
> > > > +   u32 otg_rev;
> > > > +
> > > > +   if (!otg_caps)
> > > > +   return;
> > > > +
> > > > +   if (!of_property_read_u32(np, "otg-rev", &otg_rev))
> > > > +   otg_caps->otg_rev = otg_rev;
> > > 
> > > should we check if otg_rev is in correct format?
> > > anything non BCD and greater than 0x is invalid.
> > > 
> > > Also if otg-rev is not passed then we need to treat it as legacy
> > > platform right? How is this taken care of?
> > > 
> > Missed this comment
> > This handling rely on controller driver, cannot decided here.
> > There are several cases we need take care:
> > 1) otg-rev is not passed, but all 3 disable flags passed, this is
> >   valid, means user want to disable whole OTG, so only "otg-rev"
> >   not passed, cannot treat as legacy platform.
> > 2) Legacy platform means: none of 4 properties is present.
> 
> Right. Plus controller drivers that are not updated to use these otg_caps
> are also legacy.
>
Did not understand the "Plus" case.
Some of 4 properties is present, but its driver dose not use otg_caps?

> > 3) Some controller drivers already support OTG HNP/SRP, then change
> >   to utilize those new flags, still should support OTG HNP/SRP w/o
> >   any dt change, so OTG caps should be enabled for legacy platforms.
> 
> I didn't understand this point. If a controller driver is not updated
> to use otg_caps it is legacy and gadget->otg_caps will be NULL.
> 
Some of existing chipdea platforms work fine on HNP and SRP , which did
not use any new flags and properties, after my patch, those platform should
still enable HNP and SRP without any DT change.

> > 4) Some controller drivers does not support any OTG, after add OTG
> >   functions and utilize those new flags, should keep OTG disabled
> >   for legacy platforms.
> 
> If controller drivers don't support OTG. gadget->is_otg and
> gadget->otg_caps will not be set by them and they don't have to use
> of_usb_set_otg_caps().
> 
But after my patch, some time later, this driver adds OTG functions on
it new platform, it should disable any OTG feature for its legacy
platforms (none of properties is passed).
 
> So I didn't understand why the decision can't be taken here
> for non-legacy controller drivers with legacy DT.
> They will set gadget->otg_caps and gadget->is_otg.
> 
> If none of the 4 DT flags are passed then we know it is legacy DT
> and we can limit to legacy behaviour.
> 
legacy behaviour number is 2, not only one legacy behaviour.
That's why I leave the otg caps decided by controller drivers.

> cheers,
> -roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/5] usb: Add usb interface authorization

2015-06-18 Thread Stefan Koch
Am Mittwoch, den 17.06.2015, 11:38 -0400 schrieb Alan Stern:
> On Wed, 17 Jun 2015, Stefan Koch wrote:
> 
> > You write in another mail:
> > "You could probe all the interfaces whenever any interface is
> > authorized. Or there could be a separate mechanism to initiate probing."
> > 
> > The first is the actual approach and this works fine.
> > It is regardless in which order the interfaces for USB-Tethering are
> > authorized. Both works.
> > Before probing *all* interfaces it was needed to authorize interface 1
> > before interface 0.
> > 
> > Also btusb works fine.
> > 
> > What do you think?
> 
> I think it's inelegant and will cause unnecessary probing with 
> errors whenever a driver needs to claim multiple interfaces.
> 
> However, I would like to hear what other people on the mailing list 
> think.
> 
> Alan Stern
> 
I'll send a fourth patch without automatically probing.

An option could be to implement the automatically probing and enable or
disable it by another sysfs attribute. (not included in the fourth
patch)


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


[PATCH v4 0/6] usb: interface authorization

2015-06-18 Thread Stefan Koch
This patch introduces an interface authorization for USB devices.
The kernel supports a device authorization because of wireless USB.

But the new interface authorization allows to authorize or deauthorize
individual interfaces instead authorization or deauthorize a whole device.

Therefore the authorized attribute is introduced for each interface.

Each patch depends on all patches with a lesser number.

Stefan Koch (6):
  usb: interface authorization: Declare authorized attribute
  usb: interface authorization: Introduces the default interface
authorization
  usb: interface authorization: Control interface probing and claiming
  usb: interface authorization: Introduces the USB interface
authorization.
  usb: interface authorization: SysFS part of USB interface
authorization.
  usb: interface authorization: Documentation part

 Documentation/ABI/testing/sysfs-bus-usb | 22 ++
 Documentation/usb/authorization.txt | 34 +
 drivers/usb/core/driver.c   | 11 +++
 drivers/usb/core/hcd.c  | 54 +
 drivers/usb/core/message.c  | 54 +
 drivers/usb/core/sysfs.c| 41 +
 drivers/usb/core/usb.h  |  2 ++
 include/linux/usb.h |  2 ++
 include/linux/usb/hcd.h |  4 +++
 9 files changed, 224 insertions(+)

-- 
2.1.4

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


[PATCH v4 1/6] usb: interface authorization: Declare authorized attribute

2015-06-18 Thread Stefan Koch
The attribute authorized shows the authorization state for an interface.

Signed-off-by: Stefan Koch 
---
 include/linux/usb.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447fe29..2a991cb 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -179,6 +179,8 @@ struct usb_interface {
unsigned needs_binding:1;   /* needs delayed unbind/rebind */
unsigned resetting_device:1;/* true: bandwidth alloc after reset */
 
+   unsigned authorized:1; /* used for interface authorization */
+
struct device dev;  /* interface specific device info */
struct device *usb_dev;
atomic_t pm_usage_cnt;  /* usage counter for autosuspend */
-- 
2.1.4

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


[PATCH v4 2/6] usb: interface authorization: Introduces the default interface authorization

2015-06-18 Thread Stefan Koch
Interfaces are allowed per default.
This can disabled or enabled (again) by writing 0 or 1 to
/sys/bus/usb/devices/usbX/interface_authorized_default

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/hcd.c | 54 ++
 drivers/usb/core/message.c |  2 ++
 include/linux/usb/hcd.h|  4 
 3 files changed, 60 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 45a915c..f00819c 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -882,9 +882,60 @@ static ssize_t authorized_default_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(authorized_default);
 
+/*
+ * interface_authorized_default_show - show default authorization status
+ * for USB interfaces
+ *
+ * note: interface_auhorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
+   unsigned def = HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd) ? 1 : 0;
+
+   return sprintf(buf, "%u\n", def);
+}
+
+/*
+ * interface_authorized_default_store - store default authorization status
+ * for USB interfaces
+ *
+ * note: interface_auhorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
+   int rc = count;
+   bool val;
+
+   if (!usb_dev || !hcd)
+   return -ENODEV;
+   else if (strtobool(buf, &val) != 0)
+   return -EINVAL;
+
+   switch (val) {
+   case 0:
+   clear_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+   break;
+   case 1:
+   set_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+   break;
+   }
+
+   return rc;
+}
+static DEVICE_ATTR_RW(interface_authorized_default);
+
 /* Group all the USB bus attributes */
 static struct attribute *usb_bus_attrs[] = {
&dev_attr_authorized_default.attr,
+   &dev_attr_interface_authorized_default.attr,
NULL,
 };
 
@@ -2679,6 +2730,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
hcd->authorized_default = authorized_default;
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
 
+   /* per default all interfaces are authorized */
+   set_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+
/* HC is in reset state, but accessible.  Now do the one-time init,
 * bottom up so that hcds can customize the root hubs before hub_wq
 * starts talking to them.  (Note, bus id is assigned early too.)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f368d20..1e85f62 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1807,6 +1807,8 @@ free_interfaces:
intfc = cp->intf_cache[i];
intf->altsetting = intfc->altsetting;
intf->num_altsetting = intfc->num_altsetting;
+   intf->authorized =
+   HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd) ? 1 : 0;
kref_get(&intfc->ref);
 
alt = usb_altnum_to_altsetting(intf, 0);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 68b1e83..87b52ac 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -120,6 +120,7 @@ struct usb_hcd {
 #define HCD_FLAG_WAKEUP_PENDING4   /* root hub is 
resuming? */
 #define HCD_FLAG_RH_RUNNING5   /* root hub is running? */
 #define HCD_FLAG_DEAD  6   /* controller has died? */
+#define HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT  8
 
/* The flags can be tested using these macros; they are likely to
 * be slightly faster than test_bit().
@@ -130,6 +131,8 @@ struct usb_hcd {
 #define HCD_WAKEUP_PENDING(hcd)((hcd)->flags & (1U << 
HCD_FLAG_WAKEUP_PENDING))
 #define HCD_RH_RUNNING(hcd)((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
 #define HCD_DEAD(hcd)  ((hcd)->flags & (1U << HCD_FLAG_DEAD))
+#define HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd)  \
+   ((hcd)->flags & (1U << HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT))
 
/* Flags that get set only during HCD registration or removal. */
unsignedrh_registered:1;/* is root hub registered? */
@@ -142,6 +145,7 @@ struct usb_hcd {
unsigneduses_new_polling:1;
unsignedwireless:1; /* Wireless USB HCD */
unsignedauthorized_default:1;
+   unsigned

[PATCH v4 4/6] usb: interface authorization: Introduces the USB interface authorization.

2015-06-18 Thread Stefan Koch
The kernel supports the device authorization because of wireless USB.
These is usable for wired USB devices, too.
These new interface authorization allows to enable or disable
individual interfaces instead a whole device.

If a deauthorized interface will be authorized so the driver probing must
be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/message.c | 52 ++
 drivers/usb/core/usb.h |  2 ++
 2 files changed, 54 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 1e85f62..333957a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1555,6 +1555,58 @@ static void usb_release_interface(struct device *dev)
kfree(intf);
 }
 
+/*
+ * usb_deauthorize_interface - deauthorize an USB interface
+ *
+ * @intf: USB interface structure
+ *
+ * Returns: 0 at success, <0 at failure
+ */
+int usb_deauthorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = &intf->dev;
+
+   if (!dev || !dev->parent)
+   return -ENODEV;
+
+   device_lock(dev->parent);
+
+   if (intf->authorized) {
+   device_lock(dev);
+   intf->authorized = 0;
+   device_unlock(dev);
+
+   usb_forced_unbind_intf(intf);
+   }
+
+   device_unlock(dev->parent);
+
+   return 0;
+}
+
+/*
+ * usb_authorize_interface - authorize an USB interface
+ *
+ * @intf: USB interface structure
+ *
+ * Returns: 0 at success, <0 at failure
+ */
+int usb_authorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = &intf->dev;
+
+   if (!dev)
+   return -ENODEV;
+
+   if (!intf->authorized) {
+   device_lock(dev);
+   intf->authorized = 1; /* authorize interface */
+   device_unlock(dev);
+   }
+
+   return 0;
+}
+
 static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
struct usb_device *usb_dev;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 7eb1e26..37b0055 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -27,6 +27,8 @@ extern void usb_release_interface_cache(struct kref *ref);
 extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
 extern int usb_deauthorize_device(struct usb_device *);
 extern int usb_authorize_device(struct usb_device *);
+extern int usb_deauthorize_interface(struct usb_interface *);
+extern int usb_authorize_interface(struct usb_interface *);
 extern void usb_detect_quirks(struct usb_device *udev);
 extern void usb_detect_interface_quirks(struct usb_device *udev);
 extern int usb_remove_device(struct usb_device *udev);
-- 
2.1.4

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


[PATCH v4 5/6] usb: interface authorization: SysFS part of USB interface authorization.

2015-06-18 Thread Stefan Koch
This introduces an attribute for each interface to
authorize (1) or deauthorize (0) it:
/sys/bus/usb/devices/INTERFACE/authorized

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/sysfs.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index d269738..457bff5 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -926,6 +926,46 @@ static ssize_t supports_autosuspend_show(struct device 
*dev,
 }
 static DEVICE_ATTR_RO(supports_autosuspend);
 
+/*
+ * interface_authorized_show - show authorization status of an USB interface
+ * 1 is authorized, 0 is deauthorized
+ */
+static ssize_t interface_authorized_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+
+   return sprintf(buf, "%u\n", intf->authorized);
+}
+
+/*
+ * interface_authorized_store - authorize or deauthorize an USB interface
+ * 1 is to authorize, 0 is to deauthorize
+ */
+static ssize_t interface_authorized_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+   bool val;
+
+   if (strtobool(buf, &val) != 0)
+   return -EINVAL;
+
+   switch (val) {
+   case 0:
+   usb_deauthorize_interface(intf);
+   break;
+   case 1:
+   usb_authorize_interface(intf);
+   break;
+   }
+
+   return count;
+}
+static struct device_attribute dev_attr_interface_authorized =
+   __ATTR(authorized, S_IRUGO | S_IWUSR,
+   interface_authorized_show, interface_authorized_store);
+
 static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceNumber.attr,
&dev_attr_bAlternateSetting.attr,
@@ -935,6 +975,7 @@ static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceProtocol.attr,
&dev_attr_modalias.attr,
&dev_attr_supports_autosuspend.attr,
+   &dev_attr_interface_authorized.attr,
NULL,
 };
 static struct attribute_group intf_attr_grp = {
-- 
2.1.4

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


[PATCH v4 6/6] usb: interface authorization: Documentation part

2015-06-18 Thread Stefan Koch
This part adds the documentation for the interface authorization.

Signed-off-by: Stefan Koch 
---
 Documentation/ABI/testing/sysfs-bus-usb | 22 +
 Documentation/usb/authorization.txt | 34 +
 2 files changed, 56 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index e5cc763..ca8c8d3 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -1,3 +1,25 @@
+What:  /sys/bus/usb/devices/INTERFACE/authorized
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This allows to authorize (1) or deauthorize (0)
+   individual interfaces instead a whole device
+   in contrast to the device authorization.
+   If a deauthorized interface will be authorized
+   so the driver probing must be triggered manually
+   by writing INTERFACE to /sys/bus/usb/drivers_probe
+   This allows to avoid side-effects with drivers
+   that need multiple interfaces.
+   A deauthorized interface cannot be probed or claimed.
+
+What:  /sys/bus/usb/devices/usbX/interface_authorized_default
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This is used as default value that determines
+   if interfaces would authorized per default.
+   The value can be 1 or 0. It is per default 1.
+
 What:  /sys/bus/usb/device/.../authorized
 Date:  July 2008
 KernelVersion: 2.6.26
diff --git a/Documentation/usb/authorization.txt 
b/Documentation/usb/authorization.txt
index c069b68..020cec5 100644
--- a/Documentation/usb/authorization.txt
+++ b/Documentation/usb/authorization.txt
@@ -3,6 +3,9 @@ Authorizing (or not) your USB devices to connect to the system
 
 (C) 2007 Inaky Perez-Gonzalez  Intel Corporation
 
+Interface authorization part:
+   (C) 2015 Stefan Koch  SUSE LLC
+
 This feature allows you to control if a USB device can be used (or
 not) in a system. This feature will allow you to implement a lock-down
 of USB devices, fully controlled by user space.
@@ -90,3 +93,34 @@ etc, but you get the idea. Anybody with access to a device 
gadget kit
 can fake descriptors and device info. Don't trust that. You are
 welcome.
 
+
+Interface authorization
+---
+There is a similar approach to allow or deny specific USB interfaces.
+That allows to block only a subset of an USB device.
+
+Authorize an interface:
+$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized
+
+Deauthorize an interface:
+$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized
+
+The default value for new interfaces
+on a particular USB bus can be changed, too.
+
+Allow interfaces per default:
+$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Deny interfaces per default:
+$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Per default the interface_authorized_default bit is 1.
+So all interfaces would authorized per default.
+
+Note:
+If a deauthorized interface will be authorized so the driver probing must
+be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe
+
+For drivers that need multiple interfaces all needed interfaces should be
+authroized first. After that the drivers should be probed.
+This avoids side effects.
-- 
2.1.4

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


[PATCH v4 3/6] usb: interface authorization: Control interface probing and claiming

2015-06-18 Thread Stefan Koch
Driver probings and interface claims get rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/driver.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 818369a..74169a5 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev)
if (udev->authorized == 0) {
dev_err(&intf->dev, "Device is not authorized for usage\n");
return error;
+   } else if (intf->authorized == 0) {
+   unsigned intf_num = intf->altsetting->desc.bInterfaceNumber;
+
+   dev_err(&intf->dev, "Interface 0x%02x is not authorized for 
usage\n",
+   intf_num);
+
+   return error;
}
 
id = usb_match_dynamic_id(intf, driver);
@@ -507,6 +514,10 @@ int usb_driver_claim_interface(struct usb_driver *driver,
if (dev->driver)
return -EBUSY;
 
+   /* reject claim if not iterface is not authorized */
+   if (!iface->authorized)
+   return -ENODEV;
+
udev = interface_to_usbdev(iface);
 
dev->driver = &driver->drvwrap.driver;
-- 
2.1.4

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


Re: [PATCH v2 5/7] samples: kdbus: disable for mn10300

2015-06-18 Thread Greg Kroah-Hartman
On Thu, Jun 18, 2015 at 05:47:51PM +0530, Sudip Mukherjee wrote:
> While building it failed with:
> In function 'prime_new':
> error: '__NR_memfd_create' undeclared (first use in this function)
> 
> memfd_create syscall has not yet been implemented for mn10300.
> so disable compilation of samples/kdbus for now with mn10300.
> 
> Signed-off-by: Sudip Mukherjee 
> ---
>  samples/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/samples/Kconfig b/samples/Kconfig
> index a4c6b2f..20c55af 100644
> --- a/samples/Kconfig
> +++ b/samples/Kconfig
> @@ -57,7 +57,7 @@ config SAMPLE_KDB
>  
>  config SAMPLE_KDBUS
>   bool "Build kdbus API example"
> - depends on KDBUS
> + depends on KDBUS && !MN10300

Why not just add the memfd syscall to this arch?  I thought someone had
already sent such a patch in a while ago.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] usb: common: add API to set usb otg capabilities by device tree

2015-06-18 Thread Li Jun
On Thu, Jun 18, 2015 at 03:18:24PM +0300, Roger Quadros wrote:
> On Thu, 18 Jun 2015 15:55:28 +0800
> Li Jun  wrote:
> 
> > On Thu, Jun 18, 2015 at 10:36:50AM +0300, Roger Quadros wrote:
> > > Lin,
> > > 
> > > You can use --in-reply-to "message id of v5 of this path" so that it 
> > > appears together
> > > with the other patches in peoples mailboxes.
> > > 
> > okay, I will try that next time, thanks.
> > 
> > Li Jun
> > > On Thu, 18 Jun 2015 09:18:22 +0800
> > > Li Jun  wrote:
> > > 
> > > 
> > Then that's not so simple, every number should be checked,
> > if ((otg_caps->otg_rev % 10) > 9) ||
> > ((otg_caps->otg_rev >> 4) % 10) > 9) ||
> > ((otg_caps->otg_rev >> 8) % 10) > 9) ||
> > ((otg_caps->otg_rev >> 12) % 10) > 9))
> > return error;
> > We really need this kind of format check? seems no this check
> > for bcdUSB.
> 
> How about checking for released spec versions instead?
> 
>   switch (otg_rev) {
>   case 0x0100:
>   case 0x0110:
>   case 0x0200:
>   case 0x0300:
>   break;
>   default:
>   dev_err(dev, "unsupported otg-rev: 0x%x\n", otg_rev);
>   return error;
>   }
> 
Currently only 1.x and 2.0 can make sense, but this could be done.

> cheers,
> -roger
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/7] fix build failure of mn10300

2015-06-18 Thread Russell King - ARM Linux
On Thu, Jun 18, 2015 at 05:47:46PM +0530, Sudip Mukherjee wrote:
> This is an attempt to fix the build failures when building mn10300 with
> allmodconfig. As I have never worked with arch files so I hope you will
> point me to right direction to correct my mistakes in this attempt.

Why has the linux-arm-kernel mailing list been copied for something
which clearly has nothing to do with ARM?  Am I missing something
in this series?

(Or is there a competition on to see who can add as many entries in
the Cc without getting caught by any filtering? :) )

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/6] usb: interface authorization

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> This patch introduces an interface authorization for USB devices.
> The kernel supports a device authorization because of wireless USB.
> 
> But the new interface authorization allows to authorize or deauthorize
> individual interfaces instead authorization or deauthorize a whole device.
> 
> Therefore the authorized attribute is introduced for each interface.
> 
> Each patch depends on all patches with a lesser number.

I like this a lot better than the earlier versions.  It's simple and 
straightforward.

I have a few minor comments on individual patches, in follow-up emails.

Alan Stern

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


Re: [PATCH v4 1/6] usb: interface authorization: Declare authorized attribute

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> The attribute authorized shows the authorization state for an interface.
> 
> Signed-off-by: Stefan Koch 
> ---
>  include/linux/usb.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 447fe29..2a991cb 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -179,6 +179,8 @@ struct usb_interface {
>   unsigned needs_binding:1;   /* needs delayed unbind/rebind */
>   unsigned resetting_device:1;/* true: bandwidth alloc after reset */
>  

Extra blank line not needed.

> + unsigned authorized:1; /* used for interface authorization */

Please align the comment with the line above.

> +
>   struct device dev;  /* interface specific device info */
>   struct device *usb_dev;
>   atomic_t pm_usage_cnt;  /* usage counter for autosuspend */

Alan Stern

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


Re: [PATCH v4 2/6] usb: interface authorization: Introduces the default interface authorization

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> Interfaces are allowed per default.
> This can disabled or enabled (again) by writing 0 or 1 to
> /sys/bus/usb/devices/usbX/interface_authorized_default
> 
> Signed-off-by: Stefan Koch 

> +/*
> + * interface_authorized_default_store - store default authorization status
> + * for USB interfaces
> + *
> + * note: interface_auhorized_default is the default value
> + *   for initializing the authorized attribute of interfaces
> + */
> +static ssize_t interface_authorized_default_store(struct device *dev,
> + struct device_attribute *attr, const char *buf, size_t count)
> +{
> + struct usb_device *usb_dev = to_usb_device(dev);
> + struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
> + int rc = count;
> + bool val;
> +
> + if (!usb_dev || !hcd)
> + return -ENODEV;

This can never happen; you should get rid of it.

> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -120,6 +120,7 @@ struct usb_hcd {
>  #define HCD_FLAG_WAKEUP_PENDING  4   /* root hub is 
> resuming? */
>  #define HCD_FLAG_RH_RUNNING  5   /* root hub is running? */
>  #define HCD_FLAG_DEAD6   /* controller has died? 
> */
> +#define HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT8
>  
>   /* The flags can be tested using these macros; they are likely to
>* be slightly faster than test_bit().
> @@ -130,6 +131,8 @@ struct usb_hcd {
>  #define HCD_WAKEUP_PENDING(hcd)  ((hcd)->flags & (1U << 
> HCD_FLAG_WAKEUP_PENDING))
>  #define HCD_RH_RUNNING(hcd)  ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
>  #define HCD_DEAD(hcd)((hcd)->flags & (1U << HCD_FLAG_DEAD))
> +#define HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd)\
> + ((hcd)->flags & (1U << HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT))
>  
>   /* Flags that get set only during HCD registration or removal. */
>   unsignedrh_registered:1;/* is root hub registered? */
> @@ -142,6 +145,7 @@ struct usb_hcd {
>   unsigneduses_new_polling:1;
>   unsignedwireless:1; /* Wireless USB HCD */
>   unsignedauthorized_default:1;
> + unsignedinterface_authorized_default:1;

What's this doing here?

Alan Stern

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


Re: [Linux-am33-list] [PATCH v2 0/7] fix build failure of mn10300

2015-06-18 Thread Russell King - ARM Linux
On Thu, Jun 18, 2015 at 10:31:07AM -0500, Jay C. Polmar wrote:
> I am on this list by mistake and 5/15/2011 we requested to be removed,
> can someone remove me from this list?

There are six mailing lists in the Cc line.  For all of the lists
present there, I can't help you, but you should be able to unsubscribe
yourself.  Look at the footer on any message you receive from the list
and it should tell you how to get more information on that subject.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 3/6] usb: interface authorization: Control interface probing and claiming

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> Driver probings and interface claims get rejected
> if an interface is not authorized.
> 
> Signed-off-by: Stefan Koch 
> ---
>  drivers/usb/core/driver.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 818369a..74169a5 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev)
>   if (udev->authorized == 0) {
>   dev_err(&intf->dev, "Device is not authorized for usage\n");
>   return error;
> + } else if (intf->authorized == 0) {
> + unsigned intf_num = intf->altsetting->desc.bInterfaceNumber;
> +
> + dev_err(&intf->dev, "Interface 0x%02x is not authorized for 
> usage\n",

Interface numbers should be decimal (%d), not hex (0x%02x).

Alan Stern

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


Re: [PATCH v4 4/6] usb: interface authorization: Introduces the USB interface authorization.

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> The kernel supports the device authorization because of wireless USB.
> These is usable for wired USB devices, too.
> These new interface authorization allows to enable or disable
> individual interfaces instead a whole device.
> 
> If a deauthorized interface will be authorized so the driver probing must
> be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe
> 
> Signed-off-by: Stefan Koch 
> ---
>  drivers/usb/core/message.c | 52 
> ++
>  drivers/usb/core/usb.h |  2 ++
>  2 files changed, 54 insertions(+)
> 
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 1e85f62..333957a 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -1555,6 +1555,58 @@ static void usb_release_interface(struct device *dev)
>   kfree(intf);
>  }
>  
> +/*
> + * usb_deauthorize_interface - deauthorize an USB interface
> + *
> + * @intf: USB interface structure
> + *
> + * Returns: 0 at success, <0 at failure
> + */
> +int usb_deauthorize_interface(struct usb_interface *intf)
> +{
> + struct device *dev = &intf->dev;
> +
> + if (!dev || !dev->parent)
> + return -ENODEV;

This can't happen; you should remove it.

> +
> + device_lock(dev->parent);
> +
> + if (intf->authorized) {
> + device_lock(dev);
> + intf->authorized = 0;
> + device_unlock(dev);
> +
> + usb_forced_unbind_intf(intf);
> + }
> +
> + device_unlock(dev->parent);
> +
> + return 0;
> +}
> +
> +/*
> + * usb_authorize_interface - authorize an USB interface
> + *
> + * @intf: USB interface structure
> + *
> + * Returns: 0 at success, <0 at failure
> + */
> +int usb_authorize_interface(struct usb_interface *intf)
> +{
> + struct device *dev = &intf->dev;
> +
> + if (!dev)
> + return -ENODEV;

This can't happen either.

Alan Stern

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


Re: [PATCH v2 0/7] fix build failure of mn10300

2015-06-18 Thread Sudip Mukherjee
On Thu, Jun 18, 2015 at 03:51:38PM +0100, Russell King - ARM Linux wrote:
> On Thu, Jun 18, 2015 at 05:47:46PM +0530, Sudip Mukherjee wrote:
> > This is an attempt to fix the build failures when building mn10300 with
> > allmodconfig. As I have never worked with arch files so I hope you will
> > point me to right direction to correct my mistakes in this attempt.
> 
> Why has the linux-arm-kernel mailing list been copied for something
> which clearly has nothing to do with ARM?  Am I missing something
> in this series?
get_maintainer.pl is giving linux-arm-kernel mailing list for
patch 3/7 ("mmc: mediatek: build as module").

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 5/7] samples: kdbus: disable for mn10300

2015-06-18 Thread Sudip Mukherjee
On Thu, Jun 18, 2015 at 07:39:58AM -0700, Greg Kroah-Hartman wrote:
> On Thu, Jun 18, 2015 at 05:47:51PM +0530, Sudip Mukherjee wrote:
> > While building it failed with:
> > In function 'prime_new':
> > error: '__NR_memfd_create' undeclared (first use in this function)
> > 
> > memfd_create syscall has not yet been implemented for mn10300.
> > so disable compilation of samples/kdbus for now with mn10300.
> > 
> > Signed-off-by: Sudip Mukherjee 
> > ---
> >  samples/Kconfig | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/samples/Kconfig b/samples/Kconfig
> > index a4c6b2f..20c55af 100644
> > --- a/samples/Kconfig
> > +++ b/samples/Kconfig
> > @@ -57,7 +57,7 @@ config SAMPLE_KDB
> >  
> >  config SAMPLE_KDBUS
> > bool "Build kdbus API example"
> > -   depends on KDBUS
> > +   depends on KDBUS && !MN10300
> 
> Why not just add the memfd syscall to this arch?
Yes, I intend to. But for now this will fix allmodconfig.
>I thought someone had already sent such a patch in a while ago.
Then it is still not merged. :(
I will try to find that patch adding memfd syscall. And if i find it whom
shall I forward it to?

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 5/7] samples: kdbus: disable for mn10300

2015-06-18 Thread Greg Kroah-Hartman
On Thu, Jun 18, 2015 at 09:49:05PM +0530, Sudip Mukherjee wrote:
> On Thu, Jun 18, 2015 at 07:39:58AM -0700, Greg Kroah-Hartman wrote:
> > On Thu, Jun 18, 2015 at 05:47:51PM +0530, Sudip Mukherjee wrote:
> > > While building it failed with:
> > > In function 'prime_new':
> > > error: '__NR_memfd_create' undeclared (first use in this function)
> > > 
> > > memfd_create syscall has not yet been implemented for mn10300.
> > > so disable compilation of samples/kdbus for now with mn10300.
> > > 
> > > Signed-off-by: Sudip Mukherjee 
> > > ---
> > >  samples/Kconfig | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/samples/Kconfig b/samples/Kconfig
> > > index a4c6b2f..20c55af 100644
> > > --- a/samples/Kconfig
> > > +++ b/samples/Kconfig
> > > @@ -57,7 +57,7 @@ config SAMPLE_KDB
> > >  
> > >  config SAMPLE_KDBUS
> > >   bool "Build kdbus API example"
> > > - depends on KDBUS
> > > + depends on KDBUS && !MN10300
> > 
> > Why not just add the memfd syscall to this arch?
> Yes, I intend to. But for now this will fix allmodconfig.
> >I thought someone had already sent such a patch in a while ago.
> Then it is still not merged. :(
> I will try to find that patch adding memfd syscall. And if i find it whom
> shall I forward it to?

The maintainers of this arch.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb:gadget:Simplify the error checking of the function,at91sam9261_udc_init

2015-06-18 Thread Alexandre Belloni
On 03/05/2015 at 23:25:02 -0400, Nicholas Krause wrote :
> This simplifies the error checking of the function,at91sam9261_udc_init
> by using PTR_ERR_OR_ZERO in the return statement rather then a unnessary
> if statement to check the return value of a call to the function,
> syscon_regmap_lookup_by_phandle by checking with a call to the function,
> IS_ERR and returning a error pointer if there is one for the function,
> at91sam9261_udc_init. Furthermore this was found by running coccinelle
> against the lastest kernel tree.
> 
> Signed-off-by: Nicholas Krause 
Acked-by: Alexandre Belloni 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: ulpi: call put_device if device_register fails

2015-06-18 Thread ChengYi He
put_device is required to release the last reference to the device.

Signed-off-by: ChengYi He 
---
 drivers/usb/common/ulpi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 0e6f968..bd25bdb 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -184,8 +184,10 @@ static int ulpi_register(struct device *dev, struct ulpi 
*ulpi)
request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product);
 
ret = device_register(&ulpi->dev);
-   if (ret)
+   if (ret) {
+   put_device(&ulpi->dev);
return ret;
+   }
 
dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",
ulpi->id.vendor, ulpi->id.product);
-- 
1.9.1

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


Re: [PATCH v4 0/6] usb: interface authorization

2015-06-18 Thread Stefan Koch
Am Donnerstag, den 18.06.2015, 11:41 -0400 schrieb Alan Stern:
> On Thu, 18 Jun 2015, Stefan Koch wrote:
> 
> > This patch introduces an interface authorization for USB devices.
> > The kernel supports a device authorization because of wireless USB.
> > 
> > But the new interface authorization allows to authorize or deauthorize
> > individual interfaces instead authorization or deauthorize a whole device.
> > 
> > Therefore the authorized attribute is introduced for each interface.
> > 
> > Each patch depends on all patches with a lesser number.
> 
> I like this a lot better than the earlier versions.  It's simple and 
> straightforward.
> 
> I have a few minor comments on individual patches, in follow-up emails.
> 
> Alan Stern
> 
The next patch series contains your suggestions.
Thanks for commenting the patches.


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


[PATCH v5 0/6] usb: interface authorization

2015-06-18 Thread Stefan Koch
This patch introduces an interface authorization for USB devices.
The kernel supports a device authorization because of wireless USB.

But the new interface authorization allows to authorize or deauthorize
individual interfaces instead authorization or deauthorize a whole device.

Therefore the authorized attribute is introduced for each interface.

Each patch depends on all patches with a lesser number.

Stefan Koch (6):
  usb: interface authorization: Declare authorized attribute
  usb: interface authorization: Introduces the default interface
authorization
  usb: interface authorization: Control interface probing and claiming
  usb: interface authorization: Introduces the USB interface
authorization.
  usb: interface authorization: SysFS part of USB interface
authorization.
  usb: interface authorization: Documentation part

 Documentation/ABI/testing/sysfs-bus-usb | 22 ++
 Documentation/usb/authorization.txt | 34 +
 drivers/usb/core/driver.c   | 11 +++
 drivers/usb/core/hcd.c  | 52 +
 drivers/usb/core/message.c  | 48 ++
 drivers/usb/core/sysfs.c| 41 ++
 drivers/usb/core/usb.h  |  2 ++
 include/linux/usb.h |  1 +
 include/linux/usb/hcd.h |  3 ++
 9 files changed, 214 insertions(+)

-- 
2.1.4

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


[PATCH v5 5/6] usb: interface authorization: SysFS part of USB interface authorization.

2015-06-18 Thread Stefan Koch
This introduces an attribute for each interface to
authorize (1) or deauthorize (0) it:
/sys/bus/usb/devices/INTERFACE/authorized

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/sysfs.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index d269738..457bff5 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -926,6 +926,46 @@ static ssize_t supports_autosuspend_show(struct device 
*dev,
 }
 static DEVICE_ATTR_RO(supports_autosuspend);
 
+/*
+ * interface_authorized_show - show authorization status of an USB interface
+ * 1 is authorized, 0 is deauthorized
+ */
+static ssize_t interface_authorized_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+
+   return sprintf(buf, "%u\n", intf->authorized);
+}
+
+/*
+ * interface_authorized_store - authorize or deauthorize an USB interface
+ * 1 is to authorize, 0 is to deauthorize
+ */
+static ssize_t interface_authorized_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_interface *intf = to_usb_interface(dev);
+   bool val;
+
+   if (strtobool(buf, &val) != 0)
+   return -EINVAL;
+
+   switch (val) {
+   case 0:
+   usb_deauthorize_interface(intf);
+   break;
+   case 1:
+   usb_authorize_interface(intf);
+   break;
+   }
+
+   return count;
+}
+static struct device_attribute dev_attr_interface_authorized =
+   __ATTR(authorized, S_IRUGO | S_IWUSR,
+   interface_authorized_show, interface_authorized_store);
+
 static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceNumber.attr,
&dev_attr_bAlternateSetting.attr,
@@ -935,6 +975,7 @@ static struct attribute *intf_attrs[] = {
&dev_attr_bInterfaceProtocol.attr,
&dev_attr_modalias.attr,
&dev_attr_supports_autosuspend.attr,
+   &dev_attr_interface_authorized.attr,
NULL,
 };
 static struct attribute_group intf_attr_grp = {
-- 
2.1.4

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


[PATCH v5 6/6] usb: interface authorization: Documentation part

2015-06-18 Thread Stefan Koch
This part adds the documentation for the interface authorization.

Signed-off-by: Stefan Koch 
---
 Documentation/ABI/testing/sysfs-bus-usb | 22 +
 Documentation/usb/authorization.txt | 34 +
 2 files changed, 56 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index e5cc763..ca8c8d3 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -1,3 +1,25 @@
+What:  /sys/bus/usb/devices/INTERFACE/authorized
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This allows to authorize (1) or deauthorize (0)
+   individual interfaces instead a whole device
+   in contrast to the device authorization.
+   If a deauthorized interface will be authorized
+   so the driver probing must be triggered manually
+   by writing INTERFACE to /sys/bus/usb/drivers_probe
+   This allows to avoid side-effects with drivers
+   that need multiple interfaces.
+   A deauthorized interface cannot be probed or claimed.
+
+What:  /sys/bus/usb/devices/usbX/interface_authorized_default
+Date:  June 2015
+KernelVersion: 4.2
+Description:
+   This is used as default value that determines
+   if interfaces would authorized per default.
+   The value can be 1 or 0. It is per default 1.
+
 What:  /sys/bus/usb/device/.../authorized
 Date:  July 2008
 KernelVersion: 2.6.26
diff --git a/Documentation/usb/authorization.txt 
b/Documentation/usb/authorization.txt
index c069b68..020cec5 100644
--- a/Documentation/usb/authorization.txt
+++ b/Documentation/usb/authorization.txt
@@ -3,6 +3,9 @@ Authorizing (or not) your USB devices to connect to the system
 
 (C) 2007 Inaky Perez-Gonzalez  Intel Corporation
 
+Interface authorization part:
+   (C) 2015 Stefan Koch  SUSE LLC
+
 This feature allows you to control if a USB device can be used (or
 not) in a system. This feature will allow you to implement a lock-down
 of USB devices, fully controlled by user space.
@@ -90,3 +93,34 @@ etc, but you get the idea. Anybody with access to a device 
gadget kit
 can fake descriptors and device info. Don't trust that. You are
 welcome.
 
+
+Interface authorization
+---
+There is a similar approach to allow or deny specific USB interfaces.
+That allows to block only a subset of an USB device.
+
+Authorize an interface:
+$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized
+
+Deauthorize an interface:
+$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized
+
+The default value for new interfaces
+on a particular USB bus can be changed, too.
+
+Allow interfaces per default:
+$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Deny interfaces per default:
+$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default
+
+Per default the interface_authorized_default bit is 1.
+So all interfaces would authorized per default.
+
+Note:
+If a deauthorized interface will be authorized so the driver probing must
+be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe
+
+For drivers that need multiple interfaces all needed interfaces should be
+authroized first. After that the drivers should be probed.
+This avoids side effects.
-- 
2.1.4

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


[PATCH v5 2/6] usb: interface authorization: Introduces the default interface authorization

2015-06-18 Thread Stefan Koch
Interfaces are allowed per default.
This can disabled or enabled (again) by writing 0 or 1 to
/sys/bus/usb/devices/usbX/interface_authorized_default

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/hcd.c | 52 ++
 drivers/usb/core/message.c |  2 ++
 include/linux/usb/hcd.h|  3 +++
 3 files changed, 57 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 45a915c..4ceb753 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -882,9 +882,58 @@ static ssize_t authorized_default_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(authorized_default);
 
+/*
+ * interface_authorized_default_show - show default authorization status
+ * for USB interfaces
+ *
+ * note: interface_auhorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
+   unsigned def = HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd) ? 1 : 0;
+
+   return sprintf(buf, "%u\n", def);
+}
+
+/*
+ * interface_authorized_default_store - store default authorization status
+ * for USB interfaces
+ *
+ * note: interface_auhorized_default is the default value
+ *   for initializing the authorized attribute of interfaces
+ */
+static ssize_t interface_authorized_default_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct usb_device *usb_dev = to_usb_device(dev);
+   struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus);
+   int rc = count;
+   bool val;
+
+   if (strtobool(buf, &val) != 0)
+   return -EINVAL;
+
+   switch (val) {
+   case 0:
+   clear_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+   break;
+   case 1:
+   set_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+   break;
+   }
+
+   return rc;
+}
+static DEVICE_ATTR_RW(interface_authorized_default);
+
 /* Group all the USB bus attributes */
 static struct attribute *usb_bus_attrs[] = {
&dev_attr_authorized_default.attr,
+   &dev_attr_interface_authorized_default.attr,
NULL,
 };
 
@@ -2679,6 +2728,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
hcd->authorized_default = authorized_default;
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
 
+   /* per default all interfaces are authorized */
+   set_bit(HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT, &hcd->flags);
+
/* HC is in reset state, but accessible.  Now do the one-time init,
 * bottom up so that hcds can customize the root hubs before hub_wq
 * starts talking to them.  (Note, bus id is assigned early too.)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f368d20..1e85f62 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1807,6 +1807,8 @@ free_interfaces:
intfc = cp->intf_cache[i];
intf->altsetting = intfc->altsetting;
intf->num_altsetting = intfc->num_altsetting;
+   intf->authorized =
+   HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd) ? 1 : 0;
kref_get(&intfc->ref);
 
alt = usb_altnum_to_altsetting(intf, 0);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 68b1e83..93c19b2 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -120,6 +120,7 @@ struct usb_hcd {
 #define HCD_FLAG_WAKEUP_PENDING4   /* root hub is 
resuming? */
 #define HCD_FLAG_RH_RUNNING5   /* root hub is running? */
 #define HCD_FLAG_DEAD  6   /* controller has died? */
+#define HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT  8
 
/* The flags can be tested using these macros; they are likely to
 * be slightly faster than test_bit().
@@ -130,6 +131,8 @@ struct usb_hcd {
 #define HCD_WAKEUP_PENDING(hcd)((hcd)->flags & (1U << 
HCD_FLAG_WAKEUP_PENDING))
 #define HCD_RH_RUNNING(hcd)((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
 #define HCD_DEAD(hcd)  ((hcd)->flags & (1U << HCD_FLAG_DEAD))
+#define HCD_INTERFACE_AUTHORIZED_DEFAULT(hcd)  \
+   ((hcd)->flags & (1U << HCD_FLAG_INTERFACE_AUTHORIZED_DEFAULT))
 
/* Flags that get set only during HCD registration or removal. */
unsignedrh_registered:1;/* is root hub registered? */
-- 
2.1.4

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


[PATCH v5 1/6] usb: interface authorization: Declare authorized attribute

2015-06-18 Thread Stefan Koch
The attribute authorized shows the authorization state for an interface.

Signed-off-by: Stefan Koch 
---
 include/linux/usb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447fe29..135c50c 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -178,6 +178,7 @@ struct usb_interface {
unsigned needs_altsetting0:1;   /* switch to altsetting 0 is pending */
unsigned needs_binding:1;   /* needs delayed unbind/rebind */
unsigned resetting_device:1;/* true: bandwidth alloc after reset */
+   unsigned authorized:1;  /* used for interface authorization */
 
struct device dev;  /* interface specific device info */
struct device *usb_dev;
-- 
2.1.4

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


[PATCH v5 3/6] usb: interface authorization: Control interface probing and claiming

2015-06-18 Thread Stefan Koch
Driver probings and interface claims get rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/driver.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 818369a..3344daf 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev)
if (udev->authorized == 0) {
dev_err(&intf->dev, "Device is not authorized for usage\n");
return error;
+   } else if (intf->authorized == 0) {
+   unsigned intf_num = intf->altsetting->desc.bInterfaceNumber;
+
+   dev_err(&intf->dev, "Interface %d is not authorized for 
usage\n",
+   intf_num);
+
+   return error;
}
 
id = usb_match_dynamic_id(intf, driver);
@@ -507,6 +514,10 @@ int usb_driver_claim_interface(struct usb_driver *driver,
if (dev->driver)
return -EBUSY;
 
+   /* reject claim if not iterface is not authorized */
+   if (!iface->authorized)
+   return -ENODEV;
+
udev = interface_to_usbdev(iface);
 
dev->driver = &driver->drvwrap.driver;
-- 
2.1.4

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


[PATCH v5 4/6] usb: interface authorization: Introduces the USB interface authorization.

2015-06-18 Thread Stefan Koch
The kernel supports the device authorization because of wireless USB.
These is usable for wired USB devices, too.
These new interface authorization allows to enable or disable
individual interfaces instead a whole device.

If a deauthorized interface will be authorized so the driver probing must
be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe

Signed-off-by: Stefan Koch 
---
 drivers/usb/core/message.c | 46 ++
 drivers/usb/core/usb.h |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 1e85f62..b1b2772 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1555,6 +1555,52 @@ static void usb_release_interface(struct device *dev)
kfree(intf);
 }
 
+/*
+ * usb_deauthorize_interface - deauthorize an USB interface
+ *
+ * @intf: USB interface structure
+ *
+ * Returns: 0 at success, <0 at failure
+ */
+int usb_deauthorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = &intf->dev;
+
+   device_lock(dev->parent);
+
+   if (intf->authorized) {
+   device_lock(dev);
+   intf->authorized = 0;
+   device_unlock(dev);
+
+   usb_forced_unbind_intf(intf);
+   }
+
+   device_unlock(dev->parent);
+
+   return 0;
+}
+
+/*
+ * usb_authorize_interface - authorize an USB interface
+ *
+ * @intf: USB interface structure
+ *
+ * Returns: 0 at success, <0 at failure
+ */
+int usb_authorize_interface(struct usb_interface *intf)
+{
+   struct device *dev = &intf->dev;
+
+   if (!intf->authorized) {
+   device_lock(dev);
+   intf->authorized = 1; /* authorize interface */
+   device_unlock(dev);
+   }
+
+   return 0;
+}
+
 static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
struct usb_device *usb_dev;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 7eb1e26..37b0055 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -27,6 +27,8 @@ extern void usb_release_interface_cache(struct kref *ref);
 extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
 extern int usb_deauthorize_device(struct usb_device *);
 extern int usb_authorize_device(struct usb_device *);
+extern int usb_deauthorize_interface(struct usb_interface *);
+extern int usb_authorize_interface(struct usb_interface *);
 extern void usb_detect_quirks(struct usb_device *udev);
 extern void usb_detect_interface_quirks(struct usb_device *udev);
 extern int usb_remove_device(struct usb_device *udev);
-- 
2.1.4

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


Re: [PATCH v5 0/6] usb: interface authorization

2015-06-18 Thread Alan Stern
On Thu, 18 Jun 2015, Stefan Koch wrote:

> This patch introduces an interface authorization for USB devices.
> The kernel supports a device authorization because of wireless USB.
> 
> But the new interface authorization allows to authorize or deauthorize
> individual interfaces instead authorization or deauthorize a whole device.
> 
> Therefore the authorized attribute is introduced for each interface.
> 
> Each patch depends on all patches with a lesser number.
> 
> Stefan Koch (6):
>   usb: interface authorization: Declare authorized attribute
>   usb: interface authorization: Introduces the default interface
> authorization
>   usb: interface authorization: Control interface probing and claiming
>   usb: interface authorization: Introduces the USB interface
> authorization.
>   usb: interface authorization: SysFS part of USB interface
> authorization.
>   usb: interface authorization: Documentation part
> 
>  Documentation/ABI/testing/sysfs-bus-usb | 22 ++
>  Documentation/usb/authorization.txt | 34 +
>  drivers/usb/core/driver.c   | 11 +++
>  drivers/usb/core/hcd.c  | 52 
> +
>  drivers/usb/core/message.c  | 48 ++
>  drivers/usb/core/sysfs.c| 41 ++
>  drivers/usb/core/usb.h  |  2 ++
>  include/linux/usb.h |  1 +
>  include/linux/usb/hcd.h |  3 ++
>  9 files changed, 214 insertions(+)

Acked-by: Alan Stern 

Other people may still have some comments.

Alan Stern

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


Re: [PATCH] usb:gadget:Simplify the error checking of the function,at91sam9261_udc_init

2015-06-18 Thread Alexandre Belloni
On 18/06/2015 at 18:41:14 +0200, Alexandre Belloni wrote :
> On 03/05/2015 at 23:25:02 -0400, Nicholas Krause wrote :
> > This simplifies the error checking of the function,at91sam9261_udc_init
> > by using PTR_ERR_OR_ZERO in the return statement rather then a unnessary
> > if statement to check the return value of a call to the function,
> > syscon_regmap_lookup_by_phandle by checking with a call to the function,
> > IS_ERR and returning a error pointer if there is one for the function,
> > at91sam9261_udc_init. Furthermore this was found by running coccinelle
> > against the lastest kernel tree.
> > 
> > Signed-off-by: Nicholas Krause 
> Acked-by: Alexandre Belloni 
> 

OK, it seems the original patch got ignored by all the mailing lists. To
bad, that one was actually applicable :)

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cdc_acm / cdc_wdm issue. Connection to device lost (Sony Ericsson w660)

2015-06-18 Thread Fab Stz
Hello,

I'm facing some issues to connect to my mobile phone (Sony Ericsson W660i)

I use Gammu/Wammu to connect to my mobile phone
With kernel 3.2 (debian wheezy) it works fine. But with kernel 3.16 (debian 
jessie) or even 4.0.2 it doesn't work.

Moreover, the connection of the phone to the PC makes some configuration 
changes on my phone. It changes my netwok connection type from "2G only" to 
"2G/3G" for obscure reasons

BTW, it seems the connection gets lost when the phone backlight turns off

Here is the dmesg when I connect the phone
[ 1536.912061] usb 3-2: new full-speed USB device number 2 using uhci_hcd
[ 1537.168027] usb 3-2: New USB device found, idVendor=0fce, idProduct=d0a3
[ 1537.168035] usb 3-2: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
[ 1537.168040] usb 3-2: Product: Sony Ericsson W660
[ 1537.168044] usb 3-2: Manufacturer: Sony Ericsson
[ 1537.168048] usb 3-2: SerialNumber: 3571550133112050
[ 1537.371402] cdc_ether 3-2:3.8 usb0: register 'cdc_ether' at 
usb-:00:1d.1-2, CDC Ethernet Device, 02:80:37:fa:02:00
[ 1537.371459] usbcore: registered new interface driver cdc_ether
[ 1537.380242] cdc_wdm 3-2:3.7: cdc-wdm0: USB WDM device
[ 1537.380282] usbcore: registered new interface driver cdc_wdm
[ 1537.382752] cdc_acm 3-2:3.1: ttyACM0: USB ACM device
[ 1537.387047] cdc_acm 3-2:3.3: ttyACM1: USB ACM device
[ 1537.389890] usbcore: registered new interface driver cdc_acm
[ 1537.389894] cdc_acm: USB Abstract Control Model driver for USB modems and 
ISDN adapters
[ 1537.424010] cdc_wdm 3-2:3.7: wdm_int_callback - 0 bytes
[ 1537.446697] cdc_ether 3-2:3.8 usb0: kevent 12 may have been dropped

I already reported the following bug
https://bugzilla.kernel.org/show_bug.cgi?id=100091

Is there anything to do ? Fix ?

Kind regards

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


Re: [PATCH] usb:gadget:Simplify the error checking of the function,at91sam9261_udc_init

2015-06-18 Thread Greg KH
On Thu, Jun 18, 2015 at 09:04:52PM +0200, Alexandre Belloni wrote:
> On 18/06/2015 at 18:41:14 +0200, Alexandre Belloni wrote :
> > On 03/05/2015 at 23:25:02 -0400, Nicholas Krause wrote :
> > > This simplifies the error checking of the function,at91sam9261_udc_init
> > > by using PTR_ERR_OR_ZERO in the return statement rather then a unnessary
> > > if statement to check the return value of a call to the function,
> > > syscon_regmap_lookup_by_phandle by checking with a call to the function,
> > > IS_ERR and returning a error pointer if there is one for the function,
> > > at91sam9261_udc_init. Furthermore this was found by running coccinelle
> > > against the lastest kernel tree.
> > > 
> > > Signed-off-by: Nicholas Krause 
> > Acked-by: Alexandre Belloni 
> > 
> 
> OK, it seems the original patch got ignored by all the mailing lists. To
> bad, that one was actually applicable :)

Nick is banned from vger.kernel.org, so that is why his patches will not
ever show up.  I recommend that you do the same if possible.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: optimal io size / custom alignment

2015-06-18 Thread Martin K. Petersen
> "Tom" == Tom Yan  writes:

Tom> No I put it in the wrong way. What I meant was "sd vs md". For
Tom> example, couldn't the scsi disk driver bind the value it reads from
Tom> the VPD to another variable instead of "optimal i/o size", so that
Tom> this value would be exclusively for RAID (and other virtual
Tom> devices)?

Who says that RAID is a virtual device? Hardware RAID controllers as
well as SAS, iSCSI and Fibre Channel disk arrays all use the Block
Limits VPD to communicate their preferred I/O size and alignment to
us. As do enterprise disk drives.

We deal with broken devices by blacklisting them. I suggest you try to
find a way we can reliably identify your UAS devices. If there is a
common pattern, we can entertain adding a workaround.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


usbip: usb3 support?

2015-06-18 Thread Florian Klink
Hey,

I tried to use usbip to access a USB3 device over the network.

However, `usbip attach -r $HOST -b $BUS` on the client failed with

> Failed attach request for unsupported USB speed: super-speed"

I looked at drivers/usb/usbip/vhci_sysfs.c:150 and discovered
USB_SPEED_SUPER wasn't in the list of supported USB speeds.

I quickly tried to make it working by adding USB_SPEED_SUPER to the
switch case.
I was now able to attach the device, however the client complained about
a bad usb cable and the hosts dmesg got filled with

> [332349.125642] usbip-host 3-2: stub up
> [332464.550074] usbip-host 3-2: recv a header, 0
> [332464.658740] usbip-host 3-2: reset SuperSpeed USB device number 2 using 
> xhci_hcd
> [332464.672536] usbip-host 3-2: device reset

which comes from drivers/usb/usbip/stub_rx.c:549.

It seems like usbip_recv gets packages that don't have the size of
usbip_header.

Is usbip specified for usb3? Is it possible to add support for it?

Thanks in advance,
--
Florian
>From 2b3aee13d093b73aaf42f88ccbf46db35250fc05 Mon Sep 17 00:00:00 2001
From: Florian Klink 
Date: Thu, 18 Jun 2015 22:46:15 +0200
Subject: [PATCH] usbip: add support for USB_SPEED_SUPER

---
 drivers/usb/usbip/vhci_sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 211f43f..95339b7 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -148,6 +148,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
 	case USB_SPEED_FULL:
 	case USB_SPEED_HIGH:
 	case USB_SPEED_WIRELESS:
+	case USB_SPEED_SUPER:
 		break;
 	default:
 		pr_err("Failed attach request for unsupported USB speed: %s\n",
-- 
2.4.2



Re: usbip: usb3 support?

2015-06-18 Thread Greg KH
On Fri, Jun 19, 2015 at 12:36:05AM +0200, Florian Klink wrote:
> Hey,
> 
> I tried to use usbip to access a USB3 device over the network.
> 
> However, `usbip attach -r $HOST -b $BUS` on the client failed with
> 
> > Failed attach request for unsupported USB speed: super-speed"
> 
> I looked at drivers/usb/usbip/vhci_sysfs.c:150 and discovered
> USB_SPEED_SUPER wasn't in the list of supported USB speeds.
> 
> I quickly tried to make it working by adding USB_SPEED_SUPER to the
> switch case.
> I was now able to attach the device, however the client complained about
> a bad usb cable and the hosts dmesg got filled with
> 
> > [332349.125642] usbip-host 3-2: stub up
> > [332464.550074] usbip-host 3-2: recv a header, 0
> > [332464.658740] usbip-host 3-2: reset SuperSpeed USB device number 2 using 
> > xhci_hcd
> > [332464.672536] usbip-host 3-2: device reset
> 
> which comes from drivers/usb/usbip/stub_rx.c:549.
> 
> It seems like usbip_recv gets packages that don't have the size of
> usbip_header.
> 
> Is usbip specified for usb3?

As you have found out, no, sorry.

> Is it possible to add support for it?

Sure, patches are greatly encouraged to fix it properly :)

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usbip: usb3 support?

2015-06-18 Thread Florian Klink
>> I tried to use usbip to access a USB3 device over the network.
>>
>> However, `usbip attach -r $HOST -b $BUS` on the client failed with
>>
>>> Failed attach request for unsupported USB speed: super-speed"
>>
>> I looked at drivers/usb/usbip/vhci_sysfs.c:150 and discovered
>> USB_SPEED_SUPER wasn't in the list of supported USB speeds.
>>
>> I quickly tried to make it working by adding USB_SPEED_SUPER to the
>> switch case.
>> I was now able to attach the device, however the client complained about
>> a bad usb cable and the hosts dmesg got filled with
>>
>>> [332349.125642] usbip-host 3-2: stub up
>>> [332464.550074] usbip-host 3-2: recv a header, 0
>>> [332464.658740] usbip-host 3-2: reset SuperSpeed USB device number 2 using 
>>> xhci_hcd
>>> [332464.672536] usbip-host 3-2: device reset
>>
>> which comes from drivers/usb/usbip/stub_rx.c:549.
>>
>> It seems like usbip_recv gets packages that don't have the size of
>> usbip_header.
>>
>> Is usbip specified for usb3?
> 
> As you have found out, no, sorry.
> 
>> Is it possible to add support for it?
> 
> Sure, patches are greatly encouraged to fix it properly :)

I don't know yet what exactly is broken, neither how USB3 differs from
USB2 on this level.

But I'll try to dig deeper into how the usbip protocol and linux urb
handling in general works :-)

--
Florian

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


[PATCH 2/2] usb: chipidea: imx: enable CI_HDRC_SET_NON_ZERO_TTHA

2015-06-18 Thread Peter Chen
For i.mx platform, set ttctrl.ttha with non-zero value only affects
sitd, and ehci core makes sure the schedule is not full when accepts
new request, so it will not occur the transaction which will acorss
the SoF.

Signed-off-by: Peter Chen 
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 389f0e0..6d2a85a 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -126,7 +126,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
struct ci_hdrc_platform_data pdata = {
.name   = dev_name(&pdev->dev),
.capoffset  = DEF_CAPOFFSET,
-   .flags  = CI_HDRC_DISABLE_STREAMING,
+   .flags  = CI_HDRC_DISABLE_STREAMING |
+   CI_HDRC_SET_NON_ZERO_TTHA,
};
int ret;
const struct of_device_id *of_id =
-- 
1.9.1

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


[PATCH 1/2] usb: chipidea: add ttctrl.ttha control interface

2015-06-18 Thread Peter Chen
The register of ttctrl.ttha describes like below:
- Internal TT Hub Address Representation
- RW
- Default = 000b
This field is used to match against the Hub Address field in QH & siTD
to determine if the packet is routed to the internal TT for directly
attached FS/LS devices. If the Hub Address in the QH or siTD does not
match this address then the packet will be broadcast on the High Speed
ports destined for a downstream High Speed hub with the address in the QH/siTD.

In silicon RTL, this entry only affects QH and siTD, and the hub.addr at
both QH and siTD are 0 in ehci core for chipidea (with hcd->has_tt = 1).

So, for QH, if the "usage_tt" flag at RTL is 0, set CI_HDRC_SET_NON_ZERO_TTHA
will not affect QH (with non-hs device); for siTD, set this flag
will change remaining space requirement for the last transaction from 1023
bytes to 188 bytes, it can increase the number of transactions within one
frame, ehci periodic schedule code will not queue the packet if the frame space
is full, so it is safe to set this flag for siTD.

With this flag, it can fix the problem Alan Stern reported below:
http://www.spinics.net/lists/linux-usb/msg123125.html
And may fix Michael Tessier's problem too.
http://www.spinics.net/lists/linux-usb/msg118679.html

CC: st...@rowland.harvard.edu
CC: michael.tess...@axiontech.ca
Signed-off-by: Peter Chen 
---
 drivers/usb/chipidea/bits.h  | 5 +
 drivers/usb/chipidea/ci.h| 1 +
 drivers/usb/chipidea/core.c  | 2 ++
 drivers/usb/chipidea/host.c  | 3 +++
 include/linux/usb/chipidea.h | 1 +
 5 files changed, 12 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 3cb9bda..831a8f6 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -53,6 +53,11 @@
 #define DEVICEADDR_USBADRABIT(24)
 #define DEVICEADDR_USBADR (0x7FUL << 25)
 
+/* TTCTRL */
+#define TTCTRL_TTHA_MASK   (0x7fUL << 24)
+/* Set non-zero value for internal TT Hub address representation */
+#define TTCTRL_TTHA(0x7fUL << 24)
+
 /* PORTSC */
 #define PORTSC_CCSBIT(0)
 #define PORTSC_CSCBIT(1)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 6d6200e..df57e49 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -50,6 +50,7 @@ enum ci_hw_regs {
OP_USBINTR,
OP_DEVICEADDR,
OP_ENDPTLISTADDR,
+   OP_TTCTRL,
OP_PORTSC,
OP_DEVLC,
OP_OTGSC,
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 74fea4f..40cdd5e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -84,6 +84,7 @@ static const u8 ci_regs_nolpm[] = {
[OP_USBINTR]= 0x08U,
[OP_DEVICEADDR] = 0x14U,
[OP_ENDPTLISTADDR]  = 0x18U,
+   [OP_TTCTRL] = 0x1CU,
[OP_PORTSC] = 0x44U,
[OP_DEVLC]  = 0x84U,
[OP_OTGSC]  = 0x64U,
@@ -105,6 +106,7 @@ static const u8 ci_regs_lpm[] = {
[OP_USBSTS] = 0x04U,
[OP_USBINTR]= 0x08U,
[OP_DEVICEADDR] = 0x14U,
+   [OP_TTCTRL] = 0x1CU,
[OP_ENDPTLISTADDR]  = 0x18U,
[OP_PORTSC] = 0x44U,
[OP_DEVLC]  = 0x84U,
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 21fe1a3..f5eaab1 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -147,6 +147,9 @@ static int host_start(struct ci_hdrc *ci)
if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED)
hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
 
+   if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
+   hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
+
return ret;
 
 disable_reg:
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ab94f78..d1e1285 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -29,6 +29,7 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_IMX28_WRITE_FIXBIT(5)
 #define CI_HDRC_FORCE_FULLSPEEDBIT(6)
 #define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7)
+#define CI_HDRC_SET_NON_ZERO_TTHA  BIT(8)
enum usb_dr_modedr_mode;
 #define CI_HDRC_CONTROLLER_RESET_EVENT 0
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT   1
-- 
1.9.1

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