Commit graph

646 commits

Author SHA1 Message Date
John Youn 77966eb85e usb: dwc3: Validate the maximum_speed parameter
Check that dwc->maximum_speed is set to a valid value. Also add an error
when we use it later if we encounter an invalid value.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:38 +02:00
John Youn 7580862b3e usb: dwc3: Enable SuperSpeedPlus
Enable SuperSpeedPlus by programming the DCFG.speed and after
enumerating, set gadget->speed appropriately.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:27 +02:00
John Youn 2c7f1bd912 usb: dwc3: Update maximum_speed for SuperSpeedPlus
If the maximum_speed is not set, set it to a known value, either
SuperSpeed or SuperSpeedPlus based on the type of controller we are
using. If we are on DWC_usb31 controller, check the PHY interface to see
if it is capable of SuperSpeedPlus.

Also this check is moved after dwc3_core_init() so that we can check
dwc->revision.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:27 +02:00
John Youn ee5cd41c91 usb: dwc3: Update speed checks for SuperSpeedPlus
Update various places where the speed is checked so that it takes into
account SuperSpeedPlus properly.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:27 +02:00
John Youn 1f38f88a24 usb: dwc3: Update register fields for SuperSpeedPlus
Update various registers fields definitions for the DWC_usb31 controller
for SuperSpeedPlus support.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:26 +02:00
John Youn c4137a9c84 usb: dwc3: DWC_usb31 controller check
Add a convenience function to check if the controller is DWC_usb31.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-03-04 15:14:26 +02:00
John Youn c450960187 usb: dwc3: Fix assignment of EP transfer resources
The assignement of EP transfer resources was not handled properly in the
dwc3 driver. Commit aebda61871 ("usb: dwc3: Reset the transfer
resource index on SET_INTERFACE") previously fixed one aspect of this
where resources may be exhausted with multiple calls to SET_INTERFACE.
However, it introduced an issue where composite devices with multiple
interfaces can be assigned the same transfer resources for different
endpoints. This patch solves both issues.

The assignment of transfer resources cannot perfectly follow the data
book due to the fact that the controller driver does not have all
knowledge of the configuration in advance. It is given this information
piecemeal by the composite gadget framework after every
SET_CONFIGURATION and SET_INTERFACE. Trying to follow the databook
programming model in this scenario can cause errors. For two reasons:

1) The databook says to do DEPSTARTCFG for every SET_CONFIGURATION and
SET_INTERFACE (8.1.5). This is incorrect in the scenario of multiple
interfaces.

2) The databook does not mention doing more DEPXFERCFG for new endpoint
on alt setting (8.1.6).

The following simplified method is used instead:

All hardware endpoints can be assigned a transfer resource and this
setting will stay persistent until either a core reset or hibernation.
So whenever we do a DEPSTARTCFG(0) we can go ahead and do DEPXFERCFG for
every hardware endpoint as well. We are guaranteed that there are as
many transfer resources as endpoints.

This patch triggers off of the calling dwc3_gadget_start_config() for
EP0-out, which always happens first, and which should only happen in one
of the above conditions.

Fixes: aebda61871 ("usb: dwc3: Reset the transfer resource index on SET_INTERFACE")
Cc: <stable@vger.kernel.org> # v3.2+
Reported-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-02-17 10:31:53 +02:00
Jianqiang Tang 6a4290cc28 usb: dwc3: gadget: set the OTG flag in dwc3 gadget driver.
This patch is needed in order to pass one test case
defined in the OTG Automated Compliance Test specification.

Specification location:
http://www.usb.org/developers/onthego/otgeh_compliance_plan_1_2.pdf

This test case uses PET Tool, and PET Tool is one USB hardware
equipment provided by MQP Electronics.

Test case id is 6.8.3 B-UUT Bypass Capacitance.

We must set this otg flag in order to be able to return OTG
descriptor during enumeration, otherwise this test case with
failed with below error: "Get OTG descriptor request stalled".

Signed-off-by: Jianqiang Tang <jianqiang.tang@intel.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2016-02-03 23:58:20 +02:00
Felipe Balbi 5072cfc40a usb: dwc3: of-simple: fix build warning on !PM
if we have a !PM kernel build, our runtime
suspend/resume callbacks will be left defined but
unused. Add a ifdef CONFIG_PM guard.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-22 21:58:26 -06:00
John Youn d9261898a4 usb: dwc3: gadget: don't send extra ZLP
If the request->length is zero, a ZLP should already be sent due to that
and another ZLP is not needed to terminate the transfer.

Fixes: 04c03d10e5 ("usb: dwc3: gadget: handle request->zero")
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-22 21:58:26 -06:00
Felipe Balbi 95ca961c75 usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()
instead of using:

	if (condition) {
		dev_WARN_ONCE(dev, true, "foo");
		return -EINVAL;
	}

let's use:

	if (dev_WARN_ONCE(dev, condition, "foo"))
		return -EINVAL;

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-16 10:07:27 -06:00
Felipe Balbi 46a01427e9 usb: dwc3: trace: show request flags
struct usb_request have 3 flags which might be
important to know about during debug. This patch
shows each of the 3 flags as a single letter:

z -> for zero
s -> short not okay
i -> interrupt

A capital letter means the feature is enabled
while a lower case letter means it is disabled;

Thus 'zsI' indicates that a ZLP is not needed,
that we can accept a short packet and interrupt
for this request should be enabled.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi 04c03d10e5 usb: dwc3: gadget: handle request->zero
So far, dwc3 has always missed request->zero
handling for every endpoint. Let's implement
that so we can handle cases where transfer must
be finished with a ZLP.

Note that dwc3 is a little special. Even though
we're dealing with a ZLP, we still need a buffer
of wMaxPacketSize bytes; to hide that detail from
every gadget driver, we have a preallocated buffer
of 1024 bytes (biggest bulk size) to use (and
share) among all endpoints.

Reported-by: Ravi B <ravibabu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi b084662776 usb: dwc3: remove dwc3-qcom in favor of dwc3-of-simple
Now that we have a generic dwc3-of-simple.c, we can
use that instead of maintaining dwc3-qcom.c which is
extremely similar.

Cc: Ivan T. Ivanov <iivanov@mm-sol.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi 16adc674d0 usb: dwc3: add generic OF glue layer
For simple platforms which merely enable some clocks
and populate its children, we can use this generic
glue layer to avoid boilerplate code duplication.

For now this supports Qcom and Xilinx, but if we
find a way to add generic handling of regulators and
optional PHYs, we can absorb exynos as well.

Tested-by: Subbaraya Sundeep Bhatta <subbaraya.sundeep.bhatta@xilinx.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi b5d335e5ea usb: dwc3: ep0: fix setup_packet_pending initialization
It just ocurred to me that dwc3 already gives a
really hint of when a setup packet is pending and
that's the SETUP_PENDING TRB Status for EP0 IRQs.

Fix setup_packet_pending initialization based on
that. While at that, also make sure the comment in
gadget.c matches what code is doing.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi ac7bdcc1b3 usb: dwc3: gadget: simplify next_request() return check
In dwc3_cleanup_done_reqs() we expect that all
iterations of our while (1) loop will find a valid
struct dwc3_request *. In case we don't, we're
dumping a WARN_ON_ONCE() splat so that people report
the failure.

This patch is a simple cleanup converting:

	if (!req) {
		WARN_ON_ONCE(1);
		return 1;
	}

to:

	if (WARN_ON_ONCE(!req))
		return 1;

which is a little easier to read.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi acc38c4970 usb: dwc3: ep0: purge dev_dbg() calls
The last few dev_dbg() messages are converted to
tracepoints and we can finally ignore dev_dbg()
messages during debug sessions.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi 1407bf13e3 usb: dwc3: core: purge dev_dbg() calls
The last few dev_dbg() messages are converted to
tracepoints and we can finally ignore dev_dbg()
messages during debug sessions.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi ec5e795cde usb: dwc3: gadget: purge dev_dbg() calls
The last few dev_dbg() messages are converted to
tracepoints and we can finally ignore dev_dbg()
messages during debug sessions.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi bb423984c2 usb: dwc3: gadget: simplify dwc3_gadget_ep_queue()
By moving our sanity checks our internal function
__dwc3_gadget_ep_queue() we can simplify the
externally visible API while also making sure that
callers of __dwc3_gadget_ep_queue() also make use of
the same checks.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-15 09:12:41 -06:00
Felipe Balbi 62e345ae5b usb: dwc3: gadget: don't prestart interrupt endpoints
Because interrupt endpoints usually transmit such
small amounts of data, it seems pointless to prestart
transfers and try to get speed improvements. This
patch also sorts out a problem with CDC ECM function
where its notification endpoint gets stuck in busy
state and we continuously issue Update Transfer
commands.

Fixes: 8a1a9c9e45 ("usb: dwc3: gadget: start transfer on XFER_COMPLETE")
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-11-30 15:35:14 -06:00
Ben McCauley b9e51b2b1f usb: dwc3: gadget: let us set lower max_speed
In some SoCs, dwc3 is implemented as a USB2.0 only
core, meaning that it can't ever achieve SuperSpeed.

Currect driver always sets gadget.max_speed to
USB_SPEED_SUPER unconditionally. This can causes
issues to some Host stacks where the host will issue
a GetBOS() request and we will reply with a BOS
containing Superspeed Capability Descriptor.

At least Windows seems to be upset by this fact and
prints a warning that we should connect $this device
to another port.

[ balbi@ti.com : rewrote entire commit, including
source code comment to make a lot clearer what the
problem is ]

Cc: <stable@vger.kernel.org>
Signed-off-by: Ben McCauley <ben.mccauley@garmin.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-11-17 11:35:48 -06:00
Heikki Krogerus b4c580a43d usb: dwc3: pci: add support for Intel Broxton SOC
PCI IDs for Broxton based platforms.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-11-16 10:12:29 -06:00
Ville Syrjälä d115d7050a Revert "usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs"
This reverts commit 8f2c9544ab.

As it breaks g_ether on my Baytrail FFRD8 device. Everything starts out
fine, but after a bit of data has been transferred it just stops
flowing.

Note that I do get a bunch of these "NOHZ: local_softirq_pending 08"
when booting the machine, but I'm not really sure if they're related
to this problem.

Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-12 13:36:13 -05:00
Felipe Balbi e5f68b4a3e Revert "usb: dwc3: gadget: remove unnecessary _irqsave()"
This reverts commit 70f3a9caa1.

That commit was causing a lockdep splat with g_ether and that
was interfering with proper functionality.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-12 13:32:05 -05:00
John Youn 94218ee31b usb: dwc3: pci: Set enblslpm quirk for Synopsys platforms
Certain Synopsys prototyping PHY boards are not able to meet timings
constraints for LPM. This allows the PHY to meet those timings by
leaving the PHY clock running during suspend.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:59 -05:00
John Youn ec791d149b usb: dwc3: Add dis_enblslpm_quirk
Add a quirk to clear the GUSB2PHYCFG.ENBLSLPM bit, which controls
whether the PHY receives the suspend signal from the controller.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:59 -05:00
John Youn bb7f3d6d32 usb: dwc3: pci: Add platform data for Synopsys HAPS
Add platform data and set usb3_lpm_capable and has_lpm_erratum.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:59 -05:00
John Youn 9a5a0783e4 usb: dwc3: pci: trivial: Formatting
Fix the alignment of the PCI device definitions. Also change the hex
digit capitalization of one constant to make it consistent with the
rest of the file and driver.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:59 -05:00
John Youn 690fb3718a usb: dwc3: Support Synopsys USB 3.1 IP
This patch allows the dwc3 driver to run on the new Synopsys USB 3.1
IP core, albeit in USB 3.0 mode only.

The Synopsys USB 3.1 IP (DWC_usb31) retains mostly the same register
interface and programming model as the existing USB 3.0 controller IP
(DWC_usb3). However the GSNPSID and version numbers are different.

Add checking for the new ID to pass driver probe.

Also, since the DWC_usb31 version number is lower in value than the
full GSNPSID of the DWC_usb3 IP, we set the high bit to identify
DWC_usb31 and to ensure the values are higher.

Finally, add a documentation note about the revision numbering scheme.
Any future revision checks (for STARS, workarounds, and new features)
should take into consideration how it applies to both the 3.1/3.0 IP.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:58 -05:00
John Youn e8095a2536 usb: dwc3: pci: Add the PCI Product ID for Synopsys USB 3.1
This adds the PCI product ID for the Synopsys USB 3.1 IP core
(DWC_usb31) on a HAPS-based PCI development platform.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:58 -05:00
John Youn 41adc59cae usb: dwc3: pci: Add the Synopsys HAPS AXI Product ID
This ID is for the Synopsys DWC_usb3 core with AXI interface on PCIe
HAPS platform. This core has the debug registers mapped at a separate
BAR in order to support enhanced hibernation.

Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-10-09 16:06:58 -05:00
Felipe Balbi 70f3a9caa1 usb: dwc3: gadget: remove unnecessary _irqsave()
We *know* our threads executes with our IRQs
disabled. We really don't need to use the _irqsave()
variant of spin_lock().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-28 15:19:31 -05:00
Felipe Balbi e6e709b7ab usb: dwc3: gadget: use Update Transfer from Xfer In Progress
Instead of limiting __dwc3_gadget_kick_transfer() to
Xfer Complete, we can try to issue Update Transfer
command from Xfer In Progress too.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-28 15:19:31 -05:00
Felipe Balbi 6bb4fe12ea usb: dwc3: gadget: use update transfer command
If we get a Xfer Not Ready event with reason
"Transfer Active" it means endpoint is still
transferring data and we can use that to issue
update transfer for this particular endpoint
in case we have pending requests in our queue.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-28 15:19:31 -05:00
Felipe Balbi 8a1a9c9e45 usb: dwc3: gadget: start transfer on XFER_COMPLETE
if by the time we get to XFER_COMPLETE we have
pending requests to be processed, instead of waiting
for a following XFER_NOT_READY, let's start the request
right away and, maybe, save the time of a few NAKs
due to lack of started transfers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-28 14:17:26 -05:00
Heikki Krogerus 9caeb06ebd usb: dwc3: pci: passing forward the ACPI companion
Sharing the ACPI companion with dwc3 core so it has access
to the properties defined for DWC3 in ACPI tables.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Heikki Krogerus 3d128919b7 usb: dwc3: core: convert to unified device property interface
No functional affect on existing platforms, but the driver
is now ready to extract the properties also from ACPI tables
as well as from DT.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Heikki Krogerus 06e7114f0d usb: common: of_usb_get_dr_mode to usb_get_dr_mode
By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Heikki Krogerus 666472733b usb: dwc3: st: prepare the driver for generic usb_get_dr_mode function
of_usb_get_dr_mode will be converted into more generic
usb_get_dr_mode function that will take struct device
instead of struct device_node as its parameter.

To make the conversion possible later, waiting for the
platform device for dwc3 to be populated before calling
of_usb_get_dr_mode.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
CC: Giuseppe Cavallaro <peppe.cavallaro@st.com>
CC: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Heikki Krogerus 63863b988e usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed
By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Sekhar Nori 6344475f53 usb: dwc3: support for pinctrl state change during system sleep
Add support for USB DRVVBUS pinctrl state change during
suspend/resume. This helps is conserving power during
system sleep.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Nikhil Badola db2be4e9e3 usb: dwc3: Add frame length adjustment quirk
Add adjust_frame_length_quirk for writing to fladj register
which adjusts (micro)frame length to value provided by
"snps,quirk-frame-length-adjustment" property thus avoiding
USB 2.0 devices to time-out over a longer run

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Felipe Balbi a8f32817ee usb: dwc3: gadget: improve ep_queue's error reporting
We shouldn't return -EBUSY, that's used only internally
when the core still has transfers in flight on a given
endpoint.

Also, combine the error reporting so that we don't have
to duplicate it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Felipe Balbi 89185916d2 usb: dwc3: gadget: clear DWC3_PENDING_REQUEST when request is queued
Instead of clearing DWC3_PENDING_REQUEST when
we start transfer, let's do it when the request
is actually queued, that way we know for sure
that we're clearing in the right time.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Felipe Balbi 1d6a39186b usb: dwc3: gadget: start requests as soon as they come
In an attempt to make dwc3 slightly faster, let's
start usb_requests as soon as they come as that will
let us avoid a XFER_NOT_READY event and save a little
bit of time.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Felipe Balbi fe84f522ed usb: dwc3: gadget: move trace_dwc3_ep_queue()
by moving trace_dwc3_ep_queue() from dwc3_gadget_ep_queue()
to __dwc3_gadget_ep_queue() after usb_request is properly
initialized, makes for a better output always showing a
request with 0 actual and -115 (-EINPROGRESS) status.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-27 10:54:31 -05:00
Roger Quadros a66c275b3d usb: dwc3: gadget: Fix BUG in RT config
Using spin_lock() in hard irq handler is pointless
and causes a BUG() in RT (real-time) configuration
so get rid of it.

The reason it's pointless is because the driver is
basically accessing register which is, anyways,
atomic.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-21 14:42:36 -05:00
Felipe Balbi e2ae0692bf usb: dwc3: omap: enable irqs lately
If we enable IRQs before requesting our
extcon device, we might fall into a situation
where and IRQ fires before we're ready to
handle it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-14 09:51:58 -05:00