Add fdtbus_clock_enable and fdtbus_clock_enable_index shortcuts

This commit is contained in:
jmcneill 2019-11-09 23:28:26 +00:00
parent 088b457010
commit 47f97eb335
2 changed files with 29 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $ */
/* $NetBSD: fdt_clock.c,v 1.10 2019/11/09 23:28:26 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.9 2019/10/28 21:15:34 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.10 2019/11/09 23:28:26 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -161,6 +161,30 @@ fdtbus_clock_get(int phandle, const char *clkname)
return fdtbus_clock_get_prop(phandle, clkname, "clock-names");
}
int
fdtbus_clock_enable(int phandle, const char *clkname, bool required)
{
struct clk *clk;
clk = fdtbus_clock_get(phandle, clkname);
if (clk == NULL)
return required ? ENOENT : 0;
return clk_enable(clk);
}
int
fdtbus_clock_enable_index(int phandle, u_int index, bool required)
{
struct clk *clk;
clk = fdtbus_clock_get_index(phandle, index);
if (clk == NULL)
return required ? ENOENT : 0;
return clk_enable(clk);
}
/*
* Search the DT for a clock by "clock-output-names" property.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdtvar.h,v 1.56 2019/10/28 21:15:34 jmcneill Exp $ */
/* $NetBSD: fdtvar.h,v 1.57 2019/11/09 23:28:26 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@ -367,6 +367,8 @@ struct clk * fdtbus_clock_get_index(int, u_int);
struct clk * fdtbus_clock_byname(const char *);
void fdtbus_clock_assign(int);
u_int fdtbus_clock_count(int, const char *);
int fdtbus_clock_enable(int, const char *, bool);
int fdtbus_clock_enable_index(int, u_int, bool);
struct fdtbus_reset *fdtbus_reset_get(int, const char *);
struct fdtbus_reset *fdtbus_reset_get_index(int, u_int);