Module Name: src
Committed By: macallan
Date: Thu Aug 15 22:35:39 UTC 2019
Modified Files:
src/sys/arch/macppc/dev: ki2c.c
Log Message:
pass sensor location info to drivers if we can find it
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/dev/ki2c.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/macppc/dev/ki2c.c
diff -u src/sys/arch/macppc/dev/ki2c.c:1.25 src/sys/arch/macppc/dev/ki2c.c:1.26
--- src/sys/arch/macppc/dev/ki2c.c:1.25 Thu Mar 8 21:53:20 2018
+++ src/sys/arch/macppc/dev/ki2c.c Thu Aug 15 22:35:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ki2c.c,v 1.25 2018/03/08 21:53:20 macallan Exp $ */
+/* $NetBSD: ki2c.c,v 1.26 2019/08/15 22:35:39 macallan Exp $ */
/* Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp */
/*-
@@ -84,13 +84,13 @@ ki2c_attach(device_t parent, device_t se
struct ki2c_softc *sc = device_private(self);
struct confargs *ca = aux;
int node = ca->ca_node;
- uint32_t addr, channel;
+ uint32_t addr, channel, reg;
int rate, child, /*namelen,*/ i2cbus;
struct i2cbus_attach_args iba;
prop_dictionary_t dict = device_properties(self);
prop_array_t cfg;
- int devs;
- char compat[256];
+ int devs, devc;
+ char compat[256], num[8], descr[32];
prop_dictionary_t dev;
prop_data_t data;
char name[32];
@@ -178,6 +178,18 @@ ki2c_attach(device_t parent, device_t se
prop_object_release(data);
prop_dictionary_set_uint32(dev, "addr", addr);
prop_dictionary_set_uint64(dev, "cookie", devs);
+ /* look for location info for sensors */
+ devc = OF_child(devs);
+ while (devc != 0) {
+ if (OF_getprop(devc, "reg", ®, 4) < 4) goto nope;
+ if (OF_getprop(devc, "location", descr, 32) <= 0)
+ goto nope;
+ DPRINTF("found '%s' at %02x\n", descr, reg);
+ snprintf(num, 7, "s%02x", reg);
+ prop_dictionary_set_cstring(dev, num, descr);
+ nope:
+ devc = OF_peer(devc);
+ }
prop_array_add(cfg, dev);
prop_object_release(dev);
skip: