Re: am335x musb_hdrc broken(?)

2014-09-17 Thread Matwey V. Kornilov
2014-09-16 22:39 GMT+04:00 Felipe Balbi ba...@ti.com:
 Hi,

 (man, talk about trimming... leave some context ;-)

 On Tue, Sep 16, 2014 at 10:06:33PM +0400, Matwey V. Kornilov wrote:
 Ok. What is about musb_io.h? What does it mean TUSB6010 doesn't allow
 8-bit access; 16-bit access is the minimum.?

 it means that readb() won't work.

 I think __raw_readb is kind of return *(u8_t*)(addr), but this is CPU
 stuff as far as I understand.

 tusb6010 is a discrete device connected through GPMC (general purpose
 memory controller). Basically, this tells you that tusb6010 cannot
 understand 8-bit accesses through gpmc.


So, I checked the stuff in musb_io.h and it doesn't work properly for
my BBB. I don't know why. With this tusb6010-custom
musb_readb/musb_writeb functions I am not able to mount USB flash
drive (the device is being reset constantly, at the same time the
webcam works fine). With __raw functions, it is fine.

Do you have an idea how this could be refactored?


-- 
With best regards,
Matwey V. Kornilov
http://blog.matwey.name
xmpp://0x2...@jabber.ru
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 2/3] usb: Rename usb-common.c

2014-09-17 Thread Michal Sojka
In the next commit, we will want the usb-common module to be composed of
two object files. Since Kbuild cannot append another object to an
existing one, we need to rename usb-common.c to something
else (common.c) and create usb-common.o by linking the wanted objects
together. Currently, usb-common.o comprises only common.o.

Signed-off-by: Michal Sojka so...@merica.cz
---
 drivers/usb/common/Makefile   | 4 +++-
 drivers/usb/common/{usb-common.c = common.c} | 0
 2 files changed, 3 insertions(+), 1 deletion(-)
 rename drivers/usb/common/{usb-common.c = common.c} (100%)

diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 7526461..052c120 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -2,5 +2,7 @@
 # Makefile for the usb common parts.
 #
 
-obj-$(CONFIG_USB_COMMON) += usb-common.o
+obj-$(CONFIG_USB_COMMON) += usb-common.o
+usb-common-y += common.o
+
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
diff --git a/drivers/usb/common/usb-common.c b/drivers/usb/common/common.c
similarity index 100%
rename from drivers/usb/common/usb-common.c
rename to drivers/usb/common/common.c
-- 
2.1.0

--
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/3] usb: Add LED triggers for USB activity

2014-09-17 Thread Michal Sojka
With this patch, USB activity can be signaled by blinking a LED. There
are two triggers, one for activity on USB host and one for USB gadget.

Both triggers should work with all host/device controllers. Tested only
with musb.

Performace: I measured performance overheads on ARM Cortex-A8 (TI
AM335x) running on 600 MHz.

Duration of usb_led_activity():
- with no LED attached to the trigger:2 ± 1 µs
- with one GPIO LED attached to the trigger:  2 ± 1 µs or 8 ± 2 µs (two peaks 
in histogram)

Duration of functions calling usb_led_activity() (with this patch
applied and no LED attached to the trigger):
- __usb_hcd_giveback_urb():10 - 25 µs
- usb_gadget_giveback_request(): 2 - 6 µs

Signed-off-by: Michal Sojka so...@merica.cz
---
 drivers/usb/Kconfig   | 10 +++
 drivers/usb/common/Makefile   |  1 +
 drivers/usb/common/led.c  | 57 +++
 drivers/usb/core/hcd.c|  2 ++
 drivers/usb/gadget/udc/udc-core.c |  4 +++
 include/linux/usb.h   | 12 +
 6 files changed, 86 insertions(+)
 create mode 100644 drivers/usb/common/led.c

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index e0cad441..9d9cc3b 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -147,4 +147,14 @@ source drivers/usb/phy/Kconfig
 
 source drivers/usb/gadget/Kconfig
 
+config USB_LED_TRIG
+   bool USB LED Triggers
+   depends on LEDS_CLASS  USB_COMMON  LEDS_TRIGGERS
+   help
+ This option adds LED triggers for USB host and/or gadget activity.
+
+ Say Y here if you are working on a system with led-class supported
+ LEDs and you want to use them as activity indicators for USB host or
+ gadget.
+
 endif # USB_SUPPORT
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 052c120..ca2f8bd 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -4,5 +4,6 @@
 
 obj-$(CONFIG_USB_COMMON) += usb-common.o
 usb-common-y += common.o
+usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
diff --git a/drivers/usb/common/led.c b/drivers/usb/common/led.c
new file mode 100644
index 000..df23da0
--- /dev/null
+++ b/drivers/usb/common/led.c
@@ -0,0 +1,57 @@
+/*
+ * LED Triggers for USB Activity
+ *
+ * Copyright 2014 Michal Sojka so...@merica.cz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/leds.h
+#include linux/usb.h
+
+#define BLINK_DELAY 30
+
+static unsigned long usb_blink_delay = BLINK_DELAY;
+
+DEFINE_LED_TRIGGER(ledtrig_usb_gadget);
+DEFINE_LED_TRIGGER(ledtrig_usb_host);
+
+void usb_led_activity(enum usb_led_event ev)
+{
+   struct led_trigger *trig = NULL;
+
+   switch (ev) {
+   case USB_LED_EVENT_GADGET:
+   trig = ledtrig_usb_gadget;
+   break;
+   case USB_LED_EVENT_HOST:
+   trig = ledtrig_usb_host;
+   break;
+   }
+   /* led_trigger_blink_oneshot() handles trig == NULL gracefully */
+   led_trigger_blink_oneshot(trig, usb_blink_delay, usb_blink_delay, 0);
+}
+EXPORT_SYMBOL_GPL(usb_led_activity);
+
+
+static int __init ledtrig_usb_init(void)
+{
+   led_trigger_register_simple(usb-gadget, ledtrig_usb_gadget);
+   led_trigger_register_simple(usb-host, ledtrig_usb_host);
+   return 0;
+}
+
+static void __exit ledtrig_usb_exit(void)
+{
+   led_trigger_unregister_simple(ledtrig_usb_gadget);
+   led_trigger_unregister_simple(ledtrig_usb_host);
+}
+
+module_init(ledtrig_usb_init);
+module_exit(ledtrig_usb_exit);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487abcf..409cb95 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1664,6 +1664,8 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
usbmon_urb_complete(hcd-self, urb, status);
usb_anchor_suspend_wakeups(anchor);
usb_unanchor_urb(urb);
+   if (likely(status == 0))
+   usb_led_activity(USB_LED_EVENT_HOST);
 
/* pass ownership to the completion handler */
urb-status = status;
diff --git a/drivers/usb/gadget/udc/udc-core.c 
b/drivers/usb/gadget/udc/udc-core.c
index 29789f1..f272cf0 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -27,6 +27,7 @@
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
+#include linux/usb.h
 
 /**
  * struct usb_udc - describes one usb device controller
@@ -116,6 +117,9 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
 void usb_gadget_giveback_request(struct usb_ep *ep,
struct usb_request *req)
 {
+   if (likely(req-status == 0))
+   usb_led_activity(USB_LED_EVENT_GADGET);
+
if 

[PATCH v5 0/3] LED triggers for USB host and device

2014-09-17 Thread Michal Sojka
(this is resend of a patch series from about three weeks ago)

This adds LED triggers for USB host and device. First patch refactors
UDC drivers as requested by Felipe Balbi, second is a preparation for
the third, which adds the LED triggers.

Changes from v4:
- Added performance numbers to the commit message of the last patch
  (greg k-h).
- Replaced BUG_ON with pr_err (Alan Stern, greg k-h).
- Used proper coding style for switch statement (greg k-h).
- Added comment about NULL argument (greg k-h).
- EXPORT_SYMBOL changed to EXPORT_SYMBOL_GPL (greg k-h).
- Both triggers are now registerd even if host or gagdet subsystem
  is not enabled (Bryan Wu, greg k-h).

Changes from v3:
- usb_gadget_giveback_request() moved outside of CONFIG_HAS_DMA
  conditioned block.
- Added kernel-doc for usb_gadget_giveback_request() (Felipe Balbi).
- Removed outdated comment (Alan Stern).
- req-complete == NULL is now a bug. Previously, this was ignored
  (Alan Stern).
- File rename moved to a separate commit (greg k-h).

Changes from v2:
- Host/gadget triggers merged to a single file in usb/common/ (Felipe
  Balbi).
- UDC drivers refactored so that LED trigger works for all of them.

Changes from v1:
- Moved from drivers/leds/ to drivers/usb/.
- Improved Kconfig help.
- Linked with other modules rather than being standalone modules.

Michal Sojka (3):
  usb: gadget: Refactor request completion
  usb: Rename usb-common.c
  usb: Add LED triggers for USB activity

 drivers/usb/Kconfig   | 10 +
 drivers/usb/chipidea/udc.c|  6 +--
 drivers/usb/common/Makefile   |  5 ++-
 drivers/usb/common/{usb-common.c = common.c} |  0
 drivers/usb/common/led.c  | 57 +++
 drivers/usb/core/hcd.c|  2 +
 drivers/usb/dwc2/gadget.c |  6 +--
 drivers/usb/dwc3/gadget.c |  2 +-
 drivers/usb/gadget/udc/amd5536udc.c   |  2 +-
 drivers/usb/gadget/udc/at91_udc.c |  2 +-
 drivers/usb/gadget/udc/atmel_usba_udc.c   |  4 +-
 drivers/usb/gadget/udc/bcm63xx_udc.c  |  2 +-
 drivers/usb/gadget/udc/dummy_hcd.c| 10 ++---
 drivers/usb/gadget/udc/fotg210-udc.c  |  2 +-
 drivers/usb/gadget/udc/fsl_qe_udc.c   |  6 +--
 drivers/usb/gadget/udc/fsl_udc_core.c |  6 +--
 drivers/usb/gadget/udc/fusb300_udc.c  |  2 +-
 drivers/usb/gadget/udc/goku_udc.c |  2 +-
 drivers/usb/gadget/udc/gr_udc.c   |  2 +-
 drivers/usb/gadget/udc/lpc32xx_udc.c  |  2 +-
 drivers/usb/gadget/udc/m66592-udc.c   |  2 +-
 drivers/usb/gadget/udc/mv_u3d_core.c  |  8 +---
 drivers/usb/gadget/udc/mv_udc_core.c  |  8 +---
 drivers/usb/gadget/udc/net2272.c  |  2 +-
 drivers/usb/gadget/udc/net2280.c  |  2 +-
 drivers/usb/gadget/udc/omap_udc.c |  2 +-
 drivers/usb/gadget/udc/pch_udc.c  |  2 +-
 drivers/usb/gadget/udc/pxa25x_udc.c   |  2 +-
 drivers/usb/gadget/udc/pxa27x_udc.c   |  2 +-
 drivers/usb/gadget/udc/r8a66597-udc.c |  2 +-
 drivers/usb/gadget/udc/s3c-hsudc.c|  3 +-
 drivers/usb/gadget/udc/s3c2410_udc.c  |  2 +-
 drivers/usb/gadget/udc/udc-core.c | 23 +++
 drivers/usb/musb/musb_gadget.c|  2 +-
 drivers/usb/renesas_usbhs/mod_gadget.c|  2 +-
 include/linux/usb.h   | 12 ++
 include/linux/usb/gadget.h|  8 
 37 files changed, 157 insertions(+), 57 deletions(-)
 rename drivers/usb/common/{usb-common.c = common.c} (100%)
 create mode 100644 drivers/usb/common/led.c

-- 
2.1.0

--
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/3] usb: gadget: Refactor request completion

2014-09-17 Thread Michal Sojka
All USB peripheral controller drivers called completion routines
directly. This patch moves the completion call from drivers to
usb_gadget_giveback_request(), in order to have a place where common
functionality can be added.

All places in drivers/usb/ matching [-.]complete( were replaced with a
call to usb_gadget_giveback_request(). This was compile-tested with all
ARM drivers enabled and runtime-tested for musb.

Signed-off-by: Michal Sojka so...@merica.cz
---
 drivers/usb/chipidea/udc.c  |  6 +++---
 drivers/usb/dwc2/gadget.c   |  6 +++---
 drivers/usb/dwc3/gadget.c   |  2 +-
 drivers/usb/gadget/udc/amd5536udc.c |  2 +-
 drivers/usb/gadget/udc/at91_udc.c   |  2 +-
 drivers/usb/gadget/udc/atmel_usba_udc.c |  4 ++--
 drivers/usb/gadget/udc/bcm63xx_udc.c|  2 +-
 drivers/usb/gadget/udc/dummy_hcd.c  | 10 +-
 drivers/usb/gadget/udc/fotg210-udc.c|  2 +-
 drivers/usb/gadget/udc/fsl_qe_udc.c |  6 +-
 drivers/usb/gadget/udc/fsl_udc_core.c   |  6 ++
 drivers/usb/gadget/udc/fusb300_udc.c|  2 +-
 drivers/usb/gadget/udc/goku_udc.c   |  2 +-
 drivers/usb/gadget/udc/gr_udc.c |  2 +-
 drivers/usb/gadget/udc/lpc32xx_udc.c|  2 +-
 drivers/usb/gadget/udc/m66592-udc.c |  2 +-
 drivers/usb/gadget/udc/mv_u3d_core.c|  8 ++--
 drivers/usb/gadget/udc/mv_udc_core.c|  8 ++--
 drivers/usb/gadget/udc/net2272.c|  2 +-
 drivers/usb/gadget/udc/net2280.c|  2 +-
 drivers/usb/gadget/udc/omap_udc.c   |  2 +-
 drivers/usb/gadget/udc/pch_udc.c|  2 +-
 drivers/usb/gadget/udc/pxa25x_udc.c |  2 +-
 drivers/usb/gadget/udc/pxa27x_udc.c |  2 +-
 drivers/usb/gadget/udc/r8a66597-udc.c   |  2 +-
 drivers/usb/gadget/udc/s3c-hsudc.c  |  3 +--
 drivers/usb/gadget/udc/s3c2410_udc.c|  2 +-
 drivers/usb/gadget/udc/udc-core.c   | 19 +++
 drivers/usb/musb/musb_gadget.c  |  2 +-
 drivers/usb/renesas_usbhs/mod_gadget.c  |  2 +-
 include/linux/usb/gadget.h  |  8 
 31 files changed, 68 insertions(+), 56 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index b8125aa..0444d3f 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -627,7 +627,7 @@ __acquires(hwep-lock)
 
if (hwreq-req.complete != NULL) {
spin_unlock(hwep-lock);
-   hwreq-req.complete(hwep-ep, hwreq-req);
+   usb_gadget_giveback_request(hwep-ep, hwreq-req);
spin_lock(hwep-lock);
}
}
@@ -922,7 +922,7 @@ __acquires(hwep-lock)
if ((hwep-type == USB_ENDPOINT_XFER_CONTROL) 
hwreq-req.length)
hweptemp = hwep-ci-ep0in;
-   hwreq-req.complete(hweptemp-ep, hwreq-req);
+   usb_gadget_giveback_request(hweptemp-ep, hwreq-req);
spin_lock(hwep-lock);
}
}
@@ -1347,7 +1347,7 @@ static int ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
 
if (hwreq-req.complete != NULL) {
spin_unlock(hwep-lock);
-   hwreq-req.complete(hwep-ep, hwreq-req);
+   usb_gadget_giveback_request(hwep-ep, hwreq-req);
spin_lock(hwep-lock);
}
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0ba9c33..5a524a6 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -987,8 +987,8 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg 
*hsotg,
hs_req = ep-req;
ep-req = NULL;
list_del_init(hs_req-queue);
-   hs_req-req.complete(ep-ep,
-hs_req-req);
+   usb_gadget_giveback_request(ep-ep,
+   
hs_req-req);
}
 
/* If we have pending request, then start it */
@@ -1245,7 +1245,7 @@ static void s3c_hsotg_complete_request(struct s3c_hsotg 
*hsotg,
 
if (hs_req-req.complete) {
spin_unlock(hsotg-lock);
-   hs_req-req.complete(hs_ep-ep, hs_req-req);
+   usb_gadget_giveback_request(hs_ep-ep, hs_req-req);
spin_lock(hsotg-lock);
}
 
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 349cacc..b4b7a6b 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -268,7 +268,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct 
dwc3_request *req,
req-request.length, status);
 
spin_unlock(dwc-lock);
-   req-request.complete(dep-endpoint, req-request);
+

Re: [PATCH v4 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-17 Thread Octavian Purdila
On Wed, Sep 17, 2014 at 2:21 AM, Lee Jones lee.jo...@linaro.org wrote:

 On Tue, 09 Sep 2014, Octavian Purdila wrote:

  This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
  Master Adapter DLN-2. Details about the device can be found here:
 
  https://www.diolan.com/i2c/i2c_interface.html.
 
  Information about the USB protocol can be found in the Programmer's
  Reference Manual [1], see section 1.7.

 This driver really needs a USB Ack before I can accept it.


Greg, Johan, is the driver acceptable now?

  Because the hardware has a single transmit endpoint and a single
  receive endpoint the communication between the various DLN2 drivers
  and the hardware will be muxed/demuxed by this driver.
 
  Each DLN2 module will be identified by the handle field within the DLN2
  message header. If a DLN2 module issues multiple commands in parallel
  they will be identified by the echo counter field in the message header.
 
  The DLN2 modules can use the dln2_transfer() function to issue a
  command and wait for its response. They can also register a callback
  that is going to be called when a specific event id is generated by
  the device (e.g. GPIO interrupts). The device uses handle 0 for
  sending events.
 
  [1] https://www.diolan.com/downloads/dln-api-manual.pdf
 
  Signed-off-by: Octavian Purdila octavian.purd...@intel.com
  ---
   drivers/mfd/Kconfig  |   9 +
   drivers/mfd/Makefile |   1 +
   drivers/mfd/dln2.c   | 681 
  +++
   include/linux/mfd/dln2.h |  71 +
   4 files changed, 762 insertions(+)
   create mode 100644 drivers/mfd/dln2.c
   create mode 100644 include/linux/mfd/dln2.h

 [...]

  diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
  new file mode 100644
  index 000..b551b5e
  --- /dev/null
  +++ b/drivers/mfd/dln2.c
  @@ -0,0 +1,681 @@
  +/*
  + * Driver for the Diolan DLN-2 USB adapter
  + *
  + * Copyright (c) 2014 Intel Corporation
  + *
  + * Derived from:
  + *  i2c-diolan-u2c.c
  + *  Copyright (c) 2010-2011 Ericsson AB
  + *
  + * This program is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU General Public License as
  + * published by the Free Software Foundation, version 2.
  + */
  +
  +#include linux/kernel.h
  +#include linux/errno.h

 What are you using this for?


Not needed, I will remove it.

  +#include linux/module.h
  +#include linux/types.h
  +#include linux/slab.h
  +#include linux/usb.h
  +#include linux/i2c.h
  +#include linux/mutex.h
  +#include linux/platform_device.h
  +#include linux/mfd/core.h
  +#include linux/mfd/dln2.h
  +
  +#define DRIVER_NAME  usb-dln2

 Don't do this, just use usb-dln2 where it needs to be used.


Will do.

 [...]

  +static struct usb_driver dln2_driver = {
  + .name = DRIVER_NAME,
  + .probe = dln2_probe,
  + .disconnect = dln2_disconnect,
  + .id_table = dln2_table,
  +};
  +
  +module_usb_driver(dln2_driver);
  +
  +MODULE_AUTHOR(Octavian Purdila octavian.purd...@intel.com);
  +MODULE_DESCRIPTION(DRIVER_NAME  driver);

 This is not a description.

  +MODULE_LICENSE(GPL);

 Header says v2.


I will change it to GPL v2.

  diff --git a/include/linux/mfd/dln2.h b/include/linux/mfd/dln2.h
  new file mode 100644
  index 000..197565d
  --- /dev/null
  +++ b/include/linux/mfd/dln2.h
  @@ -0,0 +1,71 @@
  +#ifndef __LINUX_USB_DLN2_H
  +#define __LINUX_USB_DLN2_H
  +
  +#define DLN2_CMD(cmd, id)((cmd) | ((id)  8))
  +
  +struct dln2_platform_data {
  + u16 handle;
  + union {
  + struct {
  + u8 port;
  + } i2c;
  + };
  +};

 Why this complexity?


There is also an SPI interface on this adapter which will probably the
port information and maybe some additional information. Would you
prefer to add the union later, when we add the SPI driver?
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-17 Thread Johan Hovold
On Wed, Sep 17, 2014 at 10:25:18AM +0300, Octavian Purdila wrote:
 On Wed, Sep 17, 2014 at 2:21 AM, Lee Jones lee.jo...@linaro.org wrote:
 
  On Tue, 09 Sep 2014, Octavian Purdila wrote:
 
   This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
   Master Adapter DLN-2. Details about the device can be found here:
  
   https://www.diolan.com/i2c/i2c_interface.html.
  
   Information about the USB protocol can be found in the Programmer's
   Reference Manual [1], see section 1.7.
 
  This driver really needs a USB Ack before I can accept it.
 
 
 Greg, Johan, is the driver acceptable now?

I started looking through v4 yesterday and found a few more things. Will
send you some you comments shortly.

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


[PATCH fix for 3.17] uas: Add US_FL_NO_ATA_1X quirk for Seagate (0bc2:ab20) drives

2014-09-17 Thread Hans de Goede
https://bbs.archlinux.org/viewtopic.php?pid=1457492

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/storage/unusual_uas.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/storage/unusual_uas.h 
b/drivers/usb/storage/unusual_uas.h
index 3e62437..94fb09f 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -54,6 +54,13 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x, 0x,
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NO_ATA_1X),
 
+/* https://bbs.archlinux.org/viewtopic.php?id=183190 */
+UNUSUAL_DEV(0x0bc2, 0xab20, 0x, 0x,
+   Seagate,
+   Backup+ BK,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_NO_ATA_1X),
+
 /* Reported-by: Claudio Bizzarri claudio.bizza...@gmail.com */
 UNUSUAL_DEV(0x152d, 0x0567, 0x, 0x,
JMicron,
-- 
2.1.0

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


Re: [PATCH v4 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-17 Thread Johan Hovold
On Tue, Sep 09, 2014 at 10:24:44PM +0300, Octavian Purdila wrote:
 This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
 Master Adapter DLN-2. Details about the device can be found here:
 
 https://www.diolan.com/i2c/i2c_interface.html.
 
 Information about the USB protocol can be found in the Programmer's
 Reference Manual [1], see section 1.7.
 
 Because the hardware has a single transmit endpoint and a single
 receive endpoint the communication between the various DLN2 drivers
 and the hardware will be muxed/demuxed by this driver.
 
 Each DLN2 module will be identified by the handle field within the DLN2
 message header. If a DLN2 module issues multiple commands in parallel
 they will be identified by the echo counter field in the message header.
 
 The DLN2 modules can use the dln2_transfer() function to issue a
 command and wait for its response. They can also register a callback
 that is going to be called when a specific event id is generated by
 the device (e.g. GPIO interrupts). The device uses handle 0 for
 sending events.
 
 [1] https://www.diolan.com/downloads/dln-api-manual.pdf
 
 Signed-off-by: Octavian Purdila octavian.purd...@intel.com
 ---
  drivers/mfd/Kconfig  |   9 +
  drivers/mfd/Makefile |   1 +
  drivers/mfd/dln2.c   | 681 
 +++
  include/linux/mfd/dln2.h |  71 +
  4 files changed, 762 insertions(+)
  create mode 100644 drivers/mfd/dln2.c
  create mode 100644 include/linux/mfd/dln2.h
 
 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index de5abf2..7bcf895 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -183,6 +183,15 @@ config MFD_DA9063
 Additional drivers must be enabled in order to use the functionality
 of the device.
  
 +config MFD_DLN2
 + tristate Diolan DLN2 support
 + select MFD_CORE
 + depends on USB
 + help
 +   This adds support for Diolan USB-I2C/SPI/GPIO Master Adapter DLN-2.
 +   Additional drivers must be enabled in order to use the functionality
 +   of the device.
 +
  config MFD_MC13XXX
   tristate
   depends on (SPI_MASTER || I2C)
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index f001487..591988d 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_AS3711)  += as3711.o
  obj-$(CONFIG_MFD_AS3722) += as3722.o
  obj-$(CONFIG_MFD_STW481X)+= stw481x.o
  obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
 +obj-$(CONFIG_MFD_DLN2)   += dln2.o
  
  intel-soc-pmic-objs  := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
 diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
 new file mode 100644
 index 000..b551b5e
 --- /dev/null
 +++ b/drivers/mfd/dln2.c
 @@ -0,0 +1,681 @@
 +/*
 + * Driver for the Diolan DLN-2 USB adapter
 + *
 + * Copyright (c) 2014 Intel Corporation
 + *
 + * Derived from:
 + *  i2c-diolan-u2c.c
 + *  Copyright (c) 2010-2011 Ericsson AB
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License as
 + * published by the Free Software Foundation, version 2.
 + */
 +
 +#include linux/kernel.h
 +#include linux/errno.h
 +#include linux/module.h
 +#include linux/types.h
 +#include linux/slab.h
 +#include linux/usb.h
 +#include linux/i2c.h
 +#include linux/mutex.h
 +#include linux/platform_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/dln2.h
 +
 +#define DRIVER_NAME  usb-dln2
 +
 +struct dln2_header {
 + __le16 size;
 + __le16 id;
 + __le16 echo;
 + __le16 handle;
 +} __packed;
 +
 +struct dln2_response {
 + struct dln2_header hdr;
 + __le16 result;
 +} __packed;
 +
 +#define DLN2_GENERIC_MODULE_ID   0x00
 +#define DLN2_GENERIC_CMD(cmd)DLN2_CMD(cmd, 
 DLN2_GENERIC_MODULE_ID)
 +#define CMD_GET_DEVICE_VER   DLN2_GENERIC_CMD(0x30)
 +#define CMD_GET_DEVICE_SNDLN2_GENERIC_CMD(0x31)
 +
 +#define DLN2_HW_ID   0x200
 +#define DLN2_USB_TIMEOUT 200 /* in ms */
 +#define DLN2_MAX_RX_SLOTS16
 +#define DLN2_MAX_MODULES 5

Reduce to 4 until you implement support for more modules and save some
memory meanwhile? (Or is id 4 already used?)

 +#define DLN2_MAX_URBS16
 +#define DLN2_RX_BUF_SIZE 512
 +
 +#define DLN2_HANDLE_EVENT0
 +#define DLN2_HANDLE_CTRL 1
 +#define DLN2_HANDLE_GPIO 2
 +#define DLN2_HANDLE_I2C  3
 +
 +/*
 + * Receive context used between the receive demultiplexer and the
 + * transfer routine. While sending a request the transfer routine
 + * will look for a free receive context and use it to wait for a
 + * response and to receive the URB and thus the response data.
 + */
 +struct dln2_rx_context {
 + struct completion done;
 + struct urb *urb;
 + 

Re: [PATCH v4 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-17 Thread Johan Hovold
On Tue, Sep 09, 2014 at 10:24:45PM +0300, Octavian Purdila wrote:
 From: Laurentiu Palcu laurentiu.pa...@intel.com
 
 This patch adds support for the Diolan DLN-2 I2C master module. Due
 to hardware limitations it does not support SMBUS quick commands.
 
 Information about the USB protocol interface can be found in the
 Programmer's Reference Manual [1], see section 6.2.2 for the I2C
 master module commands and responses.
 
 [1] https://www.diolan.com/downloads/dln-api-manual.pdf
 
 Signed-off-by: Laurentiu Palcu laurentiu.pa...@intel.com
 Signed-off-by: Octavian Purdila octavian.purd...@intel.com
 ---
  drivers/i2c/busses/Kconfig|  10 ++
  drivers/i2c/busses/Makefile   |   1 +
  drivers/i2c/busses/i2c-dln2.c | 390 
 ++
  3 files changed, 401 insertions(+)
  create mode 100644 drivers/i2c/busses/i2c-dln2.c
 
 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
 index 2ac87fa..6afc17e 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -1021,4 +1021,14 @@ config SCx200_ACB
 This support is also available as a module.  If so, the module
 will be called scx200_acb.
  
 +config I2C_DLN2
 +   tristate Diolan DLN-2 USB I2C adapter
 +   depends on MFD_DLN2
 +   help
 + If you say yes to this option, support will be included for Diolan
 + DLN2, a USB to I2C interface.
 +
 + This driver can also be built as a module.  If so, the module
 + will be called i2c-dln2.
 +
  endmenu
 diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
 index 49bf07e..3118fea 100644
 --- a/drivers/i2c/busses/Makefile
 +++ b/drivers/i2c/busses/Makefile
 @@ -100,5 +100,6 @@ obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
  obj-$(CONFIG_I2C_PCA_ISA)+= i2c-pca-isa.o
  obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
  obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
 +obj-$(CONFIG_I2C_DLN2)   += i2c-dln2.o
  
  ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
 diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c
 new file mode 100644
 index 000..ac09ec4
 --- /dev/null
 +++ b/drivers/i2c/busses/i2c-dln2.c
 @@ -0,0 +1,390 @@
 +/*
 + * Driver for the Diolan DLN-2 USB-I2C adapter
 + *
 + * Copyright (c) 2014 Intel Corporation
 + *
 + * Derived from:
 + *  i2c-diolan-u2c.c
 + *  Copyright (c) 2010-2011 Ericsson AB
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License as
 + * published by the Free Software Foundation, version 2.
 + */
 +
 +#include linux/kernel.h
 +#include linux/errno.h
 +#include linux/module.h
 +#include linux/types.h
 +#include linux/slab.h
 +#include linux/i2c.h
 +#include linux/platform_device.h
 +#include linux/mfd/dln2.h
 +
 +#define DRIVER_NAME  dln2-i2c
 +
 +#define DLN2_I2C_MODULE_ID   0x03
 +#define DLN2_I2C_CMD(cmd)DLN2_CMD(cmd, DLN2_I2C_MODULE_ID)
 +
 +/* I2C commands */
 +#define DLN2_I2C_GET_PORT_COUNT  DLN2_I2C_CMD(0x00)
 +#define DLN2_I2C_ENABLE  DLN2_I2C_CMD(0x01)
 +#define DLN2_I2C_DISABLE DLN2_I2C_CMD(0x02)
 +#define DLN2_I2C_IS_ENABLED  DLN2_I2C_CMD(0x03)
 +#define DLN2_I2C_SET_FREQUENCY   DLN2_I2C_CMD(0x04)
 +#define DLN2_I2C_GET_FREQUENCY   DLN2_I2C_CMD(0x05)
 +#define DLN2_I2C_WRITE   DLN2_I2C_CMD(0x06)
 +#define DLN2_I2C_READDLN2_I2C_CMD(0x07)
 +#define DLN2_I2C_SCAN_DEVICESDLN2_I2C_CMD(0x08)
 +#define DLN2_I2C_PULLUP_ENABLE   DLN2_I2C_CMD(0x09)
 +#define DLN2_I2C_PULLUP_DISABLE  DLN2_I2C_CMD(0x0A)
 +#define DLN2_I2C_PULLUP_IS_ENABLED   DLN2_I2C_CMD(0x0B)
 +#define DLN2_I2C_TRANSFERDLN2_I2C_CMD(0x0C)
 +#define DLN2_I2C_SET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0D)
 +#define DLN2_I2C_GET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0E)
 +#define DLN2_I2C_GET_MIN_FREQUENCY   DLN2_I2C_CMD(0x40)
 +#define DLN2_I2C_GET_MAX_FREQUENCY   DLN2_I2C_CMD(0x41)
 +
 +#define DLN2_I2C_FREQ_STD10
 +
 +#define DLN2_I2C_MAX_XFER_SIZE   256
 +
 +struct dln2_i2c {
 + struct platform_device *pdev;
 + struct i2c_adapter adapter;
 + uint32_t freq;
 + uint32_t min_freq;
 + uint32_t max_freq;

Please use u32 throughout for consistency.

 + /*
 +  * Buffer to hold the packet for read or write transfers. One
 +  * is enough since we can't have multiple transfers in
 +  * parallel on the i2c adapter.
 +  */
 + union {
 + struct {
 + u8 port;
 + u8 addr;
 + u8 mem_addr_len;
 + __le32 mem_addr;
 + __le16 buf_len;
 + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
 + } __packed tx;
 + struct {
 + __le16 buf_len;
 + u8 

Re: [PATCH v4 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

2014-09-17 Thread Octavian Purdila
On Wed, Sep 17, 2014 at 12:44 PM, Johan Hovold jo...@kernel.org wrote:

snip

 + /*
 +  * Buffer to hold the packet for read or write transfers. One
 +  * is enough since we can't have multiple transfers in
 +  * parallel on the i2c adapter.
 +  */
 + union {
 + struct {
 + u8 port;
 + u8 addr;
 + u8 mem_addr_len;
 + __le32 mem_addr;
 + __le16 buf_len;
 + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
 + } __packed tx;
 + struct {
 + __le16 buf_len;
 + u8 buf[DLN2_I2C_MAX_XFER_SIZE];
 + } __packed rx;
 + } buf;

 While this works in this case due to the extra copy you do in
 dln2_transfer, allocating buffers that would (generally) be used for DMA
 transfers as part of a larger structure is a recipe for trouble.

 It's probably better to allocate separately, if only to prevent people
 from thinking there might be a bug here.


Just to make sure I understand this, what could the issues be? The
buffers not being aligned or not allocated in continuous physical
memory?

snip

 +
 + rx_buf_len = le16_to_cpu(dln2-buf.rx.buf_len);
 + if (rx_len  rx_buf_len + sizeof(dln2-buf.rx.buf_len))
 + return -EPROTO;
 +
 + if (data_len  rx_buf_len)
 + data_len = rx_buf_len;

 You're still not checking that the received data does not overflow the
 supplied buffer as I already commented on v3.

 +
 + memcpy(data, dln2-buf.rx.buf, data_len);
 +
 + return data_len;
 +}

Hmm, perhaps I am missing something, but we never transfer more then
data_len, where data_len is the size of the buffer supplied by the
user.

snip

 +
 + platform_set_drvdata(pdev, dln2);
 +
 + ret = device_create_file(dev, dev_attr_freq);
 + if (ret  0) {
 + dev_err(dev, failed to add freq attribute\n);
 + return ret;
 + }

 There are a couple of problems here. First, you should not make this an
 attribute of the platform device, which is created before any driver is
 bound (might not ever happen).

 Instead add the attribute to the i2c adapter below. However, you need to
 do this using device attribute groups to avoid racing with userspace (as
 you are when using device_create_file after the device itself has been
 created).

 You should probably also make your attribute name less generic by adding
 a dln2_-prefix.

Thanks for the detailed review and explanations, as always :)
--
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 v3 2/2] usb: host: ohci-exynos: Remove unnecessary usb-phy support

2014-09-17 Thread Vivek Gautam
Now that we have completely moved from older USB-PHY drivers
to newer GENERIC-PHY drivers for PHYs available with USB controllers
on Exynos series of SoCs, we can remove the support for the same
in our host drivers too.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
 drivers/usb/host/ohci-exynos.c |   89 +++-
 1 file changed, 24 insertions(+), 65 deletions(-)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 7c48e3f..992b28d 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -19,11 +19,8 @@
 #include linux/of.h
 #include linux/platform_device.h
 #include linux/phy/phy.h
-#include linux/usb/phy.h
-#include linux/usb/samsung_usb_phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
-#include linux/usb/otg.h
 
 #include ohci.h
 
@@ -38,9 +35,7 @@ static struct hc_driver __read_mostly exynos_ohci_hc_driver;
 
 struct exynos_ohci_hcd {
struct clk *clk;
-   struct usb_phy *phy;
-   struct usb_otg *otg;
-   struct phy *phy_g[PHY_NUMBER];
+   struct phy *phy[PHY_NUMBER];
 };
 
 static int exynos_ohci_get_phy(struct device *dev,
@@ -48,56 +43,40 @@ static int exynos_ohci_get_phy(struct device *dev,
 {
struct device_node *child;
struct phy *phy;
-   int phy_number;
-   int ret = 0;
+   int phy_num;
+   int ret;
 
-   /*
-* Getting generic phy:
-* We are keeping both types of phys as a part of transiting OHCI
-* to generic phy framework, so as to maintain backward compatibilty
-* with old DTB too.
-* We fallback to older USB-PHYs when we fail to get generic PHYs.
-*/
+   /* Get the generic phys */
for_each_available_child_of_node(dev-of_node, child) {
-   ret = of_property_read_u32(child, reg, phy_number);
+   ret = of_property_read_u32(child, reg, phy_num);
if (ret) {
dev_err(dev, Failed to parse device tree\n);
of_node_put(child);
return ret;
}
 
-   if (phy_number = PHY_NUMBER) {
+   if (phy_num = PHY_NUMBER) {
dev_err(dev, Invalid number of PHYs\n);
of_node_put(child);
return -EINVAL;
}
 
-   phy = devm_of_phy_get(dev, child, NULL);
+   exynos_ohci-phy[phy_num] = devm_of_phy_get(dev, child, NULL);
+   phy = exynos_ohci-phy[phy_num];
of_node_put(child);
-   if (IS_ERR(phy))
-   /* Lets fallback to older USB-PHYs */
-   goto usb_phy_old;
-   exynos_ohci-phy_g[phy_number] = phy;
-   /* Make the older PHYs unavailable */
-   exynos_ohci-phy = ERR_PTR(-ENXIO);
-   }
-
-   return 0;
-
-usb_phy_old:
-   exynos_ohci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ohci-phy)) {
-   ret = PTR_ERR(exynos_ohci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else if (ret != -ENOSYS  ret != -ENODEV) {
+   dev_err(dev,
+   Error retrieving usb2 phy: %d\n, ret);
+   return PTR_ERR(phy);
+   }
}
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ohci-otg = exynos_ohci-phy-otg;
}
 
-   return ret;
+   return 0;
 }
 
 static int exynos_ohci_phy_enable(struct device *dev)
@@ -107,16 +86,13 @@ static int exynos_ohci_phy_enable(struct device *dev)
int i;
int ret = 0;
 
-   if (!IS_ERR(exynos_ohci-phy))
-   return usb_phy_init(exynos_ohci-phy);
-
for (i = 0; ret == 0  i  PHY_NUMBER; i++)
-   if (!IS_ERR(exynos_ohci-phy_g[i]))
-   ret = phy_power_on(exynos_ohci-phy_g[i]);
+   if (!IS_ERR(exynos_ohci-phy[i]))
+   ret = phy_power_on(exynos_ohci-phy[i]);
if (ret)
for (i--; i = 0; i--)
-   if (!IS_ERR(exynos_ohci-phy_g[i]))
-   phy_power_off(exynos_ohci-phy_g[i]);
+   if (!IS_ERR(exynos_ohci-phy[i]))
+   phy_power_off(exynos_ohci-phy[i]);
 
return ret;
 }
@@ -127,14 +103,9 @@ static void exynos_ohci_phy_disable(struct device *dev)
struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
int i;
 
-   if (!IS_ERR(exynos_ohci-phy)) {
-   

[PATCH v3 1/2] usb: host: ehci-exynos: Remove unnecessary usb-phy support

2014-09-17 Thread Vivek Gautam
Now that we have completely moved from older USB-PHY drivers
to newer GENERIC-PHY drivers for PHYs available with USB controllers
on Exynos series of SoCs, we can remove the support for the same
in our host drivers too.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
 drivers/usb/host/ehci-exynos.c |   81 
 1 file changed, 23 insertions(+), 58 deletions(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 2eed9a4..99c5f5f 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -21,11 +21,8 @@
 #include linux/of_gpio.h
 #include linux/phy/phy.h
 #include linux/platform_device.h
-#include linux/usb/phy.h
-#include linux/usb/samsung_usb_phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
-#include linux/usb/otg.h
 
 #include ehci.h
 
@@ -47,9 +44,7 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
 struct exynos_ehci_hcd {
struct clk *clk;
-   struct usb_phy *phy;
-   struct usb_otg *otg;
-   struct phy *phy_g[PHY_NUMBER];
+   struct phy *phy[PHY_NUMBER];
 };
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv)
@@ -59,49 +54,39 @@ static int exynos_ehci_get_phy(struct device *dev,
 {
struct device_node *child;
struct phy *phy;
-   int phy_number;
-   int ret = 0;
+   int phy_num;
+   int ret;
 
for_each_available_child_of_node(dev-of_node, child) {
-   ret = of_property_read_u32(child, reg, phy_number);
+   ret = of_property_read_u32(child, reg, phy_num);
if (ret) {
dev_err(dev, Failed to parse device tree\n);
of_node_put(child);
return ret;
}
 
-   if (phy_number = PHY_NUMBER) {
+   if (phy_num = PHY_NUMBER) {
dev_err(dev, Invalid number of PHYs\n);
of_node_put(child);
return -EINVAL;
}
 
-   phy = devm_of_phy_get(dev, child, NULL);
+   exynos_ehci-phy[phy_num] = devm_of_phy_get(dev, child, NULL);
+   phy = exynos_ehci-phy[phy_num];
of_node_put(child);
-   if (IS_ERR(phy))
-   /* Lets fallback to older USB-PHYs */
-   goto usb_phy_old;
-   exynos_ehci-phy_g[phy_number] = phy;
-   /* Make the older PHYs unavailable */
-   exynos_ehci-phy = ERR_PTR(-ENXIO);
-   }
-
-   return 0;
-
-usb_phy_old:
-   exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ehci-phy)) {
-   ret = PTR_ERR(exynos_ehci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else if (ret != -ENOSYS  ret != -ENODEV) {
+   dev_err(dev,
+   Error retrieving usb2 phy: %d\n, ret);
+   return PTR_ERR(phy);
+   }
}
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ehci-otg = exynos_ehci-phy-otg;
}
 
-   return ret;
+   return 0;
 }
 
 static int exynos_ehci_phy_enable(struct device *dev)
@@ -111,16 +96,13 @@ static int exynos_ehci_phy_enable(struct device *dev)
int i;
int ret = 0;
 
-   if (!IS_ERR(exynos_ehci-phy))
-   return usb_phy_init(exynos_ehci-phy);
-
for (i = 0; ret == 0  i  PHY_NUMBER; i++)
-   if (!IS_ERR(exynos_ehci-phy_g[i]))
-   ret = phy_power_on(exynos_ehci-phy_g[i]);
+   if (!IS_ERR(exynos_ehci-phy[i]))
+   ret = phy_power_on(exynos_ehci-phy[i]);
if (ret)
for (i--; i = 0; i--)
-   if (!IS_ERR(exynos_ehci-phy_g[i]))
-   phy_power_off(exynos_ehci-phy_g[i]);
+   if (!IS_ERR(exynos_ehci-phy[i]))
+   phy_power_off(exynos_ehci-phy[i]);
 
return ret;
 }
@@ -131,14 +113,9 @@ static void exynos_ehci_phy_disable(struct device *dev)
struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd);
int i;
 
-   if (!IS_ERR(exynos_ehci-phy)) {
-   usb_phy_shutdown(exynos_ehci-phy);
-   return;
-   }
-
for (i = 0; i  PHY_NUMBER; i++)
-   if (!IS_ERR(exynos_ehci-phy_g[i]))
-   phy_power_off(exynos_ehci-phy_g[i]);
+   if (!IS_ERR(exynos_ehci-phy[i]))
+   

[PATCH v3 0/2] usb: host: ehci/ohci-exynos: phy cleanup

2014-09-17 Thread Vivek Gautam
Cleaning up the phy getting sequence in ehci-exynos and ohci-exynos
drivers.

Hi Alan, Jingoo,

I have not imported the Acked-by and Reviewed-by from you guys, from V2 version
of this patch series, since this version is now rebased on the already available
commit in usb-next - usb: ehci/ohci-exynos: Fix PHY getting sequence.

Please feel free to comment on it and add your Acked-by's and Reviewed-by's.

Changes since v2:
 - Rebased on top of usb-next branch, which now has
   'usb: ehci/ohci-exynos: Fix PHY getting sequence' patch.

Changes since v1:
 - This patch was part of the series [PATCH 0/7] usb-phy: samsung: Cleanup the 
unused drivers
   https://lkml.org/lkml/2014/8/14/235. I have dropped the phy cleanup patches 
from that series-
   Patches 1-5.
 - Rebased this patch on top of 3.17-rc1.

Vivek Gautam (2):
  usb: host: ehci-exynos: Remove unnecessary usb-phy support
  usb: host: ohci-exynos: Remove unnecessary usb-phy support

 drivers/usb/host/ehci-exynos.c |   81 +++-
 drivers/usb/host/ohci-exynos.c |   89 +++-
 2 files changed, 47 insertions(+), 123 deletions(-)

-- 
1.7.10.4

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


Re: [PATCH v3 1/2] usb: host: ehci-exynos: Remove unnecessary usb-phy support

2014-09-17 Thread Jingoo Han
On Wednesday, September 17, 2014 8:18 PM, Vivek Gautam wrote:
 
 Now that we have completely moved from older USB-PHY drivers
 to newer GENERIC-PHY drivers for PHYs available with USB controllers
 on Exynos series of SoCs, we can remove the support for the same
 in our host drivers too.
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com

Acked-by: Jingoo Han jg1@samsung.com

Best regards,
Jingoo Han

 ---
  drivers/usb/host/ehci-exynos.c |   81 
 
  1 file changed, 23 insertions(+), 58 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
 index 2eed9a4..99c5f5f 100644
 --- a/drivers/usb/host/ehci-exynos.c
 +++ b/drivers/usb/host/ehci-exynos.c
 @@ -21,11 +21,8 @@
  #include linux/of_gpio.h
  #include linux/phy/phy.h
  #include linux/platform_device.h
 -#include linux/usb/phy.h
 -#include linux/usb/samsung_usb_phy.h
  #include linux/usb.h
  #include linux/usb/hcd.h
 -#include linux/usb/otg.h
 
  #include ehci.h
 
 @@ -47,9 +44,7 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
  struct exynos_ehci_hcd {
   struct clk *clk;
 - struct usb_phy *phy;
 - struct usb_otg *otg;
 - struct phy *phy_g[PHY_NUMBER];
 + struct phy *phy[PHY_NUMBER];
  };
 
  #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd 
 *)(hcd_to_ehci(hcd)-priv)
 @@ -59,49 +54,39 @@ static int exynos_ehci_get_phy(struct device *dev,
  {
   struct device_node *child;
   struct phy *phy;
 - int phy_number;
 - int ret = 0;
 + int phy_num;
 + int ret;
 
   for_each_available_child_of_node(dev-of_node, child) {
 - ret = of_property_read_u32(child, reg, phy_number);
 + ret = of_property_read_u32(child, reg, phy_num);
   if (ret) {
   dev_err(dev, Failed to parse device tree\n);
   of_node_put(child);
   return ret;
   }
 
 - if (phy_number = PHY_NUMBER) {
 + if (phy_num = PHY_NUMBER) {
   dev_err(dev, Invalid number of PHYs\n);
   of_node_put(child);
   return -EINVAL;
   }
 
 - phy = devm_of_phy_get(dev, child, NULL);
 + exynos_ehci-phy[phy_num] = devm_of_phy_get(dev, child, NULL);
 + phy = exynos_ehci-phy[phy_num];
   of_node_put(child);
 - if (IS_ERR(phy))
 - /* Lets fallback to older USB-PHYs */
 - goto usb_phy_old;
 - exynos_ehci-phy_g[phy_number] = phy;
 - /* Make the older PHYs unavailable */
 - exynos_ehci-phy = ERR_PTR(-ENXIO);
 - }
 -
 - return 0;
 -
 -usb_phy_old:
 - exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - if (IS_ERR(exynos_ehci-phy)) {
 - ret = PTR_ERR(exynos_ehci-phy);
 - if (ret != -ENXIO  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 + if (IS_ERR(phy)) {
 + ret = PTR_ERR(phy);
 + if (ret == -EPROBE_DEFER) {
 + return ret;
 + } else if (ret != -ENOSYS  ret != -ENODEV) {
 + dev_err(dev,
 + Error retrieving usb2 phy: %d\n, ret);
 + return PTR_ERR(phy);
 + }
   }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - } else {
 - exynos_ehci-otg = exynos_ehci-phy-otg;
   }
 
 - return ret;
 + return 0;
  }
 
  static int exynos_ehci_phy_enable(struct device *dev)
 @@ -111,16 +96,13 @@ static int exynos_ehci_phy_enable(struct device *dev)
   int i;
   int ret = 0;
 
 - if (!IS_ERR(exynos_ehci-phy))
 - return usb_phy_init(exynos_ehci-phy);
 -
   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
 - if (!IS_ERR(exynos_ehci-phy_g[i]))
 - ret = phy_power_on(exynos_ehci-phy_g[i]);
 + if (!IS_ERR(exynos_ehci-phy[i]))
 + ret = phy_power_on(exynos_ehci-phy[i]);
   if (ret)
   for (i--; i = 0; i--)
 - if (!IS_ERR(exynos_ehci-phy_g[i]))
 - phy_power_off(exynos_ehci-phy_g[i]);
 + if (!IS_ERR(exynos_ehci-phy[i]))
 + phy_power_off(exynos_ehci-phy[i]);
 
   return ret;
  }
 @@ -131,14 +113,9 @@ static void exynos_ehci_phy_disable(struct device *dev)
   struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd);
   int i;
 
 - if (!IS_ERR(exynos_ehci-phy)) {
 - usb_phy_shutdown(exynos_ehci-phy);
 - return;
 - }
 -
   for (i = 0; i  PHY_NUMBER; i++)
 - if (!IS_ERR(exynos_ehci-phy_g[i]))
 - phy_power_off(exynos_ehci-phy_g[i]);

Re: [PATCH v3 2/2] usb: host: ohci-exynos: Remove unnecessary usb-phy support

2014-09-17 Thread Jingoo Han
On Wednesday, September 17, 2014 8:18 PM, Vivek Gautam wrote:
 
 Now that we have completely moved from older USB-PHY drivers
 to newer GENERIC-PHY drivers for PHYs available with USB controllers
 on Exynos series of SoCs, we can remove the support for the same
 in our host drivers too.
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com

Acked-by: Jingoo Han jg1@samsung.com

Best regards,
Jingoo Han

 ---
  drivers/usb/host/ohci-exynos.c |   89 
 +++-
  1 file changed, 24 insertions(+), 65 deletions(-)
 
 diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
 index 7c48e3f..992b28d 100644
 --- a/drivers/usb/host/ohci-exynos.c
 +++ b/drivers/usb/host/ohci-exynos.c
 @@ -19,11 +19,8 @@
  #include linux/of.h
  #include linux/platform_device.h
  #include linux/phy/phy.h
 -#include linux/usb/phy.h
 -#include linux/usb/samsung_usb_phy.h
  #include linux/usb.h
  #include linux/usb/hcd.h
 -#include linux/usb/otg.h
 
  #include ohci.h
 
 @@ -38,9 +35,7 @@ static struct hc_driver __read_mostly exynos_ohci_hc_driver;
 
  struct exynos_ohci_hcd {
   struct clk *clk;
 - struct usb_phy *phy;
 - struct usb_otg *otg;
 - struct phy *phy_g[PHY_NUMBER];
 + struct phy *phy[PHY_NUMBER];
  };
 
  static int exynos_ohci_get_phy(struct device *dev,
 @@ -48,56 +43,40 @@ static int exynos_ohci_get_phy(struct device *dev,
  {
   struct device_node *child;
   struct phy *phy;
 - int phy_number;
 - int ret = 0;
 + int phy_num;
 + int ret;
 
 - /*
 -  * Getting generic phy:
 -  * We are keeping both types of phys as a part of transiting OHCI
 -  * to generic phy framework, so as to maintain backward compatibilty
 -  * with old DTB too.
 -  * We fallback to older USB-PHYs when we fail to get generic PHYs.
 -  */
 + /* Get the generic phys */
   for_each_available_child_of_node(dev-of_node, child) {
 - ret = of_property_read_u32(child, reg, phy_number);
 + ret = of_property_read_u32(child, reg, phy_num);
   if (ret) {
   dev_err(dev, Failed to parse device tree\n);
   of_node_put(child);
   return ret;
   }
 
 - if (phy_number = PHY_NUMBER) {
 + if (phy_num = PHY_NUMBER) {
   dev_err(dev, Invalid number of PHYs\n);
   of_node_put(child);
   return -EINVAL;
   }
 
 - phy = devm_of_phy_get(dev, child, NULL);
 + exynos_ohci-phy[phy_num] = devm_of_phy_get(dev, child, NULL);
 + phy = exynos_ohci-phy[phy_num];
   of_node_put(child);
 - if (IS_ERR(phy))
 - /* Lets fallback to older USB-PHYs */
 - goto usb_phy_old;
 - exynos_ohci-phy_g[phy_number] = phy;
 - /* Make the older PHYs unavailable */
 - exynos_ohci-phy = ERR_PTR(-ENXIO);
 - }
 -
 - return 0;
 -
 -usb_phy_old:
 - exynos_ohci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - if (IS_ERR(exynos_ohci-phy)) {
 - ret = PTR_ERR(exynos_ohci-phy);
 - if (ret != -ENXIO  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 + if (IS_ERR(phy)) {
 + ret = PTR_ERR(phy);
 + if (ret == -EPROBE_DEFER) {
 + return ret;
 + } else if (ret != -ENOSYS  ret != -ENODEV) {
 + dev_err(dev,
 + Error retrieving usb2 phy: %d\n, ret);
 + return PTR_ERR(phy);
 + }
   }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - } else {
 - exynos_ohci-otg = exynos_ohci-phy-otg;
   }
 
 - return ret;
 + return 0;
  }
 
  static int exynos_ohci_phy_enable(struct device *dev)
 @@ -107,16 +86,13 @@ static int exynos_ohci_phy_enable(struct device *dev)
   int i;
   int ret = 0;
 
 - if (!IS_ERR(exynos_ohci-phy))
 - return usb_phy_init(exynos_ohci-phy);
 -
   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
 - if (!IS_ERR(exynos_ohci-phy_g[i]))
 - ret = phy_power_on(exynos_ohci-phy_g[i]);
 + if (!IS_ERR(exynos_ohci-phy[i]))
 + ret = phy_power_on(exynos_ohci-phy[i]);
   if (ret)
   for (i--; i = 0; i--)
 - if (!IS_ERR(exynos_ohci-phy_g[i]))
 - phy_power_off(exynos_ohci-phy_g[i]);
 + if (!IS_ERR(exynos_ohci-phy[i]))
 + phy_power_off(exynos_ohci-phy[i]);
 
   return ret;
  }
 @@ -127,14 +103,9 @@ static void exynos_ohci_phy_disable(struct device *dev)
   struct exynos_ohci_hcd *exynos_ohci = 

Re: [PATCH 0/7] xhci: patches for usb-next

2014-09-17 Thread Mathias Nyman
Ping,

Any plan on taking these to your usb-next branch?

They still apply nicely on latest 3.17-rc5 based usb-next

-Mathias

On 08/20/2014 04:41 PM, Mathias Nyman wrote:
 Hi Greg
 
 These xhci patches are for usb-next and apply on top of 3.17-rc1
 
 It contains Hans De Goede's xhci cleanups, and one small xhci
 suspend improvement.
 
 I'll be out hiking and unable to respond (no network whatsoeever)
 until mid next week, 27.8.
 
 -Mathias
 
 Al Cooper (1):
   usb: xhci_suspend is not stopping the root hub timer for the shared
 HCD
 
 Hans de Goede (6):
   xhci: Log extra info on ERROR Transfer event TRB DMA ptr not part of
 current TD
   xhci: Move allocating of command for new_dequeue_state to
 queue_set_tr_deq()
   xhci: Fold queue_set_tr_deq into xhci_queue_new_dequeue_state
   xhci: Remove FIXME - check all the stream rings for pending
 cancellations
   xhci: Always ring the doorbell for active eps when a Set TR deq ptr
 cmd completes
   xhci: xhci_ring_device: Ring stream ring bells for endpoints with
 streams
 
  drivers/usb/host/xhci-hub.c  |  15 +++--
  drivers/usb/host/xhci-mem.c  |   4 +-
  drivers/usb/host/xhci-ring.c | 137 
 ++-
  drivers/usb/host/xhci.c  |  11 ++--
  drivers/usb/host/xhci.h  |   7 +--
  5 files changed, 93 insertions(+), 81 deletions(-)
 

--
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-17 Thread Mikko Perttunen

On 09/17/2014 01:40 AM, Stephen Warren wrote:

That's a huge time-sink, unless I work out NFS root,
which probably isn't properly or easily supported by any distro.


FWIW, this is how I've been working, and it hasn't been /that/ difficult 
to get working. The Tegra side is trivial, just append something like


ip=dhcp root=/dev/nfs 
nfsroot=host_ip:/your/nfsroot,v3,rsize=8192,wsize=8192,timeo=15


(Granted, I had to do a bit of mucking around before finding this 
working incantation..)


to the kernel boot arguments. I've used Ubuntu 12.04, 13.10 and Arch 
Linux on my Jetson in this way. The more annoying part is the nfs host 
machine, but there are guides for that. Anyway, I've had both Ubuntu 
12.04 and Arch working as hosts without problems.


Mikko

--
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-17 Thread Joe Lawrence
On Tue, 16 Sep 2014 15:29:20 -0400
Alan Stern st...@rowland.harvard.edu wrote:

 ... And now I see the problem.  It's these two lines just before the 
 switch:
 
   if (ehci-rh_state  EHCI_RH_RUNNING)
   qh-qh_state = QH_STATE_IDLE;
 
 That undoubtedly caused us to destroy the QH directly without unlinking 
 it first.
 
 I'm pretty sure those two lines aren't needed any more.  Try removing 
 them and see if the problem persists.

Much better!  Two machines running the same set of device removal tests
are still running (kicked off ~5pm Tues).  Typically the qh_destroy
BUG would be hit within a few hours of testing.

(I left the BUG_ON(ehci-async-qh_next.qh == qh) in
ehci_endpoint_disable as an assertion.  Obviously no hits on that
either.)

Thanks for the debug!

-- Joe
--
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-17 Thread Alan Stern
On Tue, 16 Sep 2014, Mark wrote:

  Do you know what product ID the ethernet adapter actually uses?
 
 Sadly, I think versions exist with *both* IDs 0411:0001 and 0411:0005, and
 the Windows INF file mentions both.
 
 Some searching gave related results...
 
 Post to linux-usb on 2000-04-02, About MELCO LUA-TX USB LAN ADAPTOR:
   https://www.mail-archive.com/linux-usb@suse.com/msg00569.html
 That's a patch to add support to the pegasus driver for Buffalo LUA-TX with
 ID 0411:0001.
 
 Post to freebsd-bugs on 2000-12-12, kern/11711: USB Ethernet LUA-TX
 product ID:
   http://marc.info/?l=netbsd-bugsm=97665695908785
 The poster has an LUA-TX with ID 0411:0005.
 
 Is it possible to add an entry to unusual-devs.h, but have usb-storage only
 bind to the device if it reports itself as being a USB mass storage device?
 Or maybe to match the manufacturer or product string? Otherwise, if I add
 an entry for the Buffalo USB-SCSI cable, anyone who still uses an 0411:0001
 LUA-TX would have to blacklist usb-storage (or disable the quirk on the

You could use the UNUSUAL_VENDOR_INTF macro.  That will match entries
based on the vendor ID and the interface class, subclass, and protocol.  
(Presumably the LUA-TX doesn't have an interface claiming to belong to
the Mass-Storage class.)  But the macro doesn't take the product ID
into account.

Alan Stern

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


Re: [PATCH v3 1/2] usb: host: ehci-exynos: Remove unnecessary usb-phy support

2014-09-17 Thread Alan Stern
On Wed, 17 Sep 2014, Vivek Gautam wrote:

 Now that we have completely moved from older USB-PHY drivers
 to newer GENERIC-PHY drivers for PHYs available with USB controllers
 on Exynos series of SoCs, we can remove the support for the same
 in our host drivers too.
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com

I don't see why you made your changes in this awkward way.  For 
instance...

 @@ -59,49 +54,39 @@ static int exynos_ehci_get_phy(struct device *dev,
  {
   struct device_node *child;
   struct phy *phy;
 - int phy_number;
 - int ret = 0;
 + int phy_num;

Why rename this variable?  Wasn't the original name good enough?

 + int ret;
  
   for_each_available_child_of_node(dev-of_node, child) {
 - ret = of_property_read_u32(child, reg, phy_number);
 + ret = of_property_read_u32(child, reg, phy_num);
   if (ret) {
   dev_err(dev, Failed to parse device tree\n);
   of_node_put(child);
   return ret;
   }
  
 - if (phy_number = PHY_NUMBER) {
 + if (phy_num = PHY_NUMBER) {
   dev_err(dev, Invalid number of PHYs\n);
   of_node_put(child);
   return -EINVAL;
   }
  
 - phy = devm_of_phy_get(dev, child, NULL);
 + exynos_ehci-phy[phy_num] = devm_of_phy_get(dev, child, NULL);
 + phy = exynos_ehci-phy[phy_num];

Why make two changes, resulting in more code, when you could have made 
just one change?

phy = devm_of_phy_get(dev, child, NULL);
+   exynos_ehci-phy[phy_num] = phy;

Also, the patch description should mention that you are adding support 
for EPROBE_DEFER.

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 v2 0/4] usb: hub: convert khubd into workqueue

2014-09-17 Thread Petr Mladek
The workqueue API is well defined and tested. It has many options
that could be used to tune the scheduling. The code is usually
easier and thus more safe. It allows to avoid the extra thread
in most cases. It has has clearly defined behavior vrt. system suspend.

This patchset converts khubd into the workqueue. It saves one thread,
lock, and list.

It  looks huge but the main change is in the first patch. The rest is
simple renaming of functions, comments and documentation.

Changes in v2:

+ solved potential races:
 + get hub-kref in kick_hub_wq()
 + call usb_get_dev(hdev) in hub_probe()
   and  usb_put_dev(hdev) in hub_release()
 + INIT_WORK only once in hub_probe()
 + do not call cancel_work_sync() in hub_disconnect()
   to keep it fast
 + rename kick_khubd() to kick_hub_wq() already
   in the first patch; IMHO, it is cleaner while
   adding only very few changes
   
I send all patches again. Especially, 2nd and 3rd patch
needed refresh.

Note that the while cycle in hub_events() was needed when using
the kthread. More events might appear in the list before
the thread is scheduled. This is why I kept the order of patches
as is to do not break bisection.

Thanks a lot Alan Stern for hint and guidance.

The patches can be applied either against Linus' tree or linux-next.


Petr Mladek (4):
  usb: hub: convert khubd into workqueue
  usb: hub: remove obsolete while cycle in hub_event()
  usb: hub: rename usb_kick_khubd() to usb_kick_hub_wq()
  usb: hub: rename khubd to hub_wq in documentation and comments

 Documentation/DocBook/usb.tmpl |   2 +-
 Documentation/usb/WUSB-Design-overview.txt |   6 +-
 Documentation/usb/hotplug.txt  |   2 +-
 drivers/net/usb/usbnet.c   |  14 +-
 drivers/usb/README |   2 +-
 drivers/usb/core/hcd.c |  14 +-
 drivers/usb/core/hub.c | 380 +
 drivers/usb/core/hub.h |   2 +-
 drivers/usb/core/usb.h |   2 +-
 drivers/usb/host/ehci-fsl.c|   2 +-
 drivers/usb/host/ehci-hcd.c|   2 +-
 drivers/usb/host/ehci-hub.c|   8 +-
 drivers/usb/host/fhci-hcd.c|   6 +-
 drivers/usb/host/fotg210-hcd.c |   8 +-
 drivers/usb/host/fusbh200-hcd.c|   8 +-
 drivers/usb/host/isp1760-hcd.c |   6 +-
 drivers/usb/host/ohci-hcd.c|   6 +-
 drivers/usb/host/ohci-hub.c|   4 +-
 drivers/usb/host/ohci-omap.c   |   2 +-
 drivers/usb/host/oxu210hp-hcd.c|  10 +-
 drivers/usb/host/sl811-hcd.c   |   8 +-
 drivers/usb/host/xhci-hub.c|   2 +-
 drivers/usb/host/xhci.c|   4 +-
 drivers/usb/misc/usbtest.c |   2 +-
 drivers/usb/musb/am35x.c   |   1 +
 drivers/usb/musb/tusb6010.c|   2 +-
 drivers/usb/phy/phy-fsl-usb.c  |   2 +-
 drivers/usb/phy/phy-isp1301-omap.c |   2 +-
 drivers/usb/wusbcore/devconnect.c  |   6 +-
 drivers/usb/wusbcore/wa-hc.h   |   2 +-
 sound/usb/midi.c   |   2 +-
 31 files changed, 240 insertions(+), 279 deletions(-)

-- 
1.8.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 v2 3/4] usb: hub: rename usb_kick_khubd() to usb_kick_hub_wq()

2014-09-17 Thread Petr Mladek
USB hub started to use a workqueue instead of kthread. Let's make it clear from
the function names.

Signed-off-by: Petr Mladek pmla...@suse.cz
---
 drivers/usb/core/hcd.c | 4 ++--
 drivers/usb/core/hub.c | 2 +-
 drivers/usb/core/usb.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487abcfcccd8..4bec044a786c 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2386,7 +2386,7 @@ void usb_hc_died (struct usb_hcd *hcd)
/* make khubd clean up old urbs and devices */
usb_set_device_state (hcd-self.root_hub,
USB_STATE_NOTATTACHED);
-   usb_kick_khubd (hcd-self.root_hub);
+   usb_kick_hub_wq(hcd-self.root_hub);
}
if (usb_hcd_is_primary_hcd(hcd)  hcd-shared_hcd) {
hcd = hcd-shared_hcd;
@@ -2396,7 +2396,7 @@ void usb_hc_died (struct usb_hcd *hcd)
/* make khubd clean up old urbs and devices */
usb_set_device_state(hcd-self.root_hub,
USB_STATE_NOTATTACHED);
-   usb_kick_khubd(hcd-self.root_hub);
+   usb_kick_hub_wq(hcd-self.root_hub);
}
}
spin_unlock_irqrestore (hcd_root_hub_lock, flags);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b6b526a2e20d..8d86350cb0a2 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -597,7 +597,7 @@ static void kick_hub_wq(struct usb_hub *hub)
kref_put(hub-kref, hub_release);
 }
 
-void usb_kick_khubd(struct usb_device *hdev)
+void usb_kick_hub_wq(struct usb_device *hdev)
 {
struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
 
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index d9d08720c386..b1b34d0557c9 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -48,7 +48,7 @@ static inline unsigned usb_get_max_power(struct usb_device 
*udev,
return c-desc.bMaxPower * mul;
 }
 
-extern void usb_kick_khubd(struct usb_device *dev);
+extern void usb_kick_hub_wq(struct usb_device *dev);
 extern int usb_match_one_id_intf(struct usb_device *dev,
 struct usb_host_interface *intf,
 const struct usb_device_id *id);
-- 
1.8.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 v2 1/4] usb: hub: convert khubd into workqueue

2014-09-17 Thread Petr Mladek
There is no need to have separate kthread for handling USB hub events.
It is more elegant to use the workqueue framework.

The workqueue is allocated as freezable because the original thread was
freezable as well.

struct usb_hub is passed via the work item. Therefore we do not need
hub_event_list.

Also hub_thread() is not longer needed. It would call only hub_events().
The rest of the code did manipulate the kthread and it is handled by the
workqueue framework now.

Therefore the work item is proceed directly by hub_events(). Only one item
is manipulated in one call, so the function is renamed to hub_event().
The obsolete block from the while cycle will be removed in a followup patch.
It helps to see the real changes here.

kick_khubd is renamed to kick_hub_wq() to make the function clear. And the
protection against races is done another way, see below.

hub_event_lock has been removed. It cannot longer be used to protect struct
usb_hub between hub_event() and hub_disconnect(). Instead we need to get
hub-kref already in kick_hub_wq().

We would need to call also usb_get_dev() in kick_hub_wq(). But better
solution is to move this to hub_probe() where the struct hub is allocated.
As a result, usb_put_dev() is called in hub_release(). By other words,
it is handled the same way like usb_get_intf() and usb_put_intf().

But back to the lock. It is not really needed for the other scenarios as well.
queue_work() returns whether it succeeded. We could revert the needed operations
accordingly. This is enough to avoid duplicity and inconsistencies.

Yes, the removed lock causes that there is not longer such a strong
synchronization between scheduling the work and manipulating
hub-disconnected.

But kick_hub_wq() must never be called together with hub_disconnect()
otherwise even the original code would have failed. Any callers are
responsible for this.

Therefore the only problem is that hub_disconnect() could be called in parallel
with hub_event(). But this was possible even in the past. struct usb_hub is
still guarded by hub-kref and released in hub_events() when needed.

Note that the source file is still full of the obsolete khubd strings.
Let's remove them in a follow up patch. This patch already is complex enough.

Thanks a lot Alan Stern st...@rowland.harvard.edu for very useful tips
and guidance.

Signed-off-by: Petr Mladek pmla...@suse.cz
---
 drivers/usb/core/hub.c | 163 +++--
 drivers/usb/core/hub.h |   2 +-
 2 files changed, 65 insertions(+), 100 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d481c99a20d7..b67f454c1edb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -22,9 +22,8 @@
 #include linux/usb/hcd.h
 #include linux/usb/otg.h
 #include linux/usb/quirks.h
-#include linux/kthread.h
+#include linux/workqueue.h
 #include linux/mutex.h
-#include linux/freezer.h
 #include linux/random.h
 #include linux/pm_qos.h
 
@@ -41,14 +40,9 @@
  * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
 static DEFINE_SPINLOCK(device_state_lock);
 
-/* khubd's worklist and its lock */
-static DEFINE_SPINLOCK(hub_event_lock);
-static LIST_HEAD(hub_event_list);  /* List of hubs needing servicing */
-
-/* Wakes up khubd */
-static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
-
-static struct task_struct *khubd_task;
+/* workqueue to process hub events */
+static struct workqueue_struct *hub_wq;
+static void hub_event(struct work_struct *work);
 
 /* synchronize hub-port add/remove and peering operations */
 DEFINE_MUTEX(usb_port_peer_mutex);
@@ -104,6 +98,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
 #define HUB_DEBOUNCE_STEP25
 #define HUB_DEBOUNCE_STABLE 100
 
+static void hub_release(struct kref *kref);
 static int usb_reset_and_verify_device(struct usb_device *udev);
 
 static inline char *portspeed(struct usb_hub *hub, int portstatus)
@@ -575,20 +570,31 @@ static int hub_port_status(struct usb_hub *hub, int port1,
return ret;
 }
 
-static void kick_khubd(struct usb_hub *hub)
+static void kick_hub_wq(struct usb_hub *hub)
 {
-   unsigned long   flags;
+   struct usb_interface *intf;
 
-   spin_lock_irqsave(hub_event_lock, flags);
-   if (!hub-disconnected  list_empty(hub-event_list)) {
-   list_add_tail(hub-event_list, hub_event_list);
+   if (hub-disconnected || work_pending(hub-events))
+   return;
 
-   /* Suppress autosuspend until khubd runs */
-   usb_autopm_get_interface_no_resume(
-   to_usb_interface(hub-intfdev));
-   wake_up(khubd_wait);
-   }
-   spin_unlock_irqrestore(hub_event_lock, flags);
+   intf = to_usb_interface(hub-intfdev);
+   /*
+* Suppress autosuspend until the event is proceed.
+*
+* Be careful and make sure that the symmetric operation is
+* always called. We are here only when there is no pending
+   

[PATCH v2 4/4] usb: hub: rename khubd to hub_wq in documentation and comments

2014-09-17 Thread Petr Mladek
USB hub has started to use a workqueue instead of kthread. Let's update
the documentation and comments here and there.

This patch mostly just replaces khubd with hub_wq. There are only few
exceptions where the whole sentence was updated. These more complicated
changes can be found in the following files:

   Documentation/usb/hotplug.txt
   drivers/net/usb/usbnet.c
   drivers/usb/core/hcd.c
   drivers/usb/host/ohci-hcd.c
   drivers/usb/host/xhci.c

Signed-off-by: Petr Mladek pmla...@suse.cz
---
 Documentation/DocBook/usb.tmpl |  2 +-
 Documentation/usb/WUSB-Design-overview.txt |  6 ++--
 Documentation/usb/hotplug.txt  |  2 +-
 drivers/net/usb/usbnet.c   | 14 ++
 drivers/usb/README |  2 +-
 drivers/usb/core/hcd.c | 10 +++
 drivers/usb/core/hub.c | 44 +++---
 drivers/usb/host/ehci-fsl.c|  2 +-
 drivers/usb/host/ehci-hcd.c|  2 +-
 drivers/usb/host/ehci-hub.c|  8 +++---
 drivers/usb/host/fhci-hcd.c|  6 ++--
 drivers/usb/host/fotg210-hcd.c |  8 +++---
 drivers/usb/host/fusbh200-hcd.c|  8 +++---
 drivers/usb/host/isp1760-hcd.c |  6 ++--
 drivers/usb/host/ohci-hcd.c|  6 ++--
 drivers/usb/host/ohci-hub.c|  4 +--
 drivers/usb/host/ohci-omap.c   |  2 +-
 drivers/usb/host/oxu210hp-hcd.c| 10 +++
 drivers/usb/host/sl811-hcd.c   |  8 +++---
 drivers/usb/host/xhci-hub.c|  2 +-
 drivers/usb/host/xhci.c|  4 +--
 drivers/usb/misc/usbtest.c |  2 +-
 drivers/usb/musb/am35x.c   |  1 +
 drivers/usb/musb/tusb6010.c|  2 +-
 drivers/usb/phy/phy-fsl-usb.c  |  2 +-
 drivers/usb/phy/phy-isp1301-omap.c |  2 +-
 drivers/usb/wusbcore/devconnect.c  |  6 ++--
 drivers/usb/wusbcore/wa-hc.h   |  2 +-
 sound/usb/midi.c   |  2 +-
 29 files changed, 89 insertions(+), 86 deletions(-)

diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl
index 85fc0e28576f..4cd5b2cd0f3d 100644
--- a/Documentation/DocBook/usb.tmpl
+++ b/Documentation/DocBook/usb.tmpl
@@ -593,7 +593,7 @@ for (;;) {
Each device has one control endpoint (endpoint zero)
which supports a limited RPC style RPC access.
Devices are configured
-   by khubd (in the kernel) setting a device-wide
+   by hub_wq (in the kernel) setting a device-wide
emphasisconfiguration/emphasis that affects things
like power consumption and basic functionality.
The endpoints are part of USB emphasisinterfaces/emphasis,
diff --git a/Documentation/usb/WUSB-Design-overview.txt 
b/Documentation/usb/WUSB-Design-overview.txt
index 1cd07c017cf6..9d08f179a7ca 100644
--- a/Documentation/usb/WUSB-Design-overview.txt
+++ b/Documentation/usb/WUSB-Design-overview.txt
@@ -317,7 +317,7 @@ HC picks the /DN_Connect/ out (nep module sends to notif.c 
for delivery
 into /devconnect/). This process starts the authentication process for
 the device. First we allocate a /fake port/ and assign an
 unauthenticated address (128 to 255--what we really do is
-0x80 | fake_port_idx). We fiddle with the fake port status and /khubd/
+0x80 | fake_port_idx). We fiddle with the fake port status and /hub_wq/
 sees a new connection, so he moves on to enable the fake port with a reset.
 
 So now we are in the reset path -- we know we have a non-yet enumerated
@@ -326,7 +326,7 @@ device with an unauthorized address; we ask user space to 
authenticate
 exchange (FIXME: not yet done) and issue a /set address 0/ to bring the
 device to the default state. Device is authenticated.
 
-From here, the USB stack takes control through the usb_hcd ops. khubd
+From here, the USB stack takes control through the usb_hcd ops. hub_wq
 has seen the port status changes, as we have been toggling them. It will
 start enumerating and doing transfers through usb_hcd-urb_enqueue() to
 read descriptors and move our data.
@@ -340,7 +340,7 @@ Keep Alive IE; it responds with a /DN_Alive/ pong during 
the DNTS (this
 arrives to us as a notification through
 devconnect.c:wusb_handle_dn_alive(). If a device times out, we
 disconnect it from the system (cleaning up internal information and
-toggling the bits in the fake hub port, which kicks khubd into removing
+toggling the bits in the fake hub port, which kicks hub_wq into removing
 the rest of the stuff).
 
 This is done through devconnect:__wusb_check_devs(), which will scan the
diff --git a/Documentation/usb/hotplug.txt b/Documentation/usb/hotplug.txt
index a80b0e9a7a0b..5b243f315b2c 100644
--- a/Documentation/usb/hotplug.txt
+++ b/Documentation/usb/hotplug.txt
@@ -58,7 +58,7 @@ USB POLICY AGENT
 
 The USB subsystem 

[PATCH] USB: EHCI: unlink QHs even after the controller has stopped

2014-09-17 Thread Alan Stern
Old code in ehci-hcd tries to expedite disabling endpoints after the
controller has stopped, by destroying the endpoint's associated QH
without first unlinking the QH.  This was necessary back when the
driver wasn't so careful about keeping track of the controller's
state.

But now we are careful about it, and the driver knows that when the
controller isn't running, no unlinking delay is needed.  Furthermore,
skipping the unlink step will trigger a BUG() in qh_destroy() when the
preceding QH is released, because the link pointer will be non-NULL.

Removing the lines that skip the unlinking step and go directly to
QH_STATE_IDLE fixes the problem.

Signed-off-by: Alan Stern st...@rowland.harvard.edu
Reported-by: Joe Lawrence joe.lawre...@stratus.com
Tested-by: Joe Lawrence joe.lawre...@stratus.com
CC: sta...@vger.kernel.org

---

[as1766]


 drivers/usb/host/ehci-hcd.c |2 --
 1 file changed, 2 deletions(-)

Index: usb-3.17/drivers/usb/host/ehci-hcd.c
===
--- usb-3.17.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.17/drivers/usb/host/ehci-hcd.c
@@ -965,8 +965,6 @@ rescan:
}
 
qh-exception = 1;
-   if (ehci-rh_state  EHCI_RH_RUNNING)
-   qh-qh_state = QH_STATE_IDLE;
switch (qh-qh_state) {
case QH_STATE_LINKED:
WARN_ON(!list_empty(qh-qtd_list));

--
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/4] usb: hub: remove obsolete while cycle in hub_event()

2014-09-17 Thread Petr Mládek
On Fri 12-09-14 10:23:26, Alan Stern wrote:
 On Fri, 12 Sep 2014, Petr Mladek wrote:
 
  The USB hub events are proceed by workqueue instead of kthread now.
  The result is that hub_event() function processes only one event.
  The while cycle was not removed earlier to show the real changes when
  switching to the workqueue.
  
  This patch also consolidates the goto targets and rename them from loop*
  to out*.
  
  When touching the code, it fixes also formatting of dev_err() and dev_dbg()
  calls to make checkpatch.pl happy :-)
 
 Although the reason given in the description above is not really
 accurate, removing the loop in hub_events is a reasonable thing to do.  
 That loop doesn't serve any purpose as far as I can see.

IMHO, the while cycle was needed when hub_events() was used in
khubd thread. More events could had been added to the list before
the thread was scheduled.

Therefore I think that the above description makes sense.

And this is why I did not change the order of the patches in v2 of the patch
set. I sent all patches again because this one and the 3rd one needed
refresh.

Best Regards,
Petr
--
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-17 Thread Alan Stern
On Wed, 17 Sep 2014, Joe Lawrence wrote:

 On Tue, 16 Sep 2014 15:29:20 -0400
 Alan Stern st...@rowland.harvard.edu wrote:
 
  ... And now I see the problem.  It's these two lines just before the 
  switch:
  
  if (ehci-rh_state  EHCI_RH_RUNNING)
  qh-qh_state = QH_STATE_IDLE;
  
  That undoubtedly caused us to destroy the QH directly without unlinking 
  it first.
  
  I'm pretty sure those two lines aren't needed any more.  Try removing 
  them and see if the problem persists.
 
 Much better!  Two machines running the same set of device removal tests
 are still running (kicked off ~5pm Tues).  Typically the qh_destroy
 BUG would be hit within a few hours of testing.
 
 (I left the BUG_ON(ehci-async-qh_next.qh == qh) in
 ehci_endpoint_disable as an assertion.  Obviously no hits on that
 either.)

Very good.  I reviewed the rest of the code to make sure that removing 
those lines won't cause any other problems.  It looks safe, so I have 
submitted a patch.

 Thanks for the debug!

You're welcome.

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: am335x musb_hdrc broken(?)

2014-09-17 Thread Felipe Balbi
On Wed, Sep 17, 2014 at 10:46:57AM +0400, Matwey V. Kornilov wrote:
 2014-09-16 22:39 GMT+04:00 Felipe Balbi ba...@ti.com:
  Hi,
 
  (man, talk about trimming... leave some context ;-)
 
  On Tue, Sep 16, 2014 at 10:06:33PM +0400, Matwey V. Kornilov wrote:
  Ok. What is about musb_io.h? What does it mean TUSB6010 doesn't allow
  8-bit access; 16-bit access is the minimum.?
 
  it means that readb() won't work.
 
  I think __raw_readb is kind of return *(u8_t*)(addr), but this is CPU
  stuff as far as I understand.
 
  tusb6010 is a discrete device connected through GPMC (general purpose
  memory controller). Basically, this tells you that tusb6010 cannot
  understand 8-bit accesses through gpmc.
 
 
 So, I checked the stuff in musb_io.h and it doesn't work properly for
 my BBB. I don't know why. With this tusb6010-custom
 musb_readb/musb_writeb functions I am not able to mount USB flash
 drive (the device is being reset constantly, at the same time the
 webcam works fine). With __raw functions, it is fine.
 
 Do you have an idea how this could be refactored?

can't think of a solution off the top of my head.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH v2 2/4] usb: hub: remove obsolete while cycle in hub_event()

2014-09-17 Thread Petr Mladek
The USB hub events are proceed by workqueue instead of kthread now.
The result is that hub_event() function processes only one event.
The block from the while cycle was not removed earlier to show the real
 changes when switching to the workqueue.

When touching the code, it fixes also formatting of dev_err() and dev_dbg()
calls to make checkpatch.pl happy :-)

Signed-off-by: Petr Mladek pmla...@suse.cz
---
 drivers/usb/core/hub.c | 199 -
 1 file changed, 96 insertions(+), 103 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b67f454c1edb..b6b526a2e20d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4997,7 +4997,6 @@ static void port_event(struct usb_hub *hub, int port1)
hub_port_connect_change(hub, port1, portstatus, portchange);
 }
 
-
 static void hub_event(struct work_struct *work)
 {
struct usb_device *hdev;
@@ -5008,122 +5007,116 @@ static void hub_event(struct work_struct *work)
u16 hubchange;
int i, ret;
 
-   /* temporary keep the block to show real changes in this commit */
-   {
-   hub = container_of(work, struct usb_hub, events);
-   hdev = hub-hdev;
-   hub_dev = hub-intfdev;
-   intf = to_usb_interface(hub_dev);
-
-   dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n,
-   hdev-state, hdev-maxchild,
-   /* NOTE: expects max 15 ports... */
-   (u16) hub-change_bits[0],
-   (u16) hub-event_bits[0]);
-
-   /* Lock the device, then check to see if we were
-* disconnected while waiting for the lock to succeed. */
-   usb_lock_device(hdev);
-   if (unlikely(hub-disconnected))
-   goto out_hdev_lock;
-
-   /* If the hub has died, clean up after it */
-   if (hdev-state == USB_STATE_NOTATTACHED) {
-   hub-error = -ENODEV;
-   hub_quiesce(hub, HUB_DISCONNECT);
-   goto out_hdev_lock;
-   }
+   hub = container_of(work, struct usb_hub, events);
+   hdev = hub-hdev;
+   hub_dev = hub-intfdev;
+   intf = to_usb_interface(hub_dev);
+
+   dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n,
+   hdev-state, hdev-maxchild,
+   /* NOTE: expects max 15 ports... */
+   (u16) hub-change_bits[0],
+   (u16) hub-event_bits[0]);
+
+   /* Lock the device, then check to see if we were
+* disconnected while waiting for the lock to succeed. */
+   usb_lock_device(hdev);
+   if (unlikely(hub-disconnected))
+   goto out_hdev_lock;
+
+   /* If the hub has died, clean up after it */
+   if (hdev-state == USB_STATE_NOTATTACHED) {
+   hub-error = -ENODEV;
+   hub_quiesce(hub, HUB_DISCONNECT);
+   goto out_hdev_lock;
+   }
+
+   /* Autoresume */
+   ret = usb_autopm_get_interface(intf);
+   if (ret) {
+   dev_dbg(hub_dev, Can't autoresume: %d\n, ret);
+   goto out_hdev_lock;
+   }
 
-   /* Autoresume */
-   ret = usb_autopm_get_interface(intf);
-   if (ret) {
-   dev_dbg(hub_dev, Can't autoresume: %d\n, ret);
-   goto out_hdev_lock;
-   }
+   /* If this is an inactive hub, do nothing */
+   if (hub-quiescing)
+   goto out_autopm;
+
+   if (hub-error) {
+   dev_dbg(hub_dev, resetting for error %d\n, hub-error);
 
-   /* If this is an inactive hub, do nothing */
-   if (hub-quiescing)
+   ret = usb_reset_device(hdev);
+   if (ret) {
+   dev_dbg(hub_dev, error resetting hub: %d\n, ret);
goto out_autopm;
+   }
 
-   if (hub-error) {
-   dev_dbg (hub_dev, resetting for error %d\n,
-   hub-error);
+   hub-nerrors = 0;
+   hub-error = 0;
+   }
 
-   ret = usb_reset_device(hdev);
-   if (ret) {
-   dev_dbg (hub_dev,
-   error resetting hub: %d\n, ret);
-   goto out_autopm;
-   }
+   /* deal with port status changes */
+   for (i = 1; i = hdev-maxchild; i++) {
+   struct usb_port *port_dev = hub-ports[i - 1];
 
-   hub-nerrors = 0;
-   hub-error = 0;
+   if (test_bit(i, hub-event_bits)
+   || test_bit(i, hub-change_bits)
+   || test_bit(i, hub-wakeup_bits)) {
+   /*
+  

Re: [PATCH v5 1/3] usb: gadget: Refactor request completion

2014-09-17 Thread Felipe Balbi
On Wed, Sep 17, 2014 at 09:21:11AM +0200, Michal Sojka wrote:
 All USB peripheral controller drivers called completion routines
 directly. This patch moves the completion call from drivers to
 usb_gadget_giveback_request(), in order to have a place where common
 functionality can be added.
 
 All places in drivers/usb/ matching [-.]complete( were replaced with a
 call to usb_gadget_giveback_request(). This was compile-tested with all
 ARM drivers enabled and runtime-tested for musb.
 
 Signed-off-by: Michal Sojka so...@merica.cz
 ---
  drivers/usb/chipidea/udc.c  |  6 +++---
  drivers/usb/dwc2/gadget.c   |  6 +++---
  drivers/usb/dwc3/gadget.c   |  2 +-
  drivers/usb/gadget/udc/amd5536udc.c |  2 +-
  drivers/usb/gadget/udc/at91_udc.c   |  2 +-
  drivers/usb/gadget/udc/atmel_usba_udc.c |  4 ++--
  drivers/usb/gadget/udc/bcm63xx_udc.c|  2 +-
  drivers/usb/gadget/udc/dummy_hcd.c  | 10 +-
  drivers/usb/gadget/udc/fotg210-udc.c|  2 +-
  drivers/usb/gadget/udc/fsl_qe_udc.c |  6 +-
  drivers/usb/gadget/udc/fsl_udc_core.c   |  6 ++
  drivers/usb/gadget/udc/fusb300_udc.c|  2 +-
  drivers/usb/gadget/udc/goku_udc.c   |  2 +-
  drivers/usb/gadget/udc/gr_udc.c |  2 +-
  drivers/usb/gadget/udc/lpc32xx_udc.c|  2 +-
  drivers/usb/gadget/udc/m66592-udc.c |  2 +-
  drivers/usb/gadget/udc/mv_u3d_core.c|  8 ++--
  drivers/usb/gadget/udc/mv_udc_core.c|  8 ++--
  drivers/usb/gadget/udc/net2272.c|  2 +-
  drivers/usb/gadget/udc/net2280.c|  2 +-
  drivers/usb/gadget/udc/omap_udc.c   |  2 +-
  drivers/usb/gadget/udc/pch_udc.c|  2 +-
  drivers/usb/gadget/udc/pxa25x_udc.c |  2 +-
  drivers/usb/gadget/udc/pxa27x_udc.c |  2 +-
  drivers/usb/gadget/udc/r8a66597-udc.c   |  2 +-
  drivers/usb/gadget/udc/s3c-hsudc.c  |  3 +--
  drivers/usb/gadget/udc/s3c2410_udc.c|  2 +-
  drivers/usb/gadget/udc/udc-core.c   | 19 +++
  drivers/usb/musb/musb_gadget.c  |  2 +-
  drivers/usb/renesas_usbhs/mod_gadget.c  |  2 +-
  include/linux/usb/gadget.h  |  8 

I would rather split this into several patches, btw. With the
introduction of usb_gadget_giveback_request() being the first one in the
series. It's easier to review that way.

 diff --git a/drivers/usb/gadget/udc/udc-core.c 
 b/drivers/usb/gadget/udc/udc-core.c
 index b0d9817..29789f1 100644
 --- a/drivers/usb/gadget/udc/udc-core.c
 +++ b/drivers/usb/gadget/udc/udc-core.c
 @@ -106,6 +106,25 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
  
  /* - 
 */
  
 +/**
 + * usb_gadget_giveback_request - give the request back to the gadget layer
 + * Context: in_interrupt()
 + *
 + * This is called by device controller drivers in order to return the
 + * completed request back to the gadget layer.
 + */
 +void usb_gadget_giveback_request(struct usb_ep *ep,
 + struct usb_request *req)
 +{
 + if (likely(req-complete))
 + req-complete(ep, req);
 + else
 + pr_err(%s : req-complete must not be NULL\n, __func__);

let it Oops. We require -complete to be valid, if there's any gadget
driver not setting -complete, it deserves to oops so we can the error.

-- 
balbi


signature.asc
Description: Digital signature


Re: am335x musb_hdrc broken(?)

2014-09-17 Thread Matwey V. Kornilov
2014-09-17 19:25 GMT+04:00 Felipe Balbi ba...@ti.com:
 On Wed, Sep 17, 2014 at 10:46:57AM +0400, Matwey V. Kornilov wrote:
 2014-09-16 22:39 GMT+04:00 Felipe Balbi ba...@ti.com:
  Hi,
 
  (man, talk about trimming... leave some context ;-)
 
  On Tue, Sep 16, 2014 at 10:06:33PM +0400, Matwey V. Kornilov wrote:
  Ok. What is about musb_io.h? What does it mean TUSB6010 doesn't allow
  8-bit access; 16-bit access is the minimum.?
 
  it means that readb() won't work.
 
  I think __raw_readb is kind of return *(u8_t*)(addr), but this is CPU
  stuff as far as I understand.
 
  tusb6010 is a discrete device connected through GPMC (general purpose
  memory controller). Basically, this tells you that tusb6010 cannot
  understand 8-bit accesses through gpmc.
 

 So, I checked the stuff in musb_io.h and it doesn't work properly for
 my BBB. I don't know why. With this tusb6010-custom
 musb_readb/musb_writeb functions I am not able to mount USB flash
 drive (the device is being reset constantly, at the same time the
 webcam works fine). With __raw functions, it is fine.

 Do you have an idea how this could be refactored?

 can't think of a solution off the top of my head.

Using musb-ops-readb everywhere will add too much overhead probably.


-- 
With best regards,
Matwey V. Kornilov
http://blog.matwey.name
xmpp://0x2...@jabber.ru
--
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-17 Thread Stephen Warren

On 09/16/2014 05:51 PM, Andrew Bresticker wrote:

On Tue, Sep 16, 2014 at 4:15 PM, Stephen Warren swar...@wwwdotorg.org wrote:

On 09/16/2014 04:46 PM, Andrew Bresticker wrote:


On Tue, Sep 16, 2014 at 9:57 AM, Andrew Bresticker
abres...@chromium.org wrote:


On Tue, Sep 16, 2014 at 8:26 AM, Stephen Warren swar...@wwwdotorg.org
wrote:


On 09/15/2014 01:30 PM, Andrew Bresticker wrote:



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



...



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




Hmm. That git server was quite reluctant to cough up its bits, but it
did
eventually.


You'll also need the firmware Andrew Chew posted:
https://patchwork.ozlabs.org/patch/384013/




The XHCI driver can't load its firmware unless it's a module; if I make
it
built-in, it fails immediately with error -2 during Direct firmware
loading. The driver needs to work with either immediate or deferred
firmware loading.



If you want the driver to be built-in, you'll either need to build the
firmware in as well (i.e. EXTRA_FIRMWARE) or enable
FW_LOADER_USER_HELPER_FALLBACK to load with userspace/uevent (though
apparently this is deprecated).


The following USB2 devices had problems:

0b95:7720 ASIX Electronics Corp. AX88772


[  489.140536] usb 1-3: new high-speed USB device number 81 using
xhci-tegra
[  489.260860] usb 1-3: device descriptor read/64, error -71
[  489.370804] xhci-tegra 7009.usb: Setup ERROR: setup context
command
for slot 1.
[  489.378463] usb 1-3: hub failed to enable device, error -22
[  489.500531] usb 1-3: new high-speed USB device number 82 using
xhci-tegra
[  489.655708] usb 1-3: can't set config #1, error -71
[  489.661231] usb 1-3: USB disconnect, device number 82
[  489.940531] usb 1-3: new high-speed USB device number 83 using
xhci-tegra
[  490.060860] usb 1-3: device descriptor read/64, error -71
[  490.170805] xhci-tegra 7009.usb: Setup ERROR: setup context
command
for slot 1.
[  490.178462] usb 1-3: hub failed to enable device, error -22



(repeats over and over)

15a4:1336 Afatech Technologies, Inc. SDHC/MicroSD/MMC/MS/M2/CF/XD Flash
Card
Reader

The power light comes on, and the activity light just keeps flashing
fast.
Usually the activity light flashes a couple times and then turns off.
There
is nothing in dmesg at all for this device.

05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Not detected. There is nothing in dmesg at all for this device.

1bcf:0c31 Sunplus Innovation Technology Inc. SPIF30x Serial-ATA bridge

Not detected. There is nothing in dmesg at all for this device.



Thanks, I'll try to figure out what's going on here.



Grr... this is due to the unfortunate UTMI pad controller design on Tegra.

Here's the issue:  When UTMI pad 0 is assigned to the EHCI controller
(as is currently the case on Jetson-TK1), the UTMI parameters from
UTMIP_BIAS_CFG0 in the global UTMI pad register space are used
regardless of the owner of the UTMI pads.  If pad 0 is assigned to the
XUSB controller, then parameters in USB2_BIAS_PAD_CTL0 in the XUSB
register space are used for all UTMI pads (again, regardless of
ownership).

I wasn't able to reproduce before because I always TFTP booted and
U-Boot programs the UTMI parameters correctly when starting the EHCI
controllers.  I suspect you and Tomeu were booting without starting
the EHCI controllers and thus were stuck with the POR values.



I am loading the kernel over the PCIe Ethernet on Jetson TK1. However, the
U-Boot boot scripts do usb start first, so I would assume all the USB set
is already done either way, before U-Boot attempts to probe USB devices.


Interesting - just doing usb start made the difference for me.


The easiest way to fix this is to just assign UTMI port 0 (i.e. the
OTG port) to the XUSB controller.  AFAIK, device mode on Tegra isn't
supported yet in the kernel, so this shouldn't break any existing use
cases.  If we wanted to 

Re: am335x musb_hdrc broken(?)

2014-09-17 Thread Felipe Balbi
On Wed, Sep 17, 2014 at 07:35:14PM +0400, Matwey V. Kornilov wrote:
 2014-09-17 19:25 GMT+04:00 Felipe Balbi ba...@ti.com:
  On Wed, Sep 17, 2014 at 10:46:57AM +0400, Matwey V. Kornilov wrote:
  2014-09-16 22:39 GMT+04:00 Felipe Balbi ba...@ti.com:
   Hi,
  
   (man, talk about trimming... leave some context ;-)
  
   On Tue, Sep 16, 2014 at 10:06:33PM +0400, Matwey V. Kornilov wrote:
   Ok. What is about musb_io.h? What does it mean TUSB6010 doesn't allow
   8-bit access; 16-bit access is the minimum.?
  
   it means that readb() won't work.
  
   I think __raw_readb is kind of return *(u8_t*)(addr), but this is CPU
   stuff as far as I understand.
  
   tusb6010 is a discrete device connected through GPMC (general purpose
   memory controller). Basically, this tells you that tusb6010 cannot
   understand 8-bit accesses through gpmc.
  
 
  So, I checked the stuff in musb_io.h and it doesn't work properly for
  my BBB. I don't know why. With this tusb6010-custom
  musb_readb/musb_writeb functions I am not able to mount USB flash
  drive (the device is being reset constantly, at the same time the
  webcam works fine). With __raw functions, it is fine.
 
  Do you have an idea how this could be refactored?
 
  can't think of a solution off the top of my head.
 
 Using musb-ops-readb everywhere will add too much overhead probably.

correct :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v4 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-17 Thread Lee Jones
On Wed, 17 Sep 2014, Johan Hovold wrote:
 On Tue, Sep 09, 2014 at 10:24:44PM +0300, Octavian Purdila wrote:
  This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
  Master Adapter DLN-2. Details about the device can be found here:
  
  https://www.diolan.com/i2c/i2c_interface.html.
  
  Information about the USB protocol can be found in the Programmer's
  Reference Manual [1], see section 1.7.
  
  Because the hardware has a single transmit endpoint and a single
  receive endpoint the communication between the various DLN2 drivers
  and the hardware will be muxed/demuxed by this driver.
  
  Each DLN2 module will be identified by the handle field within the DLN2
  message header. If a DLN2 module issues multiple commands in parallel
  they will be identified by the echo counter field in the message header.
  
  The DLN2 modules can use the dln2_transfer() function to issue a
  command and wait for its response. They can also register a callback
  that is going to be called when a specific event id is generated by
  the device (e.g. GPIO interrupts). The device uses handle 0 for
  sending events.
  
  [1] https://www.diolan.com/downloads/dln-api-manual.pdf
  
  Signed-off-by: Octavian Purdila octavian.purd...@intel.com
  ---
   drivers/mfd/Kconfig  |   9 +
   drivers/mfd/Makefile |   1 +
   drivers/mfd/dln2.c   | 681 
  +++
   include/linux/mfd/dln2.h |  71 +
   4 files changed, 762 insertions(+)
   create mode 100644 drivers/mfd/dln2.c
   create mode 100644 include/linux/mfd/dln2.h

[...]

 Unless anyone suggests otherwise (e.g. to stick with auto id), I'll add
 a helper function for this and fix up those two drivers.

Appreciated.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/3] mfd: add support for Diolan DLN-2 devices

2014-09-17 Thread Lee Jones
On Wed, 17 Sep 2014, Octavian Purdila wrote:
 On Wed, Sep 17, 2014 at 2:21 AM, Lee Jones lee.jo...@linaro.org wrote:
 
  On Tue, 09 Sep 2014, Octavian Purdila wrote:
 
   This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO
   Master Adapter DLN-2. Details about the device can be found here:
  
   https://www.diolan.com/i2c/i2c_interface.html.
  
   Information about the USB protocol can be found in the Programmer's
   Reference Manual [1], see section 1.7.
  
   Because the hardware has a single transmit endpoint and a single
   receive endpoint the communication between the various DLN2 drivers
   and the hardware will be muxed/demuxed by this driver.
  
   Each DLN2 module will be identified by the handle field within the DLN2
   message header. If a DLN2 module issues multiple commands in parallel
   they will be identified by the echo counter field in the message header.
  
   The DLN2 modules can use the dln2_transfer() function to issue a
   command and wait for its response. They can also register a callback
   that is going to be called when a specific event id is generated by
   the device (e.g. GPIO interrupts). The device uses handle 0 for
   sending events.
  
   [1] https://www.diolan.com/downloads/dln-api-manual.pdf
  
   Signed-off-by: Octavian Purdila octavian.purd...@intel.com
   ---
drivers/mfd/Kconfig  |   9 +
drivers/mfd/Makefile |   1 +
drivers/mfd/dln2.c   | 681 
   +++
include/linux/mfd/dln2.h |  71 +
4 files changed, 762 insertions(+)
create mode 100644 drivers/mfd/dln2.c
create mode 100644 include/linux/mfd/dln2.h

[...]

   diff --git a/include/linux/mfd/dln2.h b/include/linux/mfd/dln2.h
   new file mode 100644
   index 000..197565d
   --- /dev/null
   +++ b/include/linux/mfd/dln2.h
   @@ -0,0 +1,71 @@
   +#ifndef __LINUX_USB_DLN2_H
   +#define __LINUX_USB_DLN2_H
   +
   +#define DLN2_CMD(cmd, id)((cmd) | ((id)  8))
   +
   +struct dln2_platform_data {
   + u16 handle;
   + union {
   + struct {
   + u8 port;
   + } i2c;
   + };
   +};
 
  Why this complexity?
 
 There is also an SPI interface on this adapter which will probably the
 port information and maybe some additional information. Would you
 prefer to add the union later, when we add the SPI driver?

Yes please.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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/4] usb: hub: remove obsolete while cycle in hub_event()

2014-09-17 Thread Alan Stern
On Wed, 17 Sep 2014, Petr [iso-8859-1] Ml�dek wrote:

 On Fri 12-09-14 10:23:26, Alan Stern wrote:
  On Fri, 12 Sep 2014, Petr Mladek wrote:
  
   The USB hub events are proceed by workqueue instead of kthread now.
   The result is that hub_event() function processes only one event.
   The while cycle was not removed earlier to show the real changes when
   switching to the workqueue.
   
   This patch also consolidates the goto targets and rename them from loop*
   to out*.
   
   When touching the code, it fixes also formatting of dev_err() and 
   dev_dbg()
   calls to make checkpatch.pl happy :-)
  
  Although the reason given in the description above is not really
  accurate, removing the loop in hub_events is a reasonable thing to do.  
  That loop doesn't serve any purpose as far as I can see.
 
 IMHO, the while cycle was needed when hub_events() was used in
 khubd thread. More events could had been added to the list before
 the thread was scheduled.

There's nothing wrong with that.  The thread would get around to 
executing the extra events in due course.

 Therefore I think that the above description makes sense.
 
 And this is why I did not change the order of the patches in v2 of the patch
 set. I sent all patches again because this one and the 3rd one needed
 refresh.

The patch is getting close.  There are still a couple of problems 
remaining.  I'll go into more detail in another email.

Alan Stern

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


Re: [PATCH v2 1/4] usb: hub: convert khubd into workqueue

2014-09-17 Thread Alan Stern

On Wed, 17 Sep 2014, Petr Mladek wrote:

 There is no need to have separate kthread for handling USB hub events.
 It is more elegant to use the workqueue framework.
 
 The workqueue is allocated as freezable because the original thread was
 freezable as well.

I've got a few comments about style.

 -static void kick_khubd(struct usb_hub *hub)
 +static void kick_hub_wq(struct usb_hub *hub)
  {
 - unsigned long   flags;
 + struct usb_interface *intf;
  
 - spin_lock_irqsave(hub_event_lock, flags);
 - if (!hub-disconnected  list_empty(hub-event_list)) {
 - list_add_tail(hub-event_list, hub_event_list);
 + if (hub-disconnected || work_pending(hub-events))
 + return;
  
 - /* Suppress autosuspend until khubd runs */
 - usb_autopm_get_interface_no_resume(
 - to_usb_interface(hub-intfdev));
 - wake_up(khubd_wait);
 - }
 - spin_unlock_irqrestore(hub_event_lock, flags);
 + intf = to_usb_interface(hub-intfdev);
 + /*
 +  * Suppress autosuspend until the event is proceed.
 +  *
 +  * Be careful and make sure that the symmetric operation is
 +  * always called. We are here only when there is no pending
 +  * work for this hub. Therefore put the interface either when
 +  * the new work is called or when it is canceled.
 +  */
 + kref_get(hub-kref);
 + usb_autopm_get_interface_no_resume(intf);

This looks a little weird.  The assignment to intf and the call to
usb_autopm_get_interface_no_resume naturally go together.  So why
put the big comment and the kref_get call in between them?  Put the
comment first, then the assigment and the autopm call, and then the
kref_get.

 @@ -5130,40 +5115,15 @@ static void hub_events(void)
   }
   }
  
 - loop_autopm:
 + out_autopm:
   /* Balance the usb_autopm_get_interface() above */
   usb_autopm_put_interface_no_suspend(intf);
 - loop:
 - /* Balance the usb_autopm_get_interface_no_resume() in
 -  * kick_khubd() and allow autosuspend.
 -  */
 - usb_autopm_put_interface(intf);
 - loop_disconnected:
 + out_hdev_lock:
   usb_unlock_device(hdev);
 - usb_put_dev(hdev);
 + /* Ballance the stuff in kick_hub_wq() and allow autosuspend */
 + usb_autopm_put_interface(intf);

You misspelled Balance.  Also, there should be a blank line before
this comment.

 @@ -5203,21 +5163,26 @@ int usb_hub_init(void)
   return -1;
   }
  
 - khubd_task = kthread_run(hub_thread, NULL, khubd);
 - if (!IS_ERR(khubd_task))
 + /*
 +  * The workqueue needs to be freezable to avoid interfering with
 +  * USB-PERSIST port handover. Otherwise it might see that a full-speed
 +  * device was gone before the EHCI controller had handed its port
 +  * over to the companion full-speed controller.
 +  */
 + hub_wq = alloc_workqueue(hub, WQ_FREEZABLE, 0);

Is hub really a good name for the workqueue?  If somebody reads it,
will they know what sort of hub it refers to?  Would usb_hub or even
usb_hub_wq be better?

  void usb_hub_cleanup(void)
  {
 -   kthread_stop(khubd_task);
 -
 +   destroy_workqueue(hub_wq);
 /*

Don't get rid of this blank line.

More to come...

Alan Stern

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


Re: [PATCH v2 2/4] usb: hub: remove obsolete while cycle in hub_event()

2014-09-17 Thread Alan Stern
On Wed, 17 Sep 2014, Petr Mladek wrote:

 The USB hub events are proceed by workqueue instead of kthread now.
 The result is that hub_event() function processes only one event.
 The block from the while cycle was not removed earlier to show the real
  changes when switching to the workqueue.
 
 When touching the code, it fixes also formatting of dev_err() and dev_dbg()
 calls to make checkpatch.pl happy :-)

More sylistic comments...

 + hub = container_of(work, struct usb_hub, events);
 + hdev = hub-hdev;
 + hub_dev = hub-intfdev;
 + intf = to_usb_interface(hub_dev);
 +
 + dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n,
 + hdev-state, hdev-maxchild,
 + /* NOTE: expects max 15 ports... */
 + (u16) hub-change_bits[0],
 + (u16) hub-event_bits[0]);

In this file, continuation lines are indented by 2 tab stops beyond the 
starting line, not one.

 + if (test_bit(i, hub-event_bits)
 + || test_bit(i, hub-change_bits)
 + || test_bit(i, hub-wakeup_bits)) {

And not four spaces.

Alan Stern

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


Re: [PATCH v2 4/4] usb: hub: rename khubd to hub_wq in documentation and comments

2014-09-17 Thread Alan Stern
On Wed, 17 Sep 2014, Petr Mladek wrote:

 USB hub has started to use a workqueue instead of kthread. Let's update
 the documentation and comments here and there.
 
 This patch mostly just replaces khubd with hub_wq. There are only few
 exceptions where the whole sentence was updated. These more complicated
 changes can be found in the following files:
 
  Documentation/usb/hotplug.txt
  drivers/net/usb/usbnet.c
  drivers/usb/core/hcd.c
  drivers/usb/host/ohci-hcd.c
  drivers/usb/host/xhci.c

Okay, here's a real issue.

 @@ -2042,7 +2042,7 @@ static void choose_devnum(struct usb_device *udev)
   int devnum;
   struct usb_bus  *bus = udev-bus;
  
 - /* If khubd ever becomes multithreaded, this will need a lock */
 + /* If hub_wq ever becomes multithreaded, this will need a lock */
   if (udev-wusb) {
   devnum = udev-portnum + 1;
   BUG_ON(test_bit(devnum, bus-devmap.devicemap));

You probably didn't notice when changing this comment.  But in fact,
workqueues _are_ multithreaded.  Therefore you need to add a lock to 
this routine.

Still, apart from these relatively minor issues, the series looks good.

Alan Stern

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


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

2014-09-17 Thread Andrew Bresticker
On Wed, Sep 17, 2014 at 8:41 AM, Stephen Warren swar...@wwwdotorg.org wrote:
 On 09/16/2014 05:51 PM, Andrew Bresticker wrote:

 On Tue, Sep 16, 2014 at 4:15 PM, Stephen Warren swar...@wwwdotorg.org
 wrote:

 On 09/16/2014 04:46 PM, Andrew Bresticker wrote:


 On Tue, Sep 16, 2014 at 9:57 AM, Andrew Bresticker
 abres...@chromium.org wrote:


 On Tue, Sep 16, 2014 at 8:26 AM, Stephen Warren swar...@wwwdotorg.org
 wrote:


 On 09/15/2014 01:30 PM, Andrew Bresticker wrote:



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



 ...



 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




 Hmm. That git server was quite reluctant to cough up its bits, but it
 did
 eventually.

 You'll also need the firmware Andrew Chew posted:
 https://patchwork.ozlabs.org/patch/384013/




 The XHCI driver can't load its firmware unless it's a module; if I
 make
 it
 built-in, it fails immediately with error -2 during Direct firmware
 loading. The driver needs to work with either immediate or deferred
 firmware loading.



 If you want the driver to be built-in, you'll either need to build the
 firmware in as well (i.e. EXTRA_FIRMWARE) or enable
 FW_LOADER_USER_HELPER_FALLBACK to load with userspace/uevent (though
 apparently this is deprecated).

 The following USB2 devices had problems:

 0b95:7720 ASIX Electronics Corp. AX88772

 [  489.140536] usb 1-3: new high-speed USB device number 81 using
 xhci-tegra
 [  489.260860] usb 1-3: device descriptor read/64, error -71
 [  489.370804] xhci-tegra 7009.usb: Setup ERROR: setup context
 command
 for slot 1.
 [  489.378463] usb 1-3: hub failed to enable device, error -22
 [  489.500531] usb 1-3: new high-speed USB device number 82 using
 xhci-tegra
 [  489.655708] usb 1-3: can't set config #1, error -71
 [  489.661231] usb 1-3: USB disconnect, device number 82
 [  489.940531] usb 1-3: new high-speed USB device number 83 using
 xhci-tegra
 [  490.060860] usb 1-3: device descriptor read/64, error -71
 [  490.170805] xhci-tegra 7009.usb: Setup ERROR: setup context
 command
 for slot 1.
 [  490.178462] usb 1-3: hub failed to enable device, error -22



 (repeats over and over)

 15a4:1336 Afatech Technologies, Inc. SDHC/MicroSD/MMC/MS/M2/CF/XD
 Flash
 Card
 Reader

 The power light comes on, and the activity light just keeps flashing
 fast.
 Usually the activity light flashes a couple times and then turns off.
 There
 is nothing in dmesg at all for this device.

 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

 Not detected. There is nothing in dmesg at all for this device.

 1bcf:0c31 Sunplus Innovation Technology Inc. SPIF30x Serial-ATA bridge

 Not detected. There is nothing in dmesg at all for this device.



 Thanks, I'll try to figure out what's going on here.



 Grr... this is due to the unfortunate UTMI pad controller design on
 Tegra.

 Here's the issue:  When UTMI pad 0 is assigned to the EHCI controller
 (as is currently the case on Jetson-TK1), the UTMI parameters from
 UTMIP_BIAS_CFG0 in the global UTMI pad register space are used
 regardless of the owner of the UTMI pads.  If pad 0 is assigned to the
 XUSB controller, then parameters in USB2_BIAS_PAD_CTL0 in the XUSB
 register space are used for all UTMI pads (again, regardless of
 ownership).

 I wasn't able to reproduce before because I always TFTP booted and
 U-Boot programs the UTMI parameters correctly when starting the EHCI
 controllers.  I suspect you and Tomeu were booting without starting
 the EHCI controllers and thus were stuck with the POR values.



 I am loading the kernel over the PCIe Ethernet on Jetson TK1. However,
 the
 U-Boot boot scripts do usb start first, so I would assume all the USB
 set
 is already done either way, before U-Boot attempts to probe USB devices.


 Interesting - just doing usb start made the difference for me.

 The easiest way to fix this is to just 

[GIT PULL] USB changes for v3.18 merge window

2014-09-17 Thread Felipe Balbi
Hi Greg,

Here's my pull request for v3.18. Now I'll ignore linux-usb for a while and get
a beer or two.

Anyway, let me know if you want anything to be changed, but I tested these
patches with beaglebone black and am437x SK.

cheers

The following changes since commit 9e82bf014195d6f0054982c463575cdce24292be:

  Linux 3.17-rc5 (2014-09-14 17:50:12 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v3.18

for you to fetch changes up to 5b484989a998074762281a1ae71b2d88f26f66d6:

  usb: gadget: gr_udc: Add bounce buffer to handle odd sized OUT requests 
(2014-09-16 10:01:45 -0500)


usb: changes for v3.18 merge window

Quite big pull request this time. Audio and UVC gadgets
can now be used with our configfs-based binding. We have
three PHY drivers being removed because a new one has been
added using new PHY framework.

Gadget framework got a new -reset callback preparing for
some other changes to come on next merge window.

A few new drivers came in as well; among those we have a
new UDC driver from Xilinx and two new glue layers for
DWC3 (ST and Qualcomm).

DWC3 also learned about tracepoints which will help debugging
quite a bit.

Other than that, a big series of non-critical fixes and
cleanups.

All patches have been on linux-next for quite a bit of time
and I boot tested these changes on platforms I have access
to and work with mainline.

Signed-of-by: Felipe Balbi ba...@ti.com


Amit Virdi (3):
  usb: gadget: zero: Add support for interrupt EP
  usbtest: Add interrupt EP testcases
  usb: gadget: zero: Fix warning generated by kbuild

Andreas Larsson (2):
  usb: gadget: udc_core: Use right kobj when calling sysfs_notify
  usb: gadget: gr_udc: Add bounce buffer to handle odd sized OUT requests

Andrzej Pietrasiewicz (23):
  usb: gadget: audio: Use container_of to free audio_dev
  usb: gadget: f_uac2: convert to new function interface with backward 
compatibility
  usb: gadget: audio: convert to new interface of f_uac2
  usb: gadget: f_uac2: remove compatibility layer
  usb: gadget: f_uac2: use usb_gstrings_attach
  usb: gadget: f_uac2: use defined constants as defaults
  usb: gadget: f_uac2: add configfs support
  usb: gadget: f_uac1: add function strings
  usb: gadget: f_uac1: prepare for separate compilation
  usb: gadget: f_uac1: convert to new function interface with backward 
compatibility
  usb: gadget: audio: convert to new interface of f_uac1
  usb: gadget: f_uac1: remove compatibility layer
  usb: gadget: f_uac1: use usb_gstrings_attach
  usb: gadget: f_uac1: use defined constants as defaults
  usb: gadget: f_uac1: add configfs support
  usb: gadget: f_uvc: fix potential memory leak
  usb: gadget: uvc: move module parameters from f_uvc
  usb: gadget: uvc: rename functions to avoid conflicts with host uvc
  usb: gadget: uvc: separately compile some components of f_uvc
  usb: gadget: f_uvc: convert f_uvc to new function interface
  usb: gadget: webcam: convert webcam to new interface of f_uvc
  usb: gadget: f_uvc: remove compatibility layer
  usb: gadget: f_uvc: use usb_gstrings_attach

Bartlomiej Zolnierkiewicz (3):
  usb: phy: samsung: remove old USB 2.0 PHY driver
  usb: phy: samsung: remove old USB 3.0 PHY driver
  usb: phy: samsung: remove old common USB PHY code

Dan Carpenter (1):
  usb: gadget: f_fs: signedness bug in __ffs_func_bind_do_descs()

Daniel Mack (6):
  usb: gadget: f_uac2: restructure some code in afunc_set_alt()
  usb: gadget: f_uac2: add short-hand for 'dev'
  usb: gadget: f_uac2: introduce agdev_to_uac2_opts
  usb: gadget: f_uac2: handle partial dma area wrap
  usb: gadget: f_uac2: send reasonably sized packets
  usb: musb: cppi41: tweak hrtimer values

Felipe Balbi (8):
  usb: phy: msm: mark msm_otg_mode_fops static
  usb: dwc3: move all string helper functions to debug.h
  usb: dwc3: debug: add dwc3_gadget_event_type_string
  usb: dwc3: gadget: cmd argument should always be unsigned
  usb: dwc3: add tracepoints to aid debugging
  Merge tag 'v3.17-rc4' into next
  Merge tag 'v3.17-rc5' into next
  usb: musb: dsps: kill OTG timer on suspend

Fengguang Wu (1):
  usb: gadget: uvc: uvc_alloc() can be static

Geert Uytterhoeven (1):
  usb: gadget: USB_RENESAS_USBHS_UDC should depend on HAS_DMA

Himangi Saraogi (1):
  usb: gadget: udc: use USB API functions rather than constants

Ivan T. Ivanov (2):
  usb: dwc3: qcom: Add device tree binding
  usb: dwc3: Add Qualcomm DWC3 glue layer driver

Jingoo Han (2):
  usb: dwc3: remove unnecessary OOM messages
  usb: phy: samsung: Remove unnecessary lines of register bit definitions

Laurent Pinchart (4):
  usb: gadget: f_uvc: 

[PATCH] storage: Add quirks for Entrega/Xircom USB to SCSI converters

2014-09-17 Thread Mark
Hi,

This should be applied instead of the previous patch I sent, storage: Add
quirk for Entrega/PortGear USB to SCSI Converter


This patch adds quirks for Entrega Technologies (later Xircom PortGear) USB-
SCSI converters. They use Shuttle Technology EUSB-01/EUSB-S1 chips. The
US_FL_SCM_MULT_TARG quirk is needed to allow multiple devices on the SCSI
chain to be accessed. Without it only the (single) device with SCSI ID 0
can be used.

The standalone converter sold by Entrega had model number U1-SC25. Xircom
acquired Entrega and re-branded the product line PortGear. The PortGear USB
to SCSI Converter (model PGSCSI) is internally identical to the Entrega
product, but later models may use a different USB ID. The Entrega-branded
units have USB ID 1645:0007, as does my Xircom PGSCSI, but the Windows and
Macintosh drivers also support 085A:0028.

Entrega also sold the Mac USB Dock, which provides two USB ports, a Mac
(8-pin mini-DIN) serial port and a SCSI port. It appears to the computer as
a four-port hub, USB-serial, and USB-SCSI converters. The USB-SCSI part may
have initially used the same ID as the standalone U1-SC25 (1645:0007), but
later production used 085A:0026.

My Xircom PortGear PGSCSI has bcdDevice=0x0100. Units with bcdDevice=0x0133
probably also exist.

This patch adds quirks for 1645:0007, 085A:0026 and 085A:0028. The Windows
driver INF file also mentions 085A:0032 PortStation SCSI Module, but I
couldn't find any mention of that actually existing in the wild; perhaps it
was cancelled before release?


Signed-off-by: Mark Knibbs ma...@clara.co.uk
---

diff -up linux-3.17-rc5/drivers/usb/storage/unusual_devs.h.orig 
linux-3.17-rc5/drivers/usb/storage/unusual_devs.h
--- linux-3.17-rc5/drivers/usb/storage/unusual_devs.h.orig  2014-09-15 
01:50:12.0 +0100
+++ linux-3.17-rc5/drivers/usb/storage/unusual_devs.h   2014-09-17 
18:56:19.0 +0100
@@ -1125,6 +1125,18 @@ UNUSUAL_DEV(  0x0851, 0x1543, 0x0200, 0x
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NOT_LOCKABLE),
 
+UNUSUAL_DEV(  0x085a, 0x0026, 0x0100, 0x0133,
+   Xircom,
+   PortGear USB-SCSI (Mac USB Dock),
+   USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
+   US_FL_SCM_MULT_TARG ),
+
+UNUSUAL_DEV(  0x085a, 0x0028, 0x0100, 0x0133,
+   Xircom,
+   PortGear USB to SCSI Converter,
+   USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
+   US_FL_SCM_MULT_TARG ),
+
 /* Submitted by Jan De Luyck l...@kcore.org */
 UNUSUAL_DEV(  0x08bd, 0x1100, 0x, 0x,
CITIZEN,
@@ -1964,6 +1976,14 @@ UNUSUAL_DEV(  0x152d, 0x2329, 0x0100, 0x
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
 
+/* Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
+ * and Mac USB Dock USB-SCSI */
+UNUSUAL_DEV(  0x1645, 0x0007, 0x0100, 0x0133,
+   Entrega Technologies,
+   USB to SCSI Converter,
+   USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
+   US_FL_SCM_MULT_TARG ),
+
 /* Reported by Robert Schedel r.sche...@yahoo.de
  * Note: this is a 'super top' device like the above 14cd/6600 device */
 UNUSUAL_DEV(  0x1652, 0x6600, 0x0201, 0x0201,
--
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: Fixed a few typos

2014-09-17 Thread Mickael Maison
Signed-off-by: Mickael Maison mickael.mai...@gmail.com
---
 drivers/usb/core/hcd.c   | 2 +-
 drivers/usb/musb/musb_regs.h | 2 +-
 drivers/usb/storage/realtek_cr.c | 4 ++--
 drivers/usb/storage/scsiglue.c   | 2 +-
 drivers/usb/storage/usb.c| 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 487abcf..56a0661 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1272,7 +1272,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep);
  * The usb core itself is however optimized for host controllers that can dma
  * using regular system memory - like pci devices doing bus mastering.
  *
- * To support host controllers with limited dma capabilites we provide dma
+ * To support host controllers with limited dma capabilities we provide dma
  * bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag.
  * For this to work properly the host controller code must first use the
  * function dma_declare_coherent_memory() to point out which memory area
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index b9bcda5..37122a4 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -577,7 +577,7 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
 {
/*
 * This register is invisible on Blackfin, actually the MUSB
-* RTL version of Blackfin is 1.9, so just harcode its value.
+* RTL version of Blackfin is 1.9, so just hardcode its value.
 */
return MUSB_HWVERS_1900;
 }
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 281be56..8591d89 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -115,7 +115,7 @@ struct rts51x_chip {
enum RTS51X_STAT state;
int support_auto_delink;
 #endif
-   /* used to back up the protocal choosen in probe1 phase */
+   /* used to back up the protocol chosen in probe1 phase */
proto_cmnd proto_handler_backup;
 };
 
@@ -925,7 +925,7 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
(unsigned long)chip);
fw5895_init(us);
 
-   /* enable autosuspend funciton of the usb device */
+   /* enable autosuspend function of the usb device */
usb_enable_autosuspend(us-pusb_dev);
 
return 0;
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 866b5df..0e400f3 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -241,7 +241,7 @@ static int slave_configure(struct scsi_device *sdev)
 
/* Some USB cardreaders have trouble reading an sdcard's last
 * sector in a larger then 1 sector read, since the performance
-* impact is negible we set this flag for all USB disks */
+* impact is negligible we set this flag for all USB disks */
sdev-last_sector_bug = 1;
 
/* Enable last-sector hacks for single-target devices using
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index cedb292..3aef968 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(quirks, supplemental list of device IDs and 
their quirks);
 /* The vendor name should be kept at eight characters or less, and
  * the product name should be kept at 16 characters or less. If a device
  * has the US_FL_FIX_INQUIRY flag, then the vendor and product names
- * normally generated by a device thorugh the INQUIRY response will be
+ * normally generated by a device through the INQUIRY response will be
  * taken from this list, and this is the reason for the above size
  * restriction. However, if the flag is not present, then you
  * are free to use as many characters as you like.
-- 
1.8.3.2

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


Re: [PATCH 3/3] uwb: remove UWB build dependency on PCI

2014-09-17 Thread Sergei Shtylyov

On 9/16/2014 11:40 PM, Thomas Pugliese wrote:


UWB does not require PCI to be enabled so remove build dependency.



Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
---
  drivers/uwb/Kconfig | 1 -
  1 file changed, 1 deletion(-)



diff --git a/drivers/uwb/Kconfig b/drivers/uwb/Kconfig
index 2431eed..c204094 100644
--- a/drivers/uwb/Kconfig
+++ b/drivers/uwb/Kconfig
@@ -4,7 +4,6 @@

  menuconfig UWB
tristate Ultra Wideband devices
-   depends on PCI
default n


   Could drop the default default as well. :-)

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] usb: Fixed a few typos

2014-09-17 Thread Felipe Balbi
On Wed, Sep 17, 2014 at 09:16:25PM +0200, Mickael Maison wrote:

you really wanna add a commit log here, even if obvious. Also,
scripts/get_maintainer.pl would've told you to Cc me as the MUSB
maintainer :-) No harm done though, just keep that in mind next time ;-)

 Signed-off-by: Mickael Maison mickael.mai...@gmail.com

After adding a commit log, for musb:

Acked-by: Felipe Balbi ba...@ti.com

 diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
 index b9bcda5..37122a4 100644
 --- a/drivers/usb/musb/musb_regs.h
 +++ b/drivers/usb/musb/musb_regs.h
 @@ -577,7 +577,7 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
  {
   /*
* This register is invisible on Blackfin, actually the MUSB
 -  * RTL version of Blackfin is 1.9, so just harcode its value.
 +  * RTL version of Blackfin is 1.9, so just hardcode its value.
*/
   return MUSB_HWVERS_1900;
  }

-- 
balbi


signature.asc
Description: Digital signature


[PATCH v4 3/9] of: Update Tegra XUSB pad controller binding for USB

2014-09-17 Thread Andrew Bresticker
Add new bindings used for USB support by the Tegra XUSB pad controller.
This includes additional PHY types, USB-specific pinconfig properties, etc.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
Changes from v2:
 - Added nvidia,otg-hs-curr-level-offset property.
 - Dropped -otg from VBUS supplies.
 - Added mbox-names property.
 - Removed extra whitespace.
Changes from v1:
 - Updated to use common mailbox bindings.
 - Made USB3 port-to-lane mappins a top-level binding rather than a pinconfig
   binding.
 - Add #defines for the padctl lanes.
---
 .../pinctrl/nvidia,tegra124-xusb-padctl.txt| 56 --
 include/dt-bindings/pinctrl/pinctrl-tegra-xusb.h   | 20 
 2 files changed, 72 insertions(+), 4 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt 
b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt
index 2f9c0bd..4a1b9475 100644
--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt
@@ -21,6 +21,18 @@ Required properties:
   - padctl
 - #phy-cells: Should be 1. The specifier is the index of the PHY to reference.
   See dt-bindings/pinctrl/pinctrl-tegra-xusb.h for the list of valid values.
+- mboxes: Must contain an entry for the XUSB mailbox channel.
+  See ../mailbox/mailbox.txt for details.
+- mbox-names: Must include the following entries:
+  - xusb
+
+Optional properties:
+---
+- vbus-{0,1,2}-supply: VBUS regulator for the corresponding UTMI pad.
+- vddio-hsic-supply: VDDIO regulator for the HSIC pads.
+- nvidia,usb3-port-{0,1}-lane: PCIe/SATA lane to which the corresponding USB3
+  port is mapped.  See dt-bindings/pinctrl/pinctrl-tegra-xusb.h for the list
+  of valid values.
 
 Lane muxing:
 
@@ -50,6 +62,17 @@ Optional properties:
   pin or group should be assigned to. Valid values for function names are
   listed below.
 - nvidia,iddq: Enables IDDQ mode of the lane. (0: no, 1: yes)
+- nvidia,usb2-port-num: USB2 port (0, 1, or 2) to which the lane is mapped.
+- nvidia,hsic-strobe-trim: HSIC strobe trimmer value.
+- nvidia,hsic-rx-strobe-trim: HSIC RX strobe trimmer value.
+- nvidia,hsic-rx-data-trim: HSIC RX data trimmer value.
+- nvidia,hsic-tx-rtune-n: HSIC TX RTUNEN value.
+- nvidia,hsic-tx-rtune-p: HSIC TX RTUNEP value.
+- nvidia,hsic-tx-slew-n: HSIC TX SLEWN value.
+- nvidia,hsic-tx-slew-p: HSIC TX SLEWP value.
+- nvidia,hsic-auto-term: Enables HSIC AUTO_TERM. (0: no, 1: yes)
+- nvidia,otg-hs-curr-level-offset: Offset to be applied to the pad's fused
+  HS_CURR_LEVEL value.
 
 Note that not all of these properties are valid for all lanes. Lanes can be
 divided into three groups:
@@ -58,18 +81,21 @@ divided into three groups:
 
 Valid functions for this group are: snps, xusb, uart, rsvd.
 
-The nvidia,iddq property does not apply to this group.
+The nvidia,otg-hs-curr-level-offset property only applies.
 
   - ulpi-0, hsic-0, hsic-1:
 
 Valid functions for this group are: snps, xusb.
 
-The nvidia,iddq property does not apply to this group.
+The nvidia,hsic-* properties apply only to the pins hsic-{0,1} when
+the function is xusb.
 
   - pcie-0, pcie-1, pcie-2, pcie-3, pcie-4, sata-0:
 
 Valid functions for this group are: pcie, usb3, sata, rsvd.
 
+The nvidia,usb2-port-num property only applies and is required when
+the function is usb3.
 
 Example:
 
@@ -82,6 +108,8 @@ SoC file extract:
reg = 0x0 0x7009f000 0x0 0x1000;
resets = tegra_car 142;
reset-names = padctl;
+   mboxes = xusb_mbox;
+   mbox-names = xusb;
 
#phy-cells = 1;
};
@@ -100,15 +128,35 @@ Board file extract:
 
...
 
+   usb@0,7009 {
+   ...
+
+   phys = padctl 5, padctl 6, padctl 7;
+   phy-names = utmi-1, utmi-2, usb3-0;
+
+   ...
+   }
+
+   ...
+
padctl: padctl@0,7009f000 {
pinctrl-0 = padctl_default;
pinctrl-names = default;
 
+   nvidia,usb3-port-0-lane = TEGRA_XUSB_PADCTL_PIN_PCIE_0;
+   vbus-2-supply = vdd_usb3_vbus;
+
padctl_default: pinmux {
-   usb3 {
-   nvidia,lanes = pcie-0, pcie-1;
+   otg {
+   nvidia,lanes = otg-1, otg-2;
+   nvidia,function = xusb;
+   };
+
+   usb3p0 {
+   nvidia,lanes = pcie-0;
nvidia,function = usb3;
nvidia,iddq = 0;
+   nvidia,usb2-port-num = 2;
};
 
pcie {
diff --git 

[PATCH v4 5/9] of: Add NVIDIA Tegra xHCI controller binding

2014-09-17 Thread Andrew Bresticker
Add device-tree binding documentation for the xHCI controller present
on Tegra124 and later SoCs.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Added mbox-names property.
Changes from v1:
 - Updated to use common mailbox bindings.
 - Added remaining XUSB-related clocks and resets.
 - Updated list of power supplies to be more accurate wrt to the hardware.
---
 .../bindings/usb/nvidia,tegra124-xhci.txt  | 104 +
 1 file changed, 104 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt
new file mode 100644
index 000..51a7751
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt
@@ -0,0 +1,104 @@
+NVIDIA Tegra xHCI controller
+
+
+The Tegra xHCI controller supports both USB2 and USB3 interfaces exposed
+by the Tegra XUSB pad controller.
+
+Required properties:
+
+ - compatible: Should be nvidia,tegra124-xhci.
+ - reg: Address and length of the register sets.  There should be three
+   entries in the following order: xHCI host registers, FPCI registers, and
+   IPFS registers.
+ - interrupts: xHCI host interrupt.
+ - clocks: Must contain an entry for each entry in clock-names.
+   See ../clock/clock-bindings.txt for details.
+ - clock-names: Must include the following entries:
+- xusb_host
+- xusb_host_src
+- xusb_dev
+- xusb_dev_src
+- xusb_falcon_src
+- xusb_ss
+- xusb_ss_src
+- xusb_ss_div2
+- xusb_hs_src
+- xusb_fs_src
+- pll_u_480m
+- clk_m
+- pll_e
+ - resets: Must contain an entry for each entry in reset-names.
+   See ../reset/reset.txt for details.
+ - reset-names: Must include the following entries:
+   - xusb_host
+   - xusb_dev
+   - xusb_ss
+   - xusb
+   Note that xusb_dev is the shared reset for xusb_dev and xusb_dev_src and
+   that xusb is the shared reset for xusb_{ss,hs,fs,falcon,host}_src.
+ - mboxes: Must contain an entry for the XUSB mailbox channel.
+   See ../mailbox/mailbox.txt for details.
+ - mbox-names: Must include the following entries:
+   - xusb
+
+Optional properties:
+
+ - phys: Must contain an entry for each entry in phy-names.
+   See ../phy/phy-bindings.txt for details.
+ - phy-names: Should include an entry for each PHY used by the controller.
+   May be a subset of the following:
+- utmi-{0,1,2}
+- hsic-{0,1}
+- usb3-{0,1}
+ - avddio-pex-supply: PCIe/USB3 analog logic power supply.  Must supply 1.05V.
+ - dvddio-pex-supply: PCIe/USB3 digital logic power supply.  Must supply 1.05V.
+ - avdd-usb-supply: USB controller power supply.  Must supply 3.3V.
+ - avdd-pll-utmip-supply: UTMI PLL power supply.  Must supply 1.8V.
+ - avdd-pll-erefe-supply: PLLE reference PLL power supply.  Must supply 1.05V.
+ - avdd-pex-pll-supply: PCIe/USB3 PLL power supply.  Must supply 1.05V.
+ - hvdd-pex-supply: High-voltage PCIe/USB3 power supply.  Must supply 3.3V.
+ - hvdd-pex-plle-supply: High-voltage PLLE power supply.  Must supply 3.3V.
+
+Example:
+
+   usb@0,7009 {
+   compatible = nvidia,tegra124-xhci;
+   reg = 0x0 0x7009 0x0 0x8000,
+ 0x0 0x70098000 0x0 0x1000,
+ 0x0 0x70099000 0x0 0x1000;
+   interrupts = GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH;
+   clocks = tegra_car TEGRA124_CLK_XUSB_HOST,
+tegra_car TEGRA124_CLK_XUSB_HOST_SRC,
+tegra_car TEGRA124_CLK_XUSB_DEV,
+tegra_car TEGRA124_CLK_XUSB_DEV_SRC,
+tegra_car TEGRA124_CLK_XUSB_FALCON_SRC,
+tegra_car TEGRA124_CLK_XUSB_SS,
+tegra_car TEGRA124_CLK_XUSB_SS_DIV2,
+tegra_car TEGRA124_CLK_XUSB_SS_SRC,
+tegra_car TEGRA124_CLK_XUSB_HS_SRC,
+tegra_car TEGRA124_CLK_XUSB_FS_SRC,
+tegra_car TEGRA124_CLK_PLL_U_480M,
+tegra_car TEGRA124_CLK_CLK_M,
+tegra_car TEGRA124_CLK_PLL_E;
+   clock-names = xusb_host, xusb_host_src, xusb_dev,
+ xusb_dev_src, xusb_falcon_src, xusb_ss,
+ xusb_ss_div2, xusb_ss_src, xusb_hs_src,
+ xusb_fs_src, pll_u_480m, clk_m, pll_e;
+   resets = tegra_car 89, tegra_car 95, tegra_car 156,
+tegra_car 143;
+   reset-names = xusb_host, xusb_dev, xusb_ss, xusb;
+   mboxes = xusb_mbox;
+   mbox-names = xusb;
+   phys = padctl TEGRA_XUSB_PADCTL_UTMI_P1, /* mini-PCIe USB */
+  padctl 

[PATCH v4 6/9] usb: xhci: Add NVIDIA Tegra xHCI host-controller driver

2014-09-17 Thread Andrew Bresticker
Add support for the on-chip xHCI host controller present on Tegra SoCs.

The driver is currently very basic: it loads the controller with its
firmware, starts the controller, and is able to service messages sent
by the controller's firmware.  The hardware also supports device mode
as well as powergating of the SuperSpeed and host-controller logic
when not in use, but support for these is not yet implemented.

Based on work by:
  Ajay Gupta aj...@nvidia.com
  Bharath Yadav bya...@nvidia.com

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
Changes from v3:
 - Used 32-bit DMA mask (platforms may have  32-bit physical address space
   and  64-bit dma_addr_t).
 - Moved comment about SET_BW command.
Changes from v2:
 - Added filtering out of non-host mailbox messages.
 - Removed MODULE_ALIAS.
Changes from v1:
 - Updated to use common mailbox API.
 - Fixed up so that the driver can be built and used as a module.
 - Incorporated review feedback from Stephen.
 - Misc. cleanups.
---
 drivers/usb/host/Kconfig  |   9 +
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/xhci-tegra.c | 907 ++
 3 files changed, 917 insertions(+)
 create mode 100644 drivers/usb/host/xhci-tegra.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f5a5831..1fffbed 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -50,6 +50,15 @@ config USB_XHCI_RCAR
  Say 'Y' to enable the support for the xHCI host controller
  found in Renesas R-Car ARM SoCs.
 
+config USB_XHCI_TEGRA
+   tristate NVIDIA Tegra XHCI support
+   depends on ARCH_TEGRA
+   select MAILBOX
+   select FW_LOADER
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ found in NVIDIA Tegra124 and later SoCs.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 702d9b7..0a30e26 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_PCI) += pci-quirks.o
 
 obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
 obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
+obj-$(CONFIG_USB_XHCI_TEGRA)   += xhci-tegra.o
 
 obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
new file mode 100644
index 000..82d275f
--- /dev/null
+++ b/drivers/usb/host/xhci-tegra.c
@@ -0,0 +1,907 @@
+/*
+ * NVIDIA Tegra xHCI host controller driver
+ *
+ * Copyright (C) 2014 NVIDIA Corporation
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/dma-mapping.h
+#include linux/firmware.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/mailbox_client.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/pm.h
+#include linux/regulator/consumer.h
+#include linux/reset.h
+#include linux/slab.h
+#include linux/workqueue.h
+
+#include soc/tegra/xusb.h
+
+#include xhci.h
+
+#define TEGRA_XHCI_SS_CLK_HIGH_SPEED 12000
+#define TEGRA_XHCI_SS_CLK_LOW_SPEED 1200
+
+/* FPCI CFG registers */
+#define XUSB_CFG_1 0x004
+#define  XUSB_IO_SPACE_EN  BIT(0)
+#define  XUSB_MEM_SPACE_EN BIT(1)
+#define  XUSB_BUS_MASTER_ENBIT(2)
+#define XUSB_CFG_4 0x010
+#define  XUSB_BASE_ADDR_SHIFT  15
+#define  XUSB_BASE_ADDR_MASK   0x1
+#define XUSB_CFG_ARU_C11_CSBRANGE  0x41c
+#define XUSB_CFG_CSB_BASE_ADDR 0x800
+
+/* IPFS registers */
+#define IPFS_XUSB_HOST_CONFIGURATION_0 0x180
+#define  IPFS_EN_FPCI  BIT(0)
+#define IPFS_XUSB_HOST_INTR_MASK_0 0x188
+#define  IPFS_IP_INT_MASK  BIT(16)
+#define IPFS_XUSB_HOST_CLKGATE_HYSTERESIS_00x1bc
+
+#define CSB_PAGE_SELECT_MASK   0x7f
+#define CSB_PAGE_SELECT_SHIFT  9
+#define CSB_PAGE_OFFSET_MASK   0x1ff
+#define CSB_PAGE_SELECT(addr)  ((addr)  (CSB_PAGE_SELECT_SHIFT) \
+CSB_PAGE_SELECT_MASK)
+#define CSB_PAGE_OFFSET(addr)  ((addr)  CSB_PAGE_OFFSET_MASK)
+
+/* Falcon CSB registers */
+#define XUSB_FALC_CPUCTL   0x100
+#define  CPUCTL_STARTCPU   BIT(1)
+#define  CPUCTL_STATE_HALTED   BIT(4)
+#define XUSB_FALC_BOOTVEC  0x104
+#define XUSB_FALC_DMACTL   0x10c
+#define 

[PATCH v4 9/9] ARM: tegra: venice2: Add xHCI support

2014-09-17 Thread Andrew Bresticker
Assign ports previously owned by the EHCI controllers to the xHCI
controller.  There are two external USB ports (UTMI ports 0/2 and
USB3 ports 0/1) and an internal USB port (UTMI port 1).  PCIe lanes
0 and 1 are used by the USB3 ports.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Updated VBUS power supply names.
Changes from v1:
 - Updated USB power supplies.
---
 arch/arm/boot/dts/tegra124-venice2.dts | 79 ++
 1 file changed, 51 insertions(+), 28 deletions(-)

diff --git a/arch/arm/boot/dts/tegra124-venice2.dts 
b/arch/arm/boot/dts/tegra124-venice2.dts
index 70ad91d..1cc3be2 100644
--- a/arch/arm/boot/dts/tegra124-venice2.dts
+++ b/arch/arm/boot/dts/tegra124-venice2.dts
@@ -736,7 +736,7 @@
regulator-always-on;
};
 
-   ldo0 {
+   avdd_1v05_run: ldo0 {
regulator-name = +1.05V_RUN_AVDD;
regulator-min-microvolt = 105;
regulator-max-microvolt = 105;
@@ -878,6 +878,56 @@
status = okay;
};
 
+   usb@0,7009 {
+   status = okay;
+   phys = padctl TEGRA_XUSB_PADCTL_UTMI_P0, /* 1st USB A */
+  padctl TEGRA_XUSB_PADCTL_UTMI_P1, /* Internal USB */
+  padctl TEGRA_XUSB_PADCTL_UTMI_P2, /* 2nd USB A */
+  padctl TEGRA_XUSB_PADCTL_USB3_P0, /* 1st USB A */
+  padctl TEGRA_XUSB_PADCTL_USB3_P1; /* 2nd USB A */
+   phy-names = utmi-0, utmi-1, utmi-2, usb3-0, usb3-1;
+   avddio-pex-supply = vdd_1v05_run;
+   dvddio-pex-supply = vdd_1v05_run;
+   avdd-usb-supply = vdd_3v3_lp0;
+   avdd-pll-utmip-supply = vddio_1v8;
+   avdd-pll-erefe-supply = avdd_1v05_run;
+   avdd-pex-pll-supply = vdd_1v05_run;
+   hvdd-pex-supply = vdd_3v3_lp0;
+   hvdd-pex-plle-supply = vdd_3v3_lp0;
+   };
+
+   padctl@0,7009f000 {
+   pinctrl-0 = padctl_default;
+   pinctrl-names = default;
+
+   vbus-0-supply = vdd_usb1_vbus;
+   vbus-1-supply = vdd_run_cam;
+   vbus-2-supply = vdd_usb3_vbus;
+   nvidia,usb3-port-0-lane = TEGRA_XUSB_PADCTL_PIN_PCIE_0;
+   nvidia,usb3-port-1-lane = TEGRA_XUSB_PADCTL_PIN_PCIE_1;
+
+   padctl_default: pinmux {
+   otg {
+   nvidia,lanes = otg-0, otg-1, otg-2;
+   nvidia,function = xusb;
+   };
+
+   usb3p0 {
+   nvidia,lanes = pcie-0;
+   nvidia,function = usb3;
+   nvidia,iddq = 0;
+   nvidia,usb2-port-num = 0;
+   };
+
+   usb3p1 {
+   nvidia,lanes = pcie-1;
+   nvidia,function = usb3;
+   nvidia,iddq = 0;
+   nvidia,usb2-port-num = 2;
+   };
+   };
+   };
+
sdhci@0,700b0400 {
cd-gpios = gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH;
power-gpios = gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH;
@@ -898,33 +948,6 @@
};
};
 
-   usb@0,7d00 {
-   status = okay;
-   };
-
-   usb-phy@0,7d00 {
-   status = okay;
-   vbus-supply = vdd_usb1_vbus;
-   };
-
-   usb@0,7d004000 {
-   status = okay;
-   };
-
-   usb-phy@0,7d004000 {
-   status = okay;
-   vbus-supply = vdd_run_cam;
-   };
-
-   usb@0,7d008000 {
-   status = okay;
-   };
-
-   usb-phy@0,7d008000 {
-   status = okay;
-   vbus-supply = vdd_usb3_vbus;
-   };
-
backlight: backlight {
compatible = pwm-backlight;
 
-- 
2.1.0.rc2.206.gedb03e5

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


[PATCH v4 7/9] ARM: tegra: Add Tegra124 XUSB mailbox and xHCI controller

2014-09-17 Thread Andrew Bresticker
Add nodes for the Tegra XUSB mailbox and Tegra xHCI controller and
add the PHY mailbox channel to the XUSB padctl node.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Dropped channel specifier from mailbox bindings.
 - Added mbox-names properties.
Changes from v1:
 - Updated to use common mailbox bindings.
 - Added remaining clocks/resets.
---
 arch/arm/boot/dts/tegra124.dtsi | 41 +
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi
index 03916ef..89afd45 100644
--- a/arch/arm/boot/dts/tegra124.dtsi
+++ b/arch/arm/boot/dts/tegra124.dtsi
@@ -495,11 +495,52 @@
status = disabled;
};
 
+   usb@0,7009 {
+   compatible = nvidia,tegra124-xhci;
+   reg = 0x0 0x7009 0x0 0x8000,
+ 0x0 0x70098000 0x0 0x1000,
+ 0x0 0x70099000 0x0 0x1000;
+   interrupts = GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH;
+   clocks = tegra_car TEGRA124_CLK_XUSB_HOST,
+tegra_car TEGRA124_CLK_XUSB_HOST_SRC,
+tegra_car TEGRA124_CLK_XUSB_DEV,
+tegra_car TEGRA124_CLK_XUSB_DEV_SRC,
+tegra_car TEGRA124_CLK_XUSB_FALCON_SRC,
+tegra_car TEGRA124_CLK_XUSB_SS,
+tegra_car TEGRA124_CLK_XUSB_SS_DIV2,
+tegra_car TEGRA124_CLK_XUSB_SS_SRC,
+tegra_car TEGRA124_CLK_XUSB_HS_SRC,
+tegra_car TEGRA124_CLK_XUSB_FS_SRC,
+tegra_car TEGRA124_CLK_PLL_U_480M,
+tegra_car TEGRA124_CLK_CLK_M,
+tegra_car TEGRA124_CLK_PLL_E;
+   clock-names = xusb_host, xusb_host_src, xusb_dev,
+ xusb_dev_src, xusb_falcon_src, xusb_ss,
+ xusb_ss_div2, xusb_ss_src, xusb_hs_src,
+ xusb_fs_src, pll_u_480m, clk_m, pll_e;
+   resets = tegra_car 89, tegra_car 95, tegra_car 156,
+tegra_car 143;
+   reset-names = xusb_host, xusb_dev, xusb_ss, xusb;
+   mboxes = xusb_mbox;
+   mbox-names = xusb;
+   status = disabled;
+   };
+
+   xusb_mbox: mailbox@0,70098000 {
+   compatible = nvidia,tegra124-xusb-mbox;
+   reg = 0x0 0x70098000 0x0 0x1000;
+   interrupts = GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH;
+
+   #mbox-cells = 0;
+   };
+
padctl: padctl@0,7009f000 {
compatible = nvidia,tegra124-xusb-padctl;
reg = 0x0 0x7009f000 0x0 0x1000;
resets = tegra_car 142;
reset-names = padctl;
+   mboxes = xusb_mbox;
+   mbox-names = xusb;
 
#phy-cells = 1;
};
-- 
2.1.0.rc2.206.gedb03e5

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


[PATCH v4 8/9] ARM: tegra: jetson-tk1: Add xHCI support

2014-09-17 Thread Andrew Bresticker
Assign USB ports previously owned by the EHCI controllers to the xHCI
controller.  There is a mini-PCIe USB port (UTMI port 1) and a USB A
connector (UTMI port 2, USB3 port 0).  PCIe lane 0 is used for USB3
port 0.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
Changes from v3:
 - Assigned otg-0 to XUSB to avoid USB2.0 flakiness.
Changes from v2:
 - Updated VBUS power supply names.
Changes from v1:
 - Updated USB power supplies.
---
 arch/arm/boot/dts/tegra124-jetson-tk1.dts | 48 +--
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts 
b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
index 624b0fb..dacb0d0 100644
--- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts
+++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
@@ -1515,7 +1515,7 @@
regulator-always-on;
};
 
-   ldo0 {
+   avdd_1v05_run: ldo0 {
regulator-name = +1.05V_RUN_AVDD;
regulator-min-microvolt = 105;
regulator-max-microvolt = 105;
@@ -1619,15 +1619,40 @@
nvidia,sys-clock-req-active-high;
};
 
+   usb@0,7009 {
+   status = okay;
+   phys = padctl TEGRA_XUSB_PADCTL_UTMI_P1, /* mini-PCIe USB */
+  padctl TEGRA_XUSB_PADCTL_UTMI_P2, /* USB A */
+  padctl TEGRA_XUSB_PADCTL_USB3_P0; /* USB A */
+   phy-names = utmi-1, utmi-2, usb3-0;
+   avddio-pex-supply = vdd_1v05_run;
+   dvddio-pex-supply = vdd_1v05_run;
+   avdd-usb-supply = vdd_3v3_lp0;
+   avdd-pll-utmip-supply = vddio_1v8;
+   avdd-pll-erefe-supply = avdd_1v05_run;
+   avdd-pex-pll-supply = vdd_1v05_run;
+   hvdd-pex-supply = vdd_3v3_lp0;
+   hvdd-pex-plle-supply = vdd_3v3_lp0;
+   };
+
padctl@0,7009f000 {
pinctrl-0 = padctl_default;
pinctrl-names = default;
 
+   vbus-2-supply = vdd_usb3_vbus;
+   nvidia,usb3-port-0-lane = TEGRA_XUSB_PADCTL_PIN_PCIE_0;
+
padctl_default: pinmux {
+   otg {
+   nvidia,lanes = otg-0, otg-1, otg-2;
+   nvidia,function = xusb;
+   };
+
usb3 {
-   nvidia,lanes = pcie-0, pcie-1;
+   nvidia,lanes = pcie-0;
nvidia,function = usb3;
nvidia,iddq = 0;
+   nvidia,usb2-port-num = 2;
};
 
pcie {
@@ -1668,25 +1693,6 @@
};
};
 
-   /* mini-PCIe USB */
-   usb@0,7d004000 {
-   status = okay;
-   };
-
-   usb-phy@0,7d004000 {
-   status = okay;
-   };
-
-   /* USB A connector */
-   usb@0,7d008000 {
-   status = okay;
-   };
-
-   usb-phy@0,7d008000 {
-   status = okay;
-   vbus-supply = vdd_usb3_vbus;
-   };
-
clocks {
compatible = simple-bus;
#address-cells = 1;
-- 
2.1.0.rc2.206.gedb03e5

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


[PATCH v4 1/9] of: Add NVIDIA Tegra XUSB mailbox binding

2014-09-17 Thread Andrew Bresticker
Add device-tree bindings for the Tegra XUSB mailbox which will be used
for communication between the Tegra xHCI controller's firmware and the
host processor.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Dropped channel specifier.
 - Added pointer to mailbox documentation.
Changes from v1:
 - Updated to use common mailbox bindings.
---
 .../bindings/mailbox/nvidia,tegra124-xusb-mbox.txt | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt

diff --git 
a/Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt 
b/Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt
new file mode 100644
index 000..b35ea6e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt
@@ -0,0 +1,32 @@
+NVIDIA Tegra XUSB mailbox
+=
+
+The Tegra XUSB mailbox is used by the Tegra xHCI controller's firmware to
+communicate requests to the host and PHY drivers.
+
+Refer to ./mailbox.txt for generic information about mailbox device-tree
+bindings.
+
+Required properties:
+
+ - compatible: Should be nvidia,tegra124-xusb-mbox.
+ - reg: Address and length of the XUSB FPCI registers.
+ - interrupts: XUSB mailbox interrupt.
+ - #mbox-cells: Should be 0.  There is only one physical channel.
+
+Example:
+
+   xusb_mbox: mailbox@0,70098000 {
+   compatible = nvidia,tegra124-xusb-mbox;
+   reg = 0x0 0x70098000 0x0 0x1000;
+   interrupts = GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH;
+
+   #mbox-cells = 0;
+   };
+
+   usb@0,7009 {
+   ...
+   mboxes = xusb_mbox;
+   mbox-names = xusb;
+   ...
+   };
-- 
2.1.0.rc2.206.gedb03e5

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


[PATCH v4 4/9] pinctrl: tegra-xusb: Add USB PHY support

2014-09-17 Thread Andrew Bresticker
In addition to the PCIe and SATA PHYs, the XUSB pad controller also
supports 3 UTMI, 2 HSIC, and 2 USB3 PHYs.  Each USB3 PHY uses a single
PCIe or SATA lane and is mapped to one of the three UTMI ports.

The xHCI controller will also send messages intended for the PHY driver,
so request and listen for messages on the mailbox's PHY channel.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Acked-by: Linus Walleij linus.wall...@linaro.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Added support for nvidia,otg-hs-curr-level-offset property.
 - Moved mailbox request handling to workqueue.
 - Added filtering out of non-PHY mailbox messages.
 - Dropped -otg from VBUS supplies.
Changes from v1:
 - Updated to use common mailbox API.
 - Added SATA PHY enable sequence for USB3 ports using the SATA lane.
 - Made USB3 port-to-lane mappins a top-level binding rather than a pinconfig
   binding.
---
 drivers/pinctrl/Kconfig  |1 +
 drivers/pinctrl/pinctrl-tegra-xusb.c | 1233 +-
 include/soc/tegra/xusb.h |7 +
 3 files changed, 1213 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index bfd2c2e..d5bc4f5 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -265,6 +265,7 @@ config PINCTRL_TEGRA_XUSB
select GENERIC_PHY
select PINCONF
select PINMUX
+   select MAILBOX
 
 config PINCTRL_TZ1090
bool Toumaz Xenif TZ1090 pin control driver
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c 
b/drivers/pinctrl/pinctrl-tegra-xusb.c
index e641b42..0618be5 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -13,23 +13,54 @@
 
 #include linux/delay.h
 #include linux/io.h
+#include linux/mailbox_client.h
 #include linux/module.h
 #include linux/of.h
 #include linux/phy/phy.h
 #include linux/pinctrl/pinctrl.h
 #include linux/pinctrl/pinmux.h
 #include linux/platform_device.h
+#include linux/regulator/consumer.h
 #include linux/reset.h
+#include linux/workqueue.h
+
+#include soc/tegra/fuse.h
+#include soc/tegra/xusb.h
 
 #include dt-bindings/pinctrl/pinctrl-tegra-xusb.h
 
 #include core.h
 #include pinctrl-utils.h
 
+#define FUSE_SKU_CALIB_HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? 15 : 0)
+#define FUSE_SKU_CALIB_HS_CURR_LEVEL_PAD_MASK 0x3f
+#define FUSE_SKU_CALIB_HS_IREF_CAP_SHIFT 13
+#define FUSE_SKU_CALIB_HS_IREF_CAP_MASK 0x3
+#define FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_SHIFT 11
+#define FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_MASK 0x3
+#define FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_SHIFT 7
+#define FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_MASK 0xf
+
+#define XUSB_PADCTL_USB2_PORT_CAP 0x008
+#define XUSB_PADCTL_USB2_PORT_CAP_PORTX_CAP_SHIFT(x) ((x) * 4)
+#define XUSB_PADCTL_USB2_PORT_CAP_PORT_CAP_MASK 0x3
+#define XUSB_PADCTL_USB2_PORT_CAP_DISABLED 0x0
+#define XUSB_PADCTL_USB2_PORT_CAP_HOST 0x1
+#define XUSB_PADCTL_USB2_PORT_CAP_DEVICE 0x2
+#define XUSB_PADCTL_USB2_PORT_CAP_OTG 0x3
+
+#define XUSB_PADCTL_SS_PORT_MAP 0x014
+#define XUSB_PADCTL_SS_PORT_MAP_PORTX_SHIFT(x) ((x) * 4)
+#define XUSB_PADCTL_SS_PORT_MAP_PORT_MASK 0x7
+
 #define XUSB_PADCTL_ELPG_PROGRAM 0x01c
 #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_VCORE_DOWN (1  26)
 #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN_EARLY (1  25)
 #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN (1  24)
+#define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_VCORE_DOWN(x) (1  (18 + (x) * 4))
+#define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN_EARLY(x) \
+   (1  (17 + (x) * 4))
+#define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN(x) (1  (16 + (x) * 4))
 
 #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1 0x040
 #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL0_LOCKDET (1  19)
@@ -41,17 +72,136 @@
 #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_EN (1  5)
 #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_SEL (1  4)
 
+#define XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(x) (0x058 + (x) * 4)
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_SHIFT 24
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_MASK 0xff
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT 16
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_MASK 0x3f
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT 8
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_MASK 0x3f
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_SHIFT 8
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_MASK 0x
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_SHIFT 4
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_MASK 0x7
+
+#define XUSB_PADCTL_IOPHY_USB3_PADX_CTL4(x) (0x068 + (x) * 4)
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT 24
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_MASK 0x1f
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT 16
+#define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_MASK 0x7f
+
+#define XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL2(x) ((x)  2 ? 0x078 + (x) * 4 : 

[PATCH v4 0/9] Tegra xHCI support

2014-09-17 Thread Andrew Bresticker
This series adds support for xHCI on NVIDIA Tegra SoCs.  This includes:
 - patches 1 and 2: adding a driver for the mailbox used to communicate
   with the xHCI controller's firmware,
 - patches 3 and 4: extending the XUSB pad controller driver to support
   the USB PHY types (UTMI, HSIC, and USB3),
 - patches 5 and 6: adding a xHCI host-controller driver, and
 - patches 7, 8, and 9: updating the relevant DT files.

The PHY and host drivers have compile-time dependencies on the mailbox
driver, and the host driver has compile-time dependencies on the PHY
driver.  It is probably best if these all get merged through the Tegra
tree.  This series still needs ACKs from the relevant maintainers for
the mailbox and XHCI host drivers and their device-tree bindings.

Based on 3.17-rc5, Jassi Brar's common mailbox framework [0], and my
xHCI modules series [1].  I've published a branch [2] with all the
dependencies for those that want to test this.

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 [3].

Notes:
 - HSIC support is mostly untested and I think there are still some issues
   to work out there.  I do have a Tegra124 board with a HSIC hub so I'll
   try to sort those out later.
 - The XUSB padctl driver doesn't play nice with the existing Tegra USB2.0
   PHY driver, so all ports should be assigned to the XHCI controller.

Based on work by:
  a lot of people, but from what I can tell from the L4T tree [4], the
  original authors of the Tegra xHCI driver are:
Ajay Gupta aj...@nvidia.com
Bharath Yadav bya...@nvidia.com

Changes from v3:
 - Fixed USB2.0 flakiness on Jetson-TK1.
 - Switched to 32-bit DMA mask for host.
 - Addressed Stephen's review comments.

Chagnes from v2:
 - Dropped mailbox channel specifier.  The mailbox driver allocates virtual
   channels backed by the single physical channel.
 - Added support for HS_CURR_LEVEL adjustment pinconfig property, which
   will be required for the Blaze board.
 - Addressed Stephen's review comments.

Changes from v1:
 - Converted mailbox driver to use the common mailbox framework.
 - Fixed up host driver so that it can now be built and used as a module.
 - Addressed Stephen's review comments.
 - Misc. cleanups.

Changes from RFC:
 - Dropped Tegra114 support.
 - Split out mailbox into separate driver.
 - Stopped using child xhci-plat device in xHCI host-controller driver.
 - Added PHY support to Thierry's XUSB padctl driver instead of in a separate
   USB PHY driver.
 - Added Jetson TK1 support.
 - Misc. cleanups.

[0] https://lkml.org/lkml/2014/8/1/200
[1] https://lkml.org/lkml/2014/8/18/504
[2] https://github.com/abrestic/linux/tree/tegra-xhci-v4
[3] https://patchwork.ozlabs.org/patch/384013/
[4] git://nv-tegra.nvidia.com/linux-3.10.git

Andrew Bresticker (9):
  of: Add NVIDIA Tegra XUSB mailbox binding
  mailbox: Add NVIDIA Tegra XUSB mailbox driver
  of: Update Tegra XUSB pad controller binding for USB
  pinctrl: tegra-xusb: Add USB PHY support
  of: Add NVIDIA Tegra xHCI controller binding
  usb: xhci: Add NVIDIA Tegra xHCI host-controller driver
  ARM: tegra: Add Tegra124 XUSB mailbox and xHCI controller
  ARM: tegra: jetson-tk1: Add xHCI support
  ARM: tegra: venice2: Add xHCI support

 .../bindings/mailbox/nvidia,tegra124-xusb-mbox.txt |   32 +
 .../pinctrl/nvidia,tegra124-xusb-padctl.txt|   56 +-
 .../bindings/usb/nvidia,tegra124-xhci.txt  |  104 ++
 arch/arm/boot/dts/tegra124-jetson-tk1.dts  |   48 +-
 arch/arm/boot/dts/tegra124-venice2.dts |   79 +-
 arch/arm/boot/dts/tegra124.dtsi|   41 +
 drivers/mailbox/Kconfig|3 +
 drivers/mailbox/Makefile   |2 +
 drivers/mailbox/tegra-xusb-mailbox.c   |  290 +
 drivers/pinctrl/Kconfig|1 +
 drivers/pinctrl/pinctrl-tegra-xusb.c   | 1233 +++-
 drivers/usb/host/Kconfig   |9 +
 drivers/usb/host/Makefile  |1 +
 drivers/usb/host/xhci-tegra.c  |  907 ++
 include/dt-bindings/pinctrl/pinctrl-tegra-xusb.h   |   20 +
 include/soc/tegra/xusb.h   |   53 +
 16 files changed, 2798 insertions(+), 81 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/mailbox/nvidia,tegra124-xusb-mbox.txt
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra124-xhci.txt
 create mode 100644 drivers/mailbox/tegra-xusb-mailbox.c
 create mode 100644 drivers/usb/host/xhci-tegra.c
 create mode 100644 include/soc/tegra/xusb.h

-- 
2.1.0.rc2.206.gedb03e5

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


[PATCH v4 2/9] mailbox: Add NVIDIA Tegra XUSB mailbox driver

2014-09-17 Thread Andrew Bresticker
The Tegra xHCI controller's firmware communicates requests to the host
processor through a mailbox interface.  While there is only a single
physical channel, messages sent by the controller can be divided
into two groups: those intended for the PHY driver and those intended
for the host-controller driver.  The requesting driver is assigned
one of two virtual channels when the single physical channel is
requested.  All incoming messages are sent to both virtual channels.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Stephen Warren swar...@nvidia.com
---
No changes from v3.
Changes from v2:
 - Fixed mailbox IRQ vs. channel alloc/free race.
 - Renamed defines to match TRM.
 - Dropped channel specifier and instead allocated virtual channels as they
   were requested.
 - Removed MODULE_ALIAS.
Changes from v1:
 - Converted to common mailbox framework.
 - Removed useless polling sequences in TX path.
 - Moved xusb include from linux/ to soc/tegra/
---
 drivers/mailbox/Kconfig  |   3 +
 drivers/mailbox/Makefile |   2 +
 drivers/mailbox/tegra-xusb-mailbox.c | 290 +++
 include/soc/tegra/xusb.h |  46 ++
 4 files changed, 341 insertions(+)
 create mode 100644 drivers/mailbox/tegra-xusb-mailbox.c
 create mode 100644 include/soc/tegra/xusb.h

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 9fd9c67..97369c2 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -33,4 +33,7 @@ config OMAP_MBOX_KFIFO_SIZE
  Specify the default size of mailbox's kfifo buffers (bytes).
  This can also be changed at runtime (via the mbox_kfifo_size
  module parameter).
+
+config TEGRA_XUSB_MBOX
+   def_bool y if ARCH_TEGRA
 endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 94ed7ce..7f0af9c 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -5,3 +5,5 @@ obj-$(CONFIG_MAILBOX)   += mailbox.o
 obj-$(CONFIG_PL320_MBOX)   += pl320-ipc.o
 
 obj-$(CONFIG_OMAP2PLUS_MBOX)   += omap-mailbox.o
+
+obj-$(CONFIG_TEGRA_XUSB_MBOX)  += tegra-xusb-mailbox.o
diff --git a/drivers/mailbox/tegra-xusb-mailbox.c 
b/drivers/mailbox/tegra-xusb-mailbox.c
new file mode 100644
index 000..2d87b8a
--- /dev/null
+++ b/drivers/mailbox/tegra-xusb-mailbox.c
@@ -0,0 +1,290 @@
+/*
+ * NVIDIA Tegra XUSB mailbox driver
+ *
+ * Copyright (C) 2014 NVIDIA Corporation
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/mailbox_controller.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/slab.h
+
+#include soc/tegra/xusb.h
+
+#define XUSB_CFG_ARU_MBOX_CMD  0xe4
+#define  MBOX_DEST_FALCBIT(27)
+#define  MBOX_DEST_PME BIT(28)
+#define  MBOX_DEST_SMI BIT(29)
+#define  MBOX_DEST_XHCIBIT(30)
+#define  MBOX_INT_EN   BIT(31)
+#define XUSB_CFG_ARU_MBOX_DATA_IN  0xe8
+#define  CMD_DATA_SHIFT0
+#define  CMD_DATA_MASK 0xff
+#define  CMD_TYPE_SHIFT24
+#define  CMD_TYPE_MASK 0xff
+#define XUSB_CFG_ARU_MBOX_DATA_OUT 0xec
+#define XUSB_CFG_ARU_MBOX_OWNER0xf0
+#define  MBOX_OWNER_NONE   0
+#define  MBOX_OWNER_FW 1
+#define  MBOX_OWNER_SW 2
+#define XUSB_CFG_ARU_SMI_INTR  0x428
+#define  MBOX_SMI_INTR_FW_HANG BIT(1)
+#define  MBOX_SMI_INTR_EN  BIT(3)
+
+struct tegra_xusb_mbox {
+   struct mbox_controller mbox;
+   int irq;
+   void __iomem *regs;
+   spinlock_t lock;
+   bool vchan_allocated[TEGRA_XUSB_MBOX_NUM_CHANS];
+};
+
+static inline u32 mbox_readl(struct tegra_xusb_mbox *mbox, unsigned long 
offset)
+{
+   return readl(mbox-regs + offset);
+}
+
+static inline void mbox_writel(struct tegra_xusb_mbox *mbox, u32 val,
+  unsigned long offset)
+{
+   writel(val, mbox-regs + offset);
+}
+
+static inline u32 mbox_pack_msg(struct tegra_xusb_mbox_msg *msg)
+{
+   u32 val;
+
+   val = (msg-cmd  CMD_TYPE_MASK)  CMD_TYPE_SHIFT;
+   val |= (msg-data  CMD_DATA_MASK)  CMD_DATA_SHIFT;
+
+   return val;
+}
+
+static inline void mbox_unpack_msg(u32 val, struct tegra_xusb_mbox_msg *msg)
+{
+   msg-cmd = (val  CMD_TYPE_SHIFT)  CMD_TYPE_MASK;
+   msg-data = (val  CMD_DATA_SHIFT)  CMD_DATA_MASK;
+}
+
+static int tegra_xusb_mbox_send_data(struct 

Re: [PATCH 0/7] xhci: patches for usb-next

2014-09-17 Thread Greg KH
On Wed, Sep 17, 2014 at 04:35:41PM +0300, Mathias Nyman wrote:
 Ping,
 
 Any plan on taking these to your usb-next branch?

Yes, I plan to, been on the road, and am typing this from a conference.
Hope to get to all of my pending patches soon...

thanks,

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


Re: [PATCHv4 04/12] usb: dwc2: Add the appropriate init calls in platform code

2014-09-17 Thread Dinh Nguyen
Hi Robert,

On 9/12/14, 7:13 AM, Robert Baldyga wrote:
 Hi Dinh,
 
 On 08/26/2014 06:19 PM, dingu...@opensource.altera.com wrote:
 From: Dinh Nguyen dingu...@opensource.altera.com

 Add the proper init calls for either host, gadget or both in platform.c

 Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
 Acked-by: Paul Zimmerman pa...@synopsys.com
 ---
  drivers/usb/dwc2/core.h | 13 +
  drivers/usb/dwc2/gadget.c   |  2 +-
  drivers/usb/dwc2/platform.c | 28 
  3 files changed, 38 insertions(+), 5 deletions(-)

 diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
 index f55e62d..3a49a00 100644
 --- a/drivers/usb/dwc2/core.h
 +++ b/drivers/usb/dwc2/core.h
 @@ -960,6 +960,19 @@ extern void dwc2_dump_global_registers(struct 
 dwc2_hsotg *hsotg);
   */
  extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
  
 +/* Gadget defines */
 +#if defined(CONFIG_USB_DWC2_PERIPHERAL) || 
 defined(CONFIG_USB_DWC2_DUAL_ROLE)
 +extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 +extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
 
 Function s3c_hsotg_core_init() is used only inside file gadget.c so
 exporting it makes no sense. By the way it should be static.

Yes, I agree here. Fixed up in v5.

 
 +extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 +#else
 +static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
 +static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 +{ return 0; }
 +static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 +{ return 0; }
 
 It also makes no sense to have this functions declared if you don't have
 to use them. They are called in one place in code, inside
 dwc2_driver_probe() function, so you can rather use if defined() there.

I'm not sure I agree here. This is necessary for the current runtime
implementation of the role initialization. This is probably relevant
with your next 2 comments.

 
 +#endif
 +
  #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
  /**
   * dwc2_hcd_get_frame_number() - Returns current frame number
 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
 index 96f868f..efa68a0 100644
 --- a/drivers/usb/dwc2/gadget.c
 +++ b/drivers/usb/dwc2/gadget.c
 @@ -3572,7 +3572,7 @@ err_clk:
   * s3c_hsotg_remove - remove function for hsotg driver
   * @pdev: The platform information for the driver
   */
 -static int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
 +int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
  {
  usb_del_gadget_udc(hsotg-gadget);
  
 diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
 index dd2f8f5..2871f351 100644
 --- a/drivers/usb/dwc2/platform.c
 +++ b/drivers/usb/dwc2/platform.c
 @@ -92,7 +92,14 @@ static int dwc2_driver_remove(struct platform_device *dev)
  {
  struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
  
 -dwc2_hcd_remove(hsotg);
 +if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
 +s3c_hsotg_remove(hsotg);
 +else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
 +dwc2_hcd_remove(hsotg);
 +else { /* dual role */
 +dwc2_hcd_remove(hsotg);
 +s3c_hsotg_remove(hsotg);
 +}
 
 Why don't make this checks compile-time?
 

Do you have a reason for a compile-time versus runtime here? It just
seems that from a few discussion threads on lkml that there is a general
biased towards using IS_ENABLED() as it looks a bit cleaner than
littering the code with a bunch of #ifdefs.

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


Re: [PATCHv4 04/12] usb: dwc2: Add the appropriate init calls in platform code

2014-09-17 Thread Stephen Warren

On 09/17/2014 02:47 PM, Dinh Nguyen wrote:

Hi Robert,

On 9/12/14, 7:13 AM, Robert Baldyga wrote:

Hi Dinh,

On 08/26/2014 06:19 PM, dingu...@opensource.altera.com wrote:

From: Dinh Nguyen dingu...@opensource.altera.com

Add the proper init calls for either host, gadget or both in platform.c

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Acked-by: Paul Zimmerman pa...@synopsys.com
---
  drivers/usb/dwc2/core.h | 13 +
  drivers/usb/dwc2/gadget.c   |  2 +-
  drivers/usb/dwc2/platform.c | 28 
  3 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index f55e62d..3a49a00 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -960,6 +960,19 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
   */
  extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);

+/* Gadget defines */
+#if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
+extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);


Function s3c_hsotg_core_init() is used only inside file gadget.c so
exporting it makes no sense. By the way it should be static.


Yes, I agree here. Fixed up in v5.




+extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
+#else
+static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
+{ return 0; }


It also makes no sense to have this functions declared if you don't have
to use them. They are called in one place in code, inside
dwc2_driver_probe() function, so you can rather use if defined() there.


I'm not sure I agree here. This is necessary for the current runtime
implementation of the role initialization. This is probably relevant
with your next 2 comments.




+#endif
+
  #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
  /**
   * dwc2_hcd_get_frame_number() - Returns current frame number
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 96f868f..efa68a0 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3572,7 +3572,7 @@ err_clk:
   * s3c_hsotg_remove - remove function for hsotg driver
   * @pdev: The platform information for the driver
   */
-static int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
  {
usb_del_gadget_udc(hsotg-gadget);

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index dd2f8f5..2871f351 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -92,7 +92,14 @@ static int dwc2_driver_remove(struct platform_device *dev)
  {
struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);

-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   dwc2_hcd_remove(hsotg);
+   s3c_hsotg_remove(hsotg);
+   }


Why don't make this checks compile-time?



Do you have a reason for a compile-time versus runtime here? It just
seems that from a few discussion threads on lkml that there is a general
biased towards using IS_ENABLED() as it looks a bit cleaner than
littering the code with a bunch of #ifdefs.


With typical compiler optimization, if (IS_ENABLED(...)) *is* a 
compile-time check. Yet, it allows the code within the if block body to 
be parsed, so that even if the code doesn't make it into the binary, it 
still gets syntax checking etc.

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


Re: [PATCH v2 4/4] usb: hub: rename khubd to hub_wq in documentation and comments

2014-09-17 Thread Tejun Heo
Hello, Alan, Petr.

On Wed, Sep 17, 2014 at 01:36:26PM -0400, Alan Stern wrote:
  -   /* If khubd ever becomes multithreaded, this will need a lock */
  +   /* If hub_wq ever becomes multithreaded, this will need a lock */
  if (udev-wusb) {
  devnum = udev-portnum + 1;
  BUG_ON(test_bit(devnum, bus-devmap.devicemap));
 
 You probably didn't notice when changing this comment.  But in fact,
 workqueues _are_ multithreaded.  Therefore you need to add a lock to 
 this routine.

Haven't read the code but if this function is called from a single
work_struct, workqueue guarantees that there's only single thread of
execution at any given time.  A work item is never executed
concurrently no matter what.

Thanks.

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


Re: [PATCHv4 06/12] usb: dwc2: Update common interrupt handler to call gadget interrupt handler

2014-09-17 Thread Dinh Nguyen


On 9/12/14, 7:50 AM, Robert Baldyga wrote:
 Hi,
 
 On 08/26/2014 06:19 PM, dingu...@opensource.altera.com wrote:
 From: Dinh Nguyen dingu...@opensource.altera.com

 Make dwc2_handle_common_intr call the gadget interrupt function when 
 operating
 in peripheral mode. Remove the spinlock functions in s3c_hsotg_irq as
 dwc2_handle_common_intr() already has the spinlocks.

 Remove duplicate interrupt conditions that was in gadget, as those are 
 handled
 by dwc2 common interrupt handler.

 Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
 Acked-by: Paul Zimmerman pa...@synopsys.com
 ---
 v2: Keep interrupt handler for host and peripheral modes separate
 ---
  drivers/usb/dwc2/core.h  |  3 +++
  drivers/usb/dwc2/core_intr.c |  3 +++
  drivers/usb/dwc2/gadget.c| 50 
 
  3 files changed, 10 insertions(+), 46 deletions(-)

 diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
 index 3a49a00..bbb0f52 100644
 --- a/drivers/usb/dwc2/core.h
 +++ b/drivers/usb/dwc2/core.h
 @@ -965,12 +965,15 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg 
 *hsotg);
  extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
  extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
  extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 +irqreturn_t s3c_hsotg_irq(int irq, void *pw);
  #else
  static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
  static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
  { return 0; }
  static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
  { return 0; }
 +static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
 +{ return IRQ_HANDLED; }
  #endif
  
  #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
 diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
 index c93918b..24d4c0d 100644
 --- a/drivers/usb/dwc2/core_intr.c
 +++ b/drivers/usb/dwc2/core_intr.c
 @@ -472,6 +472,9 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
  
  spin_lock(hsotg-lock);
  
 +if (dwc2_is_device_mode(hsotg))
 +retval = s3c_hsotg_irq(irq, dev);
 +
  gintsts = dwc2_read_common_intr(hsotg);
  if (gintsts  ~GINTSTS_PRTINT)
  retval = IRQ_HANDLED;
 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
 index efa68a0..a1c93bf 100644
 --- a/drivers/usb/dwc2/gadget.c
 +++ b/drivers/usb/dwc2/gadget.c
 @@ -2257,14 +2257,13 @@ void s3c_hsotg_core_init(struct dwc2_hsotg *hsotg)
   * @irq: The IRQ number triggered
   * @pw: The pw value when registered the handler.
   */
 -static irqreturn_t s3c_hsotg_irq(int irq, void *pw)
 +irqreturn_t s3c_hsotg_irq(int irq, void *pw)
  {
  struct dwc2_hsotg *hsotg = pw;
  int retry_count = 8;
  u32 gintsts;
  u32 gintmsk;
  
 -spin_lock(hsotg-lock);
  irq_retry:
  gintsts = readl(hsotg-regs + GINTSTS);
  gintmsk = readl(hsotg-regs + GINTMSK);
 @@ -2274,33 +2273,12 @@ irq_retry:
  
  gintsts = gintmsk;
  
 -if (gintsts  GINTSTS_OTGINT) {
 -u32 otgint = readl(hsotg-regs + GOTGINT);
 -
 -dev_info(hsotg-dev, OTGInt: %08x\n, otgint);
 -
 -writel(otgint, hsotg-regs + GOTGINT);
 -}
 -
 -if (gintsts  GINTSTS_SESSREQINT) {
 -dev_dbg(hsotg-dev, %s: SessReqInt\n, __func__);
 -writel(GINTSTS_SESSREQINT, hsotg-regs + GINTSTS);
 -}
 -
  if (gintsts  GINTSTS_ENUMDONE) {
  writel(GINTSTS_ENUMDONE, hsotg-regs + GINTSTS);
  
  s3c_hsotg_irq_enumdone(hsotg);
  }
  
 -if (gintsts  GINTSTS_CONIDSTSCHNG) {
 -dev_dbg(hsotg-dev, ConIDStsChg (DSTS=0x%08x, GOTCTL=%08x)\n,
 -readl(hsotg-regs + DSTS),
 -readl(hsotg-regs + GOTGCTL));
 -
 -writel(GINTSTS_CONIDSTSCHNG, hsotg-regs + GINTSTS);
 -}
 -
  if (gintsts  (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
  u32 daint = readl(hsotg-regs + DAINT);
  u32 daintmsk = readl(hsotg-regs + DAINTMSK);
 @@ -2381,25 +2359,6 @@ irq_retry:
  s3c_hsotg_handle_rx(hsotg);
  }
  
 -if (gintsts  GINTSTS_MODEMIS) {
 -dev_warn(hsotg-dev, warning, mode mismatch triggered\n);
 -writel(GINTSTS_MODEMIS, hsotg-regs + GINTSTS);
 -}
 -
 -if (gintsts  GINTSTS_USBSUSP) {
 -dev_info(hsotg-dev, GINTSTS_USBSusp\n);
 -writel(GINTSTS_USBSUSP, hsotg-regs + GINTSTS);
 -
 -call_gadget(hsotg, suspend);
 -}
 -
 -if (gintsts  GINTSTS_WKUPINT) {
 -dev_info(hsotg-dev, GINTSTS_WkUpIn\n);
 -writel(GINTSTS_WKUPINT, hsotg-regs + GINTSTS);
 -
 -call_gadget(hsotg, resume);
 -}
 -
  if (gintsts  GINTSTS_ERLYSUSP) {
  dev_dbg(hsotg-dev, GINTSTS_ErlySusp\n);
  writel(GINTSTS_ERLYSUSP, hsotg-regs + GINTSTS);
 @@ -2435,10 +2394,9 @@ irq_retry:
  if (gintsts  IRQ_RETRY_MASK  --retry_count  0)