History log of /drivers/usb/dwc3/gadget.c
Revision Date Author Comments
1200a82a59b6aa65758ccc92c3447b98c53cd7a2 22-Oct-2014 Jack Pham <jackp@codeaurora.org> usb: dwc3: gadget: Properly initialize LINK TRB

On ISOC endpoints the last trb_pool entry used as a
LINK TRB is not getting zeroed out correctly due to
memset being called incorrectly and in the wrong place.
If pool allocated from DMA was not zero-initialized
to begin with this will result in the size and ctrl
values being random garbage. Call memset correctly after
assignment of the trb_link pointer.

Fixes: f6bafc6a1c ("usb: dwc3: convert TRBs into bitshifts")
Cc: <stable@vger.kernel.org> # v3.4+
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
7a60855972f0d3c014093046cb6f013a1ee5bb19 24-Sep-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: fix set_halt() bug with pending transfers

According to our Gadget Framework API documentation,
->set_halt() *must* return -EAGAIN if we have pending
transfers (on either direction) or FIFO isn't empty (on
TX endpoints).

Fix this bug so that the mass storage gadget can be used
without stall=0 parameter.

This patch should be backported to all kernels since v3.2.

Cc: <stable@vger.kernel.org> # v3.2+
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
95aa4e8d658778f787e2ce205d3018443d027477 24-Sep-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: hold the lock through set_wedge()'s life

Instead of releasing the lock and calling locked
versions of our set_halt() methods, let's hold
the lock all the way through and call unlocked
versions of those functions.

Signed-off-by: Felipe Balbi <balbi@ti.com>
5ad02fb813a9d8f39af1ccb1f2166cc80fd76f09 24-Sep-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: move isoc endpoint check to unlocked set_halt

__dwc3_gadget_ep_set_halt() is the function which
handles the actual halt feature. In order to cope
with some extra cleanup comming as a follow-up patch
let's move the isochronous endpoint check there too.

Signed-off-by: Felipe Balbi <balbi@ti.com>
304f7e5e1d08fa2f5674c1323bd0ebd806c86b81 24-Sep-2014 Michal Sojka <sojka@merica.cz> usb: gadget: Refactor request completion

Use the recently introduced usb_gadget_giveback_request() in favor of
direct invocation of the completion routine.

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

Signed-off-by: Michal Sojka <sojka@merica.cz>
Acked-by: Felipe Balbi <balbi@ti.com>
Tested-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2c4cbe6e5a9c71408b496e00a78ea9284e98af16 01-May-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: add tracepoints to aid debugging

When we're debugging hard-to-reproduce and time-sensitive
use cases, printk() poses too much overhead. That's when
the kernel's tracing infrastructure comes into play.

This patch implements a few initial tracepoints for the
dwc3 driver. More traces can be added as necessary in order
to ease the task of debugging dwc3.

Reviewed-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3ece0ec474bf3cea9eefa7f92e3d4b6c3f9f71fd 05-Sep-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: cmd argument should always be unsigned

No functional changes, just making sure we're dealing
with unsigned ints.

Signed-off-by: Felipe Balbi <balbi@ti.com>
80977dc99be5d874d10716594e716ef317c1723c 19-Aug-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: move all string helper functions to debug.h

Those functions are only using within debugging
messages, grouping them into debug.h makes sense.

While at that, also add missing multiple inclusion
guard.

Signed-off-by: Felipe Balbi <balbi@ti.com>
0b93a4c838fa10370d72f86fe712426ac63804de 04-Sep-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: fix TRB completion when multiple TRBs are started

After commit 2ec2a8be (usb: dwc3: gadget:
always enable IOC on bulk/interrupt transfers)
we created a situation where it was possible to
hang a bulk/interrupt endpoint if we had more
than one pending request in our queue and they
were both started with a single Start Transfer
command.

The problems triggers because we had not enabled
Transfer In Progress event for those endpoints
and we were not able to process early giveback
of requests completed without LST bit set.

Fix the problem by finally enabling Xfer In Progress
event for all endpoint types, except control.

Fixes: 2ec2a8be (usb: dwc3: gadget: always
enable IOC on bulk/interrupt transfers)
Cc: <stable@vger.kernel.org> # v3.14+
Reported-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
fdee4ebac96bb44c9c488fdd830b7cc831cd295d 03-Sep-2014 Zhuang Jin Can <jin.can.zhuang@intel.com> usb: dwc3: gadget: Fix desc NULL pointer in dwc3_gadget_ep_queue()

dep->endpoint.desc is checked at the beginning of
dwc3_gadget_ep_queue(), but after that it may be set to NULL
by another thread and then accessed again in dwc3_gadget_ep_queue().
This will lead to kernel oops.

Expand spinlock protection area to aviod race condition.

Signed-off-by: Zhuang Jin Can <jin.can.zhuang@intel.com>
Signed-off-by: Jiebing Li <jiebing.li@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
734d5a5393ed8eedf70f13c7078cb4a6134f49f2 16-Jul-2014 Jingoo Han <jg1.han@samsung.com> usb: dwc3: remove unnecessary OOM messages

The site-specific OOM messages are unnecessary, because they
duplicate the MM subsystem generic OOM message.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
029d97ff543219762685805e15d71f7005ad7c5e 04-Jul-2014 Jingoo Han <jg1.han@samsung.com> usb: dwc3: gadget: remove unnecessary 'start_new' variable

Remove 'start_new' variable from dwc3_endpoint_transfer_complete(),
since this variable has not been used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
5cd8c48d95c10f729090c89757727e090719fd83 15-May-2014 Zhuang Jin Can <jin.can.zhuang@intel.com> usb: dwc3: gadget: check link trb after free_slot is increased

In ISOC transfers, when free_slot points to the last TRB (i.e. Link
TRB), and all queued requests meet Missed Interval Isoc error, busy_slot
points to trb0.
busy_slot->trb0
trb1
...
free_slot->trb31(Link TRB)

After end transfer and receiving the XferNotReady event, trb_left is
caculated as 1 which is wrong, and no TRB will be primed to the
endpoint.

The root cause is free_slot is not increased the same way as busy_slot.
When busy_slot is increased by one, it checks if points to a link TRB
after increasement, but free_slot checks it before increasement.
free_slot should behave the same as busy_slot to make the trb_left
caculation correct.

Reviewed-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Zhuang Jin Can <jin.can.zhuang@intel.com>
Signed-off-by: Jiebing Li <jiebing.li@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
b09e99ee7c2b7ee80cca128b93b07fb830e6ecad 15-May-2014 Andy Shevchenko <andriy.shevchenko@linux.intel.com> usb: dwc3: no need to initialize ret variable

First usage of ret variable will re-write initial value. Thus, there is no need
to initialize it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
427c3df684ab97379b529188d505cc99c2a1429d 25-Apr-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: pretty print Generic CMDs

this makes it slightly easier to read generic CMD
logs. It also helps make sure we're sending proper
parameters for each command.

Signed-off-by: Felipe Balbi <balbi@ti.com>
e57ebc1db6ef796124b69abca044a373b9110a47 22-Apr-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: pretty print link states

this makes it slightly easier to read link state
change interrupt logs.

Signed-off-by: Felipe Balbi <balbi@ti.com>
40cc57c71b27998c558d4ea23556cad2baef8a56 25-Apr-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: print both cmd string and number

That way it's easy for humans looking at dmesg
and humans(?) looking at Databooks.

Signed-off-by: Felipe Balbi <balbi@ti.com>
687ef9817df7ed960d14575b9033dde3d04631fe 16-Apr-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: clear stall when disabling endpoint

so it seems like DWC3 IP doesn't clear stalls
automatically when we disable an endpoint, because
of that, we _must_ make sure stalls are cleared
before clearing the proper bit in DALEPENA register.

Cc: <stable@vger.kernel.org> # v3.4+
Reported-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Felipe Balbi <balbi@ti.com>
32702e96a9f76ea0e0a1d218310d2ac1adbd2907 26-Mar-2014 Jack Pham <jackp@codeaurora.org> usb: dwc3: gadget: Iterate only over valid endpoints

Make dwc3_gadget_resize_tx_fifos() iterate only over IN
endpoints that are actually present, based on the
num_in_eps parameter. This terminates the loop so as to
prevent dereferencing a potential NULL dwc->eps[i] where
i >= (num_in_eps + num_out_eps).

Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3f89204bae896e1d44468886a646b84acadc3c8f 07-Mar-2014 Dan Carpenter <dan.carpenter@oracle.com> usb: dwc3: gadget: remove known conditions

We know what "value" is and it upsets static checkers that we appear to
have doubts about it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
73a30bfc0d526db899033165db6f95c427e70505 07-Mar-2014 Dan Carpenter <dan.carpenter@oracle.com> usb: dwc3: gadget: cut and paste fixups in suspend/resume

These were cut and paste from the ->disconnect function.

Fixes commit 30d577b9bcc4 ('usb: dwc3: gadget: call gadget driver's
->suspend/->resume')

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
b997ada5db905e24494bcc689c7b2c07d278ca27 26-Jul-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: pre-start Stream transfers when they're queued

we need to pre-start stream transfers otherwise we
will never know when to start them.

Signed-off-by: Felipe Balbi <balbi@ti.com>
bc5ba2e0b829c9397f96df1191c7d2319ebc36d9 26-Feb-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: call gadget driver's ->suspend/->resume

When going into bus suspend/resume we _must_
call gadget driver's ->suspend/->resume callbacks
accordingly. This patch implements that very feature
which has been missing forever.

Signed-off-by: Felipe Balbi <balbi@ti.com>
b992e6813e257269e9599ca07be8bd52df784bf5 27-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: add 'force' argument to stop_active_transfer

It's not always we need to force a transfer to be removed
from the core's internal cache. This extra argument will
help differentiating those two cases.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
356363bf6b2fc4785d874ef87ed2fad4b8543490 19-Dec-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: make sure HIRD threshold is 0 in superspeed

During superspeed, HIRD threshold should always
be zero. Curent driver wasn't making sure that
was the case.

Signed-off-by: Felipe Balbi <balbi@ti.com>
7b2a0368bbc9bc4a7936d8587eaff4b8c35b2247 19-Dec-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: set KEEP_CONNECT in case of hibernation

if we have hibernation configured, Databook
instructs us to set KEEP_CONNECT bit together
with RUN_STOP bit, in step 9 of section 12.3.6.1
Initialization for Hibernation Support.

Signed-off-by: Felipe Balbi <balbi@ti.com>
265b70a73aff2a21e74f1fbe7ffaaeb4608adc98 19-Dec-2013 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: add a 'restore' argument to set_ep_config

That argument will be used in later patches when we
have working hibernation support. For now, always
pass it as false.

The idea of this patch is to decrease to size of
following patches and slowly add hibernation building
blocks to the gadget side of dwc3 so that it becomes
very easy to review the actual hibernation code.

[ balbi@ti.com : rewrote patch on top of current
tree. Added commit log. ]

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
911f1f88cadf4b64bad5aa4c257d72494a62f928 27-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: implement dwc3_gadget_get_link_state

This function will be used during hibernation to get
the current link state. It will be needed at least
for Hibernation support.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
e1dadd3b0f277e59847d6b7de86ff67306bee4b1 25-Feb-2014 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: bogus hibernation events

Revision 2.20a of the core has a known issue
which would generate bogus hibernation events
_and_ random failures on USB CV TD.9.23 test
case.

The suggested workaround is to ignore hibernation
events which don't match currently connected
speed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
f3af36511e60669a2b5644d17378c7ea4e42d8b1 13-Dec-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: always enable IOC on bulk/interrupt transfers

by setting IOC always, we can recycle TRBs a
lot sooner at the expense of some increased
CPU load.

The extra load seems to be quite minimal on
OMAP5 devices (instead of 1 IRQ for one MSC
transfer, we get
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS).

Signed-off-by: Felipe Balbi <balbi@ti.com>
e117e742d310683b410951faeab4b13b6c3c609f 13-Dec-2013 Robert Baldyga <r.baldyga@samsung.com> usb: gadget: add "maxpacket_limit" field to struct usb_ep

This patch adds "maxpacket_limit" to struct usb_ep. This field contains
maximum value of maxpacket supported by driver, and is set in driver probe.
This value should be used by autoconfig() function, because value of field
"maxpacket" is set to value from endpoint descriptor when endpoint becomes
enabled. So when autoconfig() function will be called again for this endpoint,
"maxpacket" value will contain wMaxPacketSize from descriptior instead of
maximum packet size for this endpoint.

For this reason this patch adds new field "maxpacket_limit" which contains
value of maximum packet size (which defines maximum endpoint capabilities).
This value is used in ep_matches() function used by autoconfig().

Value of "maxpacket_limit" should be set in UDC driver probe function, using
usb_ep_set_maxpacket_limit() function, defined in gadget.h. This function
set choosen value to both "maxpacket_limit" and "maxpacket" fields.

This patch modifies UDC drivers by adding support for maxpacket_limit.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
a4b9d94b3dc8e65951c1819d37f213b3c6815adc 10-Dec-2013 David Cohen <david.a.cohen@linux.intel.com> usb: dwc3: set gadget's quirk ep_out_align_size

DWC3 requires epout to have buffer size aligned to MaxPacketSize value.
This patch sets necessary quirk for it.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
a535d81c92615b8ffb99b7e1fd1fb01effaed1af 01-Nov-2013 Alan Stern <stern@rowland.harvard.edu> usb: dwc3: fix implementation of endpoint wedge

The dwc3 UDC driver doesn't implement endpoint wedging correctly.
When an endpoint is wedged, the gadget driver should be allowed to
clear the wedge by calling usb_ep_clear_halt(). Only the host is
prevented from resetting the endpoint.

This patch fixes the implementation.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Pratyush Anand <pratyush.anand@st.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
e1f804676a95b9d5caaa3a822d90bc1101595468 12-Sep-2013 David Cohen <david.a.cohen@linux.intel.com> usb: dwc3: gadget: avoid memory leak when failing to allocate all eps

If dwc3_gadget_init_endpoint() fails after allocate some of the eps, we
need to free their memory to avoid leak.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
f42f2447d66233a5bf86e8631e4eb4e863b2ff0b 12-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: introduce dwc3_process_event_buf

in order to make our IRQ handler thread easier
to read, we re-factor the inner loop to a separate
function.

Signed-off-by: Felipe Balbi <balbi@ti.com>
7f97aa9865800766e570d0e1be772a034dd30388 12-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: rename dwc3_process_event_buf

that function isn't really processing any event
buffer, rather just checking whether it contains
events to be processed.

Due to that reason, we're reaning it to dwc3_check_event_buf()
instead.

Signed-off-by: Felipe Balbi <balbi@ti.com>
e8adfc30ff9282a728fd8b666b6418308164c415 12-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: get rid of IRQF_ONESHOT

We can make use of bit 31 of the GEVNTSIZ(n)
registers to mask/unmask interrupts from that
particular interrupter.

With that feature, we can easily drop IRQF_ONESHOT
from our driver which makes it possible to
properly change IRQ priorities when using RT
patchset *and* it allows us to make use of the
scheduler to choose the proper time to handle
this IRQ thread.

Signed-off-by: Felipe Balbi <balbi@ti.com>
fb49740d72a305f2e4110b4dfb53fdd9130d8878 15-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't enable LPM early

LPM is enabled in Connection Done interrupt,
there's no need to enable it early.

Signed-off-by: Felipe Balbi <balbi@ti.com>
653df35e6b3c0df875999a9b842327301269f55d 12-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: add a debugging print when initializing endpoints

that way we get debugging information when
enabling verbose debug of the driver.

It will be no-op otherwise.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9aa62ae4292a2450634345d79a7fa1461bf7b39c 12-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: move direction setting up

no functional changes, just grouping dep
initialization.

Signed-off-by: Felipe Balbi <balbi@ti.com>
ff62d6b6727360ae73382213bc1ebac6cf5160d7 12-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: move debugging print around

by moving that dev_vdbg() to the internal
__dwc3_gadget_ep_enable() we get the print
even when enable ep0, which calls the internal
function directly.

Signed-off-by: Felipe Balbi <balbi@ti.com>
636e2a2caeafcb1b55b6799b29fe436039819eb9 12-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: drop dwc3 manual phy control

Recent versions of the core, can suspend and resume
the PHYs automatically, so we don't need to fiddle
with dwc3's Global PHY registers at all.

On versions prior to 1.94a this patch will mean
that we will never ask dwc3 to suspend the PHY.

This is an acceptable behavior or such old versions
of the core, specially considering that the only
chip known to have a version prior to 1.94a was
OMAP5 ES1.0 and that's not supported in mainline
kernel, because it was just a test spin of OMAP5.

Signed-off-by: Felipe Balbi <balbi@ti.com>
f7e846f0956917888b28b52726ee8779a39d84b6 30-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: make maximum-speed a per-instance attribute

in order to allow different instances of the
core work in different maximum speeds, we will
move the maximum_speed module_parameter to
both DeviceTree (making use the new maximum-speed
DT property) and platform_data.

Signed-off-by: Felipe Balbi <balbi@ti.com>
5945f789c864d8676b297880cc6961fea4511a7a 30-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: switch to GPL v2 only

This is a Linux-only driver which makes use
of GPL-only symbols. It makes no sense to
maintain Dual BSD/GPL licensing for this driver.

Considering that the amount of work to use this
driver in any different operating system would likely
be as large as developing the driver from scratch and
considering that we depend on GPL-only symbols, we
will switch over to a GPL v2-only license.

Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
b0d7ffd44ba9cd2dfbf299674418193a5f9ed21a 27-Jun-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't request IRQs in atomic

We cannot request an IRQ with spinlocks held
as that would trigger a sleeping inside
spinlock warning.

Cc: <stable@vger.kernel.org> # v3.10
Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
cdcedd6981194e511cc206887db661d016069d68 14-Jul-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't prevent gadget from being probed if we fail

In case we fail our ->udc_start() callback, we
should be ready to accept another modprobe following
the failed one.

We had forgotten to clear dwc->gadget_driver back
to NULL and, because of that, we were preventing
gadget driver modprobe from being retried.

Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
5bf8fae33d14cc5c3c53a926f9079f92c8b082b0 27-May-2013 George Cherian <george.cherian@ti.com> usb: dwc3: gadget: free trb pool only from epnum 2

we never allocate a TRB pool for physical endpoints
0 and 1 so trying to free it (a invalid TRB pool pointer)
will lead us in a warning while removing dwc3.ko module.

In order to fix the situation, all we have to do is skip
dwc3_free_trb_pool() for physical endpoints 0 and 1 just
as we while deleting endpoints from the endpoints list.

Cc: stable@vger.kernel.org
Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
6a1e3ef45fb0c4d79cbb5190c8fc59263c630b0e 05-May-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: use num_(in|out)_eps from HW params

that way we will only tell gadget framework about
the endpoints we actually have.

Signed-off-by: Felipe Balbi <balbi@ti.com>
0b0cc1cd31bed3e3147398e54530f1f819b27692 18-Sep-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: unexpected transtion U3 -> RESUME

In DWC3 versions < 2.50a configured without
Hibernation mode enabled, there will be an
extra link status change interrupt if device
detects host-initiated U3 exit.

In that case, core will generate an unnecessary
U3 -> RESUME transition which should be ignored
by the driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
e5caff6831d00d96b4618de939312570527ad54a 26-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't assign gadget.dev.release directly

udc-core provides a better way to handle release
methods, let's use it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
180cc68ed82ced0c19f5a478f8d1cdd2024c1875 26-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't touch gadget.dev.driver

udc-core now handles that for us, which means
we can remove it from our driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
1048d83d5bfcbf1c71391fc1aae57326e940149c 26-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: remove unnecessary initializations

udc-core now sets dma-related and parent fields
for us, we don't need to do it ourselves.

Signed-off-by: Felipe Balbi <balbi@ti.com>
14cd592f72ea1ce1a25d7a576a5ed6aa761456bc 19-Dec-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: implement gadget state tracking

make use of the previously introduced gadget->state
field.

Signed-off-by: Felipe Balbi <balbi@ti.com>
b15a762f02acb4f1e695a17435f719350f9d5bc1 30-Jun-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: move to threaded IRQ

by moving to threaded IRQs, we allow our IRQ
priorities to be configurable when running with
realtime patch. Also, since we're running in
thread context, we can call functions which
might sleep, such as sysfs_notify() without
problems.

Signed-off-by: Felipe Balbi <balbi@ti.com>
7415f17c9560c923ba61cd330c8dfcd5c3630b80 30-Apr-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: core: add power management support

Add support for basic power management on
the dwc3 driver. While there is still lots
to improve for full PM support, this minimal
patch will already make sure that we survive
suspend-to-ram and suspend-to-disk without
major issues.

Cc: Vikas C Sajjan <vikas.sajjan@linaro.org>
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9fcb3bd8d12db29c101d3722d37ddef9d1915317 08-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: save state of pullups

This will be used during resume to verify
if we should reconnect our pullups or not.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
8698e2acf3a5e8d6f260ca7675f94e5087df5ae8 08-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: introduce and use enable/disable irq methods

we don't need to enable IRQs until we have
a gadget driver loaded and ready to work,
so let's delay IRQ enable to ->udc_start()
and IRQ disable to ->udc_stop().

While at that, also move the related use of
request_irq() and free_irq().

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
7bce401cc6db5508ef2517e45bd8caf7ce0a15ee 24-Jan-2013 Felipe Balbi <balbi@ti.com> usb: gadget: drop now unnecessary flag

We don't need the ->register_my_device flag
anymore because all UDC drivers have been
properly converted.

Let's remove every history of it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
1e1930bd3d9c6174eba1e3ca4135fd25ea3ad59c 24-Jan-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: let udc-core manage gadget->dev

We don't need to register that device ourselves
if we simply set gadget->register_my_device.

Signed-off-by: Felipe Balbi <balbi@ti.com>
e5b29b25f8f88ece53579fa87580bb2973815977 15-Feb-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: remove unnecessary code

the params variables on dwc3_gadget_conndone_interrupt()
is only memset() to zero but never used in
that function, so we can safely drop the variable
and memset() call.

Signed-off-by: Felipe Balbi <balbi@ti.com>
1a947746dbe1486d0e305ab512ddf085b7874cb3 24-Jan-2013 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: change HIRD threshold to 12

First of all, that 28 value makes no sense as
HIRD threshold is a 4-bit value, second of all
it's causing issues for OMAP5.

Using 12 because commit cbc725b3 (usb: dwc3:
keep default hird threshold value as 4b1100)
had the intention of setting the maximum allowed
value of 0xc.

Also, original code has been wrong forever, so
this should be backported as far back as
possible.

Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
c9fda7d6f62a6520e01652d370654c5657d3c1a1 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: req->queued must be forced to false in cleanup

I am not sure, why I found it during SG debugging. But, I noticed that
even when req_queued list was empty, there were some request in
request_list having queued flag true. If I run test second time, it
first removes all request from request_list and hence busy_slot was
wrongly incremented.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
e5ba5ec833aa4a76980b512d6a6779643516b850 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix scatter gather implementation

To work with scatter gather properly, fixes have been done in number of
functions. I will explain requirement of each fixes one by one.

start_slot: used to retrieve all request of SG during cleanup

dwc3_gadget_giveback: We need to skip link TRB if it was one of the
intermediate TRB of SG.

dwc3_prepare_one_trb: We need to track all submitted TRBs during
cleanup. Since, all TRBs would be serially allocated, so we can just
keep starting slot info and we can always find rest of them. We need to
pass sg node number, so that we cab appropriately program ISOC_FIRST/ISOC,
Chain etc.

dwc3_prepare_trbs: last_one should be set when it is last node
of SG as well as last node of request_list.

__dwc3_cleanup_done_trbs: It has been prepared after re-factorization of
dwc3_cleanup_done_reqs. It is called for each TRB of SG.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
1877d6c9a57802d50a059cf2dacdba10168cece7 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: no need to pass params in case of UPDATE_TRANSFER

UPDATE_TRANSFER does not need any parameters. So, no need to prepare it.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
915e202aeeb59e272992a6364c910aaef3073544 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix skip LINK_TRB on ISOC

When we reach to link trb, we just need to increase free_slot and then
calculate TRB. Return is not correct, as it will cause wrong TRB DMA
address to fetch in case of update transfer.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
cdc359dd87ab6c39a67dab724fd0b61c16e6f08b 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix isoc END TRANSFER Condition

There were still some corner cases where isoc transfer was not able to
restart, specially when missed isoc does not happen , and in fact gadget does
not queue any new request during giveback.

Cleanup function calls giveback first, which provides a way to queue
another request to gadget. But gadget did not had any data. So , it did
not call ep_queue. To twist it further, gadget did not queue till
cleanup for last queued TRB is called. If we ever reach this scenario,
we must call END TRANSFER, so that we receive a new xfernotready with
information about current microframe number.

Also insure that there is no request submitted to core when issuing END
TRANSFER.

Cc: <stable@vger.kernel.org> # v3.8
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
15f86bde29f0fdfb877d9c753547fa2e2f5ef1fe 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: correct return from ep_queue

Its better to return from each if condition as they are mutually
exclusive.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
7efea86c2868b8fd9df65e589e33aebe498ce21d 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix missed isoc

There are two reasons to generate missed isoc.

1. when the host does not poll for all the data.
2. because of application-side delays that prevent all the data from
being transferred in programmed microframe.

Current code was able to handle first case only. This patch handles
scenario 2 as well.Scenario 2 sometime may occur with complex gadget
application, however it can be easily reproduced for testing purpose as
follows:

a. use isoc binterval as 1 in f_sourcesink.
b. use pattern=0
c. introduce a delay of 150us deliberately in source_sink_complete, so
that after few frames it lands into scenario 2.
d. now run testusb 16 (isoc in test). You will notice that if this
patch is not applied then isoc transfer is not able to recover after
first missed.

Current patch's approach is as under:

If missed isoc occurs and there is no request queued then issue END
TRANSFER, so that core generates next xfernotready and we will issue a
fresh START TRANSFER.
If there are still queued request then wait, do not issue either END or
UPDATE TRANSFER, just attach next request in request_list during giveback.
If any future queued request is successfully transferred then we will issue
UPDATE TRANSFER for all request in the request_list.

Cc: <stable@vger.kernel.org> # v3.6 v3.7 v3.8
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2b758350af19db9a5c98241cf222c2e211d7a912 14-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: Enable usb2 LPM only when connected as usb2.0

Synopsys says:
The HIRD Threshold field must be set to ā€˜0ā€™ when the device core is
operating in super speed mode.

This patch implements above statement.

Cc: <stable@vger.kernel.org> # v3.6 v3.7 v3.8
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
6048e4c69d80600baba35856651056860d5d8f5a 18-Jan-2013 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix ep->maxburst for ep0

dwc3_gadget_set_ep_config expects maxburst as incremented by 1. So, by
default initialize ep->maxburst to 1 for ep0.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
7dbdf4e4b37766a2389680c460b9dab278a5444c 13-Dec-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't redefine 'ret'

we have an extra 'ret' variable shadowing a previous
definition. Remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
41ac7b3ab7fe1d6175839947a877fdf95cbd2211 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu> usb: remove use of __devinit

CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Peter Korsgaard <jacmet@sunsite.dk>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Cc: Li Yang <leoli@freescale.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Geoff Levand <geoff@infradead.org>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Olav Kongas <ok@artecdesign.ee>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
041d81f493d90c940ec41f0ec98bc7c4f2fba431 04-Oct-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: fix 'endpoint always busy' bug

If a USB transfer has already been started, meaning
we have already issued StartTransfer command to that
particular endpoint, DWC3_EP_BUSY flag has also
already been set.

When we try to cancel this transfer which is already
in controller's cache, we will not receive XferComplete
event and we must clear DWC3_EP_BUSY in order to allow
subsequent requests to be properly started.

The best place to clear that flag is right after issuing
DWC3_DEPCMD_ENDTRANSFER.

Cc: stable@vger.kernel.org # v3.4 v3.5 v3.6
Reported-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
f4a53c55117b82e895ec98b1765c9d66940377fc 29-Aug-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: fix pending isoc handling

If xfernotready is received and there is no request in request_list then
REQUEST_PENDING flag must be set, so that next request in ep queue is executed.

In case of isoc transfer, if xfernotready is already elapsed and even first
request has not been queued to request_list, then issue END TRANSFER, so that
you can receive xfernotready again and can have notion of current microframe.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
0416e494ce7dc84e2719bc9fb7daecb330476074 10-Aug-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: ep0: correct cache sync issue in case of ep0_bounced

In case of ep0 out, if length is not aligned to maxpacket size then we use
dwc->ep_bounce_addr for dma transfer and not request->dma. Since, we have
alreday done memcpy from dwc->ep0_bounce to request->buf, so we do not need to
issue cache sync function. In fact, cache sync function will bring wrong data
in request->buf from request->dma in this scenario.

So, cache sync function must not be executed in case of ep0 bounced.

Cc: <stable@vger.kernel.org> # v3.4 v3.5
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
d2e9a13a388304bc2a7b25a6c34c6e2ab1540a5d 31-Aug-2012 Chanho Park <chanho61.park@samsung.com> usb: dwc3: set up burst size only superspeed mode

When connection is established non-ss mode, endpoint.maxburst is correctly set
to 0, this means that current code will set maxburst bitfield on DEPCFG's
parameter 0 to the highest possible value (0x0f) which is wrong.

Even though this hasn't caused any issues so far (HW seems to ignore that when
not running in SS mode) we want to make sure maxburst bitfield is only set to
anything other than zero if we're running on SuperSpeed mode. In order to
achieve that, let's check for gadget's operating speed before setting maxburst
bitfield when issuing DEPCFG command.

[ balbi@ti.com : improved commit log a bit in order to clarify the situation ]

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
c6f83f386c2f7987a344368e33e55840c12bd38f 14-Aug-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: warn about endpoint already enabled before changing ep name

In case some gadget driver tries to enable an endpoint
which is already enabled, we print a nice WARN so we
can track broken gadget drivers. The only problem is that
we're printing the WARN when we already changed endpoint's
name, which would result in endpoints named as:

ep1in-bulk-bulk-bulk-bulk-bulk-bulk-bulk

To prevent that, we will continue to print the WARN,
but do so before changing endpoint's name and return
early.

Signed-off-by: Felipe Balbi <balbi@ti.com>
57911504a93909034ba5b90c20f3e6df8409ebd8 06-Jul-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: Fix dwc3_stop_active_transfer for synchronization delay

dwc3_stop_active_transfer has been called from two places. After each
calling of this function , we should allow 100 us delay to synchronize
with interconnect.

It would be better if we put this delay in that function only, rather
than into calling routine of this function.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Reported-by: Michel Sanches <michel.sanches@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
79c9046ec52b5aaa9f055e3d928d676dd37a6f9d 07-Aug-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: gadget: correct missed isoc when endpoint is busy

When MISSED_ISOC is set, BUSY is also set. Since, we are handling
MISSED_ISOC as a separate case in third scenario, therefore handle only
BUSY but not MISSED_ISOC in second scenario.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
348e026fafe2501281db5fb7fed599b337cad358 01-Aug-2012 Moiz Sonasath <m-sonasath@ti.com> usb: dwc3: gadget: Fix sparse warnings

This patch fixes the following sparse warnings:

drivers/usb/dwc3/gadget.c:1096:7: warning: symbol 'ret' shadows an earlier one
drivers/usb/dwc3/gadget.c:1058:8: originally declared here
drivers/usb/dwc3/gadget.c:1100:16: warning: symbol 'dwc' shadows an earlier one
drivers/usb/dwc3/gadget.c:1057:15: originally declared here
drivers/usb/dwc3/gadget.c:1118:16: warning: symbol 'dwc' shadows an earlier one
drivers/usb/dwc3/gadget.c:1057:15: originally declared here
drivers/usb/dwc3/gadget.c:1800:19: warning: symbol 'dep' shadows an earlier one
drivers/usb/dwc3/gadget.c:1778:18: originally declared here

Also, fix the potential checkpatch errors around the if() loops that
this fix patch can create.

Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
4b345c9a3c7452340fb477868d8db475f05978b1 16-Jul-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: set Ignore Sequence Number bit from ConnectDone Event

Databook says we should set Ignore Sequence Number bit
from ConnectDone Event, so let's do so.

Signed-off-by: Felipe Balbi <balbi@ti.com>
6f17f74b3d8345663f5fcfd834145685110075bd 02-Jul-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: return error in case of run/stop timeout

Although timeout has never been experienced, still to make it
meaningful, its better to return error if it ever occurs.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
e274a31e29b6a097c32f526493f4ebce10856dcb 02-Jul-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: enable ACCEPT{U1,U2}ENA when SetConfiguration received

As per databook, ACCEPT{U1,U2}ENA bits should be set after receiving
SetConfiguration Command.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
dd864f20b382b131bfe10c87c5c81985f5bafa54 02-Jul-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: no need to clear INIT{U1,U2}ENA bits

as per databook, these bits are cleared by hardware on each USB reset,
so no need to clear it explicitly by software in reset ISR.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
cbc725b371f80710c5c611db78a501a6cd314ec3 02-Jul-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: keep default hird threshold value as 4b1100

as per data book any HIRD threshold value greater than 4b1100 is
invalid. So set the maximum valid value as default values.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
08f0d96670c53898b4154e7945e77cdd966003f7 25-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: correct set_halt implementation for ep0

set_halt for ep0 is called to stall a deferred control responses by the
gadget. We already have a function to stall default control endpoint.
This patch points set_halt for ep0 to the already available function.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Michel Sanches <michel.sanches@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9be2395186b3504aa5e337bd3284afb4966caae7 25-Jun-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: remove duplicated code from __dwc3_gadget_ep_set_halt

whenever we want to stall ep0, we always call
dwc3_ep0_stall_and_restart() which makes sure
to send ep0state properly rendering the code
in __dwc3_gadget_ep_set_halt() duplicated.

Reported-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
b4996a8631e80a2aaddb5c487ff6b9ad37315f70 05-Jun-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: rename res_trans_idx to resource_index

resource_index is more human readable. No
functional changes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
b511e5e76bf488cd3eec1048483a3898393a4dca 05-Jun-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: split special cases of ep_queue()

It makes it easier to read and also avoids
setting DWC3_EP_PENDING_REQUEST just so the
next branch evaluates true.

No functional changes otherwise.

Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3daf74d78dfcd552445c35f1b82a271ca305ceb9 22-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: remove WARN_ON from dwc_stop_active_transfer

Now we are sure that, if res_trans_idx is zero, then endpoint has been
stopped. So it's safe to just return if endpoint is already stopped. No
need to generate warning anymore.

While doing so, it's better to return when res_trans_idx is zero and
decrease one level of indentation.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>

[ balbi@ti.com: slightly changed commit log ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
1591633ed6c4c3994944f31ddb59bc072a2ed0ca 15-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: giveback all queued request when ep disabled or reset received

In case of ep_disable and reset interrupt is received and, still there
was at least one request queued for dma transfer, then endpoint is
stopped first. Once endpoint is stopped, callback for all queued
request must be called.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
e8d4e8be860d935099ffcf695dcd29b55ae50b36 15-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: fix giveback of queued request in ep_dequeue

In case of ep_dequeue , if dequeued request was submitted for dma
transfer, then endpoint is stopped. Once endpoint is stooped, callback
for the dequeued request must be called.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
b785ea7ce662c47f6208071320638a4813722803 06-Jun-2012 Felipe Balbi <balbi@ti.com> usb: gadget: composite: fix ep->maxburst initialization

bMaxBurst field on endpoint companion descriptor
is supposed to contain the number of burst minus
1. When passing that to controller drivers, we
should be passing the real number instead (by
incrementing 1).

While doing that, also fix the assumption on
dwc3 that value comes decremented by one.

Signed-off-by: Felipe Balbi <balbi@ti.com>
dcae3573b98b2205961bfa5821427f5664422cd8 06-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: resume phy during gadget initialization on recent cores

It is needed to enumerate recent cores like 2.10a.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3336abb5b608300550136ddab7a7101b30d45fa7 06-Jun-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: ignore endpoint IRQs when endpoint is disabled

By the time we're disabling the endpoint, HW
could already have posted more events to our
event buffer. In that case, we will receive
endpoint events for a disabled endpoint.

In order to protect ourselves from that situation,
we simply ignore endpoint interrupts whenever
the endpoint is disabled.

Tested-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
1e2360eadaa33c09bb72afb14f74b6c6ab2aca66 06-Jun-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't call stop_active_transfers() on disconnect

In case we get disconnected, we will call gadget
driver's disconnect method, which should make
sure to disable all endpoints. At that point
we will call stop_active_transfers() to make
sure we didn't leave any pending request on the
controller.

Tested-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
ea53b8828c50b7a5138a8931c41b2671682c86b5 16-Feb-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't wait for ep cmd IRQ

That IRQ is causing way too much trouble. We have
a different handling which was agreed with IP
provider and has been tested with FPGA and OMAP5.

Tested-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
6dbc10c61d5841f64945fd94977fa8fa1c0192da 17-Feb-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: drop useless code

We never set CMDIOC bit for Start Transfer
command, so that code will never be used.

Tested-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
70b674bfeb735557fc03cdc125ffe6d34218fcfd 03-Jun-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: Fix break from cleanup request loop

If event status says that its last completed TRB but TRB is still owned
by HW then break from the loop, because we are not going to get correct
TRB status from trb control/size register.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
d6d6ec7b8854ab62f7f3907656d5d29eb47532e7 25-May-2012 Pratyush Anand <pratyush.anand@st.com> usb: dwc3: Fix missed isoc IN transaction

If an IN transfer is missed on isoc endpoint, then driver must insure
that next ep_queue is properly handled.
This patch fixes this issue by starting a new transfer for next queued
request.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
206dd69a62a06197b308fa0decfd0b649fcc2811 20-May-2012 Pratyush Anand <pratyush.anand@st.com> USB: DWC3: Generate interrupt on each TRB as default option

Currently in case of isoc, interrupt is programmed after each
TRB_NUM/4 ie 8th TRB. A TRB is programmed against each submitted
request from gadget. If we do not want to limit the minimum number of
necessary request to be submitted from gadget then we must receive
interrupt on each TRB submission. There can be such situation with a
gadget working with ping-pong buffer.

If a gadget does not want to receive interrupt after each request
completion then it may set no_interrupt flag.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
5cbe8c220c1e126dd0855ad57fe4491b267132b9 23-May-2012 Gerard CAUVY <g-cauvy1@ti.com> usb: dwc3: gadget: move AcceptU1Ena and AcceptU2Ena to Reset IRQ

According to the databook, the DWC3 Core will
reset those bits to 0 on USB Bus Reset. This
means we must re-enable those bits on every
reset interrupt.

Because we will always get a Reset interrupt
after loading a gadget driver, we can, instead
of re-enabling something that was just lost,
move the handling of those bits to the Reset
Interrupt.

This patch fixes USB30CV U1/U2 Test.

Signed-off-by: Gerard CAUVY <g-cauvy1@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
c4430a26948b84c0d820e83f8c640229f960d3b6 24-May-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: disable U1/U2 on disconnect

If we get a disconnect IRQ, we should take
the core out of low power mode so we can
reconnect afterwards.

Signed-off-by: Felipe Balbi <balbi@ti.com>
fcc023c726b5879d8f3f0f0f48c45d09055272c4 24-May-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: prevent DCTL register corruption

If we don't read out the contents of the register
(in order to reinitialize 'reg' variable) we will
be writing unknown contents to the DCTL register
whenever we try to use dwc3_gadget_wakeup() function.

Signed-off-by: Felipe Balbi <balbi@ti.com>
802fde983e8a3391e059bd41fc272993ae642816 27-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: support new revisions of DWC3 core

Recent cores (>= 1.94a) have a set of new features,
commands and a slightly different programming model.

This patch aims to support those changes.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
d7a46a8dfc45191b39daa19c05d3ff74d1881f15 26-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: rename phy_power() to phy_suspend()

those two functions don't power PHYs, they simply
put them in suspend state. Rename to reflect better
what functions actually do.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
aed430e5139af3e2c251f52db7fc6c5e2ce2b714 26-Apr-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: reinitialize retries

retries is used twice without being reinitialized.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
a092532483e3200a53c8b1170b3988cc668c07ef 22-May-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: remove trailing semicolon

That semicolon doesn't do anything, it's not
needed and should be removed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
16e78db720baa9356485336ec137c7ee0a482a9b 12-Mar-2012 Ido Shayevitz <idos@codeaurora.org> usb: dwc3: Update dwc3 udc to use usb_endpoint_descriptor inside the struct usb_ep

Remove redundant pointer to struct usb_endpoint_descriptor.

Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3ef35fafdc87b72851f7785dc5331a0f4eb1b3ce 03-May-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: define DWC3_EP0_BOUNCE_SIZE

to avoid sprinkling magic constants on the driver
we define a constant to be used when allocating
setup_buffer and ep0_bounce buffer.

Signed-off-by: Felipe Balbi <balbi@ti.com>
f898ae09a043cf9c3c4be82c04e08fcf00fe82c1 29-Mar-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: issue Update Transfer command after queuing isoc request

Issue an Update Transfer command after queuing a request to an isoc
EP with an active transfer. This is required according to the dwc3
databook. Pratyush Anand reports that this fixes a problem he was
having with Isoc IN transfers.

Tested-by: Pratyush Anand<pratyush.anand@st.com>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
7ed6d227c3d29e156f7affbad4d4679d1e409ef2 25-Apr-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: increase setup buffer size

We want to re-use that buffer for other USB
requests, so let's increase it to biggest
wMaxPacketSize for ep0 so it works for everything
we have in mind.

Signed-off-by: Felipe Balbi <balbi@ti.com>
b09bb64239c83113b8b35fa6a1ecae43d8297eaa 24-Apr-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: implement Global Command support

This will be used by the ep0 layer for implementing
Set SEL Standard Request.

Signed-off-by: Felipe Balbi <balbi@ti.com>
e6a3b5e2888b51e37c65c97dae966f793bc4806a 13-Sep-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: ep0: add LPM handling

On device loading the driver enables LPM and the acceptance of U1 and U2
states. The [Set|Clear]Feature requests for "U1/U2" are forwarded
directly to the hardware and allow / forbid the initiation of the low
power links.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
07e7f47b6d8da3e290f90615c9a74dff0115709e 22-Mar-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: metastability state on Run/Stop bit

All revisions prior to 2.20a have a known issue which
causes metastability state on Run/Stop bit if we
configure the core to work on any of the USB2-only
speeds.

The suggested workaround is just to never configure the
core to anything other than SuperSpeed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
c2df85ca31645ed3c68c56bd30a3673e034224f1 25-Feb-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: clear 'res_trans_idx' as soon as it becomes invalid

Transfer resource index is cleared in hardware when XFERCOMPLETE
event is generated, so clear the driver's res_trans_idx variable
immediately after that event is received. The upcoming hibernation
patches depend on this change.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
249a456930cd2df29d085fb738b0e8f4bc1680cf 25-Feb-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: take lock while modifying flags

dwc3_gadget_ep_set_wedge() and dwc3_gadget_set_selfpowered() were
modifying dwc->flags/dwc->is_selfpowered without taking the lock.
Since those modifications are non-atomic, that could cause other
flags to be corrupted. Fix them both to take the lock.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
aee63e3cb6b0396b99c6387a47cb90a7417f3957 25-Feb-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: shorten long delay in dwc3_gadget_set_link_state()

The loop in dwc3_gadget_set_link_state() was using a udelay(500),
which is a long time to delay in interrupt context. Change it to
udelay(5) and increase the loop count to match.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9bafa56c7cee5c6fa68de5924220abb220c7e229 17-Feb-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: fix bogus test in dwc3_gadget_start_isoc

Zero is a valid value for a microframe number. So remove the bogus
test for non-zero in dwc3_gadget_start_isoc().

Cc: stable@vger.kernel.org
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
27a78d6a283d6782438f72306746afe4bf44c215 23-Feb-2012 Anton Tikhomirov <av.tikhomirov@samsung.com> usb: dwc3: use proper function for setting endpoint name

It's wrong to use the size of array as an argument for strncat.
Memory corruption is possible. strlcat is exactly what we need here.

Cc: stable@vger.kernel.org
Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
8d62cd65d74d0e241b3a152f7347bb66126b705b 15-Feb-2012 Paul Zimmerman <paulz@synopsys.com> usb: dwc3: gadget: don't wrap around the TRB poll on non-ISOC

If we have a non-ISOC endpoint, we will not have a Link TRB
pointing to the beginning of the TRB pool. On such endpoints,
we don't want to let the driver wrap around the TRB pool
otherwise controller will hang waiting for a valid TRB.

Cc: stable@vger.kernel.org
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
1d046793958f128dd43d42a4a0dac48bf6914273 16-Feb-2012 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: clean up whitespace damage, typos, missing parens, etc.

trivial patch, no functional changes

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
0fc9a1be09d9f8b19bcf64ab96836cb92beb0970 19-Dec-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: use generic map/unmap routines

those routines have everything we need to map/unmap
USB requests and it's better to use them.

In order to achieve that, we had to add a simple
change on how we allocate and use our setup buffer;
we cannot allocate it from coherent anymore otherwise
the generic map/unmap routines won't be able to easily
know that the GetStatus request already has a DMA
address.

Signed-off-by: Felipe Balbi <balbi@ti.com>
f9c56cdd3905c96c600456203637bd7ec8ec6383 08-Feb-2012 Ido Shayevitz <idos@codeaurora.org> usb: gadget: Clear usb_endpoint_descriptor inside the struct usb_ep on disable

This fix a bug in f_serial, which expect the ep->desc to be NULL after
disabling an endpoint.

Cc: stable@vger.kernel.org
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
f6bafc6a1c9d58f0c234ac5052b9c09b0747348c 06-Feb-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: convert TRBs into bitshifts

this will get rid of a useless memcpy on
IRQ handling, thus improving driver performance.

Tested with OMAP5430 running g_mass_storage on
SuperSpeed and HighSpeed.

Note that we are removing the little endian access
of the TRB and all accesses will be in System endianness,
if there happens to be a system in BE, bit 12 of GSBUSCFG0
should be set so that HW does byte invariant BE accesses
when fetching TRBs.

Signed-off-by: Felipe Balbi <balbi@ti.com>
3b637367ae40b6d3c20e30cb0cdd059e67bbf848 09-Feb-2012 Gerard Cauvy <g-cauvy1@ti.com> usb: dwc3: ep0: fix SetFeature(TEST)

When host requests us to enter a test mode,
we cannot directly enter the test mode before
Status Phase is completed, otherwise the core
will never be able to deliver the Status ZLP
to host, because it has already entered the
requested Test Mode.

In order to fix the error, we move the actual
start of Test Mode right after we receive
Transfer Complete event of the status phase.

Signed-off-by: Gerard Cauvy <g-cauvy1@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2e81c36a00d0eb8ce72faaaec1a1d865617374ae 02-Feb-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: allocate 3 packets for bulk and isoc endpoints

Those transfer types are generally high bandwidth, so we
want to optimize transfers with those endpoints.

For that, databook suggests allocating 3 * wMaxPacketSize
of FIFO. Let's do that.

Signed-off-by: Felipe Balbi <balbi@ti.com>
d70d84423cbc5d6d929640189cf204e693024309 06-Feb-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: avoid memcpy()ing event buffer

We're only using the 4 byte events and memcpy()
will make us slower. We can easily avoid that.

Signed-off-by: Felipe Balbi <balbi@ti.com>
8db7ed15f2557e26371e4b2d98fee290d992b715 18-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: start core on Rx.Detect

When we set Run/Stop bit, we also move the
core to Rx.Detect state so that USB3 handshake
can start from a known location.

Signed-off-by: Felipe Balbi <balbi@ti.com>
457e84b6624b4d97e6ffae437887ea51a22d54a0 18-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: dynamically re-size TxFifos

We need to dynamically re-size TxFifos for the
cases where default values will not do.

While at that, we create a simple function which,
for now, will just allocate one full packet fifo
space for each of the enabled endpoints.

This can be improved later in order to allow for
better throughput by allocating more space for
endpoints which could make good use of that like
isochronous and bulk.

Signed-off-by: Felipe Balbi <balbi@ti.com>
7b7dd0253cd50fdc413b4ec199f1f3af08b7ba0d 18-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: use the descriptor pointer we hold

We hold that pointer for one reason. It just
looks nicer to use it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
40aa41fba348bc5bd19ff5bcf2b03d67bb01d1ce 18-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: fix XferNotReady debug print

Only bit 3 of the event status bitfield is valid
and the others should not be considered.

Make sure SW matches documentation on that case
to avoid bogus debugging prints which would
confuse an engineer.

Signed-off-by: Felipe Balbi <balbi@ti.com>
138801aaa566ecb5a5739a85909b9ec7285efd70 02-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: allow Link state changes via debugfs

This is very useful for low level link testing where
we might not have a USB Host stack, only a scope to
verify signal integrity.

Signed-off-by: Felipe Balbi <balbi@ti.com>
8598bde7fa125e85bc97decd6513d37dcf1e7bd9 02-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: re-factor Link state change to a function

Most link changes will, of course, happen with
the help of a matching host HW, but in some cases
we might want to debug very low level details about
the link and exposing this to debugfs sounds like
a good plan.

This is a preparation for such setup.

Signed-off-by: Felipe Balbi <balbi@ti.com>
04a9bfcd50dd568a8f1a10194a7f336f6b3ad81c 02-Jan-2012 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: re-factor USB2 test mode to a function

There are some situations were we might need to
enable USB Test Modes without having access to a
Host stack. In such situations we cannot rely
solely on USB Control Messages to enable test
features.

For those cases, we will also allow test mode
to be enabled via debugfs and this patch is a
preparation for that.

Signed-off-by: Felipe Balbi <balbi@ti.com>
c09d6b51d78f5ad33417dbac9b479bd6709f9f25 24-Jan-2012 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: unmap the proper number of sg entries

num_sgs contains the number of sgs assigned by the gadget.
num_mapped_sgs contains the number of mapped sgs which may differ from
the gadget's values. For dma_unmap_sg() we have to provide the value
which was returned by dma_map_sg().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
18b7ede5f7ee2092aedcb578d3ac30bd5d4fc23c 02-Jan-2012 Felipe Balbi <balbi@ti.com> usb: ch9: fix up MaxStreams helper

According to USB 3.0 Specification Table 9-22, if
bmAttributes [4:0] are set to zero, it means "no
streams supported", but the way this helper was
defined on Linux, we will *always* have one stream
which might cause several problems.

For example on DWC3, we would tell the controller
endpoint has streams enabled and yet start transfers
with Stream ID set to 0, which would goof up the host
side.

While doing that, convert the macro to an inline
function due to the different checks we now need.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
eeb720fb21d61dfc3aac780e721150998ef603af 27-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: add support for SG lists

add support for SG lists on dwc3 driver. With
this we can e.g. use VFS layer's SG lists on
storage gadgets so that we can start bigger
transfers and improve throughput.

Signed-off-by: Felipe Balbi <balbi@ti.com>
42f8eb7a1087442e9710ce75b355c0f28aadbf96 27-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't force 'LST' always

the LST bit is to be set on the last of a series
of consecutive TRBs. We had a workaround for a
problem where data would get corrupted but that
doesn't happen anymore. It's likely that it was
caused by some FPGA instability during development
phase.

Signed-off-by: Felipe Balbi <balbi@ti.com>
68e823e24aea5227eaf20d6435485e733109d113 27-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't return anything on prepare trbs

all that function does is setup a TRB to be sent
to HW later. There's no need to return anything
actually.

Signed-off-by: Felipe Balbi <balbi@ti.com>
c71fc37c191747ea1f00424e84f96c1f88e52bfc 22-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: re-factor dwc3_prepare_trbs()

In order to make it easier to add SG support,
let's split the big loop out to its own function.

Signed-off-by: Felipe Balbi <balbi@ti.com>
961906edb549c95f4cc33e4f3dbfd0fcc364954d 20-Dec-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: move us to Default State after reset

After a bus reset, we should move our state to
Default, in order to be able to re-enumerate again.

I only managed to trigger this problem with g_ether
by removing the cable after a few transfers had been
completed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
c90bfaece97c18d1ad66b9d4c717b1cb55a647ad 29-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: fix stream enable bit

ep->max_streams is a mere hint to the gadget
driver that 'ep' supports stream handling. Using
that as a decision variable for enabling streams
was my worst brain-fart to date.

Instead, we should check from the Superspeed
Endpoint Companion Descriptor if the endpoint
has requested streams. For that we need a little
re-factoring but it is now correct.

Debugged-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
df62df56e13d73cb0dd4c54649d4fe13557128f8 14-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: missing disconnect event

DWC3 revisions <1.88a have an issue which would
case a missing Disconnect event if cable is
disconnected while there's a Setup packet
pending the FIFO.

Signed-off-by: Felipe Balbi <balbi@ti.com>
05870c5ba2002c7d49adf8875cca49ee062af894 14-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: missing USB3 Reset event

DWC3 revisions <1.90a have an issue which would cause
a missing USB3 Reset event. In such cases, it's
suggested that we follow the steps of a normal
USB3 Reset on Connection Done Event.

Signed-off-by: Felipe Balbi <balbi@ti.com>
fae2b904aa85beecd0950026de28921ae65fb3da 14-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: workaround: U1/U2 -> U0 transiton

RTL revisions <1.83a have an issue where, depending
on the link partner, the USB link might do multiple
entry/exit of low power states before a transfer
takes place causing degraded throughput.

The suggested workaround is to clear bits
12:9 of DCTL register if we see a transition
from U1|U2 to U0 and only re-enable that on
a transfer complete IRQ and we have no pending
transfers on any of the enabled endpoints.

Signed-off-by: Felipe Balbi <balbi@ti.com>
d39ee7be2aaf0a53d7b5f43c13571bac95f7cc0c 03-Nov-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: return early in dwc3_cleanup_done_reqs()

This patch avoids the compiler spitting out the following warning:
|drivers/usb/dwc3/gadget.c:1304: warning: 'trb' is used uninitialized \
in this function

This is only uninitialized if the list of to-cleanup TRBs is empty which
should not be the case because we call this functions once a transfer
completed so it should be on list.

In order to make the warning disappear we return early. This should
never happen and the WARN_ON_ONCE(1) is there in case it happens
so we can investigate what went wrong.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
25b8ff68bf1d4954d4a9dcb4862c6b6a53cb09e2 03-Nov-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: fix few coding style problems

There were a few coding style issues with this driver
which are now fixed:

drivers/usb/dwc3/debugfs.c:48: WARNING: Use #include \
<linux/uaccess.h> instead of <asm/uaccess.h>
drivers/usb/dwc3/debugfs.c:484: ERROR: space required \
before the open brace '{'
drivers/usb/dwc3/ep0.c:261: WARNING: line over 80 characters
drivers/usb/dwc3/ep0.c:287: WARNING: suspect code indent \
for conditional statements (16, 23)
drivers/usb/dwc3/gadget.c:749: WARNING: line over 80 characters
drivers/usb/dwc3/gadget.c:1267: WARNING: line over 80 characters
drivers/usb/dwc3/gadget.h:116: WARNING: line over 80 characters
drivers/usb/dwc3/io.h:42: WARNING: Use #include \
<linux/io.h> instead of <asm/io.h>

Signed-off-by: Felipe Balbi <balbi@ti.com>
4878a02898bab1a988206341e529997cb46e5f29 31-Oct-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: move generic dwc3 code from gadget into core

A few inits like the scale value or the removal of the DISSCRAMBLE is
done in the gadget code however it touches a general register.
Move this piece to the core.c file since it is likely to be requied by
both, parts of the core (device and host).

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
3140e8cbfec18ecb9c9ef856933fdb98c09af1e8 31-Oct-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: use a helper function for operation mode setting

There are two where need to set operational mode:
- during initialization while we decide to run in host,device or DRD
mode
- at runtime via the debugfs interface.

This patch provides a new function which sets the operational mode and
moves its initialiation to the mode switch instead in the gadget code
itself.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9f622b2a407d8b34a5a7f5b4abd8b29b25cf4f32 12-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: calculate number of event buffers dynamically

This will allow us to only allocate memory when
we actually need.

Signed-off-by: Felipe Balbi <balbi@ti.com>
6c167fc9b0c23ead791edb94cf4debb6b8e534b5 07-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: allow forcing a maximum speed

this is mainly for testing. In order to be able
to test if we're enumerating correctly on all
speeds, let that be controlled by a module
parameter.

Signed-off-by: Felipe Balbi <balbi@ti.com>
b2c2271c826589c5c5b285a5a32e158d36d263d9 07-Oct-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: don't disable endpoints on exit

when we remove the gadget driver, it will already
do that for us.

Signed-off-by: Felipe Balbi <balbi@ti.com>
d327ab5b6d660d6fe22b073b743fde1668e593bb 19-Nov-2011 Michal Nazarewicz <mina86@mina86.com> usb: gadget: replace usb_gadget::is_dualspeed with max_speed

This commit replaces usb_gadget's is_dualspeed field with
a max_speed field.

[ balbi@ti.com : Fixed DWC3 driver ]

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12d36c16bde3ee0643d705caa87723de536dbe49 03-Nov-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: initialize max_streams

Without this the gadget will never be able to allocate a stream capable
endpoint. The manual says that the stream id is a 16bit id. It does not
talk about an upper limit in any other way. So I think 15 is a
reasonable limit :)

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
dc1c70a774b6fe3744b330d58bb9cf802f7eac89 30-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: convert structures into bitshifts

our parameter structures need to be written to
HW, so instead of assuming little endian, we
convert those into bit shifts.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
aabb70752361a8b8ca44142a942a5bd133c4d304 30-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: allow clock gating to work

The dwc3 core has internal clock gating support.

Let's allow that to happen by clearing the disable
bit in GCTL register.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
879631aa658be2c1307758223b6d15236f9f6335 30-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: implement streams support

The following patch adds support for streams
to dwc3 driver.

While at that, also fix one small issue on
endpoint disable where we should clear all
flags not only ENABLED.

Reviewied-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a4af9008bb69f49df3abf816d48e224aca810af4 30-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: add support for Bursts

We already have the value from gadget drivers,
just need to pass it to our controller.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c439ef87c33a1df30f528cb152151465c2529cac 30-Sep-2011 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: fix DMA offset calculation

Fix offset calculation in dwc3_trb_dma_offset()

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5275455a6e6ae6b57303834b0afd267bb9657ffc 30-Sep-2011 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: make DWC3_EP_WEDGE do the right thing

This makes DWC3_EP_WEDGE do the right thing, which is
prevent DWC3_EP_WEDGE from ever being cleared by a
ClearFeature(HALT) command.

[ balbi@ti.com : allowed set_wedge to send SetHalt command
to controller ]

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
82828ca77b8b63b817d9bb540145a4cafa9be582 30-Sep-2011 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: driver should not wait for RxFIFO to drain

An older version of the databook said to wait for the FIFO to
drain, but that has been removed from the newer databooks.

Waiting for RxFIFO to drain caused problems when testing against
one of the host controllers available in the market.

After talking to one of the RTL engineers, he stated that we
should _not_ wait for RxFIFO to drain.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b23c843992b659d537514e6493d673284f5d6724 30-Sep-2011 Paul Zimmerman <Paul.Zimmerman@synopsys.com> usb: dwc3: gadget: fix DEPSTARTCFG for non-EP0 EPs

DEPSTARTCFG for non-EP0 EPs must only be sent once per config

[ balbi@ti.com : changed config_start to start_config_issued ]

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
49a25cc9a7effe2993e65229c2ea0be726919bcf 30-Sep-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc: remove "All rights reserved" statement.

Some people think that this line is not compatible with the GPL. The
statement was required due to the Buenos Aires Convention and is now
deprecated. I remove it because it is said that it is pointless nowdays.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
019ac83252dc2b356cb0ca81c25a077ec90309e7 08-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: improve debug on link state change

It's useful to know which states core is going
through, as it might help us figure out misbehavior
on specific link states.

Signed-off-by: Felipe Balbi <balbi@ti.com>
bb7ea2841e9c8669ac31e4262f585729bf779bff 08-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: drop the useless dma_sync_single* calls

if req->dma isn't DMA_ADDR_INVALID it means gadget driver
mapped the request or allocated from coherent, so it's
unnecessary to do anything.

Signed-off-by: Felipe Balbi <balbi@ti.com>
771f184ecebf34929a849eaa707aa463234254f7 08-Sep-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: fix GCTL programming

ensure a few bits are cleared before enabling
what we need.

Signed-off-by: Felipe Balbi <balbi@ti.com>
78c58a53c9864447f2a46d4c06dd3c2616823ad2 31-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: do not map/unmap ZLP transfers

If the gadget drivers sends a ZLP we are trying to map this this request
which does not work on all implementations. So we simply skip mapping
it.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
0b7836a9eb32f626ffd3fe3045e8c618cb8ed965 30-Aug-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: drop EP0_STALL state

Whenever we issue a Set Stall command on EP0,
the state machine will be restarted and Stall
is cleared automatically, when core receives
the next SETUP packet.

There's no need to track that EP0_STALL state.

Signed-off-by: Felipe Balbi <balbi@ti.com>
61d58242f634642de42d6a4098913b7254a65053 29-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: replace mdelay with udelay in the busy loop

There are two spots where we wait until the HW finishes processing a
certain command. Initially we had a few problems and we used 500ms as a
limit to be on a the safe side. Paul Zimmerman mentioned this is little too
much. After a debugging session, we noticed that we hardly ever go over 20us
and didn't pass 30usec so far. Using mdelay() seems way overloaded.

Giving the current numbers 500usec as the upper limit is more than enough.
Should it ever timeout then something is definitely wrong.

While here, also replace the type with u32 since long does not really
fit here.

Cc: Paul Zimmerman <paul.zimmerman@synopsys.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
624407f96f134bcd3063eb0d404fc6d41323bef8 29-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: rework the dequeue on RESET & DISCONNECT

- since a while we are disabling an endpoint and purging every requests on
RESET and DISCONNECT which leads to a warning since the endpoint was
disabled twice (once by the UDC, and second time by the gadget). I
think UDC should nuke all requests because all those requests
become invalid. It's gadget driver's responsability, though, to disable
its used endpoints. This is done by merging dwc3_stop_active_transfer()
and dwc3_gadget_nuke_reqs() into dwc3_remove_requests().

- dwc3_stop_active_transfer() is now no longer called unconditionaly.
This has the advantage that it is always called to disable an active
transfer which means if res_trans_idx 0 than something went wrong and
it is an error condition because we can't clean up the requests.

- Remove the DWC3_EP_WILL_SHUTDOWN which was introduced while
introducing the command complete part for dequeue. All requests on
req_queued list should be removed during the dwc3_cleanup_done_reqs()
callback so there is no reason to go through the list again.
We consider it an error condition if requests are still on this
list since we never queue TRB without LST=1 (the last requests has
always LST=1, there are no requests with LST=0 behind it).

[ balbi@ti.com : reworked commit log a bit, made patch apply ]

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
c7fcdeb2627c46b7ec3f0bcb2054b10405f9a70e 27-Aug-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: ep0: simplify EP0 state machine

The DesignWare USB3 core tells us which phase
of a control transfer should be started, it
also tells us which physical endpoint needs
that transfer.

With these two informations, we have all we
need to simply EP0 handling quite a lot and
get rid rid of the SW state machine tracking
ep0 states.

For achieving this perfectly, we needed to
add support for situations where we get
XferNotReady while endpoint is still busy
and XferNotReady while gadget driver still
hasn't queued a request.

Signed-off-by: Felipe Balbi <balbi@ti.com>
5812b1c236774ea580b6af39411eb4f7297d7623 27-Aug-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: add a bounce buffer for control endpoints

This core cannot handle OUT transfers which aren't
aligned to wMaxPacketSize, but that can happen at
least on control endpoint with the USB Audio Class.

This patch adds a bounce buffer to be used on the
case of a non-aligned ep0out request is queued.

Signed-off-by: Felipe Balbi <balbi@ti.com>
164f6e141ed214bda30fb219d41ec3254bd90886 27-Aug-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: improve command completion debug message

the previous message had too little meaning. Make
it more human readable and use the macro we already
had for extracting the command completion status out
of DEPCMDn register.

Signed-off-by: Felipe Balbi <balbi@ti.com>
f198ead21bcb7b03d7bb2cba7ba0f5ad615a3862 27-Aug-2011 Felipe Balbi <balbi@ti.com> usb: dwc3: gadget: set request dma to invalid when unmapping

if we don't set DMA address to invalid when unmapping,
we might fall in a situation where request buffer
can't be mapped to DMA again.

Signed-off-by: Felipe Balbi <balbi@ti.com>
0156cf8603b86c949d02aa315684b4c677e66638 22-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gaget: clear DWC3_EP_WILL_SHUTDOWN bit

Without this patch we won't clear that bit and instead will
clear all other bits on our endpoint flag.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
5a18999ebd880f6fc4264aa5687daad4c4013bce 22-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: use TRB type 6 for ISOC transfers

Type 6 should be used for the first transfer during an interval. This is
also what the reference driver is using. Type 7 seems to be for following
or additional transfers within the same interval.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
a1ae9be5fc137d7e911a77ef408273ff55a53a39 22-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: reset resource index to zero

If we collected two requests together (i.e. only the last of them has
LST=1) then we only have to stop transfer once: The clean-up code will
cleanup everything until first TRB with the LST bit set.
After XferComplete this index should be no longer valid since there is
no transfer pending.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
0d2f4758530d1598087d1d2f3e75b4f7d17fc6c7 19-Aug-2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb: dwc3: gadget: fixing dequeue of TRBs

A TRB which is dequeued seems to have its HWO bits set to 1. Therefore
we ignore it if we dequeue it after the command is completed.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
29cc88979a8818cd8c5019426e945aed118b400e 23-Aug-2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> USB: use usb_endpoint_maxp() instead of le16_to_cpu()

Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
instead of le16_to_cpu(desc->wMaxPacketSize).
This patch fix it up

Cc: Armin Fuerst <fuerst@in.tum.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Johannes Erdfelt <johannes@erdfelt.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: David Kubicek <dave@awk.cz>
Cc: Johan Hovold <jhovold@gmail.com>
Cc: Brad Hards <bhards@bigpond.net.au>
Acked-by: Felipe Balbi <balbi@ti.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
Cc: David Brownell <david-b@pacbell.net>
Cc: David Lopo <dlopo@chipidea.mips.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Xie Xiaobo <X.Xie@freescale.com>
Cc: Li Yang <leoli@freescale.com>
Cc: Jiang Bo <tanya.jiang@freescale.com>
Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Ben Dooks <ben@simtec.co.uk>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Herbert Pƶtzl <herbert@13thfloor.at>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Roman Weissgaerber <weissg@vienna.at>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Tony Olech <tony.olech@elandigitalsystems.com>
Cc: Florian Floe Echtler <echtler@fs.tum.de>
Cc: Christian Lucht <lucht@codemercs.com>
Cc: Juergen Stuber <starblue@sourceforge.net>
Cc: Georges Toth <g.toth@e-biz.lu>
Cc: Bill Ryder <bryder@sgi.com>
Cc: Kuba Ober <kuba@mareimbrium.org>
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
72246da40f3719af3bfd104a2365b32537c27d83 19-Aug-2011 Felipe Balbi <balbi@ti.com> usb: Introduce DesignWare USB3 DRD Driver

The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.

Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.

The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.

More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.

While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.

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

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>