Add helper to lookup syscon by phandle

This commit is contained in:
jmcneill 2018-06-30 18:07:12 +00:00
parent a515ac423f
commit 1ca6c5c5ec
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdt_syscon.c,v 1.1 2018/06/30 12:35:18 jmcneill Exp $ */
/* $NetBSD: fdt_syscon.c,v 1.2 2018/06/30 18:07:12 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fdt_syscon.c,v 1.1 2018/06/30 12:35:18 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: fdt_syscon.c,v 1.2 2018/06/30 18:07:12 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -96,3 +96,15 @@ fdtbus_syscon_acquire(int phandle, const char *prop)
return sc->sc_syscon;
}
struct syscon *
fdtbus_syscon_lookup(int phandle)
{
struct fdtbus_syscon *sc;
sc = fdtbus_get_syscon(phandle);
if (sc == NULL)
return NULL;
return sc->sc_syscon;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdtvar.h,v 1.36 2018/06/30 16:22:56 jmcneill Exp $ */
/* $NetBSD: fdtvar.h,v 1.37 2018/06/30 18:07:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@ -296,6 +296,7 @@ int fdtbus_regulator_set_voltage(struct fdtbus_regulator *,
int fdtbus_regulator_get_voltage(struct fdtbus_regulator *,
u_int *);
struct syscon * fdtbus_syscon_acquire(int, const char *);
struct syscon * fdtbus_syscon_lookup(int);
struct fdtbus_dma *fdtbus_dma_get(int, const char *, void (*)(void *), void *);
struct fdtbus_dma *fdtbus_dma_get_index(int, u_int, void (*)(void *),