aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3 (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-02-17usb: dwc3: Fix assignment of EP transfer resourcesJohn Youn3-24/+52
The assignement of EP transfer resources was not handled properly in the dwc3 driver. Commit aebda6187181 ("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: aebda6187181 ("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-03usb: dwc3: gadget: set the OTG flag in dwc3 gadget driver.Jianqiang Tang1-0/+1
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>
2015-12-22usb: dwc3: of-simple: fix build warning on !PMFelipe Balbi1-0/+2
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-22usb: dwc3: gadget: don't send extra ZLPJohn Youn1-1/+2
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: 04c03d10e507 ("usb: dwc3: gadget: handle request->zero") Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-12-16usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()Felipe Balbi1-8/+6
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-15usb: dwc3: trace: show request flagsFelipe Balbi1-1/+10
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-15usb: dwc3: gadget: handle request->zeroFelipe Balbi2-2/+51
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-15usb: dwc3: remove dwc3-qcom in favor of dwc3-of-simpleFelipe Balbi3-139/+0
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-15usb: dwc3: add generic OF glue layerFelipe Balbi3-0/+188
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-15usb: dwc3: ep0: fix setup_packet_pending initializationFelipe Balbi2-5/+7
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-15usb: dwc3: gadget: simplify next_request() return checkFelipe Balbi1-3/+2
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-15usb: dwc3: ep0: purge dev_dbg() callsFelipe Balbi1-2/+2
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-15usb: dwc3: core: purge dev_dbg() callsFelipe Balbi1-3/+5
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-15usb: dwc3: gadget: purge dev_dbg() callsFelipe Balbi1-16/+21
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-15usb: dwc3: gadget: simplify dwc3_gadget_ep_queue()Felipe Balbi1-15/+11
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-11-30usb: dwc3: gadget: don't prestart interrupt endpointsFelipe Balbi1-0/+1
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: 8a1a9c9e4503 ("usb: dwc3: gadget: start transfer on XFER_COMPLETE") Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-11-17usb: dwc3: gadget: let us set lower max_speedBen McCauley1-1/+23
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-16usb: dwc3: pci: add support for Intel Broxton SOCHeikki Krogerus1-0/+4
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-10-12Revert "usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs"Ville Syrjälä1-16/+21
This reverts commit 8f2c9544aba636134303105ecb164190a39dece4. 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-12Revert "usb: dwc3: gadget: remove unnecessary _irqsave()"Felipe Balbi1-2/+3
This reverts commit 70f3a9caa11665e9f9aace581d85d8483716a4c8. 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-09usb: dwc3: pci: Set enblslpm quirk for Synopsys platformsJohn Youn1-0/+1
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-09usb: dwc3: Add dis_enblslpm_quirkJohn Youn3-0/+11
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-09usb: dwc3: pci: Add platform data for Synopsys HAPSJohn Youn1-0/+15
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-09usb: dwc3: pci: trivial: FormattingJohn Youn1-8/+8
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-09usb: dwc3: Support Synopsys USB 3.1 IPJohn Youn2-2/+26
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-09usb: dwc3: pci: Add the PCI Product ID for Synopsys USB 3.1John Youn1-0/+5
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-09usb: dwc3: pci: Add the Synopsys HAPS AXI Product IDJohn Youn1-0/+5
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-09-28usb: dwc3: gadget: remove unnecessary _irqsave()Felipe Balbi1-3/+2
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-28usb: dwc3: gadget: use Update Transfer from Xfer In ProgressFelipe Balbi1-2/+2
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-28usb: dwc3: gadget: use update transfer commandFelipe Balbi1-4/+5
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-28usb: dwc3: gadget: start transfer on XFER_COMPLETEFelipe Balbi1-0/+8
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-27usb: dwc3: pci: passing forward the ACPI companionHeikki Krogerus1-0/+1
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-27usb: dwc3: core: convert to unified device property interfaceHeikki Krogerus1-26/+24
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-27usb: common: of_usb_get_dr_mode to usb_get_dr_modeHeikki Krogerus2-2/+2
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-27usb: dwc3: st: prepare the driver for generic usb_get_dr_mode functionHeikki Krogerus1-2/+10
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-27usb: common: of_usb_get_maximum_speed to usb_get_maximum_speedHeikki Krogerus1-1/+2
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-27usb: dwc3: support for pinctrl state change during system sleepSekhar Nori1-0/+5
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-27usb: dwc3: Add frame length adjustment quirkNikhil Badola3-0/+41
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-27usb: dwc3: gadget: improve ep_queue's error reportingFelipe Balbi1-19/+12
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-27usb: dwc3: gadget: clear DWC3_PENDING_REQUEST when request is queuedFelipe Balbi1-1/+4
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-27usb: dwc3: gadget: start requests as soon as they comeFelipe Balbi1-0/+16
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-27usb: dwc3: gadget: move trace_dwc3_ep_queue()Felipe Balbi1-2/+2
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-21usb: dwc3: gadget: Fix BUG in RT configRoger Quadros1-4/+0
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-14usb: dwc3: omap: enable irqs latelyFelipe Balbi1-2/+2
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-08-04usb: dwc3: gadget: add ep capabilities supportRobert Baldyga1-0/+11
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-30usb: dwc3: ep0: handle non maxpacket aligned transfers > 512Kishon Vijay Abraham I1-14/+28
Use chained TRB mechanism to handle non maxpacket aligned transfers greater than bounce buffer size. With this the first TRB will be programmed to receive 'ALIGN(ur->length - maxp, maxp)' data and the second TRB will be programmed to receive the remaining data using bounce buffer. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-30usb: dwc3: ep0: Add chained TRB supportKishon Vijay Abraham I2-4/+14
Add chained TRB support to ep0. Now TRB's can be chained just by invoking _dwc3_ep0_start_trans_ with 'chain' parameter set to true. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-30usb: dwc3; ep0: Modify _dwc3_ep0_start_trans_ API to take 'chain' parameterKishon Vijay Abraham I1-7/+8
No functional change. Added a new parameter in _dwc3_ep0_start_trans_ to indicate whether the TRB is a chained TRB or last TRB. This is in preparation for adding chained TRB support for ep0. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-30usb: dwc3: ep0: preparation for handling non maxpacket aligned transfers > 512Kishon Vijay Abraham I1-8/+17
No functional change. This is in preparation for handling non maxpacket aligned transfers greater than bounce buffer size. This is basically to avoid code duplication when using chained TRB transfers to handle non maxpacket aligned transfers greater than bounce buffer size. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-30usb: dwc3: ep0: use _roundup_ to calculate the transfer sizeKishon Vijay Abraham I1-3/+1
No functional change. Used _roundup_ macro to calculate the transfer size aligned to maxpacket in dwc3_ep0_complete_data. It also makes it similar to how transfer size is calculated in __dwc3_ep0_do_control_data. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>