Re: [Patch v9 3/3] phy: Add Qualcomm DWC3 HS/SS PHY driver

2014-09-15 Thread Kishon Vijay Abraham I
Hi,

On Sunday 14 September 2014 07:54 AM, Felipe Balbi wrote:
 Hi,
 
 On Sat, Sep 13, 2014 at 12:16:01PM +0530, Kishon Vijay Abraham I wrote:
 On Saturday 13 September 2014 12:58 AM, Andy Gross wrote:
 This patch adds a new driver for the Qualcomm USB 3.0 PHY that exists on 
 some
 Qualcomm platforms.  This driver uses the generic PHY framework and will
 interact with the DWC3 controller.

 Do you have dt documentation for this driver?
 
 see patch 1

hmm.. missed that.
 
 +static inline void qcom_dwc3_phy_write_readback(
 +   struct qcom_dwc3_usb_phy *phy_dwc3, u32 offset,
 +   const u32 mask, u32 val)
 +{
 +   u32 write_val, tmp = readl(phy_dwc3-base + offset);
 +
 +   tmp = ~mask;   /* retain other bits */
 +   write_val = tmp | val;
 +
 +   writel(write_val, phy_dwc3-base + offset);
 +
 +   /* Read back to see if val was written */

 Does it fail sometime? I'm not sure if this should be present in the
 driver since this looks more of a debug code.
 
 this was mentioned before. Silicon bug.

okay.
 
 +   writel_relaxed(data | SSUSB_CTRL_SS_PHY_RESET,
 +   phy_dwc3-base + SSUSB_PHY_CTRL_REG);
 +   usleep_range(2000, 2200);

 use msleep here..
 
 why ? usleep_range() gives the scheduler oportunity to group timers.

Was of the opinion that for larger delays msleep should be used. But looks like
it is only for 10+ ms (Documentation/timers/timers-howto.txt).

Thanks
Kishon
--
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 v3 0/9] Tegra xHCI support

2014-09-15 Thread Tomeu Vizoso
On 12 September 2014 18:37, Andrew Bresticker abres...@chromium.org wrote:
 On Tue, Sep 9, 2014 at 1:21 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:
 On 8 September 2014 18:22, Andrew Bresticker abres...@chromium.org wrote:
 On Mon, Sep 8, 2014 at 8:34 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:
 On 2 September 2014 23:34, Andrew Bresticker abres...@chromium.org wrote:

 Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
 USB3.0 memory sticks and ethernet dongles using controller firmware
 recently posted by Andrew Chew [2].

 I have had mixed results when testing this on a Jetson TK1 board. Of 8
 USB devices I tested with, about half where probed correctly, but the
 other half repeatedly fail in hub_port_init because in the GET_STATUS
 right after the reset, the C_PORT_CONNECTION bit is set.

 I don't see any correlation between the failure and the kind of usb
 device, but I don't have much experience with USB implementations
 either.

 Hmm... I haven't seen that before.  Which particular devices were you using?

 Here they are:

 work:

 Genius keyboard: 05d5:6782
 Logitech mouse: 046d:c06a
 Denver MP3 player: 10d6:1100
 Atheros Bluetooth dongle: 0cf3:3005

 don't work:

 MCS7830 ethernet dongle: 9710:7830
 Genesys Logic hub: 05e3:0608

 I tried the hub and it works just fine for me... Have you tried this
 on any other boards like Big or Blaze?

I have a Blaze here, but haven't been able to get the external ports
to power up. I don't have schematics nor a strong interest to get that
fixed myself, as I can test my code just fine with the Blaze's
internal camera and the devices that do work on the Jetson.

I'm using the firmware file that was posted recently:

xhci-tegra 7009.usb: Firmware timestamp: 2014-05-02 02:22:50 UTC,
Falcon state 0x20

If things work for you with the same sources, .config and firmware, I
can only think of the hw being different (other hw revision?).

Regards,

Tomeu
--
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] libusbg: Always add '\0' at end of string

2014-09-15 Thread Krzysztof Opasiak
 -Original Message-
 From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-
 ow...@vger.kernel.org] On Behalf Of David Laight
 Sent: Friday, September 12, 2014 11:34 AM
 To: 'Krzysztof Opasiak'; matt.por...@linaro.org; linux-
 u...@vger.kernel.org
 Cc: s.wa...@samsung.com; k.lewando...@samsung.com;
 andrze...@samsung.com; m.szyprow...@samsung.com;
 philippedesw...@gmail.com
 Subject: RE: [PATCH 2/9] libusbg: Always add '\0' at end of string
 
 From: Krzysztof Opasiak
  strncpy() may not append trailing '\0' so let's append
  it always at end of string to avoid getting into troubles.
 
 Silently truncating strings just gives other errors.
 You really need to verify that it doesn't matter.
 ...
  diff --git a/src/usbg.c b/src/usbg.c
  index 0cc778b..785c01a 100644
  --- a/src/usbg.c
  +++ b/src/usbg.c
  @@ -1324,10 +1324,12 @@ size_t
 usbg_get_configfs_path_len(usbg_state *s)
   int usbg_get_configfs_path(usbg_state *s, char *buf, size_t len)
   {
  int ret = USBG_SUCCESS;
  -   if (s  buf)
  +   if (s  buf) {
  strncpy(buf, s-path, len);
  -   else
  +   buf[len - 1] = '\0';
  +   } else {
  ret = USBG_ERROR_INVALID_PARAM;
  +   }
 
  return ret;
   }
 
 I would use the much shorter form:
   if (!s || !buf)
   return USBG_ERROR_INVALID_PARAM;
 
   buf[--len] = 0;
   strncpy(buf, s-path, len);
   return USBG_SUCCESS;
 
 Although can either 's' or 'buf' actually be NULL?
 If you are being over-defensive can 'len' be zero?
 

Oh that's true. It can be done in shorter form.
Yes, we should also check if len is 0.
Will be fixed in v2.

Thanks,
Krzysztof Opasiak


--
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 fix for 3.17 v4] uas: Add a quirk for rejecting ATA_12 and ATA_16

2014-09-15 Thread Hans de Goede
Hi Greg,

Sorry for the high number of iterations on this one. After the documentation
issues pointed out during review, I've just received a report from a user
that (as I already suspected) another seagate disk enclosure also benifits
from this quirk. So this version sets the quirk for 2 different seagate
models.

Regards,

Hans
--
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 fix for 3.17 v4] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Hans de Goede
And set this quirk for the Seagate Expansion Desk (0bc2:2312), as that one
seems to hang upon receiving an ATA_12 or ATA_16 command.

https://bugzilla.kernel.org/show_bug.cgi?id=79511
https://bbs.archlinux.org/viewtopic.php?id=183190

While at it also add missing documentation for the u value for usb-storage
quirks.

Cc: sta...@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede hdego...@redhat.com

--
Changes in v2: Add documentation for new t and u usb-storage.quirks flags
Changes in v3: Fix typo in documentation
Changes in v4: Also apply the quirk to (0bc2:3312)
---
 Documentation/kernel-parameters.txt |  3 +++
 drivers/usb/storage/uas.c   | 13 +
 drivers/usb/storage/unusual_uas.h   | 23 +--
 drivers/usb/storage/usb.c   |  6 +-
 include/linux/usb_usual.h   |  2 ++
 5 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 5ae8608..ec6b25a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3541,6 +3541,9 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
bogus residue values);
s = SINGLE_LUN (the device has only one
Logical Unit);
+   t = NO_ATA_1X (don't allow ATA(12) and ATA(16)
+   commands, uas only);
+   u = IGNORE_UAS (do not try to use uas);
w = NO_WP_DETECT (don't test whether the
medium is write-protected).
Example: quirks=0419:aaf5:rl,0421:0433:rc
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 3f42785..75d2ccd 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -28,6 +28,7 @@
 #include scsi/scsi_tcq.h
 
 #include uas-detect.h
+#include scsiglue.h
 
 /*
  * The r00-r01c specs define this version of the SENSE IU data structure.
@@ -49,6 +50,7 @@ struct uas_dev_info {
struct usb_anchor cmd_urbs;
struct usb_anchor sense_urbs;
struct usb_anchor data_urbs;
+   unsigned long flags;
int qdepth, resetting;
struct response_iu response;
unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe;
@@ -714,6 +716,15 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
 
BUILD_BUG_ON(sizeof(struct uas_cmd_info)  sizeof(struct scsi_pointer));
 
+   if ((devinfo-flags  US_FL_NO_ATA_1X) 
+   (cmnd-cmnd[0] == ATA_12 || cmnd-cmnd[0] == ATA_16)) {
+   memcpy(cmnd-sense_buffer, usb_stor_sense_invalidCDB,
+  sizeof(usb_stor_sense_invalidCDB));
+   cmnd-result = SAM_STAT_CHECK_CONDITION;
+   cmnd-scsi_done(cmnd);
+   return 0;
+   }
+
spin_lock_irqsave(devinfo-lock, flags);
 
if (devinfo-resetting) {
@@ -1080,6 +1091,8 @@ static int uas_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
devinfo-resetting = 0;
devinfo-running_task = 0;
devinfo-shutdown = 0;
+   devinfo-flags = id-driver_info;
+   usb_stor_adjust_quirks(udev, devinfo-flags);
init_usb_anchor(devinfo-cmd_urbs);
init_usb_anchor(devinfo-sense_urbs);
init_usb_anchor(devinfo-data_urbs);
diff --git a/drivers/usb/storage/unusual_uas.h 
b/drivers/usb/storage/unusual_uas.h
index 724..3ff2dd4 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -40,13 +40,16 @@
  * and don't forget to CC: the USB development list linux-usb@vger.kernel.org
  */
 
-/*
- * This is an example entry for the US_FL_IGNORE_UAS flag. Once we have an
- * actual entry using US_FL_IGNORE_UAS this entry should be removed.
- *
- * UNUSUAL_DEV(  0xabcd, 0x1234, 0x0100, 0x0100,
- * Example,
- * Storage with broken UAS,
- * USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- * US_FL_IGNORE_UAS),
- */
+/* https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
+UNUSUAL_DEV(0x0bc2, 0x2312, 0x, 0x,
+   Seagate,
+   Expansion Desk,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_NO_ATA_1X),
+
+/* https://bbs.archlinux.org/viewtopic.php?id=183190 */
+UNUSUAL_DEV(0x0bc2, 0x3312, 0x, 0x,
+   Seagate,
+   Expansion Desk,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_NO_ATA_1X),
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index cedb292..b9d1b93 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -478,7 +478,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
unsigned long *fflags)
US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
   

RE: [PATCH fix for 3.17] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread David Laight
From: Alan Stern
...
  p = quirks;
  while (*p) {
  @@ -543,6 +544,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
  unsigned long *fflags)
  case 's':
  f |= US_FL_SINGLE_LUN;
  break;
  +   case 't':
  +   f |= US_FL_NO_ATA_1X;
  +   break;
  case 'u':
  f |= US_FL_IGNORE_UAS;
  break;
 
 You must not add an aditional value for a module parameter without
 documenting it in Documentation/kernel-parameters.txt.

How can this work as a 'module parameter'?
I might want to use two different usb-scsi devices that have different
requirements.

David



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


Re: [PATCH v4 7/9] usb: rename transceiver and phy to usb_phy in ChipIdea

2014-09-15 Thread Antoine Tenart
On Sat, Sep 13, 2014 at 06:27:06AM +, Peter Chen wrote:
  
  On Thu, Sep 11, 2014 at 08:28:59AM +0800, Peter Chen wrote:
   On Wed, Sep 03, 2014 at 09:40:38AM +0200, Antoine Tenart wrote:
  
   Again, rebase my next-tree, and modify the msm part.
  
  git://github.com/hzpeterchen/linux-usb.git ci-for-usb-next ?
  
 
 Yes.
 
  I can do that. But that would be easier if you rebased this branch on top 
  of at
  least v3.17-rc1 so that other series depending on this one could be tested 
  easily
  (like my other series introducing the USB support for Marvell Berlin).
  
  Antoine
  
 Done 

Thanks! I'll send a new version today then.

Antoine

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


[PATCH v5 3/9] usb: add support to the generic PHY framework in OTG

2014-09-15 Thread Antoine Tenart
This patch adds support of the PHY framework in OTG and keeps the USB
PHY compatibility. Here the only modification is to add PHY member in
the OTG structure, along with the USB PHY one.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 include/linux/usb/otg.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 978fbbb0e266..52661c5da690 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -9,11 +9,14 @@
 #ifndef __LINUX_USB_OTG_H
 #define __LINUX_USB_OTG_H
 
+#include linux/phy/phy.h
 #include linux/usb/phy.h
 
 struct usb_otg {
u8  default_a;
 
+   struct phy  *phy;
+   /* old usb_phy interface */
struct usb_phy  *usb_phy;
struct usb_bus  *host;
struct usb_gadget   *gadget;
-- 
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 v5 5/9] usb: rename gen_phy to phy in HCD

2014-09-15 Thread Antoine Tenart
The patch adding support to the generic PHY framework introduced a
'gen_phy' member in the HCD structure. Rename it to 'phy' to have a
consistent USB framework.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/core/hcd.c  | 22 +++---
 include/linux/usb/hcd.h |  4 +++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 86fdce55ae16..6619239baf6d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2665,7 +2665,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
phy_put(phy);
goto err_phy;
}
-   hcd-gen_phy = phy;
+   hcd-phy = phy;
}
}
 
@@ -2812,11 +2812,11 @@ err_allocate_root_hub:
 err_register_bus:
hcd_buffer_destroy(hcd);
 err_create_buf:
-   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-gen_phy) {
-   phy_power_off(hcd-gen_phy);
-   phy_exit(hcd-gen_phy);
-   phy_put(hcd-gen_phy);
-   hcd-gen_phy = NULL;
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   phy_power_off(hcd-phy);
+   phy_exit(hcd-phy);
+   phy_put(hcd-phy);
+   hcd-phy = NULL;
}
 err_phy:
if (hcd-remove_phy  hcd-usb_phy) {
@@ -2896,11 +2896,11 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(hcd-self);
hcd_buffer_destroy(hcd);
 
-   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-gen_phy) {
-   phy_power_off(hcd-gen_phy);
-   phy_exit(hcd-gen_phy);
-   phy_put(hcd-gen_phy);
-   hcd-gen_phy = NULL;
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   phy_power_off(hcd-phy);
+   phy_exit(hcd-phy);
+   phy_put(hcd-phy);
+   hcd-phy = NULL;
}
if (hcd-remove_phy  hcd-usb_phy) {
usb_phy_shutdown(hcd-usb_phy);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 604d2e6e0c1c..19b3fbd1f9e1 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -105,9 +105,11 @@ struct usb_hcd {
/*
 * OTG and some Host controllers need software interaction with phys;
 * other external phys should be software-transparent
+*
+* Keep the usb_phy for compatibility reasons, for now
 */
struct usb_phy  *usb_phy;
-   struct phy  *gen_phy;
+   struct phy  *phy;
 
/* Flags that need to be manipulated atomically because they can
 * change while the host controller is running.  Always use
-- 
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 v5 6/9] usb: allow to supply the PHY in the drivers when using HCD

2014-09-15 Thread Antoine Tenart
This patch modify the generic code handling PHYs to allow them to be
supplied from the drivers. This adds checks to ensure no PHY was already
there when looking for one in the generic code. This also makes sure we
do not modify its state in the generic HCD functions, it was provided by
the driver.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/core/hcd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6619239baf6d..dc0e46e5e618 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2646,7 +2646,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
 
-   if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  !hcd-phy) {
struct phy *phy = phy_get(hcd-self.controller, usb);
 
if (IS_ERR(phy)) {
@@ -2666,6 +2666,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
goto err_phy;
}
hcd-phy = phy;
+   hcd-remove_phy = 1;
}
}
 
@@ -2812,7 +2813,7 @@ err_allocate_root_hub:
 err_register_bus:
hcd_buffer_destroy(hcd);
 err_create_buf:
-   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-remove_phy  hcd-phy) {
phy_power_off(hcd-phy);
phy_exit(hcd-phy);
phy_put(hcd-phy);
@@ -2896,7 +2897,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(hcd-self);
hcd_buffer_destroy(hcd);
 
-   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-remove_phy  hcd-phy) {
phy_power_off(hcd-phy);
phy_exit(hcd-phy);
phy_put(hcd-phy);
-- 
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 v5 08/12] Documentation: bindings: add doc for the USB2 ChipIdea USB driver

2014-09-15 Thread Antoine Tenart
Document the USB2 ChipIdea driver (ci13xxx) bindings.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 .../devicetree/bindings/usb/ci-hdrc-usb2.txt   | 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt 
b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
new file mode 100644
index ..8dd6d8285dab
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
@@ -0,0 +1,22 @@
+* USB2 ChipIdea USB controller for ci13xxx
+
+Required properties:
+- compatible: should be chipidea,usb2
+- reg: base address and length of the registers
+- interrupts: interrupt for the USB controller
+
+Optional properties:
+- clocks: reference to the USB clock
+- phys: reference to the USB PHY
+- vbus-supply: reference to the VBUS regulator
+
+Example:
+
+   usb@f7ed {
+   compatible = chipidea,usb2;
+   reg = 0xf7ed 0x1;
+   interrupts = GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB0;
+   phys = usb_phy0;
+   vbus-supply = reg_usb0_vbus;
+   };
-- 
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 v5 05/12] phy: add the Berlin USB PHY driver

2014-09-15 Thread Antoine Tenart
Add the driver driving the Marvell Berlin USB PHY. This allows to
initialize the PHY and to use it from the USB driver later.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/phy/Kconfig  |   7 ++
 drivers/phy/Makefile |   1 +
 drivers/phy/phy-berlin-usb.c | 224 +++
 3 files changed, 232 insertions(+)
 create mode 100644 drivers/phy/phy-berlin-usb.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 0dd742719154..d1d73dd8c1fb 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,6 +15,13 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config PHY_BERLIN_USB
+   tristate Marvell Berlin USB PHY Driver
+   depends on ARCH_BERLIN  HAS_IOMEM  OF
+   select GENERIC_PHY
+   help
+ Enable this to support the USB PHY on Marvell Berlin SoCs.
+
 config PHY_BERLIN_SATA
tristate Marvell Berlin SATA PHY driver
depends on ARCH_BERLIN  HAS_IOMEM  OF
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 95c69ed5ed45..b12e84b69c23 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_PHY_BERLIN_USB)   += phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)  += phy-berlin-sata.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
diff --git a/drivers/phy/phy-berlin-usb.c b/drivers/phy/phy-berlin-usb.c
new file mode 100644
index ..f9f13067f50f
--- /dev/null
+++ b/drivers/phy/phy-berlin-usb.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2014 Marvell Technology Group Ltd.
+ *
+ * Antoine Tenart antoine.ten...@free-electrons.com
+ * Jisheng Zhang jszh...@marvell.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/gpio.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/of_gpio.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/reset.h
+
+#define USB_PHY_PLL0x04
+#define USB_PHY_PLL_CONTROL0x08
+#define USB_PHY_TX_CTRL0   0x10
+#define USB_PHY_TX_CTRL1   0x14
+#define USB_PHY_TX_CTRL2   0x18
+#define USB_PHY_RX_CTRL0x20
+#define USB_PHY_ANALOG 0x34
+
+/* USB_PHY_PLL */
+#define CLK_REF_DIV(x) ((x)  4)
+#define FEEDBACK_CLK_DIV(x)((x)  8)
+
+/* USB_PHY_PLL_CONTROL */
+#define CLK_STABLE BIT(0)
+#define PLL_CTRL_PIN   BIT(1)
+#define PLL_CTRL_REG   BIT(2)
+#define PLL_ON BIT(3)
+#define PHASE_OFF_TOL_125  (0x0  5)
+#define PHASE_OFF_TOL_250  BIT(5)
+#define KVC0_CALIB (0x0  9)
+#define KVC0_REG_CTRL  BIT(9)
+#define KVC0_HIGH  (0x0  10)
+#define KVC0_LOW   (0x3  10)
+#define CLK_BLK_EN BIT(13)
+
+/* USB_PHY_TX_CTRL0 */
+#define EXT_HS_RCAL_EN BIT(3)
+#define EXT_FS_RCAL_EN BIT(4)
+#define IMPCAL_VTH_DIV(x)  ((x)  5)
+#define EXT_RS_RCAL_DIV(x) ((x)  8)
+#define EXT_FS_RCAL_DIV(x) ((x)  12)
+
+/* USB_PHY_TX_CTRL1 */
+#define TX_VDD15_14(0x0  4)
+#define TX_VDD15_15BIT(4)
+#define TX_VDD15_16(0x2  4)
+#define TX_VDD15_17(0x3  4)
+#define TX_VDD12_VDD   (0x0  6)
+#define TX_VDD12_11BIT(6)
+#define TX_VDD12_12(0x2  6)
+#define TX_VDD12_13(0x3  6)
+#define LOW_VDD_EN BIT(8)
+#define TX_OUT_AMP(x)  ((x)  9)
+
+/* USB_PHY_TX_CTRL2 */
+#define TX_CHAN_CTRL_REG(x)((x)  0)
+#define DRV_SLEWRATE(x)((x)  4)
+#define IMP_CAL_FS_HS_DLY_0(0x0  6)
+#define IMP_CAL_FS_HS_DLY_1BIT(6)
+#define IMP_CAL_FS_HS_DLY_2(0x2  6)
+#define IMP_CAL_FS_HS_DLY_3(0x3  6)
+#define FS_DRV_EN_MASK(x)  ((x)  8)
+#define HS_DRV_EN_MASK(x)  ((x)  12)
+
+/* USB_PHY_RX_CTRL */
+#define PHASE_FREEZE_DLY_2_CL  (0x0  0)
+#define PHASE_FREEZE_DLY_4_CL  BIT(0)
+#define ACK_LENGTH_8_CL(0x0  2)
+#define ACK_LENGTH_12_CL   BIT(2)
+#define ACK_LENGTH_16_CL   (0x2  2)
+#define ACK_LENGTH_20_CL   (0x3  2)
+#define SQ_LENGTH_3(0x0  4)
+#define SQ_LENGTH_6BIT(4)
+#define SQ_LENGTH_9(0x2  4)
+#define SQ_LENGTH_12   (0x3  4)
+#define DISCON_THRESHOLD_260   (0x0  6)
+#define DISCON_THRESHOLD_270   BIT(6)
+#define DISCON_THRESHOLD_280   (0x2  6)
+#define DISCON_THRESHOLD_290   (0x3  6)
+#define SQ_THRESHOLD(x)((x)  8)
+#define LPF_COEF(x)((x)  12)
+#define INTPL_CUR_10   (0x0  14)
+#define INTPL_CUR_20   BIT(14)
+#define INTPL_CUR_30   (0x2  

[PATCH v5 07/12] usb: chipidea: add a usb2 driver for ci13xxx

2014-09-15 Thread Antoine Tenart
Add a USB2 ChipIdea driver for ci13xxx, with optional PHY, clock
and DMA mask, to support USB2 ChipIdea controllers that don't need
specific functions.

Tested on the Marvell Berlin SoCs USB controllers.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/usb/chipidea/Makefile   |   1 +
 drivers/usb/chipidea/ci_hdrc_usb2.c | 137 
 2 files changed, 138 insertions(+)
 create mode 100644 drivers/usb/chipidea/ci_hdrc_usb2.c

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 2f099c7df7b5..1fc86a2ca22d 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -10,6 +10,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o
 
 # Glue/Bridge layers go here
 
+obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_usb2.o
 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_msm.o
 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_zevio.o
 
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c 
b/drivers/usb/chipidea/ci_hdrc_usb2.c
new file mode 100644
index ..1ef0db79505a
--- /dev/null
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2014 Marvell Technology Group Ltd.
+ *
+ * Antoine Tenart antoine.ten...@free-electrons.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/clk.h
+#include linux/dma-mapping.h
+#include linux/module.h
+#include linux/of.h
+#include linux/platform_device.h
+#include linux/usb/chipidea.h
+#include linux/usb/hcd.h
+#include linux/usb/ulpi.h
+
+#include ci.h
+
+struct ci_hdrc_usb2_priv {
+   struct platform_device  *ci_pdev;
+   struct clk  *clk;
+};
+
+static int ci_hdrc_usb2_dt_probe(struct device *dev,
+struct ci_hdrc_platform_data *ci_pdata)
+{
+   ci_pdata-phy = of_phy_get(dev-of_node, 0);
+   if (IS_ERR(ci_pdata-phy)) {
+   if (PTR_ERR(ci_pdata-phy) == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+
+   /* PHY is optional */
+   ci_pdata-phy = NULL;
+   }
+
+   return 0;
+}
+
+static struct ci_hdrc_platform_data ci_default_pdata = {
+   .capoffset  = DEF_CAPOFFSET,
+   .flags  = CI_HDRC_REQUIRE_TRANSCEIVER |
+ CI_HDRC_DISABLE_STREAMING,
+};
+
+static int ci_hdrc_usb2_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct ci_hdrc_usb2_priv *priv;
+   struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(pdev-dev);
+   int ret;
+
+   if (!ci_pdata)
+   ci_pdata = ci_default_pdata;
+
+   priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+   if (!priv)
+   return -ENOMEM;
+
+   priv-clk = devm_clk_get(dev, NULL);
+   if (!IS_ERR(priv-clk)) {
+   ret = clk_prepare_enable(priv-clk);
+   if (ret) {
+   dev_err(dev, failed to enable the clock: %d\n, ret);
+   return ret;
+   }
+   }
+
+   if (dev-of_node) {
+   ret = ci_hdrc_usb2_dt_probe(dev, ci_pdata);
+   if (ret)
+   goto clk_err;
+   } else {
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
+   if (ret)
+   goto clk_err;
+   }
+
+   ci_pdata-name = dev_name(pdev-dev);
+
+   priv-ci_pdev = ci_hdrc_add_device(dev, pdev-resource,
+  pdev-num_resources, ci_pdata);
+   if (IS_ERR(priv-ci_pdev)) {
+   ret = PTR_ERR(priv-ci_pdev);
+   if (ret != -EPROBE_DEFER)
+   dev_err(dev,
+   failed to register ci_hdrc platform device: 
%d\n,
+   ret);
+   goto clk_err;
+   }
+
+   platform_set_drvdata(pdev, priv);
+
+   pm_runtime_no_callbacks(dev);
+   pm_runtime_enable(dev);
+
+   return 0;
+
+clk_err:
+   if (!IS_ERR(priv-clk))
+   clk_disable_unprepare(priv-clk);
+   return ret;
+}
+
+static int ci_hdrc_usb2_remove(struct platform_device *pdev)
+{
+   struct ci_hdrc_usb2_priv *priv = platform_get_drvdata(pdev);
+
+   pm_runtime_disable(pdev-dev);
+   ci_hdrc_remove_device(priv-ci_pdev);
+   clk_disable_unprepare(priv-clk);
+
+   return 0;
+}
+
+static const struct of_device_id ci_hdrc_usb2_of_match[] = {
+   { .compatible = chipidea,usb2 },
+   { }
+};
+MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
+
+static struct platform_driver ci_hdrc_usb2_driver = {
+   .probe  = ci_hdrc_usb2_probe,
+   .remove = ci_hdrc_usb2_remove,
+   .driver = {
+   .name   = chipidea-usb2,
+   .owner  = THIS_MODULE,
+   .of_match_table = 

[PATCH v5 11/12] ARM: dts: berlin: add BG2CD nodes for USB support

2014-09-15 Thread Antoine Tenart
From: Sebastian Hesselbarth sebastian.hesselba...@gmail.com

Adds nodes describing the Marvell Berlin BG2CD USB PHY and USB. The BG2CD
SoC has 2 USB ChipIdea controllers, with usb0 host-only and usb1 dual-role
capable.

Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 arch/arm/boot/dts/berlin2cd.dtsi | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/berlin2cd.dtsi b/arch/arm/boot/dts/berlin2cd.dtsi
index 68f7032b4686..5c6950531327 100644
--- a/arch/arm/boot/dts/berlin2cd.dtsi
+++ b/arch/arm/boot/dts/berlin2cd.dtsi
@@ -66,6 +66,22 @@
clocks = chip CLKID_TWD;
};
 
+   usb_phy0: usb-phy@b74000 {
+   compatible = marvell,berlin2cd-usb-phy;
+   reg = 0xb74000 0x128;
+   #phy-cells = 0;
+   resets = chip 0x178 23;
+   status = disabled;
+   };
+
+   usb_phy1: usb-phy@b78000 {
+   compatible = marvell,berlin2cd-usb-phy;
+   reg = 0xb78000 0x128;
+   #phy-cells = 0;
+   resets = chip 0x178 24;
+   status = disabled;
+   };
+
apb@e8 {
compatible = simple-bus;
#address-cells = 1;
@@ -242,6 +258,24 @@
};
};
 
+   usb0: usb@ed {
+   compatible = chipidea,usb2;
+   reg = 0xed 0x200;
+   interrupts = GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB0;
+   usb-phy = usb_phy0;
+   status = disabled;
+   };
+
+   usb1: usb@ee {
+   compatible = chipidea,usb2;
+   reg = 0xee 0x200;
+   interrupts = GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB1;
+   usb-phy = usb_phy1;
+   status = disabled;
+   };
+
apb@fc {
compatible = simple-bus;
#address-cells = 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 v5 06/12] Documentation: bindings: add doc for the Berlin USB PHY

2014-09-15 Thread Antoine Tenart
Document the bindings of the Marvell Berlin USB PHY driver.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 Documentation/devicetree/bindings/phy/berlin-usb-phy.txt | 16 
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/berlin-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/berlin-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/berlin-usb-phy.txt
new file mode 100644
index ..be33780f668e
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/berlin-usb-phy.txt
@@ -0,0 +1,16 @@
+* Marvell Berlin USB PHY
+
+Required properties:
+- compatible: marvell,berlin2-usb-phy or marvell,berlin2cd-usb-phy
+- reg: base address and length of the registers
+- #phys-cells: should be 0
+- resets: reference to the reset controller
+
+Example:
+
+   usb-phy@f774000 {
+   compatible = marvell,berlin2-usb-phy;
+   reg = 0xf774000 0x128;
+   #phy-cells = 0;
+   resets = chip 0x104 14;
+   };
-- 
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 v5 12/12] ARM: dts: berlin: enable USB on the Google Chromecast

2014-09-15 Thread Antoine Tenart
From: Sebastian Hesselbarth sebastian.hesselba...@gmail.com

Enable usb1 on Google Chromecast which is connected to micro-USB
plug used for external power supply, too.

Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 arch/arm/boot/dts/berlin2cd-google-chromecast.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/berlin2cd-google-chromecast.dts 
b/arch/arm/boot/dts/berlin2cd-google-chromecast.dts
index bcd81ffc495d..5c42c3bfb613 100644
--- a/arch/arm/boot/dts/berlin2cd-google-chromecast.dts
+++ b/arch/arm/boot/dts/berlin2cd-google-chromecast.dts
@@ -27,3 +27,7 @@
 };
 
 uart0 { status = okay; };
+
+usb_phy1 { status = okay; };
+
+usb1 { status = okay; };
-- 
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 v5 04/12] ARM: dts: berlin: add a required reset property in the chip controller node

2014-09-15 Thread Antoine Tenart
The chip controller node now also describes the Marvell Berlin reset
controller. Add the required 'reset-cells' property.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
---
 arch/arm/boot/dts/berlin2.dtsi   | 1 +
 arch/arm/boot/dts/berlin2cd.dtsi | 1 +
 arch/arm/boot/dts/berlin2q.dtsi  | 1 +
 3 files changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/berlin2.dtsi b/arch/arm/boot/dts/berlin2.dtsi
index 9d7c810ebd0b..d7e81e124de0 100644
--- a/arch/arm/boot/dts/berlin2.dtsi
+++ b/arch/arm/boot/dts/berlin2.dtsi
@@ -249,6 +249,7 @@
chip: chip-control@ea {
compatible = marvell,berlin2-chip-ctrl;
#clock-cells = 1;
+   #reset-cells = 2;
reg = 0xea 0x400;
clocks = refclk;
clock-names = refclk;
diff --git a/arch/arm/boot/dts/berlin2cd.dtsi b/arch/arm/boot/dts/berlin2cd.dtsi
index cc1df65da504..68f7032b4686 100644
--- a/arch/arm/boot/dts/berlin2cd.dtsi
+++ b/arch/arm/boot/dts/berlin2cd.dtsi
@@ -231,6 +231,7 @@
chip: chip-control@ea {
compatible = marvell,berlin2cd-chip-ctrl;
#clock-cells = 1;
+   #reset-cells = 2;
reg = 0xea 0x400;
clocks = refclk;
clock-names = refclk;
diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi
index 400c40fceccc..ffba5c3bdab8 100644
--- a/arch/arm/boot/dts/berlin2q.dtsi
+++ b/arch/arm/boot/dts/berlin2q.dtsi
@@ -332,6 +332,7 @@
chip: chip-control@ea {
compatible = marvell,berlin2q-chip-ctrl;
#clock-cells = 1;
+   #reset-cells = 2;
reg = 0xea 0x400, 0xdd0170 0x10;
clocks = refclk;
clock-names = refclk;
-- 
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 v5 10/12] ARM: dts: Berlin: enable USB on the BG2Q DMP

2014-09-15 Thread Antoine Tenart
Enable the 2 available USB PHY and USB nodes on the Marvell Berlin BG2Q
DMP.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 arch/arm/boot/dts/berlin2q-marvell-dmp.dts | 53 ++
 1 file changed, 53 insertions(+)

diff --git a/arch/arm/boot/dts/berlin2q-marvell-dmp.dts 
b/arch/arm/boot/dts/berlin2q-marvell-dmp.dts
index a357ce02a64e..663aedb173e0 100644
--- a/arch/arm/boot/dts/berlin2q-marvell-dmp.dts
+++ b/arch/arm/boot/dts/berlin2q-marvell-dmp.dts
@@ -7,6 +7,8 @@
  */
 
 /dts-v1/;
+
+#include dt-bindings/gpio/gpio.h
 #include berlin2q.dtsi
 
 / {
@@ -21,6 +23,39 @@
choosen {
bootargs = console=ttyS0,115200 earlyprintk;
};
+
+   regulators {
+   compatible = simple-bus;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   reg_usb0_vbus: regulator@0 {
+   compatible = regulator-fixed;
+   regulator-name = usb0_vbus;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = portb 8 GPIO_ACTIVE_HIGH;
+   enable-active-high;
+   };
+
+   reg_usb1_vbus: regulator@1 {
+   compatible = regulator-fixed;
+   regulator-name = usb1_vbus;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = portb 10 GPIO_ACTIVE_HIGH;
+   enable-active-high;
+   };
+
+   reg_usb2_vbus: regulator@2 {
+   compatible = regulator-fixed;
+   regulator-name = usb2_vbus;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = portb 12 GPIO_ACTIVE_HIGH;
+   enable-active-high;
+   };
+   };
 };
 
 sdhci1 {
@@ -45,3 +80,21 @@
 uart0 {
status = okay;
 };
+
+usb_phy0 {
+   status = okay;
+};
+
+usb_phy2 {
+   status = okay;
+};
+
+usb0 {
+   vbus-supply = reg_usb0_vbus;
+   status = okay;
+};
+
+usb2 {
+   vbus-supply = reg_usb2_vbus;
+   status = okay;
+};
-- 
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 v5 09/12] ARM: dts: berlin: add BG2Q nodes for USB support

2014-09-15 Thread Antoine Tenart
Adds nodes describing the Marvell Berlin BG2Q USB PHY and USB. The BG2Q
SoC has 3 USB host controller, compatible with ChipIdea.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 arch/arm/boot/dts/berlin2q.dtsi | 52 +
 1 file changed, 52 insertions(+)

diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi
index ffba5c3bdab8..faf7cbe2af20 100644
--- a/arch/arm/boot/dts/berlin2q.dtsi
+++ b/arch/arm/boot/dts/berlin2q.dtsi
@@ -114,6 +114,39 @@
#interrupt-cells = 3;
};
 
+   usb_phy2: phy@a2f400 {
+   compatible = marvell,berlin2-usb-phy;
+   reg = 0xa2f400 0x128;
+   #phy-cells = 0;
+   resets = chip 0x104 14;
+   status = disabled;
+   };
+
+   usb2: usb@a3 {
+   compatible = chipidea,usb2;
+   reg = 0xa3 0x1;
+   interrupts = GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB2;
+   phys = usb_phy2;
+   status = disabled;
+   };
+
+   usb_phy0: phy@b74000 {
+   compatible = marvell,berlin2-usb-phy;
+   reg = 0xb74000 0x128;
+   #phy-cells = 0;
+   resets = chip 0x104 12;
+   status = disabled;
+   };
+
+   usb_phy1: phy@b78000 {
+   compatible = marvell,berlin2-usb-phy;
+   reg = 0xb78000 0x128;
+   #phy-cells = 0;
+   resets = chip 0x104 13;
+   status = disabled;
+   };
+
cpu-ctrl@dd {
compatible = marvell,berlin-cpu-ctrl;
reg = 0xdd 0x1;
@@ -348,6 +381,24 @@
};
};
 
+   usb0: usb@ed {
+   compatible = chipidea,usb2;
+   reg = 0xed 0x1;
+   interrupts = GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB0;
+   phys = usb_phy0;
+   status = disabled;
+   };
+
+   usb1: usb@ee {
+   compatible = chipidea,usb2;
+   reg = 0xee 0x1;
+   interrupts = GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH;
+   clocks = chip CLKID_USB1;
+   phys = usb_phy1;
+   status = disabled;
+   };
+
apb@fc {
compatible = simple-bus;
#address-cells = 1;
@@ -440,5 +491,6 @@
interrupts = GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH;
};
};
+
};
 };
-- 
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 v5 00/12] ARM: berlin: USB support

2014-09-15 Thread Antoine Tenart
This series adds the support for ChipIdea USB2 (ci13xxx) controllers,
the USB PHYs of the Marvell Berlin SoCs and also adds a reset
controller for these SoCs.

The reset controller is used by the PHY driver and shares the
existing chip controller node with the clocks and one pin controller.

The Marvell Berlin USB controllers are host only on the BG2Q and are
compatible with USB ChipIdea. We here add a glue to use the available
common functions for this kind of controllers, and add a generic USB2
ChipIdea driver. A PHY driver is also added to control the USB PHY.

This series applies on top of the generic PHY support in the USB
framework[1].

Patches 1-4 have already been taken by Sebastian.

Changes since v4:
- fixed the error handling of ci_hdrc_usb2_probe()

Changes since v3:
- removed the DMA mask property
- moved the clock handling in the common probe function
- fixed the documentation for the USB2 ChipIdea USB PHY binding
- made sure the reset bit is 0-31 in the reset driver

Changes since v2:
- moved the PHY driver to the generic PHY framework
- changed the compatible to 'chipidea,usb2'
- added a property to set the DMA mask in the USB2 CI driver
- separated dt specific calls in the CI probing function
- rebased on top of the generic PHY support for CI[1]

Changes since v1:
- made the Berlin CI USB driver a generic one
- added support to custom offset for the reset register
- added fixed regulators to support supply the VBUS
- modified the PHY driver to support the one one the BG2CD as
  well
- documented the reset properties
- added bindings for the BG2CD
- cosmetic fixes

[1] git://git.free-electrons.com:users/antoine-tenart/linux.git usb-phy

Antoine Tenart (10):
  reset: add the Berlin reset controller driver
  Documentation: bindings: add reset bindings docs for Marvell Berlin
SoCs
  ARM: Berlin: select the reset controller
  ARM: dts: berlin: add a required reset property in the chip controller
node
  phy: add the Berlin USB PHY driver
  Documentation: bindings: add doc for the Berlin USB PHY
  usb: chipidea: add a usb2 driver for ci13xxx
  Documentation: bindings: add doc for the USB2 ChipIdea USB driver
  ARM: dts: berlin: add BG2Q nodes for USB support
  ARM: dts: Berlin: enable USB on the BG2Q DMP

Sebastian Hesselbarth (2):
  ARM: dts: berlin: add BG2CD nodes for USB support
  ARM: dts: berlin: enable USB on the Google Chromecast

 .../devicetree/bindings/arm/marvell,berlin.txt |  10 +
 .../devicetree/bindings/phy/berlin-usb-phy.txt |  16 ++
 .../devicetree/bindings/usb/ci-hdrc-usb2.txt   |  22 ++
 arch/arm/boot/dts/berlin2.dtsi |   1 +
 arch/arm/boot/dts/berlin2cd-google-chromecast.dts  |   4 +
 arch/arm/boot/dts/berlin2cd.dtsi   |  35 
 arch/arm/boot/dts/berlin2q-marvell-dmp.dts |  53 +
 arch/arm/boot/dts/berlin2q.dtsi|  53 +
 arch/arm/mach-berlin/Kconfig   |   2 +
 drivers/phy/Kconfig|   7 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-berlin-usb.c   | 224 +
 drivers/reset/Makefile |   1 +
 drivers/reset/reset-berlin.c   | 131 
 drivers/usb/chipidea/Makefile  |   1 +
 drivers/usb/chipidea/ci_hdrc_usb2.c| 137 +
 16 files changed, 698 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/berlin-usb-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
 create mode 100644 drivers/phy/phy-berlin-usb.c
 create mode 100644 drivers/reset/reset-berlin.c
 create mode 100644 drivers/usb/chipidea/ci_hdrc_usb2.c

-- 
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 v5 03/12] ARM: Berlin: select the reset controller

2014-09-15 Thread Antoine Tenart
The Marvell Berlin SoCs now has a reset controller. Add the needed
configuration.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 arch/arm/mach-berlin/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
index 24f85be71671..5803f773a065 100644
--- a/arch/arm/mach-berlin/Kconfig
+++ b/arch/arm/mach-berlin/Kconfig
@@ -1,11 +1,13 @@
 menuconfig ARCH_BERLIN
bool Marvell Berlin SoCs if ARCH_MULTI_V7
+   select ARCH_HAS_RESET_CONTROLLER
select ARCH_REQUIRE_GPIOLIB
select ARM_GIC
select GENERIC_IRQ_CHIP
select DW_APB_ICTL
select DW_APB_TIMER_OF
select PINCTRL
+   select RESET_CONTROLLER
 
 if ARCH_BERLIN
 
-- 
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 v5 9/9] usb: chipidea: add support to the generic PHY framework in ChipIdea

2014-09-15 Thread Antoine Tenart
This patch adds support of the PHY framework for ChipIdea drivers.
Changes are done in both the ChipIdea common code and in the drivers
accessing the PHY. This is done by adding a new PHY member in
ChipIdea's structures and by taking care of it in the code.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/usb/chipidea/ci.h  |  5 ++-
 drivers/usb/chipidea/core.c| 83 +-
 drivers/usb/chipidea/debug.c   |  2 +-
 drivers/usb/chipidea/host.c|  5 ++-
 drivers/usb/chipidea/otg_fsm.c |  6 ++-
 include/linux/usb/chipidea.h   |  2 +
 6 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index dac5ab6adfa2..7e9e8223672a 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -161,7 +161,8 @@ struct hw_bank {
  * @test_mode: the selected test mode
  * @platdata: platform specific information supplied by parent device
  * @vbus_active: is VBUS active
- * @usb_phy: pointer to USB PHY, if any
+ * @phy: pointer to PHY, if any
+ * @usb_phy: pointer to USB PHY, if any and if using the USB PHY framework
  * @hcd: pointer to usb_hcd for ehci host driver
  * @debugfs: root dentry for this controller in debugfs
  * @id_event: indicates there is an id event, and handled at ci_otg_work
@@ -202,6 +203,8 @@ struct ci_hdrc {
 
struct ci_hdrc_platform_data*platdata;
int vbus_active;
+   struct phy  *phy;
+   /* old usb_phy interface */
struct usb_phy  *usb_phy;
struct usb_hcd  *hcd;
struct dentry   *debugfs;
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ee96b0696a7b..e1d3d3f44075 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -47,6 +47,7 @@
 #include linux/delay.h
 #include linux/device.h
 #include linux/dma-mapping.h
+#include linux/phy/phy.h
 #include linux/platform_device.h
 #include linux/module.h
 #include linux/idr.h
@@ -293,6 +294,49 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 }
 
 /**
+ * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
+ * interfaces
+ * @ci: the controller
+ *
+ * This function returns an error code if the phy failed to init
+ */
+static int _ci_usb_phy_init(struct ci_hdrc *ci)
+{
+   int ret;
+
+   if (ci-phy) {
+   ret = phy_init(ci-phy);
+   if (ret)
+   return ret;
+
+   ret = phy_power_on(ci-phy);
+   if (ret) {
+   phy_exit(ci-phy);
+   return ret;
+   }
+   } else {
+   ret = usb_phy_init(ci-usb_phy);
+   }
+
+   return ret;
+}
+
+/**
+ * _ci_usb_phy_exit: deinitialize phy taking in account both phy and usb_phy
+ * interfaces
+ * @ci: the controller
+ */
+static void ci_usb_phy_exit(struct ci_hdrc *ci)
+{
+   if (ci-phy) {
+   phy_power_off(ci-phy);
+   phy_exit(ci-phy);
+   } else {
+   usb_phy_shutdown(ci-usb_phy);
+   }
+}
+
+/**
  * ci_usb_phy_init: initialize phy according to different phy type
  * @ci: the controller
   *
@@ -306,7 +350,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_UTMI:
case USBPHY_INTERFACE_MODE_UTMIW:
case USBPHY_INTERFACE_MODE_HSIC:
-   ret = usb_phy_init(ci-usb_phy);
+   ret = _ci_usb_phy_init(ci);
if (ret)
return ret;
hw_phymode_configure(ci);
@@ -314,12 +358,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_ULPI:
case USBPHY_INTERFACE_MODE_SERIAL:
hw_phymode_configure(ci);
-   ret = usb_phy_init(ci-usb_phy);
+   ret = _ci_usb_phy_init(ci);
if (ret)
return ret;
break;
default:
-   ret = usb_phy_init(ci-usb_phy);
+   ret = _ci_usb_phy_init(ci);
}
 
return ret;
@@ -595,23 +639,26 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   if (ci-platdata-usb_phy)
+   if (ci-platdata-phy) {
+   ci-phy = ci-platdata-phy;
+   } else if (ci-platdata-usb_phy) {
ci-usb_phy = ci-platdata-usb_phy;
-   else
+   } else {
+   ci-phy = devm_phy_get(dev, usb-phy);
ci-usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 
-   if (IS_ERR(ci-usb_phy)) {
-   ret = PTR_ERR(ci-usb_phy);
-   /*
-* if -ENXIO is returned, it means PHY layer wasn't
-* enabled, so it makes no sense to return -EPROBE_DEFER
-* in that case, since no PHY driver will ever probe.
-*/
-   

[PATCH v5 02/12] Documentation: bindings: add reset bindings docs for Marvell Berlin SoCs

2014-09-15 Thread Antoine Tenart
Add the reset binding documentation to the SoC binding documentation as
the reset driver in Marvell Berlin SoC is part of the chip/system
control registers. This patch adds the required properties to configure
the reset controller.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
---
 Documentation/devicetree/bindings/arm/marvell,berlin.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/marvell,berlin.txt 
b/Documentation/devicetree/bindings/arm/marvell,berlin.txt
index 904de5781f44..a99eb9eb14c0 100644
--- a/Documentation/devicetree/bindings/arm/marvell,berlin.txt
+++ b/Documentation/devicetree/bindings/arm/marvell,berlin.txt
@@ -106,11 +106,21 @@ Required subnode-properties:
 - groups: a list of strings describing the group names.
 - function: a string describing the function used to mux the groups.
 
+* Reset controller binding
+
+A reset controller is part of the chip control registers set. The chip control
+node also provides the reset. The register set is not at the same offset 
between
+Berlin SoCs.
+
+Required property:
+- #reset-cells: must be set to 2
+
 Example:
 
 chip: chip-control@ea {
compatible = marvell,berlin2-chip-ctrl;
#clock-cells = 1;
+   #reset-cells = 2;
reg = 0xea 0x400;
clocks = refclk, externaldev 0;
clock-names = refclk, video_ext0;
-- 
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 v5 0/9] usb: add support for the generic PHY framework

2014-09-15 Thread Antoine Tenart
Hi all,

This is an attempt to add more common USB code aware of the generic PHY
framework, while keeping the compatibility for the USB PHY one. It does
not add the full support, some USB PHY specific functions not being
available currently in the generic PHY subsystem (e.g. usb_phy_set_power()).
But it allows to use the generic PHY framework in other cases, and might
help others to convert their USB PHY drivers.

A little background: I submitted a series to support USB on Berlin SoCs[1].
One patch added a new PHY driver in drivers/usb/phy and Felipe asked it to
be in the generic PHY framework instead[2]. This PHY being used by a ChipIdea
driver, changes were needed in ChipIdea, OTG and HCD.

This is done in 3 steps:
1. moving the OTG state from the USB PHY structure to the OTG one
2. renaming the field 'phy' to 'usb_phy'
3. adding a field for the generic framework PHY and dissociating its
   use from the USB PHY one

Step 1 is in the first patch. Steps 2 and 3 are done for OTG, and ChipIdea
subsystems in patches 2-3, 7 and 9.

HCD generic PHY support was made by Sergei and Yoshihiro[1]. I added some
modifications to make this support consistent with this series in patches
4-6.

The usb_otg has been moved into the ci_hdrc structure in ChipIdea, in patch 8.

I tested it by using the ChipIdea driver I introduced, both with an USB PHY
and a PHY driver successfully. I also compiled a multi_v7 kernel (ARM), with
every driver I could enable in the USB section.

Patches can also be found at:
git://git.free-electrons.com:users/antoine-tenart/linux.git usb-phy

The series applies on top of Sergei and Yoshihiro generic PHY support in
HCD[2] and on top of Peter Chen's ci-for-usb-next branch[3].

Thanks a lot!

Antoine


Changes since v4:
- reworked the PHY handling in ci_hdrc_probe()
- fixed a rebase error
- rebased on top of [3]

Changes since v3:
- moved phy_exit() after phy_power_on()
- fixed the PHY handling in ci_hdrc_probe()
- some little fixes

Changes since v2:
- rebased the series on top of v3.17-rc1 (and [2])
- switched to devm_phy_get() to handle non DT cases
- moved usb_otg into the ci_hdrc structure

Changes since v1:
- rebased the series on top of [2] (generic PHY support for HCD)
- split s/phy/usb_phy/ renaming and generic PHY support in separate
  patches

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/272840.html
[2] https://www.mail-archive.com/linux-usb@vger.kernel.org/msg43471.html
[3] git://github.com/hzpeterchen/linux-usb.git ci-for-usb-next

Antoine Tenart (9):
  usb: move the OTG state from the USB PHY to the OTG structure
  usb: rename phy to usb_phy in OTG
  usb: add support to the generic PHY framework in OTG
  usb: rename phy to usb_phy in HCD
  usb: rename gen_phy to phy in HCD
  usb: allow to supply the PHY in the drivers when using HCD
  usb: rename transceiver and phy to usb_phy in ChipIdea
  usb: chipidea: move usb_otg into struct ci_hdrc
  usb: chipidea: add support to the generic PHY framework in ChipIdea

 drivers/phy/phy-omap-usb2.c | 14 ++
 drivers/usb/chipidea/ci.h   |  8 +++-
 drivers/usb/chipidea/ci_hdrc_imx.c  |  2 +-
 drivers/usb/chipidea/ci_hdrc_msm.c  |  8 ++--
 drivers/usb/chipidea/core.c | 89 ++
 drivers/usb/chipidea/debug.c|  2 +-
 drivers/usb/chipidea/host.c | 10 ++--
 drivers/usb/chipidea/otg_fsm.c  | 30 +---
 drivers/usb/chipidea/udc.c  |  4 +-
 drivers/usb/common/usb-otg-fsm.c|  8 ++--
 drivers/usb/core/hcd.c  | 45 +-
 drivers/usb/core/hub.c  |  8 ++--
 drivers/usb/host/ehci-fsl.c | 16 +++
 drivers/usb/host/ehci-hub.c |  2 +-
 drivers/usb/host/ehci-msm.c |  4 +-
 drivers/usb/host/ehci-tegra.c   | 16 +++
 drivers/usb/host/ohci-omap.c| 20 
 drivers/usb/misc/lvstest.c  |  8 ++--
 drivers/usb/musb/am35x.c| 28 +--
 drivers/usb/musb/blackfin.c | 18 +++
 drivers/usb/musb/da8xx.c| 28 +--
 drivers/usb/musb/davinci.c  | 18 +++
 drivers/usb/musb/musb_core.c| 94 ++--
 drivers/usb/musb/musb_dsps.c| 26 +-
 drivers/usb/musb/musb_gadget.c  | 36 +++---
 drivers/usb/musb/musb_host.c|  8 ++--
 drivers/usb/musb/musb_virthub.c | 22 -
 drivers/usb/musb/omap2430.c | 30 ++--
 drivers/usb/musb/tusb6010.c | 40 
 drivers/usb/musb/ux500.c| 10 ++--
 drivers/usb/phy/phy-ab8500-usb.c| 16 +++
 drivers/usb/phy/phy-fsl-usb.c   | 23 -
 drivers/usb/phy/phy-generic.c   |  6 +--
 drivers/usb/phy/phy-gpio-vbus-usb.c | 14 +++---
 drivers/usb/phy/phy-isp1301-omap.c  | 10 ++--
 drivers/usb/phy/phy-msm-usb.c   | 95 

[PATCH v5 4/9] usb: rename phy to usb_phy in HCD

2014-09-15 Thread Antoine Tenart
The USB PHY member of the HCD structure is renamed to 'usb_phy' and
modifications are done in all drivers accessing it.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/chipidea/host.c   |  2 +-
 drivers/usb/core/hcd.c| 20 ++--
 drivers/usb/core/hub.c|  8 
 drivers/usb/host/ehci-fsl.c   | 16 
 drivers/usb/host/ehci-hub.c   |  2 +-
 drivers/usb/host/ehci-msm.c   |  4 ++--
 drivers/usb/host/ehci-tegra.c | 16 
 drivers/usb/host/ohci-omap.c  | 20 ++--
 drivers/usb/misc/lvstest.c|  8 
 include/linux/usb/hcd.h   |  2 +-
 10 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index a93d950e9468..fc7541c906a2 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -59,7 +59,7 @@ static int host_start(struct ci_hdrc *ci)
hcd-has_tt = 1;
 
hcd-power_budget = ci-platdata-power_budget;
-   hcd-phy = ci-transceiver;
+   hcd-usb_phy = ci-transceiver;
 
ehci = hcd_to_ehci(hcd);
ehci-caps = ci-hw_bank.cap;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index c4ed66cb9ff3..86fdce55ae16 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2628,7 +2628,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
int retval;
struct usb_device *rhdev;
 
-   if (IS_ENABLED(CONFIG_USB_PHY)  !hcd-phy) {
+   if (IS_ENABLED(CONFIG_USB_PHY)  !hcd-usb_phy) {
struct usb_phy *phy = usb_get_phy_dev(hcd-self.controller, 0);
 
if (IS_ERR(phy)) {
@@ -2641,7 +2641,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
usb_put_phy(phy);
return retval;
}
-   hcd-phy = phy;
+   hcd-usb_phy = phy;
hcd-remove_phy = 1;
}
}
@@ -2819,10 +2819,10 @@ err_create_buf:
hcd-gen_phy = NULL;
}
 err_phy:
-   if (hcd-remove_phy  hcd-phy) {
-   usb_phy_shutdown(hcd-phy);
-   usb_put_phy(hcd-phy);
-   hcd-phy = NULL;
+   if (hcd-remove_phy  hcd-usb_phy) {
+   usb_phy_shutdown(hcd-usb_phy);
+   usb_put_phy(hcd-usb_phy);
+   hcd-usb_phy = NULL;
}
return retval;
 }
@@ -2902,10 +2902,10 @@ void usb_remove_hcd(struct usb_hcd *hcd)
phy_put(hcd-gen_phy);
hcd-gen_phy = NULL;
}
-   if (hcd-remove_phy  hcd-phy) {
-   usb_phy_shutdown(hcd-phy);
-   usb_put_phy(hcd-phy);
-   hcd-phy = NULL;
+   if (hcd-remove_phy  hcd-usb_phy) {
+   usb_phy_shutdown(hcd-usb_phy);
+   usb_put_phy(hcd-usb_phy);
+   hcd-usb_phy = NULL;
}
 
usb_put_invalidate_rhdev(hcd);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 46f5161c7891..bf023b3d0366 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4461,8 +4461,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device 
*udev, int port1,
if (retval)
goto fail;
 
-   if (hcd-phy  !hdev-parent)
-   usb_phy_notify_connect(hcd-phy, udev-speed);
+   if (hcd-usb_phy  !hdev-parent)
+   usb_phy_notify_connect(hcd-usb_phy, udev-speed);
 
/*
 * Some superspeed devices have finished the link training process
@@ -4617,9 +4617,9 @@ static void hub_port_connect(struct usb_hub *hub, int 
port1, u16 portstatus,
 
/* Disconnect any existing devices under this port */
if (udev) {
-   if (hcd-phy  !hdev-parent 
+   if (hcd-usb_phy  !hdev-parent 
!(portstatus  USB_PORT_STAT_CONNECTION))
-   usb_phy_notify_disconnect(hcd-phy, udev-speed);
+   usb_phy_notify_disconnect(hcd-usb_phy, udev-speed);
usb_disconnect(port_dev-child);
}
 
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index cf2734b532a7..4bdcd3439d47 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -136,15 +136,15 @@ static int usb_hcd_fsl_probe(const struct hc_driver 
*driver,
if (pdata-operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
-   hcd-phy = usb_get_phy(USB_PHY_TYPE_USB2);
+   hcd-usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
dev_dbg(pdev-dev, hcd=0x%p  ehci=0x%p, phy=0x%p\n,
-   hcd, ehci, hcd-phy);
+   hcd, ehci, hcd-usb_phy);
 
-   if (!IS_ERR_OR_NULL(hcd-phy)) {
-   retval = otg_set_host(hcd-phy-otg,
+   if (!IS_ERR_OR_NULL(hcd-usb_phy)) {
+   

[PATCH v5 2/9] usb: rename phy to usb_phy in OTG

2014-09-15 Thread Antoine Tenart
This patch prepares the introduction of the generic PHY support in the
USB OTG common functions. The USB PHY member of the OTG structure is
renamed to 'usb_phy' and modifications are done in all drivers accessing
it. Renaming this pointer will allow to keep the compatibility for USB
PHY drivers.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/phy/phy-omap-usb2.c |  6 ++--
 drivers/usb/chipidea/otg_fsm.c  |  2 +-
 drivers/usb/phy/phy-ab8500-usb.c|  6 ++--
 drivers/usb/phy/phy-fsl-usb.c   | 13 
 drivers/usb/phy/phy-generic.c   |  2 +-
 drivers/usb/phy/phy-gpio-vbus-usb.c |  4 +--
 drivers/usb/phy/phy-isp1301-omap.c  | 10 +++---
 drivers/usb/phy/phy-msm-usb.c   | 61 +++--
 drivers/usb/phy/phy-mv-usb.c|  4 +--
 drivers/usb/phy/phy-samsung-usb2.c  |  2 +-
 drivers/usb/phy/phy-tahvo.c |  8 +++--
 drivers/usb/phy/phy-ulpi.c  |  6 ++--
 include/linux/usb/otg.h |  2 +-
 13 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 3bb54e55c762..a454042ddb06 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -60,7 +60,7 @@ EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
 
 static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
 {
-   struct omap_usb *phy = phy_to_omapusb(otg-phy);
+   struct omap_usb *phy = phy_to_omapusb(otg-usb_phy);
 
if (!phy-comparator)
return -ENODEV;
@@ -70,7 +70,7 @@ static int omap_usb_set_vbus(struct usb_otg *otg, bool 
enabled)
 
 static int omap_usb_start_srp(struct usb_otg *otg)
 {
-   struct omap_usb *phy = phy_to_omapusb(otg-phy);
+   struct omap_usb *phy = phy_to_omapusb(otg-usb_phy);
 
if (!phy-comparator)
return -ENODEV;
@@ -255,7 +255,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg-set_vbus   = omap_usb_set_vbus;
if (phy_data-flags  OMAP_USB2_HAS_START_SRP)
otg-start_srp  = omap_usb_start_srp;
-   otg-phy= phy-phy;
+   otg-usb_phy= phy-phy;
 
platform_set_drvdata(pdev, phy);
 
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 8cb2508a6b71..d8490e758a74 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -788,7 +788,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
return -ENOMEM;
}
 
-   otg-phy = ci-transceiver;
+   otg-usb_phy = ci-transceiver;
otg-gadget = ci-gadget;
ci-fsm.otg = otg;
ci-transceiver-otg = ci-fsm.otg;
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 2d5250143ce1..3a802fa7dae2 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -1056,7 +1056,7 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg,
if (!otg)
return -ENODEV;
 
-   ab = phy_to_ab(otg-phy);
+   ab = phy_to_ab(otg-usb_phy);
 
ab-phy.otg-gadget = gadget;
 
@@ -1080,7 +1080,7 @@ static int ab8500_usb_set_host(struct usb_otg *otg, 
struct usb_bus *host)
if (!otg)
return -ENODEV;
 
-   ab = phy_to_ab(otg-phy);
+   ab = phy_to_ab(otg-usb_phy);
 
ab-phy.otg-host = host;
 
@@ -1382,7 +1382,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab-phy.set_power   = ab8500_usb_set_power;
ab-phy.otg-state  = OTG_STATE_UNDEFINED;
 
-   otg-phy= ab-phy;
+   otg-usb_phy= ab-phy;
otg-set_host   = ab8500_usb_set_host;
otg-set_peripheral = ab8500_usb_set_peripheral;
 
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index a22f88fb8176..b4cc341094ac 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -499,7 +499,8 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
 {
struct usb_otg *otg = fsm-otg;
struct device *dev;
-   struct fsl_otg *otg_dev = container_of(otg-phy, struct fsl_otg, phy);
+   struct fsl_otg *otg_dev =
+   container_of(otg-usb_phy, struct fsl_otg, phy);
u32 retval = 0;
 
if (!otg-host)
@@ -594,7 +595,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
if (!otg)
return -ENODEV;
 
-   otg_dev = container_of(otg-phy, struct fsl_otg, phy);
+   otg_dev = container_of(otg-usb_phy, struct fsl_otg, phy);
if (otg_dev != fsl_otg_dev)
return -ENODEV;
 
@@ -644,7 +645,7 @@ static int fsl_otg_set_peripheral(struct usb_otg *otg,
if (!otg)
return -ENODEV;
 
-   otg_dev = container_of(otg-phy, struct fsl_otg, phy);
+   otg_dev = container_of(otg-usb_phy, struct fsl_otg, phy);
VDBG(otg_dev 0x%x\n, 

[PATCH v5 7/9] usb: rename transceiver and phy to usb_phy in ChipIdea

2014-09-15 Thread Antoine Tenart
This patch prepares the introduction of the generic PHY support in the
USB ChipIdea common functions. The USB PHY member of the ChipIdea
structure ('transceiver') is renamed to 'usb_phy', the 'phy' member of
the ChipIdea pdata structure is renamed to 'usb_phy' and modifications
are done in all drivers accessing it. Renaming this pointer will allow
to keep the compatibility for USB PHY drivers.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/usb/chipidea/ci.h  |  4 ++--
 drivers/usb/chipidea/ci_hdrc_imx.c |  2 +-
 drivers/usb/chipidea/ci_hdrc_msm.c |  8 
 drivers/usb/chipidea/core.c| 20 ++--
 drivers/usb/chipidea/debug.c   |  2 +-
 drivers/usb/chipidea/host.c|  4 ++--
 drivers/usb/chipidea/otg_fsm.c |  4 ++--
 drivers/usb/chipidea/udc.c |  4 ++--
 include/linux/usb/chipidea.h   |  2 +-
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 9563cb56d564..b2caa1772712 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -161,7 +161,7 @@ struct hw_bank {
  * @test_mode: the selected test mode
  * @platdata: platform specific information supplied by parent device
  * @vbus_active: is VBUS active
- * @transceiver: pointer to USB PHY, if any
+ * @usb_phy: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
  * @debugfs: root dentry for this controller in debugfs
  * @id_event: indicates there is an id event, and handled at ci_otg_work
@@ -201,7 +201,7 @@ struct ci_hdrc {
 
struct ci_hdrc_platform_data*platdata;
int vbus_active;
-   struct usb_phy  *transceiver;
+   struct usb_phy  *usb_phy;
struct usb_hcd  *hcd;
struct dentry   *debugfs;
boolid_event;
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index a7ab0f15926e..6f8b1b1045b5 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -147,7 +147,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
goto err_clk;
}
 
-   pdata.phy = data-phy;
+   pdata.usb_phy = data-phy;
 
if (imx_platform_flag-flags  CI_HDRC_IMX_IMX28_WRITE_FIX)
pdata.flags |= CI_HDRC_IMX28_WRITE_FIX;
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 4935ac38fd00..3edf969ed797 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -26,15 +26,15 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, 
unsigned event)
dev_dbg(dev, CI_HDRC_CONTROLLER_RESET_EVENT received\n);
writel(0, USB_AHBBURST);
writel(0, USB_AHBMODE);
-   usb_phy_init(ci-transceiver);
+   usb_phy_init(ci-usb_phy);
break;
case CI_HDRC_CONTROLLER_STOPPED_EVENT:
dev_dbg(dev, CI_HDRC_CONTROLLER_STOPPED_EVENT received\n);
/*
-* Put the transceiver in non-driving mode. Otherwise host
+* Put the phy in non-driving mode. Otherwise host
 * may not detect soft-disconnection.
 */
-   usb_phy_notify_disconnect(ci-transceiver, USB_SPEED_UNKNOWN);
+   usb_phy_notify_disconnect(ci-usb_phy, USB_SPEED_UNKNOWN);
break;
default:
dev_dbg(dev, unknown ci_hdrc event\n);
@@ -68,7 +68,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev)
if (IS_ERR(phy))
return PTR_ERR(phy);
 
-   ci_hdrc_msm_platdata.phy = phy;
+   ci_hdrc_msm_platdata.usb_phy = phy;
 
plat_ci = ci_hdrc_add_device(pdev-dev,
pdev-resource, pdev-num_resources,
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 579b3538cb27..ee96b0696a7b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -306,7 +306,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_UTMI:
case USBPHY_INTERFACE_MODE_UTMIW:
case USBPHY_INTERFACE_MODE_HSIC:
-   ret = usb_phy_init(ci-transceiver);
+   ret = usb_phy_init(ci-usb_phy);
if (ret)
return ret;
hw_phymode_configure(ci);
@@ -314,12 +314,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_ULPI:
case USBPHY_INTERFACE_MODE_SERIAL:
hw_phymode_configure(ci);
-   ret = usb_phy_init(ci-transceiver);
+   ret = usb_phy_init(ci-usb_phy);
if (ret)
return ret;
break;
default:
-   ret = 

[PATCH v5 8/9] usb: chipidea: move usb_otg into struct ci_hdrc

2014-09-15 Thread Antoine Tenart
Move the usb_otg member from struct usb_phy to struct ci_hdrc. Rework
its initialization taking in account this modification.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/ci.h  |  1 +
 drivers/usb/chipidea/host.c|  5 +++--
 drivers/usb/chipidea/otg_fsm.c | 16 +++-
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index b2caa1772712..dac5ab6adfa2 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -177,6 +177,7 @@ struct ci_hdrc {
struct ci_role_driver   *roles[CI_ROLE_END];
enum ci_rolerole;
boolis_otg;
+   struct usb_otg  otg;
struct otg_fsm  fsm;
struct ci_otg_fsm_timer_list*fsm_timer;
struct work_struct  work;
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 0b67d78dd953..4fcebb6a6d14 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -85,10 +85,11 @@ static int host_start(struct ci_hdrc *ci)
if (ret) {
goto disable_reg;
} else {
-   struct usb_otg *otg = ci-usb_phy-otg;
+   struct usb_otg *otg = ci-otg;
 
ci-hcd = hcd;
-   if (otg) {
+
+   if (ci_otg_is_fsm_mode(ci)) {
otg-host = hcd-self;
hcd-self.otg_port = 1;
}
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 8a64ce87364e..862d7cb01b92 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -778,20 +778,10 @@ void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
 int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
 {
int retval = 0;
-   struct usb_otg *otg;
 
-   otg = devm_kzalloc(ci-dev,
-   sizeof(struct usb_otg), GFP_KERNEL);
-   if (!otg) {
-   dev_err(ci-dev,
-   Failed to allocate usb_otg structure for ci hdrc otg!\n);
-   return -ENOMEM;
-   }
-
-   otg-usb_phy = ci-usb_phy;
-   otg-gadget = ci-gadget;
-   ci-fsm.otg = otg;
-   ci-usb_phy-otg = ci-fsm.otg;
+   ci-otg.usb_phy = ci-usb_phy;
+   ci-otg.gadget = ci-gadget;
+   ci-fsm.otg = ci-otg;
ci-fsm.power_up = 1;
ci-fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
ci-fsm.otg-state = OTG_STATE_UNDEFINED;
-- 
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 v5 01/12] reset: add the Berlin reset controller driver

2014-09-15 Thread Antoine Tenart
Add a reset controller for Marvell Berlin SoCs which is used by the
USB PHYs drivers (for now).

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Signed-off-by: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
---
 drivers/reset/Makefile   |   1 +
 drivers/reset/reset-berlin.c | 131 +++
 2 files changed, 132 insertions(+)
 create mode 100644 drivers/reset/reset-berlin.c

diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 60fed3d7820b..157d421f755b 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_RESET_CONTROLLER) += core.o
 obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
+obj-$(CONFIG_ARCH_BERLIN) += reset-berlin.o
 obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_ARCH_STI) += sti/
diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c
new file mode 100644
index ..f8b48a13cf0b
--- /dev/null
+++ b/drivers/reset/reset-berlin.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2014 Marvell Technology Group Ltd.
+ *
+ * Antoine Tenart antoine.ten...@free-electrons.com
+ * Sebastian Hesselbarth sebastian.hesselba...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/platform_device.h
+#include linux/reset-controller.h
+#include linux/slab.h
+#include linux/types.h
+
+#define BERLIN_MAX_RESETS  32
+
+#define to_berlin_reset_priv(p)\
+   container_of((p), struct berlin_reset_priv, rcdev)
+
+struct berlin_reset_priv {
+   void __iomem*base;
+   unsigned intsize;
+   struct reset_controller_dev rcdev;
+};
+
+static int berlin_reset_reset(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+   struct berlin_reset_priv *priv = to_berlin_reset_priv(rcdev);
+   int offset = id  8;
+   int mask = BIT(id  0x1f);
+
+   writel(mask, priv-base + offset);
+
+   /* let the reset be effective */
+   udelay(10);
+
+   return 0;
+}
+
+static struct reset_control_ops berlin_reset_ops = {
+   .reset  = berlin_reset_reset,
+};
+
+static int berlin_reset_xlate(struct reset_controller_dev *rcdev,
+ const struct of_phandle_args *reset_spec)
+{
+   struct berlin_reset_priv *priv = to_berlin_reset_priv(rcdev);
+   unsigned offset, bit;
+
+   if (WARN_ON(reset_spec-args_count != rcdev-of_reset_n_cells))
+   return -EINVAL;
+
+   offset = reset_spec-args[0];
+   bit = reset_spec-args[1];
+
+   if (offset = priv-size)
+   return -EINVAL;
+
+   if (bit = BERLIN_MAX_RESETS)
+   return -EINVAL;
+
+   return (offset  8) | bit;
+}
+
+static int __berlin_reset_init(struct device_node *np)
+{
+   struct berlin_reset_priv *priv;
+   struct resource res;
+   resource_size_t size;
+   int ret;
+
+   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+   if (!priv)
+   return -ENOMEM;
+
+   ret = of_address_to_resource(np, 0, res);
+   if (ret)
+   goto err;
+
+   size = resource_size(res);
+   priv-base = ioremap(res.start, size);
+   if (!priv-base) {
+   ret = -ENOMEM;
+   goto err;
+   }
+   priv-size = size;
+
+   priv-rcdev.owner = THIS_MODULE;
+   priv-rcdev.ops = berlin_reset_ops;
+   priv-rcdev.of_node = np;
+   priv-rcdev.of_reset_n_cells = 2;
+   priv-rcdev.of_xlate = berlin_reset_xlate;
+
+   reset_controller_register(priv-rcdev);
+
+   return 0;
+
+err:
+   kfree(priv);
+   return ret;
+}
+
+static const struct of_device_id berlin_reset_of_match[] __initconst = {
+   { .compatible = marvell,berlin2-chip-ctrl },
+   { .compatible = marvell,berlin2cd-chip-ctrl },
+   { .compatible = marvell,berlin2q-chip-ctrl },
+   { },
+};
+
+static int __init berlin_reset_init(void)
+{
+   struct device_node *np;
+   int ret;
+
+   for_each_matching_node(np, berlin_reset_of_match) {
+   ret = __berlin_reset_init(np);
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+arch_initcall(berlin_reset_init);
-- 
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] usb: gadget: udc_core: Use right kobj when calling sysfs_notify

2014-09-15 Thread Andreas Larsson
The state attribute is connected to the kobj of the udc, not the gadget.

Signed-off-by: Andreas Larsson andr...@gaisler.com
---
 drivers/usb/gadget/udc/udc-core.c |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/udc-core.c 
b/drivers/usb/gadget/udc/udc-core.c
index b0d9817..37c129a 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -109,8 +109,20 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
 static void usb_gadget_state_work(struct work_struct *work)
 {
struct usb_gadget   *gadget = work_to_gadget(work);
+   struct usb_udc  *udc = NULL;
+
+   mutex_lock(udc_lock);
+   list_for_each_entry(udc, udc_list, list)
+   if (udc-gadget == gadget)
+   goto found;
+   mutex_unlock(udc_lock);
+
+   return;
+
+found:
+   mutex_unlock(udc_lock);
 
-   sysfs_notify(gadget-dev.kobj, NULL, state);
+   sysfs_notify(udc-dev.kobj, NULL, state);
 }
 
 void usb_gadget_set_state(struct usb_gadget *gadget,
-- 
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


[PATCH v5 1/9] usb: move the OTG state from the USB PHY to the OTG structure

2014-09-15 Thread Antoine Tenart
Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/phy/phy-omap-usb2.c |  8 +---
 drivers/usb/chipidea/debug.c|  2 +-
 drivers/usb/chipidea/otg_fsm.c  | 12 ++---
 drivers/usb/common/usb-otg-fsm.c|  8 ++--
 drivers/usb/host/ohci-omap.c|  2 +-
 drivers/usb/musb/am35x.c| 28 +--
 drivers/usb/musb/blackfin.c | 18 +++
 drivers/usb/musb/da8xx.c| 28 +--
 drivers/usb/musb/davinci.c  | 18 +++
 drivers/usb/musb/musb_core.c| 94 ++---
 drivers/usb/musb/musb_dsps.c| 26 +-
 drivers/usb/musb/musb_gadget.c  | 36 +++---
 drivers/usb/musb/musb_host.c|  8 ++--
 drivers/usb/musb/musb_virthub.c | 22 -
 drivers/usb/musb/omap2430.c | 30 ++--
 drivers/usb/musb/tusb6010.c | 40 
 drivers/usb/musb/ux500.c| 10 ++--
 drivers/usb/phy/phy-ab8500-usb.c| 10 ++--
 drivers/usb/phy/phy-fsl-usb.c   | 10 ++--
 drivers/usb/phy/phy-generic.c   |  4 +-
 drivers/usb/phy/phy-gpio-vbus-usb.c | 10 ++--
 drivers/usb/phy/phy-msm-usb.c   | 34 +++---
 drivers/usb/phy/phy-mv-usb.c| 46 +-
 include/linux/usb/otg.h |  2 +
 include/linux/usb/phy.h |  1 -
 25 files changed, 252 insertions(+), 255 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 93d78359246c..3bb54e55c762 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)
 
 static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
 {
-   struct usb_phy  *phy = otg-phy;
-
otg-host = host;
if (!host)
-   phy-state = OTG_STATE_UNDEFINED;
+   otg-state = OTG_STATE_UNDEFINED;
 
return 0;
 }
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
 {
-   struct usb_phy  *phy = otg-phy;
-
otg-gadget = gadget;
if (!gadget)
-   phy-state = OTG_STATE_UNDEFINED;
+   otg-state = OTG_STATE_UNDEFINED;
 
return 0;
 }
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 795d6538d630..8878eea38d44 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)
 
/* -- State - */
seq_printf(s, OTG state: %s\n\n,
-   usb_otg_state_string(ci-transceiver-state));
+   usb_otg_state_string(ci-transceiver-otg.state));
 
/* -- State Machine Variables - */
seq_printf(s, a_bus_drop: %d\n, fsm-a_bus_drop);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index caaabc58021e..8cb2508a6b71 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long 
indicator)
set_tmout(ci, indicator);
 
/* only vbus fall below B_sess_vld in b_idle state */
-   if (ci-transceiver-state == OTG_STATE_B_IDLE)
+   if (ci-fsm.otg-state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci);
 }
 
@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
 * when there is no gadget class driver
 */
if (ci-fsm.id  !(ci-driver) 
-   ci-transceiver-state  OTG_STATE_A_IDLE)
+   ci-fsm.otg-state  OTG_STATE_A_IDLE)
return 0;
 
if (otg_statemachine(ci-fsm)) {
-   if (ci-transceiver-state == OTG_STATE_A_IDLE) {
+   if (ci-fsm.otg-state == OTG_STATE_A_IDLE) {
/*
 * Further state change for cases:
 * a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci);
if (ci-id_event)
ci-id_event = false;
-   } else if (ci-transceiver-state == OTG_STATE_B_IDLE) {
+   } else if (ci-fsm.otg-state == OTG_STATE_B_IDLE) {
if (ci-fsm.b_sess_vld) {
ci-fsm.power_up = 0;
/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);

Re: [PATCH fix for 3.17] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Oliver Neukum
On Mon, 2014-09-15 at 08:42 +, David Laight wrote:
 From: Alan Stern
  
  You must not add an aditional value for a module parameter without
  documenting it in Documentation/kernel-parameters.txt.
 
 How can this work as a 'module parameter'?

It cannot. This parameter is an aid to debugging.

 I might want to use two different usb-scsi devices that have different
 requirements.

Indeed. Quirky devices must be added to the quirks file.

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


[PATCH] usb: gadget: gr_udc: Add bounce buffer to handle odd sized OUT requests

2014-09-15 Thread Andreas Larsson
This adds a bounce buffer that handles the end of OUT requests where
req.length is not divisible by ep-ep.maxpacket.

Before this, such requests were rejected as the DMA engine cannot
restrict itself to buffers that are smaller than ep-ep.maxpacket.

Signed-off-by: Andreas Larsson andr...@gaisler.com
---
 drivers/usb/gadget/udc/gr_udc.c |   81 +--
 drivers/usb/gadget/udc/gr_udc.h |7 
 2 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 08df5c4..ecd10b5 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -318,8 +318,26 @@ static void gr_finish_request(struct gr_ep *ep, struct 
gr_request *req,
usb_gadget_unmap_request(dev-gadget, req-req, ep-is_in);
gr_free_dma_desc_chain(dev, req);
 
-   if (ep-is_in) /* For OUT, actual gets updated bit by bit */
+   if (ep-is_in) { /* For OUT, req-req.actual gets updated bit by bit */
req-req.actual = req-req.length;
+   } else if (req-oddlen  req-req.actual  req-evenlen) {
+   /*
+* Copy to user buffer in this case where length was not evenly
+* divisible by ep-ep.maxpacket and the last descriptor was
+* actually used.
+*/
+   char *buftail = ((char *)req-req.buf + req-evenlen);
+
+   memcpy(buftail, ep-tailbuf, req-oddlen);
+
+   if (req-req.actual  req-req.length) {
+   /* We got more data than was requested */
+   dev_dbg(ep-dev-dev, Overflow for ep %s\n,
+   ep-ep.name);
+   gr_dbgprint_request(OVFL, ep, req);
+   req-req.status = -EOVERFLOW;
+   }
+   }
 
if (!status) {
if (ep-is_in)
@@ -379,6 +397,15 @@ static void gr_start_dma(struct gr_ep *ep)
/* A descriptor should already have been allocated */
BUG_ON(!req-curr_desc);
 
+   /*
+* The DMA controller can not handle smaller OUT buffers than
+* ep-ep.maxpacket. It could lead to buffer overruns if an unexpectedly
+* long packet are received. Therefore an internal bounce buffer gets
+* used when such a request gets enabled.
+*/
+   if (!ep-is_in  req-oddlen)
+   req-last_desc-data = ep-tailbuf_paddr;
+
wmb(); /* Make sure all is settled before handing it over to DMA */
 
/* Set the descriptor pointer in the hardware */
@@ -480,11 +507,11 @@ static int gr_setup_out_desc_list(struct gr_ep *ep, 
struct gr_request *req,
dma_addr_t start = req-req.dma + bytes_used;
u16 size = min(bytes_left, ep-bytes_per_buffer);
 
-   /* Should not happen however - gr_queue stops such lengths */
-   if (size  ep-bytes_per_buffer)
-   dev_warn(ep-dev-dev,
-Buffer overrun risk: %u  %u bytes/buffer\n,
-size, ep-bytes_per_buffer);
+   if (size  ep-bytes_per_buffer) {
+   /* Prepare using bounce buffer */
+   req-evenlen = req-req.length - bytes_left;
+   req-oddlen = size;
+   }
 
ret = gr_add_dma_desc(ep, req, start, size, gfp_flags);
if (ret)
@@ -584,18 +611,6 @@ static int gr_queue(struct gr_ep *ep, struct gr_request 
*req, gfp_t gfp_flags)
return -EINVAL;
}
 
-   /*
-* The DMA controller can not handle smaller OUT buffers than
-* maxpacket. It could lead to buffer overruns if unexpectedly long
-* packet are received.
-*/
-   if (!ep-is_in  (req-req.length % ep-ep.maxpacket) != 0) {
-   dev_err(dev-dev,
-   OUT request length %d is not multiple of maxpacket\n,
-   req-req.length);
-   return -EMSGSIZE;
-   }
-
if (unlikely(!dev-driver || dev-gadget.speed == USB_SPEED_UNKNOWN)) {
dev_err(dev-dev, -ESHUTDOWN);
return -ESHUTDOWN;
@@ -1286,8 +1301,8 @@ static int gr_handle_out_ep(struct gr_ep *ep)
if (ctrl  GR_DESC_OUT_CTRL_SE)
req-setup = 1;
 
-   if (len  ep-ep.maxpacket || req-req.actual == req-req.length) {
-   /* Short packet or the expected size - we are done */
+   if (len  ep-ep.maxpacket || req-req.actual = req-req.length) {
+   /* Short packet or = expected size - we are done */
 
if ((ep == dev-epo[0])  (dev-ep0state == GR_EP0_OSTATUS)) {
/*
@@ -2015,6 +2030,11 @@ static int gr_ep_init(struct gr_udc *dev, int num, int 
is_in, u32 maxplimit)
}
list_add_tail(ep-ep_list, dev-ep_list);
 
+   ep-tailbuf = dma_alloc_coherent(dev-dev, 

[no subject]

2014-09-15 Thread Christian Melki
unsubscribe linux-usb--
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


[no subject]

2014-09-15 Thread Christian Melki
unsubscribe--
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


New USB device for cp210x

2014-09-15 Thread Andreas Bomholtz

Hi,

I just want to know what is need for adding a new USB device to the 
cp210x driver?


The new USB Device:

{ USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */

Best regards,
Andreas Bomholtz
Seluxit ApS
--
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 6/6] usb: dwc3: host: convey the PHYs to xhci

2014-09-15 Thread Heikki Krogerus
On Fri, Sep 12, 2014 at 07:41:56PM +0530, Kishon Vijay Abraham I wrote:
  I don't think create lookup should be in host init. If it's dt boot, the
  binding should be in dt data or for other boot modes the bindig should be 
  done
  in the board file. This just seems hacky to me.
  
  So are you now suggesting that instead of using platform independent
  solution of sharing the PHYs here, you would have us add platform
  specific quirks? That would be totally wrong!
 
 No. The binding between the controller and the PHY is done in hardware design
 and it would be wrong to create such a binding in drivers/* IMO.

And kernel of course always knows the hardware design when it's being
booted, wrong!

Firstly, don't assume this kind of controllers are always part of some
SoC or chip set. They could easily be on a PCI card for example.
Secondly, don't assume we could tell all the details about the board
based on some identifiers. Fox example, at least with our SoCs we
won't be able to differentiate the boards. And it's not like every
board using the same SoC uses the same USB2 PHY for example. That kind
of things are up to the manufacturers.

By default we have to rely on hardware descriptions like DT and ACPI
tables or being able to runtime detect (ULPI). If those things don't
work, we live without PHY in this case. We add board specific quirks
_only_ in case of exceptions, where we simply have no other way. If
it's possible to avoid them, especially with something as simple as
this, we avoid them!

  And please don't even consider use of board files especially if there
  is an option. They are the one thing that we are meant to avoid if
  possible! No?
 
 For dt yes, I'm not sure about other modes.
 
 So in the case of dt boot, I'd prefer giving the binding in dt file than
 anywhere else.

I don't know how dt works, but at least in case of ACPI we still need
to deliver the PHY to xHCI here, even when dwc3 is provided bindings
to a PHY(s).


-- 
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 2/6] phy: improved lookup method

2014-09-15 Thread Heikki Krogerus
On Fri, Sep 12, 2014 at 08:16:01PM +0530, Kishon Vijay Abraham I wrote:
 Assume you have 2 phys in your system..
 static struct phy_lookup usb_lookup = {
   .phy_name   = phy-usb.0,
   .dev_id = usb.0,
   .con_id = usb,
 };
 
 static struct phy_lookup sata_lookup = {
   .phy_name   = sata-usb.1,
   .dev_id = sata.0,
   .con_id = sata,
 };
 
 First you do modprobe phy-usb, the probe of USB PHY driver gets invoked and it
 creates the PHY. The phy-core will find a free id (now it will be 0) and then
 name the phy as phy-usb.0.
 Then with modprobe phy-sata, the phy-core will create phy-sata.1.
 
 This is an ideal case where the .phy_name in phy_lookup matches.
 
 Consider if the order is flipped and the user does modprobe phy-sata first. 
 The
 phy_names won't match anymore (the sata phy device name would be 
 sata-usb.0).

True!

So we can't accept statically created lookups. Which is probable the
best thing to do in any case even if there wasn't this issue.

I think we already talked about this. I know I was going to create the
lookup for twl4030 in twl-core.c instead of the board file at one
point, but forgot about it. I need to do that now.

In any case, I'll fix this by dropping the possibility of creating the
lookups statically. I'll prepare new version of the whole set.


Thanks,

-- 
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 fix for 3.17] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Hans de Goede
Hi,

On 09/15/2014 10:42 AM, David Laight wrote:
 From: Alan Stern
 ...
 p = quirks;
 while (*p) {
 @@ -543,6 +544,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
 unsigned long *fflags)
 case 's':
 f |= US_FL_SINGLE_LUN;
 break;
 +   case 't':
 +   f |= US_FL_NO_ATA_1X;
 +   break;
 case 'u':
 f |= US_FL_IGNORE_UAS;
 break;

 You must not add an aditional value for a module parameter without
 documenting it in Documentation/kernel-parameters.txt.
 
 How can this work as a 'module parameter'?
 I might want to use two different usb-scsi devices that have different
 requirements.

The usb-storage.quirks format includes a usb prod:vend if pair, so unless
you've 2 identical devices, you can specify which quirks to apply to
which device.

Regards,

Hans
--
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 fix for 3.17 v5] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Hans de Goede
And set this quirk for the Seagate Expansion Desk (0bc2:2312), as that one
seems to hang upon receiving an ATA_12 or ATA_16 command.

https://bugzilla.kernel.org/show_bug.cgi?id=79511
https://bbs.archlinux.org/viewtopic.php?id=183190

While at it also add missing documentation for the u value for usb-storage
quirks.

Cc: sta...@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede hdego...@redhat.com

--
Changes in v2: Add documentation for new t and u usb-storage.quirks flags
Changes in v3: Fix typo in documentation
Changes in v4: Also apply the quirk to (0bc2:3312)
Changes in v5: Rebased on 3.17-rc5, drop u documentation, already upstream
---
 Documentation/kernel-parameters.txt |  2 ++
 drivers/usb/storage/uas.c   | 13 +
 drivers/usb/storage/unusual_uas.h   | 23 +--
 drivers/usb/storage/usb.c   |  6 +-
 include/linux/usb_usual.h   |  2 ++
 5 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 10d51c2..dd4fe98 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3541,6 +3541,8 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
bogus residue values);
s = SINGLE_LUN (the device has only one
Logical Unit);
+   t = NO_ATA_1X (don't allow ATA(12) and ATA(16)
+   commands, uas only);
u = IGNORE_UAS (don't bind to the uas driver);
w = NO_WP_DETECT (don't test whether the
medium is write-protected).
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 3f42785..75d2ccd 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -28,6 +28,7 @@
 #include scsi/scsi_tcq.h
 
 #include uas-detect.h
+#include scsiglue.h
 
 /*
  * The r00-r01c specs define this version of the SENSE IU data structure.
@@ -49,6 +50,7 @@ struct uas_dev_info {
struct usb_anchor cmd_urbs;
struct usb_anchor sense_urbs;
struct usb_anchor data_urbs;
+   unsigned long flags;
int qdepth, resetting;
struct response_iu response;
unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe;
@@ -714,6 +716,15 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
 
BUILD_BUG_ON(sizeof(struct uas_cmd_info)  sizeof(struct scsi_pointer));
 
+   if ((devinfo-flags  US_FL_NO_ATA_1X) 
+   (cmnd-cmnd[0] == ATA_12 || cmnd-cmnd[0] == ATA_16)) {
+   memcpy(cmnd-sense_buffer, usb_stor_sense_invalidCDB,
+  sizeof(usb_stor_sense_invalidCDB));
+   cmnd-result = SAM_STAT_CHECK_CONDITION;
+   cmnd-scsi_done(cmnd);
+   return 0;
+   }
+
spin_lock_irqsave(devinfo-lock, flags);
 
if (devinfo-resetting) {
@@ -1080,6 +1091,8 @@ static int uas_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
devinfo-resetting = 0;
devinfo-running_task = 0;
devinfo-shutdown = 0;
+   devinfo-flags = id-driver_info;
+   usb_stor_adjust_quirks(udev, devinfo-flags);
init_usb_anchor(devinfo-cmd_urbs);
init_usb_anchor(devinfo-sense_urbs);
init_usb_anchor(devinfo-data_urbs);
diff --git a/drivers/usb/storage/unusual_uas.h 
b/drivers/usb/storage/unusual_uas.h
index 724..3ff2dd4 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -40,13 +40,16 @@
  * and don't forget to CC: the USB development list linux-usb@vger.kernel.org
  */
 
-/*
- * This is an example entry for the US_FL_IGNORE_UAS flag. Once we have an
- * actual entry using US_FL_IGNORE_UAS this entry should be removed.
- *
- * UNUSUAL_DEV(  0xabcd, 0x1234, 0x0100, 0x0100,
- * Example,
- * Storage with broken UAS,
- * USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- * US_FL_IGNORE_UAS),
- */
+/* https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
+UNUSUAL_DEV(0x0bc2, 0x2312, 0x, 0x,
+   Seagate,
+   Expansion Desk,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_NO_ATA_1X),
+
+/* https://bbs.archlinux.org/viewtopic.php?id=183190 */
+UNUSUAL_DEV(0x0bc2, 0x3312, 0x, 0x,
+   Seagate,
+   Expansion Desk,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_NO_ATA_1X),
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index cedb292..b9d1b93 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -478,7 +478,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, 
unsigned long *fflags)
US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |

Regression: USB 3.0 stick only running at USB 2.0 speed

2014-09-15 Thread Julian Andres Klode
[Originally reported at
https://bugzilla.kernel.org/show_bug.cgi?id=84611, gregkh told me to
report it here]

My brother's USB 3.0 stick is only recognized as USB 2.0.

I reproduced this bug in kernels 3.14.15, 3.16, and 3.16.2; as built by Debian.
It used to work correctly in 3.14-rc6. The data below is from 3.14.15.

Dmesg
==
[   17.490026] usb 1-2: new high-speed USB device number 2 using xhci_hcd
[   17.681501] usb 1-2: New USB device found, idVendor=8564, idProduct=1000
[   17.681508] usb 1-2: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[   17.681512] usb 1-2: Product: Mass Storage Device
[   17.681515] usb 1-2: Manufacturer: JetFlash
[   17.681517] usb 1-2: SerialNumber: ID8UQEDI

Controller
==
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family
USB xHCI Host Controller (rev 04) (prog-if 30 [XHCI])
Subsystem: Lenovo Device 21fa
Flags: bus master, medium devsel, latency 0, IRQ 40
Memory at f252 (64-bit, non-prefetchable) [size=64K]
Capabilities: access denied
Kernel driver in use: xhci_hcd

Device
==
Bus 001 Device 002: ID 8564:1000
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  idVendor   0x8564
  idProduct  0x1000
  bcdDevice1.00
  iManufacturer   1 JetFlash
  iProduct2 Mass Storage Device
  iSerial 3 ID8UQEDI
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   32
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0
bmAttributes 0x80
  (Bus Powered)
MaxPower  100mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01  EP 1 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82  EP 2 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Device Qualifier (for other device speed):
  bLength10
  bDescriptorType 6
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  bNumConfigurations  1
Device Status: 0x
  (Bus Powered)

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
--
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 fix for 3.17 v5] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Greg Kroah-Hartman
On Mon, Sep 15, 2014 at 04:04:12PM +0200, Hans de Goede wrote:
 And set this quirk for the Seagate Expansion Desk (0bc2:2312), as that one
 seems to hang upon receiving an ATA_12 or ATA_16 command.
 
 https://bugzilla.kernel.org/show_bug.cgi?id=79511
 https://bbs.archlinux.org/viewtopic.php?id=183190
 
 While at it also add missing documentation for the u value for usb-storage
 quirks.
 
 Cc: sta...@vger.kernel.org # 3.16
 Signed-off-by: Hans de Goede hdego...@redhat.com
 
 --
 Changes in v2: Add documentation for new t and u usb-storage.quirks flags
 Changes in v3: Fix typo in documentation
 Changes in v4: Also apply the quirk to (0bc2:3312)
 Changes in v5: Rebased on 3.17-rc5, drop u documentation, already upstream

So I should wait another day for v6?  :)

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


Re: [PATCH fix for 3.17 v5] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Hans de Goede
Hi,

On 09/15/2014 04:08 PM, Greg Kroah-Hartman wrote:
 On Mon, Sep 15, 2014 at 04:04:12PM +0200, Hans de Goede wrote:
 And set this quirk for the Seagate Expansion Desk (0bc2:2312), as that one
 seems to hang upon receiving an ATA_12 or ATA_16 command.

 https://bugzilla.kernel.org/show_bug.cgi?id=79511
 https://bbs.archlinux.org/viewtopic.php?id=183190

 While at it also add missing documentation for the u value for usb-storage
 quirks.

 Cc: sta...@vger.kernel.org # 3.16
 Signed-off-by: Hans de Goede hdego...@redhat.com

 --
 Changes in v2: Add documentation for new t and u usb-storage.quirks flags
 Changes in v3: Fix typo in documentation
 Changes in v4: Also apply the quirk to (0bc2:3312)
 Changes in v5: Rebased on 3.17-rc5, drop u documentation, already upstream
 
 So I should wait another day for v6?  :)

Hehe, no I certainly hope not.

Chances are I there will eventually be more seagate models needing the quirk,
but I've none in the pipeline atm, and we can always add those with an
incremental patch.

So if this is not too late for 3.17 and you can pick up v5 that would be great.

Thanks,

Hans
--
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: Regression: USB 3.0 stick only running at USB 2.0 speed

2014-09-15 Thread Greg KH
On Mon, Sep 15, 2014 at 04:07:30PM +0200, Julian Andres Klode wrote:
 [Originally reported at
 https://bugzilla.kernel.org/show_bug.cgi?id=84611, gregkh told me to
 report it here]
 
 My brother's USB 3.0 stick is only recognized as USB 2.0.
 
 I reproduced this bug in kernels 3.14.15, 3.16, and 3.16.2; as built by 
 Debian.
 It used to work correctly in 3.14-rc6. The data below is from 3.14.15.

What does older kernels show differently?

thanks,

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


[PATCH] usb: musb: dsps: kill OTG timer on suspend

2014-09-15 Thread Felipe Balbi
if we don't make sure to kill the timer, it could
expire after we have already gated our clocks.

That will trigger a Data Abort exception because
we would try to access register while clock is gated.

Fix that bug.

Cc: sta...@vger.kernel.org # v3.14+
Fixes 869c597 (usb: musb: dsps: add support for suspend and resume)
Tested-by: Dave Gerlach d-gerl...@ti.com
Signed-off-by: Felipe Balbi ba...@ti.com
---

I'll send this one together with my v3.18 pull.

 drivers/usb/musb/musb_dsps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index c791ba5..154bcf1 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -870,6 +870,7 @@ static int dsps_suspend(struct device *dev)
struct musb *musb = platform_get_drvdata(glue-musb);
void __iomem *mbase = musb-ctrl_base;
 
+   del_timer_sync(glue-timer);
glue-context.control = dsps_readl(mbase, wrp-control);
glue-context.epintr = dsps_readl(mbase, wrp-epintr_set);
glue-context.coreintr = dsps_readl(mbase, wrp-coreintr_set);
@@ -895,6 +896,7 @@ static int dsps_resume(struct device *dev)
dsps_writel(mbase, wrp-mode, glue-context.mode);
dsps_writel(mbase, wrp-tx_mode, glue-context.tx_mode);
dsps_writel(mbase, wrp-rx_mode, glue-context.rx_mode);
+   setup_timer(glue-timer, otg_timer, (unsigned long) musb);
 
return 0;
 }
-- 
2.0.1.563.g66f467c

--
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 fix for 3.17] uas: Add a quirk for rejecting ATA_12 and ATA_16 commands

2014-09-15 Thread Alan Stern
On Mon, 15 Sep 2014, Oliver Neukum wrote:

 On Mon, 2014-09-15 at 08:42 +, David Laight wrote:
  From: Alan Stern
   
   You must not add an aditional value for a module parameter without
   documenting it in Documentation/kernel-parameters.txt.
  
  How can this work as a 'module parameter'?
 
 It cannot. This parameter is an aid to debugging.

Not true; it really is a module parameter and can be used for multiple
devices at once.  And while it is meant partially for debugging, it's
also meant for testing or for when there's no permanent unusual_devs
quirk entry.

  I might want to use two different usb-scsi devices that have different
  requirements.
 
 Indeed. Quirky devices must be added to the quirks file.

As Hans said (and as described in Documentation/kernel-parameters.txt), 
the parameter format is a comma-separated list of 
vendor-id:product-id:flags triples.

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: Ability to specify SCM_MULT_TARG quirk on command line

2014-09-15 Thread Alan Stern
On Sun, 14 Sep 2014, Mark wrote:

 Hi,
 
 Shuttle Technology/SCM Microsystems was the OEM manufacturer of SCSI-USB
 converter cables sold by various companies including Adaptec [untested
 patch posted recently], Ariston Technologies, Belkin [*], Buffalo,
 Entrega/Xircom [patch posted recently], Microtech [*], Newer Technology
 [*], Olympus[*]
 *: quirk already in unusual-devs.h
 
 The ability to specify the SCM_MULT_TARG quirk on the command line could
 be useful. At least the Ariston and Buffalo products don't have entries in
 unusual-devs.h. I hope to write a patch, but would like some advice on the
 best approach.

Devices with this capability are so rare, it didn't seem worthwhile 
adding it to the list of recognized quirks for the module parameter.

 The letter t is free; should I use that to signify the SCM_MULT_TARG
 quirk? In usb_stor_adjust_quirks() I'd add
   case 't':
   f |= US_FL_SCM_MULT_TARG;
   break;
 
 usb_stor_euscsi_init is the initFunction for all SCM_MULT_TARG quirks. In
 get_device_info(), after the call to usb_stor_adjust_quirks() I could add
 code like
   if (us-fflags  US_FL_SCM_MULT_TARG) {
   unusual_dev-initFunction = usb_stor_euscsi_init;
   }
 
 Alternatively, similar code could be added before the call to initFunction
 in usb_stor_acquire_resources():
   if (us-fflags  US_FL_SCM_MULT_TARG) {
   us-unusual_dev-initFunction = usb_stor_euscsi_init;
   }
 
   /* Just before we start our control thread, initialize
* the device if it needs initialization */
   if (us-unusual_dev-initFunction) {
   p = us-unusual_dev-initFunction(us);
   ...
 
 Is one of those options preferable? Or maybe something else?

It's probably better just to rely on entries to the unusual_devs.h
file.  Those are automatically be available to anyone with an
up-to-date kernel, with no need for messing around with module
parameters.

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


[RFC PATCH 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hi Ming-Lei,

Thanks for your patch to enable the URB giveback in a tasklet context for
the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
issue on the DWC2 HCD in the SOCFPGA platform.

However, I need your help trying to figure out why I need the 2nd patch to
get your URB giveback patch to fully work.

I enable tracepoints in the dwc2 dwc2_handle_hcd_intr for irq:irq_handler_entry
and irq:irq_handler_exit. However, I did not see any measurable differences
between enabling HCD_BH and no enabling HCD_BH. But I am able to get a full
image from a webcam with the following 2 patches, and timeouts/green screen
without the 2 patches.

I am using a Logitech HD C270 webcam.

Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
VO: [sdl] 640x480 = 640x480 Packed YUY2 
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)

Can you provide any comments on the following issues:

1) Am I placing the tracepoints in the right place for this non-ehci hcd?
2) I don't quite understand why removing local_irq_save/local_irq_restore
   around the the complete makes the webcam work?

Thanks in advance for your comments.

Dinh



Dinh Nguyen (2):
  usb: dwc2: Enable HCD_BH in the dwc2 driver
  usb-core: Remove the local_irq_save/local_irq_restore around complete

 drivers/usb/core/hcd.c | 2 --
 drivers/usb/dwc2/hcd.c | 6 +-
 2 files changed, 1 insertion(+), 7 deletions(-)

-- 
2.0.3

--
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 2/2] usb-core: Remove the local_irq_save/local_irq_restore around complete

2014-09-15 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

When enabling HCD_BH for the DWC2 HCD, these local_irq_save/local_irq_restore
was causing a timeout with a webcam.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/usb/core/hcd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487abcf..463dc44 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1678,9 +1678,7 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
 * and no one may trigger the above deadlock situation when
 * running complete() in tasklet.
 */
-   local_irq_save(flags);
urb-complete(urb);
-   local_irq_restore(flags);
 
usb_anchor_resume_wakeups(anchor);
atomic_dec(urb-use_count);
-- 
2.0.3

--
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 1/2] usb: dwc2: Enable HCD_BH in the dwc2 driver

2014-09-15 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Enable the support of running URB giveback in tasklet context.
Remove spinlocks around URB giveback as these are not needed when running
in the tasklet.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/usb/dwc2/hcd.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..9bdc077 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2193,9 +2193,7 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
kfree(qtd-urb);
qtd-urb = NULL;
 
-   spin_unlock(hsotg-lock);
usb_hcd_giveback_urb(dwc2_hsotg_to_hcd(hsotg), urb, status);
-   spin_lock(hsotg-lock);
 }
 
 /*
@@ -2528,9 +2526,7 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, 
struct urb *urb,
urb-hcpriv = NULL;
 
/* Higher layer software sets URB status */
-   spin_unlock(hsotg-lock);
usb_hcd_giveback_urb(hcd, urb, status);
-   spin_lock(hsotg-lock);
 
dev_dbg(hsotg-dev, Called usb_hcd_giveback_urb()\n);
dev_dbg(hsotg-dev,   urb-status = %d\n, urb-status);
@@ -2640,7 +2636,7 @@ static struct hc_driver dwc2_hc_driver = {
.hcd_priv_size = sizeof(struct wrapper_priv_data),
 
.irq = _dwc2_hcd_irq,
-   .flags = HCD_MEMORY | HCD_USB2,
+   .flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
 
.start = _dwc2_hcd_start,
.stop = _dwc2_hcd_stop,
-- 
2.0.3

--
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: Hitting unused qh not empty BUG in qh_destroy

2014-09-15 Thread Alan Stern
On Sat, 13 Sep 2014, Joe Lawrence wrote:

 Hi Alan,
 
 I've collected 16 crashes since kicking off automated tests a little
 over 24 hrs ago.
 
 Each crash hit the BUG in qh_destroy() and the only unique debugging
 printk from ehci_stop() was: ehci_stop: ehci-num_async = 0.

What about error messages from the check_async_ring routine?

 I can include (or upload) a full (or filtered) vmcore-dmesg.txt if that
 would be more helpful.

Only if it includes one of those messages.

 The debug code I added as you suggested is provided below...
 
 Thanks,
 
 -- Joe
 
 
 diff -Nupr before/drivers/usb/host/ehci.h after/drivers/usb/host/ehci.h
 --- before/drivers/usb/host/ehci.h2014-07-16 14:25:31.0 -0400
 +++ after/drivers/usb/host/ehci.h 2014-09-12 15:47:18.943478397 -0400
 @@ -231,6 +231,8 @@ struct ehci_hcd { /* one per controlle
  
   /* platform-specific data -- must come last */
   unsigned long   priv[0] __aligned(sizeof(s64));
 +
 + int num_async;
  };

Not a good idea to put your new field _after_ a field that is
documented as coming last, but in this case it probably won't hurt.

  /* convert between an HCD pointer and the corresponding EHCI_HCD */
 diff -Nupr before/drivers/usb/host/ehci-hcd.c 
 after/drivers/usb/host/ehci-hcd.c
 --- before/drivers/usb/host/ehci-hcd.c2014-07-16 14:25:31.0 
 -0400
 +++ after/drivers/usb/host/ehci-hcd.c 2014-09-12 15:53:16.863163627 -0400
 @@ -440,6 +440,8 @@ static void ehci_stop (struct usb_hcd *h
   if (ehci-amd_pll_fix == 1)
   usb_amd_dev_put();
  
 + pr_err(%s: ehci-num_async = %d\n, __func__, ehci-num_async);
 +
   dbg_status (ehci, ehci_stop completed,
   ehci_readl(ehci, ehci-regs-status));
  }

Always 0, as it should be.

 diff -Nupr before/drivers/usb/host/ehci-q.c after/drivers/usb/host/ehci-q.c
 --- before/drivers/usb/host/ehci-q.c  2014-07-16 14:25:31.0 -0400
 +++ after/drivers/usb/host/ehci-q.c   2014-09-12 15:52:08.023292291 -0400
 @@ -959,6 +959,24 @@ static void disable_async(struct ehci_hc
   ehci_poll_ASS(ehci);
  }
  
 +static void check_async_ring(struct ehci_hcd *ehci, int add)
 +{
 + struct ehci_qh *qh;
 + int n;
 +
 + qh = ehci-async-qh_next.qh;
 + n = ehci-num_async += add;
 + while (qh  n  0) {
 + qh = qh-qh_next.qh;
 + --n;
 + }
 + if (qh || n != 0) {
 + ehci_err(ehci, EHCI async list corrupted: num %d n %d qh %p\n,
 + ehci-num_async, n, qh);
 + BUG();
 + }
 +}

In the last call to this function, ehci-num_async must get set to 0 
(because that is the final value as printed out in ehci_stop).  This 
means n = 0, which means ehci-async-qh_next.qh must be NULL.  And 
this routine is the only place where ehci-num_async gets changed.

But then ehci-async-qh_next.qh isn't NULL when the final qh_destroy 
call is made.  This suggests that something changes it in the meantime.

You can check for this.  Sprinkle ehci_info messages throughout 
ehci_stop, printing the value of ehci-async-qh_next.qh.  It should be 
NULL the entire time.

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: [RFC PATCH 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Alan Stern
On Mon, 15 Sep 2014 dingu...@opensource.altera.com wrote:

 From: Dinh Nguyen dingu...@opensource.altera.com
 
 Hi Ming-Lei,
 
 Thanks for your patch to enable the URB giveback in a tasklet context for
 the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
 issue on the DWC2 HCD in the SOCFPGA platform.
 
 However, I need your help trying to figure out why I need the 2nd patch to
 get your URB giveback patch to fully work.

Maybe you don't need it.  Did you try testing with only the first 
patch?

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: [RFC PATCH 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Dinh Nguyen
On 09/15/2014 11:08 AM, Alan Stern wrote:
 On Mon, 15 Sep 2014 dingu...@opensource.altera.com wrote:
 
 From: Dinh Nguyen dingu...@opensource.altera.com

 Hi Ming-Lei,

 Thanks for your patch to enable the URB giveback in a tasklet context for
 the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
 issue on the DWC2 HCD in the SOCFPGA platform.

 However, I need your help trying to figure out why I need the 2nd patch to
 get your URB giveback patch to fully work.
 
 Maybe you don't need it.  Did you try testing with only the first 
 patch?

Yes, I did. 2nd patch was needed.

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


[PATCH v2] USB: serial: remove zte_ev driver

2014-09-15 Thread Johan Hovold
The zte_ev driver is based on code (once) distributed by ZTE that still
appears to originally have been reverse-engineered and bolted onto the
generic driver.

A closer analysis of the zte_ev setup code reveals that it consists of
standard CDC requests (SET/GET_LINE_CODING and SET_CONTROL_LINE_STATE)
but unfortunately fails to get some of those right. In particular, as
reported by Lei Liu, it fails to lower DTR/RTS on close. It also appears
that the control requests lack the interface argument.

Since line control is already handled properly by the option driver, and
the SET/GET_LINE_CODING requests appears to be redundant (amounts to a
SET 9600 8N1) let's remove the redundant zte_ev driver.

Also move the remaining ZTE PIDs to the generic option modem driver.

Reported-by: Lei Liu liu.le...@zte.com.cn
Signed-off-by: Johan Hovold jo...@kernel.org
---

v2:
 - update against latest usb-next branch of usb-serial tree

 drivers/usb/serial/Kconfig  |   8 --
 drivers/usb/serial/Makefile |   1 -
 drivers/usb/serial/option.c |  11 +-
 drivers/usb/serial/zte_ev.c | 305 
 4 files changed, 10 insertions(+), 315 deletions(-)
 delete mode 100644 drivers/usb/serial/zte_ev.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index c3119eb251bc..a69f7cd9d0bf 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -684,14 +684,6 @@ config USB_SERIAL_WISHBONE
  To compile this driver as a module, choose M here: the
  module will be called wishbone-serial.
 
-config USB_SERIAL_ZTE
-   tristate ZTE USB serial driver
-   help
- Say Y here if you want to use a ZTE USB to serial device.
-
- To compile this driver as a module, choose M here: the
- module will be called zte.
-
 config USB_SERIAL_SSU100
tristate USB Quatech SSU-100 Single Port Serial Driver
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index bfdafd349441..349d9df0895f 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -60,4 +60,3 @@ obj-$(CONFIG_USB_SERIAL_WISHBONE) += 
wishbone-serial.o
 obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
 obj-$(CONFIG_USB_SERIAL_XIRCOM)+= keyspan_pda.o
 obj-$(CONFIG_USB_SERIAL_XSENS_MT)  += xsens_mt.o
-obj-$(CONFIG_USB_SERIAL_ZTE)   += zte_ev.o
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 54a8120897a6..d1a3f6044c8a 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -276,6 +276,7 @@ static void option_instat_callback(struct urb *urb);
 #define ZTE_PRODUCT_MF628  0x0015
 #define ZTE_PRODUCT_MF626  0x0031
 #define ZTE_PRODUCT_AC2726 0xfff1
+#define ZTE_PRODUCT_MG880  0xfffd
 #define ZTE_PRODUCT_CDMA_TECH  0xfffe
 #define ZTE_PRODUCT_AC8710T0x
 #define ZTE_PRODUCT_MC2718 0xffe8
@@ -1560,7 +1561,15 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 
0xff) },
-
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffec, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffee, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff6, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff7, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff8, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfff9, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfffb, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfffc, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MG880, 0xff, 
0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 
0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 
0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 
0xff, 0xff, 0xff) },
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
deleted file mode 100644
index c9bb107d5e5c..
--- a/drivers/usb/serial/zte_ev.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * ZTE_EV USB serial driver
- *
- * Copyright (C) 2012 Greg Kroah-Hartman gre...@linuxfoundation.org
- * Copyright (C) 2012 Linux Foundation
- *
- * 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 

Re: [PATCH v3 0/9] Tegra xHCI support

2014-09-15 Thread Andrew Bresticker
On Mon, Sep 15, 2014 at 12:00 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:
 On 12 September 2014 18:37, Andrew Bresticker abres...@chromium.org wrote:
 On Tue, Sep 9, 2014 at 1:21 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:
 On 8 September 2014 18:22, Andrew Bresticker abres...@chromium.org wrote:
 On Mon, Sep 8, 2014 at 8:34 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:
 On 2 September 2014 23:34, Andrew Bresticker abres...@chromium.org 
 wrote:

 Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
 USB3.0 memory sticks and ethernet dongles using controller firmware
 recently posted by Andrew Chew [2].

 I have had mixed results when testing this on a Jetson TK1 board. Of 8
 USB devices I tested with, about half where probed correctly, but the
 other half repeatedly fail in hub_port_init because in the GET_STATUS
 right after the reset, the C_PORT_CONNECTION bit is set.

 I don't see any correlation between the failure and the kind of usb
 device, but I don't have much experience with USB implementations
 either.

 Hmm... I haven't seen that before.  Which particular devices were you 
 using?

 Here they are:

 work:

 Genius keyboard: 05d5:6782
 Logitech mouse: 046d:c06a
 Denver MP3 player: 10d6:1100
 Atheros Bluetooth dongle: 0cf3:3005

 don't work:

 MCS7830 ethernet dongle: 9710:7830
 Genesys Logic hub: 05e3:0608

 I tried the hub and it works just fine for me... Have you tried this
 on any other boards like Big or Blaze?

 I have a Blaze here, but haven't been able to get the external ports
 to power up. I don't have schematics nor a strong interest to get that
 fixed myself, as I can test my code just fine with the Blaze's
 internal camera and the devices that do work on the Jetson.

Ok, since Blaze has been announced, hopefully we can post a
device-tree for it soon.

 I'm using the firmware file that was posted recently:

 xhci-tegra 7009.usb: Firmware timestamp: 2014-05-02 02:22:50 UTC,
 Falcon state 0x20

Yup, I'm using the same firmware.

 If things work for you with the same sources, .config and firmware, I
 can only think of the hw being different (other hw revision?).

That, or perhaps bootloader differences?  I'm using mainline U-Boot.

Stephen, Thierry, have either of you had a chance to test this series?
--
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 v3 0/9] Tegra xHCI support

2014-09-15 Thread Stephen Warren

On 09/15/2014 11:06 AM, Andrew Bresticker wrote:

On Mon, Sep 15, 2014 at 12:00 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:

On 12 September 2014 18:37, Andrew Bresticker abres...@chromium.org wrote:

On Tue, Sep 9, 2014 at 1:21 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:

On 8 September 2014 18:22, Andrew Bresticker abres...@chromium.org wrote:

On Mon, Sep 8, 2014 at 8:34 AM, Tomeu Vizoso to...@tomeuvizoso.net wrote:

On 2 September 2014 23:34, Andrew Bresticker abres...@chromium.org wrote:


Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
USB3.0 memory sticks and ethernet dongles using controller firmware
recently posted by Andrew Chew [2].


I have had mixed results when testing this on a Jetson TK1 board. Of 8
USB devices I tested with, about half where probed correctly, but the
other half repeatedly fail in hub_port_init because in the GET_STATUS
right after the reset, the C_PORT_CONNECTION bit is set.

I don't see any correlation between the failure and the kind of usb
device, but I don't have much experience with USB implementations
either.


Hmm... I haven't seen that before.  Which particular devices were you using?


Here they are:

work:

Genius keyboard: 05d5:6782
Logitech mouse: 046d:c06a
Denver MP3 player: 10d6:1100
Atheros Bluetooth dongle: 0cf3:3005

don't work:

MCS7830 ethernet dongle: 9710:7830
Genesys Logic hub: 05e3:0608


I tried the hub and it works just fine for me... Have you tried this
on any other boards like Big or Blaze?


I have a Blaze here, but haven't been able to get the external ports
to power up. I don't have schematics nor a strong interest to get that
fixed myself, as I can test my code just fine with the Blaze's
internal camera and the devices that do work on the Jetson.


Ok, since Blaze has been announced, hopefully we can post a
device-tree for it soon.


I'm using the firmware file that was posted recently:

xhci-tegra 7009.usb: Firmware timestamp: 2014-05-02 02:22:50 UTC,
Falcon state 0x20


Yup, I'm using the same firmware.


If things work for you with the same sources, .config and firmware, I
can only think of the hw being different (other hw revision?).


That, or perhaps bootloader differences?  I'm using mainline U-Boot.

Stephen, Thierry, have either of you had a chance to test this series?


I haven't had a chance to yet. I just went to try it out, and found that 
it depends on a whole slew of other patches that I don't have. Is there 
a git branch somewhere to save me having to track down all the dependencies?


Thierry is on vacation right now. I think he was expecting to return 
sometime this week, but the start of his vacation was delayed, so 
perhaps he'll be back a bit later too.


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


Re: [PATCH v5 4/9] usb: rename phy to usb_phy in HCD

2014-09-15 Thread Sergei Shtylyov

Hello.

On 9/15/2014 1:35 PM, Antoine Tenart wrote:


The USB PHY member of the HCD structure is renamed to 'usb_phy' and
modifications are done in all drivers accessing it.



Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
  drivers/usb/chipidea/host.c   |  2 +-
  drivers/usb/core/hcd.c| 20 ++--
  drivers/usb/core/hub.c|  8 
  drivers/usb/host/ehci-fsl.c   | 16 
  drivers/usb/host/ehci-hub.c   |  2 +-
  drivers/usb/host/ehci-msm.c   |  4 ++--
  drivers/usb/host/ehci-tegra.c | 16 
  drivers/usb/host/ohci-omap.c  | 20 ++--
  drivers/usb/misc/lvstest.c|  8 


   I have already re-posted this patch (adding it to my generic PHY patch to 
form a short series) with this file added, and CC'ed you. I haven't heard any 
protest (perhaps I missed it?), why reiterate with this patch instead of 
basing the patchset on my most recent posting?



  include/linux/usb/hcd.h   |  2 +-
  10 files changed, 49 insertions(+), 49 deletions(-)


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


Re: [PATCH v5 5/9] usb: rename gen_phy to phy in HCD

2014-09-15 Thread Sergei Shtylyov

On 9/15/2014 1:35 PM, Antoine Tenart wrote:


The patch adding support to the generic PHY framework introduced a
'gen_phy' member in the HCD structure. Rename it to 'phy' to have a
consistent USB framework.



Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu


   With my recent patches we don't need this anymore. I considered quite 
stupid renaming the field which hasn't been even added yet, so just returned 
to my earlier version which called the field in question 'phy'.


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


Re: XHCI, brain-dead scanner, and microframe rounding

2014-09-15 Thread Mathias Nyman
On 09/14/2014 01:52 AM, Mike Mammarella wrote:
 On Sat, 26 Jul 2014, Mike Mammarella wrote:
 
 On Fri, 4 Jul 2014, Mathias Nyman wrote:

 On 07/01/2014 09:07 AM, Mike Mammarella wrote:
 Hi

 Can you add xhci debugging by enabling CONFIG_DYNAMIC_DEBUG, and run
 `echo -n 'module xhci_hcd =p'  /sys/kernel/debug/dynamic_debug/control`
 as root,
 and send me the output of dmesg.

 Without debugging info it's hard to guess what's going on.

 The microframe rounding look a bit suspicious:
 [12864.453456] usb 3-4: ep 0x81 - rounding interval to 128 microframes, 
 ep desc says 255 microframes

 xhci specs says it needs the interval rounded to nearest 2^(X) value, 
 which would be 256, not 128. I'll take a look at that.

 An other possibility is that it's related to how xhci handles halted 
 endpoints. I got some untested code to fix this, It needs a lot of 
 cleanup but can be tested.

 If you are able to test my ep_reset_halt_test branch (with xhci 
 debugging) I'd be interested to know if it helps.

 Code is at:
 git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git 
 ep_reset_halt_test

 -Mathias

 Thanks! I've built a kernel from fb58633e with CONFIG_DYNAMIC_DEBUG 
 enabled.
 (I also had to mount debugfs, it turns out.) The scanner does not work in
 this configuration. I've posted the logs here:

 http://spark.crystalorb.net/mikem/dmesg.log
 http://spark.crystalorb.net/mikem/scanadf.log

 dmesg seems to have much more information than what showed up on the
 console (which showed only MATTU messages); it may be relevant when
 sifting through that output that the root file system is also on USB.


 Thanks,

 Took a quick look, but can't find any obvious reason why it fails.
 I'll be out of office next week, but I'll try to take a better look again 
 when I return

 usbmon traces of this could give some hint on what is happening

 -Mathias


 Sorry for the delay getting back to you - I've captured traces with EHCI 
 (works) and XHCI (fails). In both cases the scanner is device 10 on bus 1. 
 The kernel is the Debian 3.14.12 kernel (so, in particular, not your 
 ep_reset_halt_test branch), in case that's important for these traces.

 http://spark.crystalorb.net/mikem/usbmon-success.log
 http://spark.crystalorb.net/mikem/usbmon-failure.log

 I appreciate your help looking into this!

 Mike
 
 Hi, just curious if these traces were useful? Is there any other information 
 I could collect that would help?
 
 Thanks!
 
 Mike

I haven't had time to dig into the usbmon traces, but I just got another report 
from Gunter Köningsmann about similar scanner problem, and I just noticed
that in both cases we round the interval for high speed bulk _IN_ endpoint, 
which should not have interval set at all.
The interval value should be ignored by host, but maybe setting it still could 
cause some issues. 

I don't have high hopes for this patch, but it's worth a shot.
Can you try this out and see if it makes any difference?

-Mathias

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8936211..7f21b77 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1291,7 +1291,8 @@ static unsigned int xhci_get_endpoint_interval(struct 
usb_device *udev,
/* Max NAK rate */
if (usb_endpoint_xfer_control(ep-desc) ||
usb_endpoint_xfer_bulk(ep-desc)) {
-   interval = xhci_parse_microframe_interval(udev, ep);
+   if (!usb_endpoint_dir_in(ep-desc))
+   interval = xhci_parse_microframe_interval(udev, 
ep);
break;
}
/* Fall through - SS and HS isoc/int have same decoding */



 
--
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: rounding interval to 128 microframes, ep desc says 255 microframes

2014-09-15 Thread Mathias Nyman
Hi

On 09/13/2014 10:18 AM, Gunter Königsmann wrote:
 Dear Mr. Nyman,
 
 I have finally found out why my scanner isn't working and since it
 seems like the cause is might be be a kernel bug I thought I'd better
 report it.
 I hope you are the right person to send this bug report to.
 
 Kind regards,
 
   Gunter.
 
 [1.] One line summary of the problem:
 rounding interval to 128 microframes, ep desc says 255 microframes
 [2.] Full description of the problem/report:
 When xhci support is enabled my Perfection V10 scanner as well as the
 memory sticks from some of my colleagues will appear in lsusb. But I
 won't be able to access them. What I do get is a dmesg like:
 
 [  582.536845] usb 2-1: new high-speed USB device number 5 using xhci_hcd
 [  582.704435] usb 2-1: New USB device found, idVendor=04b8,
 idProduct=0133
 [  582.704445] usb 2-1: New USB device strings: Mfr=1, Product=2,
 SerialNumber=0
 [  582.704450] usb 2-1: Product: EPSON Scanner
 [  582.704454] usb 2-1: Manufacturer: EPSON
 [  582.704873] usb 2-1: ep 0x81 - rounding interval to 128
 microframes, ep desc says 255 microframes
 [  582.704898] usb 2-1: ep 0x2 - rounding interval to 128 microframes,
 ep desc says 255 microframes
 

We got reports of other scanners some time ago with the same issue on linux-usb 
mailling list.
And they also report rounding of microframes from 255 to 128.

As this is a highspeed device,  with interval value of 255 it must be a bulk 
endpoint, and 
we should only set the interval for OUT bulk endpoints (NAK rate), but this 
shows that we also set it for the IN endpoint.

I think interval value for bulk in endpoints should be ignored, and setting it 
should not matter, but we could try not setting it,

I'll see if can create a patch, I don't have high hopes for it though  

I added  the linux-usb mailing list to cc

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


review-ping: Re: [PATCH] scsi: fix regression that accidentally disabled block-based tcq

2014-09-15 Thread Christoph Hellwig
Can I get some reviews for this patch so that we can get into 3.17-rc?

--
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] scsi: fix regression that accidentally disabled block-based tcq

2014-09-15 Thread Webb Scales

On 9/12/14 7:00 PM, Christoph Hellwig wrote:

Please try the fix below, looks like the commit broke TCQ for all drivers
using block-level tagging.

---
 From 865a19b760d2786fe37d3b5c151a4ecea4c0e95e Mon Sep 17 00:00:00 2001
From: Christoph Hellwig h...@lst.de
Date: Fri, 12 Sep 2014 16:00:19 -0700
Subject: scsi: fix regression that accidentally disabled block-based tcq

The scsi blk-mq support accidentally flipped a conditional, which lead to
never enabling block based tcq when using the legacy request path.

Fixes: d285203cf647d7c9 scsi: add support for a blk-mq based I/O path.
Reported-by: Hans de Goede hdego...@redhat.com
Signed-off-by: Christoph Hellwig h...@lst.de
---
  include/scsi/scsi_tcq.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index cdcc90b..e645835 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -68,7 +68,7 @@ static inline void scsi_activate_tcq(struct scsi_device 
*sdev, int depth)
return;
  
  	if (!shost_use_blk_mq(sdev-host) 

-   blk_queue_tagged(sdev-request_queue))
+   !blk_queue_tagged(sdev-request_queue))
blk_queue_init_tags(sdev-request_queue, depth,
sdev-host-bqt);
  



Reviewed-by: Webb Scales web...@hp.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] scsi: fix regression that accidentally disabled block-based tcq

2014-09-15 Thread Hans de Goede
Hi,

On 9/12/14 7:00 PM, Christoph Hellwig wrote:
 Please try the fix below, looks like the commit broke TCQ for all drivers
 using block-level tagging.

 ---
  From 865a19b760d2786fe37d3b5c151a4ecea4c0e95e Mon Sep 17 00:00:00 2001
 From: Christoph Hellwig h...@lst.de
 Date: Fri, 12 Sep 2014 16:00:19 -0700
 Subject: scsi: fix regression that accidentally disabled block-based tcq

 The scsi blk-mq support accidentally flipped a conditional, which lead to
 never enabling block based tcq when using the legacy request path.

 Fixes: d285203cf647d7c9 scsi: add support for a blk-mq based I/O path.
 Reported-by: Hans de Goede hdego...@redhat.com
 Signed-off-by: Christoph Hellwig h...@lst.de
 ---
   include/scsi/scsi_tcq.h | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
 index cdcc90b..e645835 100644
 --- a/include/scsi/scsi_tcq.h
 +++ b/include/scsi/scsi_tcq.h
 @@ -68,7 +68,7 @@ static inline void scsi_activate_tcq(struct scsi_device 
 *sdev, int depth)
   return;
   
   if (!shost_use_blk_mq(sdev-host) 
 - blk_queue_tagged(sdev-request_queue))
 + !blk_queue_tagged(sdev-request_queue))
   blk_queue_init_tags(sdev-request_queue, depth,
   sdev-host-bqt);
   

Reviewed-by: Hans de Goede hdego...@redhat.com

Regards,

Hans
--
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 v3 0/9] Tegra xHCI support

2014-09-15 Thread Andrew Bresticker
On Mon, Sep 15, 2014 at 11:09 AM, Stephen Warren swar...@wwwdotorg.org wrote:
 On 09/15/2014 11:06 AM, Andrew Bresticker wrote:

 On Mon, Sep 15, 2014 at 12:00 AM, Tomeu Vizoso to...@tomeuvizoso.net
 wrote:

 On 12 September 2014 18:37, Andrew Bresticker abres...@chromium.org
 wrote:

 On Tue, Sep 9, 2014 at 1:21 AM, Tomeu Vizoso to...@tomeuvizoso.net
 wrote:

 On 8 September 2014 18:22, Andrew Bresticker abres...@chromium.org
 wrote:

 On Mon, Sep 8, 2014 at 8:34 AM, Tomeu Vizoso to...@tomeuvizoso.net
 wrote:

 On 2 September 2014 23:34, Andrew Bresticker abres...@chromium.org
 wrote:


 Tested on Venice2, Jetson TK1, and Big with a variety of USB2.0 and
 USB3.0 memory sticks and ethernet dongles using controller firmware
 recently posted by Andrew Chew [2].


 I have had mixed results when testing this on a Jetson TK1 board. Of
 8
 USB devices I tested with, about half where probed correctly, but the
 other half repeatedly fail in hub_port_init because in the GET_STATUS
 right after the reset, the C_PORT_CONNECTION bit is set.

 I don't see any correlation between the failure and the kind of usb
 device, but I don't have much experience with USB implementations
 either.


 Hmm... I haven't seen that before.  Which particular devices were you
 using?


 Here they are:

 work:

 Genius keyboard: 05d5:6782
 Logitech mouse: 046d:c06a
 Denver MP3 player: 10d6:1100
 Atheros Bluetooth dongle: 0cf3:3005

 don't work:

 MCS7830 ethernet dongle: 9710:7830
 Genesys Logic hub: 05e3:0608


 I tried the hub and it works just fine for me... Have you tried this
 on any other boards like Big or Blaze?


 I have a Blaze here, but haven't been able to get the external ports
 to power up. I don't have schematics nor a strong interest to get that
 fixed myself, as I can test my code just fine with the Blaze's
 internal camera and the devices that do work on the Jetson.


 Ok, since Blaze has been announced, hopefully we can post a
 device-tree for it soon.

 I'm using the firmware file that was posted recently:

 xhci-tegra 7009.usb: Firmware timestamp: 2014-05-02 02:22:50 UTC,
 Falcon state 0x20


 Yup, I'm using the same firmware.

 If things work for you with the same sources, .config and firmware, I
 can only think of the hw being different (other hw revision?).


 That, or perhaps bootloader differences?  I'm using mainline U-Boot.

 Stephen, Thierry, have either of you had a chance to test this series?


 I haven't had a chance to yet. I just went to try it out, and found that it
 depends on a whole slew of other patches that I don't have. Is there a git
 branch somewhere to save me having to track down all the dependencies?

Yes, Tomeu has the branch he used for testing here:
http://cgit.collabora.com/git/user/tomeu/linux.git/log/?h=3.17rc4-xhci

You'll also need the firmware Andrew Chew posted:
https://patchwork.ozlabs.org/patch/384013/
--
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] scsi: fix regression that accidentally disabled block-based tcq

2014-09-15 Thread Jeff Moyer
Christoph Hellwig h...@infradead.org writes:

 Please try the fix below, looks like the commit broke TCQ for all drivers 
 using block-level tagging.

 ---
 From 865a19b760d2786fe37d3b5c151a4ecea4c0e95e Mon Sep 17 00:00:00 2001
 From: Christoph Hellwig h...@lst.de
 Date: Fri, 12 Sep 2014 16:00:19 -0700
 Subject: scsi: fix regression that accidentally disabled block-based tcq

 The scsi blk-mq support accidentally flipped a conditional, which lead to
 never enabling block based tcq when using the legacy request path.

 Fixes: d285203cf647d7c9 scsi: add support for a blk-mq based I/O path.
 Reported-by: Hans de Goede hdego...@redhat.com
 Signed-off-by: Christoph Hellwig h...@lst.de
 ---
  include/scsi/scsi_tcq.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
 index cdcc90b..e645835 100644
 --- a/include/scsi/scsi_tcq.h
 +++ b/include/scsi/scsi_tcq.h
 @@ -68,7 +68,7 @@ static inline void scsi_activate_tcq(struct scsi_device 
 *sdev, int depth)
   return;
  
   if (!shost_use_blk_mq(sdev-host) 
 - blk_queue_tagged(sdev-request_queue))
 + !blk_queue_tagged(sdev-request_queue))
   blk_queue_init_tags(sdev-request_queue, depth,
   sdev-host-bqt);

Introduced by d285203:

-   if (!blk_queue_tagged(sdev-request_queue))
+   if (!shost_use_blk_mq(sdev-host) 
+   blk_queue_tagged(sdev-request_queue))

Seems like an obvious fix.

Reviewed-by: Jeff Moyer jmo...@redhat.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: XHCI, brain-dead scanner, and microframe rounding

2014-09-15 Thread Alan Stern
On Mon, 15 Sep 2014, Mathias Nyman wrote:

 I haven't had time to dig into the usbmon traces, but I just got another 
 report from Gunter K�ningsmann about similar scanner problem, and I just 
 noticed
 that in both cases we round the interval for high speed bulk _IN_ endpoint, 
 which should not have interval set at all.
 The interval value should be ignored by host, but maybe setting it still 
 could cause some issues. 
 
 I don't have high hopes for this patch, but it's worth a shot.
 Can you try this out and see if it makes any difference?
 
 -Mathias
 
 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
 index 8936211..7f21b77 100644
 --- a/drivers/usb/host/xhci-mem.c
 +++ b/drivers/usb/host/xhci-mem.c
 @@ -1291,7 +1291,8 @@ static unsigned int xhci_get_endpoint_interval(struct 
 usb_device *udev,
 /* Max NAK rate */
 if (usb_endpoint_xfer_control(ep-desc) ||
 usb_endpoint_xfer_bulk(ep-desc)) {
 -   interval = xhci_parse_microframe_interval(udev, ep);
 +   if (!usb_endpoint_dir_in(ep-desc))
 +   interval = 
 xhci_parse_microframe_interval(udev, ep);

It's not a good idea to test the direction of control endpoints, since
they are bi-directional.

Also, xhci_parse_microframe_interval assumes the value is stored with
an exponential encoding, but the NAK rate value for control and
bulk-OUT endpoints is stored in the endpoint descriptor directly as a
number of microframes (not exponential).

It's not fully clear how xHCI controllers use the Interval field in the
Endpoint Context.  Table 65 notably fails to include a line for HS
bulk-OUT/control endpoints, and the text isn't clear as to whether the
field is interpreted using exponential coding for non-periodic
endpoints.  As near as I can tell, it is -- which means you should call
xhci_microframes_to_exponent() here, not
xhci_parse_microframe_interval().

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: XHCI, brain-dead scanner, and microframe rounding

2014-09-15 Thread Gunter Königsmann
If after applying the patch I still get the warning and the scanner still isn't 
working - did I do something wrong?

cat /proc/version is telling me I'm running the kernel I have compiled.
Thanks a lot,
and

Kind regards,

Gunter.


On 15.09.2014 21:50, Alan Stern wrote:
 On Mon, 15 Sep 2014, Mathias Nyman wrote:

  I haven't had time to dig into the usbmon traces, but I just got another 
  report from Gunter K�ningsmann about similar scanner problem, and I just 
  noticed
  that in both cases we round the interval for high speed bulk _IN_ endpoint, 
  which should not have interval set at all.
  The interval value should be ignored by host, but maybe setting it still 
  could cause some issues.
 
  I don't have high hopes for this patch, but it's worth a shot.
  Can you try this out and see if it makes any difference?
 
  -Mathias
 
  diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
  index 8936211..7f21b77 100644
  --- a/drivers/usb/host/xhci-mem.c
  +++ b/drivers/usb/host/xhci-mem.c
  @@ -1291,7 +1291,8 @@ static unsigned int xhci_get_endpoint_interval(struct 
  usb_device *udev,
  /* Max NAK rate */
  if (usb_endpoint_xfer_control(ep-desc) ||
  usb_endpoint_xfer_bulk(ep-desc)) {
  -   interval = xhci_parse_microframe_interval(udev, ep);
  +   if (!usb_endpoint_dir_in(ep-desc))
  +   interval = 
  xhci_parse_microframe_interval(udev, ep);

 It's not a good idea to test the direction of control endpoints, since
 they are bi-directional.

 Also, xhci_parse_microframe_interval assumes the value is stored with
 an exponential encoding, but the NAK rate value for control and
 bulk-OUT endpoints is stored in the endpoint descriptor directly as a
 number of microframes (not exponential).

 It's not fully clear how xHCI controllers use the Interval field in the
 Endpoint Context.  Table 65 notably fails to include a line for HS
 bulk-OUT/control endpoints, and the text isn't clear as to whether the
 field is interpreted using exponential coding for non-periodic
 endpoints.  As near as I can tell, it is -- which means you should call
 xhci_microframes_to_exponent() here, not
 xhci_parse_microframe_interval().

 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 2/3] usb: dwc2: pass gfp_t flags down to dwc2_hc_setup_align_buf()

2014-09-15 Thread Paul Zimmerman
dwc2_hc_setup_align_buf() does a DMA allocation if it needs to
allocate a buffer to handle non-aligned transfers. Pass the gfp_t
flags down the call chain to this function, instead of hard-coding
a GFP_ATOMIC allocation. Also reduce the size of the allocation
for Isoc endpoints to 3K, since that's the largest possible
transfer size.

Tested on Raspberry Pi and Altera SOCFPGA.

Signed-off-by: Paul Zimmerman pa...@synopsys.com
---
 drivers/usb/dwc2/hcd.c   | 34 +-
 drivers/usb/dwc2/hcd.h   |  6 --
 drivers/usb/dwc2/hcd_ddma.c  |  2 +-
 drivers/usb/dwc2/hcd_intr.c  |  4 ++--
 drivers/usb/dwc2/hcd_queue.c | 16 
 5 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..6a9d1c1 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -404,7 +404,7 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
return 0;
 
spin_lock_irqsave(hsotg-lock, flags);
-   tr_type = dwc2_hcd_select_transactions(hsotg);
+   tr_type = dwc2_hcd_select_transactions(hsotg, mem_flags);
if (tr_type != DWC2_TRANSACTION_NONE)
dwc2_hcd_queue_transactions(hsotg, tr_type);
spin_unlock_irqrestore(hsotg-lock, flags);
@@ -697,21 +697,27 @@ static void *dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
 }
 
 static int dwc2_hc_setup_align_buf(struct dwc2_hsotg *hsotg, struct dwc2_qh 
*qh,
-  struct dwc2_host_chan *chan, void *bufptr)
+  struct dwc2_host_chan *chan,
+  struct dwc2_hcd_urb *urb, void *bufptr,
+  gfp_t mem_flags)
 {
u32 buf_size;
 
-   if (chan-ep_type != USB_ENDPOINT_XFER_ISOC)
-   buf_size = hsotg-core_params-max_transfer_size;
-   else
-   buf_size = 4096;
-
if (!qh-dw_align_buf) {
+   if (chan-ep_type != USB_ENDPOINT_XFER_ISOC)
+   buf_size = hsotg-core_params-max_transfer_size;
+   else
+   /* 3072 = 3 max-size Isoc packets */
+   buf_size = 3072;
+
qh-dw_align_buf = dma_alloc_coherent(hsotg-dev, buf_size,
  qh-dw_align_buf_dma,
- GFP_ATOMIC);
+ mem_flags);
if (!qh-dw_align_buf)
return -ENOMEM;
+   qh-dw_align_buf_size = buf_size;
+   } else {
+   buf_size = qh-dw_align_buf_size;
}
 
if (!chan-ep_is_in  chan-xfer_len) {
@@ -735,7 +741,8 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
  * @qh:Transactions from the first QTD for this QH are selected and 
assigned
  * to a free host channel
  */
-static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh 
*qh)
+static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh 
*qh,
+  gfp_t mem_flags)
 {
struct dwc2_host_chan *chan;
struct dwc2_hcd_urb *urb;
@@ -828,7 +835,8 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh)
/* Non DWORD-aligned buffer case */
if (bufptr) {
dev_vdbg(hsotg-dev, Non-aligned buffer\n);
-   if (dwc2_hc_setup_align_buf(hsotg, qh, chan, bufptr)) {
+   if (dwc2_hc_setup_align_buf(hsotg, qh, chan, urb, bufptr,
+   mem_flags)) {
dev_err(hsotg-dev,
%s: Failed to allocate memory to handle 
non-dword aligned buffer\n,
__func__);
@@ -872,7 +880,7 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh)
  * Return: The types of new transactions that were assigned to host channels
  */
 enum dwc2_transaction_type dwc2_hcd_select_transactions(
-   struct dwc2_hsotg *hsotg)
+   struct dwc2_hsotg *hsotg, gfp_t mem_flags)
 {
enum dwc2_transaction_type ret_val = DWC2_TRANSACTION_NONE;
struct list_head *qh_ptr;
@@ -894,7 +902,7 @@ enum dwc2_transaction_type dwc2_hcd_select_transactions(
hsotg-available_host_channels--;
}
qh = list_entry(qh_ptr, struct dwc2_qh, qh_list_entry);
-   if (dwc2_assign_and_init_hc(hsotg, qh))
+   if (dwc2_assign_and_init_hc(hsotg, qh, mem_flags))
break;
 
/*
@@ -927,7 +935,7 @@ enum dwc2_transaction_type dwc2_hcd_select_transactions(
hsotg-available_host_channels--;
}
 
-   if 

[PATCH 3/3] usb: dwc2: handle DMA buffer unmapping sanely

2014-09-15 Thread Paul Zimmerman
The driver's unmapping of DMA buffers for non-aligned transfers
was kind of nuts. For IN transfers, it left the URB DMA buffer
mapped until the transfer completed, then unmapped it, copied the
data from the bounce buffer, then remapped it again.

Instead of that, just unmap the buffer before starting the
transfer. Also, use usb_hcd_unmap_urb_for_dma() to unmap the
buffer, instead of open-coding it. This should allow handling of
other types of mappings besides just dma_map_single() ones.

Tested on Raspberry Pi and Altera SOCFPGA.

Signed-off-by: Paul Zimmerman pa...@synopsys.com
---
 drivers/usb/dwc2/hcd.c  | 27 +++
 drivers/usb/dwc2/hcd_intr.c | 22 --
 2 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 6a9d1c1..dd2e802 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -702,6 +702,8 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
   gfp_t mem_flags)
 {
u32 buf_size;
+   struct urb *usb_urb;
+   struct usb_hcd *hcd;
 
if (!qh-dw_align_buf) {
if (chan-ep_type != USB_ENDPOINT_XFER_ISOC)
@@ -716,16 +718,25 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
if (!qh-dw_align_buf)
return -ENOMEM;
qh-dw_align_buf_size = buf_size;
-   } else {
-   buf_size = qh-dw_align_buf_size;
}
 
-   if (!chan-ep_is_in  chan-xfer_len) {
-   dma_sync_single_for_cpu(hsotg-dev, chan-xfer_dma, buf_size,
-   DMA_TO_DEVICE);
-   memcpy(qh-dw_align_buf, bufptr, chan-xfer_len);
-   dma_sync_single_for_device(hsotg-dev, chan-xfer_dma, buf_size,
-  DMA_TO_DEVICE);
+   if (chan-xfer_len) {
+   dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n, __func__);
+   usb_urb = urb-priv;
+
+   if (usb_urb) {
+   if (usb_urb-transfer_flags 
+   (URB_SETUP_MAP_SINGLE | URB_DMA_MAP_SG |
+URB_DMA_MAP_PAGE | URB_DMA_MAP_SINGLE)) {
+   hcd = dwc2_hsotg_to_hcd(hsotg);
+   usb_hcd_unmap_urb_for_dma(hcd, usb_urb);
+   }
+   if (!chan-ep_is_in)
+   memcpy(qh-dw_align_buf, bufptr,
+  chan-xfer_len);
+   } else {
+   dev_warn(hsotg-dev, no URB in dwc2_urb\n);
+   }
}
 
chan-align_buf = qh-dw_align_buf_dma;
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index fd6699d..13f8f55 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -465,12 +465,8 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg,
/* Non DWORD-aligned buffer case handling */
if (chan-align_buf  xfer_length  chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n, __func__);
-   dma_sync_single_for_cpu(hsotg-dev, urb-dma, urb-length,
-   DMA_FROM_DEVICE);
memcpy(urb-buf + urb-actual_length, chan-qh-dw_align_buf,
   xfer_length);
-   dma_sync_single_for_device(hsotg-dev, urb-dma, urb-length,
-  DMA_FROM_DEVICE);
}
 
dev_vdbg(hsotg-dev, urb-actual_length=%d xfer_length=%d\n,
@@ -560,14 +556,9 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n,
 __func__);
-   dma_sync_single_for_cpu(hsotg-dev, urb-dma,
-   urb-length, DMA_FROM_DEVICE);
memcpy(urb-buf + frame_desc-offset +
   qtd-isoc_split_offset, chan-qh-dw_align_buf,
   frame_desc-actual_length);
-   dma_sync_single_for_device(hsotg-dev, urb-dma,
-  urb-length,
-  DMA_FROM_DEVICE);
}
break;
case DWC2_HC_XFER_FRAME_OVERRUN:
@@ -594,14 +585,9 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n,
 __func__);
-   dma_sync_single_for_cpu(hsotg-dev, urb-dma,
-   urb-length, DMA_FROM_DEVICE);
memcpy(urb-buf + frame_desc-offset +

[PATCH 1/3] usb: dwc2: clip max_transfer_size to 65535

2014-09-15 Thread Paul Zimmerman
Clip max_transfer_size to 65535 for host. dwc2_hc_setup_align_buf()
allocates coherent buffers with this size, and if it's too large we
can exhaust the coherent DMA pool.

Tested on Raspberry Pi and Altera SOCFPGA.

Signed-off-by: Paul Zimmerman pa...@synopsys.com
---
 drivers/usb/dwc2/core.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index ea0048a..d926945 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -2743,6 +2743,13 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
width = (hwcfg3  GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK) 
GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT;
hw-max_transfer_size = (1  (width + 11)) - 1;
+   /*
+* Clip max_transfer_size to 65535. dwc2_hc_setup_align_buf() allocates
+* coherent buffers with this size, and if it's too large we can
+* exhaust the coherent DMA pool.
+*/
+   if (hw-max_transfer_size  65535)
+   hw-max_transfer_size = 65535;
width = (hwcfg3  GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK) 
GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT;
hw-max_packet_count = (1  (width + 4)) - 1;
-- 
2.1.0.24.g4109c28

--
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 0/3] usb: dwc2: driver updates for 3.18

2014-09-15 Thread Paul Zimmerman
This is a series of updates to the dwc2 driver, all related
to the handling of non-dword-aligned transfers. I have tested
all of these on the Raspberry Pi and Altera SOCFPGA platforms,
and have not seen any regressions.

Greg, can you apply this series to usb-next, please? Thanks.

-- 
Paul

Paul Zimmerman (3):
  usb: dwc2: clip max_transfer_size to 65535
  usb: dwc2: pass gfp_t flags down to dwc2_hc_setup_align_buf()
  usb: dwc2: handle DMA buffer unmapping sanely

 drivers/usb/dwc2/core.c  |  7 ++
 drivers/usb/dwc2/hcd.c   | 57 +---
 drivers/usb/dwc2/hcd.h   |  6 +++--
 drivers/usb/dwc2/hcd_ddma.c  |  2 +-
 drivers/usb/dwc2/hcd_intr.c  | 26 ++--
 drivers/usb/dwc2/hcd_queue.c | 16 -
 6 files changed, 56 insertions(+), 58 deletions(-)

-- 
2.1.0.24.g4109c28

--
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 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Paul Zimmerman
 From: dingu...@opensource.altera.com [mailto:dingu...@opensource.altera.com]
 Sent: Monday, September 15, 2014 8:23 AM
 
 Hi Ming-Lei,
 
 Thanks for your patch to enable the URB giveback in a tasklet context for
 the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
 issue on the DWC2 HCD in the SOCFPGA platform.
 
 However, I need your help trying to figure out why I need the 2nd patch to
 get your URB giveback patch to fully work.
 
 I enable tracepoints in the dwc2 dwc2_handle_hcd_intr for 
 irq:irq_handler_entry
 and irq:irq_handler_exit. However, I did not see any measurable differences
 between enabling HCD_BH and no enabling HCD_BH. But I am able to get a full
 image from a webcam with the following 2 patches, and timeouts/green screen
 without the 2 patches.
 
 I am using a Logitech HD C270 webcam.
 
 Opening video decoder: [raw] RAW Uncompressed Video
 Movie-Aspect is undefined - no prescaling applied.
 VO: [sdl] 640x480 = 640x480 Packed YUY2
 Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
 
 Can you provide any comments on the following issues:
 
 1) Am I placing the tracepoints in the right place for this non-ehci hcd?
 2) I don't quite understand why removing local_irq_save/local_irq_restore
around the the complete makes the webcam work?
 
 Thanks in advance for your comments.

Hi Dinh,

I'm not Ming, but I can hazard a guess why you are seeing this issue.

The webcam driver is likely doing a lot of processing in the -complete
callback. With local interrupts disabled, this probably causes too long
of a delay in handling other interrupts. Since the SOCFPGA platform is
a uniprocessor (I think), there is no other CPU to handle the other
interrupts.

I think the only solution is to look at whatever driver is handling the
webcam, and see if it can re-enable interrupts earlier. I believe this
is an OK thing for it to do when the interrupt handler is threaded.

Ah, wait. I just looked at the specs, and I see the SOCFPGA is
dual-core. So the second core should be available for handling the
other interrupts. I wonder if something is wrong there? Is the 2nd CPU
actually running? Are interrupts getting disabled on both CPUs somehow?

-- 
Paul

--
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/3] usb: dwc2: driver updates for 3.18

2014-09-15 Thread Paul Zimmerman
 From: Paul Zimmerman [mailto:pa...@synopsys.com]
 Sent: Monday, September 15, 2014 3:28 PM
 
 This is a series of updates to the dwc2 driver, all related
 to the handling of non-dword-aligned transfers. I have tested
 all of these on the Raspberry Pi and Altera SOCFPGA platforms,
 and have not seen any regressions.
 
 Greg, can you apply this series to usb-next, please? Thanks.

Whups, I just spotted a problem with the 2nd patch (disabling IRQs but
using the previous mem flags). Greg, please hold off applying patches 2
and 3 for now. Patch 1 is still OK though.

-- 
Paul

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


Re: [PATCH v5 7/9] usb: rename transceiver and phy to usb_phy in ChipIdea

2014-09-15 Thread Peter Chen
On Mon, Sep 15, 2014 at 12:35:07PM +0200, Antoine Tenart wrote:
 This patch prepares the introduction of the generic PHY support in the
 USB ChipIdea common functions. The USB PHY member of the ChipIdea
 structure ('transceiver') is renamed to 'usb_phy', the 'phy' member of
 the ChipIdea pdata structure is renamed to 'usb_phy' and modifications
 are done in all drivers accessing it. Renaming this pointer will allow
 to keep the compatibility for USB PHY drivers.
 

This one looks ok, will have a test.

Peter

 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
 ---
  drivers/usb/chipidea/ci.h  |  4 ++--
  drivers/usb/chipidea/ci_hdrc_imx.c |  2 +-
  drivers/usb/chipidea/ci_hdrc_msm.c |  8 
  drivers/usb/chipidea/core.c| 20 ++--
  drivers/usb/chipidea/debug.c   |  2 +-
  drivers/usb/chipidea/host.c|  4 ++--
  drivers/usb/chipidea/otg_fsm.c |  4 ++--
  drivers/usb/chipidea/udc.c |  4 ++--
  include/linux/usb/chipidea.h   |  2 +-
  9 files changed, 25 insertions(+), 25 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
 index 9563cb56d564..b2caa1772712 100644
 --- a/drivers/usb/chipidea/ci.h
 +++ b/drivers/usb/chipidea/ci.h
 @@ -161,7 +161,7 @@ struct hw_bank {
   * @test_mode: the selected test mode
   * @platdata: platform specific information supplied by parent device
   * @vbus_active: is VBUS active
 - * @transceiver: pointer to USB PHY, if any
 + * @usb_phy: pointer to USB PHY, if any
   * @hcd: pointer to usb_hcd for ehci host driver
   * @debugfs: root dentry for this controller in debugfs
   * @id_event: indicates there is an id event, and handled at ci_otg_work
 @@ -201,7 +201,7 @@ struct ci_hdrc {
  
   struct ci_hdrc_platform_data*platdata;
   int vbus_active;
 - struct usb_phy  *transceiver;
 + struct usb_phy  *usb_phy;
   struct usb_hcd  *hcd;
   struct dentry   *debugfs;
   boolid_event;
 diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
 b/drivers/usb/chipidea/ci_hdrc_imx.c
 index a7ab0f15926e..6f8b1b1045b5 100644
 --- a/drivers/usb/chipidea/ci_hdrc_imx.c
 +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
 @@ -147,7 +147,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
   goto err_clk;
   }
  
 - pdata.phy = data-phy;
 + pdata.usb_phy = data-phy;
  
   if (imx_platform_flag-flags  CI_HDRC_IMX_IMX28_WRITE_FIX)
   pdata.flags |= CI_HDRC_IMX28_WRITE_FIX;
 diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
 b/drivers/usb/chipidea/ci_hdrc_msm.c
 index 4935ac38fd00..3edf969ed797 100644
 --- a/drivers/usb/chipidea/ci_hdrc_msm.c
 +++ b/drivers/usb/chipidea/ci_hdrc_msm.c
 @@ -26,15 +26,15 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, 
 unsigned event)
   dev_dbg(dev, CI_HDRC_CONTROLLER_RESET_EVENT received\n);
   writel(0, USB_AHBBURST);
   writel(0, USB_AHBMODE);
 - usb_phy_init(ci-transceiver);
 + usb_phy_init(ci-usb_phy);
   break;
   case CI_HDRC_CONTROLLER_STOPPED_EVENT:
   dev_dbg(dev, CI_HDRC_CONTROLLER_STOPPED_EVENT received\n);
   /*
 -  * Put the transceiver in non-driving mode. Otherwise host
 +  * Put the phy in non-driving mode. Otherwise host
* may not detect soft-disconnection.
*/
 - usb_phy_notify_disconnect(ci-transceiver, USB_SPEED_UNKNOWN);
 + usb_phy_notify_disconnect(ci-usb_phy, USB_SPEED_UNKNOWN);
   break;
   default:
   dev_dbg(dev, unknown ci_hdrc event\n);
 @@ -68,7 +68,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev)
   if (IS_ERR(phy))
   return PTR_ERR(phy);
  
 - ci_hdrc_msm_platdata.phy = phy;
 + ci_hdrc_msm_platdata.usb_phy = phy;
  
   plat_ci = ci_hdrc_add_device(pdev-dev,
   pdev-resource, pdev-num_resources,
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 579b3538cb27..ee96b0696a7b 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -306,7 +306,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
   case USBPHY_INTERFACE_MODE_UTMI:
   case USBPHY_INTERFACE_MODE_UTMIW:
   case USBPHY_INTERFACE_MODE_HSIC:
 - ret = usb_phy_init(ci-transceiver);
 + ret = usb_phy_init(ci-usb_phy);
   if (ret)
   return ret;
   hw_phymode_configure(ci);
 @@ -314,12 +314,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
   case USBPHY_INTERFACE_MODE_ULPI:
   case USBPHY_INTERFACE_MODE_SERIAL:
   hw_phymode_configure(ci);
 - ret = usb_phy_init(ci-transceiver);
 + ret = usb_phy_init(ci-usb_phy);
   if (ret)
 

Re: [PATCH v5 9/9] usb: chipidea: add support to the generic PHY framework in ChipIdea

2014-09-15 Thread Peter Chen
On Mon, Sep 15, 2014 at 12:35:09PM +0200, Antoine Tenart wrote:
 This patch adds support of the PHY framework for ChipIdea drivers.
 Changes are done in both the ChipIdea common code and in the drivers
 accessing the PHY. This is done by adding a new PHY member in
 ChipIdea's structures and by taking care of it in the code.
 
 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
 ---
  drivers/usb/chipidea/ci.h  |  5 ++-
  drivers/usb/chipidea/core.c| 83 
 +-
  drivers/usb/chipidea/debug.c   |  2 +-
  drivers/usb/chipidea/host.c|  5 ++-
  drivers/usb/chipidea/otg_fsm.c |  6 ++-
  include/linux/usb/chipidea.h   |  2 +
  6 files changed, 81 insertions(+), 22 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
 index dac5ab6adfa2..7e9e8223672a 100644
 --- a/drivers/usb/chipidea/ci.h
 +++ b/drivers/usb/chipidea/ci.h
 @@ -161,7 +161,8 @@ struct hw_bank {
   * @test_mode: the selected test mode
   * @platdata: platform specific information supplied by parent device
   * @vbus_active: is VBUS active
 - * @usb_phy: pointer to USB PHY, if any
 + * @phy: pointer to PHY, if any
 + * @usb_phy: pointer to USB PHY, if any and if using the USB PHY framework
   * @hcd: pointer to usb_hcd for ehci host driver
   * @debugfs: root dentry for this controller in debugfs
   * @id_event: indicates there is an id event, and handled at ci_otg_work
 @@ -202,6 +203,8 @@ struct ci_hdrc {
  
   struct ci_hdrc_platform_data*platdata;
   int vbus_active;
 + struct phy  *phy;
 + /* old usb_phy interface */
   struct usb_phy  *usb_phy;
   struct usb_hcd  *hcd;
   struct dentry   *debugfs;
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index ee96b0696a7b..e1d3d3f44075 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -47,6 +47,7 @@
  #include linux/delay.h
  #include linux/device.h
  #include linux/dma-mapping.h
 +#include linux/phy/phy.h
  #include linux/platform_device.h
  #include linux/module.h
  #include linux/idr.h
 @@ -293,6 +294,49 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
  }
  
  /**
 + * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
 + * interfaces
 + * @ci: the controller
 + *
 + * This function returns an error code if the phy failed to init
 + */
 +static int _ci_usb_phy_init(struct ci_hdrc *ci)
 +{
 + int ret;
 +
 + if (ci-phy) {
 + ret = phy_init(ci-phy);
 + if (ret)
 + return ret;
 +
 + ret = phy_power_on(ci-phy);
 + if (ret) {
 + phy_exit(ci-phy);
 + return ret;
 + }
 + } else {
 + ret = usb_phy_init(ci-usb_phy);
 + }
 +
 + return ret;
 +}
 +
 +/**
 + * _ci_usb_phy_exit: deinitialize phy taking in account both phy and usb_phy
 + * interfaces
 + * @ci: the controller
 + */
 +static void ci_usb_phy_exit(struct ci_hdrc *ci)
 +{
 + if (ci-phy) {
 + phy_power_off(ci-phy);
 + phy_exit(ci-phy);
 + } else {
 + usb_phy_shutdown(ci-usb_phy);
 + }
 +}
 +
 +/**
   * ci_usb_phy_init: initialize phy according to different phy type
   * @ci: the controller
*
 @@ -306,7 +350,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
   case USBPHY_INTERFACE_MODE_UTMI:
   case USBPHY_INTERFACE_MODE_UTMIW:
   case USBPHY_INTERFACE_MODE_HSIC:
 - ret = usb_phy_init(ci-usb_phy);
 + ret = _ci_usb_phy_init(ci);
   if (ret)
   return ret;
   hw_phymode_configure(ci);
 @@ -314,12 +358,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
   case USBPHY_INTERFACE_MODE_ULPI:
   case USBPHY_INTERFACE_MODE_SERIAL:
   hw_phymode_configure(ci);
 - ret = usb_phy_init(ci-usb_phy);
 + ret = _ci_usb_phy_init(ci);
   if (ret)
   return ret;
   break;
   default:
 - ret = usb_phy_init(ci-usb_phy);
 + ret = _ci_usb_phy_init(ci);
   }
  
   return ret;
 @@ -595,23 +639,26 @@ static int ci_hdrc_probe(struct platform_device *pdev)
   return -ENODEV;
   }
  
 - if (ci-platdata-usb_phy)
 + if (ci-platdata-phy) {
 + ci-phy = ci-platdata-phy;
 + } else if (ci-platdata-usb_phy) {
   ci-usb_phy = ci-platdata-usb_phy;
 - else
 + } else {
 + ci-phy = devm_phy_get(dev, usb-phy);
   ci-usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
  
 - if (IS_ERR(ci-usb_phy)) {
 - ret = PTR_ERR(ci-usb_phy);
 - /*
 -  * if -ENXIO is returned, it means PHY layer wasn't
 -  * enabled, so it makes no sense to return -EPROBE_DEFER
 -  

Re: [RFC PATCH 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Ming Lei
On Mon, Sep 15, 2014 at 11:22 PM,  dingu...@opensource.altera.com wrote:
 From: Dinh Nguyen dingu...@opensource.altera.com

 Hi Ming-Lei,

 Thanks for your patch to enable the URB giveback in a tasklet context for
 the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
 issue on the DWC2 HCD in the SOCFPGA platform.

 However, I need your help trying to figure out why I need the 2nd patch to
 get your URB giveback patch to fully work.

Without your second patch, local interrupt is still disabled even the completion
handler is run from tasklet context. Generally speaking, what we want is to
decrease the interrupt disable period from USB.  But this change can make
the same host controller interrupt handled on other CPUs at the same time too.


 I enable tracepoints in the dwc2 dwc2_handle_hcd_intr for 
 irq:irq_handler_entry
 and irq:irq_handler_exit. However, I did not see any measurable differences
 between enabling HCD_BH and no enabling HCD_BH. But I am able to get a full

Which platform are you running? There should have been big difference between
the two setting. Per my experiences, some ARM platform uses a low frequency
clock source(such as 32K on pandaboard, or omap5), so the time stamp in
trace isn't accurate enough, but high resolution timer can be passed from kernel
parameter too.

 image from a webcam with the following 2 patches, and timeouts/green screen
 without the 2 patches.

 I am using a Logitech HD C270 webcam.

 Opening video decoder: [raw] RAW Uncompressed Video
 Movie-Aspect is undefined - no prescaling applied.
 VO: [sdl] 640x480 = 640x480 Packed YUY2
 Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)

 Can you provide any comments on the following issues:

 1) Am I placing the tracepoints in the right place for this non-ehci hcd?

I think it is right if URB completion is run from the only interrupt handler
of DWC2.

Maybe you needn't put it by yourself, and the built-in irq_handler_entry
and irq_handler_exit events should be enough for your test.

 2) I don't quite understand why removing local_irq_save/local_irq_restore
around the the complete makes the webcam work?

The two helpers around the -complete() should have been removed but
it isn't mature since we need to make all current drivers safe with
the conversion.

See below link:

http://marc.info/?w=2r=1s=enabling+irq+completeq=t

If you plan to use the feature, the above changes have to be merged first.

Thanks,
--
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 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Ming Lei
On Tue, Sep 16, 2014 at 7:16 AM, Paul Zimmerman
paul.zimmer...@synopsys.com wrote:
 From: dingu...@opensource.altera.com [mailto:dingu...@opensource.altera.com]
 Sent: Monday, September 15, 2014 8:23 AM

 Hi Ming-Lei,

 Thanks for your patch to enable the URB giveback in a tasklet context for
 the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
 issue on the DWC2 HCD in the SOCFPGA platform.

 However, I need your help trying to figure out why I need the 2nd patch to
 get your URB giveback patch to fully work.

 I enable tracepoints in the dwc2 dwc2_handle_hcd_intr for 
 irq:irq_handler_entry
 and irq:irq_handler_exit. However, I did not see any measurable differences
 between enabling HCD_BH and no enabling HCD_BH. But I am able to get a full
 image from a webcam with the following 2 patches, and timeouts/green screen
 without the 2 patches.

 I am using a Logitech HD C270 webcam.

 Opening video decoder: [raw] RAW Uncompressed Video
 Movie-Aspect is undefined - no prescaling applied.
 VO: [sdl] 640x480 = 640x480 Packed YUY2
 Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)

 Can you provide any comments on the following issues:

 1) Am I placing the tracepoints in the right place for this non-ehci hcd?
 2) I don't quite understand why removing local_irq_save/local_irq_restore
around the the complete makes the webcam work?

 Thanks in advance for your comments.

 Hi Dinh,

 I'm not Ming, but I can hazard a guess why you are seeing this issue.

 The webcam driver is likely doing a lot of processing in the -complete
 callback. With local interrupts disabled, this probably causes too long
 of a delay in handling other interrupts. Since the SOCFPGA platform is
 a uniprocessor (I think), there is no other CPU to handle the other
 interrupts.

Per my previous observation, on some ARM platforms it is extremely
slow to memcpy to DMA coherent buffer, which is used in uvcvideo
at default. I remember Pandaboard should be one such platform.

You can check if it is your case.


 I think the only solution is to look at whatever driver is handling the
 webcam, and see if it can re-enable interrupts earlier. I believe this
 is an OK thing for it to do when the interrupt handler is threaded.

You need to persuade all usb camera drivers' maintainera to agree
on this change to these drivers, :-)

We discussed to take threaded-irq too, looks which may decrease
usb-storage performance a bit.

 Ah, wait. I just looked at the specs, and I see the SOCFPGA is
 dual-core. So the second core should be available for handling the
 other interrupts. I wonder if something is wrong there? Is the 2nd CPU
 actually running? Are interrupts getting disabled on both CPUs somehow?

The same interrupt can't be handled on two CPU cores at the same time.

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


Re: [PATCH v5 07/12] usb: chipidea: add a usb2 driver for ci13xxx

2014-09-15 Thread Peter Chen
On Mon, Sep 15, 2014 at 12:36:13PM +0200, Antoine Tenart wrote:
 Add a USB2 ChipIdea driver for ci13xxx, with optional PHY, clock
 and DMA mask, to support USB2 ChipIdea controllers that don't need
 specific functions.
 
 Tested on the Marvell Berlin SoCs USB controllers.
 
 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
 ---
  drivers/usb/chipidea/Makefile   |   1 +
  drivers/usb/chipidea/ci_hdrc_usb2.c | 137 
 
  2 files changed, 138 insertions(+)
  create mode 100644 drivers/usb/chipidea/ci_hdrc_usb2.c
 
 diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
 index 2f099c7df7b5..1fc86a2ca22d 100644
 --- a/drivers/usb/chipidea/Makefile
 +++ b/drivers/usb/chipidea/Makefile
 @@ -10,6 +10,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM)   += otg_fsm.o
  
  # Glue/Bridge layers go here
  
 +obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_usb2.o
  obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_msm.o
  obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_zevio.o
  
 diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c 
 b/drivers/usb/chipidea/ci_hdrc_usb2.c
 new file mode 100644
 index ..1ef0db79505a
 --- /dev/null
 +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
 @@ -0,0 +1,137 @@
 +/*
 + * Copyright (C) 2014 Marvell Technology Group Ltd.
 + *
 + * Antoine Tenart antoine.ten...@free-electrons.com
 + *
 + * This file is licensed under the terms of the GNU General Public
 + * License version 2. This program is licensed as is without any
 + * warranty of any kind, whether express or implied.
 + */
 +
 +#include linux/clk.h
 +#include linux/dma-mapping.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/platform_device.h
 +#include linux/usb/chipidea.h
 +#include linux/usb/hcd.h
 +#include linux/usb/ulpi.h
 +
 +#include ci.h
 +
 +struct ci_hdrc_usb2_priv {
 + struct platform_device  *ci_pdev;
 + struct clk  *clk;
 +};
 +
 +static int ci_hdrc_usb2_dt_probe(struct device *dev,
 +  struct ci_hdrc_platform_data *ci_pdata)
 +{
 + ci_pdata-phy = of_phy_get(dev-of_node, 0);
 + if (IS_ERR(ci_pdata-phy)) {
 + if (PTR_ERR(ci_pdata-phy) == -EPROBE_DEFER)
 + return -EPROBE_DEFER;
 +
 + /* PHY is optional */
 + ci_pdata-phy = NULL;
 + }
 +
 + return 0;
 +}
 +
 +static struct ci_hdrc_platform_data ci_default_pdata = {
 + .capoffset  = DEF_CAPOFFSET,
 + .flags  = CI_HDRC_REQUIRE_TRANSCEIVER |
 +   CI_HDRC_DISABLE_STREAMING,
 +};
 +
 +static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct ci_hdrc_usb2_priv *priv;
 + struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(pdev-dev);
 + int ret;
 +
 + if (!ci_pdata)
 + ci_pdata = ci_default_pdata;
 +
 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 + if (!priv)
 + return -ENOMEM;
 +
 + priv-clk = devm_clk_get(dev, NULL);
 + if (!IS_ERR(priv-clk)) {
 + ret = clk_prepare_enable(priv-clk);
 + if (ret) {
 + dev_err(dev, failed to enable the clock: %d\n, ret);
 + return ret;
 + }
 + }
 +
 + if (dev-of_node) {
 + ret = ci_hdrc_usb2_dt_probe(dev, ci_pdata);
 + if (ret)
 + goto clk_err;
 + } else {
 + ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
 + if (ret)
 + goto clk_err;
 + }
 +
 + ci_pdata-name = dev_name(pdev-dev);
 +
 + priv-ci_pdev = ci_hdrc_add_device(dev, pdev-resource,
 +pdev-num_resources, ci_pdata);
 + if (IS_ERR(priv-ci_pdev)) {
 + ret = PTR_ERR(priv-ci_pdev);
 + if (ret != -EPROBE_DEFER)
 + dev_err(dev,
 + failed to register ci_hdrc platform device: 
 %d\n,
 + ret);
 + goto clk_err;
 + }
 +
 + platform_set_drvdata(pdev, priv);
 +
 + pm_runtime_no_callbacks(dev);
 + pm_runtime_enable(dev);
 +
 + return 0;
 +
 +clk_err:
 + if (!IS_ERR(priv-clk))
 + clk_disable_unprepare(priv-clk);
 + return ret;
 +}
 +
 +static int ci_hdrc_usb2_remove(struct platform_device *pdev)
 +{
 + struct ci_hdrc_usb2_priv *priv = platform_get_drvdata(pdev);
 +
 + pm_runtime_disable(pdev-dev);
 + ci_hdrc_remove_device(priv-ci_pdev);
 + clk_disable_unprepare(priv-clk);
 +
 + return 0;
 +}
 +
 +static const struct of_device_id ci_hdrc_usb2_of_match[] = {
 + { .compatible = chipidea,usb2 },
 + { }
 +};
 +MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
 +
 +static struct platform_driver ci_hdrc_usb2_driver = {
 + .probe  = ci_hdrc_usb2_probe,
 + .remove = ci_hdrc_usb2_remove,
 + .driver = {
 + .name   = 

Re: [RFC PATCH 0/2] usb: dwc2: Enable URB giveback in a tasklet context

2014-09-15 Thread Felipe Balbi
Hi,

On Tue, Sep 16, 2014 at 08:35:17AM +0800, Ming Lei wrote:
 On Tue, Sep 16, 2014 at 7:16 AM, Paul Zimmerman
 paul.zimmer...@synopsys.com wrote:
  From: dingu...@opensource.altera.com 
  [mailto:dingu...@opensource.altera.com]
  Sent: Monday, September 15, 2014 8:23 AM
 
  Hi Ming-Lei,
 
  Thanks for your patch to enable the URB giveback in a tasklet context for
  the EHCI driver. I found your patch to fix a USB webcam timeout/stutter
  issue on the DWC2 HCD in the SOCFPGA platform.
 
  However, I need your help trying to figure out why I need the 2nd patch to
  get your URB giveback patch to fully work.
 
  I enable tracepoints in the dwc2 dwc2_handle_hcd_intr for 
  irq:irq_handler_entry
  and irq:irq_handler_exit. However, I did not see any measurable differences
  between enabling HCD_BH and no enabling HCD_BH. But I am able to get a full
  image from a webcam with the following 2 patches, and timeouts/green screen
  without the 2 patches.
 
  I am using a Logitech HD C270 webcam.
 
  Opening video decoder: [raw] RAW Uncompressed Video
  Movie-Aspect is undefined - no prescaling applied.
  VO: [sdl] 640x480 = 640x480 Packed YUY2
  Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
 
  Can you provide any comments on the following issues:
 
  1) Am I placing the tracepoints in the right place for this non-ehci hcd?
  2) I don't quite understand why removing local_irq_save/local_irq_restore
 around the the complete makes the webcam work?
 
  Thanks in advance for your comments.
 
  Hi Dinh,
 
  I'm not Ming, but I can hazard a guess why you are seeing this issue.
 
  The webcam driver is likely doing a lot of processing in the -complete

this is correct, yes.

  callback. With local interrupts disabled, this probably causes too long
  of a delay in handling other interrupts. Since the SOCFPGA platform is
  a uniprocessor (I think), there is no other CPU to handle the other
  interrupts.
 
 Per my previous observation, on some ARM platforms it is extremely
 slow to memcpy to DMA coherent buffer, which is used in uvcvideo
 at default. I remember Pandaboard should be one such platform.

you remember correctly ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: udc_core: Use right kobj when calling sysfs_notify

2014-09-15 Thread Peter Chen
On Mon, Sep 15, 2014 at 12:42:27PM +0200, Andreas Larsson wrote:
 The state attribute is connected to the kobj of the udc, not the gadget.
 
 Signed-off-by: Andreas Larsson andr...@gaisler.com
 ---
  drivers/usb/gadget/udc/udc-core.c |   14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/udc/udc-core.c 
 b/drivers/usb/gadget/udc/udc-core.c
 index b0d9817..37c129a 100644
 --- a/drivers/usb/gadget/udc/udc-core.c
 +++ b/drivers/usb/gadget/udc/udc-core.c
 @@ -109,8 +109,20 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
  static void usb_gadget_state_work(struct work_struct *work)
  {
   struct usb_gadget   *gadget = work_to_gadget(work);
 + struct usb_udc  *udc = NULL;
 +
 + mutex_lock(udc_lock);
 + list_for_each_entry(udc, udc_list, list)
 + if (udc-gadget == gadget)
 + goto found;
 + mutex_unlock(udc_lock);
 +
 + return;
 +
 +found:
 + mutex_unlock(udc_lock);
  
 - sysfs_notify(gadget-dev.kobj, NULL, state);
 + sysfs_notify(udc-dev.kobj, NULL, state);
  }
  
  void usb_gadget_set_state(struct usb_gadget *gadget,

What's the user mode difference with and without this patch?

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


Re: [PATCH] usb: gadget: udc_core: Use right kobj when calling sysfs_notify

2014-09-15 Thread Felipe Balbi
Hi,

On Tue, Sep 16, 2014 at 10:02:25AM +0800, Peter Chen wrote:
 On Mon, Sep 15, 2014 at 12:42:27PM +0200, Andreas Larsson wrote:
  The state attribute is connected to the kobj of the udc, not the gadget.
  
  Signed-off-by: Andreas Larsson andr...@gaisler.com
  ---
   drivers/usb/gadget/udc/udc-core.c |   14 +-
   1 file changed, 13 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/usb/gadget/udc/udc-core.c 
  b/drivers/usb/gadget/udc/udc-core.c
  index b0d9817..37c129a 100644
  --- a/drivers/usb/gadget/udc/udc-core.c
  +++ b/drivers/usb/gadget/udc/udc-core.c
  @@ -109,8 +109,20 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
   static void usb_gadget_state_work(struct work_struct *work)
   {
  struct usb_gadget   *gadget = work_to_gadget(work);
  +   struct usb_udc  *udc = NULL;
  +
  +   mutex_lock(udc_lock);
  +   list_for_each_entry(udc, udc_list, list)
  +   if (udc-gadget == gadget)
  +   goto found;
  +   mutex_unlock(udc_lock);
  +
  +   return;
  +
  +found:
  +   mutex_unlock(udc_lock);
   
  -   sysfs_notify(gadget-dev.kobj, NULL, state);
  +   sysfs_notify(udc-dev.kobj, NULL, state);
   }
   
   void usb_gadget_set_state(struct usb_gadget *gadget,
 
 What's the user mode difference with and without this patch?

poll() will actually wakeup ?

-- 
balbi


signature.asc
Description: Digital signature