Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm When attaching gtmr at fdt use fdtbus_intr_esta...



details:   https://anonhg.NetBSD.org/src/rev/17836601e8ae
branches:  trunk
changeset: 828159:17836601e8ae
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Nov 30 14:50:34 2017 +0000

description:
When attaching gtmr at fdt use fdtbus_intr_establish to establish the
gtmr interrupt.

diffstat:

 sys/arch/arm/cortex/gtmr.c     |  18 ++++++++++--------
 sys/arch/arm/cortex/gtmr_var.h |   3 ++-
 sys/arch/arm/fdt/gtmr_fdt.c    |  25 ++++++++++++++++++++++---
 3 files changed, 34 insertions(+), 12 deletions(-)

diffs (110 lines):

diff -r c203c36c294a -r 17836601e8ae sys/arch/arm/cortex/gtmr.c
--- a/sys/arch/arm/cortex/gtmr.c        Thu Nov 30 14:42:37 2017 +0000
+++ b/sys/arch/arm/cortex/gtmr.c        Thu Nov 30 14:50:34 2017 +0000
@@ -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 @@
        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) {
diff -r c203c36c294a -r 17836601e8ae sys/arch/arm/cortex/gtmr_var.h
--- a/sys/arch/arm/cortex/gtmr_var.h    Thu Nov 30 14:42:37 2017 +0000
+++ b/sys/arch/arm/cortex/gtmr_var.h    Thu Nov 30 14:50:34 2017 +0000
@@ -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 @@
 #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);
diff -r c203c36c294a -r 17836601e8ae sys/arch/arm/fdt/gtmr_fdt.c
--- a/sys/arch/arm/fdt/gtmr_fdt.c       Thu Nov 30 14:42:37 2017 +0000
+++ b/sys/arch/arm/fdt/gtmr_fdt.c       Thu Nov 30 14:50:34 2017 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
 
 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 @@
 
        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);
 



Home | Main Index | Thread Index | Old Index