Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm gtmr: Add support for arm,cpu-registers-not-fw-...
details: https://anonhg.NetBSD.org/src/rev/03f45eccd1cc
branches: trunk
changeset: 1025559:03f45eccd1cc
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Nov 12 21:59:04 2021 +0000
description:
gtmr: Add support for arm,cpu-registers-not-fw-configured property.
On armv7, arm,cpu-registers-not-fw-configured means that firmware hasn't
bothered to configure any generic timer registers and we need to
initialize cntfrq ourselves.
diffstat:
sys/arch/arm/cortex/gtmr.c | 15 +++++++++++++--
sys/arch/arm/cortex/gtmr_var.h | 5 +++--
sys/arch/arm/fdt/gtmr_fdt.c | 25 +++++++++++++++++++++++--
3 files changed, 39 insertions(+), 6 deletions(-)
diffs (115 lines):
diff -r 622ae3b60ca7 -r 03f45eccd1cc sys/arch/arm/cortex/gtmr.c
--- a/sys/arch/arm/cortex/gtmr.c Fri Nov 12 21:57:44 2021 +0000
+++ b/sys/arch/arm/cortex/gtmr.c Fri Nov 12 21:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gtmr.c,v 1.46 2021/10/31 16:23:47 skrll Exp $ */
+/* $NetBSD: gtmr.c,v 1.47 2021/11/12 21:59:04 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.46 2021/10/31 16:23:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.47 2021/11/12 21:59:04 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -127,6 +127,13 @@
aprint_normal(": Generic Timer (%s, %s)\n", freqbuf,
sc->sc_physical ? "physical" : "virtual");
+#if defined(__arm__)
+ if (prop_dictionary_get_bool(dict, "arm,cpu-registers-not-fw-configured", &flag) && flag) {
+ sc->sc_flags |= GTMR_FLAG_CPU_REGISTERS_NOT_FW_CONFIGURED;
+ aprint_debug_dev(self, "CPU registers not initialized by firmware\n");
+ }
+#endif
+
if (prop_dictionary_get_bool(dict, "sun50i-a64-unstable-timer", &flag) && flag) {
sc->sc_flags |= GTMR_FLAG_SUN50I_A64_UNSTABLE_TIMER;
aprint_debug_dev(self, "enabling Allwinner A64 timer workaround\n");
@@ -250,6 +257,10 @@
/* XXX hmm... called from cpu_hatch which hasn't lowered ipl yet */
int s = splsched();
+ if ((sc->sc_flags & GTMR_FLAG_CPU_REGISTERS_NOT_FW_CONFIGURED) != 0) {
+ armreg_cnt_frq_write(sc->sc_freq);
+ }
+
/*
* Allow the virtual and physical counters to be accessed from
* usermode. (PL0)
diff -r 622ae3b60ca7 -r 03f45eccd1cc sys/arch/arm/cortex/gtmr_var.h
--- a/sys/arch/arm/cortex/gtmr_var.h Fri Nov 12 21:57:44 2021 +0000
+++ b/sys/arch/arm/cortex/gtmr_var.h Fri Nov 12 21:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gtmr_var.h,v 1.14 2020/03/05 15:18:54 riastradh Exp $ */
+/* $NetBSD: gtmr_var.h,v 1.15 2021/11/12 21:59:04 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -38,7 +38,8 @@
struct evcnt sc_ev_missing_ticks;
uint32_t sc_freq;
uint32_t sc_flags;
-#define GTMR_FLAG_SUN50I_A64_UNSTABLE_TIMER __BIT(0)
+#define GTMR_FLAG_SUN50I_A64_UNSTABLE_TIMER __BIT(0)
+#define GTMR_FLAG_CPU_REGISTERS_NOT_FW_CONFIGURED __BIT(1)
u_long sc_autoinc;
bool sc_physical;
void *sc_global_ih;
diff -r 622ae3b60ca7 -r 03f45eccd1cc sys/arch/arm/fdt/gtmr_fdt.c
--- a/sys/arch/arm/fdt/gtmr_fdt.c Fri Nov 12 21:57:44 2021 +0000
+++ b/sys/arch/arm/fdt/gtmr_fdt.c Fri Nov 12 21:59:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gtmr_fdt.c,v 1.11 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: gtmr_fdt.c,v 1.12 2021/11/12 21:59:05 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.11 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.12 2021/11/12 21:59:05 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -44,6 +44,10 @@
#include <dev/fdt/fdtvar.h>
#include <arm/fdt/arm_fdtvar.h>
+#if defined(__arm__)
+#include <arm/armreg.h>
+#endif
+
static int gtmr_fdt_match(device_t, cfdata_t, void *);
static void gtmr_fdt_attach(device_t, device_t, void *);
@@ -95,6 +99,23 @@
}
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
+#if defined(__arm__)
+ /*
+ * If arm,cpu-registers-not-fw-configured is present, we need
+ * to initialize cntfrq from the clock-frequency property. Only
+ * applicable on Armv7.
+ */
+ if (of_hasprop(phandle, "arm,cpu-registers-not-fw-configured")) {
+ uint32_t freq;
+
+ if (of_getprop_uint32(phandle, "clock-frequency", &freq) == 0) {
+ armreg_cnt_frq_write(freq);
+ prop_dictionary_set_bool(device_properties(self),
+ "arm,cpu-registers-not-fw-configured", true);
+ }
+ }
+#endif
+
config_found(self, &mpcaa, NULL, CFARGS_NONE);
arm_fdt_cpu_hatch_register(self, gtmr_fdt_cpu_hatch);
Home |
Main Index |
Thread Index |
Old Index