msm: thermal: Bring up

* Tune code and values.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
out: Update crap-cleaning script

* Thanks @eng.stk for this.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: pm-8x60: Fix suspend time tracking

Calls to sched_clock() after syscore devices have been suspend
will return the same value until the syscored devices are
resumed. Furthermore, the value won't jump forward to account for
the time left in suspend so we can't use it to calculate how much
time we spent in suspend.

We could expose the hardware directly to the pm code but it's
better to use generic interfaces. Move to using the timekeeping
APIs to determine how long we were in suspend. Unfortunately, we
can't use the timekeeping APIs this early in the resume path, so
we must read the current time of day before we suspend the
timekeeping core and after we resume the timekeeping core. Move
the calls to the suspend_late() and wake() callbacks so we can
properly read the amount of suspend time.

CRs-fixed: 536881
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: Avoid using global variable total_cpus

The change is to compile on kernels where cpufreq stats are compiled as
a module (CONFIG_CPU_FREQ_STAT=m), because total_cpus is not exported for
module use.

Reported-By: Emilio López <elopez93@gmail.com>
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
staging: binder: do not debug user errors

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: fix HPHL DAC path enable sequence

The dac_ref_en bit should not be turned ON by codec
driver when headset is inserted. Setting the
dac_ref_en bit, and not resetting it when headset is
removed, will cause the DAPM framework to keep HPHL
DAC path connected.
This change returns the ownership of setting the
dac_ref_en bit to DAPM framework and fixes the HPHL DAC
path enablement issue when headset is inserted.

Signed-off-by: Banajit Goswami <bgoswa@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Set HPH bias currents to low power mode

Setup the headphone path PA and DAC bias currents to low power
mode to increase power consumption efficiency

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: ultrasound: support up to eight TX and RX channels

Ultrasound digital pen service requires six TX channels for
the service performance improvement.

Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Change implementation to use callbacks

To use common mbhc code across multiple codecs, use
callback functions instead of mbhc version for each
codec. This will make the codec driver to handle the
codec dependent changes.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: don't assume PA is off during insertion detection

The mbhc find plug type can possibly run with audio playback on headphone.
This means micbias source can be from vddio as well as hphl status isn't
reliable.
Change micbias source to cfilt and don't refer hphl status when playback
is running with headphone during plug type detection.

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Enhance class H controller to support dynamic CP voltage

Codecs can operate at a lower voltage for vdd_buck, whereas
this voltage source being shared, it is not guaranteed that the
codec will always receive exactly the requested voltage. Add support
to class H controller to handle dynamic switching of the chargepump
voltage.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Avoid mic schmitt trigger while finding plug type

Do not enable mic schmitt trigger when the plug type
determination work is interrupted by another mechanical
or electrical mbhc interrupt. Otherwise, enabling mic
schmitt trigger will cause spurious unwanted electrical
interrupts to be generated while plug type is getting
determined.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: introduce headphone impedance detection support

Different headphones have different impedance that results in volume level
difference on ears as lower impedance headphone will have higher
volume with the same gain on PAs.
Provide impedance of headphones to be able to adjust gain according to
impedance so user can have consistent volume level with different
headphones.

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Apply class H parameters based on impedance

Different headphones have different impedance that results in volume level
difference on ears as lower impedance headphone will have higher
volume with the same gain on PAs.
To get better output on headset configure class H controller
based on the impedance detected.

Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Add config variable to enable/disable impedance detection

Some of the codecs still do not support impedance detection feature.
Currently it is only enabled for wcd9320. So, add a config variable
to mbhc configuration to enable or disable impedance detection
calculation.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: fix build warning

Fix warnings due to -Wmaybe-uninitialized in GCC

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: register available conditions to resource manager

When mbhc driver isn't used, resource conditions from mbhc driver isn't
also available even though resources might be still available.
Make resource manager to get registration of available conditions to find
out if specific conditions are available.

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: improve mbhc button release detection performance

MBHC hardware block monitors microphone's voltage when button is pressed
to detect button release event.  Reprogram release threshold to narrow
down the threshold voltage to be able to detect button release quickly.

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: request bandgap in slow mode

Since bandgap mode change requires clock block disablement when bandgap
get and clock put which are followed by clock get and bandgap put happen,
two clock get or put happen unnecessary.
Reqeust bandgap mode in slow mode to avoid unnecessary temporary clock
source changes.  Also regardless of this change, resource manager always
requests bandgap in slow mode as fast mode request is meaningless.

Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Use lower voltage micbias for plug type determination

Enable current source during plug type determination
and use it for measuring mic voltages to minimize pop
noise resulting from higher voltage of mic bias.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>