Re: [PATCH v3 5/7] USB: EHCI: make ehci-atmel a separate driver

2013-03-30 Thread Nicolas Ferre
On 03/29/2013 09:02 PM, Alan Stern :
> On Thu, 28 Mar 2013, Arnd Bergmann wrote:
> 
>> From: Manjunath Goudar 
>>
>> Separate the Atmel host controller driver from ehci-hcd host code
>> so that it can be built as a separate driver module.
>> This work is part of enabling multi-platform kernels on ARM;
>> however, note that other changes are still needed before Atmel can be
>> booted with a multi-platform kernel. This is currently planned for
>> Linux-3.11.
>>
>> With the infrastructure added by Alan Stern in patch 3e0232039
>> "USB: EHCI: prepare to make ehci-hcd a library module", we can
>> avoid this problem by turning a bus glue into a separate
>> module, as we do here for the Atmel bus glue.
> 
> Generally okay.
> 
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index 01c1acb..8c564aa 100644
>> --- a/drivers/usb/host/ehci-atmel.c
>> +++ b/drivers/usb/host/ehci-atmel.c


I missed the patch itself but I reviewed it on the mailing-list archive.
So, here is my:

Acked-by: Nicolas Ferre 

Thanks a lot for having taking care of this driver.

Best regards,


>> @@ -15,6 +15,19 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> 
> While not absolutely necessary, it would be nice to have the #include 
> files in alphabetical order.
> 
>> +
>> +#include "ehci.h"
>> +
>> +#define DRIVER_DESC "EHCI atmel driver"
> 
> "atmel" should have a capital 'A'.
> 
> Alan Stern
> 
> 
> 


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


Re: [PATCH 00/27] usb: chipidea: updates for v3.10

2013-03-30 Thread Alexander Shishkin
Greg KH  writes:

> On Sat, Mar 30, 2013 at 02:46:16AM +0200, Alexander Shishkin wrote:
>> Hi Greg,
>> 
>> This is an update for chipidea usb controller driver for
>> usb-next. Some of these patches, though mostly mine, date as far back
>> as november 2012.
>
> Why would you hold onto patches for that long?  That's not ok for a
> maintainer to do, please be more responsive.

Again, these are mine, and more specifically the tracepoint ones. I was
waiting for the kind of feedback/discussion about the tracepoint idea
that I'm finally getting now, so that's why. Note, It said,
"tracepoints" and it said "PATCH", when it was posted first in
november. [1] So I thought, these patches are not urgent, maybe I'll
wait for some more constructive feedback or at least questions about how
to use it. I do realize it is my fault, I should have submitted those to
you for inclusion instead of just sending them out and had them rejected
early, so I wouldn't end up having this conversation. This, however, has
nothing to do with being responsive, at least not on my part.

The rest of the patches in this patchset could well have been in the
reviewing and resending loop till v3.14 or so if I haven't amended them
for this round.

So now that we have carried out the beating of one unresponsive
maintainer, let's talk about tracepoints.

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

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


Re: [PATCH 04/27] usb: chipidea: convert events to tracepoints

2013-03-30 Thread Alexander Shishkin
Greg KH  writes:

> On Sat, Mar 30, 2013 at 02:46:20AM +0200, Alexander Shishkin wrote:
>> As part of the legacy from the original driver design, we retain home-grown
>> tracing infrastructure, complete with own ring buffer and timestamps. While
>> it is useful for debugging certain cases, it's a lot of extra code, which
>> these days is rather redundant.
>> 
>> This patch replaces local tracing functionality with kernel tracepoints,
>> thus getting rid of the ring buffer and all the maintenance code, while
>> making use of standard kernel infrastructure.
>
> What do these tracepoints do?  Why do you still need them at all?

These are quite useful for debugging the udc part of the driver. You can
see especially the control traffic without having to use an analyser,
with timestamps and whatnot. With perf, you can annotate certain (or
all) tracepoints of interest with a call stack, which helps you see, for
example, what the gadget driver was doing at that point. Without these,
it will sometimes take you (me, more likely) a few cycles of "instrument
code with debug prints -- grep through tons of crap in dmesg" before I
can figure out a problem. With perf, I don't need to recompile or even
reboot anything, it's all there.

> Once you make a tracepoint, you are saying you are going to keep that
> api for forever, are you really willing to do that?  I'm not, which is

What is wrong with that? This usb controller is not going to grow more
registers or data structures in the future. I was even going to suggest
a more generic set of tracepoints for all gadgets to use if they
want. In fact, most of these tracepoints are applicable to any gadget
right away, and will always be, since the structure of control traffic
in usb 2.0 is not very likely to change.

> why you don't see any USB tracepoints yet, and I really don't think that
> a single driver needs them either.

Well, if you do a "perf list -e tracepoint", you do get to see quite a
few drivers. Not that I'm using this as a justification or anything.

> So I need a whole lot of convincing before I can take a patch like this,
> sorry.

Tracepoints and perf provide incredibly powerful and useful means of
debugging, especially when it comes to things like usb, when you are
interested not only in the events per se, but also in their order and
timing. Same thing goes for profiling.

All that said, I'm now going to change the patchset to just remove the
old event buffer churn. Since nobody has really shown interest in these
tracepoints, folks are probably happy with printk debugging, which is
also fine by me, because I'm not the one who has to do most of the
debugging in the chipidea driver. The old event buffer is what's
*bothering* me.

> I took the first 3 patches here, but odds are, if I can't take this one,
> the rest will not apply, right?

Of course.

Regards,
--
Alex
--
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 net-next] cdc_ncm: return -ENOMEM if kzalloc fails

2013-03-30 Thread Devendra Naga
return -ENOMEM instead if kzalloc of cdc_ncm_ctx structure is failed.

and also remove the comparision of ctx structure with NULL and make
it as !ctx.

Signed-off-by: Devendra Naga 
---
 drivers/net/usb/cdc_ncm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4709fa3..44a989c 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -362,8 +362,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct 
usb_interface *intf, u8 data_
u8 iface_no;
 
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
-   if (ctx == NULL)
-   return -ENODEV;
+   if (!ctx)
+   return -ENOMEM;
 
hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
-- 
1.8.1.4

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


Re: [PATCH 05/27] usb: chipidea: replace interrupt accounting with tracepoints

2013-03-30 Thread Alexander Shishkin
Greg KH  writes:

> On Sat, Mar 30, 2013 at 02:46:21AM +0200, Alexander Shishkin wrote:
>> The driver also has interrupt counters and another ring buffer for keeping
>> track of the order in which they arrive. This patch converts these counters
>> to trace points. Userspace tools such as perf can provide information on both
>> order and stats of the interrupts.
>
> Why would perf care about a single driver?  Why would a user?  Why are

Sorry, I don't understand these questions. That paragraph was trying to
say that if you still want the information that the old event buffer
provided, use perf.

> these needed at all for anyone except the driver developer?

One would think that tracepoints in $X part of the kernel are only ever
of interest to the developers of $X with a few exeptions in sched and mm.

Regards,
--
Alex
--
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 12/27] usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx

2013-03-30 Thread Alexander Shishkin
Greg KH  writes:

> On Sat, Mar 30, 2013 at 02:46:28AM +0200, Alexander Shishkin wrote:
>> From: Michael Grzeschik 
>> 
>> This driver will be used for every Freescale SoC which has this misc
>> memory layout to control the basic usb handling. So better name this
>> driver, function and struct names in a more generic way.
>> 
>> Reported-by: Fabio Estevam 
>> Signed-off-by: Michael Grzeschik 
>> Signed-off-by: Marc Kleine-Budde 
>> Signed-off-by: Alexander Shishkin 
>> 
>> Conflicts:
>>  drivers/usb/chipidea/usbmisc_imx.c
>
> What does this mean?  Why are these two lines in the changelog area?

The patch that was sent to me didn't apply, so I had to fix it.

> Hint, be more careful when using git rebase, and double check what you
> send me, before you send it.

I always do, I just didn't realize it was a problem to have conflicts in
changelog, since there are other non-merge commits in the tree like that.

Regards,
--
Alex
--
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 09/27] usb: chipidea: fix precedence bug in ci_requests_show()

2013-03-30 Thread Alexander Shishkin
Greg KH  writes:

> On Sat, Mar 30, 2013 at 02:46:25AM +0200, Alexander Shishkin wrote:
>> From: Dan Carpenter 
>> 
>> The intent here was to have parenthesis around the (ci->hw_ep_max / 2)
>> so that it counts like "0 1 2 0 1 2".  In the current code, the mod
>> operation happens first so it counts like "0 0 1 1 2 2".
>> 
>> Signed-off-by: Dan Carpenter 
>> [rebased on top of debug.c changes]
>
> Can you rebase this not on top of those changes, so I can take this
> now?

If by "those" you mean tracepoints, then you can kind of see that it has
nothing to do with tracepoints. This was rebased on top of the patch
that moves files from sysfs to debugfs and I'm keeping that one.

Regards,
--
Alex
--
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 00/21] usb: chipidea: updates for v3.10

2013-03-30 Thread Alexander Shishkin
Hi,

Let's try again. Rebased it on top of usb-next and dropped the whole
tracepoint thing, but kept the part that removes the old event
buffer and other debug cleanups. So everything else is rebased on top
of that and a couple of commit messages amended.

Alexander Shishkin (5):
  usb: chipidea: remove home-grown tracing facility
  usb: chipidea: convert debug entries in sysfs to debugfs
  usb: chipidea: move role to debugfs
  usb: chipidea: move debug files creation/removal to the core
  usb: chipidea: make pci platform datas static

Dan Carpenter (1):
  usb: chipidea: fix precedence bug in ci_requests_show()

Felipe Balbi (1):
  usb: chipidea: don't redefine __ffs()

Marc Kleine-Budde (3):
  usb: chipidea: usbmisc: unset global varibale usbmisc on driver
remove
  usb: chipidea: usbmisc: fix a potential race condition
  usb: chipidea: usbmisc: prepare driver to handle more than one soc

Michael Grzeschik (10):
  usb: chipidea: usbmisc: rename file, struct and functions to
usbmisc_imx
  usb: chipidea: usbmisc: add mx53 support
  usb: chipidea: usbmisc: add post handling and errata fix for mx25
  usb: chipidea: udc: only clear active and halted bits in qhead
  usb: chipidea: udc: rework ep_enable cap setting
  usb: chipidea: udc: move ZLT flag change to ep_enable
  usb: chipidea: udc: read status of td only once in hardware_dequeue
  usb: chipidea: udc: don't truncate requests to single tds
  usb: chipidea: udc: move _ep_queue into an unlocked function
  usb: chipidea: udc: add the define TD_PAGE_COUNT and fix all users

Svetoslav Neykov (1):
  usb: chipidea: big-endian support

 .../devicetree/bindings/usb/ci13xxx-imx.txt|2 +
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci.h  |   18 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   12 +
 drivers/usb/chipidea/ci13xxx_imx.h |3 +
 drivers/usb/chipidea/ci13xxx_pci.c |6 +-
 drivers/usb/chipidea/core.c|   55 +-
 drivers/usb/chipidea/debug.c   |  871 +---
 drivers/usb/chipidea/debug.h   |   34 +-
 drivers/usb/chipidea/udc.c |  219 +++--
 drivers/usb/chipidea/usbmisc_imx.c |  261 ++
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 12 files changed, 587 insertions(+), 1058 deletions(-)
 create mode 100644 drivers/usb/chipidea/usbmisc_imx.c
 delete mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

-- 
1.7.10.4

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


[PATCH v2 01/21] usb: chipidea: remove home-grown tracing facility

2013-03-30 Thread Alexander Shishkin
As part of the legacy from the original driver design, we retain home-grown
tracing infrastructure, complete with own ring buffer and timestamps,
which among other things has a performance penalty. This patch removes it.

Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/debug.c |  360 +-
 drivers/usb/chipidea/debug.h |   25 ---
 drivers/usb/chipidea/udc.c   |   33 +---
 3 files changed, 2 insertions(+), 416 deletions(-)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index e6cc45e..898aca5 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -10,46 +10,6 @@
 #include "bits.h"
 #include "debug.h"
 
-/* Interrupt statistics */
-#define ISR_MASK   0x1F
-static struct isr_statistics {
-   u32 test;
-   u32 ui;
-   u32 uei;
-   u32 pci;
-   u32 uri;
-   u32 sli;
-   u32 none;
-   struct {
-   u32 cnt;
-   u32 buf[ISR_MASK+1];
-   u32 idx;
-   } hndl;
-} isr_statistics;
-
-void dbg_interrupt(u32 intmask)
-{
-   if (!intmask) {
-   isr_statistics.none++;
-   return;
-   }
-
-   isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intmask;
-   isr_statistics.hndl.idx &= ISR_MASK;
-   isr_statistics.hndl.cnt++;
-
-   if (USBi_URI & intmask)
-   isr_statistics.uri++;
-   if (USBi_PCI & intmask)
-   isr_statistics.pci++;
-   if (USBi_UEI & intmask)
-   isr_statistics.uei++;
-   if (USBi_UI  & intmask)
-   isr_statistics.ui++;
-   if (USBi_SLI & intmask)
-   isr_statistics.sli++;
-}
-
 /**
  * hw_register_read: reads all device registers (execute without interruption)
  * @buf:  destination buffer
@@ -196,312 +156,6 @@ static ssize_t show_driver(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR(driver, S_IRUSR, show_driver, NULL);
 
-/* Maximum event message length */
-#define DBG_DATA_MSG   64UL
-
-/* Maximum event messages */
-#define DBG_DATA_MAX   128UL
-
-/* Event buffer descriptor */
-static struct {
-   char (buf[DBG_DATA_MAX])[DBG_DATA_MSG];   /* buffer */
-   unsigned idx;   /* index */
-   unsigned tty;   /* print to console? */
-   rwlock_t lck;   /* lock */
-} dbg_data = {
-   .idx = 0,
-   .tty = 0,
-   .lck = __RW_LOCK_UNLOCKED(dbg_data.lck)
-};
-
-/**
- * dbg_dec: decrements debug event index
- * @idx: buffer index
- */
-static void dbg_dec(unsigned *idx)
-{
-   *idx = (*idx - 1) & (DBG_DATA_MAX-1);
-}
-
-/**
- * dbg_inc: increments debug event index
- * @idx: buffer index
- */
-static void dbg_inc(unsigned *idx)
-{
-   *idx = (*idx + 1) & (DBG_DATA_MAX-1);
-}
-
-/**
- * dbg_print:  prints the common part of the event
- * @addr:   endpoint address
- * @name:   event name
- * @status: status
- * @extra:  extra information
- */
-static void dbg_print(u8 addr, const char *name, int status, const char *extra)
-{
-   struct timeval tval;
-   unsigned int stamp;
-   unsigned long flags;
-
-   write_lock_irqsave(&dbg_data.lck, flags);
-
-   do_gettimeofday(&tval);
-   stamp = tval.tv_sec & 0x;   /* 2^32 = 4294967296. Limit to 4096s */
-   stamp = stamp * 100 + tval.tv_usec;
-
-   scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG,
- "%04X\t? %02X %-7.7s %4i ?\t%s\n",
- stamp, addr, name, status, extra);
-
-   dbg_inc(&dbg_data.idx);
-
-   write_unlock_irqrestore(&dbg_data.lck, flags);
-
-   if (dbg_data.tty != 0)
-   pr_notice("%04X\t? %02X %-7.7s %4i ?\t%s\n",
- stamp, addr, name, status, extra);
-}
-
-/**
- * dbg_done: prints a DONE event
- * @addr:   endpoint address
- * @td: transfer descriptor
- * @status: status
- */
-void dbg_done(u8 addr, const u32 token, int status)
-{
-   char msg[DBG_DATA_MSG];
-
-   scnprintf(msg, sizeof(msg), "%d %02X",
- (int)(token & TD_TOTAL_BYTES) >> ffs_nr(TD_TOTAL_BYTES),
- (int)(token & TD_STATUS)  >> ffs_nr(TD_STATUS));
-   dbg_print(addr, "DONE", status, msg);
-}
-
-/**
- * dbg_event: prints a generic event
- * @addr:   endpoint address
- * @name:   event name
- * @status: status
- */
-void dbg_event(u8 addr, const char *name, int status)
-{
-   if (name != NULL)
-   dbg_print(addr, name, status, "");
-}
-
-/*
- * dbg_queue: prints a QUEUE event
- * @addr:   endpoint address
- * @req:USB request
- * @status: status
- */
-void dbg_queue(u8 addr, const struct usb_request *req, int status)
-{
-   char msg[DBG_DATA_MSG];
-
-   if (req != NULL) {
-   scnprintf(msg, sizeof(msg),
- "%d %d", !req->no_interrupt, req->length);
-   dbg_print(addr, "QUEUE", status, msg);
-   }
-}
-
-/**
- * dbg_setup: prints a SETUP event
- * @addr: endpoint address
- * @req:  setup request
- *

[PATCH v2 02/21] usb: chipidea: convert debug entries in sysfs to debugfs

2013-03-30 Thread Alexander Shishkin
Currently, we have a bunch of files in sysfs that display all sorts of
debugging information for the device controller, so they have to move to
debugfs where they belong. The "registers" interface have been removed,
since it doesn't fit into the current driver design as is and it's hardly
a good idea to touch the registers from userspace anyway.

Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/ci.h|2 +
 drivers/usb/chipidea/debug.c |  469 +-
 drivers/usb/chipidea/debug.h |9 +-
 drivers/usb/chipidea/udc.c   |6 +-
 4 files changed, 151 insertions(+), 335 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index d738603..c7d4622 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -129,6 +129,7 @@ struct hw_bank {
  * @vbus_active: is VBUS active
  * @transceiver: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
+ * @debugfs: root dentry for this controller in debugfs
  */
 struct ci13xxx {
struct device   *dev;
@@ -164,6 +165,7 @@ struct ci13xxx {
boolglobal_phy;
struct usb_phy  *transceiver;
struct usb_hcd  *hcd;
+   struct dentry   *debugfs;
 };
 
 static inline struct ci_role_driver *ci_role(struct ci13xxx *ci)
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 898aca5..057ae09 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -2,6 +2,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -11,223 +14,113 @@
 #include "debug.h"
 
 /**
- * hw_register_read: reads all device registers (execute without interruption)
- * @buf:  destination buffer
- * @size: buffer size
- *
- * This function returns number of registers read
+ * ci_device_show: prints information about device capabilities and status
  */
-static size_t hw_register_read(struct ci13xxx *ci, u32 *buf, size_t size)
+static int ci_device_show(struct seq_file *s, void *data)
 {
-   unsigned i;
-
-   if (size > ci->hw_bank.size)
-   size = ci->hw_bank.size;
-
-   for (i = 0; i < size; i++)
-   buf[i] = hw_read(ci, i * sizeof(u32), ~0);
-
-   return size;
-}
-
-/**
- * hw_register_write: writes to register
- * @addr: register address
- * @data: register value
- *
- * This function returns an error code
- */
-static int hw_register_write(struct ci13xxx *ci, u16 addr, u32 data)
-{
-   /* align */
-   addr /= sizeof(u32);
+   struct ci13xxx *ci = s->private;
+   struct usb_gadget *gadget = &ci->gadget;
 
-   if (addr >= ci->hw_bank.size)
-   return -EINVAL;
+   seq_printf(s, "speed = %d\n", gadget->speed);
+   seq_printf(s, "max_speed = %d\n", gadget->max_speed);
+   seq_printf(s, "is_otg= %d\n", gadget->is_otg);
+   seq_printf(s, "is_a_peripheral   = %d\n", gadget->is_a_peripheral);
+   seq_printf(s, "b_hnp_enable  = %d\n", gadget->b_hnp_enable);
+   seq_printf(s, "a_hnp_support = %d\n", gadget->a_hnp_support);
+   seq_printf(s, "a_alt_hnp_support = %d\n", gadget->a_alt_hnp_support);
+   seq_printf(s, "name  = %s\n",
+  (gadget->name ? gadget->name : ""));
+
+   if (!ci->driver)
+   return 0;
 
-   /* align */
-   addr *= sizeof(u32);
+   seq_printf(s, "gadget function   = %s\n",
+  (ci->driver->function ? ci->driver->function : ""));
+   seq_printf(s, "gadget max speed  = %d\n", ci->driver->max_speed);
 
-   hw_write(ci, addr, ~0, data);
return 0;
 }
 
-/**
- * hw_intr_clear: disables interrupt & clears interrupt status (execute without
- *interruption)
- * @n: interrupt bit
- *
- * This function returns an error code
- */
-static int hw_intr_clear(struct ci13xxx *ci, int n)
+static int ci_device_open(struct inode *inode, struct file *file)
 {
-   if (n >= REG_BITS)
-   return -EINVAL;
-
-   hw_write(ci, OP_USBINTR, BIT(n), 0);
-   hw_write(ci, OP_USBSTS,  BIT(n), BIT(n));
-   return 0;
+   return single_open(file, ci_device_show, inode->i_private);
 }
 
-/**
- * hw_intr_force: enables interrupt & forces interrupt status (execute without
- *interruption)
- * @n: interrupt bit
- *
- * This function returns an error code
- */
-static int hw_intr_force(struct ci13xxx *ci, int n)
-{
-   if (n >= REG_BITS)
-   return -EINVAL;
-
-   hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE);
-   hw_write(ci, OP_USBINTR,  BIT(n), BIT(n));
-   hw_write(ci, OP_USBSTS,   BIT(n), BIT(n));
-   hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, 0);
-   return 0;
-}
-
-/**
- * show_device: prints information about device capabilities and status
- *
- * Check "device.h" for deta

[PATCH v2 03/21] usb: chipidea: move role to debugfs

2013-03-30 Thread Alexander Shishkin
Manual role switching function is there for debugging purposes, so has
to move to debugfs.

Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/core.c  |   39 --
 drivers/usb/chipidea/debug.c |   54 ++
 2 files changed, 54 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 42f2249..5270156 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -280,38 +280,6 @@ static void ci_role_work(struct work_struct *work)
}
 }
 
-static ssize_t show_role(struct device *dev, struct device_attribute *attr,
-char *buf)
-{
-   struct ci13xxx *ci = dev_get_drvdata(dev);
-
-   return sprintf(buf, "%s\n", ci_role(ci)->name);
-}
-
-static ssize_t store_role(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
-   struct ci13xxx *ci = dev_get_drvdata(dev);
-   enum ci_role role;
-   int ret;
-
-   for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++)
-   if (ci->roles[role] && !strcmp(buf, ci->roles[role]->name))
-   break;
-
-   if (role == CI_ROLE_END || role == ci->role)
-   return -EINVAL;
-
-   ci_role_stop(ci);
-   ret = ci_role_start(ci, role);
-   if (ret)
-   return ret;
-
-   return count;
-}
-
-static DEVICE_ATTR(role, S_IRUSR | S_IWUSR, show_role, store_role);
-
 static irqreturn_t ci_irq(int irq, void *data)
 {
struct ci13xxx *ci = data;
@@ -484,17 +452,11 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ret)
goto stop;
 
-   ret = device_create_file(dev, &dev_attr_role);
-   if (ret)
-   goto rm_attr;
-
if (ci->is_otg)
hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE);
 
return ret;
 
-rm_attr:
-   device_remove_file(dev, &dev_attr_role);
 stop:
ci_role_stop(ci);
 rm_wq:
@@ -510,7 +472,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
 
flush_workqueue(ci->wq);
destroy_workqueue(ci->wq);
-   device_remove_file(ci->dev, &dev_attr_role);
free_irq(ci->irq, ci);
ci_role_stop(ci);
 
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 057ae09..5738079 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -199,6 +199,55 @@ static const struct file_operations ci_requests_fops = {
.release= single_release,
 };
 
+static int ci_role_show(struct seq_file *s, void *data)
+{
+   struct ci13xxx *ci = s->private;
+
+   seq_printf(s, "%s\n", ci_role(ci)->name);
+
+   return 0;
+}
+
+static ssize_t ci_role_write(struct file *file, const char __user *ubuf,
+size_t count, loff_t *ppos)
+{
+   struct seq_file *s = file->private_data;
+   struct ci13xxx *ci = s->private;
+   enum ci_role role;
+   char buf[8];
+   int ret;
+
+   if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+   return -EFAULT;
+
+   for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++)
+   if (ci->roles[role] &&
+   !strncmp(buf, ci->roles[role]->name,
+strlen(ci->roles[role]->name)))
+   break;
+
+   if (role == CI_ROLE_END || role == ci->role)
+   return -EINVAL;
+
+   ci_role_stop(ci);
+   ret = ci_role_start(ci, role);
+
+   return ret ? ret : count;
+}
+
+static int ci_role_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, ci_role_show, inode->i_private);
+}
+
+static const struct file_operations ci_role_fops = {
+   .open   = ci_role_open,
+   .write  = ci_role_write,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 /**
  * dbg_create_files: initializes the attribute interface
  * @ci: device
@@ -230,6 +279,11 @@ int dbg_create_files(struct ci13xxx *ci)
 
dent = debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
   &ci_requests_fops);
+   if (!dent)
+   goto err;
+
+   dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
+  &ci_role_fops);
if (dent)
return 0;
 err:
-- 
1.7.10.4

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


[PATCH v2 05/21] usb: chipidea: fix precedence bug in ci_requests_show()

2013-03-30 Thread Alexander Shishkin
From: Dan Carpenter 

The intent here was to have parenthesis around the (ci->hw_ep_max / 2)
so that it counts like "0 1 2 0 1 2".  In the current code, the mod
operation happens first so it counts like "0 0 1 1 2 2".

Signed-off-by: Dan Carpenter 
[rebased on top of debug.c changes]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/debug.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 5738079..36a7063 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -175,7 +175,7 @@ static int ci_requests_show(struct seq_file *s, void *data)
req = list_entry(ptr, struct ci13xxx_req, queue);
 
seq_printf(s, "EP=%02i: TD=%08X %s\n",
-  i % ci->hw_ep_max/2, (u32)req->dma,
+  i % (ci->hw_ep_max / 2), (u32)req->dma,
   ((i < ci->hw_ep_max/2) ? "RX" : "TX"));
 
for (j = 0; j < qsize; j++)
-- 
1.7.10.4

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


[PATCH v2 04/21] usb: chipidea: move debug files creation/removal to the core

2013-03-30 Thread Alexander Shishkin
Create and remove debugfs entries in hdrc probe/remove instead of
start/stop of the device controller. Gadget specific will not export
anything while the controller is in host mode.

Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/core.c |6 +-
 drivers/usb/chipidea/udc.c  |9 +
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5270156..a7ce1b8 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -455,8 +455,11 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ci->is_otg)
hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE);
 
-   return ret;
+   ret = dbg_create_files(ci);
+   if (!ret)
+   return 0;
 
+   free_irq(ci->irq, ci);
 stop:
ci_role_stop(ci);
 rm_wq:
@@ -470,6 +473,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
 {
struct ci13xxx *ci = platform_get_drvdata(pdev);
 
+   dbg_remove_files(ci);
flush_workqueue(ci->wq);
destroy_workqueue(ci->wq);
free_irq(ci->irq, ci);
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index d945391..28c31ba 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1697,15 +1697,11 @@ static int udc_start(struct ci13xxx *ci)
goto put_transceiver;
}
 
-   retval = dbg_create_files(ci);
-   if (retval)
-   goto unreg_device;
-
if (!IS_ERR_OR_NULL(ci->transceiver)) {
retval = otg_set_peripheral(ci->transceiver->otg,
&ci->gadget);
if (retval)
-   goto remove_dbg;
+   goto unreg_device;
}
 
retval = usb_add_gadget_udc(dev, &ci->gadget);
@@ -1725,8 +1721,6 @@ remove_trans:
}
 
dev_err(dev, "error = %i\n", retval);
-remove_dbg:
-   dbg_remove_files(ci);
 unreg_device:
device_unregister(&ci->gadget.dev);
 put_transceiver:
@@ -1763,7 +1757,6 @@ static void udc_stop(struct ci13xxx *ci)
if (ci->global_phy)
usb_put_phy(ci->transceiver);
}
-   dbg_remove_files(ci);
device_unregister(&ci->gadget.dev);
/* my kobject is dynamic, I swear! */
memset(&ci->gadget, 0, sizeof(ci->gadget));
-- 
1.7.10.4

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


[PATCH v2 06/21] usb: chipidea: don't redefine __ffs()

2013-03-30 Thread Alexander Shishkin
From: Felipe Balbi 

chipidea's ffs_nr() is pretty much what __ffs() does.

Use that one instead.

Signed-off-by: Felipe Balbi 
[rebased on top of debug infrastructure rework]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/ci.h   |   15 +--
 drivers/usb/chipidea/core.c |8 
 drivers/usb/chipidea/udc.c  |   12 ++--
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index c7d4622..68577d1 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -235,19 +235,6 @@ enum ci13xxx_regs {
 };
 
 /**
- * ffs_nr: find first (least significant) bit set
- * @x: the word to search
- *
- * This function returns bit number (instead of position)
- */
-static inline int ffs_nr(u32 x)
-{
-   int n = ffs(x);
-
-   return n ? n-1 : 32;
-}
-
-/**
  * hw_read: reads from a hw register
  * @reg:  register index
  * @mask: bitfield mask
@@ -305,7 +292,7 @@ static inline u32 hw_test_and_write(struct ci13xxx *ci, 
enum ci13xxx_regs reg,
u32 val = hw_read(ci, reg, ~0);
 
hw_write(ci, reg, mask, data);
-   return (val & mask) >> ffs_nr(mask);
+   return (val & mask) >> __ffs(mask);
 }
 
 int hw_device_reset(struct ci13xxx *ci, u32 mode);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a7ce1b8..114d4c4 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -155,7 +155,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
if (mode > TEST_MODE_MAX)
return -EINVAL;
 
-   hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << ffs_nr(PORTSC_PTC));
+   hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC));
return 0;
 }
 
@@ -166,7 +166,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
  */
 u8 hw_port_test_get(struct ci13xxx *ci)
 {
-   return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> ffs_nr(PORTSC_PTC);
+   return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC);
 }
 
 static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
@@ -182,7 +182,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
 
hw_alloc_regmap(ci, false);
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
-   ffs_nr(HCCPARAMS_LEN);
+   __ffs(HCCPARAMS_LEN);
ci->hw_bank.lpm  = reg;
hw_alloc_regmap(ci, !!reg);
ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
@@ -190,7 +190,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
ci->hw_bank.size /= sizeof(u32);
 
reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
-   ffs_nr(DCCPARAMS_DEN);
+   __ffs(DCCPARAMS_DEN);
ci->hw_ep_max = reg * 2;   /* cache hw ENDPT_MAX */
 
if (ci->hw_ep_max > ENDPT_MAX)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 28c31ba..32e6c99 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -140,7 +140,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int 
dir, int type)
 
if (dir) {
mask  = ENDPTCTRL_TXT;  /* type*/
-   data  = type << ffs_nr(mask);
+   data  = type << __ffs(mask);
 
mask |= ENDPTCTRL_TXS;  /* unstall */
mask |= ENDPTCTRL_TXR;  /* reset data toggle */
@@ -149,7 +149,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int 
dir, int type)
data |= ENDPTCTRL_TXE;
} else {
mask  = ENDPTCTRL_RXT;  /* type*/
-   data  = type << ffs_nr(mask);
+   data  = type << __ffs(mask);
 
mask |= ENDPTCTRL_RXS;  /* unstall */
mask |= ENDPTCTRL_RXR;  /* reset data toggle */
@@ -331,7 +331,7 @@ static int hw_test_and_set_setup_guard(struct ci13xxx *ci)
 static void hw_usb_set_address(struct ci13xxx *ci, u8 value)
 {
hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR,
-value << ffs_nr(DEVICEADDR_USBADR));
+value << __ffs(DEVICEADDR_USBADR));
 }
 
 /**
@@ -418,7 +418,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
 * TODO - handle requests which spawns into several TDs
 */
memset(mReq->ptr, 0, sizeof(*mReq->ptr));
-   mReq->ptr->token= length << ffs_nr(TD_TOTAL_BYTES);
+   mReq->ptr->token= length << __ffs(TD_TOTAL_BYTES);
mReq->ptr->token   &= TD_TOTAL_BYTES;
mReq->ptr->token   |= TD_STATUS_ACTIVE;
if (mReq->zptr) {
@@ -504,7 +504,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
mReq->req.status = -1;
 
mReq->req.actual   = mReq->ptr->token & TD_TOTAL_BYTES;
-   mReq->req.actual >>= ffs_nr(TD_TOTAL_BYTES);
+   mReq->req.actual >>= __ffs(TD_TOTAL_BYTES);
mReq->req.actual   = mReq->req.length - mReq->req.actual;
mReq->req.

[PATCH v2 07/21] usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

This driver will be used for every Freescale SoC which has this misc
memory layout to control the basic usb handling. So better name this
driver, function and struct names in a more generic way.

Reported-by: Fabio Estevam 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/Makefile|2 +-
 drivers/usb/chipidea/usbmisc_imx.c   |  162 ++
 drivers/usb/chipidea/usbmisc_imx6q.c |  162 --
 3 files changed, 163 insertions(+), 163 deletions(-)
 create mode 100644 drivers/usb/chipidea/usbmisc_imx.c
 delete mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index d92ca32..4ab83e9 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx.o
 endif
diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
new file mode 100644
index 000..3c42446
--- /dev/null
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ci13xxx_imx.h"
+
+#define USB_DEV_MAX 4
+
+#define BM_OVER_CUR_DISBIT(7)
+
+struct imx_usbmisc {
+   void __iomem *base;
+   spinlock_t lock;
+   struct clk *clk;
+   struct usbmisc_usb_device usbdev[USB_DEV_MAX];
+};
+
+static struct imx_usbmisc *usbmisc;
+
+static struct usbmisc_usb_device *get_usbdev(struct device *dev)
+{
+   int i, ret;
+
+   for (i = 0; i < USB_DEV_MAX; i++) {
+   if (usbmisc->usbdev[i].dev == dev)
+   return &usbmisc->usbdev[i];
+   else if (!usbmisc->usbdev[i].dev)
+   break;
+   }
+
+   if (i >= USB_DEV_MAX)
+   return ERR_PTR(-EBUSY);
+
+   ret = usbmisc_get_init_data(dev, &usbmisc->usbdev[i]);
+   if (ret)
+   return ERR_PTR(ret);
+
+   return &usbmisc->usbdev[i];
+}
+
+static int usbmisc_imx6q_init(struct device *dev)
+{
+
+   struct usbmisc_usb_device *usbdev;
+   unsigned long flags;
+   u32 reg;
+
+   usbdev = get_usbdev(dev);
+   if (IS_ERR(usbdev))
+   return PTR_ERR(usbdev);
+
+   if (usbdev->disable_oc) {
+   spin_lock_irqsave(&usbmisc->lock, flags);
+   reg = readl(usbmisc->base + usbdev->index * 4);
+   writel(reg | BM_OVER_CUR_DIS,
+   usbmisc->base + usbdev->index * 4);
+   spin_unlock_irqrestore(&usbmisc->lock, flags);
+   }
+
+   return 0;
+}
+
+static const struct usbmisc_ops imx6q_usbmisc_ops = {
+   .init = usbmisc_imx6q_init,
+};
+
+static const struct of_device_id usbmisc_imx_dt_ids[] = {
+   { .compatible = "fsl,imx6q-usbmisc"},
+   { /* sentinel */ }
+};
+
+static int usbmisc_imx_probe(struct platform_device *pdev)
+{
+   struct resource *res;
+   struct imx_usbmisc *data;
+   int ret;
+
+   if (usbmisc)
+   return -EBUSY;
+
+   data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+   if (!data)
+   return -ENOMEM;
+
+   spin_lock_init(&data->lock);
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   data->base = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(data->base))
+   return PTR_ERR(data->base);
+
+   data->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(data->clk)) {
+   dev_err(&pdev->dev,
+   "failed to get clock, err=%ld\n", PTR_ERR(data->clk));
+   return PTR_ERR(data->clk);
+   }
+
+   ret = clk_prepare_enable(data->clk);
+   if (ret) {
+   dev_err(&pdev->dev,
+   "clk_prepare_enable failed, err=%d\n", ret);
+   return ret;
+   }
+
+   ret = usbmisc_set_ops(&imx6q_usbmisc_ops);
+   if (ret) {
+   clk_disable_unprepare(data->clk);
+   return ret;
+   }
+
+   usbmisc = data;
+
+   return 0;
+}
+
+static int usbmisc_imx_remove(struct platform_device *pdev)
+{
+   usbmisc_unset_ops(&imx6q_usbmisc_ops);
+   clk_disable_unprepare(usbmisc->clk);
+   return 0;
+}
+
+static struct platform_driver usbmisc_imx_driver = {
+   .probe = usbmisc_imx_probe,
+   .remove = usbmisc_imx

[PATCH v2 08/21] usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove

2013-03-30 Thread Alexander Shishkin
From: Marc Kleine-Budde 

The probe function checks usbmisc to be NULL in the beginning. Without
this patch the can only be loaded once.

Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/usbmisc_imx.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index 3c42446..fd4d339 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -131,6 +131,7 @@ static int usbmisc_imx_remove(struct platform_device *pdev)
 {
usbmisc_unset_ops(&imx6q_usbmisc_ops);
clk_disable_unprepare(usbmisc->clk);
+   usbmisc = NULL;
return 0;
 }
 
-- 
1.7.10.4

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


[PATCH v2 09/21] usb: chipidea: usbmisc: fix a potential race condition

2013-03-30 Thread Alexander Shishkin
From: Marc Kleine-Budde 

This fixes a potential race condition where the ci13xxx_imx glue code
could be fast enough to call one of the usbmisc_ops before he got a
valid value on the static usbmisc pointer. To fix that we first set
usbmisc, then call usbmisc_set_ops().

Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/usbmisc_imx.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index fd4d339..d77e712 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -116,14 +116,14 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
return ret;
}
 
+   usbmisc = data;
ret = usbmisc_set_ops(&imx6q_usbmisc_ops);
if (ret) {
+   usbmisc = NULL;
clk_disable_unprepare(data->clk);
return ret;
}
 
-   usbmisc = data;
-
return 0;
 }
 
-- 
1.7.10.4

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


[PATCH v2 10/21] usb: chipidea: usbmisc: prepare driver to handle more than one soc

2013-03-30 Thread Alexander Shishkin
From: Marc Kleine-Budde 

This attaches the usbmisc_ops to the of_device_id data and
makes it possible to define special functions per soc.

Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Michael Grzeschik 
[Alex: fixed one case of line-too-long and one bogus cast to void ptr]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/usbmisc_imx.c |   18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index d77e712..08b046f 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -19,13 +19,14 @@
 
 #define USB_DEV_MAX 4
 
-#define BM_OVER_CUR_DISBIT(7)
+#define MX6_BM_OVER_CUR_DISBIT(7)
 
 struct imx_usbmisc {
void __iomem *base;
spinlock_t lock;
struct clk *clk;
struct usbmisc_usb_device usbdev[USB_DEV_MAX];
+   const struct usbmisc_ops *ops;
 };
 
 static struct imx_usbmisc *usbmisc;
@@ -65,7 +66,7 @@ static int usbmisc_imx6q_init(struct device *dev)
if (usbdev->disable_oc) {
spin_lock_irqsave(&usbmisc->lock, flags);
reg = readl(usbmisc->base + usbdev->index * 4);
-   writel(reg | BM_OVER_CUR_DIS,
+   writel(reg | MX6_BM_OVER_CUR_DIS,
usbmisc->base + usbdev->index * 4);
spin_unlock_irqrestore(&usbmisc->lock, flags);
}
@@ -78,7 +79,10 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = {
 };
 
 static const struct of_device_id usbmisc_imx_dt_ids[] = {
-   { .compatible = "fsl,imx6q-usbmisc"},
+   {
+   .compatible = "fsl,imx6q-usbmisc",
+   .data = &imx6q_usbmisc_ops,
+   },
{ /* sentinel */ }
 };
 
@@ -87,6 +91,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
struct resource *res;
struct imx_usbmisc *data;
int ret;
+   struct of_device_id *tmp_dev;
 
if (usbmisc)
return -EBUSY;
@@ -116,8 +121,11 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
return ret;
}
 
+   tmp_dev = (struct of_device_id *)
+   of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
+   data->ops = (const struct usbmisc_ops *)tmp_dev->data;
usbmisc = data;
-   ret = usbmisc_set_ops(&imx6q_usbmisc_ops);
+   ret = usbmisc_set_ops(data->ops);
if (ret) {
usbmisc = NULL;
clk_disable_unprepare(data->clk);
@@ -129,7 +137,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
 
 static int usbmisc_imx_remove(struct platform_device *pdev)
 {
-   usbmisc_unset_ops(&imx6q_usbmisc_ops);
+   usbmisc_unset_ops(usbmisc->ops);
clk_disable_unprepare(usbmisc->clk);
usbmisc = NULL;
return 0;
-- 
1.7.10.4

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


[PATCH v2 11/21] usb: chipidea: usbmisc: add mx53 support

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

This adds mx53 as the next user of the usbmisc driver and makes it
possible to disable the overcurrent-detection of the internal phy.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
[Alex: fixed another set of line-too-long and void pointer cast]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/usbmisc_imx.c |   54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index 08b046f..746013d 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -19,6 +19,13 @@
 
 #define USB_DEV_MAX 4
 
+#define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08
+#define MX53_USB_UH2_CTRL_OFFSET   0x14
+#define MX53_USB_UH3_CTRL_OFFSET   0x18
+#define MX53_BM_OVER_CUR_DIS_H1BIT(5)
+#define MX53_BM_OVER_CUR_DIS_OTG   BIT(8)
+#define MX53_BM_OVER_CUR_DIS_UHx   BIT(30)
+
 #define MX6_BM_OVER_CUR_DISBIT(7)
 
 struct imx_usbmisc {
@@ -52,6 +59,45 @@ static struct usbmisc_usb_device *get_usbdev(struct device 
*dev)
return &usbmisc->usbdev[i];
 }
 
+static int usbmisc_imx53_init(struct device *dev)
+{
+   struct usbmisc_usb_device *usbdev;
+   void __iomem *reg = NULL;
+   unsigned long flags;
+   u32 val = 0;
+
+   usbdev = get_usbdev(dev);
+   if (IS_ERR(usbdev))
+   return PTR_ERR(usbdev);
+
+   if (usbdev->disable_oc) {
+   spin_lock_irqsave(&usbmisc->lock, flags);
+   switch (usbdev->index) {
+   case 0:
+   reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+   val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
+   break;
+   case 1:
+   reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+   val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
+   break;
+   case 2:
+   reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
+   val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+   break;
+   case 3:
+   reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
+   val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+   break;
+   }
+   if (reg && val)
+   writel(val, reg);
+   spin_unlock_irqrestore(&usbmisc->lock, flags);
+   }
+
+   return 0;
+}
+
 static int usbmisc_imx6q_init(struct device *dev)
 {
 
@@ -74,12 +120,20 @@ static int usbmisc_imx6q_init(struct device *dev)
return 0;
 }
 
+static const struct usbmisc_ops imx53_usbmisc_ops = {
+   .init = usbmisc_imx53_init,
+};
+
 static const struct usbmisc_ops imx6q_usbmisc_ops = {
.init = usbmisc_imx6q_init,
 };
 
 static const struct of_device_id usbmisc_imx_dt_ids[] = {
{
+   .compatible = "fsl,imx53-usbmisc",
+   .data = &imx53_usbmisc_ops,
+   },
+   {
.compatible = "fsl,imx6q-usbmisc",
.data = &imx6q_usbmisc_ops,
},
-- 
1.7.10.4

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


[PATCH v2 12/21] usb: chipidea: usbmisc: add post handling and errata fix for mx25

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

This adds a post handling routine which is called after
ci13xxx_add_device was called. The first user is the mx25, which has to
disable the external-vbus-divider after the udc has started.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
[Alex: also fixed a signed one-bit bitfield a whitespace error and yet
 another set of line-too-long and void pointer casting errors]
Signed-off-by: Alexander Shishkin 
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|2 ++
 drivers/usb/chipidea/ci13xxx_imx.c |   12 +++
 drivers/usb/chipidea/ci13xxx_imx.h |3 ++
 drivers/usb/chipidea/usbmisc_imx.c |   36 
 4 files changed, 53 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 5778b9c..1c04a4c 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -11,6 +11,7 @@ Optional properties:
   that indicate usb controller index
 - vbus-supply: regulator for vbus
 - disable-over-current: disable over current detect
+- external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -20,4 +21,5 @@ usb@02184000 { /* USB OTG */
fsl,usbphy = <&usbphy1>;
fsl,usbmisc = <&usbmisc 0>;
disable-over-current;
+   external-vbus-divider;
 };
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..8faec9d 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -79,6 +79,9 @@ int usbmisc_get_init_data(struct device *dev, struct 
usbmisc_usb_device *usbdev)
if (of_find_property(np, "disable-over-current", NULL))
usbdev->disable_oc = 1;
 
+   if (of_find_property(np, "external-vbus-divider", NULL))
+   usbdev->evdo = 1;
+
return 0;
 }
 EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
@@ -202,6 +205,15 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
goto err;
}
 
+   if (usbmisc_ops && usbmisc_ops->post) {
+   ret = usbmisc_ops->post(&pdev->dev);
+   if (ret) {
+   dev_err(&pdev->dev,
+   "usbmisc post failed, ret=%d\n", ret);
+   goto put_np;
+   }
+   }
+
data->ci_pdev = plat_ci;
platform_set_drvdata(pdev, data);
 
diff --git a/drivers/usb/chipidea/ci13xxx_imx.h 
b/drivers/usb/chipidea/ci13xxx_imx.h
index 9cd2e91..550bfa4 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.h
+++ b/drivers/usb/chipidea/ci13xxx_imx.h
@@ -13,6 +13,8 @@
 struct usbmisc_ops {
/* It's called once when probe a usb device */
int (*init)(struct device *dev);
+   /* It's called once after adding a usb device */
+   int (*post)(struct device *dev);
 };
 
 struct usbmisc_usb_device {
@@ -20,6 +22,7 @@ struct usbmisc_usb_device {
int index;
 
unsigned int disable_oc:1; /* over current detect disabled */
+   unsigned int evdo:1; /* set external vbus divider option */
 };
 
 int usbmisc_set_ops(const struct usbmisc_ops *ops);
diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index 746013d..714a6bd 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -14,11 +14,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ci13xxx_imx.h"
 
 #define USB_DEV_MAX 4
 
+#define MX25_USB_PHY_CTRL_OFFSET   0x08
+#define MX25_BM_EXTERNAL_VBUS_DIVIDER  BIT(23)
+
 #define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08
 #define MX53_USB_UH2_CTRL_OFFSET   0x14
 #define MX53_USB_UH3_CTRL_OFFSET   0x18
@@ -59,6 +63,30 @@ static struct usbmisc_usb_device *get_usbdev(struct device 
*dev)
return &usbmisc->usbdev[i];
 }
 
+static int usbmisc_imx25_post(struct device *dev)
+{
+   struct usbmisc_usb_device *usbdev;
+   void __iomem *reg;
+   unsigned long flags;
+   u32 val;
+
+   usbdev = get_usbdev(dev);
+   if (IS_ERR(usbdev))
+   return PTR_ERR(usbdev);
+
+   reg = usbmisc->base + MX25_USB_PHY_CTRL_OFFSET;
+
+   if (usbdev->evdo) {
+   spin_lock_irqsave(&usbmisc->lock, flags);
+   val = readl(reg);
+   writel(val | MX25_BM_EXTERNAL_VBUS_DIVIDER, reg);
+   spin_unlock_irqrestore(&usbmisc->lock, flags);
+   usleep_range(5000, 1); /* needed to stabilize voltage */
+   }
+
+   return 0;
+}
+
 static int usbmisc_imx53_init(struct device *dev)
 {
struct usbmisc_usb_device *usbdev;
@@ -120,6 +148,10 @@ static int usbmisc_imx6q_init(struct device *dev)
return 0;
 }
 
+static const struct usbmisc_ops imx25_usbmisc_ops = {
+   .post = usbmisc_imx25_post,
+};
+
 static const struct usbmisc_ops imx53_usb

[PATCH v2 13/21] usb: chipidea: make pci platform datas static

2013-03-30 Thread Alexander Shishkin
PCI chipideas' platform datas are not static as all such things should
be. Fix it.

Reported-by: Marc Kleine-Budde 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/ci13xxx_pci.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_pci.c 
b/drivers/usb/chipidea/ci13xxx_pci.c
index 9b227e3..4e1fc61 100644
--- a/drivers/usb/chipidea/ci13xxx_pci.c
+++ b/drivers/usb/chipidea/ci13xxx_pci.c
@@ -23,17 +23,17 @@
 /**
  * PCI block
  */
-struct ci13xxx_platform_data pci_platdata = {
+static struct ci13xxx_platform_data pci_platdata = {
.name   = UDC_DRIVER_NAME,
.capoffset  = DEF_CAPOFFSET,
 };
 
-struct ci13xxx_platform_data langwell_pci_platdata = {
+static struct ci13xxx_platform_data langwell_pci_platdata = {
.name   = UDC_DRIVER_NAME,
.capoffset  = 0,
 };
 
-struct ci13xxx_platform_data penwell_pci_platdata = {
+static struct ci13xxx_platform_data penwell_pci_platdata = {
.name   = UDC_DRIVER_NAME,
.capoffset  = 0,
.power_budget   = 200,
-- 
1.7.10.4

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


[PATCH v2 14/21] usb: chipidea: big-endian support

2013-03-30 Thread Alexander Shishkin
From: Svetoslav Neykov 

Convert between big-endian and little-endian format when accessing the usb
controller structures which are little-endian by specification.
Fix cases where the little-endian memory layout is taken for granted.
The patch doesn't have any effect on the already supported little-endian
architectures.

Signed-off-by: Svetoslav Neykov 
[Alex: minor cosmetic fixes]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/core.c |2 +-
 drivers/usb/chipidea/udc.c  |   59 +++
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 114d4c4..450107e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -178,7 +178,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
 
ci->hw_bank.cap = ci->hw_bank.abs;
ci->hw_bank.cap += ci->platdata->capoffset;
-   ci->hw_bank.op = ci->hw_bank.cap + ioread8(ci->hw_bank.cap);
+   ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff);
 
hw_alloc_regmap(ci, false);
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 32e6c99..ff393e1 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -404,10 +404,10 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, 
struct ci13xxx_req *mReq)
return -ENOMEM;
 
memset(mReq->zptr, 0, sizeof(*mReq->zptr));
-   mReq->zptr->next= TD_TERMINATE;
-   mReq->zptr->token   = TD_STATUS_ACTIVE;
+   mReq->zptr->next= cpu_to_le32(TD_TERMINATE);
+   mReq->zptr->token   = cpu_to_le32(TD_STATUS_ACTIVE);
if (!mReq->req.no_interrupt)
-   mReq->zptr->token   |= TD_IOC;
+   mReq->zptr->token   |= cpu_to_le32(TD_IOC);
}
ret = usb_gadget_map_request(&ci->gadget, &mReq->req, mEp->dir);
if (ret)
@@ -418,32 +418,35 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, 
struct ci13xxx_req *mReq)
 * TODO - handle requests which spawns into several TDs
 */
memset(mReq->ptr, 0, sizeof(*mReq->ptr));
-   mReq->ptr->token= length << __ffs(TD_TOTAL_BYTES);
-   mReq->ptr->token   &= TD_TOTAL_BYTES;
-   mReq->ptr->token   |= TD_STATUS_ACTIVE;
+   mReq->ptr->token= cpu_to_le32(length << __ffs(TD_TOTAL_BYTES));
+   mReq->ptr->token   &= cpu_to_le32(TD_TOTAL_BYTES);
+   mReq->ptr->token   |= cpu_to_le32(TD_STATUS_ACTIVE);
if (mReq->zptr) {
-   mReq->ptr->next= mReq->zdma;
+   mReq->ptr->next= cpu_to_le32(mReq->zdma);
} else {
-   mReq->ptr->next= TD_TERMINATE;
+   mReq->ptr->next= cpu_to_le32(TD_TERMINATE);
if (!mReq->req.no_interrupt)
-   mReq->ptr->token  |= TD_IOC;
+   mReq->ptr->token  |= cpu_to_le32(TD_IOC);
+   }
+   mReq->ptr->page[0]  = cpu_to_le32(mReq->req.dma);
+   for (i = 1; i < 5; i++) {
+   u32 page = mReq->req.dma + i * CI13XXX_PAGE_SIZE;
+   page &= ~TD_RESERVED_MASK;
+   mReq->ptr->page[i] = cpu_to_le32(page);
}
-   mReq->ptr->page[0]  = mReq->req.dma;
-   for (i = 1; i < 5; i++)
-   mReq->ptr->page[i] =
-   (mReq->req.dma + i * CI13XXX_PAGE_SIZE) & 
~TD_RESERVED_MASK;
 
if (!list_empty(&mEp->qh.queue)) {
struct ci13xxx_req *mReqPrev;
int n = hw_ep_bit(mEp->num, mEp->dir);
int tmp_stat;
+   u32 next = mReq->dma & TD_ADDR_MASK;
 
mReqPrev = list_entry(mEp->qh.queue.prev,
struct ci13xxx_req, queue);
if (mReqPrev->zptr)
-   mReqPrev->zptr->next = mReq->dma & TD_ADDR_MASK;
+   mReqPrev->zptr->next = cpu_to_le32(next);
else
-   mReqPrev->ptr->next = mReq->dma & TD_ADDR_MASK;
+   mReqPrev->ptr->next = cpu_to_le32(next);
wmb();
if (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
goto done;
@@ -457,9 +460,9 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
}
 
/*  QH configuration */
-   mEp->qh.ptr->td.next   = mReq->dma;/* TERMINATE = 0 */
-   mEp->qh.ptr->td.token &= ~TD_STATUS;   /* clear status */
-   mEp->qh.ptr->cap |=  QH_ZLT;
+   mEp->qh.ptr->td.next   = cpu_to_le32(mReq->dma);/* TERMINATE = 0 */
+   mEp->qh.ptr->td.token &= cpu_to_le32(~TD_STATUS);   /* clear status */
+   mEp->qh.ptr->cap |=  cpu_to_le32(QH_ZLT);
 
wmb();   /* synchronize before ep prime */
 
@@ -481,11 +484,11 @@ static int _hardware_dequeue(struct ci1

[PATCH v2 16/21] usb: chipidea: udc: rework ep_enable cap setting

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

This patch reworks the cap value from several read
and write operations to one single operation.

Signed-off-by: Michael Grzeschik 
Reviewed-by: Felipe Balbi 
[Alex: removed useless isoc-related bit of code]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 0e11172..3abd1ad 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -986,6 +986,7 @@ static int ep_enable(struct usb_ep *ep,
struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
int retval = 0;
unsigned long flags;
+   u32 cap = 0;
 
if (ep == NULL || desc == NULL)
return -EINVAL;
@@ -1005,17 +1006,12 @@ static int ep_enable(struct usb_ep *ep,
 
mEp->ep.maxpacket = usb_endpoint_maxp(desc);
 
-   mEp->qh.ptr->cap = 0;
-
if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
-   mEp->qh.ptr->cap |=  cpu_to_le32(QH_IOS);
-   else if (mEp->type == USB_ENDPOINT_XFER_ISOC)
-   mEp->qh.ptr->cap &= cpu_to_le32(~QH_MULT);
-   else
-   mEp->qh.ptr->cap &= cpu_to_le32(~QH_ZLT);
+   cap |= QH_IOS;
+   cap |= (mEp->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT;
+
+   mEp->qh.ptr->cap = cpu_to_le32(cap);
 
-   mEp->qh.ptr->cap |= cpu_to_le32((mEp->ep.maxpacket << __ffs(QH_MAX_PKT))
-   & QH_MAX_PKT);
mEp->qh.ptr->td.next |= cpu_to_le32(TD_TERMINATE);   /* needed? */
 
/*
-- 
1.7.10.4

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


[PATCH v2 17/21] usb: chipidea: udc: move ZLT flag change to ep_enable

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

Its not necessary and also not specified in the datasheet to change the
ZLT flag before every ep_prime. This patch moves this to the ep_enable
and applies it only for non configuration endpoints.

Signed-off-by: Michael Grzeschik 
Reviewed-by: Felipe Balbi 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 3abd1ad..94af020 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -463,7 +463,6 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
mEp->qh.ptr->td.next   = cpu_to_le32(mReq->dma);/* TERMINATE = 0 */
mEp->qh.ptr->td.token &=
cpu_to_le32(~(TD_STATUS_HALTED|TD_STATUS_ACTIVE));
-   mEp->qh.ptr->cap |=  cpu_to_le32(QH_ZLT);
 
wmb();   /* synchronize before ep prime */
 
@@ -1008,6 +1007,8 @@ static int ep_enable(struct usb_ep *ep,
 
if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
cap |= QH_IOS;
+   if (mEp->num)
+   cap |= QH_ZLT;
cap |= (mEp->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT;
 
mEp->qh.ptr->cap = cpu_to_le32(cap);
-- 
1.7.10.4

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


[PATCH v2 18/21] usb: chipidea: udc: read status of td only once in hardware_dequeue

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

This patch changes the read of the td status to one atomic operation to
analyse coherent bits.

Signed-off-by: Michael Grzeschik 
[Alex: fixed backwards endianness conversion]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 94af020..20a5b79 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -481,10 +481,12 @@ done:
  */
 static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
 {
+   u32 tmptoken = le32_to_cpu(mReq->ptr->token);
+
if (mReq->req.status != -EALREADY)
return -EINVAL;
 
-   if ((cpu_to_le32(TD_STATUS_ACTIVE) & mReq->ptr->token) != 0)
+   if ((TD_STATUS_ACTIVE & tmptoken) != 0)
return -EBUSY;
 
if (mReq->zptr) {
@@ -498,7 +500,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
 
usb_gadget_unmap_request(&mEp->ci->gadget, &mReq->req, mEp->dir);
 
-   mReq->req.status = le32_to_cpu(mReq->ptr->token) & TD_STATUS;
+   mReq->req.status = tmptoken & TD_STATUS;
if ((TD_STATUS_HALTED & mReq->req.status) != 0)
mReq->req.status = -1;
else if ((TD_STATUS_DT_ERR & mReq->req.status) != 0)
@@ -506,7 +508,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
else if ((TD_STATUS_TR_ERR & mReq->req.status) != 0)
mReq->req.status = -1;
 
-   mReq->req.actual   = le32_to_cpu(mReq->ptr->token) & TD_TOTAL_BYTES;
+   mReq->req.actual   = tmptoken & TD_TOTAL_BYTES;
mReq->req.actual >>= __ffs(TD_TOTAL_BYTES);
mReq->req.actual   = mReq->req.length - mReq->req.actual;
mReq->req.actual   = mReq->req.status ? 0 : mReq->req.actual;
-- 
1.7.10.4

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


[PATCH v2 19/21] usb: chipidea: udc: don't truncate requests to single tds

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

It is not safe to truncate requests to the maximum possible size the
controller can handle with one td and to keep working. That patch fixes
that with proper error handling instead.

Reported-by: Felipe Balbi 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 20a5b79..0531532 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1158,9 +1158,9 @@ static int ep_queue(struct usb_ep *ep, struct usb_request 
*req,
}
 
if (req->length > 4 * CI13XXX_PAGE_SIZE) {
-   req->length = 4 * CI13XXX_PAGE_SIZE;
retval = -EMSGSIZE;
-   dev_warn(mEp->ci->dev, "request length truncated\n");
+   dev_err(mEp->ci->dev, "request bigger than one td\n");
+   goto done;
}
 
/* push request */
-- 
1.7.10.4

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


[PATCH v2 15/21] usb: chipidea: udc: only clear active and halted bits in qhead

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

The datasheet of the synopsys core describes only to overwrite the
active and halted bits in the qhead before priming any endpoint.

Signed-off-by: Michael Grzeschik 
Reviewed-by: Felipe Balbi 
[Alex: fixed a case of line-too-long]
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index ff393e1..0e11172 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -461,7 +461,8 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
 
/*  QH configuration */
mEp->qh.ptr->td.next   = cpu_to_le32(mReq->dma);/* TERMINATE = 0 */
-   mEp->qh.ptr->td.token &= cpu_to_le32(~TD_STATUS);   /* clear status */
+   mEp->qh.ptr->td.token &=
+   cpu_to_le32(~(TD_STATUS_HALTED|TD_STATUS_ACTIVE));
mEp->qh.ptr->cap |=  cpu_to_le32(QH_ZLT);
 
wmb();   /* synchronize before ep prime */
-- 
1.7.10.4

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


[PATCH v2 20/21] usb: chipidea: udc: move _ep_queue into an unlocked function

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

There is no need to call ep_queue unlocked inside the own driver. We
move its functionionality into an unlocked version.

This patch removes potential unlocked timeslots inside
isr_setup_status_phase and isr_get_status_response, in which the lock
got released just before acquired again inside usb_ep_queue.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
Reviewed-by: Peter Chen 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/udc.c |  104 
 1 file changed, 56 insertions(+), 48 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 0531532..ec218b0 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -643,6 +643,59 @@ static void isr_get_status_complete(struct usb_ep *ep, 
struct usb_request *req)
 }
 
 /**
+ * _ep_queue: queues (submits) an I/O request to an endpoint
+ *
+ * Caller must hold lock
+ */
+static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
+   gfp_t __maybe_unused gfp_flags)
+{
+   struct ci13xxx_ep  *mEp  = container_of(ep,  struct ci13xxx_ep, ep);
+   struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
+   struct ci13xxx *ci = mEp->ci;
+   int retval = 0;
+
+   if (ep == NULL || req == NULL || mEp->ep.desc == NULL)
+   return -EINVAL;
+
+   if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
+   if (req->length)
+   mEp = (ci->ep0_dir == RX) ?
+  ci->ep0out : ci->ep0in;
+   if (!list_empty(&mEp->qh.queue)) {
+   _ep_nuke(mEp);
+   retval = -EOVERFLOW;
+   dev_warn(mEp->ci->dev, "endpoint ctrl %X nuked\n",
+_usb_addr(mEp));
+   }
+   }
+
+   /* first nuke then test link, e.g. previous status has not sent */
+   if (!list_empty(&mReq->queue)) {
+   dev_err(mEp->ci->dev, "request already in queue\n");
+   return -EBUSY;
+   }
+
+   if (req->length > 4 * CI13XXX_PAGE_SIZE) {
+   dev_err(mEp->ci->dev, "request bigger than one td\n");
+   return -EMSGSIZE;
+   }
+
+   /* push request */
+   mReq->req.status = -EINPROGRESS;
+   mReq->req.actual = 0;
+
+   retval = _hardware_enqueue(mEp, mReq);
+
+   if (retval == -EALREADY)
+   retval = 0;
+   if (!retval)
+   list_add_tail(&mReq->queue, &mEp->qh.queue);
+
+   return retval;
+}
+
+/**
  * isr_get_status_response: get_status request response
  * @ci: ci struct
  * @setup: setup request packet
@@ -689,9 +742,7 @@ __acquires(mEp->lock)
}
/* else do nothing; reserved for future use */
 
-   spin_unlock(mEp->lock);
-   retval = usb_ep_queue(&mEp->ep, req, gfp_flags);
-   spin_lock(mEp->lock);
+   retval = _ep_queue(&mEp->ep, req, gfp_flags);
if (retval)
goto err_free_buf;
 
@@ -738,8 +789,6 @@ isr_setup_status_complete(struct usb_ep *ep, struct 
usb_request *req)
  * This function returns an error code
  */
 static int isr_setup_status_phase(struct ci13xxx *ci)
-__releases(mEp->lock)
-__acquires(mEp->lock)
 {
int retval;
struct ci13xxx_ep *mEp;
@@ -748,9 +797,7 @@ __acquires(mEp->lock)
ci->status->context = ci;
ci->status->complete = isr_setup_status_complete;
 
-   spin_unlock(mEp->lock);
-   retval = usb_ep_queue(&mEp->ep, ci->status, GFP_ATOMIC);
-   spin_lock(mEp->lock);
+   retval = _ep_queue(&mEp->ep, ci->status, GFP_ATOMIC);
 
return retval;
 }
@@ -1128,8 +1175,6 @@ static int ep_queue(struct usb_ep *ep, struct usb_request 
*req,
gfp_t __maybe_unused gfp_flags)
 {
struct ci13xxx_ep  *mEp  = container_of(ep,  struct ci13xxx_ep, ep);
-   struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
-   struct ci13xxx *ci = mEp->ci;
int retval = 0;
unsigned long flags;
 
@@ -1137,44 +1182,7 @@ static int ep_queue(struct usb_ep *ep, struct 
usb_request *req,
return -EINVAL;
 
spin_lock_irqsave(mEp->lock, flags);
-
-   if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
-   if (req->length)
-   mEp = (ci->ep0_dir == RX) ?
-  ci->ep0out : ci->ep0in;
-   if (!list_empty(&mEp->qh.queue)) {
-   _ep_nuke(mEp);
-   retval = -EOVERFLOW;
-   dev_warn(mEp->ci->dev, "endpoint ctrl %X nuked\n",
-_usb_addr(mEp));
-   }
-   }
-
-   /* first nuke then test link, e.g. previous status has not sent */
-   if (!list_empty(&mReq->queue)) {
-   retval = -EBUSY;
-   dev_err(mEp->ci->dev, "request already in queue\n");
-   goto done;

[PATCH v2 21/21] usb: chipidea: udc: add the define TD_PAGE_COUNT and fix all users

2013-03-30 Thread Alexander Shishkin
From: Michael Grzeschik 

A static count of transfer descriptors was used everywhere in the driver
with the fixed number 5. This patch adds a define, named TD_PAGE_COUNT,
and replaces all users of this value. This way its possible to have only
one parameter to change and limit the amount of buffer pointers per TD.

Signed-off-by: Michael Grzeschik 
Reviewed-by: Peter Chen 
Signed-off-by: Alexander Shishkin 
---
 drivers/usb/chipidea/ci.h  |1 +
 drivers/usb/chipidea/udc.c |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 68577d1..b0a6bce 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -21,6 +21,7 @@
 /**
  * DEFINE
  */
+#define TD_PAGE_COUNT  5
 #define CI13XXX_PAGE_SIZE  4096ul /* page size for TD's */
 #define ENDPT_MAX  32
 
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index ec218b0..e502e48 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -429,7 +429,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct 
ci13xxx_req *mReq)
mReq->ptr->token  |= cpu_to_le32(TD_IOC);
}
mReq->ptr->page[0]  = cpu_to_le32(mReq->req.dma);
-   for (i = 1; i < 5; i++) {
+   for (i = 1; i < TD_PAGE_COUNT; i++) {
u32 page = mReq->req.dma + i * CI13XXX_PAGE_SIZE;
page &= ~TD_RESERVED_MASK;
mReq->ptr->page[i] = cpu_to_le32(page);
@@ -676,7 +676,7 @@ static int _ep_queue(struct usb_ep *ep, struct usb_request 
*req,
return -EBUSY;
}
 
-   if (req->length > 4 * CI13XXX_PAGE_SIZE) {
+   if (req->length > (TD_PAGE_COUNT - 1) * CI13XXX_PAGE_SIZE) {
dev_err(mEp->ci->dev, "request bigger than one td\n");
return -EMSGSIZE;
}
-- 
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/7] USB: EHCI: make ehci-orion a separate driver

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:
> I don't know about this last phrase.  When someone is running "make 
> menuconfig", for example, what shows up is the symbol's description, 
> not the symbol's name.  That person would see "EHCI support for Marvell 
> on-chip controller", not "USB_EHCI_MV".
> 
> In fact, shouldn't the description for USB_EHCI_MV be changed too, to 
> make it more distinct from this one?
> 
> All the code changes are fine.

Ok, I've included these Kconfig changes. Originally, the text change
for PXA/MMP was included in the patch for ehci-mv, but that one is
deferred to 3.11 now because of dependencies for the platform code that
we want to first merge in 3.10.

Arnd
--
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 12/27] usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx

2013-03-30 Thread Marc Kleine-Budde
On 03/30/2013 01:46 AM, Alexander Shishkin wrote:
> From: Michael Grzeschik 
> 
> This driver will be used for every Freescale SoC which has this misc
> memory layout to control the basic usb handling. So better name this
> driver, function and struct names in a more generic way.
> 
> Reported-by: Fabio Estevam 
> Signed-off-by: Michael Grzeschik 
> Signed-off-by: Marc Kleine-Budde 
> Signed-off-by: Alexander Shishkin 
> 
> Conflicts:
>   drivers/usb/chipidea/usbmisc_imx.c

You've hopefully resolved the conflict before creating a this patch, so
remove this line :)

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3 2/7] USB: EHCI: make ehci-spear a separate driver

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:
> On Thu, 28 Mar 2013, Arnd Bergmann wrote:
> 
> > From: Manjunath Goudar 
> > 
> > Separate the SPEAr host controller driver from ehci-hcd host code
> > so that it can be built as a separate driver module.
> > This work is part of enabling multi-platform kernels on ARM;
> > however, note that other changes are still needed before SPEAr can be
> > booted with a multi-platform kernel, but they are queued in the
> > arm-soc tree for 3.10.
> > 
> > With the infrastructure added by Alan Stern in patch 3e0232039
> > "USB: EHCI: prepare to make ehci-hcd a library module", we can
> > avoid this problem by turning a bus glue into a separate
> > module, as we do here for the SPEAr bus glue.
> > 
> > In V3:
> >  -Detailed commit message added here about why this patch is required.
> >  -Eliminated ehci_spear_setup routine beacuse hcd registers
> >   directly setting in spear_ehci_hcd_drv_probe function.
> 
> Fix the grammar, please.

Done. I agree some of this is hardly legible.

Manjunath, I can teach you about device drivers and submission
procedures, but I cannot teach you basic English. If necessary, find
someone to proofread your emails.
> > -static int ehci_spear_setup(struct usb_hcd *hcd)
> > -{
> > -   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
> > -
> > -   /* registers start at offset 0x0 */
> > -   ehci->caps = hcd->regs;
> 
> This line never got moved into spear_ehci_hcd_drv_probe().

Ah, I missed it. Thanks for looking at this more carefully than
I did.

> > @@ -161,7 +130,7 @@ static int spear_ehci_hcd_drv_probe(struct 
> > platform_device *pdev)
> > goto err_put_hcd;
> > }
> >  
> > -   ehci = (struct spear_ehci *)hcd_to_ehci(hcd);
> > +   ehci = to_spear_ehci(hcd);
> > ehci->clk = usbh_clk;
> 
> I strongly believe that the name "ehci" should be reserved for
> variables of type struct ehci_hcd.  Here and in the start, stop, and
> remove routines, please use "spear_ehci" as the name for a variable of
> type struct spear_ehci.  Or whatever else you want -- just don't call
> it "ehci" or "ehci_p".

Ok, renamed to "sehci" in lack of a better idea. I noticed this before,
but I did not ask Manjunath to fix it because it was a preexisting mistake
in the driver.

Arnd
--
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 3/7] USB: EHCI: make ehci-s5p a separate driver

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:
> On Thu, 28 Mar 2013, Arnd Bergmann wrote:

> 
> Personally, I would have left these two functions the way they were and 
> relied on the compiler to inline them when appropriate.  Eliminating 
> them just makes the code more complicated.

Yes, makes sense. I'm leaving the change in now, because I don't
see a strong reason to undo the change, and the two functions
will likely get collapsed into a single line each after the move
to the phy subsystem is complete.

> >  static int s5p_ehci_probe(struct platform_device *pdev)
> >  {
> > +   struct usb_hcd *hcd ;
> > struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
> > +   const struct hc_driver *driver = &s5p_ehci_hc_driver;
> > struct s5p_ehci_hcd *s5p_ehci;
> > -   struct usb_hcd *hcd;
> 
> What's the reason for these changes?  There's no need for the "driver" 
> variable, and improper whitespace was added to the declaration of 
> "hcd".

I'll let Manjunath answer this, I have no idea. My suspicion is that
it was a misguided attempt to work around a checkpatch warning for
an overly long line.

I've reverted the above changes now for v4.

> > @@ -153,16 +117,12 @@ static int s5p_ehci_probe(struct platform_device 
> > *pdev)
> > s5p_ehci->otg = phy->otg;
> > }
> >  
> > -   s5p_ehci->dev = &pdev->dev;
> > -
> > -   hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
> > -   dev_name(&pdev->dev));
> > +   hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
> 
> s5p_ehci is not initialized correctly.  The devm_kzalloc() call was 
> left in and to_s5p_ehci() was not called.

Oh crap.

I checked that Manjunath had fixed this bug in the other drivers, but
missed it here. I updated it for v4 now.

> Was anybody able to test this patch?

I thought that Manjunath had received hardware for it now, but it's pretty
evident that the patch was not tested. The Ack from Jingoo Han was for an
older version that did not contain the change to .extra_priv_size.

Arnd
--
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 5/7] USB: EHCI: make ehci-atmel a separate driver

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:

> While not absolutely necessary, it would be nice to have the #include 
> files in alphabetical order.
> 
> > +
> > +#include "ehci.h"
> > +
> > +#define DRIVER_DESC "EHCI atmel driver"
> 
> "atmel" should have a capital 'A'.
> 

Ok, added these changes for v4 along with Nicolas' Ack,
and removed the call to ehci_shutdown.

Arnd
--
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 6/7] USB: EHCI: make ehci-msm a separate driver

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:
> On Thu, 28 Mar 2013, Arnd Bergmann wrote:

> This patch is good.  However the ehci-msm driver itself is not.  While
> checking through the code, I was struck by the fact that it never calls
> usb_add_hcd() or usb_remove_hcd().  Obviously the driver cannot work
> properly.
> 
> In addition, it stores the PHY pointer in a global variable.  
> (ehci-atmel does much the same thing for its clocks.)  This means the
> driver cannot be used on a system having more than one EHCI controller.  
> Maybe this doesn't matter, though.
> 
> Maybe somebody would like to fix and test it...

I'm not too surprised. The driver was added the last time that the MSM
maintainers started a serious attempt to get a lot of their code mainlined,
a little over two years ago. While there is some activity from Qualcomm
in specific areas of the code every now and then, they literally have
thousands of patches on top of the kernel that they use in actual
products and I would not expect a mainline kernel to actually work on
any recent Qualcomm hardware.

Arnd
--
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 7/7] USB: OHCI: avoid conflicting platform drivers

2013-03-30 Thread Arnd Bergmann
On Friday 29 March 2013, Alan Stern wrote:
> I have not checked the details of all the changes; however, the basic
> idea is okay as a stop-gap measure.

Ok, thanks. 

> I guess this means the onus is now on me to split up ohci-hcd into a 
> central library and separate bus drivers, like ehci-hcd...

The original plan in my teams was that Manjunath would do that after
he was done with the simple conversion of the EHCI drivers. I think we
can all agree now that it's better if you at least the groundwork instead.

Please let us know if you would like Manjunath to continue with splitting
out the OHCI back-ends into separate drivers, or if you think that there
is no point given the quality of the earlier patches.

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


[PATCH v4 1/6] USB: EHCI: make ehci-orion a separate driver

2013-03-30 Thread Arnd Bergmann
From: Manjunath Goudar 

Separate the Orion host controller driver from ehci-hcd host
code into its own driver module because of following reason.

With the multiplatform changes in arm-soc tree, it becomes
possible to enable the mvebu platform (which uses
ehci-orion) at the same time as other platforms that require
a conflicting EHCI bus glue. At the moment, this results
in a warning like

drivers/usb/host/ehci-hcd.c:1297:0: warning: "PLATFORM_DRIVER" redefined 
[enabled by default]
drivers/usb/host/ehci-hcd.c:1277:0: note: this is the location of the previous 
definition
drivers/usb/host/ehci-orion.c:334:31: warning: 'ehci_orion_driver' defined but 
not used [-Wunused-variable]

and an ehci driver that only works on one of them.

With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the orion bus glue.

An earlier version of this patch was included in 3.9 but caused
a regression there, which has subsequently been fixed.

While we are here, use the opportunity to disabiguate the two
Marvell EHCI controller implementations in Kconfig.

In V3:
1.More detail provided in commit message regarding this patch.
2.Replaced hcd_name string "ehci-orion" into "orion-ehci".
3.MODULE_LICENSE is GPL v2.
4.In ehci_init_driver calling second argument passed  as NULL instead of
   ehci_orion_overrides because ehci_orion_overrides is removed.

In V2:
Tegra patch related changes removed from this patch.

Signed-off-by: Manjunath Goudar 
Signed-off-by: Arnd Bergmann 
Acked-by: Jason Cooper 
Tested-by: Andrew Lunn 
Cc: Greg KH 
Cc: Alan Stern 
Cc: Russell King 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 drivers/usb/host/Kconfig  | 17 -
 drivers/usb/host/Makefile |  1 +
 drivers/usb/host/ehci-hcd.c   |  6 +---
 drivers/usb/host/ehci-orion.c | 82 ++-
 4 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2f68221..e5649c1 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -163,6 +163,17 @@ config USB_EHCI_HCD_OMAP
  Enables support for the on-chip EHCI controller on
  OMAP3 and later chips.
 
+config USB_EHCI_HCD_ORION
+   tristate  "Support for Marvell EBU on-chip EHCI USB controller"
+   depends on USB_EHCI_HCD && PLAT_ORION
+   default y
+   ---help---
+ Enables support for the on-chip EHCI controller on Marvell's
+ embedded ARM SoCs, including Orion, Kirkwood, Dove, Armada XP,
+ Armada 370.  This is different from the EHCI implementation
+ on Marvell's mobile PXA and MMP SoC, see "EHCI support for
+ Marvell PXA/MMP USB controller" for those.
+
 config USB_EHCI_MSM
bool "Support for MSM on-chip EHCI USB controller"
depends on USB_EHCI_HCD && ARCH_MSM
@@ -206,13 +217,17 @@ config USB_EHCI_S5P
 Enable support for the S5P SOC's on-chip EHCI controller.
 
 config USB_EHCI_MV
-   bool "EHCI support for Marvell on-chip controller"
+   bool "EHCI support for Marvell PXA/MMP USB controller"
depends on USB_EHCI_HCD && (ARCH_PXA || ARCH_MMP)
select USB_EHCI_ROOT_HUB_TT
---help---
  Enables support for Marvell (including PXA and MMP series) on-chip
  USB SPH and OTG controller. SPH is a single port host, and it can
  only be EHCI host. OTG is controller that can switch to host mode.
+ Note that this driver will not work on Marvell's other EHCI
+ controller used by the EBU-type SoCs including Orion, Kirkwood,
+ Dova, Armada 370 and Armada XP. See "Support for Marvell EBU
+ on-chip EHCI USB controller" for those.
 
 config USB_W90X900_EHCI
bool "W90X900(W90P910) EHCI support"
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 56de410..9492f50 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_USB_EHCI_PCI)+= ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)+= ehci-platform.o
 obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 obj-$(CONFIG_USB_EHCI_HCD_OMAP)+= ehci-omap.o
+obj-$(CONFIG_USB_EHCI_HCD_ORION)   += ehci-orion.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index b12b97d..1f97268 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1249,11 +1249,6 @@ MODULE_LICENSE ("GPL");
 #define XILINX_OF_PLATFORM_DRIVER  ehci_hcd_xilinx_of_driver
 #endif
 
-#ifdef CONFIG_PLAT_ORION
-#include "ehci-orion.c"
-#definePLATFORM_DRIVER ehci_orion_driver
-#endif
-
 #ifdef CONFIG_USB_W90X900_EHCI
 #include "ehci-w90x900.c"
 #definePLATFORM_DRIVER ehci_hcd_w90x90

[PATCH v4 3/6] USB: EHCI: make ehci-s5p a separate driver

2013-03-30 Thread Arnd Bergmann
From: Manjunath Goudar 

Separate the  Samsung S5P/EXYNOS host controller driver from ehci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM;
however, note that other changes are still needed before S5P/EXYNOS can
be booted with a multi-platform kernel. We currently expect those
to get merged for 3.10.

With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the s5p bus glue.

In V4 (arnd)
 - revert some of the pointless changes.
 - fix allocation of s5p specific data structure.

In V3:
 -Detail commit message added here,why this patch is required.
 -MODULE_LICENSE is GPL v2.
 -Added .extra_priv_size to eliminate the separate allocation of the 
s5p_ehci_hcd structure
  and removed .reset function pointer initialization.
 -Arranged  #include's in alphabetical order.
 -After using extra_priv_size initialization,struct usb_hcd *hcd is redundant 
that's why removed
  from the prob function.
 -Eliminated s5p_ehci_phy_enable,contents of statements moved into the 
s5p_ehci_probe
 -Eliminated s5p_ehci_phy_disable, contents of statements moved into the 
s5p_ehci_remove.

In V2:
Tegra patch related changes removed from this patch.

Signed-off-by: Manjunath Goudar 
Acked-by: Jingoo Han 
Cc: Greg KH 
Cc: Alan Stern 
Cc: Kukjin Kim 
Cc: Kyungmin Park 
Cc: Grant Likely 
Cc: Rob Herring 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Arnd Bergmann 
---
 drivers/usb/host/Kconfig|   5 +-
 drivers/usb/host/Makefile   |   1 +
 drivers/usb/host/ehci-hcd.c |   6 +-
 drivers/usb/host/ehci-s5p.c | 164 +---
 4 files changed, 85 insertions(+), 91 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 4723f79..98abec0f 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -219,10 +219,11 @@ config USB_EHCI_SH
  If you use the PCI EHCI controller, this option is not necessary.
 
 config USB_EHCI_S5P
-   boolean "S5P EHCI support"
+   tristate "EHCI support for Samsung S5P/EXYNOS SoC Series"
depends on USB_EHCI_HCD && PLAT_S5P
help
-Enable support for the S5P SOC's on-chip EHCI controller.
+   Enable support for the Samsung S5P and Exynos3/4/5 SOC's
+   on-chip EHCI controller.
 
 config USB_EHCI_MV
bool "EHCI support for Marvell PXA/MMP USB controller"
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 3e02471..3d895b5 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_USB_EHCI_MXC)+= ehci-mxc.o
 obj-$(CONFIG_USB_EHCI_HCD_OMAP)+= ehci-omap.o
 obj-$(CONFIG_USB_EHCI_HCD_ORION)   += ehci-orion.o
 obj-$(CONFIG_USB_EHCI_HCD_SPEAR)   += ehci-spear.o
+obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c8c70a1..8f1f4b4 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1284,11 +1284,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERtegra_ehci_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_S5P
-#include "ehci-s5p.c"
-#define PLATFORM_DRIVERs5p_ehci_driver
-#endif
-
 #ifdef CONFIG_SPARC_LEON
 #include "ehci-grlib.c"
 #define PLATFORM_DRIVERehci_grlib_driver
@@ -1311,6 +1306,7 @@ MODULE_LICENSE ("GPL");
!IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_ORION) && \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_SPEAR) && \
+   !IS_ENABLED(CONFIG_USB_EHCI_S5P) && \
!defined(PLATFORM_DRIVER) && \
!defined(PS3_SYSTEM_BUS_DRIVER) && \
!defined(OF_PLATFORM_DRIVER) && \
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 738490e..3147984 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -13,13 +13,24 @@
  */
 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define DRIVER_DESC "EHCI s5p driver"
 
 #define EHCI_INSNREG00(base)   (base + 0x90)
 #define EHCI_INSNREG00_ENA_INCR16  (0x1 << 25)
@@ -30,65 +41,17 @@
(EHCI_INSNREG00_ENA_INCR16 | EHCI_INSNREG00_ENA_INCR8 | \
 EHCI_INSNREG00_ENA_INCR4 | EHCI_INSNREG00_ENA_INCRX_ALIGN)
 
+static const char hcd_name[] = "ehci-s5p";
+static struct hc_driver __read_mostly s5p_ehci_hc_driver;
+
 struct s5p_ehci_hcd {
-   struct device *dev;
-   struct usb_hcd *hcd;
struct clk *clk;
struct usb_phy *phy;
struct usb_otg *otg;
struct s5p_ehci_platdata *pdata;
 };
 
-stati

[PATCH v4 5/6] USB: EHCI: make ehci-msm a separate driver

2013-03-30 Thread Arnd Bergmann
From: Manjunath Goudar 

Separate the  Qualcomm QSD/MSM on-chip host controller driver from
ehci-hcd host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM;
however, note that other changes are still needed before Qualcomm QSD/MSM
can be booted with a multi-platform kernel, which is not expected before
3.11.

With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the msm bus glue.

In V3:
1.Detail commit message added here,why this patch is required.
2.Arranged  #include's in alphabetical order.
3.drive.name initialized hcd_name[] = "ehci-msm" in platform_driver structure 
initialization
 instead of "msm-ehci",that is reason it was breaking in EHCI USB testing.this 
one fixed in V3.

In V2:
Tegra patch related changes removed from this patch.

Signed-off-by: Manjunath Goudar 
Cc: Greg KH 
Cc: Alan Stern 
Cc: David Brown 
Cc: Daniel Walker 
Cc: Bryan Huntsman 
Cc: Brian Swetland 
Cc: linux-usb@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Arnd Bergmann 
---
 drivers/usb/host/Kconfig|  2 +-
 drivers/usb/host/Makefile   |  1 +
 drivers/usb/host/ehci-hcd.c |  6 +---
 drivers/usb/host/ehci-msm.c | 85 -
 4 files changed, 40 insertions(+), 54 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f6f7872..b9cdbbb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -191,7 +191,7 @@ config USB_EHCI_HCD_AT91
   Atmel chips.
 
 config USB_EHCI_MSM
-   bool "Support for MSM on-chip EHCI USB controller"
+   tristate "Support for Qualcomm QSD/MSM on-chip EHCI USB controller"
depends on USB_EHCI_HCD && ARCH_MSM
select USB_EHCI_ROOT_HUB_TT
select USB_MSM_OTG
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 368d3eb..4fb73c1 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_USB_EHCI_HCD_ORION)  += ehci-orion.o
 obj-$(CONFIG_USB_EHCI_HCD_SPEAR)   += ehci-spear.o
 obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
+obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index ccc78ab..2e0c2bd 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1259,11 +1259,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERehci_octeon_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_MSM
-#include "ehci-msm.c"
-#define PLATFORM_DRIVERehci_msm_driver
-#endif
-
 #ifdef CONFIG_TILE_USB
 #include "ehci-tilegx.c"
 #definePLATFORM_DRIVER ehci_hcd_tilegx_driver
@@ -1303,6 +1298,7 @@ MODULE_LICENSE ("GPL");
!IS_ENABLED(CONFIG_USB_EHCI_HCD_SPEAR) && \
!IS_ENABLED(CONFIG_USB_EHCI_S5P) && \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_AT91) && \
+   !IS_ENABLED(CONFIG_USB_EHCI_MSM) && \
!defined(PLATFORM_DRIVER) && \
!defined(PS3_SYSTEM_BUS_DRIVER) && \
!defined(OF_PLATFORM_DRIVER) && \
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 88a49c8..3b45f0c 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -22,16 +22,26 @@
  * along with this program; if not, you can find it at http://www.fsf.org
  */
 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
-
 #include 
 #include 
+#include 
+#include 
+
+#include "ehci.h"
 
 #define MSM_USB_BASE (hcd->regs)
 
+#define DRIVER_DESC "Qualcomm On-Chip EHCI Host Controller"
+
+static const char hcd_name[] = "ehci-msm";
+static struct hc_driver __read_mostly msm_hc_driver;
 static struct usb_phy *phy;
 
 static int ehci_msm_reset(struct usb_hcd *hcd)
@@ -56,52 +66,6 @@ static int ehci_msm_reset(struct usb_hcd *hcd)
return 0;
 }
 
-static struct hc_driver msm_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = "Qualcomm On-Chip EHCI Host Controller",
-   .hcd_priv_size  = sizeof(struct ehci_hcd),
-
-   /*
-* generic hardware linkage
-*/
-   .irq= ehci_irq,
-   .flags  = HCD_USB2 | HCD_MEMORY,
-
-   .reset  = ehci_msm_reset,
-   .start  = ehci_run,
-
-   .stop   = ehci_stop,
-   .shutdown   = ehci_shutdown,
-
-   /*
-* managing i/o requests and associated device resources
-*/
-   .urb_enqueue= ehci_urb_enqueue,
-   .urb_dequeue= ehci_urb_dequeue,
-   .endpoint_disable   = ehci_endpoint_disable,
-   .endpoint_re

[PATCH v4 2/6] USB: EHCI: make ehci-spear a separate driver

2013-03-30 Thread Arnd Bergmann
From: Manjunath Goudar 

Separate the SPEAr host controller driver from ehci-hcd host code
so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM;
however, note that other changes are still needed before SPEAr can be
booted with a multi-platform kernel, but they are queued in the
arm-soc tree for 3.10.

With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the SPEAr bus glue.

In V4 (arnd):
 - renamed all 'struct spear_ehci' pointers from 'ehci' to the
   less ambiguous 'sehci'.
 - folded trivial spear_start_ehci/spear_stop_ehci functions into
   callers.
 - brought back initialization of ehci->caps.

In V3:
 - Detailed commit message added here about why this patch is required.
 - Eliminated ehci_spear_setup routine because hcd registers can
   be directly set in the spear_ehci_hcd_drv_probe function.
 - spear_overrides struct initialized.
 - Converted to using .extra_priv_size for allocating spear_ehci,
   and updated all users of that structure.
 - to_spear_ehci() macro modified for spear_ehci.

In V2:
 - Replaced spear as SPEAr everywhere, leaving functions/variables/config 
options.

Signed-off-by: Deepak Saxena 
Signed-off-by: Manjunath Goudar 
Signed-off-by: Arnd Bergmann 
Acked-by: Viresh Kumar 
Cc: Greg KH 
Cc: Alan Stern 
Cc: Shiraz Hashim 
Cc: linux-usb@vger.kernel.org
Cc: spear-de...@list.st.com
---
 drivers/usb/host/Kconfig  |   8 +++
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ehci-hcd.c   |   6 +--
 drivers/usb/host/ehci-spear.c | 115 +++---
 4 files changed, 61 insertions(+), 69 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index e5649c1..4723f79 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -174,6 +174,14 @@ config USB_EHCI_HCD_ORION
  on Marvell's mobile PXA and MMP SoC, see "EHCI support for
  Marvell PXA/MMP USB controller" for those.
 
+config USB_EHCI_HCD_SPEAR
+tristate "Support for ST SPEAr on-chip EHCI USB controller"
+depends on USB_EHCI_HCD && PLAT_SPEAR
+default y
+---help---
+  Enables support for the on-chip EHCI controller on
+  ST SPEAr chips.
+
 config USB_EHCI_MSM
bool "Support for MSM on-chip EHCI USB controller"
depends on USB_EHCI_HCD && ARCH_MSM
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 9492f50..3e02471 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)   += ehci-platform.o
 obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 obj-$(CONFIG_USB_EHCI_HCD_OMAP)+= ehci-omap.o
 obj-$(CONFIG_USB_EHCI_HCD_ORION)   += ehci-orion.o
+obj-$(CONFIG_USB_EHCI_HCD_SPEAR)   += ehci-spear.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 1f97268..c8c70a1 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1264,11 +1264,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERehci_octeon_driver
 #endif
 
-#ifdef CONFIG_PLAT_SPEAR
-#include "ehci-spear.c"
-#define PLATFORM_DRIVERspear_ehci_hcd_driver
-#endif
-
 #ifdef CONFIG_USB_EHCI_MSM
 #include "ehci-msm.c"
 #define PLATFORM_DRIVERehci_msm_driver
@@ -1315,6 +1310,7 @@ MODULE_LICENSE ("GPL");
!IS_ENABLED(CONFIG_USB_EHCI_MXC) && \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_ORION) && \
+   !IS_ENABLED(CONFIG_USB_EHCI_HCD_SPEAR) && \
!defined(PLATFORM_DRIVER) && \
!defined(PS3_SYSTEM_BUS_DRIVER) && \
!defined(OF_PLATFORM_DRIVER) && \
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 210bb67..61ecfb3 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -1,5 +1,5 @@
 /*
-* Driver for EHCI HCD on SPEAR SOC
+* Driver for EHCI HCD on SPEAr SOC
 *
 * Copyright (C) 2010 ST Micro Electronics,
 * Deepak Sikri 
@@ -12,71 +12,30 @@
 */
 
 #include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
-struct spear_ehci {
-   struct ehci_hcd ehci;
-   struct clk *clk;
-};
-
-#define to_spear_ehci(hcd) (struct spear_ehci *)hcd_to_ehci(hcd)
+#include "ehci.h"
 
-static void spear_start_ehci(struct spear_ehci *ehci)
-{
-   clk_prepare_enable(ehci->clk);
-}
+#define DRIVER_DESC "EHCI SPEAr driver"
 
-static void spear_stop_ehci(struct spear_ehci *ehci)
-{
-   clk_disable_unprepare(ehci->clk);
-}
+static const char hcd_name[] = "SPEAr-ehci";
 
-static int ehci_spear_setup(struct usb_hcd *hcd)
-{
-   struct ehci_hcd *ehci = hcd

[PATCH v4 0/6] USB EHCI multiplatform conversion

2013-03-30 Thread Arnd Bergmann
Hi Alan,

This is a quick update to v3, addressing all issues you pointed in
yesterday's review. Thanks for taking a thorough look on short notice
on a public holiday!

Arnd

Arnd Bergmann (1):
  USB: OHCI: avoid conflicting platform drivers

Manjunath Goudar (5):
  USB: EHCI: make ehci-orion a separate driver
  USB: EHCI: make ehci-spear a separate driver
  USB: EHCI: make ehci-s5p a separate driver
  USB: EHCI: make ehci-atmel a separate driver
  USB: EHCI: make ehci-msm a separate driver

 drivers/usb/host/Kconfig  |  40 +--
 drivers/usb/host/Makefile |   5 ++
 drivers/usb/host/ehci-atmel.c |  88 +++
 drivers/usb/host/ehci-hcd.c   |  30 ++--
 drivers/usb/host/ehci-msm.c   |  85 ++
 drivers/usb/host/ehci-orion.c |  82 +
 drivers/usb/host/ehci-s5p.c   | 164 +-
 drivers/usb/host/ehci-spear.c | 115 +
 drivers/usb/host/ohci-hcd.c   | 136 ++-
 9 files changed, 408 insertions(+), 337 deletions(-)

-- 
1.8.1.2

Cc: Alan Stern 
Cc: Bryan Huntsman 
Cc: David Brown 
Cc: Greg KH 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Kukjin Kim 
Cc: Kyungmin Park 
Cc: Manjunath Goudar 
Cc: Nicolas Ferre 
Cc: Shiraz Hashim 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: spear-de...@list.st.com


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


[PATCH v4 4/6] USB: EHCI: make ehci-atmel a separate driver

2013-03-30 Thread Arnd Bergmann
From: Manjunath Goudar 

Separate the Atmel host controller driver from ehci-hcd host code
so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM;
however, note that other changes are still needed before Atmel can be
booted with a multi-platform kernel. This is currently planned for
Linux-3.11.

With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the Atmel bus glue.

In V4 (arnd):
 - reordered #include statements.
 - removed call to ehci_shutdown.

In V3:
 -Detailed commit message added here about why this patch is required.
 -Replaced hcd_name string "ehci-atmel" to "atmel-ehci".
 -In Makefile inserted Blank line that separates the EHCI drivers from the 
following non-EHCI drivers.
 -Export ehci_shutdown symbol as it is needed by the Atmel driver.
 -Eliminated ehci_atmel_setup routine beacuse hcd registers
  directly setting in ehci_atmel_drv_probe function.

In V2:
Resolved below compiler error.
drivers/usb/host/ehci-atmel.c: In function 'ehci_atmel_drv_remove':
drivers/usb/host/ehci-atmel.c:167: error: implicit declaration of function 
'ehci_shutdown'

Signed-off-by: Manjunath Goudar 
Acked-by: Nicolas Ferre 
Cc: Alan Stern 
Cc: Greg KH 
Cc: Andrew Victor 
Cc: Jean-Christophe Plagniol-Villard 
Cc: linux-usb@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Arnd Bergmann 
---
 drivers/usb/host/Kconfig  |  8 
 drivers/usb/host/Makefile |  1 +
 drivers/usb/host/ehci-atmel.c | 88 ---
 drivers/usb/host/ehci-hcd.c   |  6 +--
 4 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 98abec0f..f6f7872 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -182,6 +182,14 @@ config USB_EHCI_HCD_SPEAR
   Enables support for the on-chip EHCI controller on
   ST SPEAr chips.
 
+config USB_EHCI_HCD_AT91
+tristate  "Support for Atmel on-chip EHCI USB controller"
+depends on USB_EHCI_HCD && ARCH_AT91
+default y
+---help---
+  Enables support for the on-chip EHCI controller on
+  Atmel chips.
+
 config USB_EHCI_MSM
bool "Support for MSM on-chip EHCI USB controller"
depends on USB_EHCI_HCD && ARCH_MSM
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 3d895b5..368d3eb 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_USB_EHCI_HCD_OMAP)   += ehci-omap.o
 obj-$(CONFIG_USB_EHCI_HCD_ORION)   += ehci-orion.o
 obj-$(CONFIG_USB_EHCI_HCD_SPEAR)   += ehci-spear.o
 obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
+obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index f3beac4..6642009 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -12,9 +12,22 @@
  */
 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#include "ehci.h"
+
+#define DRIVER_DESC "EHCI Atmel driver"
+
+static const char hcd_name[] = "ehci-atmel";
+static struct hc_driver __read_mostly ehci_atmel_hc_driver;
 
 /* interface and function clocks */
 static struct clk *iclk, *fclk;
@@ -50,51 +63,6 @@ static void atmel_stop_ehci(struct platform_device *pdev)
 
 /*-*/
 
-static int ehci_atmel_setup(struct usb_hcd *hcd)
-{
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
-   /* registers start at offset 0x0 */
-   ehci->caps = hcd->regs;
-
-   return ehci_setup(hcd);
-}
-
-static const struct hc_driver ehci_atmel_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = "Atmel EHCI UHP HS",
-   .hcd_priv_size  = sizeof(struct ehci_hcd),
-
-   /* generic hardware linkage */
-   .irq= ehci_irq,
-   .flags  = HCD_MEMORY | HCD_USB2,
-
-   /* basic lifecycle operations */
-   .reset  = ehci_atmel_setup,
-   .start  = ehci_run,
-   .stop   = ehci_stop,
-   .shutdown   = ehci_shutdown,
-
-   /* managing i/o requests and associated device resources */
-   .urb_enqueue= ehci_urb_enqueue,
-   .urb_dequeue= ehci_urb_dequeue,
-   .endpoint_disable   = ehci_endpoint_disable,
-   .endpoint_reset = ehci_endpoint_reset,
-
-   /* scheduling support */
-   .get_frame_number   = ehci_get_frame,
-
-   /* root hub support */
-   .hub_status_data= ehci_hub_status_d

[PATCH v4 6/6] USB: OHCI: avoid conflicting platform drivers

2013-03-30 Thread Arnd Bergmann
Like the EHCI driver, OHCI supports a large number of different platform
glue drivers by directly including them, which causes problems with
conflicting macro definitions in some cases. As more ARM architecture
specific back-ends are required to coexist in a single build, we should
split those out into separate drivers. Unfortunately, the infrastructure
for that is still under development, so to give us more time, this uses
a separate *_PLATFORM_DRIVER macro for each ARM specific OHCI backend,
just like we already do on PowerPC and some of the other ARM platforms.

In linux-3.10, only the SPEAr and CNS3xxx back-ends would actually conflict
without this patch, but over time we would get more of them, so this
is a way to avoid having to patch the driver every time it breaks. We
should still split out all back-ends into separate loadable modules,
but that work is only needed to improve code size and cleanliness after
this patch, not for correctness.

While we're here, this fixes the incorrectly sorted error path
for the OMAP1 and OMAP3 backends to ensure we always unregister
the exact set of drivers that were registered before erroring out.

Signed-off-by: Arnd Bergmann 
Cc: Manjunath Goudar 
Cc: Greg KH 
Cc: Alan Stern 
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/host/ohci-hcd.c | 136 ++--
 1 file changed, 118 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 180a2b0..9e6de95 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1102,12 +1102,12 @@ MODULE_LICENSE ("GPL");
 
 #if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
 #include "ohci-s3c2410.c"
-#define PLATFORM_DRIVERohci_hcd_s3c2410_driver
+#define S3C2410_PLATFORM_DRIVERohci_hcd_s3c2410_driver
 #endif
 
 #ifdef CONFIG_USB_OHCI_EXYNOS
 #include "ohci-exynos.c"
-#define PLATFORM_DRIVERexynos_ohci_driver
+#define EXYNOS_PLATFORM_DRIVER exynos_ohci_driver
 #endif
 
 #ifdef CONFIG_USB_OHCI_HCD_OMAP1
@@ -1127,25 +1127,24 @@ MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_ARCH_EP93XX
 #include "ohci-ep93xx.c"
-#define PLATFORM_DRIVERohci_hcd_ep93xx_driver
+#define EP93XX_PLATFORM_DRIVER ohci_hcd_ep93xx_driver
 #endif
 
 #ifdef CONFIG_ARCH_AT91
 #include "ohci-at91.c"
-#define PLATFORM_DRIVERohci_hcd_at91_driver
+#define AT91_PLATFORM_DRIVER   ohci_hcd_at91_driver
 #endif
 
 #ifdef CONFIG_ARCH_LPC32XX
 #include "ohci-nxp.c"
-#define PLATFORM_DRIVERusb_hcd_nxp_driver
+#define NXP_PLATFORM_DRIVERusb_hcd_nxp_driver
 #endif
 
 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
 #include "ohci-da8xx.c"
-#define PLATFORM_DRIVERohci_hcd_da8xx_driver
+#define DAVINCI_PLATFORM_DRIVERohci_hcd_da8xx_driver
 #endif
 
-
 #ifdef CONFIG_USB_OHCI_HCD_PPC_OF
 #include "ohci-ppc-of.c"
 #define OF_PLATFORM_DRIVER ohci_hcd_ppc_of_driver
@@ -1153,7 +1152,7 @@ MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_PLAT_SPEAR
 #include "ohci-spear.c"
-#define PLATFORM_DRIVERspear_ohci_hcd_driver
+#define SPEAR_PLATFORM_DRIVER  spear_ohci_hcd_driver
 #endif
 
 #ifdef CONFIG_PPC_PS3
@@ -1199,7 +1198,14 @@ MODULE_LICENSE ("GPL");
!defined(SA_DRIVER) &&  \
!defined(PS3_SYSTEM_BUS_DRIVER) && \
!defined(SM501_OHCI_DRIVER) && \
-   !defined(TMIO_OHCI_DRIVER)
+   !defined(TMIO_OHCI_DRIVER) && \
+   !defined(S3C2410_PLATFORM_DRIVER) && \
+   !defined(EXYNOS_PLATFORM_DRIVER) && \
+   !defined(EP93XX_PLATFORM_DRIVER) && \
+   !defined(AT91_PLATFORM_DRIVER) && \
+   !defined(NXP_PLATFORM_DRIVER) && \
+   !defined(DAVINCI_PLATFORM_DRIVER) && \
+   !defined(SPEAR_PLATFORM_DRIVER)
 #error "missing bus glue for ohci-hcd"
 #endif
 
@@ -1277,9 +1283,79 @@ static int __init ohci_hcd_mod_init(void)
goto error_tmio;
 #endif
 
+#ifdef S3C2410_PLATFORM_DRIVER
+   retval = platform_driver_register(&S3C2410_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_s3c2410;
+#endif
+
+#ifdef EXYNOS_PLATFORM_DRIVER
+   retval = platform_driver_register(&EXYNOS_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_exynos;
+#endif
+
+#ifdef EP93XX_PLATFORM_DRIVER
+   retval = platform_driver_register(&EP93XX_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_ep93xx;
+#endif
+
+#ifdef AT91_PLATFORM_DRIVER
+   retval = platform_driver_register(&AT91_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_at91;
+#endif
+
+#ifdef NXP_PLATFORM_DRIVER
+   retval = platform_driver_register(&NXP_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_nxp;
+#endif
+
+#ifdef DAVINCI_PLATFORM_DRIVER
+   retval = platform_driver_register(&DAVINCI_PLATFORM_DRIVER);
+   if (retval < 0)
+   goto error_davinci;
+#endif
+
+#ifdef SPEAR_PLATFORM_DRIVER
+   retval = platform_driver_register(&SPEAR_

Re: [PATCH] USB: EHCI: fix regression during bus resume

2013-03-30 Thread Matthijs Kooijman
Hi Alan,

> This patch (as1663) fixes a regression caused by commit
> 6e0c3339a6f19d748f16091d0a05adeb1e1f822b (USB: EHCI: unlink one async
> QH at a time).
> [...]
> The symptom is that when the root hub is resumed, USB communications
> don't work for some period of time.  This is because ehci-hcd doesn't
> realize it needs to restart the async schedule; it assumes that
> because some QHs are already on the schedule, the schedule must be
> running.

This fix helps to solve a 100% reproducible hang on suspend-to-disk
on my Thinkpad X201 (which occured only when there was an SD card in the slot,
things worked flawless otherwise).

I bisected the issue to the same commit you mention above, only to find this
patch in 3.9-rc4 after that :-S

Anyway, just FYI.

Gr.

Matthijs
--
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: EHCI: fix regression during bus resume

2013-03-30 Thread Alan Stern
On Sat, 30 Mar 2013, Matthijs Kooijman wrote:

> Hi Alan,
> 
> > This patch (as1663) fixes a regression caused by commit
> > 6e0c3339a6f19d748f16091d0a05adeb1e1f822b (USB: EHCI: unlink one async
> > QH at a time).
> > [...]
> > The symptom is that when the root hub is resumed, USB communications
> > don't work for some period of time.  This is because ehci-hcd doesn't
> > realize it needs to restart the async schedule; it assumes that
> > because some QHs are already on the schedule, the schedule must be
> > running.
> 
> This fix helps to solve a 100% reproducible hang on suspend-to-disk
> on my Thinkpad X201 (which occured only when there was an SD card in the slot,
> things worked flawless otherwise).
> 
> I bisected the issue to the same commit you mention above, only to find this
> patch in 3.9-rc4 after that :-S
> 
> Anyway, just FYI.

The same sort of thing has happened to me.  Often you're better off
looking to see if someone has already fixed a problem than trying to 
fix it yourself.  :-)

Alan Stern

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


Re: [PATCH] USB: EHCI: fix regression during bus resume

2013-03-30 Thread Matthijs Kooijman
Hi Alan,

> The same sort of thing has happened to me.  Often you're better off
> looking to see if someone has already fixed a problem than trying to 
> fix it yourself.  :-)
I started debugging this before rc4 was out, and it was still broken in
rc3 (but since the lockup only occured with an SD card in the reader, I
spent two days of gathering random bisect results because I only booted
with an SD card part of the time...).

And of course I wouldn't have realized that the fix was actually a fix
for my problem until I had found the commit that caused.

Sometimes debugging just sucks ;-p

In any case, thanks for fixing it!

Gr.

Matthijs
--
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 12/27] usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx

2013-03-30 Thread Alexander Shishkin
Marc Kleine-Budde  writes:

> On 03/30/2013 01:46 AM, Alexander Shishkin wrote:
>> From: Michael Grzeschik 
>> 
>> This driver will be used for every Freescale SoC which has this misc
>> memory layout to control the basic usb handling. So better name this
>> driver, function and struct names in a more generic way.
>> 
>> Reported-by: Fabio Estevam 
>> Signed-off-by: Michael Grzeschik 
>> Signed-off-by: Marc Kleine-Budde 
>> Signed-off-by: Alexander Shishkin 
>> 
>> Conflicts:
>>  drivers/usb/chipidea/usbmisc_imx.c
>
> You've hopefully resolved the conflict before creating a this patch, so
> remove this line :)

Thanks, captain! :) See the v2 series.

Regards,
--
Alex
--
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 12/27] usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx

2013-03-30 Thread Marc Kleine-Budde
On 03/30/2013 05:11 PM, Alexander Shishkin wrote:
> Marc Kleine-Budde  writes:
> 
>> On 03/30/2013 01:46 AM, Alexander Shishkin wrote:
>>> From: Michael Grzeschik 
>>>
>>> This driver will be used for every Freescale SoC which has this misc
>>> memory layout to control the basic usb handling. So better name this
>>> driver, function and struct names in a more generic way.
>>>
>>> Reported-by: Fabio Estevam 
>>> Signed-off-by: Michael Grzeschik 
>>> Signed-off-by: Marc Kleine-Budde 
>>> Signed-off-by: Alexander Shishkin 
>>>
>>> Conflicts:
>>> drivers/usb/chipidea/usbmisc_imx.c
>>
>> You've hopefully resolved the conflict before creating a this patch, so
>> remove this line :)
> 
> Thanks, captain! :) See the v2 series.

I started to read my inbox from older to newer mails and send this
before discovering you had already send a v2.

sorry for the noise,
Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 00/21] usb: chipidea: updates for v3.10

2013-03-30 Thread Greg KH
On Sat, Mar 30, 2013 at 12:53:49PM +0200, Alexander Shishkin wrote:
> Hi,
> 
> Let's try again. Rebased it on top of usb-next and dropped the whole
> tracepoint thing, but kept the part that removes the old event
> buffer and other debug cleanups. So everything else is rebased on top
> of that and a couple of commit messages amended.

Much better, thanks, all now applied.

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: cdc_acm device - unexpected characters sent to USB device

2013-03-30 Thread Oliver Neukum
On Saturday 30 March 2013 03:20:15 Mike Verstegen wrote:

>  -  Downloaded the source code for the cdc_acm driver. 
>  -  Added a bunch of printk debug messages and stack_dumps to follow what's 
> going on. 
>  -  I rmmod'd the "stock" cdc_acm and insmod'd my instrumented module. 
>  -  All the device enumeration works, right driver attached, etc. 
>  -  Since the code works on Ubuntu 12.04/Linux 3.2, I grabbed the 3.2 cdc_acm 
> code and compiled that module on the Centos 6 / Linux 3.6 platform. Using 
> that 3.2 module instead of the 3.6 module did not make a difference. I 
> reverted to the 3.6 module. 
>  -  Turned on the debug file system with usbmon and watched the USB traffic. 
> I can see that there are extra characters being sent on the USB interface. 
>  -  To watch what's going on, on top of the printk's in the cdc_acm module, 
> I've merged the output of usb mon (cat /sys/kernel/debug/usb/usbmon/3u | 
> logger) and the output of the test application (scan_example /dev/ttyACM0 | 
> logger -s) so I have a single stream of time correlated debug trail. 
>  -  The spurious characters sent on the USB endpoint are x5E x40 x5E x40 x5E 
> x40 x5E x40 x41 (in ASCII its ^@^@^@^@A ) which looks like some sort of 
> probing or trying to get the attention of a modem These characters are sent 
> immediately after the application's write() causes the 4 hello bytes to be 
> sent to the end point.

To clarify, is acm_tty_write() called with the additional bytes or isn't it?

Regards
Oliver

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


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2013-03-30 Thread Pavel Machek
On Mon 2013-01-21 10:05:06, Felipe Balbi wrote:
> Hi,
> 
> On Sun, Jan 20, 2013 at 11:17:31AM +0100, Pali Rohár wrote:
> > On Sunday 20 January 2013 10:25:37 Felipe Balbi wrote:
> > > On Sun, Jan 20, 2013 at 03:58:13AM +0100, Pali Rohár wrote:
> > > > Signed-off-by: Pali Rohár 
> > > 
> > > NAK for two reasons:
> > > 
> > > a) the original Nokia kernel used a separate g_file_storage
> > > gadget to use Mass Storage mode, use that
> > > 
> > > b) there is no commit log
> > 
> > Reason why add mass storage mode to g_nokia is to avoid switching 
> > between g_{file,mass}_storage and g_nokia and to have one gadget 
> > driver for Nokia N900. It is better to have usb network and mass 
> > storage mode in one driver (and not to unload & load another).
> > 
> > I tested this patch with 3.8-rc3 kernel on Nokia N900 and usb 
> > network with mass storage mode working without problems.
> 
> Doesn't matter, in this case this is something which nokia wrote to
> carry on their Maemo/MeeGo devices so unless someone from Nokia says
> this is how they want to use nokia.c from now on, I can't simply risk
> breaking all other users for your own convenience.

Nokia is unlikely to continue linux development, sorry.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next] cdc_ncm: return -ENOMEM if kzalloc fails

2013-03-30 Thread David Miller
From: Devendra Naga 
Date: Sat, 30 Mar 2013 14:33:22 +0530

> return -ENOMEM instead if kzalloc of cdc_ncm_ctx structure is failed.
> 
> and also remove the comparision of ctx structure with NULL and make
> it as !ctx.
> 
> Signed-off-by: Devendra Naga 

Applied.
--
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: EHCI: port power regression when canceling suspend-to-disk

2013-03-30 Thread Alan Stern
On Sat, 30 Mar 2013, Matthijs Kooijman wrote:

> Hi guys,
> 
> I recently noticed a problem with suspend-to-disk on my Thinkpad X201.
> I'm using swsusp, which offers a "press backspace to cancel" while it is
> writing out the suspend image to the swap partition. When I do this, the
> system mostly recovers, except for the USB ports on my docking station,
> which stop working (until I undock and redock again).
> 
> The USB ports on the laptop itself seem unaffected. During a normal
> suspend-resume (both to disk and to ram), the ports are also enabled
> properly.
> 
> I bisected this problem and it was introduced by the following commit:
> 
>   commit c73cee717e7d5da0698acb720ad1219646fe4f46
>   Author: Alan Stern 
>   Date:   Wed Oct 31 13:21:06 2012 -0400
> 
>   USB: EHCI: remove ehci_port_power() routine
> 
>   This patch (as1623) removes the ehci_port_power() routine and all 
> the
>   places that call it.  There's no reason for ehci-hcd to change the
>   port power settings; the hub driver takes care of all that stuff.
> 
>   There is one exception: When the controller is resumed from
>   hibernation or following a loss of power, the ports that are 
> supposed
>   to be handed over to a companion controller must be powered on 
> first.
>   Otherwise the handover won't work.  This process is not visible to 
> the
>   hub driver, so it has to be handled in ehci-hcd.

Are you totally certain about this?  I can't see how removing code to 
change the EHCI port power would make any difference in your case, 
because the power was on the whole time.

> Perhaps there is some code path or set of ports that also need this exception?

Not that I can think of.  And even if there were, it wouldn't matter in 
this case because the power level wasn't changed.

> I tried reverting this patch on 3.9-rc4 and usb-next, but I got conflicts that
> I didn't try to resolve yet.

On your system, the only files in the patch that matter are ehci-hcd.c
and ehci-pci.c.  You could try reverting them alone.  Or even just the
ehci-hcd.c part, because the one-line change to ehci-pci.c gets used
only during probing, not during hibernation.

> I've attached the dmesg output from a kernel compiled from usb-next (571bb7a:
> Revert "USB: chipidea: add vbus detect for udc") with
> CONFIG_USB_DEBUG=y. I booted the kernel and immediately started a
> suspend-to-disk (around 50-51s). As soon as the image started being
> written to disk, I canceled it and the system resumed (at 52s). These
> messages look relevant:
> 
> [   52.899290] usb 1-1.4: link qh1-0e01/880230cb97c0 start 0 [1/2 us]
> [   52.899345] hub 1-1:1.0: port 5 status .0100 after resume, -19
> [   52.899347] usb 1-1.5: can't resume, status -19
> [   52.899348] hub 1-1:1.0: logical disconnect on port 5

Actually the relevant messages are earlier:

> [   52.798212] hub 1-1:1.0: hub_resume
> [   52.798214] hub 2-1:1.0: hub_resume
> [   52.798692] hub 1-1:1.0: port 4: status 0103 change 
> [   52.798819] hub 1-1:1.0: port 5: status 0100 change 0001
> [   52.799042] hub 1-1:1.0: port 6: status 0503 change 

The line for port 5 shows that even though power to the port is on, the
docking station's hub has disconnected itself.  By contrast, the
onboard webcam and bluetooth devices had no problem.

> Any idea how to fix this? Do you need any other info?

The only thing I can think of is that the 20-ms delay in the 
ehci_port_power() routine might have made a difference.  After 
reverting the patch, you could try removing everything in that function 
except the delay.

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


Multiple usb_storage problems

2013-03-30 Thread Andy Lutomirski
I have a Corsair Flash Voyager GT and a Lenovo x220 running Fedora's
3.8.2 kernel.  It doesn't work very well, and the problems vary
depending on whether I'm using usb2 or usb3.

 - On usb3, the device node can't be opened with O_DIRECT (using, for
example, dd oflag=direct).  It returns -EINVAL.  (On usb2, O_DIRECT
works.)
 - Also on usb3, if I dd if=/dev/zero of=/dev/sdb bs=1M, dd finishes
in a second or two and no I/O occurs.  This system only has 2GB of RAM
-- caching shouldn't be that extreme.

On either usb version, if I mount an NTFS partition and write a few GB
of data, I get tons of buffer I/O errors.  The point at which they
happen varies, but this is entirely repeatable.  Oddly, dd
if=/dev/zero of=/dev/sdc oflag=direct bs=1M works fine and
successfully zeroes the whole device.

Other computers (running Windows or OS X) seem fine with this USB
stick.  I don't think the stick is bad.

Any ideas?

--Andy
--
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: Multiple usb_storage problems

2013-03-30 Thread Andy Lutomirski
On Sat, Mar 30, 2013 at 8:21 PM, Andy Lutomirski  wrote:
> I have a Corsair Flash Voyager GT and a Lenovo x220 running Fedora's
> 3.8.2 kernel.  It doesn't work very well, and the problems vary
> depending on whether I'm using usb2 or usb3.
>
>  - On usb3, the device node can't be opened with O_DIRECT (using, for
> example, dd oflag=direct).  It returns -EINVAL.  (On usb2, O_DIRECT
> works.)
>  - Also on usb3, if I dd if=/dev/zero of=/dev/sdb bs=1M, dd finishes
> in a second or two and no I/O occurs.  This system only has 2GB of RAM
> -- caching shouldn't be that extreme.

*facepalm*.  The issue is that one of the I/O errors caused the sdb
block device to get sufficiently wedged that it still exists in /sys,
but udev removed sdb (and I replaced it with a file).  If I manually
recreate the sdb device node, ejecting it gets an IO error.  (It's not
plugged in any more.)  rmmoding and modprobing usb_storage got rid of
the bogus sdb device.

>
> On either usb version, if I mount an NTFS partition and write a few GB
> of data, I get tons of buffer I/O errors.  The point at which they
> happen varies, but this is entirely repeatable.  Oddly, dd
> if=/dev/zero of=/dev/sdc oflag=direct bs=1M works fine and
> successfully zeroes the whole device.
>
> Other computers (running Windows or OS X) seem fine with this USB
> stick.  I don't think the stick is bad.
>
> Any ideas?
>
> --Andy
--
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