- 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>
Exercise codec reset as part of ADSP subsystem restart handling
and also update codec and ASoC cache registers to defaults. This
is required to clean up codec state post ADSP restart. Add flag
to avoid codec reset during device bootup.
If the software workaround to prevent leakage on the spkdrv is
enabled, handle the workaround post subsystem restart by turning
on PA and bandgap again.
Change-Id: Ieb7f9892b45bc01f0e2ea38485c4f63298f83999
Signed-off-by: Ravishankar Sarawadi <crsaraw@codeaurora.org>
There is a chance to encounter deadlock when either electrical mbhc irq
or mechanical mbhc irq releases resource lock to let polling thread finish
its job. This is due to the possibility of one irq handler can preempt
already running the other type of irq handler.
Introduce a new mutex to avoid this preemption.
CRs-fixed: 428653
Change-Id: Idf24c62224026c9c061de12c31e248c05b47de9d
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Update the Compander register settings to remain the default
settings after the system bootup and optimize compander
configuration sequence.
Change-Id: Ib475f3bb84414546b4ead1d3f013dc173317e1b3
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
It will be nice to have the BMS also report an approximate max current
that can be drawn from a battery before it falls below the cutoff
voltage. This value can be estimated by calculating the voltage
delta between noload voltage(ocv) and the lowest voltage allowed
(cutoff). Dividing this voltage delta by the estimated resistance
gives us the max current the battery can provide, above which the
battery will likely dip below the cutoff voltage.
The open circuit voltage estimate and the battery resistance
that help in calculate the max current are available when state of
charge (SOC) is being calculated. So, calculate and save the max current
every time SOC is calculated and report this value via a public api.
This max current is used in the Battery Current Limiting (BCL) driver.
Consequently, remove the api that returns battery resistance and
clean up the charger driver from calculating the max current.
Change-Id: I8882575084eefa6a23bd59b8d2a54a53d793298e
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
WCD9XXX core driver enumerates the codec to slimbus and passes
control to individual codec drivers. Add logic to register
devices for WCD9306 codec driver
Change-Id: Ib5689d77ba677af5a5d78273fc89ba7b53a7c08d
Signed-off-by: Banajit Goswami <bgoswa@codeaurora.org>
Add codec driver for WCD9306. WCD9306 is a superset for
WCD9302 codec. Same driver will be used for both WCD9302
and WCD9306. The codec driver is ALSA compliant.
Change-Id: I50a098883de657d7272a084ede8fbd16ed03f2c4
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Currently, the system calibrates the CCADC and HKADC every 10 minutes of
kernel time. However, this does not count sleep time, which could make
calibration much more infrequent.
Fix this by saving the time of the last calibration for both ADCs and
immediately calibrate upon resume if the elapsed time is longer than the
calibration period.
Change-Id: I34f51c6202cbaa805c496360e8dbd391890decc6
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
When the charger timer expires charger h/w raises an interrupt and sets
the charger failed bit. Once the charger failed bit is set to 0 by s/w
the charger hardware resumes charging.
The current charging driver resets the charge failed bit periodically.
This is not safe. Update the code to reset failed bit only when the
charger failed interrupt happens and only if a configurable parameter
is enabled.
CRs-Fixed: 428877
Change-Id: If58279329f6c76978223369a2d08d47a7b1e3579
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
-Wcd9xxx codec can run with different master clock
rate. Codec needs to know the master clock rate
at init to update default register values. Master
clock rate is added to device tree.
-Remove use of static variable in codec I2C probe.
Change-Id: I6ba2821092e2f7e7814216ee49042845bcfdfe79
Signed-off-by: Venkat Sudhir <vsudhir@codeaurora.org>
There could be configurations where the voltage that appears on
the batt_therm line is out of specification and makes the battery
temperature comparators (btc) useless i.e. the comparators could
trigger when the battery is not really cold or hot.
Add software support to monitor battery temperature. While charging
start a worker which polls the temperature every few (configurable) ms.
If the temperature is hot or cold override btc to force hot or cold
which in turn feeds in to the charging FSM and disables charging.
When the temperature comes back to normal override btc to force normal
temperature. Note that when the temperature goes out of range while
charging the end of charge worker still runs, we can run the btc worker
piggy backed on that wakelock.
Change-Id: I1293ecc2974bae4ad530ecb775cd19072e413c72
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Allow the module parameter to be configurable through the board
files. This gives another option to set the usb_max_current
setting if userspace is not able to set this during
bootup.
Change-Id: I96886f8d0f3f03905163d93c4f8f3e637d98127f
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>