Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/sunxi Pass set_rate calls on fixed factor clock...



details:   https://anonhg.NetBSD.org/src/rev/e1c800ea35e3
branches:  trunk
changeset: 322584:e1c800ea35e3
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue May 08 22:05:25 2018 +0000

description:
Pass set_rate calls on fixed factor clocks through to the parent clock (adjusting accordingly)

diffstat:

 sys/arch/arm/sunxi/sunxi_ccu.h              |   5 +++-
 sys/arch/arm/sunxi/sunxi_ccu_fixed_factor.c |  31 +++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 3 deletions(-)

diffs (78 lines):

diff -r 046015baef38 -r e1c800ea35e3 sys/arch/arm/sunxi/sunxi_ccu.h
--- a/sys/arch/arm/sunxi/sunxi_ccu.h    Tue May 08 19:35:17 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu.h    Tue May 08 22:05:25 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu.h,v 1.17 2018/04/01 21:19:17 bouyer Exp $ */
+/* $NetBSD: sunxi_ccu.h,v 1.18 2018/05/08 22:05:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -341,6 +341,8 @@
 
 u_int  sunxi_ccu_fixed_factor_get_rate(struct sunxi_ccu_softc *,
                                        struct sunxi_ccu_clk *);
+int    sunxi_ccu_fixed_factor_set_rate(struct sunxi_ccu_softc *,
+                                       struct sunxi_ccu_clk *, u_int);
 const char *sunxi_ccu_fixed_factor_get_parent(struct sunxi_ccu_softc *,
                                              struct sunxi_ccu_clk *);
 
@@ -353,6 +355,7 @@
                .u.fixed_factor.mult = (_mult),                         \
                .get_rate = sunxi_ccu_fixed_factor_get_rate,            \
                .get_parent = sunxi_ccu_fixed_factor_get_parent,        \
+               .set_rate = sunxi_ccu_fixed_factor_set_rate,            \
        }
 
 struct sunxi_ccu_fractional {
diff -r 046015baef38 -r e1c800ea35e3 sys/arch/arm/sunxi/sunxi_ccu_fixed_factor.c
--- a/sys/arch/arm/sunxi/sunxi_ccu_fixed_factor.c       Tue May 08 19:35:17 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu_fixed_factor.c       Tue May 08 22:05:25 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_fixed_factor.c,v 1.1 2017/09/30 12:48:58 jmcneill Exp $ */
+/* $NetBSD: sunxi_ccu_fixed_factor.c,v 1.2 2018/05/08 22:05:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fixed_factor.c,v 1.1 2017/09/30 12:48:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_fixed_factor.c,v 1.2 2018/05/08 22:05:25 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -64,6 +64,33 @@
        return (u_int)(((uint64_t)p_rate * fixed_factor->mult) / fixed_factor->div);
 }
 
+static int
+sunxi_ccu_fixed_factor_set_parent_rate(struct clk *clkp, u_int rate)
+{
+       struct clk *clkp_parent;
+
+       clkp_parent = clk_get_parent(clkp);
+       if (clkp_parent == NULL)
+               return ENXIO;
+
+       return clk_set_rate(clkp_parent, rate);
+}
+
+int
+sunxi_ccu_fixed_factor_set_rate(struct sunxi_ccu_softc *sc,
+    struct sunxi_ccu_clk *clk, u_int rate)
+{
+       struct sunxi_ccu_fixed_factor *fixed_factor = &clk->u.fixed_factor;
+       struct clk *clkp = &clk->base;
+
+       KASSERT(clk->type == SUNXI_CCU_FIXED_FACTOR);
+
+       rate *= fixed_factor->div;
+       rate /= fixed_factor->mult;
+
+       return sunxi_ccu_fixed_factor_set_parent_rate(clkp, rate);
+}
+
 const char *
 sunxi_ccu_fixed_factor_get_parent(struct sunxi_ccu_softc *sc,
     struct sunxi_ccu_clk *clk)



Home | Main Index | Thread Index | Old Index