-/* $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
*
#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;
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;
}
}
+struct regmap *
+regmap_bynode(int node)
+{
+ struct regmap *rm;
+
+ LIST_FOREACH(rm, ®maps, rm_list) {
+ if (rm->rm_node == node)
+ return rm;
+ }
+
+ return NULL;
+}
+
struct regmap *
regmap_byphandle(uint32_t phandle)
{
-/* $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
*
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);