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>
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>
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>
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>
 qseecom: Process incomplete load app command

Add support to process an INCOMPLETE status returned
when a request to load app is issued to QSEE.

Change-Id: If75a5726d3288812ddc6a1e23c5d968e8bc4ee1c
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
qseecom: Release the memory after processing INCOMPLETE_CMD

Release the memory after processing the INCOMPLETE_CMD,
as the same memory location is used for processing
INCOMPLETE_CMD

Change-Id: I9fd305b0e2f272f61b9975d02e222ff543842d7d
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
qseecom: Add clk gating

Curerntly the CE clk is enabled during the probe function and left
enabled, resulting in high power consumption when there is no crypto
operation in progress.

To reduce power, CE clk is only enabled on a need basis. Remove clk
enabling from probe function. Added support to enable/disable clk on
need basis only (on client's request) and when loading images.

Change-Id: I4d56f783903c0875c4ad305a6cebc42e8db8147f
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>