CPU Temperature Patch
Here are two patches that appear to fix the cpu_temp function in setup.c. They have been applied to a number of Ben Herrenschmidt kernels on a 500 MHz Pismo powerbook and print reasonable values when you cat /proc/cpuinfo.
Note that the intrinsic resolution of the temperature seems to be 4 degrees
- the values printed are at the mid-point between two 4 degree multiples.
The key document I found for this was a Motorola application note found under
http://www.mot.com/SPS/PowerPC/teksupport/teklibrary/index.html
The specific document is "Programming the Thermal Assist Unit in the MPC750, Rev.0".
http://www.mot.com/SPS/PowerPC/teksupport/teklibrary/appnotes/an1800.pdf.
The update of processor.h means that everything gets re-compiled after applying the patch.
David Osguthorpe
include/asm-ppc/processor.h renamed from linux-2.2.17pre13-ben1/include/asm-ppc/processor.h +9 -7
@@ -163,13 +163,15 @@#define THRM1 1020#define THRM2 1021#define THRM3 1022 -#define THRM1_TIN 0x1 -#define THRM1_TIV 0x2 -#define THRM1_THRES (0x7f<<2) -#define THRM1_TID (1<<29) -#define THRM1_TIE (1<<30) -#define THRM1_V (1<<31) -#define THRM3_E (1<<31) +/* these bits were defined in inverted endian sense originally */ +#define THRM1_TIN (1 << 31) +#define THRM1_TIV (1 << 30) +#define THRM1_THRES (x) ((x&0x7f)<<23) +#define THRM3_SITV (x) ((x&0x3fff)<<1) +#define THRM1_TID (1<<2) +#define THRM1_TIE (1<<1) +#define THRM1_V (1<<0) +#define THRM3_E (1<<0)/* Segment Registers */ #define SR0 0
arch/ppc/kernel/setup.c renamed from linux-2.2.17pre13-ben1/arch/ppc/kernel/setup.c +53 -15
84 lines not on this page · raw message
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · D.J. Osguthorpe
Here are two patches that appear to fix the
cpu_tempfunction insetup.c. They have been applied to a number of Ben Herrenschmidt kernels on a 500 MHz Pismo powerbook and print reasonable values when you cat/proc/cpuinfo.
The patch seems to work on my Lombard/333, too... Really great!
Quoted 1 line
+ /* this set for 500 MHz Pismo - how do we get access to clock?? */
There is, in the same file, around line 319 code to read the clock speed from the device tree. However, is it really necessary to include the clock speed at this point? What is the drawback if we just assume 500 MHz (or even the max value) for every G3 based machine?
Albrecht.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 6 lines · Albrecht Dreß
Quoted 3 lines · D.J. Osguthorpe
Here are two patches that appear to fix the
cpu_tempfunction insetup.c. They have been applied to a number of Ben Herrenschmidt kernels on a 500 MHz Pismo powerbook and print reasonable values when you cat/proc/cpuinfo.
Quoted 8 lines
The patch seems to work on my Lombard/333, too... Really great!
Quoted 1 line
+ /* this set for 500 MHz Pismo - how do we get access to clock?? */
There is, in the same file, around line 319 code to read the clock speed from the device tree. However, is it really necessary to include the clock speed at this point? What is the drawback if we just assume 500 MHz (or even the max value) for every G3 based machine?
Why assume when we can do it properly? Besides, a friend of mine oc'ed his B&W to 550, so it's possible to have >500Mhz :)
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines
+ /* this set for 500 MHz Pismo - how do we get access to clock?? */
There is, in the same file, around line 319 code to read the clock speed from the device tree. However, is it really necessary to include the clock speed at this point? What is the drawback if we just assume 500 MHz (or even the max value) for every G3 based machine?
Why assume when we can do it properly? Besides, a friend of mine oc'ed his B&W to 550, so it's possible to have >500Mhz :)
Like this?
ppc/kernel/setup.c renamed from ppc/kernel/setup.c.org +16 -1
@@ -197,6 +197,7 @@unsigned int thresd;unsigned int threst;unsigned int i; +unsigned int cpu_freq; othrm1 =_get_THRM1 (); othrm2 =_get_THRM2 ();
@@ -208,9 +209,23 @@/* we need 20us to do the compare - assume 300MHz processor clock */ /* max value for sitv is 0x3fff - or 16383 */ /* this set for 500 MHz Pismo - how do we get access to clock?? */ + + cpu_freq =500 ; +if ( have_of ) + { +struct device_node *cpu_node; +int *fp; + + cpu_node =find_type_devices ("cpu" ); +if ( cpu_node ) { + fp = (int *)get_property (cpu_node,"clock-frequency" ,NULL ); +if ( fp ) cpu_freq = *fp /1000000 ; + } + } +/* 25 usec conversion time - max for 500 Mhz is approx. 32 usec */ _set_THRM3 (0 ); -_set_THRM3 (THRM3_E |THRM3_SITV (500 *25 ) ); +_set_THRM3 (THRM3_E |THRM3_SITV (cpu_freq*25 ) ); thresd =1 <<6 ; threst = thresd;
Only tested on my Lombard ...
Michael
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Michael Schmitz
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
+ /* this set for 500 MHz Pismo - how do we get access to clock?? */
There is, in the same file, around line 319 code to read the clock speed from the device tree. However, is it really necessary to include the clock speed at this point? What is the drawback if we just assume 500 MHz (or even the max value) for every G3 based machine?
Why assume when we can do it properly? Besides, a friend of mine oc'ed his B&W to 550, so it's possible to have >500Mhz :)
Like this?
Looks almost sane.
ppc/kernel/setup.c line 213
Quoted 6 lines
ppc/kernel/setup.c renamed from ppc/kernel/setup.c.org +2
-0@@ -208,9 +209,23 @@/* we need 20us to do the compare - assume 300MHz processor clock */ /* max value for sitv is 0x3fff - or 16383 */ /* this set for 500 MHz Pismo - how do we get access to clock?? */ + + cpu_freq =500 ;
But why 500 here? The bit for reading temp is on all G3s, yes? And since we assume 300Mhz clock, which is the middle of the clock ranges (close enough) shouldn't this be 300 as well?
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi all,
On 20 Sep, this message from Tom Rini echoed through cyberspace:
Quoted 12 lines · Albrecht Dreß
Quoted 10 lines
Quoted 3 lines · D.J. Osguthorpe
Here are two patches that appear to fix the
cpu_tempfunction insetup.c. They have been applied to a number of Ben Herrenschmidt kernels on a 500 MHz Pismo powerbook and print reasonable values when you cat/proc/cpuinfo.The patch seems to work on my Lombard/333, too... Really great!
Quoted 1 line
+ /* this set for 500 MHz Pismo - how do we get access to clock?? */
Quoted 7 lines
Quoted 4 lines
There is, in the same file, around line 319 code to read the clock speed from the device tree. However, is it really necessary to include the clock speed at this point? What is the drawback if we just assume 500 MHz (or even the max value) for every G3 based machine?
Why assume when we can do it properly? Besides, a friend of mine oc'ed his B&W to 550, so it's possible to have >500Mhz :)
To do it properly on all machines requires a processor frequency calculating routine, that doesn't depend on OF. Note that on all upgraded machines that did not initially have a G3, OF's value is wrong (too low, actually)!
On the other hand, Motorola's doc states that setting too large a value doesn't hurt, so I guess we can safely hardcode something like 600 MHz.
At the only expense of busy-waiting a bit too long on slower machines... but how often do you look at /proc/cpuinfo? Besides, you could always do the aproximation using the interrupt ;-)
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi there,
On 20 Sep, this message from D.J. Osguthorpe echoed through cyberspace:
Quoted 2 lines
Note that the intrinsic resolution of the temperature seems to be 4 degrees
- the values printed are at the mid-point between two 4 degree multiples.
Yes, that is so by design: 5 bit A/D for a range of 0 - 128 degrees. Found that in some paper on the Thermal Assist Unit (ref. 2 in the appnote).
By the way, the uncalibrated sensor has an accuracy of +- 12 degrees.
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/