Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c get sensor descriptions from OpenFirmware if we ...



details:   https://anonhg.NetBSD.org/src/rev/150b1ba34b49
branches:  trunk
changeset: 356488:150b1ba34b49
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Sep 29 14:17:47 2017 +0000

description:
get sensor descriptions from OpenFirmware if we know how
this needs to be generalized

diffstat:

 sys/dev/i2c/adm1021.c |  34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diffs (73 lines):

diff -r 2226c7f2cb73 -r 150b1ba34b49 sys/dev/i2c/adm1021.c
--- a/sys/dev/i2c/adm1021.c     Fri Sep 29 14:15:42 2017 +0000
+++ b/sys/dev/i2c/adm1021.c     Fri Sep 29 14:17:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adm1021.c,v 1.15 2017/09/20 22:44:28 macallan Exp $ */
+/*     $NetBSD: adm1021.c,v 1.16 2017/09/29 14:17:47 macallan Exp $ */
 /*     $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $        */
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.15 2017/09/20 22:44:28 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.16 2017/09/29 14:17:47 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -47,6 +47,14 @@
 
 #include <dev/i2c/i2cvar.h>
 
+#ifdef macppc
+#define HAVE_OF 1
+#endif
+
+#ifdef HAVE_OF
+#include <dev/ofw/openfirm.h>
+#endif
+
 /* Registers */
 #define ADM1021_INT_TEMP       0x00    /* Internal temperature value */
 #define ADM1021_EXT_TEMP       0x01    /* External temperature value */
@@ -322,7 +330,10 @@
        struct i2c_attach_args *ia = aux;
        uint8_t cmd, data, stat, comp, rev;
        char name[ADMTEMP_NAMELEN];
-
+#ifdef HAVE_OF
+       char ename[64], iname[64];
+       int ch;
+#endif
        sc->sc_tag = ia->ia_tag;
        sc->sc_addr = ia->ia_addr;
 
@@ -384,10 +395,27 @@
        sc->sc_sensor[ADMTEMP_EXT].units = ENVSYS_STEMP;
        sc->sc_sensor[ADMTEMP_INT].flags = ENVSYS_FMONLIMITS;
        sc->sc_sensor[ADMTEMP_EXT].flags = ENVSYS_FMONLIMITS;
+#ifdef HAVE_OF
+       strcpy(iname, "internal");
+       strcpy(ename, "external");
+       ch = OF_child(ia->ia_cookie);
+       if (ch != 0) {
+               OF_getprop(ch, "location", iname, 64);
+               ch = OF_peer(ch);
+               if (ch != 0) {
+                       OF_getprop(ch, "location", ename, 64);
+               }
+       }       
+       strlcpy(sc->sc_sensor[ADMTEMP_INT].desc, iname,
+           sizeof(sc->sc_sensor[ADMTEMP_INT].desc));
+       strlcpy(sc->sc_sensor[ADMTEMP_EXT].desc, ename,
+           sizeof(sc->sc_sensor[ADMTEMP_EXT].desc));
+#else
        strlcpy(sc->sc_sensor[ADMTEMP_INT].desc, "internal",
            sizeof(sc->sc_sensor[ADMTEMP_INT].desc));
        strlcpy(sc->sc_sensor[ADMTEMP_EXT].desc, "external",
            sizeof(sc->sc_sensor[ADMTEMP_EXT].desc));
+#endif
        sc->sc_sme = sysmon_envsys_create();
        if (sysmon_envsys_sensor_attach(
            sc->sc_sme, &sc->sc_sensor[ADMTEMP_INT])) {



Home | Main Index | Thread Index | Old Index