Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Handle speed change events



details:   https://anonhg.NetBSD.org/src/rev/e19dc7bf9e30
branches:  trunk
changeset: 372269:e19dc7bf9e30
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Nov 05 17:30:06 2022 +0000

description:
Handle speed change events

diffstat:

 sys/arch/arm/cortex/a9ptmr.c     |  27 +++++++++++++++++++++++++--
 sys/arch/arm/cortex/a9ptmr_var.h |   3 ++-
 sys/arch/arm/fdt/a9ptmr_fdt.c    |  20 ++++++++++++++++++--
 3 files changed, 45 insertions(+), 5 deletions(-)

diffs (120 lines):

diff -r b3ef93a28cf1 -r e19dc7bf9e30 sys/arch/arm/cortex/a9ptmr.c
--- a/sys/arch/arm/cortex/a9ptmr.c      Sat Nov 05 17:28:55 2022 +0000
+++ b/sys/arch/arm/cortex/a9ptmr.c      Sat Nov 05 17:30:06 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: a9ptmr.c,v 1.2 2019/08/14 09:20:00 skrll Exp $ */
+/*     $NetBSD: a9ptmr.c,v 1.3 2022/11/05 17:30:20 jmcneill Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: a9ptmr.c,v 1.2 2019/08/14 09:20:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9ptmr.c,v 1.3 2022/11/05 17:30:20 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/cpu.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
+#include <sys/xcall.h>
 
 #include <prop/proplib.h>
 
@@ -265,3 +266,25 @@
 
        return 1;
 }
+
+static void
+a9ptmr_update_freq_cb(void *arg1, void *arg2)
+{
+       a9ptmr_init_cpu_clock(curcpu());
+}
+
+void
+a9ptmr_update_freq(uint32_t freq)
+{
+       struct a9ptmr_softc * const sc = a9ptmr_sc;
+       uint64_t xc;
+
+       KASSERT(sc->sc_dev != NULL);
+       KASSERT(freq != 0);
+
+       sc->sc_freq = freq;
+       sc->sc_load = (sc->sc_freq / hz) - 1;
+
+       xc = xc_broadcast(0, a9ptmr_update_freq_cb, NULL, NULL);
+       xc_wait(xc);
+}
diff -r b3ef93a28cf1 -r e19dc7bf9e30 sys/arch/arm/cortex/a9ptmr_var.h
--- a/sys/arch/arm/cortex/a9ptmr_var.h  Sat Nov 05 17:28:55 2022 +0000
+++ b/sys/arch/arm/cortex/a9ptmr_var.h  Sat Nov 05 17:30:06 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: a9ptmr_var.h,v 1.1 2019/08/10 17:03:59 skrll Exp $ */
+/* $NetBSD: a9ptmr_var.h,v 1.2 2022/11/05 17:30:20 jmcneill Exp $ */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,6 +39,7 @@
 void   a9ptmr_init_cpu_clock(struct cpu_info *);
 
 int    a9ptmr_intr(void *);
+void   a9ptmr_update_freq(uint32_t);
 void   a9ptmr_delay(unsigned int n);
 #endif
 
diff -r b3ef93a28cf1 -r e19dc7bf9e30 sys/arch/arm/fdt/a9ptmr_fdt.c
--- a/sys/arch/arm/fdt/a9ptmr_fdt.c     Sat Nov 05 17:28:55 2022 +0000
+++ b/sys/arch/arm/fdt/a9ptmr_fdt.c     Sat Nov 05 17:30:06 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $ */
+/* $NetBSD: a9ptmr_fdt.c,v 1.7 2022/11/05 17:30:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.7 2022/11/05 17:30:06 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -50,6 +50,7 @@
 static void    a9ptmr_fdt_attach(device_t, device_t, void *);
 
 static void    a9ptmr_fdt_cpu_hatch(void *, struct cpu_info *);
+static void    a9ptmr_fdt_speed_changed(device_t);
 
 struct a9ptmr_fdt_softc {
        device_t        sc_dev;
@@ -144,6 +145,8 @@
                arm_fdt_cpu_hatch_register(self, a9ptmr_fdt_cpu_hatch);
                arm_fdt_timer_register(a9ptmr_cpu_initclocks);
        }
+
+       pmf_event_register(self, PMFE_SPEED_CHANGED, a9ptmr_fdt_speed_changed, true);
 }
 
 static void
@@ -151,3 +154,16 @@
 {
        a9ptmr_init_cpu_clock(ci);
 }
+
+static void
+a9ptmr_fdt_speed_changed(device_t dev)
+{
+       struct a9ptmr_fdt_softc * const sc = device_private(dev);
+       prop_dictionary_t dict = device_properties(dev);
+       uint32_t rate;
+
+       rate = clk_get_rate(sc->sc_clk);
+       prop_dictionary_set_uint32(dict, "frequency", rate);
+
+       a9ptmr_update_freq(rate);
+}



Home | Main Index | Thread Index | Old Index