USB: ehci-msm-hsic: Don't mark all IRQs as wakeup capable

Some HSIC core interrupts might not be capable of waking up system
from suspend (or XO shutdown) if they are not routed to MPM.
Marking such IRQs as wakeup capable may prevent system from entering
suspend.

Change-Id: Iace7214f7d847f2dc210a9021da08157cfb5bd15
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>

Conflicts:
	drivers/usb/host/ehci-msm-hsic.c
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>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: Fix correct topology for qseecom bus scaling.

Currently, bus scaling topology for qseecom is incorrect.
 -Added the correct topology paths for accessing Crypto
  Engine which is controlled by QSEE.
 -Removed setting the clock frequency of DFAB. This is
  done by the bus driver.
 -Removed references to the dfab clock instance defined
  in clocks file.

Change-Id: Ib6953ea3bf5721d458bfe2aa06c54be329a8fdb9
Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: Fix correct topology for qseecom bus scaling. - change mako board file

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Remove extra call to disable clock.

Currently the qseecom driver calls qsee_disable_clock_vote() in
the release function. This reduces the reference count during
disabling of the clock and results in turning off the bus clocks
inconsistently.
This change fixes the inconsistency.

Change-Id: I33aa90744a65a3e1a9aba0c368de99ef61a35073
Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
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>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Enable clocks for the Crypto Engine used by Trustzone.

All interactions with secure applications on TZ by non-secure
apps on HLOS need the crypto clocks on.
Without this, simple operations as loading secure apps in
Trust zone fail.

Change-Id: I37097cb401508f7582de014e502f3709170ca6b2
Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Add kernel space client support

Add support for kernel space client:
    - add support for starting secure app by kernel client
    - add support for shutting down secure app by kernel client
    - add support for sending command to secure app loaded by
      kernel space client(s)

The above is needed for allowing kernel modules to communicate
with app running in secure domain.

Change-Id: I3ae3a7648714eb7d7f4801b2f8e7cd94b5c64bdf
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Add support for loading commonlib image

Load the common library image on secure domain during
initialization of the driver.

All secure app loaded on the secure domain (TZ) is currently
refactored to not include all secure libraries. The libraries
are now a part of separate image.  This is used by all secure app.
This common lib image needs to be  loaded before any secure app
can be loaded.

This patch adds support for handling this new change based off
the QSEE version running on secure domain.  The change is to
load the common library image before loading any secure app.

Change-Id: I1c7692b612ea4c7bddbca1af07ddf32a073d70a8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Add clk management

The CE clock was initialized to run at max of 100 MHz.  This
was done during the probe call. Running the CE clk at 100 MHz
always, is causing a power regression.

Fix is to enable the clk and set it to run at the nominal level
of 50 MHz.  Further more, add clk gating to ensure CE clks are only
bumped up to the max of 100 MHz when client request for high bandwidth.

CRs-Fixed: 416759
Change-Id: I311f6b29e9129a04c3ec7e2a8f893fa08a518bbd
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Vote for CE clk before  loading image

Add support for setting the Crypto HW to operate in
high bandwidth mode before issuing a request to load
image.

This is needed for better performance when using crypto
HW to authenticate the image before loading it.

Change-Id: I42d40554ad2d64551db222ea7255bc904b9af256
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Remove mutex lock in load_fw API

Loading of app is stuck waiting for lock on app_access_lock
being released.  This mutex is already locked prior to invoking
load_fw.
Removing the mutex lock (already called before invoking load_fw),
in load_fw, fixes the issue with the loading getting stuck.

Change-Id: Ib43a7f5a01b5246b1f1b180380f14fb70a4c92ff
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Add API to set bandwidth for CE HW

Add API to allow kernel space clients to bump up
CE clks for improved performance

Change-Id: Iff4d16f3ae840a68fa0d064ce463b50a869669be
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Support Non-contiguous ION allocated memory

Get the scatter gather entries for non contiguous Ion
allocated memory and populate the list within the command
message with the physical address of each chunks.

Change-Id: I0e8d930525f50b6aac38b0bd3e7debec9024d1f0
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: fix functions arguments.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Report address of secure app region to QSEE

QSEE verion 2 supports relocatable images. To support this
a chunk of contiguous memory in the first 256MB  bank is
reserved for loading the secure applications.  The location
and size of this memory region is defined in the device tree
data of the driver.

This patch
- Adds supports for retrieving the address and size of the
  memory region reserved for the secure app from the device
  tree data
- Adds a new command to issue to QSEE for notifying this
  app region information (retrieved from device tree)

Change-Id: I0310815bf42c3705e0f15bd69bd4b02c6f4c56b0
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Check if app exists before loading the app

There is a chance of send a request to QSEE to load an app that
is already previously loaded. Requesting QSEE to load an app
that is already loaded will result in a failure.

Issuing a request to QSEE to check if app already exists before
issuing a request to load it, all within the same app_access_lock
mutex, fixes this issue.

CRs-Fixed: 420473
Change-Id: Ie839db89a10644d4f1d84ffa3a87cea8da16e796
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Fix memory leak when __check_if_app_exist() fail

In qseecom_start_app(), when __check_if_app_exist() returns an
error status, the function is exited  with a -EINVAL error.
This result in not de-allocating memory that was allocated for
the handle prior to calling __check_if_app_exists()

Memory that was allocted for the handle, needs to be de-allocated
before exiting with an error status when __check_if_app_exists()
return a failure.

The fix is to re-order the memory allocation of the handle after
__check_if_app_exists() goes through successfully.

Change-Id: I9dde552deb2296ab719ee815314c9da161a5d1da
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Tie performance request to client handle

When a user space client application crashes without
disabling clk vote,  there is a possibiltity of crypto
HW being left at its high bandwidth mode.  This results
in power drain.

This patch ties the performance request to the client
handle.  When any client handle is released (done when
the client handle is closed explicitly or when a client
application crashes), appropriate calls are invoked to
disable clk voting as part of closing the handle

Change-Id: I7f801d642ec53e3e5bf18a5d3a6076f973bb5175
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qseecom: Change the library name.

Change the name of library to be in sync with TZ change.

Change-Id: Id9e7851d50cdd0eea991561abb9ba57ebbac7ca2
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>