Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt Attach cpu nodes with status "disabled" if they ...
details: https://anonhg.NetBSD.org/src/rev/d9a0a25a5e22
branches: trunk
changeset: 835799:d9a0a25a5e22
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Sep 09 21:15:21 2018 +0000
description:
Attach cpu nodes with status "disabled" if they have an enable-method
property. This is a valid configuration according to the devicetree
specification.
diffstat:
sys/dev/fdt/cpus.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diffs (57 lines):
diff -r f43edb4fe293 -r d9a0a25a5e22 sys/dev/fdt/cpus.c
--- a/sys/dev/fdt/cpus.c Sun Sep 09 21:14:04 2018 +0000
+++ b/sys/dev/fdt/cpus.c Sun Sep 09 21:15:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpus.c,v 1.3 2018/06/30 16:30:35 jmcneill Exp $ */
+/* $NetBSD: cpus.c,v 1.4 2018/09/09 21:15:21 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.3 2018/06/30 16:30:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.4 2018/09/09 21:15:21 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -42,6 +42,8 @@
static int cpus_match(device_t, cfdata_t, void *);
static void cpus_attach(device_t, device_t, void *);
+static bool cpus_bus_match(void *, int);
+
CFATTACH_DECL_NEW(cpus, 0, cpus_match, cpus_attach, NULL, NULL);
static int
@@ -61,5 +63,28 @@
aprint_naive("\n");
aprint_normal("\n");
- fdt_add_bus(self, phandle, faa);
+ fdt_add_bus_match(self, phandle, faa, cpus_bus_match, NULL);
}
+
+static bool
+cpus_bus_match(void *priv, int child)
+{
+ const char *s;
+
+ /* Only match nodes with device_type = "cpu" */
+ s = fdtbus_get_string(child, "device_type");
+ if (!s || strcmp(s, "cpu") != 0)
+ return false;
+
+ /* If status is set, it must be either "okay" or "disabled" */
+ s = fdtbus_get_string(child, "status");
+ if (s) {
+ if (strcmp(s, "okay") == 0)
+ return false;
+ if (strcmp(s, "disabled") == 0)
+ return of_hasprop(child, "enable-method");
+ return false;
+ } else {
+ return true;
+ }
+}
Home |
Main Index |
Thread Index |
Old Index