summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2018-01-03 04:15:52 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2018-01-03 04:15:52 +0000
commit5c652f4f844ab94995782a5cb735e8c5aa7b6f93 (patch)
treea5881f99a39d84e09f1617cab9eb7f220dd8fe5e /sys/dev
parented0f56fefa013aca5912051bf5c4f42f9a394eca (diff)
Add remap_bynode() since I use it in the rkpcie(4) implementation.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ofw/ofw_misc.c17
-rw-r--r--sys/dev/ofw/ofw_misc.h3
2 files changed, 18 insertions, 2 deletions
diff --git a/sys/dev/ofw/ofw_misc.c b/sys/dev/ofw/ofw_misc.c
index 60d33f58931..06d74753316 100644
--- a/sys/dev/ofw/ofw_misc.c
+++ b/sys/dev/ofw/ofw_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_misc.c,v 1.2 2017/05/05 17:38:22 kettenis Exp $ */
+/* $OpenBSD: ofw_misc.c,v 1.3 2018/01/03 04:15:51 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis
*
@@ -25,6 +25,7 @@
#include <dev/ofw/ofw_misc.h>
struct regmap {
+ int rm_node;
uint32_t rm_phandle;
bus_space_tag_t rm_tag;
bus_space_handle_t rm_handle;
@@ -45,6 +46,7 @@ regmap_register(int node, bus_space_tag_t tag, bus_space_handle_t handle,
phandle = OF_getpropint(node, "phandle", 0);
if (phandle) {
rm = malloc(sizeof(struct regmap), M_DEVBUF, M_WAITOK);
+ rm->rm_node = node;
rm->rm_phandle = phandle;
rm->rm_tag = tag;
rm->rm_handle = handle;
@@ -54,6 +56,19 @@ regmap_register(int node, bus_space_tag_t tag, bus_space_handle_t handle,
}
struct regmap *
+regmap_bynode(int node)
+{
+ struct regmap *rm;
+
+ LIST_FOREACH(rm, &regmaps, rm_list) {
+ if (rm->rm_node == node)
+ return rm;
+ }
+
+ return NULL;
+}
+
+struct regmap *
regmap_byphandle(uint32_t phandle)
{
struct regmap *rm;
diff --git a/sys/dev/ofw/ofw_misc.h b/sys/dev/ofw/ofw_misc.h
index 37bd01105ec..add4cdf303a 100644
--- a/sys/dev/ofw/ofw_misc.h
+++ b/sys/dev/ofw/ofw_misc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_misc.h,v 1.1 2017/03/09 20:01:10 kettenis Exp $ */
+/* $OpenBSD: ofw_misc.h,v 1.2 2018/01/03 04:15:51 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis
*
@@ -21,6 +21,7 @@
void regmap_register(int, bus_space_tag_t, bus_space_handle_t, bus_size_t);
struct regmap;
+struct regmap *regmap_bynode(int);
struct regmap *regmap_byphandle(uint32_t);
uint32_t regmap_read_4(struct regmap *, bus_size_t);