Commit Graph

59 Commits

Author SHA1 Message Date
Rama Krishna Phani A 18e1a9e525 hwmon: qpnp-adc-voltage: Add version check for VADC thermistor channels
pa-therm, xo_therm channels are used for reading the temperature.
Calibration type for above thermistor channels has to be absolute
for PM8950 1.0 and ratiometric for PM8950 2.0. Add version check to
detect the PMIC used and update the calibration type accordingly.

Change-Id: Ie2ab723152eb0a94a163e484c0d694e8bc327e5d
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-05-27 23:48:19 -07:00
Siddartha Mohanadoss aa11ec8c1e hwmon: qpnp-adc-voltage: Add version check for CHG_TEMP channel
CHG_TEMP VADC channel used for reading the charger temperature
is not available on PMI8994 1.0. Add version check to return
an error if clients try and read this channel on the PMI8994 1.0
version.

Change-Id: I6443ca37f1312d0c4088d7ad6af01a0cdc75d3e0
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2015-05-07 17:38:51 -07:00
Siddartha Mohanadoss 9ed5a165d2 hwmon: qpnp-adc: Add scaling support for PMI CHG channel
The voltage measured by the HKADC is related to the junction
temperature and scaled by the following equation
tj = -138.89degC * (v_adc * 2) + 391.75degC

Change-Id: Ibd6185c3926f9f5e482b3990adff3eee61e7caa5
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2015-05-07 12:42:29 -07:00
Siddartha Mohanadoss bd037065f4 hwmon: qpnp-adc: Remove function qpnp_vadc_check_result()
The function qpnp_vadc_check_result() checks the code against
ideal min/max for 0V and 1.8V and truncates the result within
these values. However if there is a positive offset the ADC
value can be greater than 0xA800 when applying a voltage of
1.8V. Similarly if the offset is negative the value can be
less than 0x6000 when applying 0V. Having this check can
result in incorrect ratiometric calibration if the value
read for 0V and 1.8V is outside the ideal ADC code and
the value is truncated by this function call.

Change-Id: If0c89ac4bffdea5438e256233860b2aca80e826b
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2015-04-24 14:22:15 -07:00
Chunmei Cai 9994d296b5 thermal: qpnp-adc-tm: add new scale function for skue battery thermistor
The skue is using the different battery thermistor and mapping table
from the default. A new scale function is needed to use this mapping
table in the thermal adc driver.

Change-Id: Ib154bafe821ceae33803efced3c15321a39f1dad
Signed-off-by: Chunmei Cai <ccai@codeaurora.org>
2015-04-09 18:50:00 -07:00
Rama Krishna Phani A 95664ba414 hwmon: qpnp-adc-common: Add absolute calibration support
Incorrect channel readings are observed for xo_therm , pa_therm.
Changing the calibration type to absolute.

Change-Id: Ibec68b5c20206f26e1dfb4be2e02288696a64b9d
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-04-08 09:28:07 -07:00
Zhenhua Huang 61ae5f5423 hwmon: qpnp-adc: add battery thermistor mapping table for 8929 SKUL
Update battery thermistor mapping table for SKUL.

Change-Id: I83143693af83ca2ae0af481878eba1ec16003ee8
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
2015-03-12 15:08:57 +08:00
Siddartha Mohanadoss 994647d879 hwmon: qpnp-adc: Add support to vote for a regulator
Add support to vote for HKADC LDO and HKADC LDO ok signal
if needed.

Change-Id: I92dcb8bf0495e93a8eaedabfbd82c3cc9a527f7c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2015-02-26 19:24:06 -08:00
Chunmei Cai 5ffa033b23 hwmon: qpnp-adc: add battery thermistor mapping table for 8909 skue
Tcold = -20 DegC and Thot = 60 DegC are used for 8909 SKUE device.
Update battery thermistor mapping table for it.

Change-Id: Id07a66fc343c8375dd6e8ae466ff6c0e700f58cc
Signed-off-by: Chunmei Cai <ccai@codeaurora.org>
2014-12-28 18:05:47 -08:00
Dipen Parmar 01486504b1 hwmon: qpnp-adc-voltage: Add temperature compensation for PM8909
Add VBAT and OCV temperature compensation for PM8909
v1.0 SMIC parts.

The temperature compensation is required on top of
gain/offset calibration to compensate for variations
due to chip revision, manufacturer and temperature.

Change-Id: Ic0f110ed53dba314196af31c16c1fd58d20f7f1d
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-12-12 12:43:51 +05:30
Chunmei Cai 1f1ffd790a hwmon: qpnp-adc: add battery thermistor mapping table for 8909 skuc
Tcold = 0 DegC and Thot = 50 DegC are used for 8909 SKUC device.
Update battery thermistor mapping table for it.

Change-Id: Ib519fe67c4ad69d2727000fae1e4f1bd181c2355
Signed-off-by: Chunmei Cai <ccai@codeaurora.org>
2014-12-03 09:17:24 +08:00
Dipen Parmar 01d25e1586 hwmon: qpnp-adc-voltage: Avoid adc code check with recalibration
In VADC driver with recalibration parameter enabled and
MPP2 or MPP4 current sink configuration some ratiometric
channels report the adc code higher than maximum permitted
value.

VADC driver checks the adc code against the permitted
maximum value and overwrites adc code to permitted maximum
value if it is higher and this results into incorrect adc
readings.

Fix this problem by avoiding the adc code check when
recalibration parameter enabled.

Change-Id: Ic1bcc8b4e52cddc013cf1654c229c22fd348159e
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-11-14 16:58:16 +05:30
Linux Build Service Account e652d8b007 Merge "hwmon: qpnp-adc: add battery thermistor mapping table for SKUT1" 2014-11-10 03:57:59 -08:00
Siddartha Mohanadoss 7089f0861f hwmon: qpnp-adc: Fix incorrect threshold calculation
Fix using the correct types when performing integer
arithmetic.

Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Change-Id: I712a22d3f550efac1d059e1dd3ae933a3de84acd
2014-10-31 15:02:26 -07:00
Gustavo Solaira 81525fe355 hwmon: qpnp-adc: add battery thermistor mapping table for SKUT1
Tcold = 0 DegC and Thot = 45 DegC are used for 8916 SKUT1 device.
Update battery thermistor mapping table for it.

Change-Id: I53a27c73973bb94d998485b2037d54ff833b54bd
Signed-off-by: Gustavo Solaira <gustavos@codeaurora.org>
2014-10-28 17:25:44 -03:00
Siddartha Mohanadoss ae731133c8 hwmon: qpnp-adc: Add reverse scaling API
Add separate VADC reverse scaling function to consider
the channel properties that include the pre-div scaling
for the reverse calibration on VADC channels to support
recurring channel measurement mode.

Change-Id: Ifd863c3c3fd0c3c7f93b80fac8cf186f10c69e38
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-10-15 15:23:02 -07:00
Linux Build Service Account a41cba90d2 Merge "hwmon: qpnp-current: Fix parameter configuration for IADC" 2014-08-08 12:02:21 -07:00
Dipen Parmar d31e4aee0f hwmon: qpnp-current: Fix parameter configuration for IADC
Removing redundant parameters which are not applicable
on the IADC peripheral.

Fix the issue with "fast_avg_setup" and "decimation"
parameters to configure correctly as per channel
configuration.

Change-Id: Idfe823effc6255b57e31f37621971aab29f08020
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-07-25 11:51:04 +05:30
Chunmei Cai c6fff61bda power: qpnp-charger: double check BAT_THERM voltage in BTC_HOT irq
BTC_HOT interrupt might be triggered by glitches on BAT_THERM pin and
causes charging stopped unexpected.

Using VADC to sample the voltage on BAT_THERM pin when BTC_TEMP_OK
interrupt triggered and BAT_TEMP_STATUS is HOT. If HOT_THD is set
to 35% of the VREF_BAT_THM, and the voltage sampled on BATT_THERM
is higher than HOT_THD, override BTC VCP_DET comparator and toggle
HOT_THD setting to 25% to take charging back immediately.

CRs-Fixed: 685765
Change-Id: I83b3d2b8eb430be20418ba0b58c0eb8d7b8f22ec
Signed-off-by: Chunmei Cai <ccai@codeaurora.org>
2014-07-23 13:27:16 +08:00
Venkatesh Yadav Abbarapu 0f45ef107f hwmon: qpnp-adc Add support for fsm9900 target
Add support for thermistor design and mapping
table used on fsm9900 target.

Change-Id: I1c22e6a55ddb5dfcb75b69ec6f807f8c2d6b2eb8
Acked-by: Jim Granitzki <jamesg@qti.qualcomm.com>
Signed-off-by: Venkatesh Yadav Abbarapu <quicvenkat@codeaurora.org>
2014-05-28 18:15:04 +05:30
Jie Cheng 387fd20c2c thermal: qpnp-adc-tm: add new scale function for skuh battery thermistor
The skuh is using the different battery thermistor and mapping table from
the default. A new scale function is needed to use this mapping table in
the thermal adc driver.

Change-Id: I63fb02244b55b51d967b85a90cc700ef1764d20d
Signed-off-by: Jie Cheng <rockiec@codeaurora.org>
2014-05-21 15:57:01 +08:00
Zhenhua Huang dc04bdbe7b hwmon: qpnp-adc: add battery thermistor mapping table for skuh
Tcold = 0 DegC and Thot = 58 DegC are used for 8916 SKUH device.
Update battery thermistor mapping table for it.

Change-Id: I37a76022d7488734924d5fe213bc86dbf0fcea07
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
2014-05-20 04:57:40 -07:00
Dipen Parmar d90e1aba36 hwmon: qpnp-adc-voltage: Update default scaling API
Update default scaling API to support absolute and
ratiometric calibration both to convert raw adc data
to voltages.

Change-Id: I45a109d77c388564c0063d1de926813a4a929c48
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-05-15 18:07:38 +05:30
Ashay Jaiswal c55724f021 hwmon: qpnp-adc: add PM8916 1.0/1.1/2.0 temperature compensation
Add temperature compensation coefficients for PM8916 VADC to improve
accuracy.

Change-Id: I578185c5c1d852b3f8bb02bb68ce460828369a5b
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
2014-04-29 19:14:17 +05:30
Dipen Parmar 4c3c5b31f4 hwmon: qpnp-adc: Add smb batt_therm reverse scaling
Add reverse scaling function for smb batt_therm.

Change-Id: Ic81078b9738ee5ee60f505316dd9dbebea8c58fc
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-03-24 17:47:39 +05:30
Siddartha Mohanadoss d9e1a21bb1 hwmon: qpnp-adc-current: Fix offset channel selection
On PM8941 depending on the status of the BATFET
the reads on channel 0 for Internal RSENSE go to
channel 5 therefore the offset is performed on that
channel. This is applicable to only to PM8941 and
not on PM8026 and PM8110. Therefore apply the check
for offset channel selection based on the BATFET
status on PM8941 only.

Change-Id: I146b244c2b562664b85e804694f8d4b2aac3fa86
CRs-Fixed: 629758
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-03-12 19:27:56 -07:00
Siddartha Mohanadoss ea8cd32a7c thermal: qpnp-adc-tm: Add reverse scaling
Add reverse scaling to convert voltage in uV using absolute
calibration to raw ADC code written to set high/low threshold
for a specified BTM channel.

Change-Id: Ic56465df5ab60100cffe4303ff983480b71c0c95
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-03-05 18:43:08 -08:00
Siddartha Mohanadoss b69ed0a419 hwmon: qpnp-adc-current: Add temperature compensation
Add temperature compensation for IADC PM8026v2.2.
It shares the same temperature compensation parameters
as PM8026v2.1. The temperature compensation is required
on top of gain/offset calibration to compensate for
variations due to chip revision, manufacturer and
temperature.

Change-Id: Ic39ba249d8d28c36bf59d650dcc2c2a3889ee55b
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-01-28 19:53:38 -08:00
Wu Fenglin 00b02e95f4 hwmon: qpnp-adc: add battery thermistor mapping table for skug
Since the new values of parameters including Rs1=30.3K,
Rs2=12.8K, Tcold=-15DegC and Thot=55DegC are used for
skug device, we add a new table accordingly.

Change-Id: I89d86274c5c198f904766d818cb2a7882c462496
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
2013-12-26 11:52:44 +08:00
Dipen Parmar add0879f00 hwmon: qpnp-adc: Add check for wrong calib data
Add check when adc calibration data are similar
for both reference channels and return error to
avoid division by zero errors.

Change-Id: Id884eb79f606fb7361fc47a96e7a6f009a113869
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2013-12-18 18:02:30 +05:30
Xiaozhe Shi 6c5843508e hwmon: qpnp-adc: add PM8110 2.0 temperature compensation info
Add in support for PM8110 2.0 temperature compensation. Also, fix a few
bugs in the ADC compensation algorithm where 25C was treated as 2.5C.

Change-Id: Iafa3ceca2b5938432116ecc905dd54b2da7c4b0b
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
2013-11-12 14:55:43 -08:00
Siddartha Mohanadoss b8e1e4f4de hwmon: qpnp-adc-common: Reduce kernel error prints
Update the revid check to use pr_debug instead of
pr_err to reduce potential errors to get printed.
This is an optional property as far is IADC is concerned
to apply temperature compensation for the supported chips.

Change-Id: I77036fb9f0eb640e43216762461ba036b2aa0caf
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-10-24 15:51:06 -07:00
Siddartha Mohanadoss acec6c4e3c hwmon: qpnp-adc: Add smb batt_therm mapping table
The batt_therm connected to SMB THERM uses a
100K pull-up. This channel can also be read through
PMA8084 VADC. Add resistive divider table that
converts voltage to temperature in decidegC for the
corresponding battery thermistor.

Change-Id: I7af1c6b74a14d292c7cff37f5e9673980df67912
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-10-11 11:14:46 -07:00
Siddartha Mohanadoss e17597ed0d hwmon: qpnp-adc-current: Add temperature compensation
Add temperature compensation parameters for PM8026 2.1.
Compensate the vbatt voltage for temperature variance above
25degC. Add similar compensation for current compensation.

Also update using the revid api's to check for PMIC revision
instead of using peripheral revision registers. Using
revid PMIC api's makes it easy to follow on what PMIC versions
are the temperature compensation being applied to. Depending
on VADC/IADC revision registers alone may not suffice since
there is no correlation between the individual peripheral
revision and the PMIC number. You could have the same
VADC revision on different PMIC's and to avoid such a scenario
use the PMIC revid.

Change-Id: I90adb1130b2e2461f762df774ddcd018e806cf78
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-10-08 16:01:02 -07:00
Xu Kai 2983a75b71 hwmon: qpnp-adc: add battery thermistor mapping table for msm8610 qrd skuaa
Since the new values of parameters including Rs1=17.8K,
Rs2=6.1K, Tcold=-5DegC and Thot=55DegC are used for
msm8610 qrd skuaa, we add a new table accordingly.

Change-Id: I14eab97a012de62cfdddf1df920ce16ac0f3561c
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
2013-09-04 17:17:10 -07:00
Xu Kai f110b4ab2d hwmon: qpnp-adc: modify qrd battery thermistor mapping table
Change the battery thermistor voltage under the corresponding
temperature based on the values of parameters including
R0=10.0K @ 25DegC, Rs1=13.0K, Rs2=2.1K, B=3380K, Tcold=0DegC
and Thot=45DegC.

Change-Id: Icc6957946b456be4cfecc18c92cc79db85ea215e
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
2013-09-04 17:17:08 -07:00
Siddartha Mohanadoss 000325beb7 hwmon: qpnp-voltage: Support multiple device instance
Support multiple voltage ADC device instance. Clients
need to register with the voltage ADC using the device
consumer name used to associate with the corresponding
phandle of the VADC. Clients receive the device instance
which is to be used everytime an ADC request is made.

This change involves changing the interface to issue
ADC request and the corresponding clients changes.

Change-Id: If0557bc657fecd172a8cf960900ee93b4bce37f8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 17:14:32 -07:00
Siddartha Mohanadoss 166c415666 hwmon: qpnp-adc: Fix potential errors
There is a possibility of potential out of bound array
access errors and uninitialized variable access from code
inspection. Add additional checks in voltage ADC and
TSENS to check for such errors.

Change-Id: I1213cd76fb636aa457c88d3bdc3740b692f01cce
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 17:09:55 -07:00
Siddartha Mohanadoss 4b6caea204 hwmon: qpnp-adc: Add battery thermistor mapping table
Add mapping table used for converting battery thermistor
voltage to the corresponding temperature based on
the qrd resistive divider circuit.

Change-Id: I5d3a8fd446cc59e30192485f28a9436e5517350f
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:28:24 -07:00
Siddartha Mohanadoss 08501a45d1 thermal: qpnp-adc-tm: Add die_temp debug logs
Add more die_temp debug logs and fix the units for
converting millidegC to K during reverse calibration.
Also add bound checks in the status read to prevent
spurious interrupts.

Change-Id: I888216383ae9e8aed83bc5b22b4e36499b500c11
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:26:16 -07:00
Stephen Boyd a947a2fa21 hwmon: qpnp-adc: Initialize adc mutex in each driver
The qpnp adc drivers take different mutex locks one after the
other but lockdep can't figure that out because each mutex is
intialized with one call to mutex_init() in
qpnp_adc_get_devicetree_data(). Move the mutex initialization to
each caller so that lockdep can see different lock classes for
each adc mutex. This silences the below recursive mutex warning.

=============================================
[ INFO: possible recursive locking detected ]
3.4.0-gc11e688-00030-g8f5e269-dirty #567 Tainted: G        W
---------------------------------------------
kworker/u:2/21 is trying to acquire lock:
 (&adc_qpnp->adc_lock){+.+...}, at: [<c04c0918>] qpnp_iadc_read+0x64/0x174

but task is already holding lock:
 (&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&adc_qpnp->adc_lock);
  lock(&adc_qpnp->adc_lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

6 locks held by kworker/u:2/21:
 #0:  (deferwq){.+.+.+}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
 #1:  (deferred_probe_work){+.+.+.}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
 #2:  (&__lockdep_no_validate__){......}, at: [<c0339670>] device_attach+0x18/0xa4
 #3:  (&chip->last_ocv_uv_mutex){+.+...}, at: [<c04b8b74>] recalculate_soc+0x190/0x124c
 #4:  (&iadc->iadc_vadc_lock){+.+...}, at: [<c04c0aa8>] qpnp_iadc_vadc_sync_read+0x40/0xe4
 #5:  (&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198

stack backtrace:
[<c00140cc>] (unwind_backtrace+0x0/0x11c) from [<c00d6ea8>] (__lock_acquire+0x238/0x1784)
[<c00d6ea8>] (__lock_acquire+0x238/0x1784) from [<c00d895c>] (lock_acquire+0xf0/0x138)
[<c00d895c>] (lock_acquire+0xf0/0x138) from [<c079aa50>] (mutex_lock_nested+0x5c/0x3d8)
[<c079aa50>] (mutex_lock_nested+0x5c/0x3d8) from [<c04c0918>] (qpnp_iadc_read+0x64/0x174)
[<c04c0918>] (qpnp_iadc_read+0x64/0x174) from [<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4)
[<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4) from [<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68)
[<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68) from [<c04b927c>] (recalculate_soc+0x898/0x124c)
[<c04b927c>] (recalculate_soc+0x898/0x124c) from [<c04b9cfc>] (calculate_soc_work+0x10/0x4c)
[<c04b9cfc>] (calculate_soc_work+0x10/0x4c) from [<c07750f8>] (qpnp_bms_probe+0xeac/0x1228)
[<c07750f8>] (qpnp_bms_probe+0xeac/0x1228) from [<c037d6b0>] (spmi_drv_probe+0x10/0x14)
[<c037d6b0>] (spmi_drv_probe+0x10/0x14) from [<c0339884>] (driver_probe_device+0x134/0x338)
[<c0339884>] (driver_probe_device+0x134/0x338) from [<c0337d28>] (bus_for_each_drv+0x48/0x8c)
[<c0337d28>] (bus_for_each_drv+0x48/0x8c) from [<c03396d8>] (device_attach+0x80/0xa4)
[<c03396d8>] (device_attach+0x80/0xa4) from [<c0338bdc>] (bus_probe_device+0x28/0x9c)
[<c0338bdc>] (bus_probe_device+0x28/0x9c) from [<c0339144>] (deferred_probe_work_func+0x68/0xa0)
[<c0339144>] (deferred_probe_work_func+0x68/0xa0) from [<c00a7f54>] (process_one_work+0x298/0x528)
[<c00a7f54>] (process_one_work+0x298/0x528) from [<c00a83a8>] (worker_thread+0x198/0x2b8)
[<c00a83a8>] (worker_thread+0x198/0x2b8) from [<c00ad2fc>] (kthread+0x90/0xa4)
[<c00ad2fc>] (kthread+0x90/0xa4) from [<c000edcc>] (kernel_thread_exit+0x0/0x8)

Change-Id: Iebda9a8dfc407273748545bb81f91d6dc27e97cc
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2013-09-04 16:25:59 -07:00
Siddartha Mohanadoss 691cfcfd09 hwmon: qpnp-adc-common: Fix setting reverse vbatt values
Use int64_t type to while scaling the threshold values with
absolute calibration arithmetic avoid overflow errors.

Change-Id: I29d3b4ad71776a45ec1cd2c076b0f058b7bf8723
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:24:13 -07:00
Siddartha Mohanadoss 6ea00c94ac hwmon: qpnp-adc-common: Fix vbatt reverse scaling
Update the scaling function for vbatt reverse scaling
api to fix issues while performing integer operations.
Clients request the voltage in micro-volts and the
reverse scaling fix is the use the correct absolute
reverse scaling function to convert it to voltage thresholds.

Change-Id: Iea61b768daf708b4f59e5728ed1249dd60f18258
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:15:53 -07:00
Siddartha Mohanadoss a232715673 hwmon: qpnp-adc: Use EXPORT_SYMBOL
Remove instances of EXPORT_SYMBOL_GPL from the qpnp-adc driver.
Use EXPORT_SYMBOL instead.

Change-Id: If598d64a7978af8a8c1671fec9b11b6ac81d5517
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:14:57 -07:00
Siddartha Mohanadoss 6fe3a4edab hwmon: qpnp-adc-tm: Modify the btm scaling function
For battery client the warm temperature equates to a low voltage
threshold and cool temperature equates to a high voltage. Factor
it in the reverse scaling when client enters the temperature
threshold.

Change-Id: I884319bd53f4c3c563f4536a6a3462ebdf805898
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:13:43 -07:00
Siddartha Mohanadoss 0194e1fc25 hwmon: qpnp-adc-tm: Optimize and add more TM channel support
The change adds 3 additional channels and run-time
detects the supported number of channels to allow
clients to set threshold notification.

To support this, optimize the kernel api used to configure
and start a threshold monitoring request to include multiple
clients thus avoiding the need to have seperate kernel api's
for different clients. Changes are made to avoid the driver
depending on the order in which the VADC_TM DT channel
nodes should be added. Support is now included to
monitor DIE temperature for reading the pmic_therm, VBATT
and msm_thermistor scaling functions.

The change also disables the bank when an interrupt is
received or any changes are to be made in the settings,
make sure no measurements are in the queue, settings updated
and the bank is re-enabled.

Change-Id: I7a7c03857c86127dd6f1055df17099ecff4bb2f7
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 16:13:28 -07:00
Siddartha Mohanadoss ba2c302212 hwmon: qpnp-adc-common: Fix usb scaling
USB scaling should use ratiometric calibration when
performing reverse calibration to calculate set
thresholds written for threshold monitoring as it uses
the 100k pull-up.

Change-Id: Ic4317ecd9d69b17f11618abc66ae609b744f8d6e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 15:55:41 -07:00
Siddartha Mohanadoss 7a007578df hwmon: qpnp-adc-common: Update xo_therm scaling function
Use the 100K pull-up voltage to temperature mapping table
for xo_therm. The units returned to the user is in degC.

Change-Id: I63caac691df242d3cf8595fa161114042305e16c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 15:46:40 -07:00
Siddartha Mohanadoss a54f59cdb0 arm/dt: Update AMUX channel number property
Update AMUX devicetree channel node to include the reg property.

Each channel node has an index value to represent the AMUX channel
number that is used to select the corresponding analog input. The
reg property can be used to represent the above channel number
and conforms with the devicetree spec.

Change-Id: Ica53255354006ca44c57b6ca13e84fd7fb6b02de
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 15:43:26 -07:00
Siddartha Mohanadoss 758a9c329c thermal: qpnp-adc: Add thermal monitoring ADC driver
The thermal monitoring QPNP ADC driver is used for
monitoring multiple channels with recurring
measurements. It configures the VADC_TM peripheral
to set voltage and temperature thresholds and
notifies clients once the thresholds are crossed.

Upto five channels can be individually configured
for input channel, interval time, low and high
threshold.

The driver is added as part of the thermal sysfs
interface to provide the thermal clients the
ability to set temperature thresholds and receive
notification. Clients can separately enable/disable
low/high temperature thresholds for notification.
Channels 3 through 5 are allocated for thermistor
channels that can be used by the thermal clients
using thermal sysfs for temperature threshold
notification.

Separate kernel api's are provided for usb_id
and batt_therm driver to set voltage and temperature
threshold notifications. TM Channels 0 and 1 are
statically mapped for usb_id and batt_therm monitoring
respectively.

Change-Id: I8de8a494d68d3b29c029fdc7d650a8b74f17a645
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2013-09-04 15:43:25 -07:00