Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jan 2010 19:52:13 +0100
From:      Oliver Lehmann <lehmann@ans-netz.de>
To:        Jeremy Chadwick <freebsd@jdc.parodius.com>
Cc:        ru@freebsd.org, freebsd-stable@freebsd.org, freebsd-hardware@freebsd.org
Subject:   Re: smb driver for Nvidia ION (intel ATOM) chipset
Message-ID:  <20100107195213.b2c7e942.lehmann@ans-netz.de>
In-Reply-To: <20100107083908.GA58065@icarus.home.lan>
References:  <20100105192746.cc627795.lehmann@ans-netz.de> <20100107063413.614058fc.lehmann@ans-netz.de> <20100107063831.GA53300@icarus.home.lan> <20100107074805.59556.qmail@avocado.salatschuessel.net> <20100107080914.60245.qmail@avocado.salatschuessel.net> <20100107083908.GA58065@icarus.home.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

--Multipart=_Thu__7_Jan_2010_19_52_13_+0100_jDffF=aymMp4.1gV
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Jeremy Chadwick wrote:

> If you'd like, I can code up something that uses LPC/ISA to communicate
> with this IC via port 0x290 based on the datasheet.

I now was able to "hack up" mbmon to communicate with my it8720 sensor.
I've attached the patch for sens_it87.c
I also added to Makefile to the DEFS = line "-DIT8720" of course. This
made mbmon working with ISA-IO mode working. I'm now getting the
following outputs:

Temp.= 32.0, 34.0, 22.0; Rot.= 4591, 1298,    0
Vcore = 1.10, 1.81; Volt. = 3.39, 4.95, 11.93, -11.93, -4.99

I can nearly verify all values with the BIOS and they are matching. I
XXed in the following output (same as above) all values out I was not
able to verify because the BIOS-HWM does not show their values:

Temp.= 32.0, XXX, XXX; Rot.= 4591, 1298,    0
Vcore = 1.10, XXXX; Volt. = 3.39, 4.95, 11.93, -11.93, XXXXX

For the remaining values I'm pretty sure they are correct.
I enabled the 16Bit RPM mode for the 8720. In this case no devisor is
needed for calculating the RPM. I was not able to get the 2nd FAN-RPM
right in the 8Bit mode. The 1st one was correct even in the 8Bit mode.
About the voltage multipliers... I'm not sure about the last one because
I'm not able to verify this (I could with a multimeter of course but this
would create other deviations).
I'm also not sure why the multipliers (for my board?) are different. I
wonder why they are hardcoded there anyway. I can imagine that they are
depending the board layout or am I mistaken? I mean the IT spec says only
that the input of the pins need to be in the range between 0 and VCC. So
I can choose whatever multiplier I like as long as the resulting voltage
keeps within this range. Keeping the measured voltage somewhere in the
middle of 0 and VCC with the multiplier for the expected value makes
sense but this is no "must be" I guess

Now - since ISA-IO is working I want to get smbus working too ;)
First I patched src/sys/pci/nfsmb.c to detect the known remaning nforce
SMB controllers including mine.
I then added the device-id of this controller to the pci_pm.h file of
mbmon to make it detect my controller.
But now it still fails to find the it87 sensor on the bus. I guess the
bus can have many "slaves" and mbmon just needs to test all to find out
which identifies itself as it87? (reading from Adress 0x58 should return
0x90 - at least in ISA mode)

root@nudel xmbmon205> ./mbmon -S -D -p it87
Probe Request: it87
>>> Testing Reg's at SMBus <<<
 SMBus slave 0xA0(0x50) found...
 SMBus slave 0xA2(0x51) found...
 SMBus slave 0xA4(0x52) found...
 SMBus slave 0xA6(0x53) found...
 SMBus slave 0xA8(0x54) found...
 SMBus slave 0xAA(0x55) found...
 SMBus slave 0xAC(0x56) found...
 SMBus slave 0xAE(0x57) found...
SMBus[NVidia nForce2] found, but No HWM available on it!!
InitMBInfo: Device not configured
Exit 1
root@nudel xmbmon205> ./mbmon -S -s1 -D -p it87
Probe Request: it87
>>> Testing Reg's at SMBus <<<
 SMBus slave 0xA0(0x50) found...
 SMBus slave 0xA2(0x51) found...
 SMBus slave 0xE0(0x70) found...
SMBus[NVidia nForce2] found, but No HWM available on it!!
InitMBInfo: Device not configured
Exit 1
root@nudel xmbmon205> 

But it looks like at least the smb detection code for it87 is not working
for mine...

Any ideas how to proceed here?

(I have basic C skills and know something about electronics (can build a
Z80 SBC for example ;))

-- 
 Oliver Lehmann
  http://www.pofo.de/
  http://wishlist.ans-netz.de/

--Multipart=_Thu__7_Jan_2010_19_52_13_+0100_jDffF=aymMp4.1gV
Content-Type: text/x-diff;
 name="sens_it87.c.diff"
Content-Disposition: attachment;
 filename="sens_it87.c.diff"
Content-Transfer-Encoding: 7bit

--- sens_it87.c.orig	2010-01-07 19:34:04.000000000 +0100
+++ sens_it87.c	2010-01-07 19:15:11.647304000 +0100
@@ -0,0 +1,242 @@
+/*
+ * Integrated Technology Express IT8705F/IT8712F hardware monitor chip
+ *
+ ***************************************************************
+ * Before calling these routines, one must call method->Open() *
+ * After calling these routines, one must call method->Close() *
+ ***************************************************************
+ *
+
+Integrated Technology Express
+         Chip         Temp    Volt    Fan     SMBus   IOport
+        it8705         3       8       3       yes     yes
+        it8712         3       8       3       yes     yes
+
+SiS
+         Chip         Temp    Volt    Fan     SMBus   IOport
+        sis950         3       8       3       yes     yes
+
+ *
+ * by YRS
+ */
+
+
+#include	<stdio.h>
+#include	"sensors.h"
+
+/* external (global) data */
+extern int smb_slave;
+extern LM_METHODS method_isa, method_smb;
+extern int numSMBSlave, canSMBSlave[128];
+
+
+#define	IT87_ADDR_START		0x50	/*0x50-0x5E*/
+#define	IT87_ADDR_END		0x5E
+
+#define	IT87_SMBADDR	0x48
+#define	IT87_REGCHIP	0x58
+#define	IT87_CHIPID		0x90
+
+/* temp nr=0,1,2; volt nr=0,1,...6; fan nr=0,1,2 */
+#define	IT87_TEMP(nr)	(0x29 + (nr))
+#define	IT87_VOLT(nr)	(0x20 + (nr))
+#define	IT87_FAN(nr)	(0x0D + (nr))
+#define IT87_FANX(nr)   (0x18 + (nr))
+#define	IT87_FANDIV		0x0B
+#define IT87_FANDIV16		0x0C
+
+static	int		it87_probe(LM_METHODS *);
+static	float	it87_temp(LM_METHODS *, int);
+static	int		it87_fanrpm(LM_METHODS *, int);
+static	float	it87_volt(LM_METHODS *, int);
+
+SENSOR it87 = {
+	"Int.Tec.Exp. Chip IT8705F/IT8712F or SIS950",
+	it87_probe,
+	it87_temp,
+	it87_volt,
+	it87_fanrpm
+};
+
+
+#define IT87_chkRegNum 8
+
+/* Register checked for probing */
+static int chkReg[] = {
+	0x00, 0x01, 0x02, 0x03,
+	0x0A, 0x48, 0x50, 0x51,
+	0x20, 0x21, 0x22, 0x23,
+	0x24, 0x25, 0x26, 0x27,
+	0x28, 0x29, 0x2A, 0x2B,
+	0x0B, 0x0D, 0x0E, 0x0F,
+	-1 };
+
+
+/*
+ *  return 0 if not probed
+ */
+static	int     it87_probe(LM_METHODS *method)
+{
+	int n, save;
+
+	if (method != &method_isa  && method != &method_smb)
+		return 0;
+
+	save = smb_slave;
+
+	if (method == &method_smb) {
+		for (n = IT87_ADDR_START; n <= IT87_ADDR_END;) {
+			if (!(smb_slave = get_smb_slave(n, IT87_ADDR_END)))
+				goto ret0;
+			else if (smb_slave != 2 * method->Read(IT87_SMBADDR))
+				goto ret0;
+			else {
+				if (method->Read(IT87_REGCHIP) == IT87_CHIPID
+					&& chkReg_Probe(smb_slave,
+						"Probing ITE7805/7812/SIS950 chip:\n", chkReg, method)
+							>= IT87_chkRegNum)
+					goto ret1;
+				else
+					n = smb_slave + 2;
+			}
+		}
+		goto ret0;
+	} else {
+		if (method->Read(IT87_REGCHIP) == IT87_CHIPID
+			&& chkReg_Probe(0, "Probing ITE7805/7812/SIS950 chip:\n",
+				chkReg, method) >= IT87_chkRegNum)
+			goto ret1;
+	}
+
+ret0:
+	smb_slave = save;
+	return 0;
+ret1:
+	if (method == &method_smb)
+		kill_smb_slave(smb_slave);
+	return 1;
+}
+
+
+/*
+ *	\retval	0xFFFF	no sensor
+ *	\retval	other	temperature
+ *  no = 0,1,2,...
+ */
+static	float	it87_temp( LM_METHODS *method, int no )
+{
+	if (no < 0 || 2 < no)
+		return 0xFFFF;
+
+	return (float) method->Read(IT87_TEMP(no));
+}
+
+
+/*
+ *	\retval	0x0000FFFF	no sensor
+ *  no = 0,1,2,...
+ */
+static	float	it87_volt(LM_METHODS *method, int no)
+{
+	float fac;
+
+	if (no < 0 || 6 < no)
+		return 0xFFFF;
+
+	switch (no) {
+		case 0:
+		case 1:
+		case 2:
+			fac = 0.016;
+			break;
+		case 3:
+			fac = 0.016 * 1.68;
+			break;
+		case 4:
+#ifdef IT8720
+			fac = 0.016 * 5.524;
+#else
+			fac = 0.016 * 3.80;
+#endif
+			break;
+		case 5:
+#ifdef IT8720
+			fac = - 0.016 * 5.524;
+#else
+			fac = - 0.016 * 3.477;
+#endif
+			break;
+		case 6:
+#ifdef IT8720
+			fac = - 0.016 * 2.31;
+#else
+			fac = - 0.016 * 1.505;
+#endif
+
+	}
+
+	return (float) method->Read(IT87_VOLT(no)) * fac;
+}
+
+
+/*
+	Controlling Fan Divisor for 1st/2nd fans: CR = 0x0B.
+	lowest three bits for fan1, next three bits for fan2
+
+         7       3     0
+        +-+-+-+-+-+-+-+-+     xxx = 000,..,111  div1fac = 1,..,128
+        |   |y y y|x x x|     yyy = 000,..,111  div2fac = 1,..,128
+        +-+-+-+-+-+-+-+-+    initial values: xx=001, yy=001
+
+	No divisor available for fan3.
+
+ */
+
+/*
+ *	\retval	0x0000FFFF	no sensor
+ *  no = 0,1,2,...
+ *
+ *  Clock is 22.5kHz (22,500 x 60 = 1350000 counts/minute)
+ */
+static	int		it87_fanrpm(LM_METHODS *method, int no)
+{
+	int	r, n;
+	static int div[3] = {1,1,1};
+
+	if (no < 0 || 2 < no)
+		return 0xFFFF;
+
+#ifndef IT8720
+	n = method->Read(IT87_FANDIV);
+	div[0] =  n & 0x07;
+	div[1] = (n >> 3) & 0x07;
+
+	r = method->Read(IT87_FAN(no));
+	if (r == 0xFF) {
+		/* change divisor for the sake of next call ! */
+		if (no != 2) {
+			if (div[no] < 7)
+				++(div[no]);
+			else
+				div[no] = 0;
+			r = (n & 0x3F) | div[0] | (div[1] << 3);
+			method->Write(IT87_FANDIV, r);
+		}
+		return 0xFFFF;
+	} else if (r == 0) {
+		return 0xFFFF;
+	}
+#else
+	div[no] = 1;
+	method->Write(0x0C,1|0x07);
+	n = method->Read(IT87_FANDIV16);
+	if(n & 0x07) {
+		r  = method->Read(IT87_FAN(no));
+		r |= method->Read(IT87_FANX(no))<<8;
+	}
+	if(r == 0 || r == 0xFFFF)
+		return 0xFFFF;
+#endif
+
+	return 1350000 / (r * (1 << div[no]));
+}

--Multipart=_Thu__7_Jan_2010_19_52_13_+0100_jDffF=aymMp4.1gV
Content-Type: text/x-diff;
 name="nfsmb.c.diff"
Content-Disposition: attachment;
 filename="nfsmb.c.diff"
Content-Transfer-Encoding: 7bit

--- nfsmb.c.orig	2010-01-07 19:35:04.000000000 +0100
+++ nfsmb.c	2010-01-07 06:27:34.000000000 +0100
@@ -65,6 +65,10 @@
 #define	NFSMB_DEVICEID_NF4_55_SMB	0x0368
 #define	NFSMB_DEVICEID_NF4_61_SMB	0x03eb
 #define	NFSMB_DEVICEID_NF4_65_SMB	0x0446
+#define	NFSMB_DEVICEID_NF4_67_SMB	0x0542
+#define	NFSMB_DEVICEID_NF4_73_SMB	0x07d8
+#define	NFSMB_DEVICEID_NF4_78S_SMB	0x0752
+#define	NFSMB_DEVICEID_NF4_79_SMB	0x0aa2
 
 /* PCI Configuration space registers */
 #define	NF2PCI_SMBASE_1		PCIR_BAR(4)
@@ -158,6 +162,10 @@
 		case NFSMB_DEVICEID_NF4_55_SMB:
 		case NFSMB_DEVICEID_NF4_61_SMB:
 		case NFSMB_DEVICEID_NF4_65_SMB:
+		case NFSMB_DEVICEID_NF4_67_SMB:
+		case NFSMB_DEVICEID_NF4_73_SMB:
+		case NFSMB_DEVICEID_NF4_78S_SMB:
+		case NFSMB_DEVICEID_NF4_79_SMB:
 			device_set_desc(dev, "nForce2/3/4 MCP SMBus Controller");
 			return (BUS_PROBE_DEFAULT);
 		}
@@ -245,6 +253,10 @@
 	case NFSMB_DEVICEID_NF4_55_SMB:
 	case NFSMB_DEVICEID_NF4_61_SMB:
 	case NFSMB_DEVICEID_NF4_65_SMB:
+	case NFSMB_DEVICEID_NF4_67_SMB:
+	case NFSMB_DEVICEID_NF4_73_SMB:
+	case NFSMB_DEVICEID_NF4_78S_SMB:
+	case NFSMB_DEVICEID_NF4_79_SMB:
 		/* Trying to add secondary device as slave */
 		nfsmb_sc->subdev = device_add_child(dev, "nfsmb", -1);
 		if (!nfsmb_sc->subdev) {

--Multipart=_Thu__7_Jan_2010_19_52_13_+0100_jDffF=aymMp4.1gV--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100107195213.b2c7e942.lehmann>