Module Name: src Committed By: skrll Date: Thu Nov 30 14:50:34 UTC 2017
Modified Files: src/sys/arch/arm/cortex: gtmr.c gtmr_var.h src/sys/arch/arm/fdt: gtmr_fdt.c Log Message: When attaching gtmr at fdt use fdtbus_intr_establish to establish the gtmr interrupt. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/cortex/gtmr.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/cortex/gtmr_var.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/gtmr_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/cortex/gtmr.c diff -u src/sys/arch/arm/cortex/gtmr.c:1.22 src/sys/arch/arm/cortex/gtmr.c:1.23 --- src/sys/arch/arm/cortex/gtmr.c:1.22 Wed Oct 25 16:09:46 2017 +++ src/sys/arch/arm/cortex/gtmr.c Thu Nov 30 14:50:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr.c,v 1.22 2017/10/25 16:09:46 skrll Exp $ */ +/* $NetBSD: gtmr.c,v 1.23 2017/11/30 14:50:34 skrll Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.22 2017/10/25 16:09:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.23 2017/11/30 14:50:34 skrll Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -129,12 +129,14 @@ gtmr_attach(device_t parent, device_t se evcnt_attach_dynamic(&sc->sc_ev_missing_ticks, EVCNT_TYPE_MISC, NULL, device_xname(self), "missing interrupts"); - sc->sc_global_ih = intr_establish(mpcaa->mpcaa_irq, IPL_CLOCK, - IST_LEVEL | IST_MPSAFE, gtmr_intr, NULL); - if (sc->sc_global_ih == NULL) - panic("%s: unable to register timer interrupt", __func__); - aprint_normal_dev(self, "interrupting on irq %d\n", - mpcaa->mpcaa_irq); + if (mpcaa->mpcaa_irq != -1) { + sc->sc_global_ih = intr_establish(mpcaa->mpcaa_irq, IPL_CLOCK, + IST_LEVEL | IST_MPSAFE, gtmr_intr, NULL); + if (sc->sc_global_ih == NULL) + panic("%s: unable to register timer interrupt", __func__); + aprint_normal_dev(self, "interrupting on irq %d\n", + mpcaa->mpcaa_irq); + } const uint32_t cnt_frq = armreg_cnt_frq_read(); if (cnt_frq == 0) { Index: src/sys/arch/arm/cortex/gtmr_var.h diff -u src/sys/arch/arm/cortex/gtmr_var.h:1.8 src/sys/arch/arm/cortex/gtmr_var.h:1.9 --- src/sys/arch/arm/cortex/gtmr_var.h:1.8 Thu Nov 9 21:38:25 2017 +++ src/sys/arch/arm/cortex/gtmr_var.h Thu Nov 30 14:50:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr_var.h,v 1.8 2017/11/09 21:38:25 skrll Exp $ */ +/* $NetBSD: gtmr_var.h,v 1.9 2017/11/30 14:50:34 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. @@ -47,6 +47,7 @@ struct gtmr_softc { #ifdef _KERNEL #include "opt_arm_timer.h" struct cpu_info; +void gtmr_init(device_t); int gtmr_intr(void *); void gtmr_init_cpu_clock(struct cpu_info *); void gtmr_delay(unsigned int n); Index: src/sys/arch/arm/fdt/gtmr_fdt.c diff -u src/sys/arch/arm/fdt/gtmr_fdt.c:1.5 src/sys/arch/arm/fdt/gtmr_fdt.c:1.6 --- src/sys/arch/arm/fdt/gtmr_fdt.c:1.5 Thu Aug 24 13:06:23 2017 +++ src/sys/arch/arm/fdt/gtmr_fdt.c Thu Nov 30 14:50:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $ */ +/* $NetBSD: gtmr_fdt.c,v 1.6 2017/11/30 14:50:34 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.6 2017/11/30 14:50:34 skrll Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -51,6 +51,9 @@ static void gtmr_fdt_cpu_hatch(void *, s CFATTACH_DECL_NEW(gtmr_fdt, 0, gtmr_fdt_match, gtmr_fdt_attach, NULL, NULL); +/* The vritual timer list entry */ +#define GTMR_VTIMER 2 + static int gtmr_fdt_match(device_t parent, cfdata_t cf, void *aux) { @@ -72,8 +75,24 @@ gtmr_fdt_attach(device_t parent, device_ struct mpcore_attach_args mpcaa = { .mpcaa_name = "armgtmr", - .mpcaa_irq = IRQ_GTMR_PPI_VTIMER + .mpcaa_irq = -1 /* setup handler locally */ }; + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + + char intrstr[128]; + if (!fdtbus_intr_str(phandle, GTMR_VTIMER, intrstr, sizeof(intrstr))) { + aprint_error(": failed to decode interrupt\n"); + return; + } + + void *ih = fdtbus_intr_establish(phandle, GTMR_VTIMER, IPL_CLOCK, + FDT_INTR_MPSAFE, gtmr_intr, NULL); + if (ih == NULL) { + aprint_error_dev(self, "couldn't install interrupt handler\n"); + return; + } + aprint_normal_dev(self, "interrupting on %s\n", intrstr); config_found(self, &mpcaa, NULL);