mako: msm: Fix correct topology for qseecom bus scaling.
qseecom:  Fix failure to release qseecom handle

qseecom_release() returns a failure, if it is unable to find
app_id of zero, associated with the handle in the app list.

There exists scenarios where the handle may not have the
app_id initialized and remain to be 0.  In these scenarios,
once the uninitialized zero app_id is not found in the list,
it returns a failure.

Fix to this is look for non-zero valid app_id in the app_list when
releasing the handle.

Change-Id: If0bf918a6397d8d5f925abde895b096dab76a9bb
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: If78e8a3aa66209b93449569cc9bd670b8d21008c
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
msm: boards: Enable Krait Retention.

Add SPM sequences to do Krait retention for 8960,8930
and 8064. Also added a new rpmrs level containing the
latencies and power measurements for this new low power
state.

CRs-Fixed: 369864
Change-Id: Ib30a9a978cf38b35037810a4001c9277837acd4c
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
qseecom:Fix race condition while voting for clocks

In the current functionality, if DFAB clock is already on and a
request is made to turn on SFPB clock, the DFAB clock is turned
off and SFPB clock is turned on and vice-versa.

The above situation can lead to unexpected errors. The current fix
makes sure that clocks that are on are not voted to be off without
explicit request.

Change-Id: I6c3230e23b105c049cdb0aace579b8a176328c84
Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
msm: dcvs: change tz buffer to 32KB

Only around 32K of buffer is required for normal operation.
Request the scm buffer of 32kb from the contiguous area.

Change-Id: If79471c6e0cfe80b1796a14d83ea10eb6b919e40
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/msm_dcvs.c
msm: pm: Support for Krait Retention

Introduce a new low power state for Krait, retention.
This state will lower the voltage to the Krait core to
retention voltage in addition to clock gating. This state
will be in between WFI and Standalone power collapse in
terms of time overhead and power savings.

Change-Id: I6b1f0a0d2e4954a705a047fd4a07f4dd1fb3518a
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: pm-8x60: Fix bug where device enter low power mode

An incorrect ordering in the check of allowed modes, results in
standalone power collapse not getting selected when the secondary
cores are online.

Change-Id: Idc7177b78bd0ce7563cc27afbf6c12d3bc1f9f9a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: pm: Add support for retention on each core

Allow each core on 8974 to enter retention and retain
the state of the CPU. On 8960 as hardware restriction does
not permit all cores to enter retention at the same time,
allow only core 0 to enter retention when all other cores
are offline to maintain backward compatibility.

Change-Id: I6690e901afc9fa3a27010c264fa3acc9a0722c1a
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
msm: usb_bam : Add support for CI2.0 HSUSB BAM

Add support for both HSUSB and SSUSB BAM devices using device
tree. User can select required BAM device using below commands:
->To select SSUSB BAM:
	echo ssusb > /sys/bus/platform/devices/usb_bam/enable
->To select HSUSB BAM:
	echo hsusb > /sys/bus/platform/devices/usb_bam/enable

On some targets there is no SPS dedicated pipe memory for USB
BAM, hence, allow user to specify the type of memory used by
the BAM devices, which can be one of the type:
-SPS's dedidated pipe memory (DEFAULT), or
-USB Core's dedicated internal memory, or
-System memory that should be allocated by this driver

Change-Id: I5e5421c45fa611bc1ab2cdc81813c77d1329a8af
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
msm: usb_bam: Use USB3 private memory for CI2.0 USB BAM FIFOs

Some peripheral BAMs e.g. QDSS cannot access DDR or any other
system memory but they can access USB3 private memory. Hence,
add support for using USB3 private memory with CI2.0 USB BAM.

This requires specifying BAM FIFOs' starting address and length
in USB private memory and configuring QSCRACTH RAM1 register
to let USB3 core know about the part of internal memory getting
used as BAM FIFO and it shouldn't try to access that. Also
turn ON clocks are required to access the memory as part of
cable connect and turn OFF on cable disconnect.

Change-Id: Iaa0ba67cd54aa3eaae784d0be3f16f67974083e1
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
msm: usb_bam: Request SPS to ignore ACK from USB core for PIPE RESET

USB 2.0 core doesn't support RESET ACK signal to BAM performing
pipe reset. Hence, request SPS to disable this otherwise USB BAM
reports errror during connect.

Change-Id: I54374a194faf2f886b07cd4aa9eae17f8e19ca52
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
msm: usb_bam: Fix NULL pointer dereferences

usb_bam_connect() might still be called even if the usb_bam
platform device does not exist. Make sure to check that usb_bam_pdev
is not NULL before attempting to initialize the SPS pipes. Also
clean up other pdev instances in the dev_attr functions.

Change-Id: I0702f6b18eeb67783e9e84d502d64b1042c36c96
Signed-off-by: Jack Pham <jackp@codeaurora.org>
msm: ipa: add Driver for the IPA core

The IPA (Internet Protocol Accelerator) driver provides an API for
interacting with the IPA HW.
Kernel and user-space processes can call the IPA driver
to configure IPA.
Kernel processes can also use IPA driver as a data
transport for traffic to/from apps including exception traffic.
Exception traffic is any traffic that cannot be handled by IPA HW
or is specially marked through SW configuration.
Such traffic will always be sent to apps for further processing.

Change-Id: Ia940176536079a7cf7a78f49b5ea82288a0638d4
Signed-off-by: Talel Atias <tatias@codeaurora.org>
usb: usb_bam: Add support to USB-IPA BAM2BAM connection

Add support to the USB BAM driver in USB-IPA connections.
IPA (IP Accelerator) is a new HW block which implements data packet
protocol processing functions.

Change-Id: I3e782951ba7c9307c4e67f6ad44213ec7debf8ed
Signed-off-by: Ofir Cohen <ofirc@codeaurora.org>
msm: ipa: IPA Driver stub functions addition

Adding stub functions for the IPA driver.
These stubs will be used by platforms which
disable the IPA Driver.

Change-Id: I73a902f1b77ae6ab090358265abfc337c1bad93c
Signed-off-by: Talel Atias <tatias@codeaurora.org>
msm: ipa: fix data stall caused by IPA HW bottleneck.

When a receiver is not able to keep up with
the load pumped by the IPA SW bridge,
the desc FIFO gets full and subsequent SPS
transfers fail.
Unless bridge polls for completed descriptors
in this state, data path will remain stuck indefinitely.
This commit adds support for that polling and
symbol renaming (symbols such as functions
names and variables).

Change-Id: Iddb187798403a8c91e66f4c2d515fc54f983cf67
Signed-off-by: Talel Atias <tatias@codeaurora.org>
msm: usb_bam: Add support for BAM reset

This change adds new APIs for USB BAM driver, which allows a gadget
or function driver to perform a USB BAM reset.
USM BAM reset is required after a peer BAM has been reset.

The APIs added by this change are:
1. API for registering a peer BAM reset callback
2. API for performing USB BAM reset.
3. API for allowing a client to notify USB BAM driver when it
is ready to send/receive transfers.

CRs-Fixed: 424867
Change-Id: Id9d2158e04b15274bae89b8f037ca5d847453a53
Signed-off-by: Amit Blay <ablay@codeaurora.org>
usb: usb_bam: Prevent closing an un-opened SPS connection

Commit ce5e3f25, "usb: usb_bam: Add support to USB-IPA
BAM2BAM connection", introduced a regression by allowing
closing of a SPS connection even if it was never opened.
This may result in issues like clk_disable APIs getting
called twice resulting in ref_count mismatch.

CRs-fixed: 425510
Change-Id: I9564d6a576b769d725a41290c6b96add6d9f52e2
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
spi_qsd: support to transfer 64K chunks in DM mode

Support to transfer 64K bytes in a single SPI
transfer in DMA mode on targets which support
16 bits in QUP_MX_OUTPUT_CNT register. Earlier
if the application sends more than 4K data it is
split up in to 4K chunks,  irrespective of the size
of the QUP_MX_OUTPUT_CNT register.

CRs-Fixed: 383120
Change-Id: Ibbe73df2bb4fb2804ff6ebfc62adac9d0d53e9cd
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>