I have been having trouble reading the sensors using lmsensors on my 5501 
running ubuntu gutsy.  I looked around quite a bit, but haven't found anything 
authoritative regarding which registers are which on the 5501.  I modified the 
env4801 program from bsd to run on linux, which I have included below.  To 
compile it, just run 


gcc -static env4801.c -o env4801

I did the absolute minimum to get this working so that I could compare
it with lmsensors output.  If I can resolve the issues below, and there
is interest, I will clean it up.

What is driving me crazy is this:


VREF = 1.235  V245 = 2.450
Temp 2 (status=0x81)   38 C
Volt  1 VCORE 106  1.253 V scale  1.0   1.253 V +/- 0.0118 V
Volt  2 VCC   217  2.565 V scale  2.0   5.130 V +/- 0.0236 V
Volt  3 VPWR   52  0.615 V scale 20.1  12.354 V +/- 0.2376 V
Volt  4 +12V  214  2.529 V scale  4.8  12.217 V +/- 0.0571 V
Volt  5 -12V  215  2.541 V scale 19.2 -11.810 V +/- 0.2268 V
Volt  6 GND   224  2.648 V scale  1.0   2.648 V +/- 0.0118 V
Volt  7 Vsb   142  1.678 V scale  2.0   3.357 V +/- 0.0236 V
Volt  8 Vdd   142  1.678 V scale  2.0   3.357 V +/- 0.0236 V
Volt  9 Vbat  255  3.014 V scale  1.0   3.014 V +/- 0.0118 V
Volt 10 AVdd  141  1.667 V scale  2.0   3.333 V +/- 0.0236 V


I find it hard to believe that my GND potential is at 2.648 V. The same
program running on a 4801 yields the following:


VREF = 1.235  V245 = 2.450
Temp 2 (status=0x81)   57 C
Volt  1 VCORE 169  1.997 V scale  1.0   1.997 V +/- 0.0118 V
Volt  2 VCC   211  2.494 V scale  2.0   4.988 V +/- 0.0236 V
Volt  3 VPWR   50  0.591 V scale 20.1  11.878 V +/- 0.2376 V
Volt  4 +12V  208  2.458 V scale  4.8  11.874 V +/- 0.0571 V
Volt  5 -12V  210  2.482 V scale 19.2 -12.944 V +/- 0.2268 V
Volt  6 GND     0  0.000 V scale  1.0   0.000 V +/- 0.0118 V
Volt  7 Vsb   139  1.643 V scale  2.0   3.286 V +/- 0.0236 V
Volt  8 Vdd   139  1.643 V scale  2.0   3.286 V +/- 0.0236 V
Volt  9 Vbat  255  3.014 V scale  1.0   3.014 V +/- 0.0118 V
Volt 10 AVdd    0  0.000 V scale  2.0   0.000 V +/- 0.0236 V


So, methinks something is different between these two boards, else there
is something very funny with the GND on the 5501.

So, anyone have a description of how things are actually connected in
the 5501, or have changes to the code to make it accurate? 

Thanks -- any help appreciated!

-bd

-----------------


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/io.h>

#define VREF    1.235
#define V245    2.45

#define VDIV(a, b)      (((a) + (b)) / (a))
struct avi {
        const char      *name;
        double          offset;
        double          scale;
} avi[14] = {
        { "avi0",       0.0,    1.0 },
        { "VCORE",      0.0,    1.0 },
        { "VCC",        0.0,    VDIV(10.0, 10.0) },
        { "VPWR",       0.0,    VDIV(10.0, 191.0) },
        { "+12V",       0.0,    VDIV(10.0, 38.3) },
        { "-12V",       3.33,   VDIV(3.32, 60.4) },
        { "GND",        0.0,    1.0 },
        { "Vsb",        0.0,    2.0 },
        { "Vdd",        0.0,    2.0 },
        { "Vbat",       0.0,    1.0 },
        { "AVdd",       0.0,    2.0 },
        { "TS1",        0.0,    1.0 },
        { "TS2",        0.0,    1.0 },
        { "TS3",        0.0,    1.0 }
};

#define INB(x)          inb(x)
#define OUTB(x,y)       outb(y,x)

int
main(int argc, char **argv)
{
        FILE *f;
        int i, j, atms, avlm;
        struct avi *avp;
        double a;
        double vref = VREF;

        if(iopl(3)){
                printf("Sorry, you must be root to tickle these registers.\n");
                exit(0);
                }
        OUTB(0x2e, 0x20);
        i = INB(0x2f);
        if (i != 0xe9)
                errx(1, "Expected 0xe9 for SuperIO ID, got %x", i);

        OUTB(0x2e, 0x7);  OUTB(0x2f, 0xe);
        OUTB(0x2e, 0x60); atms = INB(0x2f) * 256;
        OUTB(0x2e, 0x61); atms |= INB(0x2f);
        OUTB(0x2e, 0x30); i = INB(0x2f);
        if (!(i & 1))
                errx(1, "TMS not enabled");

        OUTB(0x2e, 0x7);  OUTB(0x2f, 0xd);
        OUTB(0x2e, 0x60); avlm = INB(0x2f) * 256;
        OUTB(0x2e, 0x61); avlm |= INB(0x2f);
        OUTB(0x2e, 0x30); i = INB(0x2f);
        if (!(i & 1))
                errx(1, "VLM not enabled");

        if (argc == 2 && !strcmp(argv[1], "-i")) {
                /* Magic init sequence from page 208 */
                OUTB(atms + 0x8, 0x00);
                OUTB(atms + 0x9, 0x0f);
                OUTB(atms + 0xa, 0x08);
                OUTB(atms + 0xb, 0x04);
                OUTB(atms + 0xc, 0x35);
                OUTB(atms + 0xd, 0x05);
                OUTB(atms + 0xe, 0x05);

                OUTB(atms + 8, 0);
                for(i = 0; i < 3; i++) {
                        OUTB(atms + 9, i);
                        OUTB(atms + 0xa, 1);
                }
                OUTB(avlm + 7, 0x10);
                OUTB(avlm + 8, 0);
                for(i = 0; i < 10; i++) {
                        OUTB(avlm + 9, i);
                        OUTB(avlm + 0xa, 1);
                }
                for(; i < 14; i++) {
                        OUTB(avlm + 9, i);
                        OUTB(avlm + 0xa, 0);
                }
                return (0);
        }
        if (argc >= 2 && !strcmp(argv[1], "-r")) {
                vref = strtod(argv[2], NULL);
        }

        printf("VREF = %.3f  V245 = %.3f\n", vref, V245);

        for(i = 2; i < 3; i++) {
                OUTB(atms + 9, i);
                printf("Temp %d (status=0x%2x) %4d C\n", i,
                    INB(atms + 0xa), (char)INB(atms + 0xb));

        }

#if 0
        /* The offset for the -12V is measured on AD10 */
        i = 10;
        avp = &avi[i];
        OUTB(avlm + 9, i);
        j = INB(avlm + 0x0b);
        a = vref * V245 * j / 256.0;
        avi[5].offset = a * avp->scale;
#endif

        for(i = 1; i < 11; i++) {
                avp = &avi[i];
                OUTB(avlm + 9, i);
                j = INB(avlm + 0x0b);
                a = vref * V245 * j / 256.0;
                printf(
                    "Volt %2d %-5s %3d %6.3f V scale %4.1f %7.3f V +/- %6.4f 
V\n",
                    i, avp->name, j, a,
                    avp->scale, (a - avp->offset) * avp->scale + avp->offset,
                    vref * V245 / 256.0 * avp->scale);
        }
        return (0);
}

_______________________________________________
Soekris-tech mailing list
[email protected]
http://lists.soekris.com/mailman/listinfo/soekris-tech

Reply via email to