ARM: OMAP4: l2x0: Cleanup prefetch offset register setting

ARM: OMAP4: l2x0: Cleanup prefetch offset register setting

The bits [31:5] of Prefetch Offset Register are reserved in
PL310 r2p0 so they should be kept unchanged.
It's enough to set Data prefetch enable bit in PL310 auxiliary
control register to enable the feature, so setting of bit 28 of POR
is removed.
Before writing POR value, the bits [4:0] has to be cleared to remove
previous value.

Change-Id: Id5d047da0daa0c841c69d4d587d2280d2f3433f9
Signed-off-by: Konstantin Shlyakhovoy <x0155534@ti.com>
ARM: OMAP4: l2x0: Set optimized value for prefetch offset

ARM: OMAP4: l2x0: Set optimized value for prefetch offset

Tuning the value of prefetch offset register of PL310 cache controller
for OMAP4 family. The patch can give up to 4% better results in low level
benchmarks (like bw_mem at block size above 2 Mb) and up to 2% in benchmarks
imitating use cases (like Sunspider).
Note: if double line fill is enabled, the optimal value can be different.

Change-Id: Iba7b7b5950981b851c4eac4ed636ec5d8006c87b
Signed-off-by: Konstantin Shlyakhovoy <x0155534@ti.com>
ARM: 6998/2: kernel: use proper memory barriers for bitops

ARM: 6998/2: kernel: use proper memory barriers for bitops

Improve scalability by avoiding costly and unnecessary L2 cache sync
in handling bitops.

Change-Id: If6b9f52edbb597e3298227a13ed4e6edc629bf11
Signed-off-by: Heechul Yun <hyun@nvidia.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Maulik Mankad <maulik@ti.com>
RTC: twl6030: correct usage of static register while reading RTC

RTC: twl6030: correct usage of static register while reading RTC

RTC stores time and date in several registers. Due to the fact that
these registers can't be read momentary there is a chance that reading
from counting registers gives an error of one minute, one hour,
one day, etc. To address the issue the RTC has hardware that can copy
the counting registers to static shadowed registers. However, while
re-using driver code for twl6030, the feature wasn't correctly
implemented. So wrong time was read one - two times per 300000 readings.
This patch corrects usage of RTC registers for twl6030.

Change-Id: Iab1a9afd381e2a3de3b6b381ebf9bb8b798a6e18
Signed-off-by: Konstantin Shlyakhovoy <x0155534@ti.com>
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>