Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Support cpu nodes without a cpu-supply property.



details:   https://anonhg.NetBSD.org/src/rev/5f97586b50b0
branches:  trunk
changeset: 358197:5f97586b50b0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Dec 16 16:41:18 2017 +0000

description:
Support cpu nodes without a cpu-supply property.

diffstat:

 sys/dev/fdt/cpufreq_dt.c |  48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diffs (95 lines):

diff -r 30c8ed56bdad -r 5f97586b50b0 sys/dev/fdt/cpufreq_dt.c
--- a/sys/dev/fdt/cpufreq_dt.c  Sat Dec 16 16:40:33 2017 +0000
+++ b/sys/dev/fdt/cpufreq_dt.c  Sat Dec 16 16:41:18 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufreq_dt.c,v 1.2 2017/10/05 01:28:01 jmcneill Exp $ */
+/* $NetBSD: cpufreq_dt.c,v 1.3 2017/12/16 16:41:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.2 2017/10/05 01:28:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.3 2017/12/16 16:41:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -94,31 +94,35 @@
 
        old_rate = clk_get_rate(sc->sc_clk);
        new_rate = freq_khz * 1000;
+       new_uv = opp->voltage_uv;
 
        if (old_rate == new_rate)
                return 0;
 
-       error = fdtbus_regulator_get_voltage(sc->sc_supply, &old_uv);
-       if (error != 0)
-               return error;
-       new_uv = opp->voltage_uv;
-
-       if (new_uv > old_uv) {
-               error = fdtbus_regulator_set_voltage(sc->sc_supply,
-                   new_uv, new_uv);
+       if (sc->sc_supply != NULL) {
+               error = fdtbus_regulator_get_voltage(sc->sc_supply, &old_uv);
                if (error != 0)
                        return error;
+
+               if (new_uv > old_uv) {
+                       error = fdtbus_regulator_set_voltage(sc->sc_supply,
+                           new_uv, new_uv);
+                       if (error != 0)
+                               return error;
+               }
        }
 
        error = clk_set_rate(sc->sc_clk, new_rate);
        if (error != 0)
                return error;
 
-       if (new_uv < old_uv) {
-               error = fdtbus_regulator_set_voltage(sc->sc_supply,
-                   new_uv, new_uv);
-               if (error != 0)
-                       return error;
+       if (sc->sc_supply != NULL) {
+               if (new_uv < old_uv) {
+                       error = fdtbus_regulator_set_voltage(sc->sc_supply,
+                           new_uv, new_uv);
+                       if (error != 0)
+                               return error;
+               }
        }
 
        if (error == 0) {
@@ -298,10 +302,13 @@
        int len, i;
        u_int lat;
 
-       sc->sc_supply = fdtbus_regulator_acquire(phandle, "cpu-supply");
-       if (sc->sc_supply == NULL) {
-               aprint_error_dev(sc->sc_dev, "couldn't acquire cpu-supply\n");
-               return ENXIO;
+       if (of_hasprop(phandle, "cpu-supply")) {
+               sc->sc_supply = fdtbus_regulator_acquire(phandle, "cpu-supply");
+               if (sc->sc_supply == NULL) {
+                       aprint_error_dev(sc->sc_dev,
+                           "couldn't acquire cpu-supply\n");
+                       return ENXIO;
+               }
        }
        sc->sc_clk = fdtbus_clock_get_index(phandle, 0);
        if (sc->sc_clk == NULL) {
@@ -347,8 +354,7 @@
                return 0;
 
        if (!of_hasprop(phandle, "operating-points") ||
-           !of_hasprop(phandle, "clocks") ||
-           !of_hasprop(phandle, "cpu-supply"))
+           !of_hasprop(phandle, "clocks"))
                return 0;
 
        return 1;



Home | Main Index | Thread Index | Old Index