History log of /drivers/usb/dwc3/gadget.c
Revision Date Author Comments
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>