Subject: Re: AMD-8111 and ADT7463 support patches
To: Anil Gopinath <anil_public@yahoo.com>
From: Mihai CHELARU <kefren@netbsd.ro>
List: port-amd64
Date: 01/08/2006 16:29:37
Anil Gopinath wrote:
> I just submitted a patch for 
> 
> -  hardware random # generator found in AMD-8111
> -  smbus1.0 host controller found in AMD-8111
> -  ADT 7463 remote thermal controller and voltage
> monitor

Btw, if anyone has Abit mainboards with uGuru and wants check the 
sensors there is a nice program at 
http://hem.bredband.net/b330708/oguru/oguru.tar.gz that works on netbsd 
with minor changes (mostly because of outb params swaping difference 
between linux and netbsd):

diff -u --unidirectional-new-file oguru.old/Makefile oguru/Makefile
--- oguru.old/Makefile  1970-01-01 02:00:00.000000000 +0200
+++ oguru/Makefile      2006-01-08 14:36:00.000000000 +0200
@@ -0,0 +1,4 @@
+all:
+       gcc -o oguru main.c openGuru.c -lx86_64
+clean:
+       rm -f oguru
diff -u --unidirectional-new-file oguru.old/openGuru.c oguru/openGuru.c
--- oguru.old/openGuru.c        2005-03-24 12:08:39.000000000 +0200
+++ oguru/openGuru.c    2006-01-08 14:39:18.000000000 +0200
@@ -15,7 +15,13 @@
   * 
      *
 
***************************************************************************/

+#ifdef __NetBSD__
+#include <sys/types.h>
+#include <machine/pio.h>
+#include <machine/sysarch.h>
+#else
  #include <sys/io.h>
+#endif
  #include "openGuru.h"
  #include <stdio.h>

@@ -26,9 +32,13 @@
         unsigned char portData, portCommand;

         // Get i/o acces to the uGuru ports
+#ifdef __NetBSD__
+/* Looks like NetBSD hasn't made ioperm work on x86_64 so we'll use 
x86_64_iopl */
+       x86_64_iopl(3);
+#else
         ioperm(PORT_CMD,1,TRUE);
         ioperm(PORT_DATA,1,TRUE);
-
+#endif
         // Read the ports
         portData = inb(PORT_DATA);
         portCommand =  inb(PORT_CMD);
@@ -58,8 +68,11 @@
         // The loop shouldn't be needed to execut more then one time
         while(inb(PORT_DATA) != 0x08)
         {
+#ifdef __NetBSD__
+               outb(PORT_DATA,0x00);
+#else
                 outb(0x00,PORT_DATA);                           // 
after 0x00 is written to Data port
-
+#endif
                 // Wait until 0x09 is read at Data port
                 while( inb(PORT_DATA) != 0x09)
                 {
@@ -97,8 +110,11 @@
         Port_lAddr = (0x00FF & SensorID);

         // Ask to read from uGuru
+#ifdef __NetBSD__
+       outb(PORT_DATA, Port_hAddr);
+#else
         outb(Port_hAddr,PORT_DATA);                             // Out 
BankID @ Data
-
+#endif
         // I guess this is to se if uGuru is ready to take a command
         while(inb(PORT_DATA) != 0x08)                           // In 
0x08 @ Data
         {
@@ -107,8 +123,11 @@
                         return FALSE;
         }
         // Whitch sensor to read?
+#ifdef __NetBSD__
+       outb(PORT_CMD, Port_lAddr);
+#else
         outb(Port_lAddr,PORT_CMD);                              // Out 
Sensor ID @ Cmd
-
+#endif
         LockupCnt = 0;
         // Wait until uGuru is ready to be read
         while(inb(PORT_DATA) != 0x01)


The output looks like this:


# ./oguru
uGuru detected!
Temperatures:
CPU:            49C
SYS:            43C
PWM:            44C

Voltages:
Vcore:          1.40V
DDRVdd:         2.67V
DDRVtt:         1.34V
NBVdd:          1.59V
SBVdd:          2.22V
HTVdd:          1.22V
AGPVdd:         3.34V
Vdd5V:          5.12V
Vdd3V3:         3.32V
Vdd5VSB:        5.02V
Vdd3VDual:      3.68V

Fans:
CPU fan:        3600RPM
NB fan:         0RPM
SYS fan:        0RPM
AUX fan1:       0RPM
AUX fan2:       0RPM


If anyone cares to introduce that to kernel and sysenv it would be great.

-- 
Mihai