Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/clk As discussed on tech-kern@ 10 days ago, add a cl...



details:   https://anonhg.NetBSD.org/src/rev/2d807e894e6a
branches:  trunk
changeset: 321709:2d807e894e6a
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Apr 01 21:11:01 2018 +0000

description:
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.

diffstat:

 sys/dev/clk/clk.c         |  14 ++++++++++++--
 sys/dev/clk/clk.h         |   3 ++-
 sys/dev/clk/clk_backend.h |   3 ++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diffs (69 lines):

diff -r 958a57cd9e04 -r 2d807e894e6a sys/dev/clk/clk.c
--- a/sys/dev/clk/clk.c Sun Apr 01 21:05:55 2018 +0000
+++ b/sys/dev/clk/clk.c Sun Apr 01 21:11:01 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        }
 }
 
+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)
 {
diff -r 958a57cd9e04 -r 2d807e894e6a sys/dev/clk/clk.h
--- a/sys/dev/clk/clk.h Sun Apr 01 21:05:55 2018 +0000
+++ b/sys/dev/clk/clk.h Sun Apr 01 21:11:01 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -36,6 +36,7 @@
 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 *);
diff -r 958a57cd9e04 -r 2d807e894e6a sys/dev/clk/clk_backend.h
--- a/sys/dev/clk/clk_backend.h Sun Apr 01 21:05:55 2018 +0000
+++ b/sys/dev/clk/clk_backend.h Sun Apr 01 21:11:01 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -49,6 +49,7 @@
 
        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 *);



Home | Main Index | Thread Index | Old Index