aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3 (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-07-30Merge tag 'usb-for-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-nextGreg Kroah-Hartman9-96/+446
Felipe writes: usb: changes for v4.19 Not a big pull request with only 37 non-merge commits, most of which are touching dwc2 (74% of the changes). The most important changes are dwc2's support for uframe scheduling and its endian-agnostic readl/writel wrappers. From dwc3 side we have a special new glue layer for Synopsys HAPS which will help Synopsys running FPGA validation using our upstream driver. We also have the beginnings of dual-role support for Intel Merrifield platform. Apart from these, just a series of non-critical changes.
2018-07-30usb: dwc3: gadget: Check MaxPacketSize from descriptorThinh Nguyen1-1/+1
endpoint->maxpacket is not updated after setting the usb_set_maxpacket_limit() on endpoint enable. The MaxPacketSize can be different than the endpoint->maxpacket_limit. DWC3 has been consistently using MaxPacketSize from the endpoint's descriptor, so let's keep it consistent and use the MaxPacketSize from the endpoint's descriptor instead. Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: core: Enable AutoRetry feature in the controllerAnurag Kumar Vulisha2-0/+19
By default when core sees any transaction error (CRC or overflow) it replies with terminating retry ACK (Retry=1 and Nump == 0). Enabling this Auto Retry feature in controller will make the core send a non-terminanting ACK upon such transaction errors. That is, ACK TP with Retry=1 and Nump != 0. Doing so will give controller a chance to recover from transient error conditions. Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: Set default mode for dwc_usb31Thinh Nguyen1-0/+8
dwc_usb31 does not support OTG mode. If the controller supports DRD but the dr_mode is not specified or set to OTG, then set the mode to peripheral. Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: pci: Intel Merrifield can be hostAndy Shevchenko1-1/+7
On Intel Edison board the OTG function is enabled, thus, USB can switch to the host mode. Allow that by changing dr_mode property to "otg" for Intel Merrifield. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: pci: Supply device properties via driver dataAndy Shevchenko1-57/+74
For now all PCI enumerated dwc3 devices require some properties to be present. This allows us to unconditionally append them and supply via driver_data. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: Enable undefined length INCR burst typePengbo Mu2-0/+97
Enable the undefined length INCR burst type and set INCRx. Different platform may has the different burst size type. In order to get best performance, we need to tune the burst size to one special value, instead of the default value. Signed-off-by: Changming Huang <jerry.huang@nxp.com> Signed-off-by: Ran Wang <ran.wang_1@nxp.com> Signed-off-by: Pengbo Mu <pengbo.mu@nxp.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: add global soc bus configuration reg0Pengbo Mu1-0/+11
Add the macro definition for global soc bus configuration register 0 Signed-off-by: Changming Huang <jerry.huang@nxp.com> Signed-off-by: Ran Wang <ran.wang_1@nxp.com> Signed-off-by: Pengbo Mu <pengbo.mu@nxp.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-30usb: dwc3: Describe 'wakeup_work' field of struct dwc3_pciAndy Shevchenko1-0/+1
Describe 'wakeup_work' field of struct dwc3_pci to avoid a warning: drivers/usb/dwc3/dwc3-pci.c:59: warning: Function parameter or member 'wakeup_work' not described in 'dwc3_pci' Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: change stream event enable bit back to 13Erich E. Hoover1-1/+1
Commit ff3f0789b3dc ("usb: dwc3: use BIT() macro where possible") changed DWC3_DEPCFG_STREAM_EVENT_EN from bit 13 to bit 12. Spotted this cleanup typo while looking at diffs between 4.9.35 and 4.14.16 for a separate issue. Fixes: ff3f0789b3dc ("usb: dwc3: use BIT() macro where possible") Signed-off-by: Erich E. Hoover <ehoover@sweptlaser.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: of-simple: reset host controller at suspend/resumeEnric Balletbo i Serra1-0/+29
If we power off the SoC logic rail in S3, we can find that the Type-C PHY can't initialize correctly after system resume. We need to toggle the USB3-OTG reset before trying to initialize the PHY, or else it times out. phy phy-ff800000.phy.9: phy poweron failed --> -110 dwc3 fe900000.dwc3: failed to initialize core dwc3: probe of fe900000.dwc3 failed with error -110 Note that the RK3399 TRM suggests that we should keep the whole usb3 controller in reset for the duration of the Type-C PHY initialization. However, it's hard to assert the reset in the current framework of reset. We're still skeptical about that, and we haven't yet found a case where this seems to have mattered. This approach is much easier, it simply holds the USB3-OTG reset while device is supended. The dwc3 core is going to reinitialize the controller at suspend/resume anyway (including a "soft reset"), so it should be safe to do this. Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: pci: Use devm functions to get the phy GPIOsHans de Goede1-4/+4
Even though we only use them once, it is better to not put/release the GPIOs immediately after use, so that others cannot claim them. Use devm functions to get the phy GPIOs, so that they will be automatically released when were unbound from the device and remove the gpio_put calls. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: pci: Enable ULPI Refclk on platforms where the firmware does notHans de Goede1-0/+31
On some Bay Trail (BYT) systems the firmware does not enable the ULPI Refclk. This commit adds a helper which checks and if necessary enabled the Refclk and calls this helper for BYT machines. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resourcesHans de Goede1-0/+18
Bay Trail / BYT SoCs do not have a builtin device-mode phy, instead they require an external ULPI phy for device-mode. Only some BYT devices have an external phy, but even on those devices device-mode is not working because the dwc3 does not see the phy. The problem is that the ACPI fwnode for the dwc3 does not contain the expected GPIO resources for the GPIOs connected to the chip-select and reset pins of the phy. I've found the workaround which some Android x86 kernels use for this: https://github.com/BORETS24/Kernel-for-Asus-Zenfone-2/blob/master/arch/x86/platform/intel-mid/device_libs/pci/platform_usb_otg.c Which boils down to hardcoding the GPIOs for these devices. The good news it that all boards (*) use the same GPIOs. This commit fixes the ULPI phy not woring by adding a gpiod_lookup_table call which adds a hardcoded mapping for BYT devices. Note that the mapping added by gpiod_add_lookup_table is a fallback mapping, so boards which properly provide GPIO resources in the ACPI firmware-node resources will not use this. *) Except for the first revision of the evalulation-kit, which normal users don't have Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-26usb: dwc3: Add a glue driver for Synopsys HAPS platformThinh Nguyen4-34/+147
This driver is to be used for Synopsys PCIe-base HAPS platform. Move the the HAPS support from dwc3-pci to this driver. Signed-off-by: Thinh Nguyen <thinhn@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-07-13usb: dwc3: gadget: remove redundant variable maxpacketColin Ian King1-3/+0
Variable maxpacket is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: warning: variable 'maxpacket' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-19usb: dwc3: qcom: mark PM functions as __maybe_unusedArnd Bergmann1-8/+4
The #ifdef guards around these are wrong, resulting in warnings in certain configurations: drivers/usb/dwc3/dwc3-qcom.c:244:12: error: 'dwc3_qcom_resume' defined but not used [-Werror=unused-function] static int dwc3_qcom_resume(struct dwc3_qcom *qcom) ^~~~~~~~~~~~~~~~ drivers/usb/dwc3/dwc3-qcom.c:223:12: error: 'dwc3_qcom_suspend' defined but not used [-Werror=unused-function] static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) This replaces the guards with __maybe_unused annotations to shut up the warnings and give better compile time coverage. Fixes: a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver") Reviewed-by: Douglas Anderson <dianders@chromium.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-06-19usb: dwc3: Fix error return code in dwc3_qcom_probe()Wei Yongjun1-0/+1
Fix to return error code -ENODEV from the get device failed error handling case instead of 0, as done elsewhere in this function. Fixes: a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-06-18usb: dwc3: Only call clk_bulk_get() on devicetree instantiated devicesHans de Goede1-10/+13
Commit fe8abf332b8f ("usb: dwc3: support clocks and resets for DWC3 core") adds support for handling clocks and resets in the DWC3 core, so that for platforms following the standard devicetree bindings this does not need to be duplicated in all the different glue layers. These changes intended for devicetree based platforms introduce an uncoditional clk_bulk_get() in the core probe path. This leads to the following error being logged on x86/ACPI systems: [ 26.276783] dwc3 dwc3.3.auto: Failed to get clk 'ref': -2 This commits wraps the clk_bulk_get() in an if (dev->of_node) check so that it only is done on devicetree instantiated devices, fixing this error. Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-06-18usb: dwc3: of-simple: fix use-after-free on removeJohan Hovold1-1/+2
The clocks have already been explicitly disabled and put as part of remove() so the runtime suspend callback must not be run when balancing the runtime PM usage count before returning. Fixes: 16adc674d0d6 ("usb: dwc3: add generic OF glue layer") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-06-18usb: dwc3: pci: add support for Intel IceLakeHeikki Krogerus1-0/+2
PCI IDs for Intel IceLake. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-31USB: dwc3: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-32/+11
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Felipe Balbi <balbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-31usb: dwc3: Remove DEBUG define from Qualcomm DWC3 glue driverDouglas Anderson1-1/+0
It appears that a "#define DEBUG" was left in on the recent patch landed for the Qualcomm DWC3 glue driver. Let's remove it. Fixes: a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver") Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-21usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeueMayank Rana1-1/+1
dwc3_ep_dequeue() waits for completion of End Transfer command using wait_event_lock_irq(), which will release the dwc3->lock while waiting and reacquire after completion. This allows a potential race condition with ep_disable() which also removes all requests from started_list and pending_list. The check for NULL r->trb should catch this but currently it exits to the wrong 'out1' label which calls dwc3_gadget_giveback(). Since its list entry was already removed, if CONFIG_DEBUG_LIST is enabled a 'list_del corruption' bug is thrown since its next/prev pointers are already LIST_POISON1/2. If r->trb is NULL it should simply exit to 'out0'. Fixes: cf3113d893d4 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue") Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Mayank Rana <mrana@codeaurora.org> Signed-off-by: Jack Pham <jackp@codeaurora.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be staticWei Yongjun1-1/+1
Fixes the following sparse warning: drivers/usb/dwc3/gadget.c:169:6: warning: symbol 'dwc3_gadget_del_and_unmap_request' was not declared. Should it be static? Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: dwc3_get_extcon() can be statickbuild test robot1-1/+1
Fix sparse warning Fixes: 5f0b74e54890 ("USB: dwc3: get extcon device by OF graph bindings") Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: init req->{direction,epnum} from alloc_request()Felipe Balbi1-2/+1
We dont' need to touch req->direction or req->epnum from ep_queue(). It's enough that we initialize both fields from alloc_request() and just keep them for the entire lifetime of the request. No functional changes. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: initialize transfer index from send_gadget_ep_cmd()Felipe Balbi2-6/+1
Instead of *always* calling dwc3_gadget_ep_get_transfer_index() after sending a Start Transfer command, we can call it once from dwc3_send_gadget_ep_cmd() itself. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: assign resource_index inside get_transfer_index()Felipe Balbi3-10/+6
Instead of returning resource index number just to assign it to a field inside 'dep' which was passed as argument, we can assing dep->resource_index from inside dwc3_gadget_ep_get_transfer_index() itself. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: always start isochronous aligned to dep->intervalFelipe Balbi1-10/+5
We will *always* start transfer to the next uFrame number aligned to dep->interval. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: don't issue End Transfer if we have started reqsFelipe Balbi1-1/+3
In case we have many started requests and one of them in the middle is completed with Missed Isoc, let's not End Transfer as that would result in us loosing (possibly) many more intervals. Instead, let's allow the controller to go through its list of started requests. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: debug: decode uFrame from event tooFelipe Balbi1-3/+7
XferNotReady and XferInProgress give us the uFrame number we're currently in. Printing that out on tracepoints may help us find bugs in transfer scheduling. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: move dwc3_calc_trbs_left() in place of prototypeFelipe Balbi1-49/+47
Avoid a prototype when the function can be defined earlier. No functional changes, cleanup only. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: move set_xfer_resource() in place of prototypeFelipe Balbi1-13/+11
Instead of having a prototype for a function that's defined a few lines down, let's just move definition to the place where prototype was. No functional changes, cleanup only. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: remove a few more dwc argumentsFelipe Balbi1-8/+10
In a few places, the argument is completely unnecessary. On places where it's needed, we can get it from dep->dwc. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: combine modify & restore into single argumentFelipe Balbi1-22/+11
Those two arguments refer to a single bitfield in the register. In order to simplify the code, we can combine them into a single argument and expect caller to pass the correct action argument at all times. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: refactor dwc3_gadget_init_endpoints()Felipe Balbi1-87/+116
This just makes it slightly easier to read. No functional changes. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: split dwc3_gadget_ep_cleanup_completed_requests()Felipe Balbi1-24/+36
No functional changes, it just makes the code slightly easier to read. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: get rid of the length variableFelipe Balbi1-3/+1
Code is just as readable without it. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: reduce scope of ret variableFelipe Balbi1-1/+1
We can declare it inside list_for_each_entry_safe() loop and reduce its scope. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: one declaration per lineFelipe Balbi1-2/+3
Misc cleanup. No functional changes. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: simplify IOC handlingFelipe Balbi1-15/+10
We will only have event status of IOC when IOC bit is set in TRB. There's no need to check both bits. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: simplify short packet eventFelipe Balbi1-7/+1
We know that only OUT endpoints can trigger SHORT. We also know that count MUST be > 0 whenever SHORT triggers. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: trace: print out event status tooFelipe Balbi1-4/+16
This will make it easier to figure out the reason for the event. That information really helps debugging certain problems. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: simplify unaligned and zlp handlingFelipe Balbi1-4/+2
We can just call reclaim_trb_linear instead of reimplementing it. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: remove unnecessary 'chain' variableFelipe Balbi1-3/+1
Minor cleanup, no functional changes. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: remove PENDING handling from cleanup_completedFelipe Balbi1-14/+0
We are trying to kick transfers on Isochronous endpoints in a more controlled manner now. And this ended up rendering this piece of code unnecessary. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: split scatterlist and linear handlersFelipe Balbi1-26/+45
instead of having one big loop, let's split it down into two smaller handlers: one for linear buffers and one for scatterlist. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: simplify isoc case on cleanup_completed_requestsFelipe Balbi1-10/+3
Just a minor simplification, no functional changes. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-05-21usb: dwc3: gadget: simplify queueing of isoc transfersFelipe Balbi1-12/+6
After all the previous changes, it's now a lot clearer how isoc transfers should be managed. We don't need to try to End Transfers from ep_queue since that's already done by cleanup_requests. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>