usb: dwc3-msm: Update USB power supply's 'type' property

USB power supply type represents type of charger connected e.g.
standard host PC i.e. USB, or wall-charger i.e. USB_DCP. Userspace
code might be interested in distinguishing between standard host PC
and DCP chargers. Hence, update the type accordingly whenever power
supply's type changes.

CRs-Fixed: 458183
Change-Id: I6045d020394eb4baba17244bf9c9d5be7bbb1de6
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
USB: dwc3-msm: Implement VOLTAGE_NOW property for usb power supply

Implement VOLTAGE_NOW property for power supply so that usb_in
value can be read at any time through this sysfs entry by
userspace.

To read usb_in value,
	cat /sys/class/power_supply/usb/voltage_now

CRs-Fixed: 599547
Change-Id: I106ce9219c7a04c2b7436221732a6fca0cc85245
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3: Fix compilation error when debugfs is disabled

The code does not compile with debugfs disabled. Fix this.

Change-Id: I19b784495b57e7fc0c57b455dd80a63b79177569
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
USB: dwc3: debugfs: Enable logging of control endpoint events by default

Enable logging of EP0 control events, which will be useful for analyzing
the USB issues like crash. Also add more required events wherever required.

Change-Id: I0fd3edfa2cd8711928cd480e99abbf8e6f907774
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3-msm: Enable async irq wakeup capability only if required

If driver is depending on PMIC for VBUS and ID events, then async
interrupt is not required to set wakeup capable during cable
disconnect or when dcp is connected. Otherwise this interrupt can be
fired before PMIC notification during system suspend and could mess up
run time pm counters. Hence enable async irq wakeup capability
during bus suspend and disable it during device resume.

CRs-Fixed: 634833
Change-Id: Ifea0150ee947823ba4f8183af911e150fde61f1f
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3: msm: Fix bug during STM enable/disable for QDSS

commit "I0fdc5d703b3fd445e83226534f07743461c96f4c:usb: dwc3-msm:
remove use of global context variable (DBM)" is required for adding
support multiple instances in dwc3-msm driver. This added an incorrect
condition check in the driver before reinitiating USB reconnection
for STM enable/disable. Due to this, QDSS doesn't work when STM tracing
is disabled and enabled. Hence Fix this issue by using proper check.

CRs-Fixed: 523344
Change-Id: I6302396c7bf03cd2313e5d571e0aef51648a2258
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3_msm: Disable all events before error recovery for Erratic event

Currently as part of Erratic event handling, dumping all relevant registers
and then scheduling work for block reset. This does lead to erratic event
getting fired continuously and might result in watchdog crash. Hence
disable all events in DEVTEN regiser before doing block reset and reenable
the events once block reset is completed.

Change-Id: Ib2644ea8471cb87792a9524dc5103b61b2d0a74c
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3-msm: Fix USB connection issue after DCP charger disconnection

Commit "6e3630b5f28c60c403af8c6b3c87679d3d98d6af: usb: dwc3-msm: Support
external charging detection " has added check not to start charger
detection in case charger detection is done by external circuit. when otg
driver calls charger_detection API to set charger type to invalid as part
of VBUS disconnect handling, this check prevents to do that. This results
next charger detection not happening after DCP charger disconnection.
Hence fix the issue by moving down the check in the charger_detection API.

Change-Id: I5c614a208f22e4cd9f334c80dae6831bcff64ada
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: dwc3: gadget: Add support for sending zero length packets

Currently driver is not honouring req->zero flag even though
function driver sets this flag. If device has to send IN data back
to host and length is multiple of endpoint maximum packet size, it
should send additional zero length packet at the end to terminate
transfer.

CRs-Fixed: 592504
Change-Id: I5a8aecc504098ed386a9a9d19f4f5b78c911a376
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
usb: gadget: Fix synchronization issue between f_audio_source

Race is happening when both audio_pcm_close() and audio_send()
executes in parallel.
When the PCM session is closed, the substream attribute of the
audio_dev structure is set to NULL in audio_pcm_close().
As there is no synchronization protection for the audio_dev subtream
attributes in audio_send(), it is causing NULL pointer dereference.
Hence fixing the issue by adding proper synchronization protection
for the audio_dev subtream attributes in audio_send().

CRs-Fixed: 613498
Change-Id: Id9ab0d4e347b8bb2f551f9033829e541bdcaf0e8
Signed-off-by: ChandanaKishori Chiluveru <cchilu@codeaurora.org>
USB: gadget: f_mtp: Fix bug in receive_file work

If cable is disconnected while receive_file work is in progress,
there is a case where mtp driver returns -ECANCELLED instead of
-EIO. This results in mtp server thread not getting disconnect
notification and mtp release will not be called. Due to this, mtp
server will not start mtp connection after next USB connection.

CRs-Fixed: 590055
Change-Id: I909bebe0d22c19329cebb0a4a76424e08c82328c
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
CLEAN unused dwc-usb3-msm-tx-fifo-size & dwc-usb3-msm-qdss-tx-fifo-size
USB: dwc3: Allocate 3KB FIFO for bulk and isochronous endpoints

Currently dwc3 driver will allocate fifo size of maximum endpoint
packet size for TX endpoints depending on operating speed. Due
to this, double buffering may not work for TX endpoints in both high
speed and superspeed. Hence implement policy that allocates 3KB of
fifo for all bulk and isochronous endpoints irrespective of speed.

Policy is to allocate 3KB for bulk and isochronous endpoints and
allocate maximum packet size for control and interrupt endpoints.
This policy will improve the TX throughput numbers for function
drivers like MTP, mass storage. But side effect is we can't accomodate
more than nine bulk + isochronous endpoints in non QDSS composition
and five bulk + isochronous endpoints in QDSS composition. Otherwise
last interfaces in the USB composition will not work.

CRs-Fixed: 532070
Change-Id: I5e947f21f25fada7829c84eba45980295497cfbc
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
usb: gadget: qdss: Fix usage on non-DWC3 controllers

The QDSS function needs to call into controller-specific
routines to adjust parameters such as FIFO size and endpoint
configuration, but currently this only needs to be when using
the DWC3 controller. Previously this was handled by calling
stub functions if CONFIG_USB_DWC3_MSM is not defined. However,
this breaks targets that have it defined and compiled but do
not use the DWC3 controller as the primary gadget, as it
results in calling the routines of an uninstantiated driver.

Fix this by guarding the DWC3 calls by first checking
if (gadget_is_dwc3(gadget)).

Change-Id: I8fe045410bbb5dbe11cf4c14d06e6fba9351dd1b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
USB: dwc3: Fix QDSS data integrity issue

Currently RAM12, RAM13 are being used for data fifo and
descriptor fifo allocations in QDSS BAM <-> BAM usecase. Remaining
16KB out of 29KB is being used for allocation of TX FIFO for
USB IN endpoints in the composition. This resulting in data corruption
when captured with host side application. Due to this, QTF host
application is not able to parse the data collected over USB.
Hence reserve RAM11, RAM12, RAM13 for 16KB data fifo allocation and
5KB descritor fifo allocation in QDSS mode and use remaining 8KB for
TX FIFO allocation for IN endpoints.

As available tx fifo size is reduced in QDSS mode, allocate 1KB for
bulk and isochronous endpoints in highspeed mode and also for nonburst
endpoints in superspeed mode. For burst endpoint in superspeed mode,
allocate 3KB for TX FIFO.

CRs-Fixed: 553147
Change-Id: I6d50d2da631a95a921c47bb1fb1139477840a73c
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
ARM: dts: msm: Increase the drive strength for MSM8610v2

At lower 10mA random CRC errors are seen. With 12mA drive
strength for clock lines the issue is not seen

CRs-Fixed: 601882
Change-Id: If2b3246c78a2d73acdedb76da964badb0e133bdd
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
ARM: dts: msm: Add clk-ctrl-xfer flag to control clocks

Add support for configuration of clock
control event. Now the clock's state may
be set by power management suspend/resume
calls (as before) or by a transfer's begining
and ending.

CRs-Fixed: 592435
Change-Id: I68db02798cb06b74ea7c89dfae74e8a03b9cf722
Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org>
Clean Dual define.
patch-3.4.96-97 using patch -p1 <
Kernel 5.8