USB: Debugfs: Fix compilation issues when debugfs is disabled

When we disable debugfs some of the function driver does not
handle those error properly so we see error of kind variable
undeclared, too many arguements to function. This fixes all
these obseved issue

CRs-fixed: 551713
Change-Id: I1b60c86b1c489f77edf86a5df44f8766a08dc117
Signed-off-by: Tarun Gupta <tarung@codeaurora.org>
USB: f_mass_storage: Send GADGET_DELAYED_STATUS for MSC RESET command

When Host sends MSC RESET command to the device, device is expected
to clear HALT condition on the bulk IN endpoint as part of handling it,
before sending status phase to the Host. Since handling of MSC RESET is
done by sending signal to fsg_thread, it could take time for handling it.
It could lead to sending bulk IN endpoint as halted, when host asks for
endpoint status as status phase is sent for MSC RESET command immediately
after it is recieved. Due to this, MSC compliance tests fail. Hence send
delayed status in case of MSC RESET and send status phase after it is
handled and cleared halt condition.

CRs-Fixed: 547929
Change-Id: If80d0ffb2d012724b899772b1b45dff8092bd8d5
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: gadget: qdss: Fix strncmp length usage

Using a newer GCC we get the following warnings:

drivers/usb/gadget/f_qdss.c: In function 'qdss_bind_config':
drivers/usb/gadget/f_qdss.c:598: warning: argument to 'sizeof' in
'strncmp' call is the same expression as the second source; did you mean
to provide an explicit length? [-Wsizeof-pointer-memaccess]

drivers/usb/gadget/f_qdss.c: In function 'usb_qdss_open':
drivers/usb/gadget/f_qdss.c:760: warning: argument to 'sizeof' in
'strncmp' call is the same expression as the second source; did you mean
to provide an explicit length? [-Wsizeof-pointer-memaccess]

These look to be due to using sizeof(ch->name) which is a pointer, use
a simple strcmp instead.

Change-Id: I09e09a18ffb3361fc351b177ed3a35432d9ed933
Signed-off-by: Kumar Gala <galak@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: gadget: rndis: Optimize tx path for better performance

Current rndis header addition and aggregation steps:
1. Increase skb headroom by size of rndis header.
2. Copy skb data with newly created skb having more headroom.
3. Create and add rndis header with it.
4. Again copy skb data with usb request buffer for aggregation purpose.

New optimized steps :
1. Create and copy rndis header directly with usb request buffer
2. Copy skb data with usb request buffer

Above new steps avoids cpu intensive skb operations which reduces CPU
usage and provide better throughput.

This change also assigns completion handle with usb request at the time
of usb request creation instead of assigning everytime before queueing
usb request.

CRs-Fixed: 551363
Change-Id: Ifc64d6a8573f6a24e28c73ef9a19b62649e171cd
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
USB: gadget: ether: Clean up req->buf to avoid wild pointer

When OOM, the req->buf will fail to get memory from kmalloc.
And all the req->buf in dev->tx_reqs will be freed in the
error handler. But they are not cleared to NULL. So they are
not allocated while below function got called again.

int alloc_tx_buffer(struct eth_dev *dev)
{
   list_for_each(act, &dev->tx_reqs) {
       if ((!req->buf)         ->3. it can't allocate again.
          req->buf = kmalloc();->1. it fails to get memory as OOM.
       if (!req->buf)
          goto free_buf;
        ...
   }
   return 0;
free_buf:
   ...
   kfree(req->buf);             ->2. It's freed.
   return -ENOMEM;
}
So these pointers will be freed multi times. What's worse,
once they are used as normally, system maybe be panic due to
wild pointer.
CRs-fixed: 571628
Change-Id: I96eb21553eb4840c02331d68056ea0eca9a25552
Signed-off-by: Figo Wang <figow@codeaurora.org>>
USB: android: Schedule work only if suspended variable is changed

currently as part of USB link status change event for U3 -> U0,
DWC3 controller driver is not calling driver resume. This results
in not updating suspended status in composite layer due to which
disconnect, configured and then disconnect events are sent to userspace.
This might cause problems for some userspace applications. Hence handle
USB link status event for resume by reverting the commit b217f5007d
("USB: dwc3: Don't handle USB/Link Status change event for RESUME").
Fix actual issue of disconnect sent during suspend/resume in android.c
by scheduling work only if the suspended status is changed to notify
userspace.

CRs-Fixed: 569639
Change-Id: If4fe6f3e8087d3bc972705ff40e4f94f597e2d09
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
USB: msm_otg: Add support for AHB2AHB Bypass Mode in device mode

With AHB2AHB Bypass Mode, USB 2.0 Core is running using PNOC clock
and runs synchronous to PNOC which provides better throughput.
AHB2AHB Bypass mode can be enable with USB controller using
USB_AHBMODE register. It has below requirement :
- It should be enable before setting kicking USB controller
(i.e. setting R/S bit).
- PNOC should be running at MAX speed to get better throughput.
- While doing asynchronous clock reset with USB core, it is required
to disable this functionality as PNOC clock can't be disable and
re-enable as it is performed with other USB core clock.

CRs-Fixed: 550553
Change-Id: I9feac91b8885a393a13a039e9c89d63d0af2aed6
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
USB: gadget: Add support to enable streaming mode with required function

Supported different usb functions' has different throughput requirement.
USB controller supports streaming mode feature which enables double
buffering scheme on both IN and OUT endpoint, and reduces number of
NAKs for IN transfer. Hence noticeble throughput is increased with it.
Currently streaming mode is disable with USB controller. As supported
usb functions'like mtp, rndis are required to have higher throughput.
Add support which allows to enable streaming mode with usb controller
in device mode when particular function based composition is being enabled.

CRs-Fixed: 550553
Change-Id: Ibf6f3dc3f3b821647ba9beb15ed735a85c8ed586
Signed-off-by: Mayank Rana <mrana@codeaurora.org>

Conflicts:
	include/linux/usb/android.h
usb: gadget: Fixing array index out of bound violation

In mass_storage_function_init(), current code has array size
allocated as 2. Maximum number of luns which can be supported
is 3 (for cdrom, external memory and internal memory). Array
name[0] is initialized to "lun" as by default it is required to
support minimum one lun for external memory.  For additional luns
support array index 1 and 2 is required to be used.

But with current code there would be array index out of bound
violation when name[2] is accessed. Hence fixing the issue by adding
correct size for the array to 3.

CRs-Fixed: 579049
Change-Id: Iad74a95205e503bf6a30dfac70b6ac1963df76a6
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>

Conflicts:
	drivers/usb/gadget/android.c
ASoC: msm8974: Add support for HFP

Add support for HFP for 8974 target.
Front end dai for HFP hostless for RX and MM6 for TX for HFP

Change-Id: I0406bd2b10c3daab4d583c690f27a9ba1d09af60
Signed-off-by: Vimal Puthanveed <vimalp@codeaurora.org>
ASoC: msm: Update the name for pcm platform driver.

Update the name of pcm platform driver to match with device tree
node.

Change-Id: I37063c7b6aa2a04b31f86754b24f9aa046d4c4a9
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: msm8974: Add voice2 dai-link

Add voice2 dai-link to enable DSDS on msm8974 platform.

CRs-fixed: 587066
Change-Id: Ia057890525e51f4ef0344b04ccabbb1f265d1dc3
Signed-off-by: Vicky Sehrawat <vickys@codeaurora.org>
ASoC: qdsp6: Add support for post processing on low latency path

Current implementation does not send audio calibration data to
DSP if the playback goes through low latency path. This results
poor quality audio on Speaker if it needs tuning.
Update ADM and RTAC drivers to send audio calibration data
to DSP and update properly in the QACT tool.

Change-Id: Ib4bf612ffd81b63a5e083cae7d7ded5b8239c582
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: qdsp6v2: Add support of ULL and LL

Add support for Low latency pcm and Ultra low latency pcm in
legacy pcm driver. A flag, part of device tree is used to
differentiate low latency and ultra low latency.
Only one ULL stream can be be connected to one ULL COPP.
LL stream can be connected to LL or regular COPP.

Change-Id: I2663ccdb641acc4117d1c0e424a57ed942e78f40
Signed-off-by: Krishnankutty Kolathappilly <kkolat@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: i2c: change  clock rate to 19.2 MHz

For standard  requirement, I2C source
speed of 50MHz causes high power usage, hence
this patch change the clock rate to 19.2 MHz
to save power.

CRs-Fixed: 552956
Change-Id: Ifb17fb79062a390a19881d247a2ac0ca5cc55d80
Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org>
ARM: dts: msm: SPI Modify SPI BAM physical memory size

SPI  driver does not map all spi bam memory space.
When  spi driver attempts to read from a register
by adding offset to  base address, that
address exceeds  memory area thus  data
abort happen.

This patch add the correct  size for SPI BAM
memory in DT file to map all the registers thus
avoid data abort.

CRs-Fixed: 562031
Change-Id: Ibd69176c5b8c90a15141b621beb27f2655770797
Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org>
ARM: dts: msm: Add device tree node for ASM loopback

Add ASM loopback device tree node

Change-Id: I83ddea8742bb018c2bf456a3a0ea379f028d0a87
Signed-off-by: Vimal Puthanveed <vimalp@codeaurora.org>
ARM: dts: msm: Update device tree node for msm-pcm-dsp

Update the name and properties for msm-pcm-dsp. Use qti instead
of qcom for device node and its properties.

Change-Id: I97d8f336be5e3b6792d99eece27c7d7773e33aa1
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>