aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/dwc2/core.h
AgeCommit message (Collapse)AuthorFilesLines
2020-10-02usb: dwc2: override PHY input signals with usb role switch supportAmelie Delaunay1-0/+9
This patch adds support for usb role switch to dwc2, by using overriding control of the PHY voltage valid and ID input signals. iddig signal (ID) can be overridden: - when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1; - when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0. avalid/bvalid/vbusvalid signals can be overridden respectively with: - GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL - GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL - GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL It is possible to determine valid sessions thanks to usb role switch: - if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid - if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid - if USB_ROLE_HOST then avalid && !bvalid && vbusvalid Acked-by: Minas Harutyunyan <[email protected]> Acked-by: Martin Blumenstingl <[email protected]> Signed-off-by: Amelie Delaunay <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2020-07-27Revert "usb: dwc2: override PHY input signals with usb role switch support"Greg Kroah-Hartman1-8/+0
This reverts commit bc0f0d4a5853e32ba97a0318f774570428fc5634. It was not meant to be applied yet. Cc: Minas Harutyunyan <[email protected]> Cc: Amelie Delaunay <[email protected]> Cc: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2020-07-23usb: dwc2: override PHY input signals with usb role switch supportAmelie Delaunay1-0/+8
This patch adds support for usb role switch to dwc2, by using overriding control of the PHY voltage valid and ID input signals. iddig signal (ID) can be overridden: - when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1; - when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0. avalid/bvalid/vbusvalid signals can be overridden respectively with: - GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL - GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL - GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL It is possible to determine valid sessions thanks to usb role switch: - if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid - if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid - if USB_ROLE_HOST then avalid && !bvalid && vbusvalid Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Amelie Delaunay <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2020-07-01USB: Fix up terminologyGreg Kroah-Hartman1-1/+1
USB is a HOST/DEVICE protocol, as per the specification and all documentation. Fix up terms that are not applicable to make things match up with the terms used through the rest of the USB stack. Signed-off-by: Greg Kroah-Hartman <[email protected]> Acked-by: Felipe Balbi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2020-05-25usb: dwc2: Update Core Reset programming flow.Minas Harutyunyan1-0/+4
Starting from core version 4.20a Core Reset flow is changed. Introduced new bit in GRSTCTL register - GRSTCTL_CSFTRST_DONE. Core Reset new programming flow steps are follow: 1. Set GRSTCTL_CSFTRST bit. 2. Wait for bit GRSTCTL_CSFTRST_DONE is set. 3. Clear GRSTCTL_CSFTRST and GRSTCTL_CSFTRST_DONE bits. Check core version functionality separated from dwc2_get_hwparams() to new dwc2_check_core_version() function because Core Reset flow depend on SNPSID. Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2020-05-05USB: dwc2: Use the correct style for SPDX License IdentifierNishad Kamdar1-1/+1
This patch corrects the SPDX License Identifier style in header files related to DesignWare USB2 DRD Core Support. For C header files Documentation/process/license-rules.rst mandates C-like comments (opposed to C source files where C++ style should be used). Changes made by using a script provided by Joe Perches here: https://lkml.org/lkml/2019/2/7/46. Suggested-by: Joe Perches <[email protected]> Signed-off-by: Nishad Kamdar <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2020-03-15usb: dwc2: add support for STM32MP15 SoCs USB OTG HS and FSAmelie Delaunay1-0/+8
This patch introduces a new parameter to activate external ID pin and valid vbus level detection, required on STM32MP15 SoC to support dual role, either in HS or FS. The STM32MP15 SoC uses the GGPIO register to enable the level detection. The level detector requires to be powered. Also adds the params structures for STM32MP15 OTG HS and STM32MP1 OTG FS. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Amelie Delaunay <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2019-11-04usb: Spelling s/enpoint/endpoint/Geert Uytterhoeven1-1/+1
Fix misspellings of "endpoint". Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Li Yang <[email protected]> Acked-by: Minas Harutyunyan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-06-18USB: dwc2: Don't turn off the usbphy in suspend if wakeup is enabledDouglas Anderson1-0/+8
If the 'snps,need-phy-for-wake' is set in the device tree then: - We know that we can wakeup, so call device_set_wakeup_capable(). The USB core will use this knowledge to enable wakeup by default. - We know that we should keep the PHY on during suspend if something on our root hub needs remote wakeup. This requires the patch (USB: Export usb_wakeup_enabled_descendants()). Note that we don't keep the PHY on at suspend time if it's not needed because it would be a power draw. If we later find some users of dwc2 that can support wakeup without keeping the PHY on we may want to add a way to call device_set_wakeup_capable() without keeping the PHY on at suspend time. Signed-off-by: Douglas Anderson <[email protected]> Signed-off-by: Chris Zhong <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2019-05-03usb: dwc2: Delayed status supportMinas Harutyunyan1-0/+2
Added delayed status support for Control transfers. Tested in all 3 modes: Slave, BDMA and DDMA. Performed tests: USB CV (Ch9 and MSC), Control Read/Write tests using Synopsys USB test environment function driver. Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2019-05-03usb: dwc2: Move phy init into coreJules Maselbas1-0/+2
As the phy initialization is almost the same in host and gadget mode. This only move the phy initialization functions into core.c for now, the goal is to share theses functions between the two modes. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Jules Maselbas <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2019-05-03usb: dwc2: gadget: Replace phyif with phy_utmi_widthJules Maselbas1-2/+0
The phy utmi width information is already set in hsotg params, phyif is only used in few places and I don't see any reason to not use hsotg's params. Moreover the utmi width was being forced to 16 bits by platform initialization which doesn't take in account HW configuration. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Jules Maselbas <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2019-05-03usb: dwc2: optionally assert phy reset when waking upDouglas Anderson1-0/+8
On the rk3288 USB host-only port (the one that's not the OTG-enabled port) the PHY can get into a bad state when a wakeup is asserted (not just a wakeup from full system suspend but also a wakeup from autosuspend). We can get the PHY out of its bad state by asserting its "port reset", but unfortunately that seems to assert a reset onto the USB bus so it could confuse things if we don't actually deenumerate / reenumerate the device. We can also get the PHY out of its bad state by fully resetting it using the reset from the CRU (clock reset unit), which does a more full reset. The CRU-based reset appears to actually cause devices on the bus to be removed and reinserted, which fixes the problem (albeit in a hacky way). It's unfortunate that we need to do a full re-enumeration of devices at wakeup time, but this is better than alternative of letting the bus get wedged. Signed-off-by: Douglas Anderson <[email protected]> Signed-off-by: Yunzhi Li <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-10-02usb: dwc2: gadget: Program GREFCLK registerGrigor Tovmasyan1-0/+2
Added dwc2_gadget_program_ref_clk function to program GREFCLK register in device mode. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-10-02usb: dwc2: gadget: Add parameters for GREFCLK registerGrigor Tovmasyan1-0/+18
Added ref_clk_per and sof_cnt_wkup_alert parameters in dwc2_core_params struct and set default values. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-10-02usb: dwc2: Add core parameter for service interval supportGrigor Tovmasyan1-0/+9
Added core parameter for service interval based scheduling. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-07-30usb: dwc2: Make dwc2_readl/writel functions endianness-agnostic.Gevorg Sahakyan1-2/+13
Declared dwc2_check_core_endianness() function for dynamicly check core endianness. Added needs_byte_swap flag to hsotg structure, and depending on flag swap value inside dwc2_readl/writel functions. Signed-off-by: Gevorg Sahakyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-07-30usb: dwc2: replace ioread32/iowrite32_rep with dwc2_readl/writel_repGevorg Sahakyan1-38/+23
dwc2_readl_rep/dwc2_writel_rep functions using readl/writel in a loop. Signed-off-by: Gevorg Sahakyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-07-30usb: dwc2: Modify dwc2_readl/writel functions prototypeGevorg Sahakyan1-12/+13
Added hsotg argument to dwc2_readl/writel function prototype, and also instead of address pass offset of register. hsotg will contain flag field for endianness. Also customized dwc2_set_bit and dwc2_clear_bit function for dwc2_readl/writel functions. Signed-off-by: Gevorg Sahakyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-07-26usb: dwc2: Move dwc2_readl/writel functions after hsotg structureGevorg Sahakyan1-54/+54
Moved dwc2_readl/writel functions after hsotg declaration for adding hsotg structure to dwc2_readl/writel function prototypes. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Gevorg Sahakyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-06-19usb: dwc2: alloc dma aligned buffer for isoc split inWilliam Wu1-0/+3
The commit 3bc04e28a030 ("usb: dwc2: host: Get aligned DMA in a more supported way") rips out a lot of code to simply the allocation of aligned DMA. However, it also introduces a new issue when use isoc split in transfer. In my test case, I connect the dwc2 controller with an usb hs Hub (GL852G-12), and plug an usb fs audio device (Plantronics headset) into the downstream port of Hub. Then use the usb mic to record, we can find noise when playback. It's because that the usb Hub uses an MDATA for the first transaction and a DATA0 for the second transaction for the isoc split in transaction. An typical isoc split in transaction sequence like this: - SSPLIT IN transaction - CSPLIT IN transaction - MDATA packet - CSPLIT IN transaction - DATA0 packet The DMA address of MDATA (urb->dma) is always DWORD-aligned, but the DMA address of DATA0 (urb->dma + qtd->isoc_split_offset) may not be DWORD-aligned, it depends on the qtd->isoc_split_offset (the length of MDATA). In my test case, the length of MDATA is usually unaligned, this cause DATA0 packet transmission error. This patch use kmem_cache to allocate aligned DMA buf for isoc split in transaction. Note that according to usb 2.0 spec, the maximum data payload size is 1023 bytes for each fs isoc ep, and the maximum allowable interrupt data payload size is 64 bytes or less for fs interrupt ep. So we set the size of object to be 1024 bytes in the kmem cache. Tested-by: Gevorg Sahakyan <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Acked-by: Minas Harutyunyan [email protected]> Signed-off-by: William Wu <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-05-21usb: dwc2: WA for Full speed ISOC IN in DDMA mode.Artur Petrosyan1-0/+2
By clearing NAK status of EP, core will send ZLP to IN token and assert NAK interrupt relying on TxFIFO status only. The WA applies only to core versions from 2.72a to 4.00a (including both). Also for FS_IOT_1.00a and HS_IOT_1.00a. Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-05-21usb: dwc2: Fix kernel doc's warnings.Grigor Tovmasyan1-33/+137
Added descriptions for all not described parameters. Fix all kernel doc's warnings. Acked-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-05-15usb: dwc2: Change reading of current frame number flow.Artur Petrosyan1-3/+4
The current frame_number is read from core for both device and host modes. Reading of the current frame number needs to be performed ASAP due to IRQ latency's. This is why, it is moved to common interrupt handler. Accordingly updated dwc2_gadget_target_frame_elapsed() function which uses stored frame_number instead of reading frame number. In cases when target frame value is incremented the frame_number is required to read again. Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-05-15usb: dwc2: Add Interpacket Gap(IPG) feature supportGrigor Tovmasyan1-0/+11
Added GHWCFG4_IPG_ISOC_SUPPORTED and DCFG_IPG_ISOC_SUPPORDED bits definitions to enable/disable IPG feature. Added ipg_isoc_en core parameter which will indicate IPG support enable/disable and initialize it. Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-05-15usb: dwc2: Change ISOC DDMA flowMinas Harutyunyan1-2/+2
Changed existing two descriptor-chain flow to one chain. In two-chain implementation BNA interrupt used for switching between two chains. BNA interrupt asserted because of returning to beginning of the chain based on L-bit of last descriptor. Because of that we lose packets. This issue resolved by using one desc-chain. Removed all staff related to two desc-chain flow from DDMA ISOC related functions. Removed request length checking from dwc2_gadget_fill_isoc_desc() function. Request length checking added to dwc2_hsotg_ep_queue() function. If request length greater than descriptor limits then request not added to queue. Additional checking done for High Bandwidth ISOC OUT's which not supported by driver. In dwc2_gadget_fill_isoc_desc() function also checked desc-chain status (full or not) to avoid of reusing not yet processed descriptors. In dwc2_gadget_start_isoc_ddma() function creation of desc-chain always started from descriptor 0. Before filling descriptors, they were initialized by HOST BUSY status. In dwc2_gadget_complete_isoc_request_ddma() added checking for desc-chain rollover. Also added checking completion status. Request completed successfully if DEV_DMA_STS is DEV_DMA_STS_SUCC, otherwise complete with actual=0. For systems with high IRQ latency added pointer compl_desc to next descriptor to be completed by XferCompl interrupt. This pointer replace descriptor index calculation based on DxEPDMA register. On descriptor completion interrupt processing all descriptors starting from compl_desc till descriptor which Buffer Status field not equal DMA_DONE status. Actually removed dwc2_gadget_start_next_isoc_ddma() function because now driver use only one desc-chain and instead that function added dwc2_gadget_handle_isoc_bna() function for handling BNA interrupts. Handling BNA interrupt done by flushing TxFIFOs for OUT EPs, completing request with actual=0 and resetting desc-chain number and target frame to initial values for restarting transfers. On handling NAK request completed with actual=0. Incremented target frame to allow fill desc chain and start transfers. In DDMA mode avoided of frame number incrementing, because tracking of frame number performed in dwc2_gadget_fill_isoc_desc() function. When core assert XferCompl along with BNA, we should ignore XferCompl in dwc2_hsotg_epint() function. On BNA interrupt replaced dwc2_gadget_start_next_isoc_ddma() by above mentioned BNA handler. In dwc2_hsotg_ep_enable() function added sanity check of bInterval for ISOC IN in DDMA mode, because HW doesn't supported EP's with bInterval more than 10 and check for mc for ISOC OUT transfers, because core doesn't support high bandwidth transfers. Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: add support for host mode external vbus supplyAmelie Delaunay1-0/+2
This patch adds a way to enable an external vbus supply in host mode, when dwc2 drvvbus signal is not used. This patch is very similar to the one done in U-Boot dwc2 driver [1]. It also adds dynamic vbus supply management depending on the role and state of the core. [1] https://lists.denx.de/pipermail/u-boot/2017-March/283434.html Signed-off-by: Amelie Delaunay <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Force mode optimizationsVardan Mikayelyan1-4/+2
If the dr_mode is USB_DR_MODE_OTG, forcing the mode is needed during driver probe to get the host and device specific HW parameters. Then we clear the force mode bits so that the core operates in OTG mode. The force mode bits should not be touched at any other time during the driver lifetime and they should be preserved whenever the GUSBCFG register is written to. The force mode bit values will persist across soft resets of the core. If the dr_mode is either USB_DR_MODE_HOST or USB_DR_MODE_PERIPHERAL, the force mode is set just once at probe to configure the core as either a host or peripheral. Given the above, we no longer need any other reset delays, force delays, or any forced modes anywhere else in the driver. So replace all calls to dwc2_core_reset_and_force_dr_mode() with dwc2_core_reset() and remove all other unnecessary delays. Also remove the dwc2_force_mode_if_needed() function since the "if needed" part is already taken care of by the polling in dwc2_force_mode(). Finally, remove all other calls to dwc2_clear_force_mode(). Tested-by: Stefan Wahren <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add dwc2_handle_gpwrdn_intr() handlerVardan Mikayelyan1-0/+3
The GPWRDN interrupts are those that occur in both Host and Device mode while core is in hibernated state. Export dwc2_core_init to be able to use it in GPWRDN_IDSTS interrupt handler. Here we have duplicated init functions in host and gadget sides so I have left things as it was(used corresponing functions for host and gadget), maybe in the future we'll resolve this problem and will use dwc2_core_init for both sides. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add dwc2_enter_hibernation(), dwc2_exit_hibernation()Vardan Mikayelyan1-0/+3
These are wrapper functions which are calling device or host enter/exit hibernation functions. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add host/device hibernation functionsVardan Mikayelyan1-0/+18
Add host/device hibernation functions which must be wrapped by core's dwc2_enter_hibernation()/dwc2_exit_hibernation() functions. Make dwc2_backup_global_registers dwc2_restore_global_register non-static to use them in both host/gadget sides. Added function names: dwc2_gadget_enter_hibernation() dwc2_gadget_exit_hibernation() dwc2_host_enter_hibernation() dwc2_host_exit_hibernation() Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add helper functions for restore routineVardan Mikayelyan1-0/+3
Add common (host/device) helper functions, which will be called while exiting from hibernation, from both sides. dwc2_restore_essential_regs() dwc2_hib_restore_common() Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Changes in registers backup/restore functionsVardan Mikayelyan1-2/+4
Move hptxfsiz to host register's backup/restore functions, not needed to have it in global register's backup/restore functions. Add backup for glpmcfg, and read/write for gi2cctl and pcgcctl. As requires programming guide. Affected functions: dwc2_backup_host_registers() dwc2_restore_host_registers() dwc2_backup_global_registers() dwc2_restore_global_registers() Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: gadget: Add remote_wakeup_allowed flagVardan Mikayelyan1-0/+3
It will be set once corresponding set_feature command comes. True if device is allowed to wake-up host by remote-wakeup signalling. This is preparation for remote wake-up support implementation, it will not be implemented until gadget stack provide interface for bringing remote wake-up signalling. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: core: Add hibernated flagVardan Mikayelyan1-0/+2
Added a flag to indicate that core is in hibernation, it is used to determine the hibernation state of the core. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: gadget: Fix dwc2_restore_device_registersVardan Mikayelyan1-2/+3
Add parameter remote_wakeup to dwc2_restore_device_registers() to be able to restore device registers according to programming guide for dwc-otg. It says that in case of rem_wakeup DCTL must not be restored here. Remove setting of DCTL_PWRONPRGDONE from this function, because it will be done in function responsible for exiting from hibernation. WA for enabled EPx's IN and OUT in DDMA mode. On entering to hibernation wrong value read and saved from DIEPDMAx, as result BNA interrupt asserted on hibernation exit by restoring from saved area. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Artur Petrosyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: gadget: Moved dtxfsiz backup array placeVardan Mikayelyan1-2/+2
Moved dtxfsiz from dwc2_gregs_backup to dwc2_dregs_backup, because it is device register. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add hibernation field into dwc2_hw_paramsVardan Mikayelyan1-2/+10
Add parameter and it's initialization, needed for hibernation. Reimplement dwc2_set_param_power_down() to support hibernation too. Now 'power_down' parameter can be initialized with 0, 1 or 2. 0 - No 1 - Partial power down 2 - Hibernation Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Rename hibernation to partial_power_downVardan Mikayelyan1-6/+6
No-op change, only rename. This code was misnamed originally. It was only responsible for partial power down and not for hibernation. Rename core_params->hibernation to core_params->power_down, dwc2_set_param_hibernation() to dwc2_set_param_power_down(). Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: gadget: Configure the core to enable LPMSevak Arakelyan1-0/+2
Configure core in device mode to support LPM according to programming guide. Device will start giving valid responses for LPM tokens. After this patch device side LPM will start working. Signed-off-by: Sevak Arakelyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add core parameters for LPM supportSevak Arakelyan1-0/+20
Add lpm, lpm_clock_gating, besl, hird_threshold_en and hird_threshold core parameters. These will indicate LPM and LPM Errata support as well as chosen L1 sleeping mode for the core and PHY. Signed-off-by: Sevak Arakelyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Backup and restore PCGCCTL1 registerRazmik Karapetyan1-0/+1
Backup PCGCCTL1 register when entering hibernation mode and restore it after exiting from hibernation, to keep active ACG feature. Signed-off-by: Razmik Karapetyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Add ACG support to the driverRazmik Karapetyan1-0/+4
Added function for supporting Active Clock Gating functionality in the driver. PCGCCTL1 (Power and Clock Control) register will be used for controlling the core`s active clock gating feature, and the previously reserved 12th bit in GHWCFG4 now indicates that the controller supports the Dynamic Power Reduction (Active Clock Gating) during no traffic scenarios such as L0, idle, resume and suspend states. dwc2_enable_acg() function sets GATEEN bit in PCGCCTL1 register and enables ACG, if it supported. According to ACG functional specification, enabling of ACG feature in host mode done in host initialization, before turning Vbus on, specifically in dwc2_core_host_init function. Enabling of ACG feature in device mode done in device initialization, before clearing the SftDiscon bit in DCTL. This bit was cleared in dwc2_hsotg_core_connect() function.So dwc2_enable_acg() called before dwc2_core_connect() calls. Signed-off-by: Razmik Karapetyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Fix interval type issueGrigor Tovmasyan1-1/+1
The maximum value that unsigned char can hold is 255, meanwhile the maximum value of interval is 2^(bIntervalMax-1)=2^15. Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Delete unused functionalityGrigor Tovmasyan1-18/+0
Deleted dwc2_hcd_dump_frrem() function, because it used undefined parameters from dwc2_hsotg structure. The function body was in #ifdef statement and was never compiled. Also removed that parameters from dwc2_hsotg structure, which were used only in dwc2_hcd_dump_frrem() function. And also delete dwc2_sample_frrem macro, because without dwc2_hcd_dump_frrem() function it's lose its purpose. Acked-by: John Youn <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Set AHB burst size to INCRRazmik Karapetyan1-1/+1
Changed AHB burst size from INCR4 to INCR by default. With this value driver shows excellent DMA performance. Acked-by: John Youn <[email protected]> Signed-off-by: Razmik Karapetyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Update bit polling functionalitySevak Arakelyan1-0/+5
Move dwc2_hsotg_wait_bit_set function to core.c so it can be used anywhere in the code. Added dwc2_hsotg_wait_bit_clear function in core.c. Replace all the parts of register bit polling code with dwc2_hsotg_wait_bit_set or dwc2_hsotg_wait_bit_clear functions calls depends on code logic. Acked-by: John Youn <[email protected]> Signed-off-by: Sevak Arakelyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-13usb: dwc2: Remove version check in GSNPSIDGevorg Sahakyan1-0/+5
Only check the ID portion of the GSNPSID register and don’t check the version. This will allow the driver to work with version 4.00a and later of the DWC_hsotg IP. Acked-by: John Youn <[email protected]> Signed-off-by: Gevorg Sahakyan <[email protected]> Signed-off-by: Minas Harutyunyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-03-08usb: dwc2: eliminate irq parameter from dwc2_gadget_initVardan Mikayelyan1-2/+2
The irq is available in hsotg already, so there's no need to pass it as separate function parameter. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: Grigor Tovmasyan <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2018-01-08Merge tag 'usb-for-v4.16' of ↵Greg Kroah-Hartman1-0/+2
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: changes for v4.16 merge window Not many changes here, the most important being an improvement for TI's AM57xx and DRA7xx devices which allows them to disable a metastability workaround in situations where we know what's going on. Other than that, we have a set of changes on Renesas UDC to make the code a little easier to read and maintain while also better supporting extcon framework. The u_serial adaptation layer learned to use kfifo instead of cooking its own FIFO implementation. DWC3 learned to decode a few more USB requests on the trace output.