msm: camera: exit camera incase axi gets timeout

AXI hits timeout while stopping due to sensor not streaming.
Simply returning error from here puts AXI and camif in still
running state whereas userspace proceeds with releasing the
buffers. This fix ensures we halt AXi and stop camif in sensor
not streaming case. Thus avoid page faults and a delay in
stopping camera.

Change-Id: I4159ac7b21d2a22a5684d7b4a614b0dfd8f06e46
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
msm-camera: Dividing unified buffer in proportion to the image size

Write masters writing large images require large latency buffers in
unified buffer whereas write masters writing smaller images don't,
Allocating latency buffer in proportion to image size will reduce
buf overflows

Change-Id: I54d3b4389eb616b9684d5b62caaed029c83299ab
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
msm-camera: Enable proportional slicing of unified buffer

To enable proportional slicing

Change-Id: I8a21c8808085f527b9536edc51ccdcfa1de4e179
Signed-off-by: Mohit Setia <msetia@codeaurora.org>
ASoC: Fix the sync problem after SSR

After SSR default registers needs to be restored. Then
we need to sync all the registers with cache values. This
fixes the problem where register values got changed
after SSR causing AAC clip playback failure.

CRs-Fixed: 579574
Change-Id: Ibb99d69425dcb16ba09cfb131b5059f666f75012
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Signed-off-by: Fred Oh <fred@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>
msm: ultrasound: add support for aDSP Sub-System Restart

Add handling of RESET_EVENTS message from APR, which indicates
aDSP sub-system restart has begun.

Add a new internal state, USF_ADSP_RESTART_STATE, for this
scenario.

Change-Id: Ic1178f8fb4e659abc29947fac4079ba088e51447
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
mdss: mdp3: Remove extra call to clk_prepare

clk_prepare got moved inside mdp3_clk_update. Prior to this patch
unprepare would never be called successfully.

Change-Id: I28ab035b42d433f379d63748ac4f506a8575ea66
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
msm: mdss: remove panel type check for split display case.

Split display flag is derived from dsi controller configuration
specified at dtsi. Therefore no need to add checking panel
type at FB registration.

Change-Id: I5b60656c1f5724bdc358d743b8d7600d5beba0b3
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: smd_tty: Fix client notification issue in suspend state

SMD_TTY driver holds a wakeup source for 500ms to provide enough time
to notify the user client waiting for data. However, when system is in
suspend state the 500ms timer may not be sufficient to notify the
user clients because in some cases system resume of devices and tasks
is taking more time and this causes delay in client notification.

Register for PM_SUSPEND_PREPARE and PM_POST_SUSPEND events to track
system suspend and resume state and then notify the clients after system
resume completes.

CRs-Fixed: 613589
Change-Id: Iffb2ecb1c58f46e0c4a745cdcce2fb717ea2ece8
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
msm: mdss: prevent dereferencing of user space pointer

We were dereferencing a userspace pointer in kernel.

Change-Id: I128455904cd396690350fc6b784a8844d594539c
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
power: qpnp-bms: do not adjust when shutdown soc is being applied

When the shutdown SOC is being applied, do not adjust the SOC before
using it for reporting. This is to prevent situations where the SOC can
be adjusted upwards when discharging, or adjusted downwards when
charging, but before the monotonic filtering can apply.

This change will ensure SoC monotonicity during discharge across power
cycles.

Change-Id: I23c95ddb941e0544920eb5c4cac3b1ba8d2752d6
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: fix coulomb counter selection

There is a bug in the BMS code right now where reading the coulomb
counter actually reads the shadow coulomb counter and vice versa. Fix
this by correctly specifying the coulomb counter to be read.

Change-Id: Ica703d1e426e595e9ff6cd9fc45bade743740238
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: always release output locks in bms driver

If a SPMI read error occurs, there can be a situation where the
BMS_HOLD_OREG bit is not set and the bms param lock is never released.
This can cause deadlocks and battery SoC to never move. Fix this by
releasing the locks after handling an error.

Change-Id: I880b8e1ed2ff1ec3ce701f1e9922c9aac353766a
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: use consistent IAVG for raw SOC calculation

Currently the BMS uses the instantaneous current for the raw SOC
calculation. However, this current can be very high because of the boot
tiime power draw. This can bias the UUC to unreasonably levels (100% of
the battery when at cold temperatures) and cause the saved shutdown SOC
to be needlessly discarded.

Use the more realistic IAVG of 250 mA when doing this initial raw SOC
calculation as well in other places where iavg is being reset to avoid
skewing the results. Also, do not save the percent UUC when doing the raw
SOC calculation. Rather, use the loaded shutdown IAVG if there is one.

Change-Id: I426b824a50568b01bae442a3154e7c68c42409f8
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: qpnp-bms: increase resolution of temperature lookups

Currently, the BMS driver rounds to the nearest degree when doing
table lookups on FCC, rbatt, and OCV. This is done with no
interpolation.

This can be harmful because in low temperatures, a change in 1/10th of a
degree C can cause very big swings in UUC due to the rbatt lookup
crossing a threshold. There has been cases seen in -20 degC testing
where when SoC goes from -3.9C to -4C, a shift of 80 mOhms of rbatt was
observed. This increased the UUC by 8% and caused large SoC swings.

Fix this by interpolating between the temperature ranges more smoothly.

Change-Id: I21ba32fd56b802c5a68f5c193f0904e445b6a798
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
ARM: dts: msm: Add num fabrics to the msm8226 target

Add the number of fabrics present to the msm8226 device tree file. Use
this propoerty instead of APIs in code to determine the target type to
arrive at the number of bus fabrics present.

CRs-Fixed: 642345
Change-Id: I299d735b3c37c583b29a5cdb13367af42ccf8cea
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
qseecom: Replace kzalloc with ion_alloc

Allocate memory to common lib through kzalloc issues no page errors due to
higher order memory request. So allocate the memory from the heap specially
dedicated to QSEECOM.

Change-Id: Ice4a609d6791ce5adc84b9882231def31674f461
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: Fix failure to load cmnlib image

Set the physical address field of load_req data struct
correctly using the right ion_phys API. Without this,
secure domain is not able to address/dereference memory
where cmnlib image resides.

Change-Id: I9f75e78227e4eee89fff9ad8b19701ff08e5d90a
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: Check the return value of "ion_phys"

Check for return value of "ion_phys" and handle
the error cases appropriately.

Change-Id: Ib4f24af24de2b2553ed91479f46b2f79e0be0446
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
qseecom: register bus bandwidth mode when loading app

When there are multiple running qseecom clients, ce clock may be disabled
by one client while TZ is still loading another client's app, which will
lead to load app failure. So, we make a change to register bus bandwidth
mode before loading app and avoid to disable clock when current bandwidth
mode is not INACTIVE.

Change-Id: I1727f6fc038baf95da39089e1f0faefe42f3d40c
Signed-off-by: Zhen Kong <zkong@codeaurora.org>