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>

Conflicts:

	drivers/thermal/pm8xxx-tm.c
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: 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>