power: pm8921-bms: limit the number of tries for ocv calculation

When we want to force a certain percent charge we calculate the
expect percent charge (pc) from the expected RC (remaining charge
same as ocv based charge). We reverse lookup the ocv (open circuit
voltage) based on the pc. We double make sure that a forward lookup
matches the reverse lookup and if it does not within a percent limit
we repeatedly tweak the ocv by 5mV to get it to match.

This tweaking is unbounded and based on the battery profile could
result in a infinite loop. Limit the number of times we tweak the ocv
to prevent a possible watchdog bark.

CRs-Fixed: 406197
Change-Id: Iea874027a9e2f7ce326c8398f255e393fa7e4529
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
ASoC: audio: Fix MEM_UNMAP called before CLOSE ack

-When the commands for ASM_STREAM_CMD_SET_PP_PARAMS
and ASM_STREAM_CMD_CLOSE are sent back to back, Ack
for first command is misinterpreted as CMD_CLOSE ack
and proceeds to send memory unmap command resulting
in LPASS fatal.
-Maintain separate variable to wait on for CMD_CLOSE
that will avoid dependency to other commands getting
Ack early.

CRs-Fixed: 434279
Change-Id: I7b6b7f1b8154437b21c5ea14be2e774e4b96e2d1
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
msm: camera: remove frame delay at start_stream in msm_sensor

required for latency optimization

Change-Id: I3d039e21ee8736cf8df1373d5386671f77f2382c
Signed-off-by: Punit Soni <punits@codeaurora.org>
ASoC: wcd9310: Enable MBHC micbias always when headset is inserted

Add kernel parameter to select whenever micbias always
needs to be enabled. This is required when there is polling
noise due to sharing of cfilt in wrong HW designs.

Change-Id: I5f19de8303c04e5973e130e4a307240b4c74651c
Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
msm: kgsl: Add context reference counting to KGSL events

Add reference counting to all KGSL events since they are dependent
on the context.  This avoids a race condition where the context
could be destroyed while the events are being processed during cleanup.

CRs-fixed: 438134
Change-Id: Ic2cd484d441e4c392ab63b0a0131accaceafc711
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
qdsp5: audio: Avoid race condition by using mutex lock

There is chance of race condtion if audpp(audio postprocessing)
callback registration function is called concurrently
by more than one clients.

Avoid this by serializing audpp callback function using
mutex lock.

CRs-Fixed: 441525
Change-Id: Ic7524d83b32d54b09ba77648a266585957f49648
Signed-off-by: Manish Dewangan <manish@codeaurora.org>
ASoC: msm: Fix for memory map regions when buffers are not contiguous

This change fixes the issue of sending memory map command
with single region when the buffers allocated for playback
or capture are not contiguous. When the buffers are not
contiguous, we should populate the mregions structure with
all the distinct buffers allocated. Sending a single region
with the total buffer size (bufsz*bufcnt) might overlap with
already mapped region.

Change-Id: I8b1b71748285ab4c1ef278890390cb1e0170a47c
CRs-Fixed: 423082
Signed-off-by: Phani Kumar Uppalapati <phanik@codeaurora.org>
msm: vidc: Convey stride/scanline information

Video stride and scanlines are conveyed to client
in this change. This information is needed by client
to render the video properly.

Change-Id: I3dbbc78843ab521691e9998a872266c6dc7e4b8c
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
usb: gadget: Add support for enabling DIAG in more than one configuration

This change adds a support for multiple DIAG USB instances.
This is required to support USB compositions which have
several USB configurations, such that the DIAG can be included in
more than one configuration.

Change-Id: I02deab241128894d50f411557a856044fc1f02f0
CRs-Fixed: 437963
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Perf: Restore counter after powercollapse for generic ARM PMU's

The MSM SoC's which have ARM's CPU's can power collapse. Ensure
the CPU side PMU's correctly restore the counters after coming
out of power collapse.

Change-Id: I544a1dd8ced26f726ba115d14867d9e34c2a7944
Signed-off-by: Ashwin Chaugule <ashwinc@codeaurora.org>
Perf: Toggle PMU IRQ when CPU's are hotplugged

When a CPU is hotplugged out while a perf session
is active, disarm the IRQ when the CPU is preparing
to die. This ensures that perf doesn't lock up when
it tries to free the irq of a hotplugged CPU.
Similarly, when a CPU comes online during a perf session
enable the IRQ so that perf doesn't try to disable
an unarmed IRQ when it finishes.

Change-Id: Ic4e412e5f1effae0db34a3e4b5e7e5c65faed2a0
Signed-off-by: Ashwin Chaugule <ashwinc@codeaurora.org>
input: atmel_mxt_ts: Allow bootloader address to be set

The driver maintains a default mapping between appmode address
and bootloader address. Some appmode addresses may have
different corresponding bootloader addresses than what is
currently mapped. When this is the case, looking through an
array will not work and bootloader address must be passed in
through device tree or pdata. Appmode address is already
present in i2c client structure.

With this support, firmware upgrade for mxt336s and mxt1664s
touch controllers is now present.

Change-Id: I605b4ae615f30a05620847a5a9af826bc906f1c3
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
msm: mdm2: Add delay between subsequent PS_HOLD

During SSR first a reset of external modem is issued
and mdm_do_soft_power_on() toggles ap2mdm_soft_reset which
in turn toogles the PS_HOLD. Then a part of SSR external
modem is powered up and mdm_do_soft_power_on() again toggles
the gpio. For PMIC register stabilization we need a 1sec delay
between subsequent mdm_do_soft_power_on().
By default the delay is 500msec, so adding another 500msec for
stablization.

Change-Id: I928c064f386c1e376fc5b0740c2d1336f549398f
Signed-off-by: Taniya Das <tdas@codeaurora.org>
staging: android: lowmemorykiller: Reduce debug_level to 1

Under certain circumstances, such as after the lowmemorykiller
has recently killed an application, the logs can get flooded
with "select to kill" messages.

Change-Id: I7ae1de47c77d929e04b99be3432577d4f5fd1b2d
Signed-off-by: Liam Mark <lmark@codeaurora.org>
leds: leds-qpnp: add support for leds delayed turn off

In case a led is turned on by default, add an option to set the amount of
time in milliseconds before turn off.

Change-Id: I983c7c0e8091e57d512a5656152dc14dd86774bb
Signed-off-by: Asaf Penso <apenso@codeaurora.org>
input: Add support for virtual key generation

Virtual keys are used for navigation on Android.
These are not specific to the controller used
in the target but are specific to the target.
Add a module to generate virtual keys independently
of the controller.

Change-Id: I0c86dc77f1bc53c283e990be419c2715edf4e1c0
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
usb: otg: Add device tree parameter lpm-on-dev-suspend

The lpm-on-dev-suspend parameter permits the MSM otg
to enter to USB low power mode upon usb bus suspend.
Add a read for this parameter also for targets which
use device tree.

Change-Id: I72bf3b5fd17c7c64d59a0fa708002735f9cd224b
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
arm/dt: msm9625: Allow USB lpm on suspend

Configure msm9625 to enter USB low power mode upon usb
bus suspend.

Change-Id: Ia02c779a15d3b9d4e5de51d126aba7e473687b61
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
usb: otg: Add device tree parameter clk-always-on-workaround

The clk-always-on-workaround parameter allows to keep the USB
clocks active upon USB bus suspend when the cable is connected.
This is required for the USB core to respond to remote wakeup.
Add a read for this parameter also for targets which use device tree.

Change-Id: I1feb2bab6cbbcc406dfcc219b33ba7e9f4ea3807
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
arm/dt: msm9625: keep USB clocks always on when USB cable connected

Configure msm9625 to keep USB clocks active upon
USB bus suspend when USB cable is connected.
Essential to support USB remote wakeup feature.

Change-Id: I1496154ba2231c139235880f7d7cb34cfff35d0b
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>