Author: wmb
Date: Tue Jun 14 20:17:23 2011
New Revision: 2276
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2276
Log:
OLPC XO-1.75 trac #11000 - Implemented cpu-temperature
Added:
cpu/arm/mmp2/thermal.fth
Modified:
cpu/arm/olpc/1.75/devices.fth
Added: cpu/arm/mmp2/thermal.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/mmp2/thermal.fth Tue Jun 14 20:17:23 2011 (r2276)
@@ -0,0 +1,50 @@
+\ See license at end of file
+purpose: Driver for the MMP2 thermal sensor
+
+h# d4013200 value thermal-base
+: init-thermal-sensor ( -- )
+ thermal-base l@ h# 400 and if exit then
+ 3 h# d4015090 l! \ Enable clocks to thermal sensor
+ h# 10000 thermal-base l! \ Enable sensing
+;
+
+: cpu-temperature ( -- celcius )
+ 0 ( acc )
+ d# 100 0 do ( acc ) \ Accumulate 100 samples
+ thermal-base l@ ( acc reg )
+ h# 3ff and ( acc val )
+ + ( acc' )
+ loop ( acc )
+
+ \ Now we have raw value * 100
+ \ The formula (from the Linux driver) is Celcius = (raw - 529.4) / 1.96
+
+ d# 52940 - d# 196 / ( celcius )
+;
+stand-init: Thermal sensor
+ init-thermal-sensor
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Tue Jun 14 07:30:53 2011 (r2275)
+++ cpu/arm/olpc/1.75/devices.fth Tue Jun 14 20:17:23 2011 (r2276)
@@ -379,6 +379,8 @@
extra-mem-pa /extra-mem add-memory
;
+fload ${BP}/cpu/arm/mmp2/thermal.fth
+
\ LICENSE_BEGIN
\ Copyright (c) 2010 FirmWorks
\