thermal: tsens8974: Fix delay in the TSENS handler

Add a workqueue to process the status register reads for
the sensors to verify if sensors thresholds are crossed
and send uevent to clients. This change is to avoid any delay
within the TSENS interrupt handler.

Change-Id: I3f3b713a84a6e74fb94e27b8a69be3b1dd0a9dac
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
thermal: tsens: Leave sensors enabled on TSENS init.

This change allows kernel thermal mitigation to read sensors
that are not the main sensor (TSENS0) even after the driver probe
occurs.

Change-Id: I84927592be60ba5795c641a4ff7c467d39acf75b
Signed-off-by: Eugene Seah <eseah@codeaurora.org>
thermal: pm8xxx-tm: Modify userspace notification method

Change the userspace notification mechanism in the over
temperature interrupt handler from kobject_uevent() to
sysfs_notify() in order to simplify userspace notification
handling.  Ensure that the new notification mechanism is
independent from the current pm8xxx-tm mode.  This means that the
"mode" thermalfs file does not need to be modified in order for
sysfs_notify() to get called in the interrupt handler.

As before, writing "enabled" to mode will enable the software
override of the automatic PMIC hardware stage 2 partial shutdown
and stage 3 full shutdown.  Turning off these features is
typically undesirable and should be avoided unless userspace is
able to take immediate corrective action.

Change-Id: Ibd92b790778fd559df5ce74231e6cf71bef16370
Signed-off-by: David Collins <collinsd@codeaurora.org>
thermal: pm8xxx-tm: Improve temp alarm logging and notification filtering

Modify the kernel log message which is output when the PMIC
temperature alarm triggers so that the current (or estimated)
PMIC die temperature is shown regardless of ADC type.

Also change the log message printing and userspace notification
logic so that they only happen when the PMIC temp alarm stage
differs from what was previously seen.  This will reduce the
number of messages seen while the temperature fluctuates around
one of the thresholds.

Change-Id: I5ee2206ea05dee86666308d11dad1fc5560e58e0
Signed-off-by: David Collins <collinsd@codeaurora.org>
thermal: pm8xxx-tm: Use delayed_work task for temp alarm status reading

Use a delayed_work task to wait at least 40 ms in order for the
temp alarm status value to be updated after the TEMP_STAT IRQ
goes high.  Also remove IRQ enable and disable calls in the ISR
since the work item can only be enqueued once before it is run.

Change-Id: Ib5f13d0e82258b399749de96152c081d71981909
Signed-off-by: David Collins <collinsd@codeaurora.org>
thermal: pm8xxx-tm: Add configuration option for allowing shutdown override

Add a field to the PMIC thermal alarm core data named
allow_software_override which is used to control whether or not
userspace may switch the mode of a PMIC thermal device to
"enabled" in order to enable software override of PMIC automatic
over temperature shutdown.

allow_software_override -
true:  writing "enabled" to thermalfs mode file results in
       software override of PMIC automatic over temperature
       shutdown.
false: PMIC automatic over temperature shutdown is always
       enabled.  mode file cannot be set to "enabled".

Change-Id: I4c47fdf0c0c4704008591755296118ad7fac95ae
Signed-off-by: David Collins <collinsd@codeaurora.org>
thermal: tsens8960: Add platform detection

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>
thermal: pm8xxx-tm: Configure temperature alarm for always-on operation

Change the register initialization for the PMIC temperature alarm
module so that it is always on.  This ensures that die
temperature monitoring is active even if CXO is disabled (i.e.
when sleep_b is low).  This is necessary since CXO can be
disabled while the system is still heavily loaded.  Also, using
the alway-on instead of PWM-enabled configuration ensures that
the die temperature can be measured by the PMIC ADC without
reconfiguring the temperature alarm module first.

Change-Id: I4a76c959c81f222fbeca08b6c98b1e4b23653b4e
Signed-off-by: David Collins <collinsd@codeaurora.org>
thermal: tsens8960: Increase the polling rate

Change the polling rate at which the sensors temperature
is read from 1 second to .25 seconds. On faster parts
there is a need to poll the temperature at a higher
frequency to improve reporting temperature changes.

Change-Id: I10049707c3e55316597fff72fbd00246cd29bed3
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
thermal: tsens8960: Add api to read max supported sensors

Provide api to report the maximum number of TSENS sensors
supported. Backport this from the 8974 TSENS driver
to support thermal monitor driver compilation.

Change-Id: I712ccd8169eb3df0f1e83189aea1dd98180c3e7d
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:
	drivers/thermal/msm8960_tsens.c
	include/linux/msm_tsens.h
intelli/msm_thermal: initial coding for Qualcomm S4 Pro devices

an intelligent MSM thermal throttling kernel driver designed to replace the
closed sourced thermald(aemon) from Qualcomm.

The current driver can throttle the SOC via core frequency scaling or via
core hotplug with user configurable sysfs entries to adjust the throttling
temperature thresholds for each.

Derived from Qualcomm's Open source repo.

Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:

	arch/arm/mach-msm/lge/mako/board-mako.c
v1.3