Re: [PATCH 11/11] usb: core: fix a race with usb_queue_reset_device()

2015-01-21 Thread Alan Stern
On Wed, 21 Jan 2015, Olivier Sobrie wrote:

 I tested your patch. It also fixes the problem I observed.
 You can drop mine.
 
 For your info:
 
 My test consists in powering down a usb hso modem while one of its
 serial port is opened. It leads to two URB failures, each urb callback
 queues a reset.
 Without your fix (or without the one I sent), a crash happens after
 less than ~20 power up/down sequences. With your fix, after more than
 1000 power up/down I don't see any crash.

Okay, I'll submit the patch.  Thanks for testing it.

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


hid: Adding rdesc quirks

2015-01-21 Thread Simon Wörner

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hi,

I'm working on a fix for my synaptics keyboard and got some questions.

The keyboard is reporting a wrong Logical / Usage Maximum (0xFF, 0xFF)
and i patched the rdesc as seen in other quirks.
But I don't know what would be a correct (or optimal) Maximum, I changed
it to (0xFF, 0x2F) which works without issues.

For testing purposes I created a simple kernel module, but it gets
loaded after the hid module and therefor I still get usage index
exceeded errors in the kernel log.
Where do I need to define the module run/load order?

Current source can be found at:
https://github.com/SWW13/hid-synaptics/blob/master/hid-synaptics.c
I will add it to drivers/hid like other quirks and create a patch file
after everything is cleaned up and ready for upstream.

Regards,
Simon
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)

iQIcBAEBCgAGBQJUv/hAAAoJEHCWT5O8pCFZ9FoP/1QNKrFlt8oxguFOpsSKBuG2
yx2y57Cfbr2yKQnadRW/9XWewgfmi3ejHVFsf7Wludzr5FjbQQSyMdqdZdbeMle6
UmIf8mFNAU9HpQDAjo3b0SX6OAg36wx3ex/o5EjP6UqKd6hu+2MPJIdAjCsSzC40
CEFlJ1RCzDuPNKCmm7YsxiXwfi7Ta6xu9ESizVeypaxmWrzwuBdXHE4K3CMPPnmt
9KgUO+1XkRAX31OibLir4lmJbUp7pJICnAWo/7BUMUdtIaayiS8qV1MBq7kQmg5C
Z2+CaPT1LGCpi+83jYzKhJ2+fQ8B1EAYsxsjZAPApp2xKyEz9NeKLdqS2h3ZaB6C
DmAumLqkoJbzYf2APVPPqvDb47MwX9+vbEoeDwpNqjNF80hlN70lpUiykcvCHGjy
txe0x/gF/tloch1IOg89Ns92W8qyrIvHZTnt23beQa2g/Djp65KaosFuqo8l2MJQ
POkm16j2LJ+3VHukbZHZZHTjN2VKAFAG6jC8gyTwITCsLE+66LAMZUai+Hm7zAfX
e+7c//owIEjlue9D4sZR/RZIhtLYYUeCE6K6FvsyZaRID1+Or8Todho4ExyZe3Wu
yOSmVxXTGxiQiosdjyDoEd00EI8cwNWnXLCdNIqoxNiuVRu22xjBfi/LBWzgssiX
AcegI69TWL6G1tqaLKdM
=tjR/
-END PGP SIGNATURE-

--
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: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller

2015-01-21 Thread Arun Ramamurthy


Thanks Alan. I did run check patch and I had no errors or warnings.

I explained my changes in v3 in the cover patch, did that not come 
through or is it convention to do it in the individual patch?


Is the ack for the ohci patch as well? Thanks

Arun Ramamurthy

On 15-01-21 07:03 AM, Alan Stern wrote:

On Mon, 19 Jan 2015 arun.ramamur...@broadcom.com wrote:


From: Arun Ramamurthy arunr...@broadcom.com

Added support for cases where one controller is connected
to multiple phys.

Signed-off-by: Arun Ramamurthy arunr...@broadcom.com
Reviewed-by: Ray Jui r...@broadcom.com
Reviewed-by: Scott Branden sbran...@broadcom.com
Tested-by: Scott Branden sbran...@broadcom.com
---


Right here is where you should explain how v3 of this patch is
different from v2.

Anyway, it looks good.

Acked-by: Alan Stern st...@rowland.harvard.edu

Did you run it through checkpatch.pl?

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/4] toshiba_acpi: Add support for USB Sleep functions

2015-01-21 Thread Darren Hart
On Wed, Jan 21, 2015 at 11:21:06AM -0700, Azael Avalos wrote:
 Hi there,
 
 Sorry for the late reply.
 
 2015-01-20 4:15 GMT-07:00 Oliver Neukum oneu...@suse.de:
  On Sun, 2015-01-18 at 18:30 -0700, Azael Avalos wrote:
  The following patches add support to several USB Sleep functions
  found on newer Toshiba laptops, allowing to use the USB ports while
  the laptop is asleep or turned off.
 
  Hi,
 
  this is most interesting. But the interface is terrible. If
 
 Well, I'm just providing the on/off switch on Toshiba specific hardware,
 but I'm unaware/unfamiliar with how other vendors implement this
 feature.
 
  possible we would like to have a generic interface for this,
  which should not depend on the specific platform in use and would
  have to be per bus or even per port (for example the ports on a
  Thunderbolt dock would not work with your module).
 
 Sounds good, as not all ports carry such functionality, on my
 current laptop only two ports provide this, the other two are just
 normal USB 2/3 ports (configurable ;-) ).
 
  Do you think we could provide a hook from generic code into
  platform code to detect the capability for power control?
 
 If there's an existing API already, I'll be glad to modify the code to
 use it, if it doesn't exist yet, I'll simply adapt the code to the chosen
 standard whenever becomes available.

Given the ACPI calls which are platform specific, a general purpose driver
doesn't seem likely. I'm keeping this queued as is unless you ask me to drop it
Azael.

-- 
Darren Hart
Intel Open Source Technology Center
--
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: [PATCHv5 4/4] USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

2015-01-21 Thread Boris Brezillon
Hi Sylvain,

On Wed, 21 Jan 2015 20:31:14 +0100
Sylvain Rochet sylvain.roc...@finsecur.com wrote:

 This patch add suspend/resume with wakeup support for Atmel USBA.
 
 On suspend: We stay continuously clocked if Vbus signal is not
 available. If Vbus signal is available we set the Vbus signal as a wake
 up source then we stop the USBA itself and all clocks used by USBA.
 
 On resume: We recover clocks and USBA we stopped them. If a device is
 connected, i.e. connected while we were suspended without wakeup
 enabled, we enable the controller.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 61 
 +
  1 file changed, 61 insertions(+)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 963e398..326725e 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -2115,6 +2115,7 @@ static int usba_udc_probe(struct platform_device *pdev)
   ret = usb_add_gadget_udc(pdev-dev, udc-gadget);
   if (ret)
   return ret;
 + device_init_wakeup(pdev-dev, 1);
  
   usba_init_debugfs(udc);
   for (i = 1; i  udc-num_ep; i++)
 @@ -2130,6 +2131,7 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
  
   udc = platform_get_drvdata(pdev);
  
 + device_init_wakeup(pdev-dev, 0);
   usb_del_gadget_udc(udc-gadget);
  
   for (i = 1; i  udc-num_ep; i++)
 @@ -2139,6 +2141,62 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
   return 0;
  }
  
 +#ifdef CONFIG_PM
 +static int usba_udc_suspend(struct device *dev)
 +{
 + struct usba_udc *udc = dev_get_drvdata(dev);
 +
 + /* Not started */
 + if (!udc-driver)
 + return 0;
 +
 + if (!device_may_wakeup(dev)) {
 + usba_stop(udc);
 + return 0;
 + }
 +
 + /*
 +  * Device may wake up. We stay clocked if we failed
 +  * to request vbus irq, assuming always on.
 +  */
 + if (gpio_is_valid(udc-vbus_pin)) {
 + usba_stop(udc);
 + /* Only wake up on device connection */
 + irq_set_irq_type(gpio_to_irq(udc-vbus_pin),
 + udc-vbus_pin_inverted ?
 + IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING);

If I'm correct, you're testing on a at91sam9x5 platform. Be careful,
this driver is used by older SoCs (at91sam9rl and avr32 SoCs) which do
not support configuring the interrupt on a specific edge (they trigger
on both edges).

This leaves two solutions here:
1) keep the IRQ_TYPE_EDGE_BOTH setting.
2) add new compatible strings to this driver and make this specific
edge change dependent on the SoC capability.

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel 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


Re: [PATCH v2 0/4] toshiba_acpi: Add support for USB Sleep functions

2015-01-21 Thread Azael Avalos
Hi there,

Sorry for the late reply.

2015-01-20 4:15 GMT-07:00 Oliver Neukum oneu...@suse.de:
 On Sun, 2015-01-18 at 18:30 -0700, Azael Avalos wrote:
 The following patches add support to several USB Sleep functions
 found on newer Toshiba laptops, allowing to use the USB ports while
 the laptop is asleep or turned off.

 Hi,

 this is most interesting. But the interface is terrible. If

Well, I'm just providing the on/off switch on Toshiba specific hardware,
but I'm unaware/unfamiliar with how other vendors implement this
feature.

 possible we would like to have a generic interface for this,
 which should not depend on the specific platform in use and would
 have to be per bus or even per port (for example the ports on a
 Thunderbolt dock would not work with your module).

Sounds good, as not all ports carry such functionality, on my
current laptop only two ports provide this, the other two are just
normal USB 2/3 ports (configurable ;-) ).

 Do you think we could provide a hook from generic code into
 platform code to detect the capability for power control?

If there's an existing API already, I'll be glad to modify the code to
use it, if it doesn't exist yet, I'll simply adapt the code to the chosen
standard whenever becomes available.


 Regards
 Oliver




Cheers
Azael



-- 
-- El mundo apesta y vosotros apestais tambien --
--
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: [RFC PATCH] usb: dwc2: Use platform endianness when accessing registers

2015-01-21 Thread John Crispin
Hi,

small nitpick

On 21/01/2015 19:27, Antti Seppälä wrote:
 This patch switches calls to readl/writel to their
 __raw_readl/__raw_writel equivalents which preserve platform endianness.
 
 This patch is necessary to access dwc2 registers correctly on big endian
 systems such as mips. Then dwc2 can be used to replace ifx-hcd driver

this should really say on big endian systems such as the mips based
SoCs made by Lantiq

John

 for lantiq platform found e.g. in OpenWrt.
 
 The patch was autogenerated with the following commands:
 sed -i s/\readl\/__raw_readl/g *.c hcd.h hw.h
 sed -i s/\writel\/__raw_writel/g *.c hcd.h hw.h
 
 Some files were then hand-edited to fix checkpatch.pl warning about
 too long lines.
 
 Signed-off-by: Antti Seppälä a.sepp...@gmail.com
 Signed-off-by: Vincent Pelletier plr.vinc...@gmail.com
 ---
  drivers/usb/dwc2/core.c  | 341 
 ++-
  drivers/usb/dwc2/core_intr.c |  73 -
  drivers/usb/dwc2/gadget.c| 312 +++
  drivers/usb/dwc2/hcd.c   | 144 +-
  drivers/usb/dwc2/hcd.h   |  15 +-
  drivers/usb/dwc2/hcd_ddma.c  |  10 +-
  drivers/usb/dwc2/hcd_intr.c  |  82 +--
  drivers/usb/dwc2/hcd_queue.c |  10 +-
  8 files changed, 495 insertions(+), 492 deletions(-)
 
 diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
 index 7605850b..30ef56b 100644
 --- a/drivers/usb/dwc2/core.c
 +++ b/drivers/usb/dwc2/core.c
 @@ -67,10 +67,10 @@ static void dwc2_enable_common_interrupts(struct 
 dwc2_hsotg *hsotg)
   u32 intmsk;
  
   /* Clear any pending OTG Interrupts */
 - writel(0x, hsotg-regs + GOTGINT);
 + __raw_writel(0x, hsotg-regs + GOTGINT);
  
   /* Clear any pending interrupts */
 - writel(0x, hsotg-regs + GINTSTS);
 + __raw_writel(0x, hsotg-regs + GINTSTS);
  
   /* Enable the interrupts in the GINTMSK */
   intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT;
 @@ -81,7 +81,7 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
 *hsotg)
   intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
 GINTSTS_SESSREQINT;
  
 - writel(intmsk, hsotg-regs + GINTMSK);
 + __raw_writel(intmsk, hsotg-regs + GINTMSK);
  }
  
  /*
 @@ -104,10 +104,10 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg 
 *hsotg)
   }
  
   dev_dbg(hsotg-dev, Initializing HCFG.FSLSPClkSel to %08x\n, val);
 - hcfg = readl(hsotg-regs + HCFG);
 + hcfg = __raw_readl(hsotg-regs + HCFG);
   hcfg = ~HCFG_FSLSPCLKSEL_MASK;
   hcfg |= val  HCFG_FSLSPCLKSEL_SHIFT;
 - writel(hcfg, hsotg-regs + HCFG);
 + __raw_writel(hcfg, hsotg-regs + HCFG);
  }
  
  /*
 @@ -125,7 +125,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
   /* Wait for AHB master IDLE state */
   do {
   usleep_range(2, 4);
 - greset = readl(hsotg-regs + GRSTCTL);
 + greset = __raw_readl(hsotg-regs + GRSTCTL);
   if (++count  50) {
   dev_warn(hsotg-dev,
%s() HANG! AHB Idle GRSTCTL=%0x\n,
 @@ -137,10 +137,10 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
   /* Core Soft Reset */
   count = 0;
   greset |= GRSTCTL_CSFTRST;
 - writel(greset, hsotg-regs + GRSTCTL);
 + __raw_writel(greset, hsotg-regs + GRSTCTL);
   do {
   usleep_range(2, 4);
 - greset = readl(hsotg-regs + GRSTCTL);
 + greset = __raw_readl(hsotg-regs + GRSTCTL);
   if (++count  50) {
   dev_warn(hsotg-dev,
%s() HANG! Soft Reset GRSTCTL=%0x\n,
 @@ -150,20 +150,20 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
   } while (greset  GRSTCTL_CSFTRST);
  
   if (hsotg-dr_mode == USB_DR_MODE_HOST) {
 - gusbcfg = readl(hsotg-regs + GUSBCFG);
 + gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
   gusbcfg = ~GUSBCFG_FORCEDEVMODE;
   gusbcfg |= GUSBCFG_FORCEHOSTMODE;
 - writel(gusbcfg, hsotg-regs + GUSBCFG);
 + __raw_writel(gusbcfg, hsotg-regs + GUSBCFG);
   } else if (hsotg-dr_mode == USB_DR_MODE_PERIPHERAL) {
 - gusbcfg = readl(hsotg-regs + GUSBCFG);
 + gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
   gusbcfg = ~GUSBCFG_FORCEHOSTMODE;
   gusbcfg |= GUSBCFG_FORCEDEVMODE;
 - writel(gusbcfg, hsotg-regs + GUSBCFG);
 + __raw_writel(gusbcfg, hsotg-regs + GUSBCFG);
   } else if (hsotg-dr_mode == USB_DR_MODE_OTG) {
 - gusbcfg = readl(hsotg-regs + GUSBCFG);
 + gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
   gusbcfg = ~GUSBCFG_FORCEHOSTMODE;
   gusbcfg = ~GUSBCFG_FORCEDEVMODE;
 - writel(gusbcfg, hsotg-regs + GUSBCFG);
 + __raw_writel(gusbcfg, hsotg-regs + 

[PATCHv5 1/4] USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state

2015-01-21 Thread Sylvain Rochet
If vbus gpio is high at init, we should set vbus_prev to true
accordingly to the current vbus state. Without that, we skip the first
vbus interrupt because the saved vbus state is not consistent.

Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: sta...@vger.kernel.org #2.6.24+
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..e207d75 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1791,6 +1791,8 @@ static int atmel_usba_start(struct usb_gadget *gadget,
toggle_bias(1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+
+   udc-vbus_prev = 1;
}
spin_unlock_irqrestore(udc-lock, flags);
 
-- 
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


[PATCHv5 2/4] USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ instead of an auto enabled IRQ request followed by IRQ disable

2015-01-21 Thread Sylvain Rochet
Vbus IRQ handler needs a started UDC driver to work because it uses
udc-driver, which is set by the UDC start handler. The previous way
chosen was to return from interrupt if udc-driver is NULL using a
spinlock around the check.

We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
of an auto enabled IRQ followed by disable_irq(). This way we remove the
very small timeslot of enabled IRQ which existed previously between
request() and disable(). We don't need anymore to check if udc-driver
is NULL in IRQ handler.

Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
Suggested-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index e207d75..d369ae0 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1729,10 +1729,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
 
spin_lock(udc-lock);
 
-   /* May happen if Vbus pin toggles during probe() */
-   if (!udc-driver)
-   goto out;
-
vbus = vbus_is_present(udc);
if (vbus != udc-vbus_prev) {
if (vbus) {
@@ -1753,7 +1749,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
udc-vbus_prev = vbus;
}
 
-out:
spin_unlock(udc-lock);
 
return IRQ_HANDLED;
@@ -2049,6 +2044,7 @@ static int usba_udc_probe(struct platform_device *pdev)
 
if (gpio_is_valid(udc-vbus_pin)) {
if (!devm_gpio_request(pdev-dev, udc-vbus_pin, 
atmel_usba_udc)) {
+   irq_set_status_flags(gpio_to_irq(udc-vbus_pin), 
IRQ_NOAUTOEN);
ret = devm_request_irq(pdev-dev,
gpio_to_irq(udc-vbus_pin),
usba_vbus_irq, 0,
@@ -2058,8 +2054,6 @@ static int usba_udc_probe(struct platform_device *pdev)
dev_warn(udc-pdev-dev,
 failed to request vbus irq; 
 assuming always on\n);
-   } else {
-   disable_irq(gpio_to_irq(udc-vbus_pin));
}
} else {
/* gpio_request fail so use -EINVAL for gpio_is_valid */
-- 
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


[PATCHv5 4/4] USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

2015-01-21 Thread Sylvain Rochet
This patch add suspend/resume with wakeup support for Atmel USBA.

On suspend: We stay continuously clocked if Vbus signal is not
available. If Vbus signal is available we set the Vbus signal as a wake
up source then we stop the USBA itself and all clocks used by USBA.

On resume: We recover clocks and USBA we stopped them. If a device is
connected, i.e. connected while we were suspended without wakeup
enabled, we enable the controller.

Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 61 +
 1 file changed, 61 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 963e398..326725e 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2115,6 +2115,7 @@ static int usba_udc_probe(struct platform_device *pdev)
ret = usb_add_gadget_udc(pdev-dev, udc-gadget);
if (ret)
return ret;
+   device_init_wakeup(pdev-dev, 1);
 
usba_init_debugfs(udc);
for (i = 1; i  udc-num_ep; i++)
@@ -2130,6 +2131,7 @@ static int __exit usba_udc_remove(struct platform_device 
*pdev)
 
udc = platform_get_drvdata(pdev);
 
+   device_init_wakeup(pdev-dev, 0);
usb_del_gadget_udc(udc-gadget);
 
for (i = 1; i  udc-num_ep; i++)
@@ -2139,6 +2141,62 @@ static int __exit usba_udc_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int usba_udc_suspend(struct device *dev)
+{
+   struct usba_udc *udc = dev_get_drvdata(dev);
+
+   /* Not started */
+   if (!udc-driver)
+   return 0;
+
+   if (!device_may_wakeup(dev)) {
+   usba_stop(udc);
+   return 0;
+   }
+
+   /*
+* Device may wake up. We stay clocked if we failed
+* to request vbus irq, assuming always on.
+*/
+   if (gpio_is_valid(udc-vbus_pin)) {
+   usba_stop(udc);
+   /* Only wake up on device connection */
+   irq_set_irq_type(gpio_to_irq(udc-vbus_pin),
+   udc-vbus_pin_inverted ?
+   IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING);
+   enable_irq_wake(gpio_to_irq(udc-vbus_pin));
+   }
+
+   return 0;
+}
+
+static int usba_udc_resume(struct device *dev)
+{
+   struct usba_udc *udc = dev_get_drvdata(dev);
+
+   /* Not started */
+   if (!udc-driver)
+   return 0;
+
+   if (device_may_wakeup(dev)  gpio_is_valid(udc-vbus_pin)) {
+   disable_irq_wake(gpio_to_irq(udc-vbus_pin));
+   irq_set_irq_type(gpio_to_irq(udc-vbus_pin), 
IRQ_TYPE_EDGE_BOTH);
+   }
+
+   /* If Vbus is present, enable the controller and wait for reset */
+   mutex_lock(udc-vbus_mutex);
+   udc-vbus_prev = vbus_is_present(udc);
+
+   if (udc-vbus_prev)
+   usba_start(udc);
+
+   mutex_unlock(udc-vbus_mutex);
+
+   return 0;
+}
+#endif
+
 #if defined(CONFIG_OF)
 static const struct of_device_id atmel_udc_dt_ids[] = {
{ .compatible = atmel,at91sam9rl-udc },
@@ -2148,10 +2206,13 @@ static const struct of_device_id atmel_udc_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
 #endif
 
+static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
+
 static struct platform_driver udc_driver = {
.remove = __exit_p(usba_udc_remove),
.driver = {
.name   = atmel_usba_udc,
+   .pm = usba_udc_pm_ops,
.of_match_table = of_match_ptr(atmel_udc_dt_ids),
},
 };
-- 
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: Control message failures kill entire XHCI stack

2015-01-21 Thread Devin Heitmueller
 I've been following this as it somewhat resembles the problems I'm
 experiencing, which I've just formally reported in Hauppauge
 USB-Live2 recording fails on USB3 port.

Yeah, it happens with the cx231xx as well, although the sequencing of
events leading to the failure is a bit different (I wrote the original
support for the USBLive2 back in 2011).

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.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


[PATCHv5 3/4] USB: gadget: atmel_usba_udc: Start clocks on rising edge of the Vbus signal, stop clocks on falling edge of the Vbus signal

2015-01-21 Thread Sylvain Rochet
If USB PLL is not necessary for other USB drivers (e.g. OHCI and EHCI)
we will reduce power consumption by switching off the USB PLL if no USB
Host is currently connected to this USB Device.

We are using Vbus GPIO signal to detect Host presence. If Vbus signal is
not available then the device stays continuously clocked.

Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 149 +---
 drivers/usb/gadget/udc/atmel_usba_udc.h |   4 +
 2 files changed, 104 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index d369ae0..963e398 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1719,38 +1719,98 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
return IRQ_HANDLED;
 }
 
-static irqreturn_t usba_vbus_irq(int irq, void *devid)
+static int start_clock(struct usba_udc *udc)
+{
+   int ret;
+
+   if (udc-clocked)
+   return 0;
+
+   ret = clk_prepare_enable(udc-pclk);
+   if (ret)
+   return ret;
+   ret = clk_prepare_enable(udc-hclk);
+   if (ret) {
+   clk_disable_unprepare(udc-pclk);
+   return ret;
+   }
+
+   udc-clocked = true;
+   return 0;
+}
+
+static void stop_clock(struct usba_udc *udc)
+{
+   if (!udc-clocked)
+   return;
+
+   clk_disable_unprepare(udc-hclk);
+   clk_disable_unprepare(udc-pclk);
+
+   udc-clocked = false;
+}
+
+static int usba_start(struct usba_udc *udc)
+{
+   unsigned long flags;
+   int ret;
+
+   ret = start_clock(udc);
+   if (ret)
+   return ret;
+
+   spin_lock_irqsave(udc-lock, flags);
+   toggle_bias(1);
+   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
+   usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+   spin_unlock_irqrestore(udc-lock, flags);
+   return 0;
+}
+
+static void usba_stop(struct usba_udc *udc)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(udc-lock, flags);
+   udc-gadget.speed = USB_SPEED_UNKNOWN;
+   reset_all_endpoints(udc);
+
+   /* This will also disable the DP pullup */
+   toggle_bias(0);
+   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
+   spin_unlock_irqrestore(udc-lock, flags);
+
+   stop_clock(udc);
+}
+
+static irqreturn_t usba_vbus_irq_thread(int irq, void *devid)
 {
struct usba_udc *udc = devid;
int vbus;
+   int ret;
 
/* debounce */
udelay(10);
 
-   spin_lock(udc-lock);
+   mutex_lock(udc-vbus_mutex);
 
vbus = vbus_is_present(udc);
if (vbus != udc-vbus_prev) {
+   udc-vbus_prev = vbus;
if (vbus) {
-   toggle_bias(1);
-   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
-   usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+   ret = usba_start(udc);
+   if (ret)
+   goto out;
} else {
-   udc-gadget.speed = USB_SPEED_UNKNOWN;
-   reset_all_endpoints(udc);
-   toggle_bias(0);
-   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
-   if (udc-driver-disconnect) {
-   spin_unlock(udc-lock);
+   usba_stop(udc);
+
+   if (udc-driver-disconnect)
udc-driver-disconnect(udc-gadget);
-   spin_lock(udc-lock);
-   }
}
-   udc-vbus_prev = vbus;
}
 
-   spin_unlock(udc-lock);
-
+out:
+   mutex_unlock(udc-vbus_mutex);
return IRQ_HANDLED;
 }
 
@@ -1762,57 +1822,47 @@ static int atmel_usba_start(struct usb_gadget *gadget,
unsigned long flags;
 
spin_lock_irqsave(udc-lock, flags);
-
udc-devstatus = 1  USB_DEVICE_SELF_POWERED;
udc-driver = driver;
spin_unlock_irqrestore(udc-lock, flags);
 
-   ret = clk_prepare_enable(udc-pclk);
-   if (ret)
-   return ret;
-   ret = clk_prepare_enable(udc-hclk);
-   if (ret) {
-   clk_disable_unprepare(udc-pclk);
-   return ret;
-   }
+   mutex_lock(udc-vbus_mutex);
 
-   udc-vbus_prev = 0;
if (gpio_is_valid(udc-vbus_pin))
enable_irq(gpio_to_irq(udc-vbus_pin));
 
/* If Vbus is present, enable the controller and wait for reset */
-   spin_lock_irqsave(udc-lock, flags);
-   if (vbus_is_present(udc)  udc-vbus_prev == 0) {
-   toggle_bias(1);
-   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
-   usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
-
-   udc-vbus_prev = 1;
+   

[PATCHv5 0/4] USB: gadget: atmel_usba_udc: Driver improvements

2015-01-21 Thread Sylvain Rochet
Start clocks on rising edge of the Vbus signal, stop clocks on falling 
edge of the Vbus signal.

Add suspend/resume with wakeup support.

Changes since v4:
  * Now using IRQ_NOAUTOEN flag to remove the unused check for 
udc-driver is not NULL in the Vbus IRQ.
  * Reworked the start/stop of clocks on Vbus edges to prepare for 
suspend/resume support, factorised start and stop procedures
  * New patch, suspend/resume for USBA with wakeup support

Changes since v3:
  * Added stable tag for the first patch
  * As suggested, removed the unused check for udc-driver is not NULL in
Vbus IRQ by requesting IRQ after udc-driver is set and by releasing
IRQ before udc-driver is cleared
  * Rebased the core patch of this series against the just explained changes

Changes since v2:
  * Use spin_lock_irqsave/unlock_irqrestore instead of spin_lock/unlock in
threaded interrupt because we are not in irq context anymore
  * Removed useless and probably harmful IRQF_NO_SUSPEND from
devm_request_threaded_irq() flags

Changes since v1:
  * Using a threaded irq and mutex instead of spinclock as suggested
  * Moved a silently fixed bug in a separate patch (1/2)

Sylvain Rochet (4):
  USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state
  USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ
instead of an auto enabled IRQ request followed by IRQ disable
  USB: gadget: atmel_usba_udc: Start clocks on rising edge of the Vbus
signal, stop clocks on falling edge of the Vbus signal
  USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

 drivers/usb/gadget/udc/atmel_usba_udc.c | 214 
 drivers/usb/gadget/udc/atmel_usba_udc.h |   4 +
 2 files changed, 165 insertions(+), 53 deletions(-)

-- 
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: MUSB dual-role on AM335x behaving weirdly

2015-01-21 Thread Bin Liu
Hi,

On Wed, Jan 21, 2015 at 10:06 AM, Maxime Ripard
maxime.rip...@free-electrons.com wrote:
 Hi Felipe,

 I'm currently working on a custom AM335x-based board, that has a OTG
 connector wired to one of the musb controlers, and Linux 3.17

 This OTG connector seems to behave in a weird way when it comes to
 switching from one role to another:

   - The host mode works with CONFIG_USB_MUSB_DUAL_ROLE set, only if
 the dr_mode is set to host in the DT, and only if we plug the USB
 device after the kernel has booted. Otherwise, even though the
 controller seems to be set up as host in the kernel logs, it
 doesn't work. When DR-mode is set to otg, DRVVBUS is not high
 which surely doesn't help, but there might be some other issues.

   - The gadget mode works with CONFIG_USB_MUSB_DUAL_ROLE, if dr_mode
 is set to otg and not host (obviously), and only if we plug the
 USB cable after the kernel has booted.

   - The gadget mode works with CONFIG_USB_MUSB_GADGET, and with
 dr_mode set to otg, even if we cold plug the device.

   - As you might expect from the two first items, the runtime
 switching from gadget to host when CONFIG_USB_MUSB_DUAL_ROLE is
 set and dr_mode is set in otg doesn't work either.

 It looks like it's only waiting for an interrupt to occur to read the
 ID pin state, without reading its initial value, which would explain
 why both the host and gadget enumerate only when a device/cable is
 hotplugged, and that there's some configuration bits that differ
 whenever dr_mode changes, but I couldn't really see anything standing
 out in the driver nor the datasheet.

 Have you already experienced something alike with that driver?

I don't use vanilla mainline kernel very often, but I don't have such
hotplug issues with TI 3.12/14 kernels [1]. I only use
CONFIG_USB_MUSB_DUAL_ROLE though.

[1] git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git, branch
remote/origin/linux-3.14.y

Regards,
-Bin.


 Thanks,
 Maxime

 --
 Maxime Ripard, 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


[PATCHv2] usb: core: hub: modify hub reset logic in hub driver

2015-01-21 Thread deepakdas . linux
From: Deepak Das deepakdas.li...@gmail.com

Currently if port power is turned off by user on hub port
using USBDEVFS then port power is turned back ON
by hub driver.
This commit modifies hub reset logic in hub_port_connect() to prevent
hub driver from turning back the port power ON if port is not owned
by kernel.

Signed-off-by: Deepak Das deepakdas.li...@gmail.com
---
Changes from v1:
Fixed indentation of the comment

 drivers/usb/core/hub.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b649fef..a02ee0a 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4657,9 +4657,13 @@ static void hub_port_connect(struct usb_hub *hub, int 
port1, u16 portstatus,
if (!(portstatus  USB_PORT_STAT_CONNECTION) ||
test_bit(port1, hub-removed_bits)) {
 
-   /* maybe switch power back on (e.g. root hub was reset) */
+   /*
+* maybe switch power back on (e.g. root hub was reset)
+* but only if the port isn't owned by someone else.
+*/
if (hub_is_port_power_switchable(hub)
-!port_is_power_on(hub, portstatus))
+!port_is_power_on(hub, portstatus)
+!port_dev-port_owner)
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
 
if (portstatus  USB_PORT_STAT_ENABLE)
-- 
1.7.9.5

--
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


[RFC PATCH] usb: dwc2: Use platform endianness when accessing registers

2015-01-21 Thread Antti Seppälä
This patch switches calls to readl/writel to their
__raw_readl/__raw_writel equivalents which preserve platform endianness.

This patch is necessary to access dwc2 registers correctly on big endian
systems such as mips. Then dwc2 can be used to replace ifx-hcd driver
for lantiq platform found e.g. in OpenWrt.

The patch was autogenerated with the following commands:
sed -i s/\readl\/__raw_readl/g *.c hcd.h hw.h
sed -i s/\writel\/__raw_writel/g *.c hcd.h hw.h

Some files were then hand-edited to fix checkpatch.pl warning about
too long lines.

Signed-off-by: Antti Seppälä a.sepp...@gmail.com
Signed-off-by: Vincent Pelletier plr.vinc...@gmail.com
---
 drivers/usb/dwc2/core.c  | 341 ++-
 drivers/usb/dwc2/core_intr.c |  73 -
 drivers/usb/dwc2/gadget.c| 312 +++
 drivers/usb/dwc2/hcd.c   | 144 +-
 drivers/usb/dwc2/hcd.h   |  15 +-
 drivers/usb/dwc2/hcd_ddma.c  |  10 +-
 drivers/usb/dwc2/hcd_intr.c  |  82 +--
 drivers/usb/dwc2/hcd_queue.c |  10 +-
 8 files changed, 495 insertions(+), 492 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 7605850b..30ef56b 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -67,10 +67,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
u32 intmsk;
 
/* Clear any pending OTG Interrupts */
-   writel(0x, hsotg-regs + GOTGINT);
+   __raw_writel(0x, hsotg-regs + GOTGINT);
 
/* Clear any pending interrupts */
-   writel(0x, hsotg-regs + GINTSTS);
+   __raw_writel(0x, hsotg-regs + GINTSTS);
 
/* Enable the interrupts in the GINTMSK */
intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT;
@@ -81,7 +81,7 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
 
-   writel(intmsk, hsotg-regs + GINTMSK);
+   __raw_writel(intmsk, hsotg-regs + GINTMSK);
 }
 
 /*
@@ -104,10 +104,10 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg 
*hsotg)
}
 
dev_dbg(hsotg-dev, Initializing HCFG.FSLSPClkSel to %08x\n, val);
-   hcfg = readl(hsotg-regs + HCFG);
+   hcfg = __raw_readl(hsotg-regs + HCFG);
hcfg = ~HCFG_FSLSPCLKSEL_MASK;
hcfg |= val  HCFG_FSLSPCLKSEL_SHIFT;
-   writel(hcfg, hsotg-regs + HCFG);
+   __raw_writel(hcfg, hsotg-regs + HCFG);
 }
 
 /*
@@ -125,7 +125,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
/* Wait for AHB master IDLE state */
do {
usleep_range(2, 4);
-   greset = readl(hsotg-regs + GRSTCTL);
+   greset = __raw_readl(hsotg-regs + GRSTCTL);
if (++count  50) {
dev_warn(hsotg-dev,
 %s() HANG! AHB Idle GRSTCTL=%0x\n,
@@ -137,10 +137,10 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
/* Core Soft Reset */
count = 0;
greset |= GRSTCTL_CSFTRST;
-   writel(greset, hsotg-regs + GRSTCTL);
+   __raw_writel(greset, hsotg-regs + GRSTCTL);
do {
usleep_range(2, 4);
-   greset = readl(hsotg-regs + GRSTCTL);
+   greset = __raw_readl(hsotg-regs + GRSTCTL);
if (++count  50) {
dev_warn(hsotg-dev,
 %s() HANG! Soft Reset GRSTCTL=%0x\n,
@@ -150,20 +150,20 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
} while (greset  GRSTCTL_CSFTRST);
 
if (hsotg-dr_mode == USB_DR_MODE_HOST) {
-   gusbcfg = readl(hsotg-regs + GUSBCFG);
+   gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
gusbcfg = ~GUSBCFG_FORCEDEVMODE;
gusbcfg |= GUSBCFG_FORCEHOSTMODE;
-   writel(gusbcfg, hsotg-regs + GUSBCFG);
+   __raw_writel(gusbcfg, hsotg-regs + GUSBCFG);
} else if (hsotg-dr_mode == USB_DR_MODE_PERIPHERAL) {
-   gusbcfg = readl(hsotg-regs + GUSBCFG);
+   gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
gusbcfg = ~GUSBCFG_FORCEHOSTMODE;
gusbcfg |= GUSBCFG_FORCEDEVMODE;
-   writel(gusbcfg, hsotg-regs + GUSBCFG);
+   __raw_writel(gusbcfg, hsotg-regs + GUSBCFG);
} else if (hsotg-dr_mode == USB_DR_MODE_OTG) {
-   gusbcfg = readl(hsotg-regs + GUSBCFG);
+   gusbcfg = __raw_readl(hsotg-regs + GUSBCFG);
gusbcfg = ~GUSBCFG_FORCEHOSTMODE;
gusbcfg = ~GUSBCFG_FORCEDEVMODE;
-   writel(gusbcfg, hsotg-regs + GUSBCFG);
+   __raw_writel(gusbcfg, hsotg-regs + GUSBCFG);
}
 
/*
@@ -186,9 +186,9 @@ static int dwc2_fs_phy_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
 */
if 

[PATCH] USB: don't cancel queued resets when unbinding drivers

2015-01-21 Thread Alan Stern
The USB stack provides a mechanism for drivers to request an
asynchronous device reset (usb_queue_reset_device()).  The mechanism
uses a work item (reset_ws) embedded in the usb_interface structure
used by the driver, and the reset is carried out by a work queue
routine.

The asynchronous reset can race with driver unbinding.  When this
happens, we try to cancel the queued reset before unbinding the
driver, on the theory that the driver won't care about any resets once
it is unbound.

However, thanks to the fact that lockdep now tracks work queue
accesses, this can provoke a lockdep warning in situations where the
device reset causes another interface's driver to be unbound; see

http://marc.info/?l=linux-usbm=141893165203776w=2

for an example.  The reason is that the work routine for reset_ws in
one interface calls cancel_queued_work() for the reset_ws in another
interface.  Lockdep thinks this might lead to a work routine trying to
cancel itself.  The simplest solution is not to cancel queued resets
when unbinding drivers.

This means we now need to acquire a reference to the usb_interface
when queuing a reset_ws work item and to drop the reference when the
work routine finishes.  We also need to make sure that the
usb_interface structure doesn't outlive its parent usb_device; this
means acquiring and dropping a reference when the interface is created
and destroyed.

In addition, cancelling a queued reset can fail (if the device is in
the middle of an earlier reset), and this can cause usb_reset_device()
to try to rebind an interface that has been deallocated (see
http://marc.info/?l=linux-usbm=142175717016628w=2 for details).
Acquiring the extra references prevents this failure.

Signed-off-by: Alan Stern st...@rowland.harvard.edu
Reported-by: Russell King - ARM Linux li...@arm.linux.org.uk
Reported-by: Olivier Sobrie oliv...@sobrie.be
Tested-by: Olivier Sobrie oliv...@sobrie.be

---

Greg, Russell's problem doesn't affect kernels earlier than 3.19, but 
Olivier's might.  I'm not sure whether this patch should go into 
-stable.  Maybe it should...


[as1771]


 drivers/usb/core/driver.c  |   17 -
 drivers/usb/core/hub.c |   25 +
 drivers/usb/core/message.c |   23 +++
 include/linux/usb.h|5 -
 4 files changed, 12 insertions(+), 58 deletions(-)

Index: usb-3.19/include/linux/usb.h
===
--- usb-3.19.orig/include/linux/usb.h
+++ usb-3.19/include/linux/usb.h
@@ -127,10 +127,6 @@ enum usb_interface_condition {
  * to the sysfs representation for that device.
  * @pm_usage_cnt: PM usage counter for this interface
  * @reset_ws: Used for scheduling resets from atomic context.
- * @reset_running: set to 1 if the interface is currently running a
- *  queued reset so that usb_cancel_queued_reset() doesn't try to
- *  remove from the workqueue when running inside the worker
- *  thread. See __usb_queue_reset_device().
  * @resetting_device: USB core reset the device, so use alt setting 0 as
  * current; needs bandwidth alloc after reset.
  *
@@ -181,7 +177,6 @@ struct usb_interface {
unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
unsigned needs_altsetting0:1;   /* switch to altsetting 0 is pending */
unsigned needs_binding:1;   /* needs delayed unbind/rebind */
-   unsigned reset_running:1;
unsigned resetting_device:1;/* true: bandwidth alloc after reset */
 
struct device dev;  /* interface specific device info */
Index: usb-3.19/drivers/usb/core/driver.c
===
--- usb-3.19.orig/drivers/usb/core/driver.c
+++ usb-3.19/drivers/usb/core/driver.c
@@ -275,21 +275,6 @@ static int usb_unbind_device(struct devi
return 0;
 }
 
-/*
- * Cancel any pending scheduled resets
- *
- * [see usb_queue_reset_device()]
- *
- * Called after unconfiguring / when releasing interfaces. See
- * comments in __usb_queue_reset_device() regarding
- * udev-reset_running.
- */
-static void usb_cancel_queued_reset(struct usb_interface *iface)
-{
-   if (iface-reset_running == 0)
-   cancel_work_sync(iface-reset_ws);
-}
-
 /* called from driver core with dev locked */
 static int usb_probe_interface(struct device *dev)
 {
@@ -380,7 +365,6 @@ static int usb_probe_interface(struct de
usb_set_intfdata(intf, NULL);
intf-needs_remote_wakeup = 0;
intf-condition = USB_INTERFACE_UNBOUND;
-   usb_cancel_queued_reset(intf);
 
/* If the LPM disable succeeded, balance the ref counts. */
if (!lpm_disable_error)
@@ -425,7 +409,6 @@ static int usb_unbind_interface(struct d
usb_disable_interface(udev, intf, false);
 
driver-disconnect(intf);
-   usb_cancel_queued_reset(intf);
 
/* Free streams */
for (i = 0, j = 0; i  

Re: Control message failures kill entire XHCI stack

2015-01-21 Thread Alistair Grant
Hi Matthias,

On Tue, Jan 20, 2015 at 10:22 AM, Mathias Nyman
mathias.ny...@linux.intel.com wrote:
 On 19.01.2015 22:02, Devin Heitmueller wrote:
 Hi Mathias,

 Thanks for getting back to me.

 There are a couple of xhci bugs triggered by dvb devices:
 https://bugzilla.kernel.org/show_bug.cgi?id=75521
 https://bugzilla.kernel.org/show_bug.cgi?id=65021

 The first one (75521) I believe is mostly fixed by patches in 3.18 and early
 3.19-rc, so work on a 3.19-rc kernel to eliminate those issues.
 ...
 The second bug (65021) looks more like your case, it queues two 
 stop_endpoints
 commands almost simultaneously, which end up never completing, -timeout 
 and tear down xhci.
 That bug has a debug patch for command ring status, you could try it out to 
 check if
 the command queue is running among other details.

 The second bug definitely looks like what I'm seeing.  I'll try your
 tree and report back my findings.

 Ah, let me rebase that tree on top of a more current kernel first.

I've been following this as it somewhat resembles the problems I'm
experiencing, which I've just formally reported in Hauppauge
USB-Live2 recording fails on USB3 port.

It looks like you did the rebase yesterday, so I tried running your
updated kernel.  It didn't solve the problems, but was an incremental
improvement since the mainline 3.19rc5 kernel hangs during shutdown,
while your modified kernel shutdown cleanly.

I've got a syslog with verbose xhci logging (echo -n 'module xhci_hcd
=p'  /sys/kernel/debug/dynamic_debug/control as you suggested above)
if you would like to take a look.  It's 2.4M so please let me know how
you would like me to pass it on.

Thanks very much,
Alistair
--
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


MUSB dual-role on AM335x behaving weirdly

2015-01-21 Thread Maxime Ripard
Hi Felipe,

I'm currently working on a custom AM335x-based board, that has a OTG
connector wired to one of the musb controlers, and Linux 3.17

This OTG connector seems to behave in a weird way when it comes to
switching from one role to another:

  - The host mode works with CONFIG_USB_MUSB_DUAL_ROLE set, only if
the dr_mode is set to host in the DT, and only if we plug the USB
device after the kernel has booted. Otherwise, even though the
controller seems to be set up as host in the kernel logs, it
doesn't work. When DR-mode is set to otg, DRVVBUS is not high
which surely doesn't help, but there might be some other issues.

  - The gadget mode works with CONFIG_USB_MUSB_DUAL_ROLE, if dr_mode
is set to otg and not host (obviously), and only if we plug the
USB cable after the kernel has booted.

  - The gadget mode works with CONFIG_USB_MUSB_GADGET, and with
dr_mode set to otg, even if we cold plug the device.

  - As you might expect from the two first items, the runtime
switching from gadget to host when CONFIG_USB_MUSB_DUAL_ROLE is
set and dr_mode is set in otg doesn't work either.

It looks like it's only waiting for an interrupt to occur to read the
ID pin state, without reading its initial value, which would explain
why both the host and gadget enumerate only when a device/cable is
hotplugged, and that there's some configuration bits that differ
whenever dr_mode changes, but I couldn't really see anything standing
out in the driver nor the datasheet.

Have you already experienced something alike with that driver?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH] usb: core: hub: modify hub reset logic in hub driver

2015-01-21 Thread Deepak Das
On 21 January 2015 at 15:58, Alan Stern st...@rowland.harvard.edu wrote:
 On Wed, 21 Jan 2015 deepakdas.li...@gmail.com wrote:

 From: Deepak Das deepakdas.li...@gmail.com

 Currently if port power is turned off by user on hub port
 using USBDEVFS then port power is turned back ON
 by hub driver.
 This commit modifies hub reset logic in hub_port_connect() to prevent
 hub driver from turning back the port power ON if port is not owned
 by kernel.

 Signed-off-by: Deepak Das deepakdas.li...@gmail.com
 ---
  drivers/usb/core/hub.c |8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
 index b649fef..6f12de7 100644
 --- a/drivers/usb/core/hub.c
 +++ b/drivers/usb/core/hub.c
 @@ -4657,9 +4657,13 @@ static void hub_port_connect(struct usb_hub *hub, int 
 port1, u16 portstatus,
   if (!(portstatus  USB_PORT_STAT_CONNECTION) ||
   test_bit(port1, hub-removed_bits)) {

 - /* maybe switch power back on (e.g. root hub was reset) */
 + /*
 + *  maybe switch power back on (e.g. root hub was reset)
 + * but only if the port isn't owned by someone else.
 + */

 Minor issue: Multi-line comments should be formatted like this:

 /*
  * blah blah blah
  * blah blah blah
  */

 with all the '*' characters aligned vertically.  See how it is done
 elsewhere in the source file.

   if (hub_is_port_power_switchable(hub)
 -  !port_is_power_on(hub, portstatus))
 +  !port_is_power_on(hub, portstatus)
 +  !port_dev-port_owner)
   set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);

   if (portstatus  USB_PORT_STAT_ENABLE)

 Fix that and then repost the patch with:

 Acked-by: Alan Stern st...@rowland.harvard.edu

 Be sure to CC: Greg KH so he will see it and apply it.

 Alan Stern

Thanks Alen, I will repost the patch after modification.

With warm regards,
Deepak Das
--
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 2/2] usb: musb: try a race-free wakeup

2015-01-21 Thread Bin Liu
Hi Sebastian,

On Mon, Oct 27, 2014 at 1:06 PM, Sebastian Andrzej Siewior
bige...@linutronix.de wrote:
 Attaching a keyboard, using it as a wakeup via
 |for f in $(find /sys/devices/ocp.3/4740.usb -name wakeup)
 |do
 |   echo enabled  $f
 |done

 going into standby
 |  echo standby   /sys/power/state

 and now a wake up by a pressing a key.
 What happens is that the system wakes up but the USB device is dead. The
 USB stack tries to send a few control URBs but nothing comes back.
 Eventually it gaves up and the device remains dead:
 |[  632.559678] PM: Wakeup source USB1_PHY
 |[  632.581074] PM: noirq resume of devices complete after 21.261 msecs
 |[  632.607521] PM: early resume of devices complete after 10.360 msecs
 |[  632.616854] net eth2: initializing cpsw version 1.12 (0)
 |[  632.704126] net eth2: phy found : id is : 0x4dd074
 |[  636.704048] libphy: 4a101000.mdio:00 - Link is Up - 1000/Full
 |[  638.444620] usb 1-1: reset low-speed USB device number 2 using musb-hdrc
 |[  653.713435] usb 1-1: device descriptor read/64, error -110
 |[  669.093435] usb 1-1: device descriptor read/64, error -110
 |[  669.473424] usb 1-1: reset low-speed USB device number 2 using musb-hdrc
 |[  684.743436] usb 1-1: device descriptor read/64, error -110
 |[  690.065097] PM: resume of devices complete after 57450.744 msecs
 |[  690.076601] PM: Finishing wakeup.
 |[  690.076627] Restarting tasks ...

 It seems that since we got woken up via MUSB_INTR_RESUME the
 musb_host_finish_resume() callback is executed before the
 resume-callbacks of the PHY and glue layer are invoked. If I delay it
 until the glue layer resumed then I don't see this problem.

 I also move musb_host_resume_root_hub() into that callback since I don't
 see any reason in doing anything resume-link if there are still pieces
 not restored.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

With this patch, hubs stop working on TI AM335x EVMs when autosuspend
is enabled.

I booted the board, connected a hub to the USB1 host port, it got
enumerated properly, then connected a thumb drive to the hub, but the
drive was not enumerated, no any log from kernel. Removing the drive,
no any kernel message either. Finally removed the hub, no disconnect
for the hub. Now check MUSB1 DEVCTL register, it value is 0x5D.

Reverted this patch, the issue disappeared. Or disable usbcore
autosuspend, the issue did not happen.

I tested 7+ hubs, all have the same issue.

I tested on git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git, tag
ti2014.10.01. have not tested with mainline kernel yet.

Have you validated this test case?

Thanks,
-Bin.

 ---
  drivers/usb/musb/musb_core.c| 10 ++
  drivers/usb/musb/musb_core.h|  1 +
  drivers/usb/musb/musb_virthub.c |  1 +
  3 files changed, 8 insertions(+), 4 deletions(-)

 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
 index 749360d63bbe..2ff1b37a46a6 100644
 --- a/drivers/usb/musb/musb_core.c
 +++ b/drivers/usb/musb/musb_core.c
 @@ -478,13 +478,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, 
 u8 int_usb,
 | MUSB_PORT_STAT_RESUME;
 musb-rh_timer = jiffies
  + msecs_to_jiffies(20);
 -   schedule_delayed_work(
 -   musb-finish_resume_work,
 -   msecs_to_jiffies(20));
 +   musb-need_finish_resume = 1;

 musb-xceiv-state = OTG_STATE_A_HOST;
 musb-is_active = 1;
 -   musb_host_resume_root_hub(musb);
 break;
 case OTG_STATE_B_WAIT_ACON:
 musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
 @@ -2319,6 +2316,11 @@ static int musb_resume(struct device *dev)
 mask = MUSB_DEVCTL_BDEVICE | MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV;
 if ((devctl  mask) != (musb-context.devctl  mask))
 musb-port1_status = 0;
 +   if (musb-need_finish_resume) {
 +   musb-need_finish_resume = 0;
 +   schedule_delayed_work(musb-finish_resume_work,
 + msecs_to_jiffies(20));
 +   }
 return 0;
  }

 diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
 index 414e57a984bb..803a997e56d2 100644
 --- a/drivers/usb/musb/musb_core.h
 +++ b/drivers/usb/musb/musb_core.h
 @@ -390,6 +390,7 @@ struct musb {

 /* is_suspended means USB B_PERIPHERAL suspend */
 unsignedis_suspended:1;
 +   unsignedneed_finish_resume :1;

 /* may_wakeup means remote wakeup is enabled */
 unsignedmay_wakeup:1;
 diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
 index 

Re: [PATCHv2 001/002] usbhid: Fix initialisation for the Microsoft Sidewinder Force Feedback Pro 2 joystick

2015-01-21 Thread Jim Keir

Hi,

Thanks for the feedback. I've included a replacement patch here for the 
first issue, and will send a separate message with a patch for the third 
issue. I've removed the second as per Alan's request. This diff is 
against the latest version of the hid branch rather than the 3.13 branch 
I was using before. Apologies for the mistakes, I'm still feeling my way 
around here.


---

Allow the Microsoft Sidewinder Force Feedback 2 joystick to perform the 
required communication with the device during initialisation.


Signed-off-by: Jim Keir jimk...@oracledbadirect.com

---

diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index 10b6167..1b3fa70 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -1252,6 +1258,8 @@ int hid_pidff_init(struct hid_device *hid)

 pidff-hid = hid;

+hid_device_io_start(hid);
+
 pidff_find_reports(hid, HID_OUTPUT_REPORT, pidff);
 pidff_find_reports(hid, HID_FEATURE_REPORT, pidff);

@@ -1315,9 +1323,13 @@ int hid_pidff_init(struct hid_device *hid)

 hid_info(dev, Force feedback for USB HID PID devices by Anssi 
Hannula anssi.hann...@gmail.com\n);


+hid_device_io_stop(hid);
+
 return 0;

  fail:
+hid_device_io_stop(hid);
+
 kfree(pidff);
 return error;
 }

---

On 20/01/2015 14:09, Benjamin Tissoires wrote:

Hi,

Jim, in addition to what Alan said, here are some comments that I
would like to be fixed in the v2.

On Sun, Jan 18, 2015 at 11:07 AM, Jim Keir jimk...@oracledbadirect.com wrote:

From: Jim Keir jimk...@yahoo.co.uk
Signed-off-by: Jim Keir jimk...@yahoo.co.uk


The Signed-off-by line is generally at the end of the commit message.
This way, if someone else adds new changes to the patch, we can trace
which modifications belongs to which.


Currently the SWFF2 driver fails during initialisation, making the force
capability of the joystick unusable. Further, there is a long-standing
bug in the same driver where commands to update force parameters are
addressed to the last-created force effect instead of the specified one,
making it impossible to modify effects after their creation.

Three bugs are addressed:

1) The FF2 driver (usbhid/hid-pidff.c) sends commands to the stick
during ff_init. However, this is called inside a block where
driver_input_lock is locked, so the results of these initial commands
are discarded. This one is the killer, without this nothing else works.

ff_init issues commands using hid_hw_request. This eventually goes to
hid_input_report, which returns -EBUSY because driver_input_lock is
locked. The change is to delay the ff_init call in hid-core.c until
after this lock has been released.

2) The usbhid driver ignores an endpoint stall when sending control
commands, causing the first few commands of the hid-pidff.c
initialisation to get lost.

usbhid/hid-core.c has been modified by copying lines into hid_ctrl
from the hid_irq_in function in the same file.

3) The FF2 driver (usbhid/hid-pidff.c) does not set the effect ID when
uploading an effect. The result is that the initial upload works but
subsequent uploads to modify effect parameters are all directed at the
last-created effect.


Fully agree that you should split the commit in 3 if there are 3
issues (and to the rest Alan said also, but this is the most important
I think).



The targeted effect ID must be passed back to the device when effect
parameters are changed. This is done at the start of
pidff_set_condition_report, pidff_set_periodic_report etc. based on
the value of pidff-block_load[PID_EFFECT_BLOCK_INDEX].value[0].
However, this value is only ever set during pidff_request_effect_upload.
The result is stored in pidff-pid_id[effect-id] at the end of
pid_upload_effect, for later use. However, if an effect is modified and
re-sent then this identifier is not being copied back from
pidff-pid_id[effect-id] before sending the command to the device. The
fix is to do this at the start of pidff_upload_effect.

This patch taken against kernel 3.13.0

---

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 905e40a..a608ee6 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1546,9 +1546,8 @@ int hid_connect(struct hid_device *hdev, unsigned int
connect_mask)

On my local tree, hid_connect is at 1562. Is your patch based on the
for-next branch of the HID tree?
https://git.kernel.org/cgit/linux/kernel/git/jikos/hid.git



  return -ENODEV;
  }

-if ((hdev-claimed  HID_CLAIMED_INPUT) 
-(connect_mask  HID_CONNECT_FF)  hdev-ff_init)
-hdev-ff_init(hdev);
+/* Removed ff_init() call from here. It does device I/O but this
+ * is blocked because driver_input_lock is currently locked. */

Please don't. If the feedback driver needs to have access to the IO
earlier, it needs to call hid_device_io_start() (and eventually
hid_device_io_stop() if some other initialization are required).


  len = 0;
  if (hdev-claimed  

Re: Boot regression on Versatile Express TC2 after commit b2b49ccbdd

2015-01-21 Thread Alan Stern
On Wed, 21 Jan 2015, Rafael J. Wysocki wrote:

  Well, assuming that the HCD driver doesn't support wakeup signaling,
  it would be good to have a way to indicate the lack of support for
  autosuspend to the USB core so as to avoid the user-visible breakage.
  
  Do we have any means for that?
 
 For example, would it help to add
 
   device_set_wakeup_capable(hcd-self.controller, 0);
 
 somewhere at the beginning of isp1760_hc_setup()?

Yes, we could use that instead of adding a new flag.

 For example, would it help to add
 
   device_set_wakeup_capable(hcd-self.controller, 0);
 
 somewhere at the beginning of isp1760_hc_setup()?

At the moment it wouldn't help.  The problem isn't that we want to 
avoid suspending the controller or its root hub; the problem is that we 
want to avoid suspending a device plugged into the root hub if that 
device needs to be enabled for wakeup.  This is because when the device 
sends its wakeup signal, the controller won't receive it.

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: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller

2015-01-21 Thread Alan Stern
On Wed, 21 Jan 2015, Arun Ramamurthy wrote:

 Thanks Alan. I did run check patch and I had no errors or warnings.
 
 I explained my changes in v3 in the cover patch, did that not come 
 through or is it convention to do it in the individual patch?

Oh, sorry, I missed it.  Must have deleted that email by mistake.

 Is the ack for the ohci patch as well? Thanks

Yes.

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: [PATCHv5 0/4] USB: gadget: atmel_usba_udc: Driver improvements

2015-01-21 Thread Boris Brezillon
Hi Sylvain,

On Wed, 21 Jan 2015 20:31:10 +0100
Sylvain Rochet sylvain.roc...@finsecur.com wrote:

 Start clocks on rising edge of the Vbus signal, stop clocks on falling 
 edge of the Vbus signal.
 
 Add suspend/resume with wakeup support.

Apart from the minor comment I made on patch 4, you can add my:

Acked-by: Boris Brezillon boris.brezil...@free-electrons.com

to the whole series.

Thanks for your patience.

Best Regards,

Boris

 
 Changes since v4:
   * Now using IRQ_NOAUTOEN flag to remove the unused check for 
 udc-driver is not NULL in the Vbus IRQ.
   * Reworked the start/stop of clocks on Vbus edges to prepare for 
 suspend/resume support, factorised start and stop procedures
   * New patch, suspend/resume for USBA with wakeup support
 
 Changes since v3:
   * Added stable tag for the first patch
   * As suggested, removed the unused check for udc-driver is not NULL in
 Vbus IRQ by requesting IRQ after udc-driver is set and by releasing
 IRQ before udc-driver is cleared
   * Rebased the core patch of this series against the just explained changes
 
 Changes since v2:
   * Use spin_lock_irqsave/unlock_irqrestore instead of spin_lock/unlock in
 threaded interrupt because we are not in irq context anymore
   * Removed useless and probably harmful IRQF_NO_SUSPEND from
 devm_request_threaded_irq() flags
 
 Changes since v1:
   * Using a threaded irq and mutex instead of spinclock as suggested
   * Moved a silently fixed bug in a separate patch (1/2)
 
 Sylvain Rochet (4):
   USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state
   USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ
 instead of an auto enabled IRQ request followed by IRQ disable
   USB: gadget: atmel_usba_udc: Start clocks on rising edge of the Vbus
 signal, stop clocks on falling edge of the Vbus signal
   USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support
 
  drivers/usb/gadget/udc/atmel_usba_udc.c | 214 
 
  drivers/usb/gadget/udc/atmel_usba_udc.h |   4 +
  2 files changed, 165 insertions(+), 53 deletions(-)
 



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel 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


Re: Boot regression on Versatile Express TC2 after commit b2b49ccbdd

2015-01-21 Thread Alan Stern
On Wed, 21 Jan 2015, Rafael J. Wysocki wrote:

If nothing happens, there are two possibilities: The hub doesn't 
support wakeup signalling, or the isp1760-hcd driver doesn't support 
it.  To tell the truth, it wouldn't be surprising if the second turns 
out to be the case.
   
   How can this be determined?
   
   According to /proc/interrupts, isp1760-hcd:usb1 no longer receive any 
   interrupts.  Wether or not it could is something I don't know.
  
  I don't know either.  At this point, you have to ask a developer who is 
  familiar with the isp1760 hardware and driver.  Perhaps one of the 
  people on the CC: list can help.
  
  At least you are able to boot your system now with the command-line 
  option.  That's an improvement.
 
 Well, assuming that the HCD driver doesn't support wakeup signaling,
 it would be good to have a way to indicate the lack of support for
 autosuspend to the USB core so as to avoid the user-visible breakage.
 
 Do we have any means for that?

We could create a flag for it.  Right now there's no way to indicate
it; the USB stack assumes all host controller drivers fully support
wakeup signalling.

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


[PATCH] USB: cp210x: add ID for RUGGEDCOM USB Serial Console

2015-01-21 Thread Lennart Sorensen
Added the USB serial console device ID for Siemens Ruggedcom devices
which have a USB port for their serial console.

Signed-off-by: Len Sorensen lsore...@csclub.uwaterloo.ca
---
 drivers/usb/serial/cp210x.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index f4c56fc..f34e6ba 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -55,6 +55,7 @@ static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 
1000 */
{ USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, 
M5300 series, M7100 series */
{ USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless 
smartcard reader */
+   { USB_DEVICE(0x0908, 0x01FF) }, /* RUGGEDCOM USB Serial Console */
{ USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC 
Device */
{ USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher 
Acceptor */
{ USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
-- 
1.7.10.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: Boot regression on Versatile Express TC2 after commit b2b49ccbdd

2015-01-21 Thread Rafael J. Wysocki
On Wednesday, January 21, 2015 04:36:35 PM Alan Stern wrote:
 On Wed, 21 Jan 2015, Rafael J. Wysocki wrote:
 
 If nothing happens, there are two possibilities: The hub doesn't 
 support wakeup signalling, or the isp1760-hcd driver doesn't support 
 it.  To tell the truth, it wouldn't be surprising if the second turns 
 out to be the case.

How can this be determined?

According to /proc/interrupts, isp1760-hcd:usb1 no longer receive any 
interrupts.  Wether or not it could is something I don't know.
   
   I don't know either.  At this point, you have to ask a developer who is 
   familiar with the isp1760 hardware and driver.  Perhaps one of the 
   people on the CC: list can help.
   
   At least you are able to boot your system now with the command-line 
   option.  That's an improvement.
  
  Well, assuming that the HCD driver doesn't support wakeup signaling,
  it would be good to have a way to indicate the lack of support for
  autosuspend to the USB core so as to avoid the user-visible breakage.
  
  Do we have any means for that?
 
 We could create a flag for it.  Right now there's no way to indicate
 it; the USB stack assumes all host controller drivers fully support
 wakeup signalling.

Even if power.can_wakeup is not set for the controllers?

Rafael

--
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: Boot regression on Versatile Express TC2 after commit b2b49ccbdd

2015-01-21 Thread Rafael J. Wysocki
On Wednesday, January 21, 2015 05:05:36 PM Alan Stern wrote:
 On Wed, 21 Jan 2015, Rafael J. Wysocki wrote:
 
   Well, assuming that the HCD driver doesn't support wakeup signaling,
   it would be good to have a way to indicate the lack of support for
   autosuspend to the USB core so as to avoid the user-visible breakage.
   
   Do we have any means for that?
  
  For example, would it help to add
  
  device_set_wakeup_capable(hcd-self.controller, 0);
  
  somewhere at the beginning of isp1760_hc_setup()?
 
 Yes, we could use that instead of adding a new flag.
 
  For example, would it help to add
  
  device_set_wakeup_capable(hcd-self.controller, 0);
  
  somewhere at the beginning of isp1760_hc_setup()?
 
 At the moment it wouldn't help.  The problem isn't that we want to 
 avoid suspending the controller or its root hub; the problem is that we 
 want to avoid suspending a device plugged into the root hub if that 
 device needs to be enabled for wakeup.  This is because when the device 
 sends its wakeup signal, the controller won't receive it.

I understand that.

Well, OK, so there is the case when the controller is not suspended, but it
doesn't generate interrupts for wakeup signals from devices, which generally
is different from the case when the controller itself is suspended too that
requires it to be wakeup-capable for things to work.

An additional flag may still be better then.

Rafael

--
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 00/13] usb: second series of updates for dwc2 driver

2015-01-21 Thread Dinh Nguyen
On 01/21/2015 02:54 AM, Kaukab, Yousaf wrote:
 Hi John,
 
 -Original Message-
 From: Kaukab, Yousaf
 Sent: Thursday, January 15, 2015 6:09 PM
 To: linux-usb@vger.kernel.org; ba...@ti.com
 Cc: john.y...@synopsys.com; Herrero, Gregory; pa...@synopsys.com;
 r.bald...@samsung.com; dingu...@opensource.altera.com; Kaukab, Yousaf
 Subject: [PATCH 00/13] usb: second series of updates for dwc2 driver

 Hi,
 This patchset consists of some bug fixes, feature enhancements and cosmetic
 changes for the dwc2 driver. All the patches are verified on
 dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma enabled.
 Although basic testing without dma was also done.

 This is based on testing/next branch in Felipe's git.

 Thank you,

 Best regards,
 Yousaf

 Gregory Herrero (8):
   usb: dwc2: host: register hcd handle to the phy
   usb: dwc2: host: resume root hub on remote wakeup
   usb: dwc2: gadget: fix clear halt feature handling
   usb: dwc2: gadget: add TEST_MODE feature support
   usb: dwc2: gadget: fix a typo in comment
   usb: dwc2: gadget: add reset flag in init function
   usb: dwc2: gadget: don't modify pullup status during reset
   usb: dwc2: gadget: initialize controller in pullup callback

 Mian Yousaf Kaukab (5):
   usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks
   usb: dwc2: gadget: add unaligned buffers support
   usb: dwc2: gadget: fix debug message for zlp
   usb: dwc2: gadget: fix phy interface configuration
   usb: dwc2: gadget: replace constants with defines

  drivers/usb/dwc2/core.h   |  12 +-
  drivers/usb/dwc2/gadget.c | 358
 ++
  drivers/usb/dwc2/hcd.c|  43 --
  drivers/usb/dwc2/hw.h |   1 +
  4 files changed, 348 insertions(+), 66 deletions(-)

 
 Did you get a chance to review this patchset? Can you please ACK it if you 
 don't have any objections?
 
 BR,
 Yousaf
 

I have not had a chance to test this series on my v2.93a hardware, and
most likely won't be able to get to it until early next week.

Just a note in case you wanted additional testing.

Dinh
--
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 2/9] power/reset: brcmstb: Use the DT compatible string to indicate bit positions

2015-01-21 Thread Sebastian Reichel
Hi,

On Tue, Nov 25, 2014 at 04:49:47PM -0800, Kevin Cernekee wrote:
 Some of the older chips used different bits to arm and trigger the reset.
 Add the infrastructure needed to specify this through the compatible
 string.

Thanks, applied.

-- Sebastian


signature.asc
Description: Digital signature


Re: [PATCH 1/9] power/reset: brcmstb: Make the driver buildable on MIPS

2015-01-21 Thread Sebastian Reichel
Hi,

On Tue, Nov 25, 2014 at 04:49:46PM -0800, Kevin Cernekee wrote:
 Now that the driver doesn't use any ARM-specific headers, it is safe
 to build on MIPS or with COMPILE_TEST.

Thanks, applied.

-- Sebastian


signature.asc
Description: Digital signature


Re: [PATCH 3/4] mfd: dln2: add support for ACPI

2015-01-21 Thread Rafael J. Wysocki
On Tuesday, December 16, 2014 06:12:32 PM Octavian Purdila wrote:
 This patch adds support to load a custom ACPI table that describes
 devices connected via the DLN2 USB to I2C/SPI/GPIO bridge.
 
 The ACPI table can be loaded either externally (from QEMU or with
 CONFIG_ACPI_CUSTOM_DSDT) or it can be loaded as firmware file with the
 name dln2.aml. The driver looks for an ACPI device entry with _HID set
 to DLN2 and makes it the ACPI companion for DLN2 USB
 sub-drivers.
 
 Signed-off-by: Octavian Purdila octavian.purd...@intel.com
 ---
  Documentation/acpi/dln2-acpi.txt |  62 ++
  drivers/mfd/dln2.c   | 134 
 +++
  2 files changed, 196 insertions(+)
  create mode 100644 Documentation/acpi/dln2-acpi.txt
 
 diff --git a/Documentation/acpi/dln2-acpi.txt 
 b/Documentation/acpi/dln2-acpi.txt
 new file mode 100644
 index 000..d76605f
 --- /dev/null
 +++ b/Documentation/acpi/dln2-acpi.txt
 @@ -0,0 +1,62 @@
 +Diolan DLN2 custom APCI table
 +
 +The Diolan DLN2 is an USB to I2C/SPI/GPIO bridge and as such it can be used 
 to
 +connect to various I2C or SPI devices. Because these busses lack an 
 enumeration
 +protocol, the driver obtains various information about the device (such as 
 I2C
 +address and GPIO pins) from either ACPI or device tree.
 +
 +To allow enumerating devices and their properties via ACPI, the Diolan
 +driver looks for an ACPI tree with the root _HID set to DLN2. If
 +it finds such an ACPI object it will set the ACPI companion to the
 +DLN2 MFD driver and from their it will be propagated to all its
 +sub-devices (I2C, GPIO, SPI).
 +
 +The user can either load the custom DSDT table with three methods:

s/DSDT/ACPI/

 +
 +1. Via QEMU (see -acpitable)
 +
 +2. Via the CONFIG_ACPI_CUSTOM_DSDT kernel config option (see
 +Documentation/acpi/dsdt-override.txt)
 +
 +3. By placing the custom DSDT in the firmware paths in a file name
 +dln2.aml.

Surely SSDT?

 +
 +Here is an example ACPI table that enumerates a BMC150 accelerometer
 +and defines its I2C address and GPIO pin used as an interrupt source:
 +
 +DefinitionBlock (ssdt.aml, SSDT, 1, INTEL , CpuDptf, 0x0003)
 +{
 + Device (DLN0)
 + {
 + Name (_ADR, Zero)
 + Name (_HID, DLN2000)
 +
 + Device (STAC)
 + {
 + Name (_ADR, Zero)
 + Name (_HID, BMC150A)
 + Name (_CID, INTACCL)
 + Name (_UID, One)
 +
 + Method (_CRS, 0, Serialized)
 + {
 + Name (RBUF, ResourceTemplate ()
 + {
 + I2cSerialBus (0x0010, 
 ControllerInitiated, 0x00061A80,
 +   AddressingMode7Bit, 
 \\DLN0,
 +   0x00, ResourceConsumer, ,)
 +
 + GpioInt (Level, ActiveHigh, Exclusive, 
 PullDown, 0x,
 +  \\DLN0, 0x00, 
 ResourceConsumer, , )
 + { // Pin list
 + 0
 + }
 + })
 + Return (RBUF)
 +}
 + }
 + }
 +}
 +
 +The resources defined in the devices under the DLN0 are those
 +supported by the I2C, GPIO and SPI sub-systems.
 diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
 index f9c4a0b..93f6d1d 100644
 --- a/drivers/mfd/dln2.c
 +++ b/drivers/mfd/dln2.c
 @@ -23,6 +23,8 @@
  #include linux/mfd/core.h
  #include linux/mfd/dln2.h
  #include linux/rculist.h
 +#include linux/acpi.h
 +#include linux/firmware.h
  

OK, so correct me if I'm wrong.

When the (USB) dnl2 device is probed, it is supposed to find an ACPI companion
for itself and if it's not there, the driver will try to load a custom SSDT from
a firmware blob in the hope that the companion will be there?

So if I'm not wrong, why is this not broken?

It is not sufficient to call ACPI_COMPANION_SET(dev, ai-dev) to set the 
device's
companion.  acpi_bind_one() needs to be run in addition to that, but 
acpi_bind_one()
is not to be called from drivers.  It is called by the core automatically during
device registration and ACPI_COMPANION_SET() is to be used *before* that, not 
after.

So if I'm not missing anything, the design here is entirely backwards and we
need to talk about how to implement it correctly at the design level in the
first place.

And no, Let's come up with a patch that sort of works, throw it at the 
maintainers
and see what happens is not an acceptable approach, sorry.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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  

Re: [PATCH 3/9] power/reset: brcmstb: Add support for old 65nm chips

2015-01-21 Thread Sebastian Reichel
Hi,

On Tue, Nov 25, 2014 at 04:49:48PM -0800, Kevin Cernekee wrote:
 The register bit fields are a little different, so add an entry and a
 compatible string to accommodate them.

Thanks, applied.

-- Sebastian


signature.asc
Description: Digital signature


RE: [PATCH v1 00/13] usb: second series of updates for dwc2 driver

2015-01-21 Thread John Youn
  From: Mian Yousaf Kaukab [mailto:yousaf.kau...@intel.com]
  Sent: Wednesday, January 21, 2015 6:37 AM
 
  Hi,
  This patchset consists of some bug fixes, feature enhancements and
  cosmetic changes for the dwc2 driver. All the patches are verified on
  dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma
  enabled. Although basic testing without dma was also done.
 
  This is based on testing/next branch in Felipe's git.
 
  Removed Paul Zimmerman from CC as his Synopsys address is not valid
  any longer.
 
  Thank you,
 
  Best regards,
  Yousaf
 
  History:
  v1:
   - Fixed comments from Sergei Shtylyov and Robert Baldyga
 
  Gregory Herrero (8):
usb: dwc2: host: register hcd handle to the phy
usb: dwc2: host: resume root hub on remote wakeup
usb: dwc2: gadget: fix clear halt feature handling
usb: dwc2: gadget: add TEST_MODE feature support
usb: dwc2: gadget: fix a typo in comment
usb: dwc2: gadget: add reset flag in init function
usb: dwc2: gadget: don't modify pullup status during reset
usb: dwc2: gadget: initialize controller in pullup callback
 
  Mian Yousaf Kaukab (5):
usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks
usb: dwc2: gadget: add unaligned buffers support
usb: dwc2: gadget: fix debug message for zlp
usb: dwc2: gadget: fix phy interface configuration
usb: dwc2: gadget: replace constants with defines
 
   drivers/usb/dwc2/core.h   |  12 +-
   drivers/usb/dwc2/gadget.c | 359
  ++
   drivers/usb/dwc2/hcd.c|  43 --
   drivers/usb/dwc2/hw.h |   1 +
   4 files changed, 349 insertions(+), 66 deletions(-)
 
  --
  1.9.1
 
 
 Hi Yousaf,
 
 I'm working on testing this series now on our platform. Please give me a
 couple days as I am still getting up to speed.
 
 Regards,
 John
 


Robert, Dinh,

If you could provide a tested-by for this series, that would be appreciated as 
well.

Thanks,
John


--
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 v1 00/13] usb: second series of updates for dwc2 driver

2015-01-21 Thread John Youn
 From: Mian Yousaf Kaukab [mailto:yousaf.kau...@intel.com]
 Sent: Wednesday, January 21, 2015 6:37 AM
 
 Hi,
 This patchset consists of some bug fixes, feature enhancements and
 cosmetic changes for the dwc2 driver. All the patches are verified on
 dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma
 enabled. Although basic testing without dma was also done.
 
 This is based on testing/next branch in Felipe's git.
 
 Removed Paul Zimmerman from CC as his Synopsys address is not valid
 any longer.
 
 Thank you,
 
 Best regards,
 Yousaf
 
 History:
 v1:
  - Fixed comments from Sergei Shtylyov and Robert Baldyga
 
 Gregory Herrero (8):
   usb: dwc2: host: register hcd handle to the phy
   usb: dwc2: host: resume root hub on remote wakeup
   usb: dwc2: gadget: fix clear halt feature handling
   usb: dwc2: gadget: add TEST_MODE feature support
   usb: dwc2: gadget: fix a typo in comment
   usb: dwc2: gadget: add reset flag in init function
   usb: dwc2: gadget: don't modify pullup status during reset
   usb: dwc2: gadget: initialize controller in pullup callback
 
 Mian Yousaf Kaukab (5):
   usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks
   usb: dwc2: gadget: add unaligned buffers support
   usb: dwc2: gadget: fix debug message for zlp
   usb: dwc2: gadget: fix phy interface configuration
   usb: dwc2: gadget: replace constants with defines
 
  drivers/usb/dwc2/core.h   |  12 +-
  drivers/usb/dwc2/gadget.c | 359
 ++
  drivers/usb/dwc2/hcd.c|  43 --
  drivers/usb/dwc2/hw.h |   1 +
  4 files changed, 349 insertions(+), 66 deletions(-)
 
 --
 1.9.1


Hi Yousaf,

I'm working on testing this series now on our platform. Please give me a couple 
days as I am still getting up to speed.

Regards,
John


--
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/4] usb: serial: implement function for F81232

2015-01-21 Thread Peter Hung

Hello,

I'll do it later depend on this series patchs to be accpeted or rejected.

Thanks for your advice

One Thousand Gnomes 於 2015/1/21 下午 10:41 寫道:



+   if (cflag  PARENB) {
+   if (cflag  PARODD)
+   new_lcr |= UART_LCR_PARITY; /* odd */
+   else
+   new_lcr |= SERIAL_EVEN_PARITY; /* even */
+   }


If you don't support mark/space also clear CMSPAR in the passed termios


-   if (old_termios)
-   tty_termios_copy_hw(tty-termios, old_termios);


Also when you set the baud rate compute the resulting actual baud rate
you generated and set it with

/* Don't rewrite B0 */
if (tty_termios_baud_rate(termios))
tty_termios_encode_baud_rate(termios, baud, baud);

so that the application gets told the baud rate it actually got if it
isn't close to the one they requested.

Alan


--
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 0/2] usb: renesas_usbhs: add support for requesting DT DMA

2015-01-21 Thread Kuninori Morimoto

Hi shimoda-san

 This patch series is based on Felipe's usb.git / testing/next branch.
 (commit id = 05cf6e00b8ff2b80c8b2d1e69f07cdd6c830efe0)
 
 Yoshihiro Shimoda (2):
   usb: renesas_usbhs: add usbhsf_dma_init_pdev() function
   usb: renesas_usbhs: add support for requesting DT DMA
 
  .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
  drivers/usb/renesas_usbhs/fifo.c   |   21 
 +---
  2 files changed, 20 insertions(+), 3 deletions(-)

I guess we can (should ?) use dma_request_slave_channel_compat()
instead of dma_request_slave_channel_reason().
And, we can use shdma_chan_filter instead of original usbhsf_dma_filter()

--
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


Bad DMA for ehci_qtd after suspend/resume cycle on Exynos7 (64-bit)

2015-01-21 Thread Vivek Gautam

Hi all,


While working on our test board with Exynos7 SoC, we see that across
suspend/resume (Suspend to RAM) the EHCI can't resume the devices connected
to HSIC phy properly.
We have been using 3.16 kernel for our development, but on the ehci-exynos 
driver
side there isn't any delta that we have added, and the driver is pretty much 
in same shape

as in 3.19

We have a HSIC hub connected to the HSIC phy interface on the controller
which gets enumerated during boot up, and the devices connected across this
hub also get enumerated completely.
But once we suspend the system, after resume the hub gets disconnected from
the bus and we see **bad dma** error from dma_pool_free for ehci_qtd.

Below is a short log of the resume.

--
[   11.231907] Resume caused by wakeup_stat 0x8001
[   11.232926] PM: noirq resume of devices complete after 0.949 msecs
[   11.239387] PM: early resume of devices complete after 1.[   11.244699]
..
..
[   11.262665] usb usb1: root hub lost power or was reset
[   11.324501] usb usb2: root hub lost power or was reset
[   11.328747] wake disabled for irq 5
[   11.337449] usb usb3: root hub lost power or was reset
[   11.342472] usb usb4: root hub lost power or was reset
[   11.360866] wake disabled for irq 6
[   11.540541] PM: resume of devices complete after 296.332 msecs
[   11.545645] Restarting tasks ...
[   11.549009] usb 1-2: USB disconnect, device number 2
[   11.554208] done.
[   11.555727] exynos-ehci 1551.usb: dma_pool_free ehci_qtd, 
ff8000125120/b92212876c62 (bad dma)
[   11.564906] exynos-ehci 1551.usb: dma_pool_free ehci_qtd, 
ff8000125060/f2a20ae152806402 (bad dma)

--

The only difference between the controller's register dumps *before suspend* 
and *after resume*

is:

Before suspend
--
USBCMD :  0x00010015
USBSTS: 0x4008

After Resume

USBCMD :  0x00010005
USBSTS: 0x0008

so, we see the PeriodicScheduleEnable gets disabled, and the same is 
reflected from USBSTS register.


The HCCAP registers are:
HCCPBASE:   0x0110
HCSPARAMS:   0x1212
HCCPARAMS:   0xA026

Any pointers for debugging this would be very much appreciated.


Best Regards
Vivek 


--
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 v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY

2015-01-21 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 21 January 2015 03:36 PM, Yunzhi Li wrote:
 Hi Kishon :
 Hi,

 On Friday 12 December 2014 08:37 PM, Yunzhi Li wrote:
 This patch to add a generic PHY driver for ROCKCHIP usb PHYs,
 currently this driver can support RK3288. The RK3288 SoC have
 three independent USB PHY IPs which are all configured through a
 set of registers located in the GRF (general register files)
 module.

 Signed-off-by: Yunzhi Li l...@rock-chips.com

 ---

 Changes in v7:
 - Accept Kishon's comments to use phandle args to find a phy
struct directly and get rid of using a custom of_xlate
function.

 Changes in v6:
 - Rename SIDDQ_MSK to SIDDQ_WRITE_ENA.

 Changes in v5: None
 Changes in v4:
 - Get number of PHYs from device tree.
 - Model each PHY as subnode of the phy provider node.

 Changes in v3:
 - Use BIT macro instead of bit shift ops.
 - Rename the config entry to PHY_ROCKCHIP_USB.

   drivers/phy/Kconfig|   7 ++
   drivers/phy/Makefile   |   1 +
   drivers/phy/phy-rockchip-usb.c | 158
 +
   3 files changed, 166 insertions(+)
   create mode 100644 drivers/phy/phy-rockchip-usb.c

 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index ccad880..b24500a 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
   depends on OF
   select GENERIC_PHY
   +config PHY_ROCKCHIP_USB
 +tristate Rockchip USB2 PHY Driver
 +depends on ARCH_ROCKCHIP  OF
 +select GENERIC_PHY
 +help
 +  Enable this to support the Rockchip USB 2.0 PHY.
 +
   config PHY_ST_SPEAR1310_MIPHY
   tristate ST SPEAR1310-MIPHY driver
   select GENERIC_PHY
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index aa74f96..48bf5a1 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)+=
 phy-exynos5250-usb2.o
   phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)+= phy-s5pv210-usb2.o
   obj-$(CONFIG_PHY_EXYNOS5_USBDRD)+= phy-exynos5-usbdrd.o
   obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)+= phy-qcom-apq8064-sata.o
 +obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
   obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)+= phy-qcom-ipq806x-sata.o
   obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY)+= phy-spear1310-miphy.o
   obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)+= phy-spear1340-miphy.o
 diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
 new file mode 100644
 index 000..22011c3
 --- /dev/null
 +++ b/drivers/phy/phy-rockchip-usb.c
 @@ -0,0 +1,158 @@
 +/*
 + * Rockchip usb PHY driver
 + *
 + * Copyright (C) 2014 Yunzhi Li l...@rock-chips.com
 + * Copyright (C) 2014 ROCKCHIP, Inc.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/clk.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/mutex.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/regulator/consumer.h
 +#include linux/reset.h
 +#include linux/regmap.h
 +#include linux/mfd/syscon.h
 +
 +/*
 + * The higher 16-bit of this register is used for write protection
 + * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
 + */
 +#define SIDDQ_WRITE_ENABIT(29)
 +#define SIDDQ_ONBIT(13)
 +#define SIDDQ_OFF(0  13)
 +
 +struct rockchip_usb_phy {
 +unsigned intreg_offset;
 +struct regmap*reg_base;
 +struct clk*clk;
 +struct phy*phy;
 +};
 +
 +static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
 +   bool siddq)
 +{
 +return regmap_write(phy-reg_base, phy-reg_offset,
 +SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
 +}
 +
 +static int rockchip_usb_phy_power_off(struct phy *_phy)
 +{
 +struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
 +int ret = 0;
 +
 +/* Power down usb phy analog blocks by set siddq 1 */
 +ret = rockchip_usb_phy_power(phy, 1);
 +if (ret)
 +return ret;
 +
 +clk_disable_unprepare(phy-clk);
 +if (ret)
 +return ret;
 +
 +return 0;
 +}
 +
 +static int rockchip_usb_phy_power_on(struct phy *_phy)
 +{
 +struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
 +int ret = 0;
 +
 +ret = clk_prepare_enable(phy-clk);
 +if (ret)
 +return ret;
 +
 +/* Power up usb phy analog blocks by set siddq 0 */
 +ret = rockchip_usb_phy_power(phy, 0);
 +if (ret)
 +return ret;
 +
 +return 0;
 

[PATCH v2 2/4] usb: serial: fix callback wrong process for F81232

2015-01-21 Thread Peter Hung
Our int callback will return IIR, not LSR, and bulk-in callback will return
[LSR+Data][LSR+Data], so need to rewrite it

Signed-off-by: Peter Hung hpeter+linux_ker...@gmail.com
---
 drivers/usb/serial/f81232.c | 82 +
 1 file changed, 39 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index efd45a7..b372975 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -230,17 +230,33 @@ static inline int update_mctrl(struct f81232_private 
*port_priv,
 
return status;
 }
-static void f81232_update_line_status(struct usb_serial_port *port,
+
+static void f81232_iir_status(struct usb_serial_port *port,
  unsigned char *data,
  unsigned int actual_length)
 {
-   /*
-* FIXME: Update port-icount, and call
-*
-*  wake_up_interruptible(port-port.delta_msr_wait);
-*
-*on MSR changes.
-*/
+   struct f81232_private *priv = usb_get_serial_port_data(port);
+   struct usb_device *dev = port-serial-dev;
+
+   if (!actual_length)
+   return;
+
+   switch (data[0]  0x07) {
+   case 0x00: /* msr change */
+   dev_dbg(dev-dev, IIR: MSR Change: %x\n, data[0]);
+   schedule_work(priv-int_worker);
+   break;
+
+   case 0x02: /* tx-empty */
+   break;
+
+   case 0x04: /* rx data available */
+   break;
+
+   case 0x06: /* lsr change */
+   dev_dbg(dev-dev, IIR: IIR: LSR Change: %x\n, data[0]);
+   break;
+   }
 }
 
 static void f81232_read_int_callback(struct urb *urb)
@@ -271,7 +287,7 @@ static void f81232_read_int_callback(struct urb *urb)
usb_serial_debug_data(port-dev, __func__,
  urb-actual_length, urb-transfer_buffer);
 
-   f81232_update_line_status(port, data, actual_length);
+   f81232_iir_status(port, data, actual_length);
 
 exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -284,47 +300,30 @@ exit:
 static void f81232_process_read_urb(struct urb *urb)
 {
struct usb_serial_port *port = urb-context;
-   struct f81232_private *priv = usb_get_serial_port_data(port);
unsigned char *data = urb-transfer_buffer;
char tty_flag = TTY_NORMAL;
-   unsigned long flags;
-   u8 line_status;
+   u8 line_status = 0;
int i;
 
-   /* update line status */
-   spin_lock_irqsave(priv-lock, flags);
-   line_status = priv-line_status;
-   priv-line_status = ~UART_STATE_TRANSIENT_MASK;
-   spin_unlock_irqrestore(priv-lock, flags);
 
if (!urb-actual_length)
return;
 
-   /* break takes precedence over parity, */
-   /* which takes precedence over framing errors */
-   if (line_status  UART_BREAK_ERROR)
-   tty_flag = TTY_BREAK;
-   else if (line_status  UART_PARITY_ERROR)
-   tty_flag = TTY_PARITY;
-   else if (line_status  UART_FRAME_ERROR)
-   tty_flag = TTY_FRAME;
-   dev_dbg(port-dev, %s - tty_flag = %d\n, __func__, tty_flag);
-
-   /* overrun is special, not associated with a char */
-   if (line_status  UART_OVERRUN_ERROR)
-   tty_insert_flip_char(port-port, 0, TTY_OVERRUN);
-
-   if (port-port.console  port-sysrq) {
-   for (i = 0; i  urb-actual_length; ++i)
-   if (!usb_serial_handle_sysrq_char(port, data[i]))
-   tty_insert_flip_char(port-port, data[i],
-   tty_flag);
-   } else {
-   tty_insert_flip_string_fixed_flag(port-port, data, tty_flag,
-   urb-actual_length);
+   if (urb-actual_length = 2) {
+
+   for (i = 0 ; i  urb-actual_length ; i += 2) {
+   line_status |= data[i+0];
+   tty_insert_flip_string_fixed_flag(port-port,
+   data[i+1], tty_flag, 1);
+   }
+
+   if (unlikely(line_status  UART_OVERRUN_ERROR))
+   tty_insert_flip_char(port-port, 0, TTY_OVERRUN);
+
+   tty_flip_buffer_push(port-port);
}
 
-   tty_flip_buffer_push(port-port);
+
 }
 
 static int set_control_lines(struct usb_device *dev, u8 value)
@@ -456,9 +455,6 @@ static int f81232_ioctl(struct tty_struct *tty,
return -ENOIOCTLCMD;
 }
 
-
-
-
 static void f81232_int_work_wq(struct work_struct *work)
 {
struct f81232_private *priv =
-- 
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 v2 4/4] usb: serial: remove unused function for F81232

2015-01-21 Thread Peter Hung
remove unused function set_line_control

Signed-off-by: Peter Hung hpeter+linux_ker...@gmail.com
---
 drivers/usb/serial/f81232.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 9a54f56..11a236b 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -323,13 +323,6 @@ static void f81232_process_read_urb(struct urb *urb)
tty_flip_buffer_push(port-port);
}
 
-
-}
-
-static int set_control_lines(struct usb_device *dev, u8 value)
-{
-   /* FIXME - Stubbed out for now */
-   return 0;
 }
 
 static void f81232_break_ctl(struct tty_struct *tty, int break_state)
-- 
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 v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY

2015-01-21 Thread Yunzhi Li

Hi Kishon :


Hi,

On Wednesday 21 January 2015 03:36 PM, Yunzhi Li wrote:

Hi Kishon :

Hi,

On Friday 12 December 2014 08:37 PM, Yunzhi Li wrote:

This patch to add a generic PHY driver for ROCKCHIP usb PHYs,
currently this driver can support RK3288. The RK3288 SoC have
three independent USB PHY IPs which are all configured through a
set of registers located in the GRF (general register files)
module.

Signed-off-by: Yunzhi Li l...@rock-chips.com

---

Changes in v7:
- Accept Kishon's comments to use phandle args to find a phy
struct directly and get rid of using a custom of_xlate
function.

Changes in v6:
- Rename SIDDQ_MSK to SIDDQ_WRITE_ENA.

Changes in v5: None
Changes in v4:
- Get number of PHYs from device tree.
- Model each PHY as subnode of the phy provider node.

Changes in v3:
- Use BIT macro instead of bit shift ops.
- Rename the config entry to PHY_ROCKCHIP_USB.

   drivers/phy/Kconfig|   7 ++
   drivers/phy/Makefile   |   1 +
   drivers/phy/phy-rockchip-usb.c | 158
+
   3 files changed, 166 insertions(+)
   create mode 100644 drivers/phy/phy-rockchip-usb.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index ccad880..b24500a 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
   depends on OF
   select GENERIC_PHY
   +config PHY_ROCKCHIP_USB
+tristate Rockchip USB2 PHY Driver
+depends on ARCH_ROCKCHIP  OF
+select GENERIC_PHY
+help
+  Enable this to support the Rockchip USB 2.0 PHY.
+
   config PHY_ST_SPEAR1310_MIPHY
   tristate ST SPEAR1310-MIPHY driver
   select GENERIC_PHY
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index aa74f96..48bf5a1 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)+=
phy-exynos5250-usb2.o
   phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)+= phy-s5pv210-usb2.o
   obj-$(CONFIG_PHY_EXYNOS5_USBDRD)+= phy-exynos5-usbdrd.o
   obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)+= phy-qcom-apq8064-sata.o
+obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
   obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)+= phy-qcom-ipq806x-sata.o
   obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY)+= phy-spear1310-miphy.o
   obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)+= phy-spear1340-miphy.o
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
new file mode 100644
index 000..22011c3
--- /dev/null
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -0,0 +1,158 @@
+/*
+ * Rockchip usb PHY driver
+ *
+ * Copyright (C) 2014 Yunzhi Li l...@rock-chips.com
+ * Copyright (C) 2014 ROCKCHIP, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/regulator/consumer.h
+#include linux/reset.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
+
+/*
+ * The higher 16-bit of this register is used for write protection
+ * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
+ */
+#define SIDDQ_WRITE_ENABIT(29)
+#define SIDDQ_ONBIT(13)
+#define SIDDQ_OFF(0  13)
+
+struct rockchip_usb_phy {
+unsigned intreg_offset;
+struct regmap*reg_base;
+struct clk*clk;
+struct phy*phy;
+};
+
+static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
+   bool siddq)
+{
+return regmap_write(phy-reg_base, phy-reg_offset,
+SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
+}
+
+static int rockchip_usb_phy_power_off(struct phy *_phy)
+{
+struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
+int ret = 0;
+
+/* Power down usb phy analog blocks by set siddq 1 */
+ret = rockchip_usb_phy_power(phy, 1);
+if (ret)
+return ret;
+
+clk_disable_unprepare(phy-clk);
+if (ret)
+return ret;
+
+return 0;
+}
+
+static int rockchip_usb_phy_power_on(struct phy *_phy)
+{
+struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
+int ret = 0;
+
+ret = clk_prepare_enable(phy-clk);
+if (ret)
+return ret;
+
+/* Power up usb phy analog blocks by set siddq 0 */
+ret = rockchip_usb_phy_power(phy, 0);
+if (ret)
+return ret;
+
+return 0;
+}
+
+static struct phy_ops ops = {
+.power_on= rockchip_usb_phy_power_on,
+.power_off= 

Re: [PATCH] mmc: vub300: remove unreachable return value handling

2015-01-21 Thread Ulf Hansson
On 18 January 2015 at 02:51, Nicholas Mc Guire der.h...@hofr.at wrote:
 Signed-off-by: Nicholas Mc Guire der.h...@hofr.at

Thanks! Applied for next.

Kind regards
Uffe

 ---

 The return value of wait_for_completion_timeout is unsigned long,
 as it is used here for wait_for_completion_timeout only the type
 of commretval was changed to unsigned long.

 As wait_for_completion_timeout does not return negative values
 the commretval  0 case is not reachable and can be removed.

 This was only compile-tested for x86_64_defconfig + CONFIG_MMC=m,
 CONFIG_MMC_VUB300=m

 Patch is against 3.19.0-rc4 -next-20150116

  drivers/mmc/host/vub300.c |4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

 diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
 index 4262296..fbabbb8 100644
 --- a/drivers/mmc/host/vub300.c
 +++ b/drivers/mmc/host/vub300.c
 @@ -659,7 +659,7 @@ static void __vub300_irqpoll_response(struct 
 vub300_mmc_host *vub300)
  static void __do_poll(struct vub300_mmc_host *vub300)
  {
 /* cmd_mutex is held by vub300_pollwork_thread */
 -   long commretval;
 +   unsigned long commretval;
 mod_timer(vub300-inactivity_timer, jiffies + HZ);
 init_completion(vub300-irqpoll_complete);
 send_irqpoll(vub300);
 @@ -671,8 +671,6 @@ static void __do_poll(struct vub300_mmc_host *vub300)
 vub300-usb_timed_out = 1;
 usb_kill_urb(vub300-command_out_urb);
 usb_kill_urb(vub300-command_res_urb);
 -   } else if (commretval  0) {
 -   vub300_queue_poll_work(vub300, 1);
 } else { /* commretval  0 */
 __vub300_irqpoll_response(vub300);
 }
 --
 1.7.10.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 v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY

2015-01-21 Thread Yunzhi Li

Hi Kishon :

Hi,

On Friday 12 December 2014 08:37 PM, Yunzhi Li wrote:

This patch to add a generic PHY driver for ROCKCHIP usb PHYs,
currently this driver can support RK3288. The RK3288 SoC have
three independent USB PHY IPs which are all configured through a
set of registers located in the GRF (general register files)
module.

Signed-off-by: Yunzhi Li l...@rock-chips.com

---

Changes in v7:
- Accept Kishon's comments to use phandle args to find a phy
   struct directly and get rid of using a custom of_xlate
   function.

Changes in v6:
- Rename SIDDQ_MSK to SIDDQ_WRITE_ENA.

Changes in v5: None
Changes in v4:
- Get number of PHYs from device tree.
- Model each PHY as subnode of the phy provider node.

Changes in v3:
- Use BIT macro instead of bit shift ops.
- Rename the config entry to PHY_ROCKCHIP_USB.

  drivers/phy/Kconfig|   7 ++
  drivers/phy/Makefile   |   1 +
  drivers/phy/phy-rockchip-usb.c | 158 +
  3 files changed, 166 insertions(+)
  create mode 100644 drivers/phy/phy-rockchip-usb.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index ccad880..b24500a 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
depends on OF
select GENERIC_PHY
  
+config PHY_ROCKCHIP_USB

+   tristate Rockchip USB2 PHY Driver
+   depends on ARCH_ROCKCHIP  OF
+   select GENERIC_PHY
+   help
+ Enable this to support the Rockchip USB 2.0 PHY.
+
  config PHY_ST_SPEAR1310_MIPHY
tristate ST SPEAR1310-MIPHY driver
select GENERIC_PHY
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index aa74f96..48bf5a1 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += 
phy-exynos5250-usb2.o
  phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)+= phy-s5pv210-usb2.o
  obj-$(CONFIG_PHY_EXYNOS5_USBDRD)  += phy-exynos5-usbdrd.o
  obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)   += phy-qcom-apq8064-sata.o
+obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
  obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)   += phy-qcom-ipq806x-sata.o
  obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY)  += phy-spear1310-miphy.o
  obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)  += phy-spear1340-miphy.o
diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
new file mode 100644
index 000..22011c3
--- /dev/null
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -0,0 +1,158 @@
+/*
+ * Rockchip usb PHY driver
+ *
+ * Copyright (C) 2014 Yunzhi Li l...@rock-chips.com
+ * Copyright (C) 2014 ROCKCHIP, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/clk.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/regulator/consumer.h
+#include linux/reset.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
+
+/*
+ * The higher 16-bit of this register is used for write protection
+ * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
+ */
+#define SIDDQ_WRITE_ENABIT(29)
+#define SIDDQ_ON   BIT(13)
+#define SIDDQ_OFF  (0  13)
+
+struct rockchip_usb_phy {
+   unsigned intreg_offset;
+   struct regmap   *reg_base;
+   struct clk  *clk;
+   struct phy  *phy;
+};
+
+static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
+  bool siddq)
+{
+   return regmap_write(phy-reg_base, phy-reg_offset,
+   SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
+}
+
+static int rockchip_usb_phy_power_off(struct phy *_phy)
+{
+   struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
+   int ret = 0;
+
+   /* Power down usb phy analog blocks by set siddq 1 */
+   ret = rockchip_usb_phy_power(phy, 1);
+   if (ret)
+   return ret;
+
+   clk_disable_unprepare(phy-clk);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static int rockchip_usb_phy_power_on(struct phy *_phy)
+{
+   struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
+   int ret = 0;
+
+   ret = clk_prepare_enable(phy-clk);
+   if (ret)
+   return ret;
+
+   /* Power up usb phy analog blocks by set siddq 0 */
+   ret = rockchip_usb_phy_power(phy, 0);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   

[PATCH v2 3/4] usb: serial: implement function for F81232

2015-01-21 Thread Peter Hung
This patch implement the following function:
set_termios, tiocmset, tiocmget, dtr_rts

Signed-off-by: Peter Hung hpeter+linux_ker...@gmail.com
---
 drivers/usb/serial/f81232.c | 103 
 1 file changed, 84 insertions(+), 19 deletions(-)
 mode change 100644 = 100755 drivers/usb/serial/f81232.c

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index b372975..9a54f56 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -346,27 +346,99 @@ static void f81232_break_ctl(struct tty_struct *tty, int 
break_state)
 static void f81232_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
 {
-   /* FIXME - Stubbed out for now */
+   u16 divisor;
+   u16 new_lcr = 0;
+   int status;
+   struct ktermios *termios = tty-termios;
+   struct usb_device *dev = port-serial-dev;
+   unsigned int cflag = termios-c_cflag;
 
-   /* Don't change anything if nothing has changed */
-   if (old_termios  !tty_termios_hw_change(tty-termios, old_termios))
-   return;
+   divisor = calc_baud_divisor(tty_get_baud_rate(tty));
+
+   status = f81232_set_register(dev, LINE_CONTROL_REGISTER,
+UART_LCR_DLAB); /* DLAB */
+
+   status = f81232_set_register(dev, RECEIVE_BUFFER_REGISTER,
+divisor  0x00ff); /* low */
+
+   status = f81232_set_register(dev, INTERRUPT_ENABLE_REGISTER,
+(divisor  0xff00)  8); /* high */
+
+   status = f81232_set_register(dev, LINE_CONTROL_REGISTER, 0x00);
+
+
+   if (cflag  PARENB) {
+   if (cflag  PARODD)
+   new_lcr |= UART_LCR_PARITY; /* odd */
+   else
+   new_lcr |= SERIAL_EVEN_PARITY; /* even */
+   }
+
+   if (cflag  CSTOPB)
+   new_lcr |= UART_LCR_STOP;
+   else
+   new_lcr = ~UART_LCR_STOP;
+
+   switch (cflag  CSIZE) {
+   case CS5:
+   new_lcr |= UART_LCR_WLEN5;
+   break;
+   case CS6:
+   new_lcr |= UART_LCR_WLEN6;
+   break;
+   case CS7:
+   new_lcr |= UART_LCR_WLEN7;
+   break;
+   default:
+   case CS8:
+   new_lcr |= UART_LCR_WLEN8;
+   break;
+   }
+
+   status |= f81232_set_register(dev, LINE_CONTROL_REGISTER, new_lcr);
+
+   status |= f81232_set_register(dev, FIFO_CONTROL_REGISTER,
+ 0x87); /* fifo, trigger8 */
+   status |= f81232_set_register(dev,
+ INTERRUPT_ENABLE_REGISTER, 0xf); /* IER */
+
+   if (status  0)
+   dev_err(port-dev, LINE_CONTROL_REGISTER set error: %d\n,
+   status);
 
-   /* Do the real work here... */
-   if (old_termios)
-   tty_termios_copy_hw(tty-termios, old_termios);
 }
 
 static int f81232_tiocmget(struct tty_struct *tty)
 {
-   /* FIXME - Stubbed out for now */
-   return 0;
+   int r;
+   struct usb_serial_port *port = tty-driver_data;
+   struct f81232_private *port_priv = usb_get_serial_port_data(port);
+   unsigned long flags;
+   u8 mcr, msr;
+
+   spin_lock_irqsave(port_priv-lock, flags);
+   mcr = port_priv-line_control;
+   msr = port_priv-line_status;
+   spin_unlock_irqrestore(port_priv-lock, flags);
+
+   r = (mcr  UART_MCR_DTR ? TIOCM_DTR : 0) |
+   (mcr  UART_MCR_RTS ? TIOCM_RTS : 0) |
+   (msr  UART_MSR_CTS ? TIOCM_CTS : 0) |
+   (msr  UART_MSR_DCD ? TIOCM_CAR : 0) |
+   (msr  UART_MSR_RI ? TIOCM_RI : 0) |
+   (msr  UART_MSR_DSR ? TIOCM_DSR : 0);
+
+   return r;
 }
 
 static int f81232_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
 {
-   /* FIXME - Stubbed out for now */
+   struct usb_serial_port *port = tty-driver_data;
+   struct f81232_private *port_priv =
+   usb_get_serial_port_data(port);
+
+   update_mctrl(port_priv, set, clear);
return 0;
 }
 
@@ -403,18 +475,11 @@ static void f81232_close(struct usb_serial_port *port)
 static void f81232_dtr_rts(struct usb_serial_port *port, int on)
 {
struct f81232_private *priv = usb_get_serial_port_data(port);
-   unsigned long flags;
-   u8 control;
 
-   spin_lock_irqsave(priv-lock, flags);
-   /* Change DTR and RTS */
if (on)
-   priv-line_control |= (CONTROL_DTR | CONTROL_RTS);
+   update_mctrl(priv, TIOCM_DTR | TIOCM_RTS, 0);
else
-   priv-line_control = ~(CONTROL_DTR | CONTROL_RTS);
-   control = priv-line_control;
-   spin_unlock_irqrestore(priv-lock, flags);
-   set_control_lines(port-serial-dev, control);
+   update_mctrl(priv, 0, TIOCM_DTR | TIOCM_RTS);
 }
 
 static int 

[PATCH v2 1/4] usb: serial: add register map for F81232

2015-01-21 Thread Peter Hung
Add register map for F81232. and add some function to operating this device.
etc. f81232_get_register()/f81232_set_register() to work with USB control
point. and worker f81232_int_work_wq() to read MSR when IIR acquired.

Signed-off-by: Peter Hung hpeter+linux_ker...@gmail.com
---
 drivers/usb/serial/f81232.c | 229 +---
 1 file changed, 214 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index c5dc233..efd45a7 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -23,6 +23,8 @@
 #include linux/uaccess.h
 #include linux/usb.h
 #include linux/usb/serial.h
+#include linux/serial_reg.h
+#include linux/version.h
 
 static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x1934, 0x0706) },
@@ -37,19 +39,197 @@ MODULE_DEVICE_TABLE(usb, id_table);
 #define UART_STATE_TRANSIENT_MASK  0x74
 #define UART_DCD   0x01
 #define UART_DSR   0x02
-#define UART_BREAK_ERROR   0x04
 #define UART_RING  0x08
-#define UART_FRAME_ERROR   0x10
-#define UART_PARITY_ERROR  0x20
-#define UART_OVERRUN_ERROR 0x40
 #define UART_CTS   0x80
 
+#define UART_BREAK_ERROR   0x10
+#define UART_FRAME_ERROR   0x08
+#define UART_PARITY_ERROR  0x04
+#define UART_OVERRUN_ERROR 0x02
+#define  SERIAL_EVEN_PARITY (UART_LCR_PARITY | UART_LCR_EPAR)
+
+#define REGISTER_REQUEST 0xA0
+#define GET_REGISTER 0xc0
+#define SET_REGISTER 0x40
+#define F81232_USB_TIMEOUT 1000
+#define F81232_USB_RETRY 20
+
+#define SERIAL_BASE_ADDRESS   (0x0120)
+#define RECEIVE_BUFFER_REGISTER(0x00 + SERIAL_BASE_ADDRESS)
+#define TRANSMIT_HOLDING_REGISTER  (0x00 + SERIAL_BASE_ADDRESS)
+#define INTERRUPT_ENABLE_REGISTER  (0x01 + SERIAL_BASE_ADDRESS)
+#define INTERRUPT_IDENT_REGISTER   (0x02 + SERIAL_BASE_ADDRESS)
+#define FIFO_CONTROL_REGISTER  (0x02 + SERIAL_BASE_ADDRESS)
+#define LINE_CONTROL_REGISTER  (0x03 + SERIAL_BASE_ADDRESS)
+#define MODEM_CONTROL_REGISTER (0x04 + SERIAL_BASE_ADDRESS)
+#define LINE_STATUS_REGISTER   (0x05 + SERIAL_BASE_ADDRESS)
+#define MODEM_STATUS_REGISTER  (0x06 + SERIAL_BASE_ADDRESS)
+
 struct f81232_private {
spinlock_t lock;
u8 line_control;
u8 line_status;
+
+   struct work_struct int_worker;
+   struct usb_serial_port *port;
 };
 
+static inline int calc_baud_divisor(u32 baudrate)
+{
+   u32 divisor, rem;
+
+   divisor = 115200L / baudrate;
+   rem = 115200L % baudrate;
+
+   /* Round to nearest divisor */
+   if (((rem * 2) = baudrate)  (baudrate != 110))
+   divisor++;
+
+   return divisor;
+}
+
+
+static inline int f81232_get_register(struct usb_device *dev,
+ u16 reg, u8 *data)
+{
+   int status;
+   int i = F81232_USB_RETRY;
+
+   while (i--) {
+   status = usb_control_msg(dev,
+usb_rcvctrlpipe(dev, 0),
+REGISTER_REQUEST,
+GET_REGISTER,
+reg,
+0,
+data,
+sizeof(*data),
+F81232_USB_TIMEOUT);
+
+   if (status  0) {
+   dev_dbg(dev-dev,
+   f81232_get_register status: %d, fail:%d\n,
+   status, i);
+   } else
+   break;
+   }
+
+   return status;
+}
+
+
+static inline int f81232_set_register(struct usb_device *dev,
+ u16 reg, u8 data)
+{
+   int status;
+   int i = F81232_USB_RETRY;
+
+   while (i--) {
+   status = usb_control_msg(dev,
+usb_sndctrlpipe(dev, 0),
+REGISTER_REQUEST,
+SET_REGISTER,
+reg,
+0,
+data,
+1,
+F81232_USB_TIMEOUT);
+
+   if (status  0)
+   dev_dbg(dev-dev,
+   f81232_set_register status: %d, fail:%d\n,
+   status, i);
+   else
+   break;
+   }
+
+   return status;
+}
+
+static void f81232_read_msr(struct f81232_private *priv)
+{
+   unsigned long flags;
+   u8 current_msr, old_msr;
+   struct usb_device *dev = priv-port-serial-dev;
+
+   f81232_get_register(dev, MODEM_STATUS_REGISTER, current_msr);
+
+   spin_lock_irqsave(priv-lock, flags);
+   old_msr = priv-line_status;
+   

Re: [PATCH 3/3] phy: ulpi: add driver for TI TUSB1210

2015-01-21 Thread Heikki Krogerus
Hi,

On Wed, Jan 21, 2015 at 11:17:49AM +0200, Heikki Krogerus wrote:
 On Tue, Jan 20, 2015 at 09:45:39AM -0600, Felipe Balbi wrote:
   diff --git a/drivers/phy/ulpi/tusb1210.c b/drivers/phy/ulpi/tusb1210.c
   new file mode 100644
   index 000..ac77f98
   --- /dev/null
   +++ b/drivers/phy/ulpi/tusb1210.c
  
  do you really need this extra ulpi directory ?
  
  I wonder if phy-tusb1210.c as a name would be enough.
 
 IMO grouping the ULPI PHY drivers and other ULPI bus code into
 separate folder from the start is the right thing to do.

A correction to this comment. I probable don't need this folder. Like
you said, phy-tusb1210.c should be enough..

snip

  In fact, we might decide to add an entire ULPI bus, eventually, though
  I'm still considering if there's any benefit to that.
 
 I don't think I understand this comment? ULPI bus is what I'm
 introducing in this set (the first patch in it)?

..I talked with Alex about this :). So I think the bus belongs under
drivers/usb/core/ instead of driver/phy/. It's not really tied to the
Generic PHY framework in any way, but ULPI is of course USB specific.


Cheers,

-- 
heikki
--
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 4/4] usb: serial: remove unused function for F81232

2015-01-21 Thread Sergei Shtylyov

Hello.

On 1/21/2015 1:30 PM, Peter Hung wrote:


remove unused function set_line_control


   The source says set_control_lines().


Signed-off-by: Peter Hung hpeter+linux_ker...@gmail.com
---
  drivers/usb/serial/f81232.c | 7 ---
  1 file changed, 7 deletions(-)



diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 9a54f56..11a236b 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -323,13 +323,6 @@ static void f81232_process_read_urb(struct urb *urb)
tty_flip_buffer_push(port-port);
}

-
-}
-
-static int set_control_lines(struct usb_device *dev, u8 value)
-{
-   /* FIXME - Stubbed out for now */
-   return 0;
  }

  static void f81232_break_ctl(struct tty_struct *tty, int break_state)


WBR, Sergei

--
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: core: hub: modify hub reset logic in hub driver

2015-01-21 Thread deepakdas . linux
From: Deepak Das deepakdas.li...@gmail.com

Currently if port power is turned off by user on hub port
using USBDEVFS then port power is turned back ON
by hub driver.
This commit modifies hub reset logic in hub_port_connect() to prevent
hub driver from turning back the port power ON if port is not owned
by kernel.

Signed-off-by: Deepak Das deepakdas.li...@gmail.com
---
 drivers/usb/core/hub.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b649fef..6f12de7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4657,9 +4657,13 @@ static void hub_port_connect(struct usb_hub *hub, int 
port1, u16 portstatus,
if (!(portstatus  USB_PORT_STAT_CONNECTION) ||
test_bit(port1, hub-removed_bits)) {
 
-   /* maybe switch power back on (e.g. root hub was reset) */
+   /*
+   *  maybe switch power back on (e.g. root hub was reset)
+   * but only if the port isn't owned by someone else.
+   */
if (hub_is_port_power_switchable(hub)
-!port_is_power_on(hub, portstatus))
+!port_is_power_on(hub, portstatus)
+!port_dev-port_owner)
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
 
if (portstatus  USB_PORT_STAT_ENABLE)
-- 
1.7.9.5

--
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/5] usb: dwc3: Add quirk for Synopsis device disconnection errata

2015-01-21 Thread Sneeker Yeh
Hi Felipe:

Thanks for reviewing these,

2015-01-19 22:50 GMT+08:00 Felipe Balbi ba...@ti.com:
 Hi,

 On Mon, Jan 19, 2015 at 03:56:47PM +0800, Sneeker Yeh wrote:
 Synopsis Designware USB3 IP earlier than v3.00a which is configured in 
 silicon
 with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to 
 prevent
 xhci host controller from dying when device is disconnected.

 Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state
 cannot be checked from software in runtime, it has to be enabled via platform
 data or device tree.

 Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |   17 +
  drivers/usb/dwc3/core.c|6 ++
  drivers/usb/dwc3/core.h|1 +
  drivers/usb/dwc3/host.c|4 
  drivers/usb/dwc3/platform_data.h   |1 +
  5 files changed, 29 insertions(+)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index cd7f045..1b78b29 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -37,6 +37,23 @@ Optional properties:
   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
   utmi_l1_suspend_n, false when asserts utmi_sleep_n
   - snps,hird-threshold: HIRD threshold
 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon 
 with
 + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a
 + specific quirk to prevent xhci host controller from
 + dying when usb device is disconnected from root hub.
 + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP
 + configuration whose state cannot be checked from
 + software in runtime, it has to be enabled via platform
 + data or device tree.
 +
 + xhci host dying symptom here is caused by that
 + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1
 + configuration makes IP auto-suspended after PORTCSC is
 + cleared when usb device detached, then an asynchronous
 + disconnection procedure might fail using endpoint
 + command that suspened IP won't have any response to.
 +
 + this issue is fixed when IP version = 3.00a.

  This is usually a subnode to DWC3 glue to which it is connected.

 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 25ddc39..fbceab1 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev)
   snps,tx_de_emphasis_quirk);
   of_property_read_u8(node, snps,tx_de_emphasis,
   tx_de_emphasis);
 +
 + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node,
 + snps,has_suspend_on_disconnect);
   } else if (pdata) {
   dwc-maximum_speed = pdata-maximum_speed;
   dwc-has_lpm_erratum = pdata-has_lpm_erratum;
 @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk;
   if (pdata-tx_de_emphasis)
   tx_de_emphasis = pdata-tx_de_emphasis;
 +
 + dwc-suspend_on_disconnect_quirk =
 + pdata-has_suspend_on_disconnect;
   }

   /* default to superspeed if no maximum_speed passed */
 diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
 index 8090249..d7458ff 100644
 --- a/drivers/usb/dwc3/core.h
 +++ b/drivers/usb/dwc3/core.h
 @@ -832,6 +832,7 @@ struct dwc3 {

   unsignedtx_de_emphasis_quirk:1;
   unsignedtx_de_emphasis:2;
 + unsignedsuspend_on_disconnect_quirk:1;

 you're missing the comment on the structure and these should be
 alphabetically sorted.

okay, I see, I'll change it like this:

--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -692,6 +692,9 @@ struct dwc3_scratchpad_array {
  * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
  * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround
  * @start_config_issued: true when StartConfig command has been issued
+ * @suspend_on_disconnect_quirk: set if core was configured with
+ * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. Note that there's
+ * now way for software to detect this in runtime.
  * @three_stage_setup: set if we perform a three phase setup
  * @disable_scramble_quirk: set if we enable the disable scramble quirk
  * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk
@@ -818,6 +821,7 @@ struct dwc3 {

[PATCH] usb: gadget: zero: fix format string warnings

2015-01-21 Thread Asaf Vertz
Fixed the following warnings (reported by cppcheck):
[drivers/usb/gadget/function/f_sourcesink.c:1217]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1261]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1305]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1349]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1393]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1437]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1476]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1520]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1564]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/usb/gadget/function/f_sourcesink.c:1608]: (warning) %d in format 
string (no. 1)
requires 'int' but the argument type is 'unsigned int'

Signed-off-by: Asaf Vertz asaf.ve...@tandemg.com
---
 drivers/usb/gadget/function/f_sourcesink.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/function/f_sourcesink.c 
b/drivers/usb/gadget/function/f_sourcesink.c
index 80be25b..e07c50c 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -1214,7 +1214,7 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts 
*opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-pattern);
+   result = sprintf(page, %u, opts-pattern);
mutex_unlock(opts-lock);
 
return result;
@@ -1258,7 +1258,7 @@ static ssize_t f_ss_opts_isoc_interval_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-isoc_interval);
+   result = sprintf(page, %u, opts-isoc_interval);
mutex_unlock(opts-lock);
 
return result;
@@ -1302,7 +1302,7 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-isoc_maxpacket);
+   result = sprintf(page, %u, opts-isoc_maxpacket);
mutex_unlock(opts-lock);
 
return result;
@@ -1346,7 +1346,7 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts 
*opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-isoc_mult);
+   result = sprintf(page, %u, opts-isoc_mult);
mutex_unlock(opts-lock);
 
return result;
@@ -1390,7 +1390,7 @@ static ssize_t f_ss_opts_isoc_maxburst_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-isoc_maxburst);
+   result = sprintf(page, %u, opts-isoc_maxburst);
mutex_unlock(opts-lock);
 
return result;
@@ -1434,7 +1434,7 @@ static ssize_t f_ss_opts_bulk_buflen_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-bulk_buflen);
+   result = sprintf(page, %u, opts-bulk_buflen);
mutex_unlock(opts-lock);
 
return result;
@@ -1473,7 +1473,7 @@ static ssize_t f_ss_opts_int_interval_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-int_interval);
+   result = sprintf(page, %u, opts-int_interval);
mutex_unlock(opts-lock);
 
return result;
@@ -1517,7 +1517,7 @@ static ssize_t f_ss_opts_int_maxpacket_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-int_maxpacket);
+   result = sprintf(page, %u, opts-int_maxpacket);
mutex_unlock(opts-lock);
 
return result;
@@ -1561,7 +1561,7 @@ static ssize_t f_ss_opts_int_mult_show(struct f_ss_opts 
*opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, opts-int_mult);
+   result = sprintf(page, %u, opts-int_mult);
mutex_unlock(opts-lock);
 
return result;
@@ -1605,7 +1605,7 @@ static ssize_t f_ss_opts_int_maxburst_show(struct 
f_ss_opts *opts, char *page)
int result;
 
mutex_lock(opts-lock);
-   result = sprintf(page, %d, 

Re: [PATCHv4 2/3] USB: gadget: atmel_usba_udc: Enable Vbus signal IRQ in UDC start instead of UDC probe

2015-01-21 Thread Boris Brezillon
Hi Sylvain,

On Tue, 20 Jan 2015 22:23:29 +0100
Sylvain Rochet sylvain.roc...@finsecur.com wrote:

 Vbus IRQ handler needs a started UDC driver to work because it uses
 udc-driver, which is set by the UDC start handler. The previous way
 chosen was to return from interrupt if udc-driver is NULL using a
 spinlock.
 
 This patch now request the Vbus signal IRQ in UDC start instead of UDC
 probe and release the IRQ in UDC stop before udc-driver is set back to
 NULL. This way we don't need the check about udc-driver in interruption
 handler, therefore we don't need the spinlock as well anymore.
 
 This was chosen against using set_irq_flags() to request a not auto
 enabled IRQ (IRQF_NOAUTOEN flag) because set_irq_flags() can't change
 just one flag, therefore it must be called with all flags, without
 respecting what the AIC previously did. Naively copying IRQ flags
 currently set by the AIC looked like error-prone if defaults flags
 change at some point in the future.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Suggested-by: Boris Brezillon boris.brezil...@free-electrons.com
 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 64 
 -
  1 file changed, 32 insertions(+), 32 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index e207d75..546da63 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1729,10 +1729,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
  
   spin_lock(udc-lock);
  
 - /* May happen if Vbus pin toggles during probe() */
 - if (!udc-driver)
 - goto out;
 -
   vbus = vbus_is_present(udc);
   if (vbus != udc-vbus_prev) {
   if (vbus) {
 @@ -1753,7 +1749,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
   udc-vbus_prev = vbus;
   }
  
 -out:
   spin_unlock(udc-lock);
  
   return IRQ_HANDLED;
 @@ -1767,23 +1762,27 @@ static int atmel_usba_start(struct usb_gadget *gadget,
   unsigned long flags;
  
   spin_lock_irqsave(udc-lock, flags);
 -
   udc-devstatus = 1  USB_DEVICE_SELF_POWERED;
   udc-driver = driver;
   spin_unlock_irqrestore(udc-lock, flags);
  
   ret = clk_prepare_enable(udc-pclk);
   if (ret)
 - return ret;
 + goto err_pclk;
   ret = clk_prepare_enable(udc-hclk);
 - if (ret) {
 - clk_disable_unprepare(udc-pclk);
 - return ret;
 - }
 + if (ret)
 + goto err_hclk;
  
   udc-vbus_prev = 0;
 - if (gpio_is_valid(udc-vbus_pin))
 - enable_irq(gpio_to_irq(udc-vbus_pin));
 + if (gpio_is_valid(udc-vbus_pin)) {
 + ret = request_irq(gpio_to_irq(udc-vbus_pin),
 + usba_vbus_irq, 0,
 + atmel_usba_udc, udc);
 + if (ret) {
 + udc-vbus_pin = -ENODEV;

I guess you're trying to protect against free_irq by changing the
vbus_pin value (making it an invalid gpio id), but I think you should
leave it unchanged for two reasons:
1) If the request_irq call temporary fails (an ENOMEM for example) then
you should be able to retry later, and modifying the vbus_pin value
will prevent that.
2) atmel_usba_stop will never be called if the atmel_usba_start failed,
so there's no need to protect against this free_irq.

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel 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


Re: [PATCH v7 2/5] phy: add a driver for the Rockchip SoC internal USB2.0 PHY

2015-01-21 Thread Kishon Vijay Abraham I
Hi,

On Friday 12 December 2014 08:37 PM, Yunzhi Li wrote:
 This patch to add a generic PHY driver for ROCKCHIP usb PHYs,
 currently this driver can support RK3288. The RK3288 SoC have
 three independent USB PHY IPs which are all configured through a
 set of registers located in the GRF (general register files)
 module.
 
 Signed-off-by: Yunzhi Li l...@rock-chips.com
 
 ---
 
 Changes in v7:
 - Accept Kishon's comments to use phandle args to find a phy
   struct directly and get rid of using a custom of_xlate
   function.
 
 Changes in v6:
 - Rename SIDDQ_MSK to SIDDQ_WRITE_ENA.
 
 Changes in v5: None
 Changes in v4:
 - Get number of PHYs from device tree.
 - Model each PHY as subnode of the phy provider node.
 
 Changes in v3:
 - Use BIT macro instead of bit shift ops.
 - Rename the config entry to PHY_ROCKCHIP_USB.
 
  drivers/phy/Kconfig|   7 ++
  drivers/phy/Makefile   |   1 +
  drivers/phy/phy-rockchip-usb.c | 158 
 +
  3 files changed, 166 insertions(+)
  create mode 100644 drivers/phy/phy-rockchip-usb.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index ccad880..b24500a 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -239,6 +239,13 @@ config PHY_QCOM_IPQ806X_SATA
   depends on OF
   select GENERIC_PHY
  
 +config PHY_ROCKCHIP_USB
 + tristate Rockchip USB2 PHY Driver
 + depends on ARCH_ROCKCHIP  OF
 + select GENERIC_PHY
 + help
 +   Enable this to support the Rockchip USB 2.0 PHY.
 +
  config PHY_ST_SPEAR1310_MIPHY
   tristate ST SPEAR1310-MIPHY driver
   select GENERIC_PHY
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index aa74f96..48bf5a1 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -28,6 +28,7 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)   += 
 phy-exynos5250-usb2.o
  phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)   += phy-s5pv210-usb2.o
  obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o
  obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)  += phy-qcom-apq8064-sata.o
 +obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
  obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)  += phy-qcom-ipq806x-sata.o
  obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
  obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
 diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
 new file mode 100644
 index 000..22011c3
 --- /dev/null
 +++ b/drivers/phy/phy-rockchip-usb.c
 @@ -0,0 +1,158 @@
 +/*
 + * Rockchip usb PHY driver
 + *
 + * Copyright (C) 2014 Yunzhi Li l...@rock-chips.com
 + * Copyright (C) 2014 ROCKCHIP, Inc.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/clk.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/mutex.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/regulator/consumer.h
 +#include linux/reset.h
 +#include linux/regmap.h
 +#include linux/mfd/syscon.h
 +
 +/*
 + * The higher 16-bit of this register is used for write protection
 + * only if BIT(13 + 16) set to 1 the BIT(13) can be written.
 + */
 +#define SIDDQ_WRITE_ENA  BIT(29)
 +#define SIDDQ_ON BIT(13)
 +#define SIDDQ_OFF(0  13)
 +
 +struct rockchip_usb_phy {
 + unsigned intreg_offset;
 + struct regmap   *reg_base;
 + struct clk  *clk;
 + struct phy  *phy;
 +};
 +
 +static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
 +bool siddq)
 +{
 + return regmap_write(phy-reg_base, phy-reg_offset,
 + SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF));
 +}
 +
 +static int rockchip_usb_phy_power_off(struct phy *_phy)
 +{
 + struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
 + int ret = 0;
 +
 + /* Power down usb phy analog blocks by set siddq 1 */
 + ret = rockchip_usb_phy_power(phy, 1);
 + if (ret)
 + return ret;
 +
 + clk_disable_unprepare(phy-clk);
 + if (ret)
 + return ret;
 +
 + return 0;
 +}
 +
 +static int rockchip_usb_phy_power_on(struct phy *_phy)
 +{
 + struct rockchip_usb_phy *phy = phy_get_drvdata(_phy);
 + int ret = 0;
 +
 + ret = clk_prepare_enable(phy-clk);
 + if (ret)
 + return ret;
 +
 + /* Power up usb phy analog blocks by set siddq 0 */
 + ret = rockchip_usb_phy_power(phy, 0);
 + if (ret)
 + return ret;
 +
 + return 0;
 

RE: [PATCH 00/13] usb: second series of updates for dwc2 driver

2015-01-21 Thread Kaukab, Yousaf
Hi John,

 -Original Message-
 From: Kaukab, Yousaf
 Sent: Thursday, January 15, 2015 6:09 PM
 To: linux-usb@vger.kernel.org; ba...@ti.com
 Cc: john.y...@synopsys.com; Herrero, Gregory; pa...@synopsys.com;
 r.bald...@samsung.com; dingu...@opensource.altera.com; Kaukab, Yousaf
 Subject: [PATCH 00/13] usb: second series of updates for dwc2 driver
 
 Hi,
 This patchset consists of some bug fixes, feature enhancements and cosmetic
 changes for the dwc2 driver. All the patches are verified on
 dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma enabled.
 Although basic testing without dma was also done.
 
 This is based on testing/next branch in Felipe's git.
 
 Thank you,
 
 Best regards,
 Yousaf
 
 Gregory Herrero (8):
   usb: dwc2: host: register hcd handle to the phy
   usb: dwc2: host: resume root hub on remote wakeup
   usb: dwc2: gadget: fix clear halt feature handling
   usb: dwc2: gadget: add TEST_MODE feature support
   usb: dwc2: gadget: fix a typo in comment
   usb: dwc2: gadget: add reset flag in init function
   usb: dwc2: gadget: don't modify pullup status during reset
   usb: dwc2: gadget: initialize controller in pullup callback
 
 Mian Yousaf Kaukab (5):
   usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks
   usb: dwc2: gadget: add unaligned buffers support
   usb: dwc2: gadget: fix debug message for zlp
   usb: dwc2: gadget: fix phy interface configuration
   usb: dwc2: gadget: replace constants with defines
 
  drivers/usb/dwc2/core.h   |  12 +-
  drivers/usb/dwc2/gadget.c | 358
 ++
  drivers/usb/dwc2/hcd.c|  43 --
  drivers/usb/dwc2/hw.h |   1 +
  4 files changed, 348 insertions(+), 66 deletions(-)
 

Did you get a chance to review this patchset? Can you please ACK it if you 
don't have any objections?

BR,
Yousaf
--
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/3] ARM: mvebu: Enable XHCI on the Armada 385 AP

2015-01-21 Thread Maxime Ripard
On Tue, Jan 20, 2015 at 09:43:07PM +0100, Andrew Lunn wrote:
 On Tue, Jan 20, 2015 at 09:30:28PM +0100, Maxime Ripard wrote:
  Hi Andrew,
  
  On Mon, Jan 19, 2015 at 10:35:07PM +0100, Andrew Lunn wrote:
   On Mon, Jan 19, 2015 at 02:01:11PM +0100, Maxime Ripard wrote:
Hi all,

This serie enables the Armada 385 AP XHCI controller.

Since the controller uses a GPIO-controlled VBUS, we used the
phy-generic driver, and made the needed additions to the xhci-plat
driver to retrieve a USB phy.

Unfortunately, some glitches were also found along the way, mostly
because of the probe deferring that was introduced by this phy
retrieval.

Since the introduction of the Armada 38x support in 3.16, the driver
was attempting to write into registers while the clock wasn't enabled
yet. This was working because the bootloader left it enabled, but in
the case of a deferred probing, the clock would have been disabled by
the error path of our driver, and this would fail. This should go in
3.19, and any stable kernel for 3.16+.

The two patches remaining are regular patches, and are aimed at
3.20. The last patch depend on my previous serie to introduce support
for the the A385 AP board.
   
   Hi Maxime
   
   I assume you want me to take 3/3? Any other route is not simple, since
   this file only exists in mvebu/dt and maybe a staging branch of
   arm-soc.
  
   What route do you think the other patches will take?
  
  There should be no merge dependency, but merging the third patch alone
  will probably result on a boot breakage. I don't think it really
  matters though, since this is a new board, so I guess it can go
  through the USB-PHY tree.
 
 Hi Maxime
 
 Humm, maybe i'm wrong, but i think
 
 arch/arm/boot/dts/armada-385-db-ap.dts
 
 only exists in the mvebu tree?
 
 At least, i don't see it here:
 
 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/tree/arch/arm/boot/dts?h=next

Yeah, but my point was that if you merge the DT bits, without having
the PHY driver quirks fix in your tree, you'll result in a kernel that
doesn't boot at all on that board.

But again, since this is a new board, I don't really see why you would
want to bisect that.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH v2 4/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data

2015-01-21 Thread Sneeker Yeh
hi,

2015-01-19 22:51 GMT+08:00 Felipe Balbi ba...@ti.com:

 On Mon, Jan 19, 2015 at 03:56:48PM +0800, Sneeker Yeh wrote:
  If an xhci platform has Synopsis device disconnection errata then enable
  XHCI_DISCONNECT_QUIRK quirk flag.
 
  Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com
  ---
   drivers/usb/host/xhci-plat.c |3 +++
   include/linux/usb/xhci_pdriver.h |4 
   2 files changed, 7 insertions(+)
 
  diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
  index 08d402b..40beb95 100644
  --- a/drivers/usb/host/xhci-plat.c
  +++ b/drivers/usb/host/xhci-plat.c
  @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
if ((node  of_property_read_bool(node, usb3-lpm-capable)) ||
(pdata  pdata-usb3_lpm_capable))
xhci-quirks |= XHCI_LPM_SUPPORT;
  +
  + if (pdata  pdata-delay_portcsc_clear)
  + xhci-quirks |= XHCI_DISCONNECT_QUIRK;
/*
 * Set the xHCI pointer before xhci_plat_setup() (aka 
  hcd_driver.reset)
 * is called by usb_add_hcd().
  diff --git a/include/linux/usb/xhci_pdriver.h 
  b/include/linux/usb/xhci_pdriver.h
  index 376654b..a37a3a5 100644
  --- a/include/linux/usb/xhci_pdriver.h
  +++ b/include/linux/usb/xhci_pdriver.h
  @@ -18,10 +18,14 @@
*
* @usb3_lpm_capable:determines if this xhci platform supports USB3
*   LPM capability
  + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in
  + *   DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware
  + *   configuration.
*
*/
   struct usb_xhci_pdata {
unsignedusb3_lpm_capable:1;
  + unsigneddelay_portcsc_clear:1;

 previous patch won't build before this is applied. That's a problem.
 Please shuffle things around so that each and every patch builds and
 works on its own.

 We cannot break bisectability ;-)

Ah...sorry I seem to make a mess here,
i'll re-arrange all patches next round.

Much appreciate,
Sneeker


 --
 balbi
--
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 2/3] usb: dwc3: add ULPI interface support

2015-01-21 Thread Heikki Krogerus
On Tue, Jan 20, 2015 at 09:23:37AM -0600, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jan 20, 2015 at 11:18:21AM +0200, Heikki Krogerus wrote:
  Registers ULPI interface with the ULPI bus if HSPHY type is
  ULPI.
  
  Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  Cc: Felipe Balbi ba...@ti.com
 
 you're doing quite a bit in a single patch...
 
  ---
   drivers/usb/dwc3/Kconfig  |   7 
   drivers/usb/dwc3/Makefile |   4 ++
   drivers/usb/dwc3/core.c   |   9 +++-
   drivers/usb/dwc3/core.h   |  22 ++
   drivers/usb/dwc3/ulpi.c   | 102 
  ++
   5 files changed, 143 insertions(+), 1 deletion(-)
   create mode 100644 drivers/usb/dwc3/ulpi.c
  
  diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
  index 58b5b2c..6d0c5e6 100644
  --- a/drivers/usb/dwc3/Kconfig
  +++ b/drivers/usb/dwc3/Kconfig
  @@ -11,6 +11,13 @@ config USB_DWC3
   
   if USB_DWC3
   
  +config USB_DWC3_ULPI
  +   bool Provide ULPI PHY Interface
  +   depends on ULPI_PHY=y || ULPI_PHY=USB_DWC3
  +   help
  + Select this if you have ULPI type PHY attached to your DWC3
  + controller.
  +
   choice
  bool DWC3 Mode Selection
  default USB_DWC3_DUAL_ROLE if (USB  USB_GADGET)
  diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
  index bb34fbc..2fc44e0 100644
  --- a/drivers/usb/dwc3/Makefile
  +++ b/drivers/usb/dwc3/Makefile
  @@ -16,6 +16,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) 
  $(CONFIG_USB_DWC3_DUAL_ROLE)),)
  dwc3-y  += gadget.o ep0.o
   endif
   
  +ifneq ($(CONFIG_USB_DWC3_ULPI),)
  +   dwc3-y  += ulpi.o
  +endif
  +
   ifneq ($(CONFIG_DEBUG_FS),)
  dwc3-y  += debugfs.o
   endif
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 25ddc39..5219bc7 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -876,12 +876,17 @@ static int dwc3_probe(struct platform_device *pdev)
  dwc-hird_threshold = hird_threshold
  | (dwc-is_utmi_l1_suspend  4);
   
  +   platform_set_drvdata(pdev, dwc);
  +
  +   ret = dwc3_ulpi_init(dwc);
  +   if (ret)
  +   return ret;
  +
  ret = dwc3_core_get_phy(dwc);
  if (ret)
  return ret;
   
  spin_lock_init(dwc-lock);
  -   platform_set_drvdata(pdev, dwc);
 
 why do you need to move this ? Looks like this should be a cleanup and
 split into a single patch.

OK.

 it also appears that you need another patch moving dwc3_cache_hwparams()
 before all of these other calls, so you can use it from
 dwc3_ulpi_init().

OK.

  @@ -965,6 +970,7 @@ err1:
   
   err0:
  dwc3_free_event_buffers(dwc);
  +   dwc3_ulpi_exit(dwc);
   
  return ret;
   }
  @@ -984,6 +990,7 @@ static int dwc3_remove(struct platform_device *pdev)
  phy_power_off(dwc-usb3_generic_phy);
   
  dwc3_core_exit(dwc);
  +   dwc3_ulpi_exit(dwc);
   
  pm_runtime_put_sync(pdev-dev);
  pm_runtime_disable(pdev-dev);
  diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
  index 0842aa8..f6881a6 100644
  --- a/drivers/usb/dwc3/core.h
  +++ b/drivers/usb/dwc3/core.h
  @@ -32,6 +32,7 @@
   #include linux/usb/otg.h
   
   #include linux/phy/phy.h
  +#include linux/phy/ulpi/interface.h
   
   #define DWC3_MSG_MAX   500
   
  @@ -174,6 +175,14 @@
   #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1  31)
   #define DWC3_GUSB2PHYCFG_SUSPHY(1  6)
   
  +/* Global USB2 PHY Vendor Control Register */
  +#define DWC3_GUSB2PHYACC_NEWREGREQ (1  25)
  +#define DWC3_GUSB2PHYACC_BUSY  (1  23)
  +#define DWC3_GUSB2PHYACC_WRITE (1  22)
  +#define DWC3_GUSB2PHYACC_ADDR(n)   (n  16)
  +#define DWC3_GUSB2PHYACC_EXTEND_ADDR(n)(n  8)
  +#define DWC3_GUSB2PHYACC_DATA(n)   (n  0xff)
 
 separate patch

OK.

  @@ -590,6 +599,7 @@ struct dwc3_hwparams {
   #define DWC3_NUM_INT(n)(((n)  (0x3f  15))  15)
   
   /* HWPARAMS3 */
  +#define DWC3_ULPI_HSPHY(1  3)
 
 you also need a patch which defines this bit of HWPARAMS3. This is also
 the wrong definition. Which core revision do you have ? I can see that
 bit 3 is part of a 2 bit field called:
 
 DWC_USB3_HSPHY_INTERFACE

I have the same in my databook. I agree, it's not good like that.

 moreover, there are systems which have both ULPI and UTMI enabled and
 you can't really know which one the PHY is using.
 
 This needs a bit more thought.

Sure, I'll think of something better for this.

   #define DWC3_NUM_IN_EPS_MASK   (0x1f  18)
   #define DWC3_NUM_EPS_MASK  (0x3f  12)
   #define DWC3_NUM_EPS(p)(((p)-hwparams3   \
  @@ -739,6 +749,8 @@ struct dwc3 {
  struct phy  *usb2_generic_phy;
  struct phy  *usb3_generic_phy;
   
  +   struct ulpi *ulpi;
  +
  void __iomem*regs;
  size_t  regs_size;
   
  @@ -1035,4 +1047,14 @@ static inline int 

Re: [PATCH 3/3] phy: ulpi: add driver for TI TUSB1210

2015-01-21 Thread Heikki Krogerus
On Tue, Jan 20, 2015 at 09:45:39AM -0600, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jan 20, 2015 at 11:18:22AM +0200, Heikki Krogerus wrote:
  TUSB1210 ULPI PHY has vendor specific register for eye
  diagram tuning. On some platforms the system firmware has
  set optimized value to it. In order to not loose the
  optimized value, the driver stores it during probe and
  restores it every time the PHY is powered back on.
  
  Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  ---
   drivers/phy/ulpi/Kconfig|  11 
   drivers/phy/ulpi/Makefile   |   2 +
   drivers/phy/ulpi/tusb1210.c | 131 
  
   3 files changed, 144 insertions(+)
   create mode 100644 drivers/phy/ulpi/tusb1210.c
  
  diff --git a/drivers/phy/ulpi/Kconfig b/drivers/phy/ulpi/Kconfig
  index 8007df2..7cd6f82 100644
  --- a/drivers/phy/ulpi/Kconfig
  +++ b/drivers/phy/ulpi/Kconfig
  @@ -7,3 +7,14 @@ config ULPI_PHY
Say yes if you have ULPI PHY attached to your USB controller.
   
If unsure, say N.
  +
  +if ULPI_PHY
  +
  +config ULPI_TUSB1210
  +   tristate TI TUSB1210 USB PHY module
  +   depends on POWER_SUPPLY
  +   select USB_PHY
  +   help
  + Support for TI TUSB1210 USB ULPI PHY.
  +
  +endif
  diff --git a/drivers/phy/ulpi/Makefile b/drivers/phy/ulpi/Makefile
  index 59e61cb..7ee6679 100644
  --- a/drivers/phy/ulpi/Makefile
  +++ b/drivers/phy/ulpi/Makefile
  @@ -1,2 +1,4 @@
   ulpiphy-y  := ulpi.o
   obj-$(CONFIG_ULPI_PHY) += ulpiphy.o
  +
  +obj-$(CONFIG_ULPI_TUSB1210)+= tusb1210.o
  diff --git a/drivers/phy/ulpi/tusb1210.c b/drivers/phy/ulpi/tusb1210.c
  new file mode 100644
  index 000..ac77f98
  --- /dev/null
  +++ b/drivers/phy/ulpi/tusb1210.c
 
 do you really need this extra ulpi directory ?
 
 I wonder if phy-tusb1210.c as a name would be enough.

IMO grouping the ULPI PHY drivers and other ULPI bus code into
separate folder from the start is the right thing to do.

  @@ -0,0 +1,131 @@
  +/**
  + * tusb1210.c - TUSB1210 USB ULPI PHY driver
  + *
  + * Copyright (C) 2015 Intel Corporation
  + *
  + * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +#include linux/module.h
  +#include linux/phy/ulpi/driver.h
  +#include linux/phy/ulpi/regs.h
  +#include linux/gpio/consumer.h
  +
  +#include ulpi_phy.h
  +
  +struct tusb1210 {
  +   struct ulpi *ulpi;
  +   struct phy *phy;
  +   struct gpio_desc *gpio_reset;
  +   struct gpio_desc *gpio_cs;
  +   u8 ctx[1];
  +};
  +
  +static int tusb1210_power_on(struct phy *phy)
  +{
  +   struct tusb1210 *tusb = phy_get_drvdata(phy);
  +
  +   gpiod_set_value_cansleep(tusb-gpio_reset, 1);
  +   gpiod_set_value_cansleep(tusb-gpio_cs, 1);
  +
  +   /* Restore eye optimisation value */
  +   ulpi_write(tusb-ulpi, ULPI_EXT_VENDOR_SPECIFIC, tusb-ctx[0]);
  +
  +   return 0;
  +}
  +
  +static int tusb1210_power_off(struct phy *phy)
  +{
  +   struct tusb1210 *tusb = phy_get_drvdata(phy);
  +
  +   gpiod_set_value_cansleep(tusb-gpio_reset, 0);
  +   gpiod_set_value_cansleep(tusb-gpio_cs, 0);
  +
  +   return 0;
  +}
  +
  +static struct phy_ops phy_ops = {
  +   .power_on = tusb1210_power_on,
  +   .power_off = tusb1210_power_off,
  +   .init = tusb1210_power_on,
  +   .exit = tusb1210_power_off,
  +   .owner = THIS_MODULE,
  +};
  +
  +static int tusb1210_probe(struct ulpi *ulpi)
  +{
  +   struct gpio_desc *gpio;
  +   struct tusb1210 *tusb;
  +   int ret;
  +
  +   tusb = devm_kzalloc(ulpi-dev, sizeof(*tusb), GFP_KERNEL);
  +   if (!tusb)
  +   return -ENOMEM;
  +
  +   gpio = devm_gpiod_get(ulpi-dev, reset);
  +   if (!IS_ERR(gpio)) {
  +   ret = gpiod_direction_output(gpio, 0);
  +   if (ret)
  +   return ret;
  +   tusb-gpio_reset = gpio;
  +   }
  +
  +   gpio = devm_gpiod_get(ulpi-dev, cs);
  +   if (!IS_ERR(gpio)) {
  +   ret = gpiod_direction_output(gpio, 0);
  +   if (ret)
  +   return ret;
  +   tusb-gpio_cs = gpio;
  +   }
  +
  +   /* Store initial eye diagram optimisation value */
  +   ret = ulpi_read(ulpi, ULPI_EXT_VENDOR_SPECIFIC);
 
 do they *all* use this register for eye diagram optimization or is this
 something that Intel decided to do ?
 
 (sorry, don't know much about tusb1210 other than it sucks like hell :-)

All I know that somebody needs to save the value. The ones using this
PHY who don't need to save it can most likely live without the driver.

  +   if (ret  0)
  +   return ret;
  +
  +   tusb-ctx[0] = ret;
  +
  +   tusb-phy = ulpi_phy_create(ulpi, phy_ops);
  +   if (IS_ERR(tusb-phy))
  +   return PTR_ERR(tusb-phy);
  +
  +   tusb-ulpi = ulpi;
  +
  +   phy_set_drvdata(tusb-phy, tusb);
  +   dev_set_drvdata(ulpi-dev, tusb);
  +   

Re: [PATCH v2 2/5] usb: dwc3: add revision number DWC3_REVISION_300A

2015-01-21 Thread Sneeker Yeh
hi,

2015-01-20 4:00 GMT+08:00 Felipe Balbi ba...@ti.com:
 On Mon, Jan 19, 2015 at 07:45:31PM +, John Youn wrote:
  -Original Message-
  From: Felipe Balbi [mailto:ba...@ti.com]
  Sent: Monday, January 19, 2015 6:47 AM
 
  looking at Synopsys Solvnet for this IP, it shows that current version
  is 2.90a. There's no 3.00a. Paul, John, is there a 3.00a version of the
  DWC USB3 IP ?

 Yes there is, but it has not been released yet, thus it's not in Solvnet.

 alright, in that case, Sneeker, can you update this patch to add 2.90a
 and 3.00a macros ?

Sure,
I'll also add 2.90a in next round,

Thanks, and much appreciate,
Sneeker


 Thanks

 --
 balbi
--
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: [PATCHv4 2/3] USB: gadget: atmel_usba_udc: Enable Vbus signal IRQ in UDC start instead of UDC probe

2015-01-21 Thread Sylvain Rochet
Hi Boris,

On Wed, Jan 21, 2015 at 10:20:16AM +0100, Boris Brezillon wrote:
   
  udc-vbus_prev = 0;
  -   if (gpio_is_valid(udc-vbus_pin))
  -   enable_irq(gpio_to_irq(udc-vbus_pin));
  +   if (gpio_is_valid(udc-vbus_pin)) {
  +   ret = request_irq(gpio_to_irq(udc-vbus_pin),
  +   usba_vbus_irq, 0,
  +   atmel_usba_udc, udc);
  +   if (ret) {
  +   udc-vbus_pin = -ENODEV;
 
 I guess you're trying to protect against free_irq by changing the
 vbus_pin value (making it an invalid gpio id), but I think you should
 leave it unchanged for two reasons:
 1) If the request_irq call temporary fails (an ENOMEM for example) then
 you should be able to retry later, and modifying the vbus_pin value
 will prevent that.
 2) atmel_usba_stop will never be called if the atmel_usba_start failed,
 so there's no need to protect against this free_irq.

Indeed.

By the way, I just discovered irq_set_status_flags(irq, IRQ_NOAUTOEN); … 
so I am going for a v5 and the previous part is not relevant anymore.

Sylvain
--
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


[RFC]cdc-wdm: bug in ceasing IO

2015-01-21 Thread Oliver Neukum
From c37d436b8832e817ab437baa3324f6c08c846af9 Mon Sep 17 00:00:00 2001
From: Oliver Neukum oneu...@suse.de
Date: Fri, 16 Jan 2015 15:13:28 +0100
Subject: [PATCH] cdc-wdm: bug in ceasing IO

The work submits the URB and the URB queues the work.
To reliably kill this cycle a flag needs to be set
and one of the kills repeated.

Signed-off-by: Oliver Neukum oneu...@suse.de
---
 drivers/usb/class/cdc-wdm.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 5ff7018..e24bad6 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -976,8 +976,10 @@ static void wdm_disconnect(struct usb_interface *intf)
wake_up_all(desc-wait);
mutex_lock(desc-rlock);
mutex_lock(desc-wlock);
+   /* circular dependency. The second kill is needed */
kill_urbs(desc);
cancel_work_sync(desc-rxwork);
+   kill_urbs(desc);
mutex_unlock(desc-wlock);
mutex_unlock(desc-rlock);
 
@@ -1017,9 +1019,10 @@ static int wdm_suspend(struct usb_interface *intf, 
pm_message_t message)
 
set_bit(WDM_SUSPENDING, desc-flags);
spin_unlock_irq(desc-iuspin);
-   /* callback submits work - order is essential */
+   /* circular dependency. The second kill is needed */
kill_urbs(desc);
cancel_work_sync(desc-rxwork);
+   kill_urbs(desc);
}
if (!PMSG_IS_AUTO(message)) {
mutex_unlock(desc-wlock);
@@ -1077,8 +1080,10 @@ static int wdm_pre_reset(struct usb_interface *intf)
wake_up_all(desc-wait);
mutex_lock(desc-rlock);
mutex_lock(desc-wlock);
+   /* circular dependency. The second kill is needed */
kill_urbs(desc);
cancel_work_sync(desc-rxwork);
+   kill_urbs(desc);
return 0;
 }
 
-- 
1.8.4.5




--
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


[RFC]cdc-wdm: fix deadlock in scheduled work

2015-01-21 Thread Oliver Neukum
From 5cfcd26b872719089dd714b5b1047d4d6e985889 Mon Sep 17 00:00:00 2001
From: Oliver Neukum oneu...@suse.de
Date: Tue, 20 Jan 2015 15:28:53 +0100
Subject: [PATCH] cdc-wdm: fix deadlock in scheduled work

The scheduled work can deadlock in the error
handling case.

kmalloc with GFP_KERNEL in the work
VM layer decides to page to storage interface
task blocks waiting for completion of IO

SCSI layer sees an error
SCSI error handling starts
SCSI layer requests a bus reset

USB layer calls pre_reset() of cdc-wdm
wdm_pre_reset() calls cancel_work_sync()
cancel_work_sync() waits for work to finish
DEADLOCK

Signed-off-by: Oliver Neukum oneu...@suse.de
---
 drivers/usb/class/cdc-wdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index e24bad6..93dd8b8 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -738,7 +738,7 @@ static void wdm_rxwork(struct work_struct *work)
responding = test_and_set_bit(WDM_RESPONDING, desc-flags);
spin_unlock_irqrestore(desc-iuspin, flags);
if (!responding)
-   rv = usb_submit_urb(desc-response, GFP_KERNEL);
+   rv = usb_submit_urb(desc-response, GFP_NOIO);
if (rv  0  rv != -EPERM) {
spin_lock_irqsave(desc-iuspin, flags);
clear_bit(WDM_RESPONDING, desc-flags);
-- 
1.8.4.5



--
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


[RFC]cdc-wdm: race between work queue and pre_reset

2015-01-21 Thread Oliver Neukum
From 7cccf82cf2c34f8e5b3a60100a1e35108c52bfba Mon Sep 17 00:00:00 2001
From: Oliver Neukum oneu...@suse.de
Date: Fri, 16 Jan 2015 14:58:23 +0100
Subject: [PATCH] cdc-wdm: race between work queue and pre_reset

pre_reset() must cease IO so the work needs to check
the flag.

Signed-off-by: Oliver Neukum oneu...@suse.de
---
 drivers/usb/class/cdc-wdm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 6647f37..5ff7018 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -730,7 +730,9 @@ static void wdm_rxwork(struct work_struct *work)
int responding;
 
spin_lock_irqsave(desc-iuspin, flags);
-   if (test_bit(WDM_DISCONNECTING, desc-flags)) {
+   if (test_bit(WDM_DISCONNECTING, desc-flags) ||
+   test_bit(WDM_RESETTING, desc-flags)
+   ) {
spin_unlock_irqrestore(desc-iuspin, flags);
} else {
responding = test_and_set_bit(WDM_RESPONDING, desc-flags);
-- 
1.8.4.5



--
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


question on stable fix f161ead70fa6a62e432dff6e9dab8e3cfbeabea6

2015-01-21 Thread Oliver Neukum
Hi Mathias,

regarding

commit f161ead70fa6a62e432dff6e9dab8e3cfbeabea6
Author: Mathias Nyman mathias.ny...@linux.intel.com
Date:   Fri Jan 9 17:18:28 2015 +0200

xhci: Check if slot is already in default state before moving it there

you are marking this for stable only on 3.14+
I don't see why. Yes, the new scheme makes hitting
this problem easier, but as it is a limitation of
the hardware it should exist in all versions of
the xhci driver. I am confused. Could you elaborate?

Regards
Oliver


--
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: [PATCHv2 001/002] usbhid: Fix initialisation for the Microsoft Sidewinder Force Feedback Pro 2 joystick

2015-01-21 Thread Benjamin Tissoires
HI Jim,

On Wed, Jan 21, 2015 at 9:29 AM, Jim Keir jimk...@oracledbadirect.com wrote:
 Hi,

 Thanks for the feedback. I've included a replacement patch here for the
 first issue, and will send a separate message with a patch for the third
 issue. I've removed the second as per Alan's request. This diff is against
 the latest version of the hid branch rather than the 3.13 branch I was using
 before. Apologies for the mistakes, I'm still feeling my way around here.

No worries.


 ---

 Allow the Microsoft Sidewinder Force Feedback 2 joystick to perform the
 required communication with the device during initialisation.

Hmm weird, your mailer did not cut this line... It's better to have it
on 2 separate lines for the actual commit message (no more than 72 or
80 columns).


 Signed-off-by: Jim Keir jimk...@oracledbadirect.com

 ---

This time the order of the various elements is nearly good :)

Git consider that the Subject and the first part of the message (until
the first '---') are to be included in the commit (so the commit title
and the commit message). Then, between the first '---' and the first
diff, you can put whatever comments you like. and then a second '---'
terminates the patch (and you can add garbage like thanks, or the list
footer).
Anyway, I am unable to double check what I just said because your
mailer corrupted the patch.
It converted the tabs in spaces and broke the lines when it should not have.

Please resend the two patches using git send-email.

Just use git format-patch. Then edit the file in an editor to add the
greetings and a short difference between v1 and v2 after the first ---
(your explanations before the first --- should be sufficient), then
use git send-email to send it. No need to link the thread with this
mail or the previous thread.


 diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
 index 10b6167..1b3fa70 100644
 --- a/drivers/hid/usbhid/hid-pidff.c
 +++ b/drivers/hid/usbhid/hid-pidff.c
 @@ -1252,6 +1258,8 @@ int hid_pidff_init(struct hid_device *hid)

  pidff-hid = hid;

 +hid_device_io_start(hid);
 +

I *think* we should be able to move this later a little bit. Not a
biggie however.

  pidff_find_reports(hid, HID_OUTPUT_REPORT, pidff);
  pidff_find_reports(hid, HID_FEATURE_REPORT, pidff);

 @@ -1315,9 +1323,13 @@ int hid_pidff_init(struct hid_device *hid)

  hid_info(dev, Force feedback for USB HID PID devices by Anssi Hannula
 anssi.hann...@gmail.com\n);

 +hid_device_io_stop(hid);
 +
  return 0;

   fail:
 +hid_device_io_stop(hid);
 +

For the record, we need to close the IO when leaving or the whole IO
mutex will be moot.

Cheers,
Benjamin

  kfree(pidff);
  return error;
  }

 ---

 On 20/01/2015 14:09, Benjamin Tissoires wrote:

 Hi,

 Jim, in addition to what Alan said, here are some comments that I
 would like to be fixed in the v2.

 On Sun, Jan 18, 2015 at 11:07 AM, Jim Keir jimk...@oracledbadirect.com
 wrote:

 From: Jim Keir jimk...@yahoo.co.uk
 Signed-off-by: Jim Keir jimk...@yahoo.co.uk

 The Signed-off-by line is generally at the end of the commit message.
 This way, if someone else adds new changes to the patch, we can trace
 which modifications belongs to which.

 Currently the SWFF2 driver fails during initialisation, making the force
 capability of the joystick unusable. Further, there is a long-standing
 bug in the same driver where commands to update force parameters are
 addressed to the last-created force effect instead of the specified one,
 making it impossible to modify effects after their creation.

 Three bugs are addressed:

 1) The FF2 driver (usbhid/hid-pidff.c) sends commands to the stick
 during ff_init. However, this is called inside a block where
 driver_input_lock is locked, so the results of these initial commands
 are discarded. This one is the killer, without this nothing else works.

 ff_init issues commands using hid_hw_request. This eventually goes to
 hid_input_report, which returns -EBUSY because driver_input_lock is
 locked. The change is to delay the ff_init call in hid-core.c until
 after this lock has been released.

 2) The usbhid driver ignores an endpoint stall when sending control
 commands, causing the first few commands of the hid-pidff.c
 initialisation to get lost.

 usbhid/hid-core.c has been modified by copying lines into hid_ctrl
 from the hid_irq_in function in the same file.

 3) The FF2 driver (usbhid/hid-pidff.c) does not set the effect ID when
 uploading an effect. The result is that the initial upload works but
 subsequent uploads to modify effect parameters are all directed at the
 last-created effect.

 Fully agree that you should split the commit in 3 if there are 3
 issues (and to the rest Alan said also, but this is the most important
 I think).


 The targeted effect ID must be passed back to the device when effect
 parameters are changed. This is done at the start of
 pidff_set_condition_report, pidff_set_periodic_report etc. based 

Re: [PATCH] usb: core: hub: modify hub reset logic in hub driver

2015-01-21 Thread Alan Stern
On Wed, 21 Jan 2015 deepakdas.li...@gmail.com wrote:

 From: Deepak Das deepakdas.li...@gmail.com
 
 Currently if port power is turned off by user on hub port
 using USBDEVFS then port power is turned back ON
 by hub driver.
 This commit modifies hub reset logic in hub_port_connect() to prevent
 hub driver from turning back the port power ON if port is not owned
 by kernel.
 
 Signed-off-by: Deepak Das deepakdas.li...@gmail.com
 ---
  drivers/usb/core/hub.c |8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
 index b649fef..6f12de7 100644
 --- a/drivers/usb/core/hub.c
 +++ b/drivers/usb/core/hub.c
 @@ -4657,9 +4657,13 @@ static void hub_port_connect(struct usb_hub *hub, int 
 port1, u16 portstatus,
   if (!(portstatus  USB_PORT_STAT_CONNECTION) ||
   test_bit(port1, hub-removed_bits)) {
  
 - /* maybe switch power back on (e.g. root hub was reset) */
 + /*
 + *  maybe switch power back on (e.g. root hub was reset)
 + * but only if the port isn't owned by someone else.
 + */

Minor issue: Multi-line comments should be formatted like this:

/*
 * blah blah blah
 * blah blah blah
 */

with all the '*' characters aligned vertically.  See how it is done 
elsewhere in the source file.

   if (hub_is_port_power_switchable(hub)
 -  !port_is_power_on(hub, portstatus))
 +  !port_is_power_on(hub, portstatus)
 +  !port_dev-port_owner)
   set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
  
   if (portstatus  USB_PORT_STAT_ENABLE)

Fix that and then repost the patch with:

Acked-by: Alan Stern st...@rowland.harvard.edu

Be sure to CC: Greg KH so he will see it and apply it.

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: [PATCHv3 1/2] usb: ehci-platform: add support for multiple phys per controller

2015-01-21 Thread Alan Stern
On Mon, 19 Jan 2015 arun.ramamur...@broadcom.com wrote:

 From: Arun Ramamurthy arunr...@broadcom.com
 
 Added support for cases where one controller is connected
 to multiple phys.
 
 Signed-off-by: Arun Ramamurthy arunr...@broadcom.com
 Reviewed-by: Ray Jui r...@broadcom.com
 Reviewed-by: Scott Branden sbran...@broadcom.com
 Tested-by: Scott Branden sbran...@broadcom.com
 ---

Right here is where you should explain how v3 of this patch is 
different from v2.

Anyway, it looks good.

Acked-by: Alan Stern st...@rowland.harvard.edu

Did you run it through checkpatch.pl?

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


[PATCH v1 03/13] usb: dwc2: gadget: fix clear halt feature handling

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

When clearing HALT on an endpoint, req-complete of in progress
requests must be called with locks off. New request should only be
started if there is not already a pending request on the endpoint.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 50ae096..02d0e9a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1007,16 +1007,22 @@ static int s3c_hsotg_process_req_feature(struct 
dwc2_hsotg *hsotg,
hs_req = ep-req;
ep-req = NULL;
list_del_init(hs_req-queue);
-   usb_gadget_giveback_request(ep-ep,
-   
hs_req-req);
+   if (hs_req-req.complete) {
+   spin_unlock(hsotg-lock);
+   usb_gadget_giveback_request(
+   ep-ep, hs_req-req);
+   spin_lock(hsotg-lock);
+   }
}
 
/* If we have pending request, then start it */
-   restart = !list_empty(ep-queue);
-   if (restart) {
-   hs_req = get_ep_head(ep);
-   s3c_hsotg_start_req(hsotg, ep,
-   hs_req, false);
+   if (!ep-req) {
+   restart = !list_empty(ep-queue);
+   if (restart) {
+   hs_req = get_ep_head(ep);
+   s3c_hsotg_start_req(hsotg, ep,
+   hs_req, false);
+   }
}
}
 
-- 
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 v1 08/13] usb: dwc2: gadget: add reset flag in init function

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Add a flag to request physical reset of the controller when
s3c_hsotg_core_init_disconnected is called.
During the usb reset, controller must not be fully reconfigured and
resetted. Else this leads to shorter chirp-k duration during
enumeration.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/core.h   |  6 --
 drivers/usb/dwc2/gadget.c | 33 +
 drivers/usb/dwc2/hcd.c|  2 +-
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 485b195..f74304b 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -999,7 +999,8 @@ extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
 extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
-extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
+   bool reset);
 extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
 #else
@@ -1011,7 +1012,8 @@ static inline int s3c_hsotg_resume(struct dwc2_hsotg 
*dwc2)
 { return 0; }
 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
-static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
+   bool reset) {}
 static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
 static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
 #endif
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 5e91cf15..3cf9c6a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2271,9 +2271,13 @@ static int s3c_hsotg_corereset(struct dwc2_hsotg *hsotg)
  *
  * Issue a soft reset to the core, and await the core finishing it.
  */
-void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
+void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
+   bool is_usb_reset)
 {
-   s3c_hsotg_corereset(hsotg);
+   u32 val;
+
+   if (!is_usb_reset)
+   s3c_hsotg_corereset(hsotg);
 
/*
 * we must now enable ep0 ready for host detection and then
@@ -2286,7 +2290,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg)
 
s3c_hsotg_init_fifo(hsotg);
 
-   __orr32(hsotg-regs + DCTL, DCTL_SFTDISCON);
+   if (!is_usb_reset)
+   __orr32(hsotg-regs + DCTL, DCTL_SFTDISCON);
 
writel(1  18 | DCFG_DEVSPD_HS,  hsotg-regs + DCFG);
 
@@ -2357,9 +2362,11 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg)
s3c_hsotg_ctrl_epint(hsotg, 0, 0, 1);
s3c_hsotg_ctrl_epint(hsotg, 0, 1, 1);
 
-   __orr32(hsotg-regs + DCTL, DCTL_PWRONPRGDONE);
-   udelay(10);  /* see openiboot */
-   __bic32(hsotg-regs + DCTL, DCTL_PWRONPRGDONE);
+   if (!is_usb_reset) {
+   __orr32(hsotg-regs + DCTL, DCTL_PWRONPRGDONE);
+   udelay(10);  /* see openiboot */
+   __bic32(hsotg-regs + DCTL, DCTL_PWRONPRGDONE);
+   }
 
dev_dbg(hsotg-dev, DCTL=0x%08x\n, readl(hsotg-regs + DCTL));
 
@@ -2388,8 +2395,10 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg)
readl(hsotg-regs + DOEPCTL0));
 
/* clear global NAKs */
-   writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK | DCTL_SFTDISCON,
-  hsotg-regs + DCTL);
+   val = DCTL_CGOUTNAK | DCTL_CGNPINNAK;
+   if (!is_usb_reset)
+   val |= DCTL_SFTDISCON;
+   __orr32(hsotg-regs + DCTL, val);
 
/* must be at-least 3ms to allow bus to see disconnect */
mdelay(3);
@@ -2482,7 +2491,7 @@ irq_retry:
kill_all_requests(hsotg, hsotg-eps_out[0],
  -ECONNRESET);
 
-   s3c_hsotg_core_init_disconnected(hsotg);
+   s3c_hsotg_core_init_disconnected(hsotg, true);
s3c_hsotg_core_connect(hsotg);
}
}
@@ -3052,7 +3061,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
 
spin_lock_irqsave(hsotg-lock, flags);
s3c_hsotg_init(hsotg);
-   s3c_hsotg_core_init_disconnected(hsotg);
+   s3c_hsotg_core_init_disconnected(hsotg, false);
hsotg-enabled = 0;
spin_unlock_irqrestore(hsotg-lock, flags);
 
@@ -3171,7 +3180,7 @@ static int s3c_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
if (is_active) {
/* Kill any ep0 requests as controller will be 

[PATCH v1 07/13] usb: dwc2: gadget: add unaligned buffers support

2015-01-21 Thread Mian Yousaf Kaukab
When using DMA, dwc2 requires buffers to be 4 bytes aligned. Use
bounce buffers if they are not.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/core.h   |  2 ++
 drivers/usb/dwc2/gadget.c | 62 ++-
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index c750fd3..485b195 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -158,10 +158,12 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg_req - data transfer request
  * @req: The USB gadget request
  * @queue: The list of requests for the endpoint this is queued for.
+ * @saved_req_buf: variable to save req.buf when bounce buffers are used.
  */
 struct s3c_hsotg_req {
struct usb_request  req;
struct list_headqueue;
+   void *saved_req_buf;
 };
 
 #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || 
IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index fc9462a..5e91cf15 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -726,6 +726,59 @@ dma_error:
return -EIO;
 }
 
+static int s3c_hsotg_handle_unaligned_buf_start(struct dwc2_hsotg *hsotg,
+   struct s3c_hsotg_ep *hs_ep, struct s3c_hsotg_req *hs_req)
+{
+   void *req_buf = hs_req-req.buf;
+
+   /* If dma is not being used or buffer is aligned */
+   if (!using_dma(hsotg) || !((long)req_buf  3))
+   return 0;
+
+   WARN_ON(hs_req-saved_req_buf);
+
+   dev_dbg(hsotg-dev, %s: %s: buf=%p length=%d\n, __func__,
+   hs_ep-ep.name, req_buf, hs_req-req.length);
+
+   hs_req-req.buf = kmalloc(hs_req-req.length, GFP_ATOMIC);
+   if (!hs_req-req.buf) {
+   hs_req-req.buf = req_buf;
+   dev_err(hsotg-dev,
+   %s: unable to allocate memory for bounce buffer\n,
+   __func__);
+   return -ENOMEM;
+   }
+
+   /* Save actual buffer */
+   hs_req-saved_req_buf = req_buf;
+
+   if (hs_ep-dir_in)
+   memcpy(hs_req-req.buf, req_buf, hs_req-req.length);
+   return 0;
+}
+
+static void s3c_hsotg_handle_unaligned_buf_complete(struct dwc2_hsotg *hsotg,
+   struct s3c_hsotg_ep *hs_ep, struct s3c_hsotg_req *hs_req)
+{
+   /* If dma is not being used or buffer was aligned */
+   if (!using_dma(hsotg) || !hs_req-saved_req_buf)
+   return;
+
+   dev_dbg(hsotg-dev, %s: %s: status=%d actual-length=%d\n, __func__,
+   hs_ep-ep.name, hs_req-req.status, hs_req-req.actual);
+
+   /* Copy data from bounce buffer on successful out transfer */
+   if (!hs_ep-dir_in  !hs_req-req.status)
+   memcpy(hs_req-saved_req_buf, hs_req-req.buf,
+   hs_req-req.actual);
+
+   /* Free bounce buffer */
+   kfree(hs_req-req.buf);
+
+   hs_req-req.buf = hs_req-saved_req_buf;
+   hs_req-saved_req_buf = NULL;
+}
+
 static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
  gfp_t gfp_flags)
 {
@@ -733,6 +786,7 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct 
usb_request *req,
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
struct dwc2_hsotg *hs = hs_ep-parent;
bool first;
+   int ret;
 
dev_dbg(hs-dev, %s: req %p: %d@%p, noi=%d, zero=%d, snok=%d\n,
ep-name, req, req-length, req-buf, req-no_interrupt,
@@ -743,9 +797,13 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct 
usb_request *req,
req-actual = 0;
req-status = -EINPROGRESS;
 
+   ret = s3c_hsotg_handle_unaligned_buf_start(hs, hs_ep, hs_req);
+   if (ret)
+   return ret;
+
/* if we're using DMA, sync the buffers as necessary */
if (using_dma(hs)) {
-   int ret = s3c_hsotg_map_dma(hs, hs_ep, req);
+   ret = s3c_hsotg_map_dma(hs, hs_ep, req);
if (ret)
return ret;
}
@@ -1326,6 +1384,8 @@ static void s3c_hsotg_complete_request(struct dwc2_hsotg 
*hsotg,
if (hs_req-req.status == -EINPROGRESS)
hs_req-req.status = result;
 
+   s3c_hsotg_handle_unaligned_buf_complete(hsotg, hs_ep, hs_req);
+
hs_ep-req = NULL;
list_del_init(hs_req-queue);
 
-- 
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 v1 04/13] usb: dwc2: gadget: add TEST_MODE feature support

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Handle SET_FEATURE TEST_MODE request sent by the host.
Slightly rework FEATURE request handling to allow parsing
other request types than Endpoint.
Also add a debugfs to change test mode value from user space.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/core.h   |   4 +
 drivers/usb/dwc2/gadget.c | 189 --
 2 files changed, 186 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index f09b3de..c750fd3 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -567,12 +567,14 @@ struct dwc2_hw_params {
  * @num_of_eps: Number of available EPs (excluding EP0)
  * @debug_root: Root directrory for debugfs.
  * @debug_file: Main status file for debugfs.
+ * @debug_testmode: Testmode status file for debugfs.
  * @debug_fifo: FIFO status file for debugfs.
  * @ep0_reply:  Request used for ep0 reply.
  * @ep0_buff:   Buffer for EP0 reply data, if needed.
  * @ctrl_buff:  Buffer for EP0 control requests.
  * @ctrl_req:   Request for EP0 control packets.
  * @ep0_state:  EP0 control transfers state
+ * @test_mode:  USB test mode requested by the host
  * @last_rst:   Time of last reset
  * @eps:The endpoints being supplied to the gadget framework
  * @g_using_dma:  Indicate if dma usage is enabled
@@ -610,6 +612,7 @@ struct dwc2_hsotg {
 
struct dentry *debug_root;
struct dentry *debug_file;
+   struct dentry *debug_testmode;
struct dentry *debug_fifo;
 
/* DWC OTG HW Release versions */
@@ -706,6 +709,7 @@ struct dwc2_hsotg {
void *ep0_buff;
void *ctrl_buff;
enum dwc2_ep0_state ep0_state;
+   u8 test_mode;
 
struct usb_gadget gadget;
unsigned int enabled:1;
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 02d0e9a..67ea258 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -35,6 +35,7 @@
 #include linux/usb/gadget.h
 #include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
+#include linux/uaccess.h
 
 #include core.h
 #include hw.h
@@ -835,6 +836,32 @@ static struct s3c_hsotg_ep *ep_from_windex(struct 
dwc2_hsotg *hsotg,
 }
 
 /**
+ * s3c_hsotg_set_test_mode - Enable usb Test Modes
+ * @hsotg: The driver state.
+ * @testmode: requested usb test mode
+ * Enable usb Test Mode requested by the Host.
+ */
+static int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode)
+{
+   int dctl = readl(hsotg-regs + DCTL);
+
+   dctl = ~DCTL_TSTCTL_MASK;
+   switch (testmode) {
+   case TEST_J:
+   case TEST_K:
+   case TEST_SE0_NAK:
+   case TEST_PACKET:
+   case TEST_FORCE_EN:
+   dctl |= testmode  DCTL_TSTCTL_SHIFT;
+   break;
+   default:
+   return -EINVAL;
+   }
+   writel(dctl, hsotg-regs + DCTL);
+   return 0;
+}
+
+/**
  * s3c_hsotg_send_reply - send reply to control request
  * @hsotg: The device state
  * @ep: Endpoint 0
@@ -968,19 +995,48 @@ static int s3c_hsotg_process_req_feature(struct 
dwc2_hsotg *hsotg,
struct s3c_hsotg_ep *ep;
int ret;
bool halted;
+   u32 recip;
+   u32 wValue;
+   u32 wIndex;
 
dev_dbg(hsotg-dev, %s: %s_FEATURE\n,
__func__, set ? SET : CLEAR);
 
-   if (ctrl-bRequestType == USB_RECIP_ENDPOINT) {
-   ep = ep_from_windex(hsotg, le16_to_cpu(ctrl-wIndex));
+   wValue = le16_to_cpu(ctrl-wValue);
+   wIndex = le16_to_cpu(ctrl-wIndex);
+   recip = ctrl-bRequestType  USB_RECIP_MASK;
+
+   switch (recip) {
+   case USB_RECIP_DEVICE:
+   switch (wValue) {
+   case USB_DEVICE_TEST_MODE:
+   if ((wIndex  0xff) != 0)
+   return -EINVAL;
+   if (!set)
+   return -EINVAL;
+
+   hsotg-test_mode = wIndex  8;
+   ret = s3c_hsotg_send_reply(hsotg, ep0, NULL, 0);
+   if (ret) {
+   dev_err(hsotg-dev,
+   %s: failed to send reply\n, __func__);
+   return ret;
+   }
+   break;
+   default:
+   return -ENOENT;
+   }
+   break;
+
+   case USB_RECIP_ENDPOINT:
+   ep = ep_from_windex(hsotg, wIndex);
if (!ep) {
dev_dbg(hsotg-dev, %s: no endpoint for 0x%04x\n,
-   __func__, le16_to_cpu(ctrl-wIndex));
+   __func__, wIndex);
return -ENOENT;
}
 
-   switch (le16_to_cpu(ctrl-wValue)) {
+

[PATCH v1 10/13] usb: dwc2: gadget: fix debug message for zlp

2015-01-21 Thread Mian Yousaf Kaukab
Print debug message according to zlp direction. Always saying
Sending is misleading.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/gadget.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 5090300..38ba022 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1335,7 +1335,12 @@ static void s3c_hsotg_program_zlp(struct dwc2_hsotg 
*hsotg,
u32 epctl_reg = hs_ep-dir_in ? DIEPCTL(index) : DOEPCTL(index);
u32 epsiz_reg = hs_ep-dir_in ? DIEPTSIZ(index) : DOEPTSIZ(index);
 
-   dev_dbg(hsotg-dev, Sending zero-length packet on ep%d\n, index);
+   if (hs_ep-dir_in)
+   dev_dbg(hsotg-dev, Sending zero-length packet on ep%d\n,
+   index);
+   else
+   dev_dbg(hsotg-dev, Receiving zero-length packet on ep%d\n,
+   index);
 
writel(DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) |
DXEPTSIZ_XFERSIZE(0), hsotg-regs +
-- 
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 v1 13/13] usb: dwc2: gadget: initialize controller in pullup callback

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

USB reset interrupt is no more used to reset the controller.
Thus, reset the controller in pullup callback as described by
Synopsys programming guide. Otherwise enumeration sometimes
fails when usb configuration is switched without physical
disconnection.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f201f6d..15aa578 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3162,6 +3162,7 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, 
int is_on)
if (is_on) {
clk_enable(hsotg-clk);
hsotg-enabled = 1;
+   s3c_hsotg_core_init_disconnected(hsotg, false);
s3c_hsotg_core_connect(hsotg);
} else {
s3c_hsotg_core_disconnect(hsotg);
-- 
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 v1 09/13] usb: dwc2: gadget: don't modify pullup status during reset

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Pullup doesn't need to be enabled during usb reset since it is
already enabled. This leads to shorter chirp-k duration if done
during usb reset.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 3cf9c6a..5090300 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2492,7 +2492,6 @@ irq_retry:
  -ECONNRESET);
 
s3c_hsotg_core_init_disconnected(hsotg, true);
-   s3c_hsotg_core_connect(hsotg);
}
}
}
-- 
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 v1 11/13] usb: dwc2: gadget: fix phy interface configuration

2015-01-21 Thread Mian Yousaf Kaukab
hsotg-phyif is set in dwc2_gadget_init according to phy interface
width. Use it for configuration instead of hardcoded value.
Moreover, set USB turnaround time according to phy width.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/gadget.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 38ba022..8c3f8f8 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2290,8 +2290,9 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
 */
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
+   val = (hsotg-phyif == GUSBCFG_PHYIF8) ? 9 : 5;
writel(hsotg-phyif | GUSBCFG_TOUTCAL(7) |
-  (0x5  10), hsotg-regs + GUSBCFG);
+  (val  10), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
 
@@ -2978,6 +2979,7 @@ static void s3c_hsotg_phy_disable(struct dwc2_hsotg 
*hsotg)
  */
 static void s3c_hsotg_init(struct dwc2_hsotg *hsotg)
 {
+   u32 trdtim;
/* unmask subset of endpoint interrupts */
 
writel(DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK |
@@ -3002,8 +3004,10 @@ static void s3c_hsotg_init(struct dwc2_hsotg *hsotg)
s3c_hsotg_init_fifo(hsotg);
 
/* set the PLL on, remove the HNP/SRP and set the PHY */
-   writel(GUSBCFG_PHYIF16 | GUSBCFG_TOUTCAL(7) | (0x5  10),
-  hsotg-regs + GUSBCFG);
+   trdtim = (hsotg-phyif == GUSBCFG_PHYIF8) ? 9 : 5;
+   writel(hsotg-phyif | GUSBCFG_TOUTCAL(7) |
+   (trdtim  10),
+   hsotg-regs + GUSBCFG);
 
if (using_dma(hsotg))
__orr32(hsotg-regs + GAHBCFG, GAHBCFG_DMA_EN);
-- 
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 v1 05/13] usb: dwc2: gadget: fix a typo in comment

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

s3c_hsotg_process_req_feature comments was not correct

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 67ea258..aa5c0ba 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -981,7 +981,7 @@ static struct s3c_hsotg_req *get_ep_head(struct 
s3c_hsotg_ep *hs_ep)
 }
 
 /**
- * s3c_hsotg_process_req_featire - process request {SET,CLEAR}_FEATURE
+ * s3c_hsotg_process_req_feature - process request {SET,CLEAR}_FEATURE
  * @hsotg: The device state
  * @ctrl: USB control request
  */
-- 
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 v1 01/13] usb: dwc2: host: register hcd handle to the phy

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

If phy driver is present, register hcd handle to it and let it take
care of calling usb_add_hcd. Otherwise, add hcd here.

Moreover, save irq number so that it can be used to call usb_add_hcd.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd.c | 35 ++-
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 755e16b..4375d4f 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2779,6 +2779,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
u32 hcfg;
int i, num_channels;
int retval;
+   bool add_host = true;
 
if (usb_disabled())
return -ENODEV;
@@ -2935,14 +2936,30 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
/* Don't support SG list at this point */
hcd-self.sg_tablesize = 0;
 
+   /* Save irq number */
+   hcd-irq = irq;
+
/*
 * Finish generic HCD initialization and start the HCD. This function
 * allocates the DMA buffer pool, registers the USB bus, requests the
 * IRQ line, and calls hcd_start method.
+* If a phy driver is present, let it handle the hcd initialization.
 */
-   retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
-   if (retval  0)
-   goto error3;
+   if (!IS_ERR_OR_NULL(hsotg-uphy)) {
+   retval = otg_set_host(hsotg-uphy-otg, hcd-self);
+   if (retval) {
+   if (retval != -ENOTSUPP)
+   goto error3;
+   } else {
+   add_host = false;
+   }
+   }
+
+   if (add_host) {
+   retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
+   if (retval)
+   goto error3;
+   }
 
device_wakeup_enable(hcd-self.controller);
 
@@ -2976,7 +2993,8 @@ EXPORT_SYMBOL_GPL(dwc2_hcd_init);
 void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
 {
struct usb_hcd *hcd;
-
+   bool remove_host = true;
+   int retval;
dev_dbg(hsotg-dev, DWC OTG HCD REMOVE\n);
 
hcd = dwc2_hsotg_to_hcd(hsotg);
@@ -2988,7 +3006,14 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
return;
}
 
-   usb_remove_hcd(hcd);
+   if (!IS_ERR_OR_NULL(hsotg-uphy)) {
+   retval = otg_set_host(hsotg-uphy-otg, NULL);
+   if (!retval)
+   remove_host = false;
+   }
+
+   if (remove_host)
+   usb_remove_hcd(hcd);
hsotg-priv = NULL;
dwc2_hcd_release(hsotg);
usb_put_hcd(hcd);
-- 
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 v1 00/13] usb: second series of updates for dwc2 driver

2015-01-21 Thread Mian Yousaf Kaukab
Hi,
This patchset consists of some bug fixes, feature enhancements and
cosmetic changes for the dwc2 driver. All the patches are verified on
dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma
enabled. Although basic testing without dma was also done.

This is based on testing/next branch in Felipe's git.

Removed Paul Zimmerman from CC as his Synopsys address is not valid
any longer.

Thank you,

Best regards,
Yousaf

History:
v1:
 - Fixed comments from Sergei Shtylyov and Robert Baldyga

Gregory Herrero (8):
  usb: dwc2: host: register hcd handle to the phy
  usb: dwc2: host: resume root hub on remote wakeup
  usb: dwc2: gadget: fix clear halt feature handling
  usb: dwc2: gadget: add TEST_MODE feature support
  usb: dwc2: gadget: fix a typo in comment
  usb: dwc2: gadget: add reset flag in init function
  usb: dwc2: gadget: don't modify pullup status during reset
  usb: dwc2: gadget: initialize controller in pullup callback

Mian Yousaf Kaukab (5):
  usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks
  usb: dwc2: gadget: add unaligned buffers support
  usb: dwc2: gadget: fix debug message for zlp
  usb: dwc2: gadget: fix phy interface configuration
  usb: dwc2: gadget: replace constants with defines

 drivers/usb/dwc2/core.h   |  12 +-
 drivers/usb/dwc2/gadget.c | 359 ++
 drivers/usb/dwc2/hcd.c|  43 --
 drivers/usb/dwc2/hw.h |   1 +
 4 files changed, 349 insertions(+), 66 deletions(-)

-- 
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 v1 06/13] usb: dwc2: gadget: remove hardcoded if (0) and if (1) checks

2015-01-21 Thread Mian Yousaf Kaukab
Remove dead code as well.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/gadget.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index aa5c0ba..fc9462a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -566,11 +566,6 @@ static void s3c_hsotg_start_req(struct dwc2_hsotg *hsotg,
length = ureq-length - ureq-actual;
dev_dbg(hsotg-dev, ureq-length:%d ureq-actual:%d\n,
ureq-length, ureq-actual);
-   if (0)
-   dev_dbg(hsotg-dev,
-   REQ buf %p len %d dma %pad noi=%d zp=%d snok=%d\n,
-   ureq-buf, length, ureq-dma,
-   ureq-no_interrupt, ureq-zero, ureq-short_not_ok);
 
maxreq = get_ep_limit(hs_ep);
if (length  maxreq) {
@@ -1566,8 +1561,7 @@ static void s3c_hsotg_handle_rx(struct dwc2_hsotg *hsotg)
size = grxstsr  GRXSTS_BYTECNT_MASK;
size = GRXSTS_BYTECNT_SHIFT;
 
-   if (1)
-   dev_dbg(hsotg-dev, %s: GRXSTSP=0x%08x (%d@%d)\n,
+   dev_dbg(hsotg-dev, %s: GRXSTSP=0x%08x (%d@%d)\n,
__func__, grxstsr, size, epnum);
 
switch ((status  GRXSTS_PKTSTS_MASK)  GRXSTS_PKTSTS_SHIFT) {
@@ -2926,12 +2920,6 @@ static void s3c_hsotg_init(struct dwc2_hsotg *hsotg)
/* Be in disconnected state until gadget is registered */
__orr32(hsotg-regs + DCTL, DCTL_SFTDISCON);
 
-   if (0) {
-   /* post global nak until we're ready */
-   writel(DCTL_SGNPINNAK | DCTL_SGOUTNAK,
-  hsotg-regs + DCTL);
-   }
-
/* setup fifos */
 
dev_dbg(hsotg-dev, GRXFSIZ=0x%08x, GNPTXFSIZ=0x%08x\n,
-- 
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 v1 02/13] usb: dwc2: host: resume root hub on remote wakeup

2015-01-21 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

When a remote wakeup happens during bus_suspend, hcd needs to resume
its root hub.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4375d4f..7f7c16a 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -316,10 +316,12 @@ void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg)
  */
 static void dwc2_hcd_rem_wakeup(struct dwc2_hsotg *hsotg)
 {
-   if (hsotg-lx_state == DWC2_L2)
+   if (hsotg-lx_state == DWC2_L2) {
hsotg-flags.b.port_suspend_change = 1;
-   else
+   usb_hcd_resume_root_hub(hsotg-priv);
+   } else {
hsotg-flags.b.port_l1_change = 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


[PATCH v1 12/13] usb: dwc2: gadget: replace constants with defines

2015-01-21 Thread Mian Yousaf Kaukab
Defines are more readable and searchable than constants.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/gadget.c | 24 
 drivers/usb/dwc2/hw.h |  1 +
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 8c3f8f8..f201f6d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2292,14 +2292,14 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
/* set the PLL on, remove the HNP/SRP and set the PHY */
val = (hsotg-phyif == GUSBCFG_PHYIF8) ? 9 : 5;
writel(hsotg-phyif | GUSBCFG_TOUTCAL(7) |
-  (val  10), hsotg-regs + GUSBCFG);
+  (val  GUSBCFG_USBTRDTIM_SHIFT), hsotg-regs + GUSBCFG);
 
s3c_hsotg_init_fifo(hsotg);
 
if (!is_usb_reset)
__orr32(hsotg-regs + DCTL, DCTL_SFTDISCON);
 
-   writel(1  18 | DCFG_DEVSPD_HS,  hsotg-regs + DCFG);
+   writel(DCFG_EPMISCNT(1) | DCFG_DEVSPD_HS,  hsotg-regs + DCFG);
 
/* Clear any pending OTG interrupts */
writel(0x, hsotg-regs + GOTGINT);
@@ -3006,7 +3006,7 @@ static void s3c_hsotg_init(struct dwc2_hsotg *hsotg)
/* set the PLL on, remove the HNP/SRP and set the PHY */
trdtim = (hsotg-phyif == GUSBCFG_PHYIF8) ? 9 : 5;
writel(hsotg-phyif | GUSBCFG_TOUTCAL(7) |
-   (trdtim  10),
+   (trdtim  GUSBCFG_USBTRDTIM_SHIFT),
hsotg-regs + GUSBCFG);
 
if (using_dma(hsotg))
@@ -3295,7 +3295,7 @@ static int s3c_hsotg_hw_cfg(struct dwc2_hsotg *hsotg)
/* check hardware configuration */
 
cfg = readl(hsotg-regs + GHWCFG2);
-   hsotg-num_of_eps = (cfg  10)  0xF;
+   hsotg-num_of_eps = (cfg  GHWCFG2_NUM_DEV_EP_SHIFT)  0xF;
/* Add ep0 */
hsotg-num_of_eps++;
 
@@ -3326,10 +3326,10 @@ static int s3c_hsotg_hw_cfg(struct dwc2_hsotg *hsotg)
}
 
cfg = readl(hsotg-regs + GHWCFG3);
-   hsotg-fifo_mem = (cfg  16);
+   hsotg-fifo_mem = (cfg  GHWCFG3_DFIFO_DEPTH_SHIFT);
 
cfg = readl(hsotg-regs + GHWCFG4);
-   hsotg-dedicated_fifos = (cfg  25)  1;
+   hsotg-dedicated_fifos = (cfg  GHWCFG4_DED_FIFO_SHIFT)  1;
 
dev_info(hsotg-dev, EPs: %d, %s fifos, %d entries in SPRAM\n,
 hsotg-num_of_eps,
@@ -3354,8 +3354,8 @@ static void s3c_hsotg_dump(struct dwc2_hsotg *hsotg)
 readl(regs + DCFG), readl(regs + DCTL),
 readl(regs + DIEPMSK));
 
-   dev_info(dev, GAHBCFG=0x%08x, 0x44=0x%08x\n,
-readl(regs + GAHBCFG), readl(regs + 0x44));
+   dev_info(dev, GAHBCFG=0x%08x, GHWCFG1=0x%08x\n,
+readl(regs + GAHBCFG), readl(regs + GHWCFG1));
 
dev_info(dev, GRXFSIZ=0x%08x, GNPTXFSIZ=0x%08x\n,
 readl(regs + GRXFSIZ), readl(regs + GNPTXFSIZ));
@@ -3715,7 +3715,7 @@ static void s3c_hsotg_create_debug(struct dwc2_hsotg 
*hsotg)
 
/* create general state file */
 
-   hsotg-debug_file = debugfs_create_file(state, 0444, root,
+   hsotg-debug_file = debugfs_create_file(state, S_IRUGO, root,
hsotg, state_fops);
 
if (IS_ERR(hsotg-debug_file))
@@ -3729,7 +3729,7 @@ static void s3c_hsotg_create_debug(struct dwc2_hsotg 
*hsotg)
dev_err(hsotg-dev, %s: failed to create testmode\n,
__func__);
 
-   hsotg-debug_fifo = debugfs_create_file(fifo, 0444, root,
+   hsotg-debug_fifo = debugfs_create_file(fifo, S_IRUGO, root,
hsotg, fifo_fops);
 
if (IS_ERR(hsotg-debug_fifo))
@@ -3741,7 +3741,7 @@ static void s3c_hsotg_create_debug(struct dwc2_hsotg 
*hsotg)
 
ep = hsotg-eps_out[epidx];
if (ep) {
-   ep-debugfs = debugfs_create_file(ep-name, 0444,
+   ep-debugfs = debugfs_create_file(ep-name, S_IRUGO,
  root, ep, ep_fops);
 
if (IS_ERR(ep-debugfs))
@@ -3755,7 +3755,7 @@ static void s3c_hsotg_create_debug(struct dwc2_hsotg 
*hsotg)
 
ep = hsotg-eps_in[epidx];
if (ep) {
-   ep-debugfs = debugfs_create_file(ep-name, 0444,
+   ep-debugfs = debugfs_create_file(ep-name, S_IRUGO,
  root, ep, ep_fops);
 
if (IS_ERR(ep-debugfs))
diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
index d018ebe..d0a5ed8 100644
--- a/drivers/usb/dwc2/hw.h
+++ b/drivers/usb/dwc2/hw.h
@@ -294,6 +294,7 @@
 #define GHWCFG4_NUM_IN_EPS_MASK(0xf  26)
 #define GHWCFG4_NUM_IN_EPS_SHIFT   26
 #define GHWCFG4_DED_FIFO_EN(1  25)
+#define GHWCFG4_DED_FIFO_SHIFT 25
 #define GHWCFG4_SESSION_END_FILT_EN  

Re: [PATCH v2 3/4] usb: serial: implement function for F81232

2015-01-21 Thread One Thousand Gnomes

 + if (cflag  PARENB) {
 + if (cflag  PARODD)
 + new_lcr |= UART_LCR_PARITY; /* odd */
 + else
 + new_lcr |= SERIAL_EVEN_PARITY; /* even */
 + }

If you don't support mark/space also clear CMSPAR in the passed termios

 - if (old_termios)
 - tty_termios_copy_hw(tty-termios, old_termios);

Also when you set the baud rate compute the resulting actual baud rate
you generated and set it with

/* Don't rewrite B0 */
if (tty_termios_baud_rate(termios))
tty_termios_encode_baud_rate(termios, baud, baud);

so that the application gets told the baud rate it actually got if it
isn't close to the one they requested.

Alan
--
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 04/13] usb: dwc2: gadget: add TEST_MODE feature support

2015-01-21 Thread Robert Baldyga
Hi,

I got following error:
drivers/usb/dwc2/gadget.c: In function ‘testmode_write’:
drivers/usb/dwc2/gadget.c:3409:2: error: implicit declaration of
function ‘copy_from_user’ [-Werror=implicit-function-declaration]

You should add:
+#include linux/uaccess.h

Best regards,
Robert Baldyga

On 01/15/2015 06:09 PM, Mian Yousaf Kaukab wrote:
 From: Gregory Herrero gregory.herr...@intel.com
 
 Handle SET_FEATURE TEST_MODE request sent by the host.
 Slightly rework FEATURE request handling to allow parsing
 other request types than Endpoint.
 Also add a debugfs to change test mode value from user space.
 
 Signed-off-by: Gregory Herrero gregory.herr...@intel.com
 ---
  drivers/usb/dwc2/core.h   |   4 +
  drivers/usb/dwc2/gadget.c | 188 
 --
  2 files changed, 185 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
 index f09b3de..c750fd3 100644
 --- a/drivers/usb/dwc2/core.h
 +++ b/drivers/usb/dwc2/core.h
 @@ -567,12 +567,14 @@ struct dwc2_hw_params {
   * @num_of_eps: Number of available EPs (excluding EP0)
   * @debug_root: Root directrory for debugfs.
   * @debug_file: Main status file for debugfs.
 + * @debug_testmode: Testmode status file for debugfs.
   * @debug_fifo: FIFO status file for debugfs.
   * @ep0_reply:  Request used for ep0 reply.
   * @ep0_buff:   Buffer for EP0 reply data, if needed.
   * @ctrl_buff:  Buffer for EP0 control requests.
   * @ctrl_req:   Request for EP0 control packets.
   * @ep0_state:  EP0 control transfers state
 + * @test_mode:  USB test mode requested by the host
   * @last_rst:   Time of last reset
   * @eps:The endpoints being supplied to the gadget framework
   * @g_using_dma:  Indicate if dma usage is enabled
 @@ -610,6 +612,7 @@ struct dwc2_hsotg {
  
   struct dentry *debug_root;
   struct dentry *debug_file;
 + struct dentry *debug_testmode;
   struct dentry *debug_fifo;
  
   /* DWC OTG HW Release versions */
 @@ -706,6 +709,7 @@ struct dwc2_hsotg {
   void *ep0_buff;
   void *ctrl_buff;
   enum dwc2_ep0_state ep0_state;
 + u8 test_mode;
  
   struct usb_gadget gadget;
   unsigned int enabled:1;
 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
 index 0202230..1966406 100644
 --- a/drivers/usb/dwc2/gadget.c
 +++ b/drivers/usb/dwc2/gadget.c
 @@ -835,6 +835,32 @@ static struct s3c_hsotg_ep *ep_from_windex(struct 
 dwc2_hsotg *hsotg,
  }
  
  /**
 + * s3c_hsotg_set_test_mode - Enable usb Test Modes
 + * @hsotg: The driver state.
 + * @testmode: requested usb test mode
 + * Enable usb Test Mode requested by the Host.
 + */
 +static int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode)
 +{
 + int dctl = readl(hsotg-regs + DCTL);
 +
 + dctl = ~DCTL_TSTCTL_MASK;
 + switch (testmode) {
 + case TEST_J:
 + case TEST_K:
 + case TEST_SE0_NAK:
 + case TEST_PACKET:
 + case TEST_FORCE_EN:
 + dctl |= testmode  DCTL_TSTCTL_SHIFT;
 + break;
 + default:
 + return -EINVAL;
 + }
 + writel(dctl, hsotg-regs + DCTL);
 + return 0;
 +}
 +
 +/**
   * s3c_hsotg_send_reply - send reply to control request
   * @hsotg: The device state
   * @ep: Endpoint 0
 @@ -968,19 +994,48 @@ static int s3c_hsotg_process_req_feature(struct 
 dwc2_hsotg *hsotg,
   struct s3c_hsotg_ep *ep;
   int ret;
   bool halted;
 + u32 recip;
 + u32 wValue;
 + u32 wIndex;
  
   dev_dbg(hsotg-dev, %s: %s_FEATURE\n,
   __func__, set ? SET : CLEAR);
  
 - if (ctrl-bRequestType == USB_RECIP_ENDPOINT) {
 - ep = ep_from_windex(hsotg, le16_to_cpu(ctrl-wIndex));
 + wValue = le16_to_cpu(ctrl-wValue);
 + wIndex = le16_to_cpu(ctrl-wIndex);
 + recip = ctrl-bRequestType  USB_RECIP_MASK;
 +
 + switch (recip) {
 + case USB_RECIP_DEVICE:
 + switch (wValue) {
 + case USB_DEVICE_TEST_MODE:
 + if ((wIndex  0xff) != 0)
 + return -EINVAL;
 + if (!set)
 + return -EINVAL;
 +
 + hsotg-test_mode = wIndex  8;
 + ret = s3c_hsotg_send_reply(hsotg, ep0, NULL, 0);
 + if (ret) {
 + dev_err(hsotg-dev,
 + %s: failed to send reply\n, __func__);
 + return ret;
 + }
 + break;
 + default:
 + return -ENOENT;
 + }
 + break;
 +
 + case USB_RECIP_ENDPOINT:
 + ep = ep_from_windex(hsotg, wIndex);
   if (!ep) {
   dev_dbg(hsotg-dev, %s: no endpoint for 0x%04x\n,
 - __func__, 

Re: [PATCH 11/11] usb: core: fix a race with usb_queue_reset_device()

2015-01-21 Thread Olivier Sobrie
Hello Alan,

On Tue, Jan 20, 2015 at 10:26:30AM -0500, Alan Stern wrote:
 On Tue, 20 Jan 2015, Olivier Sobrie wrote:
 
  When usb_queue_reset() is called it schedules a work in view of
  resetting the usb interface. When the reset work is running, it
  can be scheduled again (e.g. by the usb disconnect method of
  the driver).
  
  Consider that the reset work is queued again while the reset work
  is running and that this work leads to a forced unbinding of the
  usb interface (e.g. because a driver is bound to the interface
  and has no pre/post_reset methods - see usb_reset_device()).
  In such condition, usb_unbind_interface() gets called and this
  function calls usb_cancel_queued_reset() which does nothing
  because the flag reset_running is set to 1. The second reset
  work that has been scheduled is therefore not cancelled.
  Later, the usb_reset_device() tries to rebind the interface.
  If it fails, then the usb interface context which contain the
  reset work struct is freed and it most likely crash when the
  second reset work tries to be run.
 
 There was an earlier patch posted for testing (no results yet)  
 affecting this same region of code:
 
   http://marc.info/?l=linux-usbm=142064533924019w=2
 
 It should fix the problem described here, because (among other things) 
 it adds usb_get/put_intf calls to the delayed-reset routines.

I tested your patch. It also fixes the problem I observed.
You can drop mine.

For your info:

My test consists in powering down a usb hso modem while one of its
serial port is opened. It leads to two URB failures, each urb callback
queues a reset.
Without your fix (or without the one I sent), a crash happens after
less than ~20 power up/down sequences. With your fix, after more than
1000 power up/down I don't see any crash.

Thanks,

-- 
Olivier
--
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