Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc/dev pass sensor locations to i2c devices if ...
details: https://anonhg.NetBSD.org/src/rev/810c96e95b60
branches: trunk
changeset: 985066:810c96e95b60
user: macallan <macallan%NetBSD.org@localhost>
date: Sat Aug 07 06:04:26 2021 +0000
description:
pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini
diffstat:
sys/arch/macppc/dev/pmu.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diffs (57 lines):
diff -r db594ef26f8e -r 810c96e95b60 sys/arch/macppc/dev/pmu.c
--- a/sys/arch/macppc/dev/pmu.c Sat Aug 07 04:19:31 2021 +0000
+++ b/sys/arch/macppc/dev/pmu.c Sat Aug 07 06:04:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $ */
+/* $NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $ */
/*-
* Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -340,7 +340,7 @@
goto next;
if (strncmp(name, "pmu-i2c", 8) == 0) {
- int devs;
+ int devs, sensors;
uint32_t addr;
char compat[256];
prop_array_t cfg;
@@ -372,6 +372,20 @@
prop_object_release(data);
prop_dictionary_set_uint32(dev, "addr", addr);
prop_dictionary_set_uint64(dev, "cookie", devs);
+ sensors = OF_child(devs);
+ while (sensors != 0) {
+ int reg;
+ char loc[64];
+ char pname[8];
+ if (OF_getprop(sensors, "reg", ®, 4) != 4)
+ goto nope;
+ if (OF_getprop(sensors, "location", loc, 63) <= 0)
+ goto nope;
+ snprintf(pname, 7, "s%02x", reg);
+ prop_dictionary_set_string(dev, pname, loc);
+ nope:
+ sensors = OF_peer(sensors);
+ }
prop_array_add(cfg, dev);
prop_object_release(dev);
skip:
@@ -818,7 +832,7 @@
if (pmu_send(sc, PMU_POWER_OFF, 4, cmd, 16, resp) >= 0)
while (1);
}
-
+
void
pmu_restart(void)
{
Home |
Main Index |
Thread Index |
Old Index