]> rtime.felk.cvut.cz Git - zynq/linux.git/log
zynq/linux.git
5 years agousb: dwc3: otg: Update Kconfig and Makefile for enabling OTG
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:19 +0000 (10:23 +0000)]
usb: dwc3: otg: Update Kconfig and Makefile for enabling OTG

This patch updates the Kconfig and Makefile for enabling
the OTG driver.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: gadget: Add new platform_data.h file
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:18 +0000 (10:23 +0000)]
usb: dwc3: gadget: Add new platform_data.h file

This patch adds new platform_data.h file which
can be used for storing the platform specific
information.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: host: xhci: Replace 0/1 values with boolean
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:17 +0000 (10:23 +0000)]
usb: host: xhci: Replace 0/1 values with boolean

This patch replaces 0/1 values used in xhci-plat.c
with boolean values for ease of understanding

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: otg: Add dependencies required by otg.c and drd.c files
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:16 +0000 (10:23 +0000)]
usb: dwc3: otg: Add dependencies required by otg.c and drd.c files

drd.c file supports the simple OTG role swap feature based on the
ULPI pin status and otg.c file supports the TRUE OTG features like
HNP, SRP and also Role swap based on ULPI ID pin.

This patch adds the dependencies required by drd.c and otg.c files.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: gadget: remove redundant otg checks from dwc3_gadget_init()
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:15 +0000 (10:23 +0000)]
usb: dwc3: gadget: remove redundant otg checks from dwc3_gadget_init()

otg_set_peripheral() is getting called from dwc3_gadget_init()
at the end, remove the redundant code

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: otg: Pass dummy address instead of value
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:14 +0000 (10:23 +0000)]
usb: dwc3: otg: Pass dummy address instead of value

dwc3_otg_set_host() stops peripheral mode once the
host initialization is done. The present code logic
detects the host init done based on the value sent
in place of  struct usb_bus * ptr. The pointer
value is checked with 0x1 to know whether host is
initialized or not. This patch changes the code
to check against the dummy address value "0xdeadbeef"
instead of value "0x1"

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: otg: Add support for ending HNP session
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:13 +0000 (10:23 +0000)]
usb: dwc3: otg: Add support for ending HNP session

As a part of sucessful HNP session both A-Device and
B-Device swaps their roles from A-Device: Host->Peripheral
and B-Device: Peripheral->Host. Once the B-Device is done
as Host, the HNP session should be ended to restore to their
previous roles i.e, A-Device: Peripheral->Host and B-Device:
Host->Peripheral. This patch adds a sysfs entry which will
end the HNP session and restore to their original roles.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: replace arguments in __dwc3_gadget_ep_enable with DWC3_DEPCFG_ACTION_INIT
Anurag Kumar Vulisha [Sat, 30 Mar 2019 10:23:12 +0000 (10:23 +0000)]
usb: dwc3: replace arguments in __dwc3_gadget_ep_enable with DWC3_DEPCFG_ACTION_INIT

DWC3_DEPCFG_ACTION_INIT is as equal as passing modify = false
and restore = false in __dwc3_gadget_ep_enable()

This patch updates the code

From:
__dwc3_gadget_ep_enable(dep, false, false);

To:
__dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: route lpd usb traffic through CCI path for making SMMU work
Anurag Kumar Vulisha [Fri, 15 Mar 2019 11:27:41 +0000 (11:27 +0000)]
usb: dwc3: route lpd usb traffic through CCI path for making SMMU work

usb dma traffic by default takes the direct DDR path from LPD switch.
Since SMMU is present before CCI, the usb dma traffic needs to be
routed to take the CCI path for making SMMU work. This can be done
by enabling "coherency" in usb.

This patch modifies the code to enable coherency in usb for below
mentioned cases

1. To route usb dma transactions through CCI path for coherency. This is
   done when "dma-coherent" property is added into dwc3 dts node.
2. To route usb dma transactions through CCI path to make SMMU work with
   usb dma. This is done when "dwc->dev->iommu_group" is populated
   (iommu_group is only populated when sucessfull smmu comtext for usb is
   created).

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agoUSB: gadget: f_hid: fix deadlock in f_hidg_write()
Anurag Kumar Vulisha [Thu, 14 Mar 2019 11:45:20 +0000 (11:45 +0000)]
USB: gadget: f_hid: fix deadlock in f_hidg_write()

In f_hidg_write() the write_spinlock is acquired before calling
usb_ep_queue() which causes a deadlock when dummy_hcd is being used.
This is because dummy_queue() callbacks into f_hidg_req_complete() which
tries to acquire the same spinlock. This is (part of) the backtrace when
the deadlock occurs:

  0xffffffffc06b1410 in f_hidg_req_complete
  0xffffffffc06a590a in usb_gadget_giveback_request
  0xffffffffc06cfff2 in dummy_queue
  0xffffffffc06a4b96 in usb_ep_queue
  0xffffffffc06b1eb6 in f_hidg_write
  0xffffffff8127730b in __vfs_write
  0xffffffff812774d1 in vfs_write
  0xffffffff81277725 in SYSC_write

Fix this by releasing the write_spinlock before calling usb_ep_queue()

Signed-off-by: Radoslav Gerganov <rgerganov@vmware.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodt-bindings: usb: Add description for interrupt-names property used
Anurag Kumar Vulisha [Tue, 5 Mar 2019 15:46:33 +0000 (15:46 +0000)]
dt-bindings: usb: Add description for interrupt-names property used

This patch updates the documentation for "interrupt-names" property used
in dwc3 dts node

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: otg: mask host/device soft reset from affecting the phy
Anurag Kumar Vulisha [Fri, 1 Mar 2019 14:38:36 +0000 (14:38 +0000)]
usb: dwc3: otg: mask host/device soft reset from affecting the phy

Setting OCFG.OTGSFTRSTMASK bit masks reset signal issued
either from host or device soft reset from affecting the
reset signal outputs sent to the phy. This patch sets
programs this bit when starting host or peripheral mode

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: otg: make otg driver work along with drd driver
Anurag Kumar Vulisha [Fri, 1 Mar 2019 14:38:35 +0000 (14:38 +0000)]
usb: dwc3: otg: make otg driver work along with drd driver

There are 2 drivers which can be used for dwc3 otg feature, they are
discussed below

1. drd.c -> This driver supports the basic Host <-> Peripheral role
    swap based on ID PIN sensing. If ID PIN is low the Host
    role is switched. When ID PIN is high Peripheral role is
    switched
2. otg.c -> This driver is internal driver which supports the TRUE OTG
    functionality. Unlike drd.c , this driver supports the OTG
    features like HNP (Host Negotiation Protocol) , SRP (Session
    Request Protocol) and Host <-> Peripheral swapping (same as
    drd.c)

This patch makes the necessary code changes for enabling
otg.c when "CONFIG_USB_DWC3_OTG" is enabled and drd.c when
the "CONFIG_USB_DWC3_DUAL_ROLE" is enabled

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Fix broken CCI feature with dwc3 usb controller
Anurag Kumar Vulisha [Thu, 14 Feb 2019 11:02:51 +0000 (11:02 +0000)]
usb: dwc3: Fix broken CCI feature with dwc3 usb controller

CCI feature was broken for dwc3 usb controller as
a part of 4.19 kernel merge. This patch fixes the
same

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Add DRD support for versal
Anurag Kumar Vulisha [Fri, 8 Jun 2018 16:02:19 +0000 (21:32 +0530)]
usb: dwc3: Add DRD support for versal

This patch makes the required changes in dwc3-of-simple.c driver to
enable dwc3 DRD support for Versal platform

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: gadget: Don't kick transfer if LST or SHORT bits are set
Anurag Kumar Vulisha [Tue, 8 Jan 2019 16:03:54 +0000 (21:33 +0530)]
usb: dwc3: gadget: Don't kick transfer if LST or SHORT bits are set

When LST bit is set in event->status, indicates that the
transfer is completed and when SHORT bit is set in
event->status, indicates that the transfer completed with
short transfer.
In dwc3_gadget_ep_cleanup_completed_request(), the transfer
should not be started again if any of LST or SHORT bits are
set in the event.This patch modifies the code to check for
LST & SHORT bits before kick starting the transfer

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Check MISSED ISOC bit only for ISOC endpoints
Anurag Kumar Vulisha [Tue, 8 Jan 2019 16:03:53 +0000 (21:33 +0530)]
usb: dwc3: Check MISSED ISOC bit only for ISOC endpoints

When streaming is enabled on BULK endpoints and LST bit is set
observed MISSED ISOC bit set in event->status for BULK ep. Since
this bit is only valid for isocronous endpoints, changed the code
to check for isocrnous endpoints when MISSED ISOC bit is set.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields
Anurag Kumar Vulisha [Tue, 8 Jan 2019 16:03:52 +0000 (21:33 +0530)]
usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields

The present code in dwc3_gadget_ep_reclaim_completed_trb() will check
for IOC/LST bit in the event->status and returns if IOC/LST bit is
set. This logic doesn't work if multiple TRBs are queued per
request and the IOC/LST bit is set on the last TRB of that request.
Consider an example where a queued request has multiple queued TRBs
and IOC/LST bit is set only for the last TRB. In this case, the Core
generates XferComplete/XferInProgress events only for the last TRB
(since IOC/LST are set only for the last TRB). As per the logic in
dwc3_gadget_ep_reclaim_completed_trb() event->status is checked for
IOC/LST bit and returns on the first TRB. This makes the remaining
TRBs left unhandled.
To aviod this, changed the code to check for IOC/LST bits in both
event->status & TRB->ctrl. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb()
Anurag Kumar Vulisha [Mon, 1 Apr 2019 15:35:59 +0000 (15:35 +0000)]
usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb()

vailability of TRB's is calculated using dwc3_calc_trbs_left(), which
determines total available TRB's based on the HWO bit set in a TRB.

In the present code, __dwc3_prepare_one_trb() is called with a TRB which
needs to be prepared for transfer. This __dwc3_prepare_one_trb() calls
dwc3_calc_trbs_left() to determine total available TRBs and set IOC bit
if the total available TRBs are zero. Since the present working TRB (which
is passed as an argument to __dwc3_prepare_one_trb() )  doesn't yet have
the HWO bit set before calling dwc3_calc_trbs_left(), there are chances
that dwc3_calc_trbs_left() wrongly calculates this present working TRB
as free(since the HWO bit is not yet set) and returns the total available
TRBs as greater than zero (including the present working TRB). This could
be a problem.

This patch corrects the above mentioned problem in __dwc3_prepare_one_trb()
by increementing the dep->trb_enqueue at the last (after preparing the TRB)
instead of increementing at the start and setting the IOC bit only if the
total available TRBs returned by dwc3_calc_trbs_left() is 1 . Since we are
increementing the dep->trb_enqueue at the last, the present working TRB is
also considered as available by dwc3_calc_trbs_left() and non zero value is
returned . So, according to the modified logic, when the total available
TRBs is equal to 1 that means the total available TRBs in the pool are 0.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Reviewed-by: Thinh Nguyen <thinhn@synopsys.com>
Tested-by: Tejas Joglekar <tejas.joglekar@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: otg: cancel the hnp_polling work before stopping host
Anurag Kumar Vulisha [Tue, 15 May 2018 13:45:02 +0000 (19:15 +0530)]
dwc3: otg: cancel the hnp_polling work before stopping host

This patch adds the code to cancel the previously queued
HNP polling work before stopping the host.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: otg: fix broken OTG HNP feature
Anurag Kumar Vulisha [Tue, 15 May 2018 13:45:01 +0000 (19:15 +0530)]
dwc3: otg: fix broken OTG HNP feature

HNP(Host Negotiation Protocol) is an USB OTG 2.0 feature where the
HOST & DEVICE can swap their roles. Using HNP feature A-device acting
in HOST mode can be role swapped to DEVICE mode and B-device acting in
DEVICE mode can be role swapped to HOST mode.

This feature was broken in earlier releases, so this patch fixes the same
by enabling HNP support before entering into device mode and also avoids
ADevBHostEndEvent getting triggered by waiting for extra time before
enabling events in A-peripheral state, thus giving enough time for HOST
stack on B-device to be loaded.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: storage: uas: Remove unused variable from uas.c
Anurag Kumar Vulisha [Tue, 15 May 2018 13:55:08 +0000 (19:25 +0530)]
usb: storage: uas: Remove unused variable from uas.c

This patch removes the unused variable from the uas.c driver
to aviod the below mentioned warning

uas.c:288:16: warning: unused variable 'flags' [-Wunused-variable]

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: gadget: ISOC transfers should be stopped before starting a transfer
Anurag Kumar Vulisha [Thu, 26 Apr 2018 07:19:17 +0000 (12:49 +0530)]
usb: dwc3: gadget: ISOC transfers should be stopped before starting a transfer

For ISOC transfers the requests are not queued until the HOST requests
for data and XferNotReady event is generated .But XferNotReady event
is not getting generated for ISOC transfers for the second time after
Endpoint configuration. Since ISOC packets depend on the XferNotReady
events, they will not be queued to controller. Because of this issue
timeout happens on the application layer.

This patch fixes this issue by issuing END TRANSFER command before
starting any ISOC transfers. Doing so will make the controller clear
the previous allocated endpoint resources and reallocate resources
when the transfer is requested. Because of this change XferNotReady
events will be generated when host requests for the ISOC transfer.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: xhci: wait for atleast 1ms after exiting U3
Anurag Kumar Vulisha [Thu, 1 Mar 2018 17:31:13 +0000 (23:01 +0530)]
usb: xhci: wait for atleast 1ms after exiting U3

XHCI controller may not properly send LFPS.U3_EXIT signalling after
resuming from suspend(D3->D0). To avoid this, lets wait for atleast
1ms after updating the PORTSC_30.PLS to enter U0 from U3. This patch
does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Correct usb dma mask for making SMMU work in device mode
Anurag Kumar Vulisha [Tue, 20 Jun 2017 10:55:18 +0000 (16:25 +0530)]
usb: dwc3: Correct usb dma mask for making SMMU work in device mode

By default dma_coherent_mask is set to 32 bits, because of this the
virtual address generated by the SMMU is masked to 32 bit width.
Due to this reason, the events generated by the USB DMA are not being
updated to the correct physical address and undefined behaviour is
generated.
This patch corrects the above said problem by reading and setting
the DMA coherent mask based on the GHWPARAMS0.MDWIDTH value.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: gadget: uvc_video: unlock before submitting a request to ep
Anurag Kumar Vulisha [Sun, 25 Feb 2018 07:33:21 +0000 (13:03 +0530)]
usb: gadget: uvc_video: unlock before submitting a request to ep

There could be chances where the usb_ep_queue() could fail and trigger
complete() handler with error status. In this case, if usb_ep_queue()
is called with lock held and the triggered complete() handler is waiting
for the same lock to be cleared could result in a deadlock situation and
could result in system hang. To aviod this scenerio, call usb_ep_queue()
with lock removed. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Fix the broken suspend/resume functionality in dwc3
Anurag Kumar Vulisha [Fri, 15 Dec 2017 11:28:09 +0000 (16:58 +0530)]
usb: dwc3: Fix the broken suspend/resume functionality in dwc3

Since the GCTL values are lost after suspend, restore the GCTL
prtcap direction values based on the mode of operation. Doing
so, will fix the host/peripheral functionality after resume.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Fix missing peripheral irq error message
Anurag Kumar Vulisha [Mon, 19 Feb 2018 11:08:49 +0000 (16:38 +0530)]
usb: dwc3: Fix missing peripheral irq error message

Due to incorrect programming sequence the "missing peripheral IRQ"
error message gets showed even after finding the correct IRQ.
This patch fixes the code logic for removing this error message

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: gadget: configfs: Add support for setting maximum supported speed
Anurag Kumar Vulisha [Thu, 15 Feb 2018 15:02:55 +0000 (20:32 +0530)]
usb: gadget: configfs: Add support for setting maximum supported speed

Since configfs driver determines the current opertaing speed of the
configured usb gadget, add support for setting the maximum_speed
from the configfs directory. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: xhci: don't clean shared_hcd when otg is enabled
Anurag Kumar Vulisha [Thu, 15 Feb 2018 15:02:54 +0000 (20:32 +0530)]
usb: xhci: don't clean shared_hcd when otg is enabled

Since xhci->shared_hcd contains all the required information
that is needed by otg driver, don't clear the xhci->shared_hcd
during xhci_stop() when otg is enabled

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: don't wait for end transfer to finish for isoc endpoints
Anurag Kumar Vulisha [Sat, 27 Jan 2018 10:13:23 +0000 (15:43 +0530)]
usb: dwc3: don't wait for end transfer to finish for isoc endpoints

Issuing End Transfer command for isocronous endpoints is not
triggering command complete interrupt, so waiting for this
command complete interrupt could endup hanging the system. This
patch modifies the code to not wait for command complete interrupt
after issuing End Transfer command for isoc endpoints.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: fix the logic for setting GBLHIBERNATIONEN in GCTL
Anurag Kumar Vulisha [Thu, 18 Jan 2018 10:47:26 +0000 (16:17 +0530)]
usb: dwc3: fix the logic for setting GBLHIBERNATIONEN in GCTL

The U3PMU/U2PMU will not save or restore any core state until
GBLHIBERNATIONEN is enabled. This patch fix the code for enabling
GBLHIBERNATIONEN for both host and device mode.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodt-bindings: usb: dwc3: Add flag for supporting hibernation
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:49:03 +0000 (17:19 +0530)]
dt-bindings: usb: dwc3: Add flag for supporting hibernation

This patch documents the snps,enable-hibernation devicetree
property , which enables the hibernation support for dwc3
driveer when operating in peripheral mode

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Mayank Adesara <mayank.adesara@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: don't return error when phy is not found
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:49:02 +0000 (17:19 +0530)]
usb: dwc3: don't return error when phy is not found

Since there could be valid cases where the phys property
is not added into dts file. So, don't return error when
phy is not found

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: add support for enabling/disabling hibernation dynamically
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:49:00 +0000 (17:19 +0530)]
usb: dwc3: add support for enabling/disabling hibernation dynamically

This patch adds support to enable/disable hibernation dynamically
using debugfs

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: avoid calling usb regs when controller in D3 state
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:48:59 +0000 (17:18 +0530)]
usb: dwc3: avoid calling usb regs when controller in D3 state

This patch modifies the code to avoid calling usb registers when the
dwc3 controller is in D3 state

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: use udelay instead of usleep to avoid crash when serving wakeup event
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:48:58 +0000 (17:18 +0530)]
usb: dwc3: use udelay instead of usleep to avoid crash when serving wakeup event

This patch changes the code to use udelay instead of usleep
to avoid crash when serving hibernation wakeup event

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Mayank Adesara <mayank.adesara@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: set susphy bit before entering D3 state
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:48:57 +0000 (17:18 +0530)]
usb: dwc3: set susphy bit before entering D3 state

This patch adds support for setting/clearing susphy bit in
GUSB2PHYCFG register if dis_u2_susphy_quirk is set

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Add hibernation support when operating as gadget
Anurag Kumar Vulisha [Mon, 1 Apr 2019 14:55:19 +0000 (14:55 +0000)]
usb: dwc3: Add hibernation support when operating as gadget

This patch adds hibernation support when dwc3 controller is
operating in gadget mode

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Mayank Adesara <mayank.adesara@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Fix the logic for allocating and setting scratchpad buffers
Anurag Kumar Vulisha [Thu, 11 Jan 2018 11:48:55 +0000 (17:18 +0530)]
usb: dwc3: Fix the logic for allocating and setting scratchpad buffers

This patch fixes the logic for allocating and seeting scratchpad buffers

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: don't setup event buffers when operating in device mode
Anurag Kumar Vulisha [Mon, 8 Jan 2018 18:14:03 +0000 (23:44 +0530)]
usb: dwc3: don't setup event buffers when operating in device mode

This patch skips the initialization of event buffers (which are required
only when USB controller is operation in device or otg mode) when
operating in host only mode.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: Put usb core in reset after entering D3 state
Anurag Kumar Vulisha [Fri, 10 Nov 2017 10:03:07 +0000 (15:33 +0530)]
usb: dwc3: Put usb core in reset after entering D3 state

After entering into D3 mode,the major part of the usb controller except
U3PMU/U2PMU power will be removed.So, it is recommented to put the usb
core in reset after entering D3 mode otherwise undefined behaviour may
occur. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: fix the logic for handling streams in peripheral mode
Anurag Kumar Vulisha [Wed, 20 Dec 2017 14:23:26 +0000 (19:53 +0530)]
usb: dwc3: fix the logic for handling streams in peripheral mode

This patch fixes the logic for handling UAS protocol capable
endpoints when dwc3 is acting as peripheral mode.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: function: f_tcm: Add support for getting alt interface number
Anurag Kumar Vulisha [Wed, 20 Dec 2017 14:23:27 +0000 (19:53 +0530)]
usb: function: f_tcm: Add support for getting alt interface number

This patch adds support for reading alt interface number using
get_alt() function. This returns '1' if currently UASP interface is
selected by host or '0' if BOT is selected.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: xhci-plat: Add remote wakeup support
Anurag Kumar Vulisha [Wed, 27 Sep 2017 14:05:07 +0000 (19:35 +0530)]
usb: xhci-plat: Add remote wakeup support

This patch adds support for enabling remote wakeup capability
to the host controller

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodwc3: Add code for supporting entering into D3 state during suspend
Anurag Kumar Vulisha [Wed, 27 Sep 2017 14:05:06 +0000 (19:35 +0530)]
dwc3: Add code for supporting entering into D3 state during suspend

This patch adds support for making the core enter D3 state during
suspend. D3 state is only entered for when wakeup capability is
enabled.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodt-bindings: usb: dwc3: update for CCI support for USB
Manish Narani [Mon, 27 Mar 2017 12:17:01 +0000 (17:47 +0530)]
dt-bindings: usb: dwc3: update for CCI support for USB

This patch adds documentation in DWC3 device-tree bindings for enabling
the DMA coherency in USB.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: update GFLADJ_REFCLK_FLADJ in dwc3_frame_length_adjustment
Subbaraya Sundeep Bhatta [Wed, 27 Jan 2016 14:28:41 +0000 (19:58 +0530)]
usb: dwc3: update GFLADJ_REFCLK_FLADJ in dwc3_frame_length_adjustment

Modified dwc3_frame_length_adjustment function to update
GFLADJ_REFCLK_FLADJ field as per dts

Signed-off-by: Subbaraya Sundeep Bhatta <subbaraya.sundeep.bhatta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodt-bindings: usb: Document snps,refclk_fladj DT property
Anurag Kumar Vulisha [Fri, 27 Oct 2017 10:35:56 +0000 (16:05 +0530)]
dt-bindings: usb: Document snps,refclk_fladj DT property

snps,refclk_fladj property needs to be added to devicetree node
when frame legth adjustment for SOF/ITP counter needs to be done.
This patch documents the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodwc3: fix the logic for finding parent node
Anurag Kumar Vulisha [Mon, 1 Apr 2019 14:28:55 +0000 (14:28 +0000)]
dwc3: fix the logic for finding parent node

The present logic doesn't fetch the correct parent node when two usb nodes
are enabled. It searches all nodes and doesn't fetch the first node with
matching compatible string when two usb nodes are enabled.
This patch fixes the logic by searching "xlnx,zynqmp-dwc3" compatible
string only in the parent nodes instead of the searching all nodes.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: fix IOC bit set when trb queue is full
Anurag Kumar Vulisha [Mon, 1 Apr 2019 14:15:50 +0000 (14:15 +0000)]
usb: dwc3: fix IOC bit set when trb queue is full

if queue is full we are depending on HWO bit to see if queue is
full or empty. after advancing trb_enqueue last trb will be the
trb we are working right now. so need to check after HWO bit is
set

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: implement stream transfer timout
Anurag Kumar Vulisha [Mon, 1 Apr 2019 14:12:28 +0000 (14:12 +0000)]
usb: dwc3: implement stream transfer timout

according to databook it may be possible host and device become
out of sync where device wait for host to issue prime transcation
and host waits for device to issue erdy to avoid such deadlock
timeout need to be implement. after timeout device will first
stop transfer and again restart the transfer

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: enable transfer complete event for stream endpoint
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:18 +0000 (04:54 -0400)]
usb: dwc3: enable transfer complete event for stream endpoint

start transfer for new stream id need to free previously held
transfer resources. transfer complete event will automatically
free up the resource once transfer associated with stream
completes

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agousb: dwc3: write stream id in depcmd
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:17 +0000 (04:54 -0400)]
usb: dwc3: write stream id in depcmd

while start transfer command stream id need to be written in depcmd

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodwc3: Fix the logic used to get data from parent node
Anurag Kumar Vulisha [Fri, 4 Aug 2017 15:01:59 +0000 (20:31 +0530)]
dwc3: Fix the logic used to get data from parent node

At present when two usb nodes are enabled, incorrect simple data is
getting fetched from parent node. Because of this kernel panic was
getting triggered when more than one usb nodes are enabled.
This patch fixes the logic used to get simple data from parent node.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodwc3: Correct errors when dwc3 loaded as module
Anurag Kumar Vulisha [Sat, 29 Jul 2017 04:29:43 +0000 (09:59 +0530)]
dwc3: Correct errors when dwc3 loaded as module

This patch fixes the errors when dwc3 is selected as a loadable
moodule.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
5 years agodwc3: Add support for removing vbus when suspended
Anurag Kumar Vulisha [Thu, 27 Jul 2017 06:55:56 +0000 (12:25 +0530)]
dwc3: Add support for removing vbus when suspended

During suspend, dwc3 host puts the device into U3 state and disables the
clocks. During resume, dwc3 host drives LFPS.polling to detect the
connected usb device and most of the usb devices detect LFPS.polling signal
and drives LFPS.U3 exit signal and gets detected by the dwc3 host. But very
few usb devices during resume doesn't drive u3 exit signalling even after
seeing LFPS.polling signal on the link and wait for the host to initiate an
u3 exit(Currently the USB stack doesn't drive U3 exit during resume from
suspened). These kind of devices doesn't even respond to warm reset
signalling sent by the host. Since these usb devices doesn't respond to
polling or warm reset, host controller doesn't generate USB detect event
after resume from suspend until manual disconnect.

To aviod the above said issue, during suspend we need to ask ULPI phy to
stop driving of VBUS and restore VBUS during resume. Doing so, will make
usb device to enter into RX Detect state and start LFPS.polling after
restoring LFPS.polling signal and thus generating detect event on the host
side.

This patch does the above said with a check to ensure that VBUS is not
disabled for the usb devices that are remote wakeup capable.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: Add support for clock disabling during suspend
Anurag Kumar Vulisha [Wed, 19 Jul 2017 13:55:51 +0000 (19:25 +0530)]
dwc3: Add support for clock disabling during suspend

In dwc3 usb controller, when remote wakeup feature is enabled and
the controller is in U3 state (suspended), it requires suspend_clk
to be active to detect wakeup signalling driven on the link.
For all other cases usb clocks can be disabled once the controller
enters U3 state.

This patch adds the logic for disabling usb clocks when remote
wakeup feature is not enabled.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: Add quirk for enabling workaround for BULK IN streams
Anurag Kumar Vulisha [Wed, 13 Sep 2017 10:30:50 +0000 (12:30 +0200)]
usb: Add quirk for enabling workaround for BULK IN streams

This patch adds support for enabling workaround for BULK IN stream
rings by adding "xhci-stream-quirk" flag to dts node. Enabling this
flag activates the timer for every BULK IN stream ring at the time
of queuing TRB's into BULK IN stream ring.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: Correct dwc3 host init code for making SMMU work in HOST Mode
Anurag Kumar Vulisha [Tue, 20 Jun 2017 10:55:17 +0000 (16:25 +0530)]
usb: dwc3: Correct dwc3 host init code for making SMMU work in HOST Mode

DWC3 driver initializes the xhci host platform device structure.
As a part of initialization it configures xhci dev DMA attributes,
but fails to set correct smmu dma ops (if iommus node is added in
dts file). But SMMU driver intializes correct context block based
on the SMMU Stream ID given by USB dts node. Due to the improper
initalization of dma ops(SWIO instead of SMMU) no proper page table
entries are updated in SMMU Contect Block, thus generating an abort
when USB DMA tries to write an event in the event ring.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: core: Enable GUCTL1 chicken bit 9 for correcting Inter Packet Delay(IPD)
Anurag Kumar Vulisha [Wed, 10 May 2017 14:12:01 +0000 (19:42 +0530)]
dwc3: core: Enable GUCTL1 chicken bit 9 for correcting Inter Packet Delay(IPD)

SNPS controller when configureed in HOST mode maintains Inter Packet
Delay (IPD) of ~380ns which works with most of super-speed hubs except
VIA-LAB hubs. When IPD is ~380ns HOST controller fails to enumerate FS/LS
devices when connected behind VIA-LAB hubs.
Enabling bit 9 of GUCTL1 enables the workaround in HW to reduce the ULPI
clock latency by 1 cycle, thus reducing the IPD (~360ns) and making
controller enumerate FS/LS devices connected behind VIA-LAB.
This patch fixes the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: core: Enable GUCTL1 chicken bit 10 for fixing crc error after resume bug
Anurag Kumar Vulisha [Wed, 10 May 2017 14:12:00 +0000 (19:42 +0530)]
dwc3: core: Enable GUCTL1 chicken bit 10 for fixing crc error after resume bug

When configured in HOST mode, after issuing U3/L2 exit controller fails to
send proper CRC checksum in CRC5 feild. Because of this behaviour
Transaction Error is generated, resulting in reset and re-enumeration of
usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this
problem. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: Add support for setting USB control registers as phy platform data
Anurag Kumar Vulisha [Tue, 18 Apr 2017 15:51:15 +0000 (21:21 +0530)]
dwc3: Add support for setting USB control registers as phy platform data

This patch adds support for setting USB vendor specific control registers
as phy platform data. These registers are used by the phy to configure USB
PIPE signals.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodwc3: dwc3-of-simple: Move ioremap calls into probe
Anurag Kumar Vulisha [Tue, 18 Apr 2017 15:51:14 +0000 (21:21 +0530)]
dwc3: dwc3-of-simple: Move ioremap calls into probe

Currently ioremap_resource & ioremap_release of USB vendor specific
control regions are being done in dwc3_enable_hw_coherency() when
CCI is enabled. These USB vendor specific regions has the PIPE3
control registers, which needs to be configured everytime to get
proper connect/disconnect events. Because of this reason moving the
ioremap_resource into probe.

Note:
This patch is a temporary workaround which is done to set pipe signals
without effecting usb cci and this will be redesigned. this change will
get it into v2017.1 and expected to change once the proper solution is
available.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: core: Enable CCI support in dwc3 core driver
Manish Narani [Tue, 28 Mar 2017 10:31:52 +0000 (16:01 +0530)]
usb: dwc3: core: Enable CCI support in dwc3 core driver

This patch adds CCI support in DWC3 driver when CCI is enabled in the
design. There are couple of registers which need to be modified for
making CCI enabled transfers in USB. This patch add the support for
the same.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: of-simple: Enable CCI support in dwc3 driver
Manish Narani [Tue, 28 Mar 2017 10:31:51 +0000 (16:01 +0530)]
usb: dwc3: of-simple: Enable CCI support in dwc3 driver

This patch adds CCI support in DWC3 driver when CCI is enabled in the
design. There are couple of registers which need to be modified for
making CCI enabled transfers in USB. This patch add the support for the
same.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: retain resource index for unforced stops
Tanmay Upadhyay [Sun, 5 Mar 2017 14:09:52 +0000 (19:39 +0530)]
usb: dwc3: retain resource index for unforced stops

all active transfers are stopped with force rm bit false while hibernating
and restarted using resource index on wakeup

Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: correct ignoring hibernation event
Tanmay Upadhyay [Sun, 5 Mar 2017 14:09:51 +0000 (19:39 +0530)]
usb: dwc3: correct ignoring hibernation event

- ignore hibernation event if event info doesn't match current USB speed
- dwc->speed holds register value, which isn't the same as USB speed enum

Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: hibernation: zero out scratchpad buffer
Tanmay Upadhyay [Sun, 5 Mar 2017 14:09:50 +0000 (19:39 +0530)]
usb: dwc3: hibernation: zero out scratchpad buffer

DWC3 core fails to save in scratchpad buffer area if it's not
initialized with zero

Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: hibernation: fix scratch buffer allocation
Tanmay Upadhyay [Sun, 5 Mar 2017 14:09:49 +0000 (19:39 +0530)]
usb: dwc3: hibernation: fix scratch buffer allocation

We would know how many scratch buffers to allocate in core_init. So,
move scratch buffer allocation in core_init. Keep a check to avoid
re-allocation when core_init is called after probe.

Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: hibernation: warn if scratch buffer is NULL
Tanmay Upadhyay [Sun, 5 Mar 2017 14:09:48 +0000 (19:39 +0530)]
usb: dwc3: hibernation: warn if scratch buffer is NULL

Signed-off-by: Tanmay Upadhyay <tanmay.upadhyay@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodrivers: dwc3: Fix cleaning of soc_rev for failure conditions
Anurag Kumar Vulisha [Tue, 7 Mar 2017 19:00:32 +0000 (00:30 +0530)]
drivers: dwc3: Fix cleaning of soc_rev for failure conditions

In the current code, we are cleaning soc_rev value even if it
has junk value which occurs because of failure to read SoC revision.
Doing so will trigger in kernel panic. This patch fixes the same.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodrivers: dwc3: Add U3 suspend disable quirk for silicon versions less than v4
Anurag Kumar Vulisha [Thu, 2 Mar 2017 09:10:50 +0000 (14:40 +0530)]
drivers: dwc3: Add U3 suspend disable quirk for silicon versions less than v4

The logic for updating dwc->revision flag got corrected in 4.9 kernel,
which sets USB3PIPECTL.SUSPENDENABLE bit for dwc3 core versions >= 2.90A.
Because of this bit being set we are seeing failure while configuring
endpoints and below error is seen

"Failure to configure ep0out"

When this bit is set the control enables autosuspended of phy. As a part
of this feature controller automatically disables the phy clocking when
it is idle. This issue is observed with silicon revisions < 4.0.

This patch adds "snps,dis_u3_susphy_quirk" into platform node if silicon
revision is found to be less than 4.0

This patch is based on the fix provided in "85e618a1be2b2092318178d1d66b"

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: host: Assign dwc3 dev archdata to xhci dev
Manish Narani [Tue, 7 Feb 2017 20:01:42 +0000 (01:31 +0530)]
usb: dwc3: host: Assign dwc3 dev archdata to xhci dev

Assign dwc3 archdata to xhci dev to avoid empty dma ops for xhci
in 4.9 kernel which causes dwc3 host failure.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: host: add support for OTG in DWC3 host driver
Manish Narani [Fri, 27 Jan 2017 10:06:12 +0000 (15:36 +0530)]
usb: dwc3: host: add support for OTG in DWC3 host driver

This patch adds support for OTG host mode initialization in DWC3
host driver. Before the host initialization sequence begins. The
driver has to make sure the no OTG peripheral mode is enabled.

This sequence is executed before the OTG driver actually senses
the ID and takes up the respective role (A or B device).

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: gadget: add support for OTG in gadget framework
Manish Narani [Fri, 27 Jan 2017 10:06:09 +0000 (15:36 +0530)]
usb: dwc3: gadget: add support for OTG in gadget framework

This patch adds support for OTG in DWC3 gadget framework. This
also adds support for HNP polling by host while in OTG mode.

Modifications in couple of functions to make it in sync with
OTG driver while keeping its original functionality intact.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: dwc3: of-simple: Add missing platform_set_drvdata
Filip Drazic [Fri, 10 Jun 2016 14:53:53 +0000 (16:53 +0200)]
usb: dwc3: of-simple: Add missing platform_set_drvdata

Device driver data is accessed in driver's remove method.
This fixes the following error when trying to unbind device from
this driver:

Unable to handle kernel NULL pointer dereference at virtual address 00000010

Signed-off-by: Filip Drazic <filip.drazic@aggios.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: support to set maxburst through configfs
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:16 +0000 (04:54 -0400)]
usb: gadget: f_tcm: support to set maxburst through configfs

support to change maxbust of endpoint through configfs is added

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: add TARGET_SCF_ACK_KREF flag in BOT
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:15 +0000 (04:54 -0400)]
usb: gadget: f_tcm: add TARGET_SCF_ACK_KREF flag in BOT

in BOT mode se_cmd and I/O resource getting free during target
fabric module operation check_stop_free which does not gauranteed
freeing of resource after actual usb bus transfer. adding
TARGET_SCF_ACK_KREF flag during submitting target request will
increment additinal cmd_kref which will prevent deallocating
se_cmd and I/O resource before actual usb bus transfer.

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: queue multiple commands request
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:14 +0000 (04:54 -0400)]
usb: gadget: f_tcm: queue multiple commands request

increase in performance can be achived by queueing multiple command
request during super speed uas mode. this will make a best use of
uas and stream support.

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: comp_descriptor workaround during SS gadget
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:13 +0000 (04:54 -0400)]
usb: gadget: f_tcm: comp_descriptor workaround during SS gadget

If device connect in SS then comp_descriptor with stream
should be atteched to descriptor. Since BOT and UAS using
same endpoint, config_ep_by_speed will returns first match
with comp_descriptor without stream. This is just workaround
proper fix need to be introduced.

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: adjust write length with max packet size
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:12 +0000 (04:54 -0400)]
usb: gadget: f_tcm: adjust write length with max packet size

transfer size on out endpoint should be in multiple of endpoint
max packet size. this patch will adjust transfer size on out endpint
with multiple of max packet size

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: f_tcm: remove code duplication
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:11 +0000 (04:54 -0400)]
usb: gadget: f_tcm: remove code duplication

function bot_send_write_request() prepares write request and will call
usbg_prepare_w_request() function which does the same

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agouas: Add US_FL_NO_ATA_1X for linux tcm_usb_gadget
Rajnikant Bhojani [Fri, 11 Aug 2017 08:54:24 +0000 (04:54 -0400)]
uas: Add US_FL_NO_ATA_1X for linux tcm_usb_gadget

tcm_usb_gadget available in linux kernel need US_FL_NO_ATA_1X quirk

Signed-off-by: Rajnikant Bhojani <rajnikant.bhojani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: uas: Add workaround for DATA IN urb's returned with status -EAGAIN
Anurag Kumar Vulisha [Fri, 30 Jun 2017 10:28:10 +0000 (15:58 +0530)]
usb: uas: Add workaround for DATA IN urb's returned with status -EAGAIN

dwc3 host controller has a bug where it fails to start processing
of TRB's present in DATA IN stream ring, because of this issue no
transfer events are generated for that stream ring and resulting
in a hang condition.
As a workaround for this issue, a timer is started for DATA IN
stream ring, which gets expired when host fails to process trbs
present in the stream ring. In that timeout handler, the urb on
which the issue occurred is stopped with urb->status set to -EAGAIN.
In UAS driver,uas_workaround() is called if urb->status == -EAGAIN.
As a part of error recovery sequence, uas_workaround() re-submits
the previous stopped URB and prepare & submit dummy sense, data in
and cmnd urb with command set to scsi standard inquiry command having
next available stream id tag. Once the trbs for the submitted urbs are
added to steam ring XHCI controller will start processing the trbs of
the re-submitted urb along with the trbs of dummy inquiry urb.

These below gives the overview of the ISSUE and workaround

ISSUE:
1. UAS submit DATA IN URB
2. XHCI fails to process trbs associated with URB
3. As a result no events are generated by host controller
4. Hang condition occur

WORKAROUND
1. UAS submit DATA IN URB
2. XHCI driver starts timer
3. XHCI fails to process trbs associated with URB
4. As a result no events generated
5. Timer timedout and timer handler gets triggered
5. XHCI driver sends urb back with status = -EAGAIN
6. UAS driver re-submits stopped URB on seeing -EAGAIN
7. UAS driver submits sense, data in & cmnd urb with scsi cmnd = inquiry
8. XHCI starts processing previous stopped URB along with inquiry cmnd urb

This patch adds the above said workaround.

NOTE: As we have already added support for usb Host streaming, this fix is
required to fix the issue that occur when UAS capable device is connected.
This fix is expected to change after the HW team comes with an alternate
workaround for this issue.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: xhci: Add workaround for fixing ep stream ring hang issue
Anurag Kumar Vulisha [Fri, 30 Jun 2017 10:28:08 +0000 (15:58 +0530)]
usb: xhci: Add workaround for fixing ep stream ring hang issue

Dwc3 host controller has an issue with BULK IN stream rings where
it stops processing the TD's present in the endpoint stream ring
(once in a while) even after ringing the stream DoorBell register.
Since host controller doesn't process TD's in stream ring, no transfer
events are generated by the controller, resulting in a hang issue.

This patch solves the above said problem by adding a timeout handler for
every BULK IN stream ring. After timer expires, timeout handler will be
called and from that stop command on the same endpoint stream ring will
be issued and urb will be given back with urb->status set to -EAGAIN.
The UAS driver checks the urb status as -EAGAIN and re-submit the same
urb which was timedout.

NOTE: As we have already added support for usb Host streaming, this fix is
required to fix the hang issue that occurs when UAS capable device is
connected. This fix is expected to change after the HW team comes with an
alternate workaround for this issue.

Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: xhci: Set XHCI Light Reset for DWC3_OTG mode
Manish Narani [Thu, 23 Mar 2017 10:26:13 +0000 (15:56 +0530)]
usb: xhci: Set XHCI Light Reset for DWC3_OTG mode

This Patch corrects the XHCI reset for OTG mode. The host cannot
have Hard Reset while in OTG mode because that will affect the
OTG peripheral mode event buffers and it will not function.

The macro for OTG is USB_DWC3_OTG not USB_DWC3_DUAL_ROLE. This patch
corrects the same.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: host: xhci: add support for Light Reset for DWC3 DRD
Manish Narani [Fri, 27 Jan 2017 10:06:14 +0000 (15:36 +0530)]
usb: host: xhci: add support for Light Reset for DWC3 DRD

This patch adds support for Light Reset in Host Driver when
the core is in DRD mode.

There is a requirement of LRESET instead of RESET (Hard) in DWC3
controller when it is switching to the peripheral mode.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: host: xhci: plat: add support for otg_set_host() call
Manish Narani [Fri, 27 Jan 2017 10:06:13 +0000 (15:36 +0530)]
usb: host: xhci: plat: add support for otg_set_host() call

This patch will add support for OTG host initialization. This will
help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: host: ehci-xilinx: Resolve kernel-doc Warnings
Manish Narani [Wed, 26 Apr 2017 08:08:05 +0000 (13:38 +0530)]
usb: host: ehci-xilinx: Resolve kernel-doc Warnings

This patch resolves kernel-doc warnings for Xilinx EHCI driver.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: host: ehci-xilinx: modified driver to resolve formatting warnings
Manish Narani [Wed, 26 Apr 2017 08:08:04 +0000 (13:38 +0530)]
usb: host: ehci-xilinx: modified driver to resolve formatting warnings

This patch resolves checkpatch warnings for xilinx EHCI driver.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: udc-xilinx: Resolve kernel-doc warnings
Manish Narani [Wed, 26 Apr 2017 08:08:06 +0000 (13:38 +0530)]
usb: gadget: udc-xilinx: Resolve kernel-doc warnings

This patch resolves kernel-doc warnings for Xilinx UDC driver.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: udc: udc-xilinx: Resolve compilation warnings
Manish Narani [Thu, 25 May 2017 10:10:34 +0000 (15:40 +0530)]
usb: gadget: udc: udc-xilinx: Resolve compilation warnings

This patch resolves sparse warnings in udc-xilinx.c.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: gadget: udc: udc-xilinx: Add identifier to read_fn function arg
Manish Narani [Wed, 26 Apr 2017 08:08:03 +0000 (13:38 +0530)]
usb: gadget: udc: udc-xilinx: Add identifier to read_fn function arg

This patch adds identifier in the read_fn function declaration.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agousb: phy: Add platform driver support for ULPI phys
Subbaraya Sundeep Bhatta [Mon, 21 Sep 2015 08:18:02 +0000 (13:48 +0530)]
usb: phy: Add platform driver support for ULPI phys

Modified to add platform driver support to ULPI phys.

Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodt-bindings: remoteproc: zynqmp-r5: correct dts example
Wendy Liang [Fri, 29 Mar 2019 16:45:29 +0000 (09:45 -0700)]
dt-bindings: remoteproc: zynqmp-r5: correct dts example

* Correct ZynqMP r5 remoteproc device node example bindings to
remove the old sram, power domain nodes, and add new reserved memory
nodes.
* Fix the remoteproc device node compatible string to match the driver
* Use the mailbox to match the OpenAMP usecase

Signed-off-by: Wendy Liang <wendy.liang@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agonet: xilinx: axiethernet: Fix crash in ifconfig down
Radhey Shyam Pandey [Fri, 29 Mar 2019 12:07:41 +0000 (17:37 +0530)]
net: xilinx: axiethernet: Fix crash in ifconfig down

In axidma(allow un-aligned transfers) designs, axienet_dma_q structure
tx_bufs pointer is not explicitly initialized to NULL so freeing it in
.ndo_stop may result in a kernel crash. To fix it allocate axienet_dma_q
structure memory using kzalloc. This fixes below crash in vcu118 design.

root@xilinx-vcu118-2019_1:~# ifconfig eth0 down
Oops: kernel access of bad area, sig: 11
CPU: 0 PID: 390 Comm: ifconfig Not tainted 4.19.0 #47
 Registers dump: mode=AEBEBBD0
 r1=00000001, r2=00000000, r3=00000694, r4=00000000
 r5=C05A1000, r6=00400000, r7=5A5A5A5A, r8=5A5A5A5A
 r9=00000000, r10=C05BE118, r11=00000000, r12=00000040
 r13=00000000, r14=C008F920, r15=C030A178, r16=00000000
 r17=C0006A88, r18=FFFFFFCF, r19=5A5A5A5A, r20=48296FF4
 r21=48115B20, r22=5A9A5A5A, r23=EE84120C, r24=EE84120C
 r25=00000001, r26=00000000, r27=EE9B8900, r28=EEB11000
 r29=00000000, r30=00000001, r31=EEB7F800, rPC=C0006A88
 msr=800046A6, ear=00000694, esr=000008B2, fsr=00000000
Segmentation fault

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Acked-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agogpio: zynq: Disable the irq if it is not a wakeup source
Shubhrajyoti Datta [Fri, 29 Mar 2019 06:34:46 +0000 (12:04 +0530)]
gpio: zynq: Disable the irq if it is not a wakeup source

If gpio is not set to wake disable the interrupt. ATF set all slaves with
enabled interrupts as wakeup sources and if gpio is used in r5 then it
wakes up linux.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agonet: can: xilinx_can: Fix the data updation logic for CANFD FD frames
Appana Durga Kedareswara rao [Sat, 30 Mar 2019 08:20:11 +0000 (13:50 +0530)]
net: can: xilinx_can: Fix the data updation logic for CANFD FD frames

commit fc8c67368936 ("net: can: xilinx_can: Add support for CANFD
 FD frames") is writing data to a wrong offset for FD frames.

This patch fixes this issue.

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Reviewed-by: Shubhrajyoti Datta <Shubhrajyoti.datta@xilinx.com>
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agonet: can: xilinx_can: Fix FSR register handling in the rx path
Appana Durga Kedareswara rao [Sat, 30 Mar 2019 08:20:10 +0000 (13:50 +0530)]
net: can: xilinx_can: Fix FSR register handling in the rx path

After commit fc8c67368936 ("net: can: xilinx_can: Add support for
 CANFD FD frames") driver is updating the FSR IRI index multiple
times(i.e in xcanfd_rx() and xcan_rx_fifo_get_next_frame()),
It should be updated once per rx packet this patch fixes this issue,
also this patch removes the unnecessary fsr register checks in
xcanfd_rx() API.

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Reviewed-by: Shubhrajyoti Datta <Shubhrajyoti.datta@xilinx.com>
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>