Module Name: src
Committed By: bouyer
Date: Sun Apr 1 21:11:01 UTC 2018
Modified Files:
src/sys/dev/clk: clk.c clk.h clk_backend.h
Log Message:
As discussed on tech-kern@ 10 days ago, add a clk_round_rate() method,
which returns the rate that would be used by this clock if clk_set_rate()
was called. Used by drivers (or other clocks) which have their own divider
and need to know the parent's clock capabilities to compute the best
parameters.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/clk/clk.c src/sys/dev/clk/clk.h \
src/sys/dev/clk/clk_backend.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/clk/clk.c
diff -u src/sys/dev/clk/clk.c:1.2 src/sys/dev/clk/clk.c:1.3
--- src/sys/dev/clk/clk.c:1.2 Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk.c Sun Apr 1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk.c,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk.c,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.2 2017/04/16 12:28:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.3 2018/04/01 21:11:01 bouyer Exp $");
#include <sys/param.h>
@@ -65,6 +65,16 @@ clk_set_rate(struct clk *clk, u_int rate
}
}
+u_int
+clk_round_rate(struct clk *clk, u_int rate)
+{
+ if (clk->domain->funcs->round_rate) {
+ return clk->domain->funcs->round_rate(clk->domain->priv,
+ clk, rate);
+ }
+ return 0;
+}
+
int
clk_enable(struct clk *clk)
{
Index: src/sys/dev/clk/clk.h
diff -u src/sys/dev/clk/clk.h:1.2 src/sys/dev/clk/clk.h:1.3
--- src/sys/dev/clk/clk.h:1.2 Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk.h Sun Apr 1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk.h,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk.h,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -36,6 +36,7 @@ struct clk * clk_get(struct clk_domain *
void clk_put(struct clk *);
u_int clk_get_rate(struct clk *);
int clk_set_rate(struct clk *, u_int);
+u_int clk_round_rate(struct clk *, u_int);
int clk_enable(struct clk *);
int clk_disable(struct clk *);
int clk_set_parent(struct clk *, struct clk *);
Index: src/sys/dev/clk/clk_backend.h
diff -u src/sys/dev/clk/clk_backend.h:1.2 src/sys/dev/clk/clk_backend.h:1.3
--- src/sys/dev/clk/clk_backend.h:1.2 Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk_backend.h Sun Apr 1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk_backend.h,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk_backend.h,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -49,6 +49,7 @@ struct clk_funcs {
u_int (*get_rate)(void *, struct clk *);
int (*set_rate)(void *, struct clk *, u_int);
+ u_int (*round_rate)(void *, struct clk *, u_int);
int (*enable)(void *, struct clk *);
int (*disable)(void *, struct clk *);
int (*set_parent)(void *, struct clk *, struct clk *);