ASoC: msm: qdsp6v2: Add check for NULL dereference

The asm loopback during close does not check
for NULL before closing the playback and capture
instances. The change ensures only the valid
playback/capture instances are closed.

CRs-Fixed: 643724
Change-Id: I3373f62a2413e1497b6f8a401158444cd2870b2a
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
cma: Make locking finer grained

CMA locking is currently very coarse. The cma_mutex protects both
the bitmap and avoids concurrency with alloc_contig_range. There
are several situations which may result in a deadlock on the CMA
mutex currently, mostly involving AB/BA situations with alloc and
free. Fix this issue by protecting the bitmap with a mutex per CMA
region and use the existing mutex for protecting against concurrency
with alloc_contig_range.

Change-Id: I6863ba7ab7fae07c68fee23b0aa4c869244fe2a1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
cma: Drop the right mutex

The lock that was locked was cma->lock not cma_mutex. Drop
the right one when breaking out of the loop.

Change-Id: I0a1831b23613c5220795fe2a63f9db7439268c3f
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
devfreq: governor_cpubw_hwmon: Fix use of decay_rate

The decay rate tunable is used to compute the current averaged bandwidth
use, but the calculated value is never used. Fix this by using the
calculated averaged bandwidth instead of the instantaneous measured
bandwidth when computing the AB and IB votes.

Change-Id: Ic0ba3ce0d98f0ec185349fe6d86c4af26f222ff2
Signed-off-by: Saravana Kannan <skannan@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>
power: qpnp-bms: use better defaults for power supply props

Currently the BMS driver just assumes that the battery power supply will
export whatever properties it requires. However, if an external charger
is being used, having good default values for the power supply
properties that are not exported by the external charger will improve
compatibility.

Change the status property to default to unknown, the present property
to default to true, and the online property to default to true if they
are not exported by the battery power supply.

Change-Id: Ic10429881f221cfb427720bdd73d908e87b912b0
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
power: smb358-charger: Add smb358 charger driver

This driver supports external smb358 switch mode charger,
can reach up to 2A charging current. This driver instead of
original qpnp-charger, will co-work with PMIC internal BMS
(Battery Monitor System).

Change-Id: I4c520e2812284af0af348beae516eba5f95c49f3
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
power: qpnp-bms: disable interrupts at probe

The ocv and cc threshold interrupt are required when the battery is
FULL. Disable them at probe time and enable them once the battery is
reported full.

Change-Id: I75bc0b9128f7a8552380ba184d8a72e54159c01d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@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: 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: 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: 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>
msm: socinfo: Introduce soc string

OEMs require the soc-id to be translated to a string
by the kernel and reported as a part of machine init
routines. Add support for it

Change-Id: I1ebdcd21061bde60815090a2d7de475a4e235f0a
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
Signed-off-by: Mao Jinlong <c_jmao@codeaurora.org>
power: qpnp-bms: clamp for SOC <= 0

In some scenarios a negative soc may be calculated even
though VBAT is above the cutoff voltage.

The clamping function does not take negative SOC values
into account and fails to clamp the SOC. Fix this
by checking for SOC values <= 0.

CRs-Fixed: 623091
Change-Id: I8d64b3c8717e8088be71d84d66225512b85e87e3
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 1ed4fee365c0d4b07d1644e864222fffda13da58)
regulator: mem-acc-regulator: Add a driver to control the MEM ACC

The memory accelerator (MEM ACC) controls the delays applied during
memory access. These delays vary based on the power-mode (corner)
on which the memory is connected. This driver adds a regulator
interface to configure the power-mode of the memory accelerator
based on the APC (application processor) corner.

CRs-fixed: 638439
Change-Id: I830ff000f8a16c4d3de5bdebf48d424354ddb086
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: Ke Liu <keliu@codeaurora.org>
msm: Camera: Return proper value for msm_camera_qup_i2c_txdata().

msm_camera_qup_i2c_txdata() is not returning proper value.
Due to which session tear down is not happening properly
in case of i2c failure.
CRs-Fixed: 640328

Change-Id: Iac8be9d4755f807b45a6ede4f660b52cb88aedd4
Signed-off-by: Vivek Veenam <vveenam@codeaurora.org>
mdss: Add newline to VSYNC timestamp for mdp3 driver

This makes sure that the userspace correctly interprets the end
of the vsync timestamp.

CRs-Fixed: 639039
Change-Id: I8a0810283a42a9c39a3c8fe36b862bbfd3ecdbea
Signed-off-by: Shivaraj Shetty <shivaraj@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>
ARM: dts: msm: Increase the drive strength for MSM8610v2

At lower 10mA random CRC errors are seen. With 12mA drive
strength for clock lines the issue is not seen

CRs-Fixed: 601882
Change-Id: If2b3246c78a2d73acdedb76da964badb0e133bdd
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
msm: camera: Fix race condition between camera driver and camera daemon

Delete checking command list before calling
wait_for_competion_timeout which could cause race condtion
if camera daemon may respond fast and there is one context swtich
between msm_enqueue and completion.

Change-Id: I28bdc4e344d2365acf49d422ba75dc64308a96aa
Signed-off-by: Yiduo Wang <yiduow@codeaurora.org>