diff options
| author | bouyer <bouyer@NetBSD.org> | 2018-04-01 21:11:01 +0000 |
|---|---|---|
| committer | bouyer <bouyer@NetBSD.org> | 2018-04-01 21:11:01 +0000 |
| commit | 9cfca8ac9b1cb2996cc84ed6c03d415ec9421de3 (patch) | |
| tree | 289b6d90afe1040648d2b603785f667b2492ceb2 /sys/dev | |
| parent | 8f1197d07c81414c5224df758d04a09286ad7c91 (diff) | |
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 (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/clk/clk.c | 14 | ||||
| -rw-r--r-- | sys/dev/clk/clk.h | 3 | ||||
| -rw-r--r-- | sys/dev/clk/clk_backend.h | 3 |
3 files changed, 16 insertions, 4 deletions
diff --git a/sys/dev/clk/clk.c b/sys/dev/clk/clk.c index 128728724ba..33c48035676 100644 --- a/sys/dev/clk/clk.c +++ b/sys/dev/clk/clk.c @@ -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> @@ -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) { diff --git a/sys/dev/clk/clk.h b/sys/dev/clk/clk.h index 1f4131ecb2e..90eca4a5722 100644 --- a/sys/dev/clk/clk.h +++ b/sys/dev/clk/clk.h @@ -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> @@ -36,6 +36,7 @@ struct clk * clk_get(struct clk_domain *, const char *); 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 --git a/sys/dev/clk/clk_backend.h b/sys/dev/clk/clk_backend.h index cfb8e0fc1bd..c4bda980051 100644 --- a/sys/dev/clk/clk_backend.h +++ b/sys/dev/clk/clk_backend.h @@ -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> @@ -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 *); |
