Source-Changes-HG archive

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

[src/trunk]: src/sys Define constants for representing the standard interrupt...



details:   https://anonhg.NetBSD.org/src/rev/771709f26a49
branches:  trunk
changeset: 447838:771709f26a49
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Jan 26 14:38:29 2019 +0000

description:
Define constants for representing the standard interrupt types
({pos,neg,double}-edge, {high,low}-level) from the FDT "interrupts"
bindings.  Use these defined constants rather than magic numbers.

diffstat:

 sys/arch/arm/broadcom/bcm2835_gpio.c |  14 +++++++-------
 sys/arch/arm/fdt/gic_fdt.c           |   7 ++++---
 sys/arch/arm/fdt/gicv3_fdt.c         |   7 ++++---
 sys/arch/arm/nvidia/tegra_lic.c      |   7 ++++---
 sys/arch/arm/sunxi/sunxi_gpio.c      |  14 +++++++-------
 sys/dev/fdt/fdtvar.h                 |  10 +++++++++-
 6 files changed, 35 insertions(+), 24 deletions(-)

diffs (194 lines):

diff -r 2d554e6fb82c -r 771709f26a49 sys/arch/arm/broadcom/bcm2835_gpio.c
--- a/sys/arch/arm/broadcom/bcm2835_gpio.c      Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_gpio.c      Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $        */
+/*     $NetBSD: bcm2835_gpio.c,v 1.9 2019/01/26 14:38:29 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.9 2019/01/26 14:38:29 thorpej Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -567,19 +567,19 @@
        const u_int type = be32toh(specifier[1]) & 0xf;
 
        switch (type) {
-       case 0x1:
+       case FDT_INTR_TYPE_POS_EDGE:
                eint_flags |= BCMGPIO_INTR_POS_EDGE;
                break;
-       case 0x2:
+       case FDT_INTR_TYPE_NEG_EDGE:
                eint_flags |= BCMGPIO_INTR_NEG_EDGE;
                break;
-       case 0x3:
+       case FDT_INTR_TYPE_DOUBLE_EDGE:
                eint_flags |= BCMGPIO_INTR_POS_EDGE | BCMGPIO_INTR_NEG_EDGE;
                break;
-       case 0x4:
+       case FDT_INTR_TYPE_HIGH_LEVEL:
                eint_flags |= BCMGPIO_INTR_HIGH_LEVEL;
                break;
-       case 0x8:
+       case FDT_INTR_TYPE_LOW_LEVEL:
                eint_flags |= BCMGPIO_INTR_LOW_LEVEL;
                break;
        default:
diff -r 2d554e6fb82c -r 771709f26a49 sys/arch/arm/fdt/gic_fdt.c
--- a/sys/arch/arm/fdt/gic_fdt.c        Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/arch/arm/fdt/gic_fdt.c        Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -249,7 +249,8 @@
        const u_int intr = be32toh(specifier[1]);
        const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr);
        const u_int trig = be32toh(specifier[2]) & 0xf;
-       const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL;
+       const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE)
+           ? IST_EDGE : IST_LEVEL;
 
        const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
 
diff -r 2d554e6fb82c -r 771709f26a49 sys/arch/arm/fdt/gicv3_fdt.c
--- a/sys/arch/arm/fdt/gicv3_fdt.c      Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/arch/arm/fdt/gicv3_fdt.c      Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -280,7 +280,8 @@
        const u_int intr = be32toh(specifier[1]);
        const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr);
        const u_int trig = be32toh(specifier[2]) & 0xf;
-       const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL;
+       const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE)
+           ? IST_EDGE : IST_LEVEL;
 
        const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
 
diff -r 2d554e6fb82c -r 771709f26a49 sys/arch/arm/nvidia/tegra_lic.c
--- a/sys/arch/arm/nvidia/tegra_lic.c   Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/arch/arm/nvidia/tegra_lic.c   Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_lic.c,v 1.5 2017/05/26 20:08:02 jmcneill Exp $ */
+/* $NetBSD: tegra_lic.c,v 1.6 2019/01/26 14:38:29 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_lic.c,v 1.5 2017/05/26 20:08:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_lic.c,v 1.6 2019/01/26 14:38:29 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -142,7 +142,8 @@
        const u_int intr = be32toh(specifier[1]);
        const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr);
        const u_int trig = be32toh(specifier[2]) & 0xf;
-       const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL;
+       const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE)
+           ? IST_EDGE : IST_LEVEL;
 
        return intr_establish(irq, ipl, level | iflags, func, arg);
 }
diff -r 2d554e6fb82c -r 771709f26a49 sys/arch/arm/sunxi/sunxi_gpio.c
--- a/sys/arch/arm/sunxi/sunxi_gpio.c   Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_gpio.c   Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_gpio.c,v 1.22 2019/01/23 04:21:54 thorpej Exp $ */
+/* $NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_soc.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.22 2019/01/23 04:21:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -458,19 +458,19 @@
        const u_int type = be32toh(specifier[2]) & 0xf;
 
        switch (type) {
-       case 0x1:
+       case FDT_INTR_TYPE_POS_EDGE:
                mode = SUNXI_GPIO_INT_MODE_POS_EDGE;
                break;
-       case 0x2:
+       case FDT_INTR_TYPE_NEG_EDGE:
                mode = SUNXI_GPIO_INT_MODE_NEG_EDGE;
                break;
-       case 0x3:
+       case FDT_INTR_TYPE_DOUBLE_EDGE:
                mode = SUNXI_GPIO_INT_MODE_DOUBLE_EDGE;
                break;
-       case 0x4:
+       case FDT_INTR_TYPE_HIGH_LEVEL:
                mode = SUNXI_GPIO_INT_MODE_HIGH_LEVEL;
                break;
-       case 0x8:
+       case FDT_INTR_TYPE_LOW_LEVEL:
                mode = SUNXI_GPIO_INT_MODE_LOW_LEVEL;
                break;
        default:
diff -r 2d554e6fb82c -r 771709f26a49 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Fri Jan 25 18:34:45 2019 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sat Jan 26 14:38:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.46 2019/01/23 04:21:55 thorpej Exp $ */
+/* $NetBSD: fdtvar.h,v 1.47 2019/01/26 14:38:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -63,6 +63,14 @@
 /* flags for fdtbus_intr_establish */
 #define FDT_INTR_MPSAFE        __BIT(0)
 
+/* Interrupt trigger types defined by the FDT "interrupts" bindings. */
+#define        FDT_INTR_TYPE_POS_EDGE          __BIT(0)
+#define        FDT_INTR_TYPE_NEG_EDGE          __BIT(1)
+#define        FDT_INTR_TYPE_DOUBLE_EDGE       (FDT_INTR_TYPE_POS_EDGE | \
+                                        FDT_INTR_TYPE_NEG_EDGE)
+#define        FDT_INTR_TYPE_HIGH_LEVEL        __BIT(2)
+#define        FDT_INTR_TYPE_LOW_LEVEL         __BIT(3)
+
 struct fdtbus_interrupt_controller_func {
        void *  (*establish)(device_t, u_int *, int, int,
                             int (*)(void *), void *);



Home | Main Index | Thread Index | Old Index