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>
ASoC: msm: Enable current source for plug type detection

Enable current source for detecting plug type on tapan.
Update cs_enable_flags accordingly to use current source
during insertion, polling and removal of the plug.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Support to configure the code for media button

There is mismatch in button 0 code value that is used
in kernel and userspace. Configure the code for button 0
to match with that of userspace.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Add run-time detection of wcd9306/wcd9302

Tapan codec has two variants wcd9306 and wcd9302. Wcd9302
is derived from wcd9306 while few hardware blocks are not
available. Add support to detect the codec variant at run
time.

Change-Id: Idb5b39aec2b8262391aea475a261ee5c0fcd1ede
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
mfd: wcd9xxx: Refactor codec core driver and irq driver

IRQ driver can be used by codecs that do not use the core driver.
Refactor the drivers so that codec drivers that are not children
of the core driver can also request/access the interrupt routines
provided by the IRQ driver.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Bringup headset detection on msm8x10 codec

Changes to enable headset detection and plug type determination
for msm8x10 codec.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>