Commit Graph
822 Commits
Author SHA1 Message Date
Anirudh Ghayal d37bc1fb63 power: pm8921-charger: BTC override fixes
- 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>
2013-04-17 19:38:37 -07:00
Linux Build Service Account 09e3653593 Merge "ASoC: wcd9320: Add support on-demand spkdrv supply" 2013-04-16 00:27:35 -07:00
Linux Build Service Account fc67fce1a4 Merge "ASoC: wcd9xxx: Add support on-demand supplies" 2013-04-16 00:27:34 -07:00
Joonwoo Park 1277cb68e4 mfd: wcd9xxx: Enhance codec detection logic to be forward compatible
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>
2013-04-15 14:09:12 -07:00
Joonwoo Park 448a8fc333 ASoC: wcd9320: Add support on-demand spkdrv supply
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>
2013-04-10 15:51:06 -07:00
Joonwoo Park 5d170a408b ASoC: wcd9xxx: Add support on-demand supplies
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>
2013-04-10 15:50:55 -07:00
Linux Build Service Account 6d2cb09b7e Merge "power: qpnp-bms: introduce configurable corrections" 2013-04-08 10:32:28 -07:00
Xiaozhe Shi 0ac7a009aa power: qpnp-bms: introduce configurable corrections
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>
2013-04-05 10:37:30 -07:00
Linux Build Service Account 0b6c17a92e Merge "ASoC: wcd9320: Set DMIC sample rate in the codec" 2013-04-02 23:49:43 -07:00
Linux Build Service Account db6850932b Merge "power: pm8xxx-ccadc: implement quick calibration" 2013-04-02 20:53:21 -07:00
Linux Build Service Account 1d27691ce0 Merge "ASoC: wcd9xxx: Cleanup userspace exported header's marking" 2013-04-02 20:50:29 -07:00
Joonwoo Park 59da0dadc4 ASoC: wcd9xxx: Cleanup userspace exported header's marking
Remove marking from userspace exported header.

Change-Id: Ie10877784212ae05a9308db5f11fdddb476143b9
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2013-04-02 15:37:22 -07:00
Damir Didjusto 1a353ce3e0 ASoC: wcd9320: Set DMIC sample rate in the codec
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>
2013-04-02 11:45:47 -07:00
Linux Build Service Account ef5f89222f Merge "power: pm8921-bms: api for battery insertion/removal" 2013-04-01 06:44:28 -07:00
Anirudh Ghayal 769ebada4a mfd: pm8xxx-misc: Add API to read PMIC registers
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>
2013-03-29 16:30:52 +05:30
Abhijeet Dharmapurikar 5389ebc8d0 power: pm8xxx-ccadc: implement quick calibration
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>
2013-03-28 21:28:21 -07:00
Abhijeet Dharmapurikar bd5e508c0a power: pm8921-bms: api for battery insertion/removal
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>
2013-03-28 21:28:13 -07:00
Abhijeet Dharmapurikar 487076194e power: pm8921-bms: introduce configurable corrections
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>
2013-03-27 10:20:16 -07:00
Anirudh Ghayal 0c7c2bcff1 power: bms: Report zero SOC if voltage is below cutoff
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>
2013-03-24 22:04:25 -07:00
Bhalchandra Gajare ea89874a1a ASoC: wcd9306: Pull in changes from WCD9320
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>
2013-03-14 13:55:04 -07:00
Bhalchandra Gajare 750d12d88f ASoC: wcd9xxx: Add support for wcd9306 v2.0
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>
2013-03-11 15:43:18 -07:00
Anirudh Ghayal 80c729b513 power: pm8921-charger: Make charger removal detection workaround optional
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>
2013-03-05 19:49:32 -08:00
Linux Build Service Account 26cae1caa4 Merge "ASoC: WCD9XXX: Add support for class H PA controller" 2013-02-22 02:18:03 -08:00
Bhalchandra Gajare 87fef4c2e2 ASoC: WCD9XXX: Add support for class H PA controller
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>
2013-02-21 22:05:10 -08:00
Abhijeet Dharmapurikar 03c6c23af4 power: pm8921-bms: add capacitive resistance
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>
2013-02-19 23:35:31 -08:00
Joonwoo Park 559a5bfc7b ASoC: wcd9320: Add wcd9320 codec hardware v2 support
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>
2013-02-15 14:46:36 -08:00
Joonwoo Park 3cf3a94c10 mfd: wcd9xxx: Pass slimbus slave address type to slimbus slave driver
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>
2013-02-14 20:23:24 -08:00
Joonwoo Park 20bc9da1fc ASoC: wcd9xxx: Avoid vddio switch during plug type detection
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>
2013-02-14 10:49:52 -08:00
Xiaozhe Shi 77a5b058c2 power: qpnp-bms: introduce custom oem battery data
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>
2013-02-14 10:48:32 -08:00
Duy Truong 790f06d941 Update copyright to The Linux Foundation
Change-Id: I9d411a9c00b37d0907066dbfa6db3a78c108646f
Signed-off-by: Duy Truong <dtruong@codeaurora.org>
2013-02-13 16:38:12 -08:00
Damir Didjusto 9841061097 ASoC: wcd9xxx: Export wcd9320_registers.h to user space
Add the additional file to Kbuild to export the registers
to userspace.

Change-Id: I25800f94851004994346b0b563ea9ef0fe37cee2
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
2013-02-11 18:45:09 -08:00
Anirudh Ghayal 6fe4ffa666 power: pm8921-bms: Enable batt alarm
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>
2013-02-06 08:13:16 +05:30
Abhijeet Dharmapurikar 1939ede393 power: pm8921-bms: disable ocv updates for flat portion of the curve
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>
2013-01-25 13:34:30 -08:00
Linux Build Service Account e7f1ab2526 Merge "ASoC: wcd9310: Update wcd9310 compander configuration" 2013-01-12 14:04:28 -08:00
Linux Build Service Account 4712e6dd1d Merge "ASoC: wcd9xxx: Handle ADSP Subsystem Restart" 2013-01-11 13:32:45 -08:00
Linux Build Service Account d10084071f Merge "ASoC: wcd9xxx: Fix MBHC irq handler deadlock scenario" 2013-01-10 19:00:36 -08:00
Ravishankar Sarawadi 839fcf3283 ASoC: wcd9xxx: Handle ADSP Subsystem Restart
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>
2013-01-10 17:01:33 -08:00
Joonwoo Park 1f9d7fddb0 ASoC: wcd9xxx: Fix MBHC irq handler deadlock scenario
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>
2013-01-09 16:08:41 -08:00
Kuirong Wang 678e417f30 ASoC: wcd9310: Update wcd9310 compander configuration
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>
2013-01-08 17:15:09 -08:00
Linux Build Service Account 52383656c1 Merge "power: pm8921-bms: implement max current indication" 2013-01-04 03:17:42 -08:00
Abhijeet Dharmapurikar eca7b3effc power: pm8921-bms: implement max current indication
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>
2013-01-02 12:27:21 -08:00
Linux Build Service Account 5a69a5a2a2 Merge "power: pm8921-charger: charging time expiry fixes" 2012-12-27 17:27:38 -08:00
Linux Build Service Account 8c0971432e Merge "ASoC: WCD9XXX: Add support for WCD9306 codec in codec core driver" 2012-12-26 20:46:08 -08:00
Banajit Goswami 4d6d891b4c ASoC: WCD9XXX: Add support for WCD9306 codec in codec core driver
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>
2012-12-26 16:39:35 -08:00
Bhalchandra Gajare dcf09f8c6e ASoC: WCD9306: Add initial driver for WCD9306 codec
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>
2012-12-26 16:29:46 -08:00
Xiaozhe Shi d035f6aabc power: pm8921-bms: account for sleep time in ADC calibration
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>
2012-12-19 10:31:40 -08:00
Abhijeet Dharmapurikar f8a66e9a59 power: pm8921-charger: charging time expiry fixes
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>
2012-12-14 18:58:38 -08:00
Venkat Sudhir a50a376f71 ASoC: wcd9xxx: Add codec clock rate in device tree
-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>
2012-12-10 17:57:04 -08:00
Abhijeet Dharmapurikar 2f45e2c93e power: pm8921-charger: support temperature less configurations
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>
2012-12-03 20:35:28 -08:00
David Keitel 8e67275cb4 power: pm8921-charger: make usb_max_current configurable
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>
2012-12-03 15:56:25 -08:00