The rbatt was observed to change with battery temperature and the state
of charge of the battery. Update the BMS driver and the battery data
to include and use a rbatt table indicating its changes w.r.t temperature
and state of charge.
On similar lines provide api for other systems to query battery resistance.
Change-Id: I681675db537b70919e6e0437bd400ce53bf97096
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Use mechanical switch on the phone jack to detect headset/headphone
insertion and removal. Mechanical switch is beneficial to avoid fake
button press and high impedance microphone headset detection.
CRs-fixed: 341402
Change-Id: Idffba14316ab25e07736d1b7385f0edb16216089
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Add a mechanism to configure the power source of
the charger indicator LED anode on the PM8921.
The configuration is specified using platform data.
Change-Id: I9a436f634ddfd5d1822f1fc8beab4936fa8bb61d
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Use the maximum number of channels added in the
ADC entry list in the board to check for channel
validity. This patch also adds additional checks
in the driver to validate the requested channel.
CRs-Fixed: 339631
Change-Id: I347f0d39a00b6ee12976ec2c24843626b54617d4
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
If HPHL and HPHR have relatively high impedance, internal MBHC HPHL
trigger cannot trigger so results in headphone/headset detection
failure.
Utilize MIC trigger as well as HPHL trigger in order to detect headphone
and headset which have high impedance on headphone line.
CRs-fixed: 339390, 337590, 336847, 334339
Change-Id: Ibfd4ba254197233f2b5e253f5d1fa2a98c848c97
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Register a PMIC pm8xxx thermal alarm device in the pm8018-core
driver. This device will allow userspace to monitor the
temperature of the PMIC die.
Change-Id: I888c0737dd991da9eaec039b20b381a2bfd7923c
Signed-off-by: David Collins <collinsd@codeaurora.org>
The charger hardware has a +/-30mv error for vdd_max settings. This
means that when vdd_max is set to 4200mV the actual voltage on vph_pwr
line could range from 4170mV to 4230mV. This further means that when
constant current to constant voltage transition happens, the battery
may not be charged up to 4200mV - leading to an premature end of charge.
Fix this by implementing periodic IR compensation. On a device measure the
resistance from the vbat terminal to the ground by shorting the +ve and
-ve of the battery terminals (without a battery), this will be referred to
as rconn in the description. In the code it is rconn_mohm to reflect the
units.
The voltage at battery terminal will be
Vbat(terminal) = Vbat(xoadc) + Ibat * rconn
where Ibat is the current flowing out of (or into if -ve) of the battery.
Vbat(xoadc) and Ibat can be obtained by using the override mode of the
bms. So Vbat(terminal) can be deduced and compensated by increasing
vdd_max. This also helps in increasing constant current mode thereby
decreasing constant voltage mode and decreasing the overall charging time.
The value of rconn will be specific to a PCB layout, it is
passed in from platform_data.
Change-Id: If8df93333ca6b0bad35505895a4fc5577562fadd
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This function is called from more places than just exit
functions. Also remove the _init/__exit markings from the header
file as they're not necessary in function prototypes.
WARNING: vmlinux.o(.devinit.text+0x7840): Section mismatch in
reference from the function pm8038_add_subdevices() to the
function .devexit.text:pm8xxx_irq_exit()
The function __devinit pm8038_add_subdevices() references
a function __devexit pm8xxx_irq_exit().
This is often seen when error handling in the init function
uses functionality in the exit path.
The fix is often to remove the __devexit annotation of
pm8xxx_irq_exit() so it may be used outside an exit section.
Change-Id: I0d2e285a03958e0fe68af48df94523aa1d0476c0
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
The compander system is intended to increase the dynamic
range of an input signal. But for the wcd9310 codec,
this feature is to use companding in a novel way in the DAC
converter path to increase the signal noise ratio.
The change is to add the compander support to wcd9310
codec. The dynamic compander enable/disable during stream
playback is not supported.
Change-Id: I916a5e4cc0a06516a691bbdcdf0103dcb7b0398c
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
* changes:
power: pm8921-bms: add api to simultaneously read vbatt and ibatt
power: pm8921-bms: calibrate xoadc more often
power: pm8921-bms: add protection against divide by zero
power: pm8921-charger: fix 10mv error on vdd_max
power: pm8921-charger: fix reverse boosting
The compensation algorithms need simultaneous readings of the battery
voltage (vbatt) and the current flowing through it (ibatt).
One needs to put the BMS in override mode to get simultaneous vbatt
and ibatt readings.
Note that since one would need to sleep for 20 milliseconds after the
BMS is put in override mode the spin_lock is changed to mutex in the bms
driver.
Change-Id: I1bfdc1f4e84d5d3c2cd6502dd66afdfba650cc0d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Improve the values of the battery voltage read from xoadc by periodically
calibrating the xoadc.
The xoadc needs to be calibrated every time a charger is plugged in
or plugged out. This is because the reference voltage shifts a bit
when a charger is plugged in.
Provide an api to calibrate xoadc. This api will be used by the charger
driver.
CRs-Fixed: 334825
Change-Id: I09735f6e5c5d4ab8be379fe001fff81c25c95397
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
PM8921 LPG banks can be configured to connect to DTESTx.
These DTEST lines can be used to observe LPG output.
Provide a feature that allows to enable DTEST modes for
a given LPG channel.
CRs-fixed: 337902
Change-Id: If881eb089aea2a66f7324af8ac906405eef4f81a
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Add support for 5 RX and 4 TX Slimbus channel support.
Headphone/Earphone/4 DMIX/2 AMIC and IIR1 support
Change-Id: I1b7ad5e5fd9d87aab80d6533503371e63df8cc0a
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
The current core assumes TABLA as the only codec driver registering.
To support single binary for multiple targets its essential that
we remove this restriction and move to a generic framework
to support multiple codec. This can be done by moving all codec
specific code to dedicated codec driver and use core driver to probe
the codec based on slimbus device id and do generic setup for the
codec. This also helps to have same boards with different flavours
of codec variants.
The WCD9XXX family of codecs share the initial codec register
mapping which holds the Slimbus device id to identify the
codec existing on the target.Core driver now registers the
codec device based on this check.
Change-Id: I4c43d5f04c20696f4f5138411460681ec7879d34
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
To ensure proper battery id dectection on LiQUID and MTP
use machine_is_msm8960/8064_mtp/cdp to determine which
calibration data to use for battery. If platform is
unknown fall back on regular battery id detection.
Change-Id: I2f5629572d1e5fcac0a2feb114947b91a96f3bf0
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Add the calibration data and battery ID information for the
Desay 5200 mAh battery which is used in LiQUID platform
devices.
Change-Id: I19ff1251ee3e71fa71d4fa0c83143d4b7667a80c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
This call configures the XO to the MP3 clocks. These
clocks route over PMIC gpios and are used as an independent
clock source for MP3, haptics.
Change-Id: Ib95f277eae8bcb9a7e9da12fc5fe2baec4e72493
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
Add the functions required to control boost regulators on PMIC
PM8XXX chips. These regulators would typically be used to output
5.0 V for USB OTG but may be programmed for voltages between
4.0 V and 5.55 V.
Change-Id: I016b9ffa41853c18fda919048eb06002d9ca0c64
Signed-off-by: David Collins <collinsd@codeaurora.org>
Previously, DSP used to setup the data path towards the
codec via slimbus. Now, the data path setup is broken into
two parts - one half of the path setup between apps to slimbus
and the other half from DSP. This configuration mode is
required to reduce overflow or underflow errors. Also this is
required to handle a configuration where mdm can talk
directly to codec.
Change-Id: Ic9f20b8a2f8a8eb355c07565ec80ec947a7a7337
Signed-off-by: Bharath Ramachandramurthy <bramacha@codeaurora.org>
The wcd9310 codec driver which is slimbus slave can access codec
registers when slimbus is suspended.
This can cause register read/write failure.
Fix to make sure slimbus is awake before accessing wcd9310 codec's
registers through slimbus.
CRs-fixed: 331338
Change-Id: Iddbdb1614c18dab4bee4f0cc7951884f34cb7173
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Add leds as a sub device to pmic 8038. This will also
take care of filling platform data for leds driver
which comes as part of pmic pdata.
Change-Id: I3814a0f36f79612684e4a2305e3c5c19dc64cb00
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
Unlike Tabla 1.x, Tabla 2.0 codec has different address of micbias 4
registers.
Check hardware version and access proper address when accessing
micbias 4 registers.
CRs-fixed: 330357
Change-Id: I5e12a6b15e82b00d2e238c21d795fdc189ead6a5
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Specify the SSBI test register address for each of the voltage
switches in PMIC 8018, 8038, and 8921 core drivers. This will
allow for future handling of over current protection (OCP) in
the pm8xxx-regulator driver.
Also define the OCP IRQs associated with each of the switches
on these PMICs.
Change-Id: Icfc51c01680e6e95b4348051c764f16cb91b4916
Signed-off-by: David Collins <collinsd@codeaurora.org>
PM8921 family provides a pullup enable bit to support USB ID.
Add the API for such support.
Change-Id: Id3056af070080c1c12f27720020ae718fc6f34f6
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
Add pre-divide=6 and update the max period based on new pre-divide.
Also update pre-divide related macros for better readability.
Change-Id: I5298c373c78f8723dab9a735e4d94f89798800d5
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
The current code assumes that the cool or warm battery temperature
can only be +ve numbers. Remove this restriction by allowing -ve
temperature settings.
Change-Id: I3c54b854a8fdf934efcf1ff21b36c7a0f763692a
CRs-Fixed: 320660
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
The PMIC PM8917 chip is very similar to the PM8921 chip. Modify
the pm8921-core driver so that it can also handle PM8917 chip
which has different number of gpios and mpps, and no LPG/PWM,
no LEDs and no vibrator.
Change-Id: I252adc2ddc4bcd9bb8b8fb5113444356ba7c969e
Signed-off-by: Willie Ruan <wruan@codeaurora.org>
Add a new API, pm8xxx_preload_dVdd, which will preload the dVdd
regulator on PMIC PM8901 chips during off state. This can help
to reduce fluctuations in the dVdd voltage during startup at the
cost of additional off state current draw.
This API should only be called if dVdd startup issues are
suspected.
Change-Id: Ic7ee60539de37a761bb9ca6c5200327a7b99da89
CRs-Fixed: 326086
Signed-off-by: David Collins <collinsd@codeaurora.org>
Add supported power devices such as charger, bms and CCADC.
These devices are required to be enabled to provide charging
functionality to the 8930 platform.
Change-Id: Iae5182ff26ba1cbcb256aeb1aee619f7a368765f
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Allow the pm8921-charger driver to initiate charging on a
registered 3rd party charging driver through the power supply class.
Also enable the maintenance of charging properties such as online
and charge type using the power supply class rather than
directly depending on the 3rd party driver.
When a external charger is registered using power_supply_register
the external_power_changed callback of the charger driver checks
for an external charger named "dc". This removes the dependency
of a 3rd party charger to call directly into the charger driver.
Also, update the isl9519q driver to reflect the changes and
utilize power supply class calls to enable charging
on the isl chip from PM8921 charger driver.
This serves as an example for other 3rd party external
chargers supporting PMIC with high current charging.
Finally, add pr_fmt macro which automatically adds function name
to print statements and remove __func__ from individual print
statements.
Change-Id: If05e598be260d924ec3263bad33317cf4e7543a1
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
HouseKeeping ADC (HKADC) on the PMIC is used by clients
to measure voltage, current and temperature. Clients
include the Battery, Charger and Thermal clients that
require reading the ADC in real time. This also
supports reading the ADC channels that are mapped through
the PMIC MPP's such as the PA THERM channel.
Change-Id: I3c4fd9d368550c1cca168ea097e0d457d01d695e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
USB can distinguish between types of USB connections such as a
DC charger or PC connection.
Let the USB drivers set the specifc power_supply_type via this
function.
CRs-Fixed: 326548
Change-Id: I31954b3f8d2b1e5fd72712e1f94f67fdbc2e205d
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Change the pm8018-core driver so that it registers devices for
the pm8xxx-regulator driver instead of for the pm8018-regulator
driver.
This necessitates changing board file platform data for existing
PMIC 8018 regulators so that additional pm8xxx-regulator data is
properly specified.
Change-Id: I3f64f756a6c48c0dd1684f8d8e98a6fa8dddd6ca
Signed-off-by: David Collins <collinsd@codeaurora.org>
Some board configurations have different needs for usb overvoltage
thresholds and debounce time for usb detection.
Provide apis to program threshold voltage, debounce time and
disable/enable overvoltage protection.
CRs-Fixed: 324137
Change-Id: Ie618ca12be819739a623cf41e5e1198305467aa5
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Add pm8xxx-regulator configuration data into the pm8038-core
driver. This adds support for PMIC PM8038 regulators.
Change-Id: I8d6e42d299141a6add3c41ca920d9186ad7fa3ee
Signed-off-by: David Collins <collinsd@codeaurora.org>
Change the pm8921-core driver so that it registers devices for
the pm8xxx-regulator driver instead of for the pm8921-regulator
driver.
This necessitates changing board file platform data for existing
PMIC 8921 regulators so that additional pm8xxx-regulator data is
properly specified.
Change-Id: I0d48f03344265bd1b7c160bceca944f8924c694c
Signed-off-by: David Collins <collinsd@codeaurora.org>
Create a PM8XXX regulator driver that can support PMIC PM8921
variants including: PM8018, PM8038, and PM8921.
Change-Id: I60d1302e4af9a4c5caa72301c904867acd2ebe0f
Signed-off-by: David Collins <collinsd@codeaurora.org>
pm8xxx_hard_reset_config implements the required functionality,
replace the pm8058 specific call with this.
Remove ssbi_read/ssbi_write functions used in pm8058_hard_reset_config.
Remove unused variable(pm_lock) and enum(pon_config, pm8058_smpl_delay).
Change-Id: I3c5982ebab9277dc088bd3abd5621eb9acf3add9
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
pm8xxx_stay_on implements the required functionality internally.
Modify other occurrences of pm8058_stay_on to pm8xxx_stay_on.
Change-Id: I1c4d932789c6b5592bcbc6fc718d037f188d0e56
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>