aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/dwc2/hcd.c
AgeCommit message (Collapse)AuthorFilesLines
2015-10-01usb: dwc2: host: disconnect hcd prior stopping itGregory Herrero1-0/+5
In case controller is asked to stop while devices are connected, disconnect all devices and clean up before stopping. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: host: resume only if bus is suspendedGregory Herrero1-1/+2
Port can be resumed in bus_resume callback. In this case, there is no need to drive resume a second time when hcd ask for it. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: host: update hcd and lx_state during start/stop callbacksGregory Herrero1-1/+5
During hcd initialization, hardware accessible flag and lx_state must be reset to the working state since controller is powered at this stage. Same logic applied for stop callback. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: host: enter hibernation during bus suspendGregory Herrero1-12/+128
Disable controller power and enter hibernation when usb bus is suspended. A phy driver is required to disable the power of the controller and detect remote-wakeup or disconnection since the controller will not be able to detect these in this state. Once the phy driver detects bus activity, it must call usb_hcd_resume_root_hub. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: host: add flag to reflect bus stateGregory Herrero1-2/+3
lx_state must be used to reflect controller power state only and not bus state. Thus add a flag to track state during bus suspend. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: host: create a function to handle port_resumeGregory Herrero1-10/+30
port resume sequence may be used in different places. Create a function to handle it. Make hprt0 read-modify-write atomic and clear HPRT0_SUSP for both writes as it is a "read, write-set, and self-clear (R_WS_SC)" bit. Since the lock is released between the writes, read hprt0 again. Since the phy clock is stopped in dwc2_port_suspend(), enable it here and remove the PCGCTL write from dwc2_hcd_hub_control() Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-09-27usb: dwc2: Use platform endianness when accessing registersAntti Seppälä1-70/+70
This patch switches calls to readl/writel to their dwc2_readl/dwc2_writel equivalents which preserve platform endianness. This patch is necessary to access dwc2 registers correctly on big-endian systems such as the mips based SoCs made by Lantiq. Then dwc2 can be used to replace ifx-hcd driver for Lantiq platforms found e.g. in OpenWrt. The patch was autogenerated with the following commands: $EDITOR core.h sed -i "s/\<readl\>/dwc2_readl/g" *.c hcd.h hw.h sed -i "s/\<writel\>/dwc2_writel/g" *.c hcd.h hw.h Some files were then hand-edited to fix checkpatch.pl warnings about too long lines. Signed-off-by: Antti Seppälä <[email protected]> Signed-off-by: Vincent Pelletier <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-09-27usb: dwc2: rename all s3c_* to dwc2_*Felipe Balbi1-2/+2
this driver has long ago became dwc2.ko with both peripheral and host roles, there's no point in keeping the old function names. Acked-by: John Youn <[email protected]> Tested-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-07-06usb: dwc2: host: allocate qtd before atomic enqueueMian Yousaf Kaukab1-10/+16
To avoid sleep while atomic bugs, allocate qtd before calling dwc2_hcd_urb_enqueue. No need to pass mem_flags to dwc2_hcd_urb_enqueue any more as no memory allocations are done in it. Acked-by: John Youn <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Doug Anderson <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-07-06usb: dwc2: host: allocate qh before atomic enqueueMian Yousaf Kaukab1-4/+27
To avoid sleep while atomic bugs, allocate qh before calling dwc2_hcd_urb_enqueue. qh pointer can be used directly now instead of passing ep->hcpriv as double pointer. Acked-by: John Youn <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Doug Anderson <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-05-13usb: dwc2: hcd: fix build warningFelipe Balbi1-1/+1
commit db62b9a804b4 (usb: dwc2: host: don't use dma_alloc_coherent with irqs disabled) introduced a build warning by using NULL as an integer. Fix that by just using 0 instead of NULL. Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: remove dwc2_platform.koMian Yousaf Kaukab1-2/+0
As dwc2 pci module is now exporting dwc2 platform device, include platform.o in dwc2-y and remove USB_DWC2_PLATFORM configuration option. Driver will be built as two modules, dwc2.ko and dwc2_pci.ko. dwc2.ko is the new platform driver. Remove all EXPORT_SYMBOL_GPL as they are not needed any more. Acked-by: John Youn <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: host: implement test modeJingwu Lin1-0/+9
Add support for SetPortFeature(PORT_TEST) for root port. Acked-by: John Youn <[email protected]> Signed-off-by: Jingwu Lin <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: host: don't use dma_alloc_coherent with irqs disabledGregory Herrero1-3/+10
Align buffer must be allocated using kmalloc since irqs are disabled. Coherency is handled through dma_map_single which can be used with irqs disabled. Reviewed-by: Julius Werner <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: host: spinlock urb_enqueueGregory Herrero1-9/+6
During urb_enqueue, if the urb can't be queued to the endpoint, the urb is freed without any spinlock protection. This leads to memory corruption when concurrent urb_dequeue try to free same urb->hcpriv. Thus, ensure the whole urb_enqueue in spinlocked. Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: host: add bus_suspend/bus_resume callbackGregory Herrero1-0/+19
Update controller state to indicate suspend entry. Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: host: register handle to the phyMian Yousaf Kaukab1-0/+6
If phy driver is present register hcd handle to it. Acked-by: John Youn <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-29usb: dwc2: set parameter values in probe functionMian Yousaf Kaukab1-35/+1
So the parameters can be used in both host and gadget modes. Also consolidate param functions in the core.h Acked-by: John Youn <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-04-10usb: dwc2: host: sleep USB_RESUME_TIMEOUT during resumeGregory Herrero1-2/+2
msleep(USB_RESUME_TIMEOUT) must be done when the controller drives the resume. This is true after HPRT0_RES is written. Moreover, restore the delay after controller power is up. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2015-04-10Merge tag 'usb-for-v4.1-part2' of ↵Greg Kroah-Hartman1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-testing Felipe writes: usb: generic resume timeout for v4.1 This part 2 pull request contains only the patches which make sure everybody on linux uses the same resume timeout value. Signed-off-by: Felipe Balbi <[email protected]>
2015-04-07usb: dwc2: hcd: use new USB_RESUME_TIMEOUTFelipe Balbi1-1/+1
Make sure we're using the new macro, so our resume signaling will always pass certification. Cc: <[email protected]> # v3.10+ Signed-off-by: Felipe Balbi <[email protected]>
2015-04-03dwc2: hcd: use USB_DT_HUBSergei Shtylyov1-1/+1
Fix using the bare number to set the 'bDescriptorType' field of the Hub Descriptor while the value is #define'd in <linux/usb/ch11.h>. Signed-off-by: Sergei Shtylyov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2015-03-19usb: dwc2: avoid leaking DMA channels on disconnectionVincent Palatin1-0/+8
When the HCD is disconnected, the DMA transfers still in-flight were cleaned-up but the count of available DMA channels (e.g. available_host_channels) was not reset. The pool of DMA channels can be depleted when doing unclean disconnection of USB peripherals, and reaches the point where no transfer was possible until the next reboot/reload of the driver. Tested by putting a programmable USB mux on the port and randomly plugging/unpluging a USB HUB with USB mass-storage key, USB-audio and USB-ethernet dongle connected to its downstream ports, and also doing the disconnection early while the devices are still enumerating to get more URBs in-flight. After the patch, the devices are still enumerating after thousands of cycles, while the port was totally dead before. Signed-off-by: Vincent Palatin <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-01-30usb: dwc2: gadget: add reset flag in init functionGregory Herrero1-1/+1
Add a flag to request physical reset of the controller when s3c_hsotg_core_init_disconnected is called. During the usb reset, controller must not be fully reconfigured and resetted. Else this leads to shorter chirp-k duration during enumeration. Tested-by: Robert Baldyga <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-01-30usb: dwc2: host: resume root hub on remote wakeupGregory Herrero1-2/+4
When a remote wakeup happens during bus_suspend, hcd needs to resume its root hub. Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-01-19usb: dwc2: hcd: use HUB_CHAR_*Sergei Shtylyov1-1/+3
Fix using the bare number to set the 'wHubCharacteristics' field of the Hub Descriptor while the values are #define'd in <linux/usb/ch11.h>. Signed-off-by: Sergei Shtylyov <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-01-19Revert "usb: dwc2: add bus suspend/resume for dwc2"Paul Zimmerman1-77/+11
This reverts commit 0cf884e819e05437287a668b9bfcc198bab6329c. Even after applying the follow-on patch at https://patchwork.kernel.org/patch/5325111 there are still problems with device connect on the Altera SOCFPGA platform at least. One possible fix would be to add a whitelist to enable suspend/resume on platforms where it does work correctly. Signed-off-by: Paul Zimmerman <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2014-11-14usb: dwc2: move usb_disabled() call to host driver onlyDinh Nguyen1-0/+3
Since platform.c will get built for both Host and Gadget, if we leave the usb_disabled() call in platform.c, it results in the following build error when (!USB && USB_GADGET) condition is met. ERROR: "usb_disabled" [drivers/usb/dwc2/dwc2_platform.ko] undefined! Since usb_disabled() is mostly used to disable USB host functionality, move the call the host portion for the DWC2 driver. Acked-by: Paul Zimmerman <[email protected]> Signed-off-by: Dinh Nguyen <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2014-11-14usb: dwc2: Initialize the USB core for peripheral modeDinh Nguyen1-0/+2
Initialize the USB driver to peripheral mode when a B-Device connector is attached. Signed-off-by: Dinh Nguyen <[email protected]> Acked-by: Paul Zimmerman <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2014-11-14usb: dwc2: Move gadget probe function into platform codeDinh Nguyen1-1/+0
This patch will aggregate the probing of gadget/hcd driver into platform.c. The gadget probe funtion is converted into gadget_init that is now only responsible for gadget only initialization. All the gadget resources are now handled by platform.c Since the host workqueue will not get initialized if the driver is configured for peripheral mode only. Thus we need to check for wq_otg before calling queue_work(). Also, we move spin_lock_init to common location for both host and gadget that is either in platform.c or pci.c. We also move suspend/resume code to common platform code. Lastly, move the "samsung,s3c6400-hsotg" binding into dwc2_of_match_table. Signed-off-by: Dinh Nguyen <[email protected]> Acked-by: Paul Zimmerman <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2014-11-12usb: dwc2: add bus suspend/resume for dwc2Kever Yang1-11/+77
Hcd controller needs bus_suspend/resume, dwc2 controller make root hub generate suspend/resume signal with hprt0 register when work in host mode. After the root hub enter suspend, we can make controller enter low power state with PCGCTL register. We also update the lx_state for hsotg state. This patch has tested on rk3288 with suspend/resume. Signed-off-by: Kever Yang <[email protected]> Acked-by: Paul Zimmerman <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2014-09-19usb: dwc2: handle DMA buffer unmapping sanelyPaul Zimmerman1-13/+29
The driver's handling of DMA buffers for non-aligned transfers was kind of nuts. For IN transfers, it left the URB DMA buffer mapped until the transfer completed, then synced it, copied the data from the bounce buffer, then synced it again. Instead of that, just call usb_hcd_unmap_urb_for_dma() to unmap the buffer before starting the transfer. Then no syncing is required when doing the copy. This should also allow handling of other types of mappings besides just dma_map_single() ones. Also reduce the size of the bounce buffer allocation for Isoc endpoints to 3K, since that's the largest possible transfer size. Tested on Raspberry Pi and Altera SOCFPGA. Signed-off-by: Paul Zimmerman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-04usb: dwc2: fix memory corruption in dwc2 driverPaul Zimmerman1-11/+0
The move from the staging tree to the main tree exposed a longstanding memory corruption bug in the dwc2 driver. The reordering of the driver initialization caused the dwc2 driver to corrupt the initialization data of the sdhci driver on the Raspberry Pi platform, which made the bug show up. The error is in calling to_usb_device(hsotg->dev), since ->dev is not a member of struct usb_device. The easiest fix is to just remove the offending code, since it is not really needed. Thanks to Stephen Warren for tracking down the cause of this. Reported-by: Andre Heider <[email protected]> Tested-by: Stephen Warren <[email protected]> Signed-off-by: Paul Zimmerman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-01-20Merge tag 'usb-3.14-rc1' of ↵Linus Torvalds1-0/+2
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB updates from Greg KH: "Here's the big USB pull request for 3.14-rc1 Lots of little things all over the place, and the usual USB gadget updates, and XHCI fixes (some for an issue reported by a lot of people). USB PHY updates as well as chipidea updates and fixes. All of these have been in the linux-next tree with no reported issues" * tag 'usb-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (318 commits) usb: chipidea: udc: using MultO at TD as real mult value for ISO-TX usb: chipidea: need to mask INT_STATUS when write otgsc usb: chipidea: put hw_phymode_configure before ci_usb_phy_init usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28 usb: chipidea: add freescale imx28 special write register method usb: ehci: add freescale imx28 special write register method usb: core: check for valid id_table when using the RefId feature usb: cdc-wdm: resp_count can be 0 even if WDM_READ is set usb: core: bail out if user gives an unknown RefId when using new_id usb: core: allow a reference device for new_id usb: core: add sanity checks when using bInterfaceClass with new_id USB: image: correct spelling mistake in comment USB: c67x00: correct spelling mistakes in comments usb: delete non-required instances of include <linux/init.h> usb:hub set hub->change_bits when over-current happens Revert "usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28" xhci: Set scatter-gather limit to avoid failed block writes. xhci: Avoid infinite loop when sg urb requires too many trbs usb: gadget: remove unused variable in gr_queue_int() ...
2014-01-13Move DWC2 driver out of stagingPaul Zimmerman1-0/+2990
The DWC2 driver should now be in good enough shape to move out of staging. I have stress tested it overnight on RPI running mass storage and Ethernet transfers in parallel, and for several days on our proprietary PCI-based platform. Signed-off-by: Paul Zimmerman <[email protected]> Cc: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>