Add additional event buffers for GSI based hardware accelerated
endpoints and its related configuration.
CRs-Fixed: 1003784
Change-Id: Ibedf73690040b8bd872f5621835680a66c22e265
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
It is possible that the extcon notifier may be triggered
soon after it is registered, but before the mdwc->dwc3
has been populated. This leads to a NULL pointer dereference
in vbus_notifier. Fix this by moving the extcon_register()
call later in the probe until when the the driver would be
ready to handle an immediate notification.
CRs-Fixed: 1003908
Change-Id: I403da246f18c25a77fa7f66e152cbcdca8c00b16
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Wehn adbd is closing eps, it is trying to unregister gadget and UDC.
When VBUS is not present and cotroller is into low power mode.
ffs_func_disable() also invokes controller's PM idle as well. This
results into unclock register access when dwc3_gadget_stop() is
called by unregister_gadget_item(). Fix this issue by resuming
controller from dwc3_gadget_stop().
Change-Id: I469e8609bf23bee97b3f9c612401aaf92bc72a30
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
In some cases it is useful to manually force the controller
into peripheral, host or disconnect mode. Add a device
attribute to sysfs to do this. Reading it back will indicate
the current mode.
Change-Id: I77d9d2a127a2a763b93b968f1d8ccf68a649493e
Signed-off-by: Jack Pham <jackp@codeaurora.org>
If cable is disconnected early during composition switch
android_disable calls the gadget pullup op which on clearing
run/stop bit does a pm_runtime_put_noidle on the dwc3 device.
This decrements the power usage count on the dwc3 device, but the
child count of the parent mdwc3 device is not decremented.
Upon disconnect handling in the DWC3 state machine,
pm_runtime_put_sync on mdwc3 parent returns EBUSY due to child count
not being 0. As a result runtime idle does not kick in and
prevents low power mode handler being invoked.
Fix this by changing the pm_runtime_put_noidle call to
pm_runtime_put_autosuspend on dwc3 device so that the child
count for the mdwc3 parent is decremented to 0.
CRs-Fixed: 980113
Change-Id: Ibb19188c4230a08bbdef72af7de066735e8c2d67
Signed-off-by: Devdutt Patnaik <dpatnaik@codeaurora.org>
TRB Pool is allocated and de-allocated per endpoint when USB endpoint
is enabled and disabled respectively. In some instance, it has been
observed that usb_ep_disable() (for rmnet case, (u_bam.c) it is called
from set_alt or resume context i.e. interrupt context) and usb_ep_queue()
(for rmnet case, (u_bam.c) it is called from work queue context) are
racing for USB endless endpoint when USB bus suspend and resume is
happening quickly. It is causing NULL pointer dereference while accessing
TRB pool. Fix this issue by moving check if USB endpoint is enable or not
after acquiring dwc3->lock and before calling __dwc3_msm_ep_queue() which
prepares endless TRB.
CRs-Fixed: 986071
Change-Id: I842f6a82f3c454111ba68661cf835e86022e3e18
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Skip check for U3 link state when we receive Function Suspend.
Link is not in U3 when host sends Function Suspend, but will
be in U3 if/when the subsequent Bus Suspend arrives.
If we check for U3 in the case of Function Suspend, we will
not disconnect channels with IPA as the API that checks
pre-conditions for suspend will always return FALSE.
The U3 check is done as usual in the case of Bus Suspend from
the host.
CRs-Fixed: 966352
Change-Id: Ie9ee045a096b58256d2e8814338ffe0aa3c01163
Signed-off-by: Devdutt Patnaik <dpatnaik@codeaurora.org>
Currently MPM pin for DP line state change is not mapped to irq.
Only MPM for DM line state chagne is mapped to hs_phy irq. But this
results in delayed device detection in VDDmin when HS/FS devices
are connected in host mode. Hence enable power event irq during
host bus suspend so that MPM pin for DP line state can be also
mapped for early detection of HS/FS devices during VDDmin.
CRs-Fixed: 972212
Change-Id: I71d7c3c374a23b51a0489cf44410d76d5734d009
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
In commit 48924e2fe107 ("dwc3: Reset USB controller/PHY after psy
connect indication at bootup") the controller initialization path
was removed from dwc3_msm_probe() and is deferred to when actually
needed, which is when beginning peripheral or host mode. This was
to optimize for the HVDCP charger already-connected case in which
case we want to avoid performing controller initialization which
can disrupt D+/D- linestate.
As part of that change, the OTG_STATE_UNDEFINED state was made
to be the entry point for starting controller initialization.
However, apart from that, the handling is identical to B_IDLE_STATE,
and therefore could be consolidated. And now that charger driver
only notifies us when SDP or CDP types, but not when DCP/HVDCP are
connected, the code can be simplified by removing the duplicate code
between dwc3_initialize() and dwc3_msm_resume().
Change-Id: Ife749c864284864098bcbcbdbda096d05397c60e
Signed-off-by: Jack Pham <jackp@codeaurora.org>
dwc3_init_sm() uses a static boolean variable which does not
play nicely when multiple instances are in use. For instance
if one controller is configured in host-only mode, it would
set the sm_initialized flag and can force the second controller
to also see ID=0 and enter host mode even if it is a peripheral.
The false ID=0 is actually caused by the init sequence never
actually setting the initial inputs bit, so the state machine
simply sees it as unset and proceeds to the A_IDLE case. Fix this
by setting it to 1 to match the id_state=FLOAT during probe().
Furthermore, there is no longer any use case for the vbus_init
completion since the state machine should only be entered upon
event changes anyway. So removing that can allow us to get rid
of dwc3_init_sm() entirely. Also ensure that sm_work is
unconditionally flushed before processing the initial events.
CRs-Fixed: 974882
Change-Id: I48e361a622bffa62ab7fa4c8d2e6719e66b90076
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Now that we use extcon for USB and USB_HOST cable connection
notification, it is no longer required to provide the usb
power_supply object in order to receive set property
notifications. Going forward the usb_psy will be maintained
by the charger driver(s) instead.
Since supply type is now also hidden from this driver (i.e.
EXTCON_USB should only be emitted in the case of SDP or CDP)
handling of dedicated charger types can also be removed which
simplifies the code a bit.
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Add extcon listeners for EXTCON_USB and EXTCON_USB_HOST cable
types to be notified of VBUS and ID notifications respectively.
Upon notification this will start the controller in either
peripheral or host mode.
This replaces the handling previously done in the power_supply
set_property() callback for PROP_PRESENT and PROP_USB_OTG. The
usb_psy will be removed in its entirety following this patch.
Change-Id: I22405a0a8da21b4c373895500d8dc4c91d97bc51
Signed-off-by: Jack Pham <jackp@codeaurora.org>
commit 269a1b78 "usb: gadget: Add support for DMA mapping
optimization of request buffers" added checks to
usb_gadget_{map,unmap}_request() to support the pre-mapped
DMA buffers that a function can map ahead of time before
enqueing the request. However, these routines check the
req->dma for a sentinel value, DMA_ERROR_CODE, in order to
determine whether or not to proceed with dma_map/unmap().
This means that UDC drivers should initialize to this value
when allocating each new request. Do this in the dwc3
gadget driver in order to properly support this. This fixes
an issue in which usb_gadget_unmap_request() was incorrectly
being called on an uninitialized (as 0) req->dma address,
and proceeds to call dma_unmap() which interprets it as
physical address 0x0.
Change-Id: I514d2b824e272c6c42c483febaa1c4084b0d09ee
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This change removes DP DM pulsing functionality related support
from QUSB PHY driver as it is not required.
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
The previous timeout value was explained as being
based on trial and error. We saw a timeout
as high as 800[us]. In order to be on the safe-side,
the new timeout value is increased to allow such a
delay with room for error
Change-Id: I7bc953d9bd494b57dd5492b492d48b18994e6b8f
Signed-off-by: Dov Levenglick <dovl@codeaurora.org>
This reverts commit 55312d5442f147aa1a366e8ecb483b07e38961b3.
WARN_ON() is seen from dma mapping API while freeing TRBs on USB
cable disconnect (i.e usb endpoint disable context) due interrupts
are disabled.
Change-Id: Ib5689cbd5a379a8d1dc1a734026174779202386b
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Fix link errors when USB_GADGET=n which causes dwc3/gadget.c
not to be built. These symbols are only used in the msm_ep_config/
unconfig functions so we can conditionally compile them.
Signed-off-by: Jack Pham <jackp@codeaurora.org>
For host mode operation, the DWC3 driver instantiates an XHCI
device directly using platform_device_alloc()/_add() instead of
using typical device population methods (i.e. DT or ACPI).
In the latter cases, there is additional setup involved beyond
the allocation itself, not the least of which is DMA setup.
On ARM64 the recent commit 1dccb598df ("arm64: simplify
dma_get_ops") sets the default DMA operations to dummy ops. This
causes a regression as this directly created XHCI platform device
now fails probe when the call to dma_set_mask_and_coherent() is
unable to proceed due to dma_supported() returning false.
Since we know that the XHCI device is a child of DWC3 and hence
is also DMA-capable, fix this in the DWC3 host driver by simply
calling arch_setup_dma_ops() after allocating the platform_device.
Signed-off-by: Jack Pham <jackp@codeaurora.org>
In some of host machine reboot usecases, it has been found that
multiple suspend events are being received before usb device is
being enumerated with host including receiving suspend before
BUS RESET. This suspend event is being seen due to not host
initiated suspend but due to LINE state at that point and may
put USB Host and Device out of sync where host may not send any
more BUS RESET which would cause USB device enumeration as unknown
device with host machine. Fix this issue by honouring suspend
event only when USB enumeration speed is known.
CRs-Fixed: 717151
Change-Id: I201f106d1be71716eaa7a6246d2187889ea53a9c
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
This patch is a squash of several commits from msm-3.18 that
add support for dual-role switching (formerly known as "OTG")
to the DWC3 and XHCI platform drivers.
Based on the following commits:
usb: dwc3: Introduce OTG driver for dwc3
usb: dwc3-msm: Add support for LPM on cable disconnect
DWC3: Enable XHCI host in OTG mode
USB: dwc3: Add support for host bus suspend
usb: dwc3 / xhci_plat: Call xhci_suspend/resume when entering/exiting LPM
USB: dwc3: gadget: Implement gadget_vbus_draw() API
USB: gadget: dwc3: Fix composition switch issue during cable disconnect
usb: dwc3: notify gadget disconnect upon VBUS low
usb: dwc3: msm: Remove last of dwc3_otg
dwc3: Reset USB controller/PHY after psy connect indication at bootup
dwc3: Use otg_sm_work state machine for host and device only mode
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Composition switch to GSI transport based composition from
another GSI transport based composition requires power on
reset of USB controller to synchronize operation with USB
wrapper for GSI. Specifically GSI_EN bit cannot be
cleared without performing usb controller reset. Hence
introduce gadget restart operation to simulate vbus off
and vbus on and perform this operation from gsi bind
config.
Change-Id: Ie4695807c73c2d14c0d9e17c486f34a90fd93ddb
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
After the device remote wake up some USB hosts are driving bus
resume for longer than 3 seconds. As a result link state change does
not happen within 3 seconds and remote wake up fails. In worst case
it is observed that usb host is driving bus resume for 8 seconds.
Hence increase the timeout value to 16 seconds.
CRs-Fixed: 803183
Change-Id: I1cbb29ccd2b4e264c032d7237efcfd87cef71942
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
If remote wakeup request is received during system resume where
resume_early is still processing, pm_runtime_get_sync returns -EACCES error
as pm_runtime framework is disabled between late_suspend and early_resume.
Due to failure of this API controller did not exit LPM. This leads to
unclocked access of registers as part of remote wakeup processing causing
target to crash.
Fix this by checking for return value of pm_runtime_get_sync, and queuing
dwc3_gadget_wakeup_work again with intermediate delay of 100ms for maximum
of 20 times.
Change-Id: I8e2215ef9ee708e86356622e85fd2f23a18f7944
Signed-off-by: Tarun Gupta <tarung@codeaurora.org>
In case of remote wakeup interrupt, dwc3_gadget_wakeup_work()
does a pm_runtime_get_sync() and dwc3_gadget_wakeup_interrupt()
does not notify OTG state machine about this state change.
Due to which OTG will be still in B_SUSPEND state.
Now when bus suspend happens, since OTG state machine is already in
B_SUSPEND state, it does not do a pm_runtime_put_autosuspend() and the
count is not decremented.
To fix, this do an unconditional pm_runtime_get_sync() and
pm_runtime_put_noidle() in dwc3_gadget_wakeup_work() to avoid any
unclocked register access. In dwc3_gadget_wakeup_interrupt() kick in
SM machine in all cases and handle the remote wakeup same as host
initiated resume, by clearing the B_SUSPEND bit so that OTG state machine
moves to B_PERIPHERAL state.
CRs-fixed: 829205
Change-Id: I270df517d5dd58fe28bf0087e0ba951c4e9e15ba
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
Moving into U0 state is being confirmed by polling for 100ms after
performing remote wakeup from device. In some of cases where host is
taking more time to respond, remote wakeup is failing. Also USB
specification does not define any limit for the host response time.
Hence this change replaces polling mechnism by using LINK status
change event notification with core and increase host response time
from 100ms to 3 seconds. It also makes sure that composite_resume()
is being called after remote wakeup is completed succesfully.
It removes some of flag used to avoid race between bus suspend/resume
and fuction suspend/resume as those are serialize and not required
anymore.
CRs-Fixed: 712681
Change-Id: I71285daf117282c738e139e9a05ead6ef16dd202
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Events may get generated for Link Power Management L1
Suspend and Resume. The suspend case currently ignores
L1 and only proceeds to call the gadget driver suspend
routines if it is for L2/U3 entry. However, the resume
callback doesn't make this distinction, which will
result in the gadget layer resume getting called for
which there had not been a previous suspend.
Instead of relying on reading the DWC3_DSTS register for
U0 and U3 state, update dwc->link_state directly on receiving
reset/wakeup and suspend/disconnect interrupts respectively.
Change-Id: Ifaa71d2e85bd797154f368e7623bc8ff94b6a727
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
[jackp@codeaurora.org: Squashed with "usb: dwc3: gadget: Update
link_state based on receiving interrupt" and "dwc3: gadget: Update
link_state flag on receiving wakeup_interrupt" ]
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Add a DT property that decides whether to allow controller
low power mode upon bus suspend, which will be invoked by
the OTG state machine.
It is also required to take the core out of LPM in case
ep_queue is called by the upper layers. In this case,
remote wakeup sequence will be initiated once the core
is out of LPM.
[jackp@codeaurora.org: Squashed with dwc3 changes from
"usb: dwc3: Add new OTG state OTG_STATE_B_SUSPENDED"]
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Upstream commit 636e2a2cae
(usb: dwc3: gadget: drop dwc3 manual phy control) removed the
support to suspend the PHYs since the recent controller versions
can do that automatically.
But MSM targets, still do not have the latest controller and hence
adding back the functionality to suspend/resume SS phy.
Change-Id: I02a7ae8daf194a645f3582480f5a6b7d504b32ec
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Targets supporting h/w accelerated path over GSI require
GSI specific configuration of USB controller.
Add support to enable h/w accelerated path to IPA.
Include operations to configure USB endpoints as
GSI capable, allocate TRBs that are associated with
GSI capable endpoints, perform operations on these
endpoints, and enable the GSI wrapper in DWC3 controller.
This allows a function driver to use GSI based h/w
accelerated data path.
Change-Id: I62688c70a04b1fdab3e522e0af759ebab69d92d7
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
commit a0c760181ca874 ("usb: dwc3: Reset the transfer resource index
on SET_INTERFACE") was resetting the start_config_issued flag on
receiving SetInterface request. But in cases where transfer resource
index is shared between two endpoints and if both are trying to do a
transfer then transfer on one of the endpoints will fail, since the
transfer resource index will be acquired by the first endpoint
and when the second endpoint tries to get the same transfer resource
index, it will fail and hence STARTTRANSFER command also fails on second
endpoint.
Reverting this change ensures endpoints get allocated with unique
transfer resource index.
CRs-fixed: 953585
Change-Id: I7800356e455900cc39b9463366275c68db777199
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
Move interrupt handling from threaded IRQ context to a tasklet.
This may help in reducing latencies associated with starvation
caused by high priority softirq over threaded USB IRQ.
Change-Id: I2f988be9c484a6ee59236d9dfd7f06f07414ee96
Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
Commit 5ad02fb813 ("usb: dwc3: gadget: move isoc endpoint check
to unlocked set_halt") moved usb isochronous endpoint check form
dwc3_gadget_ep_set_halt() to __dwc3_gadget_ep_set_halt().
dwc3_gadget_ep_set_halt() API is being called explicitly by USB
function driver to stalls USB endpoints whereas
__dwc3_gadget_ep_set_halt() API is also being called to stall ep0
on receiving invalid setup packet or not able to queue response
to setup packet. It is not supposed to have any descriptors with
ep0 early stage of enumeration process. Hence revert change which
makes sure to check usb endpoint type against isochronous before
halting endpoint with dwc3_gadget_ep_set_halt() instead of
__dwc3_gadget_ep_set_halt().
Change-Id: I24b3e78613bf89340c812e353dafaf384ac4a057
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Currently there exists a race condition between dwc3_gadget_run_stop()
and dwc3 gadget interrupt handling. run_stop() could get cleared and set
again in between hard IRQ and threaded IRQ contexts, the DWC3_GEVNTCOUNT
could first get set to 0, and then written again in the threaded handler
with a non-zero value. Writing back to this register will cause hardware
to decrement the value, and since it is 0 will result in a high unsigned
value (~65k).
To handle this condition mark received events as processed and return
IRQ_HANDLED if events count is bigger than event buffer size. Note that
the root cause of this condition will be addressed in another patch that
prevents the race by synchronizing the hard and threaded interrupt handlers
with dwc3_gadget_run_stop() getting called asynchronously.
Change-Id: I4d6ade8243867885f26876a5233a8456a7e8bf42
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
In dwc3_gadget_run_stop() when clearing the run/stop bit, ensure
that IRQs are masked and the ep0 in and out endpoints are disabled.
In case pullups are removed while a control transfer is in progress,
this makes sure that the control endpoints are properly cleaned up.
If and when run/stop is set again, the function already re-enables
the IRQ and ep0 when calling dwc3_gadget_restart(). While at it,
memset() the event buffers to clear stale contents when
reinitializing them in dwc3_event_buffers_setup().
Also, since calling dwc3_gadget_disable_irq() only masks the
interrupts at the controller layer, it might not catch instances
where an IRQ itself may have already been asserted but does not
arrive at the handler until after the pullups are removed. Add a
check to dwc3_interrupt() to catch this case as well.
Change-Id: Ie58979fe4b229240231760652189338ec5343a2d
Signed-off-by: Jack Pham <jackp@codeaurora.org>
In some of cases when ep0 operations are fails, WARN_ON is called from
interrupt context. This may lead to watchdog bark if repeated WARN_ON
condition occurs. Hence replace usage of WARN_ON() by WARN_ON_ONCE() and
logging errror as part of debug buffer.
CRs-Fixed: 907077
Change-Id: I40de055b1e8d610c43c7fff32cd904c43b9bec00
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Currently gadget driver is by default allocating dma TRB
pool per endpoint for 30 endpoints upon driver probe.
Optimize this by allocating dma memory only for enabled
endpoints.
Change-Id: I378a42d0b84fa43f7c20cd025cd9361c467cb41b
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Commit d8a39efaa477 ("dwc3: gadget: Improve TX FIFO resize functionality")
is considering USB enumerated speed to allocate TX FIFO size for each IN
endpoints. This change simplifies this by using 1024 bytes as default
TXFIFO size with each IN endpoints.
Change-Id: I55b5886c824d9b689ac8496f50f6e0e784afae98
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
HWO bit signifies that TRB is still pending with hardware. Hence
avoid processing of TRB if HWO bit is set.
Change-Id: I6d4068eb9e6934f68e7b6204cac8f6f3266dabf4
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Commit 5da9347825 ("usb: dwc3: decrease event buffer size") has
decreased controller's event buffer size to 256 bytes which results
into multiple overflow events. Receiving of overflow events suggests
that software is not able to process received events fast enough
which results into losing of those events. Fix this issue by
increasing event buffer size to 8KB.
Change-Id: I37f6203f0b6d87098d57b2ce0ba8a3a0b8ef5bd2
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
This change considers USB device speed to set max_packet size
instead of provided max_packet value from USB function driver.
It doesn't resize ep0IN TxFIFO, and starts with ep1IN TxFIFO only.
Change-Id: Ifce63f5a8570f79bad1e5d3ae6f5d580c34046b5
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
dma_coherent_alloc() API doesn't guaranteed that allocated memory
is initialized with zero. It is observed in some cases where there
is stale data seen with allocated memory for TRB pool and providing
this TRB with USB controller results into different memory access
issues. Fix this issue by using dma_zalloc_coherent() API which
allocates memory and initialized it with zero.
Change-Id: I160e319aace262958a11ba5196f53ec21b98977f
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Starting with synopsis version 220A the command to wake up the
host changed from 0x3 to 0x7. The code is fixed accordingly.
The problem that was seen is that upon MBIM function
suspend, a remote wakeup from the IPA side wouldn't
wake up the host, and at some point a stall in the IPA would be
seen.
CRs-fixed: 695414
Change-Id: I6ef5c649f263f388a1cc92a3db71c14c741b5b71
Signed-off-by: Lena Salman <esalman@codeaurora.org>
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
In case of host initiated usb bus resume upon system suspend controller
exits from LPM as part of dwc3 PM resume. Since call to dwc3 PM resume
from PM framework involves latency due to which usb device misses the
timeline of response for bus resume. This results into host issuing warm
reset. Hence bring controller out of LPM in power event irq thread context.
Set IRQF_EARLY_RESUME for power event irq which reduces irq level latency
by enabling this irq early during system resume. Also, save power event
irq time stamp to track latency between hard irq and irq thread.
CRs-Fixed: 804476
Change-Id: Ib5470c6046ffbfff55b89e717f040bd6435454da
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
For reboot usecase with some of host machine, it has been observed that
Suspend event is being received in between USB enumeration process which
is highly unlikely case. Although due to this event, device side USB goes
into suspend state which cause USB device enumerates as unknown device
with host machine. Fix this issue by ignoring suspend event until USB
enumeration process is not being completed i.e. device side USB is not
reach into CONFIGURED state.
Add check for CONFIGURED state with controller suspend routine as well
to make sure that if this routine finds controller into L2 state before
it performs LPM functionality, it confirms that state of USB as
CONFIGURED.
CRs-Fixed: 717151
Change-Id: I86925f22edf94c526a3b7504333501b6e27412d7
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Currently USB DWC3 controller's internal clock gating is disabled
unconditionally. In few platform, it is possible to enable internal
clock gating with controller. Hence this change adds support to
disable this functionality conditionally using "snps,disable-clk-gating"
device tree property. With this change USB controller's internal clock
gating is enabled by default.
CRs-Fixed: 851877
Change-Id: I17d43a23d3bff0cb516b952c35c4a13af53f7777
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
In few instances, dwc3_gadget_ep_set_halt() API is called after USB
endpoint is disabled which results into device crash with NULL pointer
dereference. USB endpoint's descriptors are set to NULL as part of USB
endpoint disable functionality. Hence fix this issue by adding NULL
pointer check against endpoint's descriptor.
CRs-Fixed: 829034
Change-Id: I2e1f67571ed202fab21655bd8f13fc54706419a7
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
The controller may sometimes generate back-to-back suspend
interrupt events. Ignore the repeated events to avoid calling
the gadget driver's suspend callback multiple times.
Change-Id: I284b461adeab5911388efd8bb7ecbf39a85c86ca
Signed-off-by: Jack Pham <jackp@codeaurora.org>
It may be useful to debug how much time is spent in the
DWC3 hard IRQ context. Add low-overhead statistics counters
which keep a histogram of the last 10 interrupts' time of
occurence, time spent, and number of events read (which will
get processed in the bottom half handler).
Change-Id: I466144d8141f4236b9fb834dded93225b56d0422
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Synopsys USB3 Controller (DWC3) has a restriction where size
of OUT requests (TRB) queued to the controller must be aligned
with the endpoint's max packet size. Hence, report error in case
function driver tries to queue an unaligned request.
Change-Id: Id5f4a0ff9d2f9c55bba936d683608c524eadd260
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>