Add OMAP on-die governor to the thermal fw

Add OMAP on-die governor to the thermal fw

Add the OMAP on-die governor to the thermal framework.
This component will impose the policy for the on-die temp
sensor.

Change-Id: I68d69309c79088e44573991c940139e9710377f1
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Thermal Governor: Disable annoying logging statement

Thermal Governor: Disable annoying logging statement

Remove the informative statement from the thermal governor

Change-Id: I2bf574ad7c57ec3b19231c27944f529b345d7cbb
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Thermal Governor: Update the actions for each thermal zone

Thermal Governor: Update the actions for each thermal zone

This patch applies the following changes to the governor:
 - Set the FATAL zone at 125C - accuracy of on-die sensor is already
included in the hot spot temperature extrapolation
 - Updated the formula to extrapolate the hot spot temperature:
the parameters of the formula are updated to keep OMAP in safe
thermal conditions
 - Fixed the main state machine handling the transition between
thermal zones
 - Fixed the thresholds and monitoring rate configuration
for the various thermal zones
 - Moved the cpu throttle from monitor zone to the panic zone
 - Updated the behavior in panic zone to handle consecutives entrance
into the panic zone
To summarize, this patch ensures that the CPU frequency is throttled
by 1 step when hot spot temperature enters into panic zone. Then
maximum CPU frequency is re-enabled when hot spot temperature comes back
into the monitor zone.

Change-Id: Idf870e3ae17c5b23921eeff9e31f2b3f193dbf2d
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal Governor: Added logging statement

Thermal Governor: Added logging statement

This patch adds log when entering thermal zones

Change-Id: Iec6d70f6625bd756d5018026d3f50fbea7eddf3f
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
Thermal: Modify the panic zone to be more agressive

Thermal: Modify the panic zone to be more agressive

Modify the panic zone to be more agressive with the cooling.
Basically once this zone is reached the governor should set the
threshold windows so that it can be notified if the temp is still
increasing once the the CPU is throttle.  If the temp is still increasing
then go to the next OPP until max throttling.

Change-Id: I4d4698a8f8ead5ce243032d80e136d7638e675f9
Signed-off-by: Dan Murphy <dmurphy@ti.com>
OMAP4 CPU Thermal governor: use PCB sensor to extrapolate hot spot temperature

OMAP4 CPU Thermal governor: use PCB sensor to extrapolate hot spot temperature

Even if OMAP4460/4470 on-die temperature sensor is located as close
as possible to OMAP MPU-SS, there is still an offset between on-die
sensor and OMAP hot spot.
This offset depends a lot on the additional system power:
various laws could be defined depending on the system power.
Relying on a PCB sensor allows correcting this offset temperature:
linear law can be used in thermal policy to adjust the temperature
read on the sensor and correct the offset at run time.

This patch adds the support of PCB temperature in the thermal governor:
- Updated formula to extrapolate hot spot from on-die sensor and PCB sensor
- Updated reconfiguration of thresholds that should take into account the
variation of PCB temperature
- Added additional thread to monitor the on-die temperature and make
average on latest 20 measurements:
This average temperature is mandatory to take care of huge delta
between on-die sensor and PCB sensor when the temperature
increases quickly (burst CPU activity).
This huge delta is coming from different response time between
on-die sensor and PCB sensor.

Change-Id: Ied89a7e3f3edd249808a245c0180cbfd073dcd1c
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>
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

Conflicts:
	arch/arm/configs/tuna_ak_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>