Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/fdt Listen for PMFE_SPEED_CHANGED events and au...
details: https://anonhg.NetBSD.org/src/rev/219324d0e8e9
branches: trunk
changeset: 448133:219324d0e8e9
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Jan 22 15:17:33 2019 +0000
description:
Listen for PMFE_SPEED_CHANGED events and automatically update a9tmr frequency
diffstat:
sys/arch/arm/fdt/a9tmr_fdt.c | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)
diffs (89 lines):
diff -r 44e451a4c91f -r 219324d0e8e9 sys/arch/arm/fdt/a9tmr_fdt.c
--- a/sys/arch/arm/fdt/a9tmr_fdt.c Tue Jan 22 15:16:24 2019 +0000
+++ b/sys/arch/arm/fdt/a9tmr_fdt.c Tue Jan 22 15:17:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: a9tmr_fdt.c,v 1.2 2019/01/19 20:56:03 jmcneill Exp $ */
+/* $NetBSD: a9tmr_fdt.c,v 1.3 2019/01/22 15:17:33 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.2 2019/01/19 20:56:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.3 2019/01/22 15:17:33 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -48,8 +48,15 @@
static void a9tmr_fdt_attach(device_t, device_t, void *);
static void a9tmr_fdt_cpu_hatch(void *, struct cpu_info *);
+static void a9tmr_fdt_speed_changed(device_t);
-CFATTACH_DECL_NEW(a9tmr_fdt, 0, a9tmr_fdt_match, a9tmr_fdt_attach, NULL, NULL);
+struct a9tmr_fdt_softc {
+ device_t sc_dev;
+ struct clk *sc_clk;
+};
+
+CFATTACH_DECL_NEW(a9tmr_fdt, sizeof(struct a9tmr_fdt_softc),
+ a9tmr_fdt_match, a9tmr_fdt_attach, NULL, NULL);
static int
a9tmr_fdt_match(device_t parent, cfdata_t cf, void *aux)
@@ -67,21 +74,23 @@
static void
a9tmr_fdt_attach(device_t parent, device_t self, void *aux)
{
+ struct a9tmr_fdt_softc * const sc = device_private(self);
struct fdt_attach_args * const faa = aux;
const int phandle = faa->faa_phandle;
bus_space_handle_t bsh;
- struct clk *clk = fdtbus_clock_get_index(phandle, 0);
- if (clk == NULL) {
+ sc->sc_dev = self;
+ sc->sc_clk = fdtbus_clock_get_index(phandle, 0);
+ if (sc->sc_clk == NULL) {
aprint_error(": couldn't get clock\n");
return;
}
- if (clk_enable(clk) != 0) {
+ if (clk_enable(sc->sc_clk) != 0) {
aprint_error(": couldn't enable clock\n");
return;
}
- uint32_t rate = clk_get_rate(clk);
+ uint32_t rate = clk_get_rate(sc->sc_clk);
prop_dictionary_t dict = device_properties(self);
prop_dictionary_set_uint32(dict, "frequency", rate);
@@ -124,6 +133,8 @@
arm_fdt_cpu_hatch_register(self, a9tmr_fdt_cpu_hatch);
arm_fdt_timer_register(a9tmr_cpu_initclocks);
+
+ pmf_event_register(self, PMFE_SPEED_CHANGED, a9tmr_fdt_speed_changed, true);
}
static void
@@ -131,3 +142,16 @@
{
a9tmr_init_cpu_clock(ci);
}
+
+static void
+a9tmr_fdt_speed_changed(device_t dev)
+{
+ struct a9tmr_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);
+
+ a9tmr_update_freq(rate);
+}
Home |
Main Index |
Thread Index |
Old Index