Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt Add fdtbus_clock_enable and fdtbus_clock_enable_...



details:   https://anonhg.NetBSD.org/src/rev/a75ae0dc50f3
branches:  trunk
changeset: 465159:a75ae0dc50f3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Nov 09 23:28:26 2019 +0000

description:
Add fdtbus_clock_enable and fdtbus_clock_enable_index shortcuts

diffstat:

 sys/dev/fdt/fdt_clock.c |  28 ++++++++++++++++++++++++++--
 sys/dev/fdt/fdtvar.h    |   4 +++-
 2 files changed, 29 insertions(+), 3 deletions(-)

diffs (67 lines):

diff -r 79c1b55eba4c -r a75ae0dc50f3 sys/dev/fdt/fdt_clock.c
--- a/sys/dev/fdt/fdt_clock.c   Sat Nov 09 23:27:50 2019 +0000
+++ b/sys/dev/fdt/fdt_clock.c   Sat Nov 09 23:28:26 2019 +0000
@@ -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@localhost>
@@ -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 @@
        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.
  *
diff -r 79c1b55eba4c -r a75ae0dc50f3 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Sat Nov 09 23:27:50 2019 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sat Nov 09 23:28:26 2019 +0000
@@ -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@localhost>
@@ -367,6 +367,8 @@
 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);



Home | Main Index | Thread Index | Old Index