From: Adrian Cox <apc@agelectronics.co.uk>
To: LinuxPPC-Dev <linuxppc-dev@lists.linuxppc.org>
Subject: New temperature patch
Date: Mon, 16 Aug 1999 17:44:46 +0100 [thread overview]
Message-ID: <37B83FFE.9078AA56@agelectronics.co.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
I've written yet another temperature patch for the 750, and I'd like
some volunteers to try it out.
The main feature is a thermal calibration value in machdep.h, which no
current machine can actually use, but which may well come in handy
later. Motorola 750s I've tested have been within about 10C of the
correct temperature, but there are no guarantees about the calibration
values of future silicon.
- Adrian Cox, AG Electronics
[-- Attachment #2: temp.patch --]
[-- Type: text/plain, Size: 3793 bytes --]
--- linuxppc-2.2.10/arch/ppc/kernel/setup.c Thu Aug 5 17:38:13 1999
+++ linux/arch/ppc/kernel/setup.c Mon Aug 16 17:13:37 1999
@@ -72,6 +78,9 @@
unsigned long ISA_DMA_THRESHOLD;
unsigned long DMA_MODE_READ, DMA_MODE_WRITE;
+/* Default value is impossible */
+int ppc_temperature_calibration = 99999;
+
/* Temporary hacks until machdep.h is fully done. */
int _machine = 0;
/* do we have OF? */
@@ -169,31 +178,50 @@
unsigned long cpu_temp(void)
{
- unsigned char thres = 0;
-
-#if 0
- /* disable thrm2 */
- _set_THRM2( 0 );
- /* threshold 0 C, tid: exceeding threshold, tie: don't generate interrupt */
- _set_THRM1( THRM1_V );
-
- /* we need 20us to do the compare - assume 300MHz processor clock */
- _set_THRM3(0);
- _set_THRM3(THRM3_E | (300*30)<<18 );
-
- udelay(100);
- /* wait for the compare to complete */
- /*while ( !(_get_THRM1() & THRM1_TIV) ) ;*/
- if ( !(_get_THRM1() & THRM1_TIV) )
- printk("no tiv\n");
- if ( _get_THRM1() & THRM1_TIN )
- printk("crossed\n");
- /* turn everything off */
- _set_THRM3(0);
+ static int never_again = 0;
+ unsigned t_lower;
+ unsigned t_upper;
+
+ if (never_again)
+ return -1;
+
_set_THRM1(0);
-#endif
-
- return thres;
+ _set_THRM2(0);
+
+ /* Converge on the correct value by moving in the boundaries */
+ t_lower = 0;
+ t_upper = 127;
+
+ while (t_upper - t_lower > 1)
+ {
+ unsigned long start_time;
+ int t_1;
+
+ t_1 = (t_lower + t_upper) / 2;
+ _set_THRM1((t_1 << 23) | THRM1_TID | THRM1_V);
+ _set_THRM3(0x00003f69);
+ /* Wait for settling of value */
+ start_time = jiffies;
+ while (!(_get_THRM1() & THRM1_TIV))
+ if (jiffies - start_time > HZ/2)
+ {
+ never_again = 1;
+ printk(KERN_CRIT "Thermal unit did not stabilise in 0.5s\n");
+ return -1;
+ }
+
+ /* Temperature less than t_1 */
+ if (_get_THRM1() & THRM1_TIN)
+ t_upper = t_1;
+ else
+ t_lower = t_1;
+
+ }
+ _set_THRM1(0);
+ _set_THRM3(0);
+
+
+ return t_upper;
}
int get_cpuinfo(char *buffer)
@@ -241,8 +275,15 @@
break;
case 8:
len += sprintf(len+buffer, "750\n");
- len += sprintf(len+buffer, "temperature \t: %lu C\n",
- cpu_temp());
+ {
+ int temp = cpu_temp();
+ if (ppc_temperature_calibration != 99999)
+ temp += ppc_temperature_calibration;
+ len += sprintf(len+buffer, "temperature \t: %lu C%s\n",
+ temp,
+ (ppc_temperature_calibration = 99999) ?
+ " (uncalibrated)" : "");
+ }
break;
case 9:
len += sprintf(len+buffer, "604e\n");
--- linuxppc-2.2.10/include/asm-ppc/machdep.h Mon Jul 5 15:53:58 1999
+++ linux/include/asm-ppc/machdep.h Mon Aug 16 15:58:14 1999
@@ -72,5 +72,6 @@
extern char cmd_line[512];
extern void setup_pci_ptrs(void);
+extern int ppc_temperature_calibration;
#endif /* _PPC_MACHDEP_H */
--- linuxppc-2.2.10/include/asm-ppc/processor.h Mon Jul 5 15:53:55 1999
+++ linux/include/asm-ppc/processor.h Mon Aug 16 15:43:36 1999
@@ -148,13 +150,13 @@
#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)
+#define THRM1_TIN (1<<31)
+#define THRM1_TIV (1<<30)
+#define THRM1_THRES (0x7f<<23)
+#define THRM1_TID (1<<2)
+#define THRM1_TIE (1<<1)
+#define THRM1_V (1)
+#define THRM3_E (1)
/* Segment Registers */
#define SR0 0
reply other threads:[~1999-08-16 16:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=37B83FFE.9078AA56@agelectronics.co.uk \
--to=apc@agelectronics.co.uk \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).