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 - sunxi_ccu_lcdxch1_set_rate(): enable pa...



details:   https://anonhg.NetBSD.org/src/rev/8b223710ff35
branches:  trunk
changeset: 831501:8b223710ff35
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Mon Apr 02 20:55:49 2018 +0000

description:
- sunxi_ccu_lcdxch1_set_rate(): enable parent before calling
  sunxi_ccu_div_set_rate(). If it's not enabled get_rate() will return 0 and
  sunxi_ccu_div_set_rate() will fail.
- rework sunxi_ccu_lcdxch0_set_rate() to actually really select the best
  parent.

diffstat:

 sys/arch/arm/sunxi/sunxi_ccu_display.c |  36 ++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 10 deletions(-)

diffs (68 lines):

diff -r 817f2ec43e09 -r 8b223710ff35 sys/arch/arm/sunxi/sunxi_ccu_display.c
--- a/sys/arch/arm/sunxi/sunxi_ccu_display.c    Mon Apr 02 20:54:47 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_ccu_display.c    Mon Apr 02 20:55:49 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_ccu_display.c,v 1.1 2018/04/01 21:19:17 bouyer Exp $ */
+/* $NetBSD: sunxi_ccu_display.c,v 1.2 2018/04/02 20:55:49 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2018 Manuel Bouyer <bouyer%antioche.eu.org@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_display.c,v 1.1 2018/04/01 21:19:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_ccu_display.c,v 1.2 2018/04/02 20:55:49 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -46,18 +46,32 @@
 {
        struct clk *clkp;
        int error;
+       int diff, diff_x2;
+       int rate, rate_x2;
 
        clkp = &pllclk->base;
-       error = clk_set_rate(clkp, new_rate);
-       if (error) {
+       rate = clk_round_rate(clkp, new_rate);
+       diff = abs(new_rate - rate);
+
+       rate_x2 = (clk_round_rate(clkp, new_rate / 2) * 2);
+       diff_x2 = abs(new_rate - rate_x2);
+
+       if (rate == 0 && rate_x2 == 0)
+               return ERANGE;
+
+       if (diff_x2 < diff) {
                error = clk_set_rate(clkp, new_rate / 2);
-               if (error != 0)
-                       return error;
-               clkp = &pllclk_x2->base;
+               KASSERT(error == 0);
+               error = clk_set_parent(&clk->base, &pllclk_x2->base);
+               KASSERT(error == 0);
+       } else {
+               error = clk_set_rate(clkp, new_rate);
+               KASSERT(error == 0);
+               error = clk_set_parent(&clk->base, clkp);
+               KASSERT(error == 0);
        }
-       error = clk_set_parent(&clk->base, clkp);
-       KASSERT(error == 0);
-       return error;
+       (void)error;
+       return 0;
 }
 
 u_int
@@ -122,6 +136,8 @@
        KASSERT(error == 0);
        error = clk_set_parent(&clk->base, clkp);
        KASSERT(error == 0);
+       error = clk_enable(clkp);
+       KASSERT(error == 0);
        error = sunxi_ccu_div_set_rate(sc, clk, new_rate);
        KASSERT(error == 0);
        return error;



Home | Main Index | Thread Index | Old Index