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.
Change-Id: I3086be02839fd735db2d32665abf7b984958dc2b
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit c68ed369921e8d08f4254b9243872785a3a5cf2f)
During subsystem restart, it's possible codec's upstream irq is disabled
if irq handler tried to access codec register when it's inaccessible.
Reinitialize codec irq handler after subsystem restart to be able to
bring codec interrupts back to work again.
CRs-fixed: 520754
Change-Id: Iaa6fa8da25cdf6ed6746754385ad895db8dcea9a
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
(cherry picked from commit 3e026864473b23c95a241ebcdf2d152c9973efec)
Update sound card's state when it went to online/offline so application
can monitor and wait for card's online prior to issue command.
Change-Id: I7cfb120e56e97cf743782a8b4b2fcbad242b227b
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
(cherry picked from commit 4aee97adf03305b3896f8e74977ef917c2fd9a32)
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>
Add the of_batterydata driver to parse device tree battery data.
Battery data contains battery profile information and is used by the
charger and the BMS drivers.
Change-Id: Ibe03800be0d51e82194c9385c6348c5a6c92711d
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
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.
Change-Id: I707f34344cd0068507bdd8a0192eb7afea1147f2
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
The max_fcc_learning_cycles variable actually indicates
the minimum number of FCC cycles required to update a new FCC,
name it accordingly.
Change-Id: I510d3a05eed736a9ee560c936faa20ed2d3c5bd1
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Clear mbhc irq before dispatching it to avoid lost irq when the same
irq asserts while driver is handling previous one.
CRs-fixed: 488535
Change-Id: I43ff7553258c0e8b260f233bbb064a5b8f118120
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
currently there is no battery data for qrd 4v2 1300mah
add qrd 4v2 1300mah battery data
Change-Id: Ie5bf0cafb2f50e85d45976178bb13d8b79017bb5
Signed-off-by: tingting <tingting@codeaurora.org>
The current design enables PWM LPG high bank with out
checking the max current. So enable PWM LPG low bank when max
current configured as 4mA and enable PWM LPG high bank when
the max current configured as 8mA. Enabled both PWM LPG low bank
and PWM LPG high bank when max current configure as 12mA.
CRs-Fixed: 486318
Change-Id: Ib7177aafc63c4c33b8c144d665a11d5aaf0ef584
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
1. Add configurable parameters to
- enable/disable fcc learning
- minimum soc to start FCC learning
- minimum ocv (pc) to start FCC learning
- minimum cycles to update fcc vs temp. table
2. New FCC is calculated using the cc count-
FCC_NEW = (cc_end - cc_start) / (soc2 - soc1)
cc_end = CC count when charing ends
cc_start = CC count when charging starts
soc1, soc2 = starting and ending SOC_rbatt value
3. Add a new sysfs entries to update the learnt fcc values
to userspace. These values are restored back on
reboot.
CRs-Fixed: 417288
Change-Id: I0dc713d59ef9c45f96b9f0b5844252758bd09320
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add data for QRD 4.35V 2000mAh battery. In pmic8x26 V1.0, batt_id pin
is connect to ground, so can't identify the battery using ADC, add
a battery type for QRD.
Change-Id: Ib54873210b6dce476c93c8e48942921e305b5d82
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
The TX4 register address are not correct and needs to be fixed to
correct offset.
Change-Id: Iacb4a57a8c0a8508a68d057d0d431715e617eba5
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
Currently wcd9320 driver assumes micbias 2 is dedicated to headset and ANC
microphones on headset. Allow different microphones share the micbias 2 to
support hardware that have shared micbias configuration.
If micbias 2 is shared by mic biases other than headset mic, MBHC's ext
cable feature will be compromized and also headset removal can make more
pop noise. If hardware has dedicated micbias 2 for headset, it's
recommanded to disable this feature.
Change-Id: I5d5e5c2feb406212dad6d211f49de49e64e1a888
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
The wcd9320 and wcd9306 codec have additional interrupt bits which are not
currently masked. Therefore it's possible those interrupts assert and
never be cleared by driver. Mask additional interrupt mask bits in order
to prevent irq flooding.
Additionally enhance irq handler to clear unhandled nested irq so even
buggy driver cannot make irq flooding.
CRs-fixed: 478185
Change-Id: I6d7c0fad8baceefd0fb8c2ee0498ca09b56a56a8
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
- Monitor battery health when charger is not connected
- Add configurable temperature hysteresis and enable the
same for BTC override
- Avoid releasing wakelock when charging is not in progress
and BTC override is enabled
- check temperature thresholds when fully charged, to handle
temperature restrictions while restarting charging
CRs-Fixed: 466525
Change-Id: I8cad3f8bcf65844fc1048625d9b387ede132d3e0
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
So far driver claims detection only when major and major chip id are
matching with predefined table. Amend the detection logic to support
possible unknown version of hardware by checking only chip id major when
driver doesn't have exact matching chip id table for both of major and
minor.
This will give us a capability of supporting hardware with minor changes
without software changes.
Change-Id: I7c5d1bce0c8542664b979a0fb2280ffa01f2279a
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
The wcd9320 codec requires enabled spkdrv supply during playback on the
speaker path. Enable supply only when it's needed.
Change-Id: Ib06300396efdf5628ad92499ae17683e05165d39
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
There are supplies only need to be enabled on-demand based on the codec's
functional activity. Discriminate on-demand supplies from static ones and
pass list of supplies to codec driver in order for driver can enable only
when the supplies are needed.
Change-Id: I91b3356e33fa89fb3ba12f36688f207c9e7a8e02
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
There are situations when the corrections can cause linearity issues.
Provide a scheme to limit the corrections via a configurable parameters.
The corrections were introduced to prevent battery dipping below UVLO.
If the battery were in the flat portion of the SOC curve a small error
in OCV measurement could drift the SOC by a large amount. Corrections
are important if the OCV falls in this range. Hence introduce two
parameters to limit the corrections based on a OCV threshold - one when
it is above 3.8 volts, where corrections could be low and the other
when the OCV is lower and 3.8 (flat portion) where corrections should be
high.
Also there are instances when the SOC appears stuck at 1% for a long
time. This is because the algorithm doesn't allow the soc to drop to 0%
if the estimated soc is high. Provide a configurable level for the
estimated SOC below which, the calculated soc can go to 0%.
Change-Id: Ie77b52ed59ba138efca86b840dbd60a38ca81d86
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Set the correct clock frequency divider values in codec registers
based on MCLK and DMIC sample rate. Set the ANC DMIC X2 based on
the sample rate.
Change-Id: I23bb38112a3f2045e1844224545a3c2a0fdd8446
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
This API reads the PMIC registers at runtime and can be called
from process/interrupt context. It is currently enabled for PM8921.
Change-Id: I63a80293e37725569d075de814f27f67382976ca
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
There are certain systems that wakeup every so often to do some
housekeeping work. We don't want to run a full calibration
when the system wakeups.
For such systems runs a quick calibration with just two samples.
Use the periodic_wakeup flag to indicate such a system.
CRs-Fixed: 454221
Change-Id: Ifc86414f7fab4d0921e3289d6e52b9e077a1f625
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Provide api to clean up the history values the driver remembers to
report the soc. These apis will be called when the battery is removed.
Similarly provide api to initiate battery SOC calculations upon battery
insertion.
Change-Id: Ie9f3f5f45c789efc2ba6d39226401691912c764c
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
There are situations when the corrections can cause linearity issues.
Provide a scheme to limit the corrections via a configurable parameters.
The corrections were introduced to prevent battery dipping below UVLO.
If the battery were in the flat portion of the SOC curve a small error
in OCV measurement could drift the SOC by a large amount. Corrections
are important if the OCV falls in this range. Hence introduce two
parameters to limit the corrections based on a OCV threshold - one when
it is above 3.8 volts, where corrections could be low and the other
when the OCV is lower and 3.8 (flat portion) where corrections should be
high.
Also there are instances when the SOC appears stuck at 1% for a long
time. This is because the algorithm doesn't allow the soc to drop to 0%
if the estimated soc is high. Provide a configurable level for the
estimated SOC below which, the calculated soc can go to 0%.
Change-Id: I265e1ea41681813ec6add6eea2a440c6e239a5dc
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
If the battery voltage remains below the cutoff threshold
for a specific period (determined by a platform data -
vbatt_cutoff_retries) report the SOC as 0. This allows
the userspace to perform a graceful shutdown. Also, provide
a platform data entry (low_voltage_detect) to enable this
functionality.
Enable 'low_voltage_detect' and set 'vbatt_cutoff_retries'
as required to enable the full functionality.
CRs-Fixed: 450387
Change-Id: I668d391cab3d0424fe5f370df0c1169124c34f5e
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Cleanup wcd9306 codec driver, pull in fixes done for WCD9320 that
are also required for WCD9306.
Change-Id: Ib0bf6c7baa32877c03ebc7a138af087438b8694b
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
WCD9306 v2.0 has enumeration address different for slimbus PGD and
interface devices, add this new enumeration address to supported codecs
over slimbus. Provide macro to identify codec version.
Change-Id: I197db5e634daceb5c7b7d91b1dc356b9c226ca18
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
On some platforms such as MPQ8064 the charger removal detection
workarounds - reverse boost fix and OVP FET stuck do not work
as expected as the SMBC module is disconnected from USBout. On
these targets the USB interface is not used for charging but merely
to indicate the USB driver of the insertion/removal.
Add a platform data variable to make this optional and enable
the same for MPQ8064
Change-Id: I3fca1b357f8fc280483302f72ffbc61fb50109a7
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Class H PA controller analyzes the signal which will be sent to
the PA's (EAR or HPHL/HPHR) in order to adjust the supply voltage
of the PA to make the system as efficient as possible.
Add support for class H PA controller as common code for multiple
audio codecs.
CRs-fixed: 410528
Change-Id: I878a801fcd89f7aa89f1da3d5c8887ec9d7e4d39
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
The current code only accounts for the series resistance via a lookup
table. Add a configurable parameter to account for capacitive resistance.
Change-Id: I6a844b51970a6bdf40cfc1340fa31f580efc1c9e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
The wcd9320 hardware v2 has different chip ID along with several
different registers' default value compare to v1. Add this new codec
hardware support.
Change-Id: I326fb066b37a1dec6c9efc224f6f362eef9fa323
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
There are slimbus slave address differences among the different wcd9xxx
codec hardwares. Fix core driver to pass this information to slimbus
slave driver in order to avoid slimbus slave device determines interface
type by itself.
Currently when new codec hardware support introduced the same change has
to be made in both of core and slimslave driver.
This change removes slimslave change requirement.
Change-Id: Ie36cfb1139ce2360be1bd66ddfc22b283f948561
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
When MBHC detects new plug type, MBHC driver turns on vddio switch in order
to check if plug is fully inserted. But utilizing vddio switch can lead to
plug type detection failure when plugged headset behaves differently
between with and without vddio switch.
The HPHL status register can replace the vddio switch so driver can check
if plug is fully inserted by reading the HPHL status register. Hence
replace vddio switch with HPHL status register.
CRs-fixed: 440803
Change-Id: I5c23cb38459e806266c806e391f8f8f2e7c65a5d
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
[smuckle@codeaurora.org: backported to msm-3.7]
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
By default, there are only palladium and desay battery profile data in
the current implementation. However, OEMs may want to maintain their own
battery profile data for other battery types.
Introduce battery type "BATT_OEM" and the corresponding profile table as
"bms-battery-data-oem.c".
Default functionality should not be impacted. The bms will still
default to palladium 1500 to maintain backwards functionality.
CRs-Fixed: 431640
Change-Id: I97d21ecacda92ae18f0aaa0f2256f62f3de1daa5
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Add the additional file to Kbuild to export the registers
to userspace.
Change-Id: I25800f94851004994346b0b563ea9ef0fe37cee2
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Set the batt alarm to wake up the system if the
battery voltage falls below a threshold. This is to
make sure that the device does not shutdown abruptly
without any notification.
Hold the low voltage wakelock to prevent the device
from going to sleep immediately after the low voltage
notification.
Change-Id: Ifaeeeb27bd85f9c95f026ac3565681432e247b02
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
An issue is observed when an OCV is updated while the device is
sleeping. When it wakes up the SOC calculations are run on the new OCV
which result in a drastically different SOC than previously reported.
The root cause of this issue is PON OCV likely was unsettled.
Provide a feature where OCV updates can be disabled between certain
SOC range.
Change-Id: I54a75a7e9d05ff2c8ccd484850f02a0190d6a3b7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>