| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpufreq_dt.c,v 1.9 2019/10/06 11:28:24 jmcneill Exp $ */ | | 1 | /* $NetBSD: cpufreq_dt.c,v 1.10 2019/10/07 13:54:59 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.9 2019/10/06 11:28:24 jmcneill Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.10 2019/10/07 13:54:59 martin Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
35 | #include <sys/kmem.h> | | 35 | #include <sys/kmem.h> |
36 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
37 | #include <sys/atomic.h> | | 37 | #include <sys/atomic.h> |
38 | #include <sys/xcall.h> | | 38 | #include <sys/xcall.h> |
39 | #include <sys/sysctl.h> | | 39 | #include <sys/sysctl.h> |
40 | #include <sys/queue.h> | | 40 | #include <sys/queue.h> |
41 | #include <sys/once.h> | | 41 | #include <sys/once.h> |
42 | #include <sys/cpu.h> | | 42 | #include <sys/cpu.h> |
43 | | | 43 | |
| @@ -261,27 +261,27 @@ cpufreq_dt_cpu_lookup(cpuid_t mpidr) | | | @@ -261,27 +261,27 @@ cpufreq_dt_cpu_lookup(cpuid_t mpidr) |
261 | if (ci->ci_cpuid == mpidr) | | 261 | if (ci->ci_cpuid == mpidr) |
262 | return ci; | | 262 | return ci; |
263 | } | | 263 | } |
264 | | | 264 | |
265 | return NULL; | | 265 | return NULL; |
266 | } | | 266 | } |
267 | | | 267 | |
268 | static void | | 268 | static void |
269 | cpufreq_dt_init_sysctl(struct cpufreq_dt_softc *sc) | | 269 | cpufreq_dt_init_sysctl(struct cpufreq_dt_softc *sc) |
270 | { | | 270 | { |
271 | const struct sysctlnode *node, *cpunode; | | 271 | const struct sysctlnode *node, *cpunode; |
272 | struct sysctllog *cpufreq_log = NULL; | | 272 | struct sysctllog *cpufreq_log = NULL; |
273 | struct cpu_info *ci; | | 273 | struct cpu_info *ci; |
274 | uint64_t mpidr; | | 274 | bus_addr_t mpidr; |
275 | int error, i; | | 275 | int error, i; |
276 | | | 276 | |
277 | if (fdtbus_get_reg(sc->sc_phandle, 0, &mpidr, 0) != 0) | | 277 | if (fdtbus_get_reg(sc->sc_phandle, 0, &mpidr, 0) != 0) |
278 | return; | | 278 | return; |
279 | | | 279 | |
280 | ci = cpufreq_dt_cpu_lookup(mpidr); | | 280 | ci = cpufreq_dt_cpu_lookup(mpidr); |
281 | if (ci == NULL) | | 281 | if (ci == NULL) |
282 | return; | | 282 | return; |
283 | | | 283 | |
284 | sc->sc_freq_available = kmem_zalloc(strlen("XXXX ") * sc->sc_nopp, KM_SLEEP); | | 284 | sc->sc_freq_available = kmem_zalloc(strlen("XXXX ") * sc->sc_nopp, KM_SLEEP); |
285 | for (i = 0; i < sc->sc_nopp; i++) { | | 285 | for (i = 0; i < sc->sc_nopp; i++) { |
286 | char buf[6]; | | 286 | char buf[6]; |
287 | snprintf(buf, sizeof(buf), i ? " %u" : "%u", sc->sc_opp[i].freq_khz / 1000); | | 287 | snprintf(buf, sizeof(buf), i ? " %u" : "%u", sc->sc_opp[i].freq_khz / 1000); |