Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Call / define fdtbus_cpus_md_attach for platform...



details:   https://anonhg.NetBSD.org/src/rev/f17e178dfa45
branches:  trunk
changeset: 376347:f17e178dfa45
user:      skrll <skrll%NetBSD.org@localhost>
date:      Mon Jun 12 12:58:17 2023 +0000

description:
Call / define fdtbus_cpus_md_attach for platforms with cpus @ fdt.

The RISC-V binding here seems somewhat of an abuse, but it exists in
mainline linux.

diffstat:

 sys/arch/arm/fdt/cpus_fdt.c   |  43 +++++++++++++++++++++++++++++++++
 sys/arch/arm/fdt/files.fdt    |   3 +-
 sys/arch/riscv/fdt/cpus_fdt.c |  55 +++++++++++++++++++++++++++++++++++++++++++
 sys/arch/riscv/fdt/files.fdt  |   4 +-
 sys/dev/fdt/cpus.c            |  13 +++-------
 sys/dev/fdt/fdtvar.h          |   4 ++-
 6 files changed, 109 insertions(+), 13 deletions(-)

diffs (199 lines):

diff -r 93457d411029 -r f17e178dfa45 sys/arch/arm/fdt/cpus_fdt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/fdt/cpus_fdt.c       Mon Jun 12 12:58:17 2023 +0000
@@ -0,0 +1,43 @@
+/* $NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <dev/fdt/fdtvar.h>
+
+void
+fdtbus_cpus_md_attach(device_t parent, device_t self, void *aux)
+{
+}
diff -r 93457d411029 -r f17e178dfa45 sys/arch/arm/fdt/files.fdt
--- a/sys/arch/arm/fdt/files.fdt        Mon Jun 12 06:47:17 2023 +0000
+++ b/sys/arch/arm/fdt/files.fdt        Mon Jun 12 12:58:17 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.34 2021/07/22 00:47:55 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.35 2023/06/12 12:58:17 skrll Exp $
 
 include        "dev/pckbport/files.pckbport"
 
@@ -7,6 +7,7 @@ attach  armfdt at root with arm_fdt
 file   arch/arm/fdt/arm_fdt.c                  arm_fdt
 file   arch/arm/fdt/arm_platform.c             arm_fdt & gtmr_fdt & psci_fdt
 file   arch/arm/fdt/arm_simplefb.c             arm_fdt & wsdisplay & genfb
+file   arch/arm/fdt/cpus_fdt.c                 arm_fdt
 
 attach cpu at fdt with cpu_fdt
 file   arch/arm/fdt/cpu_fdt.c                  cpu_fdt
diff -r 93457d411029 -r f17e178dfa45 sys/arch/riscv/fdt/cpus_fdt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/riscv/fdt/cpus_fdt.c     Mon Jun 12 12:58:17 2023 +0000
@@ -0,0 +1,55 @@
+/* $NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <dev/fdt/fdtvar.h>
+
+#include <machine/machdep.h>
+
+void
+fdtbus_cpus_md_attach(device_t parent, device_t self, void *aux)
+{
+       struct fdt_attach_args * const faa = aux;
+       const int cpus = faa->faa_phandle;
+
+       uint32_t tbfreq;
+       int ret = of_getprop_uint32(cpus, "timebase-frequency", &tbfreq);
+       if (ret < 0) {
+               aprint_error(": can't get timebase frequency\n");
+               return;
+       }
+       riscv_timer_frequency_set(tbfreq);
+}
diff -r 93457d411029 -r f17e178dfa45 sys/arch/riscv/fdt/files.fdt
--- a/sys/arch/riscv/fdt/files.fdt      Mon Jun 12 06:47:17 2023 +0000
+++ b/sys/arch/riscv/fdt/files.fdt      Mon Jun 12 12:58:17 2023 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: files.fdt,v 1.1 2023/05/07 12:41:48 skrll Exp $
+# $NetBSD: files.fdt,v 1.2 2023/06/12 12:58:17 skrll Exp $
 
 include        "dev/pckbport/files.pckbport"
 
 file   arch/riscv/fdt/riscv_platform.c
 
+file   arch/riscv/fdt/cpus_fdt.c
 file   arch/riscv/fdt/fdt_dma_machdep.c
-file   arch/riscv/fdt/fdt_cpus_machdep.c
 
 attach cpu at fdt with cpu_fdt
 file   arch/riscv/fdt/cpu_fdt.c                cpu_fdt
diff -r 93457d411029 -r f17e178dfa45 sys/dev/fdt/cpus.c
--- a/sys/dev/fdt/cpus.c        Mon Jun 12 06:47:17 2023 +0000
+++ b/sys/dev/fdt/cpus.c        Mon Jun 12 12:58:17 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpus.c,v 1.7 2023/05/07 12:41:49 skrll Exp $ */
+/* $NetBSD: cpus.c,v 1.8 2023/06/12 12:58:17 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.7 2023/05/07 12:41:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.8 2023/06/12 12:58:17 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -39,10 +39,6 @@
 
 #include <dev/fdt/fdtvar.h>
 
-#ifdef __riscv
-#include <machine/machdep.h>
-#endif
-
 static int     cpus_match(device_t, cfdata_t, void *);
 static void    cpus_attach(device_t, device_t, void *);
 
@@ -68,9 +64,8 @@ cpus_attach(device_t parent, device_t se
        aprint_naive("\n");
        aprint_normal("\n");
 
-#ifdef __riscv
-       cpus_fdt_md_attach(parent, self, faa);
-#endif
+       fdtbus_cpus_md_attach(parent, self, faa);
+
        for (child = OF_child(phandle); child; child = OF_peer(child)) {
                if (!cpus_cpu_enabled(child))
                        continue;
diff -r 93457d411029 -r f17e178dfa45 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Mon Jun 12 06:47:17 2023 +0000
+++ b/sys/dev/fdt/fdtvar.h      Mon Jun 12 12:58:17 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.78 2023/04/07 08:55:31 skrll Exp $ */
+/* $NetBSD: fdtvar.h,v 1.79 2023/06/12 12:58:17 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -552,6 +552,8 @@ const char *        fdtbus_get_string(int, cons
 const char *   fdtbus_get_string_index(int, const char *, u_int);
 int            fdtbus_get_index(int, const char *, const char *, u_int *);
 
+void           fdtbus_cpus_md_attach(device_t, device_t, void *);
+
 void           fdt_add_bus(device_t, int, struct fdt_attach_args *);
 void           fdt_add_bus_match(device_t, int, struct fdt_attach_args *,
                    bool (*)(void *, int), void *);



Home | Main Index | Thread Index | Old Index