ASoC: wcd9xxx: Prevent disabling of internal micbias

If recording is also using internal micbias, then after recording
ends, the dapm widget power down callback will reset the state of
internal micbias in codec register. To avoid such issues make sure
internal micbias is enabled while headset detection, button press
detection and polling.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Update buck control and mode registers

Leave BUCK control registers as default and set to lower BUCK ref voltage
for avoid pop noise during playback initiation.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: fix class H controller driver to handle concurrency

Fix class H controller driver's finite state machine to handle concurrent
playback.  This makes audio playback quality to be better with less power
consumption.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Update valid delta threshold when plug type is HIGH_HPH

Whenever plug type is classified as HIGH_HPH during successive DCE
measurements, it is observed that the difference min and max measured
mic voltage will be above 10mv for a current source. Update this valid
threshold limit to 80mv so that plug type cannot be classified as invalid.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Configure codec hardware in optimal mode

Update class H controller registers to configure codec in optimal mode.

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Do not use current source if micbias is already enabled

Some targets share the same micbias for handset mic and headset mic.
When any recording is in progress from handset mic and if headset
is inserted, we shouldn't be using current source for the detection
as the micbias is already enabled. Check if micbias is already enabled
or not and if it is already enabled, detect the headset insertion using
micbias not with current source.

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

mbhc hph_status status is assigned to 0, if extension cable
feature is enabled.Due to this OCP status bits are cleared
as a result OCP interrupts are masked which were stopping
OCP trigger. So donot set status to 0, instead set it appropriately.

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Correct handling of RC Oscillator

RC oscillator is not disabled properly which is
effecting recording through handset.Correct handling
RC oscillator

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Increase delta for Invalid detection

Currently only 50mv delta in DCE measuremet is considered.
Increase this delta as per observation, sometimes even
more difference in DCE can be seen.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Remove unnecessary condition

There is no need to check if internal micbias is
already enabled when we are only updating the bits,
as updating the bits does not do register write
is bit is already set.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Make recalibration configurable

Add support to have option to enable and disable
recalibration of DCE during headset detection.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Make vddio usage configurable

Switching to VDDIO for DCE measurement can cause
micbias to drop. If micbias is shared for handset
and headset, this can result in pop noise in
recorded data. Make this option configurable
so that it can be disable if micbias is shared.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Handle overflow/underflow slimbus interrupts

When slimbus overflow/underflow interrupt is observed on a slimbus port
interrupts will be firing continously. This change will disable
interrupts from the port when undeflow/overflow interrupt is recieved
to avoid continous interrupts. When port is being enabled codec driver
will turn on interrupts if they are disabled.

Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Notify mbhc when TX3 path is enabled

On Tapan, ADC2/3 both being the same, it is possible that
polling noise can be captured in the recorded audio when
IN3 path is used for the recording with headset inserted.
Notify MBHC when IN3/TX3 path is enabled so that micbias
source can be switched to VDDIO to avoid polling noise to
be captured in the recorded audio.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Account for inconsistency in dce_z during button press

It is observed that dce gnd recalibration value will change
during button press. Currently dce_z is recalibrated only during
first button press. But this would cause issues in further button
detection due to the measurement inconsistancies in dce_z.
Fix this by recalibrating everytime during button press.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Enable PWR_SWCH_OVRD to reduce noise

If headset is inserted slowly, polling noise is heard
for 5 sec. To reduce the level of polling noise set bit2
in 0x133 register.

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Don't change button threshold registers

If registers which effect button detection are changed
when mbhc is still in recovering state, sometimes release
interrupt is not getting triggered.So don't modify registers
which effect button detection.

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Prevent calling PA event unnecessarily during ANC

When Headphone ANC is enabled, do not call the headphone PA event
in pre-power down case, only in post-power down.
Headphone PA event will only process this call in post-power
down case.

Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Maintain micbias for headsets with threshold on mic

There are headsets that require to maintain  micbias while
it's plugged since mic of headsets have threshold to turn
on mic. Maintain micbias when this type of headset is detected
in order to detect headset button press.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Enable micbias always when headset is detected

As micbias is shared on 8x10, we cannot use vddio switch to
detect special headsets. We can keep micbias alwyas on
to support these headsets.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>