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>
usb: dwc3: ep0: drop unnecessary variable

When returning from ep0_queue, we have an
unnecessary ret variable which is always
zero. Remove it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: split the special cases on ep0_queue

We can return early from each if () branch
and split the special cases for clarity. While
at that also add a comment to the delayed_status
case.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: drop dead code

There's no such thing as XferNotReady(SETUP), we
can safely drop all that code with no problems
whatsoever.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: ignore XferNotReady(STATUS) when we're not expecting it

Databook doesn't say we should stall if we
get XferNotReady(STATUS) while we're expecting
something else.

Instead of stalling and restarting, tests have
proven that ignoring the event is far more
effective.

This problem has been caught while rewriting
ep0 handling in order we pass Link Layer TD7.6.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: move DATA phase away from on-demand

We uncovered a limitation of this core WRT to the
Link Layer Compliance Suite's TD7.06.

On that test, host will start a GetDescriptor(DEVICE)
standard request, but it will do so only on the
SETUP phase, meaning there will *NOT* be any DATA or
STATUS phases.

The idea of the test is to verify robustness of the
IP WRT framing errors, so the test will send a
sequence of different SETUP_DPs each with a different
framing error and the Suite expects us to be able to
receive all SETUP_DPs with no timeouts.

This core, has the ability to tell us which phase the
host is expecting before we start it. Whenever we
receive a TP or DP when no transfers are cached on
the internal IP's caches, the IP will generate a
XferNotReady event with status informing us (in case
of physical ep0/ep1) if it's related to DATA or STATUS
phases - SETUP phase is expected to be prestarted.

Because we're always waiting for XferNotReady
events for DATA and STATUS phases, we will never
be able to know that the Host wants to start another
SETUP phase instead, which will render us "not
compliant" with TD7.06.

In order to "fix" the problem we must not rely
on XferNotReady events for the DATA phase  and try
to always pre-start DATA transfers on physical
endpoints 0 and 1. If host goes back to SETUP phase
from DATA phase we will receive a XferComplete for
that phase with TRB's status set to SETUP_PENDING,
which is only useful for printing a debugging log as
the core expects us to still go through to the STATUS
phase, initiate a CONTROL_STATUS TRB just so it
completes right away and, only then, we go back to
the pending SETUP phase.

SNPS has decided to modify the programming model of
the core so that on-demand DATA phases will not be
supported anymore. Note that this limitation does not
affect 2-stage transfers, meaning that if TD7.06 would
start a 2-stage transfer instead of a 3-stage transfer,
we would receive a "fake" XferNotReady(STATUS) which
would complete right after being initiated with
SETUP_PENDING status.

Other endpoints are also not affected, so we can still
use on-demand transfers on Bulk/Isoc/Interrupt endpoints.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: drop XferNotReady(DATA) support

Due to the late Silicon limitation found, we are
now pre-starting DATA phase's TRBs. If, still, we
get XferNotReady(DATA) we will ignore it unless
we're getting it for the wrong direction.

In that case we must keep the error case handling
plus add a ENDTRANSFER command to forcefully end
the Data TRB we started previously, then continue
to SetStall and so on.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: fix status phase delayed status direction

commit 68d3e66 (usb: dwc3: ep0: fix for possible early
delayed_status) added handling for early delayed status,
but the current code only works because so far delayed
status will always be on the IN direction.

This patch makes the code more robust by making sure that
we can handle all directions properly.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: ep0: make sure to reinitilize ep1 on STALL

When issuing SetStall on ep0, we must make sure to
reinitialize all flags on physical ep1 too.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: gadget: use variables according to their names in rxstate()

In rxstate(), improper types are given to 'fifo_count' and 'len' variables, and
these variables are not used in accordance to their names (up to the certain
point), i.e. 'len' to hold the size of a packet in the RX FIFO, and 'fifo_count'
to hold a difference between 'request->length' and 'request->actual'...
Interchange the variables up to the point where their use starts to make sense
again.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: host: don't program dma for zero byte tx

This is to reduce the overhead of dma programming for zero byte
transmit as same can be done using pio mode.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: gadget: don't program dma for zero byte tx

This is to reduce the overhead of dma programming for zero byte
transmit as same can be done using pio mode.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: check for zero byte in musb_read/write_fifo

Added a check in musb_{read | write}_fifo for zero byte length.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: NAK timeout scheme on bulk TX endpoint

Fixes endpoint starvation issue when more than one bulk QH is
multiplexed on the reserved bulk TX endpoint.

This patch sets the NAK timeout interval for such QHs, and when
a timeout triggers the next QH will be scheduled.

This scheme doesn't work for devices which are connected to a
high to full speed tree (transaction translator) as there is
no NAK timeout interrupt from the musb controller from such
devices.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: xceiv: create nop-usb-xceiv.h and avoid pollution on otg.h

nop-usb-xceiv was polluting otg.h with its own
function prototypes. Move those prototypes to
a nop-usb-xceiv.h header.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: xceiv: nop: let it work as USB2 and USB3 phy

We add a platform_data to pass the desired mode
for the nop-xceiv so it can work on USB2 and USB3
modes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: cleanup while removing musb omap glue driver

No functional change. Just replaced the call to platform_device_del and
platform_device_put with platform_device_unregister.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
spi/imx: make spi_imx_data.devtype_data member point to const data

This prepares *of_device_id.data becoming const. Without this change the
following warning would occur:

	drivers/spi/spi-imx.c: In function spi_imx_probe:
	drivers/spi/spi-imx.c:814:24: warning: assignment discards const qualifier from pointer target type [enabled by default]

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
spi/spi-omap2-mcspi: add a const qualifier

This prepares *of_device_id.data becoming const. Without this change
the following warning would occur:

	drivers/spi/spi-omap2-mcspi.c: In function 'omap2_mcspi_probe':
	drivers/spi/spi-omap2-mcspi.c:1118: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
serial/imx: make imx_port.devdata member point to const data

This prepares *of_device_id.data becoming const. Without this change the
following warning would occur:

	drivers/tty/serial/imx.c: In function 'serial_imx_probe_dt':
	drivers/tty/serial/imx.c:1430:17: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>