TSENS is not supported on the MSM8960 1.0 because of a
HW bug. The driver used a platform detection mechanism
through a flag. With the 8960PRO the CPU MAJOR
version resets back to major version 1. The driver
does not distinguish the PRO parts differently and
disables the driver. Change the method to detect
the CPU using the platform detection api instead
of relying on the platform data.
Change-Id: I446eb196cf81e6a29760530dfbce6910652e867c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit 30447fec965309e30f1eb33c0d318ee4a5365026)
(cherry picked from commit 25bb62fbbc050147ae298179d7abe4ad08f78371)
This change allows kernel thermal mitigation to read sensors
that are not the main sensor (TSENS0) even after the driver probe
occurs.
Signed-off-by: Eugene Seah <eseah@codeaurora.org>
(cherry picked from commit bf8b0777937ab5f06f81d7b26cb7226f69099f70)
Change-Id: I4ab19b6b7604344f91700340115dcf6c4ecfe820
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
There are more sensors on APQ8064 and MSM8930 whose status registers are to be
read and checked against enabled sensors if thresholds interrupts are crossed.
This causes delay in processing the ISR before it is returned causing other
timer events to be delayed.
Fix this by performing the status register reads for the sensors in a separate
workqueue.
CRs-Fixed: 390508
Change-Id: I7b254d0d73dfefb667e7bf9484ae704fe4ff38a8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
MSM8x30 and APQ8064 share the same TSENS block. However
the remote sensor 10 on the MSM8x30 is not calibrated. Hence
disable the sensor since its not exposed as a thermal node.
Having the remote sensor enabled leads to incorrect TSENS
threshold trip point getting triggered.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Change-Id: I3cf4d844c806fd2cd9c9e09b5134be46ed361b31
Signed-off-by: David Brown <davidb@codeaurora.org>
TSENS does not operate reliably during VDD_CX minimization.
Incorrect temperature readings are reported on some instances
when Apps processor comes out of suspend. This leads the
TSENS reporting incorrect temperature during system resume.
Change-Id: I882b37fbe290477926c3a242d3092be8b950dfab
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
[davidb: only drivers/thermal]
Signed-off-by: David Brown <davidb@codeaurora.org>
MDM9615 has identical configuration for the number
of sensors and slope with MSM8960. Add support to
enable the TSENS for calibrated parts.
Change-Id: Ieb1f118ce916ab5a4f079b18b11541d86c3a5560
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
[davidb: only drivers/thermal]
Signed-off-by: David Brown <davidb@codeaurora.org>
Increase the character buffer to support the string length for
sensor10.
Change-Id: Ib1f49cea22604267f2a7fecb1eee4ef3e9e03615
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Thermal driver in kernel currently requires the main sensor
to perform mitigation. Disable all the auxiliary sensors
and update the mode of the main sensor as being enabled during
TSENS init.
Round the converted temperature to the nearest degree.
Remove unwanted register reads added for debug and reference
to magic numbers in the code.
Change-Id: Id5652ba16f9adb462dc61266600f394901eee194
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
TSENS is used by the thermal daemon for thermal management.
On APQ8064 there are 11 TSENS sensors that can be used by the
thermal daemon to monitor the temperature across the chip.
TSENS for APQ8064 supports individual slope for each of the
sensors. The offset used in the temperature from each of the
slope is used for temperature calcuation from the ADC code.
Change-Id: I00457aff8d67ab3367882ffe1077af863b90bc49
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
The initialization code uses the tmdev variable as an indicator as to
whether or not early initialization succeeded. However, when early init
fails, it only kfrees the pointer, it doesn't set it to NULL. This
causes us to dereference the now-freed pointer.
Additionally, squash the message that prints each time we fail to read
the temperature sensor, and print a warning to the kernel log when tsens
calibration data is not present.
Change-Id: Iab400cac687cdbc36d8c69541675c29a0b82c704
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Add kernel API to read TSENS temperature for clients
in the kernel space. Currently the TSENS driver only
supports reading the TSENS temperature from the
thermal sys.
Split the TSENS initialization into two parts.
First is to perform the initial calibration that is
used to convert the raw ADC code to Degrees Celcius
and initialize the TSENS HW. Second is to register the
TSENS driver to the linux thermal framework and create
the temperature zones that will be accessed by the
Thermal daemon to set thresholds, read the temperature
and receive notifications.
Change-Id: Id2305a7aa755e1e9cfaecd8b5c1870ed05d9b5e9
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
TSENS does not shutdown the device when the Min/Max
thresholds are crossed. Setting the thresholds to the
lowest allowed Min threshold covers cases if there is
a threshold check in the kernel driver outside of the
TSENS driver. Thermal daemon sets the lower/upper
thresholds and the TSENS sends all notification to the
daemon to take the appropriate action.
Change-Id: Icc72e27bf0b8b9184a891e024b280fc642e7e628
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
TSENS driver does not handle the decision to shut down
the device on critical temperature events. The thermal
daemon is notified to take appropriate action.
The thermal sys framework expects the kernel driver to
handle critical events. If the kernel driver does not
have any provision to handle such events the thermal
sys takes action to shutdown the device. Adding the
notify api is to avoid such an action from the thermal sys.
Change-Id: I4bdddb5db040246df40389d3a487a22e66b0820f
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Fix reading from the correct QFPROM sensor4 address for offset
value to calculate calibration.
Change-Id: I6b044a078b3b8f88802367044d773534ae679e05
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Split the writes to the TSENS controller to first enable
the CLK in the first write and enable the TSENS block in
the following write.
Change-Id: Ia5116b6b7cb3a60f8dcc40b8558112d594c63357
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Set initial value for rc in calib sensors routine.
Change-Id: Id75d1fd094f33597a9693f2ea10fcd96116bb9d0
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Current code uses default calibration offset value. Switch
over to using Calibrated offset value read from the QFPROM
to calculate the slope and offset and compensate it with the
temperature read from TSENS.
Change-Id: Ifa839f284acb7d5bba07ff46d986eeebd2132dd2
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
8960 TSENS is not supported on V1 version. Enable it only
for V2 version.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
TSENS V2 supports reading from multiple sensors and
notifiying clients when the lower/upper thresholds
are reached. The lower/upper threshold use the last
sensors threshold that are set through the thermal sysfs.
TSENS HW is enabled only when the main sensor is requested.
The TSENS block is disabled if the main senors is disabled
irrespective of any other sensors that are being enabled.
When TSENS receives notification on temperature threshold
being reached, it checks and sends events to the sensors
that are enabled and whose thresholds are above the upper
or below the lower thresholds set in the tsens threshold
register.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>