[Soekris] net4826 temp Sensors on Linux

Harrison Duong h1duong at gmail.com
Fri Oct 20 22:15:51 UTC 2006


Hi,
For those who need a fix to use the Soekris 4826 temp sensors (LM75A)
on linux. I have a patch to get the existing lm_sensors working. I'm
not sure if anybody else has done this already but here it is if
anybody needs it. I hope it helps somebody out. I worked on this over
the summer. I also emailed a few people on the list about it but
nobody seemed to have a solution. The patchfiles could also be found
at wireless.ucsdsys.net under the software link.

Thanks,

Harrison

diff -urN lm_sensors-2.10.0-orig/kernel/chips/lm75.c
lm_sensors-2.10.0/kernel/chips/lm75.c
--- lm_sensors-2.10.0-orig/kernel/chips/lm75.c	2006-02-14
17:46:47.000000000 -0800
+++ lm_sensors-2.10.0/kernel/chips/lm75.c	2006-10-15 11:13:38.000000000 -0700
@@ -146,23 +146,33 @@
 	   since it would significantly slow the detection down and would
 	   hardly add any value. */
 	if (kind < 0) {
-		int cur, conf, hyst, os;
+		int cur, conf, hyst, os, na;

 		/* Unused addresses */
 		cur = i2c_smbus_read_word_data(new_client, 0);
 		conf = i2c_smbus_read_byte_data(new_client, 1);
 		hyst = i2c_smbus_read_word_data(new_client, 2);
-		if (i2c_smbus_read_word_data(new_client, 4) != hyst
+/*		if (i2c_smbus_read_word_data(new_client, 4) != hyst
 		 || i2c_smbus_read_word_data(new_client, 5) != hyst
 		 || i2c_smbus_read_word_data(new_client, 6) != hyst
 		 || i2c_smbus_read_word_data(new_client, 7) != hyst)
+*/
+                for(i=4; i<8; ++i){
+                   na = i2c_smbus_read_word_data(new_client, 4);
+                   if(na != hyst && na != 0xffff)
 		 	goto error1;
+                }
 		os = i2c_smbus_read_word_data(new_client, 3);
-		if (i2c_smbus_read_word_data(new_client, 4) != os
+/*		if (i2c_smbus_read_word_data(new_client, 4) != os
 		 || i2c_smbus_read_word_data(new_client, 5) != os
 		 || i2c_smbus_read_word_data(new_client, 6) != os
 		 || i2c_smbus_read_word_data(new_client, 7) != os)
+*/
+                for(i=4; i<8; ++i){
+                   na = i2c_smbus_read_word_data(new_client, 4);
+                   if(na != os && na != 0xffff)
 		 	goto error1;
+                }

 		/* Unused bits */
 		if (conf & 0xe0)
diff -urN lm_sensors-2.10.0-orig/kernel/chips/lm75.h
lm_sensors-2.10.0/kernel/chips/lm75.h
--- lm_sensors-2.10.0-orig/kernel/chips/lm75.h	2003-12-01
21:53:27.000000000 -0800
+++ lm_sensors-2.10.0/kernel/chips/lm75.h	2006-10-15 11:13:38.000000000 -0700
@@ -37,13 +37,17 @@
 {
 	int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
 	ntemp += (ntemp<0 ? -2 : 2);
-	return (u16)((ntemp / 5) << 7);
+//	return (u16)((ntemp / 5) << 7);
+//	changes made by Harrison
+//	used for extra 11 bit percision for lm75a sensor
+	return (u16)((ntemp / 125) << 5);
 }

 static inline int LM75_TEMP_FROM_REG(u16 reg)
 {
 	/* use integer division instead of equivalent right shift to
 	   guarantee arithmetic shift and preserve the sign */
-	return ((s16)reg / 128) * 5;
+//	return ((s16)reg / 128) * 5;
+	return ((s16)reg / 32) * 125;
 }

diff -urN lm_sensors-2.10.0-orig/prog/sensors/chips.c
lm_sensors-2.10.0/prog/sensors/chips.c
--- lm_sensors-2.10.0-orig/prog/sensors/chips.c	2006-02-14
17:46:49.000000000 -0800
+++ lm_sensors-2.10.0/prog/sensors/chips.c	2006-10-15 11:14:27.000000000 -0700
@@ -181,7 +181,9 @@
       !sensors_get_feature(*name,SENSORS_LM75_TEMP_OVER,&over))  {
     if (valid) {
       print_label(label,10);
-      print_temp_info( cur, over, hyst, HYST, 1, 1);
+//      print_temp_info( cur, over, hyst, HYST, 1, 1);
+//      changed for precision, Harrison
+      print_temp_info( cur/100, over/100, hyst/100, HYST, 3, 3);
       printf( "\n" );
     }
   } else


--- linux-2.4.31-orig/include/linux/pci_ids.h	2005-09-16
18:11:18.000000000 -0700
+++ linux-2.4.31/include/linux/pci_ids.h	2006-10-15 00:30:27.000000000 -0700
@@ -350,6 +350,7 @@
 #define PCI_DEVICE_ID_NS_SCx200_VIDEO	0x0504
 #define PCI_DEVICE_ID_NS_SCx200_XBUS	0x0505
 #define PCI_DEVICE_ID_NS_87410		0xd001
+#define PCI_DEVICE_ID_NS_SC1100_BRIDGE  0x0510

 #define PCI_VENDOR_ID_TSENG		0x100c
 #define PCI_DEVICE_ID_TSENG_W32P_2	0x3202
--- linux-2.4.31-orig/drivers/char/scx200.c	2005-09-16 17:16:41.000000000 -0700
+++ linux-2.4.31/drivers/char/scx200.c	2006-10-03 09:09:45.000000000 -0700
@@ -85,7 +85,7 @@
 	printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");

 	if ((bridge = pci_find_device(PCI_VENDOR_ID_NS,
-				      PCI_DEVICE_ID_NS_SCx200_BRIDGE,
+				      PCI_DEVICE_ID_NS_SC1100_BRIDGE,
 				      NULL)) == NULL)
 		return -ENODEV;


More information about the Soekris-tech mailing list