Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Allow ARM FDT drivers to register per-cpu init call...
details: https://anonhg.NetBSD.org/src/rev/99d4e60edc2d
branches: trunk
changeset: 353978:99d4e60edc2d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue May 30 21:12:41 2017 +0000
description:
Allow ARM FDT drivers to register per-cpu init callbacks. Run through this
callback list when a CPU hatches instead of calling gtmr_init_cpu_clock
directly.
diffstat:
sys/arch/arm/fdt/arm_fdt.c | 36 +++++++++++++++++++++++++++++++++---
sys/arch/arm/fdt/arm_fdtvar.h | 5 ++++-
sys/arch/arm/fdt/gtmr_fdt.c | 16 ++++++++++++++--
sys/arch/evbarm/tegra/tegra_start.S | 6 +++---
4 files changed, 54 insertions(+), 9 deletions(-)
diffs (159 lines):
diff -r 3cf3e92fe7df -r 99d4e60edc2d sys/arch/arm/fdt/arm_fdt.c
--- a/sys/arch/arm/fdt/arm_fdt.c Tue May 30 20:32:08 2017 +0000
+++ b/sys/arch/arm/fdt/arm_fdt.c Tue May 30 21:12:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdt.c,v 1.1 2017/05/29 23:21:12 jmcneill Exp $ */
+/* $NetBSD: arm_fdt.c,v 1.2 2017/05/30 21:12:41 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,14 +27,15 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.1 2017/05/29 23:21:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.2 2017/05/30 21:12:41 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
+#include <sys/kmem.h>
+#include <sys/bus.h>
#include <machine/cpu.h>
-#include <sys/bus.h>
#include <dev/fdt/fdtvar.h>
#include <dev/ofw/openfirm.h>
@@ -50,6 +51,15 @@
static struct arm_platlist arm_platform_list =
TAILQ_HEAD_INITIALIZER(arm_platform_list);
+struct arm_fdt_cpu_hatch_cb {
+ TAILQ_ENTRY(arm_fdt_cpu_hatch_cb) next;
+ void (*cb)(void *, struct cpu_info *);
+ void *priv;
+};
+
+static TAILQ_HEAD(, arm_fdt_cpu_hatch_cb) arm_fdt_cpu_hatch_cbs =
+ TAILQ_HEAD_INITIALIZER(arm_fdt_cpu_hatch_cbs);
+
int
arm_fdt_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -98,3 +108,23 @@
return booted_platform == NULL ? NULL : booted_platform->ops;
}
+
+void
+arm_fdt_cpu_hatch_register(void *priv, void (*cb)(void *, struct cpu_info *))
+{
+ struct arm_fdt_cpu_hatch_cb *c;
+
+ c = kmem_alloc(sizeof(*c), KM_SLEEP);
+ c->priv = priv;
+ c->cb = cb;
+ TAILQ_INSERT_TAIL(&arm_fdt_cpu_hatch_cbs, c, next);
+}
+
+void
+arm_fdt_cpu_hatch(struct cpu_info *ci)
+{
+ struct arm_fdt_cpu_hatch_cb *c;
+
+ TAILQ_FOREACH(c, &arm_fdt_cpu_hatch_cbs, next)
+ c->cb(c->priv, ci);
+}
diff -r 3cf3e92fe7df -r 99d4e60edc2d sys/arch/arm/fdt/arm_fdtvar.h
--- a/sys/arch/arm/fdt/arm_fdtvar.h Tue May 30 20:32:08 2017 +0000
+++ b/sys/arch/arm/fdt/arm_fdtvar.h Tue May 30 21:12:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.1 2017/05/29 23:21:12 jmcneill Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.2 2017/05/30 21:12:41 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -63,4 +63,7 @@
const struct arm_platform * arm_fdt_platform(void);
+void arm_fdt_cpu_hatch_register(void *, void (*)(void *, struct cpu_info *));
+void arm_fdt_cpu_hatch(struct cpu_info *);
+
#endif /* !_ARM_ARM_FDTVAR_H */
diff -r 3cf3e92fe7df -r 99d4e60edc2d sys/arch/arm/fdt/gtmr_fdt.c
--- a/sys/arch/arm/fdt/gtmr_fdt.c Tue May 30 20:32:08 2017 +0000
+++ b/sys/arch/arm/fdt/gtmr_fdt.c Tue May 30 21:12:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gtmr_fdt.c,v 1.1 2017/05/28 00:40:20 jmcneill Exp $ */
+/* $NetBSD: gtmr_fdt.c,v 1.2 2017/05/30 21:12:41 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.1 2017/05/28 00:40:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.2 2017/05/30 21:12:41 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -39,12 +39,16 @@
#include <arm/cortex/gic_intr.h>
#include <arm/cortex/mpcore_var.h>
+#include <arm/cortex/gtmr_var.h>
#include <dev/fdt/fdtvar.h>
+#include <arm/fdt/arm_fdtvar.h>
static int gtmr_fdt_match(device_t, cfdata_t, void *);
static void gtmr_fdt_attach(device_t, device_t, void *);
+static void gtmr_fdt_cpu_hatch(void *, struct cpu_info *);
+
CFATTACH_DECL_NEW(gtmr_fdt, 0, gtmr_fdt_match, gtmr_fdt_attach, NULL, NULL);
static int
@@ -71,4 +75,12 @@
};
config_found(self, &mpcaa, NULL);
+
+ arm_fdt_cpu_hatch_register(self, gtmr_fdt_cpu_hatch);
}
+
+static void
+gtmr_fdt_cpu_hatch(void *priv, struct cpu_info *ci)
+{
+ gtmr_init_cpu_clock(ci);
+}
diff -r 3cf3e92fe7df -r 99d4e60edc2d sys/arch/evbarm/tegra/tegra_start.S
--- a/sys/arch/evbarm/tegra/tegra_start.S Tue May 30 20:32:08 2017 +0000
+++ b/sys/arch/evbarm/tegra/tegra_start.S Tue May 30 21:12:41 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.13 2017/05/30 10:27:53 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.14 2017/05/30 21:12:41 jmcneill Exp $ */
/*-
* Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
#include <arm/nvidia/tegra_reg.h>
-RCSID("$NetBSD: tegra_start.S,v 1.13 2017/05/30 10:27:53 jmcneill Exp $")
+RCSID("$NetBSD: tegra_start.S,v 1.14 2017/05/30 21:12:41 jmcneill Exp $")
#if defined(VERBOSE_INIT_ARM) && defined(CONSADDR)
#define XPUTC(n) mov r0, n; bl xputc
@@ -64,7 +64,7 @@
#define INIT_MEMSIZE 128
#define TEMP_L1_TABLE (KERNEL_BASE - KERNEL_BASE_VOFFSET + INIT_MEMSIZE * L1_S_SIZE - L1_TABLE_SIZE)
-#define MD_CPU_HATCH _C_LABEL(gtmr_init_cpu_clock)
+#define MD_CPU_HATCH _C_LABEL(arm_fdt_cpu_hatch)
/*
* Kernel start routine for Tegra SoCs.
Home |
Main Index |
Thread Index |
Old Index