ARM:OMAP4:Thermal Framework:TMP102 registration

ARM:OMAP4:Thermal Framework:TMP102 registration

The external sensor registration to omap die governor. The
sensor is present in som4470

Change-Id: I8b38dcdc4acd377bb544fa8487094cc976f6532f
Signed-off-by: Eugen Mandrenko <ievgen.mandrenko@ti.com>
Add thermal framework to the staging area

Add thermal framework to the staging area

Add a thermal framework to the kernel so that thermal
sensors, thermal governors and thermal cooling agents
can register.

This framework presents a single point of thermal integration.
The framework is responsible for receiving the temperature
from the temp sensor and pushing the temperature to the correct
governor.

The temp sensor is expected just to report the temp for a particular domain
The governor is the policy holder for the specifc domain
The cooling device is the agent used to cool the specific domain

The sensor, governor and cooling device are linked via the domain_name
entry in the thermal_dev structure.

Change-Id: I892e52d508dddf4320f7366e0eab3c706c2850bd
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Add OMAP on die temp sensor support

Add OMAP on die temp sensor support

Add the OMAP4 on-die temperature sensor support to
the thermal framework

Change-Id: I6b3a5e0de1620b229f2d6e61111da20f148bf7d8
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Fix panic on 4430 for the temp sensor idle

Fix panic on 4430 for the temp sensor idle

On 4430 the on-die temp sensor is not used.  But the CPU idle
path still calls the temp sensor idle.  This is not right

Only allow idle on 4460.

Change-Id: I1e9be21bc0d6d05c015d718121b04e01d905efb1
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Update adc to temperature table and the table boundaries

Update adc to temperature table and the table boundaries

The adc value to temperature table is changed. Incorporating
the changes in the table and also changing the boundary values correspondigly.

Change-Id: I1505073269715385459a66d86560e2902f0476f8
Signed-off-by: Keerthy <j-keerthy@ti.com>
OMAP4 TEMP_SENSOR: Update the TSHUT configuration to a safer value

OMAP4 TEMP_SENSOR: Update the TSHUT configuration to a safer value

The configuration of THSUT_HOT value (where a thermal shutdown will occur)
shall take care of the temperature gradient that exists betwen the
on-die sensor and the OMAP hot spot temperature.
Thermal shutdown shall prevent the OMAP hot spot reaching 125C,
TSHUT_HOT (at on-die sensor level) shall be set at 110C.

Change-Id: I769f267c8dd659ea06282a1778b82698bda508b7
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4 TEMP_SENSOR: Fix configurations of thresholds and associated masks

OMAP4 TEMP_SENSOR: Fix configurations of thresholds and associated masks

In omap_configure_temp_sensor_thresholds() function, the temporary variable
temp shall not be ORed as it is not always initialized to '0'. This leads
to incorrect configuration of BGAP_TSHUT_OFFSET register.

In omap_set_thresholds() function, the new thresholds are compared
to the current temperature to set/clear corresponding masks.
The current temperature shall be defined in "ADC" code instead of
milli-celsius degree. Otherwise, the comparison fails and the masks
are wrongly set.

Change-Id: Ia3939b2467edab3979513f1f8c48a68ab0d96ac4
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4 TEMP_SENSOR: Removed unwanted save/restore of ctrl register

OMAP4 TEMP_SENSOR: Removed unwanted save/restore of ctrl register

This patch fixes issue with switching temperature sensor off after
resume from suspend.

Change-Id: I015a1f8c9a3168e7da518d068e0439aaa950e490
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal FW: Temp sensor: Update PM ops for runtime

Thermal FW: Temp sensor: Update PM ops for runtime

Update the pm runtime resume handler for context lost
scenario.

Change-Id: I6cf010a396d01e096c5a0a024f6ab12bb0c7f790
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Staging: Temp sensor: Update the logging for missing func name

Staging: Temp sensor: Update the logging for missing func name

Change the logging for the clock on/off statement from err to debug
as this is not really an error.  Add the function name for debugging ease

Change-Id: I8fb5373914812ab10569de0e02d758ac034b95a5
Signed-off-by: Dan Murphy <dmurphy@ti.com>
OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds

OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds

Based on OMAP4460 experiment, it is safer to set values of the
TSHUT_HOT and TSHUT_COLD thresholds to 100 and 80 degrees Celsius
respectively.

CONTROL_TSHUT_THRESHOLD[25:16]	- TSHUT_HOT
CONTROL_TSHUT_THRESHOLD[9:0]	- TSHUT_COLD

Change-Id: Ie4263b74038e290ba593155b109d4802660e4243
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
Staging: Temp sensor: Update management of thresholds

Staging: Temp sensor: Update management of thresholds

On one side, the thermal governor reads the current temperature before
updating the temperature thresholds. On the other side, the OMAP temperature
sensor reads again the current temperature before updating the masks associated
to the temperature thresholds.
Race conditions may exist between both drivers if OMAP die temperature
changes between both temperature reads. Finally, temperature thresholds and
associated masks in OMAP Control Module could be misaligned. This may avoid the
generation of thermal events (temperature falls below cold threshold,
temperature rises above hot threshold) from HW logic: thermal manager will not
take appropriate actions (un-throttle CPU frequency when temperature falls;
throttle CPU frequency when temperature rises).

This patch removes the reading of current temperature from OMAP temperature
sensor driver when configuring the thresholds. This updated function relies
now on latest temperature reading done upon thermal alert irq generation.
In case of temperature thresholds setting through SYSFS entry, the
temperature reading is now added.

Change-Id: Id5f7fc3e83dc1d582dcadff5d8abc916a1588256
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4 Thermal Framework: added PCB temperature sensor

This patch adds kernel driver for PCB temperature sensor
connected on TWL6030 GPADC (Thermistor).
It calls dedicated function to start GPADC conversion and
convert the result into milli-degrees celsius.

Change-Id: I7b573182611bda187f6a38dc01ba65935c8a5c4b
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
modified for TUNA board by faux123

Signed-off-by: Willi Ye <williye97@gmail.com>

Conflicts:
	arch/arm/configs/tuna-tw_defconfig
OMAP4 Thermal Framework: support multiple sensors per domain

OMAP4 Thermal Framework: support multiple sensors per domain

Current thermal framework implementation supports 1 temperature
sensor per thermal domain.
The OMAP CPU thermal governor needs to support OMAP and PCB temperature
sensors.
This patch updates the thermal framework to support multiple temperature
sensors per domain.
 - Added temperature report from sensors until at least 1 governor, 1 sensor and
1 cooling device are registered to the thermal framework to have pointers to
temperature sensor initialized at governor level.
 - Updated the thermal framework to allow getting temperature from multiple
temperature sensor and not only the last registered one.

Change-Id: I201ffdeaf3ef18ab17ec84ad8c833b9fc074f4f1
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Revert "OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds"

Revert "OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds"

This patches revert commit 24e7232d9d0ad7c3ac6520c7131b82e75d8f166d.
TSHUT_HOT value was decreased to be safe without the support of
PCB temp sensor into the OMAP thermal management.
Some thermal shutdown are observed when integrating the PCB sensor
into the thermal policy and decreasing the TSHUT_HOT value.
As recommended solution is to use an external PCB temp sensor,
it is better to revert the initial patch.

Change-Id: I27ddf08fab5cdedef7b9537fc934694a5b19954f
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
OMAP4: TEMP_SENSOR: Additional checking for context lost scenario

OMAP4: TEMP_SENSOR: Additional checking for context lost scenario

Calling pm_runtime_get_sync() function during driver initialization
leads to formation of the resume request, which will restore
registers values using not yet initialized data.

To prevent invalid data writing into registers at the early
stage of booting, additional checking has been added.

Change-Id: Ia14368ef1dd8430b8ba561bede0da7d46d9efb0e
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
OMAP4470: TEMP_SENSOR: Fatal threshold hardware warm reset generation

OMAP4470: TEMP_SENSOR: Fatal threshold hardware warm reset generation

On 4470 the TSHUT signal can be mapped to the device SCRM external
warm reset logic to activate the PRM.SYS_WARMIN_RST input
when a fatal temperature threshold (TSHUT_HOT) is exceeded.
Hence, a hardware warm reset can be triggered directly on
the device upon a fatal temperature threshold crossing event.

Since this feature have been added for 4470, shutdown thresholds
can be set earlier. So, additional checking has been added to prevent
multiple writing to one time writable register.

Also this patch add corresponding sysfs debug hook functions to
enable/disable hardware reset feature.

Change-Id: I260e16e2808fddc0ecb06211a74aced8c4b12a5d
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds

OMAP4: TEMP_SENSOR: Tuning values of TSHUT-thresholds

Based on OMAP4460 experiment, it is safer to set values of the
TSHUT_HOT and TSHUT_COLD thresholds to 100 and 80 degrees Celsius
respectively.

CONTROL_TSHUT_THRESHOLD[25:16]	- TSHUT_HOT
CONTROL_TSHUT_THRESHOLD[9:0]	- TSHUT_COLD

Change-Id: Ie4263b74038e290ba593155b109d4802660e4243
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
OMAP4470: TEMP_SENSOR: Thermal sensor support for 4470

OMAP4470: TEMP_SENSOR: Thermal sensor support for 4470

Thermal sensor support is required by a new chip.

Add runtime checking for 4470 to allow usage of
thermal sensor.

Change-Id: I231826df11315a27d6174a8791c578a5abbb4257
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
OMAP4: TEMP_SENSOR: Add missing carriage returns in print-function call

OMAP4: TEMP_SENSOR: Add missing carriage returns in print-function call

Due to missing carriage return in print-functions calls
sometimes it's hard to read kernel log.
Fix this so now kernel log reading is more easy.

Change-Id: I399c12f38a8e685ea19c7f79d930fa6ffc59511f
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>