diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2019-10-28 10:43:08 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2019-10-28 10:43:08 +0000 |
| commit | 672d88fae241cbb0331c81537b5caa59031dbcfa (patch) | |
| tree | e87286bb38667c23682acfdb7686bf079d4a1ce2 /sys/dev/fdt | |
| parent | 9648274c902be25bee0d84419be98d1e2d171367 (diff) | |
Skip nodes with an "opp-suspend" property and fix tables that have disabled
nodes in the middle.
Diffstat (limited to 'sys/dev/fdt')
| -rw-r--r-- | sys/dev/fdt/cpufreq_dt.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/fdt/cpufreq_dt.c b/sys/dev/fdt/cpufreq_dt.c index 5bbcc3c9a2f..e2c0226cf4d 100644 --- a/sys/dev/fdt/cpufreq_dt.c +++ b/sys/dev/fdt/cpufreq_dt.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpufreq_dt.c,v 1.10 2019/10/07 13:54:59 martin Exp $ */ +/* $NetBSD: cpufreq_dt.c,v 1.11 2019/10/28 10:43:08 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.10 2019/10/07 13:54:59 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.11 2019/10/28 10:43:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -363,7 +363,7 @@ cpufreq_dt_parse_opp_v2(struct cpufreq_dt_softc *sc) struct cpufreq_dt_table *table; const u_int *opp_uv; uint64_t opp_hz; - int opp_node, len, i; + int opp_node, len, i, index; const int opp_table = fdtbus_get_phandle(phandle, "operating-points-v2"); if (opp_table < 0) @@ -379,27 +379,33 @@ cpufreq_dt_parse_opp_v2(struct cpufreq_dt_softc *sc) } for (opp_node = OF_child(opp_table); opp_node; opp_node = OF_peer(opp_node)) { - if (fdtbus_status_okay(opp_node)) - sc->sc_nopp++; + if (!fdtbus_status_okay(opp_node)) + continue; + if (of_hasprop(opp_node, "opp-suspend")) + continue; + sc->sc_nopp++; } if (sc->sc_nopp == 0) return EINVAL; sc->sc_opp = kmem_zalloc(sizeof(*sc->sc_opp) * sc->sc_nopp, KM_SLEEP); + index = sc->sc_nopp - 1; for (opp_node = OF_child(opp_table), i = 0; opp_node; opp_node = OF_peer(opp_node), i++) { if (!fdtbus_status_okay(opp_node)) continue; + if (of_hasprop(opp_node, "opp-suspend")) + continue; if (of_getprop_uint64(opp_node, "opp-hz", &opp_hz) != 0) return EINVAL; opp_uv = fdtbus_get_prop(opp_node, "opp-microvolt", &len); if (opp_uv == NULL || len < 1) return EINVAL; /* Table is in reverse order */ - const int index = sc->sc_nopp - i - 1; sc->sc_opp[index].freq_khz = (u_int)(opp_hz / 1000); sc->sc_opp[index].voltage_uv = be32toh(opp_uv[0]); of_getprop_uint32(opp_node, "clock-latency-ns", &sc->sc_opp[index].latency_ns); + --index; } return 0; |
